[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.122,1.123 tcAeroAirObject.cpp,1.9,1.10 tcAirObject.cpp,1.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-03-10 03:28:42
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14606/src/sim Modified Files: Game.cpp tcAeroAirObject.cpp tcAirObject.cpp tcBallisticWeapon.cpp tcGameObject.cpp tcLauncher.cpp tcLauncherState.cpp tcMissileObject.cpp tcPositionRegistry.cpp tcRadar.cpp tcSimState.cpp tcSonar.cpp tcSubObject.cpp tcTorpedoObject.cpp Log Message: Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** tcSimState.cpp 8 Mar 2005 00:41:50 -0000 1.71 --- tcSimState.cpp 10 Mar 2005 03:28:29 -0000 1.72 *************** *** 495,499 **** { tcGameObject* target = GetObject(blastPlats[idx]); ! if (target && (target->mnID != weapon->mnID)) { float range_m = 1000.0f * target->mcKin.RangeToKmAlt(weapon->mcKin); --- 495,502 ---- { tcGameObject* target = GetObject(blastPlats[idx]); ! ! bool eligible = target && (target->mnID != weapon->mnID) && (target->mcKin.mfAlt_m >= -5.0f); ! ! if (eligible) { float range_m = 1000.0f * target->mcKin.RangeToKmAlt(weapon->mcKin); *************** *** 615,619 **** return afDamage / pPlatformObj->mpDBObject->mfToughness; } ! wxASSERT(false); return afDamage; } --- 618,622 ---- return afDamage / pPlatformObj->mpDBObject->mfToughness; } ! return afDamage; } Index: tcMissileObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMissileObject.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tcMissileObject.cpp 24 Feb 2005 22:19:16 -0000 1.23 --- tcMissileObject.cpp 10 Mar 2005 03:28:29 -0000 1.24 *************** *** 192,199 **** msKState.mfPitch_rad = mcKin.mfPitch_rad; - tcString s; - s.Format("From %s", obj->mzUnit.mz); - mzUnit = s.GetBuffer(); mnAlliance = obj->mnAlliance; --- 192,198 ---- msKState.mfPitch_rad = mcKin.mfPitch_rad; + wxString s = wxString::Format("Missile %d-%d", obj->mnID, rand() % 1000); + mzUnit = s.c_str(); mnAlliance = obj->mnAlliance; *************** *** 508,514 **** mfGoalPitch_rad = 0.0f; } - // switch to next flight profile segment if within range ! if (mnCurrentSegment < (mpDBObject->mnNumSegments-1)) { if (mfRangeToObjective_km < pSegmentInfo->mfRange_km) --- 507,512 ---- mfGoalPitch_rad = 0.0f; } // switch to next flight profile segment if within range ! else if (mnCurrentSegment < (mpDBObject->mnNumSegments-1)) { if (mfRangeToObjective_km < pSegmentInfo->mfRange_km) Index: tcAeroAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAeroAirObject.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcAeroAirObject.cpp 18 Feb 2005 17:41:51 -0000 1.9 --- tcAeroAirObject.cpp 10 Mar 2005 03:28:29 -0000 1.10 *************** *** 45,48 **** --- 45,53 ---- } + bool tcAeroAirObject::IsDestroyed() + { + return mfDamageLevel >= 1.0f; + } + void tcAeroAirObject::RandInitNear(float afLon_deg, float afLat_deg) { Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tcLauncher.cpp 2 Mar 2005 22:28:44 -0000 1.12 --- tcLauncher.cpp 10 Mar 2005 03:28:29 -0000 1.13 *************** *** 157,160 **** --- 157,168 ---- /** + * Clears pending launch by resetting mnUncommitted + */ + void tcLauncher::ClearPendingLaunch() + { + mnUncommitted = (int)mnCurrent; + } + + /** * @return class name of child, or "Empty" if none */ *************** *** 341,344 **** --- 349,484 ---- } + + /** + * @return LAUNCHER_READY if launcher is ready to launch. Launch readiness + * @return conditions depend on meLaunchMode for the launcher. + * @return Otherwise return error code + * @see teWeaponLaunchMode + * @see tcLauncherState::teLauncherStatus + * This method needs to be separated into smaller pieces. + */ + int tcLauncher::GetLauncherStatus() const + { + using namespace Database; + + if (mnCurrent <= 0) {return LAUNCHER_EMPTY;} // launcher empty + if ((mfTimeToReady > 0) || (isLoading)) + { + return LAUNCHER_BUSY; + } + if (!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*>(mpChildDBObj)) + { + if (parent->mcKin.mfAlt_m < -30.0) return TOO_DEEP; + } + else if (tcTorpedoDBObject* torpedo = + dynamic_cast<tcTorpedoDBObject*>(mpChildDBObj)) + { + if (-parent->mcKin.mfAlt_m > torpedo->maxDepth_m) return TOO_DEEP; + } + + if (meLaunchMode == DATUM_ONLY) // needs a datum programmed to launch + { + if ((msDatum.mfLat_rad != 0) || (msDatum.mfLon_rad != 0)) + { + return LAUNCHER_READY; + } + else + { + return NO_DATUM; + } + } + + + + + // will launch and either proceed unguided or autonomously search out target + if (meLaunchMode == AUTO) + { + bool hasDatum = (msDatum.mfLat_rad != 0) || (msDatum.mfLon_rad != 0); + bool hasTarget = (mnTargetID == NULL_INDEX); + if ((!hasDatum) && (!hasTarget)) + { + return NO_TARGET; + } + else + { + return LAUNCHER_READY; + } + } + + // if running as multiplayer client, seeker track can't be checked so defer checking to server + if (parent->IsClientMode()) + { + return LAUNCHER_READY; + } + + tcGameObject *targetObj = simState->GetObject(mnTargetID); + + // TODO: called here as quick way to add autopoint feature, move to better location + /* + if (IsAutoPoint() && (targetObj != 0)) + { + pointingAngle = parent->BearingToRad(*targetObj) - parent->mcKin.mfHeading_rad; + if (pointingAngle >= C_PI) pointingAngle -= C_TWOPI; + else if (pointingAngle < -C_PI) pointingAngle += C_TWOPI; + } + */ + + // needs a fire control track (launching platform) to launch + if ((meLaunchMode == FC_TRACK)||(meLaunchMode == SEEKER_TRACK)) + { + if (mnTargetID == NULL_INDEX) return NO_TARGET; // needs a target + if (!fireControlSensor) return NO_FIRECONTROL; // database error + + if (!fireControlSensor->IsTrackAvailable()) return FC_BUSY; // no FC tracks available + if (targetObj == NULL) return NOT_DETECTED_FC; // target doesn't exist + + float range; + if (!fireControlSensor->CanDetectTarget(targetObj, range)) + { + return NOT_DETECTED_FC; + } + + if (meLaunchMode == FC_TRACK) return LAUNCHER_READY; + } + + // needs a seeker track to launch + if (meLaunchMode == SEEKER_TRACK) + { + tcMissileDBObject *pMissileDBObj = dynamic_cast<tcMissileDBObject*>(mpChildDBObj); + if (pMissileDBObj==NULL) + { + std::cerr << "GetLauncherStatus -- Error: SEEKER_TRACK guidance with non-missile" << std::endl; + return LAUNCHER_ERROR; + } + tnPoolIndex nSensorKey = pMissileDBObj->GetPrimarySeekerKey(); + + long fcID = parent->mnID; + unsigned fcIdx = fireControlSensorIdx; + + bool canDetect = simState->RadarCanDetect(nSensorKey, targetObj, + parent, pointingAngle, fcID, fcIdx); + + if (canDetect) + { + return LAUNCHER_READY; + } + else + { + return NOT_DETECTED_SEEKER; + } + } + + + return LAUNCHER_ERROR; // bad meLaunchMode + } + /** * *************** *** 488,494 **** { mnCurrent = quantity; ! if (mnCurrent > mpLauncherDBObj->mnCapacity) { ! mnCurrent = mpLauncherDBObj->mnCapacity; } mnUncommitted = mnCurrent; --- 628,634 ---- { mnCurrent = quantity; ! if (mnCurrent > (int)mpLauncherDBObj->mnCapacity) { ! mnCurrent = (int)mpLauncherDBObj->mnCapacity; } mnUncommitted = mnCurrent; Index: tcTorpedoObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcTorpedoObject.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcTorpedoObject.cpp 8 Mar 2005 00:41:51 -0000 1.8 --- tcTorpedoObject.cpp 10 Mar 2005 03:28:29 -0000 1.9 *************** *** 180,186 **** } ! tcString s; ! s.Format("From %s", obj->mzUnit.mz); ! mzUnit = s.GetBuffer(); mnAlliance = obj->mnAlliance; --- 180,186 ---- } ! wxString s = wxString::Format("Torp %d-%d", obj->mnID, rand() % 1000); ! mzUnit = s.c_str(); ! mnAlliance = obj->mnAlliance; Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** tcGameObject.cpp 8 Mar 2005 00:41:50 -0000 1.30 --- tcGameObject.cpp 10 Mar 2005 03:28:29 -0000 1.31 *************** *** 250,254 **** * */ ! float tcGameObject::RangeTo(tcGameObject& p) { return mcKin.RangeToKm(p.mcKin); --- 250,254 ---- * */ ! float tcGameObject::RangeTo(tcGameObject& p) const { return mcKin.RangeToKm(p.mcKin); *************** *** 285,289 **** * @return bearing to p in degrees */ ! float tcGameObject::BearingTo(tcGameObject& p) { return (float)(C_180OVERPI* --- 285,289 ---- * @return bearing to p in degrees */ ! float tcGameObject::BearingTo(tcGameObject& p) const { return (float)(C_180OVERPI* *************** *** 294,298 **** * @return bearing to p in radians */ ! float tcGameObject::BearingToRad(tcGameObject& p) { return (float)(atan2(p.mcKin.mfLon_rad-mcKin.mfLon_rad, --- 294,298 ---- * @return bearing to p in radians */ ! float tcGameObject::BearingToRad(tcGameObject& p) const { return (float)(atan2(p.mcKin.mfLon_rad-mcKin.mfLon_rad, Index: tcPositionRegistry.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPositionRegistry.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tcPositionRegistry.cpp 8 Mar 2005 00:41:50 -0000 1.2 --- tcPositionRegistry.cpp 10 Mar 2005 03:28:29 -0000 1.3 *************** *** 124,129 **** --- 124,131 ---- if (posIter == positionMap.end()) { + #ifdef _DEBUG fprintf(stderr, "tcPositionRegistry::RemoveIdFromBin - " "bin not found in positionMap (%d)\n", bin); + #endif return; } *************** *** 133,138 **** --- 135,142 ---- if (binIter == posIter->second.end()) { + #ifdef _DEBUG fprintf(stderr, "tcPositionRegistry::RemoveIdFromBin - " "id not found in bin map (%d, %d)\n", bin, id); + #endif return; } Index: tcSubObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSubObject.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** tcSubObject.cpp 8 Mar 2005 00:41:51 -0000 1.5 --- tcSubObject.cpp 10 Mar 2005 03:28:29 -0000 1.6 *************** *** 525,528 **** --- 525,530 ---- UpdateMessages(); + UpdateAI(afStatusTime); + mfStatusTime = afStatusTime; } Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcAirObject.cpp 8 Mar 2005 00:41:50 -0000 1.18 --- tcAirObject.cpp 10 Mar 2005 03:28:29 -0000 1.19 *************** *** 281,287 **** mcKin.mfPitch_rad = mcKin.mfClimbAngle_rad; ! mcKin.mfRoll_rad += 0.01f * dt_s; ! if (mcKin.mfAlt_m <= mcTerrain.mfHeight_m + 25.0f) { doneCrashing = true; --- 281,288 ---- mcKin.mfPitch_rad = mcKin.mfClimbAngle_rad; ! mcKin.mfRoll_rad += 0.1f * dt_s; ! if ((mcKin.mfAlt_m <= mcTerrain.mfHeight_m + 20.0f) || ! (mcKin.mfAlt_m <= 20.0f)) { doneCrashing = true; Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** tcLauncherState.cpp 7 Dec 2004 04:00:43 -0000 1.25 --- tcLauncherState.cpp 10 Mar 2005 03:28:29 -0000 1.26 *************** *** 215,219 **** tcLauncher* pLauncher = launchers[n]; ! if ((pLauncher->mbActive)&&(pLauncher->mnCurrent > pLauncher->mnUncommitted)) { bool bLaunch = (pLauncher->mnCurrent > 0)&&(pLauncher->mfTimeToReady <= 0); --- 215,219 ---- tcLauncher* pLauncher = launchers[n]; ! if ((pLauncher->mbActive)&&((int)pLauncher->mnCurrent > pLauncher->mnUncommitted)) { bool bLaunch = (pLauncher->mnCurrent > 0)&&(pLauncher->mfTimeToReady <= 0); *************** *** 245,248 **** --- 245,249 ---- else { + pLauncher->mnUncommitted = pLauncher->mnCurrent; // reset } *************** *** 303,307 **** { pLauncher->mnUncommitted = 0; // don't set new cmd here since this is an error case ! std::cerr << "Error - tcLauncherState::SetLaunch - negative uncommitted\n"; } else --- 304,310 ---- { pLauncher->mnUncommitted = 0; // don't set new cmd here since this is an error case ! #ifdef _DEBUG ! fprintf(stderr, "Warning - tcLauncherState::SetLaunch - request exceeds capacity\n"); ! #endif } else *************** *** 357,362 **** return false; } ! launchers[nLauncher]->mnTargetID = targetID; ! launchers[nLauncher]->msDatum.Set(0, 0, 0); // clear datum commandObj.SetNewCommand(GetLauncherFlag(nLauncher)); --- 360,368 ---- return false; } ! ! tcLauncher* launcher = launchers[nLauncher]; ! launcher->mnTargetID = targetID; ! launcher->msDatum.Set(0, 0, 0); // clear datum ! launcher->ClearPendingLaunch(); commandObj.SetNewCommand(GetLauncherFlag(nLauncher)); Index: tcSonar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSonar.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcSonar.cpp 8 Mar 2005 00:41:50 -0000 1.9 --- tcSonar.cpp 10 Mar 2005 03:28:29 -0000 1.10 *************** *** 206,210 **** else { ! fprintf(stderr, "tcSonar::SetActiveSonar - no active capability\n"); } } --- 206,211 ---- else { ! fprintf(stderr, "tcSonar::SetActiveSonar - no active capability (%s)\n", ! mpDBObj->mzClass.mz); } } *************** *** 495,499 **** wxASSERT(target->mpDBObject); unsigned int nClassification = target->mpDBObject->mnType; ! nClassification &= 0xFFF0; // leave size field unknown teAffiliation eAffil = UNKNOWN; if (nClassification & PTYPE_TORPEDO) {eAffil = HOSTILE;} --- 496,503 ---- wxASSERT(target->mpDBObject); unsigned int nClassification = target->mpDBObject->mnType; ! if (nClassification & PTYPE_SURFACE) ! { ! nClassification &= 0xFFF0; // leave size field unknown ! } teAffiliation eAffil = UNKNOWN; if (nClassification & PTYPE_TORPEDO) {eAffil = HOSTILE;} Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** Game.cpp 24 Feb 2005 22:19:15 -0000 1.122 --- Game.cpp 10 Mar 2005 03:28:29 -0000 1.123 *************** *** 2401,2405 **** popupControl->Freeze(); popupControl->SetMenu(MENUMODE_FLIGHTPANEL); ! popupControl->Track(wxPoint(mrectMap.left+20,mrectMap.top+70)); } } --- 2401,2405 ---- popupControl->Freeze(); popupControl->SetMenu(MENUMODE_FLIGHTPANEL); ! popupControl->Track(wxPoint(mrectMap.left+220,mrectMap.top+70)); } } Index: tcBallisticWeapon.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcBallisticWeapon.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcBallisticWeapon.cpp 24 Feb 2005 22:19:16 -0000 1.9 --- tcBallisticWeapon.cpp 10 Mar 2005 03:28:29 -0000 1.10 *************** *** 122,128 **** } ! tcString s; ! s.Format("Ball %s", obj->mzUnit.mz); ! mzUnit = s.GetBuffer(); mnAlliance = obj->mnAlliance; --- 122,128 ---- } ! wxString s = wxString::Format("Ball %d-%d", obj->mnID, rand() % 1000); ! mzUnit = s.c_str(); ! mnAlliance = obj->mnAlliance; Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** tcRadar.cpp 2 Mar 2005 22:28:45 -0000 1.26 --- tcRadar.cpp 10 Mar 2005 03:28:29 -0000 1.27 *************** *** 147,152 **** else { ! fprintf(stderr, "tcRadar::CanDetectTarget called with illegal target class (%s)\n", ! target->mzClass.mz); return false; } --- 147,158 ---- else { ! #ifdef _DEBUG ! static unsigned int reportCount = 0; ! if (reportCount++ < 3) ! { ! fprintf(stderr, "tcRadar::CanDetectTarget called with illegal target class (%s)\n", ! target->mzClass.mz); ! } ! #endif return false; } |