Commit 687000e2 authored by Richard Gobeille's avatar Richard Gobeille

Duke3d: savegame format update WIP

parent 02d5b61e
This diff is collapsed.
......@@ -125,24 +125,29 @@ typedef struct
{
int32_t t_data[10]; // 40b sometimes used to hold offsets to con code
int32_t flags; // 4b
vec3_t bpos; // 12b
int32_t floorz, ceilingz; // 8b
vec2_t lastv; // 8b
int16_t picnum, ang, extra, owner; // 8b
int16_t movflag, tempang, timetosleep; // 6b
int16_t stayput; // 2b
uint8_t cgg, lasttransport; // 2b
// NOTE: 'dispicnum' is updated every frame, not in sync with game tics!
int16_t dispicnum; // 2b
uint32_t flags; // 4b
vec3_t bpos; // 12b
int32_t floorz, ceilingz; // 8b
vec2_t lastv; // 8b
int16_t picnum, ang; // 4b
int16_t extra, owner; // 4b
int16_t movflag, tempang; // 4b
int16_t timetosleep, stayput; // 4b
uint16_t florhit, lzsum; // 4b
int16_t dispicnum; // 2b NOTE: updated every frame, not in sync with game tics!
uint8_t cgg, lasttransport; // 2b
} actor_t;
EDUKE32_STATIC_ASSERT(sizeof(actor_t) == 96);
#ifdef POLYMER
int16_t lightId, lightmaxrange; // 4b
typedef struct
{
_prlight *lightptr; // 4b/8b aligned on 96 bytes
uint8_t lightcount, filler[3];
int16_t lightId, lightmaxrange; // 4b
uint8_t lightcount, filler[3]; // 4b
} practor_t;
#endif
} actor_t;
// note: fields in this struct DO NOT have to be in this order,
// however if you add something to this struct, please make sure
......@@ -298,7 +303,7 @@ typedef struct
} tiledata_t;
enum sflags_t
enum sflags_t : unsigned int
{
SFLAG_SHADOW = 0x00000001,
SFLAG_NVG = 0x00000002,
......@@ -331,11 +336,14 @@ enum sflags_t
SFLAG_DAMAGEEVENT = 0x04000000,
SFLAG_NOWATERSECTOR = 0x08000000,
SFLAG_QUEUEDFORDELETE = 0x10000000,
SFLAG_RESERVED = 0x20000000,
SFLAG_RESERVED2 = 0x40000000,
SFLAG_RESERVED3 = 0x80000000,
};
// Custom projectiles "workslike" flags.
// XXX: Currently not predefined from CON.
enum pflags_t
enum pflags_t : unsigned int
{
PROJECTILE_HITSCAN = 0x00000001,
PROJECTILE_RPG = 0x00000002,
......@@ -366,6 +374,9 @@ enum pflags_t
extern tiledata_t g_tile[MAXTILES];
extern actor_t actor[MAXSPRITES];
#ifdef POLYMER
extern practor_t practor[MAXSPRITES];
#endif
extern int32_t block_deletesprite;
extern int32_t g_noEnemies;
extern int32_t otherp;
......
......@@ -57,7 +57,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#endif
// increase by 3, because atomic GRP adds 1, and Shareware adds 2
#define BYTEVERSION_EDUKE32 339
#define BYTEVERSION_EDUKE32 342
//#define BYTEVERSION_13 27
//#define BYTEVERSION_14 116
......
......@@ -1357,10 +1357,11 @@ int32_t A_InsertSprite(int16_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int1
a.stayput = -1;
a.extra = -1;
a.owner = s_ow;
#ifdef POLYMER
a.lightId = -1;
practor[newSprite].lightId = -1;
#endif
a.owner = s_ow;
G_InitActor(newSprite, s_pn, 1);
......@@ -1451,10 +1452,11 @@ int A_Spawn(int spriteNum, int tileNum)
a.floorz = sector[s.sectnum].floorz;
a.ceilingz = sector[s.sectnum].ceilingz;
a.stayput = a.extra = -1;
a.stayput = a.extra = -1;
a.florhit = a.lzsum = 0;
#ifdef POLYMER
a.lightId = -1;
practor[newSprite].lightId = -1;
#endif
if ((s.cstat & 48)
......@@ -2675,7 +2677,7 @@ int A_Spawn(int spriteNum, int tileNum)
if (pSprite->yrepeat > 32)
{
G_AddGameLight(0, newSprite, ((pSprite->yrepeat*tilesiz[pSprite->picnum].y)<<1), 32768, 255+(95<<8),PR_LIGHT_PRIO_MAX_GAME);
pActor->lightcount = 2;
practor[newSprite].lightcount = 2;
}
fallthrough__;
#endif
......@@ -4204,8 +4206,13 @@ PALONLY:
if (G_TileHasActor(pSprite->picnum))
{
if ((unsigned)scrofs_action + ACTION_PARAM_COUNT > (unsigned)g_scriptSize)
if ((unsigned)scrofs_action + ACTION_PARAM_COUNT > (unsigned)g_scriptSize || apScript[scrofs_action + ACTION_PARAM_COUNT] != CON_ACTION)
{
if (scrofs_action)
OSD_Printf("Sprite %d tile %d: invalid action at offset %d\n", i, pSprite->picnum, scrofs_action);
goto skip;
}
int32_t viewtype = apScript[scrofs_action + ACTION_VIEWTYPE];
uint16_t const action_flags = apScript[scrofs_action + ACTION_FLAGS];
......@@ -4264,6 +4271,8 @@ PALONLY:
t->picnum += frameOffset + apScript[scrofs_action + ACTION_STARTFRAME] + viewtype*curframe;
// XXX: t->picnum can be out-of-bounds by bad user code.
Bassert((unsigned)t->picnum < MAXTILES);
if (viewtype > 0)
while (tilesiz[t->picnum].x == 0 && t->picnum > 0)
t->picnum -= l; //Hack, for actors
......
......@@ -77,7 +77,7 @@ enum GametypeFlags_t {
};
// logo control
enum LogoFlags_t {
enum LogoFlags_t : unsigned int {
LOGO_ENABLED = 0x00000001,
LOGO_PLAYANIM = 0x00000002,
LOGO_PLAYMUSIC = 0x00000004,
......
......@@ -54,7 +54,6 @@ char g_scriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling
int32_t g_totalLines;
int32_t g_lineNumber;
uint32_t g_scriptcrc;
char g_szBuf[1024];
static char *textptr;
......@@ -136,7 +135,6 @@ static hashtable_t *const tables[] = {
static hashtable_t *const tables_free[] = {
&h_iter,
&h_keywords,
&h_labels,
};
static tokenmap_t const vm_keywords[] =
......@@ -1960,7 +1958,6 @@ static void C_Include(const char *confile)
kclose(fp);
mptr[len] = 0;
g_scriptcrc = Bcrc32(mptr, len, g_scriptcrc);
if (*textptr == '"') // skip past the closing quote if it's there so we don't screw up the next line
textptr++;
......@@ -6348,9 +6345,6 @@ void C_Compile(const char *fileName)
kread(kFile, (char *)textptr, kFileLen);
kclose(kFile);
g_scriptcrc = Bcrc32(NULL, 0, 0L);
g_scriptcrc = Bcrc32(textptr, kFileLen, g_scriptcrc);
Xfree(apScript);
apScript = (intptr_t *)Xcalloc(1, g_scriptSize * sizeof(intptr_t));
......
......@@ -6536,8 +6536,9 @@ void G_SaveMapState(void)
for (native_t i=g_gameVarCount-1; i>=0; i--)
{
if (aGameVars[i].flags & GAMEVAR_NORESET)
if (aGameVars[i].flags & SAVEGAMEMAPSTATEVARSKIPMASK)
continue;
if (aGameVars[i].flags & GAMEVAR_PERPLAYER)
{
if (!save->vars[i])
......@@ -6556,7 +6557,7 @@ void G_SaveMapState(void)
for (native_t i=g_gameArrayCount-1; i>=0; i--)
{
if ((aGameArrays[i].flags & GAMEARRAY_RESTORE) == 0)
if (aGameArrays[i].flags & SAVEGAMEMAPSTATEARRAYSKIPMASK)
continue;
save->arraysiz[i] = aGameArrays[i].size;
......@@ -6650,8 +6651,9 @@ void G_RestoreMapState(void)
for (native_t i=g_gameVarCount-1; i>=0; i--)
{
if (aGameVars[i].flags & GAMEVAR_NORESET)
if (aGameVars[i].flags & SAVEGAMEMAPSTATEVARSKIPMASK)
continue;
if (aGameVars[i].flags & GAMEVAR_PERPLAYER)
{
if (!pSavedState->vars[i])
......@@ -6670,7 +6672,7 @@ void G_RestoreMapState(void)
for (native_t i=g_gameArrayCount-1; i>=0; i--)
{
if ((aGameArrays[i].flags & GAMEARRAY_RESTORE) == 0)
if (aGameArrays[i].flags & SAVEGAMEMAPSTATEARRAYSKIPMASK)
continue;
aGameArrays[i].size = pSavedState->arraysiz[i];
......
This diff is collapsed.
......@@ -35,6 +35,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define GV_FLAG_ARRAY (MAXGAMEVARS<<2)
#define GV_FLAG_STRUCT (MAXGAMEVARS<<3)
#define SAVEGAMEVARSKIPMASK (GAMEVAR_READONLY|GAMEVAR_SPECIAL)
#define SAVEGAMEARRAYSKIPMASK (GAMEARRAY_READONLY|GAMEARRAY_SYSTEM)
#define SAVEGAMEMAPSTATEVARSKIPMASK (GAMEVAR_NORESET|SAVEGAMEVARSKIPMASK)
#define SAVEGAMEMAPSTATEARRAYSKIPMASK (SAVEGAMEARRAYSKIPMASK|~GAMEARRAY_RESTORE)
// store global game definitions
enum GamevarFlags_t
{
......
......@@ -65,6 +65,9 @@ enum DUKE3D_GLOBALFLAGS {
G_EXTERN DukeStatus_t sbar;
G_EXTERN actor_t actor[MAXSPRITES];
#ifdef POLYMER
G_EXTERN practor_t practor[MAXSPRITES];
#endif
// g_tile: tile-specific data THAT DOES NOT CHANGE during the course of a game
G_EXTERN tiledata_t g_tile[MAXTILES];
G_EXTERN animwalltype animwall[MAXANIMWALLS];
......
......@@ -815,11 +815,11 @@ void onvideomodechange(int32_t newmode)
while (i < MAXSPRITES)
{
if (actor[i].lightptr)
if (practor[i].lightptr)
{
polymer_deletelight(actor[i].lightId);
actor[i].lightptr = NULL;
actor[i].lightId = -1;
polymer_deletelight(practor[i].lightId);
practor[i].lightptr = NULL;
practor[i].lightId = -1;
}
i++;
}
......
......@@ -865,7 +865,7 @@ static int A_ShootCustom(int const spriteNum, int const projecTile, int shootAng
pSprite->x += x;
pSprite->y += y;
G_AddGameLight(0, spriteNum, PHEIGHT, 8192, pProj->flashcolor, PR_LIGHT_PRIO_MAX_GAME);
actor[spriteNum].lightcount = 2;
practor[spriteNum].lightcount = 2;
pSprite->x -= x;
pSprite->y -= y;
}
......@@ -1714,7 +1714,7 @@ int A_ShootWithZvel(int const spriteNum, int const projecTile, int const forceZv
pSprite->x += v.x;
pSprite->y += v.y;
G_AddGameLight(0, spriteNum, PHEIGHT, 8192, 255 + (95 << 8), PR_LIGHT_PRIO_MAX_GAME);
actor[spriteNum].lightcount = 2;
practor[spriteNum].lightcount = 2;
pSprite->x -= v.x;
pSprite->y -= v.y;
}
......@@ -2068,7 +2068,7 @@ static void P_FireWeapon(int playerNum)
s->y += y;
G_AddGameLight(0, pPlayer->i, PHEIGHT, 8192, PWEAPON(playerNum, pPlayer->curr_weapon, FlashColor),
PR_LIGHT_PRIO_MAX_GAME);
actor[pPlayer->i].lightcount = 2;
practor[pPlayer->i].lightcount = 2;
s->x -= x;
s->y -= y;
#endif // POLYMER
......@@ -4127,7 +4127,7 @@ static void P_ProcessWeapon(int playerNum)
G_AddGameLight(0, pPlayer->i, PHEIGHT, max(glowRange, 0),
PWEAPON(playerNum, pPlayer->curr_weapon, FlashColor), PR_LIGHT_PRIO_HIGH_GAME);
actor[pPlayer->i].lightcount = 2;
practor[pPlayer->i].lightcount = 2;
pSprite->x -= glowXOffset;
pSprite->y -= glowYOffset;
......
......@@ -153,9 +153,14 @@ typedef struct {
int32_t autostep, autostep_sbw;
uint32_t interface_toggle;
palette_t pals;
uint16_t max_actors_killed, actors_killed;
uint16_t gotweapon, zoom;
uint16_t frag, fraggedself;
int16_t loogiex[64], loogiey[64], sbs, sound_pitch;
int16_t cursectnum, look_ang, last_extra, subweapon;
......@@ -177,8 +182,7 @@ typedef struct {
int16_t transporter_hold, clipdist;
uint8_t max_secret_rooms, secret_rooms;
// XXX: 255 values for frag(gedself) seems too small.
uint8_t frag, fraggedself, quick_kick, last_quick_kick;
uint8_t quick_kick, last_quick_kick;
uint8_t return_to_center, reloading, weapreccnt;
uint8_t aim_mode, auto_aim, weaponswitch, movement_lock, team;
uint8_t tipincs, hbomb_hold_delay, frag_ps, kickback_pic;
......@@ -200,14 +204,14 @@ typedef struct {
int8_t last_weapon, cheat_phase, weapon_pos, wantweaponfire, curr_weapon;
uint8_t palette;
palette_t pals;
int8_t last_used_weapon;
int8_t crouch_toggle;
int8_t padding_[3];
int8_t padding_[1];
} DukePlayer_t;
EDUKE32_STATIC_ASSERT(sizeof(DukePlayer_t) % 4 == 0);
typedef struct
{
DukePlayer_t *ps;
......
This diff is collapsed.
......@@ -33,7 +33,7 @@ extern "C" {
#define SV_MAJOR_VER 1
#define SV_MINOR_VER 7
#pragma pack(push,1)
typedef struct _savehead
{
......@@ -54,7 +54,11 @@ typedef struct _savehead
char savename[MAXSAVEGAMENAMESTRUCT];
uint8_t numplayers, volnum, levnum, skill;
char boardfn[BMAX_PATH];
// this is kind of shitty, but changing the size of savehead_t would break the checkpoint saves in Fury
char boardfn[BMAX_PATH-16];
char scriptname[16];
// 286 bytes
#ifdef __ANDROID__
char skillname[32], volname[32];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment