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-861f7616d084master
parent
22844d16a6
commit
f3fd0e6fe4
|
@ -55,7 +55,7 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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 giftResearch (uint8_t from, uint8_t to, BOOL send);
|
||||
|
||||
|
@ -66,11 +66,14 @@ BOOL recvGift(void)
|
|||
{
|
||||
uint8_t type, from, to;
|
||||
int audioTrack;
|
||||
uint32_t droidID;
|
||||
|
||||
NETbeginDecode(NET_GIFT);
|
||||
NETuint8_t(&type);
|
||||
NETuint8_t(&from);
|
||||
NETuint8_t(&to);
|
||||
NETuint32_t(&droidID);
|
||||
NETend();
|
||||
|
||||
// Handle the gift depending on what it is
|
||||
switch (type)
|
||||
|
@ -78,25 +81,21 @@ BOOL recvGift(void)
|
|||
case RADAR_GIFT:
|
||||
audioTrack = ID_SENSOR_DOWNLOAD;
|
||||
giftRadar(from, to, FALSE);
|
||||
NETend();
|
||||
break;
|
||||
case DROID_GIFT: // do NOT do NETend() for this one it is handled differently.
|
||||
case DROID_GIFT:
|
||||
audioTrack = ID_UNITS_TRANSFER;
|
||||
recvGiftDroids(from, to);
|
||||
recvGiftDroids(from, to, droidID);
|
||||
break;
|
||||
case RESEARCH_GIFT:
|
||||
audioTrack = ID_TECHNOLOGY_TRANSFER;
|
||||
giftResearch(from, to, FALSE);
|
||||
NETend();
|
||||
break;
|
||||
case POWER_GIFT:
|
||||
audioTrack = ID_POWER_TRANSMIT;
|
||||
giftPower(from, to, FALSE);
|
||||
NETend();
|
||||
break;
|
||||
default:
|
||||
debug(LOG_ERROR, "recvGift: Unknown Gift recvd");
|
||||
NETend();
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
|
@ -106,7 +105,6 @@ BOOL recvGift(void)
|
|||
{
|
||||
audio_QueueTrack(audioTrack);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -149,6 +147,8 @@ BOOL sendGift(uint8_t type, uint8_t to)
|
|||
// give radar information
|
||||
void giftRadar(uint8_t from, uint8_t to, BOOL send)
|
||||
{
|
||||
uint32_t dummy = 0;
|
||||
|
||||
hqReward(from, to);
|
||||
|
||||
if (send)
|
||||
|
@ -159,6 +159,7 @@ void giftRadar(uint8_t from, uint8_t to, BOOL send)
|
|||
NETuint8_t(&subType);
|
||||
NETuint8_t(&from);
|
||||
NETuint8_t(&to);
|
||||
NETuint32_t(&dummy);
|
||||
NETend();
|
||||
}
|
||||
// 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 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;
|
||||
|
||||
NETuint32_t(&droidID);
|
||||
NETend(); // the below call calls another net function.
|
||||
if (IdToDroid(droidID, from, &psDroid))
|
||||
{
|
||||
giftSingleDroid(psDroid, to);
|
||||
|
@ -266,6 +264,7 @@ static void giftResearch(uint8_t from, uint8_t to, BOOL send)
|
|||
{
|
||||
PLAYER_RESEARCH *pR, *pRto;
|
||||
int i;
|
||||
uint32_t dummy = 0;
|
||||
|
||||
pR = asPlayerResList[from];
|
||||
pRto = asPlayerResList[to];
|
||||
|
@ -290,6 +289,7 @@ static void giftResearch(uint8_t from, uint8_t to, BOOL send)
|
|||
NETuint8_t(&giftType);
|
||||
NETuint8_t(&from);
|
||||
NETuint8_t(&to);
|
||||
NETuint32_t(&dummy);
|
||||
NETend();
|
||||
}
|
||||
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)
|
||||
{
|
||||
UDWORD gifval;
|
||||
uint32_t dummy = 0;
|
||||
|
||||
if (from == ANYPLAYER)
|
||||
{
|
||||
|
@ -326,6 +327,7 @@ void giftPower(uint8_t from, uint8_t to, BOOL send)
|
|||
NETuint8_t(&giftType);
|
||||
NETuint8_t(&from);
|
||||
NETuint8_t(&to);
|
||||
NETuint32_t(&dummy);
|
||||
NETend();
|
||||
}
|
||||
else if (to == selectedPlayer)
|
||||
|
|
Loading…
Reference in New Issue