mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-21 10:57:15 -04:00
save button states in savegames (#2165)
* save button states in savegames Mostly taken from Doom Retro. * simplify loop * simplify restoring button state
This commit is contained in:
parent
4089139a7a
commit
9a889301e0
@ -2005,6 +2005,41 @@ static void saveg_write_rng_t(rng_t *str)
|
||||
saveg_write32(str->prndindex);
|
||||
}
|
||||
|
||||
//
|
||||
// button_t
|
||||
//
|
||||
|
||||
static void saveg_read_button_t(button_t *str)
|
||||
{
|
||||
// line_t *line
|
||||
int line = saveg_read32();
|
||||
str->line = &lines[line];
|
||||
|
||||
// bwhere_e where
|
||||
str->where = (bwhere_e)saveg_read32();
|
||||
|
||||
// int btexture
|
||||
str->btexture = saveg_read32();
|
||||
|
||||
// int btimer
|
||||
str->btimer = saveg_read32();
|
||||
}
|
||||
|
||||
static void saveg_write_button_t(button_t *str)
|
||||
{
|
||||
// line_t *line
|
||||
saveg_write32(str->line - lines);
|
||||
|
||||
// bwhere_e where
|
||||
saveg_write32((int)str->where);
|
||||
|
||||
// int btexture
|
||||
saveg_write32(str->btexture);
|
||||
|
||||
// int btimer
|
||||
saveg_write32(str->btimer);
|
||||
}
|
||||
|
||||
//
|
||||
// P_ArchivePlayers
|
||||
//
|
||||
@ -2463,7 +2498,8 @@ enum {
|
||||
tc_pusher, // phares 3/22/98: new push/pull effect thinker
|
||||
tc_flicker, // killough 10/4/98
|
||||
tc_endspecials,
|
||||
tc_friction // store friction for complevel Boom
|
||||
tc_friction, // store friction for complevel Boom
|
||||
tc_button,
|
||||
} specials_e;
|
||||
|
||||
//
|
||||
@ -2653,6 +2689,18 @@ void P_ArchiveSpecials (void)
|
||||
}
|
||||
}
|
||||
|
||||
CheckSaveGame(MAXBUTTONS * sizeof(button_t));
|
||||
|
||||
for (int i = 0; i < MAXBUTTONS; i++)
|
||||
{
|
||||
if (buttonlist[i].btimer != 0)
|
||||
{
|
||||
saveg_write8(tc_button);
|
||||
saveg_write_pad();
|
||||
saveg_write_button_t(&buttonlist[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// add a terminating marker
|
||||
saveg_write8(tc_endspecials);
|
||||
}
|
||||
@ -2811,6 +2859,13 @@ void P_UnArchiveSpecials (void)
|
||||
break;
|
||||
}
|
||||
|
||||
case tc_button:
|
||||
saveg_read_pad();
|
||||
button_t button;
|
||||
saveg_read_button_t(&button);
|
||||
P_StartButton(button.line, button.where, button.btexture, button.btimer);
|
||||
break;
|
||||
|
||||
default:
|
||||
I_Error ("P_UnarchiveSpecials:Unknown tclass %i "
|
||||
"in savegame",tclass);
|
||||
|
@ -536,6 +536,8 @@ typedef struct
|
||||
struct mobj_s *soundorg;
|
||||
} button_t;
|
||||
|
||||
void P_StartButton(struct line_s *line, bwhere_e w, int texture, int time);
|
||||
|
||||
// p_lights
|
||||
|
||||
typedef struct
|
||||
|
Loading…
x
Reference in New Issue
Block a user