From: <av...@us...> - 2009-11-05 04:10:02
|
Revision: 3277 http://sc2.svn.sourceforge.net/sc2/?rev=3277&view=rev Author: avolkov Date: 2009-11-05 04:09:55 +0000 (Thu, 05 Nov 2009) Log Message: ----------- Fixes Pkunk crash bug due to a static variable; also moves the static data to owning STARSHIP Modified Paths: -------------- trunk/sc2/src/uqm/races.h trunk/sc2/src/uqm/ships/pkunk/pkunk.c Modified: trunk/sc2/src/uqm/races.h =================================================================== --- trunk/sc2/src/uqm/races.h 2009-11-05 04:02:50 UTC (rev 3276) +++ trunk/sc2/src/uqm/races.h 2009-11-05 04:09:55 UTC (rev 3277) @@ -19,6 +19,7 @@ #ifndef _RACES_H #define _RACES_H +#include "types.h" #include "libs/compiler.h" #include "units.h" #include "displist.h" @@ -275,6 +276,8 @@ // -1: neutral; this should currently never happen (asserts) BYTE control; // HUMAN, COMPUTER or NETWORK control flags, see intel.h + + intptr_t data; // private ship data, ship code owns this }; #define RPG_PLAYER_NUM 0 Modified: trunk/sc2/src/uqm/ships/pkunk/pkunk.c =================================================================== --- trunk/sc2/src/uqm/ships/pkunk/pkunk.c 2009-11-05 04:02:50 UTC (rev 3276) +++ trunk/sc2/src/uqm/ships/pkunk/pkunk.c 2009-11-05 04:09:55 UTC (rev 3277) @@ -179,20 +179,20 @@ return (3); } -static HELEMENT hPhoenix = 0; - static void pkunk_intelligence (ELEMENT *ShipPtr, EVALUATE_DESC *ObjectsOfConcern, COUNT ConcernCounter) { STARSHIP *StarShipPtr; + HELEMENT hPhoenix; GetElementStarShip (ShipPtr, &StarShipPtr); - if (hPhoenix && StarShipPtr->special_counter) + hPhoenix = (HELEMENT) StarShipPtr->data; + if (hPhoenix && (StarShipPtr->control & STANDARD_RATING)) { RemoveElement (hPhoenix); FreeElement (hPhoenix); - hPhoenix = 0; + StarShipPtr->data = 0; } if (StarShipPtr->RaceDescPtr->ship_info.energy_level < @@ -442,11 +442,14 @@ GetElementStarShip (ElementPtr, &StarShipPtr); if (ElementPtr->state_flags & APPEARING) { - ELEMENT *PhoenixPtr; + HELEMENT hPhoenix = 0; - if (((BYTE)TFB_Random () & 1) - && (hPhoenix = AllocElement ())) + if ((BYTE)TFB_Random () & 1) + hPhoenix = AllocElement (); + + if (hPhoenix) { + ELEMENT *PhoenixPtr; LockElement (hPhoenix, &PhoenixPtr); PhoenixPtr->playerNr = ElementPtr->playerNr; @@ -460,6 +463,7 @@ UnlockElement (hPhoenix); InsertElement (hPhoenix, GetHeadElement ()); } + StarShipPtr->data = (intptr_t) hPhoenix; if (ElementPtr->hTarget == 0) StarShipPtr->RaceDescPtr->preprocess_func = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |