mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-23 03:58:59 +00:00
Merge pull request #179 from winterheart/checksum-unittests
Checksum unittests and Osiris types unification
This commit is contained in:
commit
6d91c381f8
@ -35,6 +35,14 @@ if(CMAKE_CXX_BYTE_ORDER STREQUAL "BIG_ENDIAN")
|
||||
add_compile_definitions("OUTRAGE_BIG_ENDIAN")
|
||||
endif()
|
||||
|
||||
|
||||
# 64 bit machines have a different game checksum than 32 bit machines
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_definitions(-DCHECKSUM=2273889835UL)
|
||||
else()
|
||||
add_definitions(-DCHECKSUM=2273873307UL)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
find_package(GTest REQUIRED)
|
||||
enable_testing()
|
||||
|
@ -310,3 +310,7 @@ endif()
|
||||
if(WIN32)
|
||||
set_target_properties(Descent3 PROPERTIES WIN32_EXECUTABLE ON)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
@ -81,6 +81,8 @@
|
||||
#ifndef __GAMECINEMATICS_EXTERNAL_H_
|
||||
#define __GAMECINEMATICS_EXTERNAL_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "vecmat_external.h"
|
||||
#include "manage_external.h"
|
||||
|
||||
@ -95,7 +97,7 @@
|
||||
#define CANNED_LEVEL_END_FADE_WHITE 5 // fade the screen to white and end level
|
||||
|
||||
typedef struct {
|
||||
int type;
|
||||
int32_t type;
|
||||
/*
|
||||
CANNED_LEVEL_INTRO:
|
||||
camera_pathid
|
||||
@ -130,17 +132,17 @@ typedef struct {
|
||||
text_to_display
|
||||
*/
|
||||
|
||||
int camera_pathid;
|
||||
int target_pathid;
|
||||
int32_t camera_pathid;
|
||||
int32_t target_pathid;
|
||||
char *text_to_display;
|
||||
|
||||
int target_objhandle;
|
||||
int32_t target_objhandle;
|
||||
|
||||
int room;
|
||||
int32_t room;
|
||||
|
||||
float time;
|
||||
|
||||
int object_to_use_for_point;
|
||||
int32_t object_to_use_for_point;
|
||||
|
||||
vector pos;
|
||||
matrix orient;
|
||||
@ -194,18 +196,18 @@ typedef struct {
|
||||
} PercentageRange;
|
||||
|
||||
typedef struct {
|
||||
unsigned int flags;
|
||||
uint32_t flags;
|
||||
|
||||
int target_objhandle;
|
||||
int32_t target_objhandle;
|
||||
|
||||
int end_transition;
|
||||
int start_transition;
|
||||
int32_t end_transition;
|
||||
int32_t start_transition;
|
||||
|
||||
// the name of the path or the position that the camera should be at
|
||||
int pathid;
|
||||
int32_t pathid;
|
||||
vector position;
|
||||
matrix *orient;
|
||||
int room;
|
||||
int32_t room;
|
||||
|
||||
// the total time that the cinematic should play
|
||||
float max_time_play;
|
||||
|
@ -91,7 +91,8 @@
|
||||
* $NoKeywords: $
|
||||
*/
|
||||
|
||||
#include "pstypes.h"
|
||||
#include <cstdint>
|
||||
|
||||
#include "vecmat_external.h"
|
||||
#include "robotfirestruct.h"
|
||||
|
||||
@ -134,20 +135,20 @@
|
||||
|
||||
// lighting info
|
||||
typedef struct {
|
||||
int flags; // see above
|
||||
int32_t flags; // see above
|
||||
float light_distance;
|
||||
float red_light1, green_light1, blue_light1;
|
||||
float red_light2, green_light2, blue_light2;
|
||||
float time_interval;
|
||||
float flicker_distance;
|
||||
float directional_dot;
|
||||
int timebits;
|
||||
ubyte angle;
|
||||
ubyte lighting_render_type;
|
||||
int32_t timebits;
|
||||
uint8_t angle;
|
||||
uint8_t lighting_render_type;
|
||||
} light_info;
|
||||
|
||||
typedef struct {
|
||||
int type_flags; // see EF_FLAGS above
|
||||
int32_t type_flags; // see EF_FLAGS above
|
||||
|
||||
float alpha; // alpha value
|
||||
float deform_range; // how many units to deform when drawing
|
||||
@ -163,15 +164,15 @@ typedef struct {
|
||||
float damage_time;
|
||||
float damage_per_second; // how much damage this object takes per second
|
||||
float last_damage_time; // last time this object took damage
|
||||
int damage_handle; // the object handle of the owner of the damage
|
||||
int32_t damage_handle; // the object handle of the owner of the damage
|
||||
|
||||
float volume_change_time;
|
||||
vector volume_old_pos;
|
||||
int volume_old_room;
|
||||
int32_t volume_old_room;
|
||||
|
||||
// For powerups only
|
||||
float last_object_hit_time;
|
||||
int last_object_hit;
|
||||
int32_t last_object_hit;
|
||||
|
||||
// For specular lighting
|
||||
vector spec_pos;
|
||||
@ -179,21 +180,21 @@ typedef struct {
|
||||
float spec_r, spec_g, spec_b;
|
||||
|
||||
// For dynamic volume lighting
|
||||
ubyte dynamic_this_frame;
|
||||
uint8_t dynamic_this_frame;
|
||||
float dynamic_red, dynamic_green, dynamic_blue;
|
||||
|
||||
// For liquid object
|
||||
float liquid_time_left;
|
||||
ubyte liquid_mag;
|
||||
uint8_t liquid_mag;
|
||||
|
||||
// For freeze objects
|
||||
float freeze_scalar;
|
||||
|
||||
// For attach objects
|
||||
int attach_line_handle; // handle to the object that this object is tethered to
|
||||
int32_t attach_line_handle; // handle to the object that this object is tethered to
|
||||
|
||||
// Sound for special effects
|
||||
int sound_handle;
|
||||
int32_t sound_handle;
|
||||
|
||||
// For spark effect
|
||||
float spark_delay; // delay between sparks
|
||||
@ -205,37 +206,37 @@ typedef struct {
|
||||
// Describes the next animation state for a robot
|
||||
typedef struct custom_anim {
|
||||
float server_time;
|
||||
ushort server_anim_frame;
|
||||
uint16_t server_anim_frame;
|
||||
|
||||
unsigned short anim_start_frame;
|
||||
unsigned short anim_end_frame;
|
||||
uint16_t anim_start_frame;
|
||||
uint16_t anim_end_frame;
|
||||
float anim_time;
|
||||
float max_speed;
|
||||
|
||||
short anim_sound_index;
|
||||
ubyte flags;
|
||||
char next_anim_type;
|
||||
int16_t anim_sound_index;
|
||||
uint8_t flags;
|
||||
int8_t next_anim_type;
|
||||
} custom_anim;
|
||||
|
||||
typedef struct multi_turret {
|
||||
float time;
|
||||
float last_time;
|
||||
ubyte num_turrets;
|
||||
uint8_t num_turrets;
|
||||
float *last_keyframes;
|
||||
float *keyframes;
|
||||
ubyte flags;
|
||||
uint8_t flags;
|
||||
} multi_turret;
|
||||
|
||||
// Information specific to objects that render as a polygon model
|
||||
typedef struct polyobj_info {
|
||||
short model_num; // Which polygon model this object is
|
||||
short dying_model_num; // The dying model for this object
|
||||
int16_t model_num; // Which polygon model this object is
|
||||
int16_t dying_model_num; // The dying model for this object
|
||||
|
||||
float anim_start_frame;
|
||||
float anim_frame; // The model's current animation frame
|
||||
float anim_end_frame;
|
||||
float anim_time;
|
||||
uint anim_flags; // Looping/notify at finish/pending
|
||||
uint32_t anim_flags; // Looping/notify at finish/pending
|
||||
float max_speed;
|
||||
|
||||
union {
|
||||
@ -244,8 +245,8 @@ typedef struct polyobj_info {
|
||||
};
|
||||
multi_turret multi_turret_info;
|
||||
|
||||
uint subobj_flags; // Mask of which subobjects to draw
|
||||
int tmap_override; // If this is not -1, map all faces to this
|
||||
uint32_t subobj_flags; // Mask of which subobjects to draw
|
||||
int32_t tmap_override; // If this is not -1, map all faces to this
|
||||
} polyobj_info;
|
||||
|
||||
// A shard of, presumably, glass
|
||||
@ -253,7 +254,7 @@ typedef struct shard_info_s {
|
||||
vector points[3];
|
||||
float u[3], v[3];
|
||||
vector normal;
|
||||
short tmap;
|
||||
int16_t tmap;
|
||||
} shard_info_s;
|
||||
|
||||
typedef struct line_info_s {
|
||||
@ -262,38 +263,38 @@ typedef struct line_info_s {
|
||||
|
||||
typedef struct blast_info_s {
|
||||
float max_size;
|
||||
int bm_handle;
|
||||
int32_t bm_handle;
|
||||
} blast_info_s;
|
||||
|
||||
typedef struct dying_info_s {
|
||||
int death_flags; // Info about the death
|
||||
int32_t death_flags; // Info about the death
|
||||
float delay_time; // How long until object dies
|
||||
int killer_playernum; // The player who wille this object, or -1 if not a player
|
||||
int32_t killer_playernum; // The player who wille this object, or -1 if not a player
|
||||
float last_spark_time;
|
||||
float last_fireball_time;
|
||||
float last_smoke_time;
|
||||
} dying_info_s;
|
||||
|
||||
typedef struct debris_info_s {
|
||||
int death_flags; // a copy of the parent's death flags
|
||||
int32_t death_flags; // a copy of the parent's death flags
|
||||
float last_smoke_time;
|
||||
} debris_info_s;
|
||||
|
||||
typedef struct laser_info_s {
|
||||
short parent_type; // The type of the parent of this object
|
||||
short src_gun_num; // The src gunpoint that this object fired from
|
||||
int16_t parent_type; // The type of the parent of this object
|
||||
int16_t src_gun_num; // The src gunpoint that this object fired from
|
||||
|
||||
int last_hit_handle; // For persistent weapons (survive object collision), object it most recently hit.
|
||||
int track_handle; // Object this object is tracking.
|
||||
int32_t last_hit_handle; // For persistent weapons (survive object collision), object it most recently hit.
|
||||
int32_t track_handle; // Object this object is tracking.
|
||||
float last_track_time; // Last track time (see if an object is visible)
|
||||
|
||||
int hit_status; // Zero not used
|
||||
int32_t hit_status; // Zero not used
|
||||
vector hit_pnt;
|
||||
vector hit_wall_pnt;
|
||||
vector hit_wall_normal;
|
||||
int hit_room;
|
||||
int hit_pnt_room;
|
||||
short hit_face;
|
||||
int32_t hit_room;
|
||||
int32_t hit_pnt_room;
|
||||
int16_t hit_face;
|
||||
|
||||
float multiplier; // Power if this is a fusion bolt (or other super weapon to be added).
|
||||
float thrust_left; // How many seconds of thrust are left before the weapon stops thrusting
|
||||
@ -304,19 +305,19 @@ typedef struct laser_info_s {
|
||||
} laser_info_s;
|
||||
|
||||
typedef struct powerup_info_s {
|
||||
int count; // how many/much we pick up (vulcan cannon only?)
|
||||
int32_t count; // how many/much we pick up (vulcan cannon only?)
|
||||
} powerup_info_s;
|
||||
|
||||
typedef struct splinter_info_s {
|
||||
ubyte subobj_num;
|
||||
short facenum;
|
||||
uint8_t subobj_num;
|
||||
int16_t facenum;
|
||||
vector verts[MAX_VERTS_PER_SPLINTER];
|
||||
vector center;
|
||||
} splinter_info_s;
|
||||
|
||||
// Data for sourcesource objects
|
||||
typedef struct {
|
||||
int sound_index;
|
||||
int32_t sound_index;
|
||||
float volume;
|
||||
} soundsource_info_s;
|
||||
|
||||
@ -337,7 +338,7 @@ typedef struct physics_info {
|
||||
};
|
||||
angle turnroll; // Rotation caused by turn banking
|
||||
float last_still_time; // The current delta position a wiggle has caused.
|
||||
int num_bounces; // Number of bounces before exploding (PHYSICS_UNLIMITED_BOUNCE is for unlimited bouncing)
|
||||
int32_t num_bounces; // Number of bounces before exploding (PHYSICS_UNLIMITED_BOUNCE is for unlimited bouncing)
|
||||
|
||||
float coeff_restitution; // What percent of velocity is kept after a bounce
|
||||
float mass; // The mass of this object -- what about
|
||||
@ -365,32 +366,32 @@ typedef struct physics_info {
|
||||
|
||||
union {
|
||||
float hit_die_dot;
|
||||
int stuck_room;
|
||||
int32_t stuck_room;
|
||||
};
|
||||
|
||||
union {
|
||||
float max_speed_time;
|
||||
int stuck_portal;
|
||||
int32_t stuck_portal;
|
||||
};
|
||||
|
||||
uint flags; // Misc physics flags
|
||||
uint32_t flags; // Misc physics flags
|
||||
} physics_info;
|
||||
|
||||
typedef struct shockwave_info {
|
||||
uint damaged_list[(MAX_OBJECTS / 32) + 1];
|
||||
uint32_t damaged_list[(MAX_OBJECTS / 32) + 1];
|
||||
} shockwave_info;
|
||||
|
||||
typedef struct object_link_info {
|
||||
int parent_handle;
|
||||
int sobj_index;
|
||||
int32_t parent_handle;
|
||||
int32_t sobj_index;
|
||||
vector fvec;
|
||||
vector uvec;
|
||||
vector pos;
|
||||
} object_link_info;
|
||||
|
||||
typedef struct {
|
||||
ushort DLLID;
|
||||
ushort script_id;
|
||||
uint16_t DLLID;
|
||||
uint16_t script_id;
|
||||
void *script_instance;
|
||||
} tOSIRISScriptNode;
|
||||
|
||||
@ -403,28 +404,28 @@ typedef struct {
|
||||
|
||||
// The data for an object
|
||||
typedef struct object {
|
||||
ubyte type; // what type of object this is... robot, weapon, hostage, powerup, fireball
|
||||
ubyte dummy_type; // stored type of an OBJ_DUMMY
|
||||
ushort id; // which form of object...which powerup, robot, etc.
|
||||
ulong flags;
|
||||
uint8_t type; // what type of object this is... robot, weapon, hostage, powerup, fireball
|
||||
uint8_t dummy_type; // stored type of an OBJ_DUMMY
|
||||
uint16_t id; // which form of object...which powerup, robot, etc.
|
||||
uint32_t flags;
|
||||
|
||||
char *name; // the name of this object, or NULL
|
||||
|
||||
int handle; // unique handle for this object. See defines above
|
||||
short next, prev; // id of next and previous connected object in Objects, -1 = no connection
|
||||
int32_t handle; // unique handle for this object. See defines above
|
||||
int16_t next, prev; // id of next and previous connected object in Objects, -1 = no connection
|
||||
|
||||
ubyte control_type; // how this object is controlled
|
||||
ubyte movement_type; // how this object moves
|
||||
ubyte render_type; // how this object renders
|
||||
ubyte lighting_render_type; // how this object is lit. See flags above
|
||||
uint8_t control_type; // how this object is controlled
|
||||
uint8_t movement_type; // how this object moves
|
||||
uint8_t render_type; // how this object renders
|
||||
uint8_t lighting_render_type; // how this object is lit. See flags above
|
||||
|
||||
int roomnum; // room number or terrain cell containing object
|
||||
int32_t roomnum; // room number or terrain cell containing object
|
||||
|
||||
vector pos; // absolute x,y,z coordinate of center of object
|
||||
matrix orient; // orientation of object in world
|
||||
vector last_pos; // where object was last frame
|
||||
|
||||
ushort renderframe; // framenum this object was last rendered
|
||||
uint16_t renderframe; // framenum this object was last rendered
|
||||
|
||||
vector wall_sphere_offset;
|
||||
vector anim_sphere_offset;
|
||||
@ -432,28 +433,28 @@ typedef struct object {
|
||||
float size; // 3d size of object - for collision detection
|
||||
float shields; // Starts at maximum, when <0, object dies..
|
||||
|
||||
sbyte contains_type; // Type of object this object contains (eg, spider contains powerup)
|
||||
sbyte contains_id; // ID of object this object contains (eg, id = blue type = key)
|
||||
sbyte contains_count; // number of objects of type:id this object contains
|
||||
sbyte pad3; // keep alignment
|
||||
int8_t contains_type; // Type of object this object contains (eg, spider contains powerup)
|
||||
int8_t contains_id; // ID of object this object contains (eg, id = blue type = key)
|
||||
int8_t contains_count; // number of objects of type:id this object contains
|
||||
int8_t pad3; // keep alignment
|
||||
|
||||
float creation_time; // absolute time when this object was created
|
||||
float lifeleft; // how long until goes away, if OF_USES_LIFELEFT flag is set
|
||||
float lifetime; // How long this object stays alive (in seconds)
|
||||
|
||||
int parent_handle; // The handle of this object's parent
|
||||
int32_t parent_handle; // The handle of this object's parent
|
||||
|
||||
int attach_ultimate_handle;
|
||||
int attach_parent_handle;
|
||||
int *attach_children; // List of object handles for connected children
|
||||
int32_t attach_ultimate_handle;
|
||||
int32_t attach_parent_handle;
|
||||
int32_t *attach_children; // List of object handles for connected children
|
||||
|
||||
ubyte weapon_fire_flags; // Used to indicate special weapon effects. See flags above.
|
||||
uint8_t weapon_fire_flags; // Used to indicate special weapon effects. See flags above.
|
||||
|
||||
char attach_type;
|
||||
short lowest_attached_vis;
|
||||
int8_t attach_type;
|
||||
int16_t lowest_attached_vis;
|
||||
union {
|
||||
float attach_dist;
|
||||
short attach_index;
|
||||
int16_t attach_index;
|
||||
};
|
||||
|
||||
// Movement info, determined by MOVEMENT_TYPE
|
||||
@ -477,11 +478,11 @@ typedef struct object {
|
||||
float impact_force;
|
||||
|
||||
// Object change information
|
||||
int change_flags;
|
||||
int32_t change_flags;
|
||||
|
||||
// object generic vis flags
|
||||
int generic_nonvis_flags;
|
||||
int generic_sent_nonvis;
|
||||
int32_t generic_nonvis_flags;
|
||||
int32_t generic_sent_nonvis;
|
||||
|
||||
lightmap_object lm_object; // The lightmap object for this object
|
||||
|
||||
@ -513,7 +514,7 @@ typedef struct object {
|
||||
|
||||
// Something to do with multiplayer, possibly, but it's hard to know for sure
|
||||
// because some people are incapable of commented their code.
|
||||
ushort position_counter;
|
||||
uint16_t position_counter;
|
||||
|
||||
// OSIRIS Script Info (new OSIRIS)
|
||||
tOSIRISScript *osiris_script;
|
||||
|
@ -75,16 +75,17 @@
|
||||
#ifndef _PLAYER_EXTERNAL_STRUCT_H_
|
||||
#define _PLAYER_EXTERNAL_STRUCT_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "pstypes.h"
|
||||
#include "vecmat_external.h"
|
||||
#include "object_external_struct.h"
|
||||
#include "multi_external.h"
|
||||
#include "Inventory.h"
|
||||
|
||||
#define MAX_PLAYERS MAX_NET_PLAYERS
|
||||
#define MAX_TEAMS 4
|
||||
|
||||
class Inventory;
|
||||
|
||||
#define CALLSIGN_LEN 19
|
||||
// THIS CONSTANT MUST NEVER BE OVER 32!!!
|
||||
#define MAX_PLAYER_WEAPONS MAX_WBS_PER_OBJ
|
||||
@ -94,80 +95,80 @@ class Inventory;
|
||||
// Info on player weapon firing.
|
||||
// There is one of these each for the primary & secondary weapons
|
||||
typedef struct {
|
||||
int index; // the index of the current primary or secondary weapon
|
||||
int32_t index; // the index of the current primary or secondary weapon
|
||||
float firing_time; // how long the current weapon has been firing
|
||||
int sound_handle; // the handle for the sound the firing weapon is making
|
||||
int32_t sound_handle; // the handle for the sound the firing weapon is making
|
||||
} player_weapon;
|
||||
|
||||
// The structure for a player. Most of this data will be for multiplayer
|
||||
typedef struct {
|
||||
|
||||
// positional data for player starts
|
||||
int start_index;
|
||||
int32_t start_index;
|
||||
vector start_pos; // where the player starts
|
||||
int start_roomnum;
|
||||
int32_t start_roomnum;
|
||||
matrix start_orient;
|
||||
|
||||
int startpos_flags; // these flags apply to the start position (used for teams)
|
||||
int32_t startpos_flags; // these flags apply to the start position (used for teams)
|
||||
|
||||
int ship_index; // the index into the Ships array that this player is flying
|
||||
int32_t ship_index; // the index into the Ships array that this player is flying
|
||||
|
||||
// Who am I data
|
||||
char callsign[CALLSIGN_LEN + 1]; // The callsign of this player, for net purposes.
|
||||
|
||||
// Game data
|
||||
uint flags; // Powerup flags, see above...
|
||||
int score; // The player's current score
|
||||
uint32_t flags; // Powerup flags, see above...
|
||||
int32_t score; // The player's current score
|
||||
float damage_magnitude; // for shield effects
|
||||
float edrain_magnitude; // for energy drain effects
|
||||
float invul_magnitude; // for invulnerability effects
|
||||
float energy; // Amount of energy remaining.
|
||||
ubyte lives; // Lives remaining, 0 = game over.
|
||||
sbyte level; // Current level player is playing. (must be signed for secret levels)
|
||||
sbyte starting_level; // What level the player started on.
|
||||
ubyte keys; // Which keys the player has
|
||||
short killer_objnum; // Who killed me.... (-1 if no one)
|
||||
uint8_t lives; // Lives remaining, 0 = game over.
|
||||
int8_t level; // Current level player is playing. (must be signed for secret levels)
|
||||
int8_t starting_level; // What level the player started on.
|
||||
uint8_t keys; // Which keys the player has
|
||||
int16_t killer_objnum; // Who killed me.... (-1 if no one)
|
||||
float invulnerable_time; // Time left invulnerable
|
||||
float last_hit_wall_sound_time; // Last time we played a hit wall sound
|
||||
float last_homing_warning_sound_time; // Obvious :)
|
||||
float last_thrust_time; // Last time the player thrusted
|
||||
float last_afterburner_time; // Last time the player used the afterburner
|
||||
short objnum; // The object number of this player
|
||||
sbyte team; // The team number this guy is on
|
||||
int16_t objnum; // The object number of this player
|
||||
int8_t team; // The team number this guy is on
|
||||
|
||||
// The current auto-waypoint for this player
|
||||
int current_auto_waypoint_room; // the most recent auto-waypoint, or -1
|
||||
int32_t current_auto_waypoint_room; // the most recent auto-waypoint, or -1
|
||||
|
||||
// Statistics...
|
||||
// int score; // Current score.
|
||||
float time_level; // Level time played
|
||||
float time_total; // Game time played (high word = seconds)
|
||||
|
||||
int num_hits_level; // used for accuracy calculation.
|
||||
int num_discharges_level;
|
||||
int32_t num_hits_level; // used for accuracy calculation.
|
||||
int32_t num_discharges_level;
|
||||
|
||||
short num_kills_level; // Number of kills this level
|
||||
short friendly_kills_level; // Number of friendly kills this level
|
||||
short num_kills_total; // Number of kills total
|
||||
int16_t num_kills_level; // Number of kills this level
|
||||
int16_t friendly_kills_level; // Number of friendly kills this level
|
||||
int16_t num_kills_total; // Number of kills total
|
||||
|
||||
// Player weapon info
|
||||
uint weapon_flags; // Mask of currently owned weapons
|
||||
ushort weapon_ammo[MAX_PLAYER_WEAPONS]; // Ammo for each weapon
|
||||
uint32_t weapon_flags; // Mask of currently owned weapons
|
||||
uint16_t weapon_ammo[MAX_PLAYER_WEAPONS]; // Ammo for each weapon
|
||||
|
||||
// Weapons
|
||||
player_weapon weapon[2]; // Info on the player weapons
|
||||
ubyte laser_level; // Current level of the laser.
|
||||
uint8_t laser_level; // Current level of the laser.
|
||||
|
||||
// lighting
|
||||
float light_dist;
|
||||
float r, g, b;
|
||||
|
||||
float ballspeed;
|
||||
ubyte num_balls;
|
||||
uint8_t num_balls;
|
||||
float ball_r[3], ball_g[3], ball_b[3];
|
||||
|
||||
// Room tracking
|
||||
int oldroom;
|
||||
int32_t oldroom;
|
||||
|
||||
// Inventory
|
||||
Inventory inventory;
|
||||
@ -181,28 +182,28 @@ typedef struct {
|
||||
// Afterburner stuff
|
||||
float afterburner_mag; // How big the thrust is for the afterburner
|
||||
float thrust_mag;
|
||||
int afterburner_sound_handle;
|
||||
int32_t afterburner_sound_handle;
|
||||
float afterburn_time_left;
|
||||
|
||||
int thruster_sound_handle;
|
||||
int thruster_sound_state;
|
||||
int32_t thruster_sound_handle;
|
||||
int32_t thruster_sound_state;
|
||||
|
||||
// For small views and external cameras
|
||||
int small_left_obj, small_right_obj, small_dll_obj;
|
||||
int32_t small_left_obj, small_right_obj, small_dll_obj;
|
||||
|
||||
// Multiplayer stuff
|
||||
ubyte multiplayer_flags;
|
||||
ubyte last_multiplayer_flags;
|
||||
uint8_t multiplayer_flags;
|
||||
uint8_t last_multiplayer_flags;
|
||||
float last_guided_time;
|
||||
|
||||
char tracker_id[TRACKER_ID_LEN];
|
||||
int kills;
|
||||
int deaths;
|
||||
int suicides;
|
||||
int32_t kills;
|
||||
int32_t deaths;
|
||||
int32_t suicides;
|
||||
float rank;
|
||||
float lateral_thrust; // total lateral movement over the whole game
|
||||
float rotational_thrust; // total rotational movement over the whole game
|
||||
unsigned int time_in_game; // seconds in game
|
||||
uint32_t time_in_game; // seconds in game
|
||||
object *guided_obj, *user_timeout_obj;
|
||||
|
||||
float zoom_distance;
|
||||
@ -216,26 +217,26 @@ typedef struct {
|
||||
float weapon_speed_scalar;
|
||||
|
||||
// Observer stuff
|
||||
int piggy_objnum;
|
||||
int piggy_sig;
|
||||
int32_t piggy_objnum;
|
||||
int32_t piggy_sig;
|
||||
|
||||
// Custom texture stuff
|
||||
int custom_texture_handle;
|
||||
int32_t custom_texture_handle;
|
||||
|
||||
// Ship permissions (1 bit per ship)
|
||||
int ship_permissions;
|
||||
int32_t ship_permissions;
|
||||
|
||||
// For invul hit effect
|
||||
vector invul_vector;
|
||||
|
||||
// Used to disable various controller input from scripting
|
||||
unsigned int controller_bitflags;
|
||||
uint32_t controller_bitflags;
|
||||
|
||||
// Marker stuff
|
||||
short num_markers;
|
||||
int16_t num_markers;
|
||||
|
||||
short num_deaths_level; // Number of kills this level
|
||||
short num_deaths_total; // Number of kills total
|
||||
int16_t num_deaths_level; // Number of kills this level
|
||||
int16_t num_deaths_total; // Number of kills total
|
||||
|
||||
} player;
|
||||
|
||||
|
11
Descent3/tests/CMakeLists.txt
Normal file
11
Descent3/tests/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
add_executable(
|
||||
porting-tests
|
||||
porting-tests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
porting-tests
|
||||
GTest::gtest_main
|
||||
)
|
||||
|
||||
gtest_discover_tests(porting-tests)
|
54
Descent3/tests/porting-tests.cpp
Normal file
54
Descent3/tests/porting-tests.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Descent 3
|
||||
* Copyright (C) 2024 Descent Developers
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "osiris_predefs.h"
|
||||
#include "osiris_share.h"
|
||||
#include "player_external_struct.h"
|
||||
|
||||
// This is copy of actual Osiris_CreateGameChecksum(void) from OsirisLoadandBind.cpp
|
||||
uint Osiris_CreateGameChecksumTest() {
|
||||
uint value = 0xe1e1b0b0;
|
||||
|
||||
value += sizeof(object);
|
||||
value += sizeof(player) * 2;
|
||||
value += sizeof(tOSIRISModuleInit) * 3;
|
||||
value += sizeof(tOSIRISEventInfo) * 5;
|
||||
value += sizeof(tOSIRISTIMER) * 7;
|
||||
value += sizeof(tOSIRISSCRIPTID) * 11;
|
||||
value += sizeof(tOSIRISMEMCHUNK) * 13;
|
||||
value += sizeof(msafe_struct) * 17;
|
||||
value += sizeof(ray_info) * 19;
|
||||
value += sizeof(vector) * 23;
|
||||
value += sizeof(matrix) * 29;
|
||||
value += sizeof(tGameCinematic) * 31;
|
||||
value += sizeof(tCannedCinematicInfo) * 37;
|
||||
|
||||
value = value << 2;
|
||||
|
||||
/* Adds count of Osiris_module_init.fp */
|
||||
value += 123;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
TEST(D3, OsirisTests) {
|
||||
EXPECT_EQ(Osiris_CreateGameChecksumTest(), CHECKSUM);
|
||||
}
|
@ -1,10 +1,3 @@
|
||||
# 64 bit machines have a different game checksum than 32 bit machines
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_definitions(-DCHECKSUM=2273889867UL)
|
||||
else ()
|
||||
add_definitions(-DCHECKSUM=2273873307UL)
|
||||
endif()
|
||||
|
||||
set(HEADERS)
|
||||
set(CPPS)
|
||||
if (UNIX)
|
||||
|
@ -334,6 +334,8 @@
|
||||
#ifndef __OSIRIS_COMMON_H_
|
||||
#define __OSIRIS_COMMON_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "vecmat_external.h"
|
||||
#include "aistruct_external.h"
|
||||
#include "object_external.h"
|
||||
@ -955,14 +957,14 @@ inline ddgr_color GR_RGB(int r, int g, int b) { return ((r << 16) + (g << 8) + b
|
||||
#define COM_REINIT 2
|
||||
|
||||
typedef struct {
|
||||
char action;
|
||||
char index;
|
||||
int8_t action;
|
||||
int8_t index;
|
||||
void *ptr;
|
||||
} gb_com;
|
||||
|
||||
typedef struct {
|
||||
char title[256];
|
||||
int num_commands;
|
||||
int32_t num_commands;
|
||||
char command_text[MAX_GB_COMMANDS][256];
|
||||
char command_id[MAX_GB_COMMANDS];
|
||||
char command_type[MAX_GB_COMMANDS];
|
||||
@ -975,10 +977,10 @@ typedef struct {
|
||||
// =======================================================================
|
||||
|
||||
typedef struct {
|
||||
int *fp[MAX_MODULEFUNCS];
|
||||
int32_t *fp[MAX_MODULEFUNCS];
|
||||
char **string_table;
|
||||
int string_count;
|
||||
int module_identifier;
|
||||
int32_t string_count;
|
||||
int32_t module_identifier;
|
||||
|
||||
bool module_is_static; // if this is set to true after initialization
|
||||
// then the module will not unload if it's reference
|
||||
@ -990,7 +992,7 @@ typedef struct {
|
||||
// will always be valid during the lifetime of the module
|
||||
// DO NOT ALTER THE STRING IT POINTS TO.
|
||||
|
||||
uint game_checksum; // Checksum of game structures, if this doesn't match
|
||||
uint32_t game_checksum; // Checksum of game structures, if this doesn't match
|
||||
// the checksum at compile time, it is very likely that
|
||||
// bad things can happen, and this module shouldn't initialize.
|
||||
|
||||
@ -1007,30 +1009,30 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
float damage;
|
||||
int it_handle;
|
||||
int weapon_handle;
|
||||
int damage_type;
|
||||
int32_t it_handle;
|
||||
int32_t weapon_handle;
|
||||
int32_t damage_type;
|
||||
} tOSIRISEVTDAMAGED; // struct for EVT_DAMAGED data
|
||||
|
||||
typedef struct {
|
||||
int it_handle;
|
||||
int32_t it_handle;
|
||||
} tOSIRISEVTCOLLIDE; // struct for EVT_COLLIDE data
|
||||
|
||||
typedef struct {
|
||||
} tOSIRISEVTCREATED; // struct for EVT_CREATED data
|
||||
|
||||
typedef struct {
|
||||
ubyte is_dying; // if this is !=0 than the event is coming because it is
|
||||
uint8_t is_dying; // if this is !=0 than the event is coming because it is
|
||||
// really being destroyed. Else it is due to the level ending.
|
||||
} tOSIRISEVTDESTROY; // struct for EVT_DESTROY data
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
int32_t id;
|
||||
float game_time;
|
||||
} tOSIRISEVTTIMER; // struct for EVT_TIMER data
|
||||
|
||||
typedef struct {
|
||||
int it_handle;
|
||||
int32_t it_handle;
|
||||
} tOSIRISEVTUSE; // struct for EVT_USE data
|
||||
|
||||
typedef struct {
|
||||
@ -1042,13 +1044,13 @@ typedef struct {
|
||||
} tOSIRISEVTRESTORESTATE; // struct for EVT_RESTORESTATE data
|
||||
|
||||
typedef struct {
|
||||
int notify_type;
|
||||
int it_handle;
|
||||
int goal_num;
|
||||
int goal_uid;
|
||||
int32_t notify_type;
|
||||
int32_t it_handle;
|
||||
int32_t goal_num;
|
||||
int32_t goal_uid;
|
||||
union {
|
||||
int enabler_num;
|
||||
int attack_num;
|
||||
int32_t enabler_num;
|
||||
int32_t attack_num;
|
||||
};
|
||||
} tOSIRISEVTAINOTIFY; // struct for EVT_AI_NOTIFY data
|
||||
|
||||
@ -1062,26 +1064,26 @@ typedef struct {
|
||||
} tOSIRISEVTLEVELEND; // struct for EVT_LEVELEND data
|
||||
|
||||
typedef struct {
|
||||
int room_num;
|
||||
int32_t room_num;
|
||||
} tOSIRISEVTCHANGESEG; // struct for EVT_CHANGESEG data
|
||||
|
||||
typedef struct {
|
||||
int id;
|
||||
int32_t id;
|
||||
void *memory_ptr;
|
||||
} tOSIRISEVTMEMRESTORE; // struct for EVT_MEMRESTORE data
|
||||
|
||||
typedef struct {
|
||||
int handle;
|
||||
ubyte detonated;
|
||||
int32_t handle;
|
||||
uint8_t detonated;
|
||||
} tOSIRISEVTTIMERCANCEL; // struct for EVT_TIMERCANCEL data
|
||||
|
||||
typedef struct {
|
||||
int it_handle;
|
||||
int32_t it_handle;
|
||||
} tOSIRISEVTCHILDDIED;
|
||||
|
||||
typedef struct {
|
||||
int it_handle;
|
||||
int id;
|
||||
int32_t it_handle;
|
||||
int32_t id;
|
||||
} tOSIRISEVTMATCENCREATE; // struct for EVT_MATCEN_CREATE data
|
||||
|
||||
typedef struct {
|
||||
@ -1091,11 +1093,11 @@ typedef struct {
|
||||
} tOSIRISEVTDOORCLOSE; // struct for EVT_DOOR_CLOSE data
|
||||
|
||||
typedef struct {
|
||||
int level_goal_index;
|
||||
int32_t level_goal_index;
|
||||
} tOSIRISEVTLEVELGOALCOMPLETE;
|
||||
|
||||
typedef struct {
|
||||
int level_goal_index;
|
||||
int32_t level_goal_index;
|
||||
} tOSIRISEVTLEVELGOALITEMCOMPLETE;
|
||||
|
||||
typedef struct {
|
||||
@ -1108,11 +1110,11 @@ typedef struct {
|
||||
} tOSIRISEVTPLAYERMOVIEEND;
|
||||
|
||||
typedef struct {
|
||||
int it_handle; // player respawning
|
||||
int32_t it_handle; // player respawning
|
||||
} tOSIRISEVTPLAYERRESPAWN;
|
||||
|
||||
typedef struct {
|
||||
int it_handle; // player dead
|
||||
int32_t it_handle; // player dead
|
||||
} tOSIRISEVTPLAYERDIES;
|
||||
|
||||
typedef struct {
|
||||
@ -1159,7 +1161,7 @@ typedef struct {
|
||||
tOSIRISEVTPLAYERDIES evt_player_dies;
|
||||
};
|
||||
|
||||
int me_handle;
|
||||
int32_t me_handle;
|
||||
void *extra_info;
|
||||
} tOSIRISEventInfo; // contains the necessary data for all events
|
||||
// to pass what they need to their event handlers.
|
||||
@ -1171,16 +1173,16 @@ typedef struct {
|
||||
0x008 // this timer should be auto-cancelled if object_handle_detonator dies, than the
|
||||
// timer auto-cancels
|
||||
typedef struct {
|
||||
ushort flags;
|
||||
int id; // an optional id you can use to store, will be passed back on EVT_TIMER signal
|
||||
int repeat_count; // if OTF_REPEATER is set, this is how many times to repeat the signal (every
|
||||
uint16_t flags;
|
||||
int32_t id; // an optional id you can use to store, will be passed back on EVT_TIMER signal
|
||||
int32_t repeat_count; // if OTF_REPEATER is set, this is how many times to repeat the signal (every
|
||||
// interval). -1 for infinite.
|
||||
union {
|
||||
int object_handle; // handle to the object to recieve the EVT_TIMER signal
|
||||
int trigger_number; // trigger number to recieve the EVT_TIMER signal (OTF_TRIGGER)
|
||||
int32_t object_handle; // handle to the object to recieve the EVT_TIMER signal
|
||||
int32_t trigger_number; // trigger number to recieve the EVT_TIMER signal (OTF_TRIGGER)
|
||||
};
|
||||
|
||||
int object_handle_detonator; // if OTF_CANCELONDEAD is specified, this is the object handle to
|
||||
int32_t object_handle_detonator; // if OTF_CANCELONDEAD is specified, this is the object handle to
|
||||
// use for checking, if this object dies, than auto-cancel the timer
|
||||
|
||||
float timer_interval; // the timeframe in between EVT_TIMER signals (for non-repeaters, this is how
|
||||
@ -1192,15 +1194,15 @@ typedef enum { OBJECT_SCRIPT = 0, TRIGGER_SCRIPT, LEVEL_SCRIPT } script_type;
|
||||
typedef struct {
|
||||
script_type type;
|
||||
union {
|
||||
int objhandle;
|
||||
int triggernum;
|
||||
int32_t objhandle;
|
||||
int32_t triggernum;
|
||||
};
|
||||
} tOSIRISSCRIPTID;
|
||||
|
||||
typedef struct {
|
||||
tOSIRISSCRIPTID my_id;
|
||||
ushort id;
|
||||
int size;
|
||||
uint16_t id;
|
||||
int32_t size;
|
||||
} tOSIRISMEMCHUNK;
|
||||
|
||||
// =======================================================================
|
||||
@ -1210,94 +1212,94 @@ typedef struct {
|
||||
#define KOI_ID 0 // this item is specifying a type/id of object NOT to kill
|
||||
#define KOI_HANDLE 1 // this item is specifying an object handle of an object NOT to kill
|
||||
typedef struct {
|
||||
ubyte info_type;
|
||||
int id;
|
||||
int objhandle;
|
||||
uint8_t info_type;
|
||||
int32_t id;
|
||||
int32_t objhandle;
|
||||
} tKillObjectItem;
|
||||
|
||||
#define MSAFE_MESSAGE_LENGTH 255
|
||||
#define MSAFE_NAME_LENGTH 32
|
||||
typedef struct {
|
||||
// Rooms
|
||||
int roomnum;
|
||||
short facenum;
|
||||
short texnum;
|
||||
short portalnum;
|
||||
int32_t roomnum;
|
||||
int16_t facenum;
|
||||
int16_t texnum;
|
||||
int16_t portalnum;
|
||||
float fog_r, fog_g, fog_b, fog_depth;
|
||||
vector wind;
|
||||
ubyte pulse_time;
|
||||
ubyte pulse_offset;
|
||||
uint8_t pulse_time;
|
||||
uint8_t pulse_offset;
|
||||
|
||||
// Objects/Players
|
||||
uint objhandle;
|
||||
uint ithandle;
|
||||
uint32_t objhandle;
|
||||
uint32_t ithandle;
|
||||
float shields, energy;
|
||||
short start_tick;
|
||||
short end_tick;
|
||||
int16_t start_tick;
|
||||
int16_t end_tick;
|
||||
float cycle_time;
|
||||
int type, id, aux_type, aux_id;
|
||||
uint checksum;
|
||||
int path_id;
|
||||
int32_t type, id, aux_type, aux_id;
|
||||
uint32_t checksum;
|
||||
int32_t path_id;
|
||||
float amount;
|
||||
ubyte damage_type;
|
||||
uint killer_handle;
|
||||
uint8_t damage_type;
|
||||
uint32_t killer_handle;
|
||||
float ammo;
|
||||
ubyte playsound;
|
||||
ubyte remove;
|
||||
ubyte do_powerup;
|
||||
uint8_t playsound;
|
||||
uint8_t remove;
|
||||
uint8_t do_powerup;
|
||||
vector velocity;
|
||||
vector rot_velocity;
|
||||
float rot_drag;
|
||||
vector thrust;
|
||||
vector rot_thrust;
|
||||
char control_type;
|
||||
char movement_type;
|
||||
int8_t control_type;
|
||||
int8_t movement_type;
|
||||
float creation_time;
|
||||
int physics_flags;
|
||||
int32_t physics_flags;
|
||||
vector pos;
|
||||
matrix orient;
|
||||
float anim_frame;
|
||||
|
||||
// Spew
|
||||
ubyte is_real;
|
||||
ubyte random;
|
||||
ubyte unused2; // was use_gunpoint
|
||||
sbyte gunpoint;
|
||||
ubyte effect_type;
|
||||
ubyte phys_info;
|
||||
uint8_t is_real;
|
||||
uint8_t random;
|
||||
uint8_t unused2; // was use_gunpoint
|
||||
int8_t gunpoint;
|
||||
uint8_t effect_type;
|
||||
uint8_t phys_info;
|
||||
float drag, mass;
|
||||
|
||||
// Unused
|
||||
ushort unused; // was doorway_index
|
||||
uint16_t unused; // was doorway_index
|
||||
|
||||
// Weather
|
||||
int randval;
|
||||
int32_t randval;
|
||||
|
||||
// Triggers
|
||||
ubyte trigger_num;
|
||||
uint8_t trigger_num;
|
||||
|
||||
// sounds
|
||||
int sound_handle;
|
||||
int32_t sound_handle;
|
||||
float volume;
|
||||
|
||||
// Shared/misc
|
||||
int index;
|
||||
int32_t index;
|
||||
float scalar;
|
||||
float interval;
|
||||
ubyte state;
|
||||
sbyte slot;
|
||||
uint8_t state;
|
||||
int8_t slot;
|
||||
char message[MSAFE_MESSAGE_LENGTH];
|
||||
char name[MSAFE_NAME_LENGTH];
|
||||
int color;
|
||||
int32_t color;
|
||||
float longevity;
|
||||
float lifetime;
|
||||
float size;
|
||||
float speed;
|
||||
int count;
|
||||
int flags;
|
||||
int32_t count;
|
||||
int32_t flags;
|
||||
void *list;
|
||||
unsigned int control_mask;
|
||||
unsigned char control_val;
|
||||
uint32_t control_mask;
|
||||
uint8_t control_val;
|
||||
|
||||
// Object lighting stuff
|
||||
float light_distance;
|
||||
@ -1306,7 +1308,7 @@ typedef struct {
|
||||
float time_interval;
|
||||
float flicker_distance;
|
||||
float directional_dot;
|
||||
int timebits;
|
||||
int32_t timebits;
|
||||
|
||||
vector pos2;
|
||||
|
||||
@ -1316,16 +1318,16 @@ typedef struct {
|
||||
} msafe_struct;
|
||||
|
||||
typedef struct {
|
||||
int fate;
|
||||
int hit_room;
|
||||
int32_t fate;
|
||||
int32_t hit_room;
|
||||
vector hit_point;
|
||||
|
||||
int hit_object;
|
||||
int hit_subobject;
|
||||
int32_t hit_object;
|
||||
int32_t hit_subobject;
|
||||
|
||||
int hit_face;
|
||||
int32_t hit_face;
|
||||
vector hit_face_pnt;
|
||||
int hit_face_room;
|
||||
int32_t hit_face_room;
|
||||
vector hit_wallnorm;
|
||||
} ray_info;
|
||||
|
||||
@ -1341,8 +1343,8 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
vector pos; // where this node is in the world
|
||||
int roomnum; // what room?
|
||||
int flags; // if this point lives over the terrain, etc
|
||||
int32_t roomnum; // what room?
|
||||
int32_t flags; // if this point lives over the terrain, etc
|
||||
vector fvec;
|
||||
vector uvec;
|
||||
} osiris_path_node_info;
|
||||
|
Loading…
Reference in New Issue
Block a user