[Gcblue-commits] gcb_wx/src/sim tcPlatformObject.cpp,1.20,1.21
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-04-29 00:09:09
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23476/src/sim Modified Files: tcPlatformObject.cpp Log Message: Index: tcPlatformObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcPlatformObject.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** tcPlatformObject.cpp 13 Apr 2004 21:37:41 -0000 1.20 --- tcPlatformObject.cpp 29 Apr 2004 00:08:56 -0000 1.21 *************** *** 335,338 **** --- 335,360 ---- /** + * Sets goal altitude in guidance + */ + void tcPlatformObject::SetAltitude(float new_altitude_m) + { + if ((clientMode) && (commandStatus & ALT_CMD)) return; + + mcGS.SetAltitude(new_altitude_m); + commandStatus |= (ALT_CMD | NEW_CMD); + } + + /** + * Sets goal heading in guidance + */ + void tcPlatformObject::SetHeading(float afNewHeading) + { + if ((clientMode) && (commandStatus & HEADING_CMD)) return; + + mcGS.SetHeading(afNewHeading); + commandStatus |= (HEADING_CMD | NEW_CMD); + } + + /** * Set goal speed to afNewSpeed. If goal speed * is greater than max speed then set goal to *************** *** 341,349 **** void tcPlatformObject::SetSpeed(float afNewSpeed) { ! if (afNewSpeed > mpDBObject->mfMaxSpeed_kts) ! { ! afNewSpeed = mpDBObject->mfMaxSpeed_kts; ! } mcGS.SetSpeed(afNewSpeed); } --- 363,370 ---- void tcPlatformObject::SetSpeed(float afNewSpeed) { ! if ((clientMode) && (commandStatus & SPEED_CMD)) return; ! mcGS.SetSpeed(afNewSpeed); + commandStatus |= (SPEED_CMD | NEW_CMD); } *************** *** 471,474 **** --- 492,520 ---- } + + /** + * Used with multiplayer client to load a parameter from the server that + * the client can command e.g. heading, speed, altitude. If a client command + * request is outstanding and the server update does not match, then the update + * is ignored. If the update matches, the command flag is cleared representing + * 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 *************** *** 478,482 **** tcGameObject::operator<<(stream); ! mcGS << stream; return stream; --- 524,542 ---- tcGameObject::operator<<(stream); ! unsigned char updateMask; ! stream >> updateMask; ! ! 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; ! if (mcGS.mbIntercept) ! { ! mcGS.mcKinIntercept << stream; ! } ! } return stream; *************** *** 490,494 **** tcGameObject::operator>>(stream); ! mcGS >> stream; return stream; --- 550,572 ---- tcGameObject::operator>>(stream); ! unsigned char updateMask = 0; ! if (commandStatus & NEW_CMD) ! { ! updateMask = UPDATE_GUIDANCE; ! } ! stream << updateMask; ! ! if (updateMask & UPDATE_GUIDANCE) ! { ! stream << mcGS.mfGoalHeading_deg; ! stream << mcGS.mfGoalSpeed_kts; ! stream << mcGS.mfGoalAltitude_m; ! ! stream << mcGS.mbIntercept; ! if (mcGS.mbIntercept) ! { ! mcGS.mcKinIntercept >> stream; ! } ! } return stream; |