split g into multiple structures
The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.
It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.
Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.
To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.
A global variable named 'amulets', would be found in ga.
ga.amulets
^ ^
A global varable named 'move', would be found in gm.
gm.moves
^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
gv.val_for_n_or_more
^ ^
A global variable named 'youmonst' would be found in gy.
gy.youmonst
^ ^
This commit is contained in:
@@ -288,7 +288,7 @@ saveDiskPrompt(start)
|
||||
BPTR fileLock;
|
||||
if (sysflags.asksavedisk) {
|
||||
/* Don't prompt if you can find the save file */
|
||||
if (fileLock = Lock(g.SAVEF, SHARED_LOCK)) {
|
||||
if (fileLock = Lock(gs.SAVEF, SHARED_LOCK)) {
|
||||
UnLock(fileLock);
|
||||
#if defined(TTY_GRAPHICS)
|
||||
if (windowprocs.win_init_nhwindows
|
||||
@@ -303,7 +303,7 @@ saveDiskPrompt(start)
|
||||
return 1;
|
||||
}
|
||||
pline("If save file is on a SAVE disk, put that disk in now.");
|
||||
if (strlen(g.SAVEF) > QBUFSZ - 25 - 22)
|
||||
if (strlen(gs.SAVEF) > QBUFSZ - 25 - 22)
|
||||
panic("not enough buffer space for prompt");
|
||||
/* THIS IS A HACK */
|
||||
#if defined(TTY_GRAPHICS)
|
||||
@@ -314,7 +314,7 @@ saveDiskPrompt(start)
|
||||
#endif
|
||||
#if defined(AMII_GRAPHICS)
|
||||
if (windowprocs.win_init_nhwindows == amii_procs.win_init_nhwindows) {
|
||||
getlind("File name ?", buf, g.SAVEF);
|
||||
getlind("File name ?", buf, gs.SAVEF);
|
||||
clear_nhwindow(WIN_BASE);
|
||||
}
|
||||
#endif
|
||||
@@ -323,11 +323,11 @@ saveDiskPrompt(start)
|
||||
return 0;
|
||||
|
||||
/* Strip any whitespace. Also, if nothing was entered except
|
||||
* whitespace, do not change the value of g.SAVEF.
|
||||
* whitespace, do not change the value of gs.SAVEF.
|
||||
*/
|
||||
for (bp = buf; *bp; bp++) {
|
||||
if (!isspace(*bp)) {
|
||||
strncpy(g.SAVEF, bp, PATHLEN);
|
||||
strncpy(gs.SAVEF, bp, PATHLEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,12 +185,12 @@ time_t when;
|
||||
SetDrMd(rp, JAM1);
|
||||
|
||||
/* Put name on stone */
|
||||
Sprintf(buf, "%s", g.plname);
|
||||
Sprintf(buf, "%s", gp.plname);
|
||||
buf[STONE_LINE_LEN] = 0;
|
||||
tomb_text(buf);
|
||||
|
||||
/* Put $ on stone */
|
||||
Sprintf(buf, "%ld Au", g.done_money);
|
||||
Sprintf(buf, "%ld Au", gd.done_money);
|
||||
buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
|
||||
tomb_text(buf);
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ menu_item **retmip;
|
||||
nw->Screen = HackScreen;
|
||||
|
||||
if (win == WIN_INVEN) {
|
||||
sprintf(title, "%s the %s's Inventory", g.plname, g.pl_character);
|
||||
sprintf(title, "%s the %s's Inventory", gp.plname, gp.pl_character);
|
||||
nw->Title = title;
|
||||
if (lastinvent.MaxX != 0) {
|
||||
nw->LeftEdge = lastinvent.MinX;
|
||||
|
||||
@@ -437,10 +437,10 @@ amii_askname()
|
||||
amii_getlin("Who are you?", plnametmp);
|
||||
} while (strlen(plnametmp) == 0);
|
||||
|
||||
strncpy(g.plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */
|
||||
g.plname[PL_NSIZ - 1] = 0;
|
||||
strncpy(gp.plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */
|
||||
gp.plname[PL_NSIZ - 1] = 0;
|
||||
|
||||
if (*g.plname == '\33') {
|
||||
if (*gp.plname == '\33') {
|
||||
clearlocks();
|
||||
exit_nhwindows(NULL);
|
||||
nh_terminate(0);
|
||||
@@ -474,9 +474,9 @@ amii_player_selection()
|
||||
#if 0 /* Don't query the user ... instead give random character -jhsa */
|
||||
|
||||
#if 0 /* OBSOLETE */
|
||||
if( *g.pl_character ){
|
||||
g.pl_character[ 0 ] = toupper( g.pl_character[ 0 ] );
|
||||
if( strchr( pl_classes, g.pl_character[ 0 ] ) )
|
||||
if( *gp.pl_character ){
|
||||
gp.pl_character[ 0 ] = toupper( gp.pl_character[ 0 ] );
|
||||
if( strchr( pl_classes, gp.pl_character[ 0 ] ) )
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -530,19 +530,19 @@ amii_player_selection()
|
||||
case VANILLAKEY:
|
||||
if( strchr( pl_classes, toupper( code ) ) )
|
||||
{
|
||||
g.pl_character[0] = toupper( code );
|
||||
gp.pl_character[0] = toupper( code );
|
||||
aredone = 1;
|
||||
}
|
||||
else if( code == ' ' || code == '\n' || code == '\r' )
|
||||
{
|
||||
flags.initrole = randrole(FALSE);
|
||||
#if 0 /* OBSOLETE */
|
||||
strcpy( g.pl_character, roles[ rnd( 11 ) ] );
|
||||
strcpy( gp.pl_character, roles[ rnd( 11 ) ] );
|
||||
#endif
|
||||
aredone = 1;
|
||||
amii_clear_nhwindow( WIN_BASE );
|
||||
CloseShWindow( cwin );
|
||||
RandomWindow( g.pl_character );
|
||||
RandomWindow( gp.pl_character );
|
||||
return;
|
||||
}
|
||||
else if( code == 'q' || code == 'Q' )
|
||||
@@ -562,15 +562,15 @@ amii_player_selection()
|
||||
case 1: /* Random Character */
|
||||
flags.initrole = randrole(FALSE);
|
||||
#if 0 /* OBSOLETE */
|
||||
strcpy( g.pl_character, roles[ rnd( 11 ) ] );
|
||||
strcpy( gp.pl_character, roles[ rnd( 11 ) ] );
|
||||
#endif
|
||||
amii_clear_nhwindow( WIN_BASE );
|
||||
CloseShWindow( cwin );
|
||||
RandomWindow( g.pl_character );
|
||||
RandomWindow( gp.pl_character );
|
||||
return;
|
||||
|
||||
default:
|
||||
g.pl_character[0] = gd->GadgetID;
|
||||
gp.pl_character[0] = gd->GadgetID;
|
||||
break;
|
||||
}
|
||||
aredone = 1;
|
||||
|
||||
@@ -81,8 +81,8 @@ const char *str;
|
||||
|
||||
while (isspace(*str))
|
||||
str++;
|
||||
strncpy(g.toplines, str, TBUFSZ);
|
||||
g.toplines[TBUFSZ - 1] = 0;
|
||||
strncpy(gt.toplines, str, TBUFSZ);
|
||||
gt.toplines[TBUFSZ - 1] = 0;
|
||||
|
||||
/* For initial message to be visible, we need to explicitly position
|
||||
* the
|
||||
@@ -101,15 +101,15 @@ const char *str;
|
||||
memcpy(cw->data, &cw->data[1],
|
||||
(iflags.msg_history - 1) * sizeof(char *));
|
||||
cw->data[iflags.msg_history - 1] =
|
||||
(char *) alloc(strlen(g.toplines) + 5);
|
||||
(char *) alloc(strlen(gt.toplines) + 5);
|
||||
strcpy(cw->data[i = iflags.msg_history - 1] + SOFF
|
||||
+ (scrollmsg != 0),
|
||||
g.toplines);
|
||||
gt.toplines);
|
||||
} else {
|
||||
/* Otherwise, allocate a new one and copy the line in */
|
||||
cw->data[cw->maxrow] = (char *) alloc(strlen(g.toplines) + 5);
|
||||
cw->data[cw->maxrow] = (char *) alloc(strlen(gt.toplines) + 5);
|
||||
strcpy(cw->data[i = cw->maxrow++] + SOFF + (scrollmsg != 0),
|
||||
g.toplines);
|
||||
gt.toplines);
|
||||
}
|
||||
cw->data[i][SEL_ITEM] = 1;
|
||||
cw->data[i][VATTR] = attr + 1;
|
||||
@@ -182,7 +182,7 @@ const char *str;
|
||||
/ w->RPort->TxHeight,
|
||||
totalvis, totalvis);
|
||||
}
|
||||
i = strlen(g.toplines + SOFF);
|
||||
i = strlen(gt.toplines + SOFF);
|
||||
cw->maxcol = max(cw->maxcol, i);
|
||||
cw->vwy = cw->maxrow;
|
||||
break;
|
||||
@@ -191,7 +191,7 @@ const char *str;
|
||||
if (cw->data[cw->cury] == NULL)
|
||||
panic("NULL pointer for status window");
|
||||
ob = &cw->data[cw->cury][j = cw->curx];
|
||||
if (g.context.botlx)
|
||||
if (gc.context.botlx)
|
||||
*ob = 0;
|
||||
|
||||
/* Display when beam at top to avoid flicker... */
|
||||
|
||||
@@ -88,7 +88,7 @@ attempt_restore:
|
||||
if (yn("Do you want to keep the save file?") == 'n')
|
||||
(void) delete_savefile();
|
||||
else {
|
||||
nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0));
|
||||
nh_compress(fqname(gs.SAVEF, SAVEPREFIX, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,14 +132,14 @@ whoami(void)
|
||||
*/
|
||||
char *s;
|
||||
|
||||
if (*g.plname)
|
||||
if (*gp.plname)
|
||||
return;
|
||||
if (s = nh_getenv("USER")) {
|
||||
(void) strncpy(g.plname, s, sizeof(g.plname) - 1);
|
||||
(void) strncpy(gp.plname, s, sizeof(gp.plname) - 1);
|
||||
return;
|
||||
}
|
||||
if (s = nh_getenv("LOGNAME")) {
|
||||
(void) strncpy(g.plname, s, sizeof(g.plname) - 1);
|
||||
(void) strncpy(gp.plname, s, sizeof(gp.plname) - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -177,11 +177,11 @@ process_options(int argc, char **argv)
|
||||
#endif
|
||||
case 'u':
|
||||
if (argv[0][2])
|
||||
(void) strncpy(g.plname, argv[0] + 2, sizeof(g.plname) - 1);
|
||||
(void) strncpy(gp.plname, argv[0] + 2, sizeof(gp.plname) - 1);
|
||||
else if (argc > 1) {
|
||||
argc--;
|
||||
argv++;
|
||||
(void) strncpy(g.plname, argv[0], sizeof(g.plname) - 1);
|
||||
(void) strncpy(gp.plname, argv[0], sizeof(gp.plname) - 1);
|
||||
} else
|
||||
raw_print("Player name expected after -u");
|
||||
break;
|
||||
@@ -236,15 +236,15 @@ getlock(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
Sprintf(g.lock, "%d%s", getuid(), g.plname);
|
||||
regularize(g.lock);
|
||||
set_levelfile_name(g.lock, 0);
|
||||
fd = creat(g.lock, FCMASK);
|
||||
Sprintf(gl.lock, "%d%s", getuid(), gp.plname);
|
||||
regularize(gl.lock);
|
||||
set_levelfile_name(gl.lock, 0);
|
||||
fd = creat(gl.lock, FCMASK);
|
||||
if (fd == -1) {
|
||||
error("cannot creat lock file.");
|
||||
} else {
|
||||
if (write(fd, (genericptr_t) &g.hackpid, sizeof(g.hackpid))
|
||||
!= sizeof(g.hackpid)) {
|
||||
if (write(fd, (genericptr_t) &gh.hackpid, sizeof(gh.hackpid))
|
||||
!= sizeof(gh.hackpid)) {
|
||||
error("cannot write lock");
|
||||
}
|
||||
if (close(fd) == -1) {
|
||||
|
||||
@@ -228,7 +228,7 @@ macopen(const char *name, int flags, long fileType)
|
||||
Handle name;
|
||||
Str255 plnamep;
|
||||
|
||||
C2P(g.plname, plnamep);
|
||||
C2P(gp.plname, plnamep);
|
||||
name = (Handle)NewString(plnamep);
|
||||
if (name)
|
||||
replace_resource(name, 'STR ', PLAYER_NAME_RES_ID,
|
||||
|
||||
@@ -43,12 +43,12 @@ main(void)
|
||||
windowprocs = mac_procs;
|
||||
InitMac();
|
||||
|
||||
g.hname = "Mac Hack";
|
||||
gh.hname = "Mac Hack";
|
||||
hackpid = getpid();
|
||||
|
||||
setrandom();
|
||||
initoptions();
|
||||
init_nhwindows(&argc, (char **) &g.hname);
|
||||
init_nhwindows(&argc, (char **) &gh.hname);
|
||||
|
||||
/*
|
||||
* It seems you really want to play.
|
||||
@@ -102,7 +102,7 @@ attempt_restore:
|
||||
if (yn("Do you want to keep the save file?") == 'n')
|
||||
(void) delete_savefile();
|
||||
else {
|
||||
nh_compress(fqname(g.SAVEF, SAVEPREFIX, 0));
|
||||
nh_compress(fqname(gs.SAVEF, SAVEPREFIX, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,9 +225,9 @@ process_openfile(short src_vol, long src_dir, Str255 fName, OSType ftype)
|
||||
Handle name = Get1Resource('STR ', PLAYER_NAME_RES_ID);
|
||||
if (name) {
|
||||
Str255 save_f_p;
|
||||
P2C(*(StringHandle) name, g.plname);
|
||||
P2C(*(StringHandle) name, gp.plname);
|
||||
set_savefile_name(TRUE);
|
||||
C2P(fqname(g.SAVEF, SAVEPREFIX, 0), save_f_p);
|
||||
C2P(fqname(gs.SAVEF, SAVEPREFIX, 0), save_f_p);
|
||||
force_hdelete(theDirs.dataRefNum, theDirs.dataDirID,
|
||||
save_f_p);
|
||||
|
||||
|
||||
@@ -493,8 +493,8 @@ mac_askname()
|
||||
SetPortDialogPort(askdialog);
|
||||
|
||||
/* Initialize the name text item */
|
||||
ask_restring(g.plname, str);
|
||||
if (g.plname[0]) {
|
||||
ask_restring(gp.plname, str);
|
||||
if (gp.plname[0]) {
|
||||
GetDialogItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect);
|
||||
SetDialogItemText(handle, str);
|
||||
}
|
||||
@@ -502,8 +502,8 @@ mac_askname()
|
||||
{
|
||||
Str32 pName;
|
||||
pName [0] = 0;
|
||||
if (g.plname && g.plname [0]) {
|
||||
strcpy ((char *) pName, g.plname);
|
||||
if (gp.plname && gp.plname [0]) {
|
||||
strcpy ((char *) pName, gp.plname);
|
||||
c2pstr ((char *) pName);
|
||||
} else {
|
||||
Handle h;
|
||||
@@ -548,7 +548,7 @@ mac_askname()
|
||||
if (flags.initrole >= 0)
|
||||
currrole = flags.initrole;
|
||||
/* Check for backward compatibility */
|
||||
else if ((currrole = str2role(g.pl_character)) < 0)
|
||||
else if ((currrole = str2role(gp.pl_character)) < 0)
|
||||
currrole = randrole(FALSE);
|
||||
|
||||
/* Initialize the race popup menu */
|
||||
@@ -735,8 +735,8 @@ mac_askname()
|
||||
GetDialogItemText(handle, str);
|
||||
if (str[0] > PL_NSIZ - 1)
|
||||
str[0] = PL_NSIZ - 1;
|
||||
BlockMove(&str[1], g.plname, str[0]);
|
||||
g.plname[str[0]] = '\0';
|
||||
BlockMove(&str[1], gp.plname, str[0]);
|
||||
gp.plname[str[0]] = '\0';
|
||||
|
||||
/* Destroy the dialog */
|
||||
for (i = RSRC_ASK_ROLE; i <= RSRC_ASK_MODE; i++) {
|
||||
@@ -758,14 +758,14 @@ mac_askname()
|
||||
break;
|
||||
case 2: /* Debug */
|
||||
wizard = 1;
|
||||
strcpy(g.plname, WIZARD_NAME);
|
||||
strcpy(gp.plname, WIZARD_NAME);
|
||||
break;
|
||||
default: /* Quit */
|
||||
ExitToShell();
|
||||
}
|
||||
|
||||
/* Process the role */
|
||||
strcpy(g.pl_character, roles[currrole].name.m);
|
||||
strcpy(gp.pl_character, roles[currrole].name.m);
|
||||
flags.initrole = currrole;
|
||||
|
||||
/* Process the race */
|
||||
|
||||
@@ -24,16 +24,16 @@ getlock(void)
|
||||
int fd;
|
||||
int pid = getpid(); /* Process ID */
|
||||
|
||||
Sprintf(g.lock, "%d%s", getuid(), g.plname);
|
||||
set_levelfile_name(g.lock, 0);
|
||||
Sprintf(gl.lock, "%d%s", getuid(), gp.plname);
|
||||
set_levelfile_name(gl.lock, 0);
|
||||
|
||||
if ((fd = open(g.lock, O_RDWR | O_EXCL | O_CREAT, LEVL_TYPE)) == -1) {
|
||||
raw_printf("Could not lock the game %s.", g.lock);
|
||||
if ((fd = open(gl.lock, O_RDWR | O_EXCL | O_CREAT, LEVL_TYPE)) == -1) {
|
||||
raw_printf("Could not lock the game %s.", gl.lock);
|
||||
panic("Another game in progress?");
|
||||
}
|
||||
|
||||
if (write(fd, (char *) &pid, sizeof(pid)) != sizeof(pid)) {
|
||||
raw_printf("Could not lock the game %s.", g.lock);
|
||||
raw_printf("Could not lock the game %s.", gl.lock);
|
||||
panic("Disk locked?");
|
||||
}
|
||||
close(fd);
|
||||
|
||||
@@ -581,10 +581,10 @@ SanePositions(void)
|
||||
rmsg.top = rbase.bottom + 2;
|
||||
rmsg.bottom = rmsg.top + height;
|
||||
rmsg.left = rbase.left;
|
||||
rmsg.right = rbase.right;
|
||||
rmsgr.right = rbase.right;
|
||||
RetrievePosition(kMessageWindow, &rmsg.top, &rmsg.left);
|
||||
if (RetrieveSize(kMessageWindow, rmsg.top, rmsg.left, &height, &width)) {
|
||||
rmsg.right = rmsg.left + width;
|
||||
rmsgr.right = rmsg.left + width;
|
||||
rmsg.bottom = rmsg.top + height;
|
||||
}
|
||||
SetWindowBounds(theWindows[NHW_MESSAGE].its_window, kWindowContentRgn,
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/* NetHack 3.7 nhlan.c $NHDT-Date: 1596498282 2020/08/03 23:44:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.11 $ */
|
||||
/* Copyright (c) Michael Allison, 1997 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/*
|
||||
* Currently shared by the following ports:
|
||||
* WIN32
|
||||
*
|
||||
* The code in here is used to take advantage of added features
|
||||
* that might be available in a Local Area Network environment.
|
||||
*
|
||||
* Network Username of player
|
||||
*/
|
||||
|
||||
#include "hack.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef LAN_FEATURES
|
||||
|
||||
void
|
||||
init_lan_features(void)
|
||||
{
|
||||
lan_username();
|
||||
}
|
||||
/*
|
||||
* The get_lan_username() call is a required call, since some of
|
||||
* the other LAN features depend on a unique username being available.
|
||||
*
|
||||
*/
|
||||
|
||||
char *
|
||||
lan_username(void)
|
||||
{
|
||||
char *lu;
|
||||
lu = get_username(&g.lusername_size);
|
||||
if (lu) {
|
||||
Strcpy(g.lusername, lu);
|
||||
return g.lusername;
|
||||
} else
|
||||
return (char *) 0;
|
||||
}
|
||||
#endif /*LAN_FEATURES*/
|
||||
/*nhlan.c*/
|
||||
@@ -459,7 +459,7 @@ plselInitDialog(HWND hWnd)
|
||||
TCHAR wbuf[BUFSZ];
|
||||
|
||||
/* set player name */
|
||||
SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(g.plname, wbuf, sizeof(wbuf)));
|
||||
SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(gp.plname, wbuf, sizeof(wbuf)));
|
||||
|
||||
/* check flags for consistency */
|
||||
if (flags.initrole >= 0) {
|
||||
|
||||
@@ -39,7 +39,7 @@ mswin_have_input()
|
||||
return
|
||||
#ifdef SAFERHANGUP
|
||||
/* we always have input (ESC) if hangup was requested */
|
||||
g.program_state.done_hup ||
|
||||
gp.program_state.done_hup ||
|
||||
#endif
|
||||
(nhi_read_pos != nhi_write_pos);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ mswin_input_pop()
|
||||
|
||||
#ifdef SAFERHANGUP
|
||||
/* always return ESC when hangup was requested */
|
||||
if (g.program_state.done_hup) {
|
||||
if (gp.program_state.done_hup) {
|
||||
static MSNHEvent hangup_event;
|
||||
hangup_event.type = NHEVENT_CHAR;
|
||||
hangup_event.kbd.ch = '\033';
|
||||
@@ -98,7 +98,7 @@ mswin_input_peek()
|
||||
|
||||
#ifdef SAFERHANGUP
|
||||
/* always return ESC when hangup was requested */
|
||||
if (g.program_state.done_hup) {
|
||||
if (gp.program_state.done_hup) {
|
||||
static MSNHEvent hangup_event;
|
||||
hangup_event.type = NHEVENT_CHAR;
|
||||
hangup_event.kbd.ch = '\033';
|
||||
|
||||
@@ -826,7 +826,7 @@ mswin_layout_main_window(HWND changed_child)
|
||||
/* show command window only if it exists and
|
||||
the game is ready (plname is set) */
|
||||
if (GetNHApp()->bCmdPad && cmd_size.cx > 0 && cmd_size.cy > 0
|
||||
&& *g.plname) {
|
||||
&& *gp.plname) {
|
||||
MoveWindow(GetNHApp()->hCmdWnd, cmd_org.x, cmd_org.y, cmd_size.cx,
|
||||
cmd_size.cy, TRUE);
|
||||
ShowWindow(GetNHApp()->hCmdWnd, SW_SHOW);
|
||||
|
||||
@@ -533,7 +533,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (!data->text.text) {
|
||||
data->text.text = mswin_init_text_buffer(
|
||||
g.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
|
||||
gp.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
|
||||
if (!data->text.text)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ FormatStatusString(char *text, int format)
|
||||
int hp, hpmax;
|
||||
int cap = near_capacity();
|
||||
|
||||
Strcpy(text, g.plname);
|
||||
Strcpy(text, gp.plname);
|
||||
if ('a' <= text[0] && text[0] <= 'z')
|
||||
text[0] += 'A' - 'a';
|
||||
text[10] = 0;
|
||||
@@ -237,7 +237,7 @@ FormatStatusString(char *text, int format)
|
||||
hp = 0;
|
||||
(void) describe_level(nb = eos(nb));
|
||||
Sprintf(nb = eos(nb), "%c:%-2ld HP:%d(%d) Pw:%d(%d) AC:%-2d",
|
||||
showsyms[COIN_CLASS + SYM_OFF_O], money_cnt(g.invent), hp, hpmax,
|
||||
showsyms[COIN_CLASS + SYM_OFF_O], money_cnt(gi.invent), hp, hpmax,
|
||||
u.uen, u.uenmax, u.uac);
|
||||
|
||||
if (Upolyd)
|
||||
@@ -253,7 +253,7 @@ FormatStatusString(char *text, int format)
|
||||
|
||||
/* forth line */
|
||||
if (flags.time)
|
||||
Sprintf(nb = eos(nb), "T:%ld ", g.moves);
|
||||
Sprintf(nb = eos(nb), "T:%ld ", gm.moves);
|
||||
|
||||
if (strcmp(hu_stat[u.uhs], " ")) {
|
||||
Strcat(text, hu_stat[u.uhs]);
|
||||
|
||||
@@ -39,7 +39,7 @@ mswin_init_text_window()
|
||||
|
||||
ZeroMemory(data, sizeof(NHTextWindow));
|
||||
data->window_text = mswin_init_text_buffer(
|
||||
g.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
|
||||
gp.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
|
||||
SetWindowLong(ret, GWL_USERDATA, (LONG) data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -646,7 +646,7 @@ mswin_askname(void)
|
||||
{
|
||||
logDebug("mswin_askname()\n");
|
||||
|
||||
if (mswin_getlin_window("who are you?", g.plname, PL_NSIZ) == IDCANCEL) {
|
||||
if (mswin_getlin_window("who are you?", gp.plname, PL_NSIZ) == IDCANCEL) {
|
||||
bail("bye-bye");
|
||||
/* not reached */
|
||||
}
|
||||
@@ -1927,7 +1927,7 @@ NHSPhoneDialogSetup(HWND hDlg, UINT nToolBarId, BOOL is_edit,
|
||||
|
||||
rtDlg.bottom -= rtOK.bottom - rtOK.top;
|
||||
ShowWindow(hOK, SW_HIDE);
|
||||
SetWindowPos(hDlg, HWND_TOP, 0, 0, rtDlg.right - rtDlg.left,
|
||||
SetWindowPos(hDlg, HWND_TOP, 0, 0, rtDlgr.right - rtDlg.left,
|
||||
rtDlg.bottom - rtDlg.top,
|
||||
SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOZORDER);
|
||||
}
|
||||
|
||||
@@ -167,11 +167,11 @@ eraseoldlocks()
|
||||
*/
|
||||
for (i = 1; i <= MAXDUNGEON * MAXLEVEL + 1; i++) {
|
||||
/* try to remove all */
|
||||
set_levelfile_name(g.lock, i);
|
||||
(void) unlink(fqname(g.lock, LEVELPREFIX, 0));
|
||||
set_levelfile_name(gl.lock, i);
|
||||
(void) unlink(fqname(gl.lock, LEVELPREFIX, 0));
|
||||
}
|
||||
set_levelfile_name(g.lock, 0);
|
||||
if (unlink(fqname(g.lock, LEVELPREFIX, 0)))
|
||||
set_levelfile_name(gl.lock, 0);
|
||||
if (unlink(fqname(gl.lock, LEVELPREFIX, 0)))
|
||||
return 0; /* cannot remove it */
|
||||
return (1); /* success! */
|
||||
}
|
||||
@@ -187,9 +187,9 @@ getlock()
|
||||
int choice;
|
||||
|
||||
/* regularize(lock); */ /* already done in pcmain */
|
||||
Sprintf(tbuf, "%s", fqname(g.lock, LEVELPREFIX, 0));
|
||||
set_levelfile_name(g.lock, 0);
|
||||
fq_lock = fqname(g.lock, LEVELPREFIX, 1);
|
||||
Sprintf(tbuf, "%s", fqname(gl.lock, LEVELPREFIX, 0));
|
||||
set_levelfile_name(gl.lock, 0);
|
||||
fq_lock = fqname(gl.lock, LEVELPREFIX, 1);
|
||||
|
||||
f = CreateFile(NH_A2W(fq_lock, wbuf, BUFSZ), GENERIC_READ, 0, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
@@ -226,8 +226,8 @@ gotlock:
|
||||
if (fd == -1) {
|
||||
error("cannot creat lock file (%s.)", fq_lock);
|
||||
} else {
|
||||
if (write(fd, (char *) &g.hackpid, sizeof(g.hackpid))
|
||||
!= sizeof(g.hackpid)) {
|
||||
if (write(fd, (char *) &gh.hackpid, sizeof(gh.hackpid))
|
||||
!= sizeof(gh.hackpid)) {
|
||||
error("cannot write lock (%s)", fq_lock);
|
||||
}
|
||||
if (close(fd) == -1) {
|
||||
|
||||
@@ -1032,9 +1032,9 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks) :
|
||||
|
||||
QButtonGroup* namebox = new QButtonGroup(1,Horizontal,"Name",this);
|
||||
QLineEdit* name = new QLineEdit(namebox);
|
||||
name->setMaxLength(sizeof(g.plname)-1);
|
||||
if ( strncmp(g.plname,"player",6) && strncmp(g.plname,"games",5) )
|
||||
name->setText(g.plname);
|
||||
name->setMaxLength(sizeof(gp.plname)-1);
|
||||
if ( strncmp(gp.plname,"player",6) && strncmp(gp.plname,"games",5) )
|
||||
name->setText(gp.plname);
|
||||
connect(name, SIGNAL(textChanged(const QString&)),
|
||||
this, SLOT(selectName(const QString&)) );
|
||||
name->setFocus();
|
||||
@@ -1190,7 +1190,7 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks) :
|
||||
|
||||
void NetHackQtPlayerSelector::selectName(const QString& n)
|
||||
{
|
||||
strncpy(g.plname,n.latin1(),sizeof(g.plname)-1);
|
||||
strncpy(gp.plname,n.latin1(),sizeof(gp.plname)-1);
|
||||
}
|
||||
|
||||
void NetHackQtPlayerSelector::selectRole()
|
||||
@@ -2550,7 +2550,7 @@ void NetHackQtStatusWindow::updateStats()
|
||||
encumber.setLabel(enc);
|
||||
encumber.show();
|
||||
}
|
||||
Strcpy(buf, g.plname);
|
||||
Strcpy(buf, gp.plname);
|
||||
if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a';
|
||||
Strcat(buf, " the ");
|
||||
if (u.mtimedone) {
|
||||
@@ -2579,7 +2579,7 @@ void NetHackQtStatusWindow::updateStats()
|
||||
dlevel.setLabel(buf,(long)depth(&u.uz));
|
||||
}
|
||||
|
||||
gold.setLabel("Au:", money_cnt(g.invent));
|
||||
gold.setLabel("Au:", money_cnt(gi.invent));
|
||||
if (u.mtimedone) {
|
||||
// You're a monster!
|
||||
|
||||
@@ -2613,7 +2613,7 @@ void NetHackQtStatusWindow::updateStats()
|
||||
align.setLabel("Lawful");
|
||||
}
|
||||
|
||||
if (::flags.time) time.setLabel("Time:",(long)g.moves);
|
||||
if (::flags.time) time.setLabel("Time:",(long)gm.moves);
|
||||
else time.setLabel("");
|
||||
#ifdef SCORE_ON_BOTL
|
||||
if (::flags.showscore) {
|
||||
@@ -3325,7 +3325,7 @@ static char** rip_line=0;
|
||||
long year;
|
||||
|
||||
/* Put name on stone */
|
||||
Sprintf(rip_line[NAME_LINE], "%s", g.plname);
|
||||
Sprintf(rip_line[NAME_LINE], "%s", gp.plname);
|
||||
|
||||
/* Put $ on stone */
|
||||
Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money);
|
||||
@@ -4052,7 +4052,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
|
||||
void NetHackQtMainWindow::closeEvent(QCloseEvent* e)
|
||||
{
|
||||
if ( g.program_state.something_worth_saving ) {
|
||||
if ( gp.program_state.something_worth_saving ) {
|
||||
switch ( QMessageBox::information( this, "NetHack",
|
||||
"This will end your NetHack session",
|
||||
"&Save", "&Cancel", 0, 1 ) )
|
||||
@@ -4644,7 +4644,7 @@ void NetHackQtBind::qt_askname()
|
||||
NetHackQtSavedGameSelector sgsel((const char**)saved);
|
||||
ch = sgsel.choose();
|
||||
if ( ch >= 0 )
|
||||
strcpy(g.plname,saved[ch]);
|
||||
strcpy(gp.plname,saved[ch]);
|
||||
}
|
||||
free_saved_games(saved);
|
||||
|
||||
@@ -4864,7 +4864,7 @@ void NetHackQtBind::qt_update_inventory()
|
||||
if (main)
|
||||
main->updateInventory();
|
||||
/* doesn't work yet
|
||||
if (g.program_state.something_worth_saving && iflags.perm_invent)
|
||||
if (gp.program_state.something_worth_saving && iflags.perm_invent)
|
||||
display_inventory(NULL, FALSE);
|
||||
*/
|
||||
}
|
||||
@@ -4918,14 +4918,14 @@ int NetHackQtBind::qt_nhgetch()
|
||||
//
|
||||
while (keybuffer.Empty()
|
||||
#ifdef SAFERHANGUP
|
||||
&& !g.program_state.done_hup
|
||||
&& !gp.program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
qApp->enter_loop();
|
||||
}
|
||||
|
||||
#ifdef SAFERHANGUP
|
||||
if (g.program_state.done_hup && keybuffer.Empty()) return '\033';
|
||||
if (gp.program_state.done_hup && keybuffer.Empty()) return '\033';
|
||||
#endif
|
||||
return keybuffer.GetAscii();
|
||||
}
|
||||
@@ -4939,13 +4939,13 @@ int NetHackQtBind::qt_nh_poskey(int *x, int *y, int *mod)
|
||||
//
|
||||
while (keybuffer.Empty() && clickbuffer.Empty()
|
||||
#ifdef SAFERHANGUP
|
||||
&& !g.program_state.done_hup
|
||||
&& !gp.program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
qApp->enter_loop();
|
||||
}
|
||||
#ifdef SAFERHANGUP
|
||||
if (g.program_state.done_hup && keybuffer.Empty()) return '\033';
|
||||
if (gp.program_state.done_hup && keybuffer.Empty()) return '\033';
|
||||
#endif
|
||||
if (!keybuffer.Empty()) {
|
||||
return keybuffer.GetAscii();
|
||||
@@ -5194,7 +5194,7 @@ bool NetHackQtBind::notify(QObject *receiver, QEvent *event)
|
||||
|
||||
bool result=QApplication::notify(receiver,event);
|
||||
#ifdef SAFERHANGUP
|
||||
if (g.program_state.done_hup) {
|
||||
if (gp.program_state.done_hup) {
|
||||
keybuffer.Put('\033');
|
||||
qApp->exit_loop();
|
||||
return TRUE;
|
||||
|
||||
@@ -501,7 +501,7 @@ Gem_player_selection()
|
||||
void
|
||||
Gem_askname()
|
||||
{
|
||||
strncpy(g.plname, mar_ask_name(), PL_NSIZ);
|
||||
strncpy(gp.plname, mar_ask_name(), PL_NSIZ);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1078,7 +1078,7 @@ time_t when;
|
||||
}
|
||||
/* Follows same algorithm as genl_outrip() */
|
||||
/* Put name on stone */
|
||||
Sprintf(rip_line[NAME_LINE], "%s", g.plname);
|
||||
Sprintf(rip_line[NAME_LINE], "%s", gp.plname);
|
||||
/* Put $ on stone */
|
||||
Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money);
|
||||
/* Put together death description */
|
||||
|
||||
@@ -1647,13 +1647,13 @@ const char *str;
|
||||
}
|
||||
message_line[mesg_hist - 1] = tmp;
|
||||
}
|
||||
strcpy(g.toplines, str);
|
||||
strcpy(gt.toplines, str);
|
||||
messages_pro_zug++;
|
||||
msg_max++;
|
||||
|
||||
if ((int) strlen(g.toplines) >= msg_width) {
|
||||
if ((int) strlen(gt.toplines) >= msg_width) {
|
||||
int pos = msg_width;
|
||||
tmp = g.toplines + msg_width;
|
||||
tmp = gt.toplines + msg_width;
|
||||
while (*tmp != ' ' && pos >= 0) {
|
||||
tmp--;
|
||||
pos--;
|
||||
@@ -1661,12 +1661,12 @@ const char *str;
|
||||
if (pos <= 0)
|
||||
pos = msg_width; /* Mar -- Oops, what a word :-) */
|
||||
message_age[msg_max] = TRUE;
|
||||
strncpy(message_line[msg_max], g.toplines, pos);
|
||||
strncpy(message_line[msg_max], gt.toplines, pos);
|
||||
message_line[msg_max][pos] = 0;
|
||||
rest = strcpy(buf, g.toplines + pos);
|
||||
rest = strcpy(buf, gt.toplines + pos);
|
||||
} else {
|
||||
message_age[msg_max] = TRUE;
|
||||
strncpy(message_line[msg_max], g.toplines, msg_width);
|
||||
strncpy(message_line[msg_max], gt.toplines, msg_width);
|
||||
rest = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -354,7 +354,7 @@ gnome_askname()
|
||||
|
||||
/* Ask for a name and stuff the response into plname, a nethack global */
|
||||
ret = ghack_ask_string_dialog("What is your name?", "gandalf",
|
||||
"GnomeHack", g.plname);
|
||||
"GnomeHack", gp.plname);
|
||||
|
||||
/* Quit if they want to quit... */
|
||||
if (ret == -1) {
|
||||
@@ -907,7 +907,7 @@ gnome_nhgetch()
|
||||
g_askingQuestion = 1;
|
||||
/* Process events until a key press event arrives. */
|
||||
while (g_numKeys == 0) {
|
||||
if (g.program_state.done_hup)
|
||||
if (gp.program_state.done_hup)
|
||||
return '\033';
|
||||
gtk_main_iteration();
|
||||
}
|
||||
@@ -945,7 +945,7 @@ gnome_nh_poskey(int *x, int *y, int *mod)
|
||||
g_askingQuestion = 0;
|
||||
/* Process events until a key or map-click arrives. */
|
||||
while (g_numKeys == 0 && g_numClicks == 0) {
|
||||
if (g.program_state.done_hup)
|
||||
if (gp.program_state.done_hup)
|
||||
return '\033';
|
||||
gtk_main_iteration();
|
||||
}
|
||||
@@ -1169,7 +1169,7 @@ gnome_outrip(winid wid, int how, time_t when)
|
||||
long year;
|
||||
|
||||
/* Put name on stone */
|
||||
Sprintf(buf, "%s\n", g.plname);
|
||||
Sprintf(buf, "%s\n", gp.plname);
|
||||
Strcat(ripString, buf);
|
||||
|
||||
/* Put $ on stone */
|
||||
|
||||
@@ -440,7 +440,7 @@ ghack_status_window_update_stats()
|
||||
long umoney;
|
||||
|
||||
/* First, fill in the player name and the dungeon level */
|
||||
strcpy(buf, g.plname);
|
||||
strcpy(buf, gp.plname);
|
||||
if ('a' <= buf[0] && buf[0] <= 'z')
|
||||
buf[0] += 'A' - 'a';
|
||||
strcat(buf, " the ");
|
||||
@@ -558,7 +558,7 @@ ghack_status_window_update_stats()
|
||||
gtk_label_set(GTK_LABEL(chaLabel), buf);
|
||||
|
||||
/* Now do the non-pixmaped stats (gold and such) */
|
||||
umoney = money_cnt(g.invent);
|
||||
umoney = money_cnt(gi.invent);
|
||||
sprintf(buf, "Au:%ld", umoney);
|
||||
if (lastAu < umoney && firstTime == FALSE) {
|
||||
/* Ok, this changed so add it to the highlighing list */
|
||||
@@ -662,7 +662,7 @@ ghack_status_window_update_stats()
|
||||
}
|
||||
|
||||
if (flags.time) {
|
||||
sprintf(buf, "Time:%ld", g.moves);
|
||||
sprintf(buf, "Time:%ld", gm.moves);
|
||||
gtk_label_set(GTK_LABEL(timeLabel), buf);
|
||||
} else
|
||||
gtk_label_set(GTK_LABEL(timeLabel), "");
|
||||
|
||||
Reference in New Issue
Block a user