Thread: [Gcblue-commits] gcb_wx/src/sim Game.cpp,1.108,1.109 tcGoalTracker.cpp,1.6,1.7 tcLauncher.cpp,1.7,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-serv20399/src/sim Modified Files: Game.cpp tcGoalTracker.cpp tcLauncher.cpp tcLauncherState.cpp tcRadar.cpp tcSimState.cpp tcSonar.cpp tcWeaponObject.cpp Log Message: Sonar work, passive sonar, torpedoes Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** tcSimState.cpp 23 Nov 2004 23:31:18 -0000 1.59 --- tcSimState.cpp 5 Dec 2004 02:49:48 -0000 1.60 *************** *** 41,44 **** --- 41,46 ---- #include "tcBallisticWeapon.h" #include "tcBallisticDBObject.h" + #include "tcTorpedoObject.h" + #include "tcTorpedoDBObject.h" #include "tcHeloObject.h" #include "tcSubObject.h" *************** *** 397,400 **** --- 399,451 ---- /** + * Used for a torpedo that is guided with a sensor to a target. The + * assumption is that the intended target is the only possible target + * that can be hit. This saves time by not looking for nearby accidental + * targets. + */ + void tcSimState::EvaluateTorpedoHit(tcTorpedoObject* torp, tcGameObject* target) + { + float range_m = 1000.0f * torp->mcKin.RangeToKmAlt(target->mcKin); + + if (range_m >= 200) return; // too far away, no damage + + float dx, dy, dz, tclosest; + tclosest = target->mcKin.CalculateCollisionPoint(torp->mcKin, dx, dy, dz); + + if (tclosest > 0.3) return; // defer until future time step + + float trueRange2 = dx*dx + dy*dy + dz*dz; + if (trueRange2 < 64.0f) // 8.0 m range + { + float fDamage = torp->mpDBObject->mfDamage; + float fDamageFract = GetFractionalDamage(fDamage, target); + target->mfDamageLevel += fDamageFract; + torp->mfDamageLevel += 1.0f; // torp destroys itself on impact + + + if (fDamageFract > 0) + { + if (mpUserInfo->IsOwnAlliance(target->mnAlliance)) + { + ReportDamage(target); + } + else + { + tcSound::Get()->PlayEffect(SEFFECT_EXPLOSION2); + } + } + + + wxString s = wxString::Format("torpedo %d hit target %d, range^2: %3.1f m, dmg: %3.1f %%, time %.1f s", + torp->mnID, target->mnID, trueRange2, fDamageFract, mfSimTime); + WTL(s.c_str()); + std::cout << s.c_str(); + fprintf(stdout," collision relative time: %f, dx:%f dy:%f dz:%f\n", + tclosest, dx, dy, dz); + } + + } + + /** * Used for a weapon used against fixed land targets. The region near * the collision point is searched for nearby targets. Damage is applied *************** *** 522,525 **** --- 573,590 ---- } } + else if (tcTorpedoObject* torp = dynamic_cast<tcTorpedoObject*>(obj)) + { + bool bTerminal = (torp->GetGuidanceParameters(gp) != 0); + if (bTerminal && (gp.mnTargetID != -1)) + { + if (gp.mfInterceptTime < 10.0) + { + if (tcGameObject* target = GetObject(gp.mnTargetID)) + { + EvaluateTorpedoHit(torp, target); + } + } + } + } else if (tcWeaponObject* weapon = dynamic_cast<tcWeaponObject*>(obj)) { *************** *** 1380,1383 **** --- 1445,1457 ---- } } + else if (tcTorpedoObject* torp = dynamic_cast<tcTorpedoObject*>(launched)) + { + torp->LaunchFrom(launchingPlatform, nLauncher); + + if (mpUserInfo->IsOwnAlliance(launchingPlatform->mnAlliance)) + { + //tcSound::Get()->PlayEffect(SEFFECT_MISSILELAUNCH); + } + } else if (tcBallisticWeapon* ballistic = dynamic_cast<tcBallisticWeapon*>(launched)) { *************** *** 1391,1396 **** else { ! fprintf(stderr, ! "AddLaunchedPlatform - Unrecognized or NULL obj from CreateGameObject"); return; } --- 1465,1470 ---- else { ! fprintf(stderr, "tcSimState::AddLaunchedPlatform - " ! "Unrecognized or NULL obj from CreateGameObject"); return; } *************** *** 1449,1452 **** --- 1523,1530 ---- return new tcMissileObject(pMissileData); } + else if (tcTorpedoDBObject *torpData = dynamic_cast<tcTorpedoDBObject*>(apDBObject)) + { + return new tcTorpedoObject(torpData); + } else if (tcBallisticDBObject* ballisticData = dynamic_cast<tcBallisticDBObject*>(apDBObject)) { Index: tcWeaponObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcWeaponObject.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcWeaponObject.cpp 2 Nov 2004 04:23:57 -0000 1.9 --- tcWeaponObject.cpp 5 Dec 2004 02:49:48 -0000 1.10 *************** *** 108,113 **** if (smtrack == NULL) { ! fprintf(stderr, "tcWeaponObject::SetIntendedTarget - targetId %d not found in sensor map", ! targetId); } else --- 108,113 ---- if (smtrack == NULL) { ! fprintf(stderr, "tcWeaponObject::SetIntendedTarget - targetId %d not found in sensor map" ! "(%s %s)\n", targetId, mzClass.mz, mzUnit.mz); } else Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tcLauncherState.cpp 2 Dec 2004 04:17:26 -0000 1.23 --- tcLauncherState.cpp 5 Dec 2004 02:49:48 -0000 1.24 *************** *** 139,147 **** } ! const char* tcLauncherState::GetLauncherChildClass(unsigned nLauncher) const { wxASSERT((int)nLauncher < mnCount); ! return launchers[nLauncher]->mpLauncherDBObj->mzChildClass.mz; } --- 139,147 ---- } ! std::string tcLauncherState::GetLauncherChildClass(unsigned nLauncher) const { wxASSERT((int)nLauncher < mnCount); ! return launchers[nLauncher]->GetChildClassName(); } Index: tcSonar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSonar.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcSonar.cpp 2 Dec 2004 04:17:27 -0000 1.1 --- tcSonar.cpp 5 Dec 2004 02:49:48 -0000 1.2 *************** *** 26,29 **** --- 26,30 ---- #include "tcSurfaceObject.h" #include "tcSubObject.h" + #include "tcTorpedoObject.h" #include "tcGenericDBObject.h" #include "tcSonarDBObject.h" *************** *** 74,77 **** --- 75,80 ---- if (!mbActive) return false; + const tcKinematics *par_kin = &parent->mcKin; // kinematic state of sonar parent object + const tcKinematics *tgt_kin = &target->mcKin; // state of target object bool isSurface = false; *************** *** 80,101 **** 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; } --- 83,104 ---- float TS = 0; // target strength for active case float SLp = 0; // passive source level ! float NL = 10.0f + 0.2f * par_kin->mfSpeed_kts;; // noise level of parent if (const tcSurfaceObject* surfaceObj = dynamic_cast<const tcSurfaceObject*>(target)) { ! TS = 20.0f; // surfaceObj->mpDBObject->mfRcs_dbsm; SLp = 100.0f + 0.5f * tgt_kin->mfSpeed_kts; isSurface = true; } else if (const tcSubObject* sub = dynamic_cast<const tcSubObject*>(target)) { ! TS = 10; SLp = 80 + 0.5f * tgt_kin->mfSpeed_kts; ! isSubSurface = true; ! } ! else if (const tcTorpedoObject* torp = dynamic_cast<const tcTorpedoObject*>(target)) ! { ! TS = 0; ! SLp = 90 + 0.5f * tgt_kin->mfSpeed_kts; isSubSurface = true; } *************** *** 107,111 **** ! if ((mpDBObj->mfFieldOfView_deg >= 360.0f) && (!mpDBObj->isPassive)) { bInSearchVolume = true; --- 110,114 ---- ! if ((mpDBObj->mfFieldOfView_deg >= 360.0f) && (!isPassive)) { bInSearchVolume = true; *************** *** 135,149 **** 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; } --- 138,154 ---- mpDBObj->alpha * range_km; // one-way transmission loss referenced to 1 m ! float excessSNR; ! ! if (isPassive) { ! excessSNR = SLp - TL + mpDBObj->DI - mpDBObj->DT - NL; ! } else { ! excessSNR = mpDBObj->SL - 2.0f*TL + TS + mpDBObj->DI - mpDBObj->DT - NL; } ! ! return excessSNR > 0; } *************** *** 167,170 **** --- 172,176 ---- mnMode = SSMODE_SURVEILLANCE; mfSensorHeight_m = 0; + isPassive = mpDBObj->isPassive; return true; *************** *** 179,182 **** --- 185,203 ---- } + /** + * + */ + void tcSonar::SetActiveSonar() + { + wxASSERT(false); + } + + /** + * + */ + void tcSonar::SetPassiveSonar() + { + wxASSERT(false); + } *************** *** 203,206 **** --- 224,235 ---- /** + * @return true if torpedo is running in passive mode + */ + bool tcSonar::IsPassive() const + { + return isPassive; + } + + /** * Alternative to dynamic_cast */ *************** *** 221,229 **** /** ! * Updates torpedo sonar ("seeker" radar analogy) */ void tcSonar::UpdateSeeker(double t) { - #if 0 long nTargetID; tcGameObject *ptarget = 0; --- 250,257 ---- /** ! * Updates torpedo sonar */ void tcSonar::UpdateSeeker(double t) { long nTargetID; tcGameObject *ptarget = 0; *************** *** 235,273 **** 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: --- 263,296 ---- 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; ! } ! } ! // switch back to search mode if track lost or acquire failed ! bool returnToSearch = (mnMode == SSMODE_SEEKERACQUIRE) || ! ((mnMode == SSMODE_SEEKERTRACK)&&(t - mcTrack.mfTimestamp) > 6.0); ! if (returnToSearch) { ! mcTrack.mnID = -1; ! mnMode = SSMODE_SEEKERSEARCH; ! return; } } break; case SSMODE_SEEKERSEARCH: *************** *** 278,283 **** tcGameObjIterator iter(region); ! float minRange = 1e15f; ! tnPoolIndex minID = NULL_INDEX; // find closest detectable target --- 301,306 ---- tcGameObjIterator iter(region); ! float minParam = 1e15f; ! tnPoolIndex minID = -1; // find closest detectable target *************** *** 285,291 **** { 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) && --- 308,317 ---- { tcGameObject *target = iter.Get(); ! bool isEligible = (target->mpDBObject->mnType != PTYPE_TORPEDO) && ! ((target->mpDBObject->mnType & (PTYPE_SUBSURFACE | PTYPE_SURFACE)) != 0); ! if (isEligible && (target != parent)) // no self detection { float range_km; + float searchParam; /* Substitute this to disable own-alliance seeker detections: ** bool bDetected = (parent->mnAlliance != target->mnAlliance) && *************** *** 293,309 **** */ 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 } --- 319,342 ---- */ bool bDetected = CanDetectTarget(target, range_km); ! ! /* For active sonars, choose closest target in range, ! ** for passive choose target with strongest receive signal ! */ ! if (isPassive) searchParam = -last_snr_excess; ! else searchParam = range_km; ! ! if ((bDetected) && (searchParam < minParam)) { minID = target->mnID; ! minParam = searchParam; } } } ! if (minID == -1) return; // no targets found parent->DesignateTarget(minID); // select closest as target } } ! } *************** *** 448,452 **** if (bDetected) { ! if (mpDBObj->isPassive) { UpdateSensorMapPassive(t, target, range_km, last_az_rad); --- 481,485 ---- if (bDetected) { ! if (isPassive) { UpdateSensorMapPassive(t, target, range_km, last_az_rad); *************** *** 468,490 **** 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 } --- 501,540 ---- void tcSonar::UpdateTrack(const tcGameObject* target, double t) { ! ! if (isPassive) ! { ! mcTrack.mfLat_rad = 0; ! mcTrack.mfLon_rad = 0; ! mcTrack.mfAlt_m = target->mcKin.mfAlt_m; // workaround instead of having a passive elevation ! mcTrack.mfSpeed_kts = 0; ! mcTrack.mfHeading_rad = last_az_rad; ! mcTrack.mfClimbAngle_rad = 0; // or could use this as passive elevation ! mcTrack.mfTimestamp = t; ! mcTrack.mnFlags = TRACK_BEARING_ONLY | TRACK_ALT_VALID; ! } ! else ! { ! 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) { mnMode = SSMODE_SEEKERTRACK; + #ifdef _DEBUG if (simState->mpUserInfo->IsOwnAlliance(parent->mnAlliance)) { tcSound::Get()->PlayEffect(SEFFECT_TWOBEEPS); } #endif + } } *************** *** 498,502 **** UpdateSurveillance(t); } ! else if ((mnMode == SSMODE_SEEKERTRACK)||(mnMode == SSMODE_SEEKERSEARCH)) { UpdateSeeker(t); --- 548,552 ---- UpdateSurveillance(t); } ! else if ((mnMode == SSMODE_SEEKERTRACK)||(mnMode == SSMODE_SEEKERSEARCH)||(mnMode == SSMODE_SEEKERACQUIRE)) { UpdateSeeker(t); *************** *** 511,517 **** : tcSensorState(), mpDBObj(0), last_az_rad(0) { - mnMode = SSMODE_SURVEILLANCE; mfSensorHeight_m = 0.0f; --- 561,567 ---- : tcSensorState(), mpDBObj(0), + isPassive(false), last_az_rad(0) { mnMode = SSMODE_SURVEILLANCE; mfSensorHeight_m = 0.0f; *************** *** 521,524 **** --- 571,575 ---- : tcSensorState(dbObj), mpDBObj(dbObj), + isPassive(dbObj->isPassive), last_az_rad(0) { Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** Game.cpp 2 Dec 2004 04:17:26 -0000 1.108 --- Game.cpp 5 Dec 2004 02:49:48 -0000 1.109 *************** *** 267,273 **** wxMessageDialog confirmQuit(this, outcomeMessage.str().c_str(), ! "Game over, quit game?", wxOK | wxCANCEL, wxDefaultPosition); ! if (confirmQuit.ShowModal() == wxID_OK) { wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_ENDGAME); --- 267,273 ---- wxMessageDialog confirmQuit(this, outcomeMessage.str().c_str(), ! "Game over, quit game?", wxYES | wxNO, wxDefaultPosition); ! if (confirmQuit.ShowModal() == wxID_YES) { wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_ENDGAME); Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcLauncher.cpp 2 Dec 2004 04:17:26 -0000 1.7 --- tcLauncher.cpp 5 Dec 2004 02:49:48 -0000 1.8 *************** *** 25,28 **** --- 25,29 ---- #include "tcLauncherDBObject.h" #include "tcMissileDBObject.h" + #include "tcTorpedoDBObject.h" #include "tcRadar.h" #include "tcSimState.h" *************** *** 199,202 **** --- 200,219 ---- } + /** + * @return true if item is compatible with launcher (can be loaded) + */ + 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; + } /** *************** *** 237,247 **** // set detailed launch mode if missile ! tcMissileDBObject* pMissileDBObj = ! dynamic_cast<tcMissileDBObject*>(mpChildDBObj); ! if (pMissileDBObj != NULL) { meLaunchMode = pMissileDBObj->GetLaunchMode(); mnTargetFlags = pMissileDBObj->mnTargetFlags; } else // assume ballistic vs. land (TODO rework this) { --- 254,269 ---- // set detailed launch mode if missile ! if (tcMissileDBObject* pMissileDBObj = ! dynamic_cast<tcMissileDBObject*>(mpChildDBObj)) { meLaunchMode = pMissileDBObj->GetLaunchMode(); mnTargetFlags = pMissileDBObj->mnTargetFlags; } + else if (tcTorpedoDBObject* torpDBObj = + dynamic_cast<tcTorpedoDBObject*>(mpChildDBObj)) + { + meLaunchMode = DATUM_ONLY; + mnTargetFlags = SURFACE_TARGET | SUBSURFACE_TARGET; + } else // assume ballistic vs. land (TODO rework this) { *************** *** 250,256 **** --- 272,291 ---- } + } + /** + * Sets child quantity, up to capacity + */ + void tcLauncher::SetChildQuantity(unsigned int quantity) + { + mnCurrent = quantity; + if (mnCurrent > mpLauncherDBObj->mnCapacity) + { + mnCurrent = mpLauncherDBObj->mnCapacity; + } + mnUncommitted = mnCurrent; } + /** * Index: tcGoalTracker.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGoalTracker.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcGoalTracker.cpp 6 Sep 2004 01:08:04 -0000 1.6 --- tcGoalTracker.cpp 5 Dec 2004 02:49:48 -0000 1.7 *************** *** 102,107 **** { tcGoal* allianceGoal = allianceGoals[alliance]; ! return (allianceGoal && (allianceGoal->goalState != previousGoalStatus[alliance])); } --- 102,113 ---- { tcGoal* allianceGoal = allianceGoals[alliance]; ! if (!allianceGoal) return false; ! ! bool result = (allianceGoal && (allianceGoal->goalState != previousGoalStatus[alliance])); + + previousGoalStatus[alliance] = allianceGoal->goalState; + + return result; } Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcRadar.cpp 2 Dec 2004 04:17:27 -0000 1.18 --- tcRadar.cpp 5 Dec 2004 02:49:48 -0000 1.19 *************** *** 138,142 **** else { ! std::cerr << "tcRadar::CanDetectTarget called with illegal target class\n"; return false; } --- 138,143 ---- else { ! fprintf(stderr, "tcRadar::CanDetectTarget called with illegal target class (%s)\n", ! target->mzClass.mz); return false; } *************** *** 497,502 **** { float range_km = 0; bool bDetected = (parent->mnAlliance != target->mnAlliance) && ! (target->mcKin.mfAlt_m > -2.0f) && // ignore subsurface CanDetectTarget(target,range_km); if (bDetected) UpdateSensorMap(t, target, range_km); --- 498,511 ---- { float range_km = 0; + + bool surfacedSub = (target->mpDBObject->mnType == PTYPE_SUBMARINE) && + (target->mcKin.mfAlt_m > -2.0f); + + bool isEligible = surfacedSub || + ((target->mpDBObject->mnType & + (PTYPE_AIR | PTYPE_FIXED | PTYPE_MISSILE | PTYPE_SURFACE)) != 0); + bool bDetected = (parent->mnAlliance != target->mnAlliance) && ! isEligible && CanDetectTarget(target,range_km); if (bDetected) UpdateSensorMap(t, target, range_km); *************** *** 525,532 **** --- 534,543 ---- { mnMode = SSMODE_SEEKERTRACK; + #ifdef _DEBUG if (simState->mpUserInfo->IsOwnAlliance(parent->mnAlliance)) { tcSound::Get()->PlayEffect(SEFFECT_TWOBEEPS); } + #endif } } |