# HG changeset patch # User truelight # Date 1174840322 0 # Node ID 5b93bc87cc5ed5cdc2876f53274d092844b777e0 # Parent 5f26f4bc574b7cc57373d14eb315013b692767a0 (svn r9451) [NoAI] -Add: allow static and non-static members for SQ diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_accounting.hpp --- a/src/ai/api/ai_accounting.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_accounting.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -62,8 +62,8 @@ SQAIAccounting.PreRegister(engine); SQAIAccounting.AddConstructor(engine); - SQAIAccounting.DefSQFunction(engine, &AIAccounting::GetCosts, "GetCosts"); - SQAIAccounting.DefSQFunction(engine, &AIAccounting::ResetCosts, "ResetCosts"); + SQAIAccounting.DefSQMethod(engine, &AIAccounting::GetCosts, "GetCosts"); + SQAIAccounting.DefSQMethod(engine, &AIAccounting::ResetCosts, "ResetCosts"); SQAIAccounting.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_base.hpp --- a/src/ai/api/ai_base.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_base.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -57,9 +57,9 @@ SQAIBase.PreRegister(engine); SQAIBase.AddConstructor(engine); - SQAIBase.DefSQFunction(engine, &AIBase::Rand, "Rand"); - SQAIBase.DefSQFunction(engine, &AIBase::RandRange, "RandRange"); - SQAIBase.DefSQFunction(engine, &AIBase::Chance, "Chance"); + SQAIBase.DefSQMethod(engine, &AIBase::Rand, "Rand"); + SQAIBase.DefSQMethod(engine, &AIBase::RandRange, "RandRange"); + SQAIBase.DefSQMethod(engine, &AIBase::Chance, "Chance"); SQAIBase.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_cargo.hpp --- a/src/ai/api/ai_cargo.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_cargo.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -61,10 +61,10 @@ SQAICargo.PreRegister(engine); SQAICargo.AddConstructor(engine); - SQAICargo.DefSQFunction(engine, &AICargo::IsValidCargo, "IsValidCargo"); - SQAICargo.DefSQFunction(engine, &AICargo::GetCargoLabel, "GetCargoLabel"); - SQAICargo.DefSQFunction(engine, &AICargo::IsFreight, "IsFreight"); - SQAICargo.DefSQFunction(engine, &AICargo::GetCargoIncome, "GetCargoIncome"); + SQAICargo.DefSQMethod(engine, &AICargo::IsValidCargo, "IsValidCargo"); + SQAICargo.DefSQMethod(engine, &AICargo::GetCargoLabel, "GetCargoLabel"); + SQAICargo.DefSQMethod(engine, &AICargo::IsFreight, "IsFreight"); + SQAICargo.DefSQMethod(engine, &AICargo::GetCargoIncome, "GetCargoIncome"); SQAICargo.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_company.hpp --- a/src/ai/api/ai_company.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_company.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -90,14 +90,14 @@ SQAICompany.PreRegister(engine); SQAICompany.AddConstructor(engine); - SQAICompany.DefSQFunction(engine, &AICompany::SetCompanyName, "SetCompanyName"); - SQAICompany.DefSQFunction(engine, &AICompany::GetCompanyName, "GetCompanyName"); - SQAICompany.DefSQFunction(engine, &AICompany::GetCompanyValue, "GetCompanyValue"); - SQAICompany.DefSQFunction(engine, &AICompany::GetBankBalance, "GetBankBalance"); - SQAICompany.DefSQFunction(engine, &AICompany::GetLoanAmount, "GetLoanAmount"); - SQAICompany.DefSQFunction(engine, &AICompany::GetMaxLoanAmount, "GetMaxLoanAmount"); - SQAICompany.DefSQFunction(engine, &AICompany::GetLoanInterval, "GetLoanInterval"); - SQAICompany.DefSQFunction(engine, &AICompany::SetLoanAmount, "SetLoanAmount"); + SQAICompany.DefSQMethod(engine, &AICompany::SetCompanyName, "SetCompanyName"); + SQAICompany.DefSQMethod(engine, &AICompany::GetCompanyName, "GetCompanyName"); + SQAICompany.DefSQMethod(engine, &AICompany::GetCompanyValue, "GetCompanyValue"); + SQAICompany.DefSQMethod(engine, &AICompany::GetBankBalance, "GetBankBalance"); + SQAICompany.DefSQMethod(engine, &AICompany::GetLoanAmount, "GetLoanAmount"); + SQAICompany.DefSQMethod(engine, &AICompany::GetMaxLoanAmount, "GetMaxLoanAmount"); + SQAICompany.DefSQMethod(engine, &AICompany::GetLoanInterval, "GetLoanInterval"); + SQAICompany.DefSQMethod(engine, &AICompany::SetLoanAmount, "SetLoanAmount"); SQAICompany.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_controller.hpp --- a/src/ai/api/ai_controller.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_controller.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -90,8 +90,8 @@ void SQAIControllerRegister(Squirrel *engine) { DefSQClass SQAIController("AIController"); SQAIController.PreRegister(engine); - SQAIController.DefSQFunction(engine, &AIControllerSquirrel::GetTick, "GetTick"); - SQAIController.DefSQFunction(engine, &AIControllerSquirrel::Sleep, "Sleep"); + SQAIController.DefSQMethod(engine, &AIControllerSquirrel::GetTick, "GetTick"); + SQAIController.DefSQMethod(engine, &AIControllerSquirrel::Sleep, "Sleep"); SQAIController.PostRegister(engine); } #endif /* DEFINE_SQUIRREL_CLASS */ diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_industry.hpp --- a/src/ai/api/ai_industry.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_industry.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -70,11 +70,11 @@ SQAIIndustry.PreRegister(engine); SQAIIndustry.AddConstructor(engine); - SQAIIndustry.DefSQFunction(engine, &AIIndustry::GetMaxIndustryID, "GetMaxIndustryID"); - SQAIIndustry.DefSQFunction(engine, &AIIndustry::GetIndustryCount, "GetIndustryCount"); - SQAIIndustry.DefSQFunction(engine, &AIIndustry::IsValidIndustry, "IsValidIndustry"); - SQAIIndustry.DefSQFunction(engine, &AIIndustry::GetName, "GetName"); - SQAIIndustry.DefSQFunction(engine, &AIIndustry::GetLocation, "GetLocation"); + SQAIIndustry.DefSQMethod(engine, &AIIndustry::GetMaxIndustryID, "GetMaxIndustryID"); + SQAIIndustry.DefSQMethod(engine, &AIIndustry::GetIndustryCount, "GetIndustryCount"); + SQAIIndustry.DefSQMethod(engine, &AIIndustry::IsValidIndustry, "IsValidIndustry"); + SQAIIndustry.DefSQMethod(engine, &AIIndustry::GetName, "GetName"); + SQAIIndustry.DefSQMethod(engine, &AIIndustry::GetLocation, "GetLocation"); SQAIIndustry.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_map.hpp --- a/src/ai/api/ai_map.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_map.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -136,18 +136,18 @@ SQAIMap.PreRegister(engine); SQAIMap.AddConstructor(engine); - SQAIMap.DefSQFunction(engine, &AIMap::IsValidTile, "IsValidTile"); - SQAIMap.DefSQFunction(engine, &AIMap::GetMapSize, "GetMapSize"); - SQAIMap.DefSQFunction(engine, &AIMap::GetMapSizeX, "GetMapSizeX"); - SQAIMap.DefSQFunction(engine, &AIMap::GetMapSizeY, "GetMapSizeY"); - SQAIMap.DefSQFunction(engine, &AIMap::GetTileX, "GetTileX"); - SQAIMap.DefSQFunction(engine, &AIMap::GetTileY, "GetTileY"); - SQAIMap.DefSQFunction(engine, &AIMap::GetTileIndex, "GetTileIndex"); - SQAIMap.DefSQFunction(engine, &AIMap::DistanceManhattan, "DistanceManhattan"); - SQAIMap.DefSQFunction(engine, &AIMap::DistanceMax, "DistanceMax"); - SQAIMap.DefSQFunction(engine, &AIMap::DistanceSquare, "DistanceSquare"); - SQAIMap.DefSQFunction(engine, &AIMap::DistanceFromEdge, "DistanceFromEdge"); - SQAIMap.DefSQFunction(engine, &AIMap::DemolishTile, "DemolishTile"); + SQAIMap.DefSQMethod(engine, &AIMap::IsValidTile, "IsValidTile"); + SQAIMap.DefSQMethod(engine, &AIMap::GetMapSize, "GetMapSize"); + SQAIMap.DefSQMethod(engine, &AIMap::GetMapSizeX, "GetMapSizeX"); + SQAIMap.DefSQMethod(engine, &AIMap::GetMapSizeY, "GetMapSizeY"); + SQAIMap.DefSQMethod(engine, &AIMap::GetTileX, "GetTileX"); + SQAIMap.DefSQMethod(engine, &AIMap::GetTileY, "GetTileY"); + SQAIMap.DefSQMethod(engine, &AIMap::GetTileIndex, "GetTileIndex"); + SQAIMap.DefSQMethod(engine, &AIMap::DistanceManhattan, "DistanceManhattan"); + SQAIMap.DefSQMethod(engine, &AIMap::DistanceMax, "DistanceMax"); + SQAIMap.DefSQMethod(engine, &AIMap::DistanceSquare, "DistanceSquare"); + SQAIMap.DefSQMethod(engine, &AIMap::DistanceFromEdge, "DistanceFromEdge"); + SQAIMap.DefSQMethod(engine, &AIMap::DemolishTile, "DemolishTile"); SQAIMap.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_order.hpp --- a/src/ai/api/ai_order.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_order.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -175,26 +175,26 @@ SQAIOrder.PreRegister(engine); SQAIOrder.AddConstructor(engine); - SQAIOrder.DefSQConst (engine, AIOrder::AIOF_NONE, "AIOF_NONE"); - SQAIOrder.DefSQConst (engine, AIOrder::AIOF_TRANSFER, "AIOF_TRANSFER"); - SQAIOrder.DefSQConst (engine, AIOrder::AIOF_UNLOAD, "AIOF_UNLOAD"); - SQAIOrder.DefSQConst (engine, AIOrder::AIOF_FULL_LOAD, "AIOF_FULL_LOAD"); - SQAIOrder.DefSQConst (engine, AIOrder::AIOF_SERVICE_IF_NEEDED, "AIOF_SERVICE_IF_NEEDED"); - SQAIOrder.DefSQConst (engine, AIOrder::AIOF_NON_STOP, "AIOF_NON_STOP"); - SQAIOrder.DefSQConst (engine, AIOrder::AIOF_INVALID, "AIOF_INVALID"); + SQAIOrder.DefSQConst (engine, AIOrder::AIOF_NONE, "AIOF_NONE"); + SQAIOrder.DefSQConst (engine, AIOrder::AIOF_TRANSFER, "AIOF_TRANSFER"); + SQAIOrder.DefSQConst (engine, AIOrder::AIOF_UNLOAD, "AIOF_UNLOAD"); + SQAIOrder.DefSQConst (engine, AIOrder::AIOF_FULL_LOAD, "AIOF_FULL_LOAD"); + SQAIOrder.DefSQConst (engine, AIOrder::AIOF_SERVICE_IF_NEEDED, "AIOF_SERVICE_IF_NEEDED"); + SQAIOrder.DefSQConst (engine, AIOrder::AIOF_NON_STOP, "AIOF_NON_STOP"); + SQAIOrder.DefSQConst (engine, AIOrder::AIOF_INVALID, "AIOF_INVALID"); - SQAIOrder.DefSQFunction(engine, &AIOrder::IsValidVehicleOrder, "IsValidVehicleOrder"); - SQAIOrder.DefSQFunction(engine, &AIOrder::AreOrderFlagsValid, "AreOrderFlagsValid"); - SQAIOrder.DefSQFunction(engine, &AIOrder::GetNumberOfOrders, "GetNumberOfOrders"); - SQAIOrder.DefSQFunction(engine, &AIOrder::GetOrderDestination, "GetOrderDestination"); - SQAIOrder.DefSQFunction(engine, &AIOrder::GetOrderFlags, "GetOrderFlags"); - SQAIOrder.DefSQFunction(engine, &AIOrder::AppendOrder, "AppendOrder"); - SQAIOrder.DefSQFunction(engine, &AIOrder::InsertOrder, "InsertOrder"); - SQAIOrder.DefSQFunction(engine, &AIOrder::RemoveOrder, "RemoveOrder"); - SQAIOrder.DefSQFunction(engine, &AIOrder::ChangeOrder, "ChangeOrder"); - SQAIOrder.DefSQFunction(engine, &AIOrder::CopyOrders, "CopyOrders"); - SQAIOrder.DefSQFunction(engine, &AIOrder::ShareOrders, "ShareOrders"); - SQAIOrder.DefSQFunction(engine, &AIOrder::UnshareOrders, "UnshareOrders"); + SQAIOrder.DefSQMethod(engine, &AIOrder::IsValidVehicleOrder, "IsValidVehicleOrder"); + SQAIOrder.DefSQMethod(engine, &AIOrder::AreOrderFlagsValid, "AreOrderFlagsValid"); + SQAIOrder.DefSQMethod(engine, &AIOrder::GetNumberOfOrders, "GetNumberOfOrders"); + SQAIOrder.DefSQMethod(engine, &AIOrder::GetOrderDestination, "GetOrderDestination"); + SQAIOrder.DefSQMethod(engine, &AIOrder::GetOrderFlags, "GetOrderFlags"); + SQAIOrder.DefSQMethod(engine, &AIOrder::AppendOrder, "AppendOrder"); + SQAIOrder.DefSQMethod(engine, &AIOrder::InsertOrder, "InsertOrder"); + SQAIOrder.DefSQMethod(engine, &AIOrder::RemoveOrder, "RemoveOrder"); + SQAIOrder.DefSQMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder"); + SQAIOrder.DefSQMethod(engine, &AIOrder::CopyOrders, "CopyOrders"); + SQAIOrder.DefSQMethod(engine, &AIOrder::ShareOrders, "ShareOrders"); + SQAIOrder.DefSQMethod(engine, &AIOrder::UnshareOrders, "UnshareOrders"); SQAIOrder.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_road.hpp --- a/src/ai/api/ai_road.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_road.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -119,13 +119,13 @@ SQAIRoad.PreRegister(engine); SQAIRoad.AddConstructor(engine); - SQAIRoad.DefSQFunction(engine, &AIRoad::IsRoadTile, "IsRoadTile"); - SQAIRoad.DefSQFunction(engine, &AIRoad::BuildRoad, "BuildRoad"); - SQAIRoad.DefSQFunction(engine, &AIRoad::BuildRoadDepot, "BuildRoadDepot"); - SQAIRoad.DefSQFunction(engine, &AIRoad::BuildRoadStation, "BuildRoadStation"); - SQAIRoad.DefSQFunction(engine, &AIRoad::RemoveRoad, "RemoveRoad"); - SQAIRoad.DefSQFunction(engine, &AIRoad::RemoveRoadDepot, "RemoveRoadDepot"); - SQAIRoad.DefSQFunction(engine, &AIRoad::RemoveRoadStation, "RemoveRoadStation"); + SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadTile, "IsRoadTile"); + SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoad, "BuildRoad"); + SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadDepot, "BuildRoadDepot"); + SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadStation, "BuildRoadStation"); + SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoad, "RemoveRoad"); + SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadDepot, "RemoveRoadDepot"); + SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadStation, "RemoveRoadStation"); SQAIRoad.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_settings.hpp --- a/src/ai/api/ai_settings.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_settings.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -41,7 +41,7 @@ SQAISettings.PreRegister(engine); SQAISettings.AddConstructor(engine); - SQAISettings.DefSQFunction(engine, &AISettings::SetCommandDelay, "SetCommandDelay"); + SQAISettings.DefSQMethod(engine, &AISettings::SetCommandDelay, "SetCommandDelay"); SQAISettings.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_sign.hpp --- a/src/ai/api/ai_sign.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_sign.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -87,13 +87,13 @@ SQAISign.PreRegister(engine); SQAISign.AddConstructor(engine); - SQAISign.DefSQFunction(engine, &AISign::GetMaxSignID, "GetMaxSignID"); - SQAISign.DefSQFunction(engine, &AISign::GetSignCount, "GetSignCount"); - SQAISign.DefSQFunction(engine, &AISign::IsValidSign, "IsValidSign"); - SQAISign.DefSQFunction(engine, &AISign::GetText, "GetText"); - SQAISign.DefSQFunction(engine, &AISign::GetLocation, "GetLocation"); - SQAISign.DefSQFunction(engine, &AISign::RemoveSign, "RemoveSign"); - SQAISign.DefSQFunction(engine, &AISign::BuildSign, "BuildSign"); + SQAISign.DefSQMethod(engine, &AISign::GetMaxSignID, "GetMaxSignID"); + SQAISign.DefSQMethod(engine, &AISign::GetSignCount, "GetSignCount"); + SQAISign.DefSQMethod(engine, &AISign::IsValidSign, "IsValidSign"); + SQAISign.DefSQMethod(engine, &AISign::GetText, "GetText"); + SQAISign.DefSQMethod(engine, &AISign::GetLocation, "GetLocation"); + SQAISign.DefSQMethod(engine, &AISign::RemoveSign, "RemoveSign"); + SQAISign.DefSQMethod(engine, &AISign::BuildSign, "BuildSign"); SQAISign.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_town.hpp --- a/src/ai/api/ai_town.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_town.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -78,12 +78,12 @@ SQAITown.PreRegister(engine); SQAITown.AddConstructor(engine); - SQAITown.DefSQFunction(engine, &AITown::GetMaxTownID, "GetMaxTownID"); - SQAITown.DefSQFunction(engine, &AITown::GetTownCount, "GetTownCount"); - SQAITown.DefSQFunction(engine, &AITown::IsValidTown, "IsValidTown"); - SQAITown.DefSQFunction(engine, &AITown::GetName, "GetName"); - SQAITown.DefSQFunction(engine, &AITown::GetPopulation, "GetPopulation"); - SQAITown.DefSQFunction(engine, &AITown::GetLocation, "GetLocation"); + SQAITown.DefSQMethod(engine, &AITown::GetMaxTownID, "GetMaxTownID"); + SQAITown.DefSQMethod(engine, &AITown::GetTownCount, "GetTownCount"); + SQAITown.DefSQMethod(engine, &AITown::IsValidTown, "IsValidTown"); + SQAITown.DefSQMethod(engine, &AITown::GetName, "GetName"); + SQAITown.DefSQMethod(engine, &AITown::GetPopulation, "GetPopulation"); + SQAITown.DefSQMethod(engine, &AITown::GetLocation, "GetLocation"); SQAITown.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_transactionmode.hpp --- a/src/ai/api/ai_transactionmode.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_transactionmode.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -117,11 +117,11 @@ SQAITransactionMode.PreRegister(engine); SQAITransactionMode.AddConstructor(engine); - SQAITransactionMode.DefSQFunction(engine, &AITransactionMode::Execute, "Execute"); - SQAITransactionMode.DefSQFunction(engine, &AITransactionMode::Stop, "Stop"); - SQAITransactionMode.DefSQFunction(engine, &AITransactionMode::Rollback, "Rollback"); - SQAITransactionMode.DefSQFunction(engine, &AITransactionMode::GetCosts, "GetCosts"); - SQAITransactionMode.DefSQFunction(engine, &AITransactionMode::Append, "Append"); + SQAITransactionMode.DefSQMethod(engine, &AITransactionMode::Execute, "Execute"); + SQAITransactionMode.DefSQMethod(engine, &AITransactionMode::Stop, "Stop"); + SQAITransactionMode.DefSQMethod(engine, &AITransactionMode::Rollback, "Rollback"); + SQAITransactionMode.DefSQMethod(engine, &AITransactionMode::GetCosts, "GetCosts"); + SQAITransactionMode.DefSQMethod(engine, &AITransactionMode::Append, "Append"); SQAITransactionMode.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/ai/api/ai_vehicle.hpp --- a/src/ai/api/ai_vehicle.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/ai/api/ai_vehicle.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -130,16 +130,16 @@ SQAIVehicle.PreRegister(engine); SQAIVehicle.AddConstructor(engine); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::IsValidEngine, "IsValidEngine"); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::IsValidVehicle, "IsValidVehicle"); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::FindBestRoadVehicle, "FindBestRoadVehicle"); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::BuildVehicle, "BuildVehicle"); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::CloneVehicle, "CloneVehicle"); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::RefitVehicle, "RefitVehicle"); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::SellVehicle, "SellVehicle"); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::SendVehicleToDepot, "SendVehicleToDepot"); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::StartStopVehicle, "StartStopVehicle"); - SQAIVehicle.DefSQFunction(engine, &AIVehicle::SkipVehicleOrder, "SkipVehicleOrder"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::IsValidEngine, "IsValidEngine"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::IsValidVehicle, "IsValidVehicle"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::FindBestRoadVehicle, "FindBestRoadVehicle"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::BuildVehicle, "BuildVehicle"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::CloneVehicle, "CloneVehicle"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::RefitVehicle, "RefitVehicle"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::SellVehicle, "SellVehicle"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::SendVehicleToDepot, "SendVehicleToDepot"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::StartStopVehicle, "StartStopVehicle"); + SQAIVehicle.DefSQMethod(engine, &AIVehicle::SkipVehicleOrder, "SkipVehicleOrder"); SQAIVehicle.PostRegister(engine); } diff -r 5f26f4bc574b -r 5b93bc87cc5e src/squirrel_class.hpp --- a/src/squirrel_class.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/squirrel_class.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -46,9 +46,18 @@ * This defines a method inside a class for Squirrel. */ template - void DefSQFunction(Squirrel *engine, Func function_proc, const char *function_name) + void DefSQMethod(Squirrel *engine, Func function_proc, const char *function_name) { - engine->AddMethod(function_name, SQConvert::DefSQCallback, &function_proc, sizeof(function_proc)); + engine->AddMethod(function_name, SQConvert::DefSQNonStaticCallback, &function_proc, sizeof(function_proc)); + } + + /** + * This defines a static method inside a class for Squirrel. + */ + template + void DefSQStaticMethod(Squirrel *engine, Func function_proc, const char *function_name) + { + engine->AddMethod(function_name, SQConvert::DefSQStaticCallback, &function_proc, sizeof(function_proc)); } template diff -r 5f26f4bc574b -r 5b93bc87cc5e src/squirrel_helper.hpp --- a/src/squirrel_helper.hpp Sun Mar 25 16:10:40 2007 +0000 +++ b/src/squirrel_helper.hpp Sun Mar 25 16:32:02 2007 +0000 @@ -369,12 +369,12 @@ /** - * A general template for all callback functions from Squirrel. + * A general template for all non-static method callbacks from Squirrel. * In here the function_proc is recovered, and the SQCall is called that * can handle this exact amount of params. */ template - inline SQInteger DefSQCallback(HSQUIRRELVM vm) + inline SQInteger DefSQNonStaticCallback(HSQUIRRELVM vm) { /* Find the amount of params we got */ int nparam = sq_gettop(vm); @@ -402,6 +402,25 @@ return HelperT::SQCall((Tcls *)real_instance, *(Tmethod *)ptr, vm); } + /** + * A general template for all function/static method callbacks from Squirrel. + * In here the function_proc is recovered, and the SQCall is called that + * can handle this exact amount of params. + */ + template + inline SQInteger DefSQStaticCallback(HSQUIRRELVM vm) + { + /* Find the amount of params we got */ + int nparam = sq_gettop(vm); + SQUserPointer ptr = NULL; + + /* Get the real function pointer */ + sq_getuserdata(vm, nparam, &ptr, 0); + + /* Delegate it to a template that can handle this specific function */ + return HelperT::SQCall((Tcls *)NULL, *(Tmethod *)ptr, vm); + } + }; // namespace SQConvert #endif /* SQUIRREL_HELPER_HPP */