[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.128,1.129 tcBallisticWeapon.cpp,1.13,1.14 tcCommandObject
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-05-05 02:15:06
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv777/src/sim Modified Files: Game.cpp tcBallisticWeapon.cpp tcCommandObject.cpp tcLauncher.cpp tcLauncherState.cpp tcObjectControl.cpp tcPlatformObject.cpp tcSensorMap.cpp tcSimState.cpp tcTorpedoObject.cpp Log Message: Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** tcSimState.cpp 29 Apr 2005 18:52:56 -0000 1.78 --- tcSimState.cpp 5 May 2005 02:14:55 -0000 1.79 *************** *** 58,61 **** --- 58,62 ---- #include "tcMessageInterface.h" #include "tcPositionRegistry.h" + #include "network/tcMultiplayerInterface.h" #ifdef _DEBUG *************** *** 872,875 **** --- 873,880 ---- } + bool tcSimState::IsMultiplayerServer() const + { + return (multiplayerMode == MM_SERVER); + } *************** *** 931,934 **** --- 936,968 ---- /** + * In single player mode, play sound effect if entity is owned by user. + * In multiplayer server mode, send sound effect message to player + */ + void tcSimState::PlayEntitySoundEffect(tcGameObject* obj, const std::string& effect) + { + using network::tcMultiplayerInterface; + + if (multiplayerMode == MM_OFF) + { + if (mpUserInfo->IsOwnAlliance(obj->GetAlliance())) + { + tcSound::Get()->PlayEffect(effect); + } + } + else if (multiplayerMode == MM_SERVER) + { + const std::string& controller = obj->GetController(); + if (controller.size()) + { + tcMultiplayerInterface::Get()->SendSoundEffect(controller, effect, obj->mnID); + } + } + else + { + wxASSERT(false); + } + } + + /** * */ *************** *** 1587,1594 **** missile->LaunchFrom(launchingPlatform, nLauncher); ! if (mpUserInfo->IsOwnAlliance(launchingPlatform->GetAlliance())) ! { ! tcSound::Get()->PlayEffect("MissileLaunch"); ! } } else if (tcTorpedoObject* torp = dynamic_cast<tcTorpedoObject*>(launched)) --- 1621,1625 ---- missile->LaunchFrom(launchingPlatform, nLauncher); ! PlayEntitySoundEffect(launchingPlatform, "MissileLaunch"); } else if (tcTorpedoObject* torp = dynamic_cast<tcTorpedoObject*>(launched)) *************** *** 1596,1603 **** torp->LaunchFrom(launchingPlatform, nLauncher); ! if (mpUserInfo->IsOwnAlliance(launchingPlatform->GetAlliance())) ! { ! tcSound::Get()->PlayEffect("torpedo_launch"); ! } } else if (tcBallisticWeapon* ballistic = dynamic_cast<tcBallisticWeapon*>(launched)) --- 1627,1631 ---- torp->LaunchFrom(launchingPlatform, nLauncher); ! PlayEntitySoundEffect(launchingPlatform, "torpedo_launch"); } else if (tcBallisticWeapon* ballistic = dynamic_cast<tcBallisticWeapon*>(launched)) *************** *** 1605,1618 **** ballistic->LaunchFrom(launchingPlatform, nLauncher); ! if (mpUserInfo->IsOwnAlliance(launchingPlatform->GetAlliance())) { ! if (ballistic->IsGunRound()) ! { ! tcSound::Get()->PlayEffect("NavalGun1"); ! } ! else if (ballistic->IsPointDefense()) ! { ! tcSound::Get()->PlayEffect("Gatling"); ! } } } --- 1633,1643 ---- ballistic->LaunchFrom(launchingPlatform, nLauncher); ! if (ballistic->IsGunRound()) { ! PlayEntitySoundEffect(launchingPlatform, "NavalGun1"); ! } ! else if (ballistic->IsPointDefense()) ! { ! PlayEntitySoundEffect(launchingPlatform, "Gatling"); } } Index: tcBallisticWeapon.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcBallisticWeapon.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tcBallisticWeapon.cpp 29 Apr 2005 18:52:55 -0000 1.13 --- tcBallisticWeapon.cpp 5 May 2005 02:14:54 -0000 1.14 *************** *** 49,52 **** --- 49,55 ---- tcWeaponObject::operator<<(stream); + stream >> vxy_mps; + stream >> vz_mps; + return stream; } *************** *** 59,62 **** --- 62,68 ---- tcWeaponObject::operator>>(stream); + stream << vxy_mps; + stream << vz_mps; + return stream; } Index: tcTorpedoObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcTorpedoObject.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcTorpedoObject.cpp 29 Apr 2005 18:52:56 -0000 1.10 --- tcTorpedoObject.cpp 5 May 2005 02:14:55 -0000 1.11 *************** *** 54,59 **** seeker << stream; - wxASSERT(false); - return stream; } --- 54,57 ---- *************** *** 73,79 **** stream << guidanceUpdateInterval; waypoint >> stream; ! seeker << stream; ! ! wxASSERT(false); return stream; --- 71,75 ---- stream << guidanceUpdateInterval; waypoint >> stream; ! seeker >> stream; return stream; Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** tcLauncherState.cpp 17 Apr 2005 22:35:32 -0000 1.29 --- tcLauncherState.cpp 5 May 2005 02:14:54 -0000 1.30 *************** *** 383,392 **** tcCommandStream& tcLauncherState::operator<<(tcCommandStream& stream) { ! for(int n = 0; n < mnCount; n++) { ! // const tcLauncher* launcher = &launchers[n]; ! ! int launcherFlag = GetLauncherFlag(n); ! commandObj.LoadCommandParam(stream, *launchers[n], launcherFlag); } --- 383,389 ---- tcCommandStream& tcLauncherState::operator<<(tcCommandStream& stream) { ! for (int n = 0; n < mnCount; n++) { ! *launchers[n] << stream; } *************** *** 590,593 **** --- 587,595 ---- for(int i=0; i<mnCount; i++) { + if (simState->IsMultiplayerServer()) + { + launchers[i]->UpdateStatus(); + } + if (launchers[i]->mbActive) { Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.128 retrieving revision 1.129 diff -C2 -d -r1.128 -r1.129 *** Game.cpp 29 Apr 2005 18:52:55 -0000 1.128 --- Game.cpp 5 May 2005 02:14:53 -0000 1.129 *************** *** 306,310 **** creditView->SetActive(false); scenarioSelectView->SetActive(false); ! viewer->SetTerrainActive(true); --- 306,310 ---- creditView->SetActive(false); scenarioSelectView->SetActive(false); ! networkView->SetActive(false); viewer->SetTerrainActive(true); *************** *** 2230,2234 **** if (multiplayerMode != 0) { ! meScreenMode = NETWORK; } return; --- 2230,2241 ---- if (multiplayerMode != 0) { ! if (meScreenMode == NETWORK) ! { ! meScreenMode = TACTICAL; ! } ! else ! { ! meScreenMode = NETWORK; ! } } return; Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** tcLauncher.cpp 16 Apr 2005 20:44:43 -0000 1.17 --- tcLauncher.cpp 5 May 2005 02:14:54 -0000 1.18 *************** *** 74,77 **** --- 74,79 ---- } + stream >> status; + return stream; } *************** *** 86,90 **** stream << mnCurrent; stream << errorCode; ! return stream; } --- 88,92 ---- stream << mnCurrent; stream << errorCode; ! stream << status; return stream; } *************** *** 105,108 **** --- 107,123 ---- stream >> msDatum.mfLon_rad; + unsigned char useTorpedoParams; + stream >> useTorpedoParams; + if (useTorpedoParams != 0) + { + stream >> usePassive; + stream >> preEnableSpeed_kts; + stream >> runDepth_m; + stream >> ceiling_m; + stream >> floor_m; + stream >> runToEnable_m; + fprintf(stdout, "Updating launcher torpedo params (%d/%d)\n", this, parent); + } + return stream; } *************** *** 119,122 **** --- 134,149 ---- stream << msDatum.mfLon_rad; + unsigned char useTorpedoParams = (preEnableSpeed_kts > 0); + stream << useTorpedoParams; + if (useTorpedoParams != 0) + { + stream << usePassive; + stream << preEnableSpeed_kts; + stream << runDepth_m; + stream << ceiling_m; + stream << floor_m; + stream << runToEnable_m; + } + return stream; } *************** *** 231,511 **** int tcLauncher::GetLauncherStatus() { ! 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 ! ! if (isDamaged) {return 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; ! } ! ! bool hasTarget = (mnTargetID != NULL_INDEX); ! ! 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; ! } ! } ! else if (meLaunchMode == TARGET_ONLY) ! { ! if (hasTarget) ! { ! return LAUNCHER_READY; ! } ! else ! { ! return NO_TARGET; ! } ! } ! ! ! ! // will launch and either proceed unguided or autonomously search out target ! if (meLaunchMode == AUTO) ! { ! bool hasDatum = (msDatum.mfLat_rad != 0) || (msDatum.mfLon_rad != 0); ! 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 } - /** - * @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 - - if (isDamaged) {return 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; - } - - bool hasTarget = (mnTargetID != NULL_INDEX); - - 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; - } - } - else if (meLaunchMode == TARGET_ONLY) - { - if (hasTarget) - { - return LAUNCHER_READY; - } - else - { - return NO_TARGET; - } - } - - - - // will launch and either proceed unguided or autonomously search out target - if (meLaunchMode == AUTO) - { - bool hasDatum = (msDatum.mfLat_rad != 0) || (msDatum.mfLon_rad != 0); - - 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 - } /** --- 258,269 ---- int tcLauncher::GetLauncherStatus() { ! if (!parent->IsClientMode()) ! { ! UpdateStatus(); ! } ! return (int)status; } /** *************** *** 553,556 **** --- 311,319 ---- } + unsigned char tcLauncher::GetStatus() const + { + return status; + } + /** *************** *** 694,697 **** --- 457,489 ---- /** + * Added so that appropriate commandObj receives new command for multiplayer + */ + void tcLauncher::SetLaunch(unsigned int quantity) + { + if (tcPlatformObject* platform = dynamic_cast<tcPlatformObject*>(parent)) + { + // find launcher index + bool searching = true; + unsigned int nLaunchers = platform->GetLauncherCount(); + for (unsigned int n=0; (n<nLaunchers) && searching; n++) + { + if (platform->GetLauncher(n) == this) + { + platform->SetLaunch(n, quantity); + searching = false; + } + } + if (searching) + { + fprintf(stderr, "tcLauncher::SetLaunch - couldn't find launcher in parent\n"); + } + } + else + { + wxASSERT(false); + } + } + + /** * */ *************** *** 709,771 **** } /** * Converts launcher status code into string. */ ! std::string tcLauncher::TranslateStatus(int status) { ! if (status == LAUNCHER_READY) { return "Launcher ready"; } ! else if (status == LAUNCHER_EMPTY) { return "Launcher empty"; } ! else if (status == LAUNCHER_BUSY) { return "Launcher busy"; } ! else if (status == NO_DATUM) { return "No datum"; } ! else if (status == NO_TARGET) { return "No target"; } ! else if (status == NOT_DETECTED_FC) { return "Not detected by fire control"; } ! else if (status == NOT_DETECTED_SEEKER) { return "Not detected by seeker"; } ! else if (status == FC_BUSY) { return "Fire control busy"; } ! else if (status == LAUNCHER_ERROR) { return "Corrupt launcher error"; } ! else if (status == LAUNCHER_INACTIVE) { return "Launcher inactive or damaged"; } ! else if (status == NO_FIRECONTROL) { return "No fire control sensor (database error)"; } ! else if (status == TOO_DEEP) { return "Too deep for launch"; } ! else if (status == DAMAGED) { return "Launcher damaged"; } ! else if (status == BAD_LAUNCHER) { return "Invalid launcher"; --- 501,745 ---- } + void tcLauncher::UpdateStatus() + { + using namespace Database; + + if (mnCurrent <= 0) + { + status = LAUNCHER_EMPTY; + return; + } + + if ((mfTimeToReady > 0) || (isLoading)) + { + status = LAUNCHER_BUSY; + return; + } + if (!mbActive) + { + status = LAUNCHER_INACTIVE; + return; + } + + if (isDamaged) + { + status = DAMAGED; + return; + } + + 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) + { + status = TOO_DEEP; + return; + } + } + else if (tcTorpedoDBObject* torpedo = + dynamic_cast<tcTorpedoDBObject*>(mpChildDBObj)) + { + if (-parent->mcKin.mfAlt_m > torpedo->maxDepth_m) + { + status = TOO_DEEP; + return; + } + } + + bool hasTarget = (mnTargetID != NULL_INDEX); + + if (meLaunchMode == DATUM_ONLY) // needs a datum programmed to launch + { + if ((msDatum.mfLat_rad != 0) || (msDatum.mfLon_rad != 0)) + { + status = LAUNCHER_READY; + } + else + { + status = NO_DATUM; + } + return; + } + else if (meLaunchMode == TARGET_ONLY) + { + if (hasTarget) + { + status = LAUNCHER_READY; + } + else + { + status = NO_TARGET; + } + return; + } + + + + // will launch and either proceed unguided or autonomously search out target + if (meLaunchMode == AUTO) + { + bool hasDatum = (msDatum.mfLat_rad != 0) || (msDatum.mfLon_rad != 0); + if ((!hasDatum) && (!hasTarget)) + { + status = NO_TARGET; + } + else + { + status = LAUNCHER_READY; + } + return; + } + + // if running as multiplayer client, seeker track can't be checked so defer checking to server + if (parent->IsClientMode()) + { + status = LAUNCHER_READY; + return; + } + + 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) + { + status = NO_TARGET; // needs a target + return; + } + if (!fireControlSensor) + { + status = NO_FIRECONTROL; // database error + return; + } + + if (!fireControlSensor->IsTrackAvailable()) + { + status = FC_BUSY; // no FC tracks available + return; + } + if (targetObj == NULL) + { + status = NOT_DETECTED_FC; // target doesn't exist + return; + } + + float range; + if (!fireControlSensor->CanDetectTarget(targetObj, range)) + { + status = NOT_DETECTED_FC; + return; + } + + if (meLaunchMode == FC_TRACK) + { + status = LAUNCHER_READY; + return; + } + } + + // 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; + status = LAUNCHER_ERROR; + return; + } + tnPoolIndex nSensorKey = pMissileDBObj->GetPrimarySeekerKey(); + + long fcID = parent->mnID; + unsigned fcIdx = fireControlSensorIdx; + + bool canDetect = simState->RadarCanDetect(nSensorKey, targetObj, + parent, pointingAngle, fcID, fcIdx); + + if (canDetect) + { + status = LAUNCHER_READY; + } + else + { + status = NOT_DETECTED_SEEKER; + } + return; + } + + + status = LAUNCHER_ERROR; // bad meLaunchMode + } /** * Converts launcher status code into string. */ ! std::string tcLauncher::TranslateStatus(int statusCode) { ! if (statusCode == LAUNCHER_READY) { return "Launcher ready"; } ! else if (statusCode == LAUNCHER_EMPTY) { return "Launcher empty"; } ! else if (statusCode == LAUNCHER_BUSY) { return "Launcher busy"; } ! else if (statusCode == NO_DATUM) { return "No datum"; } ! else if (statusCode == NO_TARGET) { return "No target"; } ! else if (statusCode == NOT_DETECTED_FC) { return "Not detected by fire control"; } ! else if (statusCode == NOT_DETECTED_SEEKER) { return "Not detected by seeker"; } ! else if (statusCode == FC_BUSY) { return "Fire control busy"; } ! else if (statusCode == LAUNCHER_ERROR) { return "Corrupt launcher error"; } ! else if (statusCode == LAUNCHER_INACTIVE) { return "Launcher inactive or damaged"; } ! else if (statusCode == NO_FIRECONTROL) { return "No fire control sensor (database error)"; } ! else if (statusCode == TOO_DEEP) { return "Too deep for launch"; } ! else if (statusCode == DAMAGED) { return "Launcher damaged"; } ! else if (statusCode == BAD_LAUNCHER) { return "Invalid launcher"; *************** *** 794,798 **** pointingElevation(0), isLoading(false), ! isDamaged(false) { wxASSERT(dbObj); --- 768,774 ---- pointingElevation(0), isLoading(false), ! isDamaged(false), ! preEnableSpeed_kts(0), ! status(LAUNCHER_INACTIVE) { wxASSERT(dbObj); Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** tcPlatformObject.cpp 29 Apr 2005 18:52:56 -0000 1.42 --- tcPlatformObject.cpp 5 May 2005 02:14:55 -0000 1.43 *************** *** 679,682 **** --- 679,687 ---- } + if (updateMask & UPDATE_AI) + { + brain->operator<<(stream); + } + return stream; } *************** *** 701,707 **** --- 706,718 ---- updateMask |= UPDATE_SENSORS; } + if (brain->HasNewCommand()) + { + updateMask |= UPDATE_AI; + } if (stream.GetDetailLevel() == tcStream::WRITE_ALL) updateMask = 0xFF; + if (IsClientMode()) updateMask &= (~UPDATE_AI); // don't do ai updates at client + stream << updateMask; *************** *** 730,733 **** --- 741,749 ---- } + if (updateMask & UPDATE_AI) + { + brain->operator>>(stream); + } + return stream; *************** *** 792,801 **** mcLauncherState.ClearNewCommand(); tcSensorPlatform::ClearNewCommand(); } bool tcPlatformObject::HasNewCommand() const { return commandObj.HasNewCommand() || mcLauncherState.HasNewCommand() || ! tcSensorPlatform::HasNewCommand(); } --- 808,820 ---- mcLauncherState.ClearNewCommand(); tcSensorPlatform::ClearNewCommand(); + brain->ClearNewCommand(); } bool tcPlatformObject::HasNewCommand() const { + bool newBrainCommand = !IsClientMode() && brain->HasNewCommand(); + return commandObj.HasNewCommand() || mcLauncherState.HasNewCommand() || ! tcSensorPlatform::HasNewCommand() || newBrainCommand; } Index: tcSensorMap.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSensorMap.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** tcSensorMap.cpp 29 Mar 2005 00:12:46 -0000 1.18 --- tcSensorMap.cpp 5 May 2005 02:14:55 -0000 1.19 *************** *** 68,71 **** --- 68,73 ---- } + stream >> sensorFlags; + return stream; } *************** *** 84,99 **** } ! /* ! tcSensorReport maSensorReport[MAX_SENSOR_REPORTS]; // most recent data from contributing sensors ! int mnContributors; ! tsEmitterInfo maEmitterInfo[MAX_EMITTERS]; ! int mnEmitters; ! tnPoolIndex mnDatabaseID; // database ID of track ! float matchupRating; ///< matchup rating for platforms that have targeted this track ! float expectedDamage; ///< rating of expected fractional damage of weapons launched at target, 0 - none, 1.0 - totally destroyed ! float assessedDamage; ///< fractional damage assessment ! std::vector<long> intercepts; ///< vector of platform ids that are intercepting this track ! std::vector<long> engaged; ///< vector of weapon ids that are tracking / engaging ! */ return stream; } --- 86,91 ---- } ! stream << sensorFlags; ! return stream; } Index: tcCommandObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcCommandObject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcCommandObject.cpp 17 Apr 2005 22:35:32 -0000 1.3 --- tcCommandObject.cpp 5 May 2005 02:14:54 -0000 1.4 *************** *** 126,163 **** } - /** - * version that takes tcLauncher param - */ - void tcCommandObject::LoadCommandParam(tcCommandStream& stream, tcLauncher& param, int flag) - { - tcLauncher temp; - temp << stream; // read into temporary obj - - param.CopyCommandInfoFrom(temp); // apply update - - /* - - if (stream.GetAck()) - { - if ((commandStatus & flag) && (temp.CommandInfoMatches(param))) - { - commandStatus &= (~flag); // clear flag, successful ack - } - } - else // not an ack - { - if (clientMode && (commandStatus & flag)) - { - // ignore update - } - else - { - param.CopyCommandInfoFrom(temp); // apply update - commandStatus &= (~flag); // clear flag - } - - } - */ - } --- 126,129 ---- Index: tcObjectControl.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcObjectControl.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** tcObjectControl.cpp 29 Apr 2005 18:52:55 -0000 1.35 --- tcObjectControl.cpp 5 May 2005 02:14:54 -0000 1.36 *************** *** 707,711 **** for(int i=0;i<mnLaunchers;i++) { ! const tcLauncher* pLauncher = pLauncherState->GetLauncher(i); int nLaunchCount = pLauncher->mnCurrent; --- 707,711 ---- for(int i=0;i<mnLaunchers;i++) { ! tcLauncher* pLauncher = pLauncherState->GetLauncher(i); int nLaunchCount = pLauncher->mnCurrent; |