Fix crash on calling getDroidOrderName(DORDER_TEMP_HOLD) or on invalid orders.
Fixes ticket:2461.master
parent
3137d042ea
commit
3b266356c0
|
@ -4209,52 +4209,49 @@ void orderStructureObj(UDWORD player, BASE_OBJECT *psObj)
|
|||
|
||||
const char* getDroidOrderName(DROID_ORDER order)
|
||||
{
|
||||
static const char* name[] =
|
||||
switch (order)
|
||||
{
|
||||
"DORDER_NONE", // no order set
|
||||
"DORDER_STOP", // stop the current order
|
||||
"DORDER_MOVE", // 2 - move to a location
|
||||
"DORDER_ATTACK", // attack an enemy
|
||||
"DORDER_BUILD", // 4 - build a structure
|
||||
"DORDER_HELPBUILD", // help to build a structure
|
||||
"DORDER_LINEBUILD", // 6 - build a number of structures in a row (walls + bridges)
|
||||
"DORDER_DEMOLISH", // demolish a structure
|
||||
"DORDER_REPAIR", // 8 - repair a structure
|
||||
"DORDER_OBSERVE", // keep a target in sensor view
|
||||
"DORDER_FIRESUPPORT", // 10 - attack whatever the linked sensor droid attacks
|
||||
"DORDER_RETREAT", // return to the players retreat position
|
||||
"DORDER_DESTRUCT", // 12 - self destruct
|
||||
"DORDER_RTB", // return to base
|
||||
"DORDER_RTR", // 14 - return to repair at any repair facility
|
||||
"DORDER_RUN", // run away after moral failure
|
||||
"DORDER_EMBARK", // 16 - board a transporter
|
||||
"DORDER_DISEMBARK", // get off a transporter
|
||||
"DORDER_ATTACKTARGET", // 18 - a suggestion to attack something
|
||||
// i.e. the target was chosen because the droid could see it
|
||||
"DORDER_COMMANDERSUPPORT",
|
||||
"DORDER_BUILDMODULE", // 20 - build a module (power, research or factory)
|
||||
"DORDER_RECYCLE", // return to factory to be recycled
|
||||
"DORDER_TRANSPORTOUT", // 22 - offworld transporter order
|
||||
"DORDER_TRANSPORTIN", // onworld transporter order
|
||||
"DORDER_TRANSPORTRETURN", // 24 - transporter return after unloading
|
||||
"DORDER_GUARD", // guard a structure
|
||||
"DORDER_DROIDREPAIR", // 26 - repair a droid
|
||||
"DORDER_RESTORE", // restore resistance points for a structure
|
||||
"DORDER_SCOUT", // 28 - same as move, but stop if an enemy is seen
|
||||
"DORDER_RUNBURN", // run away on fire
|
||||
"DORDER_CLEARWRECK", // 30 - constructor droid to clear up building wreckage
|
||||
"DORDER_PATROL", // move between two way points
|
||||
"DORDER_REARM", // 32 - order a vtol to rearming pad
|
||||
"DORDER_RECOVER", // pick up an artifact
|
||||
"DORDER_LEAVEMAP", // 36 - vtol flying off the map
|
||||
"DORDER_RTR_SPECIFIED", // return to repair at a specified repair center
|
||||
"DORDER_UNDEFINED",
|
||||
"DORDER_UNDEFINED2",
|
||||
"DORDER_CIRCLE", // circles target location and engage
|
||||
"DORDER_TEMP_HOLD" // do nothing until given next order
|
||||
case DORDER_NONE: return "DORDER_NONE";
|
||||
case DORDER_STOP: return "DORDER_STOP";
|
||||
case DORDER_MOVE: return "DORDER_MOVE";
|
||||
case DORDER_ATTACK: return "DORDER_ATTACK";
|
||||
case DORDER_BUILD: return "DORDER_BUILD";
|
||||
case DORDER_HELPBUILD: return "DORDER_HELPBUILD";
|
||||
case DORDER_LINEBUILD: return "DORDER_LINEBUILD";
|
||||
case DORDER_DEMOLISH: return "DORDER_DEMOLISH";
|
||||
case DORDER_REPAIR: return "DORDER_REPAIR";
|
||||
case DORDER_OBSERVE: return "DORDER_OBSERVE";
|
||||
case DORDER_FIRESUPPORT: return "DORDER_FIRESUPPORT";
|
||||
case DORDER_RETREAT: return "DORDER_RETREAT";
|
||||
case DORDER_DESTRUCT: return "DORDER_DESTRUCT";
|
||||
case DORDER_RTB: return "DORDER_RTB";
|
||||
case DORDER_RTR: return "DORDER_RTR";
|
||||
case DORDER_RUN: return "DORDER_RUN";
|
||||
case DORDER_EMBARK: return "DORDER_EMBARK";
|
||||
case DORDER_DISEMBARK: return "DORDER_DISEMBARK";
|
||||
case DORDER_ATTACKTARGET: return "DORDER_ATTACKTARGET";
|
||||
case DORDER_COMMANDERSUPPORT: return "DORDER_COMMANDERSUPPORT";
|
||||
case DORDER_BUILDMODULE: return "DORDER_BUILDMODULE";
|
||||
case DORDER_RECYCLE: return "DORDER_RECYCLE";
|
||||
case DORDER_TRANSPORTOUT: return "DORDER_TRANSPORTOUT";
|
||||
case DORDER_TRANSPORTIN: return "DORDER_TRANSPORTIN";
|
||||
case DORDER_TRANSPORTRETURN: return "DORDER_TRANSPORTRETURN";
|
||||
case DORDER_GUARD: return "DORDER_GUARD";
|
||||
case DORDER_DROIDREPAIR: return "DORDER_DROIDREPAIR";
|
||||
case DORDER_RESTORE: return "DORDER_RESTORE";
|
||||
case DORDER_SCOUT: return "DORDER_SCOUT";
|
||||
case DORDER_RUNBURN: return "DORDER_RUNBURN";
|
||||
case DORDER_CLEARWRECK: return "DORDER_CLEARWRECK";
|
||||
case DORDER_PATROL: return "DORDER_PATROL";
|
||||
case DORDER_REARM: return "DORDER_REARM";
|
||||
case DORDER_RECOVER: return "DORDER_RECOVER";
|
||||
case DORDER_LEAVEMAP: return "DORDER_LEAVEMAP";
|
||||
case DORDER_RTR_SPECIFIED: return "DORDER_RTR_SPECIFIED";
|
||||
case DORDER_CIRCLE: return "DORDER_CIRCLE";
|
||||
case DORDER_TEMP_HOLD: return "DORDER_TEMP_HOLD";
|
||||
};
|
||||
|
||||
ASSERT(order < sizeof(name) / sizeof(name[0]), "DROID_ORDER out of range: %u", order);
|
||||
ASSERT(false, "DROID_ORDER out of range: %u", order);
|
||||
|
||||
return name[order];
|
||||
return "DORDER_#INVALID#";
|
||||
}
|
||||
|
|
|
@ -83,8 +83,8 @@ extern void orderSelectedObj(UDWORD player, BASE_OBJECT *psObj);
|
|||
extern void orderSelectedObjAdd(UDWORD player, BASE_OBJECT *psObj, BOOL add);
|
||||
|
||||
// add an order to a droids order list
|
||||
extern void orderDroidAdd(DROID *psDroid, struct _droid_order_data *psOrder);
|
||||
void orderDroidAddPending(DROID *psDroid, struct _droid_order_data *psOrder);
|
||||
void orderDroidAdd(DROID *psDroid, DROID_ORDER_DATA *psOrder);
|
||||
void orderDroidAddPending(DROID *psDroid, DROID_ORDER_DATA *psOrder);
|
||||
// do the next order from a droids order list
|
||||
extern BOOL orderDroidList(DROID *psDroid);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "basedef.h"
|
||||
|
||||
// The droid orders
|
||||
typedef enum _droid_order
|
||||
enum DROID_ORDER
|
||||
{
|
||||
DORDER_NONE, // no order set
|
||||
|
||||
|
@ -67,14 +67,14 @@ typedef enum _droid_order
|
|||
DORDER_PATROL, // move between two way points
|
||||
DORDER_REARM, // 32 - order a vtol to rearming pad
|
||||
DORDER_RECOVER, // pick up an artifact
|
||||
DORDER_LEAVEMAP, // 36 - vtol flying off the map
|
||||
DORDER_LEAVEMAP, // 34 - vtol flying off the map
|
||||
DORDER_RTR_SPECIFIED, // return to repair at a specified repair center
|
||||
DORDER_CIRCLE = 40, // circles target location and engage
|
||||
DORDER_TEMP_HOLD, // hold position until given next order
|
||||
} DROID_ORDER;
|
||||
};
|
||||
|
||||
// secondary orders for droids
|
||||
typedef enum _secondary_order
|
||||
enum SECONDARY_ORDER
|
||||
{
|
||||
DSO_ATTACK_RANGE,
|
||||
DSO_REPAIR_LEVEL,
|
||||
|
@ -89,10 +89,10 @@ typedef enum _secondary_order
|
|||
DSO_FIRE_DESIGNATOR, // command droid controlling IDF structures
|
||||
DSO_ASSIGN_VTOL_PRODUCTION,
|
||||
DSO_CIRCLE, // circling target position and engage
|
||||
} SECONDARY_ORDER;
|
||||
};
|
||||
|
||||
// the state of secondary orders
|
||||
typedef enum _secondary_state
|
||||
enum SECONDARY_STATE
|
||||
{
|
||||
DSS_NONE = 0x000000,
|
||||
DSS_ARANGE_SHORT = 0x000001,
|
||||
|
@ -117,7 +117,7 @@ typedef enum _secondary_state
|
|||
DSS_PATROL_SET = 0x400000,
|
||||
DSS_CIRCLE_SET = 0x400100,
|
||||
DSS_FIREDES_SET = 0x800000,
|
||||
} SECONDARY_STATE;
|
||||
};
|
||||
|
||||
// masks for the secondary order state
|
||||
#define DSS_ARANGE_MASK 0x000003
|
||||
|
@ -138,15 +138,15 @@ typedef enum _secondary_state
|
|||
#define DSS_CIRCLE_MASK 0x400100
|
||||
|
||||
// data for barbarians retreating
|
||||
typedef struct _run_data
|
||||
struct RUN_DATA
|
||||
{
|
||||
Vector2i sPos; // position to retreat to
|
||||
uint8_t forceLevel; // number of units below which might run
|
||||
uint8_t healthLevel; // %health value below which to turn and run - FOR GROUPS ONLY
|
||||
uint8_t leadership; // basic chance to run
|
||||
} RUN_DATA;
|
||||
};
|
||||
|
||||
typedef struct _droid_order_data
|
||||
struct DROID_ORDER_DATA
|
||||
{
|
||||
DROID_ORDER order;
|
||||
UWORD x,y;
|
||||
|
@ -154,6 +154,6 @@ typedef struct _droid_order_data
|
|||
uint16_t direction;
|
||||
BASE_OBJECT *psObj;
|
||||
BASE_STATS *psStats;
|
||||
} DROID_ORDER_DATA;
|
||||
};
|
||||
|
||||
#endif // __INCLUDED_SRC_ORDERDEF_H__
|
||||
|
|
Loading…
Reference in New Issue