[Gcblue-commits] gcb_wx/src/sim tcLauncher.cpp,1.11,1.12 tcMenu.cpp,1.11,1.12 tcObjectControl.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-serv15614/src/sim Modified Files: tcLauncher.cpp tcMenu.cpp tcObjectControl.cpp tcOpticalSensor.cpp tcRadar.cpp tcSensorMap.cpp tcSimState.cpp tcTorpedoObject.cpp Log Message: Better sensor ageout behavior, more ai work, misc cleanup Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** tcSimState.cpp 24 Feb 2005 22:19:16 -0000 1.67 --- tcSimState.cpp 2 Mar 2005 22:28:45 -0000 1.68 *************** *** 55,58 **** --- 55,59 ---- #include "common/tcStream.h" #include "tcMessageInterface.h" + #include "tcPositionRegistry.h" #ifdef _DEBUG *************** *** 65,69 **** using namespace ScriptInterface; [...1013 lines suppressed...] } ! /********************************************************************/ --- 2550,2566 ---- s.Format("tcSimState size: %d kB",sizeof(tcSimState)/1024); WTL(s.GetBuffer()); + #endif } ! ! /** ! * ! */ tcSimState::~tcSimState() { Clear(); if (goalTracker) delete goalTracker; + if (positionRegistry) delete positionRegistry; } ! ! Index: tcOpticalSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcOpticalSensor.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcOpticalSensor.cpp 27 Jan 2005 01:02:06 -0000 1.5 --- tcOpticalSensor.cpp 2 Mar 2005 22:28:45 -0000 1.6 *************** *** 426,430 **** wxASSERT(parent); ! if ((mnMode == SSMODE_SURVEILLANCE) || (mnMode == SSMODE_FCSURVEILLANCE)) { UpdateSurveillance(t); --- 426,430 ---- wxASSERT(parent); ! if (mnMode == SSMODE_SURVEILLANCE) { UpdateSurveillance(t); *************** *** 453,457 **** wxASSERT(dbObj); ! mnMode = mpDBObj->mbDetectsAir ? SSMODE_FCSURVEILLANCE : SSMODE_SURVEILLANCE; mfSensorHeight_m = 10.0f; mbActive = true; // optical defaults to always on --- 453,457 ---- wxASSERT(dbObj); ! mnMode = dbObj->isSurveillance ? SSMODE_SURVEILLANCE : SSMODE_FC; mfSensorHeight_m = 10.0f; mbActive = true; // optical defaults to always on Index: tcTorpedoObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcTorpedoObject.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcTorpedoObject.cpp 24 Feb 2005 22:19:16 -0000 1.5 --- tcTorpedoObject.cpp 2 Mar 2005 22:28:45 -0000 1.6 *************** *** 370,374 **** mcKin.mfSpeed_kts = C_MPSTOKTS * sqrtf(vz_mps*vz_mps + vxy_mps*vxy_mps); ! if (mcKin.mfAlt_m <= 0) mcKin.mfSpeed_kts *= 0.1f; // lose speed after hitting water --- 370,378 ---- mcKin.mfSpeed_kts = C_MPSTOKTS * sqrtf(vz_mps*vz_mps + vxy_mps*vxy_mps); ! if (mcKin.mfAlt_m <= 0) ! { ! mcKin.mfSpeed_kts *= 0.1f; // lose speed after hitting water ! if (mcKin.mfSpeed_kts < 5.0) mcKin.mfSpeed_kts = 5.0f; ! } Index: tcMenu.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMenu.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcMenu.cpp 1 Feb 2005 02:29:15 -0000 1.11 --- tcMenu.cpp 2 Mar 2005 22:28:45 -0000 1.12 *************** *** 449,453 **** tcMenu::tcMenu() ! : fontSize(16.0) { maMenuData.clear(); --- 449,453 ---- tcMenu::tcMenu() ! : fontSize(14.0) { maMenuData.clear(); *************** *** 463,467 **** tcMenu::tcMenu(tcMenu* apParent) ! : fontSize(16.0) { maMenuData.clear(); --- 463,467 ---- tcMenu::tcMenu(tcMenu* apParent) ! : fontSize(14.0) { maMenuData.clear(); Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** tcRadar.cpp 21 Feb 2005 18:26:26 -0000 1.25 --- tcRadar.cpp 2 Mar 2005 22:28:45 -0000 1.26 *************** *** 233,237 **** return false; } ! mnMode = mpDBObj->mbDetectsAir ? SSMODE_FCSURVEILLANCE : SSMODE_SURVEILLANCE; mfSensorHeight_m = 10.0f; --- 233,244 ---- return false; } ! if (mpDBObj->isSurveillance) ! { ! mnMode = SSMODE_SURVEILLANCE; ! } ! else ! { ! mnMode = SSMODE_FC; ! } mfSensorHeight_m = 10.0f; *************** *** 565,569 **** wxASSERT(parent); ! if ((mnMode == SSMODE_SURVEILLANCE) || (mnMode == SSMODE_FCSURVEILLANCE)) { UpdateSurveillance(t); --- 572,576 ---- wxASSERT(parent); ! if (mnMode == SSMODE_SURVEILLANCE) { UpdateSurveillance(t); *************** *** 592,596 **** wxASSERT(dbObj); ! mnMode = mpDBObj->mbDetectsAir ? SSMODE_FCSURVEILLANCE : SSMODE_SURVEILLANCE; mfSensorHeight_m = 10.0f; --- 599,611 ---- wxASSERT(dbObj); ! if (dbObj->isSurveillance) ! { ! mnMode = SSMODE_SURVEILLANCE; ! } ! else ! { ! mnMode = SSMODE_FC; // do not do surveillance updates ! } ! mfSensorHeight_m = 10.0f; Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcLauncher.cpp 18 Feb 2005 17:41:51 -0000 1.11 --- tcLauncher.cpp 2 Mar 2005 22:28:44 -0000 1.12 *************** *** 285,289 **** // TODO: called here as quick way to add autopoint feature, move to better location ! if (IsAutoPoint()) { pointingAngle = parent->BearingToRad(*targetObj) - parent->mcKin.mfHeading_rad; --- 285,289 ---- // TODO: called here as quick way to add autopoint feature, move to better location ! if (IsAutoPoint() && (targetObj != 0)) { pointingAngle = parent->BearingToRad(*targetObj) - parent->mcKin.mfHeading_rad; Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcSensorMap.cpp 2 Dec 2004 04:17:27 -0000 1.14 --- tcSensorMap.cpp 2 Mar 2005 22:28:45 -0000 1.15 *************** *** 40,43 **** --- 40,57 ---- tcSimState* tcSensorMapTrack::simState = NULL; unsigned int tcSensorMapTrack::ambiguityListUpdates = 0; + bool tcSensorMapTrack::autoKillAssess = false; + + + /** + * Set to true to automatically check and mark stale tracks that + * are destroyed. + */ + void tcSensorMapTrack::SetAutoKillAssess(bool state) + { + autoKillAssess = state; + } + + + /** *************** *** 71,75 **** /* - double mfLastUpdateTime; tcSensorReport maSensorReport[MAX_SENSOR_REPORTS]; // most recent data from contributing sensors int mnContributors; --- 85,88 ---- *************** *** 127,137 **** } - mfLastUpdateTime = 0; mnContributors = 0; mnEmitters = 0; mnDatabaseID = -1; ! matchupRating = 0; ! expectedDamage = 0; ! assessedDamage = 0; intercepts.clear(); engaged.clear(); --- 140,147 ---- } mnContributors = 0; mnEmitters = 0; mnDatabaseID = -1; ! assessedDamage = 0; intercepts.clear(); engaged.clear(); *************** *** 232,236 **** ! bool tcSensorMapTrack::UpdateActiveReport(Sensor::tcSensorReport*& rpReport, tnPoolIndex anSensorID) { int nPassiveIdx = -1; --- 242,247 ---- ! bool tcSensorMapTrack::UpdateActiveReport(Sensor::tcSensorReport*& rpReport, tnPoolIndex anSensorID) ! { int nPassiveIdx = -1; *************** *** 251,255 **** // add new report if there is room ! if (mnContributors < MAX_SENSOR_REPORTS) { tcSensorReport *pSensorReport = &maSensorReport[mnContributors++]; pSensorReport->Clear(); --- 262,267 ---- // add new report if there is room ! if (mnContributors < MAX_SENSOR_REPORTS) ! { tcSensorReport *pSensorReport = &maSensorReport[mnContributors++]; pSensorReport->Clear(); *************** *** 260,264 **** // overwrite passive with active if one exists ! if (nPassiveIdx >= 0) { tcSensorReport *pSensorReport = &maSensorReport[nPassiveIdx]; pSensorReport->Clear(); --- 272,277 ---- // overwrite passive with active if one exists ! if (nPassiveIdx >= 0) ! { tcSensorReport *pSensorReport = &maSensorReport[nPassiveIdx]; pSensorReport->Clear(); *************** *** 402,410 **** /** * check for update reports and update track */ void tcSensorMapTrack::UpdateTrack() { ! //bool bUpdated = false; // find first new active report since last update and update track --- 415,449 ---- /** + * Queries simState to check if track object exists. If + * not the track is marked as destroyed. + * This assumes that the track id matches the simState object + * id. This assumption will be invalid someday once the two + * sets of ids are decoupled. + * TODO repair for this + */ + void tcSensorMapTrack::KillAssess() + { + if (simState->GetObject(mnID) == 0) + { + MarkDestroyed(); + #ifdef _DEBUG + fprintf(stdout, "Track %d marked destroyed\n", mnID); + #endif + } + } + + /** * check for update reports and update track */ void tcSensorMapTrack::UpdateTrack() { ! ! if (autoKillAssess) ! { ! if (IsStale() && !IsDestroyed()) ! { ! KillAssess(); ! } ! } // find first new active report since last update and update track *************** *** 482,485 **** --- 521,551 ---- } + bool tcSensorMapTrack::IsDestroyed() const + { + return (sensorFlags & TRACK_DESTROYED) != 0; + } + + bool tcSensorMapTrack::IsStale() const + { + return (sensorFlags & TRACK_STALE) != 0; + } + + void tcSensorMapTrack::MarkDestroyed() + { + sensorFlags |= TRACK_DESTROYED; + } + + void tcSensorMapTrack::MarkStale() + { + sensorFlags |= TRACK_STALE; + } + + void tcSensorMapTrack::ClearStale() + { + sensorFlags &= (~TRACK_STALE); + } + + + tcSensorMapTrack& tcSensorMapTrack::operator= (const tcSensorMapTrack& t) *************** *** 487,491 **** *(tcTrack*)this = t ; - mfLastUpdateTime = t.mfLastUpdateTime; for(int i=0;i<MAX_SENSOR_REPORTS;i++) { --- 553,556 ---- *************** *** 501,514 **** mnEmitters = t.mnEmitters; mnDatabaseID = t.mnDatabaseID; ! matchupRating = t.matchupRating; ! expectedDamage = t.expectedDamage; ! assessedDamage = t.assessedDamage; intercepts = t.intercepts; engaged = t.engaged; return(*this); } ! tcSensorMapTrack::tcSensorMapTrack() { tcTrack::mnID = NULL_INDEX; --- 566,583 ---- mnEmitters = t.mnEmitters; mnDatabaseID = t.mnDatabaseID; ! sensorFlags = t.sensorFlags; intercepts = t.intercepts; engaged = t.engaged; + assessedDamage = t.assessedDamage; return(*this); } ! tcSensorMapTrack::tcSensorMapTrack() ! : sensorFlags(0), ! mnEmitters(0), ! mnContributors(0), ! mnDatabaseID(-1), ! assessedDamage(0) { tcTrack::mnID = NULL_INDEX; *************** *** 518,529 **** tcTrack::mfTimestamp = 0; tcTrack::mnFlags = 0; - mnEmitters = 0; - mnContributors = 0; - mfLastUpdateTime = 0; - - mnDatabaseID = -1; - matchupRating = 0; - expectedDamage = 0; - assessedDamage = 0; } --- 587,590 ---- *************** *** 770,786 **** for(int n=0;(n<psmtrack->mnContributors)&&(!bAgedReport);n++) { ! float ageOutTime = SENSORMAP_AGEOUTTIME; ! if (psmtrack->maSensorReport[n].mnFlags & TRACK_BEARING_ONLY) ! { ! ageOutTime *= 3; ! } ! ! if (afStatusTime - psmtrack->maSensorReport[n].mfTimestamp > ageOutTime) { psmtrack->RemoveReport(n); bAgedReport = true; } } ! if (psmtrack->mnContributors <= 0) { if (psmtrack->mnID >= 0) --- 831,860 ---- for(int n=0;(n<psmtrack->mnContributors)&&(!bAgedReport);n++) { ! double timeSinceUpdate = afStatusTime - psmtrack->maSensorReport[n].mfTimestamp; ! if (timeSinceUpdate >= ageOutTime) { psmtrack->RemoveReport(n); bAgedReport = true; } + else if (timeSinceUpdate >= staleTime) + { + psmtrack->MarkStale(); + if (psmtrack->IsDestroyed() && (timeSinceUpdate >= staleTime + 3.0)) + { + psmtrack->RemoveReport(n); + bAgedReport = true; + } + } + else + { + psmtrack->ClearStale(); + } } ! ! // updated to never drop ground tracks ! bool dropTrack = ((psmtrack->mnContributors <= 0) && (!psmtrack->IsGround())); ! ! ! if (dropTrack) { if (psmtrack->mnID >= 0) *************** *** 898,907 **** tcAllianceSensorMap::tcAllianceSensorMap(unsigned int mapAlliance) ! : alliance(mapAlliance) { Clear(); } ! tcAllianceSensorMap::~tcAllianceSensorMap() { } --- 972,988 ---- tcAllianceSensorMap::tcAllianceSensorMap(unsigned int mapAlliance) ! : alliance(mapAlliance), ! ageOutTime(90.0f), ! staleTime(30.0f) { Clear(); + + bool autoKillAssessment = tcOptions::Get()->OptionStringExists("AutoKillAssessment"); + tcSensorMapTrack::SetAutoKillAssess(autoKillAssessment); + } ! tcAllianceSensorMap::~tcAllianceSensorMap() ! { } *************** *** 982,992 **** ! void tcSensorMap::Clear(void) { int n; ! for(n=0;n<MAX_ALLIANCES;n++) { maMapIdxForAlliance[n] = -1; } ! for(n=0;n<mnMaps;n++) { ! if (mapMap[n] != NULL) { delete mapMap[n]; mapMap[n] = NULL; --- 1063,1077 ---- ! void tcSensorMap::Clear() ! { int n; ! for(n=0;n<MAX_ALLIANCES;n++) ! { maMapIdxForAlliance[n] = -1; } ! for(n=0;n<mnMaps;n++) ! { ! if (mapMap[n] != NULL) ! { delete mapMap[n]; mapMap[n] = NULL; Index: tcObjectControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcObjectControl.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** tcObjectControl.cpp 20 Feb 2005 18:20:20 -0000 1.31 --- tcObjectControl.cpp 2 Mar 2005 22:28:45 -0000 1.32 *************** *** 133,137 **** : brain(0), ! mzCaption("ORDERS STATUS") { } --- 133,137 ---- : brain(0), ! mzCaption("TASK STATUS") { } |