[Gcblue-commits] gcb_wx/src/scriptinterface tcPlatformInterface.cpp, 1.67, 1.68
Status: Alpha
Brought to you by:
ddcforge
From: Dewitt C. <ddc...@us...> - 2006-12-20 00:45:51
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv25403/src/scriptinterface Modified Files: tcPlatformInterface.cpp Log Message: Index: tcPlatformInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterface.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** tcPlatformInterface.cpp 20 Nov 2006 00:17:43 -0000 1.67 --- tcPlatformInterface.cpp 20 Dec 2006 00:45:46 -0000 1.68 *************** *** 107,110 **** --- 107,111 ---- float tcPlatformInterface::GetFuel() const { + if (mpPlatformObj == 0) return 0; return mpPlatformObj->fuel_kg / mpPlatformObj->GetFuelCapacity(); } *************** *** 124,127 **** --- 125,129 ---- float tcPlatformInterface::GetSpeed() { + if (mpPlatformObj == 0) return 0; return mpPlatformObj->mcKin.mfSpeed_kts; } *************** *** 129,132 **** --- 131,135 ---- float tcPlatformInterface::GetMaxSpeed() { + if (mpPlatformObj == 0) return 0; return mpPlatformObj->mpDBObject->mfMaxSpeed_kts; } *************** *** 134,137 **** --- 137,141 ---- float tcPlatformInterface::GetHeading() { + if (mpPlatformObj == 0) return 0; return C_180OVERPI*mpPlatformObj->mcKin.mfHeading_rad; } *************** *** 139,142 **** --- 143,147 ---- float tcPlatformInterface::GetHeadingRad() { + if (mpPlatformObj == 0) return 0; return mpPlatformObj->mcKin.mfHeading_rad; } *************** *** 196,199 **** --- 201,205 ---- void tcPlatformInterface::SetAltitude(float alt_m) { + if (mpPlatformObj == 0) return; if (!mpPlatformObj->IsControlled()) return; mpPlatformObj->SetAltitude(alt_m); *************** *** 206,209 **** --- 212,216 ---- void tcPlatformInterface::SetLandingState(int state) { + if (mpPlatformObj == 0) return; if (!mpPlatformObj->IsControlled()) return; if (tcAirObject *air = dynamic_cast<tcAirObject*>(mpPlatformObj)) *************** *** 227,230 **** --- 234,238 ---- void tcPlatformInterface::SetSpeed(float speed_kts) { + if (mpPlatformObj == 0) return; if (!mpPlatformObj->IsControlled()) return; mpPlatformObj->SetSpeed(speed_kts); *************** *** 253,256 **** --- 261,265 ---- void tcPlatformInterface::SetThrottle(float throttleFraction) { + if (mpPlatformObj == 0) {return;} if (!mpPlatformObj->IsControlled()) return; if (tcAeroAirObject* aaObj = dynamic_cast<tcAeroAirObject*>(mpPlatformObj)) *************** *** 263,266 **** --- 272,277 ---- bool tcPlatformInterface::IsSurface() const { + if (mpPlatformObj == 0) return false; + return (mpPlatformObj->mnModelType == MTYPE_SURFACE); } *************** *** 269,272 **** --- 280,285 ---- bool tcPlatformInterface::IsAir() const { + if (mpPlatformObj == 0) return false; + UINT32 nModelType = mpPlatformObj->mnModelType; return (nModelType == MTYPE_FIXEDWING)||(nModelType == MTYPE_FIXEDWINGX) *************** *** 277,280 **** --- 290,294 ---- bool tcPlatformInterface::IsHelo() const { + if (mpPlatformObj == 0) return false; return (mpPlatformObj->mnModelType == MTYPE_HELO); } *************** *** 282,285 **** --- 296,300 ---- bool tcPlatformInterface::IsFixed() const { + if (mpPlatformObj == 0) return false; return (mpPlatformObj->mnModelType == MTYPE_FIXED) || (mpPlatformObj->mnModelType == MTYPE_AIRFIELD); *************** *** 289,292 **** --- 304,308 ---- bool tcPlatformInterface::IsSub() const { + if (mpPlatformObj == 0) return false; return (mpPlatformObj->mnModelType == MTYPE_SUBMARINE); } *************** *** 303,306 **** --- 319,323 ---- void tcPlatformInterface::SetTarget(long anID) { + if (mpPlatformObj == 0) return; if (!mpPlatformObj->IsControlled()) return; mpPlatformObj->DesignateTarget(anID); *************** *** 309,312 **** --- 326,330 ---- long tcPlatformInterface::GetTarget() { + if (mpPlatformObj == 0) return -1; return mpPlatformObj->GetBrain()->GetTarget(); } *************** *** 314,317 **** --- 332,336 ---- float tcPlatformInterface::GetRangeToTarget() { + if (mpPlatformObj == 0) return 0; tcSensorMapTrack track; if (!GetTargetTrack(track)) *************** *** 325,328 **** --- 344,348 ---- bool tcPlatformInterface::GetTargetTrack(tcSensorMapTrack& track) { + if (mpPlatformObj == 0) return false; tcGameObject* pGameObj = GetTargetObj(); *************** *** 410,413 **** --- 430,434 ---- bool tcPlatformInterface::IsLauncherEffective(int anLauncher) { + if (mpPlatformObj == 0) return false; tcLauncher* pLauncher = mpPlatformObj->GetLauncher(anLauncher); if (pLauncher == 0) return false; // bad launcher index *************** *** 434,437 **** --- 455,459 ---- { wxASSERT(mpPlatformObj); + if (mpPlatformObj == 0) return 0; tcLauncherState* launcherState; *************** *** 455,458 **** --- 477,482 ---- void tcPlatformInterface::SetHeading(float heading_deg) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsControlled()) return; *************** *** 465,468 **** --- 489,494 ---- void tcPlatformInterface::SetHeadingRad(float heading_rad) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsControlled()) return; mpPlatformObj->SetHeading(heading_rad); *************** *** 475,478 **** --- 501,506 ---- float tcPlatformInterface::SetHeadingToInterceptTarget() { + if (mpPlatformObj == 0) return 0; + if (!mpPlatformObj->IsControlled()) return 0; tcSensorMapTrack track; *************** *** 488,491 **** --- 516,521 ---- float tcPlatformInterface::GetHeadingToDatum(float afLon_rad, float afLat_rad) { + if (mpPlatformObj == 0) return 0; + GeoPoint p; p.mfAlt_m = 0; *************** *** 498,501 **** --- 528,533 ---- float tcPlatformInterface::GetRangeToDatum(float afLon_rad, float afLat_rad) { + if (mpPlatformObj == 0) return 0; + GeoPoint p; p.mfAlt_m = 0; *************** *** 516,519 **** --- 548,553 ---- best.mfRange_km = 0; + if (mpPlatformObj == 0) return best; + tcSensorMapTrack track; if (!GetTargetTrack(track)) {return best;} *************** *** 596,599 **** --- 630,635 ---- bool tcPlatformInterface::GetLauncherInfo(scriptinterface::tcLauncherInfo& info, int anLauncher) { + if (mpPlatformObj == 0) return false; + info.mnLauncher = -1; info.launcherStatus = tcLauncher::LAUNCHER_BUSY; *************** *** 694,697 **** --- 730,739 ---- std::string s; + if (mpPlatformObj == 0) + { + s = "Error"; + return s; + } + int nCount = GetLauncherCount(); if ((anLauncher < 0)||(anLauncher >= nCount)) *************** *** 709,712 **** --- 751,756 ---- float alt_m, int anLauncher) { + if (mpPlatformObj == 0) return; + GeoPoint p; p.mfLon_rad = afLon_rad; *************** *** 718,721 **** --- 762,767 ---- bool tcPlatformInterface::HandoffTargetToLauncher(int anLauncher) { + if (mpPlatformObj == 0) return false; + UINT32 nTargetID = mpPlatformObj->GetBrain()->GetTarget(); bool bAccept = mpSimState->DesignateLauncherTarget(mpPlatformObj->mnID, *************** *** 726,729 **** --- 772,777 ---- void tcPlatformInterface::Launch(int anLauncher, int quantity) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsControlled()) return; int launcherStatus = mpPlatformObj->SetLaunch(anLauncher, quantity); *************** *** 736,739 **** --- 784,789 ---- int tcPlatformInterface::GetLauncherQuantity(int anLauncher) { + if (mpPlatformObj == 0) return 0; + return mpPlatformObj->GetLauncherQuantity(anLauncher); } *************** *** 745,748 **** --- 795,800 ---- int tcPlatformInterface::GetLauncherTypesCount(int anLauncher) { + if (mpPlatformObj == 0) return 0; + if (tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher)) { *************** *** 760,763 **** --- 812,817 ---- std::string tcPlatformInterface::GetLauncherTypeName(int anLauncher, int anType) { + if (mpPlatformObj == 0) return std::string("Error"); + if (tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher)) { *************** *** 775,778 **** --- 829,834 ---- bool tcPlatformInterface::CanMagazineAcceptItem(std::string item) { + if (mpPlatformObj == 0) return false; + unsigned int nMagazines = mpPlatformObj->GetMagazineCount(); for (unsigned int n=0; n<nMagazines; n++) *************** *** 789,792 **** --- 845,850 ---- int tcPlatformInterface::GetMagazineQuantity(std::string item) { + if (mpPlatformObj == 0) return 0; + return (int)mpPlatformObj->GetMagazineQuantity(item); } *************** *** 797,800 **** --- 855,860 ---- void tcPlatformInterface::LoadLauncher(int anLauncher, const std::string& item) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsControlled()) return; // verify launcher is empty and item is compatible with launcher *************** *** 826,829 **** --- 886,891 ---- void tcPlatformInterface::LoadOther(const std::string& item) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsControlled()) return; *************** *** 858,861 **** --- 920,925 ---- bool tcPlatformInterface::IsRefueling() const { + if (mpPlatformObj == 0) return false; + return mpPlatformObj->IsRefueling(); } *************** *** 866,869 **** --- 930,935 ---- void tcPlatformInterface::UnloadLauncher(int anLauncher) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsControlled()) return; tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher); *************** *** 887,896 **** } - - - - void tcPlatformInterface::AddTask(const std::string& taskName, double priority, int attributes) { ai::Brain* brain = mpPlatformObj->GetBrain(); wxASSERT(brain); --- 953,960 ---- } void tcPlatformInterface::AddTask(const std::string& taskName, double priority, int attributes) { + if (mpPlatformObj == 0) return; + ai::Brain* brain = mpPlatformObj->GetBrain(); wxASSERT(brain); *************** *** 901,904 **** --- 965,970 ---- void tcPlatformInterface::AddNavWaypoint(float afLon_rad, float afLat_rad) { + if (mpPlatformObj == 0) return; + if (mpPlatformObj->IsClientMode()) return; *************** *** 919,922 **** --- 985,990 ---- void tcPlatformInterface::EditNavWaypoint(size_t idx, float afLon_rad, float afLat_rad) { + if (mpPlatformObj == 0) return; + if (mpPlatformObj->IsClientMode()) return; *************** *** 933,936 **** --- 1001,1006 ---- unsigned int tcPlatformInterface::GetCurrentWaypoint() const { + if (mpPlatformObj == 0) return 0; + if (mpPlatformObj->IsClientMode()) return 0; *************** *** 948,951 **** --- 1018,1023 ---- void tcPlatformInterface::SetNavLoopState(bool state) { + if (mpPlatformObj == 0) return; + if (mpPlatformObj->IsClientMode()) return; *************** *** 968,971 **** --- 1040,1045 ---- void tcPlatformInterface::ClearTasks() { + if (mpPlatformObj == 0) return; + if (mpPlatformObj->IsClientMode()) return; *************** *** 978,981 **** --- 1052,1057 ---- void tcPlatformInterface::DeleteTask(const std::string& taskName) { + if (mpPlatformObj == 0) return; + if (mpPlatformObj->IsClientMode()) return; *************** *** 991,994 **** --- 1067,1075 ---- ai::BlackboardInterface tcPlatformInterface::GetBlackboardInterface() { + static ai::Blackboard errorBoard; + static ai::BlackboardInterface errorInterface(&errorBoard, -1, 0); + + if (mpPlatformObj == 0) return errorInterface; + ai::Brain* brain = mpPlatformObj->GetBrain(); wxASSERT(brain); *************** *** 999,1002 **** --- 1080,1085 ---- bool tcPlatformInterface::TaskExists(const std::string& taskName) { + if (mpPlatformObj == 0) return false; + ai::Brain* brain = mpPlatformObj->GetBrain(); wxASSERT(brain); *************** *** 1254,1257 **** --- 1337,1342 ---- float tcPlatformInterface::GetInterceptHeadingToTrack(const tcSensorMapTrack& track) { + if (mpPlatformObj == 0) return 0; + float fHeading_rad, fTTI; *************** *** 1266,1269 **** --- 1351,1355 ---- float tcPlatformInterface::GetRangeToTrack(const tcSensorMapTrack& track) { + if (mpPlatformObj == 0) return 0; wxASSERT(mpPlatformObj); *************** *** 1279,1282 **** --- 1365,1369 ---- float tcPlatformInterface::SetHeadingToInterceptTrack(tcSensorMapTrack track) { + if (mpPlatformObj == 0) return 0; if (!mpPlatformObj->IsControlled()) return 0; float fHeading_rad, fTTI; *************** *** 1292,1295 **** --- 1379,1384 ---- tcSensorMapTrack track; + if (mpPlatformObj == 0) return track; + mpSimState->GetTrack(id, mpPlatformObj->GetAlliance(), track); *************** *** 1301,1304 **** --- 1390,1395 ---- int tcPlatformInterface::GetSensorCount() { + if (mpPlatformObj == 0) return 0; + return (int)mpPlatformObj->GetSensorCount(); } *************** *** 1310,1313 **** --- 1401,1406 ---- info.type = 0xFF; + if (mpPlatformObj == 0) return info; + unsigned nSensors = mpPlatformObj->GetSensorCount(); if ((n < 0)||((unsigned)n >= nSensors)) return info; *************** *** 1349,1352 **** --- 1442,1447 ---- void tcPlatformInterface::SetAllSensorState(int anState) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsControlled()) return; unsigned nSensors = mpPlatformObj->GetSensorCount(); *************** *** 1360,1363 **** --- 1455,1460 ---- void tcPlatformInterface::SetSensorState(int n, int state) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsControlled()) return; mpPlatformObj->SetSensorState((unsigned)n, state != 0); *************** *** 1367,1370 **** --- 1464,1469 ---- std::string tcPlatformInterface::GetController() const { + if (mpPlatformObj == 0) return std::string("Error, not platform"); + return std::string(mpPlatformObj->GetController()); } *************** *** 1372,1375 **** --- 1471,1476 ---- bool tcPlatformInterface::IsAvailable() const { + if (mpPlatformObj == 0) return false; + return mpPlatformObj->IsAvailable(); } *************** *** 1382,1385 **** --- 1483,1488 ---- void tcPlatformInterface::ReleaseControl() { + if (mpPlatformObj == 0) return; + using network::tcMultiplayerInterface; if (mpPlatformObj->IsControlled()) *************** *** 1399,1402 **** --- 1502,1507 ---- void tcPlatformInterface::TakeControl() { + if (mpPlatformObj == 0) return; + using network::tcMultiplayerInterface; if (mpPlatformObj->IsAvailable()) *************** *** 1417,1420 **** --- 1522,1527 ---- double tcPlatformInterface::GetTime() const { + if (mpPlatformObj == 0) return -123.4; + wxASSERT(mpPlatformObj); return mpPlatformObj->mfStatusTime; *************** *** 1434,1437 **** --- 1541,1546 ---- bool tcPlatformInterface::IsPlayerControlled() const { + if (mpPlatformObj == 0) return false; + // single player, check for alliance match only if (!mpSimState->IsMultiplayerActive()) *************** *** 1447,1450 **** --- 1556,1561 ---- long tcPlatformInterface::LookupFriendlyId(const std::string& unitName) { + if (mpPlatformObj == 0) return -1; + tcGameObject* obj = mpSimState->GetObjectByName(unitName); bool isOwnAlliance = (obj != 0) && (mpPlatformObj->GetAlliance() == obj->GetAlliance()); *************** *** 1462,1465 **** --- 1573,1578 ---- std::string tcPlatformInterface::LookupFriendlyName(long id) { + if (mpPlatformObj == 0) return "Error, not platform"; + tcGameObject* obj = mpSimState->GetObject(id); bool isOwnAlliance = (obj != 0) && (mpPlatformObj->GetAlliance() == obj->GetAlliance()); *************** *** 1549,1552 **** --- 1662,1667 ---- void tcPlatformInterface::SetActionText(const std::string& text) { + if (mpPlatformObj == 0) return; + mpPlatformObj->mcAI.mzActionText = text; } *************** *** 1573,1576 **** --- 1688,1695 ---- tcTrack tcPlatformInterface::GetLandingData(long id) { + static tcTrack errorTrack; + + if (mpPlatformObj == 0) return errorTrack; + tcGameObject* obj = mpSimState->GetObject(id); *************** *** 1626,1629 **** --- 1745,1750 ---- void tcPlatformInterface::DeletePlatform() { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsEditMode()) return; *************** *** 1634,1637 **** --- 1755,1760 ---- void tcPlatformInterface::MovePlatform(float afLon_rad, float afLat_rad) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsEditMode()) return; *************** *** 1642,1645 **** --- 1765,1770 ---- void tcPlatformInterface::RenamePlatform(const std::string& s) { + if (mpPlatformObj == 0) return; + if (!mpPlatformObj->IsEditMode()) return; |