[Gcblue-commits] gcb_wx/src/sim tcAirObject.cpp,1.7,1.8 tcGameObject.cpp,1.14,1.15 tcMissileObject.c
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-05-01 21:49:17
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6949/src/sim Modified Files: tcAirObject.cpp tcGameObject.cpp tcMissileObject.cpp tcPlatformObject.cpp tcSurfaceObject.cpp tcWeaponObject.cpp Log Message: multiplayer Index: tcWeaponObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcWeaponObject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tcWeaponObject.cpp 23 Apr 2004 00:15:18 -0000 1.3 --- tcWeaponObject.cpp 1 May 2004 21:49:06 -0000 1.4 *************** *** 25,34 **** #include "tcSimState.h" #include "common/tcStream.h" /** ! * Load state from stream */ ! tcStream& tcWeaponObject::operator<<(tcStream& stream) { tcGameObject::operator<<(stream); --- 25,35 ---- #include "tcSimState.h" #include "common/tcStream.h" + #include "common/tcObjStream.h" /** ! * Load state from update stream */ ! tcUpdateStream& tcWeaponObject::operator<<(tcUpdateStream& stream) { tcGameObject::operator<<(stream); *************** *** 40,46 **** /** ! * Save state to stream */ ! tcStream& tcWeaponObject::operator>>(tcStream& stream) { tcGameObject::operator>>(stream); --- 41,47 ---- /** ! * Save state to update stream */ ! tcUpdateStream& tcWeaponObject::operator>>(tcUpdateStream& stream) { tcGameObject::operator>>(stream); Index: tcAirObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcAirObject.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tcAirObject.cpp 13 Feb 2004 01:31:33 -0000 1.7 --- tcAirObject.cpp 1 May 2004 21:49:06 -0000 1.8 *************** *** 26,29 **** --- 26,30 ---- #include "tcAirObject.h" #include "tcGenericDBObject.h" + #include "common/tcObjStream.h" /******************************************************************************/ *************** *** 31,35 **** /******************************************************************************/ ! void tcAirObject::Clear() { tcPlatformObject::Clear(); } --- 32,91 ---- /******************************************************************************/ ! tcCommandStream& tcAirObject::operator<<(tcCommandStream& stream) ! { ! tcPlatformObject::operator<<(stream); ! ! LoadCommandParam(stream, readyForLanding, commandStatus, LANDING_CMD); ! ! return stream; ! } ! ! tcCommandStream& tcAirObject::operator>>(tcCommandStream& stream) ! { ! tcPlatformObject::operator>>(stream); ! ! stream << readyForLanding; ! ! return stream; ! } ! ! tcUpdateStream& tcAirObject::operator<<(tcUpdateStream& stream) ! { ! tcPlatformObject::operator<<(stream); ! ! stream >> maxPitch_rad; ! ! return stream; ! } ! ! tcUpdateStream& tcAirObject::operator>>(tcUpdateStream& stream) ! { ! tcPlatformObject::operator>>(stream); ! ! stream << maxPitch_rad; ! ! return stream; ! } ! ! ! void tcAirObject::ClearNewCommand() ! { ! tcPlatformObject::ClearNewCommand(); ! newCommand = false; ! } ! ! bool tcAirObject::HasNewCommand() const ! { ! return tcPlatformObject::HasNewCommand() || newCommand; ! } ! ! bool tcAirObject::HasUnacknowledgedCommand() const ! { ! return tcPlatformObject::HasUnacknowledgedCommand() || (commandStatus != 0); ! } ! ! ! void tcAirObject::Clear() ! { tcPlatformObject::Clear(); } *************** *** 51,61 **** mcKin.mfRoll_rad = 0; mfDamageLevel = 0; ! mcGS.SetHeading(mcKin.mfHeading_rad); ! mcGS.SetSpeed(mcKin.mfSpeed_kts); ! mcGS.SetAltitude(mcKin.mfAlt_m); readyForLanding = 0; } /** * @param limit_rad Pitch angle limit in radians. Must be positive. */ --- 107,127 ---- mcKin.mfRoll_rad = 0; mfDamageLevel = 0; ! SetHeading(mcKin.mfHeading_rad); ! SetSpeed(mcKin.mfSpeed_kts); ! SetAltitude(mcKin.mfAlt_m); readyForLanding = 0; } /** + * Sets landing state for air object (gear up/down) + */ + void tcAirObject::SetLandingState(int state) + { + readyForLanding = state; + commandStatus |= LANDING_CMD; + newCommand = true; + } + + /** * @param limit_rad Pitch angle limit in radians. Must be positive. */ *************** *** 73,81 **** } ! void tcAirObject::PrintToFile(tcFile& file) { tcPlatformObject::PrintToFile(file); } ! void tcAirObject::SaveToFile(tcFile& file) { tcPlatformObject::SaveToFile(file); file.Write(&maxPitch_rad,sizeof(maxPitch_rad)); --- 139,149 ---- } ! void tcAirObject::PrintToFile(tcFile& file) ! { tcPlatformObject::PrintToFile(file); } ! void tcAirObject::SaveToFile(tcFile& file) ! { tcPlatformObject::SaveToFile(file); file.Write(&maxPitch_rad,sizeof(maxPitch_rad)); *************** *** 83,87 **** } ! void tcAirObject::LoadFromFile(tcFile& file) { tcPlatformObject::LoadFromFile(file); file.Read(&maxPitch_rad,sizeof(maxPitch_rad)); --- 151,156 ---- } ! void tcAirObject::LoadFromFile(tcFile& file) ! { tcPlatformObject::LoadFromFile(file); file.Read(&maxPitch_rad,sizeof(maxPitch_rad)); *************** *** 89,93 **** } ! void tcAirObject::Serialize(tcFile& file, bool mbLoad) { if (mbLoad) { LoadFromFile(file); --- 158,163 ---- } ! void tcAirObject::Serialize(tcFile& file, bool mbLoad) ! { if (mbLoad) { LoadFromFile(file); *************** *** 98,102 **** } ! void tcAirObject::ApplyRestrictions() { // check for crash if ((mcKin.mfAlt_m <= 0)||(mcTerrain.mfHeight_m >= mcKin.mfAlt_m)) { --- 168,173 ---- } ! void tcAirObject::ApplyRestrictions() ! { // check for crash if ((mcKin.mfAlt_m <= 0)||(mcTerrain.mfHeight_m >= mcKin.mfAlt_m)) { *************** *** 163,167 **** } ! void tcAirObject::UpdateHeading(float dt_s) { float heading_start,heading_end,dh; float roll_start; --- 234,239 ---- } ! void tcAirObject::UpdateHeading(float dt_s) ! { float heading_start,heading_end,dh; float roll_start; *************** *** 224,228 **** } ! void tcAirObject::Update(double afStatusTime) { const float min_update_s = 0.0f; float dt_s = (float)(afStatusTime - mfStatusTime); --- 296,301 ---- } ! void tcAirObject::Update(double afStatusTime) ! { const float min_update_s = 0.0f; float dt_s = (float)(afStatusTime - mfStatusTime); *************** *** 255,258 **** --- 328,332 ---- tcAirObject::tcAirObject(void) + : newCommand(false), commandStatus(0) { mnModelType = MTYPE_FIXEDWING; *************** *** 268,278 **** */ tcAirObject::tcAirObject(tcGenericDBObject *obj) ! : tcPlatformObject(obj) { mpDBObject = obj; mnModelType = MTYPE_FIXEDWING; - SetAltitude(2000.0f); - SetHeading(75.0f); - SetSpeed(300.0f); readyForLanding = 0; maxPitch_rad = MAX_PITCH_RAD; --- 342,349 ---- */ tcAirObject::tcAirObject(tcGenericDBObject *obj) ! : tcPlatformObject(obj), newCommand(false), commandStatus(0) { mpDBObject = obj; mnModelType = MTYPE_FIXEDWING; readyForLanding = 0; maxPitch_rad = MAX_PITCH_RAD; Index: tcSurfaceObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSurfaceObject.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tcSurfaceObject.cpp 13 Feb 2004 01:31:33 -0000 1.8 --- tcSurfaceObject.cpp 1 May 2004 21:49:06 -0000 1.9 *************** *** 131,137 **** mcKin.mfSpeed_kts = mpDBObject->mfMaxSpeed_kts; mfDamageLevel = 0; ! mcGS.SetHeading(mcKin.mfHeading_rad); ! mcGS.SetSpeed(mcKin.mfSpeed_kts); ! mcGS.SetAltitude(mcKin.mfAlt_m); } --- 131,137 ---- mcKin.mfSpeed_kts = mpDBObject->mfMaxSpeed_kts; mfDamageLevel = 0; ! SetHeading(mcKin.mfHeading_rad); ! SetSpeed(mcKin.mfSpeed_kts); ! SetAltitude(mcKin.mfAlt_m); } Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** tcPlatformObject.cpp 29 Apr 2004 00:08:56 -0000 1.21 --- tcPlatformObject.cpp 1 May 2004 21:49:06 -0000 1.22 *************** *** 32,35 **** --- 32,36 ---- #include "tc3DModel.h" #include "common/tcStream.h" + #include "common/tcObjStream.h" using namespace AI; *************** *** 289,295 **** } /******************************************************************************/ ! void tcPlatformObject::Clear(void) { tcGameObject::Clear(); msFormationParameters.mbFormation = false; msFormationParameters.mnFormationLeader = NULL_INDEX; --- 290,297 ---- } /******************************************************************************/ ! void tcPlatformObject::Clear() { tcGameObject::Clear(); + msFormationParameters.mbFormation = false; msFormationParameters.mnFormationLeader = NULL_INDEX; *************** *** 299,302 **** --- 301,307 ---- fuel_kg = 0; lastHeadingDelta = 0; + + newCommand = false; + commandStatus = 0; } *************** *** 339,346 **** void tcPlatformObject::SetAltitude(float new_altitude_m) { - if ((clientMode) && (commandStatus & ALT_CMD)) return; - mcGS.SetAltitude(new_altitude_m); ! commandStatus |= (ALT_CMD | NEW_CMD); } --- 344,350 ---- void tcPlatformObject::SetAltitude(float new_altitude_m) { mcGS.SetAltitude(new_altitude_m); ! commandStatus |= ALT_CMD; ! newCommand = true; } *************** *** 350,357 **** void tcPlatformObject::SetHeading(float afNewHeading) { - if ((clientMode) && (commandStatus & HEADING_CMD)) return; - mcGS.SetHeading(afNewHeading); ! commandStatus |= (HEADING_CMD | NEW_CMD); } --- 354,360 ---- void tcPlatformObject::SetHeading(float afNewHeading) { mcGS.SetHeading(afNewHeading); ! commandStatus |= HEADING_CMD; ! newCommand = true; } *************** *** 363,370 **** void tcPlatformObject::SetSpeed(float afNewSpeed) { - if ((clientMode) && (commandStatus & SPEED_CMD)) return; - mcGS.SetSpeed(afNewSpeed); ! commandStatus |= (SPEED_CMD | NEW_CMD); } --- 366,372 ---- void tcPlatformObject::SetSpeed(float afNewSpeed) { mcGS.SetSpeed(afNewSpeed); ! commandStatus |= SPEED_CMD; ! newCommand = true; } *************** *** 390,394 **** /******************************************************************************/ ! void tcPlatformObject::RandInitNear(float afLon_deg, float afLat_deg) { // tcGameObject::RandInitNear(afLon,afLat); if (mpDBObject == NULL) {return;} --- 392,397 ---- /******************************************************************************/ ! void tcPlatformObject::RandInitNear(float afLon_deg, float afLat_deg) ! { // tcGameObject::RandInitNear(afLon,afLat); if (mpDBObject == NULL) {return;} *************** *** 406,412 **** mcKin.mfRoll_rad = 0; mfDamageLevel = 0; ! mcGS.SetHeading(mcKin.mfHeading_rad); ! mcGS.SetSpeed(mcKin.mfSpeed_kts); ! mcGS.SetAltitude(mcKin.mfAlt_m); fuel_kg = mpDBObject->mfFuelCapacity_kg; lastHeadingDelta = 0; --- 409,415 ---- mcKin.mfRoll_rad = 0; mfDamageLevel = 0; ! SetHeading(mcKin.mfHeading_rad); ! SetSpeed(mcKin.mfSpeed_kts); ! SetAltitude(mcKin.mfAlt_m); fuel_kg = mpDBObject->mfFuelCapacity_kg; lastHeadingDelta = 0; *************** *** 500,524 **** * a successful acknowledge of the command. */ ! void tcPlatformObject::LoadCommandParam(tcStream& stream, float& param, int flag) { ! if (commandStatus & flag) { ! float temp; ! stream >> temp; ! if (temp == param) { ! commandStatus &= (~flag); // clear flag, successful ack } } ! else { ! stream >> param; } } /** ! * Loads state from stream */ ! tcStream& tcPlatformObject::operator<<(tcStream& stream) { tcGameObject::operator<<(stream); --- 503,567 ---- * a successful acknowledge of the command. */ ! void tcPlatformObject::LoadCommandParam(tcCommandStream& stream, float& param, int& cmdStatus, int flag) { ! float temp; ! stream >> temp; // read into temporary variable ! ! if (stream.GetAck()) { ! if ((cmdStatus & flag) && (temp == param)) { ! cmdStatus &= (~flag); // clear flag, successful ack } } ! else // not an ack { ! if (clientMode && (cmdStatus & flag)) ! { ! // ignore update ! } ! else ! { ! param = temp; // apply update ! cmdStatus &= (~flag); // clear flag ! } ! } } /** ! * version that takes int param */ ! void tcPlatformObject::LoadCommandParam(tcCommandStream& stream, int& param, int& cmdStatus, int flag) ! { ! int temp; ! stream >> temp; // read into temporary variable ! ! if (stream.GetAck()) ! { ! if ((cmdStatus & flag) && (temp == param)) ! { ! cmdStatus &= (~flag); // clear flag, successful ack ! } ! } ! else // not an ack ! { ! if (clientMode && (cmdStatus & flag)) ! { ! // ignore update ! } ! else ! { ! param = temp; // apply update ! cmdStatus &= (~flag); // clear flag ! } ! ! } ! } ! ! /** ! * Loads state from command stream ! */ ! tcCommandStream& tcPlatformObject::operator<<(tcCommandStream& stream) { tcGameObject::operator<<(stream); *************** *** 529,535 **** if (updateMask & UPDATE_GUIDANCE) { ! LoadCommandParam(stream, mcGS.mfGoalHeading_deg, HEADING_CMD); ! LoadCommandParam(stream, mcGS.mfGoalSpeed_kts, SPEED_CMD); ! LoadCommandParam(stream, mcGS.mfGoalAltitude_m, ALT_CMD); stream >> mcGS.mbIntercept; --- 572,578 ---- if (updateMask & UPDATE_GUIDANCE) { ! LoadCommandParam(stream, mcGS.mfGoalHeading_deg, commandStatus, HEADING_CMD); ! LoadCommandParam(stream, mcGS.mfGoalSpeed_kts, commandStatus, SPEED_CMD); ! LoadCommandParam(stream, mcGS.mfGoalAltitude_m, commandStatus, ALT_CMD); stream >> mcGS.mbIntercept; *************** *** 544,558 **** /** ! * Saves state to stream */ ! tcStream& tcPlatformObject::operator>>(tcStream& stream) { tcGameObject::operator>>(stream); unsigned char updateMask = 0; ! if (commandStatus & NEW_CMD) ! { ! updateMask = UPDATE_GUIDANCE; ! } stream << updateMask; --- 587,600 ---- /** ! * Saves state to command stream */ ! tcCommandStream& tcPlatformObject::operator>>(tcCommandStream& stream) { tcGameObject::operator>>(stream); unsigned char updateMask = 0; ! ! updateMask = UPDATE_GUIDANCE; ! stream << updateMask; *************** *** 570,576 **** --- 612,677 ---- } + + return stream; + } + + /** + * Loads state from create stream + */ + tcCreateStream& tcPlatformObject::operator<<(tcCreateStream& stream) + { + tcGameObject::operator<<(stream); + + return stream; + } + + /** + * Saves state to create stream + */ + tcCreateStream& tcPlatformObject::operator>>(tcCreateStream& stream) + { + tcGameObject::operator>>(stream); + return stream; } + + /** + * Loads state from update stream + */ + tcUpdateStream& tcPlatformObject::operator<<(tcUpdateStream& stream) + { + tcGameObject::operator<<(stream); + + return stream; + } + + /** + * Saves state to update stream + */ + tcUpdateStream& tcPlatformObject::operator>>(tcUpdateStream& stream) + { + tcGameObject::operator>>(stream); + + return stream; + } + + void tcPlatformObject::ClearNewCommand() + { + newCommand = false; + } + + bool tcPlatformObject::HasNewCommand() const + { + return newCommand; + } + + bool tcPlatformObject::HasUnacknowledgedCommand() const + { + return (commandStatus != 0); + } + + + /******************************************************************************/ tcPlatformObject::tcPlatformObject() *************** *** 619,623 **** tcPlatformObject::tcPlatformObject(tcGenericDBObject *obj) ! : tcGameObject(obj) { using namespace Database; --- 720,724 ---- tcPlatformObject::tcPlatformObject(tcGenericDBObject *obj) ! : tcGameObject(obj), newCommand(false), commandStatus(0) { using namespace Database; *************** *** 701,704 **** --- 802,808 ---- msTargetDatum = o.msTargetDatum; + newCommand = o.newCommand; + commandStatus = o.commandStatus; + // copy sensor state array mapSensorState.clear(); Index: tcGameObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcGameObject.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcGameObject.cpp 27 Apr 2004 01:24:25 -0000 1.14 --- tcGameObject.cpp 1 May 2004 21:49:06 -0000 1.15 *************** *** 30,33 **** --- 30,34 ---- #include "tcSimState.h" #include "common/tcStream.h" + #include "common/tcObjStream.h" *************** *** 267,291 **** /** ! * Loads state from stream */ ! tcStream& tcGameObject::operator<<(tcStream& stream) { ! rel_pos << stream; stream >> mnModelType; ! stream >> mnID; mzClass << stream; ! stream >> mnDBKey; mzUnit << stream; stream >> mnAlliance; - stream >> mfStatusTime; - - mcKin << stream; - - stream >> mfDamageLevel; return stream; --- 268,303 ---- /** ! * Loads state from command stream */ ! tcCommandStream& tcGameObject::operator<<(tcCommandStream& stream) { ! // no command updates for tcGameObject ! return stream; ! } ! ! /** ! * Saves state to command stream ! */ ! tcCommandStream& tcGameObject::operator>>(tcCommandStream& stream) ! { ! // no command updates for tcGameObject ! return stream; ! } + /** + * Loads state from create stream + */ + tcCreateStream& tcGameObject::operator<<(tcCreateStream& stream) + { stream >> mnModelType; ! stream >> mnID; // redundant, can remove later mzClass << stream; ! stream >> mnDBKey; // redundant, can remove later mzUnit << stream; stream >> mnAlliance; return stream; *************** *** 293,312 **** /** ! * Saves state to stream */ ! tcStream& tcGameObject::operator>>(tcStream& stream) { - rel_pos >> stream; - stream << mnModelType; ! stream << mnID; mzClass >> stream; ! stream << mnDBKey; mzUnit >> stream; stream << mnAlliance; stream << mfStatusTime; --- 305,359 ---- /** ! * Saves state to create stream */ ! tcCreateStream& tcGameObject::operator>>(tcCreateStream& stream) { stream << mnModelType; ! stream << mnID; // redundant, can remove later mzClass >> stream; ! stream << mnDBKey; // redundant, can remove later mzUnit >> stream; stream << mnAlliance; + + return stream; + } + + /** + * Loads state from update stream + */ + tcUpdateStream& tcGameObject::operator<<(tcUpdateStream& stream) + { + unsigned char hasParent; + stream >> hasParent; + if (hasParent) + { + rel_pos << stream; + } + + stream >> mfStatusTime; + + mcKin << stream; + + stream >> mfDamageLevel; + + return stream; + } + + /** + * Saves state to update stream + */ + tcUpdateStream& tcGameObject::operator>>(tcUpdateStream& stream) + { + unsigned char hasParent = (parent != 0); + stream << hasParent; + if (hasParent) + { + rel_pos >> stream; + } + stream << mfStatusTime; *************** *** 318,321 **** --- 365,382 ---- } + void tcGameObject::ClearNewCommand() + { + } + + bool tcGameObject::HasNewCommand() const + { + return false; + } + + bool tcGameObject::HasUnacknowledgedCommand() const + { + return false; + } + /** Index: tcMissileObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcMissileObject.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcMissileObject.cpp 27 Apr 2004 01:24:25 -0000 1.10 --- tcMissileObject.cpp 1 May 2004 21:49:06 -0000 1.11 *************** *** 20,28 **** #include "tcMissileObject.h" #include "common/tcStream.h" /** ! * Load state from stream */ ! tcStream& tcMissileObject::operator<<(tcStream& stream) { tcWeaponObject::operator<<(stream); --- 20,29 ---- #include "tcMissileObject.h" #include "common/tcStream.h" + #include "common/tcObjStream.h" /** ! * Load state from update stream */ ! tcUpdateStream& tcMissileObject::operator<<(tcUpdateStream& stream) { tcWeaponObject::operator<<(stream); *************** *** 44,50 **** /** ! * Save state to stream */ ! tcStream& tcMissileObject::operator>>(tcStream& stream) { tcWeaponObject::operator>>(stream); --- 45,51 ---- /** ! * Save state to update stream */ ! tcUpdateStream& tcMissileObject::operator>>(tcUpdateStream& stream) { tcWeaponObject::operator>>(stream); |