[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.134,1.135 tcLauncher.cpp,1.24,1.25 tcLauncherState.cpp,1.
Status: Alpha
Brought to you by:
ddcforge
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21991/src/sim Modified Files: Game.cpp tcLauncher.cpp tcLauncherState.cpp tcObjectControl.cpp tcPlatformObject.cpp tcSensorPlatform.cpp tcSubObject.cpp Log Message: Fixed bug with crashing when too many range circles were displayed Index: tcSubObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSubObject.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcSubObject.cpp 29 Apr 2005 18:52:56 -0000 1.8 --- tcSubObject.cpp 25 Jun 2005 22:10:36 -0000 1.9 *************** *** 262,265 **** --- 262,274 ---- SetRadarMastState(false); } + else if (mcKin.mfAlt_m <= 0) // restrict speed near surface + { + float maxSpeed = (0.5f - 0.5f*invPeriscopeDepth*mcKin.mfAlt_m) * + mpDBObject->mfMaxSpeed_kts; + if (mcKin.mfSpeed_kts > maxSpeed) + { + mcKin.mfSpeed_kts = maxSpeed; + } + } else if (mcKin.mfAlt_m > 0) { *************** *** 531,534 **** --- 540,545 ---- { mnModelType = MTYPE_SUBMARINE; + invPeriscopeDepth = 1.0f / periscopeDepth_m; + SetAltitude(-100.0f); SetHeading(75.0f); *************** *** 543,550 **** maxPitch_rad(0.5), periscopeDepth_m(18), ! doneSinking(false) { - mpDBObject = obj; mnModelType = MTYPE_SUBMARINE; } --- 554,563 ---- maxPitch_rad(0.5), periscopeDepth_m(18), ! doneSinking(false), ! mpDBObject(obj) { mnModelType = MTYPE_SUBMARINE; + + invPeriscopeDepth = 1.0f / periscopeDepth_m; } Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** tcLauncherState.cpp 22 Jun 2005 01:22:09 -0000 1.32 --- tcLauncherState.cpp 25 Jun 2005 22:10:36 -0000 1.33 *************** *** 2,6 **** ** @file tcLauncherState.cpp */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** --- 2,6 ---- ** @file tcLauncherState.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** *************** *** 41,54 **** #endif ! tcDatabase* tcLauncherState::mpDatabase = NULL; ! tcSimState* tcLauncherState::simState = NULL; - /* - class tcGame - { - public: - static void DisplayMessage(const char* msg); - }; - */ /** --- 41,48 ---- #endif ! tcDatabase* tcLauncherState::mpDatabase = 0; ! tcSimState* tcLauncherState::simState = 0; ! /** *************** *** 481,519 **** } - #if 0 - /** - * Load state from stream - */ - tcStream& tcLauncherState::operator<<(tcStream& buffer) - { - launchers.clear(); - - buffer >> mnCount; - for(int n = 0; n < mnCount; n++) - { - tcLauncher ldata; - ldata << buffer; - launchers.push_back(ldata); - } - - return buffer; - } - - /** - * Save state to stream - */ - tcStream& tcLauncherState::operator>>(tcStream& buffer) - { - buffer << mnCount; - for(int n = 0; n < mnCount; n++) - { - tcLauncher& ldata = launchers[n]; - ldata >> buffer; - } - - return buffer; - } - - #endif --- 475,478 ---- *************** *** 614,628 **** */ tcLauncherState::tcLauncherState() { - mnCount = 0; - launchers.clear(); - parent = NULL; } tcLauncherState::tcLauncherState(tcGameObject *parentObj) ! : parent(parentObj), mnCount(0) { - //launchers.clear(); } --- 573,585 ---- */ tcLauncherState::tcLauncherState() + : mnCount(0), + parent(0) { } tcLauncherState::tcLauncherState(tcGameObject *parentObj) ! : parent(parentObj), mnCount(0) { } *************** *** 630,634 **** * */ ! tcLauncherState::tcLauncherState(tcLauncherState& lstate) { for(unsigned i=0;i<lstate.launchers.size();i++) --- 587,592 ---- * */ ! tcLauncherState::tcLauncherState(tcLauncherState& lstate) ! : parent(0) { for(unsigned i=0;i<lstate.launchers.size();i++) *************** *** 637,641 **** } mnCount = (int)launchers.size(); - parent = NULL; } --- 595,598 ---- *************** *** 650,652 **** } ! } \ No newline at end of file --- 607,609 ---- } ! } Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.134 retrieving revision 1.135 diff -C2 -d -r1.134 -r1.135 *** Game.cpp 22 Jun 2005 01:22:09 -0000 1.134 --- Game.cpp 25 Jun 2005 22:10:36 -0000 1.135 *************** *** 1852,1855 **** --- 1852,1857 ---- tcMultiplayerInterface::Get()->Update(); + tcSimPythonInterface::Get()->Update(); + return mbQuit; } Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tcLauncher.cpp 22 Jun 2005 01:22:09 -0000 1.24 --- tcLauncher.cpp 25 Jun 2005 22:10:36 -0000 1.25 *************** *** 1,5 **** ! /** @file tcLauncher.cpp */ ! /* Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** --- 1,6 ---- ! /** ! ** @file tcLauncher.cpp */ ! /* Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. ** *************** *** 247,262 **** * @see IsItemCompatible */ ! unsigned int tcLauncher::GetCapacityForItem(const std::string& item) const { ! unsigned nTypes = GetCompatibleCount(); ! for (unsigned k=0; k<nTypes; k++) ! { ! if (item == mpLauncherDBObj->maChildClass[k].mz) ! { ! return mpLauncherDBObj->maCapacity[k]; ! } ! } ! ! return 0; } --- 248,254 ---- * @see IsItemCompatible */ ! unsigned short tcLauncher::GetCapacityForItem(const std::string& item) const { ! return mpLauncherDBObj->GetCapacityForItem(item); } *************** *** 267,271 **** { wxASSERT(mpLauncherDBObj); ! return mpLauncherDBObj->mnConfigurations; } --- 259,263 ---- { wxASSERT(mpLauncherDBObj); ! return mpLauncherDBObj->GetNumberConfigurations(); } *************** *** 280,293 **** wxASSERT(mpLauncherDBObj); ! if (idx >= mpLauncherDBObj->mnConfigurations) { s = ""; } else { ! s = mpLauncherDBObj->maChildClass[idx].mz; } - - return s; } --- 272,284 ---- wxASSERT(mpLauncherDBObj); ! if (idx >= mpLauncherDBObj->GetNumberConfigurations()) { s = ""; + return s; } else { ! return mpLauncherDBObj->GetConfigurationClass(idx); } } *************** *** 300,304 **** unsigned int tcLauncher::GetCompatibleQuantity(unsigned int idx) const { ! if (idx >= mpLauncherDBObj->mnConfigurations) { return 0; --- 291,295 ---- unsigned int tcLauncher::GetCompatibleQuantity(unsigned int idx) const { ! if (idx >= mpLauncherDBObj->GetNumberConfigurations()) { return 0; *************** *** 306,310 **** else { ! return mpLauncherDBObj->maCapacity[idx]; } } --- 297,301 ---- else { ! return mpLauncherDBObj->GetConfigurationCapacity(idx); } } *************** *** 419,432 **** bool tcLauncher::IsItemCompatible(const std::string& item) const { ! unsigned nTypes = GetCompatibleCount(); ! for (unsigned k=0; k<nTypes; k++) ! { ! if (GetCompatibleName(k) == item) ! { ! return true; ! } ! } ! return false; } --- 410,416 ---- bool tcLauncher::IsItemCompatible(const std::string& item) const { ! unsigned short capacity = mpLauncherDBObj->GetCapacityForItem(item); ! return capacity != 0; } *************** *** 879,884 **** wxASSERT(simState); ! SetChildClass(dbObj->mzChildClass.mz); ! SetChildQuantity(capacity); } --- 863,868 ---- wxASSERT(simState); ! SetChildClass(dbObj->GetDefaultChildClass()); ! SetChildQuantity(dbObj->GetDefaultChildCapacity()); } *************** *** 887,948 **** } - - #if 0 - /** - * Load state from stream - */ - tcStream& tcLauncher::operator<<(tcStream& buffer) - { - buffer >> mbActive; - buffer >> mnDBKey; - buffer >> mnChildDBKey; - - buffer >> mfTimeToReady; - buffer >> mnCurrent; - buffer >> mnPending; - - msDatum << buffer; - - buffer >> mnTargetID; - - int temp; - buffer >> temp; - meLaunchMode = (database::teWeaponLaunchMode)temp; - - buffer >> mnTargetFlags; - buffer >> pointingAngle; - buffer >> pointingElevation; - buffer >> fireControlSensorIdx; - - return buffer; - } - - /** - * Save state to stream - */ - tcStream& tcLauncher::operator >>(tcStream& buffer) - { - buffer << mbActive; - buffer << mnDBKey; - buffer << mnChildDBKey; - - buffer << mfTimeToReady; - buffer << mnCurrent; - buffer << mnPending; - - msDatum >> buffer; - - buffer << mnTargetID; - - int temp = (int)meLaunchMode; - buffer << temp; - - buffer << mnTargetFlags; - buffer << pointingAngle; - buffer << pointingElevation; - buffer << fireControlSensorIdx; - - return buffer; - } - - #endif --- 871,872 ---- Index: tcSensorPlatform.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorPlatform.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcSensorPlatform.cpp 22 Jun 2005 01:22:10 -0000 1.6 --- tcSensorPlatform.cpp 25 Jun 2005 22:10:36 -0000 1.7 *************** *** 58,61 **** --- 58,62 ---- wxString tcSensorPlatform::GetSensorDescription() { + static std::string errorString = "Error"; wxString description; *************** *** 63,69 **** for (unsigned n=0; n < nSensors; n++) { const tcSensorState* sensor = GetSensor(n); ! description += wxString::Format("%s\n", ! sensor->mpDBObj->mzClass.mz); } --- 64,73 ---- for (unsigned n=0; n < nSensors; n++) { + const tcSensorState* sensor = GetSensor(n); ! ! const char* text = (sensor != 0) && (sensor->mpDBObj != 0) ? ! sensor->mpDBObj->mzClass.mz : errorString.c_str(); ! description += wxString::Format("%s\n", text); } Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** tcPlatformObject.cpp 22 Jun 2005 01:22:09 -0000 1.49 --- tcPlatformObject.cpp 25 Jun 2005 22:10:36 -0000 1.50 *************** *** 342,345 **** --- 342,346 ---- wxString tcPlatformObject::GetLauncherDescription() { + static std::string errorString = "Error"; wxString description; *************** *** 348,355 **** { tcLauncher* launcher = GetLauncher(n); description += wxString::Format("%s, %d x %s\n", launcher->mpLauncherDBObj->mzClass.mz, launcher->mnCurrent, ! launcher->mpChildDBObj->mzClass.mz); } --- 349,360 ---- { tcLauncher* launcher = GetLauncher(n); + + const char* childClassName = (launcher->mpChildDBObj != 0) ? launcher->mpChildDBObj->mzClass.mz : + errorString.c_str(); + description += wxString::Format("%s, %d x %s\n", launcher->mpLauncherDBObj->mzClass.mz, launcher->mnCurrent, ! childClassName); } *************** *** 911,916 **** size_t nSensors = tcSensorPlatform::GetSensorCount(); ! // ! for(int nLauncher=0; nLauncher<mpDBObject->mnNumLaunchers; nLauncher++) { std::string fcSensor = --- 916,921 ---- size_t nSensors = tcSensorPlatform::GetSensorCount(); ! size_t nLaunchers = mcLauncherState.GetLauncherCount(); ! for(size_t nLauncher=0; nLauncher<nLaunchers; nLauncher++) { std::string fcSensor = Index: tcObjectControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcObjectControl.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** tcObjectControl.cpp 22 Jun 2005 01:22:09 -0000 1.38 --- tcObjectControl.cpp 25 Jun 2005 22:10:36 -0000 1.39 *************** *** 1555,1558 **** --- 1555,1563 ---- } + const std::vector<MapSymbolInfo>& tcObjectControl::GetMapSymbols() const + { + return symbolList; + } + /******************************************************************************/ void tcObjectControl::InitControls() *************** *** 1676,1680 **** void tcObjectControl::UpdateSymbolList() { ! msOCSymbolList.mnSymbols = 0; if (mpHookedGameObj == 0) --- 1681,1685 ---- void tcObjectControl::UpdateSymbolList() { ! symbolList.clear(); if (mpHookedGameObj == 0) *************** *** 1702,1743 **** } ! int nSensors = (int)platformObj->GetSensorCount(); ! int k = msOCSymbolList.mnSymbols; ! for(int i=0; i<nSensors; i++) { ! const tcSensorState* pSensorState = platformObj->GetSensor(i); const tcRadar* pRadarSS = dynamic_cast<const tcRadar*>(pSensorState); bool bActive = pSensorState->IsActive() ? true : false; if ((pRadarSS)&&(bActive)) { ! msOCSymbolList.maSymbol[k].mfLat_rad = (float)mpHookedGameObj->mcKin.mfLat_rad; ! msOCSymbolList.maSymbol[k].mfLon_rad = (float)mpHookedGameObj->mcKin.mfLon_rad; float fRangeX_rad = 2.0f*pRadarSS->mpDBObj->mfRefRange_km*C_KMTORAD/ cosf((float)mpHookedGameObj->mcKin.mfLat_rad); float fRangeY_rad = 2.0f*pRadarSS->mpDBObj->mfRefRange_km*C_KMTORAD; ! msOCSymbolList.maSymbol[k].mfLatExtent_rad = fRangeY_rad; ! msOCSymbolList.maSymbol[k].mfLonExtent_rad = fRangeX_rad; float sensorAz_deg = (mpHookedGameObj->mcKin.mfHeading_rad + pRadarSS->mountAz_rad) * C_180OVERPI; ! msOCSymbolList.maSymbol[k].mfArcCenter_deg = sensorAz_deg; // wrt North ! msOCSymbolList.maSymbol[k].mfArcLength_deg = pRadarSS->mpDBObj->mfFieldOfView_deg; ! if (msOCSymbolList.maSymbol[k].mfArcLength_deg < 360.0f) { ! msOCSymbolList.maSymbol[k].mfArcLength_deg *= 0.95f; // sector distortion issue, lat based? } bool bDetectsAir = pRadarSS->mpDBObj->mbDetectsAir; bool bDetectsPlatform = pRadarSS->mpDBObj->mbDetectsSurface; if (bDetectsAir) { ! msOCSymbolList.maSymbol[k].mnColor = bDetectsPlatform ? 0x80FFFF88 : 0x808888FF; } else { ! msOCSymbolList.maSymbol[k].mnColor = 0x8088FF88; } ! k++; } } - msOCSymbolList.mnSymbols = k; } --- 1707,1754 ---- } ! size_t nSensors = platformObj->GetSensorCount(); ! ! for(size_t n=0; n<nSensors; n++) { ! const tcSensorState* pSensorState = platformObj->GetSensor(n); const tcRadar* pRadarSS = dynamic_cast<const tcRadar*>(pSensorState); + wxASSERT(pSensorState); bool bActive = pSensorState->IsActive() ? true : false; if ((pRadarSS)&&(bActive)) { ! MapSymbolInfo symbol; ! ! symbol.mfLat_rad = (float)mpHookedGameObj->mcKin.mfLat_rad; ! symbol.mfLon_rad = (float)mpHookedGameObj->mcKin.mfLon_rad; ! float fRangeX_rad = 2.0f*pRadarSS->mpDBObj->mfRefRange_km*C_KMTORAD/ cosf((float)mpHookedGameObj->mcKin.mfLat_rad); float fRangeY_rad = 2.0f*pRadarSS->mpDBObj->mfRefRange_km*C_KMTORAD; ! symbol.mfLatExtent_rad = fRangeY_rad; ! symbol.mfLonExtent_rad = fRangeX_rad; ! float sensorAz_deg = (mpHookedGameObj->mcKin.mfHeading_rad + pRadarSS->mountAz_rad) * C_180OVERPI; ! symbol.mfArcCenter_deg = sensorAz_deg; // wrt North ! symbol.mfArcLength_deg = pRadarSS->mpDBObj->mfFieldOfView_deg; ! if (symbol.mfArcLength_deg < 360.0f) { ! symbol.mfArcLength_deg *= 0.95f; // sector distortion issue, lat based? } + bool bDetectsAir = pRadarSS->mpDBObj->mbDetectsAir; bool bDetectsPlatform = pRadarSS->mpDBObj->mbDetectsSurface; if (bDetectsAir) { ! symbol.mnColor = bDetectsPlatform ? 0x80FFFF88 : 0x808888FF; } else { ! symbol.mnColor = 0x8088FF88; } ! ! symbolList.push_back(symbol); } } } *************** *** 1751,1755 **** unsigned int nLaunchers = platformObj->GetLauncherCount(); ! int k = msOCSymbolList.mnSymbols; for(unsigned int i=0; i<nLaunchers; i++) { --- 1762,1766 ---- unsigned int nLaunchers = platformObj->GetLauncherCount(); ! for(unsigned int i=0; i<nLaunchers; i++) { *************** *** 1757,1762 **** if ((launcher->mnCurrent > 0) && !launcher->IsDamaged()) { ! msOCSymbolList.maSymbol[k].mfLat_rad = (float)mpHookedGameObj->mcKin.mfLat_rad; ! msOCSymbolList.maSymbol[k].mfLon_rad = (float)mpHookedGameObj->mcKin.mfLon_rad; float range_km = 0; --- 1768,1775 ---- if ((launcher->mnCurrent > 0) && !launcher->IsDamaged()) { ! MapSymbolInfo symbol; ! ! symbol.mfLat_rad = (float)mpHookedGameObj->mcKin.mfLat_rad; ! symbol.mfLon_rad = (float)mpHookedGameObj->mcKin.mfLon_rad; float range_km = 0; *************** *** 1773,1777 **** { range_km = ballisticDBObj->maxRange_km; ! color = 0xFFB04010; } else if (tcTorpedoDBObject* torpDBObj = --- 1786,1790 ---- { range_km = ballisticDBObj->maxRange_km; ! color = 0xFFB04010; } else if (tcTorpedoDBObject* torpDBObj = *************** *** 1787,1792 **** float fRangeY_rad = 2.0f* range_km * C_KMTORAD; ! msOCSymbolList.maSymbol[k].mfLatExtent_rad = fRangeY_rad; ! msOCSymbolList.maSymbol[k].mfLonExtent_rad = fRangeX_rad; float az_deg = C_180OVERPI * (launcher->GetSectorCenter() + --- 1800,1805 ---- float fRangeY_rad = 2.0f* range_km * C_KMTORAD; ! symbol.mfLatExtent_rad = fRangeY_rad; ! symbol.mfLonExtent_rad = fRangeX_rad; float az_deg = C_180OVERPI * (launcher->GetSectorCenter() + *************** *** 1797,1810 **** fov_deg *= 0.95f; // sector distortion issue, lat based? } ! msOCSymbolList.maSymbol[k].mfArcCenter_deg = az_deg; // wrt North ! msOCSymbolList.maSymbol[k].mfArcLength_deg = fov_deg; ! msOCSymbolList.maSymbol[k].mnColor = color; ! if (range_km > 0) k++; } } - msOCSymbolList.mnSymbols = k++; } --- 1810,1825 ---- fov_deg *= 0.95f; // sector distortion issue, lat based? } ! symbol.mfArcCenter_deg = az_deg; // wrt North ! symbol.mfArcLength_deg = fov_deg; ! symbol.mnColor = color; ! if (range_km > 0) ! { ! symbolList.push_back(symbol); ! } } } } *************** *** 1817,1837 **** const wxPoint& pos, const wxSize& size, const wxString& name) : ! tc3DWindow(parent, pos, size, name, 0) { - mnHookID = NULL_INDEX; - mnPreviousHookID = NULL_INDEX; - mpSS = tcSimState::Get(); mpCommandInterface = tcCommandQueue::Get(); - mnLaunchers = 0; - mpHookedGameObj = NULL; - mpUserInfo = NULL; - msOCSymbolList.mnSymbols = 0; - mpOptions = tcOptions::Get(); InitControls(); - } --- 1832,1848 ---- const wxPoint& pos, const wxSize& size, const wxString& name) : ! tc3DWindow(parent, pos, size, name, 0), ! mnHookID(NULL_INDEX), ! mnPreviousHookID(NULL_INDEX), ! mnLaunchers(0), ! mpHookedGameObj(0), ! mpUserInfo(0) { mpSS = tcSimState::Get(); mpCommandInterface = tcCommandQueue::Get(); mpOptions = tcOptions::Get(); InitControls(); } |