Fix crash if cheating some buildings. Closes ticket:3066

master
Per Inge Mathisen 2012-01-16 23:10:00 +01:00
parent f1749582db
commit ede78982da
2 changed files with 4 additions and 14 deletions

View File

@ -1951,26 +1951,14 @@ INT_RETVAL intRunWidgets(void)
}
else
{
//psStructure = buildStructure(psBuilding, structX, structY,
// selectedPlayer, false);
psStructure = &tmp;
tmp.id = generateNewObjectId();
tmp.pStructureType = (STRUCTURE_STATS *)psPositionStats;
tmp.pos.x = structX;
tmp.pos.y = structY;
tmp.pos.z = map_Height(structX, structY) + world_coord(1)/10;
if (!psStructure)
{
addConsoleMessage(_("Failed to create building"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
}
}
if (psStructure)
{
const char* msg;
psStructure->status = SS_BUILT;
//buildingComplete(psStructure);
// In multiplayer games be sure to send a message to the
// other players, telling them a new structure has been
// placed.
@ -1982,7 +1970,6 @@ INT_RETVAL intRunWidgets(void)
selectedPlayer, psStructure->pStructureType->pName);
sendTextMessage(msg, true);
Cheated = true;
triggerEventStructBuilt(psStructure, NULL);
}
}
else if (psPositionStats->ref >= REF_FEATURE_START && psPositionStats->ref < REF_FEATURE_START + REF_RANGE)

View File

@ -47,6 +47,7 @@
#include "lib/sound/audio_id.h"
#include "lib/sound/audio.h"
#include "research.h"
#include "qtscript.h"
// ////////////////////////////////////////////////////////////////////////////
// structures
@ -89,7 +90,8 @@ bool recvBuildFinished(NETQUEUE queue)
psStruct = IdToStruct(structId,ANYPLAYER);
if (psStruct)
{ // make it complete.
{
// make it complete.
psStruct->currentBuildPts = psStruct->pStructureType->buildPoints+1;
if (psStruct->status != SS_BUILT)
@ -137,6 +139,7 @@ bool recvBuildFinished(NETQUEUE queue)
#if defined (DEBUG)
NETlogEntry("had to plonk down a building", SYNC_FLAG, player);
#endif
triggerEventStructBuilt(psStruct, NULL);
}
else
{