diff options
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/alan2/execute.cpp | 10 | ||||
-rw-r--r-- | engines/glk/alan2/parse.cpp | 40 | ||||
-rw-r--r-- | engines/glk/alan2/parse.h | 2 | ||||
-rw-r--r-- | engines/glk/alan2/saveload.cpp | 8 | ||||
-rw-r--r-- | engines/glk/frotz/mem.cpp | 4 | ||||
-rw-r--r-- | engines/glk/hugo/heglk.cpp | 38 | ||||
-rw-r--r-- | engines/glk/hugo/hemisc.cpp | 50 | ||||
-rw-r--r-- | engines/glk/hugo/herun.cpp | 36 |
8 files changed, 94 insertions, 94 deletions
diff --git a/engines/glk/alan2/execute.cpp b/engines/glk/alan2/execute.cpp index 8359c47e37..4fc0acb33b 100644 --- a/engines/glk/alan2/execute.cpp +++ b/engines/glk/alan2/execute.cpp @@ -234,7 +234,7 @@ bool Execute::confirm(MsgKind msgno) { #ifdef USE_READLINE if (!readline(buf)) return true; #else - if (gets(buf) == NULL) return true; + if (gets(buf) == nullptr) return true; #endif #endif @@ -260,7 +260,7 @@ void Execute::quit() { #ifdef USE_READLINE if (!readline(buf)) terminate(0); #else - if (gets(buf) == NULL) terminate(0); + if (gets(buf) == nullptr) terminate(0); #endif #endif @@ -682,17 +682,17 @@ void Execute::dscrobj(Aword obj) { void Execute::dscract(Aword act) { - ScrElem *scr = NULL; + ScrElem *scr = nullptr; if (_acts[act - ACTMIN].script != 0) { for (scr = (ScrElem *) addrTo(_acts[act - ACTMIN].scradr); !endOfTable(scr); scr++) if (scr->code == _acts[act - ACTMIN].script) break; if (endOfTable(scr)) - scr = NULL; + scr = nullptr; } - if (scr != NULL && scr->dscr != 0) + if (scr != nullptr && scr->dscr != 0) _vm->_interpreter->interpret(scr->dscr); else if (_acts[act - ACTMIN].dscr != 0) _vm->_interpreter->interpret(_acts[act - ACTMIN].dscr); diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp index aac858a062..8e6427d09c 100644 --- a/engines/glk/alan2/parse.cpp +++ b/engines/glk/alan2/parse.cpp @@ -75,7 +75,7 @@ char *Parser::gettoken(char *tokenBuffer) { static char *marker; static char oldch; - if (tokenBuffer == NULL) + if (tokenBuffer == nullptr) *marker = oldch; else marker = tokenBuffer; @@ -92,7 +92,7 @@ char *Parser::gettoken(char *tokenBuffer) { while (*marker != '\"') marker++; marker++; } else if (*marker == '\0' || *marker == '\n') - return NULL; + return nullptr; else marker++; @@ -128,7 +128,7 @@ void Parser::agetline() { quit(); } #else - if (fgets(buf, LISTLEN, stdin) == NULL) { + if (fgets(buf, LISTLEN, stdin) == nullptr) { newline(); quit(); } @@ -148,12 +148,12 @@ void Parser::agetline() { token = gettoken(isobuf); - if (token != NULL && strcmp("debug", token) == 0 && _vm->header->debug) { + if (token != nullptr && strcmp("debug", token) == 0 && _vm->header->debug) { dbgflg = true; debug(); - token = NULL; + token = nullptr; } - } while (token == NULL); + } while (token == nullptr); eol = false; lin = 1; @@ -212,7 +212,7 @@ void Parser::scan() { unknown(token); wrds[i] = EOF; - eol = (token = gettoken(NULL)) == NULL; + eol = (token = gettoken(nullptr)) == nullptr; } while (!eol); } @@ -377,10 +377,10 @@ void Parser::unambig(ParamElem plst[]) { static ParamElem *savlst; // Saved list for backup at EOF int firstWord, lastWord; // The words the player used - if (refs == NULL) + if (refs == nullptr) refs = new ParamElem[MAXENTITY + 1]; - if (savlst == NULL) + if (savlst == nullptr) savlst = new ParamElem[MAXENTITY + 1]; if (isLiteral(wrds[wrdidx])) { @@ -490,12 +490,12 @@ void Parser::unambig(ParamElem plst[]) { } void Parser::simple(ParamElem olst[]) { - static ParamElem *tlst = NULL; + static ParamElem *tlst = nullptr; int savidx = wrdidx; bool savplur = false; int i; - if (tlst == NULL) + if (tlst == nullptr) tlst = new ParamElem[MAXENTITY + 1]; tlst[0].code = (Aword)EOF; @@ -549,9 +549,9 @@ void Parser::complex(ParamElem olst[]) { // they work on words.Below all is converted to indices into the // entity tables.Particularly this goes for literals... - static ParamElem *alst = NULL; + static ParamElem *alst = nullptr; - if (alst == NULL) + if (alst == nullptr) alst = new ParamElem[MAXENTITY + 1]; if (isAll(wrds[wrdidx])) { @@ -653,18 +653,18 @@ AltElem *Parser::findalt(Aword vrbsadr, Aword param) { AltElem *alt; if (vrbsadr == 0) - return NULL; + return nullptr; for (vrb = (VrbElem *)addrTo(vrbsadr); !endOfTable(vrb); vrb++) { if ((int)vrb->code == _vm->cur.vrb) { for (alt = (AltElem *)addrTo(vrb->alts); !endOfTable(alt); alt++) if (alt->param == param || alt->param == 0) return alt; - return NULL; + return nullptr; } } - return NULL; + return nullptr; } bool Parser::trycheck(Aaddr adr, bool act) { @@ -732,10 +732,10 @@ void Parser::tryMatch(ParamElem mlstArr[]) { ClaElem *cla; // Pointer to class definitions bool anyPlural = false; // Any parameter that was plural? int i, p; - static ParamElem *tlst = NULL; // List of params found by complex() - static bool *checked = NULL; // Corresponding parameter checked? + static ParamElem *tlst = nullptr; // List of params found by complex() + static bool *checked = nullptr; // Corresponding parameter checked? - if (tlst == NULL) { + if (tlst == nullptr) { tlst = new ParamElem[MAXENTITY + 1]; checked = new bool[MAXENTITY + 1]; } @@ -930,7 +930,7 @@ void Parser::action(ParamElem plst[]) { } void Parser::parse() { - if (mlst == NULL) { // Allocate large enough paramlists + if (mlst == nullptr) { // Allocate large enough paramlists mlst = new ParamElem[MAXENTITY + 1]; mlst[0].code = (Aword)EOF; pmlst = new ParamElem[MAXENTITY + 1]; diff --git a/engines/glk/alan2/parse.h b/engines/glk/alan2/parse.h index 1e3601c773..c5b223baa0 100644 --- a/engines/glk/alan2/parse.h +++ b/engines/glk/alan2/parse.h @@ -71,7 +71,7 @@ private: int listLength(ParamElem a[]); /** - * Compact a list, i.e remove any NULL elements + * Compact a list, i.e remove any nullptr elements */ void listCompact(ParamElem a[]); diff --git a/engines/glk/alan2/saveload.cpp b/engines/glk/alan2/saveload.cpp index 2d92d34591..838c2588a1 100644 --- a/engines/glk/alan2/saveload.cpp +++ b/engines/glk/alan2/saveload.cpp @@ -39,7 +39,7 @@ void SaveLoad::save() { // TODO #if 0 frefid_t fref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Write, 0); - if (fref == NULL) + if (fref == nullptr) _vm->printError(M_SAVEFAILED); strcpy(str, garglk_fileref_get_name(fref)); @@ -53,12 +53,12 @@ void SaveLoad::save() { // TODO #if 0 - if ((savfil = fopen(str, READ_MODE)) != NULL) + if ((savfil = fopen(str, READ_MODE)) != nullptr) // It already existed if (!confirm(M_SAVEOVERWRITE)) _vm->printError(MSGMAX); // Return to player without saying anything - if ((savfil = fopen(str, WRITE_MODE)) == NULL) + if ((savfil = fopen(str, WRITE_MODE)) == nullptr) _vm->printError(M_SAVEFAILED); #endif @@ -124,7 +124,7 @@ void SaveLoad::restore() { // TODO #if 0 frefid_t fref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Read, 0); - if (fref == NULL) + if (fref == nullptr) _vm->printError(M_SAVEFAILED); strcpy(str, garglk_fileref_get_name(fref)); diff --git a/engines/glk/frotz/mem.cpp b/engines/glk/frotz/mem.cpp index 32e3ab3159..57dc5b5d15 100644 --- a/engines/glk/frotz/mem.cpp +++ b/engines/glk/frotz/mem.cpp @@ -224,9 +224,9 @@ void Mem::free_undo(int count) { undo_count--; } if (first_undo) - first_undo->prev = NULL; + first_undo->prev = nullptr; else - last_undo = NULL; + last_undo = nullptr; } void Mem::reset_memory() { diff --git a/engines/glk/hugo/heglk.cpp b/engines/glk/hugo/heglk.cpp index 4884d0f8cf..f6f40814f5 100644 --- a/engines/glk/hugo/heglk.cpp +++ b/engines/glk/hugo/heglk.cpp @@ -52,7 +52,7 @@ void Hugo::hugo_getline(const char *prmpt) { window that hasn't been created, switch as a failsafe to mainwin */ - if (currentwin == NULL) + if (currentwin == nullptr) glk_set_window(currentwin = mainwin); /* Print prompt */ @@ -97,7 +97,7 @@ int Hugo::hugo_waitforkey() { window that hasn't been created, switch as a failsafe to mainwin */ - if (currentwin == NULL) + if (currentwin == nullptr) glk_set_window(currentwin = mainwin); #if defined (NO_KEYPRESS_CURSOR) @@ -211,7 +211,7 @@ void Hugo::hugo_clearwindow() { not really a window */ if (inwindow && currentwin == mainwin) return; - if (currentwin == NULL) return; + if (currentwin == nullptr) return; glk_window_clear(currentwin); @@ -227,7 +227,7 @@ void Hugo::hugo_clearwindow() { stream_result_t sr; glk_window_close(auxwin, &sr); - auxwin = NULL; + auxwin = nullptr; glk_set_window(currentwin = mainwin); } @@ -256,11 +256,11 @@ void Hugo::hugo_settextwindow(int left, int top, int right, int bottom) { in_valid_window = false; /* Glk-illegal floating window; setting currentwin - to NULL will tell hugo_print() not to print in it: + to nullptr will tell hugo_print() not to print in it: */ if (bottom<physical_windowbottom / FIXEDLINEHEIGHT + 1) { - currentwin = NULL; + currentwin = nullptr; glk_set_window(mainwin); return; } @@ -313,7 +313,7 @@ void Hugo::hugo_settextwindow(int left, int top, int right, int bottom) { } else { - currentwin = NULL; + currentwin = nullptr; glk_set_window(mainwin); secondwin_bottom = 0; return; @@ -329,37 +329,37 @@ void Hugo::hugo_settextwindow(int left, int top, int right, int bottom) { } int Hugo::heglk_get_linelength() { - static uint32 width; + static uint width; // Try to use whatever fixed-width linelength is available if (secondwin) - glk_window_get_size(secondwin, &width, NULL); + glk_window_get_size(secondwin, &width, nullptr); else if (auxwin) - glk_window_get_size(auxwin, &width, NULL); + glk_window_get_size(auxwin, &width, nullptr); // Otherwise try to approximate it by the proportionally spaced linelength else - glk_window_get_size(mainwin, &width, NULL); + glk_window_get_size(mainwin, &width, nullptr); // -1 to override automatic line wrapping return width - 1; } int Hugo::heglk_get_screenheight() { - static uint32 height = 0, mainheight = 0; + static uint height = 0, mainheight = 0; if (secondwin) - glk_window_get_size(secondwin, NULL, &height); + glk_window_get_size(secondwin, nullptr, &height); else if (auxwin) - glk_window_get_size(auxwin, NULL, &height); + glk_window_get_size(auxwin, nullptr, &height); - glk_window_get_size(mainwin, NULL, &mainheight); + glk_window_get_size(mainwin, nullptr, &mainheight); return height + mainheight; } void Hugo::hugo_settextpos(int x, int y) { - if (currentwin == NULL) return; + if (currentwin == nullptr) return; // Try to determine if we're trying to position fixed-width text in the main window, // as in a menu, for example @@ -374,7 +374,7 @@ void Hugo::hugo_settextpos(int x, int y) { /* If not, create it, making it 100% of mainwin's height */ - if (auxwin == NULL) + if (auxwin == nullptr) { auxwin = glk_window_open(mainwin, winmethod_Below | winmethod_Proportional, @@ -398,7 +398,7 @@ void Hugo::hugo_settextpos(int x, int y) { /* Close auxwin */ glk_window_close(auxwin, &sr); - auxwin = NULL; + auxwin = nullptr; /* Clear the screen (both windows) */ glk_window_clear(mainwin); @@ -425,7 +425,7 @@ void Hugo::hugo_print(const char *a) { /* Can't print in a Glk-illegal window since it hasn't been created */ - if (currentwin == NULL) return; + if (currentwin == nullptr) return; /* In lieu of colors, in case we're highlighting something such as a menu selection: diff --git a/engines/glk/hugo/hemisc.cpp b/engines/glk/hugo/hemisc.cpp index 4a2ea2557a..07800bbcf8 100644 --- a/engines/glk/hugo/hemisc.cpp +++ b/engines/glk/hugo/hemisc.cpp @@ -734,7 +734,7 @@ if (n==UNKNOWN_OP_E || n==ILLEGAL_OP_E || n==EXPECT_VAL_E || n==OVERFLOW_E) hugo_closefiles(); hugo_blockfree(mem); - mem = NULL; + mem = nullptr; error("Error code: %d", (int)n); } @@ -786,16 +786,16 @@ void Hugo::FileIO() { { #if !defined (GLK) /* stdio implementation */ - if ((io = HUGO_FOPEN(fileiopath, "wb"))==NULL) goto LeaveFileIO; + if ((io = HUGO_FOPEN(fileiopath, "wb"))==nullptr) goto LeaveFileIO; #else /* Glk implementation */ - frefid_t fref = NULL; + frefid_t fref = nullptr; fref = glk_fileref_create_by_name(fileusage_Data | fileusage_BinaryMode, fileiopath, 0); io = glk_stream_open_file(fref, filemode_Write, 0); glk_fileref_destroy(fref); - if (io==NULL) goto LeaveFileIO; + if (io==nullptr) goto LeaveFileIO; #endif ioblock = 1; } @@ -803,16 +803,16 @@ void Hugo::FileIO() { { #if !defined (GLK) /* stdio implementation */ - if ((io = HUGO_FOPEN(fileiopath, "rb"))==NULL) goto LeaveFileIO; + if ((io = HUGO_FOPEN(fileiopath, "rb"))==nullptr) goto LeaveFileIO; #else /* Glk implementation */ - frefid_t fref = NULL; + frefid_t fref = nullptr; fref = glk_fileref_create_by_name(fileusage_Data | fileusage_BinaryMode, fileiopath, 0); io = glk_stream_open_file(fref, filemode_Read, 0); glk_fileref_destroy(fref); - if (io==NULL) goto LeaveFileIO; + if (io==nullptr) goto LeaveFileIO; #endif ioblock = 2; } @@ -834,7 +834,7 @@ void Hugo::FileIO() { if (ioerror) retflag = 0; hugo_fclose(io); - io = NULL; + io = nullptr; ioblock = 0; LeaveFileIO: @@ -1098,16 +1098,16 @@ void Hugo::LoadGame() { #if defined (DEBUGGER) if (!strcmp(gamefile, "")) { - game = NULL; + game = nullptr; strcpy(gamefile, "(no file)"); return; } #endif #if !defined (GLK) /* since in Glk the game stream is always open */ - if ((game = TrytoOpen(gamefile, "rb", "games"))==NULL) + if ((game = TrytoOpen(gamefile, "rb", "games"))==nullptr) { - if ((game = TrytoOpen(gamefile, "rb", "object"))==NULL) + if ((game = TrytoOpen(gamefile, "rb", "object"))==nullptr) FatalError(OPEN_E); } #endif @@ -1154,7 +1154,7 @@ void Hugo::LoadGame() { #endif hugo_closefiles(); hugo_blockfree(mem); - mem = NULL; + mem = nullptr; hugo_exit(line); } @@ -1173,7 +1173,7 @@ void Hugo::LoadGame() { #endif hugo_closefiles(); hugo_blockfree(mem); - mem = NULL; + mem = nullptr; hugo_exit(line); /* ditto */ } @@ -1198,10 +1198,10 @@ void Hugo::LoadGame() { #ifndef LOADGAMEDATA_REPLACED /* Allocate as much memory as is required */ - if ((!loaded_in_memory) || (mem = (unsigned char *)hugo_blockalloc(filelength))==NULL) + if ((!loaded_in_memory) || (mem = (unsigned char *)hugo_blockalloc(filelength))==nullptr) { loaded_in_memory = 0; - if ((mem = (unsigned char *)hugo_blockalloc(codeend))==NULL) + if ((mem = (unsigned char *)hugo_blockalloc(codeend))==nullptr) FatalError(MEMORY_E); } @@ -1321,7 +1321,7 @@ signed char def_slbgcolor = DEF_SLBGCOLOR; void ParseCommandLine(int argc, char *argv[]) { char drive[MAXDRIVE], dir[MAXDIR], fname[MAXFILENAME], ext[MAXEXT]; - char* game_file_arg = NULL; + char* game_file_arg = nullptr; #if defined(GCC_UNIX) && defined(DO_COLOR) int ch; @@ -1345,7 +1345,7 @@ void ParseCommandLine(int argc, char *argv[]) default: Banner(); if (mem) hugo_blockfree(mem); - mem = NULL; + mem = nullptr; exit(0); } } @@ -1358,11 +1358,11 @@ void ParseCommandLine(int argc, char *argv[]) } #endif - if (game_file_arg==NULL) + if (game_file_arg==nullptr) { Banner(); if (mem) hugo_blockfree(mem); - mem = NULL; + mem = nullptr; exit(0); } @@ -1617,7 +1617,7 @@ void Hugo::Printout(char *a, int no_scrollback_linebreak) { hugo_setbackcolor(bgcolor); } -#if defined (AMIGA) +#if defined (AMIGA) && !defined (GLK) else { if (currentpos + l >= physical_windowwidth) @@ -1750,7 +1750,7 @@ void Hugo::PromptMore() { { if (hugo_fclose(playback)) FatalError(READ_E); - playback = NULL; + playback = nullptr; } else if (playback && k=='+') skipping_more = true; @@ -1802,7 +1802,7 @@ int Hugo::RecordCommands() { strcpy(recordfile, line); #else /* Glk implementation */ - frefid_t fref = NULL; + frefid_t fref = nullptr; fref = glk_fileref_create_by_prompt(fileusage_Transcript | fileusage_TextMode, filemode_Write, 0); @@ -1824,7 +1824,7 @@ int Hugo::RecordCommands() { { if (hugo_fclose(record)) return (0); - record = NULL; + record = nullptr; return 1; } break; @@ -1844,7 +1844,7 @@ int Hugo::RecordCommands() { strcpy(recordfile, line); #else /* Glk implementation */ - frefid_t fref = NULL; + frefid_t fref = nullptr; fref = glk_fileref_create_by_prompt(fileusage_InputRecord | fileusage_TextMode, filemode_Read, 0); @@ -2173,7 +2173,7 @@ HUGO_FILE TrytoOpen(char *f, char *p, char *d) } } - return NULL; /* return NULL if not openable */ + return nullptr; /* return nullptr if not openable */ } #endif /* GLK */ diff --git a/engines/glk/hugo/herun.cpp b/engines/glk/hugo/herun.cpp index 43837977d5..6466f8829f 100644 --- a/engines/glk/hugo/herun.cpp +++ b/engines/glk/hugo/herun.cpp @@ -163,7 +163,7 @@ RestartDebugger: /* If no gamefile is loaded, jump immediately to the debugger interrupt function. */ - if (game==NULL) Debugger(); + if (game==nullptr) Debugger(); #endif stack_depth = RESET_STACK_DEPTH; @@ -271,7 +271,7 @@ FreshInput: { if (hugo_fclose(playback)) FatalError(READ_E); - playback = NULL; + playback = nullptr; GetCommand(); } else @@ -635,7 +635,7 @@ EndofCommand: if (playback) { if (hugo_fclose(playback)) FatalError(READ_E); - playback = NULL; + playback = nullptr; } Flushpbuffer(); @@ -702,7 +702,7 @@ NormalTermination: debugger_collapsing = false; - if ((game!=NULL) && !RunRestart()) + if ((game!=nullptr) && !RunRestart()) DebugMessageBox("Restart Error", "Unable to restart"); SwitchtoGame(); @@ -1115,7 +1115,7 @@ int Hugo::RunRestart() { { if (hugo_fclose(playback)) FatalError(READ_E); - playback = NULL; + playback = nullptr; } if (active_screen!=DEBUGGER) @@ -1169,7 +1169,7 @@ int Hugo::RestoreGameData() { { AP("Incorrect save file."); if (hugo_fclose(save)) FatalError(READ_E); - save = NULL; + save = nullptr; return 0; } @@ -1179,7 +1179,7 @@ int Hugo::RestoreGameData() { { AP("Save file created by different version."); if (hugo_fclose(save)) FatalError(READ_E); - save = NULL; + save = nullptr; return 0; } @@ -1258,7 +1258,7 @@ RestoreError: int Hugo::RunRestore() { #if !defined (GLK) - save = NULL; + save = nullptr; /* stdio implementation */ hugo_getfilename("to restore", savefile); @@ -1273,7 +1273,7 @@ int Hugo::RunRestore() { /* Glk implementation */ frefid_t savefile; - save = NULL; + save = nullptr; savefile = glk_fileref_create_by_prompt(fileusage_SavedGame | fileusage_BinaryMode, filemode_Read, 0); @@ -1281,7 +1281,7 @@ int Hugo::RunRestore() { if (glk_fileref_does_file_exist(savefile)) save = glk_stream_open_file(savefile, filemode_Read, 0); else - save = NULL; + save = nullptr; glk_fileref_destroy(savefile); if (!save) return 0; @@ -1290,7 +1290,7 @@ int Hugo::RunRestore() { if (!RestoreGameData()) goto RestoreError; if (hugo_fclose(save)) FatalError(READ_E); - save = NULL; + save = nullptr; #if !defined (GLK) strcpy(savefile, line); @@ -1302,7 +1302,7 @@ int Hugo::RunRestore() { RestoreError: if ((save) && hugo_fclose(save)) FatalError(READ_E); - save = NULL; + save = nullptr; game_reset = false; return 0; } @@ -1413,7 +1413,7 @@ void Hugo::RunRoutine(long addr) { } /* If not object.property or an event */ - if (strchr(debug_line, '.')==NULL && strstr(debug_line, "vent ")==NULL) + if (strchr(debug_line, '.')==nullptr && strstr(debug_line, "vent ")==nullptr) { strcat(debug_line, "("); for (i=0; i<arguments_passed; i++) @@ -2302,7 +2302,7 @@ int Hugo::RunSave() { #endif #if !defined (GLK) - save = NULL; + save = nullptr; /* stdio implementation */ hugo_getfilename("to save", savefile); @@ -2319,7 +2319,7 @@ int Hugo::RunSave() { /* Glk implementation */ frefid_t savefile; - save = NULL; + save = nullptr; savefile = glk_fileref_create_by_prompt(fileusage_SavedGame | fileusage_BinaryMode, filemode_Write, 0); @@ -2333,7 +2333,7 @@ int Hugo::RunSave() { if (!SaveGameData()) goto SaveError; if (hugo_fclose(save)) FatalError(WRITE_E); - save = NULL; + save = nullptr; #if !defined (GLK) strcpy(savefile, line); @@ -2343,7 +2343,7 @@ int Hugo::RunSave() { SaveError: if ((save) && hugo_fclose(save)) FatalError(WRITE_E); - save = NULL; + save = nullptr; return 0; } @@ -2388,7 +2388,7 @@ int Hugo::RunScriptSet() { if (script) { if (hugo_fclose(script)) return (0); - script = NULL; + script = nullptr; return 1; } break; |