Moved some enum definitions into separate table files, to avoid potentially bug-inducing redundancy (because I'm going to add more of that).

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@4072 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2011-01-15 16:14:34 +00:00
parent 676ed097e9
commit a804bf350f
7 changed files with 135 additions and 200 deletions

View File

@ -38,7 +38,7 @@ ifeq ($(GNUSTEP_HOST_OS),mingw32)
JS_LIB_DIR =
JS_IMPORT_LIBRARY = js32
endif
ADDITIONAL_INCLUDE_DIRS = -Ideps/Windows-x86-deps/include -I$(JS_INCLUDE_DIR) -Isrc/SDL -Isrc/Core -Isrc/BSDCompat -Isrc/Core/Scripting -Isrc/Core/Materials -Isrc/Core/Entities -Isrc/Core/OXPVerifier -Isrc/Core/Debug
ADDITIONAL_INCLUDE_DIRS = -Ideps/Windows-x86-deps/include -I$(JS_INCLUDE_DIR) -Isrc/SDL -Isrc/Core -Isrc/BSDCompat -Isrc/Core/Scripting -Isrc/Core/Materials -Isrc/Core/Entities -Isrc/Core/OXPVerifier -Isrc/Core/Debug -Isrc/Core/Tables
ADDITIONAL_OBJC_LIBS = -lglu32 -lopengl32 -lpng14.dll -lmingw32 -lSDLmain -lSDL -lSDL_mixer -lgnustep-base -l$(JS_IMPORT_LIBRARY) -lwinmm -mwindows
ADDITIONAL_CFLAGS = -DWIN32 -DNEED_STRLCPY `sdl-config --cflags`
# note the vpath stuff above isn't working for me, so adding src/SDL and src/Core explicitly

View File

@ -1597,6 +1597,9 @@
1A3491290BC25EAA00802DA7 /* world-scripts.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = "world-scripts.plist"; sourceTree = "<group>"; };
1A3491AA0BC282DE00802DA7 /* ReleaseLockProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReleaseLockProxy.h; sourceTree = "<group>"; };
1A3491AB0BC282DE00802DA7 /* ReleaseLockProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReleaseLockProxy.m; sourceTree = "<group>"; };
1A35251112E1F89100244C9D /* OOEntityStatus.tbl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OOEntityStatus.tbl; sourceTree = "<group>"; };
1A35256012E1FC0100244C9D /* OOScanClass.tbl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OOScanClass.tbl; sourceTree = "<group>"; };
1A35256212E1FC0500244C9D /* OOBehaviour.tbl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = OOBehaviour.tbl; sourceTree = "<group>"; };
1A358CE10C1AB80D00E52220 /* ReadMe.rtfd */ = {isa = PBXFileReference; lastKnownFileType = wrapper.rtfd; name = ReadMe.rtfd; path = Doc/ReadMe.rtfd; sourceTree = SOURCE_ROOT; };
1A3591690C1C375400E52220 /* oolite-nebula-1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "oolite-nebula-1.png"; sourceTree = "<group>"; };
1A35916A0C1C375400E52220 /* oolite-star-1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "oolite-star-1.png"; sourceTree = "<group>"; };
@ -2501,6 +2504,16 @@
path = Scripts;
sourceTree = "<group>";
};
1A35251312E1F89700244C9D /* Tables */ = {
isa = PBXGroup;
children = (
1A35256212E1FC0500244C9D /* OOBehaviour.tbl */,
1A35251112E1F89100244C9D /* OOEntityStatus.tbl */,
1A35256012E1FC0100244C9D /* OOScanClass.tbl */,
);
path = Tables;
sourceTree = "<group>";
};
1A3E018F11C574AC000FF226 /* Products */ = {
isa = PBXGroup;
children = (
@ -2733,6 +2746,7 @@
1A8A3BE90B963F02007D20B8 /* Source */ = {
isa = PBXGroup;
children = (
1A35251312E1F89700244C9D /* Tables */,
1A8A3C0C0B963FF8007D20B8 /* Entities */,
1A8A3C0F0B964002007D20B8 /* AI */,
1A8A3C180B964030007D20B8 /* Resource Management */,
@ -3962,7 +3976,7 @@
OTHER_CFLAGS = "-DLOADSAVEGUIXX";
PRODUCT_NAME = Oolite;
SECTORDER_FLAGS = "";
USER_HEADER_SEARCH_PATHS = "\"$(DEPS_INCLUDE_PATH)/ogg\" \"$(DEPS_INCLUDE_PATH)/js\" \"$(DEPS_INCLUDE_PATH)/vorbis\" \"$(DEPS_INCLUDE_PATH)/png\" \"$(SRCROOT)/src/Core/\" \"$(SRCROOT)/src/Core/Entites/\" \"$(SRCROOT)/src/Core/Materials/\" \"$(SRCROOT)/src/BSDCompat/\"";
USER_HEADER_SEARCH_PATHS = "\"$(DEPS_INCLUDE_PATH)/ogg\" \"$(DEPS_INCLUDE_PATH)/js\" \"$(DEPS_INCLUDE_PATH)/vorbis\" \"$(DEPS_INCLUDE_PATH)/png\" \"$(SRCROOT)/src/Core/\" \"$(SRCROOT)/src/Core/Tables/\" \"$(SRCROOT)/src/Core/Entites/\" \"$(SRCROOT)/src/Core/Materials/\" \"$(SRCROOT)/src/BSDCompat/\"";
WARNING_CFLAGS = (
"-Wall",
"-Wextra",
@ -4009,7 +4023,7 @@
PREBINDING = NO;
PRODUCT_NAME = Oolite;
SECTORDER_FLAGS = "";
USER_HEADER_SEARCH_PATHS = "\"$(DEPS_INCLUDE_PATH)/ogg\" \"$(DEPS_INCLUDE_PATH)/js\" \"$(DEPS_INCLUDE_PATH)/vorbis\" \"$(DEPS_INCLUDE_PATH)/png\" \"$(SRCROOT)/src/Core/\" \"$(SRCROOT)/src/Core/Entites/\" \"$(SRCROOT)/src/Core/Materials/\" \"$(SRCROOT)/src/BSDCompat/\"";
USER_HEADER_SEARCH_PATHS = "\"$(DEPS_INCLUDE_PATH)/ogg\" \"$(DEPS_INCLUDE_PATH)/js\" \"$(DEPS_INCLUDE_PATH)/vorbis\" \"$(DEPS_INCLUDE_PATH)/png\" \"$(SRCROOT)/src/Core/\" \"$(SRCROOT)/src/Core/Tables/\" \"$(SRCROOT)/src/Core/Entites/\" \"$(SRCROOT)/src/Core/Materials/\" \"$(SRCROOT)/src/BSDCompat/\"";
WARNING_CFLAGS = (
"-Wall",
"-Wno-unused-parameter",
@ -4101,7 +4115,7 @@
PREBINDING = NO;
PRODUCT_NAME = Oolite;
SECTORDER_FLAGS = "";
USER_HEADER_SEARCH_PATHS = "\"$(DEPS_INCLUDE_PATH)/ogg\" \"$(DEPS_INCLUDE_PATH)/js\" \"$(DEPS_INCLUDE_PATH)/vorbis\" \"$(DEPS_INCLUDE_PATH)/png\" \"$(SRCROOT)/src/Core/\" \"$(SRCROOT)/src/Core/Entites/\" \"$(SRCROOT)/src/Core/Materials/\" \"$(SRCROOT)/src/BSDCompat/\"";
USER_HEADER_SEARCH_PATHS = "\"$(DEPS_INCLUDE_PATH)/ogg\" \"$(DEPS_INCLUDE_PATH)/js\" \"$(DEPS_INCLUDE_PATH)/vorbis\" \"$(DEPS_INCLUDE_PATH)/png\" \"$(SRCROOT)/src/Core/\" \"$(SRCROOT)/src/Core/Tables/\" \"$(SRCROOT)/src/Core/Entites/\" \"$(SRCROOT)/src/Core/Materials/\" \"$(SRCROOT)/src/BSDCompat/\"";
WARNING_CFLAGS = (
"-Wall",
"-Wno-unused-parameter",

View File

@ -32,107 +32,61 @@ MA );-);, USA.
#define REVERSE_CASE(foo) if ([string isEqualToString:@#foo]) return foo;
#define ENTRY(label, value) case label: return @#label;
NSString *EntityStatusToString(OOEntityStatus status)
{
switch (status)
{
CASE(STATUS_EFFECT);
CASE(STATUS_ACTIVE);
CASE(STATUS_COCKPIT_DISPLAY);
CASE(STATUS_TEST);
CASE(STATUS_INACTIVE);
CASE(STATUS_DEAD);
CASE(STATUS_START_GAME);
CASE(STATUS_IN_FLIGHT);
CASE(STATUS_DOCKED);
CASE(STATUS_AUTOPILOT_ENGAGED);
CASE(STATUS_DOCKING);
CASE(STATUS_LAUNCHING);
CASE(STATUS_WITCHSPACE_COUNTDOWN);
CASE(STATUS_ENTERING_WITCHSPACE);
CASE(STATUS_EXITING_WITCHSPACE);
CASE(STATUS_ESCAPE_SEQUENCE);
CASE(STATUS_IN_HOLD);
CASE(STATUS_BEING_SCOOPED);
CASE(STATUS_HANDLING_ERROR);
#include "OOEntityStatus.tbl"
}
return @"UNDEFINED";
}
OOEntityStatus StringToEntityStatus(NSString *string)
{
REVERSE_CASE(STATUS_EFFECT);
REVERSE_CASE(STATUS_ACTIVE);
REVERSE_CASE(STATUS_COCKPIT_DISPLAY);
REVERSE_CASE(STATUS_TEST);
REVERSE_CASE(STATUS_INACTIVE);
REVERSE_CASE(STATUS_DEAD);
REVERSE_CASE(STATUS_START_GAME);
REVERSE_CASE(STATUS_IN_FLIGHT);
REVERSE_CASE(STATUS_DOCKED);
REVERSE_CASE(STATUS_AUTOPILOT_ENGAGED);
REVERSE_CASE(STATUS_DOCKING);
REVERSE_CASE(STATUS_LAUNCHING);
REVERSE_CASE(STATUS_WITCHSPACE_COUNTDOWN);
REVERSE_CASE(STATUS_ENTERING_WITCHSPACE);
REVERSE_CASE(STATUS_EXITING_WITCHSPACE);
REVERSE_CASE(STATUS_ESCAPE_SEQUENCE);
REVERSE_CASE(STATUS_IN_HOLD);
REVERSE_CASE(STATUS_BEING_SCOOPED);
REVERSE_CASE(STATUS_HANDLING_ERROR);
return STATUS_INACTIVE;
}
NSString *ScanClassToString(OOScanClass scanClass)
{
switch (scanClass)
{
CASE(CLASS_NOT_SET);
CASE(CLASS_NO_DRAW);
CASE(CLASS_NEUTRAL);
CASE(CLASS_STATION);
CASE(CLASS_TARGET);
CASE(CLASS_CARGO);
CASE(CLASS_MISSILE);
CASE(CLASS_ROCK);
CASE(CLASS_MINE);
CASE(CLASS_THARGOID);
CASE(CLASS_BUOY);
CASE(CLASS_WORMHOLE);
CASE(CLASS_PLAYER);
CASE(CLASS_POLICE);
CASE(CLASS_MILITARY);
#include "OOScanClass.tbl"
}
return @"UNDEFINED";
}
NSString *BehaviourToString(OOBehaviour behaviour)
{
switch (behaviour)
{
#include "OOBehaviour.tbl"
}
return @"** BEHAVIOUR UNKNOWN **";
}
#undef ENTRY
#define ENTRY(label, value) if ([string isEqualToString:@#label]) return label;
OOEntityStatus StringToEntityStatus(NSString *string)
{
#include "OOEntityStatus.tbl"
return STATUS_INACTIVE;
}
OOScanClass StringToScanClass(NSString *string)
{
REVERSE_CASE(CLASS_NOT_SET);
REVERSE_CASE(CLASS_NO_DRAW);
REVERSE_CASE(CLASS_NEUTRAL);
REVERSE_CASE(CLASS_STATION);
REVERSE_CASE(CLASS_TARGET);
REVERSE_CASE(CLASS_CARGO);
REVERSE_CASE(CLASS_MISSILE);
REVERSE_CASE(CLASS_ROCK);
REVERSE_CASE(CLASS_MINE);
REVERSE_CASE(CLASS_THARGOID);
REVERSE_CASE(CLASS_BUOY);
REVERSE_CASE(CLASS_WORMHOLE);
REVERSE_CASE(CLASS_PLAYER);
REVERSE_CASE(CLASS_POLICE);
REVERSE_CASE(CLASS_MILITARY);
#include "OOScanClass.tbl"
return CLASS_NOT_SET;
}
#undef ENTRY
#ifdef OO_BRAIN_AI
NSString *InstinctToString(OOInstinctID instinct)
@ -166,45 +120,6 @@ OOInstinctID StringToInstinct(NSString *string)
#endif
NSString *BehaviourToString(OOBehaviour behaviour)
{
switch (behaviour)
{
CASE(BEHAVIOUR_IDLE);
CASE(BEHAVIOUR_TRACK_TARGET);
// CASE(BEHAVIOUR_FLY_TO_TARGET);
// CASE(BEHAVIOUR_HANDS_OFF);
CASE(BEHAVIOUR_TUMBLE);
CASE(BEHAVIOUR_STOP_STILL);
CASE(BEHAVIOUR_STATION_KEEPING);
CASE(BEHAVIOUR_ATTACK_TARGET);
CASE(BEHAVIOUR_ATTACK_FLY_TO_TARGET);
CASE(BEHAVIOUR_ATTACK_FLY_FROM_TARGET);
CASE(BEHAVIOUR_RUNNING_DEFENSE);
CASE(BEHAVIOUR_FLEE_TARGET);
CASE(BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX);
CASE(BEHAVIOUR_ATTACK_MINING_TARGET);
CASE(BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE);
CASE(BEHAVIOUR_AVOID_COLLISION);
CASE(BEHAVIOUR_TRACK_AS_TURRET);
CASE(BEHAVIOUR_FLY_RANGE_FROM_DESTINATION);
CASE(BEHAVIOUR_FLY_TO_DESTINATION);
CASE(BEHAVIOUR_FLY_FROM_DESTINATION);
CASE(BEHAVIOUR_FACE_DESTINATION);
CASE(BEHAVIOUR_COLLECT_TARGET);
CASE(BEHAVIOUR_INTERCEPT_TARGET);
// CASE(BEHAVIOUR_MISSILE_FLY_TO_TARGET);
CASE(BEHAVIOUR_FORMATION_FORM_UP);
CASE(BEHAVIOUR_FORMATION_BREAK);
CASE(BEHAVIOUR_ENERGY_BOMB_COUNTDOWN);
CASE(BEHAVIOUR_TRACTORED);
CASE(BEHAVIOUR_FLY_THRU_NAVPOINTS);
}
return @"** BEHAVIOUR UNKNOWN **";
}
NSString *ViewIDToString(OOViewID viewID)
{
switch (viewID)

View File

@ -31,50 +31,28 @@ MA 02110-1301, USA.
#define ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0])
#define ENTRY(label, value) label = value,
typedef enum
{
STATUS_EFFECT = 10,
STATUS_ACTIVE = 5,
STATUS_COCKPIT_DISPLAY = 2,
STATUS_TEST = 1,
STATUS_INACTIVE = 0,
STATUS_DEAD = -1,
STATUS_START_GAME = -10,
STATUS_IN_FLIGHT = 100,
STATUS_DOCKED = 200,
STATUS_AUTOPILOT_ENGAGED = 300,
STATUS_DOCKING = 401,
STATUS_LAUNCHING = 402,
STATUS_WITCHSPACE_COUNTDOWN = 410,
STATUS_ENTERING_WITCHSPACE = 411,
STATUS_EXITING_WITCHSPACE = 412,
STATUS_ESCAPE_SEQUENCE = 500,
STATUS_IN_HOLD = 600,
STATUS_BEING_SCOOPED = 700,
STATUS_HANDLING_ERROR = 999
#include "OOEntityStatus.tbl"
} OOEntityStatus;
typedef enum
{
CLASS_NOT_SET = -1,
CLASS_NO_DRAW = 0,
CLASS_NEUTRAL = 1,
CLASS_STATION = 3,
CLASS_TARGET = 4,
CLASS_CARGO = 5,
CLASS_MISSILE = 6,
CLASS_ROCK = 7,
CLASS_MINE = 8,
CLASS_THARGOID = 9,
CLASS_BUOY = 10,
CLASS_WORMHOLE = 444,
CLASS_PLAYER = 100,
CLASS_POLICE = 999,
CLASS_MILITARY = 333
#include "OOScanClass.tbl"
} OOScanClass;
typedef enum
{
#include "OOBehaviour.tbl"
} OOBehaviour;
#undef ENTRY
typedef enum
{
GALACTIC_HYPERSPACE_BEHAVIOUR_STANDARD,
@ -163,53 +141,6 @@ typedef enum
#define SHADERS_MIN SHADERS_OFF
typedef enum
{
BEHAVIOUR_IDLE = 0U,
BEHAVIOUR_TRACK_TARGET = 1,
BEHAVIOUR_TUMBLE = 4,
BEHAVIOUR_STOP_STILL = 5,
BEHAVIOUR_STATION_KEEPING = 10,
BEHAVIOUR_ATTACK_TARGET = 101,
BEHAVIOUR_ATTACK_FLY_TO_TARGET = 102,
BEHAVIOUR_ATTACK_FLY_FROM_TARGET = 103,
BEHAVIOUR_RUNNING_DEFENSE = 104,
// fleeing
BEHAVIOUR_FLEE_TARGET = 105,
// advanced combat...
BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX = 106,
BEHAVIOUR_ATTACK_MINING_TARGET = 107,
// further advanced combat...
BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE = 112,
BEHAVIOUR_AVOID_COLLISION = 130,
BEHAVIOUR_TRACK_AS_TURRET = 150,
BEHAVIOUR_FLY_RANGE_FROM_DESTINATION = 200,
BEHAVIOUR_FLY_TO_DESTINATION = 201,
BEHAVIOUR_FLY_FROM_DESTINATION = 202,
BEHAVIOUR_FACE_DESTINATION = 203,
BEHAVIOUR_FLY_THRU_NAVPOINTS = 210,
BEHAVIOUR_COLLECT_TARGET = 300,
BEHAVIOUR_INTERCEPT_TARGET = 350,
BEHAVIOUR_FORMATION_FORM_UP = 501,
BEHAVIOUR_FORMATION_BREAK = 502,
BEHAVIOUR_ENERGY_BOMB_COUNTDOWN = 601,
BEHAVIOUR_TRACTORED = 701
} OOBehaviour;
OOINLINE BOOL IsBehaviourHostile(OOBehaviour behaviour) INLINE_CONST_FUNC;
OOINLINE BOOL IsBehaviourHostile(OOBehaviour behaviour)
{

View File

@ -0,0 +1,41 @@
ENTRY(BEHAVIOUR_IDLE, 0U)
ENTRY(BEHAVIOUR_TRACK_TARGET, 1)
ENTRY(BEHAVIOUR_TUMBLE, 4)
ENTRY(BEHAVIOUR_STOP_STILL, 5)
ENTRY(BEHAVIOUR_STATION_KEEPING, 10)
ENTRY(BEHAVIOUR_ATTACK_TARGET, 101)
ENTRY(BEHAVIOUR_ATTACK_FLY_TO_TARGET, 102)
ENTRY(BEHAVIOUR_ATTACK_FLY_FROM_TARGET, 103)
ENTRY(BEHAVIOUR_RUNNING_DEFENSE, 104)
// fleeing
ENTRY(BEHAVIOUR_FLEE_TARGET, 105)
// advanced combat...
ENTRY(BEHAVIOUR_ATTACK_FLY_TO_TARGET_SIX, 106)
ENTRY(BEHAVIOUR_ATTACK_MINING_TARGET, 107)
// further advanced combat...
ENTRY(BEHAVIOUR_ATTACK_FLY_TO_TARGET_TWELVE,112)
ENTRY(BEHAVIOUR_AVOID_COLLISION, 130)
ENTRY(BEHAVIOUR_TRACK_AS_TURRET, 150)
ENTRY(BEHAVIOUR_FLY_RANGE_FROM_DESTINATION, 200)
ENTRY(BEHAVIOUR_FLY_TO_DESTINATION, 201)
ENTRY(BEHAVIOUR_FLY_FROM_DESTINATION, 202)
ENTRY(BEHAVIOUR_FACE_DESTINATION, 203)
ENTRY(BEHAVIOUR_FLY_THRU_NAVPOINTS, 210)
ENTRY(BEHAVIOUR_COLLECT_TARGET, 300)
ENTRY(BEHAVIOUR_INTERCEPT_TARGET, 350)
ENTRY(BEHAVIOUR_FORMATION_FORM_UP, 501)
ENTRY(BEHAVIOUR_FORMATION_BREAK, 502)
ENTRY(BEHAVIOUR_ENERGY_BOMB_COUNTDOWN, 601)
ENTRY(BEHAVIOUR_TRACTORED, 701)

View File

@ -0,0 +1,19 @@
ENTRY(STATUS_START_GAME, -10)
ENTRY(STATUS_DEAD, -1)
ENTRY(STATUS_INACTIVE, 0)
ENTRY(STATUS_TEST, 1)
ENTRY(STATUS_COCKPIT_DISPLAY, 2)
ENTRY(STATUS_ACTIVE, 5)
ENTRY(STATUS_EFFECT, 10)
ENTRY(STATUS_IN_FLIGHT, 100)
ENTRY(STATUS_DOCKED, 200)
ENTRY(STATUS_AUTOPILOT_ENGAGED, 300)
ENTRY(STATUS_DOCKING, 401)
ENTRY(STATUS_LAUNCHING, 402)
ENTRY(STATUS_WITCHSPACE_COUNTDOWN, 410)
ENTRY(STATUS_ENTERING_WITCHSPACE, 411)
ENTRY(STATUS_EXITING_WITCHSPACE, 412)
ENTRY(STATUS_ESCAPE_SEQUENCE, 500)
ENTRY(STATUS_IN_HOLD, 600)
ENTRY(STATUS_BEING_SCOOPED, 700)
ENTRY(STATUS_HANDLING_ERROR, 999)

View File

@ -0,0 +1,15 @@
ENTRY(CLASS_NOT_SET, -1)
ENTRY(CLASS_NO_DRAW, 0)
ENTRY(CLASS_NEUTRAL, 1)
ENTRY(CLASS_STATION, 3)
ENTRY(CLASS_TARGET, 4)
ENTRY(CLASS_CARGO, 5)
ENTRY(CLASS_MISSILE, 6)
ENTRY(CLASS_ROCK, 7)
ENTRY(CLASS_MINE, 8)
ENTRY(CLASS_THARGOID, 9)
ENTRY(CLASS_BUOY, 10)
ENTRY(CLASS_WORMHOLE, 444)
ENTRY(CLASS_PLAYER, 100)
ENTRY(CLASS_POLICE, 999)
ENTRY(CLASS_MILITARY, 333)