Move SUBMODE/SUB_FLAGS out of ai_static::flags
This commit is contained in:
parent
db90f0df62
commit
1f00d716de
|
@ -174,17 +174,12 @@ enum class ai_mode : uint8_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Constants defining meaning of flags in ai_state
|
// Constants defining meaning of flags in ai_state
|
||||||
#define MAX_AI_FLAGS 5 // This MUST cause word (4 bytes) alignment in ai_static, allowing for one byte mode
|
#define MAX_AI_FLAGS 4 // This MUST cause word (4 bytes) alignment in ai_static, allowing for one byte mode
|
||||||
|
|
||||||
#define CURRENT_GUN flags[0] // This is the last gun the object fired from
|
#define CURRENT_GUN flags[0] // This is the last gun the object fired from
|
||||||
#define CURRENT_STATE flags[1] // current behavioral state
|
#define CURRENT_STATE flags[1] // current behavioral state
|
||||||
#define GOAL_STATE flags[2] // goal state
|
#define GOAL_STATE flags[2] // goal state
|
||||||
#define PATH_DIR flags[3] // direction traveling path, 1 = forward, -1 = backward, other = error!
|
#define PATH_DIR flags[3] // direction traveling path, 1 = forward, -1 = backward, other = error!
|
||||||
#if defined(DXX_BUILD_DESCENT_I)
|
|
||||||
#define SUBMODE flags[4] // submode, eg AISM_HIDING if mode == AIM_HIDE
|
|
||||||
#elif defined(DXX_BUILD_DESCENT_II)
|
|
||||||
#define SUB_FLAGS flags[4] // bit 0: Set -> Robot's current gun in different segment than robot's center.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This is the stuff that is permanent for an AI object.
|
// This is the stuff that is permanent for an AI object.
|
||||||
#ifdef dsx
|
#ifdef dsx
|
||||||
|
@ -221,6 +216,11 @@ struct ai_static : public prohibit_void_ptr<ai_static>
|
||||||
{
|
{
|
||||||
ai_behavior behavior = static_cast<ai_behavior>(0); //
|
ai_behavior behavior = static_cast<ai_behavior>(0); //
|
||||||
std::array<sbyte, MAX_AI_FLAGS> flags{}; // various flags, meaning defined by constants
|
std::array<sbyte, MAX_AI_FLAGS> flags{}; // various flags, meaning defined by constants
|
||||||
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
|
int8_t SUBMODE; // submode, eg AISM_HIDING if mode == AIM_HIDE
|
||||||
|
#elif defined(DXX_BUILD_DESCENT_II)
|
||||||
|
int8_t SUB_FLAGS; // bit 0: Set -> Robot's current gun in different segment than robot's center.
|
||||||
|
#endif
|
||||||
int8_t GOALSIDE; // for guys who open doors, this is the side they are going after.
|
int8_t GOALSIDE; // for guys who open doors, this is the side they are going after.
|
||||||
int8_t CLOAKED{}; // Cloaked now.
|
int8_t CLOAKED{}; // Cloaked now.
|
||||||
int8_t SKIP_AI_COUNT{}; // Skip AI this frame, but decrement in do_ai_frame.
|
int8_t SKIP_AI_COUNT{}; // Skip AI this frame, but decrement in do_ai_frame.
|
||||||
|
@ -247,7 +247,7 @@ struct ai_static : public prohibit_void_ptr<ai_static>
|
||||||
struct ai_static_rw
|
struct ai_static_rw
|
||||||
{
|
{
|
||||||
ubyte behavior; //
|
ubyte behavior; //
|
||||||
int8_t flags[MAX_AI_FLAGS + 6]; // various flags, meaning defined by constants
|
int8_t flags[MAX_AI_FLAGS + 7]; // various flags, meaning defined by constants
|
||||||
short hide_segment; // Segment to go to for hiding.
|
short hide_segment; // Segment to go to for hiding.
|
||||||
short hide_index; // Index in Path_seg_points
|
short hide_index; // Index in Path_seg_points
|
||||||
short path_length; // Length of hide path.
|
short path_length; // Length of hide path.
|
||||||
|
|
|
@ -484,7 +484,12 @@ static void read_object(const vmobjptr_t obj,PHYSFS_File *f,int version)
|
||||||
i = PHYSFSX_readByte(f);
|
i = PHYSFSX_readByte(f);
|
||||||
|
|
||||||
std::array<int8_t, 11> ai_info_flags{};
|
std::array<int8_t, 11> ai_info_flags{};
|
||||||
PHYSFS_read(f, &ai_info_flags[5], 1, 6);
|
PHYSFS_read(f, &ai_info_flags[4], 1, 7);
|
||||||
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
|
obj->ctype.ai_info.SUBMODE = ai_info_flags[4];
|
||||||
|
#elif defined(DXX_BUILD_DESCENT_II)
|
||||||
|
obj->ctype.ai_info.SUB_FLAGS = ai_info_flags[4];
|
||||||
|
#endif
|
||||||
obj->ctype.ai_info.GOALSIDE = ai_info_flags[5];
|
obj->ctype.ai_info.GOALSIDE = ai_info_flags[5];
|
||||||
obj->ctype.ai_info.CLOAKED = ai_info_flags[6];
|
obj->ctype.ai_info.CLOAKED = ai_info_flags[6];
|
||||||
obj->ctype.ai_info.SKIP_AI_COUNT = ai_info_flags[7];
|
obj->ctype.ai_info.SKIP_AI_COUNT = ai_info_flags[7];
|
||||||
|
@ -746,12 +751,17 @@ static void write_object(const object &obj, short version, PHYSFS_File *f)
|
||||||
PHYSFSX_writeU8(f, i);
|
PHYSFSX_writeU8(f, i);
|
||||||
|
|
||||||
std::array<int8_t, 11> ai_info_flags{};
|
std::array<int8_t, 11> ai_info_flags{};
|
||||||
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
|
ai_info_flags[4] = obj.ctype.ai_info.SUBMODE;
|
||||||
|
#elif defined(DXX_BUILD_DESCENT_II)
|
||||||
|
ai_info_flags[4] = obj.ctype.ai_info.SUB_FLAGS;
|
||||||
|
#endif
|
||||||
ai_info_flags[5] = obj.ctype.ai_info.GOALSIDE;
|
ai_info_flags[5] = obj.ctype.ai_info.GOALSIDE;
|
||||||
ai_info_flags[6] = obj.ctype.ai_info.CLOAKED;
|
ai_info_flags[6] = obj.ctype.ai_info.CLOAKED;
|
||||||
ai_info_flags[7] = obj.ctype.ai_info.SKIP_AI_COUNT;
|
ai_info_flags[7] = obj.ctype.ai_info.SKIP_AI_COUNT;
|
||||||
ai_info_flags[8] = obj.ctype.ai_info.REMOTE_OWNER;
|
ai_info_flags[8] = obj.ctype.ai_info.REMOTE_OWNER;
|
||||||
ai_info_flags[9] = obj.ctype.ai_info.REMOTE_SLOT_NUM;
|
ai_info_flags[9] = obj.ctype.ai_info.REMOTE_SLOT_NUM;
|
||||||
PHYSFS_write(f, &ai_info_flags[5], 1, 6);
|
PHYSFS_write(f, &ai_info_flags[4], 1, 7);
|
||||||
PHYSFS_writeSLE16(f, obj.ctype.ai_info.hide_segment);
|
PHYSFS_writeSLE16(f, obj.ctype.ai_info.hide_segment);
|
||||||
PHYSFS_writeSLE16(f, obj.ctype.ai_info.hide_index);
|
PHYSFS_writeSLE16(f, obj.ctype.ai_info.hide_index);
|
||||||
PHYSFS_writeSLE16(f, obj.ctype.ai_info.path_length);
|
PHYSFS_writeSLE16(f, obj.ctype.ai_info.path_length);
|
||||||
|
|
|
@ -5996,6 +5996,11 @@ void multi_object_to_object_rw(const object &obj, object_rw *obj_rw)
|
||||||
obj_rw->ctype.ai_info.behavior = static_cast<uint8_t>(obj.ctype.ai_info.behavior);
|
obj_rw->ctype.ai_info.behavior = static_cast<uint8_t>(obj.ctype.ai_info.behavior);
|
||||||
for (i = 0; i < MAX_AI_FLAGS; i++)
|
for (i = 0; i < MAX_AI_FLAGS; i++)
|
||||||
obj_rw->ctype.ai_info.flags[i] = obj.ctype.ai_info.flags[i];
|
obj_rw->ctype.ai_info.flags[i] = obj.ctype.ai_info.flags[i];
|
||||||
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
|
obj_rw->ctype.ai_info.flags[4] = obj.ctype.ai_info.SUBMODE;
|
||||||
|
#elif defined(DXX_BUILD_DESCENT_II)
|
||||||
|
obj_rw->ctype.ai_info.flags[4] = obj.ctype.ai_info.SUB_FLAGS;
|
||||||
|
#endif
|
||||||
obj_rw->ctype.ai_info.flags[5] = obj.ctype.ai_info.GOALSIDE;
|
obj_rw->ctype.ai_info.flags[5] = obj.ctype.ai_info.GOALSIDE;
|
||||||
obj_rw->ctype.ai_info.flags[6] = obj.ctype.ai_info.CLOAKED;
|
obj_rw->ctype.ai_info.flags[6] = obj.ctype.ai_info.CLOAKED;
|
||||||
obj_rw->ctype.ai_info.flags[7] = obj.ctype.ai_info.SKIP_AI_COUNT;
|
obj_rw->ctype.ai_info.flags[7] = obj.ctype.ai_info.SKIP_AI_COUNT;
|
||||||
|
@ -6183,6 +6188,11 @@ void multi_object_rw_to_object(const object_rw *const obj_rw, object &obj)
|
||||||
obj.ctype.ai_info.behavior = static_cast<ai_behavior>(obj_rw->ctype.ai_info.behavior);
|
obj.ctype.ai_info.behavior = static_cast<ai_behavior>(obj_rw->ctype.ai_info.behavior);
|
||||||
for (i = 0; i < MAX_AI_FLAGS; i++)
|
for (i = 0; i < MAX_AI_FLAGS; i++)
|
||||||
obj.ctype.ai_info.flags[i] = obj_rw->ctype.ai_info.flags[i];
|
obj.ctype.ai_info.flags[i] = obj_rw->ctype.ai_info.flags[i];
|
||||||
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
|
obj.ctype.ai_info.SUBMODE = obj_rw->ctype.ai_info.flags[4];
|
||||||
|
#elif defined(DXX_BUILD_DESCENT_II)
|
||||||
|
obj.ctype.ai_info.SUB_FLAGS = obj_rw->ctype.ai_info.flags[4];
|
||||||
|
#endif
|
||||||
obj.ctype.ai_info.GOALSIDE = obj_rw->ctype.ai_info.flags[5];
|
obj.ctype.ai_info.GOALSIDE = obj_rw->ctype.ai_info.flags[5];
|
||||||
obj.ctype.ai_info.CLOAKED = obj_rw->ctype.ai_info.flags[6];
|
obj.ctype.ai_info.CLOAKED = obj_rw->ctype.ai_info.flags[6];
|
||||||
obj.ctype.ai_info.SKIP_AI_COUNT = obj_rw->ctype.ai_info.flags[7];
|
obj.ctype.ai_info.SKIP_AI_COUNT = obj_rw->ctype.ai_info.flags[7];
|
||||||
|
|
|
@ -401,6 +401,11 @@ static void state_object_to_object_rw(const object &obj, object_rw *const obj_rw
|
||||||
obj_rw->ctype.ai_info.behavior = static_cast<uint8_t>(obj.ctype.ai_info.behavior);
|
obj_rw->ctype.ai_info.behavior = static_cast<uint8_t>(obj.ctype.ai_info.behavior);
|
||||||
for (i = 0; i < MAX_AI_FLAGS; i++)
|
for (i = 0; i < MAX_AI_FLAGS; i++)
|
||||||
obj_rw->ctype.ai_info.flags[i] = obj.ctype.ai_info.flags[i];
|
obj_rw->ctype.ai_info.flags[i] = obj.ctype.ai_info.flags[i];
|
||||||
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
|
obj_rw->ctype.ai_info.flags[4] = obj.ctype.ai_info.SUBMODE;
|
||||||
|
#elif defined(DXX_BUILD_DESCENT_II)
|
||||||
|
obj_rw->ctype.ai_info.flags[4] = obj.ctype.ai_info.SUB_FLAGS;
|
||||||
|
#endif
|
||||||
obj_rw->ctype.ai_info.flags[5] = obj.ctype.ai_info.GOALSIDE;
|
obj_rw->ctype.ai_info.flags[5] = obj.ctype.ai_info.GOALSIDE;
|
||||||
obj_rw->ctype.ai_info.flags[6] = obj.ctype.ai_info.CLOAKED;
|
obj_rw->ctype.ai_info.flags[6] = obj.ctype.ai_info.CLOAKED;
|
||||||
obj_rw->ctype.ai_info.flags[7] = obj.ctype.ai_info.SKIP_AI_COUNT;
|
obj_rw->ctype.ai_info.flags[7] = obj.ctype.ai_info.SKIP_AI_COUNT;
|
||||||
|
@ -600,6 +605,11 @@ static void state_object_rw_to_object(const object_rw *const obj_rw, object &obj
|
||||||
obj.ctype.ai_info.behavior = static_cast<ai_behavior>(obj_rw->ctype.ai_info.behavior);
|
obj.ctype.ai_info.behavior = static_cast<ai_behavior>(obj_rw->ctype.ai_info.behavior);
|
||||||
for (i = 0; i < MAX_AI_FLAGS; i++)
|
for (i = 0; i < MAX_AI_FLAGS; i++)
|
||||||
obj.ctype.ai_info.flags[i] = obj_rw->ctype.ai_info.flags[i];
|
obj.ctype.ai_info.flags[i] = obj_rw->ctype.ai_info.flags[i];
|
||||||
|
#if defined(DXX_BUILD_DESCENT_I)
|
||||||
|
obj.ctype.ai_info.SUBMODE = obj_rw->ctype.ai_info.flags[4];
|
||||||
|
#elif defined(DXX_BUILD_DESCENT_II)
|
||||||
|
obj.ctype.ai_info.SUB_FLAGS = obj_rw->ctype.ai_info.flags[4];
|
||||||
|
#endif
|
||||||
obj.ctype.ai_info.GOALSIDE = obj_rw->ctype.ai_info.flags[5];
|
obj.ctype.ai_info.GOALSIDE = obj_rw->ctype.ai_info.flags[5];
|
||||||
obj.ctype.ai_info.CLOAKED = obj_rw->ctype.ai_info.flags[6];
|
obj.ctype.ai_info.CLOAKED = obj_rw->ctype.ai_info.flags[6];
|
||||||
obj.ctype.ai_info.SKIP_AI_COUNT = obj_rw->ctype.ai_info.flags[7];
|
obj.ctype.ai_info.SKIP_AI_COUNT = obj_rw->ctype.ai_info.flags[7];
|
||||||
|
|
Loading…
Reference in a new issue