[Gcblue-commits] gcb_wx/src/scriptinterface tcPlatformInterface.cpp,1.37,1.38 tcPlatformInterfaceExt
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-03-02 22:29:27
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15614/src/scriptinterface Modified Files: tcPlatformInterface.cpp tcPlatformInterfaceExtension.cpp tcPlatformInterfaceExtensionB.cpp tcScenarioInterface.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcPlatformInterfaceExtensionB.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtensionB.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcPlatformInterfaceExtensionB.cpp 24 Feb 2005 22:19:15 -0000 1.20 --- tcPlatformInterfaceExtensionB.cpp 2 Mar 2005 22:28:44 -0000 1.21 *************** *** 1,6 **** ! /* ! ** tcPlatformInterfaceExtensionB.cpp ! ** ! ** Copyright (C) 2003 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,6 ---- ! /** ! ** @file tcPlatformInterfaceExtensionB.cpp ! */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 36,39 **** --- 36,40 ---- #include "tcPlatformInterface.h" #include "tcSoundConsole.h" + #include "ai/BlackboardInterface.h" #ifdef _DEBUG *************** *** 43,46 **** --- 44,48 ---- using namespace boost::python; using namespace AI; + using ai::BlackboardInterface; namespace ScriptInterface { *************** *** 77,81 **** .def("IsHelo", &tcPlatformInterface::IsHelo) .def("IsSub", &tcPlatformInterface::IsSub) - .def("SetUpdate", &tcPlatformInterface::SetUpdateInterval) .def("SetActionText", &tcPlatformInterface::SetActionText) .def("GetSubInterface", &tcPlatformInterface::GetSubInterface) --- 79,82 ---- *************** *** 108,120 **** // orders ! .def("AddNavOrder",&tcPlatformInterface::AddNavOrder) ! .def("AddOrder",&tcPlatformInterface::AddOrder) ! .def("ClearOrders",&tcPlatformInterface::ClearOrders) ! .def("CompletedOrder",&tcPlatformInterface::CompletedOrder) ! .def("GetCurrentOrder",&tcPlatformInterface::GetCurrentOrder) .def("GetLocalObj",&tcPlatformInterface::GetLocalObj) - .def("GetOrder",&tcPlatformInterface::GetOrder) - .def("GetOrderCount",&tcPlatformInterface::GetOrderCount) - .def("HasOrders",&tcPlatformInterface::HasOrders) // sensors --- 109,121 ---- // orders ! .def("AddNavWaypoint", &tcPlatformInterface::AddNavWaypoint) ! .def("AddTask", &tcPlatformInterface::AddTask) ! .def("ClearTasks", &tcPlatformInterface::ClearTasks) ! .def("DeleteTask", &tcPlatformInterface::DeleteTask) ! .def("GetBlackboardInterface", &tcPlatformInterface::GetBlackboardInterface) ! .def("TaskExists", &tcPlatformInterface::TaskExists) ! ! // TODO why is this exposed?? .def("GetLocalObj",&tcPlatformInterface::GetLocalObj) // sensors *************** *** 142,147 **** // miscellaneous ! .def("GetVar", &tcPlatformInterface::GetVar) ! .def("SetVar", &tcPlatformInterface::SetVar) .def("DisplayMessage",&tcPlatformInterface::DisplayMessage) .def("IsValid",&tcPlatformInterface::IsValid) --- 143,149 ---- // miscellaneous ! .def("GetTime", &tcPlatformInterface::GetTime) ! .def("LookupFriendlyId", &tcPlatformInterface::LookupFriendlyId) ! .def("LookupFriendlyName", &tcPlatformInterface::LookupFriendlyName) .def("DisplayMessage",&tcPlatformInterface::DisplayMessage) .def("IsValid",&tcPlatformInterface::IsValid) Index: tcPlatformInterfaceExtension.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtension.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcPlatformInterfaceExtension.cpp 24 Feb 2005 22:19:15 -0000 1.14 --- tcPlatformInterfaceExtension.cpp 2 Mar 2005 22:28:44 -0000 1.15 *************** *** 42,46 **** namespace ScriptInterface { ! void tcPlatformInterface::InitPythonClassesA(void) { object class_track = class_<tcTrack>("tcTrack") .def_readwrite("Alt",&tcTrack::mfAlt_m) --- 42,47 ---- namespace ScriptInterface { ! void tcPlatformInterface::InitPythonClassesA() ! { object class_track = class_<tcTrack>("tcTrack") .def_readwrite("Alt",&tcTrack::mfAlt_m) *************** *** 56,59 **** --- 57,61 ---- .def("IsMissile", &tcTrack::IsMissile) .def("IsSurface", &tcTrack::IsSurface) + .def("IsGround", &tcTrack::IsGround) .def("IsValid", &tcTrack::IsValid) .def("Offset", &tcTrack::Offset) *************** *** 74,77 **** --- 76,80 ---- .def("IsMissile", &tcSensorMapTrack::IsMissile) .def("IsSurface", &tcSensorMapTrack::IsSurface) + .def("IsGround", &tcSensorMapTrack::IsGround) .def("IsValid", &tcSensorMapTrack::IsValid) .def("Offset", &tcSensorMapTrack::Offset) Index: tcScenarioInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcScenarioInterface.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcScenarioInterface.cpp 24 Feb 2005 22:19:15 -0000 1.20 --- tcScenarioInterface.cpp 2 Mar 2005 22:28:44 -0000 1.21 *************** *** 47,50 **** --- 47,51 ---- #include "tcSubObject.h" #include "ai/Brain.h" + #include "tcPlatformInterface.h" #include "wxcommands.h" *************** *** 141,146 **** .def("AddUnitTask", &tcScenarioInterface::AddUnitTask) .def("AddToUnitMagazine",&tcScenarioInterface::AddToUnitMagazine) .def("SetUnitLauncherItem",&tcScenarioInterface::SetUnitLauncherItem) ! .def("CreateAlliance",&tcScenarioInterface::CreateAlliance) .def("GetDefaultOrder",&tcScenarioInterface::GetDefaultOrder) --- 142,148 ---- .def("AddUnitTask", &tcScenarioInterface::AddUnitTask) .def("AddToUnitMagazine",&tcScenarioInterface::AddToUnitMagazine) + .def("GetUnitInterface", &tcScenarioInterface::GetUnitInterface) .def("SetUnitLauncherItem",&tcScenarioInterface::SetUnitLauncherItem) ! .def("CreateAlliance",&tcScenarioInterface::CreateAlliance) .def("GetDefaultOrder",&tcScenarioInterface::GetDefaultOrder) *************** *** 353,356 **** --- 355,372 ---- + tcPlatformInterface tcScenarioInterface::GetUnitInterface(const std::string& unitName) + { + wxASSERT(simState); + tcGameObject* obj = simState->GetObjectByName(unitName); + if (tcPlatformObject* platform = dynamic_cast<tcPlatformObject*>(obj)) + { + return tcPlatformInterface(platform); + } + else + { + return tcPlatformInterface(0); + } + } + /** * Sets launcher item and quantity of unit Index: tcPlatformInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterface.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** tcPlatformInterface.cpp 24 Feb 2005 22:19:15 -0000 1.37 --- tcPlatformInterface.cpp 2 Mar 2005 22:28:44 -0000 1.38 *************** *** 2,6 **** ** @file tcPlatformInterface.cpp */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 2,6 ---- ** @file tcPlatformInterface.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 715,742 **** - bool tcPlatformInterface::HasOrders() - { - return mpPlatformObj->mcAI.HasOrders(); - } - - tcOrder tcPlatformInterface::GetCurrentOrder() - { - return mpPlatformObj->mcAI.GetCurrentOrder(); - } - - void tcPlatformInterface::CompletedOrder() - { - mpPlatformObj->mcAI.CompletedOrder(); - } ! void tcPlatformInterface::AddOrder(std::string order_text, long data) { ! tcOrder o; ! o.mstrOrdername = order_text; ! o.data = data; ! mpPlatformObj->mcAI.AddOrder(o); } ! void tcPlatformInterface::AddNavOrder(float afLon_rad, float afLat_rad) { ai::Brain* brain = mpPlatformObj->GetBrain(); --- 715,728 ---- ! void tcPlatformInterface::AddTask(const std::string& taskName, double priority) { ! ai::Brain* brain = mpPlatformObj->GetBrain(); ! wxASSERT(brain); ! ! brain->AddTask(taskName, priority); } ! void tcPlatformInterface::AddNavWaypoint(float afLon_rad, float afLat_rad) { ai::Brain* brain = mpPlatformObj->GetBrain(); *************** *** 746,750 **** if (!nav) { ! brain->AddTask("Nav", 1.5f); nav = brain->GetNavTask(); } --- 732,736 ---- if (!nav) { ! brain->AddTask("Nav", 1.0f); nav = brain->GetNavTask(); } *************** *** 755,784 **** /** ! * Only removes Nav task at the moment */ ! void tcPlatformInterface::ClearOrders() { ai::Brain* brain = mpPlatformObj->GetBrain(); wxASSERT(brain); ! mpPlatformObj->GetBrain()->RemoveTask("Nav"); } void tcPlatformInterface::DeleteTask(const std::string& taskName) { ! mpPlatformObj->GetBrain()->RemoveTask(taskName); } ! int tcPlatformInterface::GetOrderCount() { ! return (int)mpPlatformObj->mcAI.maOrder.size(); } ! tcOrder tcPlatformInterface::GetOrder(int n) ! { ! tcOrder order; ! mpPlatformObj->mcAI.GetOrder(order, n); ! return order; } void tcPlatformInterface::GetSensorMap() --- 741,781 ---- /** ! * Remove all tasks from ai brain */ ! void tcPlatformInterface::ClearTasks() { ai::Brain* brain = mpPlatformObj->GetBrain(); wxASSERT(brain); ! brain->RemoveAllTasks(); } void tcPlatformInterface::DeleteTask(const std::string& taskName) { ! ai::Brain* brain = mpPlatformObj->GetBrain(); ! wxASSERT(brain); ! ! brain->RemoveTask(taskName); } ! /** ! * Used to pass parameters to tasks by posting for all tasks to see ! */ ! ai::BlackboardInterface tcPlatformInterface::GetBlackboardInterface() { ! ai::Brain* brain = mpPlatformObj->GetBrain(); ! wxASSERT(brain); ! ! return brain->GetBlackboardInterface(); } ! bool tcPlatformInterface::TaskExists(const std::string& taskName) ! { ! ai::Brain* brain = mpPlatformObj->GetBrain(); ! wxASSERT(brain); ! ! return brain->TaskExists(taskName); } + void tcPlatformInterface::GetSensorMap() *************** *** 1070,1075 **** ! /* Request user input. Python callback function is called after input is ! ** obtained */ void tcPlatformInterface::GetUserInput(std::string callback, std::string uitype) { --- 1067,1080 ---- ! double tcPlatformInterface::GetTime() const ! { ! wxASSERT(mpPlatformObj); ! return mpPlatformObj->mfStatusTime; ! } ! ! /** ! * Request user input. Python callback function is called after input is ! * obtained ! */ void tcPlatformInterface::GetUserInput(std::string callback, std::string uitype) { *************** *** 1077,1083 **** mpCommandQueue->GetUserInput(callback.c_str(),uitype.c_str()); } ! /* Send command through command queue, used for special commands to game engine ! ** such as activating the flight deck control panel. */ void tcPlatformInterface::SendCommand(std::string command) --- 1082,1115 ---- mpCommandQueue->GetUserInput(callback.c_str(),uitype.c_str()); } + + long tcPlatformInterface::LookupFriendlyId(const std::string& unitName) + { + tcGameObject* obj = mpSimState->GetObjectByName(unitName); + if ((obj == 0) || !mpSimState->mpUserInfo->IsOwnAlliance(obj->mnAlliance)) + { + return -1; + } + else + { + return obj->mnID; + } + } + + std::string tcPlatformInterface::LookupFriendlyName(long id) + { + tcGameObject* obj = mpSimState->GetObject(id); + if ((obj == 0) || !mpSimState->mpUserInfo->IsOwnAlliance(obj->mnAlliance)) + { + return std::string(""); + } + else + { + return std::string(obj->mzUnit.mz); + } + } ! /** ! * Send command through command queue, used for special commands to game engine ! * such as activating the flight deck control panel. */ void tcPlatformInterface::SendCommand(std::string command) *************** *** 1096,1100 **** ! // print message to user console void tcPlatformInterface::DisplayMessage(std::string text) { --- 1128,1134 ---- ! /** ! * print message to user console ! */ void tcPlatformInterface::DisplayMessage(std::string text) { *************** *** 1140,1144 **** * Heading_rad has runway orientation * ! * @returns track with landing data for platform id */ tcTrack tcPlatformInterface::GetLandingData(long id) --- 1174,1178 ---- * Heading_rad has runway orientation * ! * @returns track with landing data for platform matching id */ tcTrack tcPlatformInterface::GetLandingData(long id) |