Commit part 4 of patch #897 (send/recv structure demolished messages.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3159 4a71c877-e1ca-e34f-864e-861f7616d084
master
Freddie Witherden 2007-12-24 15:10:34 +00:00
parent ea9d378131
commit 7e9b108645
3 changed files with 27 additions and 21 deletions

View File

@ -729,7 +729,7 @@ BOOL recvMessage(void)
recvPing(&msg);
break;
case NET_DEMOLISH: // structure demolished.
recvDemolishFinished(&msg);
recvDemolishFinished();
break;
case NET_RESEARCH: // some research has been done.
recvResearch(&msg);

View File

@ -39,7 +39,7 @@ extern BOOL recvBuildFinished ();
//extern BOOL receiveWholeStructure (NETMSG *pMsg);
extern BOOL recvTemplate (NETMSG *pMsg);
extern BOOL recvDestroyFeature (NETMSG *pMsg);
extern BOOL recvDemolishFinished (NETMSG *pMsg);
extern BOOL recvDemolishFinished ();
extern BOOL recvPing (NETMSG *pMsg);
extern BOOL recvRequestDroid (NETMSG *pMsg);
extern BOOL recvTextMessage (NETMSG *pMsg);

View File

@ -275,43 +275,49 @@ BOOL recvBuildFinished()
// ////////////////////////////////////////////////////////////////////////////
// demolish message.
BOOL SendDemolishFinished( STRUCTURE *psStruct,DROID *psDroid)
BOOL SendDemolishFinished(STRUCTURE *psStruct, DROID *psDroid)
{
NETMSG m;
DBCONPRINTF(ConsoleString,(ConsoleString,"SendDemolishFinished() called"));
NETbeginEncode(NET_DEMOLISH, NET_ALL_PLAYERS);
// Send what is being demolish and who is doing it
NETuint32_t(&psStruct->id);
NETuint32_t(&psDroid->id);
NetAdd(m,0,psStruct->id);
NetAdd(m,4,psDroid->id);
m.size = 2*sizeof(UDWORD);
m.type = NET_DEMOLISH;
return( NETbcast(&m,FALSE));
return NETend();
}
BOOL recvDemolishFinished(NETMSG *m)
BOOL recvDemolishFinished()
{
STRUCTURE *psStruct;
UDWORD s,d;
DROID *psDroid;
uint32_t structID,droidID;
NetGet(m,0,s);
NetGet(m,4,d);
DBCONPRINTF(ConsoleString,(ConsoleString,"recvDemolishFinished() called"));
NETbeginDecode();
psStruct = IdToStruct(s,ANYPLAYER);
IdToDroid(d,ANYPLAYER,&psDroid);
NETuint32_t(&structID);
NETuint32_t(&droidID);
if(psStruct)
psStruct = IdToStruct(structID, ANYPLAYER);
IdToDroid(droidID, ANYPLAYER, &psDroid);
if (psStruct)
{
removeStruct( psStruct, TRUE ); // demolish it.
if(psDroid && psDroid->psTarStats)
// Demolish it
removeStruct(psStruct, TRUE);
if (psDroid && psDroid->psTarStats)
{
psDroid->psTarStats = NULL; // update droid if reqd.
// Update droid if reqd
psDroid->psTarStats = NULL;
}
}
NETend();
return TRUE;
}
// ////////////////////////////////////////////////////////////////////////////
// Inform others that a structure has been destroyed
BOOL SendDestroyStructure(const STRUCTURE* s)