[Gcblue-commits] gcb_wx/src/sim tcSonar.cpp,NONE,1.1 Game.cpp,1.107,1.108 tcGameObject.cpp,1.25,1.26
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:17:41
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/src/sim Modified Files: Game.cpp tcGameObject.cpp tcLauncher.cpp tcLauncherState.cpp tcMenu.cpp tcObjectControl.cpp tcOpticalSensor.cpp tcRadar.cpp tcSensorMap.cpp tcStores.cpp tcSubObject.cpp Added Files: tcSonar.cpp Log Message: Sonar work Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcSensorMap.cpp 6 Nov 2004 15:13:42 -0000 1.13 --- tcSensorMap.cpp 2 Dec 2004 04:17:27 -0000 1.14 *************** *** 718,722 **** } ! #define SENSORMAP_AGEOUTTIME 15.0f void tcAllianceSensorMap::DropTrack(tnPoolIndex anID) --- 718,722 ---- } ! #define SENSORMAP_AGEOUTTIME 30.0f void tcAllianceSensorMap::DropTrack(tnPoolIndex anID) *************** *** 770,774 **** for(int n=0;(n<psmtrack->mnContributors)&&(!bAgedReport);n++) { ! if (afStatusTime - psmtrack->maSensorReport[n].mfTimestamp > SENSORMAP_AGEOUTTIME) { psmtrack->RemoveReport(n); --- 770,780 ---- 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); Index: tcMenu.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMenu.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcMenu.cpp 2 Nov 2004 04:23:57 -0000 1.9 --- tcMenu.cpp 2 Dec 2004 04:17:26 -0000 1.10 *************** *** 116,124 **** maMenuData.push_back(md); } ! else { mpCurrent->AddItem(caption, command, param); } } /* version for user input with callback --- 116,148 ---- maMenuData.push_back(md); } ! else ! { mpCurrent->AddItem(caption, command, param); } } + /** + * Version that accepts std::string param + */ + void tcMenu::AddItem(std::string caption, std::string command, std::string textParam) + { + if (mpCurrent == this) + { + tsMenuData md; + + md.Clear(); + md.mzCaption = caption; + md.mzCommand = command; + md.mzUserInput = ""; + md.mnCommand = -1; + md.textParam = textParam; + maMenuData.push_back(md); + } + else + { + mpCurrent->AddItem(caption, command, textParam); + } + } + /* version for user input with callback Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcLauncher.cpp 29 Nov 2004 03:55:06 -0000 1.6 --- tcLauncher.cpp 2 Dec 2004 04:17:26 -0000 1.7 *************** *** 256,259 **** --- 256,267 ---- * */ + void tcLauncher::SetLoadState(bool state) + { + isLoading = state; + } + + /** + * + */ tcLauncher::tcLauncher() { *************** *** 267,276 **** mpChildDBObj(0), fireControlSensor(0), ! pointingElevation(0) { wxASSERT(dbObj); SetChildClass(dbObj->mzChildClass.mz); - mnCurrent = mpLauncherDBObj->mnCapacity; --- 275,284 ---- mpChildDBObj(0), fireControlSensor(0), ! pointingElevation(0), ! isLoading(false) { wxASSERT(dbObj); SetChildClass(dbObj->mzChildClass.mz); mnCurrent = mpLauncherDBObj->mnCapacity; Index: tcObjectControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcObjectControl.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tcObjectControl.cpp 29 Nov 2004 03:55:06 -0000 1.24 --- tcObjectControl.cpp 2 Dec 2004 04:17:26 -0000 1.25 *************** *** 245,248 **** --- 245,249 ---- osg::Vec4 backgroundColor; osgText::Font* font = context->GetDefaultFont(); + unsigned int blinkCount = tcTime::Get()->Get30HzCount(); switch (aeState) *************** *** 252,256 **** break; case BS_READYING: ! textColor.set(0, 1, 1, 1); break; default: --- 253,260 ---- break; case BS_READYING: ! textColor.set(0, 1, 1, 1); ! break; ! case BS_LOADING: ! textColor.set(1, 1, 1, 1); break; default: *************** *** 268,271 **** --- 272,282 ---- } + // blink button if loading + if ((aeState == BS_LOADING) && (blinkCount % 30 < 15)) + { + backgroundColor.set(0.5*backgroundColor._v[0], 0.5*backgroundColor._v[1], + 0.5*backgroundColor._v[2], backgroundColor._v[3]); + } + context->DrawRectangleR(rectf, backgroundColor, tc3DWindow::FILL_ON); *************** *** 724,728 **** bool bTrackActive = (pLauncher->mnTargetID != NULL_INDEX); bool bReadyForLaunch; ! bool bLauncherActive = nLaunchCount > 0; if (bTrackActive) { --- 735,739 ---- bool bTrackActive = (pLauncher->mnTargetID != NULL_INDEX); bool bReadyForLaunch; ! bool bLauncherActive = (nLaunchCount > 0) && (!pLauncher->isLoading); if (bTrackActive) { *************** *** 771,774 **** --- 782,791 ---- eLaunchState = bReadyForLaunch ? BS_ACTIVE : BS_READY; } + + if (pLauncher->isLoading) + { + eLauncherState = BS_LOADING; + } + mcWeaponPanel.maButtonState[i][0] = eLauncherState; mcWeaponPanel.maButtonState[i][1] = eLauncherState; Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** tcGameObject.cpp 23 Nov 2004 23:31:13 -0000 1.25 --- tcGameObject.cpp 2 Dec 2004 04:17:26 -0000 1.26 *************** *** 74,77 **** --- 74,78 ---- Database::tcDatabase* tcGameObject::database = NULL; tcSimState* tcGameObject::simState = NULL; + long tcGameObject::hookedId = -1; /** *************** *** 173,176 **** --- 174,187 ---- * Used to decide when to display info messages and play sound * effects. + * @return true if object is hooked by user + */ + bool tcGameObject::IsHooked() const + { + return mnID == hookedId; + } + + /** + * Used to decide when to display info messages and play sound + * effects. * @return true if object is under user control */ Index: tcSubObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSubObject.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcSubObject.cpp 29 Nov 2004 03:55:07 -0000 1.2 --- tcSubObject.cpp 2 Dec 2004 04:17:27 -0000 1.3 *************** *** 30,33 **** --- 30,34 ---- #include "tcGenericDBObject.h" #include "tc3DModel.h" + #include "tcMessageInterface.h" #include "tcParticleEffect.h" #include "common/tcObjStream.h" *************** *** 216,219 **** --- 217,230 ---- { periscopeRaised = state; + + if (IsHooked() && IsOwnAlliance() && (mcKin.mfAlt_m >= -periscopeDepth_m)) + { + std::string s; + if (state) s = "Raising "; + else s = "Lowering"; + s += "scope, aye."; + + tcMessageInterface::Get()->PopupMessage(s); + } } *************** *** 224,227 **** --- 235,248 ---- { radarMastRaised = state; + + if (IsHooked() && IsOwnAlliance() && (mcKin.mfAlt_m >= -periscopeDepth_m)) + { + std::string s; + if (state) s = "Raising "; + else s = "Lowering"; + s += "the radar mast, aye."; + + tcMessageInterface::Get()->PopupMessage(s); + } } *************** *** 355,358 **** --- 376,401 ---- } + /** + * Messages to user + */ + void tcSubObject::UpdateMessages() + { + if (!IsHooked() || !IsOwnAlliance()) + { + lastDepth_m = -mcKin.mfAlt_m; + return; + } + + if (mfStatusTime < 5) return; + + + if ((-mcKin.mfAlt_m <= periscopeDepth_m) && (lastDepth_m > periscopeDepth_m)) + { + tcMessageInterface::Get()->PopupMessage("The boat is at periscope depth, sir."); + } + + + lastDepth_m = -mcKin.mfAlt_m; + } /** *************** *** 435,438 **** --- 478,483 ---- UpdateSensors(afStatusTime); + UpdateMessages(); + mfStatusTime = afStatusTime; } Index: tcOpticalSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcOpticalSensor.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcOpticalSensor.cpp 23 Nov 2004 23:31:17 -0000 1.2 --- tcOpticalSensor.cpp 2 Dec 2004 04:17:27 -0000 1.3 *************** *** 87,119 **** float target_size_m = target->GetSpan(); ! if (const tcSurfaceObject* surfaceObj = dynamic_cast<const tcSurfaceObject*>(target)) ! { ! isSurface = true; ! } ! else if (const tcAirObject* airObj = dynamic_cast<const tcAirObject*>(target)) ! { ! isAir = true; ! } ! else if (const tcMissileObject* missileObj = dynamic_cast<const tcMissileObject*>(target)) ! { ! isAir = true; ! } ! else if (const tcAirfieldObject* fieldObj = dynamic_cast<const tcAirfieldObject*>(target)) ! { ! isGround = true; ! } ! else if (const tcBallisticWeapon* ball = dynamic_cast<const tcBallisticWeapon*>(target)) ! { ! return false; ! } ! else { ! std::cerr << "CanDetectTarget called with illegal target class\n"; ! return false; } ! bool bTargetTypeMatch = (mpDBObj->mbDetectsAir && isAir) || ! (mpDBObj->mbDetectsSurface && isSurface) || ! (mpDBObj->mbDetectsGround && isGround); if (!bTargetTypeMatch) return false; --- 87,108 ---- float target_size_m = target->GetSpan(); ! ! ! unsigned int targetClassification = target->mpDBObject->mnType; ! if (targetClassification & PTYPE_SUBSURFACE) { ! if (target->mcKin.mfAlt_m >= -2.0f) ! { ! targetClassification |= PTYPE_SURFACE; ! } } ! unsigned int targetMask = 0; ! if (mpDBObj->mbDetectsAir) targetMask |= PTYPE_AIR; ! if (mpDBObj->mbDetectsSurface) targetMask |= PTYPE_SURFACE; ! if (mpDBObj->mbDetectsGround) targetMask |= PTYPE_FIXED; ! ! ! bool bTargetTypeMatch = (targetClassification & targetMask) != 0; if (!bTargetTypeMatch) return false; Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcLauncherState.cpp 29 Nov 2004 03:55:06 -0000 1.22 --- tcLauncherState.cpp 2 Dec 2004 04:17:26 -0000 1.23 *************** *** 183,187 **** if (ldata->mnCurrent <= 0) {return LAUNCHER_EMPTY;} // launcher empty ! if (ldata->mfTimeToReady > 0) {return LAUNCHER_BUSY;} // launcher not ready if (!ldata->mbActive) {return LAUNCHER_INACTIVE;} // launcher inactive or damaged --- 183,190 ---- if (ldata->mnCurrent <= 0) {return LAUNCHER_EMPTY;} // launcher empty ! if ((ldata->mfTimeToReady > 0) || (ldata->isLoading)) ! { ! return LAUNCHER_BUSY; ! } if (!ldata->mbActive) {return LAUNCHER_INACTIVE;} // launcher inactive or damaged --- NEW FILE: tcSonar.cpp --- /** ** @file tcSonar.cpp */ /* Copyright (C) 2004 Dewitt Colclough (de...@tw...) ** All rights reserved. ** This file is part of the Global Conflict Blue (GCB) program. ** GCB is free software; you can redistribute it and/or modify ** it under the terms of version 2 of the GNU General Public License as ** published by the Free Software Foundation. ** GCB is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** You should have received a copy of the GNU General Public License ** along with GCB; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA **/ #include "stdwx.h" #include "nsNav.h" #include "tcSonar.h" #include "tcGameObject.h" #include "tcSurfaceObject.h" #include "tcSubObject.h" #include "tcGenericDBObject.h" #include "tcSonarDBObject.h" #include "tcSimState.h" #include "tcGameObjIterator.h" #include "common/tcObjStream.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // break up this file later /** * Load state from stream */ tcUpdateStream& tcSonar::operator<<(tcUpdateStream& stream) { tcSensorState::operator<<(stream); return stream; } /** * Save state to stream */ tcUpdateStream& tcSonar::operator>>(tcUpdateStream& stream) { tcSensorState::operator>>(stream); return stream; } /** * */ bool tcSonar::CanDetectTarget(const tcGameObject* target, float& range_km) { float fTargetAz_rad; float fCoverageAz1, fCoverageAz2; bool bInSearchVolume = false; wxASSERT(mpDBObj); if (!mbActive) return false; bool isSurface = false; bool isSubSurface = false; float TS = 0; // target strength for active case float SLp = 0; // passive source level float NL = 0; // noise level of parent const tcKinematics *par_kin = &parent->mcKin; // kinematic state of sonar parent object const tcKinematics *tgt_kin = &target->mcKin; // state of target object if (const tcSurfaceObject* surfaceObj = dynamic_cast<const tcSurfaceObject*>(target)) { TS = 10.0f; // surfaceObj->mpDBObject->mfRcs_dbsm; SLp = 100.0f + 0.5f * tgt_kin->mfSpeed_kts; NL = 10.0f + 0.2f * par_kin->mfSpeed_kts; isSurface = true; } else if (const tcSubObject* sub = dynamic_cast<const tcSubObject*>(target)) { TS = 0; SLp = 80 + 0.5f * tgt_kin->mfSpeed_kts; NL = 10.0f + 0.2f * par_kin->mfSpeed_kts; isSubSurface = true; } else { fprintf(stderr, "tcSonar::CanDetectTarget called with illegal target class\n"); return false; } if ((mpDBObj->mfFieldOfView_deg >= 360.0f) && (!mpDBObj->isPassive)) { bInSearchVolume = true; } else { float lookAz_rad = parent->mcKin.mfHeading_rad + mountAz_rad; fTargetAz_rad = nsNav::GCHeadingApprox_rad(par_kin->mfLat_rad, par_kin->mfLon_rad, tgt_kin->mfLat_rad, tgt_kin->mfLon_rad); last_az_rad = fTargetAz_rad; float fHalfFOV_rad = 0.5f*C_PIOVER180*mpDBObj->mfFieldOfView_deg; fCoverageAz1 = lookAz_rad - fHalfFOV_rad; fCoverageAz2 = lookAz_rad + fHalfFOV_rad; bInSearchVolume = AngleWithinRange(fTargetAz_rad,fCoverageAz1,fCoverageAz2) != 0; if (!bInSearchVolume) { range_km = 0; return false; } } range_km = C_RADTOKM * nsNav::GCDistanceApprox_rad(par_kin->mfLat_rad, par_kin->mfLon_rad, tgt_kin->mfLat_rad, tgt_kin->mfLon_rad); float TL = 60.0f + 20.0f * log10f(range_km) + mpDBObj->alpha * range_km; // one-way transmission loss referenced to 1 m bool bDetectable; if (mpDBObj->isPassive) { bDetectable = SLp - TL + mpDBObj->DI - mpDBObj->DT - NL > 0; } else { bDetectable = mpDBObj->SL - 2.0f*TL + TS + mpDBObj->DI - mpDBObj->DT - NL > 0; } return bDetectable; } /** * @return false if key not found in database */ bool tcSonar::InitFromDatabase(long key) { wxASSERT(database); tcSensorState::InitFromDatabase(key); mpDBObj = dynamic_cast<tcSonarDBObject*>(database->GetObject(key)); if (mpDBObj == NULL) { fprintf(stderr, "Error - tcSonar::InitFromDatabase - Not found in db or bad class for key\n"); return false; } mnMode = SSMODE_SURVEILLANCE; mfSensorHeight_m = 0; return true; } /** * */ void tcSonar::Serialize(tcFile& file, bool mbLoad) { tcSensorState::Serialize(file, mbLoad); } /** * */ tcSonar& tcSonar::operator=(tcSonar& ss) { tcSensorState::operator =(ss); mpDBObj = ss.mpDBObj; return(*this); } /** * */ tcSonar* tcSonar::Clone() { tcSonar *pNew = new tcSonar(); *pNew = *this; return pNew; } /** * Alternative to dynamic_cast */ bool tcSonar::IsRadar() const { return false; } /** * Alternative to dynamic_cast */ bool tcSonar::IsSonar() const { return true; } /** * Updates torpedo sonar ("seeker" radar analogy) */ void tcSonar::UpdateSeeker(double t) { #if 0 long nTargetID; tcGameObject *ptarget = 0; int bFound; switch (mnMode) { case SSMODE_SEEKERACQUIRE: // fall through to SEEKERTRACK case SSMODE_SEEKERTRACK: nTargetID = mcTrack.mnID; if (nTargetID == parent->mnID) // no self detection { bFound = false; } else { bFound = simState->maPlatformState.Lookup(nTargetID,ptarget); } if (bFound) { // own-alliance is allowed float fRange_km; if (CanDetectTarget(ptarget, fRange_km)) { UpdateTrack(ptarget, t); return; } } // shut down missile if track lost for > 7 seconds if ((mnMode == SSMODE_SEEKERTRACK)&& (t - mcTrack.mfTimestamp) > 7.0) { parent->mfDamageLevel = 1.0f; mcTrack.mnID = NULL_INDEX; if(simState->mpUserInfo->IsOwnAlliance(parent->mnAlliance)) { char zBuff[128]; sprintf(zBuff,"Missile %d shut down\n", parent->mnID); simState->mpCommandInterface->DisplayInfoMessage(zBuff); } return; } // this code to enter search mode after track lost //pTrack->mnID = NULL_INDEX; //apRadarSS->mnMode = SSMODE_SEEKERSEARCH; break; case SSMODE_SEEKERSEARCH: { // get list of candidate tracks/detections tcGeoRect region; GetTestArea(region); tcGameObjIterator iter(region); float minRange = 1e15f; tnPoolIndex minID = NULL_INDEX; // find closest detectable target for (iter.First();iter.NotDone();iter.Next()) { tcGameObject *target = iter.Get(); if (target != parent) // no self detection { float range_km; /* Substitute this to disable own-alliance seeker detections: ** bool bDetected = (parent->mnAlliance != target->mnAlliance) && ** CanDetectTarget(target,range_km); */ bool bDetected = CanDetectTarget(target, range_km); if ((bDetected) && (range_km < minRange)) { minID = target->mnID; minRange = range_km; } } } if (minID==NULL_INDEX) return; // no targets found parent->DesignateTarget(minID); // select closest as target } } #endif } /** * Called after a surveillance detection to update sensor map for * appropriate alliance. */ void tcSonar::UpdateSensorMapActive(double t, const tcGameObject* target, float range_km) { tcSensorReport *pReport; tcSensorMapTrack *pSMTrack; bool bAccept = simState->mcSensorMap.UpdateActiveReport(pReport,parent->mnID,target->mnID, pSMTrack, parent->mnAlliance); if (!bAccept) return; bool bNewReport = pReport->IsNew(); if (bNewReport) {pReport->mfStartTime = t;} // new detection pReport->mfLat_rad = (float)target->mcKin.mfLat_rad; pReport->mfLon_rad = (float)target->mcKin.mfLon_rad; pReport->mfSpeed_kts = target->mcKin.mfSpeed_kts * cosf(target->mcKin.mfClimbAngle_rad); pReport->mfHeading_rad = target->mcKin.mfHeading_rad; pReport->mfTimestamp = t; pReport->mnSensorPlatformID = parent->mnID; pReport->mnTrackID = target->mnID; double fTrackLife = pReport->mfTimestamp - pReport->mfStartTime; if (fTrackLife >= 16.0) { pReport->mnFlags = TRACK_SPEED_VALID | TRACK_HEADING_VALID; } else { pReport->mnFlags = 0; } if ((!pReport->mbClassified)&&(fTrackLife > 10.0)) { UINT16 nClassification = target->mpDBObject->mnType; teAffiliation eAffil = UNKNOWN; if (nClassification & PTYPE_TORPEDO) {eAffil = HOSTILE;} pSMTrack->UpdateClassification(nClassification, eAffil, NULL_INDEX); pReport->mbClassified = 1; } bool bNewDetection = pSMTrack->IsNew(); if (bNewDetection) { pSMTrack->UpdateTrack(); if (simState->mpUserInfo->IsOwnAlliance(parent->mnAlliance)) { tcSound::Get()->PlayEffect(SEFFECT_PING); } fprintf(stdout, "target %d detected by active sonar at %3.1f km at time %.1f [a:%d]\n", target->mnID, range_km, t, parent->mnAlliance); } } /** * Called after a surveillance detection to update sensor map for * appropriate alliance. */ void tcSonar::UpdateSensorMapPassive(double t, const tcGameObject* target, float range_km, float az_rad) { tcSensorReport *pReport = 0; tcSensorMapTrack *pSMTrack = 0; wxASSERT(simState); bool bAccept = simState->mcSensorMap.UpdatePassiveReport(pReport, parent->mnID, target->mnID, pSMTrack, parent->mnAlliance); // update passive report if update needed (if bAccept) if (bAccept) { bool bNewReport = pReport->IsNew(); bool bNewDetection = pSMTrack->IsNew(); if (bNewReport) {pReport->mfStartTime = t;} // new detection report double fTrackLife = pReport->mfTimestamp - pReport->mfStartTime; pReport->mfLat_rad = (float)parent->mcKin.mfLat_rad; pReport->mfLon_rad = (float)parent->mcKin.mfLon_rad; pReport->mfHeading_rad = az_rad; pReport->mnFlags = TRACK_BEARING_ONLY | TRACK_HEADING_VALID; pReport->mfTimestamp = t; pReport->mnSensorPlatformID = parent->mnID; pReport->mnTrackID = target->mnID; if ((!pReport->mbClassified) && (fTrackLife > 20.0)) { wxASSERT(target->mpDBObject); unsigned int nClassification = target->mpDBObject->mnType; nClassification &= 0xFFF0; // leave size field unknown teAffiliation eAffil = UNKNOWN; if (nClassification & PTYPE_TORPEDO) {eAffil = HOSTILE;} pSMTrack->UpdateClassification(nClassification, eAffil, NULL_INDEX); pReport->mbClassified = 1; } if (bNewDetection) { pSMTrack->UpdateTrack(); if (simState->mpUserInfo->IsOwnAlliance(parent->mnAlliance)) { tcSound::Get()->PlayEffect(SEFFECT_PING); } fprintf(stdout, "target %d detected with passive sonar at %3.1f deg at time %.1f [a:%d]", target->mnID, az_rad, t, parent->mnAlliance); } } } void tcSonar::UpdateSurveillance(double t) { tcGeoRect region; GetTestArea(region); tcGameObjIterator iter(region); for (iter.First();iter.NotDone();iter.Next()) { tcGameObject* target = iter.Get(); if (target != parent) // no self detection { bool isEligible = (target->mpDBObject->mnType & (PTYPE_SUBSURFACE | PTYPE_SURFACE)) != 0; float range_km = 0; bool bDetected = (parent->mnAlliance != target->mnAlliance) && isEligible && CanDetectTarget(target, range_km); if (bDetected) { if (mpDBObj->isPassive) { UpdateSensorMapPassive(t, target, range_km, last_az_rad); } else { UpdateSensorMapActive(t, target, range_km); } } } } } /** * Update sensor track with target state. Used with * torpedos */ void tcSonar::UpdateTrack(const tcGameObject* target, double t) { #if 0 mcTrack.mfLat_rad = (float)target->mcKin.mfLat_rad; mcTrack.mfLon_rad = (float)target->mcKin.mfLon_rad; mcTrack.mfAlt_m = target->mcKin.mfAlt_m; mcTrack.mfSpeed_kts = target->mcKin.mfSpeed_kts; mcTrack.mfHeading_rad = target->mcKin.mfHeading_rad; mcTrack.mfClimbAngle_rad = target->mcKin.mfClimbAngle_rad; mcTrack.mfTimestamp = t; mcTrack.mnFlags = (TRACK_HEADING_VALID | TRACK_SPEED_VALID | TRACK_ALT_VALID | TRACK_CLIMB_VALID); if ((mnMode == SSMODE_SEEKERACQUIRE) && !isCommandReceiver) { mnMode = SSMODE_SEEKERTRACK; if (simState->mpUserInfo->IsOwnAlliance(parent->mnAlliance)) { tcSound::Get()->PlayEffect(SEFFECT_TWOBEEPS); } } #endif } void tcSonar::Update(double t) { if (!UpdateScan(t)) return; // only update once per scan period wxASSERT(parent); if (mnMode == SSMODE_SURVEILLANCE) { UpdateSurveillance(t); } else if ((mnMode == SSMODE_SEEKERTRACK)||(mnMode == SSMODE_SEEKERSEARCH)) { UpdateSeeker(t); } } /** * */ tcSonar::tcSonar() : tcSensorState(), mpDBObj(0), last_az_rad(0) { mnMode = SSMODE_SURVEILLANCE; mfSensorHeight_m = 0.0f; } tcSonar::tcSonar(tcSonarDBObject* dbObj) : tcSensorState(dbObj), mpDBObj(dbObj), last_az_rad(0) { wxASSERT(dbObj); mnMode = SSMODE_SURVEILLANCE; mfSensorHeight_m = 0.0f; } /** * */ tcSonar::~tcSonar() { } Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -d -r1.107 -r1.108 *** Game.cpp 29 Nov 2004 03:55:06 -0000 1.107 --- Game.cpp 2 Dec 2004 04:17:26 -0000 1.108 *************** *** 2097,2100 **** --- 2097,2101 ---- pythonInterface->SetMenuPlatform(hookID); } + tcGameObject::SetHookedId(hookID); } *************** *** 2275,2279 **** std::string s = cmd_info.mzString; int param = cmd_info.mnData; ! pythonInterface->ProcessCommand(s, param); } } --- 2276,2280 ---- std::string s = cmd_info.mzString; int param = cmd_info.mnData; ! pythonInterface->ProcessCommand(s, param, cmd_info.textParam); } } Index: tcStores.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcStores.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcStores.cpp 29 Nov 2004 03:55:07 -0000 1.1 --- tcStores.cpp 2 Dec 2004 04:17:27 -0000 1.2 *************** *** 199,202 **** --- 199,203 ---- launcher->mfTimeToReady = 0; } + launcher->SetLoadState(false); // clear load state } *************** *** 365,368 **** --- 366,370 ---- launcher->SetChildClass(item); + launcher->SetLoadState(true); return true; *************** *** 459,463 **** ops.push_back(op); ! if (parent->IsOwnAlliance()) --- 461,465 ---- ops.push_back(op); ! launcher->SetLoadState(true); if (parent->IsOwnAlliance()) Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcRadar.cpp 23 Nov 2004 23:31:17 -0000 1.17 --- tcRadar.cpp 2 Dec 2004 04:17:27 -0000 1.18 *************** *** 138,142 **** else { ! std::cerr << "CanDetectTarget called with illegal target class\n"; return false; } --- 138,142 ---- else { ! std::cerr << "tcRadar::CanDetectTarget called with illegal target class\n"; return false; } |