Thread: [Gcblue-commits] gcb_wx/src/sim tcCarrierObject.cpp,1.9,1.10 tcFlightOpsObject.cpp,1.6,1.7 tcFlightP
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-04-06 02:19:59
|
Update of /cvsroot/gcblue/gcb_wx/src/sim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30667/src/sim Modified Files: tcCarrierObject.cpp tcFlightOpsObject.cpp tcFlightPort.cpp tcSimState.cpp Log Message: Added join game button for multiplayer, started carrier and airfield multiplayer support Index: tcSimState.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcSimState.cpp,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** tcSimState.cpp 29 Mar 2005 00:12:46 -0000 1.74 --- tcSimState.cpp 6 Apr 2005 02:19:50 -0000 1.75 *************** *** 2390,2395 **** dateZulu = tempDateZulu; } ! // if client more than 4 sec ahead, pause the client ! if (dt < -4) { timeAcceleration = 0; --- 2390,2395 ---- dateZulu = tempDateZulu; } ! // if client time is too much ahead, pause the client ! if (dt < -1) { timeAcceleration = 0; Index: tcFlightOpsObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcFlightOpsObject.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tcFlightOpsObject.cpp 6 Nov 2004 15:13:42 -0000 1.6 --- tcFlightOpsObject.cpp 6 Apr 2005 02:19:50 -0000 1.7 *************** *** 31,34 **** --- 31,36 ---- #include "tcFlightportDBObject.h" #include "tcDatabase.h" + #include "common/tcStream.h" + #include "common/tcObjStream.h" #ifdef _DEBUG *************** *** 39,82 **** Database::tcDatabase* tcFlightOpsObject::database = 0; /** ! * Determines if obj has landed on runway or crashed into flightport. ! * Calls tcFlightPort method. ! * If object successfully lands, it is added as a child. ! * @param obj Object to attempt landing ! * @return -1 if crash, 0 if not close enough for landing, 1 if landed ! * @see tcFlightPort::CheckLanding */ ! int tcFlightOpsObject::CheckLanding(tcGameObject *obj) { ! gameObj->GetRelPosOf(obj, obj->rel_pos); // set update rel_pos field of landing candidate ! int result = flight_deck.CheckLanding(obj); ! if (result == 1) ! { ! gameObj->AddChild(obj); ! } ! return result; } ! void tcFlightOpsObject::Clear() { ! flight_deck.Clear(); } /** ! * @return pointer to flight_deck */ ! tcFlightPort* tcFlightOpsObject::GetFlightPort() { ! return &flight_deck; } /** ! * @return track with landing point coord and heading with orientation */ ! tcTrack tcFlightOpsObject::GetLandingData() { ! return flight_deck.GetLandingData(gameObj); } /** * Supports aero air model and air generic models. Adding other --- 41,153 ---- Database::tcDatabase* tcFlightOpsObject::database = 0; + + + /** ! * Loads state from command stream */ ! tcCommandStream& tcFlightOpsObject::operator<<(tcCommandStream& stream) { ! ! return stream; } ! /** ! * Saves state to command stream ! */ ! tcCommandStream& tcFlightOpsObject::operator>>(tcCommandStream& stream) { ! ! return stream; } /** ! * Loads state from create stream */ ! tcCreateStream& tcFlightOpsObject::operator<<(tcCreateStream& stream) { ! ! ! return stream; } /** ! * Saves state to create stream */ ! tcCreateStream& tcFlightOpsObject::operator>>(tcCreateStream& stream) { ! unsigned short nChildren = flight_deck.GetCount(); ! ! stream << nChildren; ! ! for (unsigned short k=0; k < nChildren; k++) ! { ! tcAirState* airState = flight_deck.GetAirState(k); ! tcGameObject* obj = airState->obj; ! wxASSERT(obj); ! ! ! stream << obj->mnDBKey; ! ! std::string unitName = obj->mzUnit.mz; ! stream << unitName; ! ! unsigned char loc = unsigned char(airState->current_location); ! stream << loc; ! } ! ! ! return stream; } + + /** + * Loads state from update stream + */ + tcUpdateStream& tcFlightOpsObject::operator<<(tcUpdateStream& stream) + { + unsigned short nChildren; + stream >> nChildren; + + wxASSERT(flight_deck.GetCount() == 0); + + for (unsigned short k=0; k < nChildren; k++) + { + long key; + stream >> key; + + tcDatabaseObject* databaseObj = database->GetObject(key); + + std::string unitName; + stream >> unitName; + + unsigned char loc; + stream >> loc; + + AddChildToFlightDeck(databaseObj, unitName, teLocation(loc)); + } + + return stream; + } + + /** + * Saves state to update stream + */ + tcUpdateStream& tcFlightOpsObject::operator>>(tcUpdateStream& stream) + { + + + return stream; + } + + + bool tcFlightOpsObject::AddChildToFlightDeck(std::string className, std::string unitName, + teLocation loc) + { + return AddChildToFlightDeck(database->GetObject(className), unitName, loc); + } + + + /** * Supports aero air model and air generic models. Adding other *************** *** 84,99 **** * @return true if successful, false otherwise */ ! bool tcFlightOpsObject::AddChildToFlightDeck(std::string className, std::string unitName, teLocation loc) { ! tcGameObject *child = NULL; // object to add to flight_deck ! tcDatabaseObject *dbObj = database->GetObject(className); ! if (tcAirDBObject *airDBObj = dynamic_cast<tcAirDBObject*>(dbObj)) ! { child = new tcAeroAirObject(airDBObj); } ! else if (tcGenericDBObject *genericDBObj = dynamic_cast<tcGenericDBObject*>(dbObj)) { if (genericDBObj->mnModelType == MTYPE_FIXEDWING) --- 155,172 ---- * @return true if successful, false otherwise */ ! bool tcFlightOpsObject::AddChildToFlightDeck(tcDatabaseObject* databaseObject, std::string unitName, teLocation loc) { ! wxASSERT(databaseObject); ! tcGameObject *child = 0; // object to add to flight_deck ! ! std::string className = databaseObject->mzClass.mz; + if (tcAirDBObject *airDBObj = dynamic_cast<tcAirDBObject*>(databaseObject)) + { child = new tcAeroAirObject(airDBObj); } ! else if (tcGenericDBObject *genericDBObj = dynamic_cast<tcGenericDBObject*>(databaseObject)) { if (genericDBObj->mnModelType == MTYPE_FIXEDWING) *************** *** 128,131 **** --- 201,246 ---- } + + /** + * Determines if obj has landed on runway or crashed into flightport. + * Calls tcFlightPort method. + * If object successfully lands, it is added as a child. + * @param obj Object to attempt landing + * @return -1 if crash, 0 if not close enough for landing, 1 if landed + * @see tcFlightPort::CheckLanding + */ + int tcFlightOpsObject::CheckLanding(tcGameObject *obj) + { + gameObj->GetRelPosOf(obj, obj->rel_pos); // set update rel_pos field of landing candidate + int result = flight_deck.CheckLanding(obj); + if (result == 1) + { + gameObj->AddChild(obj); + } + return result; + } + + void tcFlightOpsObject::Clear() + { + flight_deck.Clear(); + } + + /** + * @return pointer to flight_deck + */ + tcFlightPort* tcFlightOpsObject::GetFlightPort() + { + return &flight_deck; + } + + /** + * @return track with landing point coord and heading with orientation + */ + tcTrack tcFlightOpsObject::GetLandingData() + { + return flight_deck.GetLandingData(gameObj); + } + + /** * Randomly initializes object Index: tcFlightPort.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcFlightPort.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcFlightPort.cpp 24 Feb 2005 22:19:16 -0000 1.14 --- tcFlightPort.cpp 6 Apr 2005 02:19:50 -0000 1.15 *************** *** 227,233 **** } //---------------------------------------------------------------------------- ! const tcAirState* tcFlightPort::GetAirState(unsigned n) { ! return NULL; } //---------------------------------------------------------------------------- --- 227,233 ---- } //---------------------------------------------------------------------------- ! tcAirState* tcFlightPort::GetAirState(unsigned n) { ! return units[n]; } //---------------------------------------------------------------------------- *************** *** 242,245 **** --- 242,255 ---- return -1; // not found } + + /** + * @returns game object for unit with index n + */ + tcGameObject* tcFlightPort::GetObject(unsigned n) + { + wxASSERT(n < units.size()); + + return units[n]->obj; + } //---------------------------------------------------------------------------- int tcFlightPort::Launch(int runway) Index: tcCarrierObject.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/sim/tcCarrierObject.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tcCarrierObject.cpp 2 Nov 2004 04:23:56 -0000 1.9 --- tcCarrierObject.cpp 6 Apr 2005 02:19:50 -0000 1.10 *************** *** 1,4 **** /* ! ** Copyright (C) 2003-2004 Dewitt Colclough (de...@tw...) ** All rights reserved. --- 1,4 ---- /* ! ** Copyright (C) 2003-2005 Dewitt Colclough (de...@tw...) ** All rights reserved. *************** *** 28,31 **** --- 28,33 ---- #include "tcAirDBObject.h" #include "tcFlightOpsObject.h" + #include "common/tcStream.h" + #include "common/tcObjStream.h" #ifdef _DEBUG *************** *** 34,37 **** --- 36,106 ---- + + /** + * Loads state from command stream + */ + tcCommandStream& tcCarrierObject::operator<<(tcCommandStream& stream) + { + tcPlatformObject::operator<<(stream); + + return stream; + } + + /** + * Saves state to command stream + */ + tcCommandStream& tcCarrierObject::operator>>(tcCommandStream& stream) + { + tcPlatformObject::operator>>(stream); + + return stream; + } + + /** + * Loads state from create stream + */ + tcCreateStream& tcCarrierObject::operator<<(tcCreateStream& stream) + { + tcPlatformObject::operator<<(stream); + + tcFlightOpsObject::operator<<(stream); + + return stream; + } + + /** + * Saves state to create stream + */ + tcCreateStream& tcCarrierObject::operator>>(tcCreateStream& stream) + { + tcPlatformObject::operator>>(stream); + + tcFlightOpsObject::operator>>(stream); + + return stream; + } + + + /** + * Loads state from update stream + */ + tcUpdateStream& tcCarrierObject::operator<<(tcUpdateStream& stream) + { + tcPlatformObject::operator<<(stream); + + return stream; + } + + /** + * Saves state to update stream + */ + tcUpdateStream& tcCarrierObject::operator>>(tcUpdateStream& stream) + { + tcPlatformObject::operator>>(stream); + + return stream; + } + + void tcCarrierObject::Clear() { |