Various warning cleanups from Scott A. Colcord, bug #50; reworked Umgah ship code so as not to compare FRAMEs
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3667 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
Changes towards version 0.8:
|
Changes towards version 0.8:
|
||||||
|
- Various warnings cleanup (bug #50), from Scott A. Colcord
|
||||||
- Fixed various Pkunk reincarnation and Shofixti Glory device interactions;
|
- Fixed various Pkunk reincarnation and Shofixti Glory device interactions;
|
||||||
Pkunk ditty plays in a simultaneous destruction (bug #666) - Alex
|
Pkunk ditty plays in a simultaneous destruction (bug #666) - Alex
|
||||||
- Preparing for linking with C++ code, from Scott A. Colcord
|
- Preparing for linking with C++ code, from Scott A. Colcord
|
||||||
|
|||||||
@@ -2217,6 +2217,10 @@ SOURCE=..\..\src\uqm\planets\solarsys.c
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\src\uqm\planets\solarsys.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\src\uqm\planets\sundata.h
|
SOURCE=..\..\src\uqm\planets\sundata.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -25,14 +25,11 @@
|
|||||||
#include "planets/lander.h"
|
#include "planets/lander.h"
|
||||||
#include "starcon.h"
|
#include "starcon.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
#include "planets/solarsys.h"
|
||||||
#include "sounds.h"
|
#include "sounds.h"
|
||||||
#include "libs/sndlib.h"
|
#include "libs/sndlib.h"
|
||||||
#include "libs/vidlib.h"
|
#include "libs/vidlib.h"
|
||||||
|
|
||||||
// XXX: we do not current have a header for this prototype to live in
|
|
||||||
// should be something like solarsys.h
|
|
||||||
extern void FreeIPData (void);
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FreeKernel (void)
|
FreeKernel (void)
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ uqm_CFILES="calc.c cargo.c devices.c gentopo.c lander.c orbits.c
|
|||||||
oval.c pl_stuff.c planets.c plangen.c pstarmap.c report.c
|
oval.c pl_stuff.c planets.c plangen.c pstarmap.c report.c
|
||||||
roster.c scan.c solarsys.c surface.c"
|
roster.c scan.c solarsys.c surface.c"
|
||||||
uqm_HFILES="elemdata.h generate.h lander.h lifeform.h plandata.h planets.h
|
uqm_HFILES="elemdata.h generate.h lander.h lifeform.h plandata.h planets.h
|
||||||
scan.h sundata.h"
|
scan.h solarsys.h sundata.h"
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "libs/graphics/context.h"
|
#include "libs/graphics/context.h"
|
||||||
#include "libs/graphics/drawable.h"
|
#include "libs/graphics/drawable.h"
|
||||||
|
|
||||||
|
#include "planets.h"
|
||||||
|
|
||||||
#define NUM_QUADS 4
|
#define NUM_QUADS 4
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "solarsys.h"
|
||||||
#include "lander.h"
|
#include "lander.h"
|
||||||
#include "../colors.h"
|
#include "../colors.h"
|
||||||
#include "../controls.h"
|
#include "../controls.h"
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
//Copyright (C) 2011, Scott A. Colcord
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SOLARSYS_H
|
||||||
|
#define SOLARSYS_H
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern void LoadIPData (void);
|
||||||
|
extern void FreeIPData (void);
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* SOLARSYS_H */
|
||||||
|
|
||||||
+1
-1
@@ -221,7 +221,7 @@ struct race_desc
|
|||||||
POSTPROCESS_FUNC *postprocess_func;
|
POSTPROCESS_FUNC *postprocess_func;
|
||||||
INIT_WEAPON_FUNC *init_weapon_func;
|
INIT_WEAPON_FUNC *init_weapon_func;
|
||||||
|
|
||||||
intptr_t data; // private ship data, ship code owns this
|
void* data; // private ship data, ship code owns this
|
||||||
|
|
||||||
void *CodeRef;
|
void *CodeRef;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -766,7 +766,7 @@ clear_control (WIDGET_CONTROLENTRY *widget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
count_widgets (const WIDGET **widgets)
|
count_widgets (WIDGET **widgets)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,46 @@ static RACE_DESC androsynth_desc =
|
|||||||
0, /* CodeRef */
|
0, /* CodeRef */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Private per-instance ship data
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
ElementCollisionFunc* collision_func;
|
||||||
|
} ANDROSYNTH_DATA;
|
||||||
|
|
||||||
|
// Local typedef
|
||||||
|
typedef ANDROSYNTH_DATA CustomShipData_t;
|
||||||
|
|
||||||
|
// Retrieve race-specific ship data from a race desc
|
||||||
|
static CustomShipData_t *
|
||||||
|
GetCustomShipData (RACE_DESC *pRaceDesc)
|
||||||
|
{
|
||||||
|
return pRaceDesc->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the race-specific data in a race desc
|
||||||
|
// (Re)Allocates its own storage for the data.
|
||||||
|
static void
|
||||||
|
SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data)
|
||||||
|
{
|
||||||
|
if (pRaceDesc->data == data)
|
||||||
|
return; // no-op
|
||||||
|
|
||||||
|
if (pRaceDesc->data) // Out with the old
|
||||||
|
{
|
||||||
|
HFree (pRaceDesc->data);
|
||||||
|
pRaceDesc->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data) // In with the new
|
||||||
|
{
|
||||||
|
CustomShipData_t* newData = HMalloc (sizeof (*data));
|
||||||
|
*newData = *data;
|
||||||
|
pRaceDesc->data = newData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define BLAZER_DAMAGE 3
|
#define BLAZER_DAMAGE 3
|
||||||
#define BLAZER_MASS 1
|
#define BLAZER_MASS 1
|
||||||
|
|
||||||
@@ -355,13 +395,16 @@ androsynth_postprocess (ELEMENT *ElementPtr)
|
|||||||
ElementPtr->mass_points = BLAZER_MASS;
|
ElementPtr->mass_points = BLAZER_MASS;
|
||||||
StarShipPtr->RaceDescPtr->characteristics.turn_wait
|
StarShipPtr->RaceDescPtr->characteristics.turn_wait
|
||||||
= BLAZER_TURN_WAIT;
|
= BLAZER_TURN_WAIT;
|
||||||
|
|
||||||
/* Save the current collision func because we were not the
|
/* Save the current collision func because we were not the
|
||||||
* ones who set it */
|
* ones who set it */
|
||||||
StarShipPtr->RaceDescPtr->data = (intptr_t)
|
{
|
||||||
ElementPtr->collision_func;
|
const ANDROSYNTH_DATA shipData = { ElementPtr->collision_func };
|
||||||
|
SetCustomShipData (StarShipPtr->RaceDescPtr, &shipData);
|
||||||
ElementPtr->collision_func = blazer_collision;
|
ElementPtr->collision_func = blazer_collision;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (StarShipPtr->RaceDescPtr->ship_info.energy_level == 0)
|
if (StarShipPtr->RaceDescPtr->ship_info.energy_level == 0)
|
||||||
/* if blazer wasn't able to change back into ship
|
/* if blazer wasn't able to change back into ship
|
||||||
@@ -426,8 +469,8 @@ androsynth_preprocess (ELEMENT *ElementPtr)
|
|||||||
StarShipPtr->RaceDescPtr->characteristics.special_wait;
|
StarShipPtr->RaceDescPtr->characteristics.special_wait;
|
||||||
StarShipPtr->RaceDescPtr->characteristics.energy_regeneration = ENERGY_REGENERATION;
|
StarShipPtr->RaceDescPtr->characteristics.energy_regeneration = ENERGY_REGENERATION;
|
||||||
ElementPtr->mass_points = SHIP_MASS;
|
ElementPtr->mass_points = SHIP_MASS;
|
||||||
ElementPtr->collision_func = (ElementCollisionFunc *)
|
ElementPtr->collision_func =
|
||||||
StarShipPtr->RaceDescPtr->data;
|
GetCustomShipData (StarShipPtr->RaceDescPtr)->collision_func;
|
||||||
ElementPtr->next.image.farray =
|
ElementPtr->next.image.farray =
|
||||||
StarShipPtr->RaceDescPtr->ship_data.ship;
|
StarShipPtr->RaceDescPtr->ship_data.ship;
|
||||||
ElementPtr->next.image.frame =
|
ElementPtr->next.image.frame =
|
||||||
@@ -463,11 +506,19 @@ androsynth_preprocess (ELEMENT *ElementPtr)
|
|||||||
StarShipPtr->cur_status_flags = cur_status_flags;
|
StarShipPtr->cur_status_flags = cur_status_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
uninit_androsynth (RACE_DESC *pRaceDesc)
|
||||||
|
{
|
||||||
|
SetCustomShipData (pRaceDesc, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RACE_DESC*
|
RACE_DESC*
|
||||||
init_androsynth (void)
|
init_androsynth (void)
|
||||||
{
|
{
|
||||||
RACE_DESC *RaceDescPtr;
|
RACE_DESC *RaceDescPtr;
|
||||||
|
|
||||||
|
androsynth_desc.uninit_func = uninit_androsynth;
|
||||||
androsynth_desc.preprocess_func = androsynth_preprocess;
|
androsynth_desc.preprocess_func = androsynth_preprocess;
|
||||||
androsynth_desc.postprocess_func = androsynth_postprocess;
|
androsynth_desc.postprocess_func = androsynth_postprocess;
|
||||||
androsynth_desc.init_weapon_func = initialize_bubble;
|
androsynth_desc.init_weapon_func = initialize_bubble;
|
||||||
|
|||||||
@@ -124,6 +124,41 @@ static RACE_DESC mmrnmhrm_desc =
|
|||||||
#define MISSILE_SPEED DISPLAY_TO_WORLD (20)
|
#define MISSILE_SPEED DISPLAY_TO_WORLD (20)
|
||||||
#define TRACK_WAIT 5
|
#define TRACK_WAIT 5
|
||||||
|
|
||||||
|
// Private per-instance ship data
|
||||||
|
typedef CHARACTERISTIC_STUFF MMRNMHRM_DATA;
|
||||||
|
|
||||||
|
// Local typedef
|
||||||
|
typedef MMRNMHRM_DATA CustomShipData_t;
|
||||||
|
|
||||||
|
// Retrieve race-specific ship data from a race desc
|
||||||
|
static CustomShipData_t *
|
||||||
|
GetCustomShipData (RACE_DESC *pRaceDesc)
|
||||||
|
{
|
||||||
|
return pRaceDesc->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the race-specific data in a race desc
|
||||||
|
// (Re)Allocates its own storage for the data.
|
||||||
|
static void
|
||||||
|
SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data)
|
||||||
|
{
|
||||||
|
if (pRaceDesc->data == data)
|
||||||
|
return; // no-op
|
||||||
|
|
||||||
|
if (pRaceDesc->data) // Out with the old
|
||||||
|
{
|
||||||
|
HFree (pRaceDesc->data);
|
||||||
|
pRaceDesc->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data) // In with the new
|
||||||
|
{
|
||||||
|
CustomShipData_t* newData = HMalloc (sizeof (*data));
|
||||||
|
*newData = *data;
|
||||||
|
pRaceDesc->data = newData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
missile_preprocess (ELEMENT *ElementPtr)
|
missile_preprocess (ELEMENT *ElementPtr)
|
||||||
{
|
{
|
||||||
@@ -363,8 +398,8 @@ mmrnmhrm_postprocess (ELEMENT *ElementPtr)
|
|||||||
/* take care of transform effect */
|
/* take care of transform effect */
|
||||||
if (ElementPtr->next.image.farray != ElementPtr->current.image.farray)
|
if (ElementPtr->next.image.farray != ElementPtr->current.image.farray)
|
||||||
{
|
{
|
||||||
CHARACTERISTIC_STUFF t;
|
MMRNMHRM_DATA tempShipData;
|
||||||
CHARACTERISTIC_STUFF *otherwing_desc;
|
MMRNMHRM_DATA *otherwing_desc;
|
||||||
|
|
||||||
ProcessSound (SetAbsSoundIndex (
|
ProcessSound (SetAbsSoundIndex (
|
||||||
/* TRANSFORM */
|
/* TRANSFORM */
|
||||||
@@ -373,11 +408,13 @@ mmrnmhrm_postprocess (ELEMENT *ElementPtr)
|
|||||||
StarShipPtr->weapon_counter = 0;
|
StarShipPtr->weapon_counter = 0;
|
||||||
|
|
||||||
/* Swap characteristics descriptors around */
|
/* Swap characteristics descriptors around */
|
||||||
otherwing_desc = (CHARACTERISTIC_STUFF *)
|
otherwing_desc = GetCustomShipData (StarShipPtr->RaceDescPtr);
|
||||||
StarShipPtr->RaceDescPtr->data;
|
if (!otherwing_desc)
|
||||||
t = *otherwing_desc;
|
return; // No ship data (?!)
|
||||||
*otherwing_desc = StarShipPtr->RaceDescPtr->characteristics;
|
|
||||||
StarShipPtr->RaceDescPtr->characteristics = t;
|
tempShipData = *otherwing_desc;
|
||||||
|
SetCustomShipData (StarShipPtr->RaceDescPtr, &StarShipPtr->RaceDescPtr->characteristics);
|
||||||
|
StarShipPtr->RaceDescPtr->characteristics = tempShipData;
|
||||||
StarShipPtr->RaceDescPtr->cyborg_control.ManeuverabilityIndex = 0;
|
StarShipPtr->RaceDescPtr->cyborg_control.ManeuverabilityIndex = 0;
|
||||||
|
|
||||||
if (ElementPtr->next.image.farray == StarShipPtr->RaceDescPtr->ship_data.special)
|
if (ElementPtr->next.image.farray == StarShipPtr->RaceDescPtr->ship_data.special)
|
||||||
@@ -444,8 +481,7 @@ mmrnmhrm_preprocess (ELEMENT *ElementPtr)
|
|||||||
static void
|
static void
|
||||||
uninit_mmrnmhrm (RACE_DESC *pRaceDesc)
|
uninit_mmrnmhrm (RACE_DESC *pRaceDesc)
|
||||||
{
|
{
|
||||||
HFree ((void *)pRaceDesc->data);
|
SetCustomShipData (pRaceDesc, NULL);
|
||||||
pRaceDesc->data = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RACE_DESC*
|
RACE_DESC*
|
||||||
@@ -454,7 +490,7 @@ init_mmrnmhrm (void)
|
|||||||
RACE_DESC *RaceDescPtr;
|
RACE_DESC *RaceDescPtr;
|
||||||
// The caller of this func will copy the struct
|
// The caller of this func will copy the struct
|
||||||
static RACE_DESC new_mmrnmhrm_desc;
|
static RACE_DESC new_mmrnmhrm_desc;
|
||||||
CHARACTERISTIC_STUFF *otherwing_desc;
|
MMRNMHRM_DATA otherwing_desc;
|
||||||
|
|
||||||
mmrnmhrm_desc.uninit_func = uninit_mmrnmhrm;
|
mmrnmhrm_desc.uninit_func = uninit_mmrnmhrm;
|
||||||
mmrnmhrm_desc.preprocess_func = mmrnmhrm_preprocess;
|
mmrnmhrm_desc.preprocess_func = mmrnmhrm_preprocess;
|
||||||
@@ -464,20 +500,19 @@ init_mmrnmhrm (void)
|
|||||||
|
|
||||||
new_mmrnmhrm_desc = mmrnmhrm_desc;
|
new_mmrnmhrm_desc = mmrnmhrm_desc;
|
||||||
|
|
||||||
otherwing_desc = HMalloc (sizeof (*otherwing_desc));
|
otherwing_desc.max_thrust = YWING_MAX_THRUST;
|
||||||
otherwing_desc->max_thrust = YWING_MAX_THRUST;
|
otherwing_desc.thrust_increment = YWING_THRUST_INCREMENT;
|
||||||
otherwing_desc->thrust_increment = YWING_THRUST_INCREMENT;
|
otherwing_desc.energy_regeneration = YWING_ENERGY_REGENERATION;
|
||||||
otherwing_desc->energy_regeneration = YWING_ENERGY_REGENERATION;
|
otherwing_desc.weapon_energy_cost = YWING_WEAPON_ENERGY_COST;
|
||||||
otherwing_desc->weapon_energy_cost = YWING_WEAPON_ENERGY_COST;
|
otherwing_desc.special_energy_cost = YWING_SPECIAL_ENERGY_COST;
|
||||||
otherwing_desc->special_energy_cost = YWING_SPECIAL_ENERGY_COST;
|
otherwing_desc.energy_wait = YWING_ENERGY_WAIT;
|
||||||
otherwing_desc->energy_wait = YWING_ENERGY_WAIT;
|
otherwing_desc.turn_wait = YWING_TURN_WAIT;
|
||||||
otherwing_desc->turn_wait = YWING_TURN_WAIT;
|
otherwing_desc.thrust_wait = YWING_THRUST_WAIT;
|
||||||
otherwing_desc->thrust_wait = YWING_THRUST_WAIT;
|
otherwing_desc.weapon_wait = YWING_WEAPON_WAIT;
|
||||||
otherwing_desc->weapon_wait = YWING_WEAPON_WAIT;
|
otherwing_desc.special_wait = YWING_SPECIAL_WAIT;
|
||||||
otherwing_desc->special_wait = YWING_SPECIAL_WAIT;
|
otherwing_desc.ship_mass = SHIP_MASS;
|
||||||
otherwing_desc->ship_mass = SHIP_MASS;
|
|
||||||
|
|
||||||
new_mmrnmhrm_desc.data = (intptr_t) otherwing_desc;
|
SetCustomShipData (&new_mmrnmhrm_desc, &otherwing_desc);
|
||||||
|
|
||||||
RaceDescPtr = &new_mmrnmhrm_desc;
|
RaceDescPtr = &new_mmrnmhrm_desc;
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,38 @@ typedef struct
|
|||||||
|
|
||||||
} PKUNK_DATA;
|
} PKUNK_DATA;
|
||||||
|
|
||||||
|
// Local typedef
|
||||||
|
typedef PKUNK_DATA CustomShipData_t;
|
||||||
|
|
||||||
|
// Retrieve race-specific ship data from a race desc
|
||||||
|
static CustomShipData_t *
|
||||||
|
GetCustomShipData (RACE_DESC *pRaceDesc)
|
||||||
|
{
|
||||||
|
return pRaceDesc->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the race-specific data in a race desc
|
||||||
|
// (Re)Allocates its own storage for the data.
|
||||||
|
static void
|
||||||
|
SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data)
|
||||||
|
{
|
||||||
|
if (pRaceDesc->data == data)
|
||||||
|
return; // no-op
|
||||||
|
|
||||||
|
if (pRaceDesc->data) // Out with the old
|
||||||
|
{
|
||||||
|
HFree (pRaceDesc->data);
|
||||||
|
pRaceDesc->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data) // In with the new
|
||||||
|
{
|
||||||
|
CustomShipData_t* newData = HMalloc (sizeof (*data));
|
||||||
|
*newData = *data;
|
||||||
|
pRaceDesc->data = newData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
animate (ELEMENT *ElementPtr)
|
animate (ELEMENT *ElementPtr)
|
||||||
{
|
{
|
||||||
@@ -200,7 +232,7 @@ pkunk_intelligence (ELEMENT *ShipPtr, EVALUATE_DESC *ObjectsOfConcern,
|
|||||||
PKUNK_DATA *PkunkData;
|
PKUNK_DATA *PkunkData;
|
||||||
|
|
||||||
GetElementStarShip (ShipPtr, &StarShipPtr);
|
GetElementStarShip (ShipPtr, &StarShipPtr);
|
||||||
PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data;
|
PkunkData = GetCustomShipData (StarShipPtr->RaceDescPtr);
|
||||||
if (PkunkData->hPhoenix && (StarShipPtr->control & STANDARD_RATING))
|
if (PkunkData->hPhoenix && (StarShipPtr->control & STANDARD_RATING))
|
||||||
{
|
{
|
||||||
RemoveElement (PkunkData->hPhoenix);
|
RemoveElement (PkunkData->hPhoenix);
|
||||||
@@ -227,7 +259,7 @@ new_pkunk (ELEMENT *ElementPtr)
|
|||||||
PKUNK_DATA *PkunkData;
|
PKUNK_DATA *PkunkData;
|
||||||
|
|
||||||
GetElementStarShip (ElementPtr, &StarShipPtr);
|
GetElementStarShip (ElementPtr, &StarShipPtr);
|
||||||
PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data;
|
PkunkData = GetCustomShipData (StarShipPtr->RaceDescPtr);
|
||||||
|
|
||||||
ElementPtr->state_flags = APPEARING | PLAYER_SHIP | IGNORE_SIMILAR;
|
ElementPtr->state_flags = APPEARING | PLAYER_SHIP | IGNORE_SIMILAR;
|
||||||
ElementPtr->mass_points = SHIP_MASS;
|
ElementPtr->mass_points = SHIP_MASS;
|
||||||
@@ -301,7 +333,7 @@ intercept_pkunk_death (ELEMENT *ElementPtr)
|
|||||||
ELEMENT *ShipPtr;
|
ELEMENT *ShipPtr;
|
||||||
|
|
||||||
GetElementStarShip (ElementPtr, &StarShipPtr);
|
GetElementStarShip (ElementPtr, &StarShipPtr);
|
||||||
PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data;
|
PkunkData = GetCustomShipData (StarShipPtr->RaceDescPtr);
|
||||||
|
|
||||||
if (StarShipPtr->RaceDescPtr->ship_info.crew_level != 0)
|
if (StarShipPtr->RaceDescPtr->ship_info.crew_level != 0)
|
||||||
{ // Ship not dead yet.
|
{ // Ship not dead yet.
|
||||||
@@ -447,7 +479,7 @@ pkunk_preprocess (ELEMENT *ElementPtr)
|
|||||||
PKUNK_DATA *PkunkData;
|
PKUNK_DATA *PkunkData;
|
||||||
|
|
||||||
GetElementStarShip (ElementPtr, &StarShipPtr);
|
GetElementStarShip (ElementPtr, &StarShipPtr);
|
||||||
PkunkData = (PKUNK_DATA *) StarShipPtr->RaceDescPtr->data;
|
PkunkData = GetCustomShipData (StarShipPtr->RaceDescPtr);
|
||||||
if (ElementPtr->state_flags & APPEARING)
|
if (ElementPtr->state_flags & APPEARING)
|
||||||
{
|
{
|
||||||
HELEMENT hPhoenix = 0;
|
HELEMENT hPhoenix = 0;
|
||||||
@@ -572,8 +604,7 @@ pkunk_postprocess (ELEMENT *ElementPtr)
|
|||||||
static void
|
static void
|
||||||
uninit_pkunk (RACE_DESC *pRaceDesc)
|
uninit_pkunk (RACE_DESC *pRaceDesc)
|
||||||
{
|
{
|
||||||
HFree ((void *)pRaceDesc->data);
|
SetCustomShipData (pRaceDesc, NULL);
|
||||||
pRaceDesc->data = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RACE_DESC*
|
RACE_DESC*
|
||||||
@@ -582,6 +613,8 @@ init_pkunk (void)
|
|||||||
RACE_DESC *RaceDescPtr;
|
RACE_DESC *RaceDescPtr;
|
||||||
// The caller of this func will copy the struct
|
// The caller of this func will copy the struct
|
||||||
static RACE_DESC new_pkunk_desc;
|
static RACE_DESC new_pkunk_desc;
|
||||||
|
PKUNK_DATA empty_data;
|
||||||
|
memset (&empty_data, 0, sizeof (empty_data));
|
||||||
|
|
||||||
pkunk_desc.uninit_func = uninit_pkunk;
|
pkunk_desc.uninit_func = uninit_pkunk;
|
||||||
pkunk_desc.preprocess_func = pkunk_preprocess;
|
pkunk_desc.preprocess_func = pkunk_preprocess;
|
||||||
@@ -591,7 +624,7 @@ init_pkunk (void)
|
|||||||
|
|
||||||
/* copy initial ship settings to the new descriptor */
|
/* copy initial ship settings to the new descriptor */
|
||||||
new_pkunk_desc = pkunk_desc;
|
new_pkunk_desc = pkunk_desc;
|
||||||
new_pkunk_desc.data = (intptr_t) HCalloc (sizeof (PKUNK_DATA));
|
SetCustomShipData (&new_pkunk_desc, &empty_data);
|
||||||
|
|
||||||
RaceDescPtr = &new_pkunk_desc;
|
RaceDescPtr = &new_pkunk_desc;
|
||||||
|
|
||||||
|
|||||||
@@ -136,9 +136,41 @@ static void InitDriveSlots (RACE_DESC *RaceDescPtr,
|
|||||||
const BYTE *DriveSlots);
|
const BYTE *DriveSlots);
|
||||||
static void InitJetSlots (RACE_DESC *RaceDescPtr,
|
static void InitJetSlots (RACE_DESC *RaceDescPtr,
|
||||||
const BYTE *JetSlots);
|
const BYTE *JetSlots);
|
||||||
void uninit_sis (RACE_DESC *pRaceDesc);
|
static void uninit_sis (RACE_DESC *pRaceDesc);
|
||||||
|
|
||||||
|
|
||||||
|
// Local typedef
|
||||||
|
typedef SIS_DATA CustomShipData_t;
|
||||||
|
|
||||||
|
// Retrieve race-specific ship data from a race desc
|
||||||
|
static CustomShipData_t *
|
||||||
|
GetCustomShipData (RACE_DESC *pRaceDesc)
|
||||||
|
{
|
||||||
|
return pRaceDesc->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the race-specific data in a race desc
|
||||||
|
// (Re)Allocates its own storage for the data.
|
||||||
|
static void
|
||||||
|
SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data)
|
||||||
|
{
|
||||||
|
if (pRaceDesc->data == data)
|
||||||
|
return; // no-op
|
||||||
|
|
||||||
|
if (pRaceDesc->data) // Out with the old
|
||||||
|
{
|
||||||
|
HFree (pRaceDesc->data);
|
||||||
|
pRaceDesc->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data) // In with the new
|
||||||
|
{
|
||||||
|
CustomShipData_t* newData = HMalloc (sizeof (*data));
|
||||||
|
*newData = *data;
|
||||||
|
pRaceDesc->data = newData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sis_hyper_preprocess (ELEMENT *ElementPtr)
|
sis_hyper_preprocess (ELEMENT *ElementPtr)
|
||||||
{
|
{
|
||||||
@@ -566,7 +598,7 @@ initialize_blasters (ELEMENT *ShipPtr, HELEMENT BlasterArray[])
|
|||||||
SIS_DATA *SisData;
|
SIS_DATA *SisData;
|
||||||
|
|
||||||
GetElementStarShip (ShipPtr, &StarShipPtr);
|
GetElementStarShip (ShipPtr, &StarShipPtr);
|
||||||
SisData = (SIS_DATA *) StarShipPtr->RaceDescPtr->data;
|
SisData = GetCustomShipData (StarShipPtr->RaceDescPtr);
|
||||||
|
|
||||||
nt = (BYTE)((4 - SisData->num_trackers) & 3);
|
nt = (BYTE)((4 - SisData->num_trackers) & 3);
|
||||||
|
|
||||||
@@ -606,7 +638,7 @@ sis_intelligence (ELEMENT *ShipPtr, EVALUATE_DESC *ObjectsOfConcern,
|
|||||||
SIS_DATA *SisData;
|
SIS_DATA *SisData;
|
||||||
|
|
||||||
GetElementStarShip (ShipPtr, &StarShipPtr);
|
GetElementStarShip (ShipPtr, &StarShipPtr);
|
||||||
SisData = (SIS_DATA *) StarShipPtr->RaceDescPtr->data;
|
SisData = GetCustomShipData (StarShipPtr->RaceDescPtr);
|
||||||
|
|
||||||
lpEvalDesc = &ObjectsOfConcern[ENEMY_WEAPON_INDEX];
|
lpEvalDesc = &ObjectsOfConcern[ENEMY_WEAPON_INDEX];
|
||||||
if (lpEvalDesc->ObjectPtr)
|
if (lpEvalDesc->ObjectPtr)
|
||||||
@@ -680,7 +712,7 @@ InitWeaponSlots (RACE_DESC *RaceDescPtr, const BYTE *ModuleSlots)
|
|||||||
#define BLASTER_HITS 2
|
#define BLASTER_HITS 2
|
||||||
#define BLASTER_OFFSET 8
|
#define BLASTER_OFFSET 8
|
||||||
COUNT i;
|
COUNT i;
|
||||||
SIS_DATA *SisData = (SIS_DATA *) RaceDescPtr->data;
|
SIS_DATA *SisData = GetCustomShipData (RaceDescPtr);
|
||||||
MISSILE_BLOCK *lpMB = SisData->MissileBlock;
|
MISSILE_BLOCK *lpMB = SisData->MissileBlock;
|
||||||
|
|
||||||
SisData->num_blasters = 0;
|
SisData->num_blasters = 0;
|
||||||
@@ -760,7 +792,7 @@ InitModuleSlots (RACE_DESC *RaceDescPtr, const BYTE *ModuleSlots)
|
|||||||
{
|
{
|
||||||
COUNT i;
|
COUNT i;
|
||||||
COUNT num_trackers;
|
COUNT num_trackers;
|
||||||
SIS_DATA *SisData = (SIS_DATA *) RaceDescPtr->data;
|
SIS_DATA *SisData = GetCustomShipData (RaceDescPtr);
|
||||||
|
|
||||||
RaceDescPtr->ship_info.max_crew = 0;
|
RaceDescPtr->ship_info.max_crew = 0;
|
||||||
num_trackers = 0;
|
num_trackers = 0;
|
||||||
@@ -851,6 +883,8 @@ init_sis (void)
|
|||||||
COUNT i;
|
COUNT i;
|
||||||
// The caller of this func will copy the struct
|
// The caller of this func will copy the struct
|
||||||
static RACE_DESC new_sis_desc;
|
static RACE_DESC new_sis_desc;
|
||||||
|
SIS_DATA empty_data;
|
||||||
|
memset (&empty_data, 0, sizeof (empty_data));
|
||||||
|
|
||||||
/* copy initial ship settings to new_sis_desc */
|
/* copy initial ship settings to new_sis_desc */
|
||||||
new_sis_desc = sis_desc;
|
new_sis_desc = sis_desc;
|
||||||
@@ -888,7 +922,7 @@ init_sis (void)
|
|||||||
SET_GAME_STATE (BOMB_CARRIER, 1);
|
SET_GAME_STATE (BOMB_CARRIER, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
new_sis_desc.data = (intptr_t) HCalloc (sizeof (SIS_DATA));
|
SetCustomShipData (&new_sis_desc, &empty_data);
|
||||||
InitModuleSlots (&new_sis_desc, GLOBAL_SIS (ModuleSlots));
|
InitModuleSlots (&new_sis_desc, GLOBAL_SIS (ModuleSlots));
|
||||||
InitWeaponSlots (&new_sis_desc, GLOBAL_SIS (ModuleSlots));
|
InitWeaponSlots (&new_sis_desc, GLOBAL_SIS (ModuleSlots));
|
||||||
InitDriveSlots (&new_sis_desc, GLOBAL_SIS (DriveSlots));
|
InitDriveSlots (&new_sis_desc, GLOBAL_SIS (DriveSlots));
|
||||||
@@ -913,7 +947,7 @@ init_sis (void)
|
|||||||
return (RaceDescPtr);
|
return (RaceDescPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
uninit_sis (RACE_DESC *pRaceDesc)
|
uninit_sis (RACE_DESC *pRaceDesc)
|
||||||
{
|
{
|
||||||
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
|
if (LOBYTE (GLOBAL (CurrentActivity)) != IN_HYPERSPACE)
|
||||||
@@ -923,8 +957,7 @@ uninit_sis (RACE_DESC *pRaceDesc)
|
|||||||
GLOBAL_SIS (CrewEnlisted)--;
|
GLOBAL_SIS (CrewEnlisted)--;
|
||||||
}
|
}
|
||||||
|
|
||||||
HFree ((void *)pRaceDesc->data);
|
SetCustomShipData (pRaceDesc, NULL);
|
||||||
pRaceDesc->data = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,46 @@ static RACE_DESC umgah_desc =
|
|||||||
0, /* CodeRef */
|
0, /* CodeRef */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Private per-instance ship data
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UWORD prevFacing;
|
||||||
|
} UMGAH_DATA;
|
||||||
|
|
||||||
|
// Local typedef
|
||||||
|
typedef UMGAH_DATA CustomShipData_t;
|
||||||
|
|
||||||
|
// Retrieve race-specific ship data from a race desc
|
||||||
|
static CustomShipData_t *
|
||||||
|
GetCustomShipData (RACE_DESC *pRaceDesc)
|
||||||
|
{
|
||||||
|
return pRaceDesc->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the race-specific data in a race desc
|
||||||
|
// (Re)Allocates its own storage for the data.
|
||||||
|
static void
|
||||||
|
SetCustomShipData (RACE_DESC *pRaceDesc, const CustomShipData_t *data)
|
||||||
|
{
|
||||||
|
if (pRaceDesc->data == data)
|
||||||
|
return; // no-op
|
||||||
|
|
||||||
|
if (pRaceDesc->data) // Out with the old
|
||||||
|
{
|
||||||
|
HFree (pRaceDesc->data);
|
||||||
|
pRaceDesc->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data) // In with the new
|
||||||
|
{
|
||||||
|
CustomShipData_t* newData = HMalloc (sizeof (*data));
|
||||||
|
*newData = *data;
|
||||||
|
pRaceDesc->data = newData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cone_preprocess (ELEMENT *ElementPtr)
|
cone_preprocess (ELEMENT *ElementPtr)
|
||||||
{
|
{
|
||||||
@@ -266,6 +306,7 @@ initialize_cone (ELEMENT *ShipPtr, HELEMENT ConeArray[])
|
|||||||
#define MISSILE_LIFE 1
|
#define MISSILE_LIFE 1
|
||||||
#define MISSILE_OFFSET 0
|
#define MISSILE_OFFSET 0
|
||||||
STARSHIP *StarShipPtr;
|
STARSHIP *StarShipPtr;
|
||||||
|
UMGAH_DATA* UmgahData;
|
||||||
MISSILE_BLOCK MissileBlock;
|
MISSILE_BLOCK MissileBlock;
|
||||||
|
|
||||||
GetElementStarShip (ShipPtr, &StarShipPtr);
|
GetElementStarShip (ShipPtr, &StarShipPtr);
|
||||||
@@ -285,15 +326,17 @@ initialize_cone (ELEMENT *ShipPtr, HELEMENT ConeArray[])
|
|||||||
|
|
||||||
// This func is called every frame while the player is holding down WEAPON
|
// This func is called every frame while the player is holding down WEAPON
|
||||||
// Don't reset the cone FRAME to the first image every time
|
// Don't reset the cone FRAME to the first image every time
|
||||||
if (ShipPtr->next.image.frame != (FRAME) StarShipPtr->RaceDescPtr->data)
|
UmgahData = GetCustomShipData (StarShipPtr->RaceDescPtr);
|
||||||
|
if (!UmgahData || StarShipPtr->ShipFacing != UmgahData->prevFacing)
|
||||||
{
|
{
|
||||||
StarShipPtr->RaceDescPtr->data = (intptr_t) ShipPtr->next.image.frame;
|
const UMGAH_DATA shipData = {StarShipPtr->ShipFacing};
|
||||||
|
|
||||||
|
SetCustomShipData (StarShipPtr->RaceDescPtr, &shipData);
|
||||||
|
|
||||||
StarShipPtr->RaceDescPtr->ship_data.special[0] =
|
StarShipPtr->RaceDescPtr->ship_data.special[0] =
|
||||||
SetAbsFrameIndex (
|
SetAbsFrameIndex (
|
||||||
StarShipPtr->RaceDescPtr->ship_data.special[0],
|
StarShipPtr->RaceDescPtr->ship_data.special[0],
|
||||||
StarShipPtr->ShipFacing
|
StarShipPtr->ShipFacing);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MissileBlock.index = GetFrameIndex (StarShipPtr->RaceDescPtr->ship_data.special[0]);
|
MissileBlock.index = GetFrameIndex (StarShipPtr->RaceDescPtr->ship_data.special[0]);
|
||||||
@@ -341,7 +384,7 @@ umgah_preprocess (ELEMENT *ElementPtr)
|
|||||||
if (ElementPtr->state_flags & APPEARING)
|
if (ElementPtr->state_flags & APPEARING)
|
||||||
{
|
{
|
||||||
// Reset the value just in case
|
// Reset the value just in case
|
||||||
StarShipPtr->RaceDescPtr->data = 0;
|
SetCustomShipData (StarShipPtr->RaceDescPtr, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -366,11 +409,18 @@ umgah_preprocess (ELEMENT *ElementPtr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
uninit_umgah (RACE_DESC *pRaceDesc)
|
||||||
|
{
|
||||||
|
SetCustomShipData (pRaceDesc, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
RACE_DESC*
|
RACE_DESC*
|
||||||
init_umgah (void)
|
init_umgah (void)
|
||||||
{
|
{
|
||||||
RACE_DESC *RaceDescPtr;
|
RACE_DESC *RaceDescPtr;
|
||||||
|
|
||||||
|
umgah_desc.uninit_func = uninit_umgah;
|
||||||
umgah_desc.preprocess_func = umgah_preprocess;
|
umgah_desc.preprocess_func = umgah_preprocess;
|
||||||
umgah_desc.postprocess_func = umgah_postprocess;
|
umgah_desc.postprocess_func = umgah_postprocess;
|
||||||
umgah_desc.init_weapon_func = initialize_cone;
|
umgah_desc.init_weapon_func = initialize_cone;
|
||||||
|
|||||||
Reference in New Issue
Block a user