Fix AI-designed template being sent as belonging to host.

This caused a desynch when using Semperfi AI.
master
Cyp 2011-01-18 13:16:41 +01:00
parent 826a0ef374
commit 4b26114644
4 changed files with 11 additions and 11 deletions

View File

@ -4616,7 +4616,7 @@ static BOOL saveTemplate(void)
psTempl->multiPlayerID = generateNewObjectId();
if (bMultiMessages)
{
sendTemplate(psTempl);
sendTemplate(selectedPlayer, psTempl);
}
}

View File

@ -1450,16 +1450,14 @@ BOOL recvTextMessageAI(NETQUEUE queue)
// Templates
// send a newly created template to other players
BOOL sendTemplate(DROID_TEMPLATE *pTempl)
bool sendTemplate(uint32_t player, DROID_TEMPLATE *pTempl)
{
int i;
uint8_t player = selectedPlayer;
ASSERT(pTempl != NULL, "sendTemplate: Old Pumpkin bug");
if (!pTempl) return true; /* hack */
ASSERT_OR_RETURN(true /* hack */, pTempl != NULL, "Old Pumpkin bug");
NETbeginEncode(NETgameQueue(selectedPlayer), GAME_TEMPLATE);
NETuint8_t(&player);
NETuint32_t(&player);
NETuint32_t(&pTempl->ref);
NETstring(pTempl->aName, sizeof(pTempl->aName));
@ -1488,14 +1486,14 @@ BOOL sendTemplate(DROID_TEMPLATE *pTempl)
// receive a template created by another player
BOOL recvTemplate(NETQUEUE queue)
{
uint8_t player;
uint32_t player;
DROID_TEMPLATE *psTempl;
DROID_TEMPLATE t, *pT = &t;
int i;
NETbeginDecode(queue, GAME_TEMPLATE);
NETuint8_t(&player);
ASSERT(player < MAX_PLAYERS, "recvtemplate: invalid player size: %d", player);
NETuint32_t(&player);
ASSERT_OR_RETURN(false, player < MAX_PLAYERS, "invalid player size: %d", player);
NETuint32_t(&pT->ref);
NETstring(pT->aName, sizeof(pT->aName));
@ -1571,6 +1569,8 @@ static BOOL recvDestroyTemplate(NETQUEUE queue)
NETuint32_t(&templateID);
NETend();
ASSERT_OR_RETURN(false, player < MAX_PLAYERS, "invalid player size: %d", player);
// Find the template in the list
for (psTempl = apsDroidTemplates[player]; psTempl; psTempl = psTempl->psNext)
{

View File

@ -168,7 +168,7 @@ extern char playerName[MAX_PLAYERS][MAX_STR_LENGTH]; //Array to store all playe
extern BOOL multiPlayerLoop (void); // for loop.c
extern BOOL recvMessage (void);
extern BOOL sendTemplate (DROID_TEMPLATE *t);
bool sendTemplate(uint32_t player, DROID_TEMPLATE *t);
extern BOOL SendDestroyTemplate (DROID_TEMPLATE *t);
extern BOOL SendResearch(uint8_t player, uint32_t index, bool trigger);
extern BOOL SendDestroyFeature (FEATURE *pF); // send a destruct feature message.

View File

@ -10759,7 +10759,7 @@ BOOL scrAssembleWeaponTemplate(void)
if (bMultiMessages)
{
sendTemplate(pNewTemplate);
sendTemplate(player, pNewTemplate);
}
}
else