The g? structs had a mix of variables that were written to
the savefile, and those that were not.
For better clarity and to distinguish those that end up in
the savefile, relocate some g? variables that get written
directly to the savefile into different structs.
This updates EDITLEVEL, although technically it probably
didn't need to, since savefile contents are not changing.
Details:
gb.bases -> svb.bases
gb.bbubbles -> svb.bbubbles
gb.branches -> svb.branches
gc.context -> svc.context
gd.disco -> svd.disco
gd.dndest -> svd.dndest
gd.doors -> svd.doors
gd.doors_alloc -> svd.doors_alloc
gd.dungeon_topology -> svd.dungeon_topology
gd.dungeons -> svd.dungeons
ge.exclusion_zones -> sve.exclusion_zones
gh.hackpid -> svh.hackpid
gi.inv_pos -> svi.inv_pos
gk.killer -> svk.killer
gl.lastseentyp -> svl.lastseentyp
gl.level -> svl.level
gl.level_info -> svl.level_info
gm.mapseenchn -> svm.mapseenchn
gm.moves -> svm.moves
gm.mvitals -> svm.mvitals
gn.n_dgns -> svn.n_dgns
gn.n_regions -> svn.n_regions
gn.nroom -> svn.nroom
go.oracle_cnt -> svo.oracle_cnt
gp.pl_character -> svp.pl_character
gp.pl_fruit -> svp.pl_fruit
gp.plname -> svp.plname
gp.program_state -> svp.program_state
gq.quest_status -> svq.quest_status
gr.rooms -> svr.rooms
gs.sp_levchn -> svs.sp_levchn
gs.spl_book -> svs.spl_book
gt.timer_id -> svt.timer_id
gt.tune -> svt.tune
gu.updest -> svu.updest
gx.xmax -> svx.xmax
gx.xmin -> svx.xmin
gy.ymax -> svy.ymax
gy.ymin -> svy.ymin
Related note:
There are some pointer variables that are heads of chains that were not
moved from 'g?' to 'sv?', because they are not actually written to the
savefile directly, but the objects/monst/trap/lightsource/timer in the
chains they point to are. That can be changed, if desired.
Examples: gi.invent, gm.migrating_objs, gb.billobjs, gm.migrating_mons,
gf.ftrap, gl.light_base, gt.timer_base
119 lines
2.7 KiB
C
119 lines
2.7 KiB
C
/* NetHack 3.6 mhinput.c $NHDT-Date: 1432512798 2015/05/25 00:13:18 $ $NHDT-Branch: master $:$NHDT-Revision: 1.11 $ */
|
|
/* Copyright (C) 2001 by Alex Kompel */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
#include <assert.h>
|
|
#include "winMS.h"
|
|
#include "mhinput.h"
|
|
|
|
/* nethack input queue functions */
|
|
|
|
#define NH_INPUT_BUFFER_SIZE 64
|
|
|
|
/* as it stands right now we need only one slot
|
|
since events are processed almost the same time as
|
|
they occur but I like large round numbers */
|
|
|
|
static MSNHEvent nhi_input_buffer[NH_INPUT_BUFFER_SIZE];
|
|
static int nhi_init_input = 0;
|
|
static int nhi_read_pos = 0;
|
|
static int nhi_write_pos = 0;
|
|
|
|
/* initialize input queue */
|
|
void
|
|
mswin_nh_input_init()
|
|
{
|
|
if (!nhi_init_input) {
|
|
nhi_init_input = 1;
|
|
|
|
ZeroMemory(nhi_input_buffer, sizeof(nhi_input_buffer));
|
|
nhi_read_pos = 0;
|
|
nhi_write_pos = 0;
|
|
}
|
|
}
|
|
|
|
/* check for input */
|
|
int
|
|
mswin_have_input()
|
|
{
|
|
return
|
|
#ifdef SAFERHANGUP
|
|
/* we always have input (ESC) if hangup was requested */
|
|
svp.program_state.done_hup ||
|
|
#endif
|
|
(nhi_read_pos != nhi_write_pos);
|
|
}
|
|
|
|
/* add event to the queue */
|
|
void
|
|
mswin_input_push(PMSNHEvent event)
|
|
{
|
|
int new_write_pos;
|
|
|
|
if (!nhi_init_input)
|
|
mswin_nh_input_init();
|
|
|
|
new_write_pos = (nhi_write_pos + 1) % NH_INPUT_BUFFER_SIZE;
|
|
|
|
if (new_write_pos != nhi_read_pos) {
|
|
memcpy(nhi_input_buffer + nhi_write_pos, event, sizeof(*event));
|
|
nhi_write_pos = new_write_pos;
|
|
}
|
|
}
|
|
|
|
/* get event from the queue and delete it */
|
|
PMSNHEvent
|
|
mswin_input_pop()
|
|
{
|
|
PMSNHEvent retval;
|
|
|
|
#ifdef SAFERHANGUP
|
|
/* always return ESC when hangup was requested */
|
|
if (svp.program_state.done_hup) {
|
|
static MSNHEvent hangup_event;
|
|
hangup_event.type = NHEVENT_CHAR;
|
|
hangup_event.kbd.ch = '\033';
|
|
return &hangup_event;
|
|
}
|
|
#endif
|
|
|
|
if (!nhi_init_input)
|
|
mswin_nh_input_init();
|
|
|
|
if (nhi_read_pos != nhi_write_pos) {
|
|
retval = &nhi_input_buffer[nhi_read_pos];
|
|
nhi_read_pos = (nhi_read_pos + 1) % NH_INPUT_BUFFER_SIZE;
|
|
} else {
|
|
retval = NULL;
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
|
|
/* get event from the queue but leave it there */
|
|
PMSNHEvent
|
|
mswin_input_peek()
|
|
{
|
|
PMSNHEvent retval;
|
|
|
|
#ifdef SAFERHANGUP
|
|
/* always return ESC when hangup was requested */
|
|
if (svp.program_state.done_hup) {
|
|
static MSNHEvent hangup_event;
|
|
hangup_event.type = NHEVENT_CHAR;
|
|
hangup_event.kbd.ch = '\033';
|
|
return &hangup_event;
|
|
}
|
|
#endif
|
|
|
|
if (!nhi_init_input)
|
|
mswin_nh_input_init();
|
|
|
|
if (nhi_read_pos != nhi_write_pos) {
|
|
retval = &nhi_input_buffer[nhi_read_pos];
|
|
} else {
|
|
retval = NULL;
|
|
}
|
|
return retval;
|
|
}
|