Changes needed in various ports due to globals changes.

This commit is contained in:
Bart House
2018-12-24 14:47:51 -08:00
parent 62e1a45b60
commit e5e906dc3b
33 changed files with 112 additions and 112 deletions

View File

@@ -677,13 +677,13 @@ do_positionbar()
p = pbar; p = pbar;
/* up stairway */ /* up stairway */
if (upstair.sx if (g.upstair.sx
&& (glyph_to_cmap(level.locations[upstair.sx][upstair.sy].glyph) && (glyph_to_cmap(level.locations[g.upstair.sx][g.upstair.sy].glyph)
== S_upstair == S_upstair
|| glyph_to_cmap(level.locations[upstair.sx][upstair.sy].glyph) || glyph_to_cmap(level.locations[g.upstair.sx][g.upstair.sy].glyph)
== S_upladder)) { == S_upladder)) {
*p++ = '<'; *p++ = '<';
*p++ = upstair.sx; *p++ = g.upstair.sx;
} }
if (g.sstairs.sx if (g.sstairs.sx
&& (glyph_to_cmap(level.locations[g.sstairs.sx][g.sstairs.sy].glyph) && (glyph_to_cmap(level.locations[g.sstairs.sx][g.sstairs.sy].glyph)

View File

@@ -164,9 +164,9 @@ coord *startp;
* Arrive at an up or down stairwell if it is in line of sight from the * Arrive at an up or down stairwell if it is in line of sight from the
* hero. * hero.
*/ */
if (couldsee(upstair.sx, upstair.sy)) { if (couldsee(g.upstair.sx, g.upstair.sy)) {
startp->x = upstair.sx; startp->x = g.upstair.sx;
startp->y = upstair.sy; startp->y = g.upstair.sy;
return TRUE; return TRUE;
} }
if (couldsee(g.dnstair.sx, g.dnstair.sy)) { if (couldsee(g.dnstair.sx, g.dnstair.sy)) {

View File

@@ -186,7 +186,7 @@ time_t when;
SetDrMd(rp, JAM1); SetDrMd(rp, JAM1);
/* Put name on stone */ /* Put name on stone */
Sprintf(buf, "%s", plname); Sprintf(buf, "%s", g.plname);
buf[STONE_LINE_LEN] = 0; buf[STONE_LINE_LEN] = 0;
tomb_text(buf); tomb_text(buf);

View File

@@ -420,10 +420,10 @@ amii_askname()
amii_getlin("Who are you?", plnametmp); amii_getlin("Who are you?", plnametmp);
} while (strlen(plnametmp) == 0); } while (strlen(plnametmp) == 0);
strncpy(plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */ strncpy(g.plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */
plname[PL_NSIZ - 1] = 0; g.plname[PL_NSIZ - 1] = 0;
if (*plname == '\33') { if (*g.plname == '\33') {
clearlocks(); clearlocks();
exit_nhwindows(NULL); exit_nhwindows(NULL);
nh_terminate(0); nh_terminate(0);
@@ -457,9 +457,9 @@ amii_player_selection()
#if 0 /* Don't query the user ... instead give random character -jhsa */ #if 0 /* Don't query the user ... instead give random character -jhsa */
#if 0 /* OBSOLETE */ #if 0 /* OBSOLETE */
if( *pl_character ){ if( *g.pl_character ){
pl_character[ 0 ] = toupper( pl_character[ 0 ] ); g.pl_character[ 0 ] = toupper( g.pl_character[ 0 ] );
if( index( pl_classes, pl_character[ 0 ] ) ) if( index( pl_classes, g.pl_character[ 0 ] ) )
return; return;
} }
#endif #endif
@@ -513,19 +513,19 @@ amii_player_selection()
case VANILLAKEY: case VANILLAKEY:
if( index( pl_classes, toupper( code ) ) ) if( index( pl_classes, toupper( code ) ) )
{ {
pl_character[0] = toupper( code ); g.pl_character[0] = toupper( code );
aredone = 1; aredone = 1;
} }
else if( code == ' ' || code == '\n' || code == '\r' ) else if( code == ' ' || code == '\n' || code == '\r' )
{ {
flags.initrole = randrole(); flags.initrole = randrole();
#if 0 /* OBSOLETE */ #if 0 /* OBSOLETE */
strcpy( pl_character, roles[ rnd( 11 ) ] ); strcpy( g.pl_character, roles[ rnd( 11 ) ] );
#endif #endif
aredone = 1; aredone = 1;
amii_clear_nhwindow( WIN_BASE ); amii_clear_nhwindow( WIN_BASE );
CloseShWindow( cwin ); CloseShWindow( cwin );
RandomWindow( pl_character ); RandomWindow( g.pl_character );
return; return;
} }
else if( code == 'q' || code == 'Q' ) else if( code == 'q' || code == 'Q' )
@@ -545,15 +545,15 @@ amii_player_selection()
case 1: /* Random Character */ case 1: /* Random Character */
flags.initrole = randrole(); flags.initrole = randrole();
#if 0 /* OBSOLETE */ #if 0 /* OBSOLETE */
strcpy( pl_character, roles[ rnd( 11 ) ] ); strcpy( g.pl_character, roles[ rnd( 11 ) ] );
#endif #endif
amii_clear_nhwindow( WIN_BASE ); amii_clear_nhwindow( WIN_BASE );
CloseShWindow( cwin ); CloseShWindow( cwin );
RandomWindow( pl_character ); RandomWindow( g.pl_character );
return; return;
default: default:
pl_character[0] = gd->GadgetID; g.pl_character[0] = gd->GadgetID;
break; break;
} }
aredone = 1; aredone = 1;

View File

@@ -348,7 +348,7 @@ menu_item **retmip;
nw->Screen = HackScreen; nw->Screen = HackScreen;
if (win == WIN_INVEN) { if (win == WIN_INVEN) {
sprintf(title, "%s the %s's Inventory", plname, pl_character); sprintf(title, "%s the %s's Inventory", g.plname, g.pl_character);
nw->Title = title; nw->Title = title;
if (lastinvent.MaxX != 0) { if (lastinvent.MaxX != 0) {
nw->LeftEdge = lastinvent.MinX; nw->LeftEdge = lastinvent.MinX;

View File

@@ -132,14 +132,14 @@ whoami(void)
*/ */
char *s; char *s;
if (*plname) if (*g.plname)
return; return;
if (s = nh_getenv("USER")) { if (s = nh_getenv("USER")) {
(void) strncpy(plname, s, sizeof(plname) - 1); (void) strncpy(g.plname, s, sizeof(g.plname) - 1);
return; return;
} }
if (s = nh_getenv("LOGNAME")) { if (s = nh_getenv("LOGNAME")) {
(void) strncpy(plname, s, sizeof(plname) - 1); (void) strncpy(g.plname, s, sizeof(g.plname) - 1);
return; return;
} }
} }
@@ -177,11 +177,11 @@ process_options(int argc, char **argv)
#endif #endif
case 'u': case 'u':
if (argv[0][2]) if (argv[0][2])
(void) strncpy(plname, argv[0] + 2, sizeof(plname) - 1); (void) strncpy(g.plname, argv[0] + 2, sizeof(g.plname) - 1);
else if (argc > 1) { else if (argc > 1) {
argc--; argc--;
argv++; argv++;
(void) strncpy(plname, argv[0], sizeof(plname) - 1); (void) strncpy(g.plname, argv[0], sizeof(g.plname) - 1);
} else } else
raw_print("Player name expected after -u"); raw_print("Player name expected after -u");
break; break;
@@ -236,7 +236,7 @@ getlock(void)
{ {
int fd; int fd;
Sprintf(lock, "%d%s", getuid(), plname); Sprintf(lock, "%d%s", getuid(), g.plname);
regularize(lock); regularize(lock);
set_levelfile_name(lock, 0); set_levelfile_name(lock, 0);
fd = creat(lock, FCMASK); fd = creat(lock, FCMASK);

View File

@@ -228,7 +228,7 @@ macopen(const char *name, int flags, long fileType)
Handle name; Handle name;
Str255 plnamep; Str255 plnamep;
C2P(plname, plnamep); C2P(g.plname, plnamep);
name = (Handle)NewString(plnamep); name = (Handle)NewString(plnamep);
if (name) if (name)
replace_resource(name, 'STR ', PLAYER_NAME_RES_ID, replace_resource(name, 'STR ', PLAYER_NAME_RES_ID,

View File

@@ -225,7 +225,7 @@ process_openfile(short src_vol, long src_dir, Str255 fName, OSType ftype)
Handle name = Get1Resource('STR ', PLAYER_NAME_RES_ID); Handle name = Get1Resource('STR ', PLAYER_NAME_RES_ID);
if (name) { if (name) {
Str255 save_f_p; Str255 save_f_p;
P2C(*(StringHandle) name, plname); P2C(*(StringHandle) name, g.plname);
set_savefile_name(TRUE); set_savefile_name(TRUE);
C2P(fqname(SAVEF, SAVEPREFIX, 0), save_f_p); C2P(fqname(SAVEF, SAVEPREFIX, 0), save_f_p);
force_hdelete(theDirs.dataRefNum, theDirs.dataDirID, force_hdelete(theDirs.dataRefNum, theDirs.dataDirID,

View File

@@ -493,8 +493,8 @@ mac_askname()
SetPortDialogPort(askdialog); SetPortDialogPort(askdialog);
/* Initialize the name text item */ /* Initialize the name text item */
ask_restring(plname, str); ask_restring(g.plname, str);
if (plname[0]) { if (g.plname[0]) {
GetDialogItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect); GetDialogItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect);
SetDialogItemText(handle, str); SetDialogItemText(handle, str);
} }
@@ -502,8 +502,8 @@ mac_askname()
{ {
Str32 pName; Str32 pName;
pName [0] = 0; pName [0] = 0;
if (plname && plname [0]) { if (g.plname && g.plname [0]) {
strcpy ((char *) pName, plname); strcpy ((char *) pName, g.plname);
c2pstr ((char *) pName); c2pstr ((char *) pName);
} else { } else {
Handle h; Handle h;
@@ -548,7 +548,7 @@ mac_askname()
if (flags.initrole >= 0) if (flags.initrole >= 0)
currrole = flags.initrole; currrole = flags.initrole;
/* Check for backward compatibility */ /* Check for backward compatibility */
else if ((currrole = str2role(pl_character)) < 0) else if ((currrole = str2role(g.pl_character)) < 0)
currrole = randrole(); currrole = randrole();
/* Initialize the race popup menu */ /* Initialize the race popup menu */
@@ -735,8 +735,8 @@ mac_askname()
GetDialogItemText(handle, str); GetDialogItemText(handle, str);
if (str[0] > PL_NSIZ - 1) if (str[0] > PL_NSIZ - 1)
str[0] = PL_NSIZ - 1; str[0] = PL_NSIZ - 1;
BlockMove(&str[1], plname, str[0]); BlockMove(&str[1], g.plname, str[0]);
plname[str[0]] = '\0'; g.plname[str[0]] = '\0';
/* Destroy the dialog */ /* Destroy the dialog */
for (i = RSRC_ASK_ROLE; i <= RSRC_ASK_MODE; i++) { for (i = RSRC_ASK_ROLE; i <= RSRC_ASK_MODE; i++) {
@@ -758,14 +758,14 @@ mac_askname()
break; break;
case 2: /* Debug */ case 2: /* Debug */
wizard = 1; wizard = 1;
strcpy(plname, WIZARD_NAME); strcpy(g.plname, WIZARD_NAME);
break; break;
default: /* Quit */ default: /* Quit */
ExitToShell(); ExitToShell();
} }
/* Process the role */ /* Process the role */
strcpy(pl_character, roles[currrole].name.m); strcpy(g.pl_character, roles[currrole].name.m);
flags.initrole = currrole; flags.initrole = currrole;
/* Process the race */ /* Process the race */

View File

@@ -24,7 +24,7 @@ getlock(void)
int fd; int fd;
int pid = getpid(); /* Process ID */ int pid = getpid(); /* Process ID */
Sprintf(lock, "%d%s", getuid(), plname); Sprintf(lock, "%d%s", getuid(), g.plname);
set_levelfile_name(lock, 0); set_levelfile_name(lock, 0);
if ((fd = open(lock, O_RDWR | O_EXCL | O_CREAT, LEVL_TYPE)) == -1) { if ((fd = open(lock, O_RDWR | O_EXCL | O_CREAT, LEVL_TYPE)) == -1) {

View File

@@ -38,7 +38,7 @@ unsigned char shift;
{ {
boolean opening_dialog; boolean opening_dialog;
opening_dialog = pl_character[0] ? FALSE : TRUE; opening_dialog = g.pl_character[0] ? FALSE : TRUE;
switch (scancode) { switch (scancode) {
#ifdef SIMULATE_CURSOR #ifdef SIMULATE_CURSOR
case 0x3d: /* F3 = toggle cursor type */ case 0x3d: /* F3 = toggle cursor type */

View File

@@ -421,20 +421,20 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
* overwritten without confirmation when a user starts up * overwritten without confirmation when a user starts up
* another game with the same player name. * another game with the same player name.
*/ */
Strcpy(lock, plname); Strcpy(lock, g.plname);
regularize(lock); regularize(lock);
getlock(); getlock();
#else /* What follows is !PC_LOCKING */ #else /* What follows is !PC_LOCKING */
#ifdef AMIGA /* We'll put the bones & levels in the user specified directory \ #ifdef AMIGA /* We'll put the bones & levels in the user specified directory \
-jhsa */ -jhsa */
Strcat(lock, plname); Strcat(lock, g.plname);
Strcat(lock, ".99"); Strcat(lock, ".99");
#else #else
#ifndef MFLOPPY #ifndef MFLOPPY
/* I'm not sure what, if anything, is left here, but MFLOPPY has /* I'm not sure what, if anything, is left here, but MFLOPPY has
* conflicts with set_lock_and_bones() in files.c. * conflicts with set_lock_and_bones() in files.c.
*/ */
Strcpy(lock, plname); Strcpy(lock, g.plname);
Strcat(lock, ".99"); Strcat(lock, ".99");
regularize(lock); /* is this necessary? */ regularize(lock); /* is this necessary? */
/* not compatible with full path a la AMIGA */ /* not compatible with full path a la AMIGA */
@@ -565,11 +565,11 @@ char *argv[];
#endif #endif
case 'u': case 'u':
if (argv[0][2]) if (argv[0][2])
(void) strncpy(plname, argv[0] + 2, sizeof(plname) - 1); (void) strncpy(g.plname, argv[0] + 2, sizeof(g.plname) - 1);
else if (argc > 1) { else if (argc > 1) {
argc--; argc--;
argv++; argv++;
(void) strncpy(plname, argv[0], sizeof(plname) - 1); (void) strncpy(g.plname, argv[0], sizeof(g.plname) - 1);
} else } else
raw_print("Player name expected after -u"); raw_print("Player name expected after -u");
break; break;
@@ -747,7 +747,7 @@ port_help()
boolean boolean
authorize_wizard_mode() authorize_wizard_mode()
{ {
if (!strcmp(plname, WIZARD_NAME)) if (!strcmp(g.plname, WIZARD_NAME))
return TRUE; return TRUE;
return FALSE; return FALSE;
} }

View File

@@ -229,11 +229,11 @@ char *argv[];
* dash matches role, race, gender, or alignment. * dash matches role, race, gender, or alignment.
*/ */
/* guard against user names with hyphens in them */ /* guard against user names with hyphens in them */
int len = (int) strlen(plname); int len = (int) strlen(g.plname);
/* append the current role, if any, so that last dash is ours */ /* append the current role, if any, so that last dash is ours */
if (++len < (int) sizeof plname) if (++len < (int) sizeof g.plname)
(void) strncat(strcat(plname, "-"), pl_character, (void) strncat(strcat(g.plname, "-"), g.pl_character,
sizeof plname - len - 1); sizeof g.plname - len - 1);
} }
/* strip role,race,&c suffix; calls askname() if plname[] is empty /* strip role,race,&c suffix; calls askname() if plname[] is empty
or holds a generic user name like "player" or "games" */ or holds a generic user name like "player" or "games" */
@@ -275,12 +275,12 @@ attempt_restore:
* clock, &c not currently in use in the playground directory * clock, &c not currently in use in the playground directory
* (for locknum > 0). * (for locknum > 0).
*/ */
if (*plname) { if (*g.plname) {
getlock(); getlock();
program_state.preserve_locks = 0; /* after getlock() */ program_state.preserve_locks = 0; /* after getlock() */
} }
if (*plname && (fd = restore_saved_game()) >= 0) { if (*g.plname && (fd = restore_saved_game()) >= 0) {
const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1); const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);
(void) chmod(fq_save, 0); /* disallow parallel restores */ (void) chmod(fq_save, 0); /* disallow parallel restores */
@@ -311,7 +311,7 @@ attempt_restore:
} }
if (!resuming) { if (!resuming) {
boolean neednewlock = (!*plname); boolean neednewlock = (!*g.plname);
/* new game: start by choosing role, race, etc; /* new game: start by choosing role, race, etc;
player might change the hero's name while doing that, player might change the hero's name while doing that,
in which case we try to restore under the new name in which case we try to restore under the new name
@@ -320,7 +320,7 @@ attempt_restore:
if (!plsel_once) if (!plsel_once)
player_selection(); player_selection();
plsel_once = TRUE; plsel_once = TRUE;
if (neednewlock && *plname) if (neednewlock && *g.plname)
goto attempt_restore; goto attempt_restore;
if (iflags.renameinprogress) { if (iflags.renameinprogress) {
/* player has renamed the hero while selecting role; /* player has renamed the hero while selecting role;
@@ -388,11 +388,11 @@ char *argv[];
#endif #endif
case 'u': case 'u':
if (argv[0][2]) { if (argv[0][2]) {
(void) strncpy(plname, argv[0] + 2, sizeof plname - 1); (void) strncpy(g.plname, argv[0] + 2, sizeof g.plname - 1);
} else if (argc > 1) { } else if (argc > 1) {
argc--; argc--;
argv++; argv++;
(void) strncpy(plname, argv[0], sizeof plname - 1); (void) strncpy(g.plname, argv[0], sizeof g.plname - 1);
} else { } else {
raw_print("Player name expected after -u"); raw_print("Player name expected after -u");
} }
@@ -540,7 +540,7 @@ whoami()
* Note that we trust the user here; it is possible to play under * Note that we trust the user here; it is possible to play under
* somebody else's name. * somebody else's name.
*/ */
if (!*plname) { if (!*g.plname) {
register const char *s; register const char *s;
s = nh_getenv("USER"); s = nh_getenv("USER");
@@ -550,8 +550,8 @@ whoami()
s = getlogin(); s = getlogin();
if (s && *s) { if (s && *s) {
(void) strncpy(plname, s, sizeof plname - 1); (void) strncpy(g.plname, s, sizeof g.plname - 1);
if (index(plname, '-')) if (index(g.plname, '-'))
return TRUE; return TRUE;
} }
} }
@@ -661,7 +661,7 @@ char *optstr;
if (!pw) if (!pw)
return FALSE; return FALSE;
if (sysopt.check_plname) if (sysopt.check_plname)
pwname = plname; pwname = g.plname;
else else
pwname = pw->pw_name; pwname = pw->pw_name;
pwlen = strlen(pwname); pwlen = strlen(pwname);

View File

@@ -120,7 +120,7 @@ getlock()
'a','b',&c below; override the default and use <uid><charname> 'a','b',&c below; override the default and use <uid><charname>
if we aren't restricting the number of simultaneous games */ if we aren't restricting the number of simultaneous games */
if (!locknum) if (!locknum)
Sprintf(lock, "%u%s", (unsigned) getuid(), plname); Sprintf(lock, "%u%s", (unsigned) getuid(), g.plname);
regularize(lock); regularize(lock);
set_levelfile_name(lock, 0); set_levelfile_name(lock, 0);

View File

@@ -257,11 +257,11 @@ char *argv[];
#endif #endif
case 'u': case 'u':
if (argv[0][2]) if (argv[0][2])
(void) strncpy(plname, argv[0] + 2, sizeof(plname) - 1); (void) strncpy(g.plname, argv[0] + 2, sizeof(g.plname) - 1);
else if (argc > 1) { else if (argc > 1) {
argc--; argc--;
argv++; argv++;
(void) strncpy(plname, argv[0], sizeof(plname) - 1); (void) strncpy(g.plname, argv[0], sizeof(g.plname) - 1);
} else } else
raw_print("Player name expected after -u"); raw_print("Player name expected after -u");
break; break;
@@ -368,8 +368,8 @@ whoami()
*/ */
register char *s; register char *s;
if (!*plname && (s = nh_getenv("USER"))) if (!*g.plname && (s = nh_getenv("USER")))
(void) lcase(strncpy(plname, s, sizeof(plname) - 1)); (void) lcase(strncpy(g.plname, s, sizeof(g.plname) - 1));
} }
static void static void

View File

@@ -459,7 +459,7 @@ plselInitDialog(HWND hWnd)
TCHAR wbuf[BUFSZ]; TCHAR wbuf[BUFSZ];
/* set player name */ /* set player name */
SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(plname, wbuf, sizeof(wbuf))); SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(g.plname, wbuf, sizeof(wbuf)));
/* check flags for consistency */ /* check flags for consistency */
if (flags.initrole >= 0) { if (flags.initrole >= 0) {

View File

@@ -826,7 +826,7 @@ mswin_layout_main_window(HWND changed_child)
/* show command window only if it exists and /* show command window only if it exists and
the game is ready (plname is set) */ the game is ready (plname is set) */
if (GetNHApp()->bCmdPad && cmd_size.cx > 0 && cmd_size.cy > 0 if (GetNHApp()->bCmdPad && cmd_size.cx > 0 && cmd_size.cy > 0
&& *plname) { && *g.plname) {
MoveWindow(GetNHApp()->hCmdWnd, cmd_org.x, cmd_org.y, cmd_size.cx, MoveWindow(GetNHApp()->hCmdWnd, cmd_org.x, cmd_org.y, cmd_size.cx,
cmd_size.cy, TRUE); cmd_size.cy, TRUE);
ShowWindow(GetNHApp()->hCmdWnd, SW_SHOW); ShowWindow(GetNHApp()->hCmdWnd, SW_SHOW);

View File

@@ -182,7 +182,7 @@ FormatStatusString(char *text, int format)
int hp, hpmax; int hp, hpmax;
int cap = near_capacity(); int cap = near_capacity();
Strcpy(text, plname); Strcpy(text, g.plname);
if ('a' <= text[0] && text[0] <= 'z') if ('a' <= text[0] && text[0] <= 'z')
text[0] += 'A' - 'a'; text[0] += 'A' - 'a';
text[10] = 0; text[10] = 0;

View File

@@ -645,7 +645,7 @@ mswin_askname(void)
{ {
logDebug("mswin_askname()\n"); logDebug("mswin_askname()\n");
if (mswin_getlin_window("who are you?", plname, PL_NSIZ) == IDCANCEL) { if (mswin_getlin_window("who are you?", g.plname, PL_NSIZ) == IDCANCEL) {
bail("bye-bye"); bail("bye-bye");
/* not reached */ /* not reached */
} }

View File

@@ -1011,9 +1011,9 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks) :
QButtonGroup* namebox = new QButtonGroup(1,Horizontal,"Name",this); QButtonGroup* namebox = new QButtonGroup(1,Horizontal,"Name",this);
QLineEdit* name = new QLineEdit(namebox); QLineEdit* name = new QLineEdit(namebox);
name->setMaxLength(sizeof(plname)-1); name->setMaxLength(sizeof(g.plname)-1);
if ( strncmp(plname,"player",6) && strncmp(plname,"games",5) ) if ( strncmp(g.plname,"player",6) && strncmp(g.plname,"games",5) )
name->setText(plname); name->setText(g.plname);
connect(name, SIGNAL(textChanged(const QString&)), connect(name, SIGNAL(textChanged(const QString&)),
this, SLOT(selectName(const QString&)) ); this, SLOT(selectName(const QString&)) );
name->setFocus(); name->setFocus();
@@ -1169,7 +1169,7 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks) :
void NetHackQtPlayerSelector::selectName(const QString& n) void NetHackQtPlayerSelector::selectName(const QString& n)
{ {
strncpy(plname,n.latin1(),sizeof(plname)-1); strncpy(g.plname,n.latin1(),sizeof(g.plname)-1);
} }
void NetHackQtPlayerSelector::selectRole() void NetHackQtPlayerSelector::selectRole()
@@ -2529,7 +2529,7 @@ void NetHackQtStatusWindow::updateStats()
encumber.setLabel(enc); encumber.setLabel(enc);
encumber.show(); encumber.show();
} }
Strcpy(buf, plname); Strcpy(buf, g.plname);
if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a'; if ('a' <= buf[0] && buf[0] <= 'z') buf[0] += 'A'-'a';
Strcat(buf, " the "); Strcat(buf, " the ");
if (u.mtimedone) { if (u.mtimedone) {
@@ -3302,7 +3302,7 @@ static char** rip_line=0;
long year; long year;
/* Put name on stone */ /* Put name on stone */
Sprintf(rip_line[NAME_LINE], "%s", plname); Sprintf(rip_line[NAME_LINE], "%s", g.plname);
/* Put $ on stone */ /* Put $ on stone */
Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money); Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money);
@@ -4621,7 +4621,7 @@ void NetHackQtBind::qt_askname()
NetHackQtSavedGameSelector sgsel((const char**)saved); NetHackQtSavedGameSelector sgsel((const char**)saved);
ch = sgsel.choose(); ch = sgsel.choose();
if ( ch >= 0 ) if ( ch >= 0 )
strcpy(plname,saved[ch]); strcpy(g.plname,saved[ch]);
} }
free_saved_games(saved); free_saved_games(saved);

View File

@@ -184,7 +184,7 @@ void NetHackQtBind::qt_askname()
NetHackQtSavedGameSelector sgsel((const char**)saved); NetHackQtSavedGameSelector sgsel((const char**)saved);
ch = sgsel.choose(); ch = sgsel.choose();
if ( ch >= 0 ) if ( ch >= 0 )
str_copy(plname, saved[ch], SIZE(plname)); str_copy(g.plname, saved[ch], SIZE(g.plname));
} }
free_saved_games(saved); free_saved_games(saved);

View File

@@ -667,7 +667,7 @@ static char** rip_line=0;
int line; int line;
/* Put name on stone */ /* Put name on stone */
snprintf(rip_line[NAME_LINE], STONE_LINE_LEN+1, "%s", plname); snprintf(rip_line[NAME_LINE], STONE_LINE_LEN+1, "%s", g.plname);
/* Put $ on stone */ /* Put $ on stone */
snprintf(rip_line[GOLD_LINE], STONE_LINE_LEN+1, "%ld Au", money_cnt(invent)); snprintf(rip_line[GOLD_LINE], STONE_LINE_LEN+1, "%ld Au", money_cnt(invent));

View File

@@ -172,9 +172,9 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(NetHackQtKeyBuffer& ks) :
QVBoxLayout *namelayout = new QVBoxLayout(namebox); QVBoxLayout *namelayout = new QVBoxLayout(namebox);
QLineEdit* name = new QLineEdit(namebox); QLineEdit* name = new QLineEdit(namebox);
namelayout->addWidget(name); namelayout->addWidget(name);
name->setMaxLength(sizeof(plname)-1); name->setMaxLength(sizeof(g.plname)-1);
if ( strncmp(plname,"player",6) && strncmp(plname,"games",5) ) if ( strncmp(g.plname,"player",6) && strncmp(g.plname,"games",5) )
name->setText(plname); name->setText(g.plname);
connect(name, SIGNAL(textChanged(const QString&)), connect(name, SIGNAL(textChanged(const QString&)),
this, SLOT(selectName(const QString&)) ); this, SLOT(selectName(const QString&)) );
name->setFocus(); name->setFocus();
@@ -370,7 +370,7 @@ void NetHackQtPlayerSelector::Randomize()
void NetHackQtPlayerSelector::selectName(const QString& n) void NetHackQtPlayerSelector::selectName(const QString& n)
{ {
str_copy(plname,n.toLatin1().constData(),SIZE(plname)); str_copy(g.plname,n.toLatin1().constData(),SIZE(g.plname));
} }
void NetHackQtPlayerSelector::selectRole(int crow, int ccol, int prow, int pcol) void NetHackQtPlayerSelector::selectRole(int crow, int ccol, int prow, int pcol)

View File

@@ -434,7 +434,7 @@ void NetHackQtStatusWindow::updateStats()
buf = rank_of(u.ulevel, pl_character[0], ::flags.female); buf = rank_of(u.ulevel, pl_character[0], ::flags.female);
} }
QString buf2; QString buf2;
buf2.sprintf("%s the %s", plname, buf.toLatin1().constData()); buf2.sprintf("%s the %s", g.plname, buf.toLatin1().constData());
name.setLabel(buf2, NetHackQtLabelledIcon::NoNum, u.ulevel); name.setLabel(buf2, NetHackQtLabelledIcon::NoNum, u.ulevel);
char buf3[BUFSZ]; char buf3[BUFSZ];

View File

@@ -1713,7 +1713,7 @@ Cardinal *num_params;
nhUse(num_params); nhUse(num_params);
nh_XtPopdown(w); nh_XtPopdown(w);
(void) strcpy(plname, "Mumbles"); /* give them a name... ;-) */ (void) strcpy(g.plname, "Mumbles"); /* give them a name... ;-) */
exit_x_event = TRUE; exit_x_event = TRUE;
} }
@@ -1741,11 +1741,11 @@ XtPointer call_data;
} }
/* Truncate name if necessary */ /* Truncate name if necessary */
if (len >= sizeof plname - 1) if (len >= sizeof g.plname - 1)
len = sizeof plname - 1; len = sizeof g.plname - 1;
(void) strncpy(plname, s, len); (void) strncpy(g.plname, s, len);
plname[len] = '\0'; g.plname[len] = '\0';
XtFree(s); XtFree(s);
nh_XtPopdown(XtParent(dialog)); nh_XtPopdown(XtParent(dialog));
@@ -1778,7 +1778,7 @@ X11_askname()
(XtCallbackProc) 0); (XtCallbackProc) 0);
SetDialogPrompt(dialog, nhStr("What is your name?")); /* set prompt */ SetDialogPrompt(dialog, nhStr("What is your name?")); /* set prompt */
SetDialogResponse(dialog, plname, PL_NSIZ); /* set default answer */ SetDialogResponse(dialog, g.plname, PL_NSIZ); /* set default answer */
XtRealizeWidget(popup); XtRealizeWidget(popup);
positionpopup(popup, TRUE); /* center,bottom */ positionpopup(popup, TRUE); /* center,bottom */

View File

@@ -358,11 +358,11 @@ plsel_dialog_acceptvalues()
XtSetArg(args[0], nhStr(XtNstring), &s); XtSetArg(args[0], nhStr(XtNstring), &s);
XtGetValues(plsel_name_input, args, ONE); XtGetValues(plsel_name_input, args, ONE);
(void) strncpy(plname, (char *) s, sizeof plname - 1); (void) strncpy(g.plname, (char *) s, sizeof g.plname - 1);
plname[sizeof plname - 1] = '\0'; g.plname[sizeof g.plname - 1] = '\0';
(void) mungspaces(plname); (void) mungspaces(g.plname);
if (strlen(plname) < 1) if (strlen(g.plname) < 1)
(void) strcpy(plname, "Mumbles"); (void) strcpy(g.plname, "Mumbles");
iflags.renameinprogress = FALSE; iflags.renameinprogress = FALSE;
} }
@@ -829,8 +829,8 @@ Widget form;
XtSetArg(args[num_args], nhStr(XtNeditType), XtSetArg(args[num_args], nhStr(XtNeditType),
!plsel_ask_name ? XawtextRead : XawtextEdit); num_args++; !plsel_ask_name ? XawtextRead : XawtextEdit); num_args++;
XtSetArg(args[num_args], nhStr(XtNresize), XawtextResizeWidth); num_args++; XtSetArg(args[num_args], nhStr(XtNresize), XawtextResizeWidth); num_args++;
XtSetArg(args[num_args], nhStr(XtNstring), plname); num_args++; XtSetArg(args[num_args], nhStr(XtNstring), g.plname); num_args++;
XtSetArg(args[num_args], XtNinsertPosition, strlen(plname)); num_args++; XtSetArg(args[num_args], XtNinsertPosition, strlen(g.plname)); num_args++;
XtSetArg(args[num_args], nhStr(XtNaccelerators), XtSetArg(args[num_args], nhStr(XtNaccelerators),
XtParseAcceleratorTable(plsel_input_accelerators)); num_args++; XtParseAcceleratorTable(plsel_input_accelerators)); num_args++;
plsel_name_input = XtCreateManagedWidget("name_input", plsel_name_input = XtCreateManagedWidget("name_input",
@@ -1564,15 +1564,15 @@ void
X11_player_selection() X11_player_selection()
{ {
if (iflags.wc_player_selection == VIA_DIALOG) { if (iflags.wc_player_selection == VIA_DIALOG) {
if (!*plname) { if (!*g.plname) {
#ifdef UNIX #ifdef UNIX
char *defplname = get_login_name(); char *defplname = get_login_name();
#else #else
char *defplname = (char *)0; char *defplname = (char *)0;
#endif #endif
(void) strncpy(plname, defplname ? defplname : "Mumbles", (void) strncpy(g.plname, defplname ? defplname : "Mumbles",
sizeof plname - 1); sizeof g.plname - 1);
plname[sizeof plname - 1] = '\0'; g.plname[sizeof g.plname - 1] = '\0';
iflags.renameinprogress = TRUE; iflags.renameinprogress = TRUE;
} }
X11_player_selection_dialog(); X11_player_selection_dialog();

View File

@@ -1060,7 +1060,7 @@ long new_value;
if (attr_rec->type == SV_LABEL) { if (attr_rec->type == SV_LABEL) {
if (attr_rec == &shown_stats[F_NAME]) { if (attr_rec == &shown_stats[F_NAME]) {
Strcpy(buf, plname); Strcpy(buf, g.plname);
buf[0] = highc(buf[0]); buf[0] = highc(buf[0]);
Strcat(buf, " the "); Strcat(buf, " the ");
if (Upolyd) { if (Upolyd) {

View File

@@ -492,7 +492,7 @@ calculate_rip_text(int how, time_t when)
long year; long year;
/* Put name on stone */ /* Put name on stone */
Sprintf(rip_line[NAME_LINE], "%s", plname); Sprintf(rip_line[NAME_LINE], "%s", g.plname);
/* Put $ on stone */ /* Put $ on stone */
Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money); Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money);

View File

@@ -198,7 +198,7 @@ curses_player_selection()
void void
curses_askname() curses_askname()
{ {
curses_line_input_dialog("Who are you?", plname, PL_NSIZ); curses_line_input_dialog("Who are you?", g.plname, PL_NSIZ);
} }

View File

@@ -1152,7 +1152,7 @@ draw_horizontal(int x, int y, int hp, int hpmax)
wmove(win, y, x); wmove(win, y, x);
get_playerrank(rank); get_playerrank(rank);
sprintf(buf, "%s the %s", plname, rank); sprintf(buf, "%s the %s", g.plname, rank);
/* Use the title as HP bar (similar to hitpointbar) */ /* Use the title as HP bar (similar to hitpointbar) */
draw_bar(TRUE, hp, hpmax, buf); draw_bar(TRUE, hp, hpmax, buf);
@@ -1239,7 +1239,7 @@ draw_horizontal_new(int x, int y, int hp, int hpmax)
char race[BUFSZ]; char race[BUFSZ];
Strcpy(race, urace.adj); Strcpy(race, urace.adj);
race[0] = highc(race[0]); race[0] = highc(race[0]);
wprintw(win, "%s the %s %s%s%s", plname, wprintw(win, "%s the %s %s%s%s", g.plname,
(u.ualign.type == A_CHAOTIC ? "Chaotic" : (u.ualign.type == A_CHAOTIC ? "Chaotic" :
u.ualign.type == A_NEUTRAL ? "Neutral" : "Lawful"), u.ualign.type == A_NEUTRAL ? "Neutral" : "Lawful"),
Upolyd ? "" : race, Upolyd ? "" : " ", Upolyd ? "" : race, Upolyd ? "" : " ",
@@ -1358,7 +1358,7 @@ draw_vertical(int x, int y, int hp, int hpmax)
get_playerrank(rank); get_playerrank(rank);
int ranklen = strlen(rank); int ranklen = strlen(rank);
int namelen = strlen(plname); int namelen = strlen(g.plname);
int maxlen = 19; int maxlen = 19;
#ifdef STATUS_COLORS #ifdef STATUS_COLORS
if (!iflags.hitpointbar) if (!iflags.hitpointbar)
@@ -1375,7 +1375,7 @@ draw_vertical(int x, int y, int hp, int hpmax)
while ((ranklen + namelen) > maxlen) while ((ranklen + namelen) > maxlen)
ranklen--; /* Still doesn't fit, strip rank */ ranklen--; /* Still doesn't fit, strip rank */
} }
sprintf(buf, "%-*s the %-*s", namelen, plname, ranklen, rank); sprintf(buf, "%-*s the %-*s", namelen, g.plname, ranklen, rank);
draw_bar(TRUE, hp, hpmax, buf); draw_bar(TRUE, hp, hpmax, buf);
wmove(win, y++, x); wmove(win, y++, x);
wprintw(win, "%s", dungeons[u.uz.dnum].dname); wprintw(win, "%s", dungeons[u.uz.dnum].dname);

View File

@@ -499,7 +499,7 @@ Gem_player_selection()
void void
Gem_askname() Gem_askname()
{ {
strncpy(plname, mar_ask_name(), PL_NSIZ); strncpy(g.plname, mar_ask_name(), PL_NSIZ);
} }
void void
@@ -1074,7 +1074,7 @@ time_t when;
} }
/* Follows same algorithm as genl_outrip() */ /* Follows same algorithm as genl_outrip() */
/* Put name on stone */ /* Put name on stone */
Sprintf(rip_line[NAME_LINE], "%s", plname); Sprintf(rip_line[NAME_LINE], "%s", g.plname);
/* Put $ on stone */ /* Put $ on stone */
Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money); Sprintf(rip_line[GOLD_LINE], "%ld Au", done_money);
/* Put together death description */ /* Put together death description */

View File

@@ -355,7 +355,7 @@ gnome_askname()
/* Ask for a name and stuff the response into plname, a nethack global */ /* Ask for a name and stuff the response into plname, a nethack global */
ret = ghack_ask_string_dialog("What is your name?", "gandalf", ret = ghack_ask_string_dialog("What is your name?", "gandalf",
"GnomeHack", plname); "GnomeHack", g.plname);
/* Quit if they want to quit... */ /* Quit if they want to quit... */
if (ret == -1) { if (ret == -1) {
@@ -1169,7 +1169,7 @@ gnome_outrip(winid wid, int how, time_t when)
long year; long year;
/* Put name on stone */ /* Put name on stone */
Sprintf(buf, "%s\n", plname); Sprintf(buf, "%s\n", g.plname);
Strcat(ripString, buf); Strcat(ripString, buf);
/* Put $ on stone */ /* Put $ on stone */

View File

@@ -440,7 +440,7 @@ ghack_status_window_update_stats()
long umoney; long umoney;
/* First, fill in the player name and the dungeon level */ /* First, fill in the player name and the dungeon level */
strcpy(buf, plname); strcpy(buf, g.plname);
if ('a' <= buf[0] && buf[0] <= 'z') if ('a' <= buf[0] && buf[0] <= 'z')
buf[0] += 'A' - 'a'; buf[0] += 'A' - 'a';
strcat(buf, " the "); strcat(buf, " the ");