mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 04:00:42 +00:00
- SW: serialize SO interpolations as JSON.
This commit is contained in:
parent
2d571586bd
commit
c49c5fcf1d
3 changed files with 36 additions and 54 deletions
|
@ -30,6 +30,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
|
||||
#include "game.h"
|
||||
#include "interpso.h"
|
||||
#include "serializer.h"
|
||||
#include "names2.h"
|
||||
|
||||
BEGIN_SW_NS
|
||||
|
@ -398,58 +399,46 @@ void so_restoreinterpolations(void) // Stick at end of drawscree
|
|||
}
|
||||
}
|
||||
|
||||
int SaveSymDataInfo(MFILE_WRITE fil, void *ptr);
|
||||
|
||||
int so_writeinterpolations(MFILE_WRITE fil)
|
||||
void so_serializeinterpolations(FSerializer& arc)
|
||||
{
|
||||
int32_t i;
|
||||
SECTOR_OBJECTp sop;
|
||||
so_interp *interp;
|
||||
int saveisshot = 0;
|
||||
so_interp* interp;
|
||||
|
||||
for (sop = SectorObject, interp = so_interpdata;
|
||||
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
|
||||
if (arc.BeginArray("sop_interp"))
|
||||
{
|
||||
so_interp::interp_data *data = interp->data;
|
||||
MWRITE(&interp->numinterpolations,sizeof(interp->numinterpolations),1,fil);
|
||||
MWRITE(&interp->hasvator,sizeof(interp->hasvator),1,fil);
|
||||
for (i = 0; i < interp->numinterpolations; i++, data++)
|
||||
for (sop = SectorObject, interp = so_interpdata; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
|
||||
{
|
||||
MWRITE(&data->curelement, sizeof(data->curelement), 1, fil);
|
||||
MWRITE(&data->oldipos,sizeof(data->oldipos),1,fil);
|
||||
MWRITE(&data->spriteofang,sizeof(data->spriteofang),1,fil);
|
||||
if (arc.BeginObject(nullptr))
|
||||
{
|
||||
so_interp::interp_data* data = interp->data;
|
||||
arc("numinterp", interp->numinterpolations)
|
||||
("hasvator", interp->hasvator);
|
||||
if (arc.BeginArray("data"))
|
||||
{
|
||||
for (int i = 0; i < interp->numinterpolations; i++, data++)
|
||||
{
|
||||
if (arc.BeginObject(nullptr))
|
||||
{
|
||||
arc("curelement", data->curelement)
|
||||
("oldipos", data->oldipos)
|
||||
("spriteofang", data->spriteofang)
|
||||
.EndObject();
|
||||
if (arc.isReading())
|
||||
{
|
||||
data->lastipos = data->lastoldipos = data->oldipos;
|
||||
data->lastangdiff = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
arc.EndArray();
|
||||
}
|
||||
arc.EndObject();
|
||||
interp->tic = 0;
|
||||
interp->lasttic = synctics;
|
||||
}
|
||||
}
|
||||
arc.EndArray();
|
||||
}
|
||||
return saveisshot;
|
||||
}
|
||||
|
||||
int LoadSymDataInfo(MFILE_READ fil, void** ptr);
|
||||
|
||||
int so_readinterpolations(MFILE_READ fil)
|
||||
{
|
||||
int32_t i;
|
||||
SECTOR_OBJECTp sop;
|
||||
so_interp *interp;
|
||||
int saveisshot = 0;
|
||||
|
||||
for (sop = SectorObject, interp = so_interpdata;
|
||||
sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++, interp++)
|
||||
{
|
||||
so_interp::interp_data *data = interp->data;
|
||||
MREAD(&interp->numinterpolations,sizeof(interp->numinterpolations),1,fil);
|
||||
MREAD(&interp->hasvator,sizeof(interp->hasvator),1,fil);
|
||||
for (i = 0; i < interp->numinterpolations; i++, data++)
|
||||
{
|
||||
MREAD(&data->curelement, sizeof(data->curelement), 1, fil);
|
||||
MREAD(&data->oldipos,sizeof(data->oldipos),1,fil);
|
||||
MREAD(&data->spriteofang,sizeof(data->spriteofang),1,fil);
|
||||
data->lastipos = data->lastoldipos = data->oldipos;
|
||||
data->lastangdiff = 0;
|
||||
}
|
||||
interp->tic = 0;
|
||||
interp->lasttic = synctics;
|
||||
}
|
||||
return saveisshot;
|
||||
}
|
||||
|
||||
END_SW_NS
|
||||
|
|
|
@ -41,8 +41,7 @@ void so_setinterpolationtics(SECTOR_OBJECTp sop, int16_t locktics);
|
|||
void so_updateinterpolations(void);
|
||||
void so_dointerpolations(int32_t smoothratio);
|
||||
void so_restoreinterpolations(void);
|
||||
int so_writeinterpolations(MFILE_WRITE fil);
|
||||
int so_readinterpolations(MFILE_READ fil);
|
||||
void so_serializeinterpolations(FSerializer& arc);
|
||||
|
||||
END_SW_NS
|
||||
|
||||
|
|
|
@ -1178,6 +1178,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
|||
preSerializePanelSprites(arc);
|
||||
SerializeUser(arc);
|
||||
SerializeSectUser(arc);
|
||||
so_serializeinterpolations(arc);
|
||||
arc("numplayers", numplayers)
|
||||
.Array("players", Player, numplayers)
|
||||
("skill", Skill)
|
||||
|
@ -1422,10 +1423,6 @@ bool GameInterface::SaveGame()
|
|||
#endif
|
||||
#endif
|
||||
|
||||
// SO interpolations
|
||||
saveisshot |= so_writeinterpolations(fil);
|
||||
assert(!saveisshot);
|
||||
|
||||
return !saveisshot;
|
||||
}
|
||||
|
||||
|
@ -1525,9 +1522,6 @@ bool GameInterface::LoadGame()
|
|||
#endif
|
||||
#endif
|
||||
|
||||
// SO interpolations
|
||||
saveisshot |= so_readinterpolations(fil);
|
||||
if (saveisshot) { MCLOSE_READ(fil); return false; }
|
||||
MCLOSE_READ(fil);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue