* Move the send/recv-RequestDroid functions over to the new net primitives API (patch #905 by myself)

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3244 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-12-30 17:14:52 +00:00
parent 05d14b995a
commit b5e426a66b
3 changed files with 23 additions and 21 deletions

View File

@ -1100,46 +1100,48 @@ BOOL receiveWholeDroid(NETMSG *m)
// find out about it.
BOOL sendRequestDroid(uint32_t droidId)
{
NETMSG msg;
if (ingame.localJoiningInProgress) // Don't worry if still joining.
{
return FALSE;
}
NetAdd(msg,0,droidId);
NetAdd(msg,4,player2dpid[selectedPlayer] );
debug(LOG_NEVER, "multibot: unknown droid %u, requesting info", droidId);
debug( LOG_NEVER, "multibot: unknown droid %d, requesting info\n", droidId );
NETbeginEncode(NET_REQUESTDROID, NET_ALL_PLAYERS);
{
int32_t dpid = player2dpid[selectedPlayer];
msg.type = NET_REQUESTDROID;
msg.size = sizeof(UDWORD)+sizeof(UDWORD); // DPID + UDWORD
NETbcast(&msg,FALSE);
return TRUE;
NETuint32_t(&droidId);
NETint32_t(&dpid);
}
return NETend();
}
// ////////////////////////////////////////////////////////////////////////////
BOOL recvRequestDroid(NETMSG *pMsg)
BOOL recvRequestDroid()
{
DROID *pDroid;
UDWORD droidid,dpid;
NetGet(pMsg,0,droidid); // get the droid's id
NetGet(pMsg,4,dpid); // get the player who needs it.
DROID* psDroid;
uint32_t droidId;
int32_t dpid;
NETbeginDecode();
{
NETuint32_t(&droidId);
NETint32_t(&dpid);
}
NETend();
// Get the droid
if (!(IdToDroid(droidid, ANYPLAYER, &pDroid)))
if (!(IdToDroid(droidId, ANYPLAYER, &psDroid)))
{
// Can't find it, so ignore
return TRUE;
}
// If we are responsible, send it
if (myResponsibility(pDroid->player))
if (myResponsibility(psDroid->player))
{
sendWholeDroid(pDroid,dpid);
sendWholeDroid(psDroid, dpid);
}
return TRUE;

View File

@ -691,7 +691,7 @@ BOOL recvMessage(void)
recvDroidDisEmbark(); //droid has disembarked from a Transporter
break;
case NET_REQUESTDROID: // player requires a droid that they dont have.
recvRequestDroid(&msg);
recvRequestDroid();
break;
// case NET_REQUESTPLAYER: // a new player requires information
// multiPlayerRequest(&msg);

View File

@ -41,7 +41,7 @@ extern BOOL recvTemplate (NETMSG *pMsg);
extern BOOL recvDestroyFeature (NETMSG *pMsg);
extern BOOL recvDemolishFinished ();
extern BOOL recvPing ();
extern BOOL recvRequestDroid (NETMSG *pMsg);
extern BOOL recvRequestDroid (void);
extern BOOL recvTextMessage (NETMSG *pMsg);
extern BOOL recvDroidSecondary (void);
extern BOOL recvDroidSecondaryAll (void);