//===========================================================================//
// File:	Mech_Tool.cpp																	  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 09/09/98  JSE  Inital base class based off of Shadowrun/Adept
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Fasa Interactive										 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//

#include "MW4Headers.hpp"

#include "Hovercraft.hpp"
#include "MWTool.hpp"

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
void
	Hovercraft__GameModel::ConstructGameModel(Script *script)
{
	Check_Object(script);

	//
	//--------------
	// Set up stream
	//--------------
	//
	MemoryStream *model_stream = script->modelStream;
	Check_Object(model_stream);
	model_stream->AllocateBytes(sizeof(Hovercraft__GameModel));
	BaseClass::ConstructGameModel(script);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
bool
	Hovercraft__GameModel::ReadAndVerify(
		Hovercraft__GameModel *model,
		ModelAttributeEntry *attribute_entry,
		const char *data,
		char **error,
		int error_buffer
	)
{
	Check_Object(attribute_entry);

	bool result = false;
	bool valid_data = (*data != '\0');

	//
	//----------------------------------------
	//Read in the values from the data entered
	//----------------------------------------
	//
	result =
		Vehicle__GameModel::ReadAndVerify(
			model,
			attribute_entry,
			data,
			error,
			error_buffer
		);
	//
	//---------------------------
	//Verify all the model values
	//---------------------------
	//
	switch(attribute_entry->attributeID)
	{
	case HoverVehicleHeightAttributeID:
		{
			if(!valid_data)
			{
				Scalar value = 0.5f;
				attribute_entry->SetValue(model, &value);
				result = true;
			}
			if(model->hoverVehicleHeight < 0.0f)
			{
				_snprintf(
					*error,
					error_buffer,
					"{[GameData]HoverVehicleHeight=%f}: value must be > 0!",
					model->hoverVehicleHeight
				);
				result = false;
			}
			break;
		}
	case MaxHoverVehicleHeightAttributeID:
		{
			if(!valid_data)
			{
				Scalar value = 0.0f;
				attribute_entry->SetValue(model, &value);
				result = true;
			}
			if(model->maxHoverVehicleHeight < 0.0f)
			{
				_snprintf(
					*error,
					error_buffer,
					"{[GameData]MaxHoverVehicleHeight=%f}: value must be > 0!",
					model->maxHoverVehicleHeight
				);
				result = false;
			}
			break;
		}
	}
	return result;
}
