Fixes Pkunk crash bug due to a static variable; also moves the static data to owning STARSHIP
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3277 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#ifndef _RACES_H
|
#ifndef _RACES_H
|
||||||
#define _RACES_H
|
#define _RACES_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
#include "libs/compiler.h"
|
#include "libs/compiler.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "displist.h"
|
#include "displist.h"
|
||||||
@@ -275,6 +276,8 @@ struct STARSHIP
|
|||||||
// -1: neutral; this should currently never happen (asserts)
|
// -1: neutral; this should currently never happen (asserts)
|
||||||
BYTE control;
|
BYTE control;
|
||||||
// HUMAN, COMPUTER or NETWORK control flags, see intel.h
|
// HUMAN, COMPUTER or NETWORK control flags, see intel.h
|
||||||
|
|
||||||
|
intptr_t data; // private ship data, ship code owns this
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RPG_PLAYER_NUM 0
|
#define RPG_PLAYER_NUM 0
|
||||||
|
|||||||
@@ -179,20 +179,20 @@ initialize_bug_missile (ELEMENT *ShipPtr, HELEMENT MissileArray[])
|
|||||||
return (3);
|
return (3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HELEMENT hPhoenix = 0;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pkunk_intelligence (ELEMENT *ShipPtr, EVALUATE_DESC *ObjectsOfConcern,
|
pkunk_intelligence (ELEMENT *ShipPtr, EVALUATE_DESC *ObjectsOfConcern,
|
||||||
COUNT ConcernCounter)
|
COUNT ConcernCounter)
|
||||||
{
|
{
|
||||||
STARSHIP *StarShipPtr;
|
STARSHIP *StarShipPtr;
|
||||||
|
HELEMENT hPhoenix;
|
||||||
|
|
||||||
GetElementStarShip (ShipPtr, &StarShipPtr);
|
GetElementStarShip (ShipPtr, &StarShipPtr);
|
||||||
if (hPhoenix && StarShipPtr->special_counter)
|
hPhoenix = (HELEMENT) StarShipPtr->data;
|
||||||
|
if (hPhoenix && (StarShipPtr->control & STANDARD_RATING))
|
||||||
{
|
{
|
||||||
RemoveElement (hPhoenix);
|
RemoveElement (hPhoenix);
|
||||||
FreeElement (hPhoenix);
|
FreeElement (hPhoenix);
|
||||||
hPhoenix = 0;
|
StarShipPtr->data = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StarShipPtr->RaceDescPtr->ship_info.energy_level <
|
if (StarShipPtr->RaceDescPtr->ship_info.energy_level <
|
||||||
@@ -442,11 +442,14 @@ pkunk_preprocess (ELEMENT *ElementPtr)
|
|||||||
GetElementStarShip (ElementPtr, &StarShipPtr);
|
GetElementStarShip (ElementPtr, &StarShipPtr);
|
||||||
if (ElementPtr->state_flags & APPEARING)
|
if (ElementPtr->state_flags & APPEARING)
|
||||||
{
|
{
|
||||||
ELEMENT *PhoenixPtr;
|
HELEMENT hPhoenix = 0;
|
||||||
|
|
||||||
if (((BYTE)TFB_Random () & 1)
|
if ((BYTE)TFB_Random () & 1)
|
||||||
&& (hPhoenix = AllocElement ()))
|
hPhoenix = AllocElement ();
|
||||||
|
|
||||||
|
if (hPhoenix)
|
||||||
{
|
{
|
||||||
|
ELEMENT *PhoenixPtr;
|
||||||
|
|
||||||
LockElement (hPhoenix, &PhoenixPtr);
|
LockElement (hPhoenix, &PhoenixPtr);
|
||||||
PhoenixPtr->playerNr = ElementPtr->playerNr;
|
PhoenixPtr->playerNr = ElementPtr->playerNr;
|
||||||
@@ -460,6 +463,7 @@ pkunk_preprocess (ELEMENT *ElementPtr)
|
|||||||
UnlockElement (hPhoenix);
|
UnlockElement (hPhoenix);
|
||||||
InsertElement (hPhoenix, GetHeadElement ());
|
InsertElement (hPhoenix, GetHeadElement ());
|
||||||
}
|
}
|
||||||
|
StarShipPtr->data = (intptr_t) hPhoenix;
|
||||||
|
|
||||||
if (ElementPtr->hTarget == 0)
|
if (ElementPtr->hTarget == 0)
|
||||||
StarShipPtr->RaceDescPtr->preprocess_func = 0;
|
StarShipPtr->RaceDescPtr->preprocess_func = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user