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

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

View File

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

View File

@@ -348,7 +348,7 @@ menu_item **retmip;
nw->Screen = HackScreen;
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;
if (lastinvent.MaxX != 0) {
nw->LeftEdge = lastinvent.MinX;

View File

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

View File

@@ -228,7 +228,7 @@ macopen(const char *name, int flags, long fileType)
Handle name;
Str255 plnamep;
C2P(plname, plnamep);
C2P(g.plname, plnamep);
name = (Handle)NewString(plnamep);
if (name)
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);
if (name) {
Str255 save_f_p;
P2C(*(StringHandle) name, plname);
P2C(*(StringHandle) name, g.plname);
set_savefile_name(TRUE);
C2P(fqname(SAVEF, SAVEPREFIX, 0), save_f_p);
force_hdelete(theDirs.dataRefNum, theDirs.dataDirID,

View File

@@ -493,8 +493,8 @@ mac_askname()
SetPortDialogPort(askdialog);
/* Initialize the name text item */
ask_restring(plname, str);
if (plname[0]) {
ask_restring(g.plname, str);
if (g.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 (plname && plname [0]) {
strcpy ((char *) pName, plname);
if (g.plname && g.plname [0]) {
strcpy ((char *) pName, g.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(pl_character)) < 0)
else if ((currrole = str2role(g.pl_character)) < 0)
currrole = randrole();
/* 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], plname, str[0]);
plname[str[0]] = '\0';
BlockMove(&str[1], g.plname, str[0]);
g.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(plname, WIZARD_NAME);
strcpy(g.plname, WIZARD_NAME);
break;
default: /* Quit */
ExitToShell();
}
/* Process the role */
strcpy(pl_character, roles[currrole].name.m);
strcpy(g.pl_character, roles[currrole].name.m);
flags.initrole = currrole;
/* Process the race */

View File

@@ -24,7 +24,7 @@ getlock(void)
int fd;
int pid = getpid(); /* Process ID */
Sprintf(lock, "%d%s", getuid(), plname);
Sprintf(lock, "%d%s", getuid(), g.plname);
set_levelfile_name(lock, 0);
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;
opening_dialog = pl_character[0] ? FALSE : TRUE;
opening_dialog = g.pl_character[0] ? FALSE : TRUE;
switch (scancode) {
#ifdef SIMULATE_CURSOR
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
* another game with the same player name.
*/
Strcpy(lock, plname);
Strcpy(lock, g.plname);
regularize(lock);
getlock();
#else /* What follows is !PC_LOCKING */
#ifdef AMIGA /* We'll put the bones & levels in the user specified directory \
-jhsa */
Strcat(lock, plname);
Strcat(lock, g.plname);
Strcat(lock, ".99");
#else
#ifndef MFLOPPY
/* I'm not sure what, if anything, is left here, but MFLOPPY has
* conflicts with set_lock_and_bones() in files.c.
*/
Strcpy(lock, plname);
Strcpy(lock, g.plname);
Strcat(lock, ".99");
regularize(lock); /* is this necessary? */
/* not compatible with full path a la AMIGA */
@@ -565,11 +565,11 @@ char *argv[];
#endif
case 'u':
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) {
argc--;
argv++;
(void) strncpy(plname, argv[0], sizeof(plname) - 1);
(void) strncpy(g.plname, argv[0], sizeof(g.plname) - 1);
} else
raw_print("Player name expected after -u");
break;
@@ -747,7 +747,7 @@ port_help()
boolean
authorize_wizard_mode()
{
if (!strcmp(plname, WIZARD_NAME))
if (!strcmp(g.plname, WIZARD_NAME))
return TRUE;
return FALSE;
}

View File

@@ -229,11 +229,11 @@ char *argv[];
* dash matches role, race, gender, or alignment.
*/
/* 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 */
if (++len < (int) sizeof plname)
(void) strncat(strcat(plname, "-"), pl_character,
sizeof plname - len - 1);
if (++len < (int) sizeof g.plname)
(void) strncat(strcat(g.plname, "-"), g.pl_character,
sizeof g.plname - len - 1);
}
/* strip role,race,&c suffix; calls askname() if plname[] is empty
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
* (for locknum > 0).
*/
if (*plname) {
if (*g.plname) {
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);
(void) chmod(fq_save, 0); /* disallow parallel restores */
@@ -311,7 +311,7 @@ attempt_restore:
}
if (!resuming) {
boolean neednewlock = (!*plname);
boolean neednewlock = (!*g.plname);
/* new game: start by choosing role, race, etc;
player might change the hero's name while doing that,
in which case we try to restore under the new name
@@ -320,7 +320,7 @@ attempt_restore:
if (!plsel_once)
player_selection();
plsel_once = TRUE;
if (neednewlock && *plname)
if (neednewlock && *g.plname)
goto attempt_restore;
if (iflags.renameinprogress) {
/* player has renamed the hero while selecting role;
@@ -388,11 +388,11 @@ char *argv[];
#endif
case 'u':
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) {
argc--;
argv++;
(void) strncpy(plname, argv[0], sizeof plname - 1);
(void) strncpy(g.plname, argv[0], sizeof g.plname - 1);
} else {
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
* somebody else's name.
*/
if (!*plname) {
if (!*g.plname) {
register const char *s;
s = nh_getenv("USER");
@@ -550,8 +550,8 @@ whoami()
s = getlogin();
if (s && *s) {
(void) strncpy(plname, s, sizeof plname - 1);
if (index(plname, '-'))
(void) strncpy(g.plname, s, sizeof g.plname - 1);
if (index(g.plname, '-'))
return TRUE;
}
}
@@ -661,7 +661,7 @@ char *optstr;
if (!pw)
return FALSE;
if (sysopt.check_plname)
pwname = plname;
pwname = g.plname;
else
pwname = pw->pw_name;
pwlen = strlen(pwname);

View File

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

View File

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

View File

@@ -459,7 +459,7 @@ plselInitDialog(HWND hWnd)
TCHAR wbuf[BUFSZ];
/* 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 */
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
the game is ready (plname is set) */
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,
cmd_size.cy, TRUE);
ShowWindow(GetNHApp()->hCmdWnd, SW_SHOW);

View File

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

View File

@@ -645,7 +645,7 @@ mswin_askname(void)
{
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");
/* not reached */
}