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

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3240 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-12-30 17:08:13 +00:00
parent 8e1536d867
commit 204611ba6b
4 changed files with 32 additions and 25 deletions

View File

@ -118,38 +118,46 @@ BOOL recvHappyVtol(NETMSG *pMsg)
// Secondary Orders. // Secondary Orders.
// Send // Send
BOOL sendDroidSecondary(DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE state) BOOL sendDroidSecondary(const DROID* psDroid, SECONDARY_ORDER sec, SECONDARY_STATE state)
{ {
NETMSG m; NETbeginEncode(NET_SECONDARY, NET_ALL_PLAYERS);
{
uint8_t player = psDroid->player;
uint32_t droid = psDroid->id;
NetAdd(m,0,psDroid->id); NETuint8_t(&player);
NetAdd(m,4,sec); NETuint32_t(&droid);
NetAdd(m,8,state); NETenum(&sec);
m.body[12] = (char) psDroid->player; NETenum(&state);
}
m.size = 13; return NETend();
m.type = NET_SECONDARY;
return NETbcast(&m,FALSE);
} }
// recv // recv
BOOL recvDroidSecondary(NETMSG *pMsg) BOOL recvDroidSecondary()
{ {
DROID* psDroid; DROID* psDroid;
SECONDARY_ORDER sec; SECONDARY_ORDER sec;
SECONDARY_STATE state; SECONDARY_STATE state;
UDWORD id,player;
NetGet(pMsg,0,id); NETbeginDecode();
NetGet(pMsg,4,sec); {
NetGet(pMsg,8,state); uint8_t player;
player = pMsg->body[12]; uint32_t droid;
NETuint8_t(&player);
NETuint32_t(&droid);
NETenum(&sec);
NETenum(&state);
// If we can not find the droid should we not ask for it? // If we can not find the droid should we not ask for it?
if(!IdToDroid(id,player,&psDroid)) //find droid. if (!IdToDroid(droid, player, &psDroid))
{ {
NETend();
return FALSE; return FALSE;
} }
}
NETend();
// Set the droids secondary order // Set the droids secondary order
turnOffMultiMsg(TRUE); turnOffMultiMsg(TRUE);
@ -159,7 +167,6 @@ BOOL recvDroidSecondary(NETMSG *pMsg)
return TRUE; return TRUE;
} }
BOOL sendDroidSecondaryAll(DROID *psDroid) BOOL sendDroidSecondaryAll(DROID *psDroid)
{ {
NETMSG m; NETMSG m;

View File

@ -679,7 +679,7 @@ BOOL recvMessage(void)
recvDestroyStructure(); recvDestroyStructure();
break; break;
case NET_SECONDARY: // set a droids secondary order level. case NET_SECONDARY: // set a droids secondary order level.
recvDroidSecondary(&msg); recvDroidSecondary();
break; break;
case NET_SECONDARY_ALL: // set a droids secondary order level. case NET_SECONDARY_ALL: // set a droids secondary order level.
recvDroidSecondaryAll(&msg); recvDroidSecondaryAll(&msg);

View File

@ -252,7 +252,7 @@ extern BOOL SendCmdGroup (DROID_GROUP *psGroup, UWORD x, UWORD y, BASE_OBJECT *
extern BOOL SendGroupOrderGroup(DROID_GROUP *psGroup, DROID_ORDER order,UDWORD x,UDWORD y,BASE_OBJECT *psObj); extern BOOL SendGroupOrderGroup(DROID_GROUP *psGroup, DROID_ORDER order,UDWORD x,UDWORD y,BASE_OBJECT *psObj);
extern BOOL sendDroidSecondary (DROID *psDroid, SECONDARY_ORDER sec, SECONDARY_STATE state); extern BOOL sendDroidSecondary (const DROID* psDroid, SECONDARY_ORDER sec, SECONDARY_STATE state);
extern BOOL sendDroidSecondaryAll(DROID *psDroid); extern BOOL sendDroidSecondaryAll(DROID *psDroid);
extern BOOL sendDroidEmbark (const DROID* psDroid); extern BOOL sendDroidEmbark (const DROID* psDroid);
extern BOOL sendDroidDisEmbark (const DROID* psDroid); extern BOOL sendDroidDisEmbark (const DROID* psDroid);

View File

@ -43,7 +43,7 @@ extern BOOL recvDemolishFinished ();
extern BOOL recvPing (); extern BOOL recvPing ();
extern BOOL recvRequestDroid (NETMSG *pMsg); extern BOOL recvRequestDroid (NETMSG *pMsg);
extern BOOL recvTextMessage (NETMSG *pMsg); extern BOOL recvTextMessage (NETMSG *pMsg);
extern BOOL recvDroidSecondary (NETMSG *pMsg); extern BOOL recvDroidSecondary (void);
extern BOOL recvDroidSecondaryAll (NETMSG *pMsg); extern BOOL recvDroidSecondaryAll (NETMSG *pMsg);
extern BOOL recvDroidEmbark (void); extern BOOL recvDroidEmbark (void);
extern BOOL recvDroidDisEmbark (void); extern BOOL recvDroidDisEmbark (void);