[Gcblue-commits] gcb_wx/src/sim Game.cpp,1.80,1.81 tcLauncher.cpp,1.1,1.2 tcLauncherState.cpp,1.9,1.
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-05-29 00:12:05
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18876/src/sim Modified Files: Game.cpp tcLauncher.cpp tcLauncherState.cpp tcPlatformObject.cpp tcRadar.cpp Log Message: Index: tcLauncher.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncher.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tcLauncher.cpp 24 May 2004 00:14:47 -0000 1.1 --- tcLauncher.cpp 29 May 2004 00:11:54 -0000 1.2 *************** *** 32,35 **** --- 32,90 ---- * */ + tcCreateStream& tcLauncher::operator<<(tcCreateStream& stream) + { + return stream; + } + + + /** + * + */ + tcCreateStream& tcLauncher::operator>>(tcCreateStream& stream) + { + + return stream; + } + + + /** + * Loads state from update stream + */ + tcUpdateStream& tcLauncher::operator<<(tcUpdateStream& stream) + { + stream >> mfTimeToReady; + stream >> mnCurrent; + + if (mnUncommitted > mnCurrent) mnUncommitted = mnCurrent; + + stream >> errorCode; + if (errorCode != 0) + { + mnUncommitted = mnCurrent; + } + + return stream; + } + + /** + * Saves state to update stream + */ + tcUpdateStream& tcLauncher::operator>>(tcUpdateStream& stream) + { + + stream << mfTimeToReady; + stream << mnCurrent; + stream << errorCode; + + return stream; + } + + + + + + /** + * + */ tcCommandStream& tcLauncher::operator<<(tcCommandStream& stream) { *************** *** 92,138 **** } - /** - * - */ - tcCreateStream& tcLauncher::operator<<(tcCreateStream& stream) - { - return stream; - } - - /** - * Loads state from update stream - */ - tcUpdateStream& tcLauncher::operator<<(tcUpdateStream& stream) - { - stream >> mfTimeToReady; - stream >> mnCurrent; - if (mnUncommitted > mnCurrent) mnUncommitted = mnCurrent; - - return stream; - } - - /** - * Saves state to update stream - */ - tcUpdateStream& tcLauncher::operator>>(tcUpdateStream& stream) - { - - stream << mfTimeToReady; - stream << mnCurrent; - - return stream; - } - - - - /** - * - */ - tcCreateStream& tcLauncher::operator>>(tcCreateStream& stream) - { - - return stream; - } - --- 147,150 ---- Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** tcPlatformObject.cpp 24 May 2004 00:14:47 -0000 1.23 --- tcPlatformObject.cpp 29 May 2004 00:11:54 -0000 1.24 *************** *** 232,235 **** --- 232,236 ---- void tcPlatformObject::UpdateSensors(double t) { + if (clientMode) return; // no sensor update for client unsigned nSensors = mapSensorState.size(); for(unsigned n=0;n<nSensors;n++) Index: Game.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/Game.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** Game.cpp 24 May 2004 00:14:47 -0000 1.80 --- Game.cpp 29 May 2004 00:11:54 -0000 1.81 *************** *** 89,92 **** --- 89,97 ---- END_EVENT_TABLE() + + + tcSoundConsole* tcGame::messageConsole = NULL; + + /** * The tcGame object constructor. *************** *** 156,159 **** --- 161,165 ---- delete pythonInterface; } + messageConsole = NULL; Finish(); *************** *** 201,204 **** --- 207,221 ---- } + /** + * Static method to display generic message to user in game + */ + void tcGame::DisplayMessage(const char* msg) + { + if (messageConsole) + { + messageConsole->Print(msg); + } + } + /** *************** *** 678,681 **** --- 695,699 ---- infoConsole = new tcSoundConsole(glCanvas, wxPoint(mrectLowerLeft.left,mrectLowerLeft.top), wxSize(200,200)); + messageConsole = infoConsole; if (!infoConsole) Index: tcLauncherState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcLauncherState.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcLauncherState.cpp 24 May 2004 00:14:47 -0000 1.9 --- tcLauncherState.cpp 29 May 2004 00:11:54 -0000 1.10 *************** *** 34,37 **** --- 34,43 ---- tcSimState* tcLauncherState::simState = NULL; + class tcGame + { + public: + static void DisplayMessage(const char* msg); + }; + /** * @param anKey, key of launcher database object in database *************** *** 89,92 **** --- 95,100 ---- new_launcher.pointingAngle = azimuth_rad; new_launcher.fireControlSensor = NULL; + new_launcher.errorCode = 0; + // set detailed launch mode if missile tcMissileDBObject* pMissileDBObj = *************** *** 180,183 **** --- 188,213 ---- wxASSERT(parent); + + // will launch and either proceed unguided or autonomously search out target + if (ldata.meLaunchMode == AUTO) + { + bool hasDatum = (ldata.msDatum.mfLat_rad != 0) || (ldata.msDatum.mfLon_rad != 0); + bool hasTarget = (ldata.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(ldata.mnTargetID); *************** *** 227,244 **** } ! // will launch and either proceed unguided or autonomously search out target ! if (ldata.meLaunchMode == AUTO) ! { ! bool hasDatum = (ldata.msDatum.mfLat_rad != 0) || (ldata.msDatum.mfLon_rad != 0); ! bool hasTarget = (ldata.mnTargetID == NULL_INDEX); ! if ((!hasDatum) && (!hasTarget)) ! { ! return NO_TARGET; ! } ! else ! { ! return LAUNCHER_READY; ! } ! } return LAUNCHER_ERROR; // bad meLaunchMode --- 257,261 ---- } ! return LAUNCHER_ERROR; // bad meLaunchMode *************** *** 262,266 **** * This only handles one launch per call (not efficient for simultaneous launches) */ ! void tcLauncherState::Launch(tnPoolIndex& key, unsigned& nLauncher) { for (int n=0; n<mnCount; n++) --- 279,283 ---- * This only handles one launch per call (not efficient for simultaneous launches) */ ! void tcLauncherState::Launch(long& key, unsigned& nLauncher) { for (int n=0; n<mnCount; n++) *************** *** 273,283 **** if (bLaunch) { ! pLauncher->mnCurrent--; ! key = pLauncher->mnChildDBKey; ! nLauncher = n; ! pLauncher->mfTimeToReady = 2.0f; // TODO: add db parameter for this ! return; } } } key = NULL_INDEX; --- 290,326 ---- if (bLaunch) { ! /* If no error is set, then check for a new error. ! ** If this is a multiplayer client object, the only way to clear ! ** an error is for the client to remove the launch request. ! ** If a multiplayer server obj or single-player, the launch request ! ** should never happen in the first place. This is not the best way ! ** to do this. In the future add an auto-clear, or at least an error ! ** message to test this case. ! */ ! int statusCode = pLauncher->GetErrorCode(); ! if (statusCode == 0) ! { ! statusCode = GetLauncherStatus(nLauncher); ! pLauncher->SetErrorCode(statusCode); ! } ! ! if (statusCode == LAUNCHER_READY) ! { ! pLauncher->mnCurrent--; ! key = pLauncher->mnChildDBKey; ! nLauncher = n; ! pLauncher->mfTimeToReady = 2.0f; // TODO: add db parameter for this ! return; ! } ! else ! { ! } ! } } + else + { + pLauncher->SetErrorCode(0); // clear error if not active or no launch requested + } } key = NULL_INDEX; *************** *** 318,322 **** statusCode = GetLauncherStatus(nLauncher); ! if (statusCode != tcLauncherState::LAUNCHER_READY) return statusCode; tcLauncher* pLauncher = &launchers[nLauncher]; --- 361,369 ---- statusCode = GetLauncherStatus(nLauncher); ! ! if (statusCode != tcLauncherState::LAUNCHER_READY) ! { ! return statusCode; ! } tcLauncher* pLauncher = &launchers[nLauncher]; *************** *** 467,470 **** --- 514,523 ---- tcLauncher& ldata = launchers[n]; ldata << stream; + if (int errorCode = ldata.GetErrorCode()) + { + // set the new command flag to allow the launch request to be cleared + commandObj.SetNewCommand(GetLauncherFlag(n)); + tcGame::DisplayMessage(TranslateLauncherStatus(errorCode).c_str()); + } } Index: tcRadar.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcRadar.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcRadar.cpp 24 May 2004 00:14:47 -0000 1.7 --- tcRadar.cpp 29 May 2004 00:11:54 -0000 1.8 *************** *** 40,44 **** tcSensorState::operator<<(stream); ! //stream >> fireControlTrackCount; stream >> illuminatorID; stream >> illuminatorSensorIdx; --- 40,44 ---- tcSensorState::operator<<(stream); ! stream >> fireControlTrackCount; stream >> illuminatorID; stream >> illuminatorSensorIdx; *************** *** 56,60 **** tcSensorState::operator>>(stream); ! //stream << fireControlTrackCount; stream << illuminatorID; stream << illuminatorSensorIdx; --- 56,60 ---- tcSensorState::operator>>(stream); ! stream << fireControlTrackCount; stream << illuminatorID; stream << illuminatorSensorIdx; |