Lose the packed attribute on / rearrange some game struct types.

actors.h: remove 'packed' from projectile_t, tiledata_t. In tiledata_t,
 make .cacherange member an int32_t so that the following member
 "projectile_t defproj" is aligned on a 4-byte boundary.
player.h: remove 'packed' from playerspawn_t, DukeStatus_t, input_t.
In Lunatic, correct packing attribute of the base type of the unrestricted
actor_t and DukePlayer_t pointer types (the declaration was used without

Bump BYTEVERSION.

git-svn-id: https://svn.eduke32.com/eduke32@3458 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-02-03 12:48:25 +00:00
parent b5aa49953e
commit 728ae2bb76
4 changed files with 29 additions and 32 deletions

View file

@ -71,7 +71,6 @@ enum uactortypes_t {
enemystayput enemystayput
}; };
#pragma pack(push,1)
#ifdef LUNATIC #ifdef LUNATIC
struct action { struct action {
@ -83,8 +82,10 @@ struct move {
int16_t hvel, vvel; int16_t hvel, vvel;
}; };
#pragma pack(push,1)
typedef struct { int32_t id; struct move mv; } con_move_t; typedef struct { int32_t id; struct move mv; } con_move_t;
typedef struct { int32_t id; struct action ac; } con_action_t; typedef struct { int32_t id; struct action ac; } con_action_t;
#pragma pack(pop)
#endif #endif
typedef struct { typedef struct {
@ -102,6 +103,7 @@ typedef struct {
int8_t filler[6]; // 6b int8_t filler[6]; // 6b
} projectile_t; } projectile_t;
#pragma pack(push,1)
// (+ 40 16 16 4 8 6 8 6 4 20) // (+ 40 16 16 4 8 6 8 6 4 20)
typedef struct { typedef struct {
int32_t t_data[10]; // 40b sometimes used to hold offsets to con code int32_t t_data[10]; // 40b sometimes used to hold offsets to con code
@ -175,6 +177,7 @@ typedef struct {
int16_t netIndex; int16_t netIndex;
} netactor_t; } netactor_t;
#pragma pack(pop)
typedef struct { typedef struct {
#if !defined LUNATIC #if !defined LUNATIC
@ -183,13 +186,12 @@ typedef struct {
#endif #endif
uint32_t flags; // formerly SpriteFlags, ActorType uint32_t flags; // formerly SpriteFlags, ActorType
int16_t cacherange; // formerly SpriteCache int32_t cacherange; // formerly SpriteCache
// todo: make this a pointer and allocate at runtime // todo: make this a pointer and allocate at runtime
projectile_t defproj; projectile_t defproj;
} tiledata_t; } tiledata_t;
#pragma pack(pop)
// KEEPINSYNC lunatic/con_lang.lua // KEEPINSYNC lunatic/con_lang.lua
enum sflags_t { enum sflags_t {

View file

@ -57,7 +57,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define VOLUMEONE (g_Shareware == 1) #define VOLUMEONE (g_Shareware == 1)
// increase by 3, because atomic GRP adds 1, and Shareware adds 2 // increase by 3, because atomic GRP adds 1, and Shareware adds 2
#define BYTEVERSION_JF 270 #define BYTEVERSION_JF 273
#define BYTEVERSION_13 27 #define BYTEVERSION_13 27
#define BYTEVERSION_14 116 #define BYTEVERSION_14 116

View file

@ -128,7 +128,7 @@ typedef struct {
-- to make more 'const'), but still has array members exposed, so is unsuited -- to make more 'const'), but still has array members exposed, so is unsuited
-- for external exposure. -- for external exposure.
local ACTOR_STRUCT = [[ local ACTOR_STRUCT = [[
{ __attribute__((packed)) struct {
const int32_t t_data[10]; // 56b sometimes used to hold offsets to con code const int32_t t_data[10]; // 56b sometimes used to hold offsets to con code
const struct move mv; const struct move mv;
const struct action ac; const struct action ac;
@ -165,7 +165,7 @@ bcarray.new("int16_t", ffiC.MAX_WEAPONS, "weapon", "int16_x_MAX_WEAPONS")
bcarray.new("int16_t", ffiC.GET_MAX, "inventory", "int16_x_GET_MAX") bcarray.new("int16_t", ffiC.GET_MAX, "inventory", "int16_x_GET_MAX")
local DUKEPLAYER_STRUCT = [[ local DUKEPLAYER_STRUCT = [[
{ __attribute__((packed)) struct {
vec3_t pos, opos, vel, npos; vec3_t pos, opos, vel, npos;
int32_t bobposx, bobposy; int32_t bobposx, bobposy;
int32_t truefz, truecz, player_par; int32_t truefz, truecz, player_par;
@ -291,17 +291,8 @@ end
local con_lang = require("con_lang") local con_lang = require("con_lang")
ffi.cdef([[ ffi.cdef([[
#pragma pack(push, 1)
typedef struct
]].. mangle_arrays(ACTOR_STRUCT) ..[[
actor_t;
typedef struct { int32_t _p; } weaponaccess_t; typedef struct { int32_t _p; } weaponaccess_t;
typedef struct
]].. mangle_arrays(DUKEPLAYER_STRUCT) ..[[
DukePlayer_t;
typedef struct { typedef struct {
uint32_t bits; // 4b uint32_t bits; // 4b
int16_t fvel, svel; // 4b int16_t fvel, svel; // 4b
@ -309,6 +300,15 @@ typedef struct {
int8_t extbits, filler; // 2b int8_t extbits, filler; // 2b
} input_t; } input_t;
#pragma pack(push, 1)
typedef
]].. mangle_arrays(ACTOR_STRUCT) ..[[
actor_t;
typedef
]].. mangle_arrays(DUKEPLAYER_STRUCT) ..[[
DukePlayer_t;
typedef struct { typedef struct {
DukePlayer_t *ps; DukePlayer_t *ps;
input_t *sync; input_t *sync;
@ -322,6 +322,7 @@ typedef struct {
char user_name[32]; char user_name[32];
uint32_t revision; uint32_t revision;
} playerdata_t; } playerdata_t;
#pragma pack(pop)
typedef struct { typedef struct {
int32_t cur, count; int32_t cur, count;
@ -347,12 +348,9 @@ typedef struct {
typedef struct { typedef struct {
uint32_t flags; uint32_t flags;
int32_t cacherange;
int16_t cacherange;
projectile_t defproj; projectile_t defproj;
} tiledata_t; } tiledata_t;
#pragma pack(pop)
typedef struct { typedef struct {
vec3_t pos; vec3_t pos;
@ -361,7 +359,6 @@ typedef struct {
int16_t sect; int16_t sect;
} camera_t; } camera_t;
// NOTE: not packed!
typedef struct { typedef struct {
]] .. table.concat(con_lang.wdata_members, ';')..';' .. [[ ]] .. table.concat(con_lang.wdata_members, ';')..';' .. [[
} weapondata_t; } weapondata_t;
@ -617,8 +614,8 @@ local function check_literal_am(am, typename)
end end
-- An unrestricted actor_t pointer, for internal use: -- An unrestricted actor_t pointer, for internal use:
local actor_ptr_ct = ffi.typeof("$ *", ffi.typeof("struct"..strip_const(ACTOR_STRUCT))) local actor_ptr_ct = ffi.typeof("$ *", ffi.typeof(strip_const(ACTOR_STRUCT)))
local player_ptr_ct = ffi.typeof("$ *", ffi.typeof("struct"..strip_const(DUKEPLAYER_STRUCT))) local player_ptr_ct = ffi.typeof("$ *", ffi.typeof(strip_const(DUKEPLAYER_STRUCT)))
local con_action_ct = ffi.typeof("con_action_t") local con_action_ct = ffi.typeof("con_action_t")
local con_move_ct = ffi.typeof("con_move_t") local con_move_ct = ffi.typeof("con_move_t")
local con_ai_ct = ffi.typeof("con_ai_t") local con_ai_ct = ffi.typeof("con_ai_t")

View file

@ -135,7 +135,6 @@ enum playeraction_t {
pfacing = 0x00010000 pfacing = 0x00010000
}; };
#pragma pack(push,1)
typedef struct { typedef struct {
int32_t ox,oy,oz; int32_t ox,oy,oz;
int16_t oa,os; int16_t oa,os;
@ -149,6 +148,14 @@ typedef struct {
char inven_icon, jetpack_on, heat_on; char inven_icon, jetpack_on, heat_on;
} DukeStatus_t; } DukeStatus_t;
typedef struct {
uint32_t bits; // 4b
int16_t fvel, svel; // 4b
int8_t avel, horz; // 2b
int8_t extbits, filler; // 2b
} input_t;
#pragma pack(push,1)
// XXX: r1625 changed a lot types here, among others // XXX: r1625 changed a lot types here, among others
// * int32_t --> int16_t // * int32_t --> int16_t
// * int16_t --> int8_t // * int16_t --> int8_t
@ -231,13 +238,6 @@ typedef struct {
int8_t padding_; int8_t padding_;
} DukePlayer_t; } DukePlayer_t;
typedef struct {
uint32_t bits; // 4b
int16_t fvel, svel; // 4b
int8_t avel, horz; // 2b
int8_t extbits, filler; // 2b
} input_t;
// KEEPINSYNC lunatic/defs.ilua // KEEPINSYNC lunatic/defs.ilua
typedef struct { typedef struct {
DukePlayer_t *ps; DukePlayer_t *ps;
@ -316,11 +316,9 @@ typedef struct {
int32_t shade; int32_t shade;
} hudweapon_t; } hudweapon_t;
#pragma pack(push,1)
extern input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS]; extern input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];
extern playerspawn_t g_playerSpawnPoints[MAXPLAYERS]; extern playerspawn_t g_playerSpawnPoints[MAXPLAYERS];
extern playerdata_t g_player[MAXPLAYERS]; extern playerdata_t g_player[MAXPLAYERS];
#pragma pack(pop)
//extern char dashow2dsector[(MAXSECTORS+7)>>3]; //extern char dashow2dsector[(MAXSECTORS+7)>>3];
//extern int16_t searchsect[MAXSECTORS],searchparent[MAXSECTORS]; //extern int16_t searchsect[MAXSECTORS],searchparent[MAXSECTORS];
extern int16_t WeaponPickupSprites[MAX_WEAPONS]; extern int16_t WeaponPickupSprites[MAX_WEAPONS];