gcblue-commits Mailing List for Global Conflict Blue (Page 39)
Status: Alpha
Brought to you by:
ddcforge
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(112) |
Feb
(106) |
Mar
(88) |
Apr
(111) |
May
(53) |
Jun
(60) |
Jul
(58) |
Aug
(61) |
Sep
(45) |
Oct
(31) |
Nov
(71) |
Dec
(70) |
| 2005 |
Jan
(33) |
Feb
(57) |
Mar
(98) |
Apr
(47) |
May
(53) |
Jun
(79) |
Jul
(79) |
Aug
|
Sep
(33) |
Oct
(1) |
Nov
(20) |
Dec
(64) |
| 2006 |
Jan
(20) |
Feb
(1) |
Mar
(43) |
Apr
(11) |
May
(8) |
Jun
(23) |
Jul
|
Aug
(28) |
Sep
(58) |
Oct
(25) |
Nov
(47) |
Dec
(70) |
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 } } |
|
From: Dewitt C. <ddc...@us...> - 2004-12-05 02:49:59
|
Update of /cvsroot/gcblue/gcb_wx/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20399/xml Modified Files: options.xml Log Message: Sonar work, passive sonar, torpedoes Index: options.xml =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/xml/options.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** options.xml 2 Dec 2004 04:17:27 -0000 1.8 --- options.xml 5 Dec 2004 02:49:48 -0000 1.9 *************** *** 5,8 **** <LastScenarioName>SubTest</LastScenarioName> <xCopyDatabase /> ! <WriteXmlDatabase /> </Options> --- 5,8 ---- <LastScenarioName>SubTest</LastScenarioName> <xCopyDatabase /> ! <xWriteXmlDatabase /> </Options> |
|
From: Dewitt C. <ddc...@us...> - 2004-12-05 02:49:59
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20399/src/common Modified Files: simmath.cpp tcOggStreamer.cpp Log Message: Sonar work, passive sonar, torpedoes Index: tcOggStreamer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcOggStreamer.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcOggStreamer.cpp 14 Sep 2004 02:01:46 -0000 1.10 --- tcOggStreamer.cpp 5 Dec 2004 02:49:47 -0000 1.11 *************** *** 222,225 **** --- 222,234 ---- } + bool tcOggStreamer::IsPaused() + { + ALenum state; + + alGetSourcei(source, AL_SOURCE_STATE, &state); + + return (state == AL_PAUSED); + } + bool tcOggStreamer::IsPlaying() *************** *** 232,235 **** --- 241,253 ---- } + bool tcOggStreamer::IsStopped() + { + ALenum state; + + alGetSourcei(source, AL_SOURCE_STATE, &state); + + return (state == AL_STOPPED); + } + *************** *** 261,273 **** { bool active = true; ! int processed; ! if (paused) return true; // Ask OpenAL how many buffers it has managed to play back ! alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed); ! nFreeBuffers += processed; if (nFreeBuffers > NUM_BUFFERS) --- 279,303 ---- { bool active = true; ! int nProcessed; ! int queued; ! if (paused) ! { ! return true; ! } + if (IsStopped()) + { + alSourcePlay(source); + #ifdef _DEBUG + fprintf(stderr, "tcOggStreamer::Update - Restarting source\n"); + #endif + } + alGetSourcei(source, AL_BUFFERS_QUEUED, &queued); // Ask OpenAL how many buffers it has managed to play back ! alGetSourcei(source, AL_BUFFERS_PROCESSED, &nProcessed); ! nFreeBuffers += nProcessed; if (nFreeBuffers > NUM_BUFFERS) *************** *** 291,296 **** while (active && nFreeBuffers) { ! alSourceUnqueueBuffers(source, 1, &buffers[bufferIndex]); ! //fill the buffer active = Stream(buffers[bufferIndex]); --- 321,330 ---- while (active && nFreeBuffers) { ! if (nProcessed) ! { ! alSourceUnqueueBuffers(source, 1, &buffers[bufferIndex]); ! nProcessed--; ! } ! Check(); //fill the buffer active = Stream(buffers[bufferIndex]); Index: simmath.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/simmath.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** simmath.cpp 14 Nov 2004 22:52:20 -0000 1.19 --- simmath.cpp 5 Dec 2004 02:49:47 -0000 1.20 *************** *** 384,388 **** td.mnAlliance = mnAlliance; td.mnClassification = mnClassification; ! if (td.mfAlt_m < 0) {td.mfAlt_m = 0;} } --- 384,388 ---- td.mnAlliance = mnAlliance; td.mnClassification = mnClassification; ! if ((mfAlt_m >= 0)&&(td.mfAlt_m < 0)) {td.mfAlt_m = 0;} } *************** *** 460,464 **** float v = C_KTSTOMPS*mfSpeed_kts; ! float vc = C_KTSTOMPS*mfSpeed_kts; float dvz = v*sinf(mfPitch_rad) - vc*sinf(collider.mfPitch_rad); float cospitch = cosf(mfPitch_rad); --- 460,464 ---- float v = C_KTSTOMPS*mfSpeed_kts; ! float vc = C_KTSTOMPS*collider.mfSpeed_kts; float dvz = v*sinf(mfPitch_rad) - vc*sinf(collider.mfPitch_rad); float cospitch = cosf(mfPitch_rad); *************** *** 467,470 **** --- 467,472 ---- float dvy = v*cospitch*cosf(mfHeading_rad) - vc*cospitchc*cosf(collider.mfHeading_rad); + wxASSERT(dvx*dvx + dvy*dvy + dvz*dvz != 0); + float tclosest = -(dx*dvx + dy*dvy + dz*dvz) / (dvx*dvx + dvy*dvy + dvz*dvz); |
|
From: Dewitt C. <ddc...@us...> - 2004-12-05 02:49:57
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20399/src/scriptinterface Modified Files: tcPlatformInterface.cpp tcPlatformInterfaceExtensionB.cpp tcScenarioInterface.cpp tcSimPythonInterface.cpp Log Message: Sonar work, passive sonar, torpedoes Index: tcPlatformInterfaceExtensionB.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtensionB.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcPlatformInterfaceExtensionB.cpp 29 Nov 2004 03:55:05 -0000 1.17 --- tcPlatformInterfaceExtensionB.cpp 5 Dec 2004 02:49:47 -0000 1.18 *************** *** 145,148 **** --- 145,149 ---- .def("SetVar", &tcPlatformInterface::SetVar) .def("DisplayMessage",&tcPlatformInterface::DisplayMessage) + .def("IsValid",&tcPlatformInterface::IsValid) .def("PlaySound",&tcPlatformInterface::PlaySound) .def("Rand",&tcPlatformInterface::GetRand) Index: tcSimPythonInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcSimPythonInterface.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcSimPythonInterface.cpp 2 Dec 2004 04:17:25 -0000 1.22 --- tcSimPythonInterface.cpp 5 Dec 2004 02:49:48 -0000 1.23 *************** *** 551,555 **** tcPlatformObject *pPlatformObj = dynamic_cast<tcPlatformObject*>(pGameObj); mpHookedObj = pPlatformObj; ! if (pPlatformObj == NULL) {return;} hookedInterface->SetPlatform(pPlatformObj); /* --- 551,555 ---- tcPlatformObject *pPlatformObj = dynamic_cast<tcPlatformObject*>(pGameObj); mpHookedObj = pPlatformObj; ! //if (pPlatformObj == NULL) {return;} hookedInterface->SetPlatform(pPlatformObj); /* Index: tcScenarioInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcScenarioInterface.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcScenarioInterface.cpp 23 Nov 2004 23:30:58 -0000 1.14 --- tcScenarioInterface.cpp 5 Dec 2004 02:49:48 -0000 1.15 *************** *** 29,48 **** #endif ! #include "tcScenarioInterface.h" ! #include "tcMapData.h" ! #include "tcSimState.h" #include "tcAIData.h" ! #include "tcSoundConsole.h" #include "tcDirector.h" #include "tcDirectorEvent.h" ! #include "wxcommands.h" ! #include "tcGoalTracker.h" #include "tcGoal.h" ! #include "tcCarrierObject.h" ! #include "tcAeroAirObject.h" #include "tcSubObject.h" - #include "tcAirfieldObject.h" - #include "tcGenericDBObject.h" using namespace std; --- 29,50 ---- #endif ! #include "tcAeroAirObject.h" ! #include "tcAirfieldObject.h" #include "tcAIData.h" ! #include "tcCarrierObject.h" #include "tcDirector.h" #include "tcDirectorEvent.h" ! #include "tcGenericDBObject.h" #include "tcGoal.h" ! #include "tcGoalTracker.h" ! #include "tcLauncher.h" ! #include "tcMapData.h" ! #include "tcScenarioInterface.h" ! #include "tcSimState.h" ! #include "tcSoundConsole.h" ! #include "tcStores.h" #include "tcSubObject.h" + #include "wxcommands.h" using namespace std; *************** *** 134,137 **** --- 136,142 ---- .def("AddUnitToAlliance",&tcScenarioInterface::AddUnitToAlliance) .def("AddUnitToFlightDeck",&tcScenarioInterface::AddUnitToFlightDeck) + .def("AddToUnitMagazine",&tcScenarioInterface::AddToUnitMagazine) + .def("SetUnitLauncherItem",&tcScenarioInterface::SetUnitLauncherItem) + .def("CreateAlliance",&tcScenarioInterface::CreateAlliance) .def("GetDefaultOrder",&tcScenarioInterface::GetDefaultOrder) *************** *** 281,284 **** --- 286,360 ---- } + /** + * Adds items (normally weapons) to first compatible magazine of unit + */ + void tcScenarioInterface::AddToUnitMagazine(const std::string& unitName, + const std::string& item, unsigned int quantity) + { + wxASSERT(simState); + tcGameObject* parentObj = simState->GetObjectByName(unitName); + if (tcPlatformObject* platform = dynamic_cast<tcPlatformObject*>(parentObj)) + { + unsigned int nMagazines = platform->GetMagazineCount(); + for (unsigned int n=0; n<nMagazines; n++) + { + tcStores* mag = platform->GetMagazine(n); + if (!mag->IsFull() && mag->IsCompatible(item)) + { + mag->AddItems(item, quantity); + return; + } + } + + fprintf(stderr, "tcScenarioInterface::AddToUnitMagazine - " + "Failed to load %s to unit %s\n", item.c_str(),unitName.c_str()); + + } + else + { + fprintf(stderr, "tcScenarioInterface::AddToUnitMagazine - " + "Unit not found: %s\n", unitName.c_str()); + } + } + + /** + * Sets launcher item and quantity of unit + */ + void tcScenarioInterface::SetUnitLauncherItem(const std::string& unitName, + unsigned int launcherIdx, const std::string& item, unsigned int quantity) + { + wxASSERT(simState); + tcGameObject* parentObj = simState->GetObjectByName(unitName); + if (tcPlatformObject* platform = dynamic_cast<tcPlatformObject*>(parentObj)) + { + if (tcLauncher* launcher = platform->GetLauncher(launcherIdx)) + { + if (launcher->IsItemCompatible(item)) + { + launcher->SetChildClass(item); + launcher->SetChildQuantity(quantity); + } + else + { + fprintf(stderr, "tcScenarioInterface::SetUnitLauncherItem - " + "%s not compatible with unit %s, launcher %d\n", item.c_str(), + unitName.c_str(), launcherIdx); + } + } + else + { + fprintf(stderr, "tcScenarioInterface::SetUnitLauncherItem - " + "Bad launcher index (unit %s, launcher %d)\n", + unitName.c_str(), launcherIdx); + } + } + else + { + fprintf(stderr, "tcScenarioInterface::AddToUnitMagazine - " + "Unit not found or bad type (%s)\n", unitName.c_str()); + } + } + + void tcScenarioInterface::CreateAlliance(int alliance, std::string name) { Index: tcPlatformInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterface.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tcPlatformInterface.cpp 29 Nov 2004 03:55:05 -0000 1.30 --- tcPlatformInterface.cpp 5 Dec 2004 02:49:47 -0000 1.31 *************** *** 40,45 **** #include "commandlist.h" #include "tcAeroAirObject.h" - #include "tcGenericDBObject.h" #include "tcBallisticDBObject.h" #include "tcLauncherState.h" #include "tcLauncher.h" --- 40,46 ---- #include "commandlist.h" #include "tcAeroAirObject.h" #include "tcBallisticDBObject.h" + #include "tcGenericDBObject.h" + #include "tcTorpedoDBObject.h" #include "tcLauncherState.h" #include "tcLauncher.h" *************** *** 316,319 **** --- 317,324 ---- return true; } + if ((track.mnClassification & PTYPE_SUBMARINE)&&(info.mnTargetFlags & SUBSURFACE_TARGET)) + { + return true; + } return false; } *************** *** 470,475 **** info.mfRange_km = 20; } ! else ! { fprintf(stderr, "Error - unsupported launcher child class (%s)\n", pLauncherData->mpChildDBObj->GetClassName()); --- 475,484 ---- info.mfRange_km = 20; } ! else if (tcTorpedoDBObject* torpDBObj = ! dynamic_cast<tcTorpedoDBObject*>(pLauncherData->mpChildDBObj)) ! { ! info.mfRange_km = torpDBObj->mfRange_km; ! } ! else { fprintf(stderr, "Error - unsupported launcher child class (%s)\n", pLauncherData->mpChildDBObj->GetClassName()); *************** *** 629,646 **** } ! bool found = false; ! int nTypes = (int)launcher->GetCompatibleCount(); ! for (int k=0; (k<nTypes) && !found; k++) ! { ! if (launcher->GetCompatibleName(unsigned(k)) == item) ! { ! found = true; ! } ! } ! if (!found) ! { ! return; ! } ! unsigned int nMagazines = mpPlatformObj->GetMagazineCount(); --- 638,642 ---- } ! if (!launcher->IsItemCompatible(item)) return; unsigned int nMagazines = mpPlatformObj->GetMagazineCount(); *************** *** 741,749 **** } ! void tcPlatformInterface::GetSensorMap(void) { ! UINT8 nAlliance = mpPlatformObj->mnAlliance; ! mpSensorMap = mpSimState->mcSensorMap.GetMap(nAlliance); ! wxASSERT(mpSensorMap); } --- 737,752 ---- } ! void tcPlatformInterface::GetSensorMap() { ! if (mpPlatformObj) ! { ! unsigned int nAlliance = mpPlatformObj->mnAlliance; ! mpSensorMap = mpSimState->mcSensorMap.GetMap(nAlliance); ! wxASSERT(mpSensorMap); ! } ! else ! { ! mpSensorMap = 0; ! } } *************** *** 1021,1024 **** --- 1024,1036 ---- } + /** + * @return true if interface has valid (non null) platform object + */ + bool tcPlatformInterface::IsValid() const + { + return mpPlatformObj != 0; + } + + // print message to user console void tcPlatformInterface::DisplayMessage(std::string text) |
|
From: Dewitt C. <ddc...@us...> - 2004-12-05 02:49:57
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20399/src/graphics Modified Files: tcCreditView.cpp tcMapView.cpp Log Message: Sonar work, passive sonar, torpedoes Index: tcMapView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMapView.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcMapView.cpp 23 Nov 2004 23:30:55 -0000 1.9 --- tcMapView.cpp 5 Dec 2004 02:49:47 -0000 1.10 *************** *** 1296,1300 **** --- 1296,1365 ---- } + return symbol; + } + + /** + * Creates osg::Geometry object for requested NTDS symbol + */ + osg::Geometry* tcTacticalMapView::DrawNTDSTorpedo(teAffiliation affil) + { + float w = 8.0f; + osg::Geometry* symbol = CreateSymbolGeometry(); + + // set color + osg::Vec4Array* colors = new osg::Vec4Array; + colors->push_back(GetAffiliationColor(affil)); + symbol->setColorArray(colors); + symbol->setColorBinding(osg::Geometry::BIND_OVERALL); + + // create vertex array + osg::Vec3Array* vertices = new osg::Vec3Array; + symbol->setVertexArray(vertices); + + + switch (affil) + { + case FRIENDLY: + case NEUTRAL: + { + AddArcPrimitive(symbol, vertices, 0, 0, 2*w, -2*w, -90, 90, 32); + break; + } + case UNKNOWN: + { + vertices->push_back(osg::Vec3(w, 0, 0)); + vertices->push_back(osg::Vec3(w, -w, 0)); + vertices->push_back(osg::Vec3(-w, -w, 0)); + vertices->push_back(osg::Vec3(-w, 0, 0)); + + symbol->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,4)); + break; + } + case HOSTILE: + { + vertices->push_back(osg::Vec3(w, 0, 0)); + vertices->push_back(osg::Vec3(0, -w, 0)); + vertices->push_back(osg::Vec3(-w, 0, 0)); + + symbol->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,3)); + break; + } + default: + { + fprintf(stderr, "Error - tcTacticalMapView::DrawNTDSSubsurface\n"); + } + } + + // add "T" + size_t v_idx = vertices->size(); + vertices->push_back(osg::Vec3(-0.65*w, -0.2*w, 0)); + vertices->push_back(osg::Vec3(0.65*w, -0.2*w, 0)); + vertices->push_back(osg::Vec3(0, -0.2*w, 0)); + vertices->push_back(osg::Vec3(0, -1.1*w, 0)); + + symbol->addPrimitiveSet(new osg::DrawArrays(GL_LINES, v_idx, 4)); + + return symbol; } *************** *** 1328,1331 **** --- 1393,1399 ---- osg::Geometry* pSub = DrawNTDSSubsurface((teAffiliation)nAffiliation); + // torpedo + osg::Geometry* pTorpedo = DrawNTDSTorpedo((teAffiliation)nAffiliation); + *************** *** 1356,1359 **** --- 1424,1429 ---- break; case SYMBOL_TORPEDO: + pSymbol = pTorpedo; + break; case SYMBOL_SUBSURFACE: case SYMBOL_SUBMARINE: *************** *** 1407,1410 **** --- 1477,1483 ---- osg::Geometry* pAir = CreateTexturedSymbol(zBuff); + sprintf(zBuff,"air_rw%s",zAffil); + osg::Geometry* pHelo = CreateTexturedSymbol(zBuff); + sprintf(zBuff,"missile%s",zAffil); osg::Geometry* pMissile = CreateTexturedSymbol(zBuff); *************** *** 1416,1419 **** --- 1489,1496 ---- osg::Geometry* pSub = CreateTexturedSymbol(zBuff); + sprintf(zBuff,"torp%s",zAffil); + osg::Geometry* pTorpedo = CreateTexturedSymbol(zBuff); + + osg::Geometry* pUnknown = CreateTexturedSymbol("unknown.png"); *************** *** 1435,1438 **** --- 1512,1517 ---- break; case SYMBOL_HELO: + pSymbol = pHelo; + break; case SYMBOL_AIR: case SYMBOL_FIXEDWING: *************** *** 1440,1443 **** --- 1519,1524 ---- break; case SYMBOL_TORPEDO: + pSymbol = pTorpedo; + break; case SYMBOL_SUBSURFACE: case SYMBOL_SUBMARINE: Index: tcCreditView.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcCreditView.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcCreditView.cpp 7 Nov 2004 03:40:44 -0000 1.9 --- tcCreditView.cpp 5 Dec 2004 02:49:47 -0000 1.10 *************** *** 267,270 **** --- 267,271 ---- } + #ifdef _DEBUG static unsigned int frameCount = 0; wxString infoString = wxString::Format("%d Y:%f\n", frameCount, fY); *************** *** 272,275 **** --- 273,277 ---- DrawText(infoString.c_str(), 10, 10, defaultFont.get(), nColorBright, 16.0f, LEFT_BASE_LINE); + #endif DrawBorder(); |
|
From: Dewitt C. <ddc...@us...> - 2004-12-05 02:49:56
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20399/include/sim Modified Files: tcLauncher.h tcLauncherState.h tcSimState.h tcSonar.h Log Message: Sonar work, passive sonar, torpedoes Index: tcLauncher.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcLauncher.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcLauncher.h 2 Dec 2004 04:17:24 -0000 1.6 --- tcLauncher.h 5 Dec 2004 02:49:46 -0000 1.7 *************** *** 93,99 **** --- 93,102 ---- void SetErrorCode(int code) {errorCode = code;} void SetChildClass(const std::string& childClass); + void SetChildQuantity(unsigned int quantity); void SetLoadState(bool state); unsigned int GetCompatibleCount() const; std::string GetCompatibleName(unsigned int idx) const; + bool IsItemCompatible(const std::string& item) const; + tcLauncher(); tcLauncher(tcLauncherDBObject* dbObj); Index: tcSimState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSimState.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tcSimState.h 14 Nov 2004 22:52:20 -0000 1.30 --- tcSimState.h 5 Dec 2004 02:49:46 -0000 1.31 *************** *** 64,67 **** --- 64,68 ---- class tcStream; class tcMissileObject; + class tcTorpedoObject; #define N_GAME_OBJECTS 1024 *************** *** 196,199 **** --- 197,201 ---- void EvaluateGuidedMissileHit(tcMissileObject* missile, tcGameObject* target); void EvaluateImpactWeaponHit(tcWeaponObject* weapon); + void EvaluateTorpedoHit(tcTorpedoObject* torp, tcGameObject* target); float GetFractionalDamage(float afDamage, tcGameObject *apGameObj); bool IsDetectedESM(tcESMSensor* apESM, const tcRadar* apEmitterRadar, float& rfAz_rad); Index: tcLauncherState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcLauncherState.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcLauncherState.h 29 Nov 2004 03:54:49 -0000 1.11 --- tcLauncherState.h 5 Dec 2004 02:49:46 -0000 1.12 *************** *** 88,92 **** tcLauncher* GetLauncher(unsigned int nLauncher); const tcLauncher* GetLauncher(unsigned nLauncher) const; ! const char* GetLauncherChildClass(unsigned nLauncher) const; int GetLauncherCount() const; int GetLauncherQuantity(unsigned anLauncher); --- 88,92 ---- tcLauncher* GetLauncher(unsigned int nLauncher); const tcLauncher* GetLauncher(unsigned nLauncher) const; ! std::string GetLauncherChildClass(unsigned nLauncher) const; int GetLauncherCount() const; int GetLauncherQuantity(unsigned anLauncher); Index: tcSonar.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSonar.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcSonar.h 2 Dec 2004 04:17:24 -0000 1.1 --- tcSonar.h 5 Dec 2004 02:49:46 -0000 1.2 *************** *** 60,65 **** --- 60,68 ---- void Serialize(tcFile& file, bool mbLoad); + bool IsPassive() const; virtual bool IsRadar() const; virtual bool IsSonar() const; + void SetActiveSonar(); + void SetPassiveSonar(); virtual void Update(double t); *************** *** 75,78 **** --- 78,83 ---- protected: + bool isPassive; + void UpdateSeeker(double t); void UpdateSensorMapActive(double t, const tcGameObject* target, float range_km); *************** *** 82,86 **** private: float last_az_rad; ///< [rad] target azimuth from last call to CanDetectTarget ! }; --- 87,91 ---- private: float last_az_rad; ///< [rad] target azimuth from last call to CanDetectTarget ! float last_snr_excess; ///< [dB] snr excess from last call to CanDetectTarget }; |
|
From: Dewitt C. <ddc...@us...> - 2004-12-05 02:49:55
|
Update of /cvsroot/gcblue/gcb_wx/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20399/scripts Modified Files: Menu.py Log Message: Sonar work, passive sonar, torpedoes Index: Menu.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/Menu.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Menu.py 2 Dec 2004 04:17:24 -0000 1.9 --- Menu.py 5 Dec 2004 02:49:46 -0000 1.10 *************** *** 57,60 **** --- 57,63 ---- def BuildUnitMenu(UnitMenu, UnitInfo): UnitMenu.Clear() + + if (not UnitInfo.IsValid()): + return UnitMenu.AddItemUI('Change heading','SetHeading','Heading') # Speed submenu |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:18:13
|
Update of /cvsroot/gcblue/gcb_wx/src/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/src/database Modified Files: tcDatabase.cpp tcStoresDBObject.cpp Added Files: tcSonarDBObject.cpp Log Message: Sonar work --- NEW FILE: tcSonarDBObject.cpp --- /** ** @file tcSonarDBObject.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" #if _MSC_VER > 1000 #pragma warning(disable:4786) // suppress warning for STL bug in VC6, see Q167355 in the MSDN Library. #endif // _MSC_VER > 1000 #include "tcSonarDBObject.h" #include "tcSonar.h" #include "common/tinyxml.h" #include "database/tcSqlReader.h" #include <sstream> //#include "tcSonar.h" #ifdef _DEBUG #define new DEBUG_NEW #endif namespace Database { /** * Calculate parameters based on database values. * e.g. alpha, attenuation coefficient */ void tcSonarDBObject::CalculateParams() { // Thorp eqn float freq_avg_kHz = 0.0005 * (minFrequency_Hz + maxFrequency_Hz); if (freq_avg_kHz < 0) freq_avg_kHz = 2.0f; float f2 = freq_avg_kHz * freq_avg_kHz; alpha = (0.1f * f2 / (1.0 + f2)) + (40.0f * f2 / (4100.0f + f2)) + (2.75e-4f * f2) + 0.003; alpha *= 1.0936133f; // convert dB/kyd to dB/km } tcSensorState* tcSonarDBObject::CreateSensor(tcGameObject* parent) { tcSonar* sonar = new tcSonar(this); sonar->SetParent(parent); return sonar; } /** * workaround for write serialization issue * @return true if db obj is a leaf obj */ bool tcSonarDBObject::IsLeaf() const { return mnClassID == DTYPE_SONAR; } /** * */ void tcSonarDBObject::PrintToFile(tcFile& file) { tcString s; tcSensorDBObject::PrintToFile(file); s.Format(" SL: %f, passive: %d, alpha: %f dB/km\n", SL, isPassive, alpha); file.WriteString(s.GetBuffer()); } /** * */ int tcSonarDBObject::Serialize(tcFile& file, bool mbLoad, UINT32 anVersion) { if (anVersion <= VERSION_1_0_3) { tcSensorDBObject::Serialize(file, mbLoad, anVersion); if (mbLoad) { wxASSERT(false); } else { wxASSERT(false); } return true; } else { tcSensorDBObject::Serialize(file,mbLoad,anVersion); if (mbLoad) { wxASSERT(false); } else { wxASSERT(false); } return true; } } /** * Loads/saves XML data for database object * @param load true to load, false to save */ void tcSonarDBObject::SerializeXml(TiXmlElement* node, bool load) { if (load) return; // write only for now wxASSERT(node); TiXmlElement* localNode = node->InsertEndChild(TiXmlElement("sonar"))->ToElement(); localNode->SetAttribute("SL", SL); localNode->SetAttribute("DI", DI); localNode->SetAttribute("DT", DT); localNode->SetAttribute("DTr", DTr); localNode->SetAttribute("minFrequency_Hz", minFrequency_Hz); localNode->SetAttribute("maxFrequency_Hz", maxFrequency_Hz); localNode->SetAttribute("isPassive", (int)isPassive); localNode->SetAttribute("audioFile", audioFile.c_str()); tcSensorDBObject::SerializeXml(node, load); } /** * Adds sql column definitions to columnString. This is used for * SQL create table command */ void tcSonarDBObject::AddSqlColumns(std::string& columnString) { tcSensorDBObject::AddSqlColumns(columnString); columnString += ","; columnString += "SL number(4),"; columnString += "DI number(4),"; columnString += "DT number(4),"; columnString += "DTr number(4),"; columnString += "minFrequency_Hz number(5),"; columnString += "maxFrequency_Hz number(5),"; columnString += "isPassive number(1),"; columnString += "audioFile varchar(30)"; } void tcSonarDBObject::ReadSql(tcSqlReader& entry) { tcSensorDBObject::ReadSql(entry); SL = entry.GetDouble("SL"); DI = entry.GetDouble("DI"); DT = entry.GetDouble("DT"); DTr = entry.GetDouble("DTr"); minFrequency_Hz = entry.GetDouble("minFrequency_Hz"); maxFrequency_Hz = entry.GetDouble("maxFrequency_Hz"); isPassive = entry.GetInt("isPassive") != 0; audioFile = entry.GetString("audioFile"); } void tcSonarDBObject::WriteSql(std::string& valueString) { tcSensorDBObject::WriteSql(valueString); std::stringstream s; s << ","; s << SL << ","; s << DI << ","; s << DT << ","; s << DTr << ","; s << minFrequency_Hz << ","; s << maxFrequency_Hz << ","; s << (long)isPassive << ","; s << "'" << audioFile.c_str() << "'"; valueString += s.str(); } tcSonarDBObject::tcSonarDBObject() : tcSensorDBObject(), SL(10), DI(3), DT(3), DTr(3), minFrequency_Hz(2000), maxFrequency_Hz(3000), isPassive(false) { mzClass = "Default Sonar"; mnClassID = DTYPE_SONAR; mfMaxRange_km = 10.0f; mfRefRange_km = 1.0f; mfFieldOfView_deg = 90.0f; mfScanPeriod_s = 4.0f; CalculateParams(); } tcSonarDBObject::tcSonarDBObject(tcSonarDBObject& obj) : tcSensorDBObject(obj), SL(obj.SL), DI(obj.DI), DT(obj.DT), DTr(obj.DTr), minFrequency_Hz(obj.minFrequency_Hz), maxFrequency_Hz(obj.maxFrequency_Hz), isPassive(obj.isPassive) { mnClassID = DTYPE_SONAR; CalculateParams(); } tcSonarDBObject::~tcSonarDBObject() { } } Index: tcDatabase.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcDatabase.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcDatabase.cpp 29 Nov 2004 03:55:04 -0000 1.20 --- tcDatabase.cpp 2 Dec 2004 04:17:24 -0000 1.21 *************** *** 43,46 **** --- 43,47 ---- #include "tcOpticalDBObject.h" #include "tcESMDBObject.h" + #include "tcSonarDBObject.h" #include "tcFixedDBObject.h" #include "tcAirDBObject.h" *************** *** 273,276 **** --- 274,284 ---- else serializer.Save(); } + // tcSonarDBObject + { + tcDBObjSerializerSql<tcSonarDBObject> + serializer(this, sqlConnection, "sonar"); + if (load) serializer.Load(); + else serializer.Save(); + } // tcAirDBObject { Index: tcStoresDBObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/database/tcStoresDBObject.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcStoresDBObject.cpp 29 Nov 2004 03:55:05 -0000 1.1 --- tcStoresDBObject.cpp 2 Dec 2004 04:17:24 -0000 1.2 *************** *** 42,45 **** --- 42,55 ---- { + /** + * workaround for write serialization issue + * @return true if db obj is a leaf obj + */ + bool tcStoresDBObject::IsLeaf() const + { + return mnClassID == DTYPE_STORES; + } + + void tcStoresDBObject::PrintToFile(tcFile& file) { *************** *** 192,196 **** s << ","; ! s << "'" << displayName << "',"; s << capacity << ","; s << moveTime << ","; --- 202,206 ---- s << ","; ! s << "'" << displayName.c_str() << "',"; s << capacity << ","; s << moveTime << ","; |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:18:13
|
Update of /cvsroot/gcblue/gcb_wx/include/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/include/scriptinterface Modified Files: tcSimPythonInterface.h Log Message: Sonar work Index: tcSimPythonInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/scriptinterface/tcSimPythonInterface.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcSimPythonInterface.h 23 Nov 2004 23:30:47 -0000 1.16 --- tcSimPythonInterface.h 2 Dec 2004 04:17:24 -0000 1.17 *************** *** 65,68 **** --- 65,69 ---- void AddItem(std::string caption, std::string command); void AddItemWithParam(std::string caption, std::string command, int param); + void AddItemWithTextParam(std::string caption, std::string command, std::string textParam); void AddItemUI(std::string caption, std::string callback, std::string input); void AddItemUIWithParam(std::string caption, std::string callback, *************** *** 102,106 **** void SetMenuPlatform(long anID); void SetMenuGroup(std::vector<long>& unitIds); ! void ProcessCommand(std::string command, int param = -1); void ProcessCallback(std::string command, float afData, int param); void ProcessCallback(std::string command, float afData1, float afData2, int param); --- 103,107 ---- void SetMenuPlatform(long anID); void SetMenuGroup(std::vector<long>& unitIds); ! void ProcessCommand(std::string command, int param = -1, std::string textParam = ""); void ProcessCallback(std::string command, float afData, int param); void ProcessCallback(std::string command, float afData1, float afData2, int param); |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:18:13
|
Update of /cvsroot/gcblue/gcb_wx/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/scripts Modified Files: Menu.py UnitCommands.py Log Message: Sonar work Index: UnitCommands.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/UnitCommands.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** UnitCommands.py 23 Nov 2004 23:30:53 -0000 1.11 --- UnitCommands.py 2 Dec 2004 04:17:24 -0000 1.12 *************** *** 181,185 **** else: SubInterface.RaiseRadarMast() ! def SetFractionalSpeed(UI, k, dispMessage=0): --- 181,203 ---- else: SubInterface.RaiseRadarMast() ! ! ! def Reload0(UI, weap_name): ! UI.LoadLauncher(0, weap_name) ! ! def Reload1(UI, weap_name): ! UI.LoadLauncher(1, weap_name) ! ! def Reload2(UI, weap_name): ! UI.LoadLauncher(2, weap_name) ! ! def Reload3(UI, weap_name): ! UI.LoadLauncher(3, weap_name) ! ! def Reload4(UI, weap_name): ! UI.LoadLauncher(4, weap_name) ! ! def Unload(UI, launcher): ! UI.UnloadLauncher(launcher) def SetFractionalSpeed(UI, k, dispMessage=0): Index: Menu.py =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/scripts/Menu.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Menu.py 23 Nov 2004 23:30:51 -0000 1.8 --- Menu.py 2 Dec 2004 04:17:24 -0000 1.9 *************** *** 129,132 **** --- 129,150 ---- UnitMenu.EndSubMenu() + + UnitMenu.AddItem('Mounts','') + UnitMenu.BeginSubMenu() + nCount = UnitInfo.GetLauncherCount() + for n in range(0, nCount): + weap_name = UnitInfo.GetLauncherWeaponName(n) + weap_qty = UnitInfo.GetLauncherQuantity(n) + if (weap_qty == 0): + nTypes = UnitInfo.GetLauncherTypesCount(n) + for k in range(0, nTypes): + type_name = UnitInfo.GetLauncherTypeName(n, k) + reload_qty = UnitInfo.GetMagazineQuantity(type_name) + if (reload_qty > 0): + UnitMenu.AddItemWithTextParam('Reload %s [%d]' % (type_name, reload_qty), 'Reload%d' % n, type_name) + else: + if (UnitInfo.CanMagazineAcceptItem(weap_name)): + UnitMenu.AddItemWithParam('Unload %s' % weap_name, 'Unload', n) + UnitMenu.EndSubMenu() |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:18:07
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/include/sim Modified Files: commandlist.h tcGameObject.h tcLauncher.h tcMenu.h tcObjectControl.h tcRadar.h tcSubObject.h Added Files: tcSonar.h Log Message: Sonar work Index: tcGameObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcGameObject.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** tcGameObject.h 23 Nov 2004 23:30:49 -0000 1.27 --- tcGameObject.h 2 Dec 2004 04:17:24 -0000 1.28 *************** *** 163,166 **** --- 163,167 ---- static void SetGameObjectDatabase(Database::tcDatabase *db) {database = db;} static void SetGameObjectMapData(tcMapData *md) {mapData = md;} + static void SetHookedId(long id) {hookedId = id;} static void SetSimState(tcSimState *ss) {simState = ss;} const tcGameObject* operator= (const tcGameObject *p) {return p;} *************** *** 173,177 **** --- 174,181 ---- static Database::tcDatabase *database; static tcSimState *simState; + static long hookedId; ///< id hooked by user, used for messaging only static bool clientMode; ///< true if running as multiplayer client + + bool IsHooked() const; }; #endif \ No newline at end of file Index: tcLauncher.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcLauncher.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcLauncher.h 29 Nov 2004 03:54:49 -0000 1.5 --- tcLauncher.h 2 Dec 2004 04:17:24 -0000 1.6 *************** *** 66,69 **** --- 66,70 ---- unsigned int mnUncommitted; ///< mnCurrent - mnUncommitted = # pending launch int errorCode; ///< used in multiplayer to pass error code to client + bool isLoading; ///< true if launcher is offline to load/unload weapons tsGeoPoint msDatum; ///< datum to pass to weapon nav guidance *************** *** 92,95 **** --- 93,97 ---- void SetErrorCode(int code) {errorCode = code;} void SetChildClass(const std::string& childClass); + void SetLoadState(bool state); unsigned int GetCompatibleCount() const; std::string GetCompatibleName(unsigned int idx) const; Index: tcObjectControl.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcObjectControl.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcObjectControl.h 29 Nov 2004 03:54:49 -0000 1.10 --- tcObjectControl.h 2 Dec 2004 04:17:24 -0000 1.11 *************** *** 90,94 **** BS_READYING, BS_READY, ! BS_ACTIVE }; --- 90,95 ---- BS_READYING, BS_READY, ! BS_ACTIVE, ! BS_LOADING }; Index: tcMenu.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcMenu.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcMenu.h 1 Nov 2004 03:17:17 -0000 1.8 --- tcMenu.h 2 Dec 2004 04:17:24 -0000 1.9 *************** *** 48,51 **** --- 48,52 ---- std::string mzCommand; std::string mzUserInput; + std::string textParam; int mnCommand; bool mbSelected; *************** *** 57,61 **** void Clear() { ! mzCaption="";mzCommand="";mzUserInput=""; mnCommand=0;mbSelected=0;mbTop=0;mbBottom=0;mpSubMenu=NULL; } --- 58,62 ---- void Clear() { ! mzCaption="";mzCommand="";mzUserInput="";textParam=""; mnCommand=0;mbSelected=0;mbTop=0;mbBottom=0;mpSubMenu=NULL; } *************** *** 72,75 **** --- 73,77 ---- void AddItem(std::string caption, int command); void AddItem(std::string caption, std::string command, int param = -1); + void AddItem(std::string caption, std::string command, std::string textParam); void AddItemUI(std::string caption, std::string callback, std::string input, int param = -1); void BeginSubMenu(); Index: tcRadar.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcRadar.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcRadar.h 23 Nov 2004 23:30:50 -0000 1.11 --- tcRadar.h 2 Dec 2004 04:17:24 -0000 1.12 *************** *** 34,40 **** } using Database::tcRadarDBObject; ! /** ! * ! */ struct tsRadarTargetInfo { --- 34,39 ---- } using Database::tcRadarDBObject; ! ! /* struct tsRadarTargetInfo { *************** *** 46,49 **** --- 45,49 ---- float mfRCS_dbsm; } ; + */ class tcGameObject; Index: tcSubObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSubObject.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcSubObject.h 23 Nov 2004 23:30:50 -0000 1.1 --- tcSubObject.h 2 Dec 2004 04:17:24 -0000 1.2 *************** *** 81,87 **** --- 81,89 ---- bool periscopeRaised; float periscopeDepth_m; ///< periscope depth (positive number) + float lastDepth_m; ///< for depth notification messages virtual void UpdateEffects(); virtual void UpdateHeading(float dt_s); + virtual void UpdateMessages(); virtual void UpdateSensors(double t); virtual void UpdateSpeed(float dt_s); Index: commandlist.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/commandlist.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** commandlist.h 8 Aug 2004 00:31:33 -0000 1.4 --- commandlist.h 2 Dec 2004 04:17:24 -0000 1.5 *************** *** 49,52 **** --- 49,55 ---- #define MAX_QUEUED_COMMANDS 32 + /** + * + */ struct tsCommandInfo { *************** *** 60,63 **** --- 63,67 ---- bool mbCallback; bool mbGetUserInput; + std::string textParam; ///< string parameter for python }; *************** *** 100,105 **** } } ! // version without user input and callback ! void AddPythonCommand(const char *azCommand, int param = -1) { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; --- 104,112 ---- } } ! /** ! * version without user input and callback ! */ ! void AddPythonCommand(const char *azCommand, int param = -1) ! { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; *************** *** 107,111 **** newcmd.mbCallback = false; newcmd.mbGetUserInput = false; ! newcmd.mnData = param; strcpy(newcmd.mzString , azCommand); strcpy(newcmd.mzUserInput, ""); --- 114,119 ---- newcmd.mbCallback = false; newcmd.mbGetUserInput = false; ! newcmd.mnData = param; // int param ! newcmd.textParam = ""; // text param strcpy(newcmd.mzString , azCommand); strcpy(newcmd.mzUserInput, ""); *************** *** 114,117 **** --- 122,146 ---- } } + + /** + * version without user input and callback + */ + void AddPythonCommand(const char *azCommand, std::string textParam) + { + tsCommandInfo newcmd; + newcmd.meCmd = (teGameCommand)0; + newcmd.mbUsePython = true; + newcmd.mbCallback = false; + newcmd.mbGetUserInput = false; + newcmd.mnData = -1; // int param + newcmd.textParam = textParam; + strcpy(newcmd.mzString , azCommand); + strcpy(newcmd.mzUserInput, ""); + if (mnCount < MAX_QUEUED_COMMANDS) { + maCommand[mnCount++] = newcmd; + } + } + + /* GetUserInput is called to add a command to get user input data. ** Once the user input is complete, the callback function is called though *************** *** 119,123 **** ** callback function along with an optional parameter. */ ! void GetUserInput(const char *azCallback, const char *azUserInput, int param = -1) { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; --- 148,153 ---- ** callback function along with an optional parameter. */ ! void GetUserInput(const char *azCallback, const char *azUserInput, int param = -1) ! { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; *************** *** 126,129 **** --- 156,160 ---- newcmd.mbGetUserInput = true; newcmd.mnData = param; + newcmd.textParam = ""; strcpy(newcmd.mzString , azCallback); strcpy(newcmd.mzUserInput, azUserInput); *************** *** 132,137 **** } } ! // version for callback ! void AddPythonCallback(const char *azCallback, const char *azUserInput, int param = -1) { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; --- 163,171 ---- } } ! /** ! * version for callback ! */ ! void AddPythonCallback(const char *azCallback, const char *azUserInput, int param = -1) ! { tsCommandInfo newcmd; newcmd.meCmd = (teGameCommand)0; *************** *** 140,143 **** --- 174,178 ---- newcmd.mbGetUserInput = false; newcmd.mnData = param; + newcmd.textParam = ""; strcpy(newcmd.mzString , azCallback); strcpy(newcmd.mzUserInput, azUserInput); --- NEW FILE: tcSonar.h --- /** ** @file tcSonar.h */ /* 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 **/ #if _MSC_VER > 1000 #pragma once #endif #ifndef _TCSONAR_H_ #define _TCSONAR_H_ #include "tcSensorState.h" #include <vector> namespace Database { class tcSonarDBObject; } using Database::tcSonarDBObject; class tcGameObject; class tcStream; class tcUpdateStream; /** * Class to handle surveillance, fire control, and seeker radars. * May want to break this up use derived classes for detailed * functions. * */ class tcSonar : public tcSensorState { public: tcSonarDBObject *mpDBObj; virtual bool CanDetectTarget(const tcGameObject* target, float& range_km); virtual bool InitFromDatabase(long key); ///< initializes sensor using database data at key void Serialize(tcFile& file, bool mbLoad); virtual bool IsRadar() const; virtual bool IsSonar() const; virtual void Update(double t); tcSonar& operator=(tcSonar& ss); virtual tcUpdateStream& operator<<(tcUpdateStream& stream); virtual tcUpdateStream& operator>>(tcUpdateStream& stream); tcSonar* Clone(); tcSonar(); tcSonar(tcSonarDBObject* dbObj); virtual ~tcSonar(); protected: void UpdateSeeker(double t); void UpdateSensorMapActive(double t, const tcGameObject* target, float range_km); void UpdateSensorMapPassive(double t, const tcGameObject* target, float range_km, float az_rad); void UpdateSurveillance(double t); void UpdateTrack(const tcGameObject* target, double t); private: float last_az_rad; ///< [rad] target azimuth from last call to CanDetectTarget }; #endif |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:18:06
|
Update of /cvsroot/gcblue/gcb_wx/include/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/include/database Modified Files: tcDatabaseObject.h tcRadarDBObject.h tcStoresDBObject.h Added Files: tcSonarDBObject.h Log Message: Sonar work --- NEW FILE: tcSonarDBObject.h --- /** ** @file tcSonarDBObject.h */ /* 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 */ #ifndef _SONARDBOBJECT_H_ #define _SONARDBOBJECT_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "tcSensorDBObject.h" class TiXmlElement; namespace Database { class tcSqlReader; /** * */ class tcSonarDBObject : public tcSensorDBObject { public: float SL; ///< [dB] source level (active only) float DI; ///< [dB] receive directivity index float DT; ///< [dB] detectability threshold in noise float DTr; ///< [dB] detectability threshold with reverberation background float minFrequency_Hz; float maxFrequency_Hz; bool isPassive; std::string audioFile; ///< filename for audio sound effect (active only) float alpha; ///< CALCULATED attenuation coefficent in dB/km virtual tcSensorState* CreateSensor(tcGameObject* parent); ///< factory method virtual const char* GetClassName() {return "Sonar";} ///< returns class name of database object bool IsLeaf() const; ///< returns true if db obj is a leaf obj virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, unsigned int anVersion); virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization static void AddSqlColumns(std::string& columnString); void ReadSql(tcSqlReader& entry); void WriteSql(std::string& valueString); tcSonarDBObject(); tcSonarDBObject(tcSonarDBObject& obj); ///< copy constructor virtual ~tcSonarDBObject(); private: void CalculateParams(); }; } // namespace Database #endif Index: tcStoresDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcStoresDBObject.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcStoresDBObject.h 29 Nov 2004 03:54:49 -0000 1.1 --- tcStoresDBObject.h 2 Dec 2004 04:17:23 -0000 1.2 *************** *** 51,54 **** --- 51,55 ---- virtual const char* GetClassName() {return "Stores";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); Index: tcRadarDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcRadarDBObject.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcRadarDBObject.h 29 Nov 2004 03:54:49 -0000 1.11 --- tcRadarDBObject.h 2 Dec 2004 04:17:23 -0000 1.12 *************** *** 33,68 **** namespace Database { ! class tcSqlReader; ! class tcRadarDBObject : public tcSensorDBObject ! { ! public: ! float mfMinRange_km; ///< [km] min range ! float mfERP_dBW; ///< [dBW] effective radiated power, peak ! float mfMinRangeRate_mps; ///< minimum detectable range rate ! unsigned int maxFireControlTracks; ///< max number of simultaneous fire control tracks ! bool isSemiactive; ///< set true if this is a semiactive radar ! bool isCommandReceiver; ///< set true if this is a command guidance receiver (a workaround) ! bool mbDetectsSurface; ///< set true if detects surface targets ! bool mbDetectsAir; ///< set true if detects airborne targets ! bool mbDetectsGround; ///< set true if detects ground targets ! virtual tcSensorState* CreateSensor(tcGameObject* parent); ///< factory method ! virtual const char* GetClassName() {return "Radar";} ///< returns class name of database object ! bool IsLeaf() const; ///< returns true if db obj is a leaf obj ! virtual void PrintToFile(tcFile& file); ! int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); ! int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization ! virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings ! static void AddSqlColumns(std::string& columnString); ! void ReadSql(tcSqlReader& entry); ! void WriteSql(std::string& valueString); ! tcRadarDBObject(); ! tcRadarDBObject(tcRadarDBObject& obj); ///< copy constructor ! virtual ~tcRadarDBObject(); ! }; } // namespace Database --- 33,68 ---- namespace Database { ! class tcSqlReader; ! class tcRadarDBObject : public tcSensorDBObject ! { ! public: ! float mfMinRange_km; ///< [km] min range ! float mfERP_dBW; ///< [dBW] effective radiated power, peak ! float mfMinRangeRate_mps; ///< minimum detectable range rate ! unsigned int maxFireControlTracks; ///< max number of simultaneous fire control tracks ! bool isSemiactive; ///< set true if this is a semiactive radar ! bool isCommandReceiver; ///< set true if this is a command guidance receiver (a workaround) ! bool mbDetectsSurface; ///< set true if detects surface targets ! bool mbDetectsAir; ///< set true if detects airborne targets ! bool mbDetectsGround; ///< set true if detects ground targets ! virtual tcSensorState* CreateSensor(tcGameObject* parent); ///< factory method ! virtual const char* GetClassName() {return "Radar";} ///< returns class name of database object ! bool IsLeaf() const; ///< returns true if db obj is a leaf obj ! virtual void PrintToFile(tcFile& file); ! int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); ! int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization ! virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings ! static void AddSqlColumns(std::string& columnString); ! void ReadSql(tcSqlReader& entry); ! void WriteSql(std::string& valueString); ! tcRadarDBObject(); ! tcRadarDBObject(tcRadarDBObject& obj); ///< copy constructor ! virtual ~tcRadarDBObject(); ! }; } // namespace Database Index: tcDatabaseObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDatabaseObject.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcDatabaseObject.h 29 Nov 2004 03:54:49 -0000 1.17 --- tcDatabaseObject.h 2 Dec 2004 04:17:23 -0000 1.18 *************** *** 91,96 **** #define MTYPE_AIRFIELD 13 #define MTYPE_BALLISTIC 14 ! // database object types (database class identifier) #define DTYPE_OBJECT 0 #define DTYPE_GENERIC 1 --- 91,97 ---- #define MTYPE_AIRFIELD 13 #define MTYPE_BALLISTIC 14 + ! // database object types (database class identifier / typeid) #define DTYPE_OBJECT 0 #define DTYPE_GENERIC 1 *************** *** 107,110 **** --- 108,113 ---- #define DTYPE_OPTICAL 12 #define DTYPE_STORES 13 + #define DTYPE_SONAR 14 + #define DTYPE_TORPEDO 15 #define DTYPE_NULL 0xFFFFFFFF |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:18:06
|
Update of /cvsroot/gcblue/gcb_wx/include/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/include/graphics Modified Files: tcMessageCenter.h tcMessageInterface.h Log Message: Sonar work Index: tcMessageCenter.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMessageCenter.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcMessageCenter.h 14 Nov 2004 22:52:20 -0000 1.1 --- tcMessageCenter.h 2 Dec 2004 04:17:23 -0000 1.2 *************** *** 44,47 **** --- 44,48 ---- public: void AddMessage(const std::string& channel, const std::string& msg); + void PopupMessage(const std::string& msg); void Clear(); virtual void Draw(); *************** *** 58,61 **** --- 59,64 ---- tcRect channelTab; ///< rectangle for next new channel selection button tcRect defaultTextRect; ///< text box rectangle for channels + wxPoint popupBase; + unsigned int popupCount; tcMessageChannel* GetChannel(const std::string& channelName); Index: tcMessageInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/graphics/tcMessageInterface.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcMessageInterface.h 14 Nov 2004 22:52:20 -0000 1.1 --- tcMessageInterface.h 2 Dec 2004 04:17:23 -0000 1.2 *************** *** 41,44 **** --- 41,45 ---- public: void ChannelMessage(const std::string& channelName, const std::string& msg); + void PopupMessage(const std::string& msg); static tcMessageInterface* Get(); ///< singleton accessor |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:18:06
|
Update of /cvsroot/gcblue/gcb_wx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820 Modified Files: GCblue.vcproj Log Message: Sonar work Index: GCblue.vcproj =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/GCblue.vcproj,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** GCblue.vcproj 23 Nov 2004 23:30:29 -0000 1.73 --- GCblue.vcproj 2 Dec 2004 04:17:22 -0000 1.74 *************** *** 521,524 **** --- 521,530 ---- </File> <File + RelativePath=".\src\sim\tcSonar.cpp"> + </File> + <File + RelativePath=".\src\sim\tcStores.cpp"> + </File> + <File RelativePath=".\src\sim\tcSubObject.cpp"> </File> *************** *** 588,594 **** --- 594,609 ---- </File> <File + RelativePath=".\src\database\tcSonarDBObject.cpp"> + </File> + <File RelativePath=".\src\database\tcSqlReader.cpp"> </File> <File + RelativePath=".\src\database\tcStoresDBObject.cpp"> + </File> + <File + RelativePath=".\src\database\tcTorpedoDBObject.cpp"> + </File> + <File RelativePath=".\src\database\tcWeaponDBObject.cpp"> </File> *************** *** 1403,1406 **** --- 1418,1427 ---- </File> <File + RelativePath=".\include\sim\tcSonar.h"> + </File> + <File + RelativePath=".\include\sim\tcStores.h"> + </File> + <File RelativePath=".\include\sim\tcSubObject.h"> </File> *************** *** 1479,1485 **** --- 1500,1515 ---- </File> <File + RelativePath=".\include\database\tcSonarDBObject.h"> + </File> + <File RelativePath=".\include\database\tcSqlReader.h"> </File> <File + RelativePath=".\include\database\tcStoresDBObject.h"> + </File> + <File + RelativePath=".\include\database\tcTorpedoDBObject.h"> + </File> + <File RelativePath=".\include\database\tcWeaponDBObject.h"> </File> |
|
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; } |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:17:39
|
Update of /cvsroot/gcblue/gcb_wx/xml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/xml Modified Files: options.xml Log Message: Sonar work Index: options.xml =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/xml/options.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** options.xml 23 Nov 2004 23:31:19 -0000 1.7 --- options.xml 2 Dec 2004 04:17:27 -0000 1.8 *************** *** 4,6 **** --- 4,8 ---- <LastScenarioPath>Test.SubTest.py</LastScenarioPath> <LastScenarioName>SubTest</LastScenarioName> + <xCopyDatabase /> + <WriteXmlDatabase /> </Options> |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:17:38
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/src/scriptinterface Modified Files: tcSimPythonInterface.cpp Log Message: Sonar work Index: tcSimPythonInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcSimPythonInterface.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** tcSimPythonInterface.cpp 23 Nov 2004 23:30:58 -0000 1.21 --- tcSimPythonInterface.cpp 2 Dec 2004 04:17:25 -0000 1.22 *************** *** 69,72 **** --- 69,86 ---- mpMenu->AddItem(caption, command, param); } + + /** + * Adds a menu item with command string and command parameter + * @param caption caption for menu item + * @param command command string for item + * @param textParam std::string parameter + */ + void tcMenuInterface::AddItemWithTextParam(std::string caption, std::string command, + std::string textParam) + { + if (mpMenu == NULL) {return;} + mpMenu->AddItem(caption, command, textParam); + } + /** * Adds a menu item that gets a coordinate or target from the user via a mouse click *************** *** 349,353 **** } ! void tcSimPythonInterface::ProcessCommand(std::string command, int param) { std::string s = "Menu."; --- 363,367 ---- } ! void tcSimPythonInterface::ProcessCommand(std::string command, int param, std::string textParam) { std::string s = "Menu."; *************** *** 366,369 **** --- 380,389 ---- s += zBuff; } + else if (textParam.length() > 0) + { + s += ",'"; + s += textParam; + s += "'"; + } s += ")\n"; *************** *** 586,589 **** --- 606,610 ---- .def("AddItem", &tcMenuInterface::AddItem) .def("AddItemWithParam", &tcMenuInterface::AddItemWithParam) + .def("AddItemWithTextParam", &tcMenuInterface::AddItemWithTextParam) .def("AddItemUI",&tcMenuInterface::AddItemUI) .def("AddItemUIWithParam",&tcMenuInterface::AddItemUIWithParam) |
|
From: Dewitt C. <ddc...@us...> - 2004-12-02 04:17:35
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31820/src/graphics Modified Files: tcMessageCenter.cpp tcMessageInterface.cpp tcPopupControl.cpp Log Message: Sonar work Index: tcPopupControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcPopupControl.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcPopupControl.cpp 2 Nov 2004 04:23:56 -0000 1.5 --- tcPopupControl.cpp 2 Dec 2004 04:17:25 -0000 1.6 *************** *** 198,201 **** --- 198,202 ---- /** * modified to handle panel, TODO system needs rework + * This is a mess. */ void tcPopupControl::OnLButtonDown(wxMouseEvent& event) *************** *** 212,215 **** --- 213,217 ---- wxPoint p = event.GetPosition(); wxRealPoint pointf((float)p.x,(float)p.y); + std::string textParam = ""; if (mpMenu != NULL) *************** *** 221,224 **** --- 223,227 ---- pythonCommand = pmd->mzCommand; uiCommand = pmd->mzUserInput; + textParam = pmd->textParam; callCommand = true; } *************** *** 256,260 **** else { ! mpCommandInterface->AddPythonCommand(pythonCommand.c_str(), builtInCommand); // builtInCommand used as a param here } } --- 259,270 ---- else { ! if (builtInCommand == -1) ! { ! mpCommandInterface->AddPythonCommand(pythonCommand.c_str(), textParam); ! } ! else ! { ! mpCommandInterface->AddPythonCommand(pythonCommand.c_str(), builtInCommand); // builtInCommand used as a param here ! } } } Index: tcMessageInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMessageInterface.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcMessageInterface.cpp 14 Nov 2004 22:52:21 -0000 1.1 --- tcMessageInterface.cpp 2 Dec 2004 04:17:25 -0000 1.2 *************** *** 45,48 **** --- 45,51 ---- } + /** + * + */ tcMessageInterface* tcMessageInterface::Get() { *************** *** 53,56 **** --- 56,69 ---- /** + * + */ + void tcMessageInterface::PopupMessage(const std::string& msg) + { + wxASSERT(messageCenter); + + messageCenter->PopupMessage(msg); + } + + /** * Must be called before using DisplayChannelMessage */ Index: tcMessageCenter.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcMessageCenter.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcMessageCenter.cpp 23 Nov 2004 23:30:56 -0000 1.2 --- tcMessageCenter.cpp 2 Dec 2004 04:17:25 -0000 1.3 *************** *** 24,27 **** --- 24,28 ---- #include "tcMessageCenter.h" #include "tcMessageChannel.h" + #include "tcPopupMessage.h" #include <stdio.h> *************** *** 170,173 **** --- 171,191 ---- } + /** + * Pops up a message for the user to see. Manages placement of + * popup to allow multiple popups to be displayed simultaneously. + */ + void tcMessageCenter::PopupMessage(const std::string& msg) + { + wxPoint pos = popupBase; + pos.y += popupCount * 25; + + + tcPopupMessage* popup = new tcPopupMessage(msg, pos, 200); + popup->SetActive(true); + + popupCount = (popupCount + 1) % 4; + } + + /** *************** *** 177,181 **** const wxSize& size, const wxString& name) : tc3DWindow(parent, pos, size, name, 0), ! activeChannelName("") { channelTab.Set(10, 140, 10, 30); --- 195,201 ---- const wxSize& size, const wxString& name) : tc3DWindow(parent, pos, size, name, 0), ! activeChannelName(""), ! popupBase(50, 70), ! popupCount(0) { channelTab.Set(10, 140, 10, 30); |
|
From: Dewitt C. <ddc...@us...> - 2004-11-29 03:55:16
|
Update of /cvsroot/gcblue/gcb_wx/src/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21076/src/scriptinterface Modified Files: tcPlatformInterface.cpp tcPlatformInterfaceExtensionB.cpp Log Message: Magazine class tcStores and related Index: tcPlatformInterface.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterface.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** tcPlatformInterface.cpp 23 Nov 2004 23:30:57 -0000 1.29 --- tcPlatformInterface.cpp 29 Nov 2004 03:55:05 -0000 1.30 *************** *** 44,47 **** --- 44,48 ---- #include "tcLauncherState.h" #include "tcLauncher.h" + #include "tcStores.h" *************** *** 555,558 **** --- 556,689 ---- } + + /** + * + */ + int tcPlatformInterface::GetLauncherTypesCount(int anLauncher) + { + if (tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher)) + { + return (int)launcher->GetCompatibleCount(); + } + else + { + return 0; + } + } + + /** + * + */ + std::string tcPlatformInterface::GetLauncherTypeName(int anLauncher, int anType) + { + if (tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher)) + { + return launcher->GetCompatibleName(anType); + } + else + { + return std::string("Error"); + } + } + + /** + * true if any of the magazines on the platform can accept the item + */ + bool tcPlatformInterface::CanMagazineAcceptItem(std::string item) + { + unsigned int nMagazines = mpPlatformObj->GetMagazineCount(); + for (unsigned int n=0; n<nMagazines; n++) + { + tcStores* mag = mpPlatformObj->GetMagazine(n); + if (!mag->IsFull() && mag->IsCompatible(item)) return true; + } + return false; + } + + /** + * + */ + int tcPlatformInterface::GetMagazineQuantity(std::string item) + { + int quantity = 0; + unsigned int nMagazines = mpPlatformObj->GetMagazineCount(); + for (unsigned int n=0; n<nMagazines; n++) + { + tcStores* mag = mpPlatformObj->GetMagazine(n); + quantity += mag->CurrentItemQuantity(item); + } + return quantity; + } + + /** + * + */ + void tcPlatformInterface::LoadLauncher(int anLauncher, std::string item) + { + // verify launcher is empty and item is compatible with launcher + tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher); + if (!launcher) return; + if (launcher->mnCurrent) + { + return; + } + + bool found = false; + int nTypes = (int)launcher->GetCompatibleCount(); + for (int k=0; (k<nTypes) && !found; k++) + { + if (launcher->GetCompatibleName(unsigned(k)) == item) + { + found = true; + } + } + if (!found) + { + return; + } + + + unsigned int nMagazines = mpPlatformObj->GetMagazineCount(); + for (unsigned int n=0; n<nMagazines; n++) + { + tcStores* mag = mpPlatformObj->GetMagazine(n); + if (mag->CurrentItemQuantity(item)) + { + mag->LoadLauncher(anLauncher, item); + return; + } + } + + // error not found + } + + /** + * + */ + void tcPlatformInterface::UnloadLauncher(int anLauncher) + { + tcLauncher* launcher = mpPlatformObj->GetLauncher(anLauncher); + if (!launcher) return; + if (!launcher->mpChildDBObj) return; + + std::string item = launcher->mpChildDBObj->mzClass.mz; + + unsigned int nMagazines = mpPlatformObj->GetMagazineCount(); + for (unsigned int n=0; n<nMagazines; n++) + { + tcStores* mag = mpPlatformObj->GetMagazine(n); + if (!mag->IsFull() && mag->IsCompatible(item)) + { + mag->UnloadLauncher(anLauncher); + return; + } + } + + // error not found + } + + + + bool tcPlatformInterface::HasOrders() { Index: tcPlatformInterfaceExtensionB.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/scriptinterface/tcPlatformInterfaceExtensionB.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcPlatformInterfaceExtensionB.cpp 23 Nov 2004 23:30:58 -0000 1.16 --- tcPlatformInterfaceExtensionB.cpp 29 Nov 2004 03:55:05 -0000 1.17 *************** *** 98,101 **** --- 98,109 ---- .def("GetLauncherInterceptTime", &tcPlatformInterface::GetLauncherInterceptTime) + .def("GetLauncherTypesCount", &tcPlatformInterface::GetLauncherTypesCount) + .def("GetLauncherTypeName", &tcPlatformInterface::GetLauncherTypeName) + .def("CanMagazineAcceptItem", &tcPlatformInterface::CanMagazineAcceptItem) + .def("GetMagazineQuantity", &tcPlatformInterface::GetMagazineQuantity) + .def("LoadLauncher", &tcPlatformInterface::LoadLauncher) + .def("UnloadLauncher", &tcPlatformInterface::UnloadLauncher) + + // orders .def("AddNavOrder",&tcPlatformInterface::AddNavOrder) |
|
From: Dewitt C. <ddc...@us...> - 2004-11-29 03:55:15
|
Update of /cvsroot/gcblue/gcb_wx/src/graphics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21076/src/graphics Modified Files: tcPanel.cpp Log Message: Magazine class tcStores and related Index: tcPanel.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/graphics/tcPanel.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcPanel.cpp 2 Nov 2004 04:23:56 -0000 1.5 --- tcPanel.cpp 29 Nov 2004 03:55:05 -0000 1.6 *************** *** 268,273 **** boundingBox.top = (bottom > boundingBox.top) ? bottom : boundingBox.top; } ! boundingBox.right += border_width; ! boundingBox.top += border_width; titleBox = boundingBox; --- 268,273 ---- boundingBox.top = (bottom > boundingBox.top) ? bottom : boundingBox.top; } ! boundingBox.right += border_width + 10.0f; ! boundingBox.top += border_width + 10.0f; titleBox = boundingBox; |
|
From: Dewitt C. <ddc...@us...> - 2004-11-29 03:55:03
|
Update of /cvsroot/gcblue/gcb_wx/include/database In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21010/include/database Modified Files: tcAirDBObject.h tcBallisticDBObject.h tcDBObjSerializerSql.h tcDatabaseObject.h tcESMDBObject.h tcFixedDBObject.h tcFlightportDBObject.h tcGenericDBObject.h tcLauncherDBObject.h tcMissileDBObject.h tcOpticalDBObject.h tcRadarDBObject.h tcSensorDBObject.h tcWeaponDBObject.h Added Files: tcStoresDBObject.h Log Message: Magazine class tcStores and related Index: tcGenericDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcGenericDBObject.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tcGenericDBObject.h 6 Nov 2004 15:13:39 -0000 1.11 --- tcGenericDBObject.h 29 Nov 2004 03:54:49 -0000 1.12 *************** *** 53,57 **** MAXLAUNCHERS = 8, MAXSENSORS = 8, ! MAXANIMATIONS = 4 }; float mfRcs_dbsm; ///< radar cross section, [dBsm] --- 53,58 ---- MAXLAUNCHERS = 8, MAXSENSORS = 8, ! MAXANIMATIONS = 4, ! MAXMAGAZINES = 3 }; float mfRcs_dbsm; ///< radar cross section, [dBsm] *************** *** 71,77 **** --- 72,81 ---- int mnNumLaunchers; + int mnNumMagazines; int mnNumSensors; tcDBString maLauncherClass[MAXLAUNCHERS]; + tcDBString maMagazineClass[MAXMAGAZINES]; tcDBString maSensorClass[MAXSENSORS]; + std::vector<long> sensorId; ///< database id's of sensors float launcherAz[MAXLAUNCHERS]; ///< pointing angles of launchers in degrees *************** *** 85,88 **** --- 89,93 ---- void Animate3DModel(); virtual const char* GetClassName() {return "Generic";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj tcFlightportDBObject* GetFlightport(); tc3DPoint GetLauncherPosition(unsigned n); --- NEW FILE: tcStoresDBObject.h --- /** ** @file tcStoresDBObject.h */ /* 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 */ #ifndef _STORESDBOBJECT_H_ #define _STORESDBOBJECT_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "tcDatabaseObject.h" #include <vector> class TiXmlElement; namespace Database { class tcSqlReader; #define MAX_LAUNCHER_CONFIGURATIONS 8 // number of weapon class/capacity options supported /** * Database object to describe storage, used for weapons magazines, etc. */ class tcStoresDBObject : public tcDatabaseObject { public: enum {MAX_STORES = 4}; std::string displayName; unsigned int capacity; float moveTime; ///< time to unload to or load from stores std::vector<std::string> compatibleItems; virtual const char* GetClassName() {return "Stores";} ///< returns class name of database object virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings static void AddSqlColumns(std::string& columnString); void ReadSql(tcSqlReader& entry); void WriteSql(std::string& valueString); tcStoresDBObject(); tcStoresDBObject(tcStoresDBObject& obj); ///< copy constructor virtual ~tcStoresDBObject(); }; } // namespace Database #endif Index: tcRadarDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcRadarDBObject.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcRadarDBObject.h 6 Nov 2004 15:13:39 -0000 1.10 --- tcRadarDBObject.h 29 Nov 2004 03:54:49 -0000 1.11 *************** *** 50,53 **** --- 50,54 ---- virtual tcSensorState* CreateSensor(tcGameObject* parent); ///< factory method virtual const char* GetClassName() {return "Radar";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); Index: tcSensorDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcSensorDBObject.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcSensorDBObject.h 6 Nov 2004 15:13:39 -0000 1.7 --- tcSensorDBObject.h 29 Nov 2004 03:54:49 -0000 1.8 *************** *** 47,50 **** --- 47,51 ---- virtual tcSensorState* CreateSensor(tcGameObject* parent); ///< factory method virtual const char* GetClassName() {return "Sensor";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); Index: tcFixedDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcFixedDBObject.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcFixedDBObject.h 8 Aug 2004 00:31:32 -0000 1.5 --- tcFixedDBObject.h 29 Nov 2004 03:54:49 -0000 1.6 *************** *** 39,42 **** --- 39,43 ---- public: virtual const char* GetClassName() {return "Fixed";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); Index: tcLauncherDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcLauncherDBObject.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcLauncherDBObject.h 8 Aug 2004 00:31:32 -0000 1.8 --- tcLauncherDBObject.h 29 Nov 2004 03:54:49 -0000 1.9 *************** *** 33,66 **** namespace Database { ! class tcSqlReader; #define MAX_LAUNCHER_CONFIGURATIONS 8 // number of weapon class/capacity options supported ! class tcLauncherDBObject : public tcDatabaseObject ! { ! public: ! float cycleTime; ///< down time between shots ! tcDBString mzChildClass; ///< class of platform to launch (simple model) ! UINT mnCapacity; ///< max number of launch objects held (simple model) ! tcDBString maChildClass[MAX_LAUNCHER_CONFIGURATIONS]; ///< array for multiple options ! UINT maCapacity[MAX_LAUNCHER_CONFIGURATIONS]; ///< array for mult configs ! UINT mnConfigurations; ! std::string fireControlSensorClass; ///< class of sensor on platform for fire control ! ///< (track required to launch) ! virtual const char* GetClassName() {return "Launcher";} ///< returns class name of database object ! virtual void PrintToFile(tcFile& file); ! int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); ! int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization ! virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings ! static void AddSqlColumns(std::string& columnString); ! void ReadSql(tcSqlReader& entry); ! void WriteSql(std::string& valueString); ! tcLauncherDBObject(); ! tcLauncherDBObject(tcLauncherDBObject& obj); ///< copy constructor ! virtual ~tcLauncherDBObject(); ! }; } // namespace Database --- 33,71 ---- namespace Database { ! class tcSqlReader; #define MAX_LAUNCHER_CONFIGURATIONS 8 // number of weapon class/capacity options supported + /** + * + */ + class tcLauncherDBObject : public tcDatabaseObject + { + public: + float cycleTime; ///< down time between shots + tcDBString mzChildClass; ///< class of platform to launch (simple model) + UINT mnCapacity; ///< max number of launch objects held (simple model) + tcDBString maChildClass[MAX_LAUNCHER_CONFIGURATIONS]; ///< array for multiple options + UINT maCapacity[MAX_LAUNCHER_CONFIGURATIONS]; ///< array for mult configs + UINT mnConfigurations; + std::string fireControlSensorClass; ///< class of sensor on platform for fire control + ///< (track required to launch) + std::string displayName; ///< name to display in vehicle controls ! virtual const char* GetClassName() {return "Launcher";} ///< returns class name of database object ! bool IsLeaf() const; ///< returns true if db obj is a leaf obj ! virtual void PrintToFile(tcFile& file); ! int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); ! int SerializeCSV(CsvTranslator* csv, bool mbLoad); ///< CSV serialization ! virtual void SerializeXml(TiXmlElement* node, bool load); ///< XML serialization ! static int WriteCSVHeader(CsvTranslator* csv); ///< writes column headings ! static void AddSqlColumns(std::string& columnString); ! void ReadSql(tcSqlReader& entry); ! void WriteSql(std::string& valueString); ! tcLauncherDBObject(); ! tcLauncherDBObject(tcLauncherDBObject& obj); ///< copy constructor ! virtual ~tcLauncherDBObject(); ! }; } // namespace Database Index: tcWeaponDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcWeaponDBObject.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcWeaponDBObject.h 8 Aug 2004 00:31:32 -0000 1.3 --- tcWeaponDBObject.h 29 Nov 2004 03:54:49 -0000 1.4 *************** *** 42,45 **** --- 42,46 ---- virtual const char* GetClassName() {return "Sensor";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); Index: tcESMDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcESMDBObject.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcESMDBObject.h 6 Nov 2004 15:13:39 -0000 1.6 --- tcESMDBObject.h 29 Nov 2004 03:54:49 -0000 1.7 *************** *** 39,42 **** --- 39,43 ---- virtual tcSensorState* CreateSensor(tcGameObject* parent); ///< factory method virtual const char* GetClassName() {return "ESM";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); Index: tcAirDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcAirDBObject.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcAirDBObject.h 8 Aug 2004 00:31:32 -0000 1.8 --- tcAirDBObject.h 29 Nov 2004 03:54:48 -0000 1.9 *************** *** 66,69 **** --- 66,70 ---- virtual const char* GetClassName() {return "Air";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj void PrintToFile(tcFile& file) {} ///< not supported, redundant with CSV serialization, TODO get rid of these int Serialize(tcFile& file, bool mbLoad) {return 0;} ///< binary serialization not supported here Index: tcDatabaseObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDatabaseObject.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcDatabaseObject.h 6 Nov 2004 15:13:39 -0000 1.16 --- tcDatabaseObject.h 29 Nov 2004 03:54:49 -0000 1.17 *************** *** 106,109 **** --- 106,110 ---- #define DTYPE_BALLISTIC 11 #define DTYPE_OPTICAL 12 + #define DTYPE_STORES 13 #define DTYPE_NULL 0xFFFFFFFF *************** *** 136,139 **** --- 137,141 ---- virtual const char* GetClassName() {return "Object";} ///< returns class name of database object tc3DModel* Get3DModel(); + bool IsLeaf() const; ///< returns true if db obj is a leaf obj void Load3DModel(); void RandInit(void); Index: tcMissileDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcMissileDBObject.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcMissileDBObject.h 23 Nov 2004 23:30:32 -0000 1.13 --- tcMissileDBObject.h 29 Nov 2004 03:54:49 -0000 1.14 *************** *** 136,140 **** virtual const char* GetClassName() {return "Missile";} ///< returns class name of database object ! teWeaponLaunchMode GetLaunchMode(void); tnPoolIndex GetPrimarySeekerKey(); bool HasAllEmitters(std::vector<long>& emitters); --- 136,141 ---- virtual const char* GetClassName() {return "Missile";} ///< returns class name of database object ! bool IsLeaf() const; ///< returns true if db obj is a leaf obj ! teWeaponLaunchMode GetLaunchMode(); tnPoolIndex GetPrimarySeekerKey(); bool HasAllEmitters(std::vector<long>& emitters); Index: tcBallisticDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcBallisticDBObject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcBallisticDBObject.h 6 Nov 2004 15:13:39 -0000 1.4 --- tcBallisticDBObject.h 29 Nov 2004 03:54:48 -0000 1.5 *************** *** 42,45 **** --- 42,46 ---- virtual const char* GetClassName() {return "Ballistic";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); Index: tcOpticalDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcOpticalDBObject.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcOpticalDBObject.h 6 Nov 2004 15:13:39 -0000 1.1 --- tcOpticalDBObject.h 29 Nov 2004 03:54:49 -0000 1.2 *************** *** 46,49 **** --- 46,50 ---- virtual tcSensorState* CreateSensor(tcGameObject* parent); ///< factory method virtual const char* GetClassName() {return "Optical";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj virtual void PrintToFile(tcFile& file); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); Index: tcDBObjSerializerSql.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcDBObjSerializerSql.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcDBObjSerializerSql.h 9 Aug 2004 02:35:13 -0000 1.2 --- tcDBObjSerializerSql.h 29 Nov 2004 03:54:48 -0000 1.3 *************** *** 178,183 **** { database->mcObjectData.GetNextAssoc(pos, key, dbObj); ! ! if (T* obj = dynamic_cast<T*>(dbObj)) { try --- 178,183 ---- { database->mcObjectData.GetNextAssoc(pos, key, dbObj); ! T* obj = dynamic_cast<T*>(dbObj); ! if (obj && obj->IsLeaf()) // only write leaf classes { try Index: tcFlightportDBObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/database/tcFlightportDBObject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcFlightportDBObject.h 8 Aug 2004 00:31:32 -0000 1.4 --- tcFlightportDBObject.h 29 Nov 2004 03:54:49 -0000 1.5 *************** *** 59,62 **** --- 59,63 ---- virtual const char* GetClassName() {return "FlightPort";} ///< returns class name of database object + bool IsLeaf() const; ///< returns true if db obj is a leaf obj void RandInit(); int Serialize(tcFile& file, bool mbLoad, UINT32 anVersion); |
|
From: Dewitt C. <ddc...@us...> - 2004-11-29 03:55:01
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21010/include/sim Modified Files: tcLauncher.h tcLauncherState.h tcObjectControl.h tcPlatformObject.h Added Files: tcStores.h Log Message: Magazine class tcStores and related Index: tcLauncher.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcLauncher.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tcLauncher.h 5 Aug 2004 02:22:35 -0000 1.4 --- tcLauncher.h 29 Nov 2004 03:54:49 -0000 1.5 *************** *** 87,94 **** bool CommandInfoMatches(const tcLauncher& launcher); void CopyCommandInfoFrom(const tcLauncher& launcher); ! float GetCycleTime() const; int GetErrorCode() const {return errorCode;} void SetErrorCode(int code) {errorCode = code;} }; #endif \ No newline at end of file --- 87,101 ---- bool CommandInfoMatches(const tcLauncher& launcher); void CopyCommandInfoFrom(const tcLauncher& launcher); ! std::string GetChildClassName() const; float GetCycleTime() const; int GetErrorCode() const {return errorCode;} void SetErrorCode(int code) {errorCode = code;} + void SetChildClass(const std::string& childClass); + unsigned int GetCompatibleCount() const; + std::string GetCompatibleName(unsigned int idx) const; + tcLauncher(); + tcLauncher(tcLauncherDBObject* dbObj); + ~tcLauncher(); + }; #endif \ No newline at end of file --- NEW FILE: tcStores.h --- /** ** @file tcStores.h */ /* 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 */ #ifndef _TCSTORES_H_ #define _TCSTORES_H_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include <vector> namespace Database { class tcStoresDBObject; } using namespace Database; class tcPlatformObject; class tcStream; class tcCommandStream; class tcCreateStream; class tcUpdateStream; /** * State for stores object, used for weapons magazines for subs */ class tcStores { public: class StoreItem { public: std::string className; unsigned int quantity; StoreItem(); StoreItem(const StoreItem& src); StoreItem(const std::string& name, unsigned int qty); }; struct StoreOperation { enum {UNLOAD = 0, LOAD = 1}; std::string item; ///< item type to transfer unsigned int quantity; ///< quantity of item float timeToComplete; ///< time left for op to complete [s] unsigned int launcherIdx; ///< launcher idx to transfer to/from int transferType; ///< UNLOAD or LOAD }; bool AddItems(const std::string& item, unsigned int quantity); unsigned int CurrentItemQuantity(const std::string& item) const; unsigned int CurrentQuantity() const; bool IsCompatible(const std::string& item) const; bool IsFull() const; bool LoadLauncher(unsigned int idx, const std::string& item); void SetParent(tcPlatformObject* obj); bool UnloadLauncher(unsigned int idx); void Update(double t); tcCommandStream& operator<<(tcCommandStream& stream); tcCreateStream& operator<<(tcCreateStream& stream); tcUpdateStream& operator<<(tcUpdateStream& stream); tcCommandStream& operator>>(tcCommandStream& stream); tcCreateStream& operator>>(tcCreateStream& stream); tcUpdateStream& operator>>(tcUpdateStream& stream); bool CommandInfoMatches(const tcStores& launcher); void CopyCommandInfoFrom(const tcStores& launcher); tcStores(tcStoresDBObject* dbObj); virtual ~tcStores(); private: tcStoresDBObject* storesDBObj; tcPlatformObject* parent; std::vector<StoreItem> stores; std::vector<StoreOperation> ops; int errorCode; ///< used in multiplayer to pass error code to client double lastUpdate; void CompleteOperation(StoreOperation& op); }; #endif Index: tcObjectControl.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcObjectControl.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcObjectControl.h 23 Nov 2004 23:30:49 -0000 1.9 --- tcObjectControl.h 29 Nov 2004 03:54:49 -0000 1.10 *************** *** 127,131 **** bool ButtonContainingPoint(wxPoint point, int& rnRow, int& rnColumn); void GetRect(tcRect& r); ! void SetCaption(char *caption, unsigned row, unsigned button); tcButtonPanel(); ~tcButtonPanel(); --- 127,132 ---- bool ButtonContainingPoint(wxPoint point, int& rnRow, int& rnColumn); void GetRect(tcRect& r); ! void SetCaption(const char *caption, unsigned row, unsigned button); ! tcButtonPanel(); ~tcButtonPanel(); Index: tcLauncherState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcLauncherState.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcLauncherState.h 23 Nov 2004 23:30:49 -0000 1.10 --- tcLauncherState.h 29 Nov 2004 03:54:49 -0000 1.11 *************** *** 124,128 **** private: ! std::vector<tcLauncher> launchers; ///< vector of launcher state info tcCommandObject commandObj; static tcSimState *simState; --- 124,128 ---- private: ! std::vector<tcLauncher*> launchers; ///< vector of launcher state info tcCommandObject commandObj; static tcSimState *simState; Index: tcPlatformObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcPlatformObject.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcPlatformObject.h 6 Sep 2004 01:08:03 -0000 1.20 --- tcPlatformObject.h 29 Nov 2004 03:54:49 -0000 1.21 *************** *** 39,42 **** --- 39,43 ---- class tcCreateStream; class tcUpdateStream; + class tcStores; namespace Database *************** *** 72,75 **** --- 73,78 ---- //tcSensorState* mapSensorState[MAXSENSORS]; std::vector<tcSensorState*> mapSensorState; + std::vector<tcStores*> magazines; + //int mnSensors; tcGuidanceState mcGS; *************** *** 94,98 **** virtual void GetLauncherState(tcLauncherState*& pLauncherState) {pLauncherState=&mcLauncherState;} ! unsigned GetSensorCount() const; // virtual void GetSensorState(tcSensorState** aapSensorState, int& rnCount); // virtual void GetSensorStateRef(tcSensorState**& rapSensorState, int& rnCount); --- 97,105 ---- virtual void GetLauncherState(tcLauncherState*& pLauncherState) {pLauncherState=&mcLauncherState;} ! unsigned int GetMagazineCount() const; ! tcStores* GetMagazine(unsigned int idx); ! unsigned int GetMagazineQuantity(const std::string& item); ! ! unsigned int GetSensorCount() const; // virtual void GetSensorState(tcSensorState** aapSensorState, int& rnCount); // virtual void GetSensorStateRef(tcSensorState**& rapSensorState, int& rnCount); *************** *** 148,151 **** --- 155,159 ---- virtual void UpdateHeading(float dt_s); virtual void UpdateLauncherState(float dt_s); + virtual void UpdateMagazines(double t); virtual void UpdateSensors(double t); virtual void UpdateSpeed(float dt_s); |
|
From: Dewitt C. <ddc...@us...> - 2004-11-29 03:54:58
|
Update of /cvsroot/gcblue/gcb_wx/include/scriptinterface In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21010/include/scriptinterface Modified Files: tcPlatformInterface.h Log Message: Magazine class tcStores and related Index: tcPlatformInterface.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/scriptinterface/tcPlatformInterface.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** tcPlatformInterface.h 23 Nov 2004 23:30:46 -0000 1.26 --- tcPlatformInterface.h 29 Nov 2004 03:54:49 -0000 1.27 *************** *** 211,214 **** --- 211,228 ---- bool GetLauncherInfo(tcLauncherInfo& info, int anLauncher); + /// count of types of weapons accepted by this launcher + int GetLauncherTypesCount(int anLauncher); + /// class name of type + std::string GetLauncherTypeName(int anLauncher, int anType); + /// true if magazine can accept item (unloaded from launcher) + bool CanMagazineAcceptItem(std::string item); + /// quantity of item available in platform magazines + int GetMagazineQuantity(std::string item); + /// loads item into launcher, launcher must be empty + void LoadLauncher(int anLauncher, std::string item); + /// unloads launcher + void UnloadLauncher(int anLauncher); + + // order related commands /// true if platform has any orders |
|
From: Dewitt C. <ddc...@us...> - 2004-11-23 23:33:06
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29552/src/sim Modified Files: Game.cpp tcAirObject.cpp tcESMSensor.cpp tcGameObject.cpp tcLauncherState.cpp tcMissileObject.cpp tcObjectControl.cpp tcOpticalSensor.cpp tcRadar.cpp tcSensorState.cpp tcSimState.cpp tcSurfaceObject.cpp tcUserInfo.cpp Added Files: tcSubObject.cpp Log Message: Text message "message center" GUI screen Index: tcUserInfo.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcUserInfo.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcUserInfo.cpp 2 Nov 2004 04:23:57 -0000 1.5 --- tcUserInfo.cpp 23 Nov 2004 23:31:18 -0000 1.6 *************** *** 31,40 **** #endif ! UINT8 tcUserInfo::GetOwnAlliance(void) { return mnOwnAlliance; } ! int tcUserInfo::IsOwnAlliance(UINT anAlliance) { return (anAlliance == mnOwnAlliance); --- 31,40 ---- #endif ! UINT8 tcUserInfo::GetOwnAlliance() const { return mnOwnAlliance; } ! int tcUserInfo::IsOwnAlliance(UINT anAlliance) const { return (anAlliance == mnOwnAlliance); Index: tcMissileObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMissileObject.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcMissileObject.cpp 7 Nov 2004 03:40:45 -0000 1.20 --- tcMissileObject.cpp 23 Nov 2004 23:31:14 -0000 1.21 *************** *** 31,34 **** --- 31,35 ---- #include "tcSimState.h" #include "tc3DPoint.h" + #include "tcSubObject.h" #ifdef _DEBUG *************** *** 120,123 **** --- 121,128 ---- mcKin.mfLat_rad = pos.mfLat_rad; mcKin.mfAlt_m = pos.mfAlt_m; + if (tcSubObject* sub = dynamic_cast<tcSubObject*>(obj)) + { + subSurfaceLaunch = true; + } } else *************** *** 132,143 **** ! if (dynamic_cast<tcSurfaceObject*>(obj)) { ! // point surface launched missiles up ! mcKin.mfPitch_rad = 0.45f * C_PI; } else { ! mcKin.mfPitch_rad = obj->mcKin.mfPitch_rad; } --- 137,148 ---- ! if (dynamic_cast<tcAirObject*>(obj)) { ! mcKin.mfPitch_rad = obj->mcKin.mfPitch_rad; } else { ! // point surface launched missiles up ! mcKin.mfPitch_rad = 0.45f * C_PI; } *************** *** 145,152 **** msKState.mfAltitude_m = mcKin.mfAlt_m; ! if (msKState.mfAltitude_m < 5.0f) { msKState.mfAltitude_m = 5.0f; } msKState.mfSpeed_mps = obj->mcKin.mfSpeed_kts * (float)C_KTSTOMPS; --- 150,158 ---- msKState.mfAltitude_m = mcKin.mfAlt_m; ! if (!subSurfaceLaunch && (msKState.mfAltitude_m < 5.0f)) { msKState.mfAltitude_m = 5.0f; } + msKState.mfSpeed_mps = obj->mcKin.mfSpeed_kts * (float)C_KTSTOMPS; *************** *** 261,265 **** /*** check for crash ***/ ! if ((mcTerrain.mfHeight_m >= mcKin.mfAlt_m)||(mcKin.mfAlt_m <=0.0f)) { mfDamageLevel = 1.0f; tcString s; --- 267,278 ---- /*** check for crash ***/ ! bool underWater = (mcKin.mfAlt_m <= 0.0f); ! bool seaSurfaceCrash = (!subSurfaceLaunch) && underWater; ! ! // clear subSurfaceLaunch once weapon breaks surface ! if (!underWater) subSurfaceLaunch = false; ! ! if ((mcTerrain.mfHeight_m >= mcKin.mfAlt_m) || seaSurfaceCrash) ! { mfDamageLevel = 1.0f; tcString s; *************** *** 645,649 **** */ tcMissileObject::tcMissileObject() ! : tcWeaponObject() { Clear(); --- 658,662 ---- */ tcMissileObject::tcMissileObject() ! : tcWeaponObject(), subSurfaceLaunch(false) { Clear(); *************** *** 672,675 **** --- 685,689 ---- mfGoalSpeed_kts = o.mfGoalSpeed_kts; mfInterceptTime = o.mfInterceptTime; + subSurfaceLaunch = o.subSurfaceLaunch; mfLastGuidanceUpdate = o.mfLastGuidanceUpdate; guidanceStatusTime = o.guidanceStatusTime; *************** *** 686,690 **** */ tcMissileObject::tcMissileObject(tcMissileDBObject *obj) ! : tcWeaponObject(obj) { mpDBObject = obj; --- 700,704 ---- */ tcMissileObject::tcMissileObject(tcMissileDBObject *obj) ! : tcWeaponObject(obj), subSurfaceLaunch(false) { mpDBObject = obj; Index: tcESMSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcESMSensor.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcESMSensor.cpp 6 Nov 2004 15:13:42 -0000 1.9 --- tcESMSensor.cpp 23 Nov 2004 23:31:13 -0000 1.10 *************** *** 150,153 **** --- 150,161 ---- /** + * Alternative to dynamic_cast + */ + bool tcESMSensor::IsESM() const + { + return true; + } + + /** * */ Index: tcObjectControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcObjectControl.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** tcObjectControl.cpp 7 Nov 2004 03:40:45 -0000 1.22 --- tcObjectControl.cpp 23 Nov 2004 23:31:14 -0000 1.23 *************** *** 30,33 **** --- 30,34 ---- #include "tcObjectControl.h" #include "tcMissileObject.h" + #include "tcSubObject.h" #include "tcOptions.h" #include "tcUserInfo.h" *************** *** 40,43 **** --- 41,47 ---- #include "tcTime.h" #include "tcLauncher.h" + #include "tcControl.h" + #include "tcAltitudeBarControl.h" + #include <osg/Geometry> *************** *** 218,222 **** float width = mar[0][mnColumns-1].GetRight() - mar[0][0].left + 10.0f; ! float height = mar[0][0].GetBottom() - mfyloc + 15.0f; context->DrawRectangleR(mar[0][0].left - 5.0f, mfyloc, width, height, lineColor, tc3DWindow::FILL_OFF); --- 222,226 ---- float width = mar[0][mnColumns-1].GetRight() - mar[0][0].left + 10.0f; ! float height = mar[0][0].GetBottom() - mfyloc + 20.0f; context->DrawRectangleR(mar[0][0].left - 5.0f, mfyloc, width, height, lineColor, tc3DWindow::FILL_OFF); *************** *** 460,467 **** --- 464,473 ---- /*** mnClassID, mnModelType, mnType (classification) ***/ + /* GetObjectInfo(s ,mpHookedGameObj->mpDBObject, mpHookedGameObj); DrawTextR(s.GetBuffer(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE); ftexty += 12; + */ /*** speed, heading, altitude, terrain info ***/ *************** *** 554,563 **** (mpHookedGameObj->mnModelType == MTYPE_HELO); ! bool mbDrawSpeed = mbSurface || mbAir; ! bool mbDrawAltitude = mbAir; // bool mbDrawEngagement = mbSurface; if (mbDrawSpeed) {DrawBarObject(&msSOI, pkin->mfSpeed_kts, mfGoalSpeed_kts);} ! if (mbDrawAltitude) {DrawBarObject(&msAltitude, pkin->mfAlt_m, mfGoalAlt_m);} //if (mbDrawEngagement) {DrawEngagementInfo(pGraphics);} --- 560,571 ---- (mpHookedGameObj->mnModelType == MTYPE_HELO); ! bool mbSub = (mpHookedGameObj->mnModelType == MTYPE_SUBMARINE); ! ! bool mbDrawSpeed = mbSurface || mbAir || mbSub; ! // bool mbDrawEngagement = mbSurface; if (mbDrawSpeed) {DrawBarObject(&msSOI, pkin->mfSpeed_kts, mfGoalSpeed_kts);} ! //if (mbDrawEngagement) {DrawEngagementInfo(pGraphics);} *************** *** 566,570 **** DrawSensorControl(); DrawLandingInfo(); ! DrawFuelInfo(); DrawBorder(); --- 574,581 ---- DrawSensorControl(); DrawLandingInfo(); ! ! if (!mbSub) DrawFuelInfo(); ! ! DrawControls(); DrawBorder(); *************** *** 622,626 **** const float barWidth = 8.0f; const float barHeight = 60.0f; ! const float xbar = 100.0f; const float ybar = 120.0f; //mnHeight-21-barHeight; --- 633,637 ---- const float barWidth = 8.0f; const float barHeight = 60.0f; ! const float xbar = 120.0f; const float ybar = 120.0f; //mnHeight-21-barHeight; *************** *** 778,783 **** { // place next to altitude bar ! float x = msAltitude.mrectbar.GetRight() + 8.0f; ! float y = msAltitude.mrectbar.GetBottom() - 2.0f; // negative is up osg::Vec4 color(0.4f, 1.0f, 0.4f, 1.0f); DrawTextR("Gear down", x, y, defaultFont.get(), --- 789,794 ---- { // place next to altitude bar ! float x = 70.0f; ! float y = 80.0f; osg::Vec4 color(0.4f, 1.0f, 0.4f, 1.0f); DrawTextR("Gear down", x, y, defaultFont.get(), *************** *** 931,934 **** --- 942,958 ---- } + + /** + * Calls Draw method of tcControl objects in controls vector + */ + void tcObjectControl::DrawControls() + { + size_t nControls = controls.size(); + for (size_t n=0; n<nControls; n++) + { + controls[n]->Draw(this); + } + } + /******************************************************************************/ void tcObjectControl::DrawEngagementInfo() *************** *** 971,975 **** #endif } ! /******************************************************************************/ void tcObjectControl::DrawBarObject(tsBarObjectInfo *apBOI, float afValue, float afValueGoal) --- 995,1002 ---- #endif } ! ! /** ! * ! */ void tcObjectControl::DrawBarObject(tsBarObjectInfo *apBOI, float afValue, float afValueGoal) *************** *** 1024,1035 **** DrawRectangleR(rcurrent, color, FILL_OFF); if (apBOI->mbVertical) { rcurrent.top = apBOI->mrectbar.GetTop(); ! rcurrent.bottom = rcurrent.top - (afValue/apBOI->mfmaxvalue)*(apBOI->mrectbar.Height()); } else { ! rcurrent.right = rcurrent.left + (afValue/apBOI->mfmaxvalue)*(apBOI->mrectbar.Width()); } color.set(0.4f, 1.0f, 0.4f, 1.0f); --- 1051,1065 ---- DrawRectangleR(rcurrent, color, FILL_OFF); + float valueRange = apBOI->mfmaxvalue - apBOI->mfminvalue; + float fractionalValue = (afValue - apBOI->mfminvalue) / valueRange; + if (apBOI->mbVertical) { rcurrent.top = apBOI->mrectbar.GetTop(); ! rcurrent.bottom = rcurrent.top - (fractionalValue)*(apBOI->mrectbar.Height()); } else { ! rcurrent.right = rcurrent.left + (fractionalValue)*(apBOI->mrectbar.Width()); } color.set(0.4f, 1.0f, 0.4f, 1.0f); *************** *** 1041,1044 **** --- 1071,1075 ---- if (fabsf(dVal) >= 0.0078125f) { + float fractionalGoalValue = (afValueGoal - apBOI->mfminvalue) / valueRange; float x1,x2,y1,y2; if (apBOI->mbVertical) *************** *** 1046,1050 **** x1 = rcurrent.GetLeft() - 2.0f; x2 = rcurrent.GetRight() + 2.0f; ! y1 = rcurrent.GetTop() - (afValueGoal/apBOI->mfmaxvalue)*(apBOI->mrectbar.Height()); y2 = y1; } --- 1077,1081 ---- x1 = rcurrent.GetLeft() - 2.0f; x2 = rcurrent.GetRight() + 2.0f; ! y1 = rcurrent.GetTop() - (fractionalGoalValue)*(apBOI->mrectbar.Height()); y2 = y1; } *************** *** 1053,1057 **** y1 = rcurrent.GetBottom() - 2.0f; y2 = rcurrent.GetTop() + 2.0f; ! x1 = rcurrent.left + (afValueGoal/apBOI->mfmaxvalue)*(apBOI->mrectbar.Width()); x2 = x1; } --- 1084,1088 ---- y1 = rcurrent.GetBottom() - 2.0f; y2 = rcurrent.GetTop() + 2.0f; ! x1 = rcurrent.left + (fractionalGoalValue)*(apBOI->mrectbar.Width()); x2 = x1; } *************** *** 1064,1067 **** --- 1095,1101 ---- if (apBOI->mfmousevalue > apBOI->mfmaxvalue) {apBOI->mfmousevalue = apBOI->mfmaxvalue;} if (apBOI->mfmousevalue < apBOI->mfminvalue) {apBOI->mfmousevalue = apBOI->mfminvalue;} + + float fractionalMouseValue = (apBOI->mfmousevalue - apBOI->mfminvalue) / valueRange; + color.set(1, 1, 1, 0.63f); *************** *** 1070,1079 **** rcurrent.top = apBOI->mrectbar.GetTop(); rcurrent.bottom = rcurrent.top - ! (apBOI->mfmousevalue/apBOI->mfmaxvalue)*(apBOI->mrectbar.Height()); } else { rcurrent.right = rcurrent.left + ! (apBOI->mfmousevalue/apBOI->mfmaxvalue)*(apBOI->mrectbar.Width()); } DrawRectangleR(rcurrent, color, FILL_ON); --- 1104,1113 ---- rcurrent.top = apBOI->mrectbar.GetTop(); rcurrent.bottom = rcurrent.top - ! (fractionalMouseValue)*(apBOI->mrectbar.Height()); } else { rcurrent.right = rcurrent.left + ! (fractionalMouseValue)*(apBOI->mrectbar.Width()); } DrawRectangleR(rcurrent, color, FILL_ON); *************** *** 1166,1169 **** --- 1200,1206 ---- strcpy(zModel,"FIELD"); break; + case MTYPE_SUBMARINE: + strcpy(zModel,"SUB"); + break; default: strcpy(zModel,"ERR"); *************** *** 1296,1317 **** } } - else if (msAltitude.mrectcontrol.ContainsPoint((float)point.x,(float)point.y)) - { - tcAirObject *pAirObj = dynamic_cast<tcAirObject*>(mpHookedGameObj); - if (pAirObj != NULL) - { - pAirObj->mcGS.SetAltitude(msAltitude.mfmousevalue); - } - msAltitude.mbMouseOver = false; - } ! else { ! return; } - } bool tcObjectControl::ProcessWeaponPanelButton(int anLauncher, int anButton) { --- 1333,1350 ---- } } ! ! event.m_y = mnHeight - event.m_y; ! size_t nControls = controls.size(); ! for (size_t n=0; n<nControls; n++) { ! controls[n]->OnLButtonDown(event); } } + /** + * + */ bool tcObjectControl::ProcessWeaponPanelButton(int anLauncher, int anButton) { *************** *** 1416,1420 **** return false; } ! /******************************************************************************/ void tcObjectControl::OnMouseMove(wxMouseEvent& event) { --- 1449,1469 ---- return false; } ! ! /** ! * Calls SetGameObject method of tcControl objects in controls ! * vector. ! */ ! void tcObjectControl::SetControlGameObject(tcGameObject* obj) ! { ! size_t nControls = controls.size(); ! for (size_t n=0; n<nControls; n++) ! { ! controls[n]->SetGameObject(obj); ! } ! } ! ! /** ! * ! */ void tcObjectControl::OnMouseMove(wxMouseEvent& event) { *************** *** 1449,1460 **** msFormRange.mfmaxvalue; } - else if (msAltitude.mrectcontrol.ContainsPoint(fx, fy)) - { - msAltitude.mbMouseOver = true; - //msAltitude.mfmousevalue = msAltitude.mfmaxvalue; - msAltitude.mfmousevalue = (msAltitude.mrectbar.GetTop()-fy)/(msAltitude.mrectbar.Height())* - msAltitude.mfmaxvalue; - - } else { --- 1498,1501 ---- *************** *** 1463,1467 **** msFormHeading.mbMouseOver = false; msFormRange.mbMouseOver = false; ! msAltitude.mbMouseOver = false; } --- 1504,1514 ---- msFormHeading.mbMouseOver = false; msFormRange.mbMouseOver = false; ! } ! ! event.m_y = mnHeight - event.m_y; ! size_t nControls = controls.size(); ! for (size_t n=0; n<nControls; n++) ! { ! controls[n]->OnMouseMove(event); } *************** *** 1518,1529 **** msFormRange.mbVertical = false; ! // altitude control ! msAltitude.mbMouseOver = false; ! msAltitude.mrectcontrol.left = 60.0f; ! msAltitude.mrectcontrol.bottom = 120.0f; ! msAltitude.mrectcontrol.right = msAltitude.mrectcontrol.left + 8.0f; ! msAltitude.mrectcontrol.top = msAltitude.mrectcontrol.bottom + 60.0f; ! msAltitude.mrectbar = msAltitude.mrectcontrol; ! msAltitude.mbVertical = true; } --- 1565,1574 ---- msFormRange.mbVertical = false; ! ! ! altitudeControl = new tcAltitudeBarControl(60, 17, 10, 60); ! altitudeControl->SetActive(true); ! controls.push_back(altitudeControl); ! } *************** *** 1536,1539 **** --- 1581,1587 ---- if (mnHookID==NULL_INDEX) {mpHookedGameObj=NULL;return;} bFound = mpSS->GetPlatformState(mnHookID,mpHookedGameObj); + + SetControlGameObject(mpHookedGameObj); + if (!bFound) {return;} *************** *** 1550,1560 **** --- 1598,1612 ---- } + altitudeControl->SetActive(true); + switch (mpHookedGameObj->mnModelType) { case MTYPE_SURFACE: case MTYPE_CARRIER: + altitudeControl->SetActive(false); case MTYPE_FIXEDWING: case MTYPE_FIXEDWINGX: case MTYPE_HELO: + case MTYPE_SUBMARINE: { //tcSurfaceObject *pSurfaceObj = (tcSurfaceObject*)mpHookedGameObj; *************** *** 1575,1582 **** msFormRange.mrectbar.right -= 5.0f; - msAltitude.mrectbar = msAltitude.mrectcontrol; - msAltitude.mfminvalue = 50.0f; - msAltitude.mfmaxvalue = pGenericData->mfMaxAltitude_m; - } break; --- 1627,1630 ---- *************** *** 1667,1670 **** tcObjectControl::~tcObjectControl() { ! } --- 1715,1723 ---- tcObjectControl::~tcObjectControl() { ! // delete controls ! size_t nControls = controls.size(); ! for (size_t n=0; n<nControls; n++) ! { ! delete controls[n]; ! } } Index: tcSurfaceObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSurfaceObject.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcSurfaceObject.cpp 2 Nov 2004 04:23:57 -0000 1.13 --- tcSurfaceObject.cpp 23 Nov 2004 23:31:18 -0000 1.14 *************** *** 210,213 **** --- 210,214 ---- mnModelType = MTYPE_SURFACE; mcEngagementData.mnCount = 0; + mcGS.mfGoalAltitude_m = 0; } Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** tcGameObject.cpp 6 Nov 2004 15:13:42 -0000 1.24 --- tcGameObject.cpp 23 Nov 2004 23:31:13 -0000 1.25 *************** *** 170,173 **** --- 170,183 ---- } + /** + * Used to decide when to display info messages and play sound + * effects. + * @return true if object is under user control + */ + bool tcGameObject::IsOwnAlliance() const + { + return simState->mpUserInfo->IsOwnAlliance(mnAlliance) != 0; + } + tsGeoPoint tcGameObject::RelPosToLatLonAlt(const tsRelativePosition& rel_pos) const { --- NEW FILE: tcSubObject.cpp --- /** ** @file tcSubObject.cpp ** Basic submarine model */ /* 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" #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "tcSubObject.h" #include "tcGenericDBObject.h" #include "tc3DModel.h" #include "tcParticleEffect.h" #include "common/tcObjStream.h" #ifdef _DEBUG #define new DEBUG_NEW #endif /******************************************************************************/ /****************************** tcSubObject *******************************/ /******************************************************************************/ /** * */ tcCommandStream& tcSubObject::operator<<(tcCommandStream& stream) { tcPlatformObject::operator<<(stream); return stream; } /** * */ tcCommandStream& tcSubObject::operator>>(tcCommandStream& stream) { tcPlatformObject::operator>>(stream); return stream; } /** * */ tcUpdateStream& tcSubObject::operator<<(tcUpdateStream& stream) { tcPlatformObject::operator<<(stream); return stream; } /** * */ tcUpdateStream& tcSubObject::operator>>(tcUpdateStream& stream) { tcPlatformObject::operator>>(stream); return stream; } /** * */ void tcSubObject::ClearNewCommand() { tcPlatformObject::ClearNewCommand(); commandObj.ClearNewCommand(); } bool tcSubObject::HasNewCommand() const { return tcPlatformObject::HasNewCommand() || commandObj.HasNewCommand(); } /** * */ bool tcSubObject::HasUnacknowledgedCommand() const { return tcPlatformObject::HasUnacknowledgedCommand() || commandObj.HasUnacknowledgedCommand(); } /** * */ void tcSubObject::Clear() { tcPlatformObject::Clear(); } /** * */ void tcSubObject::RandInitNear(float afLon_deg, float afLat_deg) { if (mpDBObject == NULL) {return;} strcpy(mzClass.mz, mpDBObject->mzClass.mz); mzUnit = "SUB_"; mzUnit.AssignRandomSuffix(); mnAlliance = 0; mfStatusTime = 0; mcKin.mfLon_rad = C_PIOVER180*(afLon_deg + randfc(1.1f)); mcKin.mfLat_rad = C_PIOVER180*(afLat_deg + randfc(1.1f)); mcKin.mfAlt_m = -65.0f; mcKin.mfHeading_rad = C_TWOPI*randf(); mcKin.mfSpeed_kts = 0.20f*mpDBObject->mfMaxSpeed_kts; mcKin.mfPitch_rad = 0; mcKin.mfRoll_rad = 0; mfDamageLevel = 0; SetHeading(mcKin.mfHeading_rad); SetSpeed(mcKin.mfSpeed_kts); SetAltitude(mcKin.mfAlt_m); } /** * */ void tcSubObject::PrintToFile(tcFile& file) { tcPlatformObject::PrintToFile(file); } /** * */ void tcSubObject::SaveToFile(tcFile& file) { tcPlatformObject::SaveToFile(file); } /** * */ void tcSubObject::LoadFromFile(tcFile& file) { tcPlatformObject::LoadFromFile(file); } /** * */ void tcSubObject::Serialize(tcFile& file, bool mbLoad) { if (mbLoad) { LoadFromFile(file); } else { SaveToFile(file); } } /** * @return periscope depth in meters (negative number) */ float tcSubObject::GetPeriscopeDepth() const { return periscopeDepth_m; } /** * */ bool tcSubObject::GetPeriscopeState() const { return periscopeRaised; } /** * */ bool tcSubObject::GetRadarMastState() const { return radarMastRaised; } bool tcSubObject::IsAtPeriscopeDepth() const { return mcKin.mfAlt_m >= -periscopeDepth_m; } bool tcSubObject::IsSurfaced() const { return mcKin.mfAlt_m == 0; } /** * */ void tcSubObject::SetPeriscopeState(bool state) { periscopeRaised = state; } /** * */ void tcSubObject::SetRadarMastState(bool state) { radarMastRaised = state; } /** * */ void tcSubObject::ApplyRestrictions() { // check for crash (bottom) if (mcTerrain.mfHeight_m >= mcKin.mfAlt_m) { mfDamageLevel = 1.0f; } if (mcKin.mfAlt_m < -periscopeDepth_m) { SetPeriscopeState(false); SetRadarMastState(false); } else if (mcKin.mfAlt_m > 0) { mcKin.mfAlt_m = 0; // subs can't fly } } /** * Update climb related parameters. This has problems for large time * steps, > about 1 sec */ void tcSubObject::UpdateClimb(float dt_s) { // restrict to max depth if (mcGS.mfGoalAltitude_m < -mpDBObject->mfMaxDepth_m) { mcGS.mfGoalAltitude_m = -mpDBObject->mfMaxDepth_m; } // avoid bottoming out if (mcGS.mfGoalAltitude_m < mcTerrain.mfHeight_m + 10) { mcGS.mfGoalAltitude_m = mcTerrain.mfHeight_m + 10; } else if (mcGS.mfGoalAltitude_m > 0) { mcGS.mfGoalAltitude_m = 0; } float dalt_m = mcGS.mfGoalAltitude_m - mcKin.mfAlt_m; const float levelThresh_rad = 0.0035f; // 0.2 deg if ((dalt_m > -0.05f)&&(dalt_m < 0.05f)&& (mcKin.mfClimbAngle_rad < levelThresh_rad)&&(mcKin.mfClimbAngle_rad > -levelThresh_rad)) { mcKin.mfClimbAngle_rad = 0; mcKin.mfPitch_rad = 0; mcKin.mfAlt_m += dalt_m; return; } const float fHighZone = 25.0f; const float fLowZone = -25.0f; float goalPitch = 0; float maxPitch = maxPitch_rad; if (mcKin.mfAlt_m > -10) maxPitch *= 0.5f; if (dalt_m > fHighZone) { goalPitch = maxPitch_rad; } else if (dalt_m < fLowZone) { goalPitch = -maxPitch_rad; } else { goalPitch = 0.04f * dalt_m * maxPitch_rad; } if (goalPitch > maxPitch) goalPitch = maxPitch; else if (goalPitch < -maxPitch) goalPitch = -maxPitch; float oldAngle_rad = mcKin.mfClimbAngle_rad; float alpha = 0.5f * dt_s; mcKin.mfClimbAngle_rad = alpha*goalPitch + (1-alpha)*oldAngle_rad; mcKin.mfPitch_rad = mcKin.mfClimbAngle_rad; // add slow vertical ascent/descent component if (mcKin.mfAlt_m > -5) { float dz = (dalt_m > 0) ? 0.5f * dt_s : -0.5f * dt_s; mcKin.mfAlt_m += dz; } } /** * */ void tcSubObject::UpdateEffects() { if (model) { if ((mcKin.mfAlt_m < -10)&&(mcKin.mfSpeed_kts > 10)) { model->SetSmokeMode(tcParticleEffect::BUBBLES); } else { model->SetSmokeMode(tcParticleEffect::OFF); } model->UpdateEffects(); } } /** * */ void tcSubObject::UpdateHeading(float dt_s) { if (dt_s == 0) {return;} tcPlatformObject::UpdateHeading(dt_s); mcKin.mfRoll_rad = 0; } /** * Update radars if radar mast is raised * Update visual sensors if periscope is raised * Deactivate sensors that do not have mast/periscope in required state * Update sensor height for periscope and radar mast to be 4.0 m above water */ void tcSubObject::UpdateSensors(double t) { if (clientMode) return; // no sensor update for client unsigned nSensors = mapSensorState.size(); for(unsigned n=0; n<nSensors; n++) { tcSensorState* sensor = mapSensorState[n]; wxASSERT(sensor); if (sensor->IsSonar()) { sensor->Update(t); } else if (sensor->IsRadar() && radarMastRaised) { sensor->mfSensorHeight_m = 4.0f + mcKin.mfAlt_m; sensor->Update(t); } else if ((sensor->IsESM() && radarMastRaised) || (sensor->IsOptical() && periscopeRaised)) { sensor->mfSensorHeight_m = 4.0f + mcKin.mfAlt_m; sensor->SetActive(true); // assume ESM and optical always active if possible sensor->Update(t); } else { sensor->SetActive(false); } } } /** * */ void tcSubObject::UpdateSpeed(float dt_s) { tcPlatformObject::UpdateSpeed(dt_s); } /** * */ void tcSubObject::Update(double afStatusTime) { const float min_update_s = 0.0f; float dt_s = (float)(afStatusTime - mfStatusTime); UpdateEffects(); // shouldn't be called for child objects if (parent != NULL) {return;} // captive, let parent update if applicable if (dt_s <= min_update_s) {return;} // added for pause case wxASSERT(mpDBObject); UpdateFormationGuidance(); // formation heading/speed calculation UpdateHeading(dt_s); UpdateSpeed(dt_s); UpdateClimb(dt_s); ApplyRestrictions(); // crash check Move(dt_s); UpdateLauncherState(dt_s); UpdateSensors(afStatusTime); mfStatusTime = afStatusTime; } /** * */ tcSubObject::tcSubObject() : maxPitch_rad(0.5), periscopeDepth_m(18) { mnModelType = MTYPE_SUBMARINE; SetAltitude(-100.0f); SetHeading(75.0f); SetSpeed(7.0f); } /** * Constructor that initializes using info from database entry. */ tcSubObject::tcSubObject(tcGenericDBObject *obj) : tcPlatformObject(obj), maxPitch_rad(0.5), periscopeDepth_m(18) { mpDBObject = obj; mnModelType = MTYPE_SUBMARINE; } /** * */ tcSubObject::~tcSubObject() { } Index: tcOpticalSensor.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcOpticalSensor.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcOpticalSensor.cpp 6 Nov 2004 15:13:42 -0000 1.1 --- tcOpticalSensor.cpp 23 Nov 2004 23:31:17 -0000 1.2 *************** *** 174,177 **** --- 174,185 ---- /** + * Alternative to dynamic_cast + */ + bool tcOpticalSensor::IsOptical() const + { + return true; + } + + /** * */ Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcAirObject.cpp 14 Nov 2004 22:52:22 -0000 1.14 --- tcAirObject.cpp 23 Nov 2004 23:31:12 -0000 1.15 *************** *** 199,202 **** --- 199,208 ---- } + // avoid crashing + if (mcGS.mfGoalAltitude_m < mcTerrain.mfHeight_m + 20) + { + mcGS.mfGoalAltitude_m = mcTerrain.mfHeight_m + 20; + } + float dalt_m = mcGS.mfGoalAltitude_m - mcKin.mfAlt_m; // float valt_kts = (daltitude_m/dt_s)*C_MPSTOKTS; Index: tcSensorState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorState.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcSensorState.cpp 6 Nov 2004 15:13:42 -0000 1.12 --- tcSensorState.cpp 23 Nov 2004 23:31:18 -0000 1.13 *************** *** 121,125 **** bool tcSensorState::IsHidden() const { ! return isHidden; } --- 121,157 ---- bool tcSensorState::IsHidden() const { ! return isHidden; ! } ! ! /** ! * Alternative to dynamic_cast ! */ ! bool tcSensorState::IsESM() const ! { ! return false; ! } ! ! /** ! * Alternative to dynamic_cast ! */ ! bool tcSensorState::IsRadar() const ! { ! return false; ! } ! ! /** ! * Alternative to dynamic_cast ! */ ! bool tcSensorState::IsSonar() const ! { ! return false; ! } ! ! /** ! * Alternative to dynamic_cast ! */ ! bool tcSensorState::IsOptical() const ! { ! return false; } Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** tcSimState.cpp 14 Nov 2004 22:52:22 -0000 1.58 --- tcSimState.cpp 23 Nov 2004 23:31:18 -0000 1.59 *************** *** 42,45 **** --- 42,46 ---- #include "tcBallisticDBObject.h" #include "tcHeloObject.h" + #include "tcSubObject.h" #include "tcLauncher.h" *************** *** 1435,1438 **** --- 1436,1443 ---- return new tcAirfieldObject(pGenericData); } + else if (apDBObject->mnModelType == MTYPE_SUBMARINE) + { + return new tcSubObject(pGenericData); + } else { Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcLauncherState.cpp 2 Nov 2004 04:23:56 -0000 1.20 --- tcLauncherState.cpp 23 Nov 2004 23:31:14 -0000 1.21 *************** *** 231,234 **** --- 231,244 ---- if (!ldata.mbActive) {return LAUNCHER_INACTIVE;} // launcher inactive or damaged + wxASSERT(simState); + wxASSERT(parent); + + // limit depth for launching sub-launched missiles + if (tcMissileDBObject* missile = + dynamic_cast<tcMissileDBObject*>(ldata.mpChildDBObj)) + { + if (parent->mcKin.mfAlt_m < -30.0) return TOO_DEEP; + } + if (ldata.meLaunchMode == DATUM_ONLY) // needs a datum programmed to launch { *************** *** 243,248 **** } ! wxASSERT(simState); ! wxASSERT(parent); --- 253,257 ---- } ! *************** *** 546,549 **** --- 555,562 ---- return "No fire control sensor (database error)"; } + if (status == TOO_DEEP) + { + return "Too deep for launch"; + } std::cerr << "Bad launcher status code"; Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** Game.cpp 14 Nov 2004 22:52:21 -0000 1.105 --- Game.cpp 23 Nov 2004 23:30:58 -0000 1.106 *************** *** 331,335 **** viewer->SetTerrainActive(false); viewer->SetClearMode(1); // depth clearing ! viewer->SetText(""); size3D = MODE3D_START; --- 331,335 ---- viewer->SetTerrainActive(false); viewer->SetClearMode(1); // depth clearing ! viewer->SetText(" "); size3D = MODE3D_START; *************** *** 456,460 **** r.y = 2; r.width = mnWidth-margin; ! r.height = mnHeight-mnBottomMargin-1; } else if (size3D == MODE3D_FULL) --- 456,460 ---- r.y = 2; r.width = mnWidth-margin; ! r.height = mnHeight-mnBottomMargin-3; } else if (size3D == MODE3D_FULL) Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tcRadar.cpp 7 Nov 2004 03:40:45 -0000 1.16 --- tcRadar.cpp 23 Nov 2004 23:31:17 -0000 1.17 *************** *** 30,33 **** --- 30,34 ---- #include "tcAirfieldObject.h" #include "tcBallisticWeapon.h" + #include "tcSubObject.h" #include "tcGenericDBObject.h" *************** *** 129,132 **** --- 130,139 ---- return false; } + else if (const tcSubObject* sub = dynamic_cast<const tcSubObject*>(target)) + { + if (sub->mcKin.mfAlt_m < -2.0f) return false; + rcs_dBsm = sub->mpDBObject->mfRcs_dbsm; + isSurface = true; + } else { *************** *** 279,282 **** --- 286,297 ---- /** + * Alternative to dynamic_cast + */ + bool tcRadar::IsRadar() const + { + return true; + } + + /** * Does not test if radar can detect target. * @return true if track is available. *************** *** 446,449 **** --- 461,469 ---- teAffiliation eAffil = UNKNOWN; if (nClassification & PTYPE_MISSILE) {eAffil = HOSTILE;} + // surfaced sub classified as small surface + if (nClassification & PTYPE_SUBMARINE) + { + nClassification = PTYPE_SMALLSURFACE; + } pSMTrack->UpdateClassification(nClassification, eAffil, NULL_INDEX); pReport->mbClassified = 1; *************** *** 478,481 **** --- 498,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); |
|
From: Dewitt C. <ddc...@us...> - 2004-11-23 23:32:42
|
Update of /cvsroot/gcblue/gcb_wx/include/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29552/include/sim Modified Files: tcESMSensor.h tcGameObject.h tcLauncherState.h tcMissileObject.h tcObjectControl.h tcOpticalSensor.h tcRadar.h tcSensorState.h tcUserInfo.h Added Files: tcSubObject.h Log Message: Text message "message center" GUI screen Index: tcUserInfo.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcUserInfo.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcUserInfo.h 8 Aug 2004 00:31:33 -0000 1.5 --- tcUserInfo.h 23 Nov 2004 23:30:50 -0000 1.6 *************** *** 33,43 **** #endif class tcUserInfo { public: UINT8 mnOwnAlliance; ! int IsOwnAlliance(UINT anAlliance); ! UINT8 GetOwnAlliance(void); void SetOwnAlliance(UINT alliance) {mnOwnAlliance = alliance;} tcUserInfo(); --- 33,46 ---- #endif + /** + * + */ class tcUserInfo { public: UINT8 mnOwnAlliance; ! int IsOwnAlliance(UINT anAlliance) const; ! UINT8 GetOwnAlliance() const; void SetOwnAlliance(UINT alliance) {mnOwnAlliance = alliance;} tcUserInfo(); --- NEW FILE: tcSubObject.h --- /** ** @file tcSubObject.h */ /* 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 */ #ifndef _SUBOBJECT_H_ #define _SUBOBJECT_H_ #if _MSC_VER > 1000 #pragma once #endif #include "tcPlatformObject.h" #include "tcCommandObject.h" class tcUpdateStream; class tcCommandStream; /** * Models air object that can land */ class tcSubObject : public tcPlatformObject { public: tcGenericDBObject* mpDBObject; virtual void ApplyRestrictions(); virtual void Clear(); virtual void RandInitNear(float afLon_deg, float afLat_deg); virtual void UpdateClimb(float dt_s); virtual void Update(double afStatusTime); void PrintToFile(tcFile& file); void SaveToFile(tcFile& file); void LoadFromFile(tcFile& file); virtual void Serialize(tcFile& file, bool mbLoad); float GetPeriscopeDepth() const; bool GetPeriscopeState() const; bool GetRadarMastState() const; bool IsAtPeriscopeDepth() const; bool IsSurfaced() const; void SetPeriscopeState(bool state); void SetRadarMastState(bool state); virtual tcCommandStream& operator<<(tcCommandStream& stream); virtual tcUpdateStream& operator<<(tcUpdateStream& stream); virtual tcCommandStream& operator>>(tcCommandStream& stream); virtual tcUpdateStream& operator>>(tcUpdateStream& stream); virtual void ClearNewCommand(); virtual bool HasNewCommand() const; virtual bool HasUnacknowledgedCommand() const; tcSubObject(); tcSubObject(tcSubObject&); tcSubObject(tcGenericDBObject *obj); virtual ~tcSubObject(); protected: tcCommandObject commandObj; const float maxPitch_rad; bool radarMastRaised; bool periscopeRaised; float periscopeDepth_m; ///< periscope depth (positive number) virtual void UpdateEffects(); virtual void UpdateHeading(float dt_s); virtual void UpdateSensors(double t); virtual void UpdateSpeed(float dt_s); }; #endif Index: tcObjectControl.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcObjectControl.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcObjectControl.h 2 Nov 2004 04:23:55 -0000 1.8 --- tcObjectControl.h 23 Nov 2004 23:30:49 -0000 1.9 *************** *** 44,51 **** class tcUserInfo; class tcGameObject; namespace osg { ! class Geometry; } --- 44,52 ---- class tcUserInfo; class tcGameObject; + class tcControl; namespace osg { ! class Geometry; } *************** *** 65,93 **** struct tsHeadingObjectInfo { ! bool mbMouseOver; ! float mfMouseHeading_rad; ! tcRect mrectArc; ! float mfxcenter; ! float mfycenter; ! float mfradius; }; struct tsBarObjectInfo { ! bool mbMouseOver; ! bool mbVertical; ! tcRect mrectcontrol; ///< control area ! tcRect mrectbar; ! float mfmaxvalue; ! float mfminvalue; ! float mfmousevalue; }; enum teButtonState { ! BS_DISABLED, ! BS_READYING, ! BS_READY, ! BS_ACTIVE }; --- 66,94 ---- struct tsHeadingObjectInfo { ! bool mbMouseOver; ! float mfMouseHeading_rad; ! tcRect mrectArc; ! float mfxcenter; ! float mfycenter; ! float mfradius; }; struct tsBarObjectInfo { ! bool mbMouseOver; ! bool mbVertical; ! tcRect mrectcontrol; ///< control area ! tcRect mrectbar; ! float mfmaxvalue; ! float mfminvalue; ! float mfmousevalue; }; enum teButtonState { ! BS_DISABLED, ! BS_READYING, ! BS_READY, ! BS_ACTIVE }; *************** *** 95,108 **** { public: ! tcRect window; ! std::string mzCaption; ! ! void SetAIData(tcAIData *apAIData) {mpAIData = apAIData;} ! void SetLocation(tcRect rect) {window = rect;} ! void Draw(tc3DWindow* context); ! tcAIPanel(); ! ~tcAIPanel(); private: ! tcAIData* mpAIData; }; --- 96,109 ---- { public: ! tcRect window; ! std::string mzCaption; ! ! void SetAIData(tcAIData *apAIData) {mpAIData = apAIData;} ! void SetLocation(tcRect rect) {window = rect;} ! void Draw(tc3DWindow* context); ! tcAIPanel(); ! ~tcAIPanel(); private: ! tcAIData* mpAIData; }; *************** *** 112,132 **** { public: ! float mfxloc, mfyloc; // upper-left coords ! unsigned mnRows, mnColumns; ! tcString mstrTitle; ! tcString mastrCaption[MAX_PANELROWS][N_PANELBUTTONS]; ! tcRect mar[MAX_PANELROWS][N_PANELBUTTONS]; ! teButtonState maButtonState[MAX_PANELROWS][N_PANELBUTTONS]; ! float fontSize; ! void Init(int anPanelType); ! void Draw(tc3DWindow* context); ! void DrawButton(tc3DWindow* context, const tcRect& rectf, ! const char* azCaption, teButtonState aeState); ! bool ButtonContainingPoint(wxPoint point, int& rnRow, int& rnColumn); ! void GetRect(tcRect& r); ! void SetCaption(char *caption, unsigned row, unsigned button); ! tcButtonPanel(); ! ~tcButtonPanel(); private: }; --- 113,133 ---- { public: ! float mfxloc, mfyloc; // upper-left coords ! unsigned mnRows, mnColumns; ! tcString mstrTitle; ! tcString mastrCaption[MAX_PANELROWS][N_PANELBUTTONS]; ! tcRect mar[MAX_PANELROWS][N_PANELBUTTONS]; ! teButtonState maButtonState[MAX_PANELROWS][N_PANELBUTTONS]; ! float fontSize; ! void Init(int anPanelType); ! void Draw(tc3DWindow* context); ! void DrawButton(tc3DWindow* context, const tcRect& rectf, ! const char* azCaption, teButtonState aeState); ! bool ButtonContainingPoint(wxPoint point, int& rnRow, int& rnColumn); ! void GetRect(tcRect& r); ! void SetCaption(char *caption, unsigned row, unsigned button); ! tcButtonPanel(); ! ~tcButtonPanel(); private: }; *************** *** 138,216 **** struct tsOCSymbolList { ! struct ! { ! float mfLat_rad; ! float mfLon_rad; ! float mfLatExtent_rad; ! float mfLonExtent_rad; ! float mfArcCenter_deg; ! float mfArcLength_deg; ! UINT32 mnColor; ! } maSymbol[MAX_OCSYMBOLS]; ! unsigned mnSymbols; }; /** * Old code, needs refactoring */ class tcObjectControl : public tc3DWindow { public: ! void Draw(); ! void AttachSimState(tcSimState *apSS) {mpSS=apSS;} ! void AttachCommandInterface(tcCommandQueue *apCommandInterface) {mpCommandInterface=apCommandInterface;} ! void AttachUserInfo(tcUserInfo *apUserInfo) {mpUserInfo=apUserInfo;} ! bool ButtonContainingPoint(wxPoint point, int& rnRow, int& rnColumn); ! void GetSymbols(tsOCSymbolList*& rpOCSymbolList) {rpOCSymbolList=&msOCSymbolList;} ! void SetHookID(tnPoolIndex anID) {mnHookID=anID;} ! void OnLButtonDown(wxMouseEvent& event); ! void OnMouseMove(wxMouseEvent& event); ! bool ProcessWeaponPanelButton(int anLauncher, int anButton); ! bool ProcessSensorPanelButton(int anSensor, int anButton); ! tcObjectControl(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name = "ObjectControl"); ! virtual ~tcObjectControl(); private: ! tcGameObject *mpHookedGameObj; ! tcSimState *mpSS; ///< pointer to SimState object to access hook info, change this ! ///< to a UserSimState reference when ready (state as known by user's side) ! tcOptions *mpOptions; ! tcCommandQueue *mpCommandInterface; ! tcUserInfo *mpUserInfo; ///< info on which alliance user belongs to for truth view/control ! tnPoolIndex mnHookID, mnPreviousHookID; ! ! tcButtonPanel mcWeaponPanel; ! tcButtonPanel mcSensorPanel; ! tcAIPanel mcAIPanel; ! tsHeadingObjectInfo msHOI; ! tsBarObjectInfo msSOI; ///< speed object info ! tsHeadingObjectInfo msFormHeading; ! tsBarObjectInfo msFormRange; ! tsBarObjectInfo msAltitude; ! int mnLaunchers; ! int mnSensors; ! tsOCSymbolList msOCSymbolList; ! osg::ref_ptr<osg::Geometry> headingCircle; ! osg::ref_ptr<osg::Geometry> headingCircleLight; ! void CreateHeadingCircles(); ! void DrawAltitudeObject(float afAltitude_m); ! void DrawBarObject(tsBarObjectInfo *apBOI, float afValue, float afValueGoal); ! void DrawButton(const tcRect& rectf, ! char* azCaption, teButtonState aeState); ! void DrawEngagementInfo(); ! void DrawFireControl(); ! void DrawFormationControl(); ! void DrawFuelInfo(); ! void DrawHeadingObject(tsHeadingObjectInfo *apHOI, ! float afHeading_rad, float afHeadingGoal_rad); ! void DrawLandingInfo(); ! void DrawSensorControl(); - void InitControls(); - void UpdateControlObjects(); - void UpdateSymbolList(); - void GetObjectInfo(tcString& s, tcDatabaseObject *apDBObject, tcGameObject *apGameObject); }; --- 139,222 ---- struct tsOCSymbolList { ! struct ! { ! float mfLat_rad; ! float mfLon_rad; ! float mfLatExtent_rad; ! float mfLonExtent_rad; ! float mfArcCenter_deg; ! float mfArcLength_deg; ! UINT32 mnColor; ! } maSymbol[MAX_OCSYMBOLS]; ! unsigned mnSymbols; }; /** * Old code, needs refactoring + * Second that, really needs it! */ class tcObjectControl : public tc3DWindow { public: ! void Draw(); ! void AttachSimState(tcSimState *apSS) {mpSS=apSS;} ! void AttachCommandInterface(tcCommandQueue *apCommandInterface) {mpCommandInterface=apCommandInterface;} ! void AttachUserInfo(tcUserInfo *apUserInfo) {mpUserInfo=apUserInfo;} ! bool ButtonContainingPoint(wxPoint point, int& rnRow, int& rnColumn); ! void GetSymbols(tsOCSymbolList*& rpOCSymbolList) {rpOCSymbolList=&msOCSymbolList;} ! void SetHookID(tnPoolIndex anID) {mnHookID=anID;} ! void OnLButtonDown(wxMouseEvent& event); ! void OnMouseMove(wxMouseEvent& event); ! bool ProcessWeaponPanelButton(int anLauncher, int anButton); ! bool ProcessSensorPanelButton(int anSensor, int anButton); ! tcObjectControl(wxWindow *parent, const wxPoint& pos, const wxSize& size, const wxString& name = "ObjectControl"); ! virtual ~tcObjectControl(); private: ! tcGameObject *mpHookedGameObj; ! tcSimState *mpSS; ///< pointer to SimState object to access hook info, change this ! ///< to a UserSimState reference when ready (state as known by user's side) ! tcOptions *mpOptions; ! tcCommandQueue *mpCommandInterface; ! tcUserInfo *mpUserInfo; ///< info on which alliance user belongs to for truth view/control ! tnPoolIndex mnHookID, mnPreviousHookID; ! tcButtonPanel mcWeaponPanel; ! tcButtonPanel mcSensorPanel; ! tcAIPanel mcAIPanel; ! tsHeadingObjectInfo msHOI; ! tsBarObjectInfo msSOI; ///< speed object info ! tsHeadingObjectInfo msFormHeading; ! tsBarObjectInfo msFormRange; ! int mnLaunchers; ! int mnSensors; ! tsOCSymbolList msOCSymbolList; ! osg::ref_ptr<osg::Geometry> headingCircle; ! osg::ref_ptr<osg::Geometry> headingCircleLight; ! ! std::vector<tcControl*> controls; ! tcControl* altitudeControl; ! ! void CreateHeadingCircles(); ! void DrawBarObject(tsBarObjectInfo *apBOI, float afValue, float afValueGoal); ! void DrawButton(const tcRect& rectf, ! char* azCaption, teButtonState aeState); ! void DrawControls(); ! void DrawEngagementInfo(); ! void DrawFireControl(); ! void DrawFormationControl(); ! void DrawFuelInfo(); ! void DrawHeadingObject(tsHeadingObjectInfo *apHOI, ! float afHeading_rad, float afHeadingGoal_rad); ! void DrawLandingInfo(); ! void DrawSensorControl(); ! ! void InitControls(); ! void SetControlGameObject(tcGameObject* obj); ! void UpdateControlObjects(); ! void UpdateSymbolList(); ! void GetObjectInfo(tcString& s, tcDatabaseObject *apDBObject, tcGameObject *apGameObject); }; Index: tcMissileObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcMissileObject.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcMissileObject.h 7 Nov 2004 03:40:43 -0000 1.13 --- tcMissileObject.h 23 Nov 2004 23:30:49 -0000 1.14 *************** *** 46,49 **** --- 46,50 ---- float mfGoalSpeed_kts; double mfInterceptTime; + bool subSurfaceLaunch; ///< true during subsurface launch phase for sub-launched missiles // are all 3 of these necessary? needs refactoring Index: tcLauncherState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcLauncherState.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcLauncherState.h 16 Aug 2004 01:43:30 -0000 1.9 --- tcLauncherState.h 23 Nov 2004 23:30:49 -0000 1.10 *************** *** 72,75 **** --- 72,76 ---- LAUNCHER_INACTIVE = 10, NO_FIRECONTROL = 11, + TOO_DEEP = 12 ///< too deep for sub launch }; ///< launcher status codes Index: tcRadar.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcRadar.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcRadar.h 7 Nov 2004 03:40:43 -0000 1.10 --- tcRadar.h 23 Nov 2004 23:30:50 -0000 1.11 *************** *** 84,87 **** --- 84,88 ---- void Serialize(tcFile& file, bool mbLoad); + virtual bool IsRadar() const; virtual void Update(double t); Index: tcGameObject.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcGameObject.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** tcGameObject.h 6 Nov 2004 15:13:40 -0000 1.26 --- tcGameObject.h 23 Nov 2004 23:30:49 -0000 1.27 *************** *** 149,152 **** --- 149,153 ---- float GetSpan() const; float GetTerrainElevation() {return mcTerrain.mfHeight_m;} + bool IsOwnAlliance() const; virtual void Launch(tnPoolIndex& rnKey, unsigned& rnLauncher) {} virtual void SetHeading(float afNewHeading) {} Index: tcOpticalSensor.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcOpticalSensor.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcOpticalSensor.h 6 Nov 2004 15:13:40 -0000 1.1 --- tcOpticalSensor.h 23 Nov 2004 23:30:50 -0000 1.2 *************** *** 51,54 **** --- 51,55 ---- void Serialize(tcFile& file, bool mbLoad); + virtual bool IsOptical() const; virtual void Update(double t); Index: tcSensorState.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcSensorState.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcSensorState.h 6 Nov 2004 15:13:40 -0000 1.12 --- tcSensorState.h 23 Nov 2004 23:30:50 -0000 1.13 *************** *** 75,78 **** --- 75,83 ---- virtual bool InitFromDatabase(long key); ///< initializes sensor using database data at key bool IsHidden() const; + + virtual bool IsESM() const; + virtual bool IsRadar() const; + virtual bool IsSonar() const; + virtual bool IsOptical() const; void Serialize(tcFile& file, bool mbLoad); Index: tcESMSensor.h =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/include/sim/tcESMSensor.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcESMSensor.h 6 Nov 2004 15:13:40 -0000 1.6 --- tcESMSensor.h 23 Nov 2004 23:30:47 -0000 1.7 *************** *** 45,48 **** --- 45,49 ---- virtual bool InitFromDatabase(long key); ///< initializes sensor using database data at key bool IsDetected(const tcRadar* emitter, float& rfAz_rad); + virtual bool IsESM() const; void Serialize(tcFile& file, bool mbLoad); virtual void Update(double t); |