* Add some Doxygen comments
* Improve some comments * Separate parameters with both a comma and a space, i.e.: ", " * Make ForceDroidSync take its psDroid parameter const * Add some whitespace to enhance readability (as readability is a very important part of maintainability) git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5862 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
f957004f2c
commit
50519cff38
|
@ -219,8 +219,12 @@ BOOL recvDroidSecondaryAll()
|
|||
|
||||
return true;
|
||||
}
|
||||
// broadcast droid & transporter loading information
|
||||
BOOL sendDroidEmbark(const DROID* psDroid,const DROID* psTransporter )
|
||||
|
||||
/** Broadcast droid and transporter loading information
|
||||
*
|
||||
* \sa recvDroidEmbark(),sendDroidDisEmbark(),recvDroidDisEmbark()
|
||||
*/
|
||||
BOOL sendDroidEmbark(const DROID* psDroid, const DROID* psTransporter)
|
||||
{
|
||||
if (!bMultiPlayer)
|
||||
return true;
|
||||
|
@ -237,11 +241,15 @@ BOOL sendDroidEmbark(const DROID* psDroid,const DROID* psTransporter )
|
|||
}
|
||||
return NETend();
|
||||
}
|
||||
// receive droid & transporter loading information
|
||||
|
||||
/** Receive droid and transporter loading information
|
||||
*
|
||||
* \sa sendDroidEmbark(),sendDroidDisEmbark(),recvDroidDisEmbark()
|
||||
*/
|
||||
BOOL recvDroidEmbark()
|
||||
{
|
||||
DROID *psDroid;
|
||||
DROID *psTransporterDroid;
|
||||
DROID* psDroid;
|
||||
DROID* psTransporterDroid;
|
||||
BOOL bDroidRemoved;
|
||||
|
||||
NETbeginDecode(NET_DROIDEMBARK);
|
||||
|
@ -259,14 +267,14 @@ BOOL recvDroidEmbark()
|
|||
{
|
||||
NETend();
|
||||
// Possible it already died? (sync error?)
|
||||
debug(LOG_WARNING,"player's %d droid %d wasn't found?",player,droidID);
|
||||
debug(LOG_WARNING, "player's %d droid %d wasn't found?", player,droidID);
|
||||
return false;
|
||||
}
|
||||
if (!IdToDroid(transporterID, player, &psTransporterDroid))
|
||||
{
|
||||
NETend();
|
||||
// Possible it already died? (sync error?)
|
||||
debug(LOG_WARNING,"player's %d transport droid %d wasn't found?",player,transporterID);
|
||||
debug(LOG_WARNING, "player's %d transport droid %d wasn't found?", player,transporterID);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -292,13 +300,17 @@ BOOL recvDroidEmbark()
|
|||
else
|
||||
{
|
||||
// possible sync error?
|
||||
debug(LOG_WARNING,"Eh? Where did unit %d go? Couldn't load droid onto transporter.",droidID);
|
||||
debug(LOG_WARNING, "Eh? Where did unit %d go? Couldn't load droid onto transporter.", droidID);
|
||||
}
|
||||
}
|
||||
NETend();
|
||||
return true;
|
||||
}
|
||||
// sending information that droid is being unloaded from a transporter
|
||||
|
||||
/** Broadcast that droid is being unloaded from a transporter
|
||||
*
|
||||
* \sa sendDroidEmbark(),recvDroidEmbark(),recvDroidDisEmbark()
|
||||
*/
|
||||
BOOL sendDroidDisEmbark(const DROID* psDroid, const DROID* psTransporter)
|
||||
{
|
||||
if (!bMultiPlayer)
|
||||
|
@ -318,7 +330,11 @@ BOOL sendDroidDisEmbark(const DROID* psDroid, const DROID* psTransporter)
|
|||
}
|
||||
return NETend();
|
||||
}
|
||||
// getting informaton about droid is being unloaded from a transporter
|
||||
|
||||
/** Receive info about a droid that is being unloaded from a transporter
|
||||
*
|
||||
* \sa sendDroidEmbark(),recvDroidEmbark(),sendDroidDisEmbark()
|
||||
*/
|
||||
BOOL recvDroidDisEmbark()
|
||||
{
|
||||
DROID *psFoundDroid = NULL, *psTransporterDroid = NULL;
|
||||
|
@ -342,7 +358,7 @@ BOOL recvDroidDisEmbark()
|
|||
if (!IdToDroid(transporterID, player, &psTransporterDroid))
|
||||
{
|
||||
// Possible it already died? (sync error?)
|
||||
debug(LOG_WARNING,"player's %d transport droid %d wasn't found?",player,transporterID);
|
||||
debug(LOG_WARNING, "player's %d transport droid %d wasn't found?", player, transporterID);
|
||||
return false;
|
||||
}
|
||||
// we need to find the droid *in* the transporter
|
||||
|
@ -362,7 +378,7 @@ BOOL recvDroidDisEmbark()
|
|||
if (!psFoundDroid)
|
||||
{
|
||||
// I don't think this could ever be possible...but
|
||||
debug(LOG_ERROR,"Couldn't find droid %d to disembark from player %d's transporter?",droidID,player);
|
||||
debug(LOG_ERROR, "Couldn't find droid %d to disembark from player %d's transporter?", droidID, player);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -377,7 +393,7 @@ BOOL recvDroidDisEmbark()
|
|||
|
||||
if (!droidOnMap(psFoundDroid))
|
||||
{
|
||||
debug(LOG_ERROR,"droid %d disembarked was NOT on map?",psFoundDroid->id);
|
||||
debug(LOG_ERROR, "droid %d disembarked was NOT on map?", psFoundDroid->id);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -387,7 +403,7 @@ BOOL recvDroidDisEmbark()
|
|||
initDroidMovement(psFoundDroid);
|
||||
// must add it to the grid for targeting to work
|
||||
gridAddObject((BASE_OBJECT *)psFoundDroid);
|
||||
} // NetBeginDecode
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,8 @@ extern BOOL addTemplate (UDWORD player,DROID_TEMPLATE *psNew);
|
|||
extern BOOL sendCheck (void); //send/recv check info
|
||||
extern BOOL sendScoreCheck (void); //score check only(frontend)
|
||||
extern BOOL sendPing (void); // allow game to request pings.
|
||||
extern BOOL ForceDroidSync( DROID* droidToSend ); // force a sync on a droid to happen
|
||||
|
||||
extern BOOL ForceDroidSync(const DROID* droidToSend);
|
||||
// multijoin
|
||||
extern void modifyResources (POWER_GEN_FUNCTION* psFunction);
|
||||
|
||||
|
|
|
@ -205,15 +205,19 @@ static DROID* pickADroid(void)
|
|||
|
||||
return pD;
|
||||
}
|
||||
// ///////////////////////////////////////////////////////////////////////////
|
||||
// force a droid sync
|
||||
// We need to update the droid in question ASAP, to prevent 'lost' droids until
|
||||
// the next 'real' update is done.
|
||||
BOOL ForceDroidSync( DROID* droidToSend )
|
||||
|
||||
/** Force a droid to be synced
|
||||
*
|
||||
* Call this when you need to update the given droid right now.
|
||||
*/
|
||||
BOOL ForceDroidSync(const DROID* droidToSend)
|
||||
{
|
||||
uint8_t count = 1; // *always* one
|
||||
if(!droidToSend) return false;
|
||||
debug(LOG_SYNC,"Force sync of droid %d from player %d",droidToSend->id,droidToSend->player);
|
||||
|
||||
ASSERT(droidToSend != NULL, "NULL pointer passed");
|
||||
|
||||
debug(LOG_SYNC, "Force sync of droid %d from player %d", droidToSend->id, droidToSend->player);
|
||||
|
||||
NETbeginEncode(NET_CHECK_DROID, NET_ALL_PLAYERS);
|
||||
NETuint8_t(&count);
|
||||
packageCheck(droidToSend);
|
||||
|
|
|
@ -800,13 +800,18 @@ void orderUpdateDroid(DROID *psDroid)
|
|||
// save the target of current droid (the transporter)
|
||||
DROID * transporter = (DROID *)psDroid->psTarget;
|
||||
|
||||
// Make sure that it really is a valid droid
|
||||
CHECK_DROID(transporter);
|
||||
|
||||
// order the droid to stop so moveUpdateDroid does not process this unit
|
||||
orderDroid(psDroid, DORDER_STOP);
|
||||
setDroidTarget(psDroid, NULL);
|
||||
psDroid->psTarStats = NULL;
|
||||
secondarySetState(psDroid, DSO_RETURN_TO_LOC, DSS_NONE);
|
||||
// process orders *before* adding unit to transporter
|
||||
// since we remove it from the list!
|
||||
|
||||
/* We must add the droid to the transporter only *after*
|
||||
* processing changing its orders (see above).
|
||||
*/
|
||||
transporterAddDroid(transporter, psDroid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1404,8 +1404,8 @@ void transporterRemoveDroid(UDWORD id)
|
|||
psDroid->pos.x = (UWORD)world_coord(droidX);
|
||||
psDroid->pos.y = (UWORD)world_coord(droidY);
|
||||
psDroid->pos.z = map_Height(psDroid->pos.x, psDroid->pos.y);
|
||||
|
||||
}
|
||||
|
||||
// remove it from the transporter group
|
||||
grpLeave(psDroid->psGroup, psDroid);
|
||||
|
||||
|
@ -1419,12 +1419,14 @@ void transporterRemoveDroid(UDWORD id)
|
|||
{
|
||||
// add the droid back onto the droid list
|
||||
addDroid(psDroid, apsDroidLists);
|
||||
|
||||
//inform all other players about that
|
||||
if (bMultiPlayer)
|
||||
{
|
||||
sendDroidDisEmbark(psDroid,psCurrTransporter);
|
||||
}
|
||||
}
|
||||
|
||||
// We can update the orders now, since everyone has been
|
||||
// notified of the droid exiting the transporter
|
||||
updateDroidOrientation(psDroid);
|
||||
|
@ -1450,6 +1452,7 @@ void transporterRemoveDroid(UDWORD id)
|
|||
stopMissionButtonFlash(IDTRANS_LAUNCH);
|
||||
}
|
||||
}
|
||||
|
||||
// we want to sync with all clients *now*.
|
||||
ForceDroidSync(psDroid);
|
||||
}
|
||||
|
@ -1510,6 +1513,7 @@ void transporterAddDroid(DROID *psTransporter, DROID *psDroidToAdd)
|
|||
// removing from droid list
|
||||
bDroidRemoved = droidRemove(psDroidToAdd, apsDroidLists);
|
||||
}
|
||||
|
||||
if (bDroidRemoved)
|
||||
{
|
||||
// adding to transporter unit's group list
|
||||
|
|
Loading…
Reference in New Issue