Fix bug in the sending of research gifts. We cannot delay the NETend() call for long,

because other codes like to use the netcode, too.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3786 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2008-02-15 20:25:31 +00:00
parent 22844d16a6
commit f3fd0e6fe4
1 changed files with 42 additions and 40 deletions

View File

@ -55,7 +55,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// prototypes // prototypes
static void recvGiftDroids (uint8_t from, uint8_t to); static void recvGiftDroids (uint8_t from, uint8_t to, uint32_t droidID);
static void sendGiftDroids (uint8_t from, uint8_t to); static void sendGiftDroids (uint8_t from, uint8_t to);
static void giftResearch (uint8_t from, uint8_t to, BOOL send); static void giftResearch (uint8_t from, uint8_t to, BOOL send);
@ -66,11 +66,14 @@ BOOL recvGift(void)
{ {
uint8_t type, from, to; uint8_t type, from, to;
int audioTrack; int audioTrack;
uint32_t droidID;
NETbeginDecode(NET_GIFT); NETbeginDecode(NET_GIFT);
NETuint8_t(&type); NETuint8_t(&type);
NETuint8_t(&from); NETuint8_t(&from);
NETuint8_t(&to); NETuint8_t(&to);
NETuint32_t(&droidID);
NETend();
// Handle the gift depending on what it is // Handle the gift depending on what it is
switch (type) switch (type)
@ -78,25 +81,21 @@ BOOL recvGift(void)
case RADAR_GIFT: case RADAR_GIFT:
audioTrack = ID_SENSOR_DOWNLOAD; audioTrack = ID_SENSOR_DOWNLOAD;
giftRadar(from, to, FALSE); giftRadar(from, to, FALSE);
NETend();
break; break;
case DROID_GIFT: // do NOT do NETend() for this one it is handled differently. case DROID_GIFT:
audioTrack = ID_UNITS_TRANSFER; audioTrack = ID_UNITS_TRANSFER;
recvGiftDroids(from, to); recvGiftDroids(from, to, droidID);
break; break;
case RESEARCH_GIFT: case RESEARCH_GIFT:
audioTrack = ID_TECHNOLOGY_TRANSFER; audioTrack = ID_TECHNOLOGY_TRANSFER;
giftResearch(from, to, FALSE); giftResearch(from, to, FALSE);
NETend();
break; break;
case POWER_GIFT: case POWER_GIFT:
audioTrack = ID_POWER_TRANSMIT; audioTrack = ID_POWER_TRANSMIT;
giftPower(from, to, FALSE); giftPower(from, to, FALSE);
NETend();
break; break;
default: default:
debug(LOG_ERROR, "recvGift: Unknown Gift recvd"); debug(LOG_ERROR, "recvGift: Unknown Gift recvd");
NETend();
return FALSE; return FALSE;
break; break;
} }
@ -106,7 +105,6 @@ BOOL recvGift(void)
{ {
audio_QueueTrack(audioTrack); audio_QueueTrack(audioTrack);
} }
return TRUE; return TRUE;
} }
@ -149,6 +147,8 @@ BOOL sendGift(uint8_t type, uint8_t to)
// give radar information // give radar information
void giftRadar(uint8_t from, uint8_t to, BOOL send) void giftRadar(uint8_t from, uint8_t to, BOOL send)
{ {
uint32_t dummy = 0;
hqReward(from, to); hqReward(from, to);
if (send) if (send)
@ -159,6 +159,7 @@ void giftRadar(uint8_t from, uint8_t to, BOOL send)
NETuint8_t(&subType); NETuint8_t(&subType);
NETuint8_t(&from); NETuint8_t(&from);
NETuint8_t(&to); NETuint8_t(&to);
NETuint32_t(&dummy);
NETend(); NETend();
} }
// If we are recieving the gift // If we are recieving the gift
@ -175,13 +176,10 @@ void giftRadar(uint8_t from, uint8_t to, BOOL send)
// //
// \param from :player that sent us the droid // \param from :player that sent us the droid
// \param to :player that should be getting the droid // \param to :player that should be getting the droid
static void recvGiftDroids(uint8_t from, uint8_t to) static void recvGiftDroids(uint8_t from, uint8_t to, uint32_t droidID)
{ {
uint32_t droidID;
DROID *psDroid; DROID *psDroid;
NETuint32_t(&droidID);
NETend(); // the below call calls another net function.
if (IdToDroid(droidID, from, &psDroid)) if (IdToDroid(droidID, from, &psDroid))
{ {
giftSingleDroid(psDroid, to); giftSingleDroid(psDroid, to);
@ -266,6 +264,7 @@ static void giftResearch(uint8_t from, uint8_t to, BOOL send)
{ {
PLAYER_RESEARCH *pR, *pRto; PLAYER_RESEARCH *pR, *pRto;
int i; int i;
uint32_t dummy = 0;
pR = asPlayerResList[from]; pR = asPlayerResList[from];
pRto = asPlayerResList[to]; pRto = asPlayerResList[to];
@ -290,6 +289,7 @@ static void giftResearch(uint8_t from, uint8_t to, BOOL send)
NETuint8_t(&giftType); NETuint8_t(&giftType);
NETuint8_t(&from); NETuint8_t(&from);
NETuint8_t(&to); NETuint8_t(&to);
NETuint32_t(&dummy);
NETend(); NETend();
} }
else if (to == selectedPlayer) else if (to == selectedPlayer)
@ -304,6 +304,7 @@ static void giftResearch(uint8_t from, uint8_t to, BOOL send)
void giftPower(uint8_t from, uint8_t to, BOOL send) void giftPower(uint8_t from, uint8_t to, BOOL send)
{ {
UDWORD gifval; UDWORD gifval;
uint32_t dummy = 0;
if (from == ANYPLAYER) if (from == ANYPLAYER)
{ {
@ -326,6 +327,7 @@ void giftPower(uint8_t from, uint8_t to, BOOL send)
NETuint8_t(&giftType); NETuint8_t(&giftType);
NETuint8_t(&from); NETuint8_t(&from);
NETuint8_t(&to); NETuint8_t(&to);
NETuint32_t(&dummy);
NETend(); NETend();
} }
else if (to == selectedPlayer) else if (to == selectedPlayer)