[Gcblue-commits] gcb_wx/src/scriptinterface tcPlatformInterface.cpp,1.30,1.31 tcPlatformInterfaceExt
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-12-05 02:49:57
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20399/src/scriptinterface Modified Files: tcPlatformInterface.cpp tcPlatformInterfaceExtensionB.cpp tcScenarioInterface.cpp tcSimPythonInterface.cpp Log Message: Sonar work, passive sonar, torpedoes Index: tcPlatformInterfaceExtensionB.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtensionB.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcPlatformInterfaceExtensionB.cpp 29 Nov 2004 03:55:05 -0000 1.17 --- tcPlatformInterfaceExtensionB.cpp 5 Dec 2004 02:49:47 -0000 1.18 *************** *** 145,148 **** --- 145,149 ---- .def("SetVar", &tcPlatformInterface::SetVar) .def("DisplayMessage",&tcPlatformInterface::DisplayMessage) + .def("IsValid",&tcPlatformInterface::IsValid) .def("PlaySound",&tcPlatformInterface::PlaySound) .def("Rand",&tcPlatformInterface::GetRand) Index: tcSimPythonInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcSimPythonInterface.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcSimPythonInterface.cpp 2 Dec 2004 04:17:25 -0000 1.22 --- tcSimPythonInterface.cpp 5 Dec 2004 02:49:48 -0000 1.23 *************** *** 551,555 **** tcPlatformObject *pPlatformObj = dynamic_cast<tcPlatformObject*>(pGameObj); mpHookedObj = pPlatformObj; ! if (pPlatformObj == NULL) {return;} hookedInterface->SetPlatform(pPlatformObj); /* --- 551,555 ---- tcPlatformObject *pPlatformObj = dynamic_cast<tcPlatformObject*>(pGameObj); mpHookedObj = pPlatformObj; ! //if (pPlatformObj == NULL) {return;} hookedInterface->SetPlatform(pPlatformObj); /* Index: tcScenarioInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcScenarioInterface.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcScenarioInterface.cpp 23 Nov 2004 23:30:58 -0000 1.14 --- tcScenarioInterface.cpp 5 Dec 2004 02:49:48 -0000 1.15 *************** *** 29,48 **** #endif ! #include "tcScenarioInterface.h" ! #include "tcMapData.h" ! #include "tcSimState.h" #include "tcAIData.h" ! #include "tcSoundConsole.h" #include "tcDirector.h" #include "tcDirectorEvent.h" ! #include "wxcommands.h" ! #include "tcGoalTracker.h" #include "tcGoal.h" ! #include "tcCarrierObject.h" ! #include "tcAeroAirObject.h" #include "tcSubObject.h" - #include "tcAirfieldObject.h" - #include "tcGenericDBObject.h" using namespace std; --- 29,50 ---- #endif ! #include "tcAeroAirObject.h" ! #include "tcAirfieldObject.h" #include "tcAIData.h" ! #include "tcCarrierObject.h" #include "tcDirector.h" #include "tcDirectorEvent.h" ! #include "tcGenericDBObject.h" #include "tcGoal.h" ! #include "tcGoalTracker.h" ! #include "tcLauncher.h" ! #include "tcMapData.h" ! #include "tcScenarioInterface.h" ! #include "tcSimState.h" ! #include "tcSoundConsole.h" ! #include "tcStores.h" #include "tcSubObject.h" + #include "wxcommands.h" using namespace std; *************** *** 134,137 **** --- 136,142 ---- .def("AddUnitToAlliance",&tcScenarioInterface::AddUnitToAlliance) .def("AddUnitToFlightDeck",&tcScenarioInterface::AddUnitToFlightDeck) + .def("AddToUnitMagazine",&tcScenarioInterface::AddToUnitMagazine) + .def("SetUnitLauncherItem",&tcScenarioInterface::SetUnitLauncherItem) + .def("CreateAlliance",&tcScenarioInterface::CreateAlliance) .def("GetDefaultOrder",&tcScenarioInterface::GetDefaultOrder) *************** *** 281,284 **** --- 286,360 ---- } + /** + * Adds items (normally weapons) to first compatible magazine of unit + */ + void tcScenarioInterface::AddToUnitMagazine(const std::string& unitName, + const std::string& item, unsigned int quantity) + { + wxASSERT(simState); + tcGameObject* parentObj = simState->GetObjectByName(unitName); + if (tcPlatformObject* platform = dynamic_cast<tcPlatformObject*>(parentObj)) + { + unsigned int nMagazines = platform->GetMagazineCount(); + for (unsigned int n=0; n<nMagazines; n++) + { + tcStores* mag = platform->GetMagazine(n); + if (!mag->IsFull() && mag->IsCompatible(item)) + { + mag->AddItems(item, quantity); + return; + } + } + + fprintf(stderr, "tcScenarioInterface::AddToUnitMagazine - " + "Failed to load %s to unit %s\n", item.c_str(),unitName.c_str()); + + } + else + { + fprintf(stderr, "tcScenarioInterface::AddToUnitMagazine - " + "Unit not found: %s\n", unitName.c_str()); + } + } + + /** + * Sets launcher item and quantity of unit + */ + void tcScenarioInterface::SetUnitLauncherItem(const std::string& unitName, + unsigned int launcherIdx, const std::string& item, unsigned int quantity) + { + wxASSERT(simState); + tcGameObject* parentObj = simState->GetObjectByName(unitName); + if (tcPlatformObject* platform = dynamic_cast<tcPlatformObject*>(parentObj)) + { + if (tcLauncher* launcher = platform->GetLauncher(launcherIdx)) + { + if (launcher->IsItemCompatible(item)) + { + launcher->SetChildClass(item); + launcher->SetChildQuantity(quantity); + } + else + { + fprintf(stderr, "tcScenarioInterface::SetUnitLauncherItem - " + "%s not compatible with unit %s, launcher %d\n", item.c_str(), + unitName.c_str(), launcherIdx); + } + } + else + { + fprintf(stderr, "tcScenarioInterface::SetUnitLauncherItem - " + "Bad launcher index (unit %s, launcher %d)\n", + unitName.c_str(), launcherIdx); + } + } + else + { + fprintf(stderr, "tcScenarioInterface::AddToUnitMagazine - " + "Unit not found or bad type (%s)\n", unitName.c_str()); + } + } + + void tcScenarioInterface::CreateAlliance(int alliance, std::string name) { Index: tcPlatformInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterface.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tcPlatformInterface.cpp 29 Nov 2004 03:55:05 -0000 1.30 --- tcPlatformInterface.cpp 5 Dec 2004 02:49:47 -0000 1.31 *************** *** 40,45 **** #include "commandlist.h" #include "tcAeroAirObject.h" - #include "tcGenericDBObject.h" #include "tcBallisticDBObject.h" #include "tcLauncherState.h" #include "tcLauncher.h" --- 40,46 ---- #include "commandlist.h" #include "tcAeroAirObject.h" #include "tcBallisticDBObject.h" + #include "tcGenericDBObject.h" + #include "tcTorpedoDBObject.h" #include "tcLauncherState.h" #include "tcLauncher.h" *************** *** 316,319 **** --- 317,324 ---- return true; } + if ((track.mnClassification & PTYPE_SUBMARINE)&&(info.mnTargetFlags & SUBSURFACE_TARGET)) + { + return true; + } return false; } *************** *** 470,475 **** info.mfRange_km = 20; } ! else ! { fprintf(stderr, "Error - unsupported launcher child class (%s)\n", pLauncherData->mpChildDBObj->GetClassName()); --- 475,484 ---- info.mfRange_km = 20; } ! else if (tcTorpedoDBObject* torpDBObj = ! dynamic_cast<tcTorpedoDBObject*>(pLauncherData->mpChildDBObj)) ! { ! info.mfRange_km = torpDBObj->mfRange_km; ! } ! else { fprintf(stderr, "Error - unsupported launcher child class (%s)\n", pLauncherData->mpChildDBObj->GetClassName()); *************** *** 629,646 **** } ! bool found = false; ! int nTypes = (int)launcher->GetCompatibleCount(); ! for (int k=0; (k<nTypes) && !found; k++) ! { ! if (launcher->GetCompatibleName(unsigned(k)) == item) ! { ! found = true; ! } ! } ! if (!found) ! { ! return; ! } ! unsigned int nMagazines = mpPlatformObj->GetMagazineCount(); --- 638,642 ---- } ! if (!launcher->IsItemCompatible(item)) return; unsigned int nMagazines = mpPlatformObj->GetMagazineCount(); *************** *** 741,749 **** } ! void tcPlatformInterface::GetSensorMap(void) { ! UINT8 nAlliance = mpPlatformObj->mnAlliance; ! mpSensorMap = mpSimState->mcSensorMap.GetMap(nAlliance); ! wxASSERT(mpSensorMap); } --- 737,752 ---- } ! void tcPlatformInterface::GetSensorMap() { ! if (mpPlatformObj) ! { ! unsigned int nAlliance = mpPlatformObj->mnAlliance; ! mpSensorMap = mpSimState->mcSensorMap.GetMap(nAlliance); ! wxASSERT(mpSensorMap); ! } ! else ! { ! mpSensorMap = 0; ! } } *************** *** 1021,1024 **** --- 1024,1036 ---- } + /** + * @return true if interface has valid (non null) platform object + */ + bool tcPlatformInterface::IsValid() const + { + return mpPlatformObj != 0; + } + + // print message to user console void tcPlatformInterface::DisplayMessage(std::string text) |