From 0111a085604d0195240845f1f45c8ae11c5dba01 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sat, 13 Nov 2021 23:40:25 +0200 Subject: [PATCH] GLK: Use nullptr Using clang-tidy modernize-use-nullptr --- engines/glk/adrift/os_glk.cpp | 4 +- engines/glk/adrift/scdebug.cpp | 18 +- engines/glk/adrift/scexpr.cpp | 18 +- engines/glk/adrift/scgamest.cpp | 20 +- engines/glk/adrift/sclibrar.cpp | 52 +- engines/glk/adrift/sclocale.cpp | 10 +- engines/glk/adrift/scmemos.cpp | 6 +- engines/glk/adrift/scnpcs.cpp | 4 +- engines/glk/adrift/scobjcts.cpp | 2 +- engines/glk/adrift/scparser.cpp | 44 +- engines/glk/adrift/scprintf.cpp | 36 +- engines/glk/adrift/scprops.cpp | 28 +- engines/glk/adrift/screstrs.cpp | 12 +- engines/glk/adrift/scrunner.cpp | 40 +- engines/glk/adrift/sctaffil.cpp | 12 +- engines/glk/adrift/sctafpar.cpp | 42 +- engines/glk/adrift/scutils.cpp | 2 +- engines/glk/adrift/sxfile.cpp | 14 +- engines/glk/adrift/sxglob.cpp | 4 +- engines/glk/adrift/sxstubs.cpp | 26 +- engines/glk/adrift/sxutils.cpp | 4 +- engines/glk/advsys/glk_interface.cpp | 2 +- engines/glk/agt/agil.cpp | 64 +- engines/glk/agt/agtread.cpp | 110 +-- engines/glk/agt/agxfile.cpp | 142 ++-- engines/glk/agt/auxfile.cpp | 64 +- engines/glk/agt/debugcmd.cpp | 2 +- engines/glk/agt/disassemble.cpp | 16 +- engines/glk/agt/exec.cpp | 92 +-- engines/glk/agt/filename.cpp | 72 +- engines/glk/agt/gamedata.cpp | 36 +- engines/glk/agt/interface.cpp | 14 +- engines/glk/agt/metacommand.cpp | 18 +- engines/glk/agt/object.cpp | 28 +- engines/glk/agt/os_glk.cpp | 108 +-- engines/glk/agt/parser.cpp | 36 +- engines/glk/agt/runverb.cpp | 48 +- engines/glk/agt/savegame.cpp | 44 +- engines/glk/agt/token.cpp | 2 +- engines/glk/agt/util.cpp | 70 +- engines/glk/alan2/alan2.cpp | 2 +- engines/glk/alan2/args.cpp | 8 +- engines/glk/alan2/exe.cpp | 8 +- engines/glk/alan2/main.cpp | 40 +- engines/glk/alan2/parse.cpp | 32 +- engines/glk/alan2/sysdep.cpp | 10 +- engines/glk/alan3/act.cpp | 10 +- engines/glk/alan3/actor.cpp | 6 +- engines/glk/alan3/alt_info.cpp | 22 +- engines/glk/alan3/debug.cpp | 72 +- engines/glk/alan3/event.cpp | 2 +- engines/glk/alan3/exe.cpp | 22 +- engines/glk/alan3/fnmatch.cpp | 4 +- engines/glk/alan3/glkio.cpp | 8 +- engines/glk/alan3/instance.cpp | 2 +- engines/glk/alan3/inter.cpp | 6 +- engines/glk/alan3/lists.cpp | 2 +- engines/glk/alan3/main.cpp | 8 +- engines/glk/alan3/memory.cpp | 14 +- engines/glk/alan3/msg.cpp | 4 +- engines/glk/alan3/output.cpp | 8 +- engines/glk/alan3/params.cpp | 36 +- engines/glk/alan3/parse.cpp | 70 +- engines/glk/alan3/reverse.cpp | 2 +- engines/glk/alan3/scan.cpp | 22 +- engines/glk/alan3/set.cpp | 4 +- engines/glk/alan3/stack.cpp | 18 +- engines/glk/alan3/state.cpp | 26 +- engines/glk/alan3/state_stack.cpp | 6 +- engines/glk/alan3/syntax.cpp | 6 +- engines/glk/alan3/sysdep.cpp | 8 +- engines/glk/alan3/syserr.cpp | 6 +- engines/glk/alan3/word.cpp | 4 +- engines/glk/archetype/archetype.cpp | 2 +- engines/glk/comprehend/comprehend.cpp | 2 +- engines/glk/comprehend/debugger_dumper.cpp | 2 +- engines/glk/comprehend/dictionary.cpp | 8 +- engines/glk/comprehend/game.cpp | 6 +- engines/glk/glk_api.cpp | 2 +- engines/glk/hugo/heglk.cpp | 2 +- engines/glk/hugo/hemedia.cpp | 2 +- engines/glk/jacl/encapsulate.cpp | 20 +- engines/glk/jacl/findroute.cpp | 32 +- engines/glk/jacl/glk_saver.cpp | 14 +- engines/glk/jacl/interpreter.cpp | 340 +++++----- engines/glk/jacl/jacl_main.cpp | 130 ++-- engines/glk/jacl/jpp.cpp | 14 +- engines/glk/jacl/libcsv.cpp | 34 +- engines/glk/jacl/loader.cpp | 514 +++++++------- engines/glk/jacl/parser.cpp | 62 +- engines/glk/jacl/resolvers.cpp | 200 +++--- engines/glk/jacl/utils.cpp | 4 +- engines/glk/level9/bitmap.cpp | 42 +- engines/glk/level9/level9_main.cpp | 18 +- engines/glk/level9/os_glk.cpp | 4 +- engines/glk/magnetic/emu.cpp | 60 +- engines/glk/magnetic/glk.cpp | 112 ++-- engines/glk/quest/geas_file.cpp | 24 +- engines/glk/quest/geas_glk.cpp | 2 +- engines/glk/quest/geas_runner.cpp | 36 +- engines/glk/quest/quest.cpp | 4 +- engines/glk/quest/read_file.cpp | 16 +- engines/glk/scott/scott.cpp | 4 +- engines/glk/tads/os_banners.cpp | 38 +- engines/glk/tads/os_buffer.cpp | 2 +- engines/glk/tads/os_glk.cpp | 10 +- engines/glk/tads/tads2/built_in.cpp | 70 +- engines/glk/tads/tads2/character_map.cpp | 6 +- engines/glk/tads/tads2/command_line.cpp | 6 +- engines/glk/tads/tads2/debug.cpp | 2 +- engines/glk/tads/tads2/error_message.cpp | 4 +- engines/glk/tads/tads2/execute_command.cpp | 100 +-- engines/glk/tads/tads2/file_io.cpp | 50 +- engines/glk/tads/tads2/get_string.cpp | 14 +- engines/glk/tads/tads2/line_source_file.cpp | 30 +- engines/glk/tads/tads2/memory_cache.cpp | 34 +- engines/glk/tads/tads2/memory_cache_heap.cpp | 2 +- engines/glk/tads/tads2/memory_cache_swap.cpp | 6 +- engines/glk/tads/tads2/object.cpp | 24 +- engines/glk/tads/tads2/os.cpp | 2 +- engines/glk/tads/tads2/output.cpp | 662 +++++++++---------- engines/glk/tads/tads2/play.cpp | 6 +- engines/glk/tads/tads2/qa_scriptor.cpp | 14 +- engines/glk/tads/tads2/regex.cpp | 24 +- engines/glk/tads/tads2/run.cpp | 10 +- engines/glk/tads/tads2/runtime_driver.cpp | 100 +-- engines/glk/tads/tads2/tads2.cpp | 2 +- engines/glk/tads/tads2/tokenizer.cpp | 12 +- engines/glk/tads/tads2/vocabulary.cpp | 36 +- engines/glk/tads/tads2/vocabulary_parser.cpp | 176 ++--- engines/glk/window_text_buffer.cpp | 6 +- engines/glk/zcode/glk_interface.cpp | 2 +- engines/glk/zcode/processor.cpp | 2 +- engines/glk/zcode/windows.cpp | 4 +- 134 files changed, 2516 insertions(+), 2516 deletions(-) diff --git a/engines/glk/adrift/os_glk.cpp b/engines/glk/adrift/os_glk.cpp index 1f94db46d62..41375436525 100644 --- a/engines/glk/adrift/os_glk.cpp +++ b/engines/glk/adrift/os_glk.cpp @@ -2800,7 +2800,7 @@ static int gsc_startup_code(Common::SeekableReadStream *game_stream, int restore assert(game_stream); /* Open a temporary Glk main window. */ - window = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + window = g_vm->glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 0); if (window) { /* Clear and initialize the temporary window. */ g_vm->glk_window_clear(window); @@ -2907,7 +2907,7 @@ static void gsc_main() { } /* Create the Glk window, and set its stream as the current one. */ - gsc_main_window = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + gsc_main_window = g_vm->glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 0); if (!gsc_main_window) { gsc_fatal("GLK: Can't open main window"); g_vm->glk_exit(); diff --git a/engines/glk/adrift/scdebug.cpp b/engines/glk/adrift/scdebug.cpp index cb1f107a5bc..63380ae6822 100644 --- a/engines/glk/adrift/scdebug.cpp +++ b/engines/glk/adrift/scdebug.cpp @@ -72,7 +72,7 @@ static const sc_strings_t DEBUG_COMMANDS[] = { {"clearevents", DEBUG_CLEAREVENTS}, {"cleartasks", DEBUG_CLEARTASKS}, {"clearvariables", DEBUG_CLEARVARIABLES}, {"watchall", DEBUG_WATCHALL}, {"clearall", DEBUG_CLEARALL}, {"random", DEBUG_RANDOM}, {"quit", DEBUG_QUIT}, - {NULL, DEBUG_NONE} + {nullptr, DEBUG_NONE} }; /* @@ -204,7 +204,7 @@ static void debug_finalize(sc_gameref_t game) { sc_free(debug); /* Remove the debug reference from the game. */ - game->debugger = NULL; + game->debugger = nullptr; } @@ -1340,9 +1340,9 @@ static void debug_dump_common(sc_gameref_t game, sc_command_t command, /* Initialize variables to avoid gcc warnings. */ limit = 0; - class_ = NULL; - filter_function = NULL; - dumper_function = NULL; + class_ = nullptr; + filter_function = nullptr; + dumper_function = nullptr; /* Switch to undo game on relevant commands. */ switch (command) { @@ -1405,7 +1405,7 @@ static void debug_dump_common(sc_gameref_t game, sc_command_t command, case DEBUG_VARIABLES: case DEBUG_OLDVARIABLES: class_ = "Variable"; - filter_function = NULL; + filter_function = nullptr; dumper_function = debug_dump_variable; limit = debug_variable_count(game); break; @@ -1611,8 +1611,8 @@ static void debug_watchpoint_common(sc_gameref_t game, sc_command_t command, /* Initialize variables to avoid gcc warnings. */ limit = 0; - class_ = NULL; - watchpoints = NULL; + class_ = nullptr; + watchpoints = nullptr; action = FALSE; /* Set action to TRUE or FALSE, for setting/clearing watchpoints. */ @@ -2484,7 +2484,7 @@ void debug_set_enabled(sc_gameref_t game, sc_bool enable) { sc_bool debug_get_enabled(sc_gameref_t game) { const sc_debuggerref_t debug = debug_get_debugger(game); - return debug != NULL; + return debug != nullptr; } } // End of namespace Adrift diff --git a/engines/glk/adrift/scexpr.cpp b/engines/glk/adrift/scexpr.cpp index 0078f2c7acd..9a18a637253 100644 --- a/engines/glk/adrift/scexpr.cpp +++ b/engines/glk/adrift/scexpr.cpp @@ -88,13 +88,13 @@ static const sc_expr_multichar_t FUNCTION_TOKENS[] = { {"mod", 3, TOK_MOD}, {"abs", 3, TOK_ABS}, {"len", 3, TOK_LEN}, {"val", 3, TOK_VAL}, {"and", 3, TOK_AND}, {"mid", 3, TOK_MID}, {"str", 3, TOK_STR}, {"or", 2, TOK_OR}, {"if", 2, TOK_IF}, - {NULL, 0, TOK_NONE} + {nullptr, 0, TOK_NONE} }; static const sc_expr_multichar_t OPERATOR_TOKENS[] = { {"&&", 2, TOK_AND}, {"||", 2, TOK_OR}, {"==", 2, TOK_EQUAL}, {"!=", 2, TOK_NOT_EQUAL}, {"<>", 2, TOK_NOT_EQUAL}, {">=", 2, TOK_GREATER_EQ}, {"<=", 2, TOK_LESS_EQ}, - {NULL, 0, TOK_NONE} + {nullptr, 0, TOK_NONE} }; @@ -119,10 +119,10 @@ static sc_int expr_multichar_search(const sc_char *name, const sc_expr_multichar /* Tokenizer variables. */ -static const sc_char *expr_expression = NULL; +static const sc_char *expr_expression = nullptr; static sc_int expr_index = 0; static sc_vartype_t expr_token_value; -static sc_char *expr_temporary = NULL; +static sc_char *expr_temporary = nullptr; static sc_int expr_current_token = TOK_NONE; /* @@ -173,8 +173,8 @@ static void expr_tokenize_start(const sc_char *expression) { static void expr_tokenize_end(void) { /* Deallocate temporary strings, clear expression. */ sc_free(expr_temporary); - expr_temporary = NULL; - expr_expression = NULL; + expr_temporary = nullptr; + expr_expression = nullptr; expr_index = 0; expr_current_token = TOK_NONE; } @@ -339,7 +339,7 @@ static sc_int expr_next_token(void) { * Get the basic next token. We may adjust it later for unary minus/plus * depending on what it is, and the prior token. */ - token_value.voidp = NULL; + token_value.voidp = nullptr; token = expr_next_token_unadjusted(&token_value); /* Special handling for unary minus/plus signs. */ @@ -419,7 +419,7 @@ static sc_stack_t expr_eval_stack[MAX_NESTING_DEPTH]; static sc_int expr_eval_stack_index = 0; /* Variables set to reference for %...% values. */ -static sc_var_setref_t expr_varset = NULL; +static sc_var_setref_t expr_varset = nullptr; /* * expr_eval_start() @@ -675,7 +675,7 @@ static void expr_eval_action(CONTEXT, sc_int token) { * position, starting at 1, or 0 if not found. Then free the popped * strings, and push back the result. */ - search = (val1[0] != NUL) ? strstr(val1, val2) : NULL; + search = (val1[0] != NUL) ? strstr(val1, val2) : nullptr; result = (!search) ? 0 : search - val1 + 1; sc_free(val1); sc_free(val2); diff --git a/engines/glk/adrift/scgamest.cpp b/engines/glk/adrift/scgamest.cpp index bc8d24ea1e5..f5bd1e036d4 100644 --- a/engines/glk/adrift/scgamest.cpp +++ b/engines/glk/adrift/scgamest.cpp @@ -517,14 +517,14 @@ sc_gameref_t gs_create(sc_var_setref_t vars, sc_prop_setref_t bundle, sc_filterr game->filter = filter; /* Set memento to NULL for now; it's added later. */ - game->memento = NULL; + game->memento = nullptr; /* Initialize for no debugger. */ - game->debugger = NULL; + game->debugger = nullptr; /* Initialize the undo buffers to NULL for now. */ - game->temporary = NULL; - game->undo = NULL; + game->temporary = nullptr; + game->undo = nullptr; game->undo_available = FALSE; /* Create rooms state array. */ @@ -740,11 +740,11 @@ sc_gameref_t gs_create(sc_var_setref_t vars, sc_prop_setref_t bundle, sc_filterr game->score = 0; game->bold_room_names = TRUE; game->verbose = FALSE; - game->current_room_name = NULL; - game->status_line = NULL; - game->title = NULL; - game->author = NULL; - game->hint_text = NULL; + game->current_room_name = nullptr; + game->status_line = nullptr; + game->title = nullptr; + game->author = nullptr; + game->hint_text = nullptr; /* Resource controls. */ res_clear_resource(&game->requested_sound); @@ -816,7 +816,7 @@ static void gs_string_copy(sc_char **to_string, const sc_char *from_string) { *to_string = (sc_char *)sc_malloc(strlen(from_string) + 1); strcpy(*to_string, from_string); } else - *to_string = NULL; + *to_string = nullptr; } diff --git a/engines/glk/adrift/sclibrar.cpp b/engines/glk/adrift/sclibrar.cpp index 3e18b122d84..c02d1583e88 100644 --- a/engines/glk/adrift/sclibrar.cpp +++ b/engines/glk/adrift/sclibrar.cpp @@ -1008,12 +1008,12 @@ static sc_bool lib_can_go(sc_gameref_t game, sc_int room, sc_int direction) { /* List of direction names, for printing and counting exits. */ static const sc_char *const DIRNAMES_4[] = { "north", "east", "south", "west", "up", "down", "in", "out", - NULL + nullptr }; static const sc_char *const DIRNAMES_8[] = { "north", "east", "south", "west", "up", "down", "in", "out", "northeast", "southeast", "southwest", "northwest", - NULL + nullptr }; @@ -1497,7 +1497,7 @@ sc_bool lib_cmd_hints(sc_gameref_t game) { /* If the game has hints, display any relevant ones. */ if (game_has_hints) { - if (run_hint_iterate(game, NULL)) { + if (run_hint_iterate(game, nullptr)) { if (if_confirm(SC_CONF_VIEW_HINTS)) if_display_hints(game); } else @@ -1709,8 +1709,8 @@ sc_bool lib_cmd_statusline(sc_gameref_t game) { * Retrieve the game's name and author, the description of the current * game room, and any formatted game status line. */ - run_get_attributes(game, &name, &author, NULL, NULL, - &score, NULL, &room, &status, NULL, NULL, NULL, NULL); + run_get_attributes(game, &name, &author, nullptr, nullptr, + &score, nullptr, &room, &status, nullptr, nullptr, nullptr, nullptr); /* If nothing is yet determined, print the game name and author. */ if (!room || sc_strempty(room)) { @@ -2331,7 +2331,7 @@ sc_bool lib_cmd_examine_self(sc_gameref_t game) { const sc_prop_setref_t bundle = gs_get_bundle(game); sc_vartype_t vt_key[2]; sc_int task, object, count, trail; - const sc_char *description, *position = NULL; + const sc_char *description, *position = nullptr; /* Get selection task. */ vt_key[0].string = "Globals"; @@ -2649,7 +2649,7 @@ static sc_int lib_disambiguate_object_common(sc_gameref_t game, const sc_char *v } static sc_int lib_disambiguate_object(sc_gameref_t game, const sc_char *verb, sc_bool *is_ambiguous) { - return lib_disambiguate_object_common(game, verb, NULL, -1, is_ambiguous); + return lib_disambiguate_object_common(game, verb, nullptr, -1, is_ambiguous); } static sc_int lib_disambiguate_object_extended(sc_gameref_t game, const sc_char *verb, @@ -3354,7 +3354,7 @@ static sc_bool lib_try_game_command_common(sc_gameref_t game, const sc_char *ver } static sc_bool lib_try_game_command_short(sc_gameref_t game, const sc_char *verb, sc_int object) { - return lib_try_game_command_common(game, verb, object, NULL, -1, FALSE, FALSE); + return lib_try_game_command_common(game, verb, object, nullptr, -1, FALSE, FALSE); } static sc_bool lib_try_game_command_with_object(sc_gameref_t game, const sc_char *verb, @@ -4326,7 +4326,7 @@ sc_bool lib_cmd_take_all(sc_gameref_t game) { gs_set_multiple_references(game); objects = lib_apply_multiple_filter(game, lib_take_not_associated_filter, -1, - NULL); + nullptr); gs_clear_multiple_references(game); if (objects > 0) lib_take_backend(game); @@ -4544,7 +4544,7 @@ sc_bool lib_cmd_take_all_from(sc_gameref_t game) { gs_set_multiple_references(game); objects = lib_apply_multiple_filter(game, lib_take_from_filter, associate, - NULL); + nullptr); gs_clear_multiple_references(game); if (objects > 0) lib_take_from_object_backend(game, associate); @@ -4687,7 +4687,7 @@ sc_bool lib_cmd_take_all_from_npc(sc_gameref_t game) { gs_set_multiple_references(game); objects = lib_apply_multiple_filter(game, lib_take_from_npc_filter, associate, - NULL); + nullptr); gs_clear_multiple_references(game); if (objects > 0) lib_take_from_npc_backend(game, associate); @@ -4927,7 +4927,7 @@ sc_bool lib_cmd_drop_all(sc_gameref_t game) { gs_set_multiple_references(game); objects = lib_apply_multiple_filter(game, lib_drop_filter, -1, - NULL); + nullptr); gs_clear_multiple_references(game); if (objects > 0) lib_drop_backend(game); @@ -5037,7 +5037,7 @@ sc_bool lib_cmd_give_object_npc(sc_gameref_t game) { return is_ambiguous; /* Get the referenced npc, and if none, consider complete. */ - npc = lib_disambiguate_npc(game, "give to", NULL); + npc = lib_disambiguate_npc(game, "give to", nullptr); if (npc == -1) return TRUE; @@ -5338,7 +5338,7 @@ sc_bool lib_cmd_wear_all(sc_gameref_t game) { gs_set_multiple_references(game); objects = lib_apply_multiple_filter(game, lib_wear_filter, -1, - NULL); + nullptr); gs_clear_multiple_references(game); if (objects > 0) lib_wear_backend(game); @@ -5576,7 +5576,7 @@ sc_bool lib_cmd_remove_all(sc_gameref_t game) { gs_set_multiple_references(game); objects = lib_apply_multiple_filter(game, lib_remove_filter, -1, - NULL); + nullptr); gs_clear_multiple_references(game); if (objects > 0) lib_remove_backend(game); @@ -5959,8 +5959,8 @@ static void lib_attempt_key_acquisition(sc_gameref_t game, sc_int object) { * capacity checks are meaningless. */ if (!obj_indirectly_held_by_player(game, object)) { - if (lib_object_too_heavy(game, object, NULL) - || lib_object_too_large(game, object, NULL)) + if (lib_object_too_heavy(game, object, nullptr) + || lib_object_too_large(game, object, nullptr)) return; } @@ -6012,7 +6012,7 @@ sc_bool lib_cmd_unlock_object_with(sc_gameref_t game) { pf_buffer_string(filter, "What do you want to unlock that with?\n"); return TRUE; } - key = lib_disambiguate_object(game, "unlock that with", NULL); + key = lib_disambiguate_object(game, "unlock that with", nullptr); if (key == -1) return TRUE; @@ -6201,7 +6201,7 @@ sc_bool lib_cmd_lock_object_with(sc_gameref_t game) { pf_buffer_string(filter, "What do you want to lock that with?\n"); return TRUE; } - key = lib_disambiguate_object(game, "lock that with", NULL); + key = lib_disambiguate_object(game, "lock that with", nullptr); if (key == -1) return TRUE; @@ -6930,7 +6930,7 @@ sc_bool lib_cmd_put_all_in(sc_gameref_t game) { gs_set_multiple_references(game); objects = lib_apply_multiple_filter(game, lib_put_in_not_container_filter, - container, NULL); + container, nullptr); gs_clear_multiple_references(game); if (objects > 0) lib_put_in_backend(game, container); @@ -7298,7 +7298,7 @@ sc_bool lib_cmd_put_all_on(sc_gameref_t game) { gs_set_multiple_references(game); objects = lib_apply_multiple_filter(game, lib_put_on_not_supporter_filter, - supporter, NULL); + supporter, nullptr); gs_clear_multiple_references(game); if (objects > 0) lib_put_on_backend(game, supporter); @@ -7545,7 +7545,7 @@ sc_bool lib_cmd_attack_npc_with(sc_gameref_t game) { return is_ambiguous; /* Get the referenced object, and if none, consider complete. */ - object = lib_disambiguate_object(game, "attack with", NULL); + object = lib_disambiguate_object(game, "attack with", nullptr); if (object == -1) return TRUE; @@ -7918,8 +7918,8 @@ static sc_bool lib_stand_sit_lie(sc_gameref_t game, sc_int movement) { sc_bool is_ambiguous; /* Initialize variables to avoid gcc warnings. */ - disambiguate = NULL; - cant_do_that = NULL; + disambiguate = nullptr; + cant_do_that = nullptr; movement_mask = 0; /* Set disambiguation and not amenable messages. */ @@ -8761,7 +8761,7 @@ sc_bool lib_cmd_shout(sc_gameref_t game) { sc_bool lib_cmd_say(sc_gameref_t game) { const sc_filterref_t filter = gs_get_filter(game); - const sc_char *string = NULL; + const sc_char *string = nullptr; switch (sc_randomint(1, 5)) { case 1: @@ -8840,7 +8840,7 @@ sc_bool lib_cmd_whistle(sc_gameref_t game) { sc_bool lib_cmd_interrogation(sc_gameref_t game) { const sc_filterref_t filter = gs_get_filter(game); - const sc_char *string = NULL; + const sc_char *string = nullptr; switch (sc_randomint(1, 17)) { case 1: diff --git a/engines/glk/adrift/sclocale.cpp b/engines/glk/adrift/sclocale.cpp index 140e9c9be3e..9180b1b31ef 100644 --- a/engines/glk/adrift/sclocale.cpp +++ b/engines/glk/adrift/sclocale.cpp @@ -135,7 +135,7 @@ struct sc_locale_table_t { * Define a single static locale table set. This set re-initializes if it * detects a locale change. */ -static sc_locale_table_t loc_locale_tables = {NULL, {0}, {0}, {0}, {0}, {0}}; +static sc_locale_table_t loc_locale_tables = {nullptr, {0}, {0}, {0}, {0}, {0}}; /* @@ -225,7 +225,7 @@ static const sc_locale_t CYRILLIC_LOCALE = { static const sc_locale_t *const AVAILABLE_LOCALES[] = { &LATIN1_LOCALE, &CYRILLIC_LOCALE, - NULL + nullptr }; /* @@ -256,7 +256,7 @@ static const sc_char *loc_locate_signature_in_date(const sc_char *date) { if (converted == 3 && strlen(signature) == SIGNATURE_LENGTH) return strstr(date, signature); else - return NULL; + return nullptr; } @@ -297,7 +297,7 @@ static sc_bool loc_compare_locale_signatures(const char *signature, const sc_loc static const sc_locale_t *loc_find_matching_locale(const sc_char *date, const sc_locale_t *const *locales) { const sc_char *signature; - const sc_locale_t *matched = NULL; + const sc_locale_t *matched = nullptr; /* Get the month part of date, and if valid, search locale signatures. */ signature = loc_locate_signature_in_date(date); @@ -385,7 +385,7 @@ static sc_int loc_ascii_strncasecmp(const sc_char *s1, const sc_char *s2, sc_int * if none yet set. */ sc_bool loc_set_locale(const sc_char *name) { - const sc_locale_t *matched = NULL; + const sc_locale_t *matched = nullptr; const sc_locale_t *const *iterator; assert(name); diff --git a/engines/glk/adrift/scmemos.cpp b/engines/glk/adrift/scmemos.cpp index c26f6840c04..1d1ebf9bf83 100644 --- a/engines/glk/adrift/scmemos.cpp +++ b/engines/glk/adrift/scmemos.cpp @@ -470,7 +470,7 @@ void memo_next_command(sc_memo_setref_t memento, const sc_char **command, *turns = history->turns; } else { /* Return NULL and zeroes if no more commands available. */ - *command = NULL; + *command = nullptr; *sequence = 0; *timestamp = 0; *turns = 0; @@ -523,7 +523,7 @@ const sc_char *memo_find_command(sc_memo_setref_t memento, sc_int sequence) { * efficient here, but this is a rarely called function so we'll do it the * simpler way. */ - matched = NULL; + matched = nullptr; for (index_ = 0; index_ < MEMO_HISTORY_TABLE_SIZE; index_++) { sc_historyref_t history; @@ -539,7 +539,7 @@ const sc_char *memo_find_command(sc_memo_setref_t memento, sc_int sequence) { * history was not full, this will still return NULL as it should, since * this unused history's command found by the search above will be NULL. */ - return matched ? matched->command : NULL; + return matched ? matched->command : nullptr; } diff --git a/engines/glk/adrift/scnpcs.cpp b/engines/glk/adrift/scnpcs.cpp index d3567f6c8f2..debe023b0cd 100644 --- a/engines/glk/adrift/scnpcs.cpp +++ b/engines/glk/adrift/scnpcs.cpp @@ -163,13 +163,13 @@ static sc_bool npc_room_in_roomgroup(sc_gameref_t game, sc_int room, sc_int grou static const sc_char *const DIRNAMES_4[] = { "the north", "the east", "the south", "the west", "above", "below", "inside", "outside", - NULL + nullptr }; static const sc_char *const DIRNAMES_8[] = { "the north", "the east", "the south", "the west", "above", "below", "inside", "outside", "the north-east", "the south-east", "the south-west", "the north-west", - NULL + nullptr }; /* diff --git a/engines/glk/adrift/scobjcts.cpp b/engines/glk/adrift/scobjcts.cpp index 66c2e1e4ed7..d9c8ba03175 100644 --- a/engines/glk/adrift/scobjcts.cpp +++ b/engines/glk/adrift/scobjcts.cpp @@ -234,7 +234,7 @@ sc_char *obj_state_name(sc_gameref_t game, sc_int objnum) { count--; } if (count != 1) - return NULL; + return nullptr; /* Find the end of the state string. */ for (last = first; last < length; last++) { diff --git a/engines/glk/adrift/scparser.cpp b/engines/glk/adrift/scparser.cpp index c7053069746..a716b7a31e3 100644 --- a/engines/glk/adrift/scparser.cpp +++ b/engines/glk/adrift/scparser.cpp @@ -77,7 +77,7 @@ static const sc_uip_token_entry_t UIP_TOKENS[] = { {"%object%", 8, TOK_OBJECT_REFERENCE}, {"%number%", 8, TOK_NUMBER_REFERENCE}, {"%text%", 6, TOK_TEXT_REFERENCE}, - {NULL, 0, TOK_NONE} + {nullptr, 0, TOK_NONE} }; @@ -86,12 +86,12 @@ static const sc_uip_token_entry_t UIP_TOKENS[] = { * For improved performance, we'll set it to indicate a static buffer if * short enough, otherwise it's allocated. */ -static const sc_char *uip_pattern = NULL; +static const sc_char *uip_pattern = nullptr; static sc_int uip_index = 0; static const sc_char *uip_token_value; enum { UIP_ALLOCATION_AVOIDANCE_SIZE = 128 }; static sc_char uip_static_temporary[UIP_ALLOCATION_AVOIDANCE_SIZE]; -static sc_char *uip_temporary = NULL; +static sc_char *uip_temporary = nullptr; /* @@ -134,8 +134,8 @@ static void uip_tokenize_end(void) { /* Deallocate temporary if required, and clear pattern and index. */ if (uip_temporary != uip_static_temporary) sc_free(uip_temporary); - uip_temporary = NULL; - uip_pattern = NULL; + uip_temporary = nullptr; + uip_pattern = nullptr; uip_index = 0; } @@ -152,7 +152,7 @@ static sc_uip_tok_t uip_next_token(void) { /* Get next character, return EOS if at pattern end. */ if (uip_pattern[uip_index] == NUL) { - uip_token_value = NULL; + uip_token_value = nullptr; return TOK_EOS; } @@ -162,7 +162,7 @@ static sc_uip_tok_t uip_next_token(void) { while (sc_isspace(uip_pattern[uip_index]) && uip_pattern[uip_index] != NUL) uip_index++; - uip_token_value = NULL; + uip_token_value = nullptr; return TOK_WHITESPACE; } @@ -174,7 +174,7 @@ static sc_uip_tok_t uip_next_token(void) { if (entry->name) { /* Advance over string, and return token. */ uip_index += entry->length; - uip_token_value = NULL; + uip_token_value = nullptr; return entry->token; } @@ -249,7 +249,7 @@ typedef sc_ptnode_t *sc_ptnoderef_t; static sc_uip_tok_t uip_parse_lookahead = TOK_NONE; /* Parse tree for cleanup, and forward declaration of pattern list parser. */ -static sc_ptnoderef_t uip_parse_tree = NULL; +static sc_ptnoderef_t uip_parse_tree = nullptr; /* * Pool of statically allocated nodes, for faster allocations. Nodes are @@ -421,10 +421,10 @@ static sc_ptnoderef_t uip_new_node(sc_pttype_t type) { } /* Fill in the remaining fields and return the new node. */ - node->left_child = NULL; - node->right_sibling = NULL; + node->left_child = nullptr; + node->right_sibling = nullptr; node->type = type; - node->word = NULL; + node->word = nullptr; return node; } @@ -492,7 +492,7 @@ static void uip_parse_alternatives(CONTEXT, sc_ptnoderef_t node) { * Parse a single pattern element. */ static sc_ptnoderef_t uip_parse_element(CONTEXT) { - sc_ptnoderef_t node = NULL; + sc_ptnoderef_t node = nullptr; sc_uip_tok_t token; /* Handle pattern element based on lookahead token. */ @@ -746,9 +746,9 @@ static void uip_debug_dump(void) { /* String matching variables. */ -static const sc_char *uip_string = NULL; +static const sc_char *uip_string = nullptr; static sc_int uip_posn = 0; -static sc_gameref_t uip_game = NULL; +static sc_gameref_t uip_game = nullptr; /* * uip_match_start() @@ -767,9 +767,9 @@ static void uip_match_start(const sc_char *string, sc_gameref_t game) { static void uip_match_end(void) { /* Clear match target string, and variable set. */ - uip_string = NULL; + uip_string = nullptr; uip_posn = 0; - uip_game = NULL; + uip_game = nullptr; } @@ -1594,7 +1594,7 @@ static sc_char *uip_free_cleansed_string(sc_char *string, const sc_char *buffer) sc_free(string); /* Always returns NULL, for the syntactic convenience of the caller. */ - return NULL; + return nullptr; } @@ -1637,7 +1637,7 @@ sc_bool uip_match(const sc_char *pattern, const sc_char *string, sc_gameref_t ga // Parse error -- clean up and fail uip_tokenize_end(); uip_destroy_tree(uip_parse_tree); - uip_parse_tree = NULL; + uip_parse_tree = nullptr; cleansed = uip_free_cleansed_string(cleansed, buffer); return FALSE; } else { @@ -1660,7 +1660,7 @@ sc_bool uip_match(const sc_char *pattern, const sc_char *string, sc_gameref_t ga uip_match_end(); cleansed = uip_free_cleansed_string(cleansed, buffer); uip_destroy_tree(uip_parse_tree); - uip_parse_tree = NULL; + uip_parse_tree = nullptr; /* Return result of matching. */ if (uip_trace) @@ -1688,7 +1688,7 @@ sc_char *uip_replace_pronouns(sc_gameref_t game, const sc_char *string) { /* Begin with a NULL buffer for lazy allocation. */ buffer_allocation = 0; - buffer = NULL; + buffer = nullptr; /* Search for pronouns until no more string remains. */ current = string + strspn(string, WHITESPACE); @@ -1699,7 +1699,7 @@ sc_char *uip_replace_pronouns(sc_gameref_t game, const sc_char *string) { /* Initially, no object or NPC, no names, and a zero extent. */ object = npc = -1; - prefix = name = NULL; + prefix = name = nullptr; extent = 0; /* diff --git a/engines/glk/adrift/scprintf.cpp b/engines/glk/adrift/scprintf.cpp index fcbbc58767a..f444cb8e65e 100644 --- a/engines/glk/adrift/scprintf.cpp +++ b/engines/glk/adrift/scprintf.cpp @@ -83,7 +83,7 @@ static const sc_html_tags_t HTML_TAGS_TABLE[] = { {"b", 1, SC_TAG_BOLD}, {"/b", 2, SC_TAG_ENDBOLD}, {"u", 1, SC_TAG_UNDERLINE}, {"/u", 2, SC_TAG_ENDUNDERLINE}, {"c", 1, SC_TAG_COLOR}, {"/c", 2, SC_TAG_ENDCOLOR}, - {NULL, 0, SC_TAG_UNKNOWN} + {nullptr, 0, SC_TAG_UNKNOWN} }; /* @@ -144,7 +144,7 @@ sc_filterref_t pf_create(void) { filter->magic = PRINTFILTER_MAGIC; filter->buffer_length = 0; filter->buffer_allocation = 0; - filter->buffer = NULL; + filter->buffer = nullptr; filter->new_sentence = FALSE; filter->is_muted = FALSE; filter->needs_filtering = FALSE; @@ -191,8 +191,8 @@ static sc_char *pf_interpolate_vars(const sc_char *string, sc_var_setref_t vars) * Begin with NULL buffer and name strings for lazy allocation, and clear * interpolation detection flag. */ - buffer = NULL; - name = NULL; + buffer = nullptr; + name = nullptr; is_interpolated = FALSE; /* Run through the string looking for variables. */ @@ -271,7 +271,7 @@ static sc_char *pf_interpolate_vars(const sc_char *string, sc_var_setref_t vars) strcat(buffer, marker); } else { sc_free(buffer); - buffer = NULL; + buffer = nullptr; } } @@ -298,7 +298,7 @@ static sc_bool pf_replace_alr(const sc_char *string, sc_char **buffer, sc_int al vt_key[1].integer = alr; vt_key[2].string = "Original"; original = prop_get_string(bundle, "S<-sis", vt_key); - replacement = NULL; + replacement = nullptr; /* Ignore pathological empty originals. */ if (original[0] == NUL) @@ -342,7 +342,7 @@ static sc_bool pf_replace_alr(const sc_char *string, sc_char **buffer, sc_int al /* Write back buffer, and if replacement set, the buffer was altered. */ *buffer = buffer_; - return replacement != NULL; + return replacement != nullptr; } @@ -364,7 +364,7 @@ static sc_char *pf_replace_alrs(const sc_char *string, sc_prop_setref_t bundle, * lot of allocation and copying, we use two buffers to help with repeated * ALR replacement. */ - buffer1 = buffer2 = NULL; + buffer1 = buffer2 = nullptr; buffer = &buffer1; /* Run through each ALR that exists. */ @@ -421,7 +421,7 @@ static sc_char *pf_replace_alrs(const sc_char *string, sc_prop_setref_t bundle, sc_free(buffer1); return buffer2; } else - return NULL; + return nullptr; } @@ -653,15 +653,15 @@ static sc_char *pf_filter_internal(const sc_char *string, sc_var_setref_t vars, alr_applied = (sc_bool *)sc_malloc(alr_count * sizeof(*alr_applied)); memset(alr_applied, FALSE, alr_count * sizeof(*alr_applied)); } else - alr_applied = NULL; + alr_applied = nullptr; } else { /* Not including ALRs, so set alr count to 0, and flags to NULL. */ alr_count = 0; - alr_applied = NULL; + alr_applied = nullptr; } /* Loop for a sort-of arbitrary number of passes; probably enough. */ - current = NULL; + current = nullptr; for (iteration = 0; iteration < ITERATION_LIMIT; iteration++) { sc_int inner_iteration; const sc_char *initial; @@ -760,7 +760,7 @@ sc_char *pf_filter_for_info(const sc_char *string, sc_var_setref_t vars) { sc_char *current; /* Filter this string, excluding ALRs replacements. */ - current = pf_filter_internal(string, vars, NULL); + current = pf_filter_internal(string, vars, nullptr); /* Our contract is to return an allocated string; copy if required. */ if (!current) { @@ -910,7 +910,7 @@ const sc_char *pf_get_buffer(sc_filterref_t filter) { assert(filter->buffer[filter->buffer_length] == NUL); return filter->buffer; } else - return NULL; + return nullptr; } sc_char *pf_transfer_buffer(sc_filterref_t filter) { @@ -931,7 +931,7 @@ sc_char *pf_transfer_buffer(sc_filterref_t filter) { /* Clear all filter fields down to empty values. */ filter->buffer_length = 0; filter->buffer_allocation = 0; - filter->buffer = NULL; + filter->buffer = nullptr; filter->new_sentence = FALSE; filter->is_muted = FALSE; filter->needs_filtering = FALSE; @@ -939,7 +939,7 @@ sc_char *pf_transfer_buffer(sc_filterref_t filter) { /* Return the allocated buffered text. */ return retval; } else - return NULL; + return nullptr; } @@ -955,7 +955,7 @@ void pf_empty(sc_filterref_t filter) { filter->buffer_length = 0; filter->buffer_allocation = 0; sc_free(filter->buffer); - filter->buffer = NULL; + filter->buffer = nullptr; filter->new_sentence = FALSE; filter->is_muted = FALSE; filter->needs_filtering = FALSE; @@ -1314,7 +1314,7 @@ sc_char *pf_filter_input(const sc_char *string, sc_prop_setref_t bundle) { /* Begin with a NULL buffer for lazy allocation. */ buffer_allocation = 0; - buffer = NULL; + buffer = nullptr; /* Loop over each word in the string. */ current = string + strspn(string, WHITESPACE); diff --git a/engines/glk/adrift/scprops.cpp b/engines/glk/adrift/scprops.cpp index aab21d57605..97063663740 100644 --- a/engines/glk/adrift/scprops.cpp +++ b/engines/glk/adrift/scprops.cpp @@ -311,7 +311,7 @@ static sc_prop_noderef_t prop_find_child(sc_prop_noderef_t parent, sc_int type, } /* No matching child found. */ - return NULL; + return nullptr; } @@ -344,8 +344,8 @@ static sc_prop_noderef_t prop_add_child(sc_prop_noderef_t parent, sc_int type, } /* Initialize property and child list to visible nulls. */ - child->property.voidp = NULL; - child->child_list = NULL; + child->property.voidp = nullptr; + child->child_list = nullptr; /* Make a brief check for obvious overwrites. */ if (!parent->child_list && parent->property.voidp) @@ -734,16 +734,16 @@ static sc_prop_setref_t prop_create_empty() { /* Begin with an empty strings dictionary. */ bundle->dictionary_length = 0; - bundle->dictionary = NULL; + bundle->dictionary = nullptr; /* Begin with no allocated node pools. */ bundle->node_pools_length = 0; - bundle->node_pools = NULL; + bundle->node_pools = nullptr; bundle->node_count = 0; /* Begin with no adopted addresses. */ bundle->orphans_length = 0; - bundle->orphans = NULL; + bundle->orphans = nullptr; /* Leave open for insertions. */ bundle->is_readonly = FALSE; @@ -753,12 +753,12 @@ static sc_prop_setref_t prop_create_empty() { * ensuring that every set has at least one node and one allocated pool. */ bundle->root_node = prop_new_node(bundle); - bundle->root_node->child_list = NULL; + bundle->root_node->child_list = nullptr; bundle->root_node->name.string = "ROOT"; - bundle->root_node->property.voidp = NULL; + bundle->root_node->property.voidp = nullptr; /* No taf is yet connected with this set. */ - bundle->taf = NULL; + bundle->taf = nullptr; return bundle; } @@ -793,25 +793,25 @@ void prop_destroy(sc_prop_setref_t bundle) { sc_free(bundle->dictionary[index_]); bundle->dictionary_length = 0; sc_free(bundle->dictionary); - bundle->dictionary = NULL; + bundle->dictionary = nullptr; /* Free adopted addresses. */ for (index_ = 0; index_ < bundle->orphans_length; index_++) sc_free(bundle->orphans[index_]); bundle->orphans_length = 0; sc_free(bundle->orphans); - bundle->orphans = NULL; + bundle->orphans = nullptr; /* Walk the tree, destroying the child list for each node found. */ prop_destroy_child_list(bundle->root_node); - bundle->root_node = NULL; + bundle->root_node = nullptr; /* Destroy each node pool. */ for (index_ = 0; index_ < bundle->node_pools_length; index_++) sc_free(bundle->node_pools[index_]); bundle->node_pools_length = 0; sc_free(bundle->node_pools); - bundle->node_pools = NULL; + bundle->node_pools = nullptr; /* Destroy any taf associated with the bundle. */ if (bundle->taf) @@ -837,7 +837,7 @@ sc_prop_setref_t prop_create(const sc_tafref_t taf) { /* Populate it with data parsed from the taf file. */ if (!parse_game(taf, bundle)) { prop_destroy(bundle); - return NULL; + return nullptr; } /* Note the taf for destruction later, and return the new set. */ diff --git a/engines/glk/adrift/screstrs.cpp b/engines/glk/adrift/screstrs.cpp index 77b21101e7a..2c250912291 100644 --- a/engines/glk/adrift/screstrs.cpp +++ b/engines/glk/adrift/screstrs.cpp @@ -693,7 +693,7 @@ enum { }; /* #O#A(#O#)-style expression, for tokenizing. */ -static const sc_char *restr_expression = NULL; +static const sc_char *restr_expression = nullptr; static sc_int restr_index = 0; /* @@ -709,7 +709,7 @@ static void restr_tokenize_start(const sc_char *expression) { } static void restr_tokenize_end(void) { - restr_expression = NULL; + restr_expression = nullptr; restr_index = 0; } @@ -750,7 +750,7 @@ static sc_int restr_eval_stack = 0; static sc_int restr_eval_restriction = 0; /* The current game used to evaluate restrictions, and the task in question. */ -static sc_gameref_t restr_eval_game = NULL; +static sc_gameref_t restr_eval_game = nullptr; static sc_int restr_eval_task = 0; /* The id of the lowest-indexed failing restriction. */ @@ -953,7 +953,7 @@ static const sc_char *restr_get_fail_message(sc_gameref_t game, sc_int task, sc_ message = prop_get_string(bundle, "S<-sisis", vt_key); /* Return it, or NULL if empty. */ - return !sc_strempty(message) ? message : NULL; + return !sc_strempty(message) ? message : nullptr; } @@ -999,7 +999,7 @@ sc_bool restr_eval_task_restrictions(sc_gameref_t game, sc_int task, sc_bool *pa sc_trace("Restr: task %ld has no restrictions\n", task); *pass = TRUE; - *fail_message = NULL; + *fail_message = nullptr; return TRUE; } @@ -1045,7 +1045,7 @@ sc_bool restr_eval_task_restrictions(sc_gameref_t game, sc_int task, sc_bool *pa */ *pass = result; if (result) - *fail_message = NULL; + *fail_message = nullptr; else *fail_message = restr_get_fail_message(game, task, lowest_fail); return TRUE; diff --git a/engines/glk/adrift/scrunner.cpp b/engines/glk/adrift/scrunner.cpp index dbf160f3503..57ec5b0fc9f 100644 --- a/engines/glk/adrift/scrunner.cpp +++ b/engines/glk/adrift/scrunner.cpp @@ -124,7 +124,7 @@ static sc_commands_t MOVE_COMMANDS_4[] = { {"{go {to {the}}} [down/d]", lib_cmd_go_down}, {"{go {to {the}}} [in]", lib_cmd_go_in}, {"{go {to {the}}} [out/o]", lib_cmd_go_out}, - {NULL, NULL} + {nullptr, nullptr} }; /* Movement commands for the eight point compass. */ @@ -141,7 +141,7 @@ static sc_commands_t MOVE_COMMANDS_8[] = { {"{go {to {the}}} [southeast/south-east/se]", lib_cmd_go_southeast}, {"{go {to {the}}} [northwest/north-west/nw]", lib_cmd_go_northwest}, {"{go {to {the}}} [southwest/south-west/sw]", lib_cmd_go_southwest}, - {NULL, NULL} + {nullptr, nullptr} }; /* "Priority" library commands, may take precedence over the game. */ @@ -198,7 +198,7 @@ static sc_commands_t PRIORITY_COMMANDS[] = { }, {"[drop/put down] %text%", lib_cmd_drop_multiple}, {"put %text% down", lib_cmd_drop_multiple}, - {NULL, NULL} + {nullptr, nullptr} }; /* Standard library commands, other than movement and priority above. */ @@ -466,7 +466,7 @@ static sc_commands_t STANDARD_COMMANDS[] = { /* SCARE debugger hook command, placed last just in case... */ {"{#}debug{ger}", debug_cmd_debugger}, - {NULL, NULL} + {nullptr, nullptr} }; @@ -571,7 +571,7 @@ static void run_update_status(sc_gameref_t game) { pf_strip_tags(filtered); } else /* No status line, so use NULL. */ - filtered = NULL; + filtered = nullptr; /* Free any existing status line, then save this status text. */ sc_free(game->status_line); @@ -739,7 +739,7 @@ static sc_bool run_task_is_loudly_restricted(sc_gameref_t game, sc_int task) { } /* Return TRUE if the task is restricted and indicates why. */ - return !restrictions_passed && (fail_message != NULL); + return !restrictions_passed && (fail_message != nullptr); } @@ -793,7 +793,7 @@ static sc_bool run_game_commands_common(sc_gameref_t game, const sc_char *string is_matching = (sc_bool *)sc_malloc(task_count * sizeof(*is_matching)); memset(is_matching, FALSE, task_count * sizeof(*is_matching)); } else - is_matching = NULL; + is_matching = nullptr; /* * Iterate over every task, ignoring those not runnable. For each runnable @@ -1078,7 +1078,7 @@ static sc_bool run_player_input(sc_gameref_t game) { */ length = (line_buffer[0] == NUL) ? 0 : 1; while (line_buffer[length] != NUL - && strchr(SEPARATORS, line_buffer[length]) == NULL) + && strchr(SEPARATORS, line_buffer[length]) == nullptr) length++; /* @@ -1092,7 +1092,7 @@ static sc_bool run_player_input(sc_gameref_t game) { extent = length; extent += (line_buffer[length] == NUL - || strchr(SEPARATORS, line_buffer[length]) == NULL) ? 0 : 1; + || strchr(SEPARATORS, line_buffer[length]) == nullptr) ? 0 : 1; extent += strspn(line_buffer + extent, WHITESPACE); memmove(line_buffer, line_buffer + extent, strlen(line_buffer) - extent + 1); @@ -1429,7 +1429,7 @@ sc_gameref_t run_create(sc_read_callbackref_t callback, void *opaque) { /* Create a new TAF using the callback; return NULL if this fails. */ taf = taf_create(callback, opaque); if (!taf) - return NULL; + return nullptr; else if (if_get_trace_flag(SC_DUMP_TAF)) taf_debug_dump(taf); @@ -1438,7 +1438,7 @@ sc_gameref_t run_create(sc_read_callbackref_t callback, void *opaque) { if (!bundle) { sc_error("run_create: error parsing game data\n"); taf_destroy(taf); - return NULL; + return nullptr; } else if (if_get_trace_flag(SC_DUMP_PROPERTIES)) prop_debug_dump(bundle); @@ -1507,9 +1507,9 @@ static void run_restart_handler(sc_gameref_t game) { /* Destroy invalid game status strings. */ sc_free(game->current_room_name); - game->current_room_name = NULL; + game->current_room_name = nullptr; sc_free(game->status_line); - game->status_line = NULL; + game->status_line = nullptr; /* * Now it's safely copied, destroy the temporary new game, and its @@ -1793,7 +1793,7 @@ sc_bool run_restore(CONTEXT, sc_gameref_t game, sc_read_callbackref_t callback, sc_bool run_restore_prompted(CONTEXT, sc_gameref_t game) { assert(gs_is_game_valid(game)); - return run_restore_common(context, game, NULL, NULL); + return run_restore_common(context, game, nullptr, nullptr); } @@ -1955,7 +1955,7 @@ void run_get_attributes(sc_gameref_t game, const sc_char **game_name, const sc_c vt_key[0].string = "FontNameSize"; *preferred_font = prop_get_string(bundle, "S<-s", vt_key); } else - *preferred_font = NULL; + *preferred_font = nullptr; } /* Return any other selected game attributes. */ @@ -2011,7 +2011,7 @@ sc_hintref_t run_hint_iterate(sc_gameref_t game, sc_hintref_t hint) { task = hint - game->tasks; if (task < 0 || task >= gs_task_count(game)) { sc_error("run_hint_iterate: invalid iteration hint\n"); - return NULL; + return nullptr; } /* Advance beyond current task. */ @@ -2025,7 +2025,7 @@ sc_hintref_t run_hint_iterate(sc_gameref_t game, sc_hintref_t hint) { } /* Return a pointer to the state of the task identified, or NULL. */ - return task < gs_task_count(game) ? game->tasks + task : NULL; + return task < gs_task_count(game) ? game->tasks + task : nullptr; } @@ -2054,10 +2054,10 @@ static const sc_char *run_get_hint_common(sc_gameref_t game, sc_hintref_t hint, task = hint - game->tasks; if (task < 0 || task >= gs_task_count(game)) { sc_error("run_get_hint_common: invalid iteration hint\n"); - return NULL; + return nullptr; } else if (!task_has_hints(game, task)) { sc_error("run_get_hint_common: task has no hint\n"); - return NULL; + return nullptr; } /* Get the required game text by calling the given handler function. */ @@ -2073,7 +2073,7 @@ static const sc_char *run_get_hint_common(sc_gameref_t game, sc_hintref_t hint, } else { /* Hint text is empty; drop any text noted in game. */ sc_free(game->hint_text); - game->hint_text = NULL; + game->hint_text = nullptr; } return game->hint_text; diff --git a/engines/glk/adrift/sctaffil.cpp b/engines/glk/adrift/sctaffil.cpp index 2365c1a093e..555da4e979a 100644 --- a/engines/glk/adrift/sctaffil.cpp +++ b/engines/glk/adrift/sctaffil.cpp @@ -134,7 +134,7 @@ static sc_tafref_t taf_create_empty(void) { memset(taf->header, 0, sizeof(taf->header)); taf->version = TAF_VERSION_NONE; taf->total_in_bytes = 0; - taf->slabs = NULL; + taf->slabs = nullptr; taf->slab_count = 0; taf->slabs_allocated = 0; taf->is_unterminated = FALSE; @@ -476,7 +476,7 @@ static sc_tafref_t taf_create_from_callback(sc_read_callbackref_t callback, if (in_bytes != VERSION_HEADER_SIZE) { sc_error("taf_create: not enough data for standard TAF header\n"); taf_destroy(taf); - return NULL; + return nullptr; } /* Handle different TAF versions */ @@ -495,14 +495,14 @@ static sc_tafref_t taf_create_from_callback(sc_read_callbackref_t callback, sc_error("taf_create:" " not enough data for extended TAF header\n"); taf_destroy(taf); - return NULL; + return nullptr; } taf->version = TAF_VERSION_400; } else { taf_destroy(taf); - return NULL; + return nullptr; } } else { /* Saved games are always considered to be for ScummVM, version 5.0. */ @@ -537,7 +537,7 @@ static sc_tafref_t taf_create_from_callback(sc_read_callbackref_t callback, } if (!status) { taf_destroy(taf); - return NULL; + return nullptr; } /* Return successfully. */ @@ -606,7 +606,7 @@ const sc_char *taf_next_line(sc_tafref_t taf) { } /* No more lines, so return NULL. */ - return NULL; + return nullptr; } diff --git a/engines/glk/adrift/sctafpar.cpp b/engines/glk/adrift/sctafpar.cpp index 046cb24d339..a132fc3465a 100644 --- a/engines/glk/adrift/sctafpar.cpp +++ b/engines/glk/adrift/sctafpar.cpp @@ -213,7 +213,7 @@ static const sc_parse_schema_t V400_PARSE_SCHEMA[] = { "ALR", "$Original $Replacement" }, - {NULL, NULL} + {nullptr, nullptr} }; /* Version 3.9 TAF file properties descriptor table. */ @@ -347,7 +347,7 @@ static const sc_parse_schema_t V390_PARSE_SCHEMA[] = { "ALR", "$Original $Replacement" }, - {NULL, NULL} + {nullptr, nullptr} }; /* Version 3.8 TAF file properties descriptor table. */ @@ -447,7 +447,7 @@ static const sc_parse_schema_t V380_PARSE_SCHEMA[] = { "SYNONYM", "$Replacement $Original" }, - {NULL, NULL} + {nullptr, nullptr} }; @@ -467,20 +467,20 @@ static const sc_parse_schema_t *parse_select_schema(sc_tafref_t taf) { return V380_PARSE_SCHEMA; default: sc_fatal("parse_select_schema: invalid TAF file version\n"); - return NULL; + return nullptr; } } /* The uncompressed TAF file from which we get all our data. */ -static sc_tafref_t parse_taf = NULL; +static sc_tafref_t parse_taf = nullptr; static sc_int parse_tafline = 0; /* The parse schema selected for this TAF file. */ -static sc_parse_schema_t const *parse_schema = NULL; +static sc_parse_schema_t const *parse_schema = nullptr; /* Properties bundle and trace flag, set before parsing. */ -static sc_prop_setref_t parse_bundle = NULL; +static sc_prop_setref_t parse_bundle = nullptr; static sc_bool parse_trace = FALSE; /* @@ -687,7 +687,7 @@ static const sc_char *parse_get_string_property(void) { /* Pushback line, and pushback requested flag. */ -static const sc_char *parse_pushback_line = NULL; +static const sc_char *parse_pushback_line = nullptr; static sc_bool parse_use_pushback = FALSE; /* @@ -1012,7 +1012,7 @@ static void parse_expression(CONTEXT, const sc_char *expression) { * string is malloc'ed, and the caller needs to handle that. */ static sc_char *parse_read_multiline(CONTEXT) { - const sc_byte *separator = NULL; + const sc_byte *separator = nullptr; const sc_char *line; sc_char *multiline; @@ -1142,7 +1142,7 @@ struct sc_parse_resource_t { enum { RESOURCE_GROW_INCREMENT = 32 }; static sc_int parse_resources_length = 0; static sc_int parse_resources_size = 0; -static sc_parse_resource_t *parse_resources = NULL; +static sc_parse_resource_t *parse_resources = nullptr; /* @@ -1159,7 +1159,7 @@ static void parse_clear_v400_resources_table(void) { sc_free(parse_resources[index_].name); sc_free(parse_resources); - parse_resources = NULL; + parse_resources = nullptr; } parse_resources_length = 0; parse_resources_size = 0; @@ -1835,7 +1835,7 @@ static void parse_fixup_v390_v380_room_alts(void) { hide_objects = typehideobjects % V390_V380_ALT_TYPEHIDE_MULT; parse_fixup_v390_v380_room_alt(m1, type, "AltRes", - m2, var2, NULL, + m2, var2, nullptr, hide_objects, changed, var3, display_room); } @@ -1862,7 +1862,7 @@ static void parse_fixup_v390_v380_room_alts(void) { hide_objects = 0; parse_fixup_v390_v380_room_alt(m1, type, "Task2Res", - m2, var2, NULL, + m2, var2, nullptr, hide_objects, changed, var3, display_room); } @@ -1886,7 +1886,7 @@ static void parse_fixup_v390_v380_room_alts(void) { hide_objects = 0; parse_fixup_v390_v380_room_alt(m1, type, "Task1Res", - m2, var2, NULL, + m2, var2, nullptr, hide_objects, changed, var3, display_room); } @@ -1909,7 +1909,7 @@ static void parse_fixup_v390_v380_room_alts(void) { hide_objects = 0; parse_fixup_v390_v380_room_alt(m1, type, "LastRes", - m2, var2, NULL, + m2, var2, nullptr, hide_objects, changed, var3, display_room); } @@ -3370,9 +3370,9 @@ sc_bool parse_game(sc_tafref_t taf, sc_prop_setref_t bundle) { if (context._break) { // Error with one of the TAF file lines parse_clear_v400_resources_table(); - parse_taf = NULL; - parse_bundle = NULL; - parse_schema = NULL; + parse_taf = nullptr; + parse_bundle = nullptr; + parse_schema = nullptr; parse_depth = 0; return FALSE; } @@ -3399,9 +3399,9 @@ sc_bool parse_game(sc_tafref_t taf, sc_prop_setref_t bundle) { prop_solidify(parse_bundle); /* Return successfully. */ - parse_taf = NULL; - parse_bundle = NULL; - parse_schema = NULL; + parse_taf = nullptr; + parse_bundle = nullptr; + parse_schema = nullptr; parse_depth = 0; return TRUE; } diff --git a/engines/glk/adrift/scutils.cpp b/engines/glk/adrift/scutils.cpp index d1dc5141e9c..d50257992c4 100644 --- a/engines/glk/adrift/scutils.cpp +++ b/engines/glk/adrift/scutils.cpp @@ -118,7 +118,7 @@ void *sc_realloc(void *pointer, size_t size) { } if (pointer == sc_zero_allocation) - pointer = NULL; + pointer = nullptr; allocated = realloc(pointer, size); if (!allocated) diff --git a/engines/glk/adrift/sxfile.cpp b/engines/glk/adrift/sxfile.cpp index 992b93bb539..7ed749eda65 100644 --- a/engines/glk/adrift/sxfile.cpp +++ b/engines/glk/adrift/sxfile.cpp @@ -38,7 +38,7 @@ struct sx_scr_stream_t { sc_bool is_open; sc_bool is_writable; }; -static sx_scr_stream_t scr_serialization_stream = {NULL, 0, FALSE, FALSE}; +static sx_scr_stream_t scr_serialization_stream = {nullptr, 0, FALSE, FALSE}; /* @@ -59,11 +59,11 @@ void *file_open_file_callback(sc_bool is_save) { if (stream->is_open) { error("File open error: %s", "stream is in use (script limitation)"); - return NULL; + return nullptr; } else if (is_save && stream->data) { error("File open error: %s", "stream has not been read (script limitation)"); - return NULL; + return nullptr; } /* @@ -71,10 +71,10 @@ void *file_open_file_callback(sc_bool is_save) { * no data available for a read-only open. */ if (is_save) { - stream->data = NULL; + stream->data = nullptr; stream->length = 0; } else if (!stream->data) - return NULL; + return nullptr; stream->is_open = TRUE; stream->is_writable = is_save; @@ -147,7 +147,7 @@ void file_close_file_callback(void *opaque) { */ if (!stream->is_writable) { sx_free(stream->data); - stream->data = NULL; + stream->data = nullptr; stream->length = 0; } stream->is_writable = FALSE; @@ -164,7 +164,7 @@ void file_cleanup(void) { sx_scr_stream_t *const stream = &scr_serialization_stream; sx_free(stream->data); - stream->data = NULL; + stream->data = nullptr; stream->length = 0; stream->is_writable = FALSE; stream->is_open = FALSE; diff --git a/engines/glk/adrift/sxglob.cpp b/engines/glk/adrift/sxglob.cpp index f57eed7df23..3b7d0d00209 100644 --- a/engines/glk/adrift/sxglob.cpp +++ b/engines/glk/adrift/sxglob.cpp @@ -187,7 +187,7 @@ static const sx_test_data_t SHOULD_MATCH[] = { {"???]", "abc]"}, {"[z-a]", "z"}, {"[a-z", "a"}, {"[a-", "a"}, {"[a", "a"}, {"[[", "["}, - {NULL, NULL} + {nullptr, nullptr} }; static const sx_test_data_t SHOULD_NOT_MATCH[] = { @@ -213,7 +213,7 @@ static const sx_test_data_t SHOULD_NOT_MATCH[] = { {"*[a-z]*abc?xyz", "AabcQxyz"}, {"*[a-z]*abc?xyz", "aabcxyz"}, {"[z-a]", "a"}, {"[z-a]", "b"}, {"[", "a"}, {"[[", "a"}, - {NULL, NULL} + {nullptr, nullptr} }; diff --git a/engines/glk/adrift/sxstubs.cpp b/engines/glk/adrift/sxstubs.cpp index c1432e71c42..0265022824f 100644 --- a/engines/glk/adrift/sxstubs.cpp +++ b/engines/glk/adrift/sxstubs.cpp @@ -41,12 +41,12 @@ static sc_bool stub_trace = FALSE; * Input/output handler functions. If assigned, calls to os_* functions are * routed here to allow the script runner to catch interpeter i/o. */ -static sc_bool(*stub_read_line)(sc_char *, sc_int) = NULL; -static void (*stub_print_string)(const sc_char *) = NULL; -static void *(*stub_open_file)(sc_bool) = NULL; -static sc_int(*stub_read_file)(void *, sc_byte *, sc_int) = NULL; -static void (*stub_write_file)(void *, const sc_byte *, sc_int) = NULL; -static void (*stub_close_file)(void *) = NULL; +static sc_bool(*stub_read_line)(sc_char *, sc_int) = nullptr; +static void (*stub_print_string)(const sc_char *) = nullptr; +static void *(*stub_open_file)(sc_bool) = nullptr; +static sc_int(*stub_read_file)(void *, sc_byte *, sc_int) = nullptr; +static void (*stub_write_file)(void *, const sc_byte *, sc_int) = nullptr; +static void (*stub_close_file)(void *) = nullptr; /* Flags for whether to report tags and resources via stub_print_string(). */ static sc_int stub_show_resources = 0; @@ -79,12 +79,12 @@ stub_attach_handlers(sc_bool(*read_line)(sc_char *, sc_int), void stub_detach_handlers(void) { - stub_read_line = NULL; - stub_print_string = NULL; - stub_open_file = NULL; - stub_read_file = NULL; - stub_write_file = NULL; - stub_close_file = NULL; + stub_read_line = nullptr; + stub_print_string = nullptr; + stub_open_file = nullptr; + stub_read_file = nullptr; + stub_write_file = nullptr; + stub_close_file = nullptr; stub_show_resources = 0; stub_show_tags = 0; @@ -282,7 +282,7 @@ os_open_file(sc_bool is_save) { if (stub_open_file) opaque = stub_open_file(is_save); else - opaque = NULL; + opaque = nullptr; if (stub_trace) { if (opaque) diff --git a/engines/glk/adrift/sxutils.cpp b/engines/glk/adrift/sxutils.cpp index e4b3519ebf7..9e0ba0d218b 100644 --- a/engines/glk/adrift/sxutils.cpp +++ b/engines/glk/adrift/sxutils.cpp @@ -114,7 +114,7 @@ void *sx_realloc(void *pointer, size_t size) { } if (pointer == sx_zero_allocation) - pointer = NULL; + pointer = nullptr; allocated = realloc(pointer, size); if (!allocated) @@ -168,7 +168,7 @@ static const sc_char NUL = '\0'; static sc_bool sx_isspace(sc_char character) { static const sc_char *const WHITESPACE = "\t\n\v\f\r "; - return character != NUL && strchr(WHITESPACE, character) != NULL; + return character != NUL && strchr(WHITESPACE, character) != nullptr; } static sc_bool sx_isprint(sc_char character) { diff --git a/engines/glk/advsys/glk_interface.cpp b/engines/glk/advsys/glk_interface.cpp index badfbefdb3d..b42ce722c6a 100644 --- a/engines/glk/advsys/glk_interface.cpp +++ b/engines/glk/advsys/glk_interface.cpp @@ -26,7 +26,7 @@ namespace Glk { namespace AdvSys { bool GlkInterface::initialize() { - _window = glk_window_open(0, 0, 0, wintype_TextBuffer, 1); + _window = glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 1); return _window != nullptr; } diff --git a/engines/glk/agt/agil.cpp b/engines/glk/agt/agil.cpp index 908b50de90a..185e6600df0 100644 --- a/engines/glk/agt/agil.cpp +++ b/engines/glk/agt/agil.cpp @@ -163,11 +163,11 @@ static void print_title(fc_type fc) { else buff = read_ttl(fc); - if (buff == NULL) { + if (buff == nullptr) { writeln(""); writeln(""); s = formal_name(fc, fNONE); - if (s != NULL) { + if (s != nullptr) { s[0] = toupper(s[0]); agt_center(1); agt_textcolor(-1); @@ -186,7 +186,7 @@ static void print_title(fc_type fc) { writeln(""); height = 0; } else { - if (buff[0] != NULL && strncasecmp(buff[0], "COLORS", 6) == 0) { + if (buff[0] != nullptr && strncasecmp(buff[0], "COLORS", 6) == 0) { /* Do screen colors */ skip_line = 1; } else skip_line = 0; @@ -194,7 +194,7 @@ static void print_title(fc_type fc) { starting with spaces. We use height as a loop variable and center_mode to store the count temporarily. */ center_mode = 0; - for (height = skip_line; buff[height] != NULL; height++) + for (height = skip_line; buff[height] != nullptr; height++) if (!emptyline((uchar *)buff[height])) { if (rspace(buff[height][0])) center_mode++; else center_mode--; @@ -220,7 +220,7 @@ static void print_title(fc_type fc) { agt_textcolor(7); agt_center(1); - if (buff != NULL) { + if (buff != nullptr) { if (aver < AGX00 && height <= screen_height - 6) writeln("[Created with Malmberg and Welch's Adventure Game Toolkit]"); if (height <= screen_height - 9) writeln(""); @@ -255,7 +255,7 @@ void print_instructions(fc_type fc) { writeln("INSTRUCTIONS:"); if (open_ins_file(fc, 1)) { /* Instruction file exists */ - while (NULL != (buffer = read_ins_line())) { + while (nullptr != (buffer = read_ins_line())) { for (s = (uchar *)buffer; *s != 0; s++) *s = trans_ascii[*s]; writeln(buffer); } @@ -443,9 +443,9 @@ static void game_end(void) { writeln(""); agt_center(1); if (winflag) - gen_sysmsg(148, "***** $You$ have won! *****", MSG_MAIN, NULL); + gen_sysmsg(148, "***** $You$ have won! *****", MSG_MAIN, nullptr); if (deadflag) - gen_sysmsg(147, "***** $You$ have died! *****", MSG_MAIN, NULL); + gen_sysmsg(147, "***** $You$ have died! *****", MSG_MAIN, nullptr); writeln(""); writeln(""); agt_center(0); @@ -454,16 +454,16 @@ static void game_end(void) { if (curr_lives > 1) { /* Resurrection code */ if (curr_lives == max_lives) gen_sysmsg(151, "Hmmm.... so $you$'ve gotten $your$self killed. " - "Would you like me to try a resurrection?", MSG_MAIN, NULL); + "Would you like me to try a resurrection?", MSG_MAIN, nullptr); else gen_sysmsg(152, " $You$'ve died *again*. " "Would you like me to try another resurrection?", - MSG_MAIN, NULL); + MSG_MAIN, nullptr); if (yesno("? ")) { /* Now do resurrection */ curr_lives--; quitflag = deadflag = 0; gen_sysmsg(154, "$You$ emerge coughing from a cloud of dark green smoke.", - MSG_MAIN, NULL); + MSG_MAIN, nullptr); writeln(""); loc = resurrect_room - first_room; newlife_flag = 1; @@ -473,7 +473,7 @@ static void game_end(void) { return; } else writeln("As you wish..."); } else if (max_lives > 1) - gen_sysmsg(153, "$You$'ve used up all of $your$ lives.", MSG_MAIN, NULL); + gen_sysmsg(153, "$You$'ve used up all of $your$ lives.", MSG_MAIN, nullptr); } writeln(""); print_score(); @@ -481,15 +481,15 @@ static void game_end(void) { done_flag = quitflag; /* If player has QUIT, don't ask again */ while (!done_flag && !quitflag) { writestr("Would you like to "); - if (restart_state != NULL) writestr("restart, "); + if (restart_state != nullptr) writestr("restart, "); writestr("restore"); - if (undo_state != NULL && can_undo) + if (undo_state != nullptr && can_undo) writestr(", undo,"); - else if (restart_state != NULL) writestr(","); + else if (restart_state != nullptr) writestr(","); writestr(" or quit? "); s = agt_readline(5); if (strncasecmp(s, "RESTART", 7) == 0) - if (restart_state != NULL) { + if (restart_state != nullptr) { restart_game(); done_flag = 1; } else writeln("Sorry, I'm unable to do that because of limited memory."); @@ -498,7 +498,7 @@ static void game_end(void) { done_flag = 1; } else writeln("(RESTORE failed)"); else if (strncasecmp(s, "UNDO", 4) == 0) - if (can_undo && undo_state != NULL) { + if (can_undo && undo_state != nullptr) { putstate(undo_state); done_flag = 1; } else writeln("Insufficiant memory to support UNDO"); @@ -606,7 +606,7 @@ static int init(void) { agt_var[i] = 0; for (i = 0; i <= maxnoun - first_noun; i++) { - if (noun[i].position == NULL || noun[i].position[0] == '\0') + if (noun[i].position == nullptr || noun[i].position[0] == '\0') noun[i].pos_prep = 0; else noun[i].pos_prep = -1; noun[i].pos_name = 0; @@ -633,17 +633,17 @@ static int init(void) { game states */ tmp1 = (uchar *)rmalloc(MEM_MARGIN); /* Preserve some work space */ - tmp2 = getstate(NULL); /* Make sure we have space to save */ - if (tmp2 == NULL) can_save = 0; + tmp2 = getstate(nullptr); /* Make sure we have space to save */ + if (tmp2 == nullptr) can_save = 0; else can_save = 1; - if (tmp2 != NULL) - undo_state = getstate(NULL); - else undo_state = NULL; + if (tmp2 != nullptr) + undo_state = getstate(nullptr); + else undo_state = nullptr; - if (undo_state != NULL) - restart_state = getstate(NULL); - else restart_state = NULL; + if (undo_state != nullptr) + restart_state = getstate(nullptr); + else restart_state = nullptr; rfree(tmp1); rfree(tmp2); @@ -691,7 +691,7 @@ static void fix_dummy(void) { else { PURE_DOT = FORCE_PURE_DOT; for (i = 0; i < dp && !PURE_DOT; i++) - if (strchr(dict[i], '.') != NULL && /* i.e. dict[i] contains period */ + if (strchr(dict[i], '.') != nullptr && /* i.e. dict[i] contains period */ i != ext_code[wp]) /* The period itself _is_ a dictionary word: avoid this false match */ PURE_DOT = 1; @@ -703,9 +703,9 @@ static void fix_dummy(void) { static void fix_prompt(void) { descr_line *d; - if (err_ptr == NULL) return; + if (err_ptr == nullptr) return; d = read_descr(err_ptr[0].start, err_ptr[0].size); - if (d == NULL) return; + if (d == nullptr) return; if (strncasecmp(d[0], "What Now?", 9) == 0) err_ptr[0].size = err_ptr[0].start = 0; free_descr(d); @@ -750,7 +750,7 @@ static fc_type setup_game(fc_type fc) /* Now that we *have* PATH information, go looking for the games */ /* At the very least, it creates an rmalloc'd copy of game_name */ - read_config(openfile(fc, fCFG, NULL, 0), 0); + read_config(openfile(fc, fCFG, nullptr, 0), 0); text_file = 0; /* First pass through game specific config file */ build_trans_ascii(); @@ -768,7 +768,7 @@ static fc_type setup_game(fc_type fc) menu_mode = opt_data[5]; /* See agtread.c for discussion of OPT file format */ text_file = 1; - read_config(openfile(fc, fCFG, NULL, 0), 1); /*Game specific config file*/ + read_config(openfile(fc, fCFG, nullptr, 0), 1); /*Game specific config file*/ text_file = 0; if (min_ver > AGIL_VERID) { if (FORCE_VERSION) @@ -825,7 +825,7 @@ static fc_type setup_game(fc_type fc) set_statline(); if (can_save == 0) { writeln("[Insufficiant memory to support SAVE, RESTORE, or UNDO]"); - } else if (undo_state == NULL) + } else if (undo_state == nullptr) writeln("[Insufficiant memory to support UNDO]"); do_look = do_autoverb = 1; newroom(); diff --git a/engines/glk/agt/agtread.cpp b/engines/glk/agt/agtread.cpp index e10ca680d47..bc17bba888a 100644 --- a/engines/glk/agt/agtread.cpp +++ b/engines/glk/agt/agtread.cpp @@ -145,7 +145,7 @@ void open_descr(fc_type fc) { tline buff; fd_desc = readopen(fc, fDSS, &errstr); - if (errstr != NULL) fatal(errstr); + if (errstr != nullptr) fatal(errstr); desc_size = binsize(fd_desc); if (DIAG) { char *s; @@ -187,7 +187,7 @@ void open_descr(fc_type fc) { else rprintf(" [plaintext: %d/%d]\n", alpha, cnt); } - mem_descr = NULL; + mem_descr = nullptr; if (desc_size <= descr_maxmem) { /* This is where we need to read the data in and convert it: encrypted Pascal strings --> plaintext C strings */ @@ -195,7 +195,7 @@ void open_descr(fc_type fc) { mem_descr = (char *)rmalloc(desc_size); /* Read in the whole file */ binread(fd_desc, mem_descr, desc_size, 1, &errstr); - if (errstr != NULL) fatal(errstr); + if (errstr != nullptr) fatal(errstr); for (i = 0; i < desc_size; i += sizeof(tline)) convert_agt_descr((uchar *)(mem_descr + i)); /* Decode and convert to C string */ @@ -204,11 +204,11 @@ void open_descr(fc_type fc) { void close_descr(void) { - if (mem_descr != NULL) + if (mem_descr != nullptr) rfree(mem_descr); else { readclose(fd_desc); - fd_desc = NULL; + fd_desc = nullptr; } } @@ -219,10 +219,10 @@ descr_line *agt_read_descr(long start, long len) { long i; const char *errstr; - if (len == -1 || start == -1) return NULL; + if (len == -1 || start == -1) return nullptr; lines = (descr_line *)rmalloc(sizeof(descr_line) * (len + 1)); - if (mem_descr != NULL) { + if (mem_descr != nullptr) { d = ((tline *)mem_descr) + start; for (i = 0; i < len; i++) lines[i] = (char *)(d + i); @@ -230,13 +230,13 @@ descr_line *agt_read_descr(long start, long len) { d = (tline *)rmalloc(sizeof(tline) * len); binseek(fd_desc, start * sizeof(tline)); binread(fd_desc, d, sizeof(tline), len, &errstr); - if (errstr != NULL) fatal(errstr); + if (errstr != nullptr) fatal(errstr); for (i = 0; i < len; i++) { lines[i] = (char *)(d + i); convert_agt_descr((uchar *)(d + i)); } } - lines[len] = NULL; /* Mark end of array */ + lines[len] = nullptr; /* Mark end of array */ return lines; } @@ -295,7 +295,7 @@ static void read_da2(fc_type fc) { setb(seen); seti(key); setb(locked_door); - if (room_inside != NULL) + if (room_inside != nullptr) room_inside[i] = fixsign16(buff[bp], buff[bp + 1]); bp += 2; /* Skip # of nouns in this room */ @@ -403,7 +403,7 @@ static void read_da3(fc_type fc) { setb(shootable); seti(num_shots); seti(points); - if (noun_inside != NULL) + if (noun_inside != nullptr) noun_inside[i] = fixsign16(buff[bp], buff[bp + 1]); bp += 2; /* Skip # of nouns contained in this one */ setb(win); @@ -466,7 +466,7 @@ static void read_da4(fc_type fc) { seti(weapon); setb(hostile); seti(points); - if (creat_inside != NULL) + if (creat_inside != nullptr) creat_inside[i] = fixsign16(buff[bp], buff[bp + 1]); bp += 2; /* Skip # of nouns the creature is carrying */ seti(counter); @@ -567,7 +567,7 @@ static void read_da5(fc_type fc) { buffopen(fc, fDA5, CREC_SIZE, "command", last_cmd); if (aver >= AGT15F) cmd_ptr = (long *)rmalloc(sizeof(long) * last_cmd); - else cmd_ptr = NULL; + else cmd_ptr = nullptr; bp = 0; for (i = 0; i < last_cmd; i++) { @@ -686,7 +686,7 @@ static void read_da6(fc_type fc) command[i].data[ip] = fixsign16(cbuf[bp * 2L], cbuf[bp * 2L + 1]); } } else { - command[i].data = NULL; + command[i].data = nullptr; command[i].cmdsize = 0; } rfree(cbuf); @@ -880,7 +880,7 @@ static void read_line(genfile fd, const char *typestr) } else chop_newline(linebuffer); linenum++; } - if (debug_da1 && typestr != NULL) { + if (debug_da1 && typestr != nullptr) { rprintf("%s %4d:%s", typestr, linenum, linebuffer); if (bhold) rprintf(" *"); writeln(""); @@ -894,7 +894,7 @@ static void report(const char *s, genfile fd) { } static int isbool(genfile fd) { - read_line(fd, NULL); + read_line(fd, nullptr); bhold = 1; return (strncasecmp(linebuffer, "TRUE", 4) == 0 || strncasecmp(linebuffer, "FALSE", 5) == 0); @@ -903,7 +903,7 @@ static int isbool(genfile fd) { static int isnum(genfile fd) { char *errstr; - read_line(fd, NULL); + read_line(fd, nullptr); bhold = 1; (void)strtol(linebuffer, &errstr, 10); while (*errstr == '\n' || *errstr == '\r') errstr++; @@ -920,15 +920,15 @@ static rbool readrbool(genfile fd) { static long readnum(genfile fd) { read_line(fd, "NUM "); - return strtol(linebuffer, NULL, 10); + return strtol(linebuffer, nullptr, 10); } static void readptr(genfile fd, descr_ptr *desc) { read_line(fd, "PTR "); - desc->start = strtol(linebuffer, NULL, 10); + desc->start = strtol(linebuffer, nullptr, 10); read_line(fd, "LEN"); - desc->size = strtol(linebuffer, NULL, 10); + desc->size = strtol(linebuffer, nullptr, 10); } @@ -1107,16 +1107,16 @@ noun inside information; this is used by agtout */ num_rflags = num_nflags = num_cflags = 0; num_rprops = num_nprops = num_cprops = 0; - objflag = NULL; - objprop = NULL; - attrtable = NULL; - proptable = NULL; + objflag = nullptr; + objprop = nullptr; + attrtable = nullptr; + proptable = nullptr; oflag_cnt = 0; oprop_cnt = 0; - propstr = NULL; + propstr = nullptr; propstr_size = 0; - vartable = NULL; - flagtable = NULL; + vartable = nullptr; + flagtable = nullptr; @@ -1126,9 +1126,9 @@ noun inside information; this is used by agtout */ should be allocated first */ synlist = (slist *)rmalloc(sizeof(slist) * TOTAL_VERB); - comblist = NULL; /* The original AGT didn't support multi-word verbs */ + comblist = nullptr; /* The original AGT didn't support multi-word verbs */ num_comb = 0; - userprep = NULL; /* ... nor did it allow user-defined prepostions */ + userprep = nullptr; /* ... nor did it allow user-defined prepostions */ num_prep = 0; if (numglobal > 0) @@ -1468,27 +1468,27 @@ static void set_da1_null(void) /* Set pointers that are malloc'd by try_read_da1 to NULL, to clear the way for free_da1_stuff to recover them */ { - static_str = NULL; + static_str = nullptr; ss_end = ss_size = 0; - command = NULL; - cmd_ptr = NULL; - synlist = NULL; - userstr = NULL; - sub_name = NULL; - globalnoun = NULL; - err_ptr = NULL; - quest_ptr = ans_ptr = NULL; - question = answer = NULL; - msg_ptr = room_ptr = help_ptr = special_ptr = NULL; - noun_ptr = push_ptr = pull_ptr = text_ptr = turn_ptr = play_ptr = NULL; - room_inside = noun_inside = creat_inside = NULL; - creat_ptr = ask_ptr = talk_ptr = NULL; - pictlist = pixlist = fontlist = songlist = NULL; - room = NULL; - noun = NULL; - creature = NULL; - command = NULL; - t_pictlist = t_pixlist = t_fontlist = t_songlist = NULL; + command = nullptr; + cmd_ptr = nullptr; + synlist = nullptr; + userstr = nullptr; + sub_name = nullptr; + globalnoun = nullptr; + err_ptr = nullptr; + quest_ptr = ans_ptr = nullptr; + question = answer = nullptr; + msg_ptr = room_ptr = help_ptr = special_ptr = nullptr; + noun_ptr = push_ptr = pull_ptr = text_ptr = turn_ptr = play_ptr = nullptr; + room_inside = noun_inside = creat_inside = nullptr; + creat_ptr = ask_ptr = talk_ptr = nullptr; + pictlist = pixlist = fontlist = songlist = nullptr; + room = nullptr; + noun = nullptr; + creature = nullptr; + command = nullptr; + t_pictlist = t_pixlist = t_fontlist = t_songlist = nullptr; } @@ -1548,7 +1548,7 @@ static rbool read_da1(fc_type fc, rbool diag) ver = 0; aver = 0; top_quest = 0; /* Highest question actually referenced; set by fixcmd */ - fda1 = openfile(fc, fDA1, NULL, 0); + fda1 = openfile(fc, fDA1, nullptr, 0); if (!filevalid(fda1, fDA1)) return 0; if (DIAG) { @@ -1671,13 +1671,13 @@ static void finish_read(rbool cleanup) rfree(quest_ptr); rfree(ans_ptr); } else { - if (question != NULL) + if (question != nullptr) question = (tline *)rrealloc(question, top_quest * sizeof(tline)); - if (answer != NULL) + if (answer != nullptr) answer = (tline *)rrealloc(answer, top_quest * sizeof(tline)); - if (quest_ptr != NULL) + if (quest_ptr != nullptr) quest_ptr = (descr_ptr *)rrealloc(quest_ptr, top_quest * sizeof(descr_ptr)); - if (ans_ptr != NULL) + if (ans_ptr != nullptr) ans_ptr = (descr_ptr *)rrealloc(ans_ptr, top_quest * sizeof(descr_ptr)); } } @@ -1703,7 +1703,7 @@ rbool readagt(fc_type fc, rbool diag) /* If diag==1, then extra diagnostic information is preserved */ { agx_file = 0; - mem_descr = NULL; + mem_descr = nullptr; build_fixchar(); init_dict(); if (!read_da1(fc, diag)) return 0; /* Couldn't open DA1 file */ diff --git a/engines/glk/agt/agxfile.cpp b/engines/glk/agt/agxfile.cpp index 6a2d331518c..ed3f967046e 100644 --- a/engines/glk/agt/agxfile.cpp +++ b/engines/glk/agt/agxfile.cpp @@ -481,7 +481,7 @@ static file_info fi_creat[] = { }; static file_info fi_cmdhead[] = { - {FT_CMDPTR, DT_CMDPTR, NULL, 0}, + {FT_CMDPTR, DT_CMDPTR, nullptr, 0}, r(FT_INT16, xx, cmd_rec, actor), r(FT_WORD, xx, cmd_rec, verbcmd), r(FT_WORD, xx, cmd_rec, nouncmd), r(FT_WORD, xx, cmd_rec, objcmd), r(FT_WORD, xx, cmd_rec, prep), @@ -507,7 +507,7 @@ static file_info fi_descptr[] = { }; static file_info fi_tline[] = { - {FT_TLINE, xx, NULL, 0}, + {FT_TLINE, xx, nullptr, 0}, endrec }; @@ -556,7 +556,7 @@ static file_info fi_flagrec[] = { /* Ext R2-R2 */ static void set_endrec(file_info *fi, int index) { fi[index].ftype = FT_END; fi[index].dtype = 0; - fi[index].ptr = NULL; + fi[index].ptr = nullptr; fi[index].offset = 0; } @@ -576,10 +576,10 @@ const char base_nostr[] = "no"; static void conv_fstr(const char **s, rbool yes, rbool to_intern) { if (to_intern) { /* Convert to internal form */ - assert(*s != NULL); + assert(*s != nullptr); if (*s == static_str) *s = yes ? base_yesstr : base_nostr; } else { /* convert to external form */ - if (*s == NULL || *s == base_yesstr || *s == base_nostr) + if (*s == nullptr || *s == base_yesstr || *s == base_nostr) *s = static_str; } } @@ -605,7 +605,7 @@ static void fix_objflag_str(rbool to_intern) { static long descr_ofs; void agx_close_descr(void) { - if (mem_descr != NULL) + if (mem_descr != nullptr) rfree(mem_descr); else if (descr_ofs != -1) buffclose(); /* This closes the whole AGX file */ @@ -616,10 +616,10 @@ descr_line *agx_read_descr(long start, long size) { descr_line *txt; char *buff; - if (size <= 0) return NULL; + if (size <= 0) return nullptr; - if (mem_descr == NULL && descr_ofs != -1) - buff = (char *)read_recblock(NULL, FT_CHAR, size, + if (mem_descr == nullptr && descr_ofs != -1) + buff = (char *)read_recblock(nullptr, FT_CHAR, size, descr_ofs + start, size * ft_leng[FT_CHAR]); else buff = mem_descr + start; @@ -633,7 +633,7 @@ descr_line *agx_read_descr(long start, long size) { for (line = 1; line < len;) /* Determine where each of the lines is */ if (buff[i++] == 0) txt[line++] = buff + i; - txt[len] = NULL; /* Mark the end of the array */ + txt[len] = nullptr; /* Mark the end of the array */ return txt; } @@ -735,10 +735,10 @@ typedef struct { /* Entries in the index header of the AGX file */ } index_rec; static file_info fi_index[] = { - {FT_UINT32, DT_DEFAULT, NULL, offsetof(index_rec, file_offset)}, - {FT_UINT32, DT_DEFAULT, NULL, offsetof(index_rec, blocksize)}, - {FT_UINT32, DT_DEFAULT, NULL, offsetof(index_rec, numrec)}, - {FT_UINT32, DT_DEFAULT, NULL, offsetof(index_rec, recsize)}, + {FT_UINT32, DT_DEFAULT, nullptr, offsetof(index_rec, file_offset)}, + {FT_UINT32, DT_DEFAULT, nullptr, offsetof(index_rec, blocksize)}, + {FT_UINT32, DT_DEFAULT, nullptr, offsetof(index_rec, numrec)}, + {FT_UINT32, DT_DEFAULT, nullptr, offsetof(index_rec, recsize)}, endrec }; @@ -766,16 +766,16 @@ struct file_head_rec { }; static file_info fi_header[] = { - {FT_UINT32, DT_LONG, NULL, offsetof(file_head_rec, fileid)}, /* File ID */ - {FT_BYTE, DT_DEFAULT, NULL, offsetof(file_head_rec, ver_own)}, /* Owner */ - {FT_BYTE, DT_DEFAULT, NULL, offsetof(file_head_rec, version)}, /* Version */ - {FT_BYTE, DT_DEFAULT, NULL, offsetof(file_head_rec, ext_own)}, /*Ext owner*/ - {FT_BYTE, DT_DEFAULT, NULL, offsetof(file_head_rec, extnum)}, /* Ext vers */ - {FT_BYTE, DT_DEFAULT, NULL, offsetof(file_head_rec, eol_chk1)}, - {FT_BYTE, DT_DEFAULT, NULL, offsetof(file_head_rec, eol_chk2)}, - {FT_BYTE, DT_DEFAULT, NULL, offsetof(file_head_rec, fallback_ext)}, - {FT_BYTE, DT_DEFAULT, NULL, offsetof(file_head_rec, res2)}, - {FT_UINT32, DT_DEFAULT, NULL, offsetof(file_head_rec, res1)}, + {FT_UINT32, DT_LONG, nullptr, offsetof(file_head_rec, fileid)}, /* File ID */ + {FT_BYTE, DT_DEFAULT, nullptr, offsetof(file_head_rec, ver_own)}, /* Owner */ + {FT_BYTE, DT_DEFAULT, nullptr, offsetof(file_head_rec, version)}, /* Version */ + {FT_BYTE, DT_DEFAULT, nullptr, offsetof(file_head_rec, ext_own)}, /*Ext owner*/ + {FT_BYTE, DT_DEFAULT, nullptr, offsetof(file_head_rec, extnum)}, /* Ext vers */ + {FT_BYTE, DT_DEFAULT, nullptr, offsetof(file_head_rec, eol_chk1)}, + {FT_BYTE, DT_DEFAULT, nullptr, offsetof(file_head_rec, eol_chk2)}, + {FT_BYTE, DT_DEFAULT, nullptr, offsetof(file_head_rec, fallback_ext)}, + {FT_BYTE, DT_DEFAULT, nullptr, offsetof(file_head_rec, res2)}, + {FT_UINT32, DT_DEFAULT, nullptr, offsetof(file_head_rec, res1)}, endrec }; @@ -803,7 +803,7 @@ int read_agx(fc_type fc, rbool diag) { int index_start; agx_file = 1; - fsize = buffopen(fc, fAGX, 16, NULL, 1); + fsize = buffopen(fc, fAGX, 16, nullptr, 1); if (fsize == 0) { agx_file = 0; return 0; @@ -861,7 +861,7 @@ int read_agx(fc_type fc, rbool diag) { /* This assumes that the file is long enough to absorb any 'extra' blocks we read in in early versions with fewer blocks. */ /* (Right now, this must be true: the next block alone is big enough) */ - index = (index_rec *)read_recarray(NULL, sizeof(index_rec), AGX_NUMBLOCK, + index = (index_rec *)read_recarray(nullptr, sizeof(index_rec), AGX_NUMBLOCK, fi_index, "File Index", index_start, index_recsize * AGX_NUMBLOCK); @@ -926,33 +926,33 @@ int read_agx(fc_type fc, rbool diag) { /* Need to read in ss_array before rooms/nouns/creatures */ ss_size = ss_end = index[13].numrec; - static_str = (char *)read_recblock(NULL, FT_CHAR, + static_str = (char *)read_recblock(nullptr, FT_CHAR, index[13].numrec, index[13].file_offset, index[13].blocksize); synptr = syntbl_size = index[19].numrec; - syntbl = (word *)read_recblock(NULL, FT_WORD, index[19].numrec, index[19].file_offset, + syntbl = (word *)read_recblock(nullptr, FT_WORD, index[19].numrec, index[19].file_offset, index[19].blocksize); maxroom = first_room + index[2].numrec - 1; set_roomdesc(fi_room); - room = (room_rec *)read_recarray(NULL, sizeof(room_rec), index[2].numrec, + room = (room_rec *)read_recarray(nullptr, sizeof(room_rec), index[2].numrec, fi_room, "Room", index[2].file_offset, index[2].blocksize); maxnoun = first_noun + index[3].numrec - 1; set_noundesc(fi_noun); - noun = (noun_rec *)read_recarray(NULL, sizeof(noun_rec), index[3].numrec, + noun = (noun_rec *)read_recarray(nullptr, sizeof(noun_rec), index[3].numrec, fi_noun, "Noun", index[3].file_offset, index[3].blocksize); last_obj = maxcreat = first_creat + index[4].numrec - 1; set_creatdesc(fi_creat); - creature = (creat_rec *)read_recarray(NULL, sizeof(creat_rec), index[4].numrec, + creature = (creat_rec *)read_recarray(nullptr, sizeof(creat_rec), index[4].numrec, fi_creat, "Creature", index[4].file_offset, index[4].blocksize); last_cmd = index[5].numrec; set_cmdptr(fi_cmdhead); - command = (cmd_rec *)read_recarray(NULL, sizeof(cmd_rec), index[5].numrec, + command = (cmd_rec *)read_recarray(nullptr, sizeof(cmd_rec), index[5].numrec, fi_cmdhead, "Metacommand", index[5].file_offset, index[5].blocksize); if (filehead.ext_own != 'R' && filehead.fallback_ext <= 1) { @@ -961,33 +961,33 @@ int read_agx(fc_type fc, rbool diag) { } NUM_ERR = index[6].numrec; - err_ptr = (descr_ptr *)read_recarray(NULL, sizeof(descr_ptr), index[6].numrec, + err_ptr = (descr_ptr *)read_recarray(nullptr, sizeof(descr_ptr), index[6].numrec, fi_descptr, "Error Message", index[6].file_offset, index[6].blocksize); last_message = index[7].numrec; - msg_ptr = (descr_ptr *)read_recarray(NULL, sizeof(descr_ptr), index[7].numrec, + msg_ptr = (descr_ptr *)read_recarray(nullptr, sizeof(descr_ptr), index[7].numrec, fi_descptr, "Message", index[7].file_offset, index[7].blocksize); MaxQuestion = index[8].numrec; - question = answer = NULL; - quest_ptr = (descr_ptr *)read_recarray(NULL, sizeof(descr_ptr), index[8].numrec, + question = answer = nullptr; + quest_ptr = (descr_ptr *)read_recarray(nullptr, sizeof(descr_ptr), index[8].numrec, fi_descptr, "Question", index[8].file_offset, index[8].blocksize); if (index[9].numrec != index[8].numrec) fatal("File corrputed: questions and answers don't match."); - ans_ptr = (descr_ptr *)read_recarray(NULL, sizeof(descr_ptr), index[9].numrec, + ans_ptr = (descr_ptr *)read_recarray(nullptr, sizeof(descr_ptr), index[9].numrec, fi_descptr, "Answer", index[9].file_offset, index[9].blocksize); MAX_USTR = index[10].numrec; - userstr = (tline *)read_recarray(NULL, sizeof(tline), index[10].numrec, + userstr = (tline *)read_recarray(nullptr, sizeof(tline), index[10].numrec, fi_tline, "User String", index[10].file_offset, index[10].blocksize); MAX_SUB = index[14].numrec; - sub_name = (word *)read_recblock(NULL, FT_WORD, index[14].numrec, index[14].file_offset, + sub_name = (word *)read_recblock(nullptr, FT_WORD, index[14].numrec, index[14].file_offset, index[14].blocksize); if (index[16].numrec > MAX_PIX) { @@ -1001,7 +1001,7 @@ int read_agx(fc_type fc, rbool diag) { index[16].blocksize); numglobal = index[17].numrec; - globalnoun = (word *)read_recblock(NULL, FT_WORD, + globalnoun = (word *)read_recblock(nullptr, FT_WORD, index[17].numrec, index[17].file_offset, index[17].blocksize); @@ -1017,25 +1017,25 @@ int read_agx(fc_type fc, rbool diag) { DVERB = index[15].numrec - old_base_verb - MAX_SUB; - synlist = (slist *)read_recblock(NULL, FT_SLIST, index[15].numrec, index[15].file_offset, + synlist = (slist *)read_recblock(nullptr, FT_SLIST, index[15].numrec, index[15].file_offset, index[15].blocksize); correct_synlist(); num_comb = index[28].numrec; - comblist = (slist *)read_recblock(NULL, FT_SLIST, index[28].numrec, index[28].file_offset, + comblist = (slist *)read_recblock(nullptr, FT_SLIST, index[28].numrec, index[28].file_offset, index[28].blocksize); num_prep = index[29].numrec; - userprep = (slist *)read_recblock(NULL, FT_SLIST, index[29].numrec, index[29].file_offset, + userprep = (slist *)read_recblock(nullptr, FT_SLIST, index[29].numrec, index[29].file_offset, index[29].blocksize); /* dicstr must be read in before dict */ dictstrsize = dictstrptr = index[20].numrec; - dictstr = (char *)read_recblock(NULL, FT_CHAR, index[20].numrec, index[20].file_offset, + dictstr = (char *)read_recblock(nullptr, FT_CHAR, index[20].numrec, index[20].file_offset, index[20].blocksize); dp = index[21].numrec; - dict = (char **)read_recblock(NULL, FT_DICTPTR, + dict = (char **)read_recblock(nullptr, FT_DICTPTR, index[21].numrec, index[21].file_offset, index[21].blocksize); @@ -1048,20 +1048,20 @@ int read_agx(fc_type fc, rbool diag) { } maxpict = index[23].numrec; - pictlist = (filename *)read_recblock(NULL, FT_STR, index[23].numrec, index[23].file_offset, + pictlist = (filename *)read_recblock(nullptr, FT_STR, index[23].numrec, index[23].file_offset, index[23].blocksize); maxpix = index[24].numrec; - pixlist = (filename *)read_recblock(NULL, FT_STR, index[24].numrec, index[24].file_offset, + pixlist = (filename *)read_recblock(nullptr, FT_STR, index[24].numrec, index[24].file_offset, index[24].blocksize); maxfont = index[25].numrec; - fontlist = (filename *)read_recblock(NULL, FT_STR, index[25].numrec, index[25].file_offset, + fontlist = (filename *)read_recblock(nullptr, FT_STR, index[25].numrec, index[25].file_offset, index[25].blocksize); maxsong = index[26].numrec; - songlist = (filename *)read_recblock(NULL, FT_STR, index[26].numrec, index[26].file_offset, + songlist = (filename *)read_recblock(nullptr, FT_STR, index[26].numrec, index[26].file_offset, index[26].blocksize); vm_size = index[27].numrec; - verbinfo = (verbentry_rec *)read_recarray(NULL, sizeof(verbentry_rec), index[27].numrec, + verbinfo = (verbentry_rec *)read_recarray(nullptr, sizeof(verbentry_rec), index[27].numrec, fi_verbentry, "Menu Vocabulary", index[27].file_offset, index[27].blocksize); @@ -1072,13 +1072,13 @@ int read_agx(fc_type fc, rbool diag) { if (index[31].numrec != (uint32)objextsize(1)) fatal("Object property block not of the correct size."); - objflag = (uchar *)read_recblock(NULL, FT_BYTE, index[30].numrec, index[30].file_offset, + objflag = (uchar *)read_recblock(nullptr, FT_BYTE, index[30].numrec, index[30].file_offset, index[30].blocksize); - objprop = (long *)read_recblock(NULL, FT_INT32, index[31].numrec, index[31].file_offset, + objprop = (long *)read_recblock(nullptr, FT_INT32, index[31].numrec, index[31].file_offset, index[31].blocksize); oflag_cnt = index[32].numrec; - attrtable = (attrdef_rec *)read_recarray(NULL, sizeof(attrdef_rec), index[32].numrec, + attrtable = (attrdef_rec *)read_recarray(nullptr, sizeof(attrdef_rec), index[32].numrec, fi_attrrec, "Object Flag Table", index[32].file_offset, index[32].blocksize); @@ -1086,7 +1086,7 @@ int read_agx(fc_type fc, rbool diag) { block 36 has been read in. */ oprop_cnt = index[33].numrec; - proptable = (propdef_rec *)read_recarray(NULL, sizeof(propdef_rec), index[33].numrec, + proptable = (propdef_rec *)read_recarray(nullptr, sizeof(propdef_rec), index[33].numrec, fi_proprec, "Object Property Table", index[33].file_offset, index[33].blocksize); @@ -1095,29 +1095,29 @@ int read_agx(fc_type fc, rbool diag) { /* Non-standard extension */ // int i; for (i = 0; i < oflag_cnt; i++) /* These are converted later */ - attrtable[i].ystr = NULL; - attrtable[i].nstr = NULL; + attrtable[i].ystr = nullptr; + attrtable[i].nstr = nullptr; for (i = 0; i < oprop_cnt; i++) proptable[i].str_cnt = 0; propstr_size = 0; - propstr = NULL; - vartable = NULL; - flagtable = NULL; + propstr = nullptr; + vartable = nullptr; + flagtable = nullptr; } else { /* Normal case */ propstr_size = index[34].numrec; - propstr = (const char **)read_recblock(NULL, FT_STR, index[34].numrec, + propstr = (const char **)read_recblock(nullptr, FT_STR, index[34].numrec, index[34].file_offset, index[34].blocksize); if (index[35].numrec && index[35].numrec != (uint32)VAR_NUM + 1) fatal("AGX file corrupted: variable itemization table size mismatch."); - vartable = (vardef_rec *)read_recarray(NULL, sizeof(vardef_rec), index[35].numrec, + vartable = (vardef_rec *)read_recarray(nullptr, sizeof(vardef_rec), index[35].numrec, fi_varrec, "Variable Itemization Table", index[35].file_offset, index[35].blocksize); if (index[36].numrec && index[36].numrec != (uint32)FLAG_NUM + 1) fatal("AGX file corrupted: flag itemization table size mismatch."); - flagtable = (flagdef_rec *)read_recarray(NULL, sizeof(flagdef_rec), index[36].numrec, + flagtable = (flagdef_rec *)read_recarray(nullptr, sizeof(flagdef_rec), index[36].numrec, fi_flagrec, "Flag Itemization Table", index[36].file_offset, index[36].blocksize); @@ -1133,14 +1133,14 @@ int read_agx(fc_type fc, rbool diag) { agxread() but during play */ if ((long)index[11].blocksize <= descr_maxmem) { /* ... if we decided to load descriptions into memory */ - mem_descr = (char *)read_recblock(NULL, FT_CHAR, index[11].numrec, + mem_descr = (char *)read_recblock(nullptr, FT_CHAR, index[11].numrec, index[11].file_offset, index[11].blocksize); buffclose(); /* Don't need to keep it open */ descr_ofs = -1; } else { descr_ofs = index[11].file_offset; - mem_descr = NULL; + mem_descr = nullptr; } reinit_dict(); return 1; @@ -1239,8 +1239,8 @@ void agx_create(fc_type fc) { /* This writes random data to the file; their only purpose is to prevent problems with seeking beyond the end of file */ - write_recarray(NULL, sizeof(file_head_rec), 1, fi_header, 0); - write_recarray(NULL, sizeof(index_rec), AGX_NUMBLOCK, fi_index, 16); + write_recarray(nullptr, sizeof(file_head_rec), 1, fi_header, 0); + write_recarray(nullptr, sizeof(index_rec), AGX_NUMBLOCK, fi_index, 16); old_base_verb = BASE_VERB; /* This will be constant for any given version of the interpreter, but may change across @@ -1297,7 +1297,7 @@ static void agx_finish_index(void) { gindex[6].numrec = NUM_ERR; gindex[7].numrec = last_message; gindex[8].numrec = gindex[9].numrec = MaxQuestion; - if (userstr != NULL) + if (userstr != nullptr) gindex[10].numrec = MAX_USTR; else gindex[10].numrec = 0; gindex[13].numrec = ss_end; @@ -1341,18 +1341,18 @@ void write_descr(descr_ptr *dp_, descr_line *txt) { char *buff, *buffptr, *src; size = 0; - if (txt == NULL) { + if (txt == nullptr) { dp_->start = 0; dp_->size = 0; return; } - for (i = 0; txt[i] != NULL; i++) /* Compute size */ + for (i = 0; txt[i] != nullptr; i++) /* Compute size */ size += strlen(txt[i]) + 1; /* Remember trailing \0 */ buff = (char *)rmalloc(sizeof(char) * size); buffptr = buff; - for (i = 0; txt[i] != NULL; i++) { + for (i = 0; txt[i] != nullptr; i++) { for (src = txt[i]; *src != 0; src++, buffptr++) *buffptr = *src; *buffptr++ = 0; @@ -1422,7 +1422,7 @@ void agx_write(void) { write_recarray(ans_ptr, sizeof(descr_ptr), gindex[9].numrec, fi_descptr, gindex[9].file_offset); - if (userstr != NULL) + if (userstr != nullptr) write_recarray(userstr, sizeof(tline), gindex[10].numrec, fi_tline, gindex[10].file_offset); diff --git a/engines/glk/agt/auxfile.cpp b/engines/glk/agt/auxfile.cpp index 58f45202c18..e76c594aeac 100644 --- a/engines/glk/agt/auxfile.cpp +++ b/engines/glk/agt/auxfile.cpp @@ -175,7 +175,7 @@ static void cfg_option(int optnum, char *optstr[], rbool lastpass) { rbool setflag; - if (optnum == 0 || optstr[0] == NULL) return; + if (optnum == 0 || optstr[0] == nullptr) return; if (strncasecmp(optstr[0], "no_", 3) == 0) { optstr[0] += 3; @@ -226,19 +226,19 @@ rbool parse_config_line(char *buff, rbool lastpass) { int optc; optc = 0; - opt[0] = NULL; + opt[0] = nullptr; for (p = buff; *p; p++) { if (isspace(*p)) { /* Whitespace */ - if (opt[optc] != NULL) { /*... which means this is the first whitespace */ + if (opt[optc] != nullptr) { /*... which means this is the first whitespace */ if (optc == 50) return 0; /* Too many */ - opt[++optc] = NULL; + opt[++optc] = nullptr; } *p = 0; } else /* No whitespace */ - if (opt[optc] == NULL) /* ...this is the first non-whitespace */ + if (opt[optc] == nullptr) /* ...this is the first non-whitespace */ opt[optc] = p; } - if (opt[optc] != NULL) opt[++optc] = NULL; + if (opt[optc] != nullptr) opt[++optc] = nullptr; cfg_option(optc, opt, lastpass); return 1; } @@ -293,7 +293,7 @@ void read_opt(fc_type fc) { genfile optfile; have_opt = 0; - optfile = openbin(fc, fOPT, NULL, 0); + optfile = openbin(fc, fOPT, nullptr, 0); if (filevalid(optfile, fOPT)) { if (!binread(optfile, opt_data, 14, 1, &errstr)) fatal("Invalid OPT file."); @@ -341,14 +341,14 @@ descr_line *read_ttl(fc_type fc) { int i, j, height; descr_line *buff; - ttlfile = openfile(fc, fTTL, NULL, 0); + ttlfile = openfile(fc, fTTL, nullptr, 0); /* "Warning: Could not open title file '%s'." */ - if (!filevalid(ttlfile, fTTL)) return NULL; + if (!filevalid(ttlfile, fTTL)) return nullptr; build_fixchar(); buff = (descr_line *)rmalloc(sizeof(descr_line)); i = 0; - while (NULL != (buff[i] = readln(ttlfile, NULL, 0))) { + while (nullptr != (buff[i] = readln(ttlfile, nullptr, 0))) { if (strncmp(buff[i], "END OF FILE", 11) == 0) break; else if (aver >= AGT18 && aver <= AGT18MAX && check_dollar(buff[i])) statusmode = 4; @@ -357,14 +357,14 @@ descr_line *read_ttl(fc_type fc) { buff[i][j] = fixchar[(uchar)buff[i][j]]; /* Advance i and set the next pointer to NULL */ buff = (descr_line *)rrealloc(buff, sizeof(descr_line) * (++i + 1)); - buff[i] = NULL; + buff[i] = nullptr; } rfree(buff[i]); } readclose(ttlfile); rfree(buff[i]); - while (buff[i] == NULL || strlen(buff[i]) <= 1) { /* Discard 'empty' lines */ + while (buff[i] == nullptr || strlen(buff[i]) <= 1) { /* Discard 'empty' lines */ if (i == 0) break; rfree(buff[i]); i--; @@ -381,8 +381,8 @@ descr_line *read_ttl(fc_type fc) { void free_ttl(descr_line *title) { int i; - if (title == NULL) return; - for (i = 0; title[i] != NULL; i++) + if (title == nullptr) return; + for (i = 0; title[i] != nullptr; i++) rfree(title[i]); rfree(title); } @@ -416,7 +416,7 @@ void add_verbrec(const char *verb_line, rbool addnew) { s[0] = verbStr.firstChar(); s[1] = 0; - verbinfo[vm_size].objnum = strtol(s, NULL, 10) - 1; + verbinfo[vm_size].objnum = strtol(s, nullptr, 10) - 1; verbStr.deleteChar(0); verbStr.deleteChar(0); @@ -452,7 +452,7 @@ void init_verbrec(void) /* Fill in vnum field */ /* UNDO, RESTART, MENU */ { - verbinfo = NULL; + verbinfo = nullptr; vm_size = 0; newindex = 0; if (freeze_mode) newindex = 1; /* Don't include MENU option if we can't @@ -469,7 +469,7 @@ void read_voc(fc_type fc) { genfile vocfile; init_verbrec(); - vocfile = openfile(fc, fVOC, NULL, 0); + vocfile = openfile(fc, fVOC, nullptr, 0); if (filevalid(vocfile, fVOC)) { /* Vocabulary file exists */ while (readln(vocfile, linbuf, 79)) add_verbrec(linbuf, 0); @@ -490,16 +490,16 @@ void read_voc(fc_type fc) { static genfile insfile = BAD_TEXTFILE; static char *ins_buff; -static descr_line *ins_descr = NULL; +static descr_line *ins_descr = nullptr; static int ins_line; /* Current instruction line */ /* Return 1 on success, 0 on failure */ rbool open_ins_file(fc_type fc, rbool report_error) { - ins_buff = NULL; + ins_buff = nullptr; ins_line = 0; - if (ins_descr != NULL) return 1; + if (ins_descr != nullptr) return 1; if (filevalid(insfile, fINS)) { textrewind(insfile); @@ -508,7 +508,7 @@ rbool open_ins_file(fc_type fc, rbool report_error) { if (agx_file) { ins_descr = read_descr(ins_ptr.start, ins_ptr.size); - if (ins_descr != NULL) return 1; + if (ins_descr != nullptr) return 1; /* Note that if the AGX file doesn't contain an INS block, we don't immediatly give up but try opening .INS */ @@ -517,19 +517,19 @@ rbool open_ins_file(fc_type fc, rbool report_error) { insfile = openfile(fc, fINS, report_error ? "Sorry, Instructions aren't available for this game" - : NULL, + : nullptr, 0); return (filevalid(insfile, fINS)); } char *read_ins_line(void) { if (ins_descr) { - if (ins_descr[ins_line] != NULL) + if (ins_descr[ins_line] != nullptr) return ins_descr[ins_line++]; - else return NULL; + else return nullptr; } else { rfree(ins_buff); - ins_buff = readln(insfile, NULL, 0); + ins_buff = readln(insfile, nullptr, 0); return ins_buff; } } @@ -537,7 +537,7 @@ char *read_ins_line(void) { void close_ins_file(void) { if (ins_descr) { free_descr(ins_descr); - ins_descr = NULL; + ins_descr = nullptr; } else if (filevalid(insfile, fINS)) { rfree(ins_buff); readclose(insfile); @@ -553,15 +553,15 @@ descr_line *read_ins(fc_type fc) { int i; i = 0; - txt = NULL; + txt = nullptr; if (open_ins_file(fc, 0)) { /* Instruction file exists */ - while (NULL != (buff = read_ins_line())) { + while (nullptr != (buff = read_ins_line())) { /* Enlarge txt; we use (i+2) here to leave space for the trailing \0 */ txt = (descr_line *)rrealloc(txt, sizeof(descr_ptr) * (i + 2)); txt[i++] = rstrdup(buff); } - if (txt != NULL) - txt[i] = 0; /* There is space for this since we used (i+2) above */ + if (txt != nullptr) + txt[i] = nullptr; /* There is space for this since we used (i+2) above */ close_ins_file(); } return txt; @@ -570,8 +570,8 @@ descr_line *read_ins(fc_type fc) { void free_ins(descr_line *instr) { int i; - if (instr == NULL) return; - for (i = 0; instr[i] != NULL; i++) + if (instr == nullptr) return; + for (i = 0; instr[i] != nullptr; i++) rfree(instr[i]); rfree(instr); } diff --git a/engines/glk/agt/debugcmd.cpp b/engines/glk/agt/debugcmd.cpp index c5b9106881a..32998f4cf31 100644 --- a/engines/glk/agt/debugcmd.cpp +++ b/engines/glk/agt/debugcmd.cpp @@ -249,7 +249,7 @@ static void edit_str() { char buff[10]; char *tmpstr; - if (MAX_USTR == 0 || userstr == NULL) { + if (MAX_USTR == 0 || userstr == nullptr) { writeln("This game doesn't contain any user strings"); return; } diff --git a/engines/glk/agt/disassemble.cpp b/engines/glk/agt/disassemble.cpp index cd24c48f37c..f0822483aee 100644 --- a/engines/glk/agt/disassemble.cpp +++ b/engines/glk/agt/disassemble.cpp @@ -42,8 +42,8 @@ static void print_msg(descr_ptr dptr) { descr_line *txt; txt = read_descr(dptr.start, dptr.size); - if (txt != NULL) { - for (j = 0; txt[j] != NULL; j++) { + if (txt != nullptr) { + for (j = 0; txt[j] != nullptr; j++) { dbgprintf("\n"); debugout(txt[j]); } @@ -85,7 +85,7 @@ void print_special_obj(int i) dval = 0; /* Silence compiler warnings. */ fatal("INTERNAL ERROR: Invalid *dval* in print_special_obj."); } - if (dbgflagptr == NULL) + if (dbgflagptr == nullptr) /* This determines whether we are linked with agtout or agil */ return; s = getname(dval); @@ -147,10 +147,10 @@ int argout(int dtype, int dval, int optype) { dbgprintf("RoomFlag%d", dval); break; case AGT_QUEST: /* Question */ - if (dval <= MaxQuestion && dval >= 1 && question != NULL) { + if (dval <= MaxQuestion && dval >= 1 && question != nullptr) { dbgprintf("\nQ%d:%s\n", dval, question[dval - 1]); dbgprintf("[A:%s]", answer[dval - 1]); - } else if (quest_ptr != NULL) { + } else if (quest_ptr != nullptr) { dbgprintf("\nQ%d: ", dval); print_msg(quest_ptr[dval - 1]); dbgprintf("[A:"); @@ -158,7 +158,7 @@ int argout(int dtype, int dval, int optype) { } break; case AGT_MSG: /* Message */ - if (dval > last_message || dval < 1 || msg_ptr == NULL) + if (dval > last_message || dval < 1 || msg_ptr == nullptr) dbgprintf("ILLEGAL MESSAGE"); else { dbgprintf("(Msg%d)", dval); @@ -167,7 +167,7 @@ int argout(int dtype, int dval, int optype) { } break; case AGT_ERR: /* Message */ - if (dval > NUM_ERR || dval < 1 || err_ptr == NULL) + if (dval > NUM_ERR || dval < 1 || err_ptr == nullptr) dbgprintf("ILLEGAL MESSAGE"); else { dbgprintf("(Std%d)", dval); @@ -176,7 +176,7 @@ int argout(int dtype, int dval, int optype) { } break; case AGT_STR: /* String */ - if (dval - 1 >= MAX_USTR || userstr == NULL) + if (dval - 1 >= MAX_USTR || userstr == nullptr) dbgprintf("ILLEGAL STRING"); else dbgprintf("\nStr%d:%s", dval, userstr[dval]); diff --git a/engines/glk/agt/exec.cpp b/engines/glk/agt/exec.cpp index 90583e3fa51..5e88bb82b03 100644 --- a/engines/glk/agt/exec.cpp +++ b/engines/glk/agt/exec.cpp @@ -236,7 +236,7 @@ static void num_name_func(parse_rec *obj_rec, char *fill_buff, word prev_adj) { word w; - if (obj_rec == NULL) { + if (obj_rec == nullptr) { strcpy(fill_buff, ""); return; } @@ -369,7 +369,7 @@ static int wordcode_match(const char **pvarname, char *fill_buff, if (context == MSG_PARSE) { /* The only special subsitution allowed is $word$. */ if (match_str(pvarname, "WORD$")) { - if (pword == NULL) fill_buff[0] = 0; + if (pword == nullptr) fill_buff[0] = 0; else rstrncpy(fill_buff, pword, FILL_SIZE); return 1; } else return 0; @@ -489,7 +489,7 @@ static char *wordvar_match(const char **pvarname, char match_type, start = *pvarname; if (match_type == '$') { i = wordcode_match(pvarname, fill_buff, context, pword); - if (i == 0) return NULL; + if (i == 0) return nullptr; /* Now need to fix capitalization */ switch (capstate(start)) { case 0: @@ -506,18 +506,18 @@ static char *wordvar_match(const char **pvarname, char match_type, } else { /* So match type is '#' */ if (match_str(pvarname, "VAR")) { hold_val = extract_number(pvarname, VAR_NUM, '#'); - if (hold_val < 0) return NULL; + if (hold_val < 0) return nullptr; hold_val = agt_var[hold_val]; } else if (match_str(pvarname, "CNT") || match_str(pvarname, "CTR")) { hold_val = extract_number(pvarname, CNT_NUM, '#'); - if (hold_val < 0) return NULL; + if (hold_val < 0) return nullptr; hold_val = cnt_val(agt_counter[hold_val]); } else if (match_str(pvarname, "PROP")) { extract_prop_val(pvarname, &hold_prop, &hold_val, 1, '#'); if (hold_prop == BAD_PROP) hold_val = 0; } else - return NULL; + return nullptr; /* Now to convert hold_val into a string */ sprintf(fill_buff, "%d", hold_val); @@ -558,7 +558,7 @@ static char *format_line(const char *s, int context, const char *pword) oldp = p++; /* Save old value in case we are wrong and then increment p */ fill_word = wordvar_match(&p, fill_type, context, pword); - if (fill_word == NULL) { + if (fill_word == nullptr) { /*i.e. no match-- so just copy it verbatim */ t[i++] = fill_type; just_seen_adj = 0; @@ -617,9 +617,9 @@ static void gen_print_descr(descr_ptr dp_, rbool nl, textbold = 0; agt_par(1); txt = read_descr(dp_.start, dp_.size); - if (txt != NULL) - for (j = 0; txt[j] != NULL; j++) - lineout(txt[j], nl || (txt[j + 1] != NULL), context, pword); + if (txt != nullptr) + for (j = 0; txt[j] != nullptr; j++) + lineout(txt[j], nl || (txt[j + 1] != nullptr), context, pword); free_descr(txt); agt_par(0); agt_textcolor(7); @@ -627,7 +627,7 @@ static void gen_print_descr(descr_ptr dp_, rbool nl, } void print_descr(descr_ptr dp_, rbool nl) { - gen_print_descr(dp_, nl, MSG_DESC, NULL); + gen_print_descr(dp_, nl, MSG_DESC, nullptr); } void quote(int msgnum) { @@ -637,11 +637,11 @@ void quote(int msgnum) { int len; txt = read_descr(msg_ptr[msgnum - 1].start, msg_ptr[msgnum - 1].size); - if (txt != NULL) { - for (len = 0; txt[len] != NULL; len++); + if (txt != nullptr) { + for (len = 0; txt[len] != nullptr; len++); qptr = (char **)rmalloc(len * sizeof(char *)); for (i = 0; i < len; i++) - qptr[i] = format_line(txt[i], MSG_DESC, NULL); + qptr[i] = format_line(txt[i], MSG_DESC, nullptr); free_descr(txt); textbox(qptr, len, TB_BORDER | TB_CENTER); rfree(qptr); @@ -692,9 +692,9 @@ void gen_sysmsg(int msgid, const char *s, int context, const char *pword) if (DEBUG_SMSG) rprintf("\nSTD %d", msgid); - use_game_msg = ((PURE_SYSMSG || s == NULL) + use_game_msg = ((PURE_SYSMSG || s == nullptr) && msgid != 0 && msgid <= NUM_ERR - && err_ptr != NULL); + && err_ptr != nullptr); if (use_game_msg) { /* Check for fall-back messages */ @@ -714,7 +714,7 @@ void gen_sysmsg(int msgid, const char *s, int context, const char *pword) if (!use_game_msg) { /* Either the game doesn't redefine the message, or we're ignoring redefinitions */ - if (s == NULL) return; + if (s == nullptr) return; pronoun_mode = 1; lineout(s, nl, context, pword); pronoun_mode = !PURE_PROSUB; @@ -723,7 +723,7 @@ void gen_sysmsg(int msgid, const char *s, int context, const char *pword) void sysmsg(int msgid, const char *s) { - gen_sysmsg(msgid, s, MSG_RUN, NULL); + gen_sysmsg(msgid, s, MSG_RUN, nullptr); } @@ -741,7 +741,7 @@ void alt_sysmsg(int msgid, const char *s, parse_rec *new_dobjrec, parse_rec *new iobj = p_obj(new_iobjrec); iobj_rec = new_iobjrec; - gen_sysmsg(msgid, s, MSG_RUN, NULL); + gen_sysmsg(msgid, s, MSG_RUN, nullptr); dobj = save_dobj; dobj_rec = save_dobjrec; @@ -753,7 +753,7 @@ void alt_sysmsg(int msgid, const char *s, parse_rec *new_dobjrec, parse_rec *new void sysmsgd(int msgid, const char *s, parse_rec *new_dobjrec) /* Front end for sysmsg w/alternative direct object */ { - alt_sysmsg(msgid, s, new_dobjrec, NULL); + alt_sysmsg(msgid, s, new_dobjrec, nullptr); } @@ -797,33 +797,33 @@ static rbool check_answer(char *ans, long start, long size) loop over them */ astr = read_descr(start, size); - if (astr == NULL) { + if (astr == nullptr) { if (!PURE_ERROR) writeln("GAME ERROR: Empty answer field."); return 1; } match_mode = 0; - for (i = 0; astr[i] != NULL; i++) - if (strstr(astr[i], "OR") != NULL) { + for (i = 0; astr[i] != nullptr; i++) + if (strstr(astr[i], "OR") != nullptr) { match_mode = 1; break; } corr = ans; - for (i = 0; astr[i] != NULL; i++) { /* loop over all lines of the answer */ + for (i = 0; astr[i] != nullptr; i++) { /* loop over all lines of the answer */ p = astr[i]; do { q = strstr(p, "OR"); r = strstr(p, "AND"); - if (q == NULL || (r != NULL && r < q)) q = r; - if (q == NULL) q = p + strlen(p); /* i.e. points at the concluding null */ + if (q == nullptr || (r != nullptr && r < q)) q = r; + if (q == nullptr) q = p + strlen(p); /* i.e. points at the concluding null */ corr2 = match_string(corr, p, q - p); - if (corr2 == NULL && match_mode == 0) { + if (corr2 == nullptr && match_mode == 0) { free_descr(astr); return 0; } - if (corr2 != NULL && match_mode == 1) { + if (corr2 != nullptr && match_mode == 1) { free_descr(astr); return 1; } @@ -847,12 +847,12 @@ rbool match_answer(char *ans, int anum) { for (corr = ans; *corr != 0; corr++) *corr = tolower(*corr); - if (answer != NULL) { + if (answer != nullptr) { /* corr=strstr(ans,answer[anum]); */ corr = match_string(ans, answer[anum], strlen(answer[anum])); rfree(ans); - if (corr == NULL) return 0; - } else if (ans_ptr != NULL) { + if (corr == nullptr) return 0; + } else if (ans_ptr != nullptr) { ans_corr = check_answer(ans, ans_ptr[anum].start, ans_ptr[anum].size); rfree(ans); return ans_corr; @@ -870,9 +870,9 @@ rbool ask_question(int qnum) qnum--; /* Now actually ask the question and compare the answers */ - if (question != NULL) + if (question != nullptr) writeln(question[qnum]); - else if (quest_ptr != NULL) + else if (quest_ptr != nullptr) print_descr(quest_ptr[qnum], 1); else { writeln("INT ERR: Invalid question pointer"); @@ -893,12 +893,12 @@ long read_number(void) { n = 1; do { - if (n != 1) gen_sysmsg(218, "Please enter a *number*. ", MSG_MAIN, NULL); + if (n != 1) gen_sysmsg(218, "Please enter a *number*. ", MSG_MAIN, nullptr); s = agt_readline(1); n = strtol(s, &err, 10); - if (err == s) err = NULL; + if (err == s) err = nullptr; rfree(s); - } while (err == NULL); + } while (err == nullptr); return n; } @@ -1001,7 +1001,7 @@ void look_room(void) { compute_seen(); writeln(""); if (islit()) { - if (room[loc].name != NULL && room[loc].name[0] != 0 && + if (room[loc].name != nullptr && room[loc].name[0] != 0 && (!PURE_ROOMTITLE)) { agt_textcolor(-1); /* Emphasized text on */ writestr(room[loc].name); @@ -1045,7 +1045,7 @@ static void run_autoverb(void) { if (room[loc].autoverb != 0) { v0 = verb_code(room[loc].autoverb); - (void)scan_metacommand(0, v0, 0, 0, 0, NULL); + (void)scan_metacommand(0, v0, 0, 0, 0, nullptr); } free_all_parserec(); vb = savevb; @@ -1083,7 +1083,7 @@ static void creat_initdesc(void) { void listpictname(const char *s) { static rbool first_pict = 1; /* True until we output first picture */ - if (s == NULL) { + if (s == nullptr) { if (!first_pict) writeln(""); /* Trailing newline */ first_pict = 1; return; @@ -1114,7 +1114,7 @@ void list_viewable(void) { int i; - listpictname(NULL); + listpictname(nullptr); if (room[loc].pict != 0) listpictname("scene"); @@ -1128,7 +1128,7 @@ void list_viewable(void) for (i = 0; i < maxpix; i++) if (room[loc].PIX_bits & (1L << i)) listpictname(dict[pix_name[i]]); - listpictname(NULL); + listpictname(nullptr); } @@ -1337,7 +1337,7 @@ static int save_vnum; static word save_prep; static parse_rec save_actor; static parse_rec save_obj; -parse_rec *save_lnoun = NULL; +parse_rec *save_lnoun = nullptr; @@ -1350,7 +1350,7 @@ void exec(parse_rec *actor_, int vnum, if (vnum == verb_code(ext_code[wagain]) && lnoun[0].info == D_END && iobj_->info == D_END && (actor_->info == D_END || actor_->obj == save_actor.obj)) - if (save_lnoun == NULL) { + if (save_lnoun == nullptr) { rfree(lnoun); sysmsg(186, "You can't use AGAIN until you've entered at least one command."); @@ -1362,7 +1362,7 @@ void exec(parse_rec *actor_, int vnum, memcpy(iobj_, &save_obj, sizeof(parse_rec)); rfree(lnoun); lnoun = save_lnoun; - save_lnoun = NULL; + save_lnoun = nullptr; } else realverb = input[vp]; @@ -1371,12 +1371,12 @@ void exec(parse_rec *actor_, int vnum, runverbs(actor_, vnum, lnoun, prep_, iobj_); if (cmd_saveable) { - if (save_lnoun != NULL) rfree(save_lnoun); + if (save_lnoun != nullptr) rfree(save_lnoun); memcpy(&save_actor, actor_, sizeof(parse_rec)); save_vnum = vnum; save_lnoun = lnoun; - lnoun = NULL; + lnoun = nullptr; save_prep = prep_; memcpy(&save_obj, iobj_, sizeof(parse_rec)); } else diff --git a/engines/glk/agt/filename.cpp b/engines/glk/agt/filename.cpp index bf93c492aa5..70b12325286 100644 --- a/engines/glk/agt/filename.cpp +++ b/engines/glk/agt/filename.cpp @@ -47,7 +47,7 @@ const char *extname[] = { #ifdef PATH_SEP static const char *path_sep = PATH_SEP; #else -static const char *path_sep = NULL; +static const char *path_sep = nullptr; #endif /* This returns the options to use when opening the given file type */ @@ -69,7 +69,7 @@ const char *filetype_info(filetype ft, rbool rw) { } if (ft == fLOG) return rw ? "w" : "r"; fatal("INTERNAL ERROR: Invalid filetype."); - return NULL; + return nullptr; } @@ -105,17 +105,17 @@ char *assemble_filename(const char *path, const char *root, char *name; len1 = len2 = len3 = 0; - if (path != NULL) len1 = strlen(path); - if (root != NULL) len2 = strlen(root); - if (ext != NULL) len3 = strlen(ext); + if (path != nullptr) len1 = strlen(path); + if (root != nullptr) len2 = strlen(root); + if (ext != nullptr) len3 = strlen(ext); name = (char *)rmalloc(len1 + len2 + len3 + 1); - if (path != NULL) memcpy(name, path, len1); + if (path != nullptr) memcpy(name, path, len1); #ifdef PREFIX_EXT if (ext != NULL) memcpy(name + len1, ext, len3); if (root != NULL) memcpy(name + len1 + len3, root, len2); #else - if (root != NULL) memcpy(name + len1, root, len2); - if (ext != NULL) memcpy(name + len1 + len2, ext, len3); + if (root != nullptr) memcpy(name + len1, root, len2); + if (ext != nullptr) memcpy(name + len1 + len2, ext, len3); #endif name[len1 + len2 + len3] = 0; return name; @@ -145,7 +145,7 @@ static rbool smatch(char c, const char *matchset) { static int find_path_sep(const char *name) { int i; - if (path_sep == NULL) + if (path_sep == nullptr) return -1; for (i = strlen(name) - 1; i >= 0; i--) if (smatch(name[i], path_sep)) break; @@ -201,7 +201,7 @@ static char *extract_piece(const char *name, int extlen, rbool isext) { len = xlen; xlen = tmp; } - if (len == 0) return NULL; + if (len == 0) return nullptr; root = (char *)rmalloc((len + 1) * sizeof(char)); #ifdef PREFIX_EXT first = isext ? 1 : 0; @@ -293,7 +293,7 @@ fc_type init_file_context(const char *name, filetype ft) { p = find_path_sep(fc->gamename); if (p < 0) - fc->path = NULL; + fc->path = nullptr; else { fc->path = (char *)rmalloc((p + 2) * sizeof(char)); memcpy(fc->path, fc->gamename, p + 1); @@ -330,12 +330,12 @@ fc_type convert_file_context(fc_type fc, filetype ft, const char *name) { local_ftype = (ft == fSAV || ft == fSCR || ft == fLOG); if (BATCH_MODE || make_test) local_ftype = 0; - if (name == NULL) { + if (name == nullptr) { nfc = (file_context_rec *)rmalloc(sizeof(file_context_rec)); - nfc->gamename = NULL; - nfc->path = NULL; + nfc->gamename = nullptr; + nfc->path = nullptr; nfc->shortname = rstrdup(fc->shortname); - nfc->ext = NULL; + nfc->ext = nullptr; nfc->ft = fNONE; nfc->special = 0; } else { @@ -343,7 +343,7 @@ fc_type convert_file_context(fc_type fc, filetype ft, const char *name) { } /* If path already defined, then combine paths. */ - if (!local_ftype && nfc->path != NULL && !absolute_path(nfc->path)) { + if (!local_ftype && nfc->path != nullptr && !absolute_path(nfc->path)) { char *newpath; newpath = nfc->path; newpath = assemble_filename(fc->path, nfc->path, ""); @@ -353,7 +353,7 @@ fc_type convert_file_context(fc_type fc, filetype ft, const char *name) { /* scripts, save-games and logs should go in the working directory, not the game directory, so leave nfc->path equal to NULL for them. */ - if (!local_ftype && nfc->path == NULL) + if (!local_ftype && nfc->path == nullptr) nfc->path = rstrdup(fc->path); /* Put files in game directory */ return nfc; } @@ -387,7 +387,7 @@ static genfile try_open_file(const char *path, const char *root, static genfile findread(file_context_rec *fc, filetype ft) { genfile f; - f = NULL; + f = nullptr; if (ft == fAGT_STD) { f = try_open_file(fc->path, AGTpSTD, "", filetype_info(ft, 0), 0); @@ -395,7 +395,7 @@ static genfile findread(file_context_rec *fc, filetype ft) { } if (ft == fAGX || ft == fNONE) /* Try opening w/o added extension */ f = try_open_file(fc->path, fc->shortname, fc->ext, filetype_info(ft, 0), 0); - if (f == NULL) + if (f == nullptr) f = try_open_file(fc->path, fc->shortname, extname[ft], filetype_info(ft, 0), 0); return f; } @@ -408,9 +408,9 @@ static genfile findread(file_context_rec *fc, filetype ft) { genfile readopen(fc_type fc, filetype ft, const char **errstr) { genfile f; - *errstr = NULL; + *errstr = nullptr; f = findread(fc, ft); - if (f == NULL) { + if (f == nullptr) { *errstr = "Cannot open file"; } return f; @@ -421,7 +421,7 @@ rbool fileexist(fc_type fc, filetype ft) { if (fc->special) return 0; f = try_open_file(fc->path, fc->shortname, extname[ft], filetype_info(ft, 0), 1); - if (f != NULL) { /* File already exists */ + if (f != nullptr) { /* File already exists */ readclose(f); return 1; } @@ -434,17 +434,17 @@ genfile writeopen(fc_type fc, filetype ft, char *name; genfile f; - *errstr = NULL; - name = NULL; + *errstr = nullptr; + name = nullptr; { name = assemble_filename(FC(fc)->path, FC(fc)->shortname, extname[ft]); f = fopen(name, filetype_info(ft, 1)); } - if (f == NULL) { + if (f == nullptr) { *errstr = "Cannot open file"; } - if (pfileid == NULL) + if (pfileid == nullptr) rfree(name); else *pfileid = name; @@ -453,7 +453,7 @@ genfile writeopen(fc_type fc, filetype ft, rbool filevalid(genfile f, filetype ft) { - return (f != NULL); + return (f != nullptr); } @@ -470,8 +470,8 @@ void binseek(genfile f, long offset) { long varread(genfile f, void *buff, long recsize, long recnum, const char **errstr) { long num; - *errstr = NULL; - assert(f != NULL); + *errstr = nullptr; + assert(f != nullptr); num = fread(buff, recsize, recnum, f); if (num != recnum) @@ -485,14 +485,14 @@ rbool binread(genfile f, void *buff, long recsize, long recnum, const char **err long num; num = varread(f, buff, recsize, recnum, errstr); - if (num < recsize * recnum && *errstr == NULL) + if (num < recsize * recnum && *errstr == nullptr) *errstr = rstrdup("Unexpected end of file."); - return (*errstr == NULL); + return (*errstr == nullptr); } rbool binwrite(genfile f, void *buff, long recsize, long recnum, rbool ferr) { - assert(f != NULL); + assert(f != nullptr); if (fwrite(buff, recsize, recnum, f) != (size_t)recnum) { if (ferr) fatal("binwrite"); @@ -502,13 +502,13 @@ rbool binwrite(genfile f, void *buff, long recsize, long recnum, rbool ferr) { } void readclose(genfile f) { - assert(f != NULL); + assert(f != nullptr); fclose(f); } void writeclose(genfile f, file_id_type fileid) { - assert(f != NULL); + assert(f != nullptr); rfree(fileid); fclose(f); @@ -519,7 +519,7 @@ long binsize(genfile f) { long pos, leng; - assert(f != NULL); + assert(f != nullptr); pos = ftell(f); fseek(f, 0, SEEK_END); @@ -538,7 +538,7 @@ rbool textrewind(genfile f) { genfile badfile(filetype ft) { - return NULL; + return nullptr; } } // End of namespace AGT diff --git a/engines/glk/agt/gamedata.cpp b/engines/glk/agt/gamedata.cpp index 3627a30cea2..033070d88b3 100644 --- a/engines/glk/agt/gamedata.cpp +++ b/engines/glk/agt/gamedata.cpp @@ -698,7 +698,7 @@ static void init0_dict(void) dictstrptr = 4; /* Point just after 'any' */ dictstrsize = DICT_GRAN; dp = 1; - syntbl = NULL; + syntbl = nullptr; synptr = 0; syntbl_size = 0; /* Clear synonym table */ } @@ -806,15 +806,15 @@ static void enter_verbs(int vp, const char *s) void init_dict(void) { - dict = NULL; - verblist = NULL; - syntbl = NULL; + dict = nullptr; + verblist = nullptr; + syntbl = nullptr; no_syn = 0; - auxsyn = NULL; - preplist = NULL; - verbflag = NULL; - auxcomb = NULL; - old_agt_verb = NULL; + auxsyn = nullptr; + preplist = nullptr; + verbflag = nullptr; + auxcomb = nullptr; + old_agt_verb = nullptr; num_auxcomb = 0; } @@ -865,7 +865,7 @@ void reinit_dict(void) no_syn = no_auxsyn; auxsyn = (slist *)rmalloc(sizeof(slist) * TOTAL_VERB); - auxcomb = NULL; + auxcomb = nullptr; num_auxcomb = 0; preplist = (slist *)rmalloc(sizeof(slist) * TOTAL_VERB); verbflag = (uchar *)rmalloc(sizeof(uchar) * TOTAL_VERB); @@ -899,13 +899,13 @@ void reinit_dict(void) addsyn(-1); } no_syn = 0; /* Return to usual state */ - verblist = NULL; + verblist = nullptr; /* Now initialize old_agt_verb array */ - for (i = 0; old_agt_verb_str[i] != NULL; i++); + for (i = 0; old_agt_verb_str[i] != nullptr; i++); rfree(old_agt_verb); old_agt_verb = (word *)rmalloc(sizeof(word) * (i + 1)); - for (i = 0; old_agt_verb_str[i] != NULL; i++) { + for (i = 0; old_agt_verb_str[i] != nullptr; i++) { old_agt_verb[i] = search_dict(old_agt_verb_str[i]); assert(old_agt_verb[i] != -1); } @@ -1346,8 +1346,8 @@ descr_line *read_descr(long start, long size) { } void free_descr(descr_line *txt) { - if (txt == NULL) return; - if (mem_descr == NULL) + if (txt == nullptr) return; + if (mem_descr == nullptr) rfree(txt[0]); /* First free the string block containing the text...*/ rfree(txt); /* ... then the array of pointers to it */ } @@ -1571,9 +1571,9 @@ void init_flags(void) { bold_mode = 0; dbg_nomsg = 0; /* Print out MSG arguments to metacommands */ debug_mode = 0; - dbgflagptr = NULL; - dbgvarptr = NULL; - dbgcntptr = NULL; + dbgflagptr = nullptr; + dbgvarptr = nullptr; + dbgcntptr = nullptr; no_auxsyn = 0; text_file = 0; #ifdef PATH_SEP diff --git a/engines/glk/agt/interface.cpp b/engines/glk/agt/interface.cpp index 9eb3e4e218e..b2a38cba207 100644 --- a/engines/glk/agt/interface.cpp +++ b/engines/glk/agt/interface.cpp @@ -630,7 +630,7 @@ void prompt_out(int n) if (PURE_INPUT && n == 1) agt_textcolor(-1); if (n == 1) { agt_newline(); - gen_sysmsg(1, ">", MSG_MAIN, NULL); + gen_sysmsg(1, ">", MSG_MAIN, nullptr); } if (n == 2) agt_puts("? "); agt_textcolor(7); @@ -672,23 +672,23 @@ void set_test_mode(fc_type fc) { log_in = readopen(fc, fLOG, &errstr); if (make_test) { - if (errstr == NULL) + if (errstr == nullptr) fatal("Log file already exists."); - log_out = writeopen(fc, fLOG, NULL, &errstr); - if (errstr != NULL) + log_out = writeopen(fc, fLOG, nullptr, &errstr); + if (errstr != nullptr) fatal("Couldn't create log file."); logflag = 1; return; } logdelay = 0; - if (errstr != NULL) + if (errstr != nullptr) fatal("Couldn't open log file."); logflag = 2; script_on = 1; - scriptfile = writeopen(fc, fSCR, NULL, &errstr); - if (errstr != NULL) + scriptfile = writeopen(fc, fSCR, nullptr, &errstr); + if (errstr != nullptr) fatal("Couldn't open script file."); } diff --git a/engines/glk/agt/metacommand.cpp b/engines/glk/agt/metacommand.cpp index 16de023bbf6..cc1f5ed971f 100644 --- a/engines/glk/agt/metacommand.cpp +++ b/engines/glk/agt/metacommand.cpp @@ -217,7 +217,7 @@ static int decode_instr(op_rec *oprec, const integer *data, int maxleng) { rbool special_arg1; /* Is the first argument a special 0-length argument? */ oprec->negate = oprec->failmsg = oprec->disambig = 0; - oprec->errmsg = NULL; + oprec->errmsg = nullptr; oprec->op = -1; oprec->opdata = &illegal_def; oprec->argcnt = 0; @@ -336,7 +336,7 @@ static int decode_instr(op_rec *oprec, const integer *data, int maxleng) { static rbool decode_args(int ip_, op_rec *oprec) { rbool grammer_arg; /* Have NOUN/OBJECT that is 0 and so failed argok tests */ - if (oprec->errmsg != NULL) { + if (oprec->errmsg != nullptr) { if (!PURE_ERROR) writeln(oprec->errmsg); return 0; @@ -412,7 +412,7 @@ typedef struct { } subcall_rec; -static subcall_rec *substack = NULL; +static subcall_rec *substack = nullptr; static short subcnt = 0; static short subsize = 0; @@ -428,7 +428,7 @@ static rbool push_subcall(int cnum, int ip_, int failaddr) { rm_trap = 0; substack = (subcall_rec *)rrealloc(substack, subsize * sizeof(subcall_rec)); rm_trap = 1; - if (substack == NULL) { /* out of memory */ + if (substack == nullptr) { /* out of memory */ substack = savestack; return 0; } @@ -748,7 +748,7 @@ static rbool fix_objrec(parse_rec **objrec, word match, int real_obj, parse_rec *actrec, parse_rec *dobjrec, parse_rec *iobjrec) { - if (real_obj) *objrec = make_parserec(real_obj, NULL); + if (real_obj) *objrec = make_parserec(real_obj, nullptr); else if (match == ext_code[wdobject]) *objrec = copy_parserec(iobjrec); else if (match == ext_code[wdnoun]) *objrec = copy_parserec(dobjrec); else if (match == ext_code[wdname]) *objrec = copy_parserec(actrec); @@ -957,7 +957,7 @@ static void scan_for_actor(integer m_actor, int *start, int *end) { assert(m_actor != 0); if (aver >= AGX00) { - if (start != NULL) *start = verbptr[DIR_ADDR_CODE]; + if (start != nullptr) *start = verbptr[DIR_ADDR_CODE]; *end = verbend[DIR_ADDR_CODE]; return; } @@ -969,7 +969,7 @@ static void scan_for_actor(integer m_actor, int *start, int *end) { } *end = i; - if (start == NULL) return; + if (start == nullptr) return; for (i = verbptr[DIR_ADDR_CODE]; i <= *end; i++) if (creat_fix[command[i].actor - first_creat] @@ -1071,7 +1071,7 @@ int scan_metacommand(integer m_actor, int vcode, /* REDIRECT :If we do a redirect from a broader grammar to a narrower grammer, it will be noted so that certain types of grammer checking can be disabled. */ - if (redir_flag != NULL) { + if (redir_flag != nullptr) { if (*redir_flag < 2 && redir_narrows_grammar(&command[oldi], &command[i])) *redir_flag = 2; @@ -1134,7 +1134,7 @@ int scan_metacommand(integer m_actor, int vcode, if (m_actor == 0) scanend = verbend[vcode]; else - scan_for_actor(m_actor, NULL, &scanend); + scan_for_actor(m_actor, nullptr, &scanend); m_verb = syntbl[auxsyn[vcode]]; i--; /* Cause the last command to restart, diff --git a/engines/glk/agt/object.cpp b/engines/glk/agt/object.cpp index bc38354d66a..9540bc1a676 100644 --- a/engines/glk/agt/object.cpp +++ b/engines/glk/agt/object.cpp @@ -38,7 +38,7 @@ namespace AGT { /* Make artificial parse record for an object */ parse_rec *make_parserec(int obj, parse_rec *rec) { - if (rec == NULL) rec = (parse_rec *)rmalloc(sizeof(parse_rec)); + if (rec == nullptr) rec = (parse_rec *)rmalloc(sizeof(parse_rec)); rec->obj = obj; rec->info = D_NOUN; rec->noun = it_name(obj); @@ -57,7 +57,7 @@ void tmpobj(parse_rec *objrec) { parse_rec *copy_parserec(parse_rec *rec) { parse_rec *newrec; - if (rec == NULL) return NULL; + if (rec == nullptr) return nullptr; newrec = (parse_rec *)rmalloc(sizeof(parse_rec)); memcpy(newrec, rec, sizeof(parse_rec)); return newrec; @@ -91,7 +91,7 @@ static const char *it_sdesc(int item) { if (tnoun(item)) return noun[item - first_noun].shortdesc; if (tcreat(item)) return creature[item - first_creat].shortdesc; if (item < 0) return dict[-item]; - return NULL; + return nullptr; } rbool it_possess(int item) { @@ -254,7 +254,7 @@ void it_reposition(int item, int newloc, rbool save_pos) { noun[item - first_noun].pos_prep = 0; noun[item - first_noun].pos_name = 0; noun[item - first_noun].nearby_noun = 0; - noun[item - first_noun].position = NULL; + noun[item - first_noun].position = nullptr; #if 0 /* I think this was wrong, so I'm commenting it out. */ noun[item - first_noun].initdesc = 0; #endif @@ -283,7 +283,7 @@ void it_reposition(int item, int newloc, rbool save_pos) { noun[i].nearby_noun = 0; noun[i].pos_prep = 0; noun[i].pos_name = 0; - noun[i].position = NULL; + noun[i].position = nullptr; } } @@ -776,7 +776,7 @@ static void rundesc(int i, descr_ptr dp_[], const char *shortdesc, int msgid) { if (dp_[i].size > 0) print_descr(dp_[i], 1); else if (!invischeck(shortdesc)) - raw_lineout(shortdesc, 1, MSG_DESC, NULL); + raw_lineout(shortdesc, 1, MSG_DESC, nullptr); else sysmsg(msgid, "$You$ see nothing unexpected."); } @@ -840,7 +840,7 @@ static int print_obj(int obj, int ind_lev) if (tcreat(obj) && creature[obj - first_creat].initdesc != 0) return 0; /* Don't print normal description if printing initdesc */ - s0 = NULL; + s0 = nullptr; sdesc_flag = !player_has(obj); /* This should be tested. */ sdesc_flag = sdesc_flag || (ind_lev > 1); /* It seems that AGT uses the sdesc for describing items @@ -868,7 +868,7 @@ static int print_obj(int obj, int ind_lev) } else if (!invischeck(s)) { retval = 1; /* We're actually going to print something */ for (i = 0; i < ind_lev; i++) writestr(" "); - raw_lineout(s, sdesc_flag, MSG_DESC, NULL); + raw_lineout(s, sdesc_flag, MSG_DESC, nullptr); /* Do $word$ formatting if sdesc */ /* Need to output container */ parent = it_loc(obj); @@ -950,10 +950,10 @@ static void *compute_addr(int obj, int prop, const prop_struct *ptable) { } else if (tcreat(obj)) { base = (void *)(&creature[obj - first_creat]); ofs = ptable[prop].creature; - } else return NULL; + } else return nullptr; if (ofs == -1) /* Field doesn't exist in this type of object */ - return NULL; + return nullptr; return (void *)(((char *)base) + ofs); } @@ -964,7 +964,7 @@ long getprop(int obj, int prop) { if (prop >= NUM_PROP) return 0; paddr = (integer *)compute_addr(obj, prop, proplist); - if (paddr == NULL) return 0; + if (paddr == nullptr) return 0; return *paddr; } @@ -977,7 +977,7 @@ void setprop(int obj, int prop, long val) { } paddr = (integer *)compute_addr(obj, prop, proplist); - if (paddr == NULL) { + if (paddr == nullptr) { writeln("GAME ERROR: Property-object mismatch."); return; } @@ -989,7 +989,7 @@ rbool getattr(int obj, int prop) { if (prop >= NUM_ATTR) return 0; paddr = (rbool *)compute_addr(obj, prop, attrlist); - if (paddr == NULL) return 0; + if (paddr == nullptr) return 0; return *paddr; } @@ -1002,7 +1002,7 @@ void setattr(int obj, int prop, rbool val) { } paddr = (rbool *)compute_addr(obj, prop, attrlist); - if (paddr == NULL) { + if (paddr == nullptr) { writeln("GAME ERROR: Property-object mismatch."); return; } diff --git a/engines/glk/agt/os_glk.cpp b/engines/glk/agt/os_glk.cpp index 157a7ba378e..9fb168d8971 100644 --- a/engines/glk/agt/os_glk.cpp +++ b/engines/glk/agt/os_glk.cpp @@ -102,7 +102,7 @@ static void gagt_fatal(const char *string) { error("INTERNAL ERROR: %s", string); /* Cancel all possible pending window input events. */ - g_vm->glk_cancel_line_event(g_vm->gagt_main_window, NULL); + g_vm->glk_cancel_line_event(g_vm->gagt_main_window, nullptr); g_vm->glk_cancel_char_event(g_vm->gagt_main_window); /* Print a message indicating the error. */ @@ -265,7 +265,7 @@ int agt_rand(int a, int b) { */ static void gagt_workround_menus() { free(verbmenu); - verbmenu = NULL; + verbmenu = nullptr; menu_mode = 0; } @@ -286,7 +286,7 @@ static int gagt_workround_fileexist(fc_type fc, filetype ft) { genfile file; const char *errstr; - errstr = NULL; + errstr = nullptr; file = readopen(fc, ft, &errstr); if (file) { @@ -660,8 +660,8 @@ static void gagt_iso_to_cp(const unsigned char *from_string, unsigned char *to_s * that don't support separate windows. We also need a copy of the last * status buffer printed for non-windowing Glk libraries, for comparison. */ -static char *gagt_status_buffer = NULL, - *gagt_status_buffer_printed = NULL; +static char *gagt_status_buffer = nullptr, + *gagt_status_buffer_printed = nullptr; /* * Indication that we are in mid-delay. The delay is silent, and can look @@ -892,7 +892,7 @@ static void gagt_status_redraw() { parent = g_vm->glk_window_get_parent(g_vm->gagt_status_window); g_vm->glk_window_set_arrangement(parent, winmethod_Above | winmethod_Fixed, - height, NULL); + height, nullptr); gagt_status_update(); } @@ -929,10 +929,10 @@ static void gagt_status_in_delay(int inside_delay) { */ static void gagt_status_cleanup() { free(gagt_status_buffer); - gagt_status_buffer = NULL; + gagt_status_buffer = nullptr; free(gagt_status_buffer_printed); - gagt_status_buffer_printed = NULL; + gagt_status_buffer_printed = nullptr; } @@ -1437,14 +1437,14 @@ struct gagt_line_s { * Definition of the actual page buffer. This is a doubly-linked list of * lines, with a tail pointer to facilitate adding entries at the end. */ -static gagt_lineref_t gagt_page_head = NULL, - gagt_page_tail = NULL; +static gagt_lineref_t gagt_page_head = nullptr, + gagt_page_tail = nullptr; /* * Definition of the current output line; this one is appended to on * agt_puts(), and transferred into the page buffer on agt_newline(). */ -static gagt_string_t gagt_current_buffer = { NULL, NULL, 0, 0 }; +static gagt_string_t gagt_current_buffer = { nullptr, nullptr, 0, 0 }; /* * gagt_string_append() @@ -1481,14 +1481,14 @@ static void gagt_string_append(gagt_stringref_t buffer, const char *string, static void gagt_string_transfer(gagt_stringref_t from, gagt_stringref_t to) { *to = *from; - from->data = from->attributes = NULL; + from->data = from->attributes = nullptr; from->allocation = from->length = 0; } static void gagt_string_free(gagt_stringref_t buffer) { free(buffer->data); free(buffer->attributes); - buffer->data = buffer->attributes = NULL; + buffer->data = buffer->attributes = nullptr; buffer->allocation = buffer->length = 0; } @@ -1579,7 +1579,7 @@ static void gagt_output_delete() { free(line); } - gagt_page_head = gagt_page_tail = NULL; + gagt_page_head = gagt_page_tail = nullptr; gagt_string_free(&gagt_current_buffer); } @@ -1651,11 +1651,11 @@ void agt_newline() { line->is_hyphenated = gagt_is_string_hyphenated(&line->buffer); /* For now, default the remaining page buffer fields for the line. */ - line->paragraph = NULL; + line->paragraph = nullptr; line->font_hint = HINT_NONE; /* Add to the list, creating a new list if necessary. */ - line->next = NULL; + line->next = nullptr; line->prior = gagt_page_tail; if (gagt_page_head) gagt_page_tail->next = line; @@ -1740,8 +1740,8 @@ struct gagt_paragraph_s { * A doubly-linked list of paragraphs, with a tail pointer to facilitate * adding entries at the end. */ -static gagt_paragraphref_t gagt_paragraphs_head = NULL, - gagt_paragraphs_tail = NULL; +static gagt_paragraphref_t gagt_paragraphs_head = nullptr, + gagt_paragraphs_tail = nullptr; /* * gagt_paragraphs_delete() @@ -1760,7 +1760,7 @@ static void gagt_paragraphs_delete() { free(paragraph); } - gagt_paragraphs_head = gagt_paragraphs_tail = NULL; + gagt_paragraphs_head = gagt_paragraphs_tail = nullptr; } @@ -1777,7 +1777,7 @@ static gagt_lineref_t gagt_find_paragraph_start(const gagt_lineref_t begin) { * Advance line to the beginning of the next paragraph, stopping on the * first non-blank line, or at the end of the page buffer. */ - match = NULL; + match = nullptr; for (line = begin; line; line = gagt_get_next_page_line(line)) { if (!line->is_blank) { match = line; @@ -1959,12 +1959,12 @@ static void gagt_paragraph_page() { paragraph = (gagt_paragraphref_t)gagt_malloc(sizeof(*paragraph)); paragraph->magic = GAGT_PARAGRAPH_MAGIC; paragraph->first_line = start; - paragraph->special = NULL; + paragraph->special = nullptr; paragraph->line_count = 1; paragraph->id = gagt_paragraphs_tail ? gagt_paragraphs_tail->id + 1 : 0; /* Add to the list, creating a new list if necessary. */ - paragraph->next = NULL; + paragraph->next = nullptr; paragraph->prior = gagt_paragraphs_tail; if (gagt_paragraphs_head) gagt_paragraphs_tail->next = paragraph; @@ -1994,7 +1994,7 @@ static void gagt_paragraph_page() { if (line) start = gagt_find_paragraph_start(line); else - start = NULL; + start = nullptr; } } @@ -2052,7 +2052,7 @@ static gagt_lineref_t gagt_get_next_paragraph_line(const gagt_lineref_t line) { if (next_line && next_line->paragraph == line->paragraph) return next_line; else - return NULL; + return nullptr; } static gagt_lineref_t gagt_get_prior_paragraph_line(const gagt_lineref_t line) { @@ -2063,7 +2063,7 @@ static gagt_lineref_t gagt_get_prior_paragraph_line(const gagt_lineref_t line) { if (prior_line && prior_line->paragraph == line->paragraph) return prior_line; else - return NULL; + return nullptr; } @@ -2708,7 +2708,7 @@ static gagt_special_t GAGT_SPECIALS[] = { }, /* End of table sentinel entry. Do not delete. */ - {0, {NULL}, NULL} + {0, {nullptr}, nullptr} }; @@ -2767,7 +2767,7 @@ static gagt_specialref_t gagt_find_equivalent_special(gagt_paragraphref_t paragr gagt_specialref_t special, match; /* Check each special paragraph entry for a match against this paragraph. */ - match = NULL; + match = nullptr; for (special = GAGT_SPECIALS; special->replace; special++) { if (gagt_compare_special_paragraph(special, paragraph)) { match = special; @@ -3700,10 +3700,10 @@ static void gagt_command_script(const char *argument) { return; } - g_vm->glk_stream_close(g_vm->gagt_transcript_stream, NULL); - g_vm->gagt_transcript_stream = NULL; + g_vm->glk_stream_close(g_vm->gagt_transcript_stream, nullptr); + g_vm->gagt_transcript_stream = nullptr; - g_vm->glk_window_set_echo_stream(g_vm->gagt_main_window, NULL); + g_vm->glk_window_set_echo_stream(g_vm->gagt_main_window, nullptr); gagt_normal_string("Glk transcript is now off.\n"); } @@ -3765,8 +3765,8 @@ static void gagt_command_inputlog(const char *argument) { return; } - g_vm->glk_stream_close(g_vm->gagt_inputlog_stream, NULL); - g_vm->gagt_inputlog_stream = NULL; + g_vm->glk_stream_close(g_vm->gagt_inputlog_stream, nullptr); + g_vm->gagt_inputlog_stream = nullptr; gagt_normal_string("Glk input log is now off.\n"); } @@ -3833,8 +3833,8 @@ static void gagt_command_readlog(const char *argument) { return; } - g_vm->glk_stream_close(g_vm->gagt_readlog_stream, NULL); - g_vm->gagt_readlog_stream = NULL; + g_vm->glk_stream_close(g_vm->gagt_readlog_stream, nullptr); + g_vm->gagt_readlog_stream = nullptr; gagt_normal_string("Glk read log is now off.\n"); } @@ -4170,7 +4170,7 @@ static void gagt_command_statusline(const char *argument) { /* Expand the status window down to a second line. */ g_vm->glk_window_set_arrangement(g_vm->glk_window_get_parent(g_vm->gagt_status_window), - winmethod_Above | winmethod_Fixed, 2, NULL); + winmethod_Above | winmethod_Fixed, 2, nullptr); g_vm->gagt_extended_status_enabled = TRUE; gagt_normal_string("Glk status line mode is now 'extended'.\n"); @@ -4185,7 +4185,7 @@ static void gagt_command_statusline(const char *argument) { /* Shrink the status window down to one line. */ g_vm->glk_window_set_arrangement(g_vm->glk_window_get_parent(g_vm->gagt_status_window), - winmethod_Above | winmethod_Fixed, 1, NULL); + winmethod_Above | winmethod_Fixed, 1, nullptr); g_vm->gagt_extended_status_enabled = FALSE; gagt_normal_string("Glk status line mode is now 'short'.\n"); @@ -4294,7 +4294,7 @@ static gagt_command_t GAGT_COMMAND_TABLE[] = { {"version", gagt_command_version, FALSE}, {"commands", gagt_command_commands, TRUE}, {"help", gagt_command_help, TRUE}, - {NULL, NULL, FALSE} + {nullptr, nullptr, FALSE} }; @@ -4349,7 +4349,7 @@ static void gagt_command_help(const char *cmd) { return; } - matched = NULL; + matched = nullptr; for (entry = GAGT_COMMAND_TABLE; entry->command; entry++) { if (gagt_strncasecmp(cmd, entry->command, strlen(cmd)) == 0) { if (matched) { @@ -4560,7 +4560,7 @@ static int gagt_command_escape(const char *string) { * the cmd passed in. */ matches = 0; - matched = NULL; + matched = nullptr; for (entry = GAGT_COMMAND_TABLE; entry->command; entry++) { if (gagt_strncasecmp(cmd, entry->command, strlen(cmd)) == 0) { matches++; @@ -4620,7 +4620,7 @@ static gagt_abbreviation_t GAGT_ABBREVIATIONS[] = { {'k', "attack"}, {'l', "look"}, {'p', "open"}, {'q', "quit"}, {'r', "drop"}, {'t', "take"}, {'x', "examine"}, {'y', "yes"}, {'z', "wait"}, - {'\0', NULL} + {'\0', nullptr} }; @@ -4644,7 +4644,7 @@ static void gagt_expand_abbreviations(char *buffer, int size) { /* Scan the abbreviations table for a match. */ abbreviation = g_vm->glk_char_to_lower((unsigned char) command_[0]); - expansion = NULL; + expansion = nullptr; for (entry = GAGT_ABBREVIATIONS; entry->expansion; entry++) { if (entry->abbreviation == abbreviation) { expansion = entry->expansion; @@ -4736,8 +4736,8 @@ char *agt_input(int in_type) { * We're at the end of the log stream. Close it, and then continue * on to request a line from Glk. */ - g_vm->glk_stream_close(g_vm->gagt_readlog_stream, NULL); - g_vm->gagt_readlog_stream = NULL; + g_vm->glk_stream_close(g_vm->gagt_readlog_stream, nullptr); + g_vm->gagt_readlog_stream = nullptr; } /* Set this up as a read buffer for the main window, and wait. */ @@ -4884,8 +4884,8 @@ char agt_getkey(rbool echo_char) { * We're at the end of the log stream. Close it, and then continue * on to request a character from Glk. */ - g_vm->glk_stream_close(g_vm->gagt_readlog_stream, NULL); - g_vm->gagt_readlog_stream = NULL; + g_vm->glk_stream_close(g_vm->gagt_readlog_stream, nullptr); + g_vm->gagt_readlog_stream = nullptr; } /* @@ -5063,7 +5063,7 @@ void init_interface() { * If it fails, we'll return, and the caller can detect this by looking * for a NULL main window. */ - g_vm->gagt_main_window = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + g_vm->gagt_main_window = g_vm->glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 0); if (!g_vm->gagt_main_window) return; @@ -5544,7 +5544,7 @@ static void gagt_main() { if (!(gagt_workround_fileexist(fc, fAGX) || gagt_workround_fileexist(fc, fDA1))) { if (g_vm->gagt_status_window) - g_vm->glk_window_close(g_vm->gagt_status_window, NULL); + g_vm->glk_window_close(g_vm->gagt_status_window, nullptr); gagt_header_string("Glk AGiliTy Error\n\n"); gagt_normal_string("Can't find or open game '"); gagt_normal_string(g_vm->gagt_gamefile); @@ -5574,16 +5574,16 @@ static void gagt_main() { /* Close any open transcript, input log, and/or read log. */ if (g_vm->gagt_transcript_stream) { - g_vm->glk_stream_close(g_vm->gagt_transcript_stream, NULL); - g_vm->gagt_transcript_stream = NULL; + g_vm->glk_stream_close(g_vm->gagt_transcript_stream, nullptr); + g_vm->gagt_transcript_stream = nullptr; } if (g_vm->gagt_inputlog_stream) { - g_vm->glk_stream_close(g_vm->gagt_inputlog_stream, NULL); - g_vm->gagt_inputlog_stream = NULL; + g_vm->glk_stream_close(g_vm->gagt_inputlog_stream, nullptr); + g_vm->gagt_inputlog_stream = nullptr; } if (g_vm->gagt_readlog_stream) { - g_vm->glk_stream_close(g_vm->gagt_readlog_stream, NULL); - g_vm->gagt_readlog_stream = NULL; + g_vm->glk_stream_close(g_vm->gagt_readlog_stream, nullptr); + g_vm->gagt_readlog_stream = nullptr; } } @@ -5679,7 +5679,7 @@ void gagt_finalizer() { */ if (g_vm->gagt_main_window) { g_vm->glk_cancel_char_event(g_vm->gagt_main_window); - g_vm->glk_cancel_line_event(g_vm->gagt_main_window, NULL); + g_vm->glk_cancel_line_event(g_vm->gagt_main_window, nullptr); g_vm->glk_set_style(style_Alert); g_vm->glk_put_string("\n\nHit any key to exit.\n"); diff --git a/engines/glk/agt/parser.cpp b/engines/glk/agt/parser.cpp index cb873660044..f2cb355108e 100644 --- a/engines/glk/agt/parser.cpp +++ b/engines/glk/agt/parser.cpp @@ -57,7 +57,7 @@ int ip_back, parse_ip; static int vnum; /* Verb number from synonym scan */ /* Pointers to negative-terminated arrays of possible nouns */ -static parse_rec *lactor = NULL, *lobj = NULL, *lnoun = NULL; +static parse_rec *lactor = nullptr, *lobj = nullptr, *lnoun = nullptr; static int ambig_flag = 0; /* Was last input ambiguous? (so player could be entering @@ -81,7 +81,7 @@ int all_err_msg[] = {73, 83, 113, 103, /* open, close, lock, unlock: 15 - 18 */ static void freeall(void) { rfree(lnoun); rfree(lobj); - lnoun = lobj = NULL; + lnoun = lobj = nullptr; } @@ -546,7 +546,7 @@ static rbool ident_objrec(parse_rec *p1, parse_rec *p2) { static parse_rec *fix_actor(parse_rec *alist) { int i, cnt; - assert(alist != NULL); + assert(alist != nullptr); if (alist[0].info == D_ALL) { /* ALL?! */ rfree(alist); return new_list(); @@ -644,7 +644,7 @@ static int score_disambig(parse_rec *rec, int ambig_type) if (ambig_type == 1) /* ACTOR */ return DISAMBIG_SUCC; else if (ambig_type == 2) /* NOUN */ - return check_obj(lactor, vnum, rec, prep, NULL); + return check_obj(lactor, vnum, rec, prep, nullptr); else if (ambig_type == 3) /* IOBJ */ return check_obj(lactor, vnum, lnoun, prep, rec); else fatal("Invalid ambig_type!"); @@ -674,7 +674,7 @@ static parse_rec *expand_all(parse_rec *lnoun_) { creature[i].scratch = 0; objloop(i) if (((verbflag[vnum]&VERB_GLOBAL) != 0 || visible(i)) - && (lnoun_ == NULL || !scan_andrec(i, lnoun_))) { + && (lnoun_ == nullptr || !scan_andrec(i, lnoun_))) { temp_obj.obj = i; if (score_disambig(&temp_obj, 2) >= 500) { if (tnoun(i)) noun[i - first_noun].scratch = 1; @@ -950,7 +950,7 @@ static parse_rec *disambig(int ambig_set, parse_rec *list, parse_rec *truenoun) /* ambig_set = 1 for actor, 2 for noun, 3 for object */ { if (ambig_flag == ambig_set || ambig_flag == 0) { /* restart where we left off...*/ - if (truenoun == NULL || truenoun[0].info == D_END) disambig_ofs = -1; + if (truenoun == nullptr || truenoun[0].info == D_END) disambig_ofs = -1; disambig_ofs = disambig_phrase(&list, truenoun, disambig_ofs, ambig_set); if (disambig_ofs == -1) ambig_flag = 0; /* Success */ else if (disambig_ofs == -2) ambig_flag = -1; /* Error: elim all choices */ @@ -1085,7 +1085,7 @@ static parse_rec *parse_a_noun(void) nlist = add_rec(nlist, -input[oip], numval, D_NUM); /* Next handle the flag nouns and global nouns */ - if (globalnoun != NULL) + if (globalnoun != nullptr) for (i = 0; i < numglobal; i++) if (input[oip] == globalnoun[i]) nlist = add_rec(nlist, -input[oip], 0, D_GLOBAL); @@ -1191,7 +1191,7 @@ static int parse_cmd(void) /* First go looking for an actor. */ ap = ip; new_actor = 0; - if (lactor == NULL) { + if (lactor == nullptr) { new_actor = 1; lactor = parse_noun(0, 1); /* Check that actor is a creature. */ @@ -1252,7 +1252,7 @@ TELLHack: /* This is used to restart the noun/prep/object scan rfree(lactor); rfree(lobj); lactor = lnoun; - lnoun = NULL; + lnoun = nullptr; vp = ip; /* Replace TELL with new verb */ vnum = id_verb(); /* May increment ip (ip points att last word in verb) */ goto TELLHack; /* Go back up and reparse the sentence from @@ -1327,7 +1327,7 @@ TELLHack: /* This is used to restart the noun/prep/object scan static void v_undo(void) { - if (undo_state == NULL) { + if (undo_state == nullptr) { writeln("There is insufficiant memory to support UNDO"); ip = -1; return; @@ -1356,7 +1356,7 @@ rbool parse(void) int fixword; int start_ip; - currnoun = NULL; + currnoun = nullptr; start_ip = ip; /* First, we need to see if someone has issued an OOPS command. OOPS commands are always assumed to stand alone. (i.e. no @@ -1388,7 +1388,7 @@ rbool parse(void) ambig_flag = 0; rfree(currnoun); freeall(); - currnoun = NULL; + currnoun = nullptr; } } @@ -1450,7 +1450,7 @@ rbool parse(void) we save the undo state before executing if this is the first command in a sequence. (That is, UNDO undoes whole lines of commands, not just individual commands) */ - if (start_ip == 0 && undo_state != NULL) { + if (start_ip == 0 && undo_state != nullptr) { undo_state = getstate(undo_state); can_undo = 1; } @@ -1465,7 +1465,7 @@ rbool parse(void) /* Now we clear lnoun and lobj; lactor is handled elsewhere since we might have FRED, GET ROCK THEN GO NORTH */ - lnoun = lobj = NULL; + lnoun = lobj = nullptr; /* Finally check for THENs */ @@ -1495,8 +1495,8 @@ void menu_cmd(void) { int nm_size, nm_width; /* Size and width of noun menu */ - nounval = NULL; - nounmenu = NULL; + nounval = nullptr; + nounmenu = nullptr; /* Get verb+prep */ choice = agt_menu("", vm_size, vm_width, verbmenu); if (choice == -1 || doing_restore) return; @@ -1590,7 +1590,7 @@ void menu_cmd(void) { return; } - if (undo_state != NULL) { + if (undo_state != nullptr) { undo_state = getstate(undo_state); can_undo = 1; } @@ -1599,7 +1599,7 @@ void menu_cmd(void) { tmpobj(&actrec); actrec.obj = 0; exec(&actrec, vnum_, lnoun, prep_, &mobj); - lnoun = NULL; /* exec() is responsible for freeing lnoun */ + lnoun = nullptr; /* exec() is responsible for freeing lnoun */ } diff --git a/engines/glk/agt/runverb.cpp b/engines/glk/agt/runverb.cpp index 940547267c7..12cb1c0f2ba 100644 --- a/engines/glk/agt/runverb.cpp +++ b/engines/glk/agt/runverb.cpp @@ -71,7 +71,7 @@ static void v_go(int dir) { return; } clear_stack(); - (void)scan_metacommand(0, v0, 0, 0, 0, NULL); + (void)scan_metacommand(0, v0, 0, 0, 0, nullptr); return; } if (newloc < first_room) { @@ -103,7 +103,7 @@ static void v_go(int dir) { curr_creat_rec = &tmpcreat; make_parserec(i + first_creat, &tmpcreat); sysmsg(14, "$The_c$$c_name$ blocks $your$ way."); - curr_creat_rec = NULL; + curr_creat_rec = nullptr; return; } @@ -113,7 +113,7 @@ static void v_go(int dir) { oldloc = tmploc; /* Can backtrack as long as not from special */ if (dir == 12 && special_ptr[loc].size > 0) /* need to print special of NEW room */ - runptr(loc, special_ptr, "INTERNAL ERROR: Invalid special ptr", 0, NULL, NULL); + runptr(loc, special_ptr, "INTERNAL ERROR: Invalid special ptr", 0, nullptr, nullptr); if (tmploc == loc && dir == 12) /* SPECIAL that sends us nowhere */ do_look = 0; @@ -164,19 +164,19 @@ static void v_noun(int vc, parse_rec *nounrec) { if (vc == 0) /* Push */ runptr(dobj_ - first_noun, push_ptr, "$You$ $verb$ $the_n$$noun$ for a while, but nothing happens.", - 171, nounrec, NULL); + 171, nounrec, nullptr); if (vc == 1) /* Pull */ runptr(dobj_ - first_noun, pull_ptr, "$You$ $verb$ $the_n$$noun$ a bit, but nothing happens.", 174, - nounrec, NULL); + nounrec, nullptr); if (vc == 2) /* Turn */ runptr(dobj_ - first_noun, turn_ptr, "$You$ $verb$ $the_n$$noun$, but nothing happens.", 165, - nounrec, NULL); + nounrec, nullptr); if (vc == 3) /* Play */ runptr(dobj_ - first_noun, play_ptr, "$You$ $verb$ $the_n$$noun$ for a bit, but nothing happens.", 177, - nounrec, NULL); + nounrec, nullptr); } /* vc==1 if ASK, 0 if TALK TO */ @@ -254,10 +254,10 @@ static void v_read(parse_rec *nounrec) { } if (text_ptr[dobj_ - first_noun].size > 0) runptr(dobj_ - first_noun, text_ptr, - "INTERNAL ERROR: Invalid read pointer", 0, NULL, NULL); + "INTERNAL ERROR: Invalid read pointer", 0, nullptr, nullptr); else runptr(dobj_ - first_noun, noun_ptr, "$You$ learn nothing new.", - 193, nounrec, NULL); + 193, nounrec, nullptr); } @@ -729,10 +729,10 @@ static void v_attack(uchar missile, parse_rec *targrec, parse_rec *weprec) { if (targ == 0) { if (!missile) { - alt_sysmsg(206, "Attack what???", NULL, weprec); + alt_sysmsg(206, "Attack what???", nullptr, weprec); return; } else { - alt_sysmsg(188, "$You$ fire a shot into the air.", NULL, weprec); + alt_sysmsg(188, "$You$ fire a shot into the air.", nullptr, weprec); return; } } @@ -762,7 +762,7 @@ static void v_attack(uchar missile, parse_rec *targrec, parse_rec *weprec) { if (!missile) { int msgnum; if (creature[targ - first_creat].hostile) { - alt_sysmsg(50, NULL, weprec, targrec); /* Preliminary message */ + alt_sysmsg(50, nullptr, weprec, targrec); /* Preliminary message */ msgnum = 51; } else msgnum = 54; if (noun[wep - first_noun].drinkable) { /* i.e. a liquid */ @@ -970,7 +970,7 @@ void v_inventory(void) { static void v_quit(void) { sysmsg(145, "Are you sure you want to quit?"); if (yesno("")) { - sysmsg(146, NULL); + sysmsg(146, nullptr); quitflag = 1; } } @@ -1153,7 +1153,7 @@ rbool metacommand_cycle(int save_vb, int *p_redir_flag) { supress_debug = !debug_any; clear_stack(); if ((PURE_METAVERB || !was_metaverb) - && 2 == scan_metacommand(0, 0, 0, 0, 0, NULL)) + && 2 == scan_metacommand(0, 0, 0, 0, 0, nullptr)) return 1; supress_debug = 0; @@ -1165,7 +1165,7 @@ rbool metacommand_cycle(int save_vb, int *p_redir_flag) { if (actor != 0 && aver < AGX00) { if (DEBUG_AGT_CMD) debugout("*** Scanning: ANYBODY metacommands ****\n"); - if (2 == scan_metacommand(2, vb, dobj, prep, iobj, NULL)) + if (2 == scan_metacommand(2, vb, dobj, prep, iobj, nullptr)) return 1; } @@ -1293,7 +1293,7 @@ void exec_verb(void) { case 50: runptr(loc, help_ptr, "Sorry, you're on your own here.", - 2, NULL, NULL); + 2, nullptr, nullptr); break; /* HELP */ case 32: v_inventory(); @@ -1401,7 +1401,7 @@ void exec_verb(void) { break; case (OLD_VERB+1): cmd_saveable = 0; /* RESTART */ - if (restart_state == NULL) + if (restart_state == nullptr) writeln("Sorry, too little memory to support RESTART."); else { doing_restore = 2; @@ -1447,7 +1447,7 @@ void exec_verb(void) { replay(0); break; case (OLD_VERB+12): /* MENU */ - if (verbmenu == NULL) { + if (verbmenu == nullptr) { writeln("Sorry, but menus are not supported by this game."); menu_mode = 0; break; @@ -1501,7 +1501,7 @@ void exec_verb(void) { supress_debug = !debug_any; clear_stack(); if ((PURE_METAVERB || !was_metaverb) && - 2 == scan_metacommand(0, 57, 0, 0, 0, NULL)) + 2 == scan_metacommand(0, 57, 0, 0, 0, nullptr)) turndone = 1; supress_debug = 0; } @@ -1538,8 +1538,8 @@ int objcheck_cycle(rbool *success, parse_rec *act, int verbid, /* The xobj_rec don't really matter */ dobj = dorec->obj; dobj_rec = copy_parserec(dorec); - if (iorec == NULL) { - iobj_rec = make_parserec(0, NULL); + if (iorec == nullptr) { + iobj_rec = make_parserec(0, nullptr); iobj = 0; } else { iobj = iorec->obj; @@ -1550,7 +1550,7 @@ int objcheck_cycle(rbool *success, parse_rec *act, int verbid, *success = 1; supress_debug = !debug_disambig; if (actor != 0 && aver < AGX00) { - result = scan_metacommand(2, verbid, dobj, prep_, iobj, NULL); + result = scan_metacommand(2, verbid, dobj, prep_, iobj, nullptr); if (result == 2) { free_all_parserec(); return disambig_score; @@ -1561,7 +1561,7 @@ int objcheck_cycle(rbool *success, parse_rec *act, int verbid, } } clear_stack(); - result = scan_metacommand(actor, verbid, dobj, prep_, iobj, NULL); + result = scan_metacommand(actor, verbid, dobj, prep_, iobj, nullptr); supress_debug = 0; switch (result) { case -2: @@ -1589,7 +1589,7 @@ int check_obj(parse_rec *act, int verbid, int result; rbool success; - if (iorec == NULL) + if (iorec == nullptr) do_disambig = 1; /* Disambiguating dobj */ else do_disambig = 2; /* Disambiguating iobj */ diff --git a/engines/glk/agt/savegame.cpp b/engines/glk/agt/savegame.cpp index 062706444cf..3f2235b39c3 100644 --- a/engines/glk/agt/savegame.cpp +++ b/engines/glk/agt/savegame.cpp @@ -154,7 +154,7 @@ static file_info fi_savecreat[] = { }; static file_info fi_saveustr[] = { - {FT_TLINE, DT_DEFAULT, NULL, 0}, + {FT_TLINE, DT_DEFAULT, nullptr, 0}, endrec }; @@ -168,12 +168,12 @@ uchar *getstate(uchar *gs) rbool new_block; /* True if we allocate a new block */ long bp; - if (gs == NULL) { + if (gs == nullptr) { rm_trap = 0; /* Don't exit on out-of-memory condition */ gs = (uchar *)rmalloc(state_size); /* This should be enough. */ rm_trap = 1; - if (gs == NULL) /* This is why we set rm_trap to 0 before calling rmalloc */ - return NULL; + if (gs == nullptr) /* This is why we set rm_trap to 0 before calling rmalloc */ + return nullptr; new_block = 1; } else new_block = 0; @@ -202,13 +202,13 @@ uchar *getstate(uchar *gs) bp += write_recarray(creature, sizeof(creat_rec), rangefix(maxcreat - first_creat + 1), fi_savecreat, bp); - if (userstr != NULL) + if (userstr != nullptr) bp += write_recarray(userstr, sizeof(tline), MAX_USTR, fi_saveustr, bp); - if (objflag != NULL) + if (objflag != nullptr) bp += write_recblock(objflag, FT_BYTE, objextsize(0), bp); - if (objprop != NULL) + if (objprop != nullptr) bp += write_recblock(objprop, FT_INT32, objextsize(1), bp); - set_internal_buffer(NULL); + set_internal_buffer(nullptr); gs[0] = bp & 0xFF; gs[1] = (bp >> 8) & 0xFF; gs[2] = (bp >> 16) & 0xFF; @@ -257,7 +257,7 @@ void putstate(uchar *gs) { /* Restores games state. */ fi_savecreat[0].ptr = creat_ptr; bp = 6; - read_globalrec(fi_savehead, 0, bp, 0); + read_globalrec(fi_savehead, nullptr, bp, 0); bp += compute_recsize(fi_savehead); read_recblock(flag, FT_BYTE, FLAG_NUM + 1, bp, 0); bp += ft_leng[FT_BYTE] * (FLAG_NUM + 1); @@ -267,36 +267,36 @@ void putstate(uchar *gs) { /* Restores games state. */ bp += ft_leng[FT_INT32] * (VAR_NUM + 1); numrec = rangefix(maxroom - first_room + 1); - read_recarray(room, sizeof(room_rec), numrec, fi_saveroom, 0, bp, 0); + read_recarray(room, sizeof(room_rec), numrec, fi_saveroom, nullptr, bp, 0); bp += compute_recsize(fi_saveroom) * numrec; numrec = rangefix(maxnoun - first_noun + 1); - read_recarray(noun, sizeof(noun_rec), numrec, fi_savenoun, 0, bp, 0); + read_recarray(noun, sizeof(noun_rec), numrec, fi_savenoun, nullptr, bp, 0); bp += compute_recsize(fi_savenoun) * numrec; numrec = rangefix(maxcreat - first_creat + 1); - read_recarray(creature, sizeof(creat_rec), numrec, fi_savecreat, 0, bp, 0); + read_recarray(creature, sizeof(creat_rec), numrec, fi_savecreat, nullptr, bp, 0); bp += compute_recsize(fi_savecreat) * numrec; - if (userstr != NULL) { - read_recarray(userstr, sizeof(tline), MAX_USTR, fi_saveustr, 0, bp, 0); + if (userstr != nullptr) { + read_recarray(userstr, sizeof(tline), MAX_USTR, fi_saveustr, nullptr, bp, 0); bp += ft_leng[FT_TLINE] * MAX_USTR; } - if (objflag != NULL) { + if (objflag != nullptr) { i = objextsize(0); read_recblock(objflag, FT_BYTE, i, bp, 0); bp += ft_leng[FT_BYTE] * i; } - if (objprop != NULL) { + if (objprop != nullptr) { i = objextsize(1); read_recblock(objprop, FT_INT32, i, bp, 0); bp += ft_leng[FT_INT32] * i; } - set_internal_buffer(NULL); + set_internal_buffer(nullptr); if (skip_descr) /* Need to "fix" position information. This is a hack. */ /* Basically, this sets the position of each object to its default */ /* The problem here is that the usual position info is invalid-- we've changed games, and hence dictionaries */ for (i = 0; i < maxnoun - first_noun; i++) { - if (noun[i].position != NULL && noun[i].position[0] != 0) + if (noun[i].position != nullptr && noun[i].position[0] != 0) noun[i].pos_prep = -1; else noun[i].pos_prep = 0; } @@ -305,7 +305,7 @@ void putstate(uchar *gs) { /* Restores games state. */ if (noun[i].pos_prep == -1) noun[i].position = noun[i].initpos; else - noun[i].position = NULL; + noun[i].position = nullptr; init_vals(); skip_descr = 0; /* If we set this to 1, restore it to its original state */ @@ -330,7 +330,7 @@ void init_state_sys(void) + ft_leng[FT_BYTE] * objextsize(0) + ft_leng[FT_INT32] * objextsize(1) + 6; /* Six bytes in header */ - if (userstr != NULL) state_size += ft_leng[FT_TLINE] * MAX_USTR; + if (userstr != nullptr) state_size += ft_leng[FT_TLINE] * MAX_USTR; } @@ -342,11 +342,11 @@ extern Common::Error savegame(Common::WriteStream *savefile) { long size; #ifndef UNDO_SAVE - gs = getstate(NULL); + gs = getstate(nullptr); #else gs = undo_state; #endif - if (gs == NULL) { + if (gs == nullptr) { writeln("Insufficiant memory to support SAVE."); return Common::kWritingFailed; } diff --git a/engines/glk/agt/token.cpp b/engines/glk/agt/token.cpp index 84619fc3305..6e7e5114885 100644 --- a/engines/glk/agt/token.cpp +++ b/engines/glk/agt/token.cpp @@ -157,7 +157,7 @@ void move_in_dir(int obj, int dir) { /* Stack routines: Manipulating the expression stack */ /* ------------------------------------------------------------------- */ -static long *stack = NULL; +static long *stack = nullptr; static int sp = 0; /* Stack pointer */ static int stacksize = 0; /* Actual space allocated to the stack */ diff --git a/engines/glk/agt/util.cpp b/engines/glk/agt/util.cpp index ea8ae885ef2..363f573baed 100644 --- a/engines/glk/agt/util.cpp +++ b/engines/glk/agt/util.cpp @@ -151,9 +151,9 @@ void *rmalloc(long size) { error("Memory allocation error: Over-sized structure requested."); } assert(size >= 0); - if (size == 0) return NULL; + if (size == 0) return nullptr; p = malloc((size_t)size); - if (p == NULL && rm_trap && size > 0) { + if (p == nullptr && rm_trap && size > 0) { error("Memory allocation error: Out of memory."); } if (rm_acct) ralloc_cnt++; @@ -169,21 +169,21 @@ void *rrealloc(void *old, long size) { assert(size >= 0); if (size == 0) { r_free(old); - return NULL; + return nullptr; } - if (rm_acct && old == NULL) ralloc_cnt++; + if (rm_acct && old == nullptr) ralloc_cnt++; p = realloc(old, (size_t)size); - if (p == NULL && rm_trap && size > 0) { + if (p == nullptr && rm_trap && size > 0) { error("Memory reallocation error: Out of memory."); } return p; } char *rstrdup(const char *s) { - if (s == NULL) return NULL; + if (s == nullptr) return nullptr; char *t = scumm_strdup(s); - if (t == NULL && rm_trap) { + if (t == nullptr && rm_trap) { error("Memory duplication error: Out of memory."); } if (rm_acct) ralloc_cnt++; @@ -194,7 +194,7 @@ char *rstrdup(const char *s) { void r_free(void *p) { int tmp; - if (p == NULL) return; + if (p == nullptr) return; tmp = get_rm_size(); /* Take worst case in all cases */ if (tmp > rm_size) rm_size = tmp; @@ -248,14 +248,14 @@ char *concdup(const char *s1, const char *s2) { char *s; len1 = len2 = 0; - if (s1 != NULL) len1 = strlen(s1); - if (s2 != NULL) len2 = strlen(s2); + if (s1 != nullptr) len1 = strlen(s1); + if (s2 != nullptr) len2 = strlen(s2); s = (char *)rmalloc(sizeof(char) * (len1 + len2 + 2)); - if (s1 != NULL) + if (s1 != nullptr) memcpy(s, s1, len1); memcpy(s + len1, " ", 1); - if (s2 != NULL) + if (s2 != nullptr) memcpy(s + len1 + 1, s2, len2); s[len1 + len2 + 1] = 0; return s; @@ -386,7 +386,7 @@ genfile openfile(fc_type fc, filetype ext, const char *err, rbool ferr) const char *errstr; tfile = readopen(fc, ext, &errstr); - if (errstr != NULL && err != NULL) + if (errstr != nullptr && err != nullptr) print_error("", ext, err, ferr); return tfile; @@ -406,7 +406,7 @@ genfile openbin(fc_type fc, filetype ext, const char *err, rbool ferr) char *fname; f = readopen(fc, ext, &errstr); - if (errstr != NULL && err != NULL) { + if (errstr != nullptr && err != nullptr) { fname = formal_name(fc, ext); print_error(fname, ext, err, ferr); rfree(fname); @@ -439,7 +439,7 @@ pass it back as its return value. n is ignored in this case */ int i, j, csize; int buffsize; /* Current size of buff, if we are allocating it dynamically */ - if (buff == NULL) { + if (buff == nullptr) { buff = (char *)rrealloc(buff, READLN_GRAIN * sizeof(char)); buffsize = READLN_GRAIN; n = buffsize - 1; @@ -480,7 +480,7 @@ pass it back as its return value. n is ignored in this case */ if (i == 0 && (c == EOF || c == DOS_EOF)) { /* We've hit the end of the file */ if (buffsize >= 0) rfree(buff); - return NULL; + return nullptr; } if (buffsize >= 0) { /* Shrink buffer to appropriate size */ @@ -503,7 +503,7 @@ pass it back as its return value. n is ignored in this case */ genfile bfile; -static uchar *buffer = NULL; +static uchar *buffer = nullptr; static long buffsize; /* How big the buffer is */ static long record_size; /* Size of a record in the file */ static long buff_frame; /* The file index corrosponding to buffer[0] */ @@ -551,12 +551,12 @@ buffreopen will be called before any major file activity char ebuff[200]; const char *errstr; - assert(buffer == NULL); /* If not, it means these routines have been + assert(buffer == nullptr); /* If not, it means these routines have been called by someone else who isn't done yet */ bfile = readopen(fc, ext, &errstr); - if (errstr != NULL) { - if (rectype == NULL) { + if (errstr != nullptr) { + if (rectype == nullptr) { return 0; } else fatal(errstr); @@ -701,13 +701,13 @@ file_id_type bw_fileid; void bw_open(fc_type fc, filetype ext) { const char *errstr; - assert(buffer == NULL); + assert(buffer == nullptr); bfile = writeopen(fc, ext, &bw_fileid, &errstr); - if (errstr != NULL) fatal(errstr); + if (errstr != nullptr) fatal(errstr); bw_last = 0; buffsize = 0; - buffer = NULL; + buffer = nullptr; #ifdef DEBUG_SEEK bw_fileleng = 0; #endif @@ -740,7 +740,7 @@ static void bw_setblock(long fofs, long recnum, long rsize) /* Set parameters for current block */ { /* First, flush old block if neccessary */ - if (buffer != NULL) { + if (buffer != nullptr) { bw_flush(); rfree(buffer); } @@ -790,7 +790,7 @@ void bw_close(void) { /* If the internal buffer is not NULL, it is used instead of a file */ /* (This is used by RESTART, etc. to save state to memory rather than to a file) */ -static uchar *int_buff = NULL; +static uchar *int_buff = nullptr; static long ibuff_ofs, ibuff_rsize; void set_internal_buffer(void *buff) { @@ -813,7 +813,7 @@ static uchar *get_ibuff(long index) { static void buff_blockread(void *buff, long size, long offset) { const char *errstr; - if (int_buff != NULL) + if (int_buff != nullptr) memcpy((char *)buff, int_buff + offset, size); else { binseek(bfile, offset); @@ -824,7 +824,7 @@ static void buff_blockread(void *buff, long size, long offset) { /* This writes buff to disk. */ static void bw_blockwrite(void *buff, long size, long offset) { - if (int_buff != NULL) + if (int_buff != nullptr) memcpy(int_buff + offset, (char *)buff, size); else { bw_flush(); @@ -956,12 +956,12 @@ static void read_filerec(file_info *rec_desc, const uchar *filedata) { mask = 1; filedata += 1; } - if (filebase == NULL || (filedata - filebase) >= record_size) { + if (filebase == nullptr || (filedata - filebase) >= record_size) { /* We're past the end of the block; read in zeros for the rest of entries. */ past_eob = 1; filedata = zero_block; - filebase = NULL; + filebase = nullptr; } switch (rec_desc->ftype) { case FT_INT16: @@ -1186,7 +1186,7 @@ void *read_recarray(void *base, long eltsize, long numelts, file_info *curr; uchar *file_data; - if (numelts == 0) return NULL; + if (numelts == 0) return nullptr; if (int_buff) set_ibuff(file_offset, compute_recsize(field_info)); @@ -1194,7 +1194,7 @@ void *read_recarray(void *base, long eltsize, long numelts, buffreopen(file_offset, compute_recsize(field_info), numelts, file_blocksize, rectype); - if (base == NULL) + if (base == nullptr) base = rmalloc(eltsize * numelts); for (curr = field_info; curr->ftype != FT_END; curr++) @@ -1236,7 +1236,7 @@ long write_recarray(void *base, long eltsize, long numelts, else bw_setblock(file_offset, numelts, compute_recsize(field_info)); - if (base != NULL) + if (base != nullptr) for (curr = field_info; curr->ftype != FT_END; curr++) if (curr->dtype != DT_DESCPTR && curr->dtype != DT_CMDPTR) curr->ptr = ((char *)base + curr->offset); @@ -1246,7 +1246,7 @@ long write_recarray(void *base, long eltsize, long numelts, file_data = get_ibuff(i); else file_data = bw_getbuff(i); - if (base != NULL) { + if (base != nullptr) { write_filerec(field_info, file_data); for (curr = field_info; curr->ftype != FT_END; curr++) if (curr->dtype == DT_DESCPTR) @@ -1294,7 +1294,7 @@ long write_globalrec(file_info *global_info, long file_offset) { static file_info fi_temp[] = { - {0, DT_DEFAULT, NULL, 0}, + {0, DT_DEFAULT, nullptr, 0}, endrec }; @@ -1307,7 +1307,7 @@ void *read_recblock(void *base, int ftype, long numrec, switch (ftype) { case FT_CHAR: case FT_BYTE: - if (base == NULL) base = rmalloc(numrec * sizeof(char)); + if (base == nullptr) base = rmalloc(numrec * sizeof(char)); buff_blockread(base, numrec, offset); if (ftype == FT_CHAR) { long i; diff --git a/engines/glk/alan2/alan2.cpp b/engines/glk/alan2/alan2.cpp index d875deecb3a..d4d09829562 100644 --- a/engines/glk/alan2/alan2.cpp +++ b/engines/glk/alan2/alan2.cpp @@ -60,7 +60,7 @@ bool Alan2::initialize() { _advName = Common::String(_advName.c_str(), _advName.size() - 4); // first, open a window for error output - glkMainWin = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + glkMainWin = g_vm->glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 0); if (glkMainWin == nullptr) ::error("FATAL ERROR: Cannot open initial window"); diff --git a/engines/glk/alan2/args.cpp b/engines/glk/alan2/args.cpp index 66989f6058e..2306487384c 100644 --- a/engines/glk/alan2/args.cpp +++ b/engines/glk/alan2/args.cpp @@ -35,9 +35,9 @@ static void switches(unsigned argc, char *argv[]) { void args(int argc, char *argv[]) { char *prgnam; - if ((prgnam = strrchr(argv[0], '\\')) == NULL - && (prgnam = strrchr(argv[0], '/')) == NULL - && (prgnam = strrchr(argv[0], ':')) == NULL) + if ((prgnam = strrchr(argv[0], '\\')) == nullptr + && (prgnam = strrchr(argv[0], '/')) == nullptr + && (prgnam = strrchr(argv[0], ':')) == nullptr) prgnam = argv[0]; else prgnam++; @@ -50,7 +50,7 @@ void args(int argc, char *argv[]) { if (advnam[0] == '\0') /* No game given, try program name */ if (scumm_stricmp(prgnam, PROGNAME) != 0 - && strstr(prgnam, PROGNAME) == 0) + && strstr(prgnam, PROGNAME) == nullptr) advnam = scumm_strdup(argv[0]); } diff --git a/engines/glk/alan2/exe.cpp b/engines/glk/alan2/exe.cpp index 0053f68a4c4..275cf0c0613 100644 --- a/engines/glk/alan2/exe.cpp +++ b/engines/glk/alan2/exe.cpp @@ -811,15 +811,15 @@ static void dscrobj(Aword obj) { } static void 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; + if (endOfTable(scr)) scr = nullptr; } - if (scr != NULL && scr->dscr != 0) + if (scr != nullptr && scr->dscr != 0) interpret(scr->dscr); else if (acts[act - ACTMIN].dscr != 0) interpret(acts[act - ACTMIN].dscr); @@ -1125,7 +1125,7 @@ Aword contains(Aptr string, Aptr substring) { strlow((char *)string); strlow((char *)substring); - found = (strstr((char *)string, (char *)substring) != 0); + found = (strstr((char *)string, (char *)substring) != nullptr); free((char *)string); free((char *)substring); diff --git a/engines/glk/alan2/main.cpp b/engines/glk/alan2/main.cpp index bae21c07904..f0e0c3f61ee 100644 --- a/engines/glk/alan2/main.cpp +++ b/engines/glk/alan2/main.cpp @@ -174,12 +174,12 @@ void statusline() { int pcol = col; uint i; - if (NULL == glkStatusWin) + if (nullptr == glkStatusWin) return; g_vm->glk_set_window(glkStatusWin); g_vm->glk_window_clear(glkStatusWin); - g_vm->glk_window_get_size(glkStatusWin, &glkWidth, NULL); + g_vm->glk_window_get_size(glkStatusWin, &glkWidth, nullptr); g_vm->glk_set_style(style_User1); for (i = 0; i < glkWidth; i++) @@ -265,7 +265,7 @@ void clear() { void *allocate(unsigned long len /* IN - Length to allocate */) { void *p = (void *)malloc((size_t)len); - if (p == NULL) + if (p == nullptr) syserr("Out of memory."); return p; @@ -433,7 +433,7 @@ void output(const char original[]) { if (str[0] != '$' || str[1] != '$') space(); /* Output space if needed (& not inhibited) */ - while ((symptr = strchr(str, '$')) != (char *) NULL) { + while ((symptr = strchr(str, '$')) != (char *) nullptr) { ch = *symptr; /* Terminate before symbol */ *symptr = '\0'; if (strlen(str) > 0) { @@ -730,16 +730,16 @@ static AltElem *findalt( AltElem *alt; if (vrbsadr == 0) - return (NULL); + return (nullptr); for (vrb = (VrbElem *) addrTo(vrbsadr); !endOfTable(vrb); vrb++) if ((int)vrb->code == 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; } @@ -757,27 +757,27 @@ Boolean possible() { fail = FALSE; alt[0] = findalt(header->vrbs, 0); /* Perform global checks */ - if (alt[0] != 0 && alt[0]->checks != 0) { + if (alt[0] != nullptr && alt[0]->checks != 0) { if (!trycheck(alt[0]->checks, FALSE)) return FALSE; if (fail) return FALSE; } /* Now CHECKs in this location */ alt[1] = findalt(locs[cur.loc - LOCMIN].vrbs, 0); - if (alt[1] != 0 && alt[1]->checks != 0) + if (alt[1] != nullptr && alt[1]->checks != 0) if (!trycheck(alt[1]->checks, FALSE)) return FALSE; for (i = 0; params[i].code != EOD; i++) { alt[i + 2] = findalt(objs[params[i].code - OBJMIN].vrbs, i + 1); /* CHECKs in a possible parameter */ - if (alt[i + 2] != 0 && alt[i + 2]->checks != 0) + if (alt[i + 2] != nullptr && alt[i + 2]->checks != 0) if (!trycheck(alt[i + 2]->checks, FALSE)) return FALSE; } for (i = 0; i < 2 || params[i - 2].code != EOD; i++) - if (alt[i] != 0 && alt[i]->action != 0) + if (alt[i] != nullptr && alt[i]->action != 0) break; if (i >= 2 && params[i - 2].code == EOD) /* Didn't find any code for this verb/object combination */ @@ -803,7 +803,7 @@ static void do_it(CONTEXT) { fail = FALSE; alt[0] = findalt(header->vrbs, 0); /* Perform global checks */ - if (alt[0] != 0 && alt[0]->checks != 0) { + if (alt[0] != nullptr && alt[0]->checks != 0) { if (trcflg) printf("\n\n", cur.vrb); if (!trycheck(alt[0]->checks, TRUE)) return; @@ -812,7 +812,7 @@ static void do_it(CONTEXT) { /* Now CHECKs in this location */ alt[1] = findalt(locs[cur.loc - LOCMIN].vrbs, 0); - if (alt[1] != 0 && alt[1]->checks != 0) { + if (alt[1] != nullptr && alt[1]->checks != 0) { if (trcflg) printf("\n\n", cur.vrb); if (!trycheck(alt[1]->checks, TRUE)) return; @@ -821,7 +821,7 @@ static void do_it(CONTEXT) { for (i = 0; params[i].code != EOD; i++) { if (isLit(params[i].code)) - alt[i + 2] = 0; + alt[i + 2] = nullptr; else { if (isObj(params[i].code)) alt[i + 2] = findalt(objs[params[i].code - OBJMIN].vrbs, i + 1); @@ -830,7 +830,7 @@ static void do_it(CONTEXT) { else syserr("Illegal parameter type."); /* CHECKs in the parameters */ - if (alt[i + 2] != 0 && alt[i + 2]->checks != 0) { + if (alt[i + 2] != nullptr && alt[i + 2]->checks != 0) { if (trcflg) printf("\n\n", cur.vrb, i); if (!trycheck(alt[i + 2]->checks, TRUE)) return; @@ -841,7 +841,7 @@ static void do_it(CONTEXT) { /* Check for anything to execute... */ for (i = 0; i < 2 || params[i - 2].code != EOD; i++) - if (alt[i] != 0 && alt[i]->action != 0) + if (alt[i] != nullptr && alt[i]->action != 0) break; if (i >= 2 && params[i - 2].code == EOD) { // Didn't find any code for this verb/object combination @@ -857,7 +857,7 @@ static void do_it(CONTEXT) { done[i] = FALSE; i--; while (i >= 0) { - if (alt[i] != 0) + if (alt[i] != nullptr) if (alt[i]->qual == (Aword)Q_BEFORE || alt[i]->qual == (Aword)Q_ONLY) { if (alt[i]->action != 0) { if (trcflg) { @@ -883,7 +883,7 @@ static void do_it(CONTEXT) { /* Then execute any not declared as AFTER, i.e. the default */ for (i = 0; i < 2 || params[i - 2].code != EOD; i++) { - if (alt[i] != 0) + if (alt[i] != nullptr) if (alt[i]->qual != (Aword)Q_AFTER) { if (!done[i] && alt[i]->action != 0) { if (trcflg) { @@ -905,7 +905,7 @@ static void do_it(CONTEXT) { /* Finally, the ones declared as after */ i--; while (i >= 0) { - if (alt[i] != 0) + if (alt[i] != nullptr) if (!done[i] && alt[i]->action != 0) { if (trcflg) { if (i == 0) @@ -1081,7 +1081,7 @@ static void load() { /* Allocate and load memory */ /* No memory allocated yet? */ - if (memory == NULL) { + if (memory == nullptr) { #ifdef V25COMPATIBLE if (tmphdr.vers[0] == 2 && tmphdr.vers[1] == 5) /* We need some more memory to expand 2.5 format*/ diff --git a/engines/glk/alan2/parse.cpp b/engines/glk/alan2/parse.cpp index 5b97448cfbc..9a43f813068 100644 --- a/engines/glk/alan2/parse.cpp +++ b/engines/glk/alan2/parse.cpp @@ -125,7 +125,7 @@ static char *gettoken(char *tokBuf) { static char *marker; static char oldch; - if (tokBuf == NULL) + if (tokBuf == nullptr) *marker = oldch; else marker = tokBuf; @@ -140,7 +140,7 @@ static char *gettoken(char *tokBuf) { while (*marker != '\"') marker++; marker++; } else if (*marker == '\0' || *marker == '\n') - return NULL; + return nullptr; else marker++; oldch = *marker; @@ -171,12 +171,12 @@ static void agetline(CONTEXT) { strcpy(isobuf, buf); token = gettoken(isobuf); - if (token != NULL && strcmp("debug", token) == 0 && header->debug) { + if (token != nullptr && strcmp("debug", token) == 0 && header->debug) { dbgflg = TRUE; debug(); - token = NULL; + token = nullptr; } - } while (token == NULL); + } while (token == nullptr); eol = FALSE; lin = 1; } @@ -224,7 +224,7 @@ static void scan(CONTEXT) { CALL1(unknown, token) } wrds[i] = EOD; - eol = (token = gettoken(NULL)) == NULL; + eol = (token = gettoken(nullptr)) == nullptr; } while (!eol); } @@ -287,10 +287,10 @@ static void unambig(CONTEXT, ParamElem plst[]) { static ParamElem *savlst; /* Saved list for backup at EOD */ int firstWord, lastWord; /* The words the player used */ - if (refs == NULL) + if (refs == nullptr) refs = (ParamElem *)allocate((MAXENTITY + 1) * sizeof(ParamElem)); - if (savlst == NULL) + if (savlst == nullptr) savlst = (ParamElem *)allocate((MAXENTITY + 1) * sizeof(ParamElem)); if (isLiteral(wrds[wrdidx])) { @@ -388,12 +388,12 @@ static void unambig(CONTEXT, ParamElem plst[]) { } static void simple(CONTEXT, ParamElem olst[]) { - static ParamElem *tlst = NULL; + static ParamElem *tlst = nullptr; int savidx = wrdidx; Boolean savplur = FALSE; int i; - if (tlst == NULL) + if (tlst == nullptr) tlst = (ParamElem *) allocate(sizeof(ParamElem) * (MAXENTITY + 1)); tlst[0].code = EOD; @@ -448,9 +448,9 @@ static void simple(CONTEXT, ParamElem olst[]) { */ static void complex(CONTEXT, ParamElem olst[]) { - static ParamElem *alst = NULL; + static ParamElem *alst = nullptr; - if (alst == NULL) + if (alst == nullptr) alst = (ParamElem *) allocate((MAXENTITY + 1) * sizeof(ParamElem)); if (isAll(wrds[wrdidx])) { @@ -526,10 +526,10 @@ static void tryMatch(CONTEXT, ParamElem matchLst[]) { ClaElem *cla; /* Pointer to class definitions */ Boolean anyPlural = FALSE; /* Any parameter that was plural? */ int i, p; - static ParamElem *tlst = NULL; /* List of params found by complex() */ - static Boolean *checked = NULL; /* Corresponding parameter checked? */ + static ParamElem *tlst = nullptr; /* List of params found by complex() */ + static Boolean *checked = nullptr; /* Corresponding parameter checked? */ - if (tlst == NULL) { + if (tlst == nullptr) { tlst = (ParamElem *) allocate((MAXENTITY + 1) * sizeof(ParamElem)); checked = (Boolean *) allocate((MAXENTITY + 1) * sizeof(Boolean)); } @@ -695,7 +695,7 @@ static void match(CONTEXT, ParamElem *matchLst) { } void parse(CONTEXT) { - if (mlst == NULL) { /* Allocate large enough paramlists */ + if (mlst == nullptr) { /* Allocate large enough paramlists */ mlst = (ParamElem *) allocate(sizeof(ParamElem) * (MAXENTITY + 1)); mlst[0].code = EOD; pmlst = (ParamElem *) allocate(sizeof(ParamElem) * (MAXENTITY + 1)); diff --git a/engines/glk/alan2/sysdep.cpp b/engines/glk/alan2/sysdep.cpp index f9f92171fdd..2056a7f14c0 100644 --- a/engines/glk/alan2/sysdep.cpp +++ b/engines/glk/alan2/sysdep.cpp @@ -110,17 +110,17 @@ static char uppChrs[] = { int isSpace(int c) { /* IN - Native character to test */ - return (c != '\0' && strchr(spcChrs, c) != 0); + return (c != '\0' && strchr(spcChrs, c) != nullptr); } int isLower(int c) { /* IN - Native character to test */ - return (c != '\0' && strchr(lowChrs, c) != 0); + return (c != '\0' && strchr(lowChrs, c) != nullptr); } int isUpper(int c) { /* IN - Native character to test */ - return (c != '\0' && strchr(uppChrs, c) != 0); + return (c != '\0' && strchr(uppChrs, c) != nullptr); } int isLetter(int c) { /* IN - Native character to test */ @@ -158,13 +158,13 @@ char *strupp(char str[]) { /* INOUT - Native string to convert */ int isLowerCase(int c) { /* IN - ISO character to test */ static char lowChars[] = "abcdefghijklmnopqrstuvwxyz\340\341\342\343\344\345\346\347\351\352\353\354\355\356\357\360\361\362\363\364\365\366\370\371\372\373\374\375\376\377"; - return (c != '\0' && strchr(lowChars, c) != 0); + return (c != '\0' && strchr(lowChars, c) != nullptr); } int isUpperCase(int c) { /* IN - ISO character to test */ static char upperChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"; - return (c != '\0' && strchr(upperChars, c) != 0); + return (c != '\0' && strchr(upperChars, c) != nullptr); } diff --git a/engines/glk/alan3/act.cpp b/engines/glk/alan3/act.cpp index 720a35d2cee..21967e15ccd 100644 --- a/engines/glk/alan3/act.cpp +++ b/engines/glk/alan3/act.cpp @@ -33,12 +33,12 @@ namespace Alan3 { /*----------------------------------------------------------------------*/ static void executeCommand(CONTEXT, int verb, Parameter parameters[]) { - static AltInfo *altInfos = NULL; /* Need to survive lots of different exits...*/ + static AltInfo *altInfos = nullptr; /* Need to survive lots of different exits...*/ int altIndex; bool flag; /* Did we leave anything behind last time... */ - if (altInfos != NULL) + if (altInfos != nullptr) free(altInfos); altInfos = findAllAlternatives(verb, parameters); @@ -53,7 +53,7 @@ static void executeCommand(CONTEXT, int verb, Parameter parameters[]) { /* Now perform actions! First try any BEFORE or ONLY from inside out */ for (altIndex = lastAltInfoIndex(altInfos); altIndex >= 0; altIndex--) { - if (altInfos[altIndex].alt != 0) // TODO Can this ever be NULL? Why? + if (altInfos[altIndex].alt != nullptr) // TODO Can this ever be NULL? Why? if (altInfos[altIndex].alt->qual == (Aword)Q_BEFORE || altInfos[altIndex].alt->qual == (Aword)Q_ONLY) { FUNC1(executedOk, flag, &altInfos[altIndex]) @@ -66,7 +66,7 @@ static void executeCommand(CONTEXT, int verb, Parameter parameters[]) { /* Then execute any not declared as AFTER, i.e. the default */ for (altIndex = 0; !altInfos[altIndex].end; altIndex++) { - if (altInfos[altIndex].alt != 0) { + if (altInfos[altIndex].alt != nullptr) { if (altInfos[altIndex].alt->qual != (Aword)Q_AFTER) { FUNC1(executedOk, flag, &altInfos[altIndex]) if (!flag) @@ -77,7 +77,7 @@ static void executeCommand(CONTEXT, int verb, Parameter parameters[]) { /* Finally, the ones declared as AFTER */ for (altIndex = lastAltInfoIndex(altInfos); altIndex >= 0; altIndex--) { - if (altInfos[altIndex].alt != 0) { + if (altInfos[altIndex].alt != nullptr) { FUNC1(executedOk, flag, &altInfos[altIndex]) if (!flag) CALL0(abortPlayerCommand) diff --git a/engines/glk/alan3/actor.cpp b/engines/glk/alan3/actor.cpp index 337034fcd3e..b91677d1c24 100644 --- a/engines/glk/alan3/actor.cpp +++ b/engines/glk/alan3/actor.cpp @@ -42,7 +42,7 @@ ScriptEntry *scriptOf(int actor) { if (!isEndOfArray(scr)) return scr; } - return NULL; + return nullptr; } @@ -51,7 +51,7 @@ StepEntry *stepOf(int actor) { StepEntry *step; ScriptEntry *scr = scriptOf(actor); - if (scr == NULL) return NULL; + if (scr == nullptr) return nullptr; step = (StepEntry *)pointerTo(scr->steps); step = &step[admin[actor].step]; @@ -64,7 +64,7 @@ StepEntry *stepOf(int actor) { void describeActor(CONTEXT, int actor) { ScriptEntry *script = scriptOf(actor); - if (script != NULL && script->description != 0) { + if (script != nullptr && script->description != 0) { CALL1(interpret, script->description) } else if (hasDescription(actor)) { CALL1(describeAnything, actor) diff --git a/engines/glk/alan3/alt_info.cpp b/engines/glk/alan3/alt_info.cpp index 21cbb163875..17f06a5a888 100644 --- a/engines/glk/alan3/alt_info.cpp +++ b/engines/glk/alan3/alt_info.cpp @@ -75,7 +75,7 @@ static void traceAltInfo(CONTEXT, AltInfo *alt) { break; case PARAMETER_LEVEL: { char *parameterName = parameterNameInSyntax(current.verb, alt->parameter); - if (parameterName != NULL) + if (parameterName != nullptr) printf("in parameter %s(#%d)=", parameterName, alt->parameter); else printf("in parameter #%d=", alt->parameter); @@ -100,7 +100,7 @@ static void traceVerbCheck(CONTEXT, AltInfo *alt, bool execute) { /*======================================================================*/ bool checkFailed(CONTEXT, AltInfo *altInfo, bool execute) { - if (altInfo->alt != NULL && altInfo->alt->checks != 0) { + if (altInfo->alt != nullptr && altInfo->alt->checks != 0) { R0CALL2(traceVerbCheck, altInfo, execute) // TODO Why does this not generate a regression error with ! @@ -153,7 +153,7 @@ bool executedOk(CONTEXT, AltInfo *altInfo) { /*======================================================================*/ bool canBeExecuted(AltInfo *altInfo) { - return altInfo->alt != NULL && altInfo->alt->action != 0; + return altInfo->alt != nullptr && altInfo->alt->action != 0; } @@ -193,7 +193,7 @@ static void addAlternative(AltInfoArray altInfos, int verb, int level, Aint para AltInfo *altInfoP = nextFreeAltInfo(altInfos); altInfoP->alt = (*finder)(verb, parameterNumber, theInstance, theClass); - if (altInfoP->alt != NULL) { + if (altInfoP->alt != nullptr) { primeAltInfo(altInfoP, level, parameterNumber, theInstance, theClass); altInfoP[1].end = TRUE; } @@ -256,7 +256,7 @@ bool anyCheckFailed(CONTEXT, AltInfoArray altInfo, bool execute) { int altIndex; bool flag; - if (altInfo != NULL) + if (altInfo != nullptr) for (altIndex = 0; !altInfo[altIndex].end; altIndex++) { current.instance = altInfo[altIndex].instance; @@ -272,7 +272,7 @@ bool anythingToExecute(AltInfo altInfo[]) { int altIndex; /* Check for anything to execute... */ - if (altInfo != NULL) + if (altInfo != nullptr) for (altIndex = 0; !altInfo[altIndex].end; altIndex++) if (canBeExecuted(&altInfo[altIndex])) return TRUE; @@ -293,7 +293,7 @@ static VerbEntry *findVerbEntry(int verbCode, VerbEntry *entries) { return verbEntry; } } - return NULL; + return nullptr; } @@ -302,17 +302,17 @@ static AltEntry *findAlternative(Aaddr verbTableAddress, int verbCode, int param AltEntry *alt; VerbEntry *verbEntry; - if (verbTableAddress == 0) return NULL; + if (verbTableAddress == 0) return nullptr; verbEntry = findVerbEntry(verbCode, (VerbEntry *) pointerTo(verbTableAddress)); - if (verbEntry != NULL) + if (verbEntry != nullptr) for (alt = (AltEntry *) pointerTo(verbEntry->alts); !isEndOfArray(alt); alt++) { if (alt->param == parameterNumber || alt->param == 0) { if (verbEntry->code < 0) current.meta = TRUE; return alt; } } - return NULL; + return nullptr; } @@ -360,7 +360,7 @@ static bool possibleWithFinder(CONTEXT, int verb, Parameter parameters[], AltInf else anything = anythingToExecute(allAlternatives); - if (allAlternatives != NULL) + if (allAlternatives != nullptr) deallocate(allAlternatives); return (anything); diff --git a/engines/glk/alan3/debug.cpp b/engines/glk/alan3/debug.cpp index 3f5d747bbe2..7f8b343a53c 100644 --- a/engines/glk/alan3/debug.cpp +++ b/engines/glk/alan3/debug.cpp @@ -58,7 +58,7 @@ static void showAttributes(AttributeEntry *attrib) { int i; char str[80]; - if (attrib == 0) + if (attrib == nullptr) return; i = 1; @@ -151,7 +151,7 @@ static void listInstances(CONTEXT, char *pattern) { bool found = FALSE; for (ins = 1; ins <= header->instanceMax; ins++) { - if (pattern == NULL || (pattern != NULL && match(pattern, idOfInstance(context, ins)))) { + if (pattern == nullptr || (pattern != nullptr && match(pattern, idOfInstance(context, ins)))) { if (!found) { output("Instances:"); found = TRUE; @@ -159,7 +159,7 @@ static void listInstances(CONTEXT, char *pattern) { CALL1(listInstance, ins) } } - if (pattern != NULL && !found) + if (pattern != nullptr && !found) output("No instances matched the pattern."); } @@ -428,13 +428,13 @@ char *readSourceLine(int file, int line) { frefid_t sourceFileRef = g_vm->glk_fileref_create_by_name(fileusage_TextMode, sourceFileName(file), 0); strid_t sourceFile = g_vm->glk_stream_open_file(sourceFileRef, filemode_Read, 0); - if (sourceFile != NULL) { + if (sourceFile != nullptr) { for (count = 0; count < line; count++) { if (!readLine(*sourceFile, buffer, SOURCELINELENGTH)) - return NULL; + return nullptr; // If not read the whole line, or no newline, try to read again - while (strchr(buffer, '\n') == NULL) { + while (strchr(buffer, '\n') == nullptr) { if (!readLine(*sourceFile, buffer, SOURCELINELENGTH)) break; } @@ -444,13 +444,13 @@ char *readSourceLine(int file, int line) { return buffer; } - return NULL; + return nullptr; } /*======================================================================*/ void showSourceLine(int fileNumber, int line) { char *buffer = readSourceLine(fileNumber, line); - if (buffer != NULL) { + if (buffer != nullptr) { if (buffer[strlen(buffer) - 1] == '\n') buffer[strlen(buffer) - 1] = '\0'; printf("<%05d>: %s", line, buffer); @@ -653,7 +653,7 @@ static const DebugParseEntry commandEntries[] = { {"exit", "", EXIT_COMMAND, "exit to game, enter 'debug' to get back"}, {"x", "", EXIT_COMMAND, "d:o"}, {"quit", "", QUIT_COMMAND, "quit game"}, - {NULL, NULL, '\0', NULL} + {nullptr, nullptr, '\0', nullptr} }; static const DebugParseEntry traceSubcommand[] = { @@ -662,7 +662,7 @@ static const DebugParseEntry traceSubcommand[] = { {"instructions", "", TRACE_INSTRUCTION_COMMAND, ""}, {"pushs", "", TRACE_PUSH_COMMAND, ""}, {"stacks", "", TRACE_STACK_COMMAND, ""}, - {NULL, NULL, '\0', NULL} + {nullptr, nullptr, '\0', nullptr} }; @@ -691,13 +691,13 @@ static void handleHelpCommand() { const DebugParseEntry *entry = commandEntries; int maxLength = 0; - for (entry = commandEntries; entry->command != NULL; entry++) { + for (entry = commandEntries; entry->command != nullptr; entry++) { if (strlen(entry->command) + strlen(entry->parameter) > (uint)maxLength) maxLength = strlen(entry->command) + strlen(entry->parameter); } output("$nADBG Commands (can be abbreviated):"); - for (entry = commandEntries; entry->command != NULL; entry++) { + for (entry = commandEntries; entry->command != nullptr; entry++) { char buf[200]; sprintf(buf, "$i%s %s %s$n$t$t-- %s", entry->command, entry->parameter, padding(entry, maxLength), entry->helpText); output(buf); @@ -707,22 +707,22 @@ static void handleHelpCommand() { /*----------------------------------------------------------------------*/ static const DebugParseEntry *findEntry(char *command, const DebugParseEntry *entry) { - while (entry->command != NULL) { + while (entry->command != nullptr) { if (scumm_strnicmp(command, entry->command, strlen(command)) == 0) return entry; entry++; } - return NULL; + return nullptr; } /*----------------------------------------------------------------------*/ static char parseDebugCommand(char *command) { const DebugParseEntry *entry = findEntry(command, commandEntries); - if (entry != NULL) { + if (entry != nullptr) { if (strlen(command) < strlen(entry->command)) { /* See if there are any more partial matches */ - if (findEntry(command, entry + 1) != NULL) + if (findEntry(command, entry + 1) != nullptr) /* TODO: we should list the possible matches somehow */ return AMBIGUOUS_COMMAND; } @@ -813,15 +813,15 @@ static void toggleStackTrace() { /*----------------------------------------------------------------------*/ static int parseTraceCommand() { - char *subcommand = strtok(NULL, ""); + char *subcommand = strtok(nullptr, ""); const DebugParseEntry *entry; - if (subcommand == 0) + if (subcommand == nullptr) return UNKNOWN_COMMAND; else { entry = findEntry(subcommand, traceSubcommand); - if (entry != NULL) { + if (entry != nullptr) { if (strlen(subcommand) < strlen(entry->command)) { - if (findEntry(subcommand, entry + 1) != NULL) + if (findEntry(subcommand, entry + 1) != nullptr) return AMBIGUOUS_COMMAND; } return entry->code; @@ -880,16 +880,16 @@ static void handleTraceCommand() { /*----------------------------------------------------------------------*/ static void handleBreakCommand(int fileNumber) { - char *parameter = strtok(NULL, ":"); - if (parameter != NULL && Common::isAlpha((int)parameter[0])) { + char *parameter = strtok(nullptr, ":"); + if (parameter != nullptr && Common::isAlpha((int)parameter[0])) { fileNumber = sourceFileNumber(parameter); if (fileNumber == -1) { printf("No such file: '%s'\n", parameter); return; } - parameter = strtok(NULL, ""); + parameter = strtok(nullptr, ""); } - if (parameter == NULL) + if (parameter == nullptr) listBreakpoints(); else setBreakpoint(fileNumber, atoi(parameter)); @@ -898,8 +898,8 @@ static void handleBreakCommand(int fileNumber) { /*----------------------------------------------------------------------*/ static void handleDeleteCommand(bool calledFromBreakpoint, int line, int fileNumber) { - char *parameter = strtok(NULL, ""); - if (parameter == NULL) { + char *parameter = strtok(nullptr, ""); + if (parameter == nullptr) { if (calledFromBreakpoint) deleteBreakpoint(line, fileNumber); else @@ -921,8 +921,8 @@ static void handleNextCommand(bool calledFromBreakpoint) { /*----------------------------------------------------------------------*/ static void handleLocationsCommand(CONTEXT) { - char *parameter = strtok(NULL, ""); - if (parameter == 0) + char *parameter = strtok(nullptr, ""); + if (parameter == nullptr) listLocations(context); else showLocation(context, atoi(parameter)); @@ -931,8 +931,8 @@ static void handleLocationsCommand(CONTEXT) { /*----------------------------------------------------------------------*/ static void handleActorsCommand(CONTEXT) { - char *parameter = strtok(NULL, ""); - if (parameter == NULL) + char *parameter = strtok(nullptr, ""); + if (parameter == nullptr) listActors(context); else showActor(context, atoi(parameter)); @@ -941,8 +941,8 @@ static void handleActorsCommand(CONTEXT) { /*----------------------------------------------------------------------*/ static void handleClassesCommand(CONTEXT) { - char *parameter = strtok(NULL, ""); - if (parameter == NULL || strchr(parameter, '*') != 0) { + char *parameter = strtok(nullptr, ""); + if (parameter == nullptr || strchr(parameter, '*') != nullptr) { output("Classes:"); showClassHierarchy(1, 0); listInstances(context, parameter); @@ -956,8 +956,8 @@ static void handleClassesCommand(CONTEXT) { /*----------------------------------------------------------------------*/ static void handleObjectsCommand(CONTEXT) { - char *parameter = strtok(NULL, ""); - if (parameter == NULL) + char *parameter = strtok(nullptr, ""); + if (parameter == nullptr) listObjects(context); else showObject(context, atoi(parameter)); @@ -966,10 +966,10 @@ static void handleObjectsCommand(CONTEXT) { /*----------------------------------------------------------------------*/ static void handleInstancesCommand(CONTEXT) { - char *parameter = strtok(NULL, ""); + char *parameter = strtok(nullptr, ""); uint i; - if (parameter == NULL || strchr(parameter, '*') != 0) + if (parameter == nullptr || strchr(parameter, '*') != nullptr) listInstances(context, parameter); else if (Common::isDigit((int)parameter[0])) showInstance(context, atoi(parameter)); diff --git a/engines/glk/alan3/event.cpp b/engines/glk/alan3/event.cpp index 73d7d9d876e..9c582c9abd2 100644 --- a/engines/glk/alan3/event.cpp +++ b/engines/glk/alan3/event.cpp @@ -27,7 +27,7 @@ namespace Alan3 { /* PUBLIC DATA */ int eventQueueSize = 0; -EventQueueEntry *eventQueue = NULL; +EventQueueEntry *eventQueue = nullptr; int eventQueueTop = 0; EventEntry *events; diff --git a/engines/glk/alan3/exe.cpp b/engines/glk/alan3/exe.cpp index 3a7c8adf378..2e393fc9589 100644 --- a/engines/glk/alan3/exe.cpp +++ b/engines/glk/alan3/exe.cpp @@ -65,7 +65,7 @@ void print(Aword fpos, Aword len) { int i; long savfp = 0; /* Temporary saved text file position */ bool savedPrintFlag = printFlag; - void *info = NULL; /* Saved decoding info */ + void *info = nullptr; /* Saved decoding info */ if (len == 0) return; @@ -172,7 +172,7 @@ void visits(Aword v) { /*----------------------------------------------------------------------*/ static void sayUndoneCommand(char *words) { - static Parameter *messageParameters = NULL; + static Parameter *messageParameters = nullptr; messageParameters = (Parameter *)ensureParameterArrayAllocated(messageParameters); current.location = where(HERO, DIRECT); @@ -284,7 +284,7 @@ void cancelEvent(Aword theEvent) { /*----------------------------------------------------------------------*/ static void increaseEventQueue(void) { eventQueue = (EventQueueEntry *)realloc(eventQueue, (eventQueueTop + 2) * sizeof(EventQueueEntry)); - if (eventQueue == NULL) syserr("Out of memory in increaseEventQueue()"); + if (eventQueue == nullptr) syserr("Out of memory in increaseEventQueue()"); eventQueueSize = eventQueueTop + 2; } @@ -383,7 +383,7 @@ static int skipWordForwards(char *string, int position) { uint i; - for (i = position; i <= strlen(string) && strchr(separators, string[i]) == NULL; i++) + for (i = position; i <= strlen(string) && strchr(separators, string[i]) == nullptr; i++) ; return i; } @@ -419,7 +419,7 @@ static int skipWordBackwards(char *string, int position) { char separators[] = " .,?"; int i; - for (i = position; i > 0 && strchr(separators, string[i - 1]) == NULL; i--) + for (i = position; i > 0 && strchr(separators, string[i - 1]) == nullptr; i--) ; return i; } @@ -542,7 +542,7 @@ void use(CONTEXT, int actor, int script) { admin[actor].script = script; admin[actor].step = 0; step = stepOf(actor); - if (step != NULL && step->after != 0) { + if (step != nullptr && step->after != 0) { FUNC1(evaluate, admin[actor].waitCount, step->after) } @@ -609,7 +609,7 @@ bool contains(Aptr string, Aptr substring) { strlow((char *)fromAptr(string)); strlow((char *)fromAptr(substring)); - found = (strstr((char *)fromAptr(string), (char *)fromAptr(substring)) != 0); + found = (strstr((char *)fromAptr(string), (char *)fromAptr(substring)) != nullptr); return found; } @@ -631,14 +631,14 @@ bool streq(char a[], char b[]) { /*======================================================================*/ void startTranscript(void) { - if (logFile == NULL) { + if (logFile == nullptr) { Common::String filename = g_vm->getTargetName() + ".log"; uint fileUsage = transcriptOption ? fileusage_Transcript : fileusage_InputRecord; frefid_t logFileRef = g_vm->glk_fileref_create_by_name(fileUsage, filename.c_str(), 0); logFile = g_vm->glk_stream_open_file(logFileRef, filemode_Write, 0); - if (logFile == NULL) { + if (logFile == nullptr) { transcriptOption = FALSE; logOption = FALSE; } else { @@ -650,11 +650,11 @@ void startTranscript(void) { /*======================================================================*/ void stopTranscript(void) { - if (logFile != NULL) { + if (logFile != nullptr) { if (transcriptOption || logOption) delete logFile; - logFile = NULL; + logFile = nullptr; transcriptOption = FALSE; logOption = FALSE; } diff --git a/engines/glk/alan3/fnmatch.cpp b/engines/glk/alan3/fnmatch.cpp index c30c521f02c..50448dc5cf0 100644 --- a/engines/glk/alan3/fnmatch.cpp +++ b/engines/glk/alan3/fnmatch.cpp @@ -107,12 +107,12 @@ int fnmatch(const char *pattern, const char *string, int flags) { if (c == EOS) if (flags & FNM_PATHNAME) return ((flags & FNM_LEADING_DIR) || - strchr(string, '/') == NULL ? + strchr(string, '/') == nullptr ? 0 : FNM_NOMATCH); else return (0); else if (c == '/' && flags & FNM_PATHNAME) { - if ((string = strchr(string, '/')) == NULL) + if ((string = strchr(string, '/')) == nullptr) return (FNM_NOMATCH); break; } diff --git a/engines/glk/alan3/glkio.cpp b/engines/glk/alan3/glkio.cpp index 8d791cbb4aa..186bae596c8 100644 --- a/engines/glk/alan3/glkio.cpp +++ b/engines/glk/alan3/glkio.cpp @@ -41,7 +41,7 @@ GlkIO::GlkIO(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, g bool GlkIO::initialize() { // first, open a window for error output - glkMainWin = glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + glkMainWin = glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 0); if (glkMainWin == nullptr) return false; @@ -136,7 +136,7 @@ void GlkIO::statusLine(CONTEXT) { glk_set_window(glkStatusWin); glk_window_clear(glkStatusWin); - glk_window_get_size(glkStatusWin, &glkWidth, NULL); + glk_window_get_size(glkStatusWin, &glkWidth, nullptr); onStatusLine = TRUE; col = 1; @@ -182,7 +182,7 @@ bool GlkIO::readLine(CONTEXT, char *buffer, size_t maxLen) { } else if (readingCommands) { if (glk_get_line_stream(commandFile, buffer, maxLen) == 0) { - glk_stream_close(commandFile, NULL); + glk_stream_close(commandFile, nullptr); readingCommands = FALSE; } else { glk_set_style(style_Input); @@ -211,7 +211,7 @@ bool GlkIO::readLine(CONTEXT, char *buffer, size_t maxLen) { buffer[event.val1] = 0; commandFileRef = glk_fileref_create_by_name(fileusage_InputRecord + fileusage_TextMode, &buffer[1], 0); commandFile = glk_stream_open_file(commandFileRef, filemode_Read, 0); - if (commandFile != NULL) + if (commandFile != nullptr) if (glk_get_line_stream(commandFile, buffer, maxLen) != 0) { readingCommands = TRUE; glk_set_style(style_Input); diff --git a/engines/glk/alan3/instance.cpp b/engines/glk/alan3/instance.cpp index 17877bca2aa..72cbee167c9 100644 --- a/engines/glk/alan3/instance.cpp +++ b/engines/glk/alan3/instance.cpp @@ -541,7 +541,7 @@ static char *wordWithCode(int classBit, int code) { return (char *)pointerTo(dictionary[w].string); sprintf(str, "Could not find word of class %d with code %d.", classBit, code); syserr(str); - return NULL; + return nullptr; } diff --git a/engines/glk/alan3/inter.cpp b/engines/glk/alan3/inter.cpp index 6d35e2cc354..3891751a1bd 100644 --- a/engines/glk/alan3/inter.cpp +++ b/engines/glk/alan3/inter.cpp @@ -53,9 +53,9 @@ bool fail = FALSE; /* PRIVATE DATA */ static int pc; -static Stack stack = NULL; +static Stack stack = nullptr; -static void (*interpreterMock)(Aaddr adr) = NULL; +static void (*interpreterMock)(Aaddr adr) = nullptr; /*======================================================================*/ @@ -438,7 +438,7 @@ void interpret(CONTEXT, Aaddr adr) { Aword i; /* Check for mock implementation */ - if (interpreterMock != NULL) { + if (interpreterMock != nullptr) { interpreterMock(adr); return; } diff --git a/engines/glk/alan3/lists.cpp b/engines/glk/alan3/lists.cpp index 1b50896cb6e..6f45449abb1 100644 --- a/engines/glk/alan3/lists.cpp +++ b/engines/glk/alan3/lists.cpp @@ -44,7 +44,7 @@ int lengthOfArrayImplementation(void *array_of_any_type, int element_size_in_byt int length; int element_size = element_size_in_bytes / sizeof(Aword); Aword *array = (Aword *)array_of_any_type; - if (array == NULL) + if (array == nullptr) syserr("Taking length of NULL array"); for (length = 0; !isEndOfArray(&array[length * element_size]); length++) ; diff --git a/engines/glk/alan3/main.cpp b/engines/glk/alan3/main.cpp index 9939e3a682d..3a8582aed4d 100644 --- a/engines/glk/alan3/main.cpp +++ b/engines/glk/alan3/main.cpp @@ -167,7 +167,7 @@ static void setupHeader(ACodeHeader tmphdr) { static void loadAndCheckMemory(ACodeHeader tmphdr, Aword crc, char err[]) { int i; /* No memory allocated yet? */ - if (memory == NULL) { + if (memory == nullptr) { memory = (Aword *)allocate(tmphdr.size * sizeof(Aword)); } @@ -428,12 +428,12 @@ static void initStaticData(void) { } /* Scores, if already allocated, copy initial data */ - if (scores == NULL) + if (scores == nullptr) scores = (Aword *)duplicate((Aword *) pointerTo(header->scores), header->scoreCount * sizeof(Aword)); else memcpy(scores, pointerTo(header->scores), header->scoreCount * sizeof(Aword)); - if (literals == NULL) + if (literals == nullptr) literals = (LiteralEntry *)allocate(sizeof(Aword) * (MAXPARAMS + 1)); stxs = (SyntaxEntry *) pointerTo(header->syntaxTableAddress); @@ -738,7 +738,7 @@ static void moveActor(CONTEXT, int theActor) { /*======================================================================*/ void run(void) { - Stack theStack = NULL; + Stack theStack = nullptr; Context ctx; openFiles(); diff --git a/engines/glk/alan3/memory.cpp b/engines/glk/alan3/memory.cpp index 030e8cfb835..ede62ab90fa 100644 --- a/engines/glk/alan3/memory.cpp +++ b/engines/glk/alan3/memory.cpp @@ -29,7 +29,7 @@ namespace Alan3 { /* PUBLIC DATA */ -Aword *memory = NULL; +Aword *memory = nullptr; static ACodeHeader dummyHeader; /* Dummy to use until memory allocated */ ACodeHeader *header = &dummyHeader; int memTop = 0; /* Top of load memory */ @@ -39,7 +39,7 @@ int memTop = 0; /* Top of load memory */ void *allocate(unsigned long lengthInBytes) { void *p = (void *)calloc((size_t)lengthInBytes, 1); - if (p == NULL) + if (p == nullptr) syserr("Out of memory."); return p; @@ -66,14 +66,14 @@ typedef struct { void *voidp; } PointerMapEntry; -static PointerMapEntry *pointerMap = NULL; +static PointerMapEntry *pointerMap = nullptr; static int pointerMapSize = 0; static int nextAptr = 1; /*======================================================================*/ void resetPointerMap(void) { - if (pointerMap != NULL) free(pointerMap); - pointerMap = NULL; + if (pointerMap != nullptr) free(pointerMap); + pointerMap = nullptr; pointerMapSize = 0; } @@ -95,12 +95,12 @@ void *fromAptr(Aptr aptr) { Aptr toAptr(void *ptr) { int index; - if (pointerMap == NULL) { + if (pointerMap == nullptr) { pointerMap = (PointerMapEntry *)allocate(sizeof(PointerMapEntry)); pointerMapSize = 1; } - for (index = 0; index < pointerMapSize && pointerMap[index].voidp != NULL; index++) + for (index = 0; index < pointerMapSize && pointerMap[index].voidp != nullptr; index++) ; if (index == pointerMapSize) { pointerMap = (PointerMapEntry *)realloc(pointerMap, (index + 1) * sizeof(PointerMapEntry)); diff --git a/engines/glk/alan3/msg.cpp b/engines/glk/alan3/msg.cpp index 438b58d6e23..dc0617397ca 100644 --- a/engines/glk/alan3/msg.cpp +++ b/engines/glk/alan3/msg.cpp @@ -39,7 +39,7 @@ void printMessage(MsgKind msg) { /* IN - message number */ } -static void (*errorHandler)(MsgKind msg) = NULL; +static void (*errorHandler)(MsgKind msg) = nullptr; /*======================================================================*/ void setErrorHandler(void (*handler)(MsgKind msg)) { /* IN - The error message number */ @@ -50,7 +50,7 @@ void setErrorHandler(void (*handler)(MsgKind msg)) { /* IN - The error message n /*======================================================================*/ void error(CONTEXT, MsgKind msgno) { /* IN - The error message number */ - if (errorHandler != NULL) + if (errorHandler != nullptr) errorHandler(msgno); else { /* Print an error message and longjmp to main loop. */ diff --git a/engines/glk/alan3/output.cpp b/engines/glk/alan3/output.cpp index 773d916b401..dedaaae3743 100644 --- a/engines/glk/alan3/output.cpp +++ b/engines/glk/alan3/output.cpp @@ -69,7 +69,7 @@ void getPageSize(void) { /*----------------------------------------------------------------------*/ static int updateColumn(int currentColumn, const char *string) { const char *newlinePosition = strrchr(string, '\n'); - if (newlinePosition != NULL) + if (newlinePosition != nullptr) return &string[strlen(string)] - newlinePosition; else return currentColumn + strlen(string); @@ -373,7 +373,7 @@ static bool punctuationNext(char *str) { const char *punctuation = strchr(".,!?", str[0]); bool end = str[1] == '\0'; bool space = isSpaceEquivalent(&str[1]); - return (punctuation != NULL && (end || space)); + return (punctuation != nullptr && (end || space)); } @@ -399,7 +399,7 @@ void output(const char *original) { space(); /* Output space if needed (& not inhibited) */ /* Output string up to symbol and handle the symbol */ - while ((symptr = strchr(str, '$')) != (char *) NULL) { + while ((symptr = strchr(str, '$')) != (char *) nullptr) { ch = *symptr; /* Terminate before symbol */ *symptr = '\0'; if (strlen(str) > 0) { @@ -426,7 +426,7 @@ void output(const char *original) { } if (needSpace) - capitalize = strchr("!?.", str[strlen(str) - 1]) != 0; + capitalize = strchr("!?.", str[strlen(str) - 1]) != nullptr; anyOutput = TRUE; free(copy); diff --git a/engines/glk/alan3/params.cpp b/engines/glk/alan3/params.cpp index 6fe9ae771d2..6d6b77f6457 100644 --- a/engines/glk/alan3/params.cpp +++ b/engines/glk/alan3/params.cpp @@ -31,13 +31,13 @@ namespace Glk { namespace Alan3 { /* PUBLIC DATA */ -Parameter *globalParameters = NULL; +Parameter *globalParameters = nullptr; /*======================================================================*/ Parameter *newParameter(int id) { Parameter *parameter = NEW(Parameter); parameter->instance = id; - parameter->candidates = NULL; + parameter->candidates = nullptr; return parameter; } @@ -56,7 +56,7 @@ void freeParameterArray(ParameterArray arrayPointer) { Parameter *p; for (p = arrayPointer; !isEndOfArray(p); p++) - if (p->candidates != NULL) + if (p->candidates != nullptr) freeParameterArray(p->candidates); deallocate(arrayPointer); } @@ -64,7 +64,7 @@ void freeParameterArray(ParameterArray arrayPointer) { /*======================================================================*/ Parameter *ensureParameterArrayAllocated(ParameterArray currentArray) { - if (currentArray == NULL) + if (currentArray == nullptr) return newParameterArray(); else { clearParameterArray(currentArray); @@ -75,7 +75,7 @@ Parameter *ensureParameterArrayAllocated(ParameterArray currentArray) { /*======================================================================*/ bool parameterArrayIsEmpty(ParameterArray array) { - return array == NULL || lengthOfParameterArray(array) == 0; + return array == nullptr || lengthOfParameterArray(array) == 0; } @@ -84,14 +84,14 @@ void clearParameter(Parameter *parameter) { Parameter *candidates = parameter->candidates; memset(parameter, 0, sizeof(Parameter)); parameter->candidates = candidates; - if (parameter->candidates != NULL) + if (parameter->candidates != nullptr) clearParameterArray(parameter->candidates); } /*======================================================================*/ void setGlobalParameters(ParameterArray newParameters) { - if (globalParameters == NULL) + if (globalParameters == nullptr) globalParameters = newParameterArray(); copyParameterArray(globalParameters, newParameters); } @@ -99,7 +99,7 @@ void setGlobalParameters(ParameterArray newParameters) { /*======================================================================*/ Parameter *getGlobalParameters(void) { - if (globalParameters == NULL) + if (globalParameters == nullptr) globalParameters = newParameterArray(); return globalParameters; } @@ -149,7 +149,7 @@ void compressParameterArray(Parameter theArray[]) { int lengthOfParameterArray(Parameter theArray[]) { int i = 0; - if (theArray == NULL) return 0; + if (theArray == nullptr) return 0; while (!isEndOfArray(&theArray[i])) i++; @@ -161,9 +161,9 @@ int lengthOfParameterArray(Parameter theArray[]) { bool equalParameterArrays(Parameter parameters1[], Parameter parameters2[]) { int i; - if ((parameters1 == NULL) != (parameters2 == NULL)) + if ((parameters1 == nullptr) != (parameters2 == nullptr)) return FALSE; - if (parameters1 == NULL) // Because then parameter2 is also NULL + if (parameters1 == nullptr) // Because then parameter2 is also NULL return TRUE; for (i = 0; !isEndOfArray(¶meters1[i]); i++) { if (isEndOfArray(¶meters2[i])) return FALSE; @@ -187,20 +187,20 @@ void copyParameter(Parameter *to, Parameter *from) { Parameter *toCandidates = to->candidates; *to = *from; - if (from->candidates != NULL) { - if (toCandidates == NULL) + if (from->candidates != nullptr) { + if (toCandidates == nullptr) to->candidates = newParameterArray(); else to->candidates = toCandidates; copyParameterArray(to->candidates, from->candidates); - } else if (toCandidates != NULL) + } else if (toCandidates != nullptr) freeParameterArray(toCandidates); } /*======================================================================*/ void addParameterToParameterArray(ParameterArray theArray, Parameter *theParameter) { - if (theArray == NULL) syserr("Adding to null parameter array"); + if (theArray == nullptr) syserr("Adding to null parameter array"); uint i; @@ -218,9 +218,9 @@ void addParameterToParameterArray(ParameterArray theArray, Parameter *theParamet void copyParameterArray(ParameterArray to, ParameterArray from) { int i; - if (to == NULL && from == NULL) return; + if (to == nullptr && from == nullptr) return; - if (to == NULL) + if (to == nullptr) syserr("Copying to null parameter array"); else { clearParameterArray(to); @@ -234,7 +234,7 @@ void copyParameterArray(ParameterArray to, ParameterArray from) { void subtractParameterArrays(Parameter theArray[], Parameter remove[]) { int i; - if (remove == NULL) return; + if (remove == nullptr) return; for (i = 0; !isEndOfArray(&theArray[i]); i++) if (inParameterArray(remove, theArray[i].instance)) diff --git a/engines/glk/alan3/parse.cpp b/engines/glk/alan3/parse.cpp index 4a7129f2a71..93ac9104c77 100644 --- a/engines/glk/alan3/parse.cpp +++ b/engines/glk/alan3/parse.cpp @@ -68,7 +68,7 @@ typedef void (*ParameterParser)(CONTEXT, Parameter parameters[]); /* PRIVATE DATA */ -static Pronoun *pronouns = NULL; +static Pronoun *pronouns = nullptr; /* Syntax Parameters */ @@ -94,7 +94,7 @@ static void addParameterForWord(Parameter *parameters, int wordIndex) { /*----------------------------------------------------------------------*/ static Pronoun *allocatePronounArray(Pronoun *currentList) { - if (currentList == NULL) + if (currentList == nullptr) currentList = (Pronoun *)allocate(sizeof(Pronoun) * (MAXPARAMS + 1)); clearPronounList(currentList); return currentList; @@ -344,7 +344,7 @@ static bool lastPossibleNoun(int wordIndex) { /*----------------------------------------------------------------------*/ static void updateWithReferences(Parameter result[], int wordIndex, Aint * (*referenceFinder)(int wordIndex)) { - static Parameter *references = NULL; /* Instances referenced by a word */ + static Parameter *references = nullptr; /* Instances referenced by a word */ references = ensureParameterArrayAllocated(references); copyReferencesToParameterArray(referenceFinder(wordIndex), references); @@ -635,7 +635,7 @@ static char *parameterNumberAndName(int parameterNumber) { /* HERE SHOULD BE current.syntax */ char *parameterName = parameterNameInSyntax(current.syntax, parameterNumber); - if (parameterName != NULL) + if (parameterName != nullptr) sprintf(buffer, "%s(#%d)", parameterName, parameterNumber); else sprintf(buffer, "#%d", parameterNumber); @@ -754,7 +754,7 @@ static ElementEntry *elementForParameter(ElementEntry *elms) { while (!isEndOfArray(elms) && elms->code != 0) elms++; if (isEndOfArray(elms)) - return NULL; + return nullptr; return elms; } @@ -763,7 +763,7 @@ static ElementEntry *elementForEndOfSyntax(ElementEntry *elms) { while (!isEndOfArray(elms) && (Aword)elms->code != EOS) elms++; if (isEndOfArray(elms)) /* No match for EOS! */ - return NULL; + return nullptr; return elms; } @@ -772,7 +772,7 @@ static ElementEntry *elementForWord(ElementEntry *elms, Aint wordCode) { while (!isEndOfArray(elms) && elms->code != wordCode) elms++; if (isEndOfArray(elms)) - return NULL; + return nullptr; return elms; } @@ -796,7 +796,7 @@ static ElementEntry *parseInputAccordingToSyntax(CONTEXT, SyntaxEntry *syntax, P ElementEntry *nextElement = currentElement; int parameterCount = 0; - while (nextElement != NULL) { + while (nextElement != nullptr) { /* Traverse the possible branches of currentElement to find a match, let the actual input control what we look for */ parameterPositions[parameterCount].endOfList = TRUE; @@ -809,7 +809,7 @@ static ElementEntry *parseInputAccordingToSyntax(CONTEXT, SyntaxEntry *syntax, P if (isInstanceReferenceWord(currentWordIndex)) { /* If so, save word info for this parameterPosition */ nextElement = elementForParameter(currentElement); - if (nextElement != NULL) { + if (nextElement != nullptr) { // Create parameter structure for the parameter position based on player words // but without resolving them ParameterPosition *parameterPosition = ¶meterPositions[parameterCount]; @@ -828,7 +828,7 @@ static ElementEntry *parseInputAccordingToSyntax(CONTEXT, SyntaxEntry *syntax, P if (isPrepositionWord(currentWordIndex) || isVerbWord(currentWordIndex)) { /* A preposition? Or rather, an intermediate word? */ nextElement = elementForWord(currentElement, dictionary[playerWords[currentWordIndex].code].code); - if (nextElement != NULL) { + if (nextElement != nullptr) { currentWordIndex++; /* Word matched, go to next */ currentElement = (ElementEntry *) pointerTo(nextElement->next); continue; @@ -840,9 +840,9 @@ static ElementEntry *parseInputAccordingToSyntax(CONTEXT, SyntaxEntry *syntax, P R0CALL1(errorButAfterAll, currentWordIndex) /* If we get here we couldn't match anything... */ - nextElement = NULL; + nextElement = nullptr; } - return NULL; + return nullptr; } @@ -871,7 +871,7 @@ static bool anyAll(ParameterPosition parameterPositions[]) { /*----------------------------------------------------------------------*/ static void checkRestrictedParameters(CONTEXT, ParameterPosition parameterPositions[], ElementEntry elms[]) { RestrictionEntry *restriction; - static Parameter *localParameters = NULL; + static Parameter *localParameters = nullptr; int i; localParameters = ensureParameterArrayAllocated(localParameters); @@ -911,7 +911,7 @@ static void checkRestrictedParameters(CONTEXT, ParameterPosition parameterPositi parameterPositions[restriction->parameterNumber - 1].checked = TRUE; } freeParameterArray(localParameters); - localParameters = NULL; + localParameters = nullptr; } @@ -959,7 +959,7 @@ static void restrictParametersAccordingToSyntax(CONTEXT, ParameterPosition param /*----------------------------------------------------------------------*/ static void matchPronoun(CONTEXT, Parameter *parameter) { - static Parameter *pronounInstances = NULL; + static Parameter *pronounInstances = nullptr; pronounInstances = ensureParameterArrayAllocated(pronounInstances); int pronounCandidateCount = getPronounInstances(playerWords[parameter->firstWord].code, pronounInstances); @@ -1022,7 +1022,7 @@ static void findCandidates(CONTEXT, Parameter parameters[], void (*instanceMatch /*----------------------------------------------------------------------*/ static void handleFailedParse(CONTEXT, ElementEntry *elms) { - if (elms == NULL) + if (elms == nullptr) error(context, M_WHAT); else if (elms->next == 0) { /* No verb code, verb not declared! */ /* TODO Does this ever happen? */ @@ -1145,7 +1145,7 @@ static Parameter *disambiguate00N(CONTEXT, Parameter allCandidates[], Parameter R0CALL1(errorWhat, allCandidates[0].firstWord) else R0CALL1(errorNoSuch, allCandidates[0]); - return NULL; + return nullptr; } static Parameter *disambiguate01N(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { @@ -1153,7 +1153,7 @@ static Parameter *disambiguate01N(CONTEXT, Parameter allCandidates[], Parameter R0CALL1(errorWhat, allCandidates[0].firstWord) else R0CALL1(errorNoSuch, allCandidates[0]) - return NULL; + return nullptr; } static Parameter *disambiguate0MN(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { @@ -1161,7 +1161,7 @@ static Parameter *disambiguate0MN(CONTEXT, Parameter allCandidates[], Parameter R0CALL1(errorWhat, allCandidates[0].firstWord) else R0CALL1(errorNoSuch, allCandidates[0]) - return NULL; + return nullptr; } static Parameter *disambiguate10N(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { @@ -1177,29 +1177,29 @@ static Parameter *disambiguate1MN(CONTEXT, Parameter allCandidates[], Parameter } static Parameter *disambiguateM0N(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { R0CALL1(errorWhichOne, presentCandidates) - return NULL; + return nullptr; } static Parameter *disambiguateM1N(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { R0CALL1(errorWhichOne, presentCandidates) - return NULL; + return nullptr; } static Parameter *disambiguateMMN(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { R0CALL1(errorWhichOne, presentCandidates) - return NULL; + return nullptr; } static Parameter *disambiguate00Y(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { errorNoSuch(context, allCandidates[0]); - return NULL; + return nullptr; } static Parameter *disambiguate01Y(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { return allCandidates; } static Parameter *disambiguate0MY(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { R0CALL1(errorWhichOne, allCandidates) - return NULL; + return nullptr; } static Parameter *disambiguate10Y(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { return presentCandidates; @@ -1212,15 +1212,15 @@ static Parameter *disambiguate1MY(CONTEXT, Parameter allCandidates[], Parameter } static Parameter *disambiguateM0Y(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { R0CALL1(errorWhichOne, presentCandidates) - return NULL; + return nullptr; } static Parameter *disambiguateM1Y(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { R0CALL1(errorWhichOne, presentCandidates) - return NULL; + return nullptr; } static Parameter *disambiguateMMY(CONTEXT, Parameter allCandidates[], Parameter presentCandidates[]) { R0CALL1(errorWhichOne, presentCandidates) - return NULL; + return nullptr; } static DisambiguationHandlerTable disambiguationHandlerTable = { @@ -1273,7 +1273,7 @@ static DisambiguationHandlerTable disambiguationHandlerTable = { /*----------------------------------------------------------------------*/ static void disambiguateCandidates(CONTEXT, Parameter *allCandidates, bool omnipotent, bool (*reachable)(int), DisambiguationHandlerTable handler) { - static Parameter *presentCandidates = NULL; + static Parameter *presentCandidates = nullptr; int present; int distant; Parameter *result; @@ -1349,8 +1349,8 @@ static void disambiguate(CONTEXT, ParameterPosition parameterPositions[], Elemen /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ static void tryParam(CONTEXT, Parameter parameters[], Parameter multipleParameters[]) { ElementEntry *element; /* Pointer to element list */ - static ParameterPosition *parameterPositions = NULL; - if (parameterPositions != NULL) + static ParameterPosition *parameterPositions = nullptr; + if (parameterPositions != nullptr) deallocateParameterPositions(parameterPositions); // TODO newParameterPositionArray()!!!! Or even reallocatePP.. or cleanPP.. @@ -1366,7 +1366,7 @@ static void tryParam(CONTEXT, Parameter parameters[], Parameter multipleParamete convertMultipleCandidatesToMultipleParameters(parameterPositions, multipleParameters); deallocateParameterPositions(parameterPositions); - parameterPositions = NULL; + parameterPositions = nullptr; } @@ -1471,8 +1471,8 @@ static void parseInstanceCommand(CONTEXT, Parameter parameters[], Parameter mult /*======================================================================*/ void parse(CONTEXT) { /* longjmp's ahead so these need to survive to not leak memory */ - static Parameter *parameters = NULL; - static Parameter *multipleParameters = NULL; + static Parameter *parameters = nullptr; + static Parameter *multipleParameters = nullptr; parameters = ensureParameterArrayAllocated(parameters); multipleParameters = ensureParameterArrayAllocated(multipleParameters); @@ -1512,9 +1512,9 @@ void parse(CONTEXT) { clearParameterArray(previousMultipleParameters); freeParameterArray(parameters); - parameters = NULL; + parameters = nullptr; freeParameterArray(multipleParameters); - multipleParameters = NULL; + multipleParameters = nullptr; } } // End of namespace Alan3 diff --git a/engines/glk/alan3/reverse.cpp b/engines/glk/alan3/reverse.cpp index ead87251ea8..4d705746486 100644 --- a/engines/glk/alan3/reverse.cpp +++ b/engines/glk/alan3/reverse.cpp @@ -37,7 +37,7 @@ extern Aword *memory; /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ static Aaddr memorySize = 0; -static Aword *addressesDone = NULL; +static Aword *addressesDone = nullptr; static int numberDone = 0; static int doneSize = 0; diff --git a/engines/glk/alan3/scan.cpp b/engines/glk/alan3/scan.cpp index 881f08178cc..45dfdfb344a 100644 --- a/engines/glk/alan3/scan.cpp +++ b/engines/glk/alan3/scan.cpp @@ -47,7 +47,7 @@ bool continued = FALSE; static char buf[1000]; /* The input buffer */ static char isobuf[1000]; /* The input buffer in ISO */ static bool eol = TRUE; /* Looking at End of line? Yes, initially */ -static char *token = NULL; +static char *token = nullptr; /*======================================================================*/ @@ -102,7 +102,7 @@ static char *gettoken(char *txtBuf) { static char *marker; static char oldch; - if (txtBuf == NULL) + if (txtBuf == nullptr) *marker = oldch; else marker = txtBuf; @@ -121,7 +121,7 @@ static char *gettoken(char *txtBuf) { marker++; marker++; } else if (*marker == '\0' || *marker == '\n' || *marker == ';') - return NULL; + return nullptr; else marker++; oldch = *marker; @@ -169,20 +169,20 @@ static void getLine(CONTEXT) { strcpy(isobuf, buf); token = gettoken(isobuf); - if (token != NULL) { + if (token != nullptr) { if (strcmp("debug", token) == 0 && header->debug) { debugOption = TRUE; CALL3(debug, FALSE, 0, 0) - token = NULL; + token = nullptr; } else if (strcmp("undo", token) == 0) { - token = gettoken(NULL); - if (token != NULL) /* More tokens? */ + token = gettoken(nullptr); + if (token != nullptr) /* More tokens? */ CALL1(error, M_WHAT) CALL0(undo) } } - } while (token == NULL); + } while (token == nullptr); eol = FALSE; } @@ -196,8 +196,8 @@ void scan(CONTEXT) { if (continued) { /* Player used '.' to separate commands. Read next */ para(); - token = gettoken(NULL); /* Or did he just finish the command with a full stop? */ - if (token == NULL) { + token = gettoken(nullptr); /* Or did he just finish the command with a full stop? */ + if (token == nullptr) { CALL0(getLine) } continued = FALSE; @@ -236,7 +236,7 @@ void scan(CONTEXT) { } else CALL1(unknown, token) setEndOfArray(&playerWords[i]); - eol = (token = gettoken(NULL)) == NULL; + eol = (token = gettoken(nullptr)) == nullptr; } while (!eol); } diff --git a/engines/glk/alan3/set.cpp b/engines/glk/alan3/set.cpp index c5750c455c0..dc9bdd304fa 100644 --- a/engines/glk/alan3/set.cpp +++ b/engines/glk/alan3/set.cpp @@ -159,8 +159,8 @@ bool equalSets(Set *set1, Set *set2) { /*======================================================================*/ void freeSet(Set *theSet) { - if (theSet != NULL) { - if (theSet->members != NULL) + if (theSet != nullptr) { + if (theSet->members != nullptr) deallocate(theSet->members); deallocate(theSet); } diff --git a/engines/glk/alan3/stack.cpp b/engines/glk/alan3/stack.cpp index a2a7989fa00..ca87ce088be 100644 --- a/engines/glk/alan3/stack.cpp +++ b/engines/glk/alan3/stack.cpp @@ -44,7 +44,7 @@ Stack createStack(int size) { /*======================================================================*/ void deleteStack(Stack theStack) { - if (theStack == NULL) + if (theStack == nullptr) syserr("deleting a NULL stack"); deallocate(theStack->stack); @@ -62,7 +62,7 @@ int stackDepth(Stack theStack) { void dumpStack(Stack theStack) { int i; - if (theStack == NULL) + if (theStack == nullptr) syserr("NULL stack not supported anymore"); printf("["); @@ -76,7 +76,7 @@ void dumpStack(Stack theStack) { /*======================================================================*/ void push(Stack theStack, Aptr i) { - if (theStack == NULL) + if (theStack == nullptr) syserr("NULL stack not supported anymore"); if (theStack->stackp == theStack->stackSize) @@ -87,7 +87,7 @@ void push(Stack theStack, Aptr i) { /*======================================================================*/ Aptr pop(Stack theStack) { - if (theStack == NULL) + if (theStack == nullptr) syserr("NULL stack not supported anymore"); if (theStack->stackp == 0) @@ -98,7 +98,7 @@ Aptr pop(Stack theStack) { /*======================================================================*/ Aptr top(Stack theStack) { - if (theStack == NULL) + if (theStack == nullptr) syserr("NULL stack not supported anymore"); return theStack->stack[theStack->stackp - 1]; @@ -111,7 +111,7 @@ Aptr top(Stack theStack) { void newFrame(Stack theStack, Aint noOfLocals) { int n; - if (theStack == NULL) + if (theStack == nullptr) syserr("NULL stack not supported anymore"); push(theStack, theStack->framePointer); @@ -130,7 +130,7 @@ Aptr getLocal(Stack theStack, Aint framesBelow, Aint variableNumber) { if (variableNumber < 1) syserr("Reading a non-existing block-local variable."); - if (theStack == NULL) + if (theStack == nullptr) syserr("NULL stack not supported anymore"); frame = theStack->framePointer; @@ -151,7 +151,7 @@ void setLocal(Stack theStack, Aint framesBelow, Aint variableNumber, Aptr value) if (variableNumber < 1) syserr("Writing a non-existing block-local variable."); - if (theStack == NULL) + if (theStack == nullptr) syserr("NULL stack not supported anymore"); frame = theStack->framePointer; @@ -164,7 +164,7 @@ void setLocal(Stack theStack, Aint framesBelow, Aint variableNumber, Aptr value) /*======================================================================*/ void endFrame(Stack theStack) { - if (theStack == NULL) + if (theStack == nullptr) syserr("NULL stack not supported anymore"); theStack->stackp = theStack->framePointer; diff --git a/engines/glk/alan3/state.cpp b/engines/glk/alan3/state.cpp index 0ebf52f3a4d..fa39ea503a5 100644 --- a/engines/glk/alan3/state.cpp +++ b/engines/glk/alan3/state.cpp @@ -59,7 +59,7 @@ struct game_state { /* PRIVATE DATA */ static GameState gameState; /* TODO: Make pointer, then we don't have to copy to stack, we can just use the pointer */ -static StateStackP stateStack = NULL; +static StateStackP stateStack = nullptr; static char *playerCommand; @@ -116,7 +116,7 @@ void deallocateGameState(GameState *gState) { if (gState->eventQueueTop > 0) { deallocate(gState->eventQueue); - gState->eventQueue = NULL; + gState->eventQueue = nullptr; } if (gState->scores) deallocate(gState->scores); @@ -133,14 +133,14 @@ void forgetGameState(void) { char *playerCmd; popGameState(stateStack, &gameState, &playerCmd); deallocateGameState(&gameState); - if (playerCmd != NULL) + if (playerCmd != nullptr) deallocate(playerCmd); } /*======================================================================*/ void initStateStack(void) { - if (stateStack != NULL) + if (stateStack != nullptr) deleteStateStack(stateStack); stateStack = createStateStack(sizeof(GameState)); } @@ -149,7 +149,7 @@ void initStateStack(void) { /*======================================================================*/ void terminateStateStack(void) { deleteStateStack(stateStack); - stateStack = NULL; + stateStack = nullptr; } @@ -166,7 +166,7 @@ static Set **collectSets(void) { Set **sets; int i; - if (count == 0) return NULL; + if (count == 0) return nullptr; sets = (Set **)allocate(count * sizeof(Set)); @@ -185,7 +185,7 @@ static char **collectStrings(void) { char **strings; int i; - if (count == 0) return NULL; + if (count == 0) return nullptr; strings = (char **)allocate(count * sizeof(char *)); @@ -225,8 +225,8 @@ static void collectInstanceData(void) { /*----------------------------------------------------------------------*/ static void collectScores(void) { gameState.score = current.score; - if (scores == NULL) - gameState.scores = NULL; + if (scores == nullptr) + gameState.scores = nullptr; else gameState.scores = (Aword *)duplicate(scores, header->scoreCount * sizeof(Aword)); } @@ -238,7 +238,7 @@ void rememberGameState(void) { collectInstanceData(); collectScores(); - if (stateStack == NULL) + if (stateStack == nullptr) initStateStack(); pushGameState(stateStack, &gameState); @@ -269,7 +269,7 @@ static void recallSets(Set **sets) { entry = (SetInitEntry *)pointerTo(header->setInitTable); for (i = 0; i < count; i++) { setAttribute(admin[entry[i].instanceCode].attributes, entry[i].attributeCode, toAptr(sets[i])); - sets[i] = NULL; /* Since we reuse the saved set, we need to clear the pointer */ + sets[i] = nullptr; /* Since we reuse the saved set, we need to clear the pointer */ } } @@ -297,7 +297,7 @@ static void recallStrings(char **strings) { entry = (StringInitEntry *)pointerTo(header->stringInitTable); for (i = 0; i < count; i++) { setAttribute(admin[entry[i].instanceCode].attributes, entry[i].attributeCode, toAptr(strings[i])); - strings[i] = NULL; /* Since we reuse the saved, we need to clear the state */ + strings[i] = nullptr; /* Since we reuse the saved, we need to clear the state */ } } @@ -315,7 +315,7 @@ static void recallEvents(void) { /*----------------------------------------------------------------------*/ static void recallInstances(void) { - if (admin == NULL) + if (admin == nullptr) syserr("admin[] == NULL in recallInstances()"); memcpy(admin, gameState.admin, diff --git a/engines/glk/alan3/state_stack.cpp b/engines/glk/alan3/state_stack.cpp index 3c749139306..d9f6e58c1be 100644 --- a/engines/glk/alan3/state_stack.cpp +++ b/engines/glk/alan3/state_stack.cpp @@ -45,7 +45,7 @@ struct StateStackStructure { /*----------------------------------------------------------------------*/ static void *reallocate(void *from, int newSize) { void *newArea = realloc(from, newSize * sizeof(void *)); - if (newArea == NULL) + if (newArea == nullptr) syserr("Out of memory in 'reallocateStack()'"); return newArea; } @@ -62,7 +62,7 @@ StateStackP createStateStack(int elementSize) { /*======================================================================*/ void deleteStateStack(StateStackP stateStack) { - if (stateStack != NULL) { + if (stateStack != nullptr) { while (stateStack->stackPointer > 0) { stateStack->stackPointer--; deallocateGameState((GameState *)stateStack->states[stateStack->stackPointer]); @@ -99,7 +99,7 @@ void pushGameState(StateStackP stateStack, void *gameState) { void *element = allocate(stateStack->elementSize); memcpy(element, gameState, stateStack->elementSize); ensureSpaceForGameState(stateStack); - stateStack->commands[stateStack->stackPointer] = NULL; + stateStack->commands[stateStack->stackPointer] = nullptr; stateStack->states[stateStack->stackPointer++] = element; } diff --git a/engines/glk/alan3/syntax.cpp b/engines/glk/alan3/syntax.cpp index a3c44c6bb07..c28900bd7b2 100644 --- a/engines/glk/alan3/syntax.cpp +++ b/engines/glk/alan3/syntax.cpp @@ -64,19 +64,19 @@ static SyntaxEntry *findSyntaxEntry(int verbCode) { return stx; break; } - return NULL; + return nullptr; } /*======================================================================*/ SyntaxEntry *findSyntaxTreeForVerb(CONTEXT, int verbCode) { - SyntaxEntry *foundStx = NULL; + SyntaxEntry *foundStx = nullptr; if (isPreBeta2(header->version)) { foundStx = findSyntaxEntryForPreBeta2(verbCode, foundStx); } else { foundStx = findSyntaxEntry(verbCode); } - if (foundStx == NULL) + if (foundStx == nullptr) // No matching syntax R0CALL1(error, M_WHAT) return foundStx; diff --git a/engines/glk/alan3/sysdep.cpp b/engines/glk/alan3/sysdep.cpp index 268ea9cead1..499d1a7b3de 100644 --- a/engines/glk/alan3/sysdep.cpp +++ b/engines/glk/alan3/sysdep.cpp @@ -101,17 +101,17 @@ static const byte upperCaseCharacters[] = { int isSpace(unsigned int c) { - return (c != '\0' && strchr((const char *)spaceCharacters, c) != 0); + return (c != '\0' && strchr((const char *)spaceCharacters, c) != nullptr); } int isLower(unsigned int c) { - return (c != '\0' && strchr((const char *)lowerCaseCharacters, c) != 0); + return (c != '\0' && strchr((const char *)lowerCaseCharacters, c) != nullptr); } int isUpper(unsigned int c) { - return (c != '\0' && strchr((const char *)upperCaseCharacters, c) != 0); + return (c != '\0' && strchr((const char *)upperCaseCharacters, c) != nullptr); } int isLetter(unsigned int c) { @@ -321,7 +321,7 @@ char *baseNameStart(char *fullPathName) { int i; for (i = strlen(fullPathName) - 1; i > 0; i--) - if (strchr(delimiters, fullPathName[i]) != NULL) + if (strchr(delimiters, fullPathName[i]) != nullptr) return &fullPathName[i + 1]; return (fullPathName); } diff --git a/engines/glk/alan3/syserr.cpp b/engines/glk/alan3/syserr.cpp index 6ed6d0b95dc..a126757cc82 100644 --- a/engines/glk/alan3/syserr.cpp +++ b/engines/glk/alan3/syserr.cpp @@ -68,7 +68,7 @@ void setSyserrHandler(void (*f)(const char *)) { // TODO Make syserr() use ... as printf() void syserr(const char *description) { lin = 0; - if (handler == NULL) { + if (handler == nullptr) { const char *blurb = ""; /*======================================================================*/ void apperr(const char *description) { - if (handler == NULL) { + if (handler == nullptr) { const char *blurb = "_words.size(); i++) if (word_match(&game->_words[i], string)) return &game->_words[i]; - return NULL; + return nullptr; } Word *dict_find_word_by_index_type(ComprehendGame *game, @@ -60,7 +60,7 @@ Word *dict_find_word_by_index_type(ComprehendGame *game, return &game->_words[i]; } - return NULL; + return nullptr; } Word *find_dict_word_by_index(ComprehendGame *game, @@ -73,7 +73,7 @@ Word *find_dict_word_by_index(ComprehendGame *game, return &game->_words[i]; } - return NULL; + return nullptr; } bool dict_match_index_type(ComprehendGame *game, const char *word, diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp index 054a9213206..51ba45d5fac 100644 --- a/engines/glk/comprehend/game.cpp +++ b/engines/glk/comprehend/game.cpp @@ -225,7 +225,7 @@ void ComprehendGame::console_println(const char *text) { while (*p) { switch (*p) { case '\n': - word = NULL; + word = nullptr; word_len = 0; g_comprehend->print("\n"); p++; @@ -372,7 +372,7 @@ Item *ComprehendGame::get_item_by_noun(byte noun) { if (_items[i]._word == noun) return &_items[i]; - return NULL; + return nullptr; } int ComprehendGame::get_item_id(byte noun) { @@ -392,7 +392,7 @@ void ComprehendGame::update_graphics() { if (!g_comprehend->isGraphicsEnabled()) return; - type = roomIsSpecial(_currentRoomCopy, NULL); + type = roomIsSpecial(_currentRoomCopy, nullptr); switch (type) { case ROOM_IS_DARK: diff --git a/engines/glk/glk_api.cpp b/engines/glk/glk_api.cpp index 6a0ee405687..fa326726fbb 100644 --- a/engines/glk/glk_api.cpp +++ b/engines/glk/glk_api.cpp @@ -242,7 +242,7 @@ uint GlkAPI::glk_window_get_type(winid_t win) { winid_t GlkAPI::glk_window_get_parent(winid_t win) { if (!win) { warning("window_get_parent: invalid ref"); - return 0; + return nullptr; } return win->_parent; diff --git a/engines/glk/hugo/heglk.cpp b/engines/glk/hugo/heglk.cpp index 4eeacb65041..ea29af90298 100644 --- a/engines/glk/hugo/heglk.cpp +++ b/engines/glk/hugo/heglk.cpp @@ -27,7 +27,7 @@ namespace Hugo { void Hugo::hugo_init_screen() { // Open the main window... - mainwin = currentwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 1); + mainwin = currentwin = glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 1); assert(mainwin); // ...and set it up for default output diff --git a/engines/glk/hugo/hemedia.cpp b/engines/glk/hugo/hemedia.cpp index ba7fdb23cab..8c4bbddcace 100644 --- a/engines/glk/hugo/hemedia.cpp +++ b/engines/glk/hugo/hemedia.cpp @@ -70,7 +70,7 @@ int Hugo::loadres(HUGO_FILE infile, int reslen, int type) { reslen -= n; } - glk_stream_close(stream, NULL); + glk_stream_close(stream, nullptr); return idVal; } diff --git a/engines/glk/jacl/encapsulate.cpp b/engines/glk/jacl/encapsulate.cpp index 8daba293d28..96bcd0483df 100644 --- a/engines/glk/jacl/encapsulate.cpp +++ b/engines/glk/jacl/encapsulate.cpp @@ -120,7 +120,7 @@ encapsulate() { /* NULL OUT ALL THE WORD POINTERS BEYOND THE LAST WORD */ for (index = position; index < MAX_WORDS; index++) - word[index] = NULL; + word[index] = nullptr; wp = 0; } @@ -221,7 +221,7 @@ command_encapsulate() { // NULL OUT ALL THE WORD POINTERS BEYOND THE LAST WORD for (index = position; index < MAX_WORDS; index++) { - word[index] = NULL; + word[index] = nullptr; } wp = 0; @@ -238,19 +238,19 @@ jacl_truncate() { struct filter_type *filter = filter_table; // REMOVE ALL THE DEFINED 'filter's FROM THE PLAYER'S COMMAND - if (filter != NULL) { - while (word[position] != NULL) { + if (filter != nullptr) { + while (word[position] != nullptr) { match = FALSE; do { if (!strcmp(word[position], filter->word)) { - for (index = position; word[index + 1] != NULL; + for (index = position; word[index + 1] != nullptr; index++) word[index] = word[index + 1]; - word[index] = NULL; + word[index] = nullptr; match = TRUE; } filter = filter->next_filter; - } while (filter != NULL && !match); + } while (filter != nullptr && !match); filter = filter_table; if (!match) position++; @@ -258,15 +258,15 @@ jacl_truncate() { } // SUBTITUTE ALL THE DEFINED 'synonym's IN THE PLAYER'S COMMAND - if (synonym_table != NULL) { - for (counter = 0; word[counter] != NULL; counter++) { + if (synonym_table != nullptr) { + for (counter = 0; word[counter] != nullptr; counter++) { synonym = synonym_table; do { if (!strcmp(word[counter], synonym->original)) { word[counter] = synonym->standard; break; } - if (synonym->next_synonym != NULL) + if (synonym->next_synonym != nullptr) synonym = synonym->next_synonym; else break; diff --git a/engines/glk/jacl/findroute.cpp b/engines/glk/jacl/findroute.cpp index d05dbea590e..c6d09c0682c 100644 --- a/engines/glk/jacl/findroute.cpp +++ b/engines/glk/jacl/findroute.cpp @@ -47,32 +47,32 @@ struct Queue { }; void qInit(Queue *q) { - q->head = q->tail = NULL; + q->head = q->tail = nullptr; } void qDelete(Queue *q) { QueueNode *node, *next; - for (node = q->head; node != NULL; node = next) { + for (node = q->head; node != nullptr; node = next) { next = node->next; free(node); } - q->head = q->tail = NULL; + q->head = q->tail = nullptr; } int qIsEmpty(Queue *q) { - return (q->head == NULL); + return (q->head == nullptr); } void qDebug(Queue *q) { debug("Queue:"); - if (q->head == NULL) { + if (q->head == nullptr) { debug(" empty"); } else { QueueNode *node; - for (node = q->head; node != NULL; node = node->next) { + for (node = q->head; node != nullptr; node = node->next) { debug(" %d (%d)", node->val, node->val2); } } @@ -84,9 +84,9 @@ void qAppend(Queue *q, int val, int val2) { QueueNode *node = (QueueNode *) malloc(sizeof(QueueNode)); node->val = val; node->val2 = val2; - node->next = NULL; + node->next = nullptr; - if (q->head == NULL) { + if (q->head == nullptr) { q->head = q->tail = node; } else { q->tail->next = node; @@ -101,7 +101,7 @@ void qPop(Queue *q, int *val, int *val2) { *val2 = q->head->val2; if (q->head == q->tail) { - q->head = q->tail = NULL; + q->head = q->tail = nullptr; } else { q->head = q->head->next; } @@ -163,7 +163,7 @@ void setInit(Set *set) { int n; for (n = 0; n < SET_HASHSIZE; n++) { - set->node[n] = NULL; + set->node[n] = nullptr; } } @@ -173,12 +173,12 @@ void setDelete(Set *set) { for (n = 0; n < SET_HASHSIZE; n++) { SetNode *node, *next; - for (node = set->node[n]; node != NULL; node = next) { + for (node = set->node[n]; node != nullptr; node = next) { next = node->next; free(node); } - set->node[n] = NULL; + set->node[n] = nullptr; } } @@ -190,7 +190,7 @@ void setDebug(Set *set) { for (n = 0; n < SET_HASHSIZE; n++) { SetNode *node; - for (node = set->node[n]; node != NULL; node = node->next) { + for (node = set->node[n]; node != nullptr; node = node->next) { debug(" %d", node->val); } } @@ -208,7 +208,7 @@ void setAdd(Set *set, int val) { /* check if val is already in the set */ - for (node = set->node[n]; node != NULL; node = node->next) { + for (node = set->node[n]; node != nullptr; node = node->next) { if (node->val == val) { return; } @@ -226,7 +226,7 @@ int setContains(Set *set, int val) { SetNode *node; int n = setHash(val); - for (node = set->node[n]; node != NULL; node = node->next) { + for (node = set->node[n]; node != nullptr; node = node->next) { if (node->val == val) { return 1; } @@ -297,7 +297,7 @@ int find_route(int fromRoom, int toRoom, int known) { if (dest < 1 || dest > objects) continue; - if (object[dest] == NULL) continue; + if (object[dest] == nullptr) continue; if (dest != NOWHERE && !setContains(&visited, dest)) { if (!known || (object[dest]->attributes & KNOWN)) { diff --git a/engines/glk/jacl/glk_saver.cpp b/engines/glk/jacl/glk_saver.cpp index 54739d82226..7b8fb2d335a 100644 --- a/engines/glk/jacl/glk_saver.cpp +++ b/engines/glk/jacl/glk_saver.cpp @@ -64,12 +64,12 @@ bool save_game(strid_t save) { write_integer(save, functions); write_integer(save, strings); - while (current_integer != NULL) { + while (current_integer != nullptr) { write_integer(save, current_integer->value); current_integer = current_integer->next_integer; } - while (current_function != NULL) { + while (current_function != nullptr) { write_integer(save, current_function->call_count); current_function = current_function->next_function; } @@ -87,7 +87,7 @@ bool save_game(strid_t save) { } // Write out all the current values of the string variables - while (current_string != NULL) { + while (current_string != nullptr) { for (index = 0; index < 255; index++) { g_vm->glk_put_char_stream(save, current_string->value[index]); } @@ -131,16 +131,16 @@ bool restore_game(strid_t save, bool warn) { if (warn == FALSE) { log_error(cstring_resolve("BAD_SAVED_GAME")->value, PLUS_STDOUT); } - g_vm->glk_stream_close(save, NULL); + g_vm->glk_stream_close(save, nullptr); return (FALSE); } - while (current_integer != NULL) { + while (current_integer != nullptr) { current_integer->value = read_integer(save); current_integer = current_integer->next_integer; } - while (current_function != NULL) { + while (current_function != nullptr) { current_function->call_count = read_integer(save); current_function = current_function->next_function; } @@ -157,7 +157,7 @@ bool restore_game(strid_t save, bool warn) { object[index]->user_attributes = read_integer(save); } - while (current_string != NULL) { + while (current_string != nullptr) { for (index = 0; index < 255; index++) { current_string->value[index] = g_vm->glk_get_char_stream(save); } diff --git a/engines/glk/jacl/interpreter.cpp b/engines/glk/jacl/interpreter.cpp index d7586677135..a8ae09682bf 100644 --- a/engines/glk/jacl/interpreter.cpp +++ b/engines/glk/jacl/interpreter.cpp @@ -66,7 +66,7 @@ const char *strcasestr(const char *s, const char *find) { do { do { if ((sc = *s++) == 0) - return (NULL); + return (nullptr); } while ((char)tolower((unsigned char)sc) != c); } while (scumm_strnicmp(s, find, len) != 0); s--; @@ -89,7 +89,7 @@ const char *location_attributes[] = { "VISITED ", "DARK ", "ON_WATER ", "UNDER_WATER ", "WITHOUT_AIR ", "OUTDOORS ", "MID_AIR ", "TIGHT_ROPE ", "POLLUTED ", "SOLVED ", "MID_WATER ", "DARKNESS ", "MAPPED ", "KNOWN ", - NULL + nullptr }; const char *object_attributes[] = { @@ -98,19 +98,19 @@ const char *object_attributes[] = { "CONTAINER ", "SURFACE ", "PLURAL ", "FLAMMABLE ", "BURNING ", "LOCATION ", "ON ", "DAMAGED ", "FEMALE ", "POSSESSIVE ", "OUT_OF_REACH ", "TOUCHED ", "SCORED ", "SITTING ", "NPC ", "DONE ", "GAS ", "NO_TAB ", - "NOT_IMPORTANT ", NULL + "NOT_IMPORTANT ", nullptr }; const char *object_elements[] = { "parent", "capacity", "mass", "bearing", "velocity", "next", "previous", "child", "index", "status", "state", "counter", "points", "class", "x", "y", - NULL + nullptr }; const char *location_elements[] = { "north", "south", "east", "west", "northeast", "northwest", "southeast", "southwest", "up", "down", "in", "out", "points", "class", "x", "y", - NULL + nullptr }; struct csv_parser parser_csv; @@ -127,16 +127,16 @@ int field_no = 0; struct stack_type backup[STACK_SIZE]; struct proxy_type proxy_backup[STACK_SIZE]; -struct function_type *resolved_function = NULL; -struct string_type *resolved_string = NULL; +struct function_type *resolved_function = nullptr; +struct string_type *resolved_string = nullptr; -struct string_type *new_string = NULL; -struct string_type *current_cstring = NULL; -struct string_type *previous_cstring = NULL; +struct string_type *new_string = nullptr; +struct string_type *current_cstring = nullptr; +struct string_type *previous_cstring = nullptr; -struct cinteger_type *new_cinteger = NULL; -struct cinteger_type *current_cinteger = NULL; -struct cinteger_type *previous_cinteger = NULL; +struct cinteger_type *new_cinteger = nullptr; +struct cinteger_type *current_cinteger = nullptr; +struct cinteger_type *previous_cinteger = nullptr; long bit_mask; extern int encrypted; @@ -150,8 +150,8 @@ char csv_buffer[1024]; int resolved_attribute; /* THE ITERATION VARIABLE USED FOR LOOPS */ -int *loop_integer = NULL; -int *select_integer = NULL; +int *loop_integer = nullptr; +int *select_integer = nullptr; int criterion_value = 0; int criterion_type = 0; @@ -281,14 +281,14 @@ void terminate(int code) { /* CLOSE THE SOUND CHANNELS */ for (index = 0; index < 8; index++) { - if (sound_channel[index] != NULL) { + if (sound_channel[index] != nullptr) { g_vm->glk_schannel_destroy(sound_channel[index]); } } /* CLOSE THE STREAM */ - if (game_stream != NULL) { - g_vm->glk_stream_close(game_stream, NULL); + if (game_stream != nullptr) { + g_vm->glk_stream_close(game_stream, nullptr); } g_vm->glk_exit(); @@ -307,7 +307,7 @@ void build_proxy() { /* LOOP THROUGH ALL THE PARAMETERS OF THE PROXY COMMAND AND BUILD THE MOVE TO BE ISSUED ON THE PLAYER'S BEHALF */ - for (index = 1; word[index] != NULL; index++) { + for (index = 1; word[index] != nullptr; index++) { strcat(proxy_buffer, text_of_word(index)); } @@ -328,7 +328,7 @@ void cb1(void *s, size_t i, void *not_used) { sprintf(temp_buffer, "field[%d]", field_no); - if ((resolved_cstring = cstring_resolve(temp_buffer)) != NULL) { + if ((resolved_cstring = cstring_resolve(temp_buffer)) != nullptr) { //write_text("Resolved "); //write_text(temp_buffer); //write_text("^"); @@ -350,7 +350,7 @@ void cb2(int c, void *not_used) { // THE END OF THE RECORD HAS BEEN REACHED, EXPORT THE NUMBER OF FIELDS READ struct cinteger_type *resolved_cinteger; - if ((resolved_cinteger = cinteger_resolve("field_count")) != NULL) { + if ((resolved_cinteger = cinteger_resolve("field_count")) != nullptr) { resolved_cinteger->value = field_no; } } @@ -385,7 +385,7 @@ int execute(const char *funcname) { /* GET THE FUNCTION OBJECT BY THE FUNCTION NAME */ resolved_function = function_resolve(called_name); - if (resolved_function == NULL) { + if (resolved_function == nullptr) { //printf("--- failed to find %s\n", called_name); return (FALSE); } @@ -434,7 +434,7 @@ int execute(const char *funcname) { while (text_buffer[0] != 125 && !interrupted) { encapsulate(); - if (word[0] == NULL); + if (word[0] == nullptr); else if (!strcmp(word[0], "endwhile")) { currentLevel--; if (currentLevel < executionLevel) { @@ -540,7 +540,7 @@ int execute(const char *funcname) { top_of_do_loop = ftell(file); #endif } else if (!strcmp(word[0], "until")) { - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -557,7 +557,7 @@ int execute(const char *funcname) { } } } else if (!strcmp(word[0], "untilall")) { - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -588,7 +588,7 @@ int execute(const char *funcname) { // infile REMAINS OPEN DURING THE ITERATION, ONLY NEEDS // OPENING THE FIRST TIME - if (infile == NULL) { + if (infile == nullptr) { strcpy(temp_buffer, data_directory); strcat(temp_buffer, prefix); strcat(temp_buffer, "-"); @@ -597,18 +597,18 @@ int execute(const char *funcname) { infile = File::openForReading(temp_buffer); - if (word[2] != NULL && !strcmp(word[2], "skip_header")) { + if (word[2] != nullptr && !strcmp(word[2], "skip_header")) { assert(infile); infile->read(csv_buffer, 1024); } } - if (infile == NULL) { + if (infile == nullptr) { sprintf(error_buffer, "Failed to open file %s\n", temp_buffer); log_error(error_buffer, LOG_ONLY); - infile = NULL; + infile = nullptr; } else { - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -621,18 +621,18 @@ int execute(const char *funcname) { i = strlen(csv_buffer); //sprintf (temp_buffer, "Read ~%s~ with %d bytes.^", csv_buffer, i); //write_text(temp_buffer); - if (csv_parse(&parser_csv, csv_buffer, i, cb1, cb2, (void *) NULL) != (uint)i) { + if (csv_parse(&parser_csv, csv_buffer, i, cb1, cb2, (void *) nullptr) != (uint)i) { sprintf(error_buffer, "Error parsing file: %s\n", csv_strerror(csv_error(&parser_csv))); log_error(error_buffer, PLUS_STDOUT); delete infile; - infile = NULL; + infile = nullptr; } else { // A LINE HAS BEEN SUCCESSFULLY READ, EXECUTE THE CONTENTS OF THE LOOP executionLevel++; } } else { delete infile; - infile = NULL; + infile = nullptr; } } } @@ -662,7 +662,7 @@ int execute(const char *funcname) { // infile REMAINS OPEN DURING THE ITERATION, ONLY NEEDS // OPENING THE FIRST TIME - if (infile == NULL) { + if (infile == nullptr) { strcpy(in_name, data_directory); strcat(in_name, prefix); strcat(in_name, "-"); @@ -672,7 +672,7 @@ int execute(const char *funcname) { infile = File::openForReading(in_name); } - if (outfile == NULL) { + if (outfile == nullptr) { // OPEN A TEMPORARY OUTPUT FILE TO WRITE THE MODIFICATIONS TO strcpy(out_name, data_directory); strcat(out_name, prefix); @@ -685,21 +685,21 @@ int execute(const char *funcname) { outfile = File::openForWriting(out_name); } - if (infile == NULL) { + if (infile == nullptr) { sprintf(error_buffer, "Failed to open input CSV file ~%s\n", in_name); log_error(error_buffer, LOG_ONLY); - if (outfile != NULL) { + if (outfile != nullptr) { delete outfile; - outfile = NULL; + outfile = nullptr; } return (exit_function(TRUE)); } else { - if (outfile == NULL) { + if (outfile == nullptr) { sprintf(error_buffer, "Failed to open output CSV file ~%s~\n", out_name); log_error(error_buffer, LOG_ONLY); - if (infile != NULL) { + if (infile != nullptr) { delete infile; - infile = NULL; + infile = nullptr; } return (exit_function(TRUE)); } else { @@ -739,7 +739,7 @@ int execute(const char *funcname) { } } #endif - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -755,7 +755,7 @@ int execute(const char *funcname) { read_lck.l_type = F_UNLCK; // SETTING A READ LOCK fcntl(read_fd, F_SETLK, &read_lck); delete infile; - infile = NULL; + infile = nullptr; } else { // A LINE HAS BEEN SUCCESSFULLY READ, EXECUTE THE CONTENTS OF THE LOOP executionLevel++; @@ -771,8 +771,8 @@ int execute(const char *funcname) { rename(out_name, in_name); - outfile = NULL; - infile = NULL; + outfile = nullptr; + infile = nullptr; } } } @@ -782,7 +782,7 @@ int execute(const char *funcname) { /* THIS LOOP COMES BACK TO THE START OF THE LINE CURRENTLY EXECUTING, NOT THE LINE AFTER */ top_of_while = before_command; - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -794,7 +794,7 @@ int execute(const char *funcname) { /* THIS LOOP COMES BACK TO THE START OF THE LINE CURRENTLY EXECUTING, NOT THE LINE AFTER */ top_of_while = before_command; - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -809,7 +809,7 @@ int execute(const char *funcname) { #else top_of_loop = ftell(file); #endif - if (word[1] == NULL) { + if (word[1] == nullptr) { // IF NONE IS SUPPLIED DEFAULT TO noun3 loop_integer = &noun[2]; } else { @@ -818,7 +818,7 @@ int execute(const char *funcname) { // IF THE SUPPLIED CONTAINER CAN'T BE RESOLVED // DEFAULT TO noun3 - if (loop_integer == NULL) + if (loop_integer == nullptr) loop_integer = &noun[2]; } @@ -850,11 +850,11 @@ int execute(const char *funcname) { #else top_of_select = ftell(file); #endif - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); - } else if (word[2] == NULL) { + } else if (word[2] == nullptr) { // IF NONE IS SUPPLIED DEFAULT TO noun3 select_integer = &noun[2]; } else { @@ -863,7 +863,7 @@ int execute(const char *funcname) { // IF THE SUPPLIED CONTAINER CAN'T BE RESOLVED // DEFAULT TO noun3 - if (select_integer == NULL) { + if (select_integer == nullptr) { select_integer = &noun[2]; } } @@ -925,7 +925,7 @@ int execute(const char *funcname) { while (text_buffer[0] != '}') { encapsulate(); - if (word[0] != NULL && !strcmp(word[0], "endselect")) { + if (word[0] != nullptr && !strcmp(word[0], "endselect")) { break; } #ifdef GLK @@ -956,7 +956,7 @@ int execute(const char *funcname) { executionLevel--; #ifdef GLK } else if (!strcmp(word[0], "cursor")) { - if (word[2] == NULL) { + if (word[2] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); @@ -972,7 +972,7 @@ int execute(const char *funcname) { if (SOUND_SUPPORTED->value) { /* SET THE CHANNEL TO STOP, IF SUPPLIED */ - if (word[1] == NULL) { + if (word[1] == nullptr) { channel = 0; } else { channel = value_of(word[1], TRUE); @@ -989,7 +989,7 @@ int execute(const char *funcname) { if (SOUND_SUPPORTED->value) { /* SET THE CHANNEL TO STOP, IF SUPPLIED */ - if (word[2] == NULL) { + if (word[2] == nullptr) { channel = 0; } else { channel = value_of(word[2], TRUE); @@ -1000,7 +1000,7 @@ int execute(const char *funcname) { } } - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -1031,7 +1031,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "timer")) { if (TIMER_SUPPORTED->value && TIMER_ENABLED->value) { - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -1054,7 +1054,7 @@ int execute(const char *funcname) { if (SOUND_SUPPORTED->value && SOUND_ENABLED->value) { /* SET THE CHANNEL TO USE, IF SUPPLIED */ - if (word[2] == NULL) { + if (word[2] == nullptr) { channel = 0; } else { channel = value_of(word[2], TRUE); @@ -1066,13 +1066,13 @@ int execute(const char *funcname) { } /* SET THE NUMBER OF REPEATS, IF SUPPLIED */ - if (word[3] == NULL) { + if (word[3] == nullptr) { repeats = 1; } else { repeats = value_of(word[3], TRUE); } - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -1089,7 +1089,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "image")) { if (GRAPHICS_SUPPORTED->value && GRAPHICS_ENABLED->value) { - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -1101,13 +1101,13 @@ int execute(const char *funcname) { } } } else if (!strcmp(word[0], "askstring") || !strcmp(word[0], "getstring")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); } else { /* GET A POINTER TO THE STRING BEING MODIFIED */ - if ((resolved_string = string_resolve(word[1])) == NULL) { + if ((resolved_string = string_resolve(word[1])) == nullptr) { unkstrrun(word[1]); return (exit_function(TRUE)); } @@ -1128,9 +1128,9 @@ int execute(const char *funcname) { insist = TRUE; } - if (word[3] != NULL) { + if (word[3] != nullptr) { ask_integer = container_resolve(word[1]); - if (ask_integer == NULL) { + if (ask_integer == nullptr) { unkvarrun(word[1]); return (exit_function(TRUE)); } @@ -1149,9 +1149,9 @@ int execute(const char *funcname) { return (exit_function(TRUE)); } } else if (!strcmp(word[0], "getyesorno")) { - if (word[1] != NULL) { + if (word[1] != nullptr) { ask_integer = container_resolve(word[1]); - if (ask_integer == NULL) { + if (ask_integer == nullptr) { unkvarrun(word[1]); return (exit_function(TRUE)); } @@ -1170,7 +1170,7 @@ int execute(const char *funcname) { terminate(0); return 0; } else if (!strcmp(word[0], "more")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { more("[MORE]"); } else { more(word[1]); @@ -1178,7 +1178,7 @@ int execute(const char *funcname) { } else if (!strcmp(word[0], "style")) { /* THIS COMMAND IS USED TO OUTPUT ANSI CODES OR SET GLK * STREAM STYLES */ - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -1211,7 +1211,7 @@ int execute(const char *funcname) { } else if (!strcmp(word[0], "flush")) { } else if (!strcmp(word[0], "hyperlink")) { /* OUTPUT LINK TEXT AS PLAIN TEXT UNDER Glk */ - if (word[2] == NULL) { + if (word[2] == nullptr) { noproprun(); pop_stack(); return (TRUE); @@ -1621,7 +1621,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "execute") || !strcmp(word[0], "call")) { /* CALLS ANOTHER JACL FUNCTION */ - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -1629,17 +1629,17 @@ int execute(const char *funcname) { /* RESOLVE ALL THE TEXT AND STORE IT IN A TEMPORARY BUFFER*/ string_buffer[0] = 0; - for (counter = 1; word[counter] != NULL && counter < MAX_WORDS; counter++) { + for (counter = 1; word[counter] != nullptr && counter < MAX_WORDS; counter++) { strcat(string_buffer, arg_text_of_word(counter)); } - if (function_resolve(string_buffer) == NULL && !strcmp(word[0], "execute")) { + if (function_resolve(string_buffer) == nullptr && !strcmp(word[0], "execute")) { char *argstart; /* REMOVE ANY PARAMETERS FROM FUNCTION NAME BEFORE DISPLAYING ERROR MESSAGE */ argstart = strchr(string_buffer, '<'); - if (argstart != NULL) + if (argstart != nullptr) *argstart = 0; sprintf(error_buffer, UNDEFINED_FUNCTION, executing_function->name, string_buffer); @@ -1650,7 +1650,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "points")) { /* INCREASE THE PLAYER'S SCORE AND POTENTIALLY INFORM THEM OF THE INCREASE */ - if (word[1] != NULL) { + if (word[1] != nullptr) { SCORE->value += value_of(word[1], TRUE); if (NOTIFY->value) { #ifdef GLK @@ -1752,23 +1752,23 @@ int execute(const char *funcname) { if (encrypted) jacl_decrypt(text_buffer); } } else if (!strcmp(word[0], "mesg")) { - for (counter = 1; word[counter] != NULL && counter < MAX_WORDS; counter++) { + for (counter = 1; word[counter] != nullptr && counter < MAX_WORDS; counter++) { warning("%s", text_of_word(counter)); } } else if (!strcmp(word[0], "error")) { write_text("ERROR: In function ~"); write_text(executing_function->name); write_text("~, "); - for (counter = 1; word[counter] != NULL && counter < MAX_WORDS; counter++) { + for (counter = 1; word[counter] != nullptr && counter < MAX_WORDS; counter++) { write_text(text_of_word(counter)); } } else if (!strcmp(word[0], "debug") && DEBUG->value) { write_text("DEBUG: "); - for (counter = 1; word[counter] != NULL && counter < MAX_WORDS; counter++) { + for (counter = 1; word[counter] != nullptr && counter < MAX_WORDS; counter++) { write_text(text_of_word(counter)); } } else if (!strcmp(word[0], "write")) { - for (counter = 1; word[counter] != NULL && counter < MAX_WORDS; counter++) { + for (counter = 1; word[counter] != nullptr && counter < MAX_WORDS; counter++) { output = text_of_word(counter); if (*output != 0) { // IF THE OUTPUT ISN'T AN EMPTY STRING, DISPLAY IT @@ -1776,12 +1776,12 @@ int execute(const char *funcname) { } } } else if (!strcmp(word[0], "length")) { - if (word[2] == NULL) { + if (word[2] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); } else { - if ((container = container_resolve(word[1])) == NULL) { + if ((container = container_resolve(word[1])) == nullptr) { unkvarrun(word[1]); return (exit_function(TRUE)); } @@ -1789,12 +1789,12 @@ int execute(const char *funcname) { *container = strlen(text_of(word[2])); } } else if (!strcmp(word[0], "savegame")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); } else { - if ((container = container_resolve(word[1])) == NULL) { + if ((container = container_resolve(word[1])) == nullptr) { unkvarrun(word[1]); return (exit_function(TRUE)); } else { @@ -1802,12 +1802,12 @@ int execute(const char *funcname) { } } } else if (!strcmp(word[0], "restoregame")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); } else { - if ((container = container_resolve(word[1])) == NULL) { + if ((container = container_resolve(word[1])) == nullptr) { unkvarrun(word[1]); return (exit_function(TRUE)); } else { @@ -1836,22 +1836,22 @@ int execute(const char *funcname) { char split_buffer[256] = ""; char container_buffer[256] = ""; char delimiter[256] = ""; - char *match = NULL; - struct string_type *resolved_splitstring = NULL; + char *match = nullptr; + struct string_type *resolved_splitstring = nullptr; strcpy(split_buffer, text_of_word(2)); strcpy(delimiter, text_of_word(3)); char *source = split_buffer; - if (word[4] == NULL) { + if (word[4] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); } else { split_container = container_resolve(var_text_of_word(1)); - if (split_container == NULL) { + if (split_container == nullptr) { unkvarrun(var_text_of_word(1)); return (exit_function(TRUE)); } else { @@ -1867,7 +1867,7 @@ int execute(const char *funcname) { strcat(container_buffer, integer_buffer); strcat(container_buffer, "]"); - if ((resolved_splitstring = string_resolve(container_buffer)) == NULL) { + if ((resolved_splitstring = string_resolve(container_buffer)) == nullptr) { unkstrrun(var_text_of_word(4)); return (exit_function(TRUE)); } else { @@ -1882,7 +1882,7 @@ int execute(const char *funcname) { strcat(container_buffer, integer_buffer); strcat(container_buffer, "]"); - if ((resolved_splitstring = string_resolve(container_buffer)) == NULL) { + if ((resolved_splitstring = string_resolve(container_buffer)) == nullptr) { unkstrrun(word[1]); return (exit_function(TRUE)); } else { @@ -1894,21 +1894,21 @@ int execute(const char *funcname) { } else if (!strcmp(word[0], "setstring") || !strcmp(word[0], "addstring")) { char setstring_buffer[2048] = ""; - struct string_type *resolved_setstring = NULL; + struct string_type *resolved_setstring = nullptr; - if (word[2] == NULL) { + if (word[2] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); } else { /* GET A POINTER TO THE STRING BEING MODIFIED */ - if ((resolved_setstring = string_resolve(var_text_of_word(1))) == NULL) { + if ((resolved_setstring = string_resolve(var_text_of_word(1))) == nullptr) { unkstrrun(word[1]); return (exit_function(TRUE)); } /* RESOLVE ALL THE TEXT AND STORE IT IN A TEMPORARY BUFFER*/ - for (counter = 2; word[counter] != NULL && counter < MAX_WORDS; counter++) { + for (counter = 2; word[counter] != nullptr && counter < MAX_WORDS; counter++) { strcat(setstring_buffer, text_of_word(counter)); } @@ -1925,16 +1925,16 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "padstring")) { char setstring_buffer[2048] = ""; - struct string_type *resolved_setstring = NULL; + struct string_type *resolved_setstring = nullptr; string_buffer[0] = 0; - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); } else { /* GET A POINTER TO THE STRING BEING MODIFIED */ - if ((resolved_setstring = string_resolve(word[1])) == NULL) { + if ((resolved_setstring = string_resolve(word[1])) == nullptr) { unkstrrun(word[1]); return (exit_function(TRUE)); } @@ -1951,7 +1951,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "return")) { /* RETURN FROM THIS FUNCTION, POSSIBLY RETURNING AN INTEGER VALUE */ - if (word[1] == NULL) { + if (word[1] == nullptr) { return (exit_function(TRUE)); } else { index = value_of(word[1], TRUE); @@ -1960,7 +1960,7 @@ int execute(const char *funcname) { } else if (!strcmp(word[0], "position")) { /* MOVE AN OBJECT TO ITS NEW X,Y COORDINATES BASED ON ITS CURRENT VALUES * FOR x, y, bearing, velocity */ - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -1982,12 +1982,12 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "bearing")) { /* CALCULATE THE BEARING BETWEEN TWO OBJECTS */ - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); } else { - if ((container = container_resolve(word[1])) == NULL) { + if ((container = container_resolve(word[1])) == nullptr) { unkvarrun(word[1]); return (exit_function(TRUE)); } @@ -2004,7 +2004,7 @@ int execute(const char *funcname) { badptrrun(word[3], object_2); return (exit_function(TRUE)); } else { - if (container != NULL + if (container != nullptr && object_1 != FALSE && object_2 != FALSE) { *container = bearing((double) object[object_1]->X, @@ -2017,7 +2017,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "distance")) { /* CALCULATE THE DISTANCE BETWEEN TWO OBJECTS */ - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -2036,7 +2036,7 @@ int execute(const char *funcname) { badptrrun(word[3], object_2); return (exit_function(TRUE)); } else { - if (container != NULL + if (container != nullptr && object_1 != FALSE && object_2 != FALSE) { *container = distance((double) @@ -2055,7 +2055,7 @@ int execute(const char *funcname) { !strcmp(word[0], "npc_to")) { /* CALCULATE THE FIRST DIRECTION TO TRAVEL IN GET TO * A SPECIFIED LOCATION */ - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -2074,7 +2074,7 @@ int execute(const char *funcname) { badptrrun(word[3], object_2); return (exit_function(TRUE)); } else { - if (container != NULL + if (container != nullptr && object_1 != FALSE && object_2 != FALSE) { if (!strcmp(word[0], "dir_to")) { @@ -2088,19 +2088,19 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "set")) { /* SET THE VALUE OF AN ELEMENT TO A SUPPLIED INTEGER */ - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); } else { container = container_resolve(var_text_of_word(1)); - if (container == NULL) { + if (container == nullptr) { unkvarrun(word[1]); return (exit_function(TRUE)); } else { int mark = 2; // SET mark TO POINT TO THE FIRST OPERATOR - while (word[mark + 1] != NULL) { + while (word[mark + 1] != nullptr) { counter = value_of(word[mark + 1], TRUE); if (word[mark][0] == '+') @@ -2137,7 +2137,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "ensure")) { /* USED TO GIVE OR TAKE AN ATTRIBUTE TO OR FROM AND OBJECT */ - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -2180,7 +2180,7 @@ int execute(const char *funcname) { } else if (!strcmp(word[0], "append")) { int first = TRUE; - if (word[2] == NULL) { + if (word[2] == nullptr) { // NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND noproprun(); return (exit_function(TRUE)); @@ -2193,11 +2193,11 @@ int execute(const char *funcname) { outfile = File::openForWriting(temp_buffer); - if (outfile == NULL) { + if (outfile == nullptr) { sprintf(error_buffer, "Failed to open file %s\n", temp_buffer); log_error(error_buffer, PLUS_STDOUT); } else { - for (counter = 2; word[counter] != NULL && counter < MAX_WORDS; counter++) { + for (counter = 2; word[counter] != nullptr && counter < MAX_WORDS; counter++) { output = text_of_word(counter); if (*output != 0) { if (first == FALSE) { @@ -2216,20 +2216,20 @@ int execute(const char *funcname) { } delete outfile; - outfile = NULL; + outfile = nullptr; } } else if (!strcmp(word[0], "insert")) { int first = TRUE; - if (word[1] == NULL) { + if (word[1] == nullptr) { // NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND noproprun(); return (exit_function(TRUE)); } else { - if (outfile == NULL) { + if (outfile == nullptr) { log_error("Insert statement not inside an 'update' loop.", PLUS_STDOUT); } else { - for (counter = 1; word[counter] != NULL && counter < MAX_WORDS; counter++) { + for (counter = 1; word[counter] != nullptr && counter < MAX_WORDS; counter++) { output = text_of_word(counter); if (*output != 0) { if (first == FALSE) { @@ -2245,7 +2245,7 @@ int execute(const char *funcname) { } } } else if (!strcmp(word[0], "inspect")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { // NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND noproprun(); return (exit_function(TRUE)); @@ -2255,7 +2255,7 @@ int execute(const char *funcname) { } else if (!strcmp(word[0], "move")) { /* THIS COMMAND IS USED TO MOVE AN OBJECT TO HAVE ANOTHER PARENT * INCLUDING MODIFYING ALL QUANTITY VALUES BASED ON THE OBJECTS MASS */ - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(); return (exit_function(TRUE)); @@ -2283,7 +2283,7 @@ int execute(const char *funcname) { } else if (!strcmp(word[0], "ifstringall")) { /* CHECK IF A STRING EQUALS OR CONTAINS ANOTHER STRING */ currentLevel++; - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); @@ -2293,7 +2293,7 @@ int execute(const char *funcname) { } else if (!strcmp(word[0], "ifstring")) { /* CHECK IF A STRING EQUALS OR CONTAINS ANOTHER STRING */ currentLevel++; - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); @@ -2302,7 +2302,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "ifexecute")) { currentLevel++; - if (word[1] == NULL) { + if (word[1] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); @@ -2310,7 +2310,7 @@ int execute(const char *funcname) { /* RESOLVE ALL THE TEXT AND STORE IT IN A TEMPORARY BUFFER*/ string_buffer[0] = 0; - for (counter = 1; word[counter] != NULL && counter < MAX_WORDS; counter++) { + for (counter = 1; word[counter] != nullptr && counter < MAX_WORDS; counter++) { strcat(string_buffer, arg_text_of_word(counter)); } @@ -2320,7 +2320,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "if")) { currentLevel++; - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); @@ -2329,7 +2329,7 @@ int execute(const char *funcname) { } } else if (!strcmp(word[0], "ifall")) { currentLevel++; - if (word[3] == NULL) { + if (word[3] == nullptr) { /* NOT ENOUGH PARAMETERS SUPPLIED FOR THIS COMMAND */ noproprun(0); return (exit_function(TRUE)); @@ -2370,18 +2370,18 @@ int execute(const char *funcname) { } int exit_function(int return_code) { - if (infile != NULL) { + if (infile != nullptr) { read_lck.l_type = F_UNLCK; // SETTING A READ LOCK fcntl(read_fd, F_SETLK, &read_lck); delete infile; - infile = NULL; + infile = nullptr; } - if (outfile != NULL) { + if (outfile != nullptr) { write_lck.l_type = F_UNLCK; // SETTING A WRITE LOCK fcntl(write_fd, F_SETLK, &write_lck); delete outfile; - outfile = NULL; + outfile = nullptr; } /* POP THE STACK REGARDLESS OF THE RETURN CODE */ @@ -2397,7 +2397,7 @@ char *object_names(int object_index, char *names_buffer) { struct name_type *current_name = object[object_index]->first_name; names_buffer[0] = 0; - while (current_name != NULL) { + while (current_name != nullptr) { strcat(names_buffer, " "); strcat(names_buffer, current_name->name); current_name = current_name->next_name; @@ -2587,16 +2587,16 @@ void set_arguments(const char *function_call) { argument_buffer[index] = 0; /* CLEAR THE NEXT ARGUMENT POINTER */ - arg_ptr[position] = NULL; + arg_ptr[position] = nullptr; /* STORE THE INTEGER VALUE OF EACH ARGUMENT PASSED*/ index = 0; - while (arg_ptr[index] != NULL) { + while (arg_ptr[index] != nullptr) { //arg_value[index] = value_of(arg_ptr[index], TRUE); - if ((resolved_integer = integer_resolve(arg_ptr[index])) != NULL) { + if ((resolved_integer = integer_resolve(arg_ptr[index])) != nullptr) { arg_value[index] = resolved_integer->value; - } else if ((resolved_cinteger = cinteger_resolve(arg_ptr[index])) != NULL) { + } else if ((resolved_cinteger = cinteger_resolve(arg_ptr[index])) != nullptr) { arg_value[index] = resolved_cinteger->value; } else if (object_element_resolve(arg_ptr[index])) { arg_value[index] = oec; @@ -2625,7 +2625,7 @@ void set_arguments(const char *function_call) { /* CREATE A CONSTANT FOR EACH ARGUMENT AFTER THE CORE FUNCTION NAME */ index = 0; - while (arg_ptr[index] != NULL) { + while (arg_ptr[index] != nullptr) { if (index == 0) noun[3] = arg_value[index]; add_cinteger("arg", arg_value[index]); //printf("--- %s = %s\n", arg_ptr[index], arg_text_of(arg_ptr[index])); @@ -2680,7 +2680,7 @@ void pop_stack() { executing_function = backup[stack].function; - if (executing_function != NULL) { + if (executing_function != nullptr) { strncpy(function_name, executing_function->name, 80); strncpy(cstring_resolve("function_name")->value, executing_function->name, 80); } @@ -2721,9 +2721,9 @@ void push_stack(int32 file_pointer) { return; } else { backup[stack].infile = infile; - infile = NULL; + infile = nullptr; backup[stack].outfile = outfile; - outfile = NULL; + outfile = nullptr; backup[stack].function = executing_function; backup[stack].address = file_pointer; backup[stack].wp = wp; @@ -2766,13 +2766,13 @@ void push_stack(int32 file_pointer) { index = 0; current_cinteger = cinteger_table; - if (current_cinteger != NULL) { + if (current_cinteger != nullptr) { do { if (!strcmp(current_cinteger->name, "arg")) { backup[stack].arguments[index++] = current_cinteger->value; } current_cinteger = current_cinteger->next_cinteger; - } while (current_cinteger != NULL); + } while (current_cinteger != nullptr); } // STORE THE NUMBER OF ARGUMENTS PASSED TO THIS FUNCTION @@ -2783,14 +2783,14 @@ void push_stack(int32 file_pointer) { index = 0; current_cstring = cstring_table; - if (current_cstring != NULL) { + if (current_cstring != nullptr) { do { if (!strcmp(current_cstring->name, "string_arg")) { strncpy(backup[stack].str_arguments[index++], current_cstring->value, 255); } current_cstring = current_cstring->next_string; - } while (current_cstring != NULL); + } while (current_cstring != nullptr); } } @@ -2876,13 +2876,13 @@ void push_proxy() { /* PUSH ALL THE CURRENT COMMAND INTEGERS ONTO THE STACK */ counter = 0; - if (current_cinteger != NULL) { + if (current_cinteger != nullptr) { do { if (!strcmp(current_cinteger->name, "$integer")) { proxy_backup[proxy_stack].integer[counter++] = current_cinteger->value; } current_cinteger = current_cinteger->next_cinteger; - } while (current_cinteger != NULL); + } while (current_cinteger != nullptr); } proxy_backup[proxy_stack].integercount = counter; @@ -2891,7 +2891,7 @@ void push_proxy() { text = 0; command = 0; - if (current_cstring != NULL) { + if (current_cstring != nullptr) { do { if (!strcmp(current_cstring->name, "$string")) { strncpy(proxy_backup[proxy_stack].text[text++], current_cstring->value, 255); @@ -2901,7 +2901,7 @@ void push_proxy() { } current_cstring = current_cstring->next_string; - } while (current_cstring != NULL); + } while (current_cstring != nullptr); } proxy_backup[proxy_stack].textcount = counter; @@ -2921,7 +2921,7 @@ int condition() { first = 1; - while (word[first + 2] != NULL && ((first + 2) < MAX_WORDS)) { + while (word[first + 2] != nullptr && ((first + 2) < MAX_WORDS)) { if (logic_test(first)) return (TRUE); else @@ -2937,7 +2937,7 @@ int and_condition() { first = 1; - while (word[first + 2] != NULL && ((first + 2) < MAX_WORDS)) { + while (word[first + 2] != nullptr && ((first + 2) < MAX_WORDS)) { if (logic_test(first) == FALSE) return (FALSE); else @@ -3068,7 +3068,7 @@ int strcondition() { first = 1; - while (word[first + 2] != NULL && ((first + 2) < MAX_WORDS)) { + while (word[first + 2] != nullptr && ((first + 2) < MAX_WORDS)) { if (str_test(first)) return (TRUE); else @@ -3082,7 +3082,7 @@ int and_strcondition() { first = 1; - while (word[first + 2] != NULL && ((first + 2) < MAX_WORDS)) { + while (word[first + 2] != nullptr && ((first + 2) < MAX_WORDS)) { if (str_test(first) == FALSE) return (FALSE); else @@ -3155,15 +3155,15 @@ void add_cinteger(const char *name, int value) { /* THIS FUNCTION ADDS A NEW JACL CONSTANT TO THE LIST */ if ((new_cinteger = (struct cinteger_type *) - malloc(sizeof(struct cinteger_type))) == NULL) + malloc(sizeof(struct cinteger_type))) == nullptr) outofmem(); else { - if (cinteger_table == NULL) { + if (cinteger_table == nullptr) { cinteger_table = new_cinteger; } else { /* FIND LAST CONSTANT IN LIST */ current_cinteger = cinteger_table; - while (current_cinteger->next_cinteger != NULL) { + while (current_cinteger->next_cinteger != nullptr) { current_cinteger = current_cinteger->next_cinteger; } current_cinteger->next_cinteger = new_cinteger; @@ -3171,7 +3171,7 @@ void add_cinteger(const char *name, int value) { strncpy(new_cinteger->name, name, 40); new_cinteger->name[40] = 0; new_cinteger->value = value; - new_cinteger->next_cinteger = NULL; + new_cinteger->next_cinteger = nullptr; } } @@ -3179,10 +3179,10 @@ void clear_cinteger(const char *name) { /* FREE CONSTANTS THAT HAVE SUPPLIED NAME*/ //printf("--- clear integer %s\n", name); - if (cinteger_table != NULL) { + if (cinteger_table != nullptr) { current_cinteger = cinteger_table; previous_cinteger = cinteger_table; - while (current_cinteger != NULL) { + while (current_cinteger != nullptr) { //sprintf(temp_buffer, "--- checking integer %s^", current_cinteger->name); //write_text(temp_buffer); if (!strcmp(current_cinteger->name, name)) { @@ -3213,15 +3213,15 @@ void add_cstring(const char *name, const char *value) { /* ADD A STRING CONSTANT WITH THE SUPPLIED NAME AND VALUE */ if ((new_string = (struct string_type *) - malloc(sizeof(struct string_type))) == NULL) + malloc(sizeof(struct string_type))) == nullptr) outofmem(); else { - if (cstring_table == NULL) { + if (cstring_table == nullptr) { cstring_table = new_string; } else { /* FIND LAST STRING IN LIST */ current_cstring = cstring_table; - while (current_cstring->next_string != NULL) { + while (current_cstring->next_string != nullptr) { current_cstring = current_cstring->next_string; } current_cstring->next_string = new_string; @@ -3230,16 +3230,16 @@ void add_cstring(const char *name, const char *value) { new_string->name[40] = 0; strncpy(new_string->value, value, 255); new_string->value[255] = 0; - new_string->next_string = NULL; + new_string->next_string = nullptr; } } void clear_cstring(const char *name) { /* FREE CONSTANTS THAT HAVE SUPPLIED NAME*/ - if (cstring_table != NULL) { + if (cstring_table != nullptr) { current_cstring = cstring_table; previous_cstring = cstring_table; - while (current_cstring != NULL) { + while (current_cstring != nullptr) { if (!strcmp(current_cstring->name, name)) { /* FREE THIS STRING */ if (previous_cstring == current_cstring) { @@ -3280,7 +3280,7 @@ void inspect(int object_num) { write_text("^has location attributes: "); index = 0; attribute_value = 1; - while (location_attributes[index] != NULL) { + while (location_attributes[index] != nullptr) { if (object[object_num]->attributes & attribute_value) { write_text(location_attributes[index]); } @@ -3292,7 +3292,7 @@ void inspect(int object_num) { write_text("^has object attributes: "); index = 0; attribute_value = 1; - while (object_attributes[index] != NULL) { + while (object_attributes[index] != nullptr) { if (object[object_num]->attributes & attribute_value) { write_text(object_attributes[index]); } @@ -3304,7 +3304,7 @@ void inspect(int object_num) { attribute_value = 1; } - if (pointer != NULL) { + if (pointer != nullptr) { // THERE ARE USER ATTRIBUTES, SO CHECK IF THIS OBJECT OR LOCATION // HAS ANY OF THEM do { @@ -3314,14 +3314,14 @@ void inspect(int object_num) { } pointer = pointer->next_attribute; - } while (pointer != NULL); + } while (pointer != nullptr); } write_text("^"); index = 0; if (object[object_num]->attributes & LOCATION) { - while (location_elements[index] != NULL) { + while (location_elements[index] != nullptr) { if (index < 12) { if (object[object_num]->integer[index] < 1 || object[object_num]->integer[index] > objects) { sprintf(temp_buffer, "%s: nowhere (%d)^", location_elements[index], object[object_num]->integer[index]); @@ -3335,7 +3335,7 @@ void inspect(int object_num) { index++; } } else { - while (object_elements[index] != NULL) { + while (object_elements[index] != nullptr) { if (index == 0) { sprintf(temp_buffer, "%s: %s (%d)^", object_elements[index], object[object[object_num]->integer[index]]->label, object[object_num]->integer[index]); } else { diff --git a/engines/glk/jacl/jacl_main.cpp b/engines/glk/jacl/jacl_main.cpp index a3b99ac4608..ac0a6fcea6e 100644 --- a/engines/glk/jacl/jacl_main.cpp +++ b/engines/glk/jacl/jacl_main.cpp @@ -34,8 +34,8 @@ int convert_to_utf32(unsigned char *text); uint status_width, status_height; -schanid_t sound_channel[8] = { NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL +schanid_t sound_channel[8] = { nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, nullptr, nullptr }; event_t *cancelled_event; @@ -89,7 +89,7 @@ char oops_buffer[1024]; char oopsed_current[1024]; char last_command[1024]; const char *blank_command = "blankjacl\0"; -const char *current_command = (const char *)NULL; +const char *current_command = (const char *)nullptr; char command_buffer[1024]; #ifndef NOUNICODE glui32 command_buffer_uni[1024]; @@ -105,15 +105,15 @@ int objects, integers, functions, strings; int jpp_error = FALSE; /* A STREAM FOR THE GAME FILE, WHEN IT'S OPEN. */ -strid_t game_stream = NULL; +strid_t game_stream = nullptr; /* THE STREAM FOR OPENING UP THE ARCHIVE CONTAINING GRAPHICS AND SOUND */ strid_t blorb_stream; /* A FILE REFERENCE FOR THE TRANSCRIPT FILE. */ -static frefid_t script_fref = NULL; +static frefid_t script_fref = nullptr; /* A STREAM FOR THE TRANSCRIPT FILE, WHEN IT'S OPEN. */ -static strid_t script_stream = NULL; +static strid_t script_stream = nullptr; int noun[4]; int player = 0; @@ -133,17 +133,17 @@ int delay = 0; /* START OF GLK STUFF */ /* POINTERS TO THE GLK WINDOWS */ -winid_t mainwin = NULL; -winid_t statuswin = NULL; -winid_t promptwin = NULL; -winid_t inputwin = NULL; -winid_t current_window = NULL; +winid_t mainwin = nullptr; +winid_t statuswin = nullptr; +winid_t promptwin = nullptr; +winid_t inputwin = nullptr; +winid_t current_window = nullptr; /* POINTERS TO THE WINDOWS STREAMS */ -strid_t mainstr = NULL; -strid_t statusstr = NULL; -strid_t promptstr = NULL; -strid_t inputstr = NULL; +strid_t mainstr = nullptr; +strid_t statusstr = nullptr; +strid_t promptstr = nullptr; +strid_t inputstr = nullptr; /* END OF GLK STUFF */ @@ -155,18 +155,18 @@ char game_file[256] = "\0"; char processed_file[256] = "\0"; struct object_type *object[MAX_OBJECTS]; -struct integer_type *integer_table = NULL; -struct cinteger_type *cinteger_table = NULL; -struct window_type *window_table = NULL; -struct attribute_type *attribute_table = NULL; -struct string_type *string_table = NULL; -struct string_type *cstring_table = NULL; -struct function_type *function_table = NULL; -struct function_type *executing_function = NULL; -struct command_type *completion_list = NULL; -struct word_type *grammar_table = NULL; -struct synonym_type *synonym_table = NULL; -struct filter_type *filter_table = NULL; +struct integer_type *integer_table = nullptr; +struct cinteger_type *cinteger_table = nullptr; +struct window_type *window_table = nullptr; +struct attribute_type *attribute_table = nullptr; +struct string_type *string_table = nullptr; +struct string_type *cstring_table = nullptr; +struct function_type *function_table = nullptr; +struct function_type *executing_function = nullptr; +struct command_type *completion_list = nullptr; +struct word_type *grammar_table = nullptr; +struct synonym_type *synonym_table = nullptr; +struct filter_type *filter_table = nullptr; // Forward declarations static void word_check(); @@ -179,7 +179,7 @@ void glk_main() { override_[0] = 0; /* ALLOC AN EVENT TO STORE A CANCELLED EVENT IN */ - if ((cancelled_event = (event_t *) malloc(sizeof(event_t))) == NULL) + if ((cancelled_event = (event_t *) malloc(sizeof(event_t))) == nullptr) outofmem(); /* CREATE style_User1 FOR USE IN THE STATUS LINE */ @@ -187,7 +187,7 @@ void glk_main() { g_vm->glk_stylehint_set(wintype_TextBuffer, style_User2, stylehint_ReverseColor, 1); /* OPEN THE MAIN WINDOW THE GLK WINDOWS */ - mainwin = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 1); + mainwin = g_vm->glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 1); if (!mainwin) { /* IT'S POSSIBLE THAT THE MAIN WINDOW FAILED TO OPEN. THERE's @@ -232,7 +232,7 @@ void glk_main() { 0, wintype_TextGrid, 0); // GET A REFERENCE TO statuswin's STREAM - if (statuswin != NULL) { + if (statuswin != nullptr) { statusstr = g_vm->glk_window_get_stream(statuswin); } @@ -256,7 +256,7 @@ void glk_main() { execute("+intro"); - if (object[2] == NULL) { + if (object[2] == nullptr) { log_error(CANT_RUN, PLUS_STDERR); terminate(43); return; @@ -283,7 +283,7 @@ void glk_main() { status_line(); - if (current_command != NULL) { + if (current_command != nullptr) { strcpy(last_command, current_command); } @@ -420,7 +420,7 @@ void glk_main() { interrupted = FALSE; - if (word[0] != NULL) { + if (word[0] != nullptr) { if (strcmp(word[0], "undo")) { /* COMMAND DOES NOT EQUAL undo */ save_game_state(); @@ -451,7 +451,7 @@ void preparse() { // THE INTERRUPTED VARIABLE IS USED TO STOP LATER ACTIONS IN A COMMAND // IF ANY ONE - while (word[wp] != NULL && INTERRUPTED->value == FALSE) { + while (word[wp] != nullptr && INTERRUPTED->value == FALSE) { //printf("--- preparse %s\n", word[wp]); // PROCESS THE CURRENT COMMAND // CREATE THE command STRINGS FROM THIS POINT ONWARDS SO THE VERB OF @@ -461,7 +461,7 @@ void preparse() { position = wp; - while (word[position] != NULL && strcmp(word[position], cstring_resolve("THEN_WORD")->value)) { + while (word[position] != nullptr && strcmp(word[position], cstring_resolve("THEN_WORD")->value)) { add_cstring("command", word[position]); position++; }; @@ -470,8 +470,8 @@ void preparse() { word_check(); /* THE PREVIOUS COMMAND HAS FINISHED, LOOK FOR ANOTHER COMMAND */ - while (word[wp] != NULL) { - if (word[wp] != NULL && !strcmp(word[wp], cstring_resolve("THEN_WORD")->value)) { + while (word[wp] != nullptr) { + if (word[wp] != nullptr && !strcmp(word[wp], cstring_resolve("THEN_WORD")->value)) { wp++; break; } @@ -521,7 +521,7 @@ void word_check() { } } else if (!strcmp(word[wp], cstring_resolve("OOPS_WORD")->value) || !strcmp(word[wp], "o")) { //printf("--- oops word is %d\n", oops_word); - if (word[++wp] != NULL) { + if (word[++wp] != nullptr) { if (oops_word == -1) { if (TOTAL_MOVES->value == 0) { write_text(cstring_resolve("NO_MOVES")->value); @@ -542,7 +542,7 @@ void word_check() { oopsed_current[0] = 0; index = 0; - while (word[index] != NULL) { + while (word[index] != nullptr) { if (oopsed_current[0] != 0) { strcat(oopsed_current, " "); } @@ -587,9 +587,9 @@ void word_check() { } else { /* Close the file. */ g_vm->glk_put_string_stream(script_stream, "\nEND OF A TRANSCRIPT\n"); - g_vm->glk_stream_close(script_stream, NULL); + g_vm->glk_stream_close(script_stream, nullptr); write_text(cstring_resolve("SCRIPTING_OFF")->value); - script_stream = NULL; + script_stream = nullptr; } } else if (!strcmp(word[wp], cstring_resolve("WALKTHRU_WORD")->value)) { walking_thru(); @@ -645,12 +645,12 @@ void save_game_state() { do { current_function->call_count_backup = current_function->call_count; current_function = current_function->next_function; - } while (current_function != NULL); + } while (current_function != nullptr); do { current_integer->value_backup = current_integer->value; current_integer = current_integer->next_integer; - } while (current_integer != NULL); + } while (current_integer != nullptr); for (index = 1; index <= objects; index++) { if (object[index]->nosave) @@ -690,13 +690,13 @@ void restore_game_state() { do { current_function->call_count = current_function->call_count_backup; current_function = current_function->next_function; - } while (current_function != NULL); + } while (current_function != nullptr); do { current_integer->value = current_integer->value_backup; current_integer = current_integer->next_integer; - } while (current_integer != NULL); + } while (current_integer != nullptr); for (index = 1; index <= objects; index++) { if (object[index]->nosave) @@ -1096,7 +1096,7 @@ strid_t open_glk_file(uint usage, uint mode, char *filename) { } } - return (strid_t) NULL; + return (strid_t) nullptr; } void scripting() { @@ -1147,10 +1147,10 @@ void walking_thru() { char script_line[81]; /* A FILE REFERENCE FOR THE WALKTHRU FILE. */ - frefid_t walkthru_fref = NULL; + frefid_t walkthru_fref = nullptr; /* A STREAM FOR THE WALKTHRU FILE, WHEN IT'S OPEN. */ - strid_t walkthru_stream = NULL; + strid_t walkthru_stream = nullptr; walkthru_fref = g_vm->glk_fileref_create_by_prompt(fileusage_Data | fileusage_TextMode, filemode_Read, 0); @@ -1195,7 +1195,7 @@ void walking_thru() { g_vm->glk_tick(); command_encapsulate(); jacl_truncate(); - if (word[0] != NULL) { + if (word[0] != nullptr) { custom_error = FALSE; execute("+bottom"); @@ -1227,7 +1227,7 @@ void walking_thru() { } /* CLOSE THE STREAM */ - g_vm->glk_stream_close(walkthru_stream, NULL); + g_vm->glk_stream_close(walkthru_stream, nullptr); /* FINISH UP */ walkthru_running = FALSE; @@ -1288,7 +1288,7 @@ const char *object_generator(const char *text, int state) { static int len; static struct command_type *now; struct command_type *to_send; - struct name_type *current_name = (struct name_type *) NULL; + struct name_type *current_name = (struct name_type *) nullptr; /* IF THIS IS A NEW WORD TO COMPLETE, INITIALIZE NOW. THIS INCLUDES SAVING THE LENGTH OF TEXT FOR EFFICIENCY, AND INITIALIZING THE INDEX @@ -1297,7 +1297,7 @@ const char *object_generator(const char *text, int state) { if (!state) { /* BUILD THE LIST */ int index; - completion_list = NULL; + completion_list = nullptr; /* LOOP THROUGH ALL THE OBJECTS AND SEE IF THEY ARE IN THE CURRENT LOCATION */ @@ -1316,7 +1316,7 @@ const char *object_generator(const char *text, int state) { len = strlen(text); } - while (now != NULL) { + while (now != nullptr) { if (!strncmp(text, now->word, len)) { to_send = now; now = now->next; @@ -1325,7 +1325,7 @@ const char *object_generator(const char *text, int state) { now = now->next; } - return (const char *)NULL; + return (const char *)nullptr; } const char *verb_generator(const char *text, int state) { @@ -1340,10 +1340,10 @@ const char *verb_generator(const char *text, int state) { if (!state) { /* BUILD THE LIST */ - completion_list = NULL; + completion_list = nullptr; pointer = grammar_table; - while (pointer != NULL) { + while (pointer != nullptr) { add_word(pointer->word); pointer = pointer->next_sibling; } @@ -1354,7 +1354,7 @@ const char *verb_generator(const char *text, int state) { len = strlen(text); } - while (now != NULL) { + while (now != nullptr) { if (!strncmp(text, now->word, len)) { to_send = now; now = now->next; @@ -1365,34 +1365,34 @@ const char *verb_generator(const char *text, int state) { now = now->next; } - return (const char *)NULL; + return (const char *)nullptr; } /* ADD A COPY OF STRING TO A LIST OF STRINGS IF IT IS NOT ALREADY IN THE LIST. THIS IS FOR THE USE OF READLINE */ void add_word(const char *newWord) { - static struct command_type *current_word = NULL; - struct command_type *previous_word = NULL; + static struct command_type *current_word = nullptr; + struct command_type *previous_word = nullptr; /* DON'T ADD WORDS SUCH AS *present TO THE LIST*/ if (*newWord == '*') return; - if (current_word != NULL) + if (current_word != nullptr) previous_word = current_word; current_word = (struct command_type *) malloc(sizeof(struct command_type)); - if (current_word != NULL) { - if (completion_list == NULL) { + if (current_word != nullptr) { + if (completion_list == nullptr) { completion_list = current_word; } strncpy(current_word->word, newWord, 40); current_word->word[40] = 0; - current_word->next = NULL; + current_word->next = nullptr; - if (previous_word != NULL) { + if (previous_word != nullptr) { previous_word->next = current_word; } } diff --git a/engines/glk/jacl/jpp.cpp b/engines/glk/jacl/jpp.cpp index 3e7f44a4d7a..5e1a2b64051 100644 --- a/engines/glk/jacl/jpp.cpp +++ b/engines/glk/jacl/jpp.cpp @@ -48,8 +48,8 @@ extern char error_buffer[]; int lines_written; -Common::WriteStream *outputFile = NULL; -Common::SeekableReadStream *inputFile = NULL; +Common::WriteStream *outputFile = nullptr; +Common::SeekableReadStream *inputFile = nullptr; char *stripped_line; @@ -142,8 +142,8 @@ int jpp() { int process_file(const char *sourceFile1, char *sourceFile2) { char temp_buffer1[1025]; char temp_buffer2[1025]; - Common::File *srcFile = NULL; - char *includeFile = NULL; + Common::File *srcFile = nullptr; + char *includeFile = nullptr; /* THIS FUNCTION WILL CREATE A PROCESSED FILE THAT HAS HAD ALL * LEADING AND TRAILING WHITE SPACE REMOVED AND ALL INCLUDED @@ -151,7 +151,7 @@ int process_file(const char *sourceFile1, char *sourceFile2) { srcFile = File::openForReading(sourceFile1); if (!srcFile) { - if (sourceFile2 != NULL) { + if (sourceFile2 != nullptr) { srcFile = File::openForReading(sourceFile2); if (!srcFile) { sprintf(error_buffer, CANT_OPEN_OR, sourceFile1, sourceFile2); @@ -177,12 +177,12 @@ int process_file(const char *sourceFile1, char *sourceFile2) { (!strncmp(text_buffer, "#debug", 6) & !release)) { includeFile = strrchr(text_buffer, '"'); - if (includeFile != NULL) + if (includeFile != nullptr) *includeFile = 0; includeFile = strchr(text_buffer, '"'); - if (includeFile != NULL) { + if (includeFile != nullptr) { strcpy(temp_buffer1, game_path); strcat(temp_buffer1, includeFile + 1); strcpy(temp_buffer2, include_directory); diff --git a/engines/glk/jacl/libcsv.cpp b/engines/glk/jacl/libcsv.cpp index 21dbc5380f3..f4fc5e56ead 100644 --- a/engines/glk/jacl/libcsv.cpp +++ b/engines/glk/jacl/libcsv.cpp @@ -93,7 +93,7 @@ const char *csv_strerror(int status) { int csv_get_opts(struct csv_parser *p) { /* Return the currently set options of parser */ - if (p == NULL) + if (p == nullptr) return -1; return p->options; @@ -101,7 +101,7 @@ int csv_get_opts(struct csv_parser *p) { int csv_set_opts(struct csv_parser *p, unsigned char options) { /* Set the options */ - if (p == NULL) + if (p == nullptr) return -1; p->options = options; @@ -110,10 +110,10 @@ int csv_set_opts(struct csv_parser *p, unsigned char options) { int csv_init(struct csv_parser *p, unsigned char options) { /* Initialize a csv_parser object returns 0 on success, -1 on error */ - if (p == NULL) + if (p == nullptr) return -1; - p->entry_buf = NULL; + p->entry_buf = nullptr; p->pstate = ROW_NOT_BEGUN; p->quoted = 0; p->spaces = 0; @@ -123,10 +123,10 @@ int csv_init(struct csv_parser *p, unsigned char options) { p->options = options; p->quote_char = CSV_QUOTE; p->delim_char = CSV_COMMA; - p->is_space = NULL; - p->is_term = NULL; + p->is_space = nullptr; + p->is_term = nullptr; p->blk_size = MEM_BLK_SIZE; - p->malloc_func = NULL; + p->malloc_func = nullptr; p->realloc_func = realloc; p->free_func = free; @@ -135,13 +135,13 @@ int csv_init(struct csv_parser *p, unsigned char options) { void csv_free(struct csv_parser *p) { /* Free the entry_buffer of csv_parser object */ - if (p == NULL) + if (p == nullptr) return; if (p->entry_buf) p->free_func(p->entry_buf); - p->entry_buf = NULL; + p->entry_buf = nullptr; p->entry_size = 0; return; @@ -154,7 +154,7 @@ int csv_fini(struct csv_parser *p, void (*cb1)(void *, size_t, void *), void (*c size_t spaces = p->spaces; size_t entry_pos = p->entry_pos; - if (p == NULL) + if (p == nullptr) return -1; @@ -258,7 +258,7 @@ static int csv_increase_buffer(struct csv_parser *p) { return -1; } - while ((vp = p->realloc_func(p->entry_buf, p->entry_size + to_add)) == NULL) { + while ((vp = p->realloc_func(p->entry_buf, p->entry_size + to_add)) == nullptr) { to_add /= 2; if (!to_add) { p->status = CSV_ENOMEM; @@ -423,10 +423,10 @@ size_t csv_write(void *dest, size_t dest_size, const void *src, size_t src_size) const unsigned char *csrc = (const unsigned char *)src; size_t chars = 0; - if (src == NULL) + if (src == nullptr) return 0; - if (cdest == NULL) + if (cdest == nullptr) dest_size = 0; if (dest_size > 0) @@ -456,7 +456,7 @@ size_t csv_write(void *dest, size_t dest_size, const void *src, size_t src_size) int csv_fwrite(Common::WriteStream *fp, const void *src, size_t src_size) { const unsigned char *csrc = (const unsigned char *)src; - if (fp == NULL || src == NULL) + if (fp == nullptr || src == nullptr) return 0; fp->writeByte('"'); @@ -479,10 +479,10 @@ size_t csv_write2(void *dest, size_t dest_size, const void *src, size_t src_size const unsigned char *csrc = (const unsigned char *)src; size_t chars = 0; - if (src == NULL) + if (src == nullptr) return 0; - if (dest == NULL) + if (dest == nullptr) dest_size = 0; if (dest_size > 0) @@ -512,7 +512,7 @@ size_t csv_write2(void *dest, size_t dest_size, const void *src, size_t src_size int csv_fwrite2(Common::WriteStream *fp, const void *src, size_t src_size, unsigned char quote) { const unsigned char *csrc = (const unsigned char *)src; - if (fp == NULL || src == NULL) + if (fp == nullptr || src == nullptr) return 0; fp->writeByte(quote); diff --git a/engines/glk/jacl/loader.cpp b/engines/glk/jacl/loader.cpp index 6af3b76c795..e30294a00e9 100644 --- a/engines/glk/jacl/loader.cpp +++ b/engines/glk/jacl/loader.cpp @@ -59,9 +59,9 @@ extern struct synonym_type *synonym_table; extern struct filter_type *filter_table; -struct string_type *current_string = NULL; -struct integer_type *current_integer = NULL; -struct integer_type *last_system_integer = NULL; +struct string_type *current_string = nullptr; +struct integer_type *current_integer = nullptr; +struct integer_type *last_system_integer = nullptr; extern struct string_type *current_cstring; extern struct cinteger_type *current_cinteger; @@ -97,15 +97,15 @@ void read_gamefile() { long start_of_file = 0; long bit_mask; - filter_type *current_filter = NULL; - filter_type *new_filter = NULL; - attribute_type *current_attribute = NULL; - attribute_type *new_attribute = NULL; - cinteger_type *resolved_cinteger = NULL; - synonym_type *current_synonym = NULL; - synonym_type *new_synonym = NULL; - function_type *current_function = NULL; - name_type *current_name = NULL; + filter_type *current_filter = nullptr; + filter_type *new_filter = nullptr; + attribute_type *current_attribute = nullptr; + attribute_type *new_attribute = nullptr; + cinteger_type *resolved_cinteger = nullptr; + synonym_type *current_synonym = nullptr; + synonym_type *new_synonym = nullptr; + function_type *current_function = nullptr; + name_type *current_name = nullptr; char function_name[81]; @@ -235,7 +235,7 @@ void read_gamefile() { /* CREATE A DUMMY FUNCTION TO BE USED WHEN AN ERROR MESSAGE IS PRINTED AS A RESULT OF CODE CALLED BY THE INTERPRETER */ if ((function_table = (struct function_type *) - malloc(sizeof(struct function_type))) == NULL) + malloc(sizeof(struct function_type))) == nullptr) outofmem(); else { current_function = function_table; @@ -244,7 +244,7 @@ void read_gamefile() { current_function->self = 0; current_function->call_count = 0; current_function->call_count_backup = 0; - current_function->next_function = NULL; + current_function->next_function = nullptr; } executing_function = function_table; @@ -271,7 +271,7 @@ void read_gamefile() { while (result) { encapsulate(); - if (word[0] == NULL); + if (word[0] == nullptr); else if (text_buffer[0] == '{') { while (result) { result = glk_get_bin_line_stream(game_stream, text_buffer, (glui32) 1024); @@ -288,19 +288,19 @@ void read_gamefile() { } } else { if (!strcmp(word[0], "grammar")) { - if (word[++wp] == NULL) { + if (word[++wp] == nullptr) { noproperr(line); errors++; } else { - if (grammar_table == NULL) { + if (grammar_table == nullptr) { if ((grammar_table = (struct word_type *) - malloc(sizeof(struct word_type))) == NULL) + malloc(sizeof(struct word_type))) == nullptr) outofmem(); else { strncpy(grammar_table->word, word[wp], 40); grammar_table->word[40] = 0; - grammar_table->next_sibling = NULL; - grammar_table->first_child = NULL; + grammar_table->next_sibling = nullptr; + grammar_table->first_child = nullptr; build_grammar_table(grammar_table); } } else @@ -308,7 +308,7 @@ void read_gamefile() { } } else if (!strcmp(word[0], "object") || !strcmp(word[0], "location")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { noproperr(line); errors++; } else if (legal_label_check(word[1], line, OBJ_TYPE)) { @@ -322,13 +322,13 @@ void read_gamefile() { return; } else { if ((object[objects] = (struct object_type *) - malloc(sizeof(struct object_type))) == NULL) + malloc(sizeof(struct object_type))) == nullptr) outofmem(); strncpy(object[objects]->label, word[1], 40); object[objects]->label[40] = 0; - object[objects]->first_plural = NULL; + object[objects]->first_plural = nullptr; strcpy(object[objects]->described, object[objects]->label); strcpy(object[objects]->inventory, object[objects]->label); @@ -343,15 +343,15 @@ void read_gamefile() { object[objects]->nosave = FALSE; } } else if (!strcmp(word[0], "synonym")) { - if (word[++wp] == NULL) { + if (word[++wp] == nullptr) { noproperr(line); errors++; } else { if ((new_synonym = (struct synonym_type *) - malloc(sizeof(struct synonym_type))) == NULL) + malloc(sizeof(struct synonym_type))) == nullptr) outofmem(); else { - if (synonym_table == NULL) { + if (synonym_table == nullptr) { synonym_table = new_synonym; } else { current_synonym->next_synonym = new_synonym; @@ -360,14 +360,14 @@ void read_gamefile() { current_synonym = new_synonym; strncpy(current_synonym->original, word[wp], 40); current_synonym->original[40] = 0; - if (word[++wp] == NULL) { + if (word[++wp] == nullptr) { noproperr(line); errors++; } else { strncpy(current_synonym->standard, word[wp], 40); current_synonym->standard[40] = 0; } - current_synonym->next_synonym = NULL; + current_synonym->next_synonym = nullptr; } } else if (!strcmp(word[0], "parameter")) { #ifdef UNUSED @@ -413,7 +413,7 @@ void read_gamefile() { warning("parameter"); #endif } else if (!strcmp(word[0], "constant")) { - if (word[2] == NULL) { + if (word[2] == nullptr) { noproperr(line); errors++; } else { @@ -421,7 +421,7 @@ void read_gamefile() { ADDITIONAL CONSTANTS IF REQUIRED */ index = 2; - while (word[index] != NULL && index < MAX_WORDS) { + while (word[index] != nullptr && index < MAX_WORDS) { if (quoted[index] == TRUE || !validate(word[index])) { if (legal_label_check(word[1], line, CSTR_TYPE)) { errors++; @@ -443,20 +443,20 @@ void read_gamefile() { } } } else if (!strcmp(word[0], "attribute")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { noproperr(line); errors++; } else if (legal_label_check(word[1], line, ATT_TYPE)) { errors++; - } else if (current_attribute != NULL && current_attribute->value == 1073741824) { + } else if (current_attribute != nullptr && current_attribute->value == 1073741824) { maxatterr(line, 1); errors++; } else { if ((new_attribute = (struct attribute_type *) - malloc(sizeof(struct attribute_type))) == NULL) + malloc(sizeof(struct attribute_type))) == nullptr) outofmem(); else { - if (attribute_table == NULL) { + if (attribute_table == nullptr) { attribute_table = new_attribute; new_attribute->value = 1; } else { @@ -466,21 +466,21 @@ void read_gamefile() { current_attribute = new_attribute; strncpy(current_attribute->name, word[1], 40); current_attribute->name[40] = 0; - current_attribute->next_attribute = NULL; + current_attribute->next_attribute = nullptr; } /* CHECK IF MORE THAN ONE VALUE IS SUPPLIED AND CREATE ADDITIONAL CONSTANTS IF REQUIRED */ index = 2; - while (word[index] != NULL && index < MAX_WORDS) { + while (word[index] != nullptr && index < MAX_WORDS) { if (legal_label_check(word[index], line, ATT_TYPE)) { errors++; - } else if (current_attribute != NULL && current_attribute->value == 1073741824) { + } else if (current_attribute != nullptr && current_attribute->value == 1073741824) { maxatterr(line, index); errors++; } else { if ((new_attribute = (struct attribute_type *) - malloc(sizeof(struct attribute_type))) == NULL) + malloc(sizeof(struct attribute_type))) == nullptr) outofmem(); else { current_attribute->next_attribute = new_attribute; @@ -488,40 +488,40 @@ void read_gamefile() { current_attribute = new_attribute; strncpy(current_attribute->name, word[index], 40); current_attribute->name[40] = 0; - current_attribute->next_attribute = NULL; + current_attribute->next_attribute = nullptr; } } index++; } } } else if (!strcmp(word[0], "string")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { noproperr(line); errors++; } else if (legal_label_check(word[1], line, STR_TYPE)) { errors++; } else { - if (word[2] == NULL) { + if (word[2] == nullptr) { create_string(word[1], ""); } else { create_string(word[1], word[2]); index = 3; - while (word[index] != NULL && index < MAX_WORDS) { + while (word[index] != nullptr && index < MAX_WORDS) { create_string(word[1], word[index]); index++; } } } } else if (!strcmp(word[0], "filter")) { - if (word[++wp] == NULL) { + if (word[++wp] == nullptr) { noproperr(line); errors++; } else { if ((new_filter = (struct filter_type *) - malloc(sizeof(struct filter_type))) == NULL) + malloc(sizeof(struct filter_type))) == nullptr) outofmem(); else { - if (filter_table == NULL) { + if (filter_table == nullptr) { filter_table = new_filter; } else { current_filter->next_filter = new_filter; @@ -529,11 +529,11 @@ void read_gamefile() { current_filter = new_filter; strncpy(current_filter->word, word[wp], 40); current_filter->word[40] = 0; - current_filter->next_filter = NULL; + current_filter->next_filter = nullptr; } } } else if (!strcmp(word[0], "string_array")) { - if (word[2] == NULL) { + if (word[2] == nullptr) { noproperr(line); errors++; } else if (legal_label_check(word[1], line, STR_TYPE)) { @@ -552,7 +552,7 @@ void read_gamefile() { } } } else if (!strcmp(word[0], "integer_array")) { - if (word[2] == NULL) { + if (word[2] == nullptr) { noproperr(line); errors++; } else if (legal_label_check(word[1], line, INT_TYPE)) { @@ -560,7 +560,7 @@ void read_gamefile() { } else { int default_value, x; - if (word[3] != NULL) { + if (word[3] != nullptr) { default_value = value_of(word[3], FALSE); if (!value_resolved) { unkvalerr(line, 3); @@ -582,7 +582,7 @@ void read_gamefile() { } } } else if (!strcmp(word[0], "integer")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { noproperr(line); errors++; } else if (legal_label_check(word[1], line, INT_TYPE)) { @@ -593,7 +593,7 @@ void read_gamefile() { /* CHECK IF MORE THAN ONE VALUE IS SUPPLIED AND CREATE ADDITIONAL VARIABLES IF REQUIRED */ index = 3; - while (word[index] != NULL && index < MAX_WORDS) { + while (word[index] != nullptr && index < MAX_WORDS) { create_integer(word[1], 0); index++; } @@ -623,17 +623,17 @@ void read_gamefile() { *************************************************************************/ /* IF NO SIZE IS SPECIFIED FOR THE STATUS WINDOW, SET IT TO 1 */ - if (integer_resolve("status_window") == NULL) { + if (integer_resolve("status_window") == nullptr) { create_integer("status_window", 1); } /* IF NO STRING IS SPECIFIED FOR THE COMMAND PROMPT, SET IT TO "^> " */ - if (string_resolve("command_prompt") == NULL) { + if (string_resolve("command_prompt") == nullptr) { create_string("command_prompt", "^> "); } /* IF NO STRING IS SPECIFIED FOR THE GAME_TITLE, SET IT TO THE FILENAME */ - if (cstring_resolve("game_title") == NULL) { + if (cstring_resolve("game_title") == nullptr) { create_cstring("game_title", prefix); } @@ -661,7 +661,7 @@ void read_gamefile() { while (result) { encapsulate(); - if (word[0] == NULL); + if (word[0] == nullptr); else if (text_buffer[0] == '{') { word[wp]++; /* MOVE THE START OF THE FIRST WORD ONLY * TO PAST THE '{'. */ @@ -669,13 +669,13 @@ void read_gamefile() { nofnamerr(line); errors++; } else { - while (word[wp] != NULL && wp < MAX_WORDS) { + while (word[wp] != nullptr && wp < MAX_WORDS) { if (word[wp][0] == '+') { strncpy(function_name, word[wp], 80); function_name[80] = 0; self_parent = 0; } else if (word[wp][0] == '*') { - const char *last_underscore = (char *)NULL; + const char *last_underscore = (char *)nullptr; /* ALLOW MANUAL NAMING OF ASSOCIATED FUNCTIONS */ /* TO GIVE CLASS-LIKE BEHAVIOR */ @@ -685,7 +685,7 @@ void read_gamefile() { /* LOOK FOR THE FINAL UNDERSCORE AND SEE IF */ /* IT IS FOLLOWED BY AN OBJECT LABEL */ last_underscore = strrchr(word[wp], '_'); - if (last_underscore != NULL) { + if (last_underscore != nullptr) { self_parent = object_resolve(last_underscore + 1); } else { self_parent = 0; @@ -699,9 +699,9 @@ void read_gamefile() { strcat(function_name, object[object_count]->label); self_parent = object_count; } - if (function_table == NULL) { + if (function_table == nullptr) { if ((function_table = (struct function_type *) - malloc(sizeof(struct function_type))) == NULL) + malloc(sizeof(struct function_type))) == nullptr) outofmem(); else { // STORE THE NUMBER OF FUNCTION DEFINED TO @@ -715,12 +715,12 @@ void read_gamefile() { current_function->call_count = 0; current_function->call_count_backup = 0; current_function->self = self_parent; - current_function->next_function = NULL; + current_function->next_function = nullptr; } } else { if ((current_function->next_function = (struct function_type *) - malloc(sizeof(struct function_type))) == NULL) + malloc(sizeof(struct function_type))) == nullptr) outofmem(); else { // STORE THE NUMBER OF FUNCTION DEFINED TO @@ -734,7 +734,7 @@ void read_gamefile() { current_function->call_count = 0; current_function->call_count_backup = 0; current_function->self = self_parent; - current_function->next_function = NULL; + current_function->next_function = nullptr; } } wp++; @@ -757,7 +757,7 @@ void read_gamefile() { } else if (!strcmp(word[0], "string_array")) { } else if (!strcmp(word[0], "integer_array")) { - if (word[2] == NULL) { + if (word[2] == nullptr) { noproperr(line); errors++; } else { @@ -775,7 +775,7 @@ void read_gamefile() { } } } else if (!strcmp(word[0], "integer")) { - if (word[2] != NULL) { + if (word[2] != nullptr) { current_integer = current_integer->next_integer; current_integer->value = value_of(word[2], FALSE); if (!value_resolved) { @@ -783,7 +783,7 @@ void read_gamefile() { errors++; } index = 3; - while (word[index] != NULL && index < MAX_WORDS) { + while (word[index] != nullptr && index < MAX_WORDS) { current_integer = current_integer->next_integer; current_integer->value = value_of(word[index], FALSE); if (!value_resolved) { @@ -807,14 +807,14 @@ void read_gamefile() { else if (!strcmp(word[0], "grammar")); else if (!strcmp(word[0], "filter")); else if (!strcmp(word[0], "has")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { noproperr(line); errors++; } else if (object_count == 0) { noobjerr(line); errors++; } else { - for (index = 1; word[index] != NULL && index < MAX_WORDS; index++) { + for (index = 1; word[index] != nullptr && index < MAX_WORDS; index++) { if ((bit_mask = attribute_resolve(word[index]))) { object[object_count]->attributes = object[object_count]->attributes | bit_mask; } else if ((bit_mask = user_attribute_resolve(word[index]))) { @@ -845,60 +845,60 @@ void read_gamefile() { if ((object[object_count]->first_name = (struct name_type *) malloc(sizeof(struct name_type))) - == NULL) + == nullptr) outofmem(); else { current_name = object[object_count]->first_name; - if (word[2] != NULL) { + if (word[2] != nullptr) { strncpy(current_name->name, word[2], 40); } else { strncpy(current_name->name, object[object_count]->label, 40); } current_name->name[40] = 0; - current_name->next_name = NULL; + current_name->next_name = nullptr; } wp = 3; - while (word[wp] != NULL && wp < MAX_WORDS) { + while (word[wp] != nullptr && wp < MAX_WORDS) { if ((current_name->next_name = (struct name_type *) - malloc(sizeof(struct name_type))) == NULL) + malloc(sizeof(struct name_type))) == nullptr) outofmem(); else { current_name = current_name->next_name; strncpy(current_name->name, word[wp], 40); current_name->name[40] = 0; - current_name->next_name = NULL; + current_name->next_name = nullptr; } wp++; } } else if (!strcmp(word[0], "plural")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { noproperr(line); errors++; } else { if ((object[object_count]->first_plural = (struct name_type *) malloc(sizeof(struct name_type))) - == NULL) + == nullptr) outofmem(); else { current_name = object[object_count]->first_plural; strncpy(current_name->name, word[1], 40); current_name->name[40] = 0; - current_name->next_name = NULL; + current_name->next_name = nullptr; } wp = 2; - while (word[wp] != NULL && wp < MAX_WORDS) { + while (word[wp] != nullptr && wp < MAX_WORDS) { if ((current_name->next_name = (struct name_type *) - malloc(sizeof(struct name_type))) == NULL) + malloc(sizeof(struct name_type))) == nullptr) outofmem(); else { current_name = current_name->next_name; strncpy(current_name->name, word[wp], 40); current_name->name[40] = 0; - current_name->next_name = NULL; + current_name->next_name = nullptr; } wp++; } @@ -916,7 +916,7 @@ void read_gamefile() { } else player = object_count; } else if (!strcmp(word[0], "short")) { - if (word[2] == NULL) { + if (word[2] == nullptr) { noproperr(line); errors++; } else if (object_count == 0) { @@ -929,7 +929,7 @@ void read_gamefile() { object[object_count]->inventory[40] = 0; } } else if (!strcmp(word[0], "definite")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { noproperr(line); errors++; } else if (object_count == 0) { @@ -940,7 +940,7 @@ void read_gamefile() { object[object_count]->definite[10] = 0; } } else if (!strcmp(word[0], "long")) { - if (word[1] == NULL) { + if (word[1] == nullptr) { noproperr(line); errors++; } else if (object_count == 0) { @@ -950,9 +950,9 @@ void read_gamefile() { strncpy(object[object_count]->described, word[1], 80); object[object_count]->described[80] = 0; } - } else if ((resolved_cinteger = cinteger_resolve(word[0])) != NULL) { + } else if ((resolved_cinteger = cinteger_resolve(word[0])) != nullptr) { index = resolved_cinteger->value; - if (word[1] == NULL) { + if (word[1] == nullptr) { noproperr(line); errors++; } else if (object_count == 0) { @@ -1004,39 +1004,39 @@ void read_gamefile() { void build_grammar_table(struct word_type *pointer) { do { if (!strcmp(word[wp], pointer->word)) { - if (pointer->first_child == NULL && word[wp + 1] != NULL) { + if (pointer->first_child == nullptr && word[wp + 1] != nullptr) { if ((pointer->first_child = (struct word_type *) malloc(sizeof(struct word_type))) - == NULL) + == nullptr) outofmem(); else { pointer = pointer->first_child; strncpy(pointer->word, word[++wp], 40); pointer->word[40] = 0; - pointer->next_sibling = NULL; - pointer->first_child = NULL; + pointer->next_sibling = nullptr; + pointer->first_child = nullptr; } } else { pointer = pointer->first_child; wp++; } } else { - if (pointer->next_sibling == NULL) { + if (pointer->next_sibling == nullptr) { if ((pointer->next_sibling = (struct word_type *) malloc(sizeof(struct word_type))) - == NULL) + == nullptr) outofmem(); else { pointer = pointer->next_sibling; strncpy(pointer->word, word[wp], 40); pointer->word[40] = 0; - pointer->next_sibling = NULL; - pointer->first_child = NULL; + pointer->next_sibling = nullptr; + pointer->first_child = nullptr; } } else pointer = pointer->next_sibling; } - } while (word[wp] != NULL && wp < MAX_WORDS); + } while (word[wp] != nullptr && wp < MAX_WORDS); } int legal_label_check(const char *label_word, int line, int type) { @@ -1078,7 +1078,7 @@ int legal_label_check(const char *label_word, int line, int type) { } } - while (integer_pointer != NULL && type != INT_TYPE) { + while (integer_pointer != nullptr && type != INT_TYPE) { if (!strcmp(label_word, integer_pointer->name)) { sprintf(error_buffer, USED_LABEL_INT, line, label_word); log_error(error_buffer, PLUS_STDERR); @@ -1089,7 +1089,7 @@ int legal_label_check(const char *label_word, int line, int type) { } - while (cinteger_pointer != NULL && type != CINT_TYPE) { + while (cinteger_pointer != nullptr && type != CINT_TYPE) { if (!strcmp(label_word, cinteger_pointer->name)) { sprintf(error_buffer, USED_LABEL_CINT, line, label_word); log_error(error_buffer, PLUS_STDERR); @@ -1099,7 +1099,7 @@ int legal_label_check(const char *label_word, int line, int type) { cinteger_pointer = cinteger_pointer->next_cinteger; } - while (string_pointer != NULL && type != STR_TYPE) { + while (string_pointer != nullptr && type != STR_TYPE) { if (!strcmp(label_word, string_pointer->name)) { sprintf(error_buffer, USED_LABEL_STR, line, label_word); log_error(error_buffer, PLUS_STDERR); @@ -1109,7 +1109,7 @@ int legal_label_check(const char *label_word, int line, int type) { string_pointer = string_pointer->next_string; } - while (cstring_pointer != NULL && type != CSTR_TYPE) { + while (cstring_pointer != nullptr && type != CSTR_TYPE) { if (!strcmp(label_word, cstring_pointer->name)) { sprintf(error_buffer, USED_LABEL_CSTR, line, label_word); log_error(error_buffer, PLUS_STDERR); @@ -1120,7 +1120,7 @@ int legal_label_check(const char *label_word, int line, int type) { } /* DON'T CHECK FOR ATT_TYPE AS YOU CAN'T HAVE ATTRIBUTE ARRAYS. */ - while (attribute_pointer != NULL) { + while (attribute_pointer != nullptr) { if (!strcmp(label_word, attribute_pointer->name)) { sprintf(error_buffer, USED_LABEL_ATT, line, label_word); write_text(error_buffer); @@ -1178,7 +1178,7 @@ void restart_game() { /* FREE ALL OBJECTS */ for (index = 1; index <= objects; index++) { current_name = object[index]->first_name; - while (current_name->next_name != NULL) { + while (current_name->next_name != nullptr) { next_name = current_name->next_name; free(current_name); current_name = next_name; @@ -1189,157 +1189,157 @@ void restart_game() { /* FREE ALL VARIABLES */ - if (integer_table != NULL) { - if (integer_table->next_integer != NULL) { + if (integer_table != nullptr) { + if (integer_table->next_integer != nullptr) { do { curr_integer = integer_table; previous_integer = integer_table; - while (curr_integer->next_integer != NULL) { + while (curr_integer->next_integer != nullptr) { previous_integer = curr_integer; curr_integer = curr_integer->next_integer; } free(curr_integer); - previous_integer->next_integer = NULL; + previous_integer->next_integer = nullptr; } while (previous_integer != integer_table); } free(integer_table); - integer_table = NULL; + integer_table = nullptr; } /* FREE ALL FUNCTIONS */ - if (function_table != NULL) { - if (function_table->next_function != NULL) { + if (function_table != nullptr) { + if (function_table->next_function != nullptr) { do { current_function = function_table; previous_function = function_table; - while (current_function->next_function != NULL) { + while (current_function->next_function != nullptr) { previous_function = current_function; current_function = current_function->next_function; } free(current_function); - previous_function->next_function = NULL; + previous_function->next_function = nullptr; } while (previous_function != function_table); } free(function_table); - function_table = NULL; + function_table = nullptr; } /* FREE ALL FILTERS */ - if (filter_table != NULL) { - if (filter_table->next_filter != NULL) { + if (filter_table != nullptr) { + if (filter_table->next_filter != nullptr) { do { current_filter = filter_table; previous_filter = filter_table; - while (current_filter->next_filter != NULL) { + while (current_filter->next_filter != nullptr) { previous_filter = current_filter; current_filter = current_filter->next_filter; } free(current_filter); - previous_filter->next_filter = NULL; + previous_filter->next_filter = nullptr; } while (previous_filter != filter_table); } free(filter_table); - filter_table = NULL; + filter_table = nullptr; } /* FREE ALL STRINGS */ - if (string_table != NULL) { - if (string_table->next_string != NULL) { + if (string_table != nullptr) { + if (string_table->next_string != nullptr) { do { curr_string = string_table; previous_string = string_table; - while (curr_string->next_string != NULL) { + while (curr_string->next_string != nullptr) { previous_string = curr_string; curr_string = curr_string->next_string; } free(curr_string); - previous_string->next_string = NULL; + previous_string->next_string = nullptr; } while (previous_string != string_table); } free(string_table); - string_table = NULL; + string_table = nullptr; } /* FREE ALL ATTRIBUTES */ - if (attribute_table != NULL) { - if (attribute_table->next_attribute != NULL) { + if (attribute_table != nullptr) { + if (attribute_table->next_attribute != nullptr) { do { current_attribute = attribute_table; previous_attribute = attribute_table; - while (current_attribute->next_attribute != NULL) { + while (current_attribute->next_attribute != nullptr) { previous_attribute = current_attribute; current_attribute = current_attribute->next_attribute; } free(current_attribute); - previous_attribute->next_attribute = NULL; + previous_attribute->next_attribute = nullptr; } while (previous_attribute != attribute_table); } free(attribute_table); - attribute_table = NULL; + attribute_table = nullptr; } /* FREE ALL CONSTANTS */ - if (cinteger_table != NULL) { - if (cinteger_table->next_cinteger != NULL) { + if (cinteger_table != nullptr) { + if (cinteger_table->next_cinteger != nullptr) { do { current_cinteger = cinteger_table; previous_cinteger = cinteger_table; - while (current_cinteger->next_cinteger != NULL) { + while (current_cinteger->next_cinteger != nullptr) { previous_cinteger = current_cinteger; current_cinteger = current_cinteger->next_cinteger; } free(current_cinteger); - previous_cinteger->next_cinteger = NULL; + previous_cinteger->next_cinteger = nullptr; } while (previous_cinteger != cinteger_table); } free(cinteger_table); - cinteger_table = NULL; + cinteger_table = nullptr; } - if (cstring_table != NULL) { - if (cstring_table->next_string != NULL) { + if (cstring_table != nullptr) { + if (cstring_table->next_string != nullptr) { do { curr_string = cstring_table; previous_string = cstring_table; - while (curr_string->next_string != NULL) { + while (curr_string->next_string != nullptr) { previous_string = curr_string; curr_string = curr_string->next_string; } free(curr_string); - previous_string->next_string = NULL; + previous_string->next_string = nullptr; } while (previous_string != cstring_table); } free(cstring_table); - cstring_table = NULL; + cstring_table = nullptr; } /* FREE ALL SYNONYMS */ - if (synonym_table != NULL) { - if (synonym_table->next_synonym != NULL) { + if (synonym_table != nullptr) { + if (synonym_table->next_synonym != nullptr) { do { current_synonym = synonym_table; previous_synonym = synonym_table; - while (current_synonym->next_synonym != NULL) { + while (current_synonym->next_synonym != nullptr) { previous_synonym = current_synonym; current_synonym = current_synonym->next_synonym; } free(current_synonym); - previous_synonym->next_synonym = NULL; + previous_synonym->next_synonym = nullptr; } while (previous_synonym != synonym_table); } free(synonym_table); - synonym_table = NULL; + synonym_table = nullptr; } free_from(grammar_table); - grammar_table = NULL; + grammar_table = nullptr; read_gamefile(); } @@ -1361,13 +1361,13 @@ void set_defaults() { } void create_cinteger(const char *name, int value) { - struct cinteger_type *new_cinteger = NULL; + struct cinteger_type *new_cinteger = nullptr; if ((new_cinteger = (struct cinteger_type *) - malloc(sizeof(struct cinteger_type))) == NULL) { + malloc(sizeof(struct cinteger_type))) == nullptr) { outofmem(); } else { - if (cinteger_table == NULL) { + if (cinteger_table == nullptr) { cinteger_table = new_cinteger; } else { current_cinteger->next_cinteger = new_cinteger; @@ -1377,22 +1377,22 @@ void create_cinteger(const char *name, int value) { strncpy(current_cinteger->name, name, 40); current_cinteger->name[40] = 0; current_cinteger->value = value; - current_cinteger->next_cinteger = NULL; + current_cinteger->next_cinteger = nullptr; } } void create_integer(const char *name, int value) { - struct integer_type *new_integer = NULL; + struct integer_type *new_integer = nullptr; if ((new_integer = (struct integer_type *) - malloc(sizeof(struct integer_type))) == NULL) { + malloc(sizeof(struct integer_type))) == nullptr) { outofmem(); } else { /* KEEP A COUNT OF HOW MANY INTEGERS ARE DEFINED TO * VALIDATE SAVED GAMES */ integers++; - if (integer_table == NULL) { + if (integer_table == nullptr) { integer_table = new_integer; } else { current_integer->next_integer = new_integer; @@ -1401,22 +1401,22 @@ void create_integer(const char *name, int value) { strncpy(current_integer->name, name, 40); current_integer->name[40] = 0; current_integer->value = value; - current_integer->next_integer = NULL; + current_integer->next_integer = nullptr; } } void create_string(const char *name, const char *value) { - struct string_type *new_string = NULL; + struct string_type *new_string = nullptr; if ((new_string = (struct string_type *) - malloc(sizeof(struct string_type))) == NULL) { + malloc(sizeof(struct string_type))) == nullptr) { outofmem(); } else { /* KEEP A COUNT OF HOW MANY STRINGS ARE DEFINED TO * VALIDATE SAVED GAMES */ strings++; - if (string_table == NULL) { + if (string_table == nullptr) { string_table = new_string; } else { current_string->next_string = new_string; @@ -1425,7 +1425,7 @@ void create_string(const char *name, const char *value) { strncpy(current_string->name, name, 40); current_string->name[40] = 0; - if (value != NULL) { + if (value != nullptr) { strncpy(current_string->value, value, 255); } else { /* IF NO VALUE IS SUPPLIED, JUST NULL-TERMINATE @@ -1434,18 +1434,18 @@ void create_string(const char *name, const char *value) { } current_string->value[255] = 0; - current_string->next_string = NULL; + current_string->next_string = nullptr; } } void create_cstring(const char *name, const char *value) { - struct string_type *new_string = NULL; + struct string_type *new_string = nullptr; if ((new_string = (struct string_type *) - malloc(sizeof(struct string_type))) == NULL) { + malloc(sizeof(struct string_type))) == nullptr) { outofmem(); } else { - if (cstring_table == NULL) { + if (cstring_table == nullptr) { cstring_table = new_string; } else { current_cstring->next_string = new_string; @@ -1454,7 +1454,7 @@ void create_cstring(const char *name, const char *value) { strncpy(current_cstring->name, name, 40); current_cstring->name[40] = 0; - if (value != NULL) { + if (value != nullptr) { strncpy(current_cstring->value, value, 255); } else { /* IF NO VALUE IS SUPPLIED, JUST NULL-TERMINATE @@ -1463,7 +1463,7 @@ void create_cstring(const char *name, const char *value) { } current_cstring->value[255] = 0; - current_cstring->next_string = NULL; + current_cstring->next_string = nullptr; } } @@ -1472,201 +1472,201 @@ void create_language_constants() { * ARE MISSING FROM THE GAME THAT IS BEING LOADED. DEFAULT * TO THE NATIVE_LANGUAGE SETTING IN language.h */ - if (cstring_resolve("COMMENT_IGNORED") == NULL) + if (cstring_resolve("COMMENT_IGNORED") == nullptr) create_cstring("COMMENT_IGNORED", COMMENT_IGNORED); - if (cstring_resolve("COMMENT_RECORDED") == NULL) + if (cstring_resolve("COMMENT_RECORDED") == nullptr) create_cstring("COMMENT_RECORDED", COMMENT_RECORDED); - if (cstring_resolve("YES_WORD") == NULL) + if (cstring_resolve("YES_WORD") == nullptr) create_cstring("YES_WORD", YES_WORD); - if (cstring_resolve("NO_WORD") == NULL) + if (cstring_resolve("NO_WORD") == nullptr) create_cstring("NO_WORD", NO_WORD); - if (cstring_resolve("YES_OR_NO") == NULL) + if (cstring_resolve("YES_OR_NO") == nullptr) create_cstring("YES_OR_NO", YES_OR_NO); - if (cstring_resolve("INVALID_SELECTION") == NULL) + if (cstring_resolve("INVALID_SELECTION") == nullptr) create_cstring("INVALID_SELECTION", INVALID_SELECTION); - if (cstring_resolve("RESTARTING") == NULL) + if (cstring_resolve("RESTARTING") == nullptr) create_cstring("RESTARTING", RESTARTING); - if (cstring_resolve("RETURN_GAME") == NULL) + if (cstring_resolve("RETURN_GAME") == nullptr) create_cstring("RETURN_GAME", RETURN_GAME); - if (cstring_resolve("SCRIPTING_ON") == NULL) + if (cstring_resolve("SCRIPTING_ON") == nullptr) create_cstring("SCRIPTING_ON", SCRIPTING_ON); - if (cstring_resolve("SCRIPTING_OFF") == NULL) + if (cstring_resolve("SCRIPTING_OFF") == nullptr) create_cstring("SCRIPTING_OFF", SCRIPTING_OFF); - if (cstring_resolve("SCRIPTING_ALREADY_OFF") == NULL) + if (cstring_resolve("SCRIPTING_ALREADY_OFF") == nullptr) create_cstring("SCRIPTING_ALREADY_OFF", SCRIPTING_ALREADY_OFF); - if (cstring_resolve("SCRIPTING_ALREADY_ON") == NULL) + if (cstring_resolve("SCRIPTING_ALREADY_ON") == nullptr) create_cstring("SCRIPTING_ALREADY_ON", SCRIPTING_ALREADY_ON); - if (cstring_resolve("CANT_WRITE_SCRIPT") == NULL) + if (cstring_resolve("CANT_WRITE_SCRIPT") == nullptr) create_cstring("CANT_WRITE_SCRIPT", CANT_WRITE_SCRIPT); - if (cstring_resolve("ERROR_READING_WALKTHRU") == NULL) + if (cstring_resolve("ERROR_READING_WALKTHRU") == nullptr) create_cstring("ERROR_READING_WALKTHRU", ERROR_READING_WALKTHRU); - if (cstring_resolve("BAD_OOPS") == NULL) + if (cstring_resolve("BAD_OOPS") == nullptr) create_cstring("BAD_OOPS", BAD_OOPS); - if (cstring_resolve("CANT_CORRECT") == NULL) + if (cstring_resolve("CANT_CORRECT") == nullptr) create_cstring("CANT_CORRECT", CANT_CORRECT); - if (cstring_resolve("SURE_QUIT") == NULL) + if (cstring_resolve("SURE_QUIT") == nullptr) create_cstring("SURE_QUIT", SURE_QUIT); - if (cstring_resolve("SURE_RESTART") == NULL) + if (cstring_resolve("SURE_RESTART") == nullptr) create_cstring("SURE_RESTART", SURE_RESTART); - if (cstring_resolve("NOT_CLEVER") == NULL) + if (cstring_resolve("NOT_CLEVER") == nullptr) create_cstring("NOT_CLEVER", NOT_CLEVER); - if (cstring_resolve("NO_MOVES") == NULL) + if (cstring_resolve("NO_MOVES") == nullptr) create_cstring("NO_MOVES", NO_MOVES); - if (cstring_resolve("TYPE_NUMBER") == NULL) + if (cstring_resolve("TYPE_NUMBER") == nullptr) create_cstring("TYPE_NUMBER", TYPE_NUMBER); - if (cstring_resolve("BY") == NULL) + if (cstring_resolve("BY") == nullptr) create_cstring("BY", BY); - if (cstring_resolve("REFERRING_TO") == NULL) + if (cstring_resolve("REFERRING_TO") == nullptr) create_cstring("REFERRING_TO", REFERRING_TO); - if (cstring_resolve("WALKTHRU_WORD") == NULL) + if (cstring_resolve("WALKTHRU_WORD") == nullptr) create_cstring("WALKTHRU_WORD", WALKTHRU_WORD); - if (cstring_resolve("INFO_WORD") == NULL) + if (cstring_resolve("INFO_WORD") == nullptr) create_cstring("INFO_WORD", INFO_WORD); - if (cstring_resolve("RESTART_WORD") == NULL) + if (cstring_resolve("RESTART_WORD") == nullptr) create_cstring("RESTART_WORD", RESTART_WORD); - if (cstring_resolve("AGAIN_WORD") == NULL) + if (cstring_resolve("AGAIN_WORD") == nullptr) create_cstring("AGAIN_WORD", AGAIN_WORD); - if (cstring_resolve("SCRIPT_WORD") == NULL) + if (cstring_resolve("SCRIPT_WORD") == nullptr) create_cstring("SCRIPT_WORD", SCRIPT_WORD); - if (cstring_resolve("UNSCRIPT_WORD") == NULL) + if (cstring_resolve("UNSCRIPT_WORD") == nullptr) create_cstring("UNSCRIPT_WORD", UNSCRIPT_WORD); - if (cstring_resolve("QUIT_WORD") == NULL) + if (cstring_resolve("QUIT_WORD") == nullptr) create_cstring("QUIT_WORD", QUIT_WORD); - if (cstring_resolve("UNDO_WORD") == NULL) + if (cstring_resolve("UNDO_WORD") == nullptr) create_cstring("UNDO_WORD", UNDO_WORD); - if (cstring_resolve("OOPS_WORD") == NULL) + if (cstring_resolve("OOPS_WORD") == nullptr) create_cstring("OOPS_WORD", OOPS_WORD); - if (cstring_resolve("FROM_WORD") == NULL) + if (cstring_resolve("FROM_WORD") == nullptr) create_cstring("FROM_WORD", FROM_WORD); - if (cstring_resolve("EXCEPT_WORD") == NULL) + if (cstring_resolve("EXCEPT_WORD") == nullptr) create_cstring("EXCEPT_WORD", EXCEPT_WORD); - if (cstring_resolve("FOR_WORD") == NULL) + if (cstring_resolve("FOR_WORD") == nullptr) create_cstring("FOR_WORD", FOR_WORD); - if (cstring_resolve("BUT_WORD") == NULL) + if (cstring_resolve("BUT_WORD") == nullptr) create_cstring("BUT_WORD", BUT_WORD); - if (cstring_resolve("AND_WORD") == NULL) + if (cstring_resolve("AND_WORD") == nullptr) create_cstring("AND_WORD", AND_WORD); - if (cstring_resolve("THEN_WORD") == NULL) + if (cstring_resolve("THEN_WORD") == nullptr) create_cstring("THEN_WORD", THEN_WORD); - if (cstring_resolve("OF_WORD") == NULL) + if (cstring_resolve("OF_WORD") == nullptr) create_cstring("OF_WORD", OF_WORD); - if (cstring_resolve("SHE_WORD") == NULL) + if (cstring_resolve("SHE_WORD") == nullptr) create_cstring("SHE_WORD", SHE_WORD); - if (cstring_resolve("HE_WORD") == NULL) + if (cstring_resolve("HE_WORD") == nullptr) create_cstring("HE_WORD", HE_WORD); - if (cstring_resolve("THAT_WORD") == NULL) + if (cstring_resolve("THAT_WORD") == nullptr) create_cstring("THAT_WORD", THAT_WORD); - if (cstring_resolve("THEM_WORD") == NULL) + if (cstring_resolve("THEM_WORD") == nullptr) create_cstring("THEM_WORD", THEM_WORD); - if (cstring_resolve("THOSE_WORD") == NULL) + if (cstring_resolve("THOSE_WORD") == nullptr) create_cstring("THOSE_WORD", THOSE_WORD); - if (cstring_resolve("THEY_WORD") == NULL) + if (cstring_resolve("THEY_WORD") == nullptr) create_cstring("THEY_WORD", THEY_WORD); - if (cstring_resolve("IT_WORD") == NULL) + if (cstring_resolve("IT_WORD") == nullptr) create_cstring("IT_WORD", IT_WORD); - if (cstring_resolve("ITSELF_WORD") == NULL) + if (cstring_resolve("ITSELF_WORD") == nullptr) create_cstring("ITSELF_WORD", ITSELF_WORD); - if (cstring_resolve("HIM_WORD") == NULL) + if (cstring_resolve("HIM_WORD") == nullptr) create_cstring("HIM_WORD", HIM_WORD); - if (cstring_resolve("HIMSELF_WORD") == NULL) + if (cstring_resolve("HIMSELF_WORD") == nullptr) create_cstring("HIMSELF_WORD", HIMSELF_WORD); - if (cstring_resolve("HER_WORD") == NULL) + if (cstring_resolve("HER_WORD") == nullptr) create_cstring("HER_WORD", HER_WORD); - if (cstring_resolve("HERSELF_WORD") == NULL) + if (cstring_resolve("HERSELF_WORD") == nullptr) create_cstring("HERSELF_WORD", HERSELF_WORD); - if (cstring_resolve("THEMSELVES_WORD") == NULL) + if (cstring_resolve("THEMSELVES_WORD") == nullptr) create_cstring("THEMSELVES_WORD", THEMSELVES_WORD); - if (cstring_resolve("YOU_WORD") == NULL) + if (cstring_resolve("YOU_WORD") == nullptr) create_cstring("YOU_WORD", YOU_WORD); - if (cstring_resolve("YOURSELF_WORD") == NULL) + if (cstring_resolve("YOURSELF_WORD") == nullptr) create_cstring("YOURSELF_WORD", YOURSELF_WORD); - if (cstring_resolve("ONES_WORD") == NULL) + if (cstring_resolve("ONES_WORD") == nullptr) create_cstring("ONES_WORD", ONES_WORD); - if (cstring_resolve("NO_MULTI_VERB") == NULL) + if (cstring_resolve("NO_MULTI_VERB") == nullptr) create_cstring("NO_MULTI_VERB", NO_MULTI_VERB); - if (cstring_resolve("NO_MULTI_START") == NULL) + if (cstring_resolve("NO_MULTI_START") == nullptr) create_cstring("NO_MULTI_START", NO_MULTI_START); - if (cstring_resolve("PERSON_CONCEALING") == NULL) + if (cstring_resolve("PERSON_CONCEALING") == nullptr) create_cstring("PERSON_CONCEALING", PERSON_CONCEALING); - if (cstring_resolve("PERSON_POSSESSIVE") == NULL) + if (cstring_resolve("PERSON_POSSESSIVE") == nullptr) create_cstring("PERSON_POSSESSIVE", PERSON_POSSESSIVE); - if (cstring_resolve("CONTAINER_CLOSED") == NULL) + if (cstring_resolve("CONTAINER_CLOSED") == nullptr) create_cstring("CONTAINER_CLOSED", CONTAINER_CLOSED); - if (cstring_resolve("CONTAINER_CLOSED_FEM") == NULL) + if (cstring_resolve("CONTAINER_CLOSED_FEM") == nullptr) create_cstring("CONTAINER_CLOSED_FEM", CONTAINER_CLOSED_FEM); - if (cstring_resolve("FROM_NON_CONTAINER") == NULL) + if (cstring_resolve("FROM_NON_CONTAINER") == nullptr) create_cstring("FROM_NON_CONTAINER", FROM_NON_CONTAINER); - if (cstring_resolve("DOUBLE_EXCEPT") == NULL) + if (cstring_resolve("DOUBLE_EXCEPT") == nullptr) create_cstring("DOUBLE_EXCEPT", DOUBLE_EXCEPT); - if (cstring_resolve("NONE_HELD") == NULL) + if (cstring_resolve("NONE_HELD") == nullptr) create_cstring("NONE_HELD", NONE_HELD); - if (cstring_resolve("NO_OBJECTS") == NULL) + if (cstring_resolve("NO_OBJECTS") == nullptr) create_cstring("NO_OBJECTS", NO_OBJECTS); - if (cstring_resolve("NO_FILENAME") == NULL) + if (cstring_resolve("NO_FILENAME") == nullptr) create_cstring("NO_FILENAME", NO_FILENAME); - if (cstring_resolve("MOVE_UNDONE") == NULL) + if (cstring_resolve("MOVE_UNDONE") == nullptr) create_cstring("MOVE_UNDONE", MOVE_UNDONE); - if (cstring_resolve("NO_UNDO") == NULL) + if (cstring_resolve("NO_UNDO") == nullptr) create_cstring("NO_UNDO", NO_UNDO); - if (cstring_resolve("CANT_SAVE") == NULL) + if (cstring_resolve("CANT_SAVE") == nullptr) create_cstring("CANT_SAVE", CANT_SAVE); - if (cstring_resolve("CANT_RESTORE") == NULL) + if (cstring_resolve("CANT_RESTORE") == nullptr) create_cstring("CANT_RESTORE", CANT_RESTORE); - if (cstring_resolve("GAME_SAVED") == NULL) + if (cstring_resolve("GAME_SAVED") == nullptr) create_cstring("GAME_SAVED", GAME_SAVED); - if (cstring_resolve("INCOMPLETE_SENTENCE") == NULL) + if (cstring_resolve("INCOMPLETE_SENTENCE") == nullptr) create_cstring("INCOMPLETE_SENTENCE", INCOMPLETE_SENTENCE); - if (cstring_resolve("UNKNOWN_OBJECT") == NULL) + if (cstring_resolve("UNKNOWN_OBJECT") == nullptr) create_cstring("UNKNOWN_OBJECT", UNKNOWN_OBJECT); - if (cstring_resolve("UNKNOWN_OBJECT_END") == NULL) + if (cstring_resolve("UNKNOWN_OBJECT_END") == nullptr) create_cstring("UNKNOWN_OBJECT_END", UNKNOWN_OBJECT_END); - if (cstring_resolve("CANT_USE_WORD") == NULL) + if (cstring_resolve("CANT_USE_WORD") == nullptr) create_cstring("CANT_USE_WORD", CANT_USE_WORD); - if (cstring_resolve("IN_CONTEXT") == NULL) + if (cstring_resolve("IN_CONTEXT") == nullptr) create_cstring("IN_CONTEXT", IN_CONTEXT); - if (cstring_resolve("DONT_SEE") == NULL) + if (cstring_resolve("DONT_SEE") == nullptr) create_cstring("DONT_SEE", DONT_SEE); - if (cstring_resolve("HERE_WORD") == NULL) + if (cstring_resolve("HERE_WORD") == nullptr) create_cstring("HERE_WORD", HERE_WORD); - if (cstring_resolve("BAD_SAVED_GAME") == NULL) + if (cstring_resolve("BAD_SAVED_GAME") == nullptr) create_cstring("BAD_SAVED_GAME", BAD_SAVED_GAME); - if (cstring_resolve("ARENT") == NULL) + if (cstring_resolve("ARENT") == nullptr) create_cstring("ARENT", ARENT); - if (cstring_resolve("ISNT") == NULL) + if (cstring_resolve("ISNT") == nullptr) create_cstring("ISNT", ISNT); - if (cstring_resolve("ARE") == NULL) + if (cstring_resolve("ARE") == nullptr) create_cstring("ARE", ARE); - if (cstring_resolve("IS") == NULL) + if (cstring_resolve("IS") == nullptr) create_cstring("IS", IS); - if (cstring_resolve("DONT") == NULL) + if (cstring_resolve("DONT") == nullptr) create_cstring("DONT", DONT); - if (cstring_resolve("DOESNT") == NULL) + if (cstring_resolve("DOESNT") == nullptr) create_cstring("DOESNT", DOESNT); - if (cstring_resolve("DO") == NULL) + if (cstring_resolve("DO") == nullptr) create_cstring("DO", DO); - if (cstring_resolve("DOES") == NULL) + if (cstring_resolve("DOES") == nullptr) create_cstring("DOES", DOES); - if (cstring_resolve("SCORE_UP") == NULL) + if (cstring_resolve("SCORE_UP") == nullptr) create_cstring("SCORE_UP", SCORE_UP); - if (cstring_resolve("POINT") == NULL) + if (cstring_resolve("POINT") == nullptr) create_cstring("POINT", POINT); - if (cstring_resolve("POINTS") == NULL) + if (cstring_resolve("POINTS") == nullptr) create_cstring("POINTS", POINTS); - if (cstring_resolve("STARTING") == NULL) + if (cstring_resolve("STARTING") == nullptr) create_cstring("STARTING", STARTING); - if (cstring_resolve("NO_IT") == NULL) + if (cstring_resolve("NO_IT") == nullptr) create_cstring("NO_IT", NO_IT); - if (cstring_resolve("NO_IT_END") == NULL) + if (cstring_resolve("NO_IT_END") == nullptr) create_cstring("NO_IT_END", NO_IT_END); - if (cstring_resolve("BACK_REFERENCE") == NULL) + if (cstring_resolve("BACK_REFERENCE") == nullptr) create_cstring("BACK_REFERENCE", BACK_REFERENCE); - if (cstring_resolve("BACK_REFERENCE_END") == NULL) + if (cstring_resolve("BACK_REFERENCE_END") == nullptr) create_cstring("BACK_REFERENCE_END", BACK_REFERENCE_END); - if (cstring_resolve("WHEN_YOU_SAY") == NULL) + if (cstring_resolve("WHEN_YOU_SAY") == nullptr) create_cstring("WHEN_YOU_SAY", WHEN_YOU_SAY); - if (cstring_resolve("MUST_SPECIFY") == NULL) + if (cstring_resolve("MUST_SPECIFY") == nullptr) create_cstring("MUST_SPECIFY", MUST_SPECIFY); - if (cstring_resolve("OR_WORD") == NULL) + if (cstring_resolve("OR_WORD") == nullptr) create_cstring("OR_WORD", OR_WORD); } diff --git a/engines/glk/jacl/parser.cpp b/engines/glk/jacl/parser.cpp index 666a1e9430d..0421366dc20 100644 --- a/engines/glk/jacl/parser.cpp +++ b/engines/glk/jacl/parser.cpp @@ -115,7 +115,7 @@ void parser() { // GRAMMAR TREE OF POSSIBLE COMMANDS struct word_type *pointer; - struct word_type *matched_word = NULL; + struct word_type *matched_word = nullptr; int index; int current_noun = 0; @@ -146,7 +146,7 @@ void parser() { //printf("--- clear action\n"); clear_cstring("action"); - if (grammar_table == NULL) { + if (grammar_table == nullptr) { // THERE ARE NO USER DEFINED COMMANDS AVAILABLE, SO THE USER'S // COMMAND IS INEVITABLY INVALID //printf("--- no grammar table\n"); @@ -159,7 +159,7 @@ void parser() { // START AT THE TOP OF THE GRAMMAR TREE pointer = grammar_table; - while (word[wp] != NULL && pointer != NULL) { + while (word[wp] != nullptr && pointer != nullptr) { //printf("--- wp = %d\n", wp); //printf("--- word[%d] = %s\n", wp, word[wp]); object_expected = FALSE; @@ -168,12 +168,12 @@ void parser() { // CONSIDER THIS THE END OF THIS COMMAND AS 'THEN' IS // TREATED LIKE A FULL STOP break; - } else if ((matched_word = exact_match(pointer)) != NULL) { + } else if ((matched_word = exact_match(pointer)) != nullptr) { // THIS WORD WAS AN EXACT MATCH FOR ONE OF THE POSSIBLE WORDS // AT THE CURRENT GRAMMAR TREE LEVEL - MOVE ON! pointer = matched_word; pointer = pointer->first_child; - } else if ((matched_word = object_match(pointer, current_noun)) != NULL) { + } else if ((matched_word = object_match(pointer, current_noun)) != nullptr) { // THIS WAS AN OBJECT PLACE HOLDER AT THIS GRAMMAR LEVEL AND // THIS POINT IN THE PLAYER'S COMMAND COULD BE RESOLVED TO // AT LEAST ONE OBJECT @@ -206,7 +206,7 @@ void parser() { pointer = pointer->first_child; } else { // THIS IS AN UNKNOWN WORD - if (oops_word == -1 && word[wp] != NULL) { + if (oops_word == -1 && word[wp] != nullptr) { oops_word = wp; } @@ -226,7 +226,7 @@ void parser() { } }; - if (pointer == NULL) { + if (pointer == nullptr) { // THIS CAN ONLY HAPPEN IF MOVING THE POINTER TO ITS // FIRST CHILD RESULTS IN A NULL - AN INCOMPLETE // GRAMMAR STATEMENT. @@ -340,7 +340,7 @@ void parser() { //printf("--- move to next grammar sibling\n"); // MOVE THROUGH THE OPTIONS AT THIS LEVEL OF THE GRAMMAR TREE // TO FIND THE ACTION THAT MATCHES THIS COMMAND - if (pointer->next_sibling == NULL) { + if (pointer->next_sibling == nullptr) { break; } else { pointer = pointer->next_sibling; @@ -560,9 +560,9 @@ struct word_type *object_match(struct word_type *iterator, int noun_number) { if (custom_error == TRUE) { /* AN ERROR OCCURRED IN THE FIRST OBJECT PLACEHOLDER, DON'T * TRY ANY OTHERS */ - return (NULL); + return (nullptr); } - } while ((iterator = iterator->next_sibling) != NULL); + } while ((iterator = iterator->next_sibling) != nullptr); /* THERE WERE NO OBJECT PLACE HOLDERS OR, IF THERE WERE, NO * MATCHING OBJECTS COULD BE RESOLVED */ @@ -575,7 +575,7 @@ struct word_type *object_match(struct word_type *iterator, int noun_number) { custom_error = TRUE; } - return (NULL); + return (nullptr); } struct word_type *exact_match(struct word_type *pointer) { @@ -605,16 +605,16 @@ struct word_type *exact_match(struct word_type *pointer) { wp++; return (iterator); } - } while ((iterator = iterator->next_sibling) != NULL); + } while ((iterator = iterator->next_sibling) != nullptr); /* THERE WERE NO EXACT MATCHES, SO RETURN FALSE */ - return (NULL); + return (nullptr); } int is_terminator(struct word_type *scope_word) { struct word_type *terminator = scope_word->first_child; - if (terminator != NULL) { + if (terminator != nullptr) { /* THERE MAY NO BE ANY MORE POSSIBLE WORDS IN THIS COMMAND * BUT THERE SHOULD ALWAYS AT LEAST BE A BASE FUNCTION NAME */ do { @@ -626,7 +626,7 @@ int is_terminator(struct word_type *scope_word) { && validate(word[wp]))) { return (TRUE); } - } while ((terminator = terminator->next_sibling) != NULL); + } while ((terminator = terminator->next_sibling) != nullptr); } return (FALSE); @@ -649,7 +649,7 @@ int build_object_list(struct word_type *scope_word, int noun_number) { return (FALSE); } - while (word[wp] != NULL) { + while (word[wp] != nullptr) { /* LOOP THROUGH WORDS IN THE PLAYER'S INPUT ENDING WHEN EITHER * THERE ARE NO MORE WORDS OR ONE OF THE CHILD NODES OF THE * CURRENT scope_word NODE IS REACHED INDICATING THERE ARE NO @@ -663,7 +663,7 @@ int build_object_list(struct word_type *scope_word, int noun_number) { wp++; - if (word[wp] != NULL && !strcmp(word[wp], cstring_resolve("FOR_WORD")->value)) { + if (word[wp] != nullptr && !strcmp(word[wp], cstring_resolve("FOR_WORD")->value)) { /* SKIP PAST THE WORD 'FOR' */ wp++; } @@ -920,18 +920,18 @@ int get_from_object(struct word_type *scope_word, int noun_number) { /* SEE IF 'FROM' IS ONE OF THE TERMINATORS OF THIS CURRENT OBJECT * PLACEHOLDER. IF SO, DON'T LOOK FOR A FROM OBJECT */ - if (terminator != NULL) { + if (terminator != nullptr) { //printf("--- checking if terminator word (%s) is from\n", terminator->word); if (!strcmp(cstring_resolve("FROM_WORD")->value, terminator->word)) { //printf("--- from is a terminator, don't get a from object\n"); return (TRUE); } - while ((terminator = terminator->next_sibling) != NULL); + while ((terminator = terminator->next_sibling) != nullptr); } /* LOOP FROM THE CURRENT WORD TO THE NEXT TERMINATOR AND LOOK FOR THE * WORD 'FROM' AND STORE THE FOLLOWING OBJECT */ - while (word[wp] != NULL) { + while (word[wp] != nullptr) { //printf("--- from loop checking %s\n", word[wp]); if (!strcmp(word[wp], cstring_resolve("FROM_WORD")->value)) { from_word = word[wp]; @@ -1102,7 +1102,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number backup_pointer = wp; everything = FALSE; - if (word[wp] == NULL) { + if (word[wp] == nullptr) { /* NOTHING TO RESOLVE... */ return (FALSE); } @@ -1120,7 +1120,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number /* FIRST WORD IS AN INTEGER AND SECOND WORD IS 'OF' SO * TREAT THIS AS A LIMIT QUALIFIER BEFORE STARTING TO * PROCESS THE REST OF THE WORDS */ - if (word[wp + 1] != NULL && !strcmp(word[wp + 1], cstring_resolve("OF_WORD")->value)) { + if (word[wp + 1] != nullptr && !strcmp(word[wp + 1], cstring_resolve("OF_WORD")->value)) { return_limit = atoi(word[wp]); /* MAKE SURE THE RETURN LIMIT IS SOMETHING SENSIBLE */ @@ -1144,7 +1144,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number // HAS USED TO REFER TO THE OBJECT error_buffer[0] = 0; - while (word[wp] != NULL) { + while (word[wp] != nullptr) { // ADD THE WORDS USED TO error_buffer FOR POSSIBLE USE // IN A DISABMIGUATE EMESSAGE if (first_word == FALSE) { @@ -1158,7 +1158,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number /* RESET TERMINATOR TO THE FIRST OF THE TERMINATING WORDS */ terminator = scope_word->first_child; - if (terminator != NULL) { + if (terminator != nullptr) { /* THERE MAY NO BE ANY MORE POSSIBLE WORDS IN THIS COMMAND * BUT THERE SHOULD ALWAYS AT LEAST BE A BASE FUNCTION NAME */ do { @@ -1187,7 +1187,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number break; } } - } while ((terminator = terminator->next_sibling) != NULL); + } while ((terminator = terminator->next_sibling) != nullptr); } if (done == TRUE) { @@ -1230,7 +1230,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number } //printf("--- exiting for loop\n"); - if (word[wp + 1] != NULL && !strcmp(cstring_resolve("OF_WORD")->value, word[wp + 1])) { + if (word[wp + 1] != nullptr && !strcmp(cstring_resolve("OF_WORD")->value, word[wp + 1])) { /* MOVE PAST THE 'OF' IF IT IS NEXT */ wp++; } @@ -1319,7 +1319,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number } else { current_name = object[index]->first_name; - while (current_name != NULL) { + while (current_name != nullptr) { /* LOOP THROUGH ALL THE CURRENT OBJECTS NAMES */ if (!strcmp(word[wp], current_name->name)) { /* CURRENT WORD MATCHES THE CURRENT NAME @@ -1337,7 +1337,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number /* NOW LOOP THROUGH ALL THE OJBECTS PLURAL NAMES */ current_name = object[index]->first_plural; - while (current_name != NULL) { + while (current_name != nullptr) { /* LOOP THROUGH ALL THE CURRENT OBJECTS NAMES */ if (!strcmp(word[wp], current_name->name)) { /* CURRENT WORD MATCHES THE CURRENT NAME @@ -1397,7 +1397,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number /* THIS WORD IS A LIKELY BE INCORRECT AS IT DIDN'T MATCH * ANY OBJECTS */ - if (oops_word == -1 && word[wp] != NULL) { + if (oops_word == -1 && word[wp] != nullptr) { oops_word = wp; } @@ -1473,7 +1473,7 @@ int noun_resolve(struct word_type *scope_word, int finding_from, int noun_number if (confidence[index] != FALSE && return_limit == 1) { current_name = object[index]->first_name; counter = 0; - while (current_name != NULL) { + while (current_name != nullptr) { counter++; current_name = current_name->next_name; } @@ -1729,7 +1729,7 @@ void diagnose() { TIME->value = FALSE; return; } - if (word[wp] == NULL) + if (word[wp] == nullptr) write_text(cstring_resolve("INCOMPLETE_SENTENCE")->value); else if (object_expected && wp != 0) { write_text(cstring_resolve("UNKNOWN_OBJECT")->value); diff --git a/engines/glk/jacl/resolvers.cpp b/engines/glk/jacl/resolvers.cpp index 6e277cac3db..164161ff233 100644 --- a/engines/glk/jacl/resolvers.cpp +++ b/engines/glk/jacl/resolvers.cpp @@ -89,7 +89,7 @@ int *container_resolve(const char *container_name) { /* IN JACL, A 'CONTAINER' IS ANYTHING THAT CAN STORE AN INTEGER */ struct integer_type *resolved_integer; - if ((resolved_integer = integer_resolve(container_name)) != NULL) + if ((resolved_integer = integer_resolve(container_name)) != nullptr) return (&resolved_integer->value); else if (object_element_resolve(container_name)) return (object_element_address); @@ -106,7 +106,7 @@ int *container_resolve(const char *container_name) { else if (!strcmp(container_name, "here")) return (&object[player]->PARENT); else - return ((int *) NULL); + return ((int *) nullptr); } const char *var_text_of_word(int wordnumber) { @@ -171,15 +171,15 @@ const char *text_of(const char *string) { /* CHECK IF THE SUPPLIED STRING IS THE NAME OF A STRING CONSTANT, * IF NOT, RETURN THE STRING LITERAL */ - if ((return_string = macro_resolve(string)) != NULL) { + if ((return_string = macro_resolve(string)) != nullptr) { value_has_been_resolved = FALSE; return (return_string); - } else if ((resolved_integer = integer_resolve(string)) != NULL) { + } else if ((resolved_integer = integer_resolve(string)) != nullptr) { value_has_been_resolved = FALSE; integer_buffer[0] = 0; sprintf(integer_buffer, "%d", resolved_integer->value); return (integer_buffer); - } else if ((resolved_cinteger = cinteger_resolve(string)) != NULL) { + } else if ((resolved_cinteger = cinteger_resolve(string)) != nullptr) { value_has_been_resolved = FALSE; integer_buffer[0] = 0; sprintf(integer_buffer, "%d", resolved_cinteger->value); @@ -197,11 +197,11 @@ const char *text_of(const char *string) { } else { return (object[index]->label); } - } else if ((resolved_string = string_resolve(string)) != NULL) { + } else if ((resolved_string = string_resolve(string)) != nullptr) { return (resolved_string->value); - } else if ((resolved_cstring = cstring_resolve(string)) != NULL) { + } else if ((resolved_cstring = cstring_resolve(string)) != nullptr) { return (resolved_cstring->value); - } else if (function_resolve(string) != NULL) { + } else if (function_resolve(string) != nullptr) { value_has_been_resolved = FALSE; sprintf(integer_buffer, "%d", execute(string)); return (integer_buffer); @@ -228,12 +228,12 @@ const char *arg_text_of(const char *string) { /* CHECK IF THE SUPPLIED STRING IS THE NAME OF A STRING CONSTANT, * IF NOT, RETURN THE STRING LITERAL */ - if ((macro_text = macro_resolve(string)) != NULL) { + if ((macro_text = macro_resolve(string)) != nullptr) { value_has_been_resolved = FALSE; return (macro_text); - } else if ((resolved_string = string_resolve(string)) != NULL) { + } else if ((resolved_string = string_resolve(string)) != nullptr) { return (resolved_string->value); - } else if ((resolved_cstring = cstring_resolve(string)) != NULL) { + } else if ((resolved_cstring = cstring_resolve(string)) != nullptr) { value_has_been_resolved = FALSE; return (resolved_cstring->value); } else { @@ -246,7 +246,7 @@ int validate(const char *string) { int index, count; - if (string == NULL) { + if (string == nullptr) { return (FALSE); } @@ -320,11 +320,11 @@ long value_of(const char *value, int run_time) { return g_system->getMillis() / 1000; } else if (validate(value)) { return (atoi(value)); - } else if ((resolved_cinteger = cinteger_resolve(value)) != NULL) { + } else if ((resolved_cinteger = cinteger_resolve(value)) != nullptr) { return (resolved_cinteger->value); - } else if ((resolved_integer = integer_resolve(value)) != NULL) { + } else if ((resolved_integer = integer_resolve(value)) != nullptr) { return (resolved_integer->value); - } else if (function_resolve(value) != NULL) { + } else if (function_resolve(value) != nullptr) { return (execute(value)); } else if (object_element_resolve(value)) { return (oec); @@ -379,13 +379,13 @@ struct integer_type *integer_resolve(const char *name) { } else if (expression[index] == '<') { /* HIT A < BEFORE A [ THEREFORE */ /* IS A FUNCTION CALL, NOT AN ARRAY */ - return (NULL); + return (nullptr); } else if (expression[index] == '(') { /* HIT A ( BEFORE A [ THEREFORE */ /* IS AN OBJECT ELEMENT, NOT AN ARRAY */ - return (NULL); + return (nullptr); } else if (expression[index] == ' ') - return (NULL); + return (nullptr); } // NO DELIMITER FOUND, TRY AS UNINDEXED VARIABLE @@ -395,7 +395,7 @@ struct integer_type *integer_resolve(const char *name) { // NO STRING BEFORE DELIMITER if (delimiter == 1) { - return (NULL); + return (nullptr); } counter = value_of(&expression[delimiter], TRUE); @@ -404,15 +404,15 @@ struct integer_type *integer_resolve(const char *name) { return (integer_resolve_indexed(expression, counter)); } else { /* INDEX OUT OF RANGE */ - return (NULL); + return (nullptr); } } struct integer_type *integer_resolve_indexed(const char *name, int index) { struct integer_type *pointer = integer_table; - if (pointer == NULL) - return (NULL); + if (pointer == nullptr) + return (nullptr); do { if (!strcmp(name, pointer->name)) { @@ -426,10 +426,10 @@ struct integer_type *integer_resolve_indexed(const char *name, int index) { } } else pointer = pointer->next_integer; - } while (pointer != NULL); + } while (pointer != nullptr); /* IF index != 0, INDEX OUT OF RANGE, OTHERWISE NOT VARIABLE */ - return (NULL); + return (nullptr); } struct cinteger_type *cinteger_resolve(const char *name) { @@ -464,13 +464,13 @@ struct cinteger_type *cinteger_resolve(const char *name) { } else if (expression[index] == '<') { /* HIT A < BEFORE A [ THEREFORE */ /* IS A FUNCTION CALL, NOT AN ARRAY */ - return (NULL); + return (nullptr); } else if (expression[index] == '(') { /* HIT A ( BEFORE A [ THEREFORE */ /* IS AN OBJECT ELEMENT, NOT AN ARRAY */ - return (NULL); + return (nullptr); } else if (expression[index] == ' ') - return (NULL); + return (nullptr); } // NO DELIMITER FOUND, TRY AS UNINDEXED CONSTANT @@ -480,7 +480,7 @@ struct cinteger_type *cinteger_resolve(const char *name) { // NO STRING BEFORE DELIMITER if (delimiter == 1) { - return (NULL); + return (nullptr); } counter = value_of(&expression[delimiter], TRUE); @@ -489,15 +489,15 @@ struct cinteger_type *cinteger_resolve(const char *name) { return (cinteger_resolve_indexed(expression, counter)); } else { /* INDEX OUT OF RANGE */ - return (NULL); + return (nullptr); } } struct cinteger_type *cinteger_resolve_indexed(const char *name, int index) { struct cinteger_type *pointer = cinteger_table; - if (pointer == NULL) - return (NULL); + if (pointer == nullptr) + return (nullptr); do { if (!strcmp(name, pointer->name)) { @@ -511,10 +511,10 @@ struct cinteger_type *cinteger_resolve_indexed(const char *name, int index) { } } else pointer = pointer->next_cinteger; - } while (pointer != NULL); + } while (pointer != nullptr); /* IF index != 0, INDEX OUT OF RANGE, OTHERWISE NOT VARIABLE */ - return (NULL); + return (nullptr); } struct string_type *string_resolve(const char *name) { @@ -542,13 +542,13 @@ struct string_type *string_resolve(const char *name) { } else if (expression[index] == '<') { /* HIT A < BEFORE A [ THEREFORE */ /* IS A FUNCTION CALL, NOT AN ARRAY */ - return (NULL); + return (nullptr); } else if (expression[index] == '(') { /* HIT A ( BEFORE A [ THEREFORE */ /* IS AN OBJECT ELEMENT, NOT AN ARRAY */ - return (NULL); + return (nullptr); } else if (expression[index] == ' ') - return (NULL); + return (nullptr); } if (delimiter == 0) { @@ -558,7 +558,7 @@ struct string_type *string_resolve(const char *name) { if (delimiter == 1) { /* NO STRING BEFORE DELIMITER */ - return (NULL); + return (nullptr); } counter = value_of(&expression[delimiter], TRUE); @@ -566,14 +566,14 @@ struct string_type *string_resolve(const char *name) { if (counter > -1) { return (string_resolve_indexed(expression, counter)); } else - return (NULL); + return (nullptr); } struct string_type *string_resolve_indexed(const char *name, int index) { struct string_type *pointer = string_table; - if (pointer == NULL) - return (NULL); + if (pointer == nullptr) + return (nullptr); do { if (!strcmp(name, pointer->name)) { @@ -588,9 +588,9 @@ struct string_type *string_resolve_indexed(const char *name, int index) { } else { pointer = pointer->next_string; } - } while (pointer != NULL); + } while (pointer != nullptr); - return (NULL); + return (nullptr); } struct string_type *cstring_resolve(const char *name) { @@ -618,13 +618,13 @@ struct string_type *cstring_resolve(const char *name) { } else if (expression[index] == '<') { /* HIT A < BEFORE A [ THEREFORE */ /* IS A FUNCTION CALL, NOT AN ARRAY */ - return (NULL); + return (nullptr); } else if (expression[index] == '(') { /* HIT A ( BEFORE A [ THEREFORE */ /* IS AN OBJECT ELEMENT, NOT AN ARRAY */ - return (NULL); + return (nullptr); } else if (expression[index] == ' ') - return (NULL); + return (nullptr); } if (delimiter == 0) { @@ -634,7 +634,7 @@ struct string_type *cstring_resolve(const char *name) { if (delimiter == 1) { /* NO STRING BEFORE DELIMITER */ - return (NULL); + return (nullptr); } counter = value_of(&expression[delimiter], TRUE); @@ -642,14 +642,14 @@ struct string_type *cstring_resolve(const char *name) { if (counter > -1) { return (cstring_resolve_indexed(expression, counter)); } else - return (NULL); + return (nullptr); } struct string_type *cstring_resolve_indexed(const char *name, int index) { struct string_type *pointer = cstring_table; - if (pointer == NULL) - return (NULL); + if (pointer == nullptr) + return (nullptr); do { if (!strcmp(name, pointer->name)) { @@ -664,9 +664,9 @@ struct string_type *cstring_resolve_indexed(const char *name, int index) { } else { pointer = pointer->next_string; } - } while (pointer != NULL); + } while (pointer != nullptr); - return (NULL); + return (nullptr); } struct function_type *function_resolve(const char *name) { @@ -676,8 +676,8 @@ struct function_type *function_resolve(const char *name) { struct function_type *pointer = function_table; - if (function_table == NULL) - return (NULL); + if (function_table == nullptr) + return (nullptr); /* STRIP ARGUMENTS OFF FIRST, THEN EXPAND RESOLVE NAME */ index = 0; @@ -701,10 +701,10 @@ struct function_type *function_resolve(const char *name) { return (pointer); else pointer = pointer->next_function; - } while (pointer != NULL); + } while (pointer != nullptr); /* RETURN A POINTER TO THE STRUCTURE THAT ENCAPSULATES THE FUNCTION */ - return (NULL); + return (nullptr); } const char *expand_function(const char *name) { @@ -741,8 +741,8 @@ const char *expand_function(const char *name) { return ((const char *) name); } - if (cinteger_resolve(&expression[delimiter]) != NULL || - integer_resolve(&expression[delimiter]) != NULL || + if (cinteger_resolve(&expression[delimiter]) != nullptr || + integer_resolve(&expression[delimiter]) != nullptr || object_element_resolve(&expression[delimiter])) { /* THE DELIMETER RESOLVES TO A CONSTANT, VARIABLE OR OBJECT * ELEMENT, SO TAKE NOTE OF THAT */ @@ -775,7 +775,7 @@ char *macro_resolve(const char *testString) { } if (delimiter == FALSE) - return (NULL); + return (nullptr); if (*expression != 0) { index = value_of(expression, TRUE); @@ -786,91 +786,91 @@ char *macro_resolve(const char *testString) { if (!strcmp(&expression[delimiter], "list")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (list_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "plain")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (plain_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "long")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (long_output(index)); } } else if (!strcmp(&expression[delimiter], "sub")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (sub_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "obj")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (obj_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "that")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (that_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "it")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (it_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "doesnt")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (doesnt_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "does")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (does_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "isnt")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (isnt_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "is")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (is_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "the")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (sentence_output(index, FALSE)); } } else if (!strcmp(&expression[delimiter], "s")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { if (object[index]->attributes & PLURAL) { strcpy(temp_buffer, ""); @@ -882,91 +882,91 @@ char *macro_resolve(const char *testString) { } else if (!strcmp(&expression[delimiter], "names")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (object_names(index, temp_buffer)); } } else if (!strcmp(&expression[delimiter], "label")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (object[index]->label); } } else if (!strcmp(&expression[delimiter], "List")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (list_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "Plain")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (plain_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "Sub")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (sub_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "Obj")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (obj_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "That")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (that_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "It")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (it_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "Doesnt")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (doesnt_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "Does")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (does_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "Isnt")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (isnt_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "Is")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (is_output(index, TRUE)); } } else if (!strcmp(&expression[delimiter], "The")) { if (index < 1 || index > objects) { badptrrun(expression, index); - return (NULL); + return (nullptr); } else { return (sentence_output(index, TRUE)); } @@ -984,17 +984,17 @@ char *macro_resolve(const char *testString) { } } - return (NULL); + return (nullptr); } int count_resolve(const char *testString) { - struct function_type *resolved_function = NULL; + struct function_type *resolved_function = nullptr; if (*(testString + 1) == 0) { // @ ON ITS OWN, SO RETURN THE CALL COUNT OF THE CURRENTLY EXECUTING // FUNCTION return (executing_function->call_count); - } else if ((resolved_function = function_resolve(testString + 1)) != NULL) { + } else if ((resolved_function = function_resolve(testString + 1)) != nullptr) { return (resolved_function->call_count); } else { return array_length_resolve(testString); @@ -1010,13 +1010,13 @@ int array_length_resolve(const char *testString) { struct string_type *string_pointer = string_table; struct string_type *cstring_pointer = cstring_table; - if (integer_pointer != NULL) { + if (integer_pointer != nullptr) { do { if (!strcmp(array_name, integer_pointer->name)) { counter++; } integer_pointer = integer_pointer->next_integer; - } while (integer_pointer != NULL); + } while (integer_pointer != nullptr); } /* IF ONE OR MORE INTEGERS WITH THIS NAME WERE FOUND @@ -1024,13 +1024,13 @@ int array_length_resolve(const char *testString) { if (counter) return (counter); - if (string_pointer != NULL) { + if (string_pointer != nullptr) { do { if (!strcmp(array_name, string_pointer->name)) { counter++; } string_pointer = string_pointer->next_string; - } while (string_pointer != NULL); + } while (string_pointer != nullptr); } /* IF ONE OR MORE STRINGS WITH THIS NAME WERE FOUND @@ -1038,13 +1038,13 @@ int array_length_resolve(const char *testString) { if (counter) return (counter); - if (cinteger_pointer != NULL) { + if (cinteger_pointer != nullptr) { do { if (!strcmp(array_name, cinteger_pointer->name)) { counter++; } cinteger_pointer = cinteger_pointer->next_cinteger; - } while (cinteger_pointer != NULL); + } while (cinteger_pointer != nullptr); } /* IF ONE OR MORE INTEGER CONSTANTS WITH THIS NAME WERE FOUND @@ -1052,13 +1052,13 @@ int array_length_resolve(const char *testString) { if (counter) return (counter); - if (cstring_pointer != NULL) { + if (cstring_pointer != nullptr) { do { if (!strcmp(array_name, cstring_pointer->name)) { counter++; } cstring_pointer = cstring_pointer->next_string; - } while (cstring_pointer != NULL); + } while (cstring_pointer != nullptr); } /* IF ONE OR MORE STRING CONSTANTS WITH THIS NAME WERE FOUND @@ -1133,9 +1133,9 @@ int object_element_resolve(const char *testString) { //write_text(temp_buffer); // COULDN'T BE RESOLVED AS AN OBJECT, TRY AS A VARIABLE - if ((resolved_integer = integer_resolve(expression)) != NULL) { + if ((resolved_integer = integer_resolve(expression)) != nullptr) { index = resolved_integer->value; - } else if ((resolved_cinteger = cinteger_resolve(expression)) != NULL) { + } else if ((resolved_cinteger = cinteger_resolve(expression)) != nullptr) { index = resolved_cinteger->value; } } @@ -1177,7 +1177,7 @@ int object_resolve(const char *object_string) { return (HERE); else if (!strcmp(object_string, "self") || !strcmp(object_string, "this")) { - if (executing_function != NULL && executing_function->self == 0) { + if (executing_function != nullptr && executing_function->self == 0) { sprintf(error_buffer, "ERROR: Reference to 'self' from global function \"%s\".^", executing_function->name); @@ -1301,7 +1301,7 @@ long attribute_resolve(const char *attribute) { long user_attribute_resolve(const char *name) { struct attribute_type *pointer = attribute_table; - if (pointer == NULL) + if (pointer == nullptr) return (0); do { @@ -1309,7 +1309,7 @@ long user_attribute_resolve(const char *name) { return (pointer->value); } else pointer = pointer->next_attribute; - } while (pointer != NULL); + } while (pointer != nullptr); /* ATTRIBUTE NOT FOUND */ return (0); diff --git a/engines/glk/jacl/utils.cpp b/engines/glk/jacl/utils.cpp index 294543455fd..a4d87b55690 100644 --- a/engines/glk/jacl/utils.cpp +++ b/engines/glk/jacl/utils.cpp @@ -116,7 +116,7 @@ void create_paths(char *full_path) { /* FIND THE LAST SLASH IN THE SPECIFIED GAME PATH AND REMOVE THE GAME * FILE SUFFIX IF ANY EXISTS */ - last_slash = (char *)NULL; + last_slash = (char *)nullptr; /* GET A POINTER TO THE LAST SLASH IN THE FULL PATH */ last_slash = strrchr(full_path, DIR_SEPARATOR); @@ -133,7 +133,7 @@ void create_paths(char *full_path) { } /* STORE THE GAME PATH AND THE GAME FILENAME PARTS SEPARATELY */ - if (last_slash == (const char *) NULL) { + if (last_slash == (const char *) nullptr) { /* GAME MUST BE IN CURRENT DIRECTORY SO THERE WILL BE NO GAME PATH */ strcpy(prefix, full_path); game_path[0] = 0; diff --git a/engines/glk/level9/bitmap.cpp b/engines/glk/level9/bitmap.cpp index 50b808c4108..4cc206d11f9 100644 --- a/engines/glk/level9/bitmap.cpp +++ b/engines/glk/level9/bitmap.cpp @@ -35,7 +35,7 @@ L9BOOL bitmap_exists(char *file) { } L9BYTE *bitmap_load(char *file, L9UINT32 *size) { - L9BYTE *data = NULL; + L9BYTE *data = nullptr; Common::File f; if (f.open(file)) { @@ -49,7 +49,7 @@ L9BYTE *bitmap_load(char *file, L9UINT32 *size) { } Bitmap *bitmap_alloc(int x, int y) { - Bitmap *b = NULL; + Bitmap *b = nullptr; L9Allocate((L9BYTE **)&b, sizeof(Bitmap) + (x * y)); b->width = x; @@ -257,13 +257,13 @@ L9UINT32 bitmap_st1_decode_pixels(L9BYTE *pic, L9BYTE *data, L9UINT32 count, L9U block in a row.) */ L9BOOL bitmap_st1_decode(char *file, int x, int y) { - L9BYTE *data = NULL; + L9BYTE *data = nullptr; int i, xi, yi, max_x, max_y, last_block; int bitplanes_row, bitmaps_row, pixel_count, get_pixels; L9UINT32 size; data = bitmap_load(file, &size); - if (data == NULL) + if (data == nullptr) return FALSE; bitplanes_row = data[35] + data[34] * 256; @@ -293,7 +293,7 @@ L9BOOL bitmap_st1_decode(char *file, int x, int y) { free(bitmap); bitmap = bitmap_alloc(max_x, max_y); } - if (bitmap == NULL) { + if (bitmap == nullptr) { free(data); return FALSE; } @@ -389,12 +389,12 @@ Colour bitmap_pc1_colour(int i) { bottom left last, each row in turn. */ L9BOOL bitmap_pc1_decode(char *file, int x, int y) { - L9BYTE *data = NULL; + L9BYTE *data = nullptr; int i, xi, yi, max_x, max_y; L9UINT32 size; data = bitmap_load(file, &size); - if (data == NULL) + if (data == nullptr) return FALSE; max_x = data[2] + data[3] * 256; @@ -409,7 +409,7 @@ L9BOOL bitmap_pc1_decode(char *file, int x, int y) { free(bitmap); bitmap = bitmap_alloc(max_x, max_y); } - if (bitmap == NULL) { + if (bitmap == nullptr) { free(data); return FALSE; } @@ -584,7 +584,7 @@ L9BOOL bitmap_pc1_decode(char *file, int x, int y) { Gerin Philippe for NoSTalgia . */ L9BOOL bitmap_pc2_decode(char *file, int x, int y) { - L9BYTE *data = NULL; + L9BYTE *data = nullptr; int i, xi, yi, max_x, max_y; L9BYTE theNewPixel, theNewPixelIndex; @@ -594,7 +594,7 @@ L9BOOL bitmap_pc2_decode(char *file, int x, int y) { L9UINT32 size; data = bitmap_load(file, &size); - if (data == NULL) + if (data == nullptr) return FALSE; max_x = data[37] + data[36] * 256; @@ -609,7 +609,7 @@ L9BOOL bitmap_pc2_decode(char *file, int x, int y) { free(bitmap); bitmap = bitmap_alloc(max_x, max_y); } - if (bitmap == NULL) { + if (bitmap == nullptr) { free(data); return FALSE; } @@ -792,12 +792,12 @@ Colour bitmap_amiga_colour(int i1, int i2) { high bit of the f5-bit pixel. */ L9BOOL bitmap_amiga_decode(char *file, int x, int y) { - L9BYTE *data = NULL; + L9BYTE *data = nullptr; int i, xi, yi, max_x, max_y, p, b; L9UINT32 size; data = bitmap_load(file, &size); - if (data == NULL) + if (data == nullptr) return FALSE; max_x = (((((data[64] << 8) | data[65]) << 8) | data[66]) << 8) | data[67]; @@ -812,7 +812,7 @@ L9BOOL bitmap_amiga_decode(char *file, int x, int y) { free(bitmap); bitmap = bitmap_alloc(max_x, max_y); } - if (bitmap == NULL) { + if (bitmap == nullptr) { free(data); return FALSE; } @@ -914,12 +914,12 @@ BitmapType bitmap_noext_type(char *file) { for sub-images. */ L9BOOL bitmap_mac_decode(char *file, int x, int y) { - L9BYTE *data = NULL; + L9BYTE *data = nullptr; int xi, yi, max_x, max_y; L9UINT32 size; data = bitmap_load(file, &size); - if (data == NULL) + if (data == nullptr) return FALSE; max_x = data[3] + data[2] * 256; @@ -937,7 +937,7 @@ L9BOOL bitmap_mac_decode(char *file, int x, int y) { free(bitmap); bitmap = bitmap_alloc(max_x, max_y); } - if (bitmap == NULL) { + if (bitmap == nullptr) { free(data); return FALSE; } @@ -1089,13 +1089,13 @@ BitmapType bitmap_c64_type(char *file) { byte header). */ L9BOOL bitmap_c64_decode(char *file, BitmapType type, int num) { - L9BYTE *data = NULL; + L9BYTE *data = nullptr; int i = 0, xi, yi, max_x = 0, max_y = 0, cx, cy, px, py, p; int off = 0, off_scr = 0, off_col = 0, off_bg = 0, col_comp = 0; L9UINT32 size; data = bitmap_load(file, &size); - if (data == NULL) + if (data == nullptr) return FALSE; if (type == C64_BITMAPS) { @@ -1184,7 +1184,7 @@ L9BOOL bitmap_c64_decode(char *file, BitmapType type, int num) { if (bitmap) free(bitmap); bitmap = bitmap_alloc(max_x, max_y); - if (bitmap == NULL) { + if (bitmap == nullptr) { free(data); return FALSE; } @@ -1453,7 +1453,7 @@ Bitmap *DecodeBitmap(char *dir, BitmapType type, int num, int x, int y) { break; } - return NULL; + return nullptr; } } // End of namespace Level9 diff --git a/engines/glk/level9/level9_main.cpp b/engines/glk/level9/level9_main.cpp index c3f64b8f33e..5a6a4eb4d1f 100644 --- a/engines/glk/level9/level9_main.cpp +++ b/engines/glk/level9/level9_main.cpp @@ -641,7 +641,7 @@ void FreeMemory() { } if (bitmap) { free(bitmap); - bitmap = NULL; + bitmap = nullptr; } if (scriptfile) { delete scriptfile; @@ -2078,20 +2078,20 @@ int scaley(int y) { void detect_gfx_mode() { if (g_vm->_detection._gameType == L9_V3) { /* These V3 games use graphics logic similar to the V2 games */ - if (strstr(FirstLine, "price of magik") != 0) + if (strstr(FirstLine, "price of magik") != nullptr) gfx_mode = GFX_V3A; - else if (strstr(FirstLine, "the archers") != 0) + else if (strstr(FirstLine, "the archers") != nullptr) gfx_mode = GFX_V3A; - else if (strstr(FirstLine, "secret diary of adrian mole") != 0) + else if (strstr(FirstLine, "secret diary of adrian mole") != nullptr) gfx_mode = GFX_V3A; - else if ((strstr(FirstLine, "worm in paradise") != 0) - && (strstr(FirstLine, "silicon dreams") == 0)) + else if ((strstr(FirstLine, "worm in paradise") != nullptr) + && (strstr(FirstLine, "silicon dreams") == nullptr)) gfx_mode = GFX_V3A; - else if (strstr(FirstLine, "growing pains of adrian mole") != 0) + else if (strstr(FirstLine, "growing pains of adrian mole") != nullptr) gfx_mode = GFX_V3B; - else if (strstr(FirstLine, "jewels of darkness") != 0 && picturesize < 11000) + else if (strstr(FirstLine, "jewels of darkness") != nullptr && picturesize < 11000) gfx_mode = GFX_V3B; - else if (strstr(FirstLine, "silicon dreams") != 0) { + else if (strstr(FirstLine, "silicon dreams") != nullptr) { if (picturesize > 11000 || (startdata[0] == 0x14 && startdata[1] == 0x7d) /* Return to Eden /SD (PC) */ || (startdata[0] == 0xd7 && startdata[1] == 0x7c)) /* Worm in Paradise /SD (PC) */ diff --git a/engines/glk/level9/os_glk.cpp b/engines/glk/level9/os_glk.cpp index 0454f3cb393..5bd676ec270 100644 --- a/engines/glk/level9/os_glk.cpp +++ b/engines/glk/level9/os_glk.cpp @@ -1301,7 +1301,7 @@ static void gln_graphics_locate_bitmaps(const char *gamefile) { bitmap_type = DetectBitmaps(dirname); if (bitmap_type == NO_BITMAPS) { free(dirname); - gln_graphics_bitmap_directory = NULL; + gln_graphics_bitmap_directory = nullptr; gln_graphics_bitmap_type = NO_BITMAPS; return; } @@ -4649,7 +4649,7 @@ void gln_main(const char *filename) { int saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; /* Create the main Glk window, and set its stream as current. */ - gln_main_window = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + gln_main_window = g_vm->glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 0); if (!gln_main_window) { gln_fatal("GLK: Can't open main window"); g_vm->glk_exit(); diff --git a/engines/glk/magnetic/emu.cpp b/engines/glk/magnetic/emu.cpp index bb2b34dd2d7..9d55a7c16b1 100644 --- a/engines/glk/magnetic/emu.cpp +++ b/engines/glk/magnetic/emu.cpp @@ -112,7 +112,7 @@ void Magnetic::ms_freemem() { free(undo[1]); if (restart) free(restart); - code = string = string2 = string3 = dict = undo[0] = undo[1] = restart = 0; + code = string = string2 = string3 = dict = undo[0] = undo[1] = restart = nullptr; if (gfx_data) free(gfx_data); if (gfx_buf) @@ -124,7 +124,7 @@ void Magnetic::ms_freemem() { delete gfx_fp; gfx_data = gfx_buf = gfx2_hdr = gfx2_buf = nullptr; - gfx2_name = 0; + gfx2_name = nullptr; gfx_fp = nullptr; gfx_ver = 0; gfxtable = table_dist = 0; @@ -140,8 +140,8 @@ void Magnetic::ms_freemem() { free(hints); if (hint_contents) free(hint_contents); - hints = 0; - hint_contents = 0; + hints = nullptr; + hint_contents = nullptr; if (snd_hdr) free(snd_hdr); if (snd_buf) @@ -221,7 +221,7 @@ type8 Magnetic::init_gfx2(type8 *header) { free(gfx2_hdr); delete gfx_fp; gfx_buf = nullptr; - gfx2_hdr = 0; + gfx2_hdr = nullptr; gfx_fp = nullptr; return 1; } @@ -402,7 +402,7 @@ type8 Magnetic::ms_init(const char *name, const char *gfxname, const char *hntna /* Allocate memory for hints */ hints = (ms_hint *)malloc(MAX_HINTS * sizeof(struct ms_hint)); hint_contents = (type8 *)malloc(MAX_HCONTENTS); - if ((hints != 0) && (hint_contents != 0)) { + if ((hints != nullptr) && (hint_contents != nullptr)) { /* Read number of blocks */ if (hnt_fp.read(&buf, 2) != 2 && !hnt_fp.eos()) return 0; @@ -474,8 +474,8 @@ type8 Magnetic::ms_init(const char *name, const char *gfxname, const char *hntna free(hints); if (hint_contents) free(hint_contents); - hints = 0; - hint_contents = 0; + hints = nullptr; + hint_contents = nullptr; } } hnt_fp.close(); @@ -655,7 +655,7 @@ type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal type32 j; #endif - if (is_anim != 0) + if (is_anim != nullptr) *is_anim = 0; gfx2_name = name; @@ -670,7 +670,7 @@ type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal if (header_pos < 0) header_pos = find_name_in_header(name, 0); if (header_pos < 0) - return 0; + return nullptr; offset = read_l(gfx2_hdr + header_pos + 8); length = read_l(gfx2_hdr + header_pos + 12); @@ -683,18 +683,18 @@ type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal gfx2_buf = (type8 *)malloc(length); if (!gfx2_buf) - return 0; + return nullptr; if (!gfx_fp->seek(offset)) { free(gfx2_buf); gfx2_buf = nullptr; - return 0; + return nullptr; } if (gfx_fp->read(gfx2_buf, length) != length) { free(gfx2_buf); gfx2_buf = nullptr; - return 0; + return nullptr; } for (i = 0; i < 16; i++) @@ -706,7 +706,7 @@ type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal main_pic.height = read_w2(gfx2_buf + 44); main_pic.wbytes = (type16)(main_pic.data_size / main_pic.height); main_pic.plane_step = (type16)(main_pic.wbytes / 4); - main_pic.mask = (type8 *)0; + main_pic.mask = (type8 *)nullptr; extract_frame(&main_pic); *w = main_pic.width; @@ -720,14 +720,14 @@ type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal type16 frame_count; type16 value1, value2; - if (is_anim != 0) + if (is_anim != nullptr) *is_anim = 1; current = anim_data + 6; frame_count = read_w2(anim_data + 2); if (frame_count > MAX_ANIMS) { ms_fatal("animation frame array too short"); - return 0; + return nullptr; } /* Loop through each animation frame */ @@ -738,7 +738,7 @@ type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal anim_frame_table[i].height = read_w2(current + 6); anim_frame_table[i].wbytes = (type16)(anim_frame_table[i].data_size / anim_frame_table[i].height); anim_frame_table[i].plane_step = (type16)(anim_frame_table[i].wbytes / 4); - anim_frame_table[i].mask = (type8 *)0; + anim_frame_table[i].mask = (type8 *)nullptr; current += anim_frame_table[i].data_size + 12; value1 = read_w2(current - 2); @@ -758,7 +758,7 @@ type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal pos_table_size = read_w2(current - 2); if (pos_table_size > MAX_POSITIONS) { ms_fatal("animation position array too short"); - return 0; + return nullptr; } #ifdef LOGGFX_EXT @@ -770,7 +770,7 @@ type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal if (pos_table_count[i] > MAX_ANIMS) { ms_fatal("animation position array too short"); - return 0; + return nullptr; } for (j = 0; j < pos_table_count[i]; j++) { @@ -801,7 +801,7 @@ type8 *Magnetic::ms_extract2(const char *name, type16 *w, type16 *h, type16 *pal #endif return gfx_buf; } - return 0; + return nullptr; } type8 *Magnetic::ms_extract(type32 pic, type16 *w, type16 *h, type16 *pal, type8 *is_anim) { @@ -818,7 +818,7 @@ type8 *Magnetic::ms_extract(type32 pic, type16 *w, type16 *h, type16 *pal, type8 break; } } - return 0; + return nullptr; } type8 Magnetic::ms_animate(struct ms_position **positions, type16 *count) { @@ -826,13 +826,13 @@ type8 Magnetic::ms_animate(struct ms_position **positions, type16 *count) { type8 got_anim = 0; type16 i, j, ttable; - if ((gfx_buf == 0) || (gfx2_buf == 0) || (gfx_ver != 2)) + if ((gfx_buf == nullptr) || (gfx2_buf == nullptr) || (gfx_ver != 2)) return 0; if ((pos_table_size == 0) || (command_index < 0)) return 0; *count = 0; - *positions = (struct ms_position *)0; + *positions = (struct ms_position *)nullptr; while (got_anim == 0) { if (pos_table_max >= 0) { @@ -983,7 +983,7 @@ type8 *Magnetic::ms_get_anim_frame(type16s number, type16 *width, type16 *height return gfx_buf; } #endif - return 0; + return nullptr; } type8 Magnetic::ms_anim_is_repeating() const { @@ -1014,7 +1014,7 @@ type8 *Magnetic::sound_extract(const char *name, type32 *length, type16 *tempo) if (header_pos < 0) header_pos = find_name_in_sndheader(name); if (header_pos < 0) - return 0; + return nullptr; *tempo = read_w(snd_hdr + header_pos + 8); offset = read_l(snd_hdr + header_pos + 10); @@ -1022,9 +1022,9 @@ type8 *Magnetic::sound_extract(const char *name, type32 *length, type16 *tempo) if (offset != 0) { if (!snd_buf) - return 0; + return nullptr; if (!snd_fp->seek(offset) || snd_fp->read(snd_buf, *length) != *length) - return 0; + return nullptr; return snd_buf; } @@ -2219,7 +2219,7 @@ void Magnetic::do_line_a() { case 10: /* Open window commands */ switch ((code + a1reg + 3)[0]) { case 4: /* Help/Hints */ - if (hints != 0) { + if (hints != nullptr) { if (ms_showhints(hints) == 0) show_hints_text(hints, 0); } else @@ -2239,7 +2239,7 @@ void Magnetic::do_line_a() { case 13: /* Music */ switch ((code + a1reg + 3)[0]) { case 0: /* stop music */ - ms_playmusic(0, 0, 0); + ms_playmusic(nullptr, 0, 0); break; default: /* play music */ #ifdef LOGSND @@ -2249,7 +2249,7 @@ void Magnetic::do_line_a() { type32 length = 0; type16 tempo = 0; type8 *midi = sound_extract((const char *)(code + a1reg + 3), &length, &tempo); - if (midi != NULL) + if (midi != nullptr) ms_playmusic(midi, length, tempo); } break; diff --git a/engines/glk/magnetic/glk.cpp b/engines/glk/magnetic/glk.cpp index 350fdbaa9d3..7c9433043ee 100644 --- a/engines/glk/magnetic/glk.cpp +++ b/engines/glk/magnetic/glk.cpp @@ -82,7 +82,7 @@ const gms_gamma_t Magnetic::GMS_GAMMA_TABLE[38] = { { "2.60", { 0, 121, 158, 184, 206, 224, 240, 255 }, true }, { "2.65", { 0, 122, 159, 185, 206, 225, 241, 255 }, true }, { "2.70", { 0, 124, 160, 186, 207, 225, 241, 255 }, true }, - { NULL, { 0, 0, 0, 0, 0, 0, 0, 0 }, false } + { nullptr, { 0, 0, 0, 0, 0, 0, 0, 0 }, false } }; static gms_abbreviation_t GMS_ABBREVIATIONS[] = { @@ -90,7 +90,7 @@ static gms_abbreviation_t GMS_ABBREVIATIONS[] = { {'k', "attack"}, {'l', "look"}, {'p', "open"}, {'q', "quit"}, {'r', "drop"}, {'t', "take"}, {'x', "examine"}, {'y', "yes"}, {'z', "wait"}, - {'\0', NULL} + {'\0', nullptr} }; /*---------------------------------------------------------------------*/ @@ -196,15 +196,15 @@ void Magnetic::gms_fatal(const char *str) { error("\n\nINTERNAL ERROR: %s", str); /* Cancel all possible pending window input events. */ - glk_cancel_line_event(gms_main_window, NULL); + glk_cancel_line_event(gms_main_window, nullptr); glk_cancel_char_event(gms_main_window); if (gms_hint_menu_window) { glk_cancel_char_event(gms_hint_menu_window); - glk_window_close(gms_hint_menu_window, NULL); + glk_window_close(gms_hint_menu_window, nullptr); } if (gms_hint_text_window) { glk_cancel_char_event(gms_hint_text_window); - glk_window_close(gms_hint_text_window, NULL); + glk_window_close(gms_hint_text_window, nullptr); } /* Print a message indicating the error. */ @@ -314,7 +314,7 @@ void Magnetic::gms_gameid_identify_game(const Common::String &text_file) { /* Search for these values in the table, and set game name if found. */ game = gms_gameid_lookup_game(game_size, game_pc); - gms_gameid_game_name = game ? game->name : NULL; + gms_gameid_game_name = game ? game->name : nullptr; } /*---------------------------------------------------------------------*/ @@ -330,13 +330,13 @@ int Magnetic::gms_graphics_open() { wintype_Graphics, 0); } - return gms_graphics_window != NULL; + return gms_graphics_window != nullptr; } void Magnetic::gms_graphics_close() { if (gms_graphics_window) { - glk_window_close(gms_graphics_window, NULL); - gms_graphics_window = NULL; + glk_window_close(gms_graphics_window, nullptr); + gms_graphics_window = nullptr; } } @@ -546,7 +546,7 @@ gms_gammaref_t Magnetic::gms_graphics_equal_contrast_gamma(type16 palette[], lon long lowest_variance; assert(palette && color_usage); - result = NULL; + result = nullptr; lowest_variance = INT32_MAX_VAL; /* Search the gamma table for the entry with the lowest contrast variance. */ @@ -1204,7 +1204,7 @@ void Magnetic::gms_graphics_timeout() { /* Save the color count for possible queries later. */ gms_graphics_count_colors(off_screen, gms_graphics_width, gms_graphics_height, - &gms_graphics_color_count, NULL); + &gms_graphics_color_count, nullptr); } /* @@ -1592,11 +1592,11 @@ int Magnetic::gms_graphics_interpreter_enabled() { void Magnetic::gms_graphics_cleanup() { free(gms_graphics_bitmap); - gms_graphics_bitmap = NULL; + gms_graphics_bitmap = nullptr; free(gms_graphics_off_screen); - gms_graphics_off_screen = NULL; + gms_graphics_off_screen = nullptr; free(gms_graphics_on_screen); - gms_graphics_on_screen = NULL; + gms_graphics_on_screen = nullptr; gms_graphics_animated = false; gms_graphics_picture = 0; @@ -1744,7 +1744,7 @@ void Magnetic::gms_status_redraw() { */ parent = glk_window_get_parent(gms_status_window); glk_window_set_arrangement(parent, - winmethod_Above | winmethod_Fixed, 1, NULL); + winmethod_Above | winmethod_Fixed, 1, nullptr); gms_status_update(); } @@ -1802,7 +1802,7 @@ void Magnetic::gms_detect_game_prompt() { void Magnetic::gms_output_delete() { free(gms_output_buffer); - gms_output_buffer = NULL; + gms_output_buffer = nullptr; gms_output_allocation = gms_output_length = 0; } @@ -1981,7 +1981,7 @@ const char *Magnetic::gms_get_hint_topic(const ms_hint hints_[], type16 node) { */ parent = hints_[node].parent; - topic = NULL; + topic = nullptr; for (index = 0; index < hints_[parent].elcount; index++) { if (hints_[parent].links[index] == node) { topic = gms_get_hint_content(hints_, parent, index); @@ -2016,8 +2016,8 @@ int Magnetic::gms_hint_open() { | winmethod_Proportional, 100, wintype_TextBuffer, 0); if (!gms_hint_text_window) { - glk_window_close(gms_hint_menu_window, NULL); - gms_hint_menu_window = NULL; + glk_window_close(gms_hint_menu_window, nullptr); + gms_hint_menu_window = nullptr; return false; } } @@ -2029,10 +2029,10 @@ void Magnetic::Magnetic::gms_hint_close() { if (gms_hint_menu_window) { assert(gms_hint_text_window); - glk_window_close(gms_hint_menu_window, NULL); - gms_hint_menu_window = NULL; - glk_window_close(gms_hint_text_window, NULL); - gms_hint_text_window = NULL; + glk_window_close(gms_hint_menu_window, nullptr); + gms_hint_menu_window = nullptr; + glk_window_close(gms_hint_text_window, nullptr); + gms_hint_text_window = nullptr; } } @@ -2192,7 +2192,7 @@ void Magnetic::gms_hint_arrange_windows(int requested_lines, glui32 *width, glui parent = glk_window_get_parent(gms_hint_menu_window); glk_window_set_arrangement(parent, winmethod_Above | winmethod_Fixed, - requested_lines, NULL); + requested_lines, nullptr); uint width_temp, height_temp; @@ -2545,9 +2545,9 @@ void Magnetic::gms_hint_redraw() { void Magnetic::gms_hints_cleanup() { free(gms_hint_cursor); - gms_hint_cursor = NULL; + gms_hint_cursor = nullptr; - gms_hints = NULL; + gms_hints = nullptr; gms_current_hint_node = 0; } @@ -2600,10 +2600,10 @@ void Magnetic::gms_command_script(const char *argument) { return; } - glk_stream_close(gms_transcript_stream, NULL); - gms_transcript_stream = NULL; + glk_stream_close(gms_transcript_stream, nullptr); + gms_transcript_stream = nullptr; - glk_window_set_echo_stream(gms_main_window, NULL); + glk_window_set_echo_stream(gms_main_window, nullptr); gms_normal_string("Glk transcript is now off.\n"); } @@ -2659,8 +2659,8 @@ void Magnetic::gms_command_inputlog(const char *argument) { return; } - glk_stream_close(gms_inputlog_stream, NULL); - gms_inputlog_stream = NULL; + glk_stream_close(gms_inputlog_stream, nullptr); + gms_inputlog_stream = nullptr; gms_normal_string("Glk input log is now off.\n"); } @@ -2721,8 +2721,8 @@ void Magnetic::gms_command_readlog(const char *argument) { return; } - glk_stream_close(gms_readlog_stream, NULL); - gms_readlog_stream = NULL; + glk_stream_close(gms_readlog_stream, nullptr); + gms_readlog_stream = nullptr; gms_normal_string("Glk read log is now off.\n"); } @@ -2996,7 +2996,7 @@ void Magnetic::gms_command_animations(const char *argument) { * changing animation mode doesn't affect this picture. */ gms_animation_enabled = true; - if (gms_graphics_get_picture_details(NULL, NULL, &is_animated)) { + if (gms_graphics_get_picture_details(nullptr, nullptr, &is_animated)) { if (is_animated) gms_graphics_restart(); } @@ -3013,7 +3013,7 @@ void Magnetic::gms_command_animations(const char *argument) { } gms_animation_enabled = false; - if (gms_graphics_get_picture_details(NULL, NULL, &is_animated)) { + if (gms_graphics_get_picture_details(nullptr, nullptr, &is_animated)) { if (is_animated) gms_graphics_restart(); } @@ -3167,7 +3167,7 @@ void Magnetic::gms_command_help(const char *command) { return; } - matched = NULL; + matched = nullptr; for (entry = GMS_COMMAND_TABLE; entry->command; entry++) { if (gms_strncasecmp(command, entry->command, strlen(command)) == 0) { if (matched) { @@ -3366,7 +3366,7 @@ int Magnetic::gms_command_escape(const char *string_, int *undo_command) { * the command passed in. */ matches = 0; - matched = NULL; + matched = nullptr; for (entry = GMS_COMMAND_TABLE; entry->command; entry++) { if (gms_strncasecmp(command, entry->command, strlen(command)) == 0) { matches++; @@ -3446,7 +3446,7 @@ void Magnetic::gms_expand_abbreviations(char *buffer_, int size) { /* Scan the abbreviations table for a match. */ abbreviation = glk_char_to_lower((unsigned char) command[0]); - expansion = NULL; + expansion = nullptr; for (entry = GMS_ABBREVIATIONS; entry->expansion; entry++) { if (entry->abbreviation == abbreviation) { expansion = entry->expansion; @@ -3522,8 +3522,8 @@ void Magnetic::gms_buffer_input() { * We're at the end of the log stream. Close it, and then continue * on to request a line from Glk. */ - glk_stream_close(gms_readlog_stream, NULL); - gms_readlog_stream = NULL; + glk_stream_close(gms_readlog_stream, nullptr); + gms_readlog_stream = nullptr; } /* @@ -3754,9 +3754,9 @@ void Magnetic::gms_establish_filenames(const char *name, char **text, char **gra * No access to a usable game text file. Return immediately, * without looking for any associated graphics or hints_ files. */ - *text = NULL; - *graphics = NULL; - *hints_ = NULL; + *text = nullptr; + *graphics = nullptr; + *hints_ = nullptr; free(text_file); free(base); @@ -3783,7 +3783,7 @@ void Magnetic::gms_establish_filenames(const char *name, char **text, char **gra * reset graphics file to NULL. */ free(graphics_file); - graphics_file = NULL; + graphics_file = nullptr; } } stream.close(); @@ -3806,7 +3806,7 @@ void Magnetic::gms_establish_filenames(const char *name, char **text, char **gra * reset hints_ file to NULL. */ free(hints_file); - hints_file = NULL; + hints_file = nullptr; } } stream.close(); @@ -3820,11 +3820,11 @@ void Magnetic::gms_establish_filenames(const char *name, char **text, char **gra } void Magnetic::gms_main() { - char *text_file = NULL, *graphics_file = NULL, *hints_file = NULL; + char *text_file = nullptr, *graphics_file = nullptr, *hints_file = nullptr; int ms_init_status, is_running; /* Create the main Glk window, and set its stream as current. */ - gms_main_window = glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + gms_main_window = glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 0); if (!gms_main_window) { gms_fatal("GLK: Can't open main window"); glk_exit(); @@ -3875,14 +3875,14 @@ void Magnetic::gms_main() { */ if (gms_graphics_possible) { assert(graphics_file); - ms_init_status = ms_init(text_file, graphics_file, hints_file, NULL); + ms_init_status = ms_init(text_file, graphics_file, hints_file, nullptr); } else - ms_init_status = ms_init(text_file, NULL, hints_file, NULL); + ms_init_status = ms_init(text_file, nullptr, hints_file, nullptr); /* Look for a complete failure to load the game. */ if (ms_init_status == 0) { if (gms_status_window) - glk_window_close(gms_status_window, NULL); + glk_window_close(gms_status_window, nullptr); gms_header_string("Glk Magnetic Error\n\n"); gms_normal_string("Can't load game '"); gms_normal_string(gameFile.c_str()); @@ -3940,16 +3940,16 @@ void Magnetic::gms_main() { /* Close any open transcript, input log, and/or read log. */ if (gms_transcript_stream) { - glk_stream_close(gms_transcript_stream, NULL); - gms_transcript_stream = NULL; + glk_stream_close(gms_transcript_stream, nullptr); + gms_transcript_stream = nullptr; } if (gms_inputlog_stream) { - glk_stream_close(gms_inputlog_stream, NULL); - gms_inputlog_stream = NULL; + glk_stream_close(gms_inputlog_stream, nullptr); + gms_inputlog_stream = nullptr; } if (gms_readlog_stream) { - glk_stream_close(gms_readlog_stream, NULL); - gms_readlog_stream = NULL; + glk_stream_close(gms_readlog_stream, nullptr); + gms_readlog_stream = nullptr; } /* Free the text file path, and any graphics/hints file path. */ diff --git a/engines/glk/quest/geas_file.cpp b/engines/glk/quest/geas_file.cpp index 1226e952682..e518012ae41 100644 --- a/engines/glk/quest/geas_file.cpp +++ b/engines/glk/quest/geas_file.cpp @@ -34,13 +34,13 @@ namespace Quest { void report_error(const String &s); // FIXME: This requires global constructor -reserved_words obj_tag_property("look", "examine", "speak", "take", "alias", "prefix", "suffix", "detail", "displaytype", "gender", "article", "hidden", "invisible", (char *) NULL); +reserved_words obj_tag_property("look", "examine", "speak", "take", "alias", "prefix", "suffix", "detail", "displaytype", "gender", "article", "hidden", "invisible", (char *) nullptr); // FIXME: This requires global constructor //reserved_words room_tag_property("look", "alias", "prefix", "indescription", "description", "north", "south", "east", "west", "northwest", "northeast", "southeast", "southwest", "up", "down", "out", (char *) NULL); void GeasFile::debug_print(String s) const { - if (gi == NULL) + if (gi == nullptr) cerr << s << endl; else gi->debug_print(s); @@ -55,7 +55,7 @@ const GeasBlock *GeasFile::find_by_name(String type, String name) const { if (ci_equal(block(type, i).name, name)) return &block(type, i); } - return NULL; + return nullptr; } const GeasBlock &GeasFile::block(String type, uint index) const { @@ -108,12 +108,12 @@ void GeasFile::get_obj_keys(String obj, Set &rv) const { uint c1, c2; String tok, line; - reserved_words *rw = NULL; + reserved_words *rw = nullptr; const GeasBlock *gb = find_by_name("object", obj); rw = &obj_tag_property; - if (gb == NULL) { + if (gb == nullptr) { cerr << "No such object found, aborting\n"; //return rv; return; @@ -154,7 +154,7 @@ void GeasFile::get_obj_keys(String obj, Set &rv) const { get_type_keys(param_contents(tok), rv); } //else if (has (tag_property, tok) && tag_property[tok]) - else if (rw != NULL && rw->has(tok)) { + else if (rw != nullptr && rw->has(tok)) { String tok1 = next_token(line, c1, c2); if (is_param(tok1)) rv.insert(tok); @@ -167,7 +167,7 @@ void GeasFile::get_obj_keys(String obj, Set &rv) const { void GeasFile::get_type_keys(String typen, Set &rv) const { cerr << "get_type_keys (" << typen << ", " << rv << ")\n"; const GeasBlock *gb = find_by_name("type", typen); - if (gb == NULL) { + if (gb == nullptr) { cerr << " g_t_k: Nonexistent type\n"; return; } @@ -237,7 +237,7 @@ bool GeasFile::get_obj_property(String objname, String propname, String &string_ String not_prop = "not " + propname; uint c1, c2; - assert(geasBlock != NULL); + assert(geasBlock != nullptr); //assert (geasBlock->data != NULL); for (uint i = 0; i < geasBlock->data.size(); i ++) { String line = geasBlock->data[i]; @@ -288,7 +288,7 @@ bool GeasFile::get_obj_property(String objname, String propname, String &string_ void GeasFile::get_type_property(String typenamex, String propname, bool &bool_rv, String &string_rv) const { //cerr << " Checking type <" << typenamex << "> for prop <" << propname << ">\n"; const GeasBlock *geasBlock = find_by_name("type", typenamex); - if (geasBlock == NULL) { + if (geasBlock == nullptr) { debug_print("Object of nonexistent type " + typenamex); return; } @@ -363,7 +363,7 @@ bool GeasFile::obj_of_type(String objname, String typenamex) const { const GeasBlock *geasBlock = find_by_name(objtype, objname); uint c1, c2; - assert(geasBlock != NULL); + assert(geasBlock != nullptr); for (uint i = 0; i < geasBlock->data.size(); i ++) { String line = geasBlock->data[i]; String tok = first_token(line, c1, c2); @@ -387,7 +387,7 @@ bool GeasFile::type_of_type(String subtype, String supertype) const { return true; //cerr << " Checking type <" << subtype << "> for type <" << supertype << ">\n"; const GeasBlock *geasBlock = find_by_name("type", subtype); - if (geasBlock == NULL) { + if (geasBlock == nullptr) { debug_print("t_o_t: Nonexistent type " + subtype); return false; } @@ -484,7 +484,7 @@ bool GeasFile::get_obj_action(String objname, String propname, String &string_rv void GeasFile::get_type_action(String typenamex, String actname, bool &bool_rv, String &string_rv) const { //cerr << " Checking type <" << typenamex << "> for action <" << actname << ">\n"; const GeasBlock *geasBlock = find_by_name("type", typenamex); - if (geasBlock == NULL) { + if (geasBlock == nullptr) { debug_print("Object of nonexistent type " + typenamex); return; } diff --git a/engines/glk/quest/geas_glk.cpp b/engines/glk/quest/geas_glk.cpp index 169ac04ea85..7aa8f8581ba 100644 --- a/engines/glk/quest/geas_glk.cpp +++ b/engines/glk/quest/geas_glk.cpp @@ -50,7 +50,7 @@ void draw_banner() { strid_t stream = g_vm->glk_window_get_stream(bannerwin); g_vm->glk_set_style_stream(stream, style_User1); - g_vm->glk_window_get_size(bannerwin, &width, NULL); + g_vm->glk_window_get_size(bannerwin, &width, nullptr); for (index = 0; index < width; index++) g_vm->glk_put_char_stream(stream, ' '); g_vm->glk_window_move_cursor(bannerwin, 1, 0); diff --git a/engines/glk/quest/geas_runner.cpp b/engines/glk/quest/geas_runner.cpp index c8438e57c33..71b6c9802bd 100644 --- a/engines/glk/quest/geas_runner.cpp +++ b/engines/glk/quest/geas_runner.cpp @@ -378,7 +378,7 @@ void geas_implementation::display_error(String errorname, String obj) { } const GeasBlock *game = gf.find_by_name("game", "game"); - assert(game != NULL); + assert(game != nullptr); String tok; uint c1, c2; for (uint i = 0; i < game->data.size(); i ++) { @@ -479,7 +479,7 @@ Common::Array > geas_implementation::get_places(String roo Common::Array > rv; const GeasBlock *gb = gf.find_by_name("room", room); - if (gb == NULL) + if (gb == nullptr) return rv; String line, tok; @@ -570,7 +570,7 @@ Common::Array > geas_implementation::get_places(String roo String geas_implementation::exit_dest(String room, String dir, bool *is_script) const { uint c1, c2; String tok; - if (is_script != NULL) + if (is_script != nullptr) *is_script = false; for (uint i = state.exits.size() - 1; i + 1 > 0; i --) if (state.exits[i].src == room) { @@ -607,7 +607,7 @@ String geas_implementation::exit_dest(String room, String dir, bool *is_script) */ const GeasBlock *gb = gf.find_by_name("room", room); - if (gb == NULL) { + if (gb == nullptr) { gi->debug_print(String("Trying to find exit <") + dir + "> of nonexistent room <" + room + ">."); return ""; @@ -622,7 +622,7 @@ String geas_implementation::exit_dest(String room, String dir, bool *is_script) if (is_param(tok)) return param_contents(tok); if (tok != "") { - if (is_script != NULL) + if (is_script != nullptr) *is_script = true; return trim(line.substr(line_start + 1)); } @@ -980,7 +980,7 @@ String geas_implementation::substitute_synonyms(String s) const { String orig = s; cerr << "substitute_synonyms (" << s << ")\n"; const GeasBlock *gb = gf.find_by_name("synonyms", ""); - if (gb != NULL) { + if (gb != nullptr) { /* TODO: exactly in what order does it try synonyms? * Does it have to be flanked by whitespace? */ @@ -1103,7 +1103,7 @@ void geas_implementation::run_command(String s) { dont_process = false; const GeasBlock *gb = gf.find_by_name("room", state.location); - if (gb != NULL) { + if (gb != nullptr) { String line, tok; uint c1, c2; for (uint i = 0; i < gb->data.size(); i ++) { @@ -1128,7 +1128,7 @@ void geas_implementation::run_command(String s) { if (!overridden) { gb = gf.find_by_name("game", "game"); - if (gb != NULL) { + if (gb != nullptr) { String line, tok; uint c1, c2; for (uint i = 0; i < gb->data.size(); i ++) { @@ -1163,7 +1163,7 @@ void geas_implementation::run_command(String s) { overridden = false; gb = gf.find_by_name("room", state.location); - if (gb != NULL) { + if (gb != nullptr) { String line, tok; uint c1, c2; for (uint i = 0; i < gb->data.size(); i ++) { @@ -1186,7 +1186,7 @@ void geas_implementation::run_command(String s) { } if (!overridden) { gb = gf.find_by_name("game", "game"); - if (gb != NULL) { + if (gb != nullptr) { String line, tok; uint c1, c2; for (uint i = 0; i < gb->data.size(); i ++) { @@ -1316,7 +1316,7 @@ bool geas_implementation::match_object(String text, String name, bool is_interna return true; const GeasBlock *gb = gf.find_by_name("object", name); - if (gb != NULL) { + if (gb != nullptr) { String tok, line; uint c1, c2; for (uint ln = 0; ln < gb->data.size(); ln ++) { @@ -1414,7 +1414,7 @@ bool geas_implementation::run_commands(String cmd, const GeasBlock *room, bool i String line, tok; match_rv match; - if (room != NULL) { + if (room != nullptr) { for (uint i = 0; i < room->data.size(); i++) { line = room->data[i]; tok = first_token(line, c1, c2); @@ -1632,7 +1632,7 @@ bool geas_implementation::try_match(String cmd, bool is_internal, bool is_normal } const GeasBlock *gb = gf.find_by_name("object", obj); - if (gb != NULL) { + if (gb != nullptr) { uint c1, c2, script_begins; for (uint i = 0; i < gb->data.size(); i ++) { line = gb->data[i]; @@ -1690,7 +1690,7 @@ bool geas_implementation::try_match(String cmd, bool is_internal, bool is_normal if (cmd == "exit" || cmd == "out" || cmd == "go out") { const GeasBlock *gb = gf.find_by_name("room", state.location); - if (gb == NULL) { + if (gb == nullptr) { gi->debug_print("Bad room"); return true; } @@ -1801,7 +1801,7 @@ bool geas_implementation::try_match(String cmd, bool is_internal, bool is_normal if (ci_equal(cmd, "about")) { const GeasBlock *gb = gf.find_by_name("game", "game"); - if (gb == NULL) + if (gb == nullptr) return true; cerr << *gb << endl; @@ -1934,7 +1934,7 @@ void geas_implementation::run_script(String s, String &rv) { } tok = eval_param(tok); const GeasBlock *gb = gf.find_by_name("selection", tok); - if (gb == NULL) { + if (gb == nullptr) { gi->debug_print("No selection called " + tok + " found"); return; } @@ -2065,7 +2065,7 @@ void geas_implementation::run_script(String s, String &rv) { return; } const GeasBlock *gb = gf.find_by_name("text", param_contents(tok)); - if (gb != NULL) { + if (gb != nullptr) { for (uint i = 0; i < gb->data.size(); i ++) { print_formatted(gb->data[i]); print_newline(); @@ -3507,7 +3507,7 @@ void geas_implementation::tick_timers() { tr.is_running = false; tr.timeleft = tr.interval; const GeasBlock *gb = gf.find_by_name("timer", tr.name); - if (gb != NULL) { + if (gb != nullptr) { //cout << "Running it!\n"; String tok, line; uint c1, c2; diff --git a/engines/glk/quest/quest.cpp b/engines/glk/quest/quest.cpp index 2121108d3a6..ed7b9bcea51 100644 --- a/engines/glk/quest/quest.cpp +++ b/engines/glk/quest/quest.cpp @@ -122,7 +122,7 @@ bool Quest::initialize() { glk_stylehint_set(wintype_TextBuffer, style_User2, stylehint_ReverseColor, 1); // Open the main window - mainglkwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 1); + mainglkwin = glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 1); if (!mainglkwin) return false; glk_set_window(mainglkwin); @@ -137,7 +137,7 @@ bool Quest::initialize() { winmethod_Below | winmethod_Fixed, 1, wintype_TextBuffer, 0); else - inputwin = NULL; + inputwin = nullptr; if (!inputwin) inputwin = mainglkwin; diff --git a/engines/glk/quest/read_file.cpp b/engines/glk/quest/read_file.cpp index d3aa691a460..f90d47ab517 100644 --- a/engines/glk/quest/read_file.cpp +++ b/engines/glk/quest/read_file.cpp @@ -133,7 +133,7 @@ bool is_end_define(String s) { extern Common::Array split_lines(String data); // FIXME: This requires global constructor -reserved_words dir_tag_property("north", "south", "east", "west", "northwest", "northeast", "southeast", "southwest", "up", "down", "out", (char *) NULL); +reserved_words dir_tag_property("north", "south", "east", "west", "northwest", "northeast", "southeast", "southwest", "up", "down", "out", (char *) nullptr); void GeasFile::read_into(const Common::Array &in_data, String in_parent, uint cur_line, bool recurse, @@ -300,8 +300,8 @@ GeasFile::GeasFile(const Common::Array &v, GeasInterface *_gi) : gi(_gi) "function", "selection", "synonyms", "text", "timer" }; - reserved_words recursive_passes("game", "room", (char *) NULL), - object_passes("game", "room", "objects", (char *) NULL); + reserved_words recursive_passes("game", "room", (char *) nullptr), + object_passes("game", "room", "objects", (char *) nullptr); //Common::Array outv; @@ -311,16 +311,16 @@ GeasFile::GeasFile(const Common::Array &v, GeasInterface *_gi) : gi(_gi) bool recursive = recursive_passes[this_pass]; //bool is_object = object_passes[this_pass]; - reserved_words actions((char *) NULL), props((char *) NULL); + reserved_words actions((char *) nullptr), props((char *) nullptr); // SENSITIVE? if (this_pass == "room") { - props = reserved_words("look", "alias", "prefix", "indescription", "description", "north", "south", "east", "west", "northeast", "northwest", "southeast", "southwest", "out", "up", "down", (char *) NULL); - actions = reserved_words("description", "script", "north", "south", "east", "west", "northeast", "northwest", "southeast", "southwest", "out", "up", "down", (char *) NULL); + props = reserved_words("look", "alias", "prefix", "indescription", "description", "north", "south", "east", "west", "northeast", "northwest", "southeast", "southwest", "out", "up", "down", (char *) nullptr); + actions = reserved_words("description", "script", "north", "south", "east", "west", "northeast", "northwest", "southeast", "southwest", "out", "up", "down", (char *) nullptr); } // SENSITIVE? else if (this_pass == "object") { - props = reserved_words("look", "examine", "speak", "take", "alias", "prefix", "suffix", "detail", "displaytype", "gender", "article", "hidden", "invisible", (char *) NULL); - actions = reserved_words("look", "examine", "speak", "take", "gain", "lose", "use", "give", (char *) NULL); + props = reserved_words("look", "examine", "speak", "take", "alias", "prefix", "suffix", "detail", "displaytype", "gender", "article", "hidden", "invisible", (char *) nullptr); + actions = reserved_words("look", "examine", "speak", "take", "gain", "lose", "use", "give", (char *) nullptr); } depth = 0; diff --git a/engines/glk/scott/scott.cpp b/engines/glk/scott/scott.cpp index 5fdf2261a19..c4c44d9da54 100644 --- a/engines/glk/scott/scott.cpp +++ b/engines/glk/scott/scott.cpp @@ -31,7 +31,7 @@ namespace Scott { Scott::Scott(OSystem *syst, const GlkGameDescription &gameDesc) : GlkAPI(syst, gameDesc), _currentCounter(0), _savedRoom(0), _options(0), _width(0), _topHeight(0), _splitScreen(true), - _bottomWindow(0), _topWindow(0), _bitFlags(0), _saveSlot(-1) { + _bottomWindow(nullptr), _topWindow(nullptr), _bitFlags(0), _saveSlot(-1) { Common::fill(&_nounText[0], &_nounText[16], '\0'); Common::fill(&_counters[0], &_counters[16], 0); Common::fill(&_roomSaved[0], &_roomSaved[16], 0); @@ -41,7 +41,7 @@ void Scott::runGame() { int vb, no; initialize(); - _bottomWindow = glk_window_open(0, 0, 0, wintype_TextBuffer, 1); + _bottomWindow = glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 1); if (_bottomWindow == nullptr) { glk_exit(); return; diff --git a/engines/glk/tads/os_banners.cpp b/engines/glk/tads/os_banners.cpp index db83081cb25..11c4b63bc01 100644 --- a/engines/glk/tads/os_banners.cpp +++ b/engines/glk/tads/os_banners.cpp @@ -79,7 +79,7 @@ struct banner_contents_t { uint len; }; -static osbanid_t os_banners = NULL; +static osbanid_t os_banners = nullptr; static uint os_banner_count = 999; extern winid_t mainwin; @@ -108,15 +108,15 @@ osbanid_t os_banner_init() { osbanid_t instance; instance = (osbanid_t)malloc(sizeof(os_banner_t)); if (!instance) - return 0; + return nullptr; instance->id = ++ os_banner_count; instance->valid = 1; - instance->prev = 0; - instance->next = 0; - instance->children = 0; - instance->parent = 0; + instance->prev = nullptr; + instance->next = nullptr; + instance->children = nullptr; + instance->parent = nullptr; instance->method = 0; instance->size = 0; @@ -126,14 +126,14 @@ osbanid_t os_banner_init() { instance->cheight = 0; instance->cwidth = 0; - instance->contents = 0; + instance->contents = nullptr; instance->style = style_Normal; instance->newline = 0; instance->move = 0; instance->x = 0; instance->y = 0; - instance->win = 0; + instance->win = nullptr; return instance; } @@ -142,7 +142,7 @@ osbanid_t os_banner_insert(osbanid_t parent, uint operation, osbanid_t other, uint method, uint size, uint type, uint status) { if (!parent || !(parent->valid)) - return 0; + return nullptr; if (operation == OS_BANNER_BEFORE || operation == OS_BANNER_AFTER) if (!other || !(other->valid) || !(other->parent == parent)) @@ -150,7 +150,7 @@ osbanid_t os_banner_insert(osbanid_t parent, uint operation, osbanid_t other, osbanid_t baby = os_banner_init(); if (!baby) - return 0; + return nullptr; baby->parent = parent; if (!(parent->children)) @@ -295,8 +295,8 @@ void os_banners_close(osbanid_t banner) if (banner->win && (banner->win != mainwin)) { - g_vm->glk_window_close(banner->win, 0); - banner->win = 0; + g_vm->glk_window_close(banner->win, nullptr); + banner->win = nullptr; } } @@ -343,10 +343,10 @@ contentid_t banner_contents_init(void) contentid_t instance; instance = (contentid_t)malloc(sizeof(banner_contents_t)); if (!instance) - return 0; + return nullptr; - instance->banner = 0; - instance->next = 0; + instance->banner = nullptr; + instance->next = nullptr; instance->style = style_Normal; instance->newline = 0; @@ -354,7 +354,7 @@ contentid_t banner_contents_init(void) instance->x = 0; instance->y = 0; - instance->chars = 0; + instance->chars = nullptr; instance->len = 0; return instance; @@ -442,13 +442,13 @@ void *os_banner_create(void *parent, int where, void *other, int wintype, uint gstatus = (style & OS_BANNER_STYLE_TAB_ALIGN); if (gparent && !(gparent->valid)) - return 0; + return nullptr; if (!os_banners) { os_banners = os_banner_init(); if (!os_banners) - return 0; + return nullptr; os_banners->win = mainwin; } @@ -639,7 +639,7 @@ void os_banner_clear(void *banner_handle) } banner_contents_clear(banner->contents); - banner->contents = 0; + banner->contents = nullptr; banner->newline = 0; banner->move = 0; banner->x = 0; diff --git a/engines/glk/tads/os_buffer.cpp b/engines/glk/tads/os_buffer.cpp index 46047784fc8..9c084683cba 100644 --- a/engines/glk/tads/os_buffer.cpp +++ b/engines/glk/tads/os_buffer.cpp @@ -48,7 +48,7 @@ char *os_fill_buffer(char *buf, size_t len) #else -static uint32 *input = 0; +static uint32 *input = nullptr; static uint max = 0; void os_put_buffer(const char *buf, size_t len) { diff --git a/engines/glk/tads/os_glk.cpp b/engines/glk/tads/os_glk.cpp index f7e1bcc2371..5fe52dae98d 100644 --- a/engines/glk/tads/os_glk.cpp +++ b/engines/glk/tads/os_glk.cpp @@ -67,7 +67,7 @@ char G_os_gamename[OSFNMAX]; int os_init(int *argc, char *argv[], const char *prompt, char *buf, int bufsiz) { - mainwin = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + mainwin = g_vm->glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 0); if (!mainwin) error("fatal: could not open window!\n"); @@ -90,7 +90,7 @@ int os_init(int *argc, char *argv[], const char *prompt, statusbg = 0; /* close statuswin; reopened on request */ - g_vm->glk_window_close(statuswin, 0); + g_vm->glk_window_close(statuswin, nullptr); statuswin = nullptr; @@ -318,7 +318,7 @@ void os_status(int stat) if (stat == 1) { - if (statuswin == NULL) + if (statuswin == nullptr) { g_vm->glk_stylehint_set(wintype_TextGrid, style_User1, stylehint_ReverseColor, 1); statuswin = g_vm->glk_window_open(mainwin, @@ -366,7 +366,7 @@ static void os_status_redraw(void) { if (!statuswin) return; - g_vm->glk_window_get_size(statuswin, &wid, NULL); + g_vm->glk_window_get_size(statuswin, &wid, nullptr); div = wid - strlen(rbuf) - 3; sprintf(fmt, " %%%ds %%s ", - (int)div); @@ -532,7 +532,7 @@ int os_askfile(const char *prompt, char *fname_buf, int fname_buf_len, gusage = fileusage_Data; fileref = g_vm->glk_fileref_create_by_prompt(gusage, (FileMode)gprompt, 0); - if (fileref == NULL) + if (fileref == nullptr) return OS_AFE_CANCEL; strcpy(fname_buf, g_vm->garglk_fileref_get_name(fileref)); diff --git a/engines/glk/tads/tads2/built_in.cpp b/engines/glk/tads/tads2/built_in.cpp index 134d4d10ab3..5ce1152248a 100644 --- a/engines/glk/tads/tads2/built_in.cpp +++ b/engines/glk/tads/tads2/built_in.cpp @@ -68,7 +68,7 @@ void bifyon(bifcxdef *ctx, int argc) tioreset(ctx->bifcxtio); /* read a line of text */ - if (tiogets(ctx->bifcxtio, (char *)0, rsp, (int)sizeof(rsp))) + if (tiogets(ctx->bifcxtio, (char *)nullptr, rsp, (int)sizeof(rsp))) runsig(ctx->bifcxrun, ERR_RUNQUIT); /* if we're in HTML mode, close the input font tag */ @@ -306,7 +306,7 @@ void bifsav(bifcxdef *ctx, int argc) bifcntargs(ctx, 1, argc); fn = runpopstr(ctx->bifcxrun); bifcstr(ctx, buf, (size_t)sizeof(buf), fn); - os_defext(buf, ctx->bifcxsavext != 0 ? ctx->bifcxsavext : "sav"); + os_defext(buf, ctx->bifcxsavext != nullptr ? ctx->bifcxsavext : "sav"); err = fiosav(ctx->bifcxrun->runcxvoc, buf, ctx->bifcxrun->runcxgamename); runpush(ctx->bifcxrun, runclog(err), &val); } @@ -337,7 +337,7 @@ void bifrso(bifcxdef *ctx, int argc) /* get string parameter - it's the filename */ fn = runpopstr(ctx->bifcxrun); bifcstr(ctx, buf, (size_t)sizeof(buf), fn); - os_defext(buf, ctx->bifcxsavext != 0 ? ctx->bifcxsavext : "sav"); + os_defext(buf, ctx->bifcxsavext != nullptr ? ctx->bifcxsavext : "sav"); } /* try restoring the file */ @@ -424,7 +424,7 @@ void bifinp(bifcxdef *ctx, int argc) tioreset(ctx->bifcxtio); /* read a line of text */ - if (tiogets(ctx->bifcxtio, (char *)0, inbuf, (int)sizeof(inbuf))) + if (tiogets(ctx->bifcxtio, (char *)nullptr, inbuf, (int)sizeof(inbuf))) runsig(ctx->bifcxrun, ERR_RUNQUIT); /* push the string, converting escapes */ @@ -449,7 +449,7 @@ void bifnfy(bifcxdef *ctx, int argc) tm = VOCDTIM_EACH_TURN; vocsetfd(voc, voc->voccxalm, objn, prp, tm, - (runsdef *)0, ERR_MANYNFY); + (runsdef *)nullptr, ERR_MANYNFY); } @@ -464,7 +464,7 @@ void bifunn(bifcxdef *ctx, int argc) objn = runpopobj(ctx->bifcxrun); prop = runpopprp(ctx->bifcxrun); vocremfd(voc, voc->voccxalm, objn, prop, - (runsdef *)0, ERR_NONFY); + (runsdef *)nullptr, ERR_NONFY); } /* trace on/off */ @@ -916,7 +916,7 @@ static const char *bif_stristr(const char *s1, const char *s2) return (const char *)s1; } - return 0; + return nullptr; } /* @@ -965,13 +965,13 @@ void bifask(bifcxdef *ctx, int argc) { "save", "write", - 0 + nullptr }; static const char *game_strs[] = { "restore", "game", - 0 + nullptr }; const char **sp; @@ -998,7 +998,7 @@ void bifask(bifcxdef *ctx, int argc) file_type = OSFTSAVE; /* look for any one of the "save" substrings */ - for (sp = save_strs ; *sp != 0 ; ++sp) + for (sp = save_strs ; *sp != nullptr ; ++sp) { /* check to see if this substring matches */ if (bif_stristr(pbuf, *sp)) @@ -1016,9 +1016,9 @@ void bifask(bifcxdef *ctx, int argc) * find any of them, be conservative and make no assumptions * about the file type */ - for (sp = game_strs ; *sp != 0 ; ++sp) + for (sp = game_strs ; *sp != nullptr ; ++sp) { - if (bif_stristr(pbuf, *sp) == 0) + if (bif_stristr(pbuf, *sp) == nullptr) { /* * this one doesn't match - don't make assumptions about @@ -1034,7 +1034,7 @@ void bifask(bifcxdef *ctx, int argc) /* check for a transcript */ if (file_type == OSFTUNK && prompt_type == OS_AFP_SAVE - && bif_stristr(pbuf, "script") != 0) + && bif_stristr(pbuf, "script") != nullptr) { /* looks like a log file */ file_type = OSFTLOG; @@ -2167,7 +2167,7 @@ void bifwrd(bifcxdef *ctx, int argc) } /* now build a list of strings from the words, if there are any */ - if (v != 0 && voclistlen(v) != 0 && v->vocolfst != 0 && v->vocollst != 0) + if (v != nullptr && voclistlen(v) != 0 && v->vocolfst != nullptr && v->vocollst != nullptr) { for (dst = buf + 2, src = (const uchar *)v->vocolfst ; src <= (const uchar *)v->vocollst ; src += len + 1) @@ -2521,7 +2521,7 @@ void biffopen(bifcxdef *ctx, int argc) /* allocate a filenum for the file */ for (fnum = 0 ; fnum < BIFFILMAX ; ++fnum) { - if (ctx->bifcxfile[fnum].fp == 0) + if (ctx->bifcxfile[fnum].fp == nullptr) break; } if (fnum == BIFFILMAX) @@ -2595,7 +2595,7 @@ void biffopen(bifcxdef *ctx, int argc) * current file safety level, which overrides our current setting. */ appctx = ctx->bifcxappctx; - if (appctx != 0 && appctx->get_io_safety_level != 0) + if (appctx != nullptr && appctx->get_io_safety_level != nullptr) { /* * ask the host system for the current level, and override any @@ -2721,7 +2721,7 @@ void biffopen(bifcxdef *ctx, int argc) } /* if we couldn't open it, return nil */ - if (fp == 0) + if (fp == nullptr) { runpnil(ctx->bifcxrun); return; @@ -2752,15 +2752,15 @@ static osfildef *bif_get_file(bifcxdef *ctx, int *fnump, int *bin_modep) /* get the file number and make sure it's valid */ fnum = runpopnum(ctx->bifcxrun); - if (fnum < 0 || fnum >= BIFFILMAX || ctx->bifcxfile[fnum].fp == 0) + if (fnum < 0 || fnum >= BIFFILMAX || ctx->bifcxfile[fnum].fp == nullptr) runsig(ctx->bifcxrun, ERR_BADFILE); /* put the validated file number, if the caller wants it */ - if (fnump != 0) + if (fnump != nullptr) *fnump = (int)fnum; /* set the binary-mode flag, if the caller wants it */ - if (bin_modep != 0) + if (bin_modep != nullptr) *bin_modep = ((ctx->bifcxfile[fnum].flags & BIFFIL_F_BINARY) != 0); /* return the file array pointer */ @@ -2774,11 +2774,11 @@ void biffclose(bifcxdef *ctx, int argc) /* get the file number */ bifcntargs(ctx, 1, argc); - fp = bif_get_file(ctx, &fnum, 0); + fp = bif_get_file(ctx, &fnum, nullptr); /* close the file and release the slot */ osfcls(fp); - ctx->bifcxfile[fnum].fp = 0; + ctx->bifcxfile[fnum].fp = nullptr; } void bifftell(bifcxdef *ctx, int argc) @@ -2787,7 +2787,7 @@ void bifftell(bifcxdef *ctx, int argc) /* get the file number */ bifcntargs(ctx, 1, argc); - fp = bif_get_file(ctx, (int *)0, 0); + fp = bif_get_file(ctx, (int *)nullptr, nullptr); /* return the seek position */ runpnum(ctx->bifcxrun, osfpos(fp)); @@ -2800,7 +2800,7 @@ void biffseek(bifcxdef *ctx, int argc) /* get the file pointer */ bifcntargs(ctx, 2, argc); - fp = bif_get_file(ctx, (int *)0, 0); + fp = bif_get_file(ctx, (int *)nullptr, nullptr); /* get the seek position, and seek there */ pos = runpopnum(ctx->bifcxrun); @@ -2813,7 +2813,7 @@ void biffseekeof(bifcxdef *ctx, int argc) /* get the file pointer */ bifcntargs(ctx, 1, argc); - fp = bif_get_file(ctx, (int *)0, 0); + fp = bif_get_file(ctx, (int *)nullptr, nullptr); /* seek to the end */ osfseek(fp, 0L, OSFSK_END); @@ -2829,7 +2829,7 @@ void biffwrite(bifcxdef *ctx, int argc) /* get the file */ bifcntargs(ctx, 2, argc); - fp = bif_get_file(ctx, (int *)0, &bin_mode); + fp = bif_get_file(ctx, (int *)nullptr, &bin_mode); /* get the value to write */ runpop(ctx->bifcxrun, &val); @@ -2957,7 +2957,7 @@ void biffread(bifcxdef *ctx, int argc) /* get the file pointer */ bifcntargs(ctx, 1, argc); - fp = bif_get_file(ctx, (int *)0, &bin_mode); + fp = bif_get_file(ctx, (int *)nullptr, &bin_mode); if (bin_mode) { @@ -3281,7 +3281,7 @@ void bifsysinfo(bifcxdef *ctx, int argc) * take no additional arguments */ bifcntargs(ctx, 1, argc); - if (os_get_sysinfo(id, 0, &result)) + if (os_get_sysinfo(id, nullptr, &result)) { /* we got a valid result - return it */ runpnum(ctx->bifcxrun, result); @@ -3313,13 +3313,13 @@ void bifsysinfo(bifcxdef *ctx, int argc) * colors. */ bifcntargs(ctx, 1, argc); - if (os_get_sysinfo(SYSINFO_HTML, 0, &result) && result != 0) + if (os_get_sysinfo(SYSINFO_HTML, nullptr, &result) && result != 0) { /* * we're in HTML mode, so ask the underlying HTML OS * implementation for its level of text color support */ - if (os_get_sysinfo(id, 0, &result)) + if (os_get_sysinfo(id, nullptr, &result)) { /* push the OS-level result */ runpnum(ctx->bifcxrun, result); @@ -3531,7 +3531,7 @@ void bifregroup(bifcxdef *ctx, int argc) reg = &ctx->bifcxregex.regs[grp]; /* if the group wasn't set, return nil */ - if (reg->start_ofs == 0 || reg->end_ofs == 0) + if (reg->start_ofs == nullptr || reg->end_ofs == nullptr) { runpnil(ctx->bifcxrun); return; @@ -3981,7 +3981,7 @@ void bifgetobj(bifcxdef *ctx, int argc) case 3: /* direct object */ - obj = (voc->voccxdobj == 0 ? MCMONINV : voc->voccxdobj->vocolobj); + obj = (voc->voccxdobj == nullptr ? MCMONINV : voc->voccxdobj->vocolobj); break; case 4: @@ -3991,7 +3991,7 @@ void bifgetobj(bifcxdef *ctx, int argc) case 5: /* indirect object */ - obj = (voc->voccxiobj == 0 ? MCMONINV : voc->voccxiobj->vocolobj); + obj = (voc->voccxiobj == nullptr ? MCMONINV : voc->voccxiobj->vocolobj); break; case 6: @@ -4319,8 +4319,8 @@ void bifresexists(bifcxdef *ctx, int argc) * supports external resource loading */ appctx = ctx->bifcxappctx; - found = (appctx != 0 - && appctx->resfile_exists != 0 + found = (appctx != nullptr + && appctx->resfile_exists != nullptr && (*appctx->resfile_exists)(appctx->resfile_exists_ctx, resname, strlen(resname))); diff --git a/engines/glk/tads/tads2/character_map.cpp b/engines/glk/tads/tads2/character_map.cpp index 623b1a26505..1d5de2cb92a 100644 --- a/engines/glk/tads/tads2/character_map.cpp +++ b/engines/glk/tads/tads2/character_map.cpp @@ -95,7 +95,7 @@ static int cmap_load_internal(char *filename) int sysblk; /* if there's no mapping file, use the default mapping */ - if (filename == 0) + if (filename == nullptr) { /* initialize with the default mapping */ cmap_init_default(); @@ -106,7 +106,7 @@ static int cmap_load_internal(char *filename) /* open the file */ fp = osfoprb(filename, OSFTCMAP); - if (fp == 0) + if (fp == nullptr) return 1; /* check the signature */ @@ -255,7 +255,7 @@ int cmap_load(char *filename) * a character set (if not, this simply establishes the default * setting, so we haven't explicitly loaded anything) */ - if (filename != 0) + if (filename != nullptr) S_cmap_loaded = TRUE; /* success */ diff --git a/engines/glk/tads/tads2/command_line.cpp b/engines/glk/tads/tads2/command_line.cpp index d5ec617444b..9fd4684295d 100644 --- a/engines/glk/tads/tads2/command_line.cpp +++ b/engines/glk/tads/tads2/command_line.cpp @@ -43,7 +43,7 @@ int cmdtog(errcxdef *ec, int prv, char *argp, int ofs, default: /* invalid - display usage if we have a callback for it */ - if (usagefn != 0) + if (usagefn != nullptr) (*usagefn)(ec); NOTREACHEDV(int); return 0; @@ -69,14 +69,14 @@ char *cmdarg(errcxdef *ec, char ***argpp, int *ip, int argc, int ofs, */ ++(*ip); ++(*argpp); - ret = (*ip >= argc ? 0 : **argpp); + ret = (*ip >= argc ? nullptr : **argpp); } /* * if we didn't find the argument, it's an error - display usage if * we have a valid usage callback */ - if ((ret == 0 || *ret == 0) && usagefn != 0) + if ((ret == nullptr || *ret == 0) && usagefn != nullptr) (*usagefn)(ec); return ret; diff --git a/engines/glk/tads/tads2/debug.cpp b/engines/glk/tads/tads2/debug.cpp index 8f46a79242f..51337e39918 100644 --- a/engines/glk/tads/tads2/debug.cpp +++ b/engines/glk/tads/tads2/debug.cpp @@ -266,7 +266,7 @@ void dbgpval(dbgcxdef *ctx, runsdef *val, uchar buf[TOKNAMMAX + 1]; uint len; const uchar *p = buf; - const char *typ = 0; + const char *typ = nullptr; switch(val->runstyp) { diff --git a/engines/glk/tads/tads2/error_message.cpp b/engines/glk/tads/tads2/error_message.cpp index a2701f3c13b..cdb01c0e538 100644 --- a/engines/glk/tads/tads2/error_message.cpp +++ b/engines/glk/tads/tads2/error_message.cpp @@ -33,11 +33,11 @@ errcxdef *lerini() { // allocate an error context if (!(errcx = (errcxdef *)ltk_suballoc(sizeof(errcxdef)))) { // failure - return((errcxdef *)0); + return((errcxdef *)nullptr); } // initialize the error context - errcx->errcxfp = (osfildef *)0; /* no error file handle */ + errcx->errcxfp = (osfildef *)nullptr; /* no error file handle */ errcx->errcxofs = 0; /* no offset in argument buffer */ errcx->errcxlog = ltk_errlog; /* error logging routine */ errcx->errcxlgc = errcx; /* error logging context */ diff --git a/engines/glk/tads/tads2/execute_command.cpp b/engines/glk/tads/tads2/execute_command.cpp index 9fd82c029a2..bcf9ad69aff 100644 --- a/engines/glk/tads/tads2/execute_command.cpp +++ b/engines/glk/tads/tads2/execute_command.cpp @@ -123,7 +123,7 @@ static void vocdusav(voccxdef *ctx, vocddef *what) ushort siz = sizeof(what) + sizeof(*what) + 1; /* if we don't need to save undo, quit now */ - if (uc == 0 || !objuok(uc)) + if (uc == nullptr || !objuok(uc)) return; /* reserve space for our record */ @@ -280,7 +280,7 @@ void vocdusave_me(voccxdef *ctx, objnum old_me) objucxdef *uc = ctx->voccxundo; /* if we don't need to save undo, there's nothing to do */ - if (uc == 0 || !objuok(uc)) + if (uc == nullptr || !objuok(uc)) return; /* reserve space for our record */ @@ -433,7 +433,7 @@ void vocsetfd(voccxdef *ctx, vocddef *what, objnum func, prpnum prop, /* record the information */ what->vocdfn = func; - if (val != 0) + if (val != nullptr) OSCPYSTRUCT(what->vocdarg, *val); what->vocdprp = prop; what->vocdtim = tm; @@ -713,14 +713,14 @@ static void exe_get_tpl(voccxdef *ctx, objnum verb, uint *tplofs, uint *actofs) { /* look up the new-style template first */ - *tplofs = objgetap(ctx->voccxmem, verb, PRP_TPL2, (objnum *)0, FALSE); + *tplofs = objgetap(ctx->voccxmem, verb, PRP_TPL2, (objnum *)nullptr, FALSE); /* if there's no new-style template, look up the old-style template */ if (*tplofs == 0) - *tplofs = objgetap(ctx->voccxmem, verb, PRP_TPL, (objnum *)0, FALSE); + *tplofs = objgetap(ctx->voccxmem, verb, PRP_TPL, (objnum *)nullptr, FALSE); /* also look to see if the verb has an Action method */ - *actofs = objgetap(ctx->voccxmem, verb, PRP_ACTION, (objnum *)0, FALSE); + *actofs = objgetap(ctx->voccxmem, verb, PRP_ACTION, (objnum *)nullptr, FALSE); } @@ -827,13 +827,13 @@ static void exe_save_again_obj(vocoldef *againv, const vocoldef *objv, char **bufp) { /* if there's an object, save it */ - if (objv != 0) + if (objv != nullptr) { /* copy the object information structure */ memcpy(againv, objv, sizeof(*againv)); /* copy the original command words to the "again" buffer */ - if (objv->vocolfst != 0 && objv->vocollst != 0) + if (objv->vocolfst != nullptr && objv->vocollst != nullptr) { size_t copylen; @@ -911,8 +911,8 @@ static int exe1cmd(voccxdef *ctx, objnum actor, objnum verb, vocoldef *dobjv, int err; runcxdef *rcx = ctx->voccxrun; objnum prep = *prepptr; - objnum dobj = (dobjv != 0 ? dobjv->vocolobj : MCMONINV); - objnum iobj = (iobjv != 0 ? iobjv->vocolobj : MCMONINV); + objnum dobj = (dobjv != nullptr ? dobjv->vocolobj : MCMONINV); + objnum iobj = (iobjv != nullptr ? iobjv->vocolobj : MCMONINV); int tplflags; int dobj_first; objnum old_tio_actor; @@ -1076,7 +1076,7 @@ static int exe1cmd(voccxdef *ctx, objnum actor, objnum verb, vocoldef *dobjv, ctx->voccxlsv = verb; ctx->voccxlsp = prep; ctx->voccxlssty = newstyle; - if (tpl != 0) + if (tpl != nullptr) memcpy(ctx->voccxlst, tpl, (size_t)(newstyle ? VOCTPL2SIZ : VOCTPLSIZ)); @@ -1099,7 +1099,7 @@ static int exe1cmd(voccxdef *ctx, objnum actor, objnum verb, vocoldef *dobjv, } /* remember the flags */ - tplflags = (tpl != 0 && newstyle ? voctplflg(tpl) : 0); + tplflags = (tpl != nullptr && newstyle ? voctplflg(tpl) : 0); dobj_first = (tplflags & VOCTPLFLG_DOBJ_FIRST); /* set up actor for tio subsystem - format strings need to know */ @@ -1164,7 +1164,7 @@ static int exe1cmd(voccxdef *ctx, objnum actor, objnum verb, vocoldef *dobjv, * check to see if the verb has verbAction defined - if so, invoke * the method */ - if (objgetap(ctx->voccxmem, verb, PRP_VERBACTION, (objnum *)0, FALSE)) + if (objgetap(ctx->voccxmem, verb, PRP_VERBACTION, (objnum *)nullptr, FALSE)) { /* call verb.verbAction(actor, dobj, prep, iobj) */ runpobj(rcx, iobj); @@ -1307,7 +1307,7 @@ static int exe1cmd(voccxdef *ctx, objnum actor, objnum verb, vocoldef *dobjv, } else if (iobj == MCMONINV) { - if (!objgetap(ctx->voccxmem, dobj, voctplvd(tpl), (objnum *)0, FALSE)) + if (!objgetap(ctx->voccxmem, dobj, voctplvd(tpl), (objnum *)nullptr, FALSE)) { /* display the error */ exeperr(ctx, verb, dobj, MCMONINV, MCMONINV); @@ -1347,7 +1347,7 @@ static int exe1cmd(voccxdef *ctx, objnum actor, objnum verb, vocoldef *dobjv, else { /* check to see if the verDoVerb and verIoVerb methods exist */ - if (!objgetap(ctx->voccxmem, dobj, voctplvd(tpl), (objnum *)0, FALSE)) + if (!objgetap(ctx->voccxmem, dobj, voctplvd(tpl), (objnum *)nullptr, FALSE)) { /* no verDoVerb method - show a default message */ exeperr(ctx, verb, dobj, MCMONINV, MCMONINV); @@ -1358,7 +1358,7 @@ static int exe1cmd(voccxdef *ctx, objnum actor, objnum verb, vocoldef *dobjv, /* skip to the end of the turn */ goto skipToFuses; } - else if (!objgetap(ctx->voccxmem, iobj, voctplvi(tpl), (objnum *)0, + else if (!objgetap(ctx->voccxmem, iobj, voctplvi(tpl), (objnum *)nullptr, FALSE)) { /* no verIoVerb method - show a default mesage */ @@ -1710,7 +1710,7 @@ void voc_multi_prefix(voccxdef *ctx, objnum objn, * older multisdesc (or even older sdesc) approach */ if (objgetap(ctx->voccxmem, objn, PRP_PREFIXDESC, - (objnum *)0, FALSE) != 0) + (objnum *)nullptr, FALSE) != 0) { runsdef val; @@ -1747,7 +1747,7 @@ void voc_multi_prefix(voccxdef *ctx, objnum objn, * use sdesc if multisdesc doesn't exist for this object) */ if (objgetap(ctx->voccxmem, objn, PRP_MULTISDESC, - (objnum *)0, FALSE) == 0) + (objnum *)nullptr, FALSE) == 0) { /* there's no multisdesc defined - use the plain sdesc */ runppr(rcx, objn, PRP_SDESC, 0); @@ -1778,7 +1778,7 @@ static int exeloop(voccxdef *ctx, objnum actor, objnum verb, * count the direct objects; we'll iterate over the direct objects, * so we execute the command once per direct object */ - exec_cnt = dobj_cnt = (dolist != 0 ? voclistlen(dolist) : 0); + exec_cnt = dobj_cnt = (dolist != nullptr ? voclistlen(dolist) : 0); /* * if there are no direct objects, we still must execute the command @@ -1830,13 +1830,13 @@ static int exeloop(voccxdef *ctx, objnum actor, objnum verb, int show_multi_prefix; /* get the current direct object, if we have one */ - dobj = (dolist != 0 ? &dolist[i] : 0); + dobj = (dolist != nullptr ? &dolist[i] : nullptr); /* * If we have a number or string, set the current one in * numObj/strObj */ - if (dolist != 0) + if (dolist != nullptr) { if (dolist[i].vocolflg == VOCS_STR) { @@ -1862,7 +1862,7 @@ static int exeloop(voccxdef *ctx, objnum actor, objnum verb, * each iteration with the name of the object we're acting on * currently. In other cases, there is no prefix. */ - show_multi_prefix = ((multi_flags != 0 || dobj_cnt > 1) && dobj != 0); + show_multi_prefix = ((multi_flags != 0 || dobj_cnt > 1) && dobj != nullptr); /* * Execute the command for this object. For every object except @@ -1985,9 +1985,9 @@ int execmd_recurs(voccxdef *ctx, objnum actor, objnum verb, if (actofs != 0) { /* execute the "action" method */ - err = exe1cmd(ctx, actor, verb, 0, &prep, 0, FALSE, - 0, FALSE, TRUE, validate_dobj, validate_iobj, - 0, 0, 0, FALSE, 0); + err = exe1cmd(ctx, actor, verb, nullptr, &prep, nullptr, FALSE, + nullptr, FALSE, TRUE, validate_dobj, validate_iobj, + nullptr, 0, 0, FALSE, 0); } else { @@ -2005,7 +2005,7 @@ int execmd_recurs(voccxdef *ctx, objnum actor, objnum verb, if (voctplfnd(ctx, verb, MCMONINV, tpl, &newstyle)) { /* execute the command */ - err = exe1cmd(ctx, actor, verb, &dobjv, &prep, 0, FALSE, + err = exe1cmd(ctx, actor, verb, &dobjv, &prep, nullptr, FALSE, tpl, newstyle, TRUE, validate_dobj, validate_iobj, &dobjv, 0, 1, FALSE, 0); } @@ -2276,7 +2276,7 @@ static void voc_askobj_indirect(voccxdef *ctx, vocoldef *dolist, * we need space to store the strings for the words in this noun * phrase */ - for (p = dolist[i].vocolfst ; p != 0 && p <= dolist[i].vocollst ; + for (p = dolist[i].vocolfst ; p != nullptr && p <= dolist[i].vocollst ; p += curlen + 1) { /* @@ -2347,7 +2347,7 @@ static void voc_askobj_indirect(voccxdef *ctx, vocoldef *dolist, lstp += 2; /* store the word strings in the sub-sublist */ - for (p = dolist[i].vocolfst ; p != 0 && p <= dolist[i].vocollst ; + for (p = dolist[i].vocolfst ; p != nullptr && p <= dolist[i].vocollst ; p += curlen + 1) { /* get this string's length */ @@ -2505,10 +2505,10 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, /* look up the verb based on the verb and verb-prep */ n = vocffw(ctx, vverb, (int)strlen(vverb), vprep, (vprep ? (int)strlen(vprep) : 0), PRP_VERB, - (vocseadef *)0); + (vocseadef *)nullptr); /* if we didn't find a verb template, we can't process the sentence */ - if (n == 0) + if (n == nullptr) { /* try parseUnknownVerb, and show an error if that doesn't handle it */ if (try_unknown_verb(ctx, actor, cmd, typelist, wrdcnt, next_word, @@ -2620,9 +2620,9 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, { if (actofs || verb == ctx->voccxvag) { - if ((err = exeloop(ctx, actor, verb, (vocoldef *)0, &prep, - (vocoldef *)0, multi_flags, - (uchar *)0, 0)) != 0) + if ((err = exeloop(ctx, actor, verb, (vocoldef *)nullptr, &prep, + (vocoldef *)nullptr, multi_flags, + (uchar *)nullptr, 0)) != 0) goto exit_error; } else @@ -2698,7 +2698,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, { o = osrp2(l + 1); if (!objgetap(ctx->voccxmem, o, voctplvd(tpl), - (objnum *)0, FALSE)) + (objnum *)nullptr, FALSE)) continue; tiohide(ctx->voccxtio); @@ -2725,10 +2725,10 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, { dolist[0].vocolobj = defobj; dolist[0].vocolflg = 0; - dolist[0].vocolfst = dolist[0].vocollst = 0; + dolist[0].vocolfst = dolist[0].vocollst = nullptr; dolist[1].vocolobj = MCMONINV; dolist[1].vocolflg = 0; - dolist[1].vocolfst = dolist[1].vocollst = 0; + dolist[1].vocolfst = dolist[1].vocollst = nullptr; runrst(rcx); if (ctx->voccxpdef2 != MCMONINV) @@ -2798,7 +2798,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, /* save it/them/him/her, and execute the command */ exesaveit(ctx, dolist1); if ((err = exeloop(ctx, actor, verb, dolist1, &prep, - (vocoldef *)0, multi_flags, + (vocoldef *)nullptr, multi_flags, tpl, newstyle)) != 0) goto exit_error; } @@ -2908,7 +2908,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, { o = osrp2(l + 1); if (!objgetap(ctx->voccxmem, o, voctplvi(tpl), - (objnum *)0, FALSE)) + (objnum *)nullptr, FALSE)) continue; tiohide(ctx->voccxtio); @@ -2934,10 +2934,10 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, { iolist[0].vocolobj = defobj; iolist[0].vocolflg = 0; - iolist[0].vocolfst = iolist[0].vocollst = 0; + iolist[0].vocolfst = iolist[0].vocollst = nullptr; iolist[1].vocolobj = MCMONINV; iolist[1].vocolflg = 0; - iolist[1].vocolfst = iolist[1].vocollst = 0; + iolist[1].vocolfst = iolist[1].vocollst = nullptr; /* tell the user what we're assuming */ runrst(rcx); @@ -3240,7 +3240,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, : voctplvi(tpl)); if (!objgetap(ctx->voccxmem, o, verprop, - (objnum *)0, FALSE)) + (objnum *)nullptr, FALSE)) continue; tiohide(ctx->voccxtio); @@ -3300,19 +3300,19 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, { dolist[0].vocolobj = defobj; dolist[0].vocolflg = 0; - dolist[0].vocolfst = dolist[0].vocollst = 0; + dolist[0].vocolfst = dolist[0].vocollst = nullptr; dolist[1].vocolobj = MCMONINV; dolist[1].vocolflg = 0; - dolist[1].vocolfst = dolist[1].vocollst = 0; + dolist[1].vocolfst = dolist[1].vocollst = nullptr; } else { iolist[0].vocolobj = defobj; iolist[0].vocolflg = 0; - iolist[0].vocolfst = iolist[0].vocollst = 0; + iolist[0].vocolfst = iolist[0].vocollst = nullptr; iolist[1].vocolobj = MCMONINV; iolist[1].vocolflg = 0; - iolist[1].vocolfst = iolist[1].vocollst = 0; + iolist[1].vocolfst = iolist[1].vocollst = nullptr; } /* tell the user what we're assuming */ @@ -3355,7 +3355,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, rundisc(rcx); /* make sure output capturing is off for the prompt */ - tiocapture(ctx->voccxtio, (mcmcxdef *)0, FALSE); + tiocapture(ctx->voccxtio, (mcmcxdef *)nullptr, FALSE); tioclrcapture(ctx->voccxtio); /* @@ -3436,7 +3436,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, * multiple distinct objects were specified. */ vcnt = voclistlen(dolist); - for (distinct = 0, i = 0, lastfst = 0 ; i < vcnt ; ++i) + for (distinct = 0, i = 0, lastfst = nullptr ; i < vcnt ; ++i) { /* if the first word is different here, note it */ if (lastfst != dolist[i].vocolfst) @@ -3613,7 +3613,7 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, ctx->voccxunknown = 1; /* get the types */ - exenewlist[cnt] = 0; + exenewlist[cnt] = nullptr; if (vocgtyp(ctx, exenewlist, exenewtype, cmdbuf)) { /* @@ -3647,8 +3647,8 @@ int execmd(voccxdef *ctx, objnum actor, objnum prep, /* get the preposition */ vp = vocffw(ctx, exenewlist[0], (int)strlen(exenewlist[0]), - (char *)0, 0, PRP_PREP, (vocseadef *)0); - if (vp != 0 && vp->vocwobj == prep) + (char *)nullptr, 0, PRP_PREP, (vocseadef *)nullptr); + if (vp != nullptr && vp->vocwobj == prep) ++exenewpos; } diff --git a/engines/glk/tads/tads2/file_io.cpp b/engines/glk/tads/tads2/file_io.cpp index be839f3415d..6f615c2df63 100644 --- a/engines/glk/tads/tads2/file_io.cpp +++ b/engines/glk/tads/tads2/file_io.cpp @@ -80,13 +80,13 @@ void OS_LOADDS fioldobj(void *ctx0, mclhd handle, uchar *ptr, ushort siz) /* shut down load-on-demand subsystem (close load file) */ void fiorcls(fiolcxdef *ctx) { - if (ctx != 0 && ctx->fiolcxfp != 0) + if (ctx != nullptr && ctx->fiolcxfp != nullptr) { /* close the file */ osfcls(ctx->fiolcxfp); /* forget the file object */ - ctx->fiolcxfp = 0; + ctx->fiolcxfp = nullptr; } } @@ -101,7 +101,7 @@ static void fiordhtml(errcxdef *ec, osfildef *fp, appctxdef *appctx, /* * resource map - if the host system is interested, tell it about it */ - if (appctx != 0) + if (appctx != nullptr) { ulong entry_cnt; ulong i; @@ -146,7 +146,7 @@ static void fiordhtml(errcxdef *ec, osfildef *fp, appctxdef *appctx, } /* tell the host system where the resources start */ - if (appctx->set_resmap_seek != 0) + if (appctx->set_resmap_seek != nullptr) { long pos = osfpos(fp); (*appctx->set_resmap_seek)(appctx->set_resmap_seek_ctx, @@ -377,7 +377,7 @@ static void fiord1(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, curpos = osfpos(fp) - startofs; bsiz = endpos - curpos; if (bsiz && bsiz < OSMALMAX - && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != 0) + && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != nullptr) { uchar *p1; ulong siz2; @@ -538,7 +538,7 @@ static void fiord1(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, curpos = osfpos(fp) - startofs; bsiz = endpos - curpos; if (bsiz && bsiz < OSMALMAX - && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != 0) + && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != nullptr) { uchar *p1; ulong siz2; @@ -721,7 +721,7 @@ static void fiord1(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, curpos = osfpos(fp) - startofs; bsiz = endpos - curpos; if (bsiz && bsiz < OSMALMAX - && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != 0) + && (bufp = p = (uchar *)osmalloc((size_t)bsiz)) != nullptr) { uchar *p1; ulong siz2; @@ -742,7 +742,7 @@ static void fiord1(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, xor_seed, xor_inc); vocadd2(vctx, (prpnum)osrp2(p+4), (objnum)osrp2(p+6), osrp2(p+8), p + 10, len1, - (len2 ? p + 10 + len1 : (uchar*)0), len2); + (len2 ? p + 10 + len1 : (uchar*)nullptr), len2); p += 10 + len1 + len2; bsiz -= 10 + len1 + len2; @@ -766,7 +766,7 @@ static void fiord1(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, xor_seed, xor_inc); vocadd2(vctx, (prpnum)osrp2(buf+4), (objnum)osrp2(buf+6), osrp2(buf+8), buf + 10, len1, - (len2 ? buf + 10 + len1 : (uchar*)0), len2); + (len2 ? buf + 10 + len1 : (uchar*)nullptr), len2); curpos += 10 + len1 + len2; } } @@ -849,7 +849,7 @@ static void fiord1(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, else if (fioisrsc(buf, "SRC")) { /* skip source file id's if there's no debugger context */ - if (vctx->voccxrun->runcxdbg == 0) + if (vctx->voccxrun->runcxdbg == nullptr) { osfseek(fp, endpos + startofs, OSFSK_SET); continue; @@ -869,7 +869,7 @@ static void fiord1(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, * (line-number-based) source debugging information in the * file -- set the new-style debug info flag */ - if (vctx->voccxrun->runcxdbg != 0) + if (vctx->voccxrun->runcxdbg != nullptr) vctx->voccxrun->runcxdbg->dbgcxflg |= DBGCXFLIN2; /* the contents are empty - skip the block */ @@ -919,7 +919,7 @@ static void fiord1(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, if (osfrb(fp, buf, 2)) errsig(ec, ERR_RDGAM); if (pcntptr) *pcntptr = osrp2(buf); } - else if (fioisrsc(buf, "TADSPP") && tctx != 0) + else if (fioisrsc(buf, "TADSPP") && tctx != nullptr) { tok_read_defines(tctx, fp, ec); } @@ -979,10 +979,10 @@ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname, * get the display filename - use the real filename if one is * provided, otherwise use the name of the executable file itself */ - display_fname = (fname != 0 ? fname : exename); + display_fname = (fname != nullptr ? fname : exename); /* save the filename in G_os_gamename */ - if (display_fname != 0) + if (display_fname != nullptr) { size_t copylen; @@ -998,16 +998,16 @@ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname, G_os_gamename[0] = '\0'; /* open the file and read and check file header */ - fp = (fname != 0 ? osfoprb(fname, OSFTGAME) + fp = (fname != nullptr ? osfoprb(fname, OSFTGAME) : os_exeseek(exename, "TGAM")); - if (fp == 0) + if (fp == nullptr) errsig(vctx->voccxerr, ERR_OPRGAM); /* * we've identified the .GAM file source - tell the host system * about it, if it's interested */ - if (appctx != 0 && appctx->set_game_name != 0) + if (appctx != nullptr && appctx->set_game_name != nullptr) (*appctx->set_game_name)(appctx->set_game_name_ctx, display_fname); /* remember starting location in file */ @@ -1029,7 +1029,7 @@ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname, * as the .GAM file, with the .GAM suffix replaced by suffixes from *. RS0 to .RS9. */ - if (appctx != 0 && appctx->add_resfile != 0) + if (appctx != nullptr && appctx->add_resfile != nullptr) { char suffix_lc[4]; char suffix_uc[4]; @@ -1059,7 +1059,7 @@ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname, * resource path, use it, otherwise use the same directory * that contains the .GAM file. */ - if (appctx->ext_res_path != 0) + if (appctx->ext_res_path != nullptr) { /* * There's an explicit resource path - append the root @@ -1077,7 +1077,7 @@ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname, * filename, including directory, so that we look in the * same directory that contains the .GAM file */ - if (base_name != 0) + if (base_name != nullptr) strcpy(resname, base_name); else resname[0] = '\0'; @@ -1092,7 +1092,7 @@ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname, fpres = osfoprb(resname, OSFTGAME); /* if that didn't work, try the upper-case name */ - if (fpres == 0) + if (fpres == nullptr) { /* replace the suffix with the upper-case version */ os_remext(resname); @@ -1103,7 +1103,7 @@ void fiord(mcmcxdef *mctx, voccxdef *vctx, tokcxdef *tctx, const char *fname, } /* if we opened it successfully, read it */ - if (fpres != 0) + if (fpres != nullptr) { /* tell the host system about it */ resfileno = (*appctx->add_resfile) @@ -1625,7 +1625,7 @@ int fiosav(voccxdef *vctx, char *fname, char *game_fname) struct fiosav_cb_ctx fnctx; /* open the output file */ - if ((fp = osfopwb(fname, OSFTSAVE)) == 0) + if ((fp = osfopwb(fname, OSFTSAVE)) == nullptr) return TRUE; /* @@ -1634,7 +1634,7 @@ int fiosav(voccxdef *vctx, char *fname, char *game_fname) * run-time and restore the game by specifying only the saved game * file. */ - if (game_fname != 0) + if (game_fname != nullptr) { size_t len; @@ -1659,7 +1659,7 @@ int fiosav(voccxdef *vctx, char *fname, char *game_fname) if (!*vpg) continue; for (v = *vpg, obj = (i << 8), j = 0 ; j < 256 ; ++v, ++obj, ++j) { - if (*v != 0) + if (*v != nullptr) { /* write object if it's dirty */ if (mcmobjdirty(mctx, (mcmon)obj)) diff --git a/engines/glk/tads/tads2/get_string.cpp b/engines/glk/tads/tads2/get_string.cpp index c7d39d23446..71dbf57224d 100644 --- a/engines/glk/tads/tads2/get_string.cpp +++ b/engines/glk/tads/tads2/get_string.cpp @@ -64,7 +64,7 @@ int getstring(const char *prompt, char *buf, int bufl) /* show prompt if one was given and flush output */ savemoremode = setmore(0); - if (prompt != 0) + if (prompt != nullptr) { /* display the prompt text */ outformat(prompt); @@ -76,12 +76,12 @@ int getstring(const char *prompt, char *buf, int bufl) outreset(); /* read from the command input file if we have one */ - if (scrfp != 0) + if (scrfp != nullptr) { int quiet = scrquiet; /* try reading from command input file */ - if ((result = qasgets(buf, bufl)) == 0) + if ((result = qasgets(buf, bufl)) == nullptr) { /* * End of command input file; return to reading the @@ -93,7 +93,7 @@ int getstring(const char *prompt, char *buf, int bufl) * command here but instead handle it later when we check to * see if we need to read from the keyboard. */ - if (quiet && prompt != 0) + if (quiet && prompt != nullptr) outformat(prompt); outflushn(0); outreset(); @@ -116,7 +116,7 @@ int getstring(const char *prompt, char *buf, int bufl) } /* if we don't have a script file, read from the keyboard */ - if (scrfp == 0) + if (scrfp == nullptr) { /* update the status line */ runstat(); @@ -129,7 +129,7 @@ int getstring(const char *prompt, char *buf, int bufl) * value; otherwise, we successfully read a command, so return * zero */ - retval = (result == 0); + retval = (result == nullptr); } /* restore the original "more" mode */ @@ -152,7 +152,7 @@ int getstring(const char *prompt, char *buf, int bufl) * appropriate */ out_logfile_print(buf, TRUE); - if (cmdfile != 0) + if (cmdfile != nullptr) { os_fprintz(cmdfile, ">"); os_fprintz(cmdfile, buf); diff --git a/engines/glk/tads/tads2/line_source_file.cpp b/engines/glk/tads/tads2/line_source_file.cpp index 193ca72037b..e3530b1449a 100644 --- a/engines/glk/tads/tads2/line_source_file.cpp +++ b/engines/glk/tads/tads2/line_source_file.cpp @@ -96,7 +96,7 @@ linfdef *linfini(mcmcxdef *mctx, errcxdef *ec, const char *filename, if (!path) { path = &fakepath; - fakepath.tokpnxt = (tokpdef *)0; + fakepath.tokpnxt = (tokpdef *)nullptr; fakepath.tokplen = 0; } @@ -125,7 +125,7 @@ linfdef *linfini(mcmcxdef *mctx, errcxdef *ec, const char *filename, fbuf[len + flen] = '\0'; /* attempt to open this file */ - if ((fp = osfoprs(fbuf, OSFTTEXT)) != 0) + if ((fp = osfoprs(fbuf, OSFTTEXT)) != nullptr) break; } @@ -134,9 +134,9 @@ linfdef *linfini(mcmcxdef *mctx, errcxdef *ec, const char *filename, * let the debugger UI try to find the file. If nothing works, give * up and return failure. */ - if (fp == 0 - && (!os_locate(filename, flen, (char *)0, fbuf, sizeof(fbuf)) - || (fp = osfoprs(fbuf, OSFTTEXT)) == 0)) + if (fp == nullptr + && (!os_locate(filename, flen, (char *)nullptr, fbuf, sizeof(fbuf)) + || (fp = osfoprs(fbuf, OSFTTEXT)) == nullptr)) { /* * Ask the debugger UI for advice. If the debugger isn't @@ -144,7 +144,7 @@ linfdef *linfini(mcmcxdef *mctx, errcxdef *ec, const char *filename, */ if (!dbgu_find_src(filename, flen, fbuf, sizeof(fbuf), must_find_file)) - return 0; + return nullptr; /* try opening the file */ if (fbuf[0] == '\0') @@ -153,7 +153,7 @@ linfdef *linfini(mcmcxdef *mctx, errcxdef *ec, const char *filename, * we didn't get a filename - the UI wants to defer finding * the file until later */ - fp = 0; + fp = nullptr; } else { @@ -165,12 +165,12 @@ linfdef *linfini(mcmcxdef *mctx, errcxdef *ec, const char *filename, * if the file isn't present, and we're required to find it, * return failure */ - if (fp == 0 && must_find_file) - return 0; + if (fp == nullptr && must_find_file) + return nullptr; } /* figure out how much space we need for the file's full name */ - if (fp == 0) + if (fp == nullptr) { /* * we didn't find the file, so we don't yet know its name - use @@ -460,10 +460,10 @@ int linfload(osfildef *fp, dbgcxdef *dbgctx, errcxdef *ec, tokpdef *path) } /* if we opened the file, close it - don't hold all files open */ - if (linf->linffp != 0) + if (linf->linffp != nullptr) { osfcls(linf->linffp); - linf->linffp = 0; + linf->linffp = nullptr; } /* link into debug line source chain */ @@ -870,7 +870,7 @@ void linfdis(lindef *lin) if (linf->linffp) { osfcls(linf->linffp); - linf->linffp = (osfildef *)0; + linf->linffp = (osfildef *)nullptr; } # undef linf @@ -902,7 +902,7 @@ void linfact(lindef *lin) else { /* there's no file to open */ - linf->linffp = 0; + linf->linffp = nullptr; } # undef linf @@ -978,7 +978,7 @@ int linfgets(lindef *lin, uchar *buf, uint siz) startpos = osfpos(linf->linffp); /* read the next line */ - ret = (osfgets((char *)buf, siz, linf->linffp) != 0); + ret = (osfgets((char *)buf, siz, linf->linffp) != nullptr); if (!ret) return ret; diff --git a/engines/glk/tads/tads2/memory_cache.cpp b/engines/glk/tads/tads2/memory_cache.cpp index 36f1aacaea4..df4fedff463 100644 --- a/engines/glk/tads/tads2/memory_cache.cpp +++ b/engines/glk/tads/tads2/memory_cache.cpp @@ -174,7 +174,7 @@ mcmcx1def *mcmini(ulong max, uint pages, ulong swapsize, ctx->mcmcxhpch = (mcmhdef *)chunk; /* set start of heap chain */ chunk += sizeof(mcmhdef); rem -= sizeof(mcmhdef); - ctx->mcmcxhpch->mcmhnxt = (mcmhdef *)0; /* no next heap in chain yet */ + ctx->mcmcxhpch->mcmhnxt = (mcmhdef *)nullptr; /* no next heap in chain yet */ /* allocate the first page */ *(mcmon *)chunk = 0; /* set object number header in chunk */ @@ -238,7 +238,7 @@ void mcmterm(mcmcx1def *ctx) * sub-allocated the context structure itself and the page table out of * that memory. */ - for (cur = ctx->mcmcxhpch ; cur != 0 && cur->mcmhnxt != 0 ; cur = nxt) + for (cur = ctx->mcmcxhpch ; cur != nullptr && cur->mcmhnxt != nullptr ; cur = nxt) { /* remember the next chunk, and delete this one */ nxt = cur->mcmhnxt; @@ -310,13 +310,13 @@ startover: error: *nump = MCMONINV; - return((uchar *)0); + return((uchar *)nullptr); } static void mcmcliexp(mcmcxdef *cctx, mcmon clinum) { /* add global number to client mapping table at client number */ - if (cctx->mcmcxmtb[clinum >> 8] == (mcmon *)0) + if (cctx->mcmcxmtb[clinum >> 8] == (mcmon *)nullptr) { mcmcx1def *ctx = cctx->mcmcxgl; int i; @@ -342,7 +342,7 @@ uchar *mcmalo0(mcmcxdef *cctx, ushort siz, mcmon *nump, MCMGLBCTX(ctx); /* try once */ - if ((ret = mcmalo1(ctx, siz, &glb)) != 0) + if ((ret = mcmalo1(ctx, siz, &glb)) != nullptr) goto done; /* collect some garbage */ @@ -352,7 +352,7 @@ uchar *mcmalo0(mcmcxdef *cctx, ushort siz, mcmon *nump, for ( ;; ) { /* try again */ - if ((ret = mcmalo1(ctx, siz, &glb)) != 0) + if ((ret = mcmalo1(ctx, siz, &glb)) != nullptr) goto done; /* nothing left to swap? */ @@ -360,7 +360,7 @@ uchar *mcmalo0(mcmcxdef *cctx, ushort siz, mcmon *nump, break; /* try yet again */ - if ((ret = mcmalo1(ctx, siz, &glb)) != 0) + if ((ret = mcmalo1(ctx, siz, &glb)) != nullptr) goto done; /* collect garbage once again */ @@ -368,7 +368,7 @@ uchar *mcmalo0(mcmcxdef *cctx, ushort siz, mcmon *nump, } /* try again */ - if ((ret = mcmalo1(ctx, siz, &glb)) != 0) + if ((ret = mcmalo1(ctx, siz, &glb)) != nullptr) goto done; /* we have no other way of getting more memory, so signal an error */ @@ -485,7 +485,7 @@ uchar *mcmrealo(mcmcxdef *cctx, mcmon cliobj, ushort newsize) /* see if there's a free block after this block */ p = o->mcmoptr; nxt = *(mcmon *)(p + o->mcmosiz); - nxto = (nxt == MCMONINV) ? (mcmodef *)0 : mcmgobje(ctx, nxt); + nxto = (nxt == MCMONINV) ? (mcmodef *)nullptr : mcmgobje(ctx, nxt); if (nxto && ((nxto->mcmoflg & MCMOFFREE) && nxto->mcmosiz >= newsize - o->mcmosiz)) @@ -657,7 +657,7 @@ startover: error: *nump = MCMONINV; - return((mcmodef *)0); + return((mcmodef *)nullptr); } /* find free block: find a block from the free pool to satisfy allocation */ @@ -671,7 +671,7 @@ static mcmodef *mcmffb(mcmcx1def *ctx, ushort siz, mcmon *nump) MCMGLBCTX(ctx); - for (minn = MCMONINV, mino = 0, n = ctx->mcmcxfre ; n != MCMONINV ; + for (minn = MCMONINV, mino = nullptr, n = ctx->mcmcxfre ; n != MCMONINV ; n = o->mcmonxt) { o = mcmgobje(ctx, n); @@ -734,8 +734,8 @@ static void mcmunl(mcmcx1def *ctx, mcmon n, mcmon *lst) o->mcmoflg &= ~MCMOFLRU; } - nxt = o->mcmonxt == MCMONINV ? (mcmodef *)0 : mcmgobje(ctx, o->mcmonxt); - prv = o->mcmoprv == MCMONINV ? (mcmodef *)0 : mcmgobje(ctx, o->mcmoprv); + nxt = o->mcmonxt == MCMONINV ? (mcmodef *)nullptr : mcmgobje(ctx, o->mcmonxt); + prv = o->mcmoprv == MCMONINV ? (mcmodef *)nullptr : mcmgobje(ctx, o->mcmoprv); /* set back link for next object, if there is a next object */ if (nxt) nxt->mcmoprv = o->mcmoprv; @@ -810,13 +810,13 @@ static uchar *mcmhalo(mcmcx1def *ctx) MCMGLBCTX(ctx); - if (ctx->mcmcxmax < MCMCHUNK) return((uchar *)0); + if (ctx->mcmcxmax < MCMCHUNK) return((uchar *)nullptr); ERRBEGIN(ctx->mcmcxerr) chunk = mchalo(ctx->mcmcxerr, size, "mcmhalo"); ERRCATCH_ERRCODE_UNUSED(ctx->mcmcxerr) ctx->mcmcxmax = 0; /* remember we can't allocate anything more */ - return((uchar *)0); /* return no memory */ + return((uchar *)nullptr); /* return no memory */ ERREND(ctx->mcmcxerr) ctx->mcmcxmax -= MCMCHUNK; @@ -873,7 +873,7 @@ static uchar *mcmffh(mcmcx1def *ctx, uchar *p) if (o->mcmoflg & MCMOFFREE) return(p); p += osrndsz(sizeof(mcmon)) + o->mcmosiz; /* move on to next chunk */ } - return((uchar *)0); /* no more free blocks in heap */ + return((uchar *)nullptr); /* no more free blocks in heap */ } #ifdef NEVER @@ -1106,7 +1106,7 @@ uchar *mcmlck(mcmcxdef *ctx, mcmon objnum) if ((o->mcmoflg & MCMOFFREE) != 0 || mcmc2g(ctx, objnum) == MCMONINV) { errsig(ctx->mcmcxgl->mcmcxerr, ERR_INVOBJ); - return 0; + return nullptr; } else if (o->mcmoflg & MCMOFPRES) { diff --git a/engines/glk/tads/tads2/memory_cache_heap.cpp b/engines/glk/tads/tads2/memory_cache_heap.cpp index b64b18a9d67..d6876b7d6d8 100644 --- a/engines/glk/tads/tads2/memory_cache_heap.cpp +++ b/engines/glk/tads/tads2/memory_cache_heap.cpp @@ -42,7 +42,7 @@ uchar *mchalo(errcxdef *ctx, size_t siz, const char *comment) { else { errsig(ctx, ERR_NOMEM); NOTREACHEDV(uchar *); - return 0; + return nullptr; } } diff --git a/engines/glk/tads/tads2/memory_cache_swap.cpp b/engines/glk/tads/tads2/memory_cache_swap.cpp index 81b7574b87f..729edddcf61 100644 --- a/engines/glk/tads/tads2/memory_cache_swap.cpp +++ b/engines/glk/tads/tads2/memory_cache_swap.cpp @@ -34,7 +34,7 @@ void mcsini(mcscxdef *ctx, mcmcx1def *gmemctx, ulong maxsiz, osfildef *fp, char *swapfilename, errcxdef *errctx) { uchar *p; - ctx->mcscxtab = (mcsdsdef **)0; /* anticipate failure */ + ctx->mcscxtab = (mcsdsdef **)nullptr; /* anticipate failure */ /* allocate space from the low-level heap for page table and one page */ p = mchalo(errctx, ((MCSPAGETAB * sizeof(mcsdsdef *)) + (MCSPAGECNT * sizeof(mcsdsdef))), "mcsini"); @@ -57,11 +57,11 @@ void mcsini(mcscxdef *ctx, mcmcx1def *gmemctx, ulong maxsiz, * store the swap filename - make a copy so that the caller doesn't * have to retain the original copy (in case it's on the stack) */ - if (swapfilename != 0) { + if (swapfilename != nullptr) { ctx->mcscxfname = (char *)mchalo(errctx, (strlen(swapfilename) + 1), "mcsini"); strcpy(ctx->mcscxfname, swapfilename); } else { - ctx->mcscxfname = 0; + ctx->mcscxfname = nullptr; } } diff --git a/engines/glk/tads/tads2/object.cpp b/engines/glk/tads/tads2/object.cpp index c1881dc3939..867d88440bd 100644 --- a/engines/glk/tads/tads2/object.cpp +++ b/engines/glk/tads/tads2/object.cpp @@ -128,7 +128,7 @@ uint objgetp_end(mcmcxdef *ctx, objnum objn, prpnum prop) uint valsiz; /* get the start of the object */ - ofs = objgetp(ctx, objn, prop, 0); + ofs = objgetp(ctx, objn, prop, nullptr); if (ofs == 0) return 0; @@ -213,11 +213,11 @@ static uint objgetap0(mcmcxdef *ctx, noreg objnum obj, prpnum prop, * tell the caller which object this came from, if the caller * wants to know */ - if (orn != 0) + if (orn != nullptr) *orn = obj; /* if the caller wants to know the type, return it */ - if (ortyp != 0) + if (ortyp != nullptr) *ortyp = typ; /* return the property offset */ @@ -268,11 +268,11 @@ static uint objgetap0(mcmcxdef *ctx, noreg objnum obj, prpnum prop, } /* set return pointer and return the offset of what we found */ - if (orn != 0) + if (orn != nullptr) *orn = osavn; /* return the object type if the caller wanted it */ - if (ortyp != 0) + if (ortyp != nullptr) *ortyp = typsav; /* return the offset of the property if we found one, or zero if not */ @@ -300,7 +300,7 @@ uint objgetap(mcmcxdef *ctx, noreg objnum obj, prpnum prop, * even if the caller doesn't care about the original object number, * we do, so provide our own location to store it if necessary */ - if (ornp == 0) + if (ornp == nullptr) ornp = &orn; /* keep going until we've finished translating synonyms */ @@ -381,7 +381,7 @@ void objdelp(mcmcxdef *mctx, objnum objn, prpnum prop, int mark_only) prpdef *nxt; size_t movsiz; - pofs = objgetp(mctx, objn, prop, (dattyp *)0); /* try to find property */ + pofs = objgetp(mctx, objn, prop, (dattyp *)nullptr); /* try to find property */ if (!pofs) return; /* not defined - nothing to delete */ objptr = (objdef *)mcmlck(mctx, objn); /* get lock on object */ @@ -437,9 +437,9 @@ void objsetp(mcmcxdef *ctx, objnum objn, prpnum prop, dattyp typ, ERRBEGIN(ctx->mcmcxgl->mcmcxerr) { /* get the previous value of the property, if any */ - pofs = objgetp(ctx, objn, prop, (dattyp *)0); + pofs = objgetp(ctx, objn, prop, (dattyp *)nullptr); p = objofsp(objptr, pofs); - prop_was_set = (p != 0); + prop_was_set = (p != nullptr); /* start the undo record if we are keeping undo information */ if (undoctx && objuok(undoctx)) @@ -452,7 +452,7 @@ void objsetp(mcmcxdef *ctx, objnum objn, prpnum prop, dattyp typ, if (prpflg(p) & PRPFORG) { cmd = OBJUOVR; /* override original */ - p = (prpdef *)0; /* pretend it doesn't even exist */ + p = (prpdef *)nullptr; /* pretend it doesn't even exist */ } else cmd = OBJUCHG; /* change property */ } @@ -724,7 +724,7 @@ void obj1undo(mcmcxdef *mctx, objucxdef *undoctx) case OBJUOVR: objdelp(mctx, objn, prop, FALSE); /* delete the non-original value */ - pofs = objgetp(mctx, objn, prop, (dattyp *)0); /* get ignored prop */ + pofs = objgetp(mctx, objn, prop, (dattyp *)nullptr); /* get ignored prop */ objptr = (objdef *)mcmlck(mctx, objn); /* lock the object */ prpflg(objofsp(objptr, pofs)) &= ~PRPFIGN; /* no longer ignored */ mcmunlck(mctx, objn); /* unlock the object */ @@ -733,7 +733,7 @@ void obj1undo(mcmcxdef *mctx, objucxdef *undoctx) case OBJUCHG: memcpy(pr, p, (size_t)PRPHDRSIZ); p += PRPHDRSIZ; - objsetp(mctx, objn, prop, prptype(pr), (void *)p, (objucxdef *)0); + objsetp(mctx, objn, prop, prptype(pr), (void *)p, (objucxdef *)nullptr); break; case OBJUCLI: diff --git a/engines/glk/tads/tads2/os.cpp b/engines/glk/tads/tads2/os.cpp index ec94b681613..d4569c67c5f 100644 --- a/engines/glk/tads/tads2/os.cpp +++ b/engines/glk/tads/tads2/os.cpp @@ -31,7 +31,7 @@ osfildef *oserrop(const char *arg0) { char buf[128]; if (!os_locate("tadserr.msg", 11, arg0, buf, sizeof(buf))) - return((osfildef *)0); + return((osfildef *)nullptr); return(osfoprb(buf, OSFTERRS)); } diff --git a/engines/glk/tads/tads2/output.cpp b/engines/glk/tads/tads2/output.cpp index a56007c0656..fe24cb389d0 100644 --- a/engines/glk/tads/tads2/output.cpp +++ b/engines/glk/tads/tads2/output.cpp @@ -408,7 +408,7 @@ static void do_log_print(out_stream_info *stream, const char *str) VARUSED(stream); /* display to the log file */ - if (logfp != 0 && G_os_moremode) + if (logfp != nullptr && G_os_moremode) { os_fprintz(logfp, str); osfflush(logfp); @@ -568,312 +568,312 @@ struct amp_tbl_t { * table. */ static struct amp_tbl_t amp_tbl[] = { - { "AElig", 198, 0 }, - { "Aacute", 193, 0 }, - { "Abreve", 258, 0 }, - { "Acirc", 194, 0 }, - { "Agrave", 192, 0 }, - { "Alpha", 913, 0 }, - { "Aogon", 260, 0 }, - { "Aring", 197, 0 }, - { "Atilde", 195, 0 }, - { "Auml", 196, 0 }, - { "Beta", 914, 0 }, - { "Cacute", 262, 0 }, - { "Ccaron", 268, 0 }, - { "Ccedil", 199, 0 }, - { "Chi", 935, 0 }, - { "Dagger", 8225, 0 }, - { "Dcaron", 270, 0 }, - { "Delta", 916, 0 }, - { "Dstrok", 272, 0 }, - { "ETH", 208, 0 }, - { "Eacute", 201, 0 }, - { "Ecaron", 282, 0 }, - { "Ecirc", 202, 0 }, - { "Egrave", 200, 0 }, - { "Eogon", 280, 0 }, - { "Epsilon", 917, 0 }, - { "Eta", 919, 0 }, - { "Euml", 203, 0 }, - { "Gamma", 915, 0 }, - { "Iacute", 205, 0 }, - { "Icirc", 206, 0 }, - { "Igrave", 204, 0 }, - { "Iota", 921, 0 }, - { "Iuml", 207, 0 }, - { "Kappa", 922, 0 }, - { "Lacute", 313, 0 }, - { "Lambda", 923, 0 }, - { "Lcaron", 317, 0 }, - { "Lstrok", 321, 0 }, - { "Mu", 924, 0 }, - { "Nacute", 323, 0 }, - { "Ncaron", 327, 0 }, - { "Ntilde", 209, 0 }, - { "Nu", 925, 0 }, - { "OElig", 338, 0 }, - { "Oacute", 211, 0 }, - { "Ocirc", 212, 0 }, - { "Odblac", 336, 0 }, - { "Ograve", 210, 0 }, - { "Omega", 937, 0 }, - { "Omicron", 927, 0 }, - { "Oslash", 216, 0 }, - { "Otilde", 213, 0 }, - { "Ouml", 214, 0 }, - { "Phi", 934, 0 }, - { "Pi", 928, 0 }, - { "Prime", 8243, 0 }, - { "Psi", 936, 0 }, - { "Racute", 340, 0 }, - { "Rcaron", 344, 0 }, - { "Rho", 929, 0 }, - { "Sacute", 346, 0 }, - { "Scaron", 352, 0 }, - { "Scedil", 350, 0 }, - { "Sigma", 931, 0 }, - { "THORN", 222, 0 }, - { "Tau", 932, 0 }, - { "Tcaron", 356, 0 }, - { "Tcedil", 354, 0 }, - { "Theta", 920, 0 }, - { "Uacute", 218, 0 }, - { "Ucirc", 219, 0 }, - { "Udblac", 368, 0 }, - { "Ugrave", 217, 0 }, - { "Upsilon", 933, 0 }, - { "Uring", 366, 0 }, - { "Uuml", 220, 0 }, - { "Xi", 926, 0 }, - { "Yacute", 221, 0 }, - { "Yuml", 376, 0 }, - { "Zacute", 377, 0 }, - { "Zcaron", 381, 0 }, - { "Zdot", 379, 0 }, - { "Zeta", 918, 0 }, - { "aacute", 225, 0 }, - { "abreve", 259, 0 }, - { "acirc", 226, 0 }, - { "acute", 180, 0 }, - { "aelig", 230, 0 }, - { "agrave", 224, 0 }, - { "alefsym", 8501, 0 }, - { "alpha", 945, 0 }, - { "amp", '&', 0 }, - { "and", 8743, 0 }, - { "ang", 8736, 0 }, - { "aogon", 261, 0 }, - { "aring", 229, 0 }, - { "asymp", 8776, 0 }, - { "atilde", 227, 0 }, - { "auml", 228, 0 }, - { "bdquo", 8222, 0 }, - { "beta", 946, 0 }, - { "breve", 728, 0 }, - { "brvbar", 166, 0 }, - { "bull", 8226, 0 }, - { "cacute", 263, 0 }, - { "cap", 8745, 0 }, - { "caron", 711, 0 }, - { "ccaron", 269, 0 }, - { "ccedil", 231, 0 }, - { "cedil", 184, 0 }, - { "cent", 162, 0 }, - { "chi", 967, 0 }, - { "circ", 710, 0 }, - { "clubs", 9827, 0 }, - { "cong", 8773, 0 }, - { "copy", 169, 0 }, - { "crarr", 8629, 0 }, - { "cup", 8746, 0 }, - { "curren", 164, 0 }, - { "dArr", 8659, 0 }, - { "dagger", 8224, 0 }, - { "darr", 8595, 0 }, - { "dblac", 733, 0 }, - { "dcaron", 271, 0 }, - { "deg", 176, 0 }, - { "delta", 948, 0 }, - { "diams", 9830, 0 }, - { "divide", 247, 0 }, - { "dot", 729, 0 }, - { "dstrok", 273, 0 }, - { "eacute", 233, 0 }, - { "ecaron", 283, 0 }, - { "ecirc", 234, 0 }, - { "egrave", 232, 0 }, - { "emdash", 8212, 0 }, - { "empty", 8709, 0 }, - { "endash", 8211, 0 }, - { "eogon", 281, 0 }, - { "epsilon", 949, 0 }, - { "equiv", 8801, 0 }, - { "eta", 951, 0 }, - { "eth", 240, 0 }, - { "euml", 235, 0 }, - { "exist", 8707, 0 }, - { "fnof", 402, 0 }, - { "forall", 8704, 0 }, - { "frac12", 189, 0 }, - { "frac14", 188, 0 }, - { "frac34", 190, 0 }, - { "frasl", 8260, 0 }, - { "gamma", 947, 0 }, - { "ge", 8805, 0 }, - { "gt", '>', 0 }, - { "hArr", 8660, 0 }, - { "harr", 8596, 0 }, - { "hearts", 9829, 0 }, - { "hellip", 8230, 0 }, - { "iacute", 237, 0 }, - { "icirc", 238, 0 }, - { "iexcl", 161, 0 }, - { "igrave", 236, 0 }, - { "image", 8465, 0 }, - { "infin", 8734, 0 }, - { "int", 8747, 0 }, - { "iota", 953, 0 }, - { "iquest", 191, 0 }, - { "isin", 8712, 0 }, - { "iuml", 239, 0 }, - { "kappa", 954, 0 }, - { "lArr", 8656, 0 }, - { "lacute", 314, 0 }, - { "lambda", 955, 0 }, - { "lang", 9001, 0 }, - { "laquo", 171, 0 }, - { "larr", 8592, 0 }, - { "lcaron", 318, 0 }, - { "lceil", 8968, 0 }, - { "ldq", 8220, 0 }, - { "ldquo", 8220, 0 }, - { "le", 8804, 0 }, - { "lfloor", 8970, 0 }, - { "lowast", 8727, 0 }, - { "loz", 9674, 0 }, - { "lsaquo", 8249, 0 }, - { "lsq", 8216, 0 }, - { "lsquo", 8216, 0 }, - { "lstrok", 322, 0 }, - { "lt", '<', 0 }, - { "macr", 175, 0 }, - { "mdash", 8212, 0 }, - { "micro", 181, 0 }, - { "middot", 183, 0 }, - { "minus", 8722, 0 }, - { "mu", 956, 0 }, - { "nabla", 8711, 0 }, - { "nacute", 324, 0 }, - { "nbsp", QSPACE, 0 }, - { "ncaron", 328, 0 }, - { "ndash", 8211, 0 }, - { "ne", 8800, 0 }, - { "ni", 8715, 0 }, - { "not", 172, 0 }, - { "notin", 8713, 0 }, - { "nsub", 8836, 0 }, - { "ntilde", 241, 0 }, - { "nu", 957, 0 }, - { "oacute", 243, 0 }, - { "ocirc", 244, 0 }, - { "odblac", 337, 0 }, - { "oelig", 339, 0 }, - { "ogon", 731, 0 }, - { "ograve", 242, 0 }, - { "oline", 8254, 0 }, - { "omega", 969, 0 }, - { "omicron", 959, 0 }, - { "oplus", 8853, 0 }, - { "or", 8744, 0 }, - { "ordf", 170, 0 }, - { "ordm", 186, 0 }, - { "oslash", 248, 0 }, - { "otilde", 245, 0 }, - { "otimes", 8855, 0 }, - { "ouml", 246, 0 }, - { "para", 182, 0 }, - { "part", 8706, 0 }, - { "permil", 8240, 0 }, - { "perp", 8869, 0 }, - { "phi", 966, 0 }, - { "pi", 960, 0 }, - { "piv", 982, 0 }, - { "plusmn", 177, 0 }, - { "pound", 163, 0 }, - { "prime", 8242, 0 }, - { "prod", 8719, 0 }, - { "prop", 8733, 0 }, - { "psi", 968, 0 }, - { "quot", '"', 0 }, - { "rArr", 8658, 0 }, - { "racute", 341, 0 }, - { "radic", 8730, 0 }, - { "rang", 9002, 0 }, - { "raquo", 187, 0 }, - { "rarr", 8594, 0 }, - { "rcaron", 345, 0 }, - { "rceil", 8969, 0 }, - { "rdq", 8221, 0 }, - { "rdquo", 8221, 0 }, - { "real", 8476, 0 }, - { "reg", 174, 0 }, - { "rfloor", 8971, 0 }, - { "rho", 961, 0 }, - { "rsaquo", 8250, 0 }, - { "rsq", 8217, 0 }, - { "rsquo", 8217, 0 }, - { "sacute", 347, 0 }, - { "sbquo", 8218, 0 }, - { "scaron", 353, 0 }, - { "scedil", 351, 0 }, - { "sdot", 8901, 0 }, - { "sect", 167, 0 }, - { "shy", 173, 0 }, - { "sigma", 963, 0 }, - { "sigmaf", 962, 0 }, - { "sim", 8764, 0 }, - { "spades", 9824, 0 }, - { "sub", 8834, 0 }, - { "sube", 8838, 0 }, - { "sum", 8721, 0 }, - { "sup", 8835, 0 }, - { "sup1", 185, 0 }, - { "sup2", 178, 0 }, - { "sup3", 179, 0 }, - { "supe", 8839, 0 }, - { "szlig", 223, 0 }, - { "tau", 964, 0 }, - { "tcaron", 357, 0 }, - { "tcedil", 355, 0 }, - { "there4", 8756, 0 }, - { "theta", 952, 0 }, - { "thetasym", 977, 0 }, - { "thorn", 254, 0 }, - { "thorn", 254, 0 }, - { "tilde", 732, 0 }, - { "times", 215, 0 }, - { "trade", 8482, 0 }, - { "uArr", 8657, 0 }, - { "uacute", 250, 0 }, - { "uarr", 8593, 0 }, - { "ucirc", 251, 0 }, - { "udblac", 369, 0 }, - { "ugrave", 249, 0 }, - { "uml", 168, 0 }, - { "upsih", 978, 0 }, - { "upsilon", 965, 0 }, - { "uring", 367, 0 }, - { "uuml", 252, 0 }, - { "weierp", 8472, 0 }, - { "xi", 958, 0 }, - { "yacute", 253, 0 }, - { "yen", 165, 0 }, - { "yuml", 255, 0 }, - { "zacute", 378, 0 }, - { "zcaron", 382, 0 }, - { "zdot", 380, 0 }, - { "zeta", 950, 0 } + { "AElig", 198, nullptr }, + { "Aacute", 193, nullptr }, + { "Abreve", 258, nullptr }, + { "Acirc", 194, nullptr }, + { "Agrave", 192, nullptr }, + { "Alpha", 913, nullptr }, + { "Aogon", 260, nullptr }, + { "Aring", 197, nullptr }, + { "Atilde", 195, nullptr }, + { "Auml", 196, nullptr }, + { "Beta", 914, nullptr }, + { "Cacute", 262, nullptr }, + { "Ccaron", 268, nullptr }, + { "Ccedil", 199, nullptr }, + { "Chi", 935, nullptr }, + { "Dagger", 8225, nullptr }, + { "Dcaron", 270, nullptr }, + { "Delta", 916, nullptr }, + { "Dstrok", 272, nullptr }, + { "ETH", 208, nullptr }, + { "Eacute", 201, nullptr }, + { "Ecaron", 282, nullptr }, + { "Ecirc", 202, nullptr }, + { "Egrave", 200, nullptr }, + { "Eogon", 280, nullptr }, + { "Epsilon", 917, nullptr }, + { "Eta", 919, nullptr }, + { "Euml", 203, nullptr }, + { "Gamma", 915, nullptr }, + { "Iacute", 205, nullptr }, + { "Icirc", 206, nullptr }, + { "Igrave", 204, nullptr }, + { "Iota", 921, nullptr }, + { "Iuml", 207, nullptr }, + { "Kappa", 922, nullptr }, + { "Lacute", 313, nullptr }, + { "Lambda", 923, nullptr }, + { "Lcaron", 317, nullptr }, + { "Lstrok", 321, nullptr }, + { "Mu", 924, nullptr }, + { "Nacute", 323, nullptr }, + { "Ncaron", 327, nullptr }, + { "Ntilde", 209, nullptr }, + { "Nu", 925, nullptr }, + { "OElig", 338, nullptr }, + { "Oacute", 211, nullptr }, + { "Ocirc", 212, nullptr }, + { "Odblac", 336, nullptr }, + { "Ograve", 210, nullptr }, + { "Omega", 937, nullptr }, + { "Omicron", 927, nullptr }, + { "Oslash", 216, nullptr }, + { "Otilde", 213, nullptr }, + { "Ouml", 214, nullptr }, + { "Phi", 934, nullptr }, + { "Pi", 928, nullptr }, + { "Prime", 8243, nullptr }, + { "Psi", 936, nullptr }, + { "Racute", 340, nullptr }, + { "Rcaron", 344, nullptr }, + { "Rho", 929, nullptr }, + { "Sacute", 346, nullptr }, + { "Scaron", 352, nullptr }, + { "Scedil", 350, nullptr }, + { "Sigma", 931, nullptr }, + { "THORN", 222, nullptr }, + { "Tau", 932, nullptr }, + { "Tcaron", 356, nullptr }, + { "Tcedil", 354, nullptr }, + { "Theta", 920, nullptr }, + { "Uacute", 218, nullptr }, + { "Ucirc", 219, nullptr }, + { "Udblac", 368, nullptr }, + { "Ugrave", 217, nullptr }, + { "Upsilon", 933, nullptr }, + { "Uring", 366, nullptr }, + { "Uuml", 220, nullptr }, + { "Xi", 926, nullptr }, + { "Yacute", 221, nullptr }, + { "Yuml", 376, nullptr }, + { "Zacute", 377, nullptr }, + { "Zcaron", 381, nullptr }, + { "Zdot", 379, nullptr }, + { "Zeta", 918, nullptr }, + { "aacute", 225, nullptr }, + { "abreve", 259, nullptr }, + { "acirc", 226, nullptr }, + { "acute", 180, nullptr }, + { "aelig", 230, nullptr }, + { "agrave", 224, nullptr }, + { "alefsym", 8501, nullptr }, + { "alpha", 945, nullptr }, + { "amp", '&', nullptr }, + { "and", 8743, nullptr }, + { "ang", 8736, nullptr }, + { "aogon", 261, nullptr }, + { "aring", 229, nullptr }, + { "asymp", 8776, nullptr }, + { "atilde", 227, nullptr }, + { "auml", 228, nullptr }, + { "bdquo", 8222, nullptr }, + { "beta", 946, nullptr }, + { "breve", 728, nullptr }, + { "brvbar", 166, nullptr }, + { "bull", 8226, nullptr }, + { "cacute", 263, nullptr }, + { "cap", 8745, nullptr }, + { "caron", 711, nullptr }, + { "ccaron", 269, nullptr }, + { "ccedil", 231, nullptr }, + { "cedil", 184, nullptr }, + { "cent", 162, nullptr }, + { "chi", 967, nullptr }, + { "circ", 710, nullptr }, + { "clubs", 9827, nullptr }, + { "cong", 8773, nullptr }, + { "copy", 169, nullptr }, + { "crarr", 8629, nullptr }, + { "cup", 8746, nullptr }, + { "curren", 164, nullptr }, + { "dArr", 8659, nullptr }, + { "dagger", 8224, nullptr }, + { "darr", 8595, nullptr }, + { "dblac", 733, nullptr }, + { "dcaron", 271, nullptr }, + { "deg", 176, nullptr }, + { "delta", 948, nullptr }, + { "diams", 9830, nullptr }, + { "divide", 247, nullptr }, + { "dot", 729, nullptr }, + { "dstrok", 273, nullptr }, + { "eacute", 233, nullptr }, + { "ecaron", 283, nullptr }, + { "ecirc", 234, nullptr }, + { "egrave", 232, nullptr }, + { "emdash", 8212, nullptr }, + { "empty", 8709, nullptr }, + { "endash", 8211, nullptr }, + { "eogon", 281, nullptr }, + { "epsilon", 949, nullptr }, + { "equiv", 8801, nullptr }, + { "eta", 951, nullptr }, + { "eth", 240, nullptr }, + { "euml", 235, nullptr }, + { "exist", 8707, nullptr }, + { "fnof", 402, nullptr }, + { "forall", 8704, nullptr }, + { "frac12", 189, nullptr }, + { "frac14", 188, nullptr }, + { "frac34", 190, nullptr }, + { "frasl", 8260, nullptr }, + { "gamma", 947, nullptr }, + { "ge", 8805, nullptr }, + { "gt", '>', nullptr }, + { "hArr", 8660, nullptr }, + { "harr", 8596, nullptr }, + { "hearts", 9829, nullptr }, + { "hellip", 8230, nullptr }, + { "iacute", 237, nullptr }, + { "icirc", 238, nullptr }, + { "iexcl", 161, nullptr }, + { "igrave", 236, nullptr }, + { "image", 8465, nullptr }, + { "infin", 8734, nullptr }, + { "int", 8747, nullptr }, + { "iota", 953, nullptr }, + { "iquest", 191, nullptr }, + { "isin", 8712, nullptr }, + { "iuml", 239, nullptr }, + { "kappa", 954, nullptr }, + { "lArr", 8656, nullptr }, + { "lacute", 314, nullptr }, + { "lambda", 955, nullptr }, + { "lang", 9001, nullptr }, + { "laquo", 171, nullptr }, + { "larr", 8592, nullptr }, + { "lcaron", 318, nullptr }, + { "lceil", 8968, nullptr }, + { "ldq", 8220, nullptr }, + { "ldquo", 8220, nullptr }, + { "le", 8804, nullptr }, + { "lfloor", 8970, nullptr }, + { "lowast", 8727, nullptr }, + { "loz", 9674, nullptr }, + { "lsaquo", 8249, nullptr }, + { "lsq", 8216, nullptr }, + { "lsquo", 8216, nullptr }, + { "lstrok", 322, nullptr }, + { "lt", '<', nullptr }, + { "macr", 175, nullptr }, + { "mdash", 8212, nullptr }, + { "micro", 181, nullptr }, + { "middot", 183, nullptr }, + { "minus", 8722, nullptr }, + { "mu", 956, nullptr }, + { "nabla", 8711, nullptr }, + { "nacute", 324, nullptr }, + { "nbsp", QSPACE, nullptr }, + { "ncaron", 328, nullptr }, + { "ndash", 8211, nullptr }, + { "ne", 8800, nullptr }, + { "ni", 8715, nullptr }, + { "not", 172, nullptr }, + { "notin", 8713, nullptr }, + { "nsub", 8836, nullptr }, + { "ntilde", 241, nullptr }, + { "nu", 957, nullptr }, + { "oacute", 243, nullptr }, + { "ocirc", 244, nullptr }, + { "odblac", 337, nullptr }, + { "oelig", 339, nullptr }, + { "ogon", 731, nullptr }, + { "ograve", 242, nullptr }, + { "oline", 8254, nullptr }, + { "omega", 969, nullptr }, + { "omicron", 959, nullptr }, + { "oplus", 8853, nullptr }, + { "or", 8744, nullptr }, + { "ordf", 170, nullptr }, + { "ordm", 186, nullptr }, + { "oslash", 248, nullptr }, + { "otilde", 245, nullptr }, + { "otimes", 8855, nullptr }, + { "ouml", 246, nullptr }, + { "para", 182, nullptr }, + { "part", 8706, nullptr }, + { "permil", 8240, nullptr }, + { "perp", 8869, nullptr }, + { "phi", 966, nullptr }, + { "pi", 960, nullptr }, + { "piv", 982, nullptr }, + { "plusmn", 177, nullptr }, + { "pound", 163, nullptr }, + { "prime", 8242, nullptr }, + { "prod", 8719, nullptr }, + { "prop", 8733, nullptr }, + { "psi", 968, nullptr }, + { "quot", '"', nullptr }, + { "rArr", 8658, nullptr }, + { "racute", 341, nullptr }, + { "radic", 8730, nullptr }, + { "rang", 9002, nullptr }, + { "raquo", 187, nullptr }, + { "rarr", 8594, nullptr }, + { "rcaron", 345, nullptr }, + { "rceil", 8969, nullptr }, + { "rdq", 8221, nullptr }, + { "rdquo", 8221, nullptr }, + { "real", 8476, nullptr }, + { "reg", 174, nullptr }, + { "rfloor", 8971, nullptr }, + { "rho", 961, nullptr }, + { "rsaquo", 8250, nullptr }, + { "rsq", 8217, nullptr }, + { "rsquo", 8217, nullptr }, + { "sacute", 347, nullptr }, + { "sbquo", 8218, nullptr }, + { "scaron", 353, nullptr }, + { "scedil", 351, nullptr }, + { "sdot", 8901, nullptr }, + { "sect", 167, nullptr }, + { "shy", 173, nullptr }, + { "sigma", 963, nullptr }, + { "sigmaf", 962, nullptr }, + { "sim", 8764, nullptr }, + { "spades", 9824, nullptr }, + { "sub", 8834, nullptr }, + { "sube", 8838, nullptr }, + { "sum", 8721, nullptr }, + { "sup", 8835, nullptr }, + { "sup1", 185, nullptr }, + { "sup2", 178, nullptr }, + { "sup3", 179, nullptr }, + { "supe", 8839, nullptr }, + { "szlig", 223, nullptr }, + { "tau", 964, nullptr }, + { "tcaron", 357, nullptr }, + { "tcedil", 355, nullptr }, + { "there4", 8756, nullptr }, + { "theta", 952, nullptr }, + { "thetasym", 977, nullptr }, + { "thorn", 254, nullptr }, + { "thorn", 254, nullptr }, + { "tilde", 732, nullptr }, + { "times", 215, nullptr }, + { "trade", 8482, nullptr }, + { "uArr", 8657, nullptr }, + { "uacute", 250, nullptr }, + { "uarr", 8593, nullptr }, + { "ucirc", 251, nullptr }, + { "udblac", 369, nullptr }, + { "ugrave", 249, nullptr }, + { "uml", 168, nullptr }, + { "upsih", 978, nullptr }, + { "upsilon", 965, nullptr }, + { "uring", 367, nullptr }, + { "uuml", 252, nullptr }, + { "weierp", 8472, nullptr }, + { "xi", 958, nullptr }, + { "yacute", 253, nullptr }, + { "yen", 165, nullptr }, + { "yuml", 255, nullptr }, + { "zacute", 378, nullptr }, + { "zcaron", 382, nullptr }, + { "zdot", 380, nullptr }, + { "zeta", 950, nullptr } }; @@ -964,7 +964,7 @@ static void t_outline(out_stream_info *stream, int nl, * Skip the MORE prompt if this stream doesn't use it. */ if (stream->use_more_mode - && scrfp == 0 + && scrfp == nullptr && G_os_moremode && nl != 0 && nl != 4 && stream->linecnt++ >= G_os_pagelength) @@ -980,7 +980,7 @@ static void t_outline(out_stream_info *stream, int nl, for (i = 0, dst = buf ; txt[i] != '\0' ; ++i) { /* if the attribute is changing, notify osifc */ - if (attr != 0 && attr[i] != stream->os_attr) + if (attr != nullptr && attr[i] != stream->os_attr) { /* flush the preceding text */ if (dst != buf) @@ -1089,7 +1089,7 @@ static void outflushn_stream(out_stream_info *stream, int nl) case 3: case 4: /* no newline - just flush out what we have with no suffix */ - suffix = 0; + suffix = nullptr; break; case 1: @@ -1110,7 +1110,7 @@ static void outflushn_stream(out_stream_info *stream, int nl) else { /* don't add a newline */ - suffix = 0; + suffix = nullptr; } break; @@ -1141,13 +1141,13 @@ static void outflushn_stream(out_stream_info *stream, int nl) &stream->attrbuf[stream->preview]); /* write the suffix, if any */ - if (suffix != 0) - t_outline(stream, 0, suffix, 0); + if (suffix != nullptr) + t_outline(stream, 0, suffix, nullptr); } /* generate an HTML line break if necessary */ if (nl == 1 && stream->html_mode && stream->html_target) - t_outline(stream, 0, "
", 0); + t_outline(stream, 0, "
", nullptr); if (nl == 0) { @@ -1235,7 +1235,7 @@ static void outblank_stream(out_stream_info *stream) outstring_stream(stream, "
"); /* write out the newline */ - t_outline(stream, 1, "\n", 0); + t_outline(stream, 1, "\n", nullptr); } /* ------------------------------------------------------------------------ */ @@ -1665,7 +1665,7 @@ static void outchar_html_stream(out_stream_info *stream, * expansion; otherwise, use the default expansion. */ if (ampptr >= amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) - || ampptr->expan == 0) + || ampptr->expan == nullptr) { char xlat_buf[50]; @@ -1744,7 +1744,7 @@ static char nextout_copy(const char **s, size_t *slen, char prv, out_stream_info *stream) { /* if there's a stream, write the previous character to the stream */ - if (stream != 0) + if (stream != nullptr) outchar_stream(stream, prv); /* return the next character */ @@ -1818,7 +1818,7 @@ static int outformatlen_stream(out_stream_info *stream, int done = 0; char fmsbuf[40]; /* space for constructing translation string */ uint fmslen; - char *f = 0; + char *f = nullptr; char *f1; int infmt = 0; @@ -2422,7 +2422,7 @@ static int outformatlen_stream(out_stream_info *stream, char tagbuf[50]; int is_end_tag; c = read_tag(tagbuf, sizeof(tagbuf), &is_end_tag, - &s, &slen, 0); + &s, &slen, nullptr); /* * Check to see if we recognize the tag. We only @@ -2811,7 +2811,7 @@ static char out_parse_entity(char *outbuf, size_t outbuf_size, const char **sp, /* if we've converged, look no further */ if (lo > hi || lo >= sizeof(amp_tbl)/sizeof(amp_tbl[0])) { - ampptr = 0; + ampptr = nullptr; break; } @@ -2832,7 +2832,7 @@ static char out_parse_entity(char *outbuf, size_t outbuf_size, const char **sp, if (cur == hi && cur == 0) { /* we've failed to find it */ - ampptr = 0; + ampptr = nullptr; break; } @@ -2852,7 +2852,7 @@ static char out_parse_entity(char *outbuf, size_t outbuf_size, const char **sp, /* name ended with semicolon - skip the semicolon */ c = nextout(sp, slenp); } - else if (ampptr != 0) + else if (ampptr != nullptr) { int skipcnt; @@ -2863,13 +2863,13 @@ static char out_parse_entity(char *outbuf, size_t outbuf_size, const char **sp, } /* if we found the entry, write out the character */ - if (ampptr != 0) + if (ampptr != nullptr) { /* * if this one has an external mapping table entry, use the mapping * table entry; otherwise, use the default OS routine mapping */ - if (ampptr->expan != 0) + if (ampptr->expan != nullptr) { /* * we have an explicit expansion from the mapping table file - @@ -3072,7 +3072,7 @@ int outformatlen(const char *s, uint slen) { ret = outformatlen_stream(&G_std_disp, orig_s, orig_slen); /* if there's a log file, write to the log file as well */ - if (logfp != 0) + if (logfp != nullptr) { outformatlen_stream(&G_log_disp, orig_s, orig_slen); osfflush(logfp); @@ -3104,7 +3104,7 @@ void outblank() outblank_stream(&G_std_disp); /* if we're logging, generate the newline to the log file as well */ - if (logfp != 0) + if (logfp != nullptr) { outblank_stream(&G_log_disp); osfflush(logfp); @@ -3165,7 +3165,7 @@ int tiologopn(tiocxdef *ctx, char *fn) G_log_disp.html_mode = G_std_disp.html_mode; /* return 0 on success, non-zero on failure */ - return (logfp == 0); + return (logfp == nullptr); } /* @@ -3174,7 +3174,7 @@ int tiologopn(tiocxdef *ctx, char *fn) int tiologcls(tiocxdef *ctx) { /* if we have a file, close it */ - if (logfp != 0) + if (logfp != nullptr) { /* close the handle */ osfcls(logfp); @@ -3183,7 +3183,7 @@ int tiologcls(tiocxdef *ctx) os_settype(logfname, OSFTLOG); /* forget about our log file handle */ - logfp = 0; + logfp = nullptr; } /* success */ @@ -3206,7 +3206,7 @@ int tiologcls(tiocxdef *ctx) void out_logfile_print(const char *txt, int nl) { /* if there's no log file, there's nothing to do */ - if (logfp == 0) + if (logfp == nullptr) return; /* add the text */ @@ -3450,7 +3450,7 @@ void outflushn(int nl) outflushn_stream(&G_std_disp, nl); /* flush the log stream, if we have an open log file */ - if (logfp != 0) + if (logfp != nullptr) { outflushn_stream(&G_log_disp, nl); osfflush(logfp); diff --git a/engines/glk/tads/tads2/play.cpp b/engines/glk/tads/tads2/play.cpp index 1fa9a08723f..abeae05acd4 100644 --- a/engines/glk/tads/tads2/play.cpp +++ b/engines/glk/tads/tads2/play.cpp @@ -96,7 +96,7 @@ startover: * a game directly from the command line AND there's an * initRestore function defined. */ - if (restore_fname == 0 || voc->voccxinitrestore == MCMONINV) + if (restore_fname == nullptr || voc->voccxinitrestore == MCMONINV) { ERRBEGIN(ec) { @@ -134,7 +134,7 @@ startover: restore_fname = filbuf; /* check for a file to restore */ - if (restore_fname != 0) + if (restore_fname != nullptr) { /* * Check to see if the game file supports the initRestore @@ -197,7 +197,7 @@ startover: } /* forget the saved game name, in case we restore */ - restore_fname = 0; + restore_fname = nullptr; } /* clear out the redo command buffer */ diff --git a/engines/glk/tads/tads2/qa_scriptor.cpp b/engines/glk/tads/tads2/qa_scriptor.cpp index 794b0ffb060..e436bab356b 100644 --- a/engines/glk/tads/tads2/qa_scriptor.cpp +++ b/engines/glk/tads/tads2/qa_scriptor.cpp @@ -33,12 +33,12 @@ namespace TADS2 { /* * Globals for the script reader */ -osfildef *scrfp = (osfildef *)0; /* script file */ +osfildef *scrfp = (osfildef *)nullptr; /* script file */ int scrquiet = 0; /* flag: true ==> script is NOT shown as read */ int qasopn(char *scrnam, int quiet) { if (scrfp) return 1; /* already reading from script */ - if ((scrfp = osfoprt(scrnam, OSFTCMD)) == 0) return 1; + if ((scrfp = osfoprt(scrnam, OSFTCMD)) == nullptr) return 1; scrquiet = quiet; return 0; } @@ -48,15 +48,15 @@ void qasclose() { if (scrfp) { osfcls(scrfp); - scrfp = 0; /* no more script file */ + scrfp = nullptr; /* no more script file */ scrquiet = 0; } } char *qasgets(char *buf, int bufl) { /* shouldn't be here at all if there's no script file */ - if (scrfp == 0) - return 0; + if (scrfp == nullptr) + return nullptr; /* update status line */ runstat(); @@ -79,7 +79,7 @@ char *qasgets(char *buf, int bufl) { { /* end of file: close the script and return eof */ qasclose(); - return 0; + return nullptr; } /* if the line started with '>', strip '\n' and return line */ @@ -108,7 +108,7 @@ char *qasgets(char *buf, int bufl) { } else if ((int)c == EOF) { /* end of file - close the script and return eof */ qasclose(); - return 0; + return nullptr; } } } diff --git a/engines/glk/tads/tads2/regex.cpp b/engines/glk/tads/tads2/regex.cpp index d94c4a454ec..37770a1c0b7 100644 --- a/engines/glk/tads/tads2/regex.cpp +++ b/engines/glk/tads/tads2/regex.cpp @@ -150,7 +150,7 @@ void re_init(re_context *ctx, errcxdef *errctx) ctx->errctx = errctx; /* no tuple array yet */ - ctx->tuple_arr = 0; + ctx->tuple_arr = nullptr; ctx->tuples_alloc = 0; /* clear states */ @@ -160,7 +160,7 @@ void re_init(re_context *ctx, errcxdef *errctx) ctx->cur_group = 0; /* no string buffer yet */ - ctx->strbuf = 0; + ctx->strbuf = nullptr; } /* ------------------------------------------------------------------------ */ @@ -174,10 +174,10 @@ static void re_reset(re_context *ctx) /* delete any range tables we've allocated */ for (i = 0 ; i < ctx->next_state ; ++i) { - if (ctx->tuple_arr[i].char_range != 0) + if (ctx->tuple_arr[i].char_range != nullptr) { mchfre(ctx->tuple_arr[i].char_range); - ctx->tuple_arr[i].char_range = 0; + ctx->tuple_arr[i].char_range = nullptr; } } @@ -199,17 +199,17 @@ void re_delete(re_context *ctx) re_reset(ctx); /* if we've allocated an array, delete it */ - if (ctx->tuple_arr != 0) + if (ctx->tuple_arr != nullptr) { mchfre(ctx->tuple_arr); - ctx->tuple_arr = 0; + ctx->tuple_arr = nullptr; } /* if we allocated a string buffer, delete it */ - if (ctx->strbuf != 0) + if (ctx->strbuf != nullptr) { mchfre(ctx->strbuf); - ctx->strbuf = 0; + ctx->strbuf = nullptr; } } @@ -266,7 +266,7 @@ static re_state_id re_alloc_state(re_context *ctx) ctx->tuple_arr[ctx->next_state].next_state_2 = RE_STATE_INVALID; ctx->tuple_arr[ctx->next_state].ch = RE_EPSILON; ctx->tuple_arr[ctx->next_state].flags = 0; - ctx->tuple_arr[ctx->next_state].char_range = 0; + ctx->tuple_arr[ctx->next_state].char_range = nullptr; /* return the new state's ID */ return ctx->next_state++; @@ -1181,7 +1181,7 @@ static int re_match(re_context *ctx, const char *entire_str, * if this register isn't defined, there's nothing * to match, so fail */ - if (group_reg->start_ofs == 0 || group_reg->end_ofs == 0) + if (group_reg->start_ofs == nullptr || group_reg->end_ofs == nullptr) return -1; /* calculate the length of the register value */ @@ -1492,14 +1492,14 @@ static void re_save_search_str(re_context *ctx, const char *str, size_t len) } /* if the current buffer isn't big enough, allocate a new one */ - if (ctx->strbuf == 0 || ctx->strbufsiz < len) + if (ctx->strbuf == nullptr || ctx->strbufsiz < len) { /* * free any previous buffer - its contents are no longer * important, since we're about to overwrite it with a new * string */ - if (ctx->strbuf != 0) + if (ctx->strbuf != nullptr) mchfre(ctx->strbuf); /* diff --git a/engines/glk/tads/tads2/run.cpp b/engines/glk/tads/tads2/run.cpp index dd3b0491ab5..a1b4e2cab3e 100644 --- a/engines/glk/tads/tads2/run.cpp +++ b/engines/glk/tads/tads2/run.cpp @@ -79,7 +79,7 @@ static void run_new(runcxdef *ctx, uchar *noreg *codepp, /* set up its vocabulary, inheriting from the class */ if (sccnt) - supivoc1((struct supcxdef *)0, ctx->runcxvoc, + supivoc1((struct supcxdef *)nullptr, ctx->runcxvoc, vocinh(ctx->runcxvoc, objn), objn, TRUE, VOCFNEW); /* run the constructor */ @@ -117,7 +117,7 @@ static void run_delete(runcxdef *ctx, uchar *noreg *codepp, /* make sure it was allocated with "new" */ voci = vocinh(vctx, objn); - if (voci == 0 || !(voci->vociflg & VOCIFNEW)) + if (voci == nullptr || !(voci->vociflg & VOCIFNEW)) runsig(ctx, ERR_BADDEL); /* run the destructor */ @@ -610,7 +610,7 @@ uchar *runfind(uchar *lst, runsdef *item) } curlen = datsiz(*lst, lst + 1) + 1; } - return((uchar *)0); + return((uchar *)nullptr); } /* add values */ @@ -741,7 +741,7 @@ int runsub(runcxdef *ctx, runsdef *val, runsdef *val2, uint below) val->runsv.runsvstr = ctx->runcxhp; ctx->runcxhp = dst; } - else if ((sublist = runfind(val->runsv.runsvstr, val2)) != 0) + else if ((sublist = runfind(val->runsv.runsvstr, val2)) != nullptr) { subsize = datsiz(*sublist, sublist + 1) + 1; listsize = runsiz(val); @@ -779,7 +779,7 @@ static uint runcpsav(runcxdef *ctx, uchar *noreg *cp, objnum obj, prpnum prop) ofs = *cp - mcmobjptr(ctx->runcxmem, (mcmon)obj); /* clear the pointer so the caller knows the object is unlocked */ - *cp = 0; + *cp = nullptr; /* unlock the object, and return the derived offset */ mcmunlck(ctx->runcxmem, (mcmon)obj); diff --git a/engines/glk/tads/tads2/runtime_driver.cpp b/engines/glk/tads/tads2/runtime_driver.cpp index dc5c827de5e..ae049c33827 100644 --- a/engines/glk/tads/tads2/runtime_driver.cpp +++ b/engines/glk/tads/tads2/runtime_driver.cpp @@ -139,7 +139,7 @@ struct runsdef *dbgfrfind(dbgcxdef *ctx, objnum frobj, uint frofs) VARUSED(frobj); VARUSED(frofs); errsig(ctx->dbgcxerr, ERR_INACTFR); - return 0; + return nullptr; } void dbgss(struct dbgcxdef *ctx, uint ofs, int instr, int err, @@ -214,7 +214,7 @@ static void trdusage(errcxdef *ec) * hard-coded text in the message identifying the app */ first = ERR_TRUS1; - if (ec->errcxappctx != 0 && ec->errcxappctx->usage_app_name != 0) + if (ec->errcxappctx != nullptr && ec->errcxappctx->usage_app_name != nullptr) { char buf[128]; char buf2[128]; @@ -256,16 +256,16 @@ static void trdusage_s(errcxdef *ec) static void trdmain1(errcxdef *ec, int argc, char *argv[], appctxdef *appctx, const char *save_ext) { - osfildef *swapfp = (osfildef *)0; + osfildef *swapfp = (osfildef *)nullptr; runcxdef runctx; bifcxdef bifctx; voccxdef vocctx; void (*bif[100])(struct bifcxdef *, int); - mcmcxdef *mctx = 0; - mcmcx1def *globalctx = 0; + mcmcxdef *mctx = nullptr; + mcmcx1def *globalctx = nullptr; dbgcxdef dbg; supcxdef supctx; - char *swapname = 0; + char *swapname = nullptr; char swapbuf[OSFNMAX]; char **argp; char *arg; @@ -282,7 +282,7 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], char inbuf[OSFNMAX]; ulong cachelimit = 0xffffffff; ushort undosiz = TRD_UNDOSIZ; /* default undo context size 16k */ - objucxdef *undoptr = 0; + objucxdef *undoptr = nullptr; uint flags; /* flags used to write the file we're reading */ objnum preinit; /* preinit object, if we need to execute it */ uint heapsiz = TRD_HEAPSIZ; @@ -295,8 +295,8 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], ulong totsize; extern voccxdef *main_voc_ctx; int safety_read, safety_write; /* file I/O safety level */ - char *restore_file = 0; /* .SAV file to restore */ - char *charmap = 0; /* character map file */ + char *restore_file = nullptr; /* .SAV file to restore */ + char *charmap = nullptr; /* character map file */ int charmap_none; /* explicitly do not use a character set */ int doublespace = TRUE; /* formatter double-space setting */ @@ -396,7 +396,7 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], trdusage_s(ec); /* tell the host system about the setting */ - if (appctx != 0 && appctx->set_io_safety_level != 0) + if (appctx != nullptr && appctx->set_io_safety_level != nullptr) (*appctx->set_io_safety_level) (appctx->io_safety_level_ctx, safety_read, safety_write); @@ -455,7 +455,7 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], } /* presume we won't take the .gam from the application executable */ - exefile = 0; + exefile = nullptr; /* get input name argument, and make sure it's the last argument */ if (i == argc) @@ -476,14 +476,14 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], */ /* presume we won't find a game attached to the executable file */ - infile = 0; + infile = nullptr; use_exe = FALSE; /* * see if we have a saved game to restore, and it specifies the * GAM file that saved it */ - if (restore_file != 0) + if (restore_file != nullptr) { /* try getting the game name from the restore file */ if (fiorso_getgame(restore_file, inbuf, sizeof(inbuf))) @@ -497,12 +497,12 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], * it that didn't work, try to read from os-dependent part of * program being executed */ - if (infile == 0) + if (infile == nullptr) { /* try opening the executable file */ exefile = (argv && argv[0] ? argv[0] : "TRX"); fp = os_exeseek(exefile, "TGAM"); - if (fp != 0) + if (fp != nullptr) { /* see if there's a game file attached to the executable */ curpos = osfpos(fp); @@ -520,13 +520,13 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], * if we didn't find a game in the executable, try the host * system callback */ - if (infile == 0 && !use_exe) + if (infile == nullptr && !use_exe) { /* * ask the host system callback what to do - if we don't * have a host system callback, or the callback */ - if (appctx != 0 && appctx->get_game_name != 0) + if (appctx != nullptr && appctx->get_game_name != nullptr) { /* call the host system callback */ if ((*appctx->get_game_name)(appctx->get_game_name_ctx, @@ -583,8 +583,8 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], if (swapena && swapsize) { swapfp = os_create_tempfile(swapname, swapbuf); - if (swapname == 0) swapname = swapbuf; - if (swapfp == 0) errsig(ec, ERR_OPSWAP); + if (swapname == nullptr) swapname = swapbuf; + if (swapfp == nullptr) errsig(ec, ERR_OPSWAP); } /* load the character map */ @@ -598,14 +598,14 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], /* initialize cache manager context */ globalctx = mcmini(cachelimit, 128, swapsize, swapfp, swapname, ec); mctx = mcmcini(globalctx, 128, fioldobj, &fiolctx, - objrevert, (void *)0); + objrevert, (void *)nullptr); mctx->mcmcxrvc = mctx; /* set up an undo context */ if (undosiz) undoptr = objuini(mctx, undosiz, vocdundo, vocdusz, &vocctx); else - undoptr = (objucxdef *)0; + undoptr = (objucxdef *)nullptr; /* set up vocabulary context */ vocini(&vocctx, ec, mctx, &runctx, undoptr, 100, 100, 200); @@ -625,9 +625,9 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], myheap = mchalo(ec, heapsiz, "runtime heap"); /* get the absolute path for the input file */ - if (infile != 0) + if (infile != nullptr) os_get_abs_filename(infile_abs, sizeof(infile_abs), infile); - else if (exefile != 0) + else if (exefile != nullptr) os_get_abs_filename(infile_abs, sizeof(infile_abs), exefile); else infile_abs[0] = '\0'; @@ -646,38 +646,38 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], runctx.runcxundo = undoptr; runctx.runcxbcx = &bifctx; runctx.runcxbi = bif; - runctx.runcxtio = (tiocxdef *)0; + runctx.runcxtio = (tiocxdef *)nullptr; runctx.runcxdbg = &dbg; runctx.runcxvoc = &vocctx; runctx.runcxdmd = supcont; runctx.runcxdmc = &supctx; - runctx.runcxext = 0; + runctx.runcxext = nullptr; runctx.runcxgamename = infile; runctx.runcxgamepath = infile_path; /* set up setup context */ supctx.supcxerr = ec; supctx.supcxmem = mctx; - supctx.supcxtab = (tokthdef *)0; - supctx.supcxbuf = (uchar *)0; + supctx.supcxtab = (tokthdef *)nullptr; + supctx.supcxbuf = (uchar *)nullptr; supctx.supcxlen = 0; supctx.supcxvoc = &vocctx; supctx.supcxrun = &runctx; /* set up debug context */ - dbg.dbgcxtio = (tiocxdef *)0; + dbg.dbgcxtio = (tiocxdef *)nullptr; dbg.dbgcxmem = mctx; dbg.dbgcxerr = ec; - dbg.dbgcxtab = (tokthdef *)0; + dbg.dbgcxtab = (tokthdef *)nullptr; dbg.dbgcxfcn = 0; dbg.dbgcxdep = 0; dbg.dbgcxflg = 0; - dbg.dbgcxlin = (lindef *)0; /* no line sources yet */ + dbg.dbgcxlin = (lindef *)nullptr; /* no line sources yet */ /* set up built-in function context */ bifctx.bifcxerr = ec; bifctx.bifcxrun = &runctx; - bifctx.bifcxtio = (tiocxdef *)0; + bifctx.bifcxtio = (tiocxdef *)nullptr; bifctx.bifcxrnd = 0; bifctx.bifcxrndset = FALSE; bifctx.bifcxappctx = appctx; @@ -692,15 +692,15 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], supbif(&supctx, bif, (int)(sizeof(bif)/sizeof(bif[0]))); /* set up status line hack */ - runistat(&vocctx, &runctx, (tiocxdef *)0); + runistat(&vocctx, &runctx, (tiocxdef *)nullptr); /* turn on the "busy" cursor before loading */ os_csr_busy(TRUE); /* read the game from the binary file */ - fiord(mctx, &vocctx, (struct tokcxdef *)0, + fiord(mctx, &vocctx, (struct tokcxdef *)nullptr, infile, exefile, &fiolctx, &preinit, &flags, - (struct tokpdef *)0, (uchar **)0, (uint *)0, (uint *)0, + (struct tokpdef *)nullptr, (uchar **)nullptr, (uint *)nullptr, (uint *)nullptr, (preload ? 2 : 0), appctx, argv[0]); loadopen = TRUE; @@ -708,7 +708,7 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], os_csr_busy(FALSE); /* play the game */ - plygo(&runctx, &vocctx, (tiocxdef *)0, preinit, restore_file); + plygo(&runctx, &vocctx, (tiocxdef *)nullptr, preinit, restore_file); /* close load file */ fiorcls(&fiolctx); @@ -735,30 +735,30 @@ static void trdmain1(errcxdef *ec, int argc, char *argv[], fiorcls(&fiolctx); /* vocctx is going out of scope - forget the global reference to it */ - main_voc_ctx = 0; + main_voc_ctx = nullptr; /* delete the voc context */ vocterm(&vocctx); /* delete the undo context */ - if (undoptr != 0) + if (undoptr != nullptr) objuterm(undoptr); /* release the object cache structures */ - if (mctx != 0) + if (mctx != nullptr) mcmcterm(mctx); - if (globalctx != 0) + if (globalctx != nullptr) mcmterm(globalctx); ERRENDCLN(ec) /* vocctx is going out of scope - forget the global reference to it */ - main_voc_ctx = 0; + main_voc_ctx = nullptr; /* delete the voc contxt */ vocterm(&vocctx); /* delete the undo context */ - if (undoptr != 0) + if (undoptr != nullptr) objuterm(undoptr); /* release the object cache structures */ @@ -818,10 +818,10 @@ void trd_close_swapfile(runcxdef *runctx) mcscxdef *mcsctx; /* if no run context was supplied, find it from the main voc context */ - if (runctx == 0) + if (runctx == nullptr) { /* if there is no main voc context, we're out of luck */ - if (main_voc_ctx == 0) + if (main_voc_ctx == nullptr) return; /* get the run context */ @@ -834,24 +834,24 @@ void trd_close_swapfile(runcxdef *runctx) mcsctx = &globalctx->mcmcxswc; /* if we have a swap file open, close it */ - if (mcsctx->mcscxfp != 0) + if (mcsctx->mcscxfp != nullptr) { /* close the file */ osfcls(mcsctx->mcscxfp); /* forget about the file, so we don't try to close it again */ - mcsctx->mcscxfp = (osfildef *)0; + mcsctx->mcscxfp = (osfildef *)nullptr; } /* if we have a filename, delete the file */ - if (mcsctx->mcscxfname != 0) + if (mcsctx->mcscxfname != nullptr) { /* delete the file */ osfdel_temp(mcsctx->mcscxfname); /* forget the filename, so we don't try to delete the file again */ mchfre(mcsctx->mcscxfname); - mcsctx->mcscxfname = 0; + mcsctx->mcscxfname = nullptr; } } @@ -864,7 +864,7 @@ int trdmain(int argc, char *argv[], appctxdef *appctx, const char *save_ext) errctx.errcxlog = trdlogerr; errctx.errcxlgc = &errctx; - errctx.errcxfp = (osfildef *)0; + errctx.errcxfp = (osfildef *)nullptr; errctx.errcxofs = 0; errctx.errcxappctx = appctx; fp = oserrop(argv[0]); @@ -891,7 +891,7 @@ int trdmain(int argc, char *argv[], appctxdef *appctx, const char *save_ext) errclog(&errctx); /* close the error file */ - if (errctx.errcxfp != 0) + if (errctx.errcxfp != nullptr) osfcls(errctx.errcxfp); /* pause before exiting if the OS desires it */ @@ -902,7 +902,7 @@ int trdmain(int argc, char *argv[], appctxdef *appctx, const char *save_ext) ERREND(&errctx) /* close the error file if we opened it */ - if (errctx.errcxfp != 0) + if (errctx.errcxfp != nullptr) osfcls(errctx.errcxfp); /* successful completion */ diff --git a/engines/glk/tads/tads2/tads2.cpp b/engines/glk/tads/tads2/tads2.cpp index 547cb0f748b..8c45a6900e0 100644 --- a/engines/glk/tads/tads2/tads2.cpp +++ b/engines/glk/tads/tads2/tads2.cpp @@ -34,7 +34,7 @@ TADS2::TADS2(OSystem *syst, const GlkGameDescription &gameDesc) : TADS(syst, gam void TADS2::runGame() { // Initialize the OS layer - os_init(nullptr, nullptr, 0, 0, 0); + os_init(nullptr, nullptr, nullptr, nullptr, 0); os_instbrk(true); char name[255]; diff --git a/engines/glk/tads/tads2/tokenizer.cpp b/engines/glk/tads/tads2/tokenizer.cpp index 5ad41ebcc3a..9ecf3a60280 100644 --- a/engines/glk/tads/tads2/tokenizer.cpp +++ b/engines/glk/tads/tads2/tokenizer.cpp @@ -115,7 +115,7 @@ static tokdfdef *tok_find_define(tokcxdef *ctx, const char *sym, int len) } /* didn't find anything */ - return 0; + return nullptr; } /* @@ -271,7 +271,7 @@ void tok_del_define(tokcxdef *ctx, const char *sym, int len) hsh = tokdfhsh(sym, len); /* search the chain for this symbol */ - for (prv = 0, df = ctx->tokcxdf[hsh] ; df ; prv = df, df = df->nxt) + for (prv = nullptr, df = ctx->tokcxdf[hsh] ; df ; prv = df, df = df->nxt) { /* if this one matches, delete it */ if (df->len == len && !memcmp(df->nm, sym, (size_t)len)) @@ -391,7 +391,7 @@ static void tok_ifdef_ifndef(tokcxdef *ctx, const char *p, int len, int is_ifdef sym = tok_casefold_defsym(ctx, mysym, sym, symlen); /* see if we can find it in the table, and set the status accordingly */ - found = (tok_find_define(ctx, sym, symlen) != 0); + found = (tok_find_define(ctx, sym, symlen) != nullptr); /* invert the test if this is an ifndef */ if (!is_ifdef) found = !found; @@ -1001,12 +1001,12 @@ nexttoken: /* check to see if it's defined */ tok->toktyp = TOKTNUMBER; - tok->tokval = (tok_find_define(ctx, q, symlen) != 0); + tok->tokval = (tok_find_define(ctx, q, symlen) != nullptr); goto done; } /* substitute the preprocessor #define, if any */ - if ((df = tok_find_define(ctx, tok->toknam, l)) != 0) + if ((df = tok_find_define(ctx, tok->toknam, l)) != nullptr) { /* save the current parsing position */ if (ctx->tokcxmlvl >= TOKMACNEST) @@ -1487,7 +1487,7 @@ void tokaddinc(tokcxdef *ctx, char *path, int pathlen) (sizeof(tokpdef) + pathlen - 1), "tokaddinc"); newpath->tokplen = pathlen; - newpath->tokpnxt = (tokpdef *)0; + newpath->tokpnxt = (tokpdef *)nullptr; memcpy(newpath->tokpdir, path, (size_t)pathlen); /* link in at end of list (if no list yet, newpath becomes first entry) */ diff --git a/engines/glk/tads/tads2/vocabulary.cpp b/engines/glk/tads/tads2/vocabulary.cpp index 585ceb64480..6b2dca5ab85 100644 --- a/engines/glk/tads/tads2/vocabulary.cpp +++ b/engines/glk/tads/tads2/vocabulary.cpp @@ -36,7 +36,7 @@ namespace TADS2 { * that routines that don't have any other access to it (such as * Unix-style signal handlers) can reach it. */ -voccxdef *main_voc_ctx = 0; +voccxdef *main_voc_ctx = nullptr; #ifdef VOCW_IN_CACHE vocwdef *vocwget(voccxdef *ctx, uint idx) @@ -259,7 +259,7 @@ void vocadd2(voccxdef *ctx, prpnum p, objnum objn, int classflg, } /* look for a free vocdef entry of the same size */ - for (prv = (vocdef *)0, v = ctx->voccxfre ; v ; prv = v, v = v->vocnxt) + for (prv = (vocdef *)nullptr, v = ctx->voccxfre ; v ; prv = v, v = v->vocnxt) if (v->voclen == len + len2) break; if (v) @@ -312,7 +312,7 @@ static void voc_parse_words(char **wrdtxt, int *len, char **wrd2, int *len2) else { /* no space ==> no second word */ - *wrd2 = (char *)0; + *wrd2 = (char *)nullptr; } } @@ -351,7 +351,7 @@ void vociadd(voccxdef *ctx, objnum obj, objnum loc, vocialo(ctx, obj); /* look in free list for an entry that's big enough */ - for (prv = (vocidef *)0, min = (vocidef *)0, v = ctx->voccxifr ; v ; + for (prv = (vocidef *)nullptr, min = (vocidef *)nullptr, v = ctx->voccxifr ; v ; prv = v, v = v->vocinxt) { if (v->vocinsc == numsc) @@ -399,7 +399,7 @@ void vociadd(voccxdef *ctx, objnum obj, objnum loc, } /* set up the entry */ - if (vocinh(ctx, obj) != (vocidef *)0) errsig(ctx->voccxerr, ERR_VOCINUS); + if (vocinh(ctx, obj) != (vocidef *)nullptr) errsig(ctx->voccxerr, ERR_VOCINUS); v->vociloc = loc; v->vociilc = MCMONINV; v->vociflg = (flags & ~VOCIFXLAT); @@ -463,7 +463,7 @@ void vocrevert(voccxdef *vctx) * Revert the vocabulary list: delete all newly added words, and * undelete all original words marked as deleted. */ - vocdel1(vctx, MCMONINV, (char *)0, 0, TRUE, TRUE, FALSE); + vocdel1(vctx, MCMONINV, (char *)nullptr, 0, TRUE, TRUE, FALSE); } /* initialize voc context */ @@ -517,15 +517,15 @@ void vocini(voccxdef *vocctx, errcxdef *errctx, mcmcxdef *memctx, vocctx->voccxactor = MCMONINV; vocctx->voccxverb = MCMONINV; vocctx->voccxprep = MCMONINV; - vocctx->voccxdobj = 0; - vocctx->voccxiobj = 0; + vocctx->voccxdobj = nullptr; + vocctx->voccxiobj = nullptr; vocctx->voccxunknown = 0; vocctx->voccxlastunk = 0; - vocctx->voc_stk_ptr = 0; - vocctx->voc_stk_cur = 0; - vocctx->voc_stk_end = 0; + vocctx->voc_stk_ptr = nullptr; + vocctx->voc_stk_cur = nullptr; + vocctx->voc_stk_end = nullptr; /* allocate fuses, daemons, notifiers */ vocinialo(vocctx, &vocctx->voccxfus, (vocctx->voccxfuc = fuses)); @@ -545,14 +545,14 @@ void vocterm(voccxdef *ctx) voctermfree(ctx->voccxalm); /* delete the private stack */ - if (ctx->voc_stk_ptr != 0) + if (ctx->voc_stk_ptr != nullptr) mchfre(ctx->voc_stk_ptr); } /* clean up the vocab context */ void voctermfree(vocddef *what) { - if (what != 0) + if (what != nullptr) mchfre(what); } @@ -681,7 +681,7 @@ void vocdel1(voccxdef *ctx, objnum objn, char *wrd1, prpnum prp, for (i = VOCHASHSIZ, vp = ctx->voccxhsh ; i ; ++vp, --i) { /* go through all words in this hash chain */ - for (prv = (vocdef *)0, v = *vp ; v ; v = nxt) + for (prv = (vocdef *)nullptr, v = *vp ; v ; v = nxt) { /* remember next word in hash chain */ nxt = v->vocnxt; @@ -711,7 +711,7 @@ void vocdel1(voccxdef *ctx, objnum objn, char *wrd1, prpnum prp, deleted_vocdef = FALSE; /* go through all object relations for this word */ - for (prvw = 0, idx = v->vocwlst, vw = vocwget(ctx, idx) ; vw ; + for (prvw = nullptr, idx = v->vocwlst, vw = vocwget(ctx, idx) ; vw ; vw = nxtw, idx = nxtidx) { /* remember next word in relation list */ @@ -741,7 +741,7 @@ void vocdel1(voccxdef *ctx, objnum objn, char *wrd1, prpnum prp, * match) */ do_del = (vw->vocwobj == objn - && (wrd1 == 0 || vw->vocwtyp == prp)); + && (wrd1 == nullptr || vw->vocwtyp == prp)); /* * if we're not in really_delete mode, and the word @@ -814,7 +814,7 @@ void vocdel1(voccxdef *ctx, objnum objn, char *wrd1, prpnum prp, /* delete all vocabulary for an object */ void vocdel(voccxdef *ctx, objnum objn) { - vocdel1(ctx, objn, (char *)0, (prpnum)0, TRUE, FALSE, FALSE); + vocdel1(ctx, objn, (char *)nullptr, (prpnum)0, TRUE, FALSE, FALSE); } /* delete object inheritance records for a particular object */ @@ -824,7 +824,7 @@ void vocidel(voccxdef *ctx, objnum obj) /* get entry out of page table, and clear page table slot */ v = vocinh(ctx, obj); - vocinh(ctx, obj) = (vocidef *)0; + vocinh(ctx, obj) = (vocidef *)nullptr; /* link into free list */ if (v) diff --git a/engines/glk/tads/tads2/vocabulary_parser.cpp b/engines/glk/tads/tads2/vocabulary_parser.cpp index 167f716771a..73f264ef948 100644 --- a/engines/glk/tads/tads2/vocabulary_parser.cpp +++ b/engines/glk/tads/tads2/vocabulary_parser.cpp @@ -215,7 +215,7 @@ static void voc_push_strlist(voccxdef *ctx, const char *firstwrd, const char *la * entry, we need one byte for the type prefix, two bytes for the * length prefix, and the bytes of the string itself. */ - for (lstsiz = 0, p = firstwrd ; p != 0 && p <= lastwrd ; p += curlen + 1) + for (lstsiz = 0, p = firstwrd ; p != nullptr && p <= lastwrd ; p += curlen + 1) { curlen = strlen(p); lstsiz += curlen + (1+2); @@ -225,7 +225,7 @@ static void voc_push_strlist(voccxdef *ctx, const char *firstwrd, const char *la lstp = voc_push_list_siz(ctx, lstsiz); /* enter the list elements */ - for (p = firstwrd ; p != 0 && p <= lastwrd ; p += curlen + 1) + for (p = firstwrd ; p != nullptr && p <= lastwrd ; p += curlen + 1) { /* add the type prefix */ *lstp++ = DAT_SSTRING; @@ -397,7 +397,7 @@ int vocread(voccxdef *ctx, objnum actor, objnum verb, ret = VOCREAD_OK; /* make sure output capturing is off */ - tiocapture(ctx->voccxtio, (mcmcxdef *)0, FALSE); + tiocapture(ctx->voccxtio, (mcmcxdef *)nullptr, FALSE); tioclrcapture(ctx->voccxtio); /* @@ -554,7 +554,7 @@ vocwdef *vocfnw(voccxdef *voccx, vocseadef *search_ctx) vw = vocwget(voccx, search_ctx->vw->vocwnxt); /* keep going until we run out of hash chain entries or find a match */ - for (v = c, vf = 0 ; v != 0 && vf == 0 ; v = v->vocnxt, first = FALSE) + for (v = c, vf = nullptr ; v != nullptr && vf == nullptr ; v = v->vocnxt, first = FALSE) { /* if this word matches, look at the objects in its list */ if (first @@ -594,7 +594,7 @@ vocwdef *vocfnw(voccxdef *voccx, vocseadef *search_ctx) /* return the first vocwdef in this word's list */ search_ctx->v = vf; - search_ctx->vw = (vf ? vwf : 0); + search_ctx->vw = (vf ? vwf : nullptr); return(search_ctx->vw); } @@ -610,7 +610,7 @@ vocwdef *vocffw(voccxdef *ctx, const char *wrd, int len, const char *wrd2, int l hshval = vochsh((const uchar *)wrd, len); /* scan the hash list until we run out of entries, or find a match */ - for (v = ctx->voccxhsh[hshval], vf = 0 ; v != 0 && vf == 0 ; + for (v = ctx->voccxhsh[hshval], vf = nullptr ; v != nullptr && vf == nullptr ; v = v->vocnxt) { /* if this word matches, look at the objects in its list */ @@ -638,7 +638,7 @@ vocwdef *vocffw(voccxdef *ctx, const char *wrd, int len, const char *wrd2, int l } /* set up the caller-provided search structure for next time */ - vw = (vf != 0 ? vwf : 0); + vw = (vf != nullptr ? vwf : nullptr); if (search_ctx) { /* save the search position */ @@ -982,7 +982,7 @@ int try_unknown_verb(voccxdef *ctx, objnum actor, if (wrdcnt == 0) { /* count the words before the terminating null entry */ - for ( ; cmd[wrdcnt] != 0 ; ++wrdcnt) ; + for ( ; cmd[wrdcnt] != nullptr ; ++wrdcnt) ; } /* if parseUnknownVerb exists, call it */ @@ -1123,7 +1123,7 @@ int try_unknown_verb(voccxdef *ctx, objnum actor, { /* execute fuses and daemons */ if (exe_fuses_and_daemons(ctx, err, do_fuses, - actor, MCMONINV, 0, 0, + actor, MCMONINV, nullptr, 0, MCMONINV, MCMONINV) != 0) { /* @@ -1187,7 +1187,7 @@ static const vocspdef vocsptab[] = { "her", VOCW_HER }, { "any", VOCW_ANY }, { "either", VOCW_ANY }, - { 0, 0 } + { nullptr, 0 } }; /* test a word to see if it's a particular special word */ @@ -1281,10 +1281,10 @@ int voctok(voccxdef *ctx, char *cmd, char *outbuf, char **wrd, *outbuf++ = *cmd++; /* add the period to the word */ *outbuf = '\0'; /* null-terminate it */ ++len; - if (!vocffw(ctx, (char *)w, len, 0, 0, PRP_NOUN, - (vocseadef *)0) - && !vocffw(ctx, (char *)w, len, 0, 0, PRP_ADJ, - (vocseadef *)0)) + if (!vocffw(ctx, (char *)w, len, nullptr, 0, PRP_NOUN, + (vocseadef *)nullptr) + && !vocffw(ctx, (char *)w, len, nullptr, 0, PRP_ADJ, + (vocseadef *)nullptr)) { /* no word with period in dictionary - remove period */ --outbuf; @@ -1500,14 +1500,14 @@ static int voc_lookup_type(voccxdef *ctx, char *p, int len, int of_is_spec) * verbs; the second word is considered later during the * semantic analysis. */ - for (t = 0, v = ctx->voccxhsh[vochsh((uchar *)p, len)] ; v != 0 ; + for (t = 0, v = ctx->voccxhsh[vochsh((uchar *)p, len)] ; v != nullptr ; v = v->vocnxt) { /* if this hash chain entry matches, add it to our types */ if (voceq((uchar *)p, len, v->voctxt, v->voclen)) { /* we have a match - look through relation list for word */ - for (vw = vocwget(ctx, v->vocwlst) ; vw != 0 ; + for (vw = vocwget(ctx, v->vocwlst) ; vw != nullptr ; vw = vocwget(ctx, vw->vocwnxt)) { /* skip this word if it's been deleted */ @@ -1567,7 +1567,7 @@ static char *voc_read_oops(voccxdef *ctx, char *oopsbuf, size_t oopsbuflen, * we've already decided it's not an OOPS input - return null to * indicate to the caller that we have a new command */ - return 0; + return nullptr; } /* lower-case the string */ @@ -1599,7 +1599,7 @@ static char *voc_read_oops(voccxdef *ctx, char *oopsbuf, size_t oopsbuflen, * we didn't find any form of "OOPS" response - return null to * indicate to the caller that the player entered a new command */ - return 0; + return nullptr; } /* skip spaces before the replacement text */ @@ -1676,7 +1676,7 @@ startover: p1 = voc_read_oops(ctx, oopsbuf, sizeof(oopsbuf), p); /* if they responded with replacement text, apply it */ - if (p1 != 0) + if (p1 != nullptr) { char redobuf[200]; char *q; @@ -1690,7 +1690,7 @@ startover: * the unknown word with what follows the "oops" in * the new command */ - for (outp = redobuf, i = 0, w = cmd ; *w != 0 ; ++i, ++w) + for (outp = redobuf, i = 0, w = cmd ; *w != nullptr ; ++i, ++w) { /* see what we have */ @@ -1789,7 +1789,7 @@ startover: if ((wc = voctok(ctx, redobuf, cmd[0], cmd, FALSE, FALSE, TRUE)) <= 0) return 1; - cmd[wc] = 0; + cmd[wc] = nullptr; /* start over with the typing */ goto startover; @@ -2065,8 +2065,8 @@ static int vocgol(voccxdef *ctx, objnum *list, uint *flags, char **wrdlst, cnt = 0; add_words: - for (v = vocffw(ctx, wrd, len, (char *)0, 0, wrdtyp, &search_ctx) - ; v != 0 ; v = vocfnw(ctx, &search_ctx)) + for (v = vocffw(ctx, wrd, len, (char *)nullptr, 0, wrdtyp, &search_ctx) + ; v != nullptr ; v = vocfnw(ctx, &search_ctx)) { int i; @@ -2245,7 +2245,7 @@ static int voc_pnp_hook(voccxdef *ctx, char *cmd[], int typelist[], runpnum(rcx, cur + 1); /* count the entries in the command list */ - for (wordcnt = 0, cmdp = cmd ; *cmdp != 0 && **cmdp != '\0' ; + for (wordcnt = 0, cmdp = cmd ; *cmdp != nullptr && **cmdp != '\0' ; ++wordcnt, ++cmdp) ; /* push the type list */ @@ -2368,7 +2368,7 @@ static int voc_pnp_hook(voccxdef *ctx, char *cmd[], int typelist[], * set "no_match" appropriately -- set "no_match" true if we're * returning an empty list and we parsed one or more words */ - if (no_match != 0) + if (no_match != nullptr) *no_match = (outcnt == 0 && *next > cur); /* @@ -2441,7 +2441,7 @@ void voc_make_obj_name_from_list(voccxdef *ctx, char *namebuf, int i, i1, i2; /* find the cmd indices */ - for (i = i1 = i2 = 0 ; cmd[i] != 0 && *cmd[i] != 0 ; ++i) + for (i = i1 = i2 = 0 ; cmd[i] != nullptr && *cmd[i] != 0 ; ++i) { if (cmd[i] == firstwrd) i1 = i; @@ -2505,7 +2505,7 @@ static int vocg1o(voccxdef *ctx, char *cmd[], int typelist[], VOC_STK_ARRAY(ctx, char, namebuf, VOCBUFSIZ); /* presume we'll find a match */ - if (no_match != 0) + if (no_match != nullptr) *no_match = FALSE; /* start at the first word */ @@ -2558,7 +2558,7 @@ static int vocg1o(voccxdef *ctx, char *cmd[], int typelist[], if ((vocspec(cmd[cur], VOCW_ALL) || vocspec(cmd[cur], VOCW_BOTH) || vocspec(cmd[cur], VOCW_ANY)) && - cmd[cur+1] != (char *)0) + cmd[cur+1] != (char *)nullptr) { int nxt; int n = cur+1; @@ -2678,7 +2678,7 @@ static int vocg1o(voccxdef *ctx, char *cmd[], int typelist[], cur++; cnt = vocgobj(ctx, cmd, typelist, cur, next, complain, xlist, 1, - chkact, 0); + chkact, nullptr); if (cnt < 0) { /* @@ -2744,7 +2744,7 @@ static int vocg1o(voccxdef *ctx, char *cmd[], int typelist[], if (typelist[cur] & VOCT_ARTICLE) { ++cur; - if (cmd[cur] == (char *)0 + if (cmd[cur] == (char *)nullptr || ((typelist[cur] & (VOCT_ADJ | VOCT_NOUN | VOCT_UNKNOWN)) == 0 && !vocisdigit(*cmd[cur]))) { @@ -2760,7 +2760,7 @@ static int vocg1o(voccxdef *ctx, char *cmd[], int typelist[], /* scan words for inclusion in this noun phrase */ for (found_plural = FALSE, unknown_count = 0, l1 = 0 ; ; ) { - if (cmd[cur] == (char *)0) + if (cmd[cur] == (char *)nullptr) break; if (typelist[cur] & VOCT_ADJ) @@ -2778,9 +2778,9 @@ static int vocg1o(voccxdef *ctx, char *cmd[], int typelist[], else if (typelist[cur] & VOCT_NOUN) { ++cur; - if (cmd[cur] == (char *)0) break; + if (cmd[cur] == (char *)nullptr) break; if (vocisdigit(*cmd[cur])) ++cur; - if (cmd[cur] == (char *)0) break; + if (cmd[cur] == (char *)nullptr) break; if (!voc_check_special(ctx, cmd[cur], VOCW_OF)) break; } else if (vocisdigit(*cmd[cur])) @@ -2802,7 +2802,7 @@ static int vocg1o(voccxdef *ctx, char *cmd[], int typelist[], break; /* note whether we found anything that might be a plural */ - if (cmd[cur] != 0 && (typelist[cur] & VOCT_PLURAL) != 0) + if (cmd[cur] != nullptr && (typelist[cur] & VOCT_PLURAL) != 0) found_plural = TRUE; } @@ -3025,7 +3025,7 @@ retry_exclude_first: */ if (complain) vocerr(ctx, VOCERR(9), "I don't see any %s here.", namebuf); - if (no_match != 0) + if (no_match != nullptr) *no_match = TRUE; VOC_RETVAL(ctx, save_sp, 0); } @@ -3166,7 +3166,7 @@ int vocgobj(voccxdef *ctx, char *cmd[], int typelist[], * if we're looking at a noun phrase separator ("and" or a * comma), get the next noun phrase; otherwise, we're done */ - if (cur != -1 && cmd[cur] != 0 && vocspec(cmd[cur], VOCW_AND)) + if (cur != -1 && cmd[cur] != nullptr && vocspec(cmd[cur], VOCW_AND)) { lastcur = cur; while (cmd[cur] && vocspec(cmd[cur], VOCW_AND)) ++cur; @@ -3439,7 +3439,7 @@ void voc_parse_np(voccxdef *ctx) } /* store an empty last entry */ - wordarr[i] = 0; + wordarr[i] = nullptr; /* build the type array */ for (i = 0, lstp = typp, lstsiz = typsiz ; @@ -3714,7 +3714,7 @@ void voc_parse_dict_lookup(voccxdef *ctx) else { /* no embedded space -> no second word */ - curword2 = 0; + curword2 = nullptr; curwordlen2 = 0; } @@ -3774,7 +3774,7 @@ void voc_parse_dict_lookup(voccxdef *ctx) /* scan for matching words */ for (v = vocffw(ctx, curword, curwordlen, curword2, curwordlen2, type_prop, &search_ctx) ; - v != 0 ; + v != nullptr ; v = vocfnw(ctx, &search_ctx)) { int i; @@ -3965,7 +3965,7 @@ void voc_parse_disambig(voccxdef *ctx) } /* store a null at the end of the command pointer list */ - cmd[i] = 0; + cmd[i] = nullptr; /* * The object list is provided in the same format as the list @@ -4169,7 +4169,7 @@ void voc_parse_disambig(voccxdef *ctx) * find the unknown word - look up each word until we find one * that's not in the dictionary */ - for (i = 0, unk = 0 ; cmd[i] != 0 ; ++i) + for (i = 0, unk = nullptr ; cmd[i] != nullptr ; ++i) { int t; @@ -4191,7 +4191,7 @@ void voc_parse_disambig(voccxdef *ctx) * if we didn't find any unknown words, assume the first word * was unknown */ - if (unk == 0) + if (unk == nullptr) { unk_idx = 0; unk = cmd[0]; @@ -4204,7 +4204,7 @@ void voc_parse_disambig(voccxdef *ctx) * if they didn't respond with "oops," treat the response as a * brand new command to replace the current command */ - if (rpl_text == 0) + if (rpl_text == nullptr) { /* * it's a replacement command - set the redo flag to @@ -4226,7 +4226,7 @@ void voc_parse_disambig(voccxdef *ctx) * then the replacement text, then all of the remaining * tokens. */ - for (p = cmdbuf, i = 0 ; cmd[i] != 0 ; ++i) + for (p = cmdbuf, i = 0 ; cmd[i] != nullptr ; ++i) { size_t needed; @@ -4246,7 +4246,7 @@ void voc_parse_disambig(voccxdef *ctx) * if more tokens follow, we need a space after the * replacement text to separate it from what follows */ - if (cmd[i+1] != 0 && needed != 0) + if (cmd[i+1] != nullptr && needed != 0) needed += 1; /* leave room for null termination */ @@ -4322,7 +4322,7 @@ void voc_parse_disambig(voccxdef *ctx) p += strlen(p); /* add a space if another token follows */ - if (cmd[i+1] != 0) + if (cmd[i+1] != nullptr) *p++ = ' '; } @@ -4494,7 +4494,7 @@ static objnum vocgetactor(voccxdef *ctx, char *cmd[], int typelist[], verprop = PRP_VERACTOR; if (nounlist[0].vocolobj == MCMONINV || objgetap(ctx->voccxmem, nounlist[0].vocolobj, PRP_VALIDACTOR, - (objnum *)0, FALSE)) + (objnum *)nullptr, FALSE)) valprop = PRP_VALIDACTOR; else valprop = PRP_VALIDDO; @@ -4588,7 +4588,7 @@ int vocchkaccess(voccxdef *ctx, objnum obj, prpnum verprop, if (verprop == PRP_VALIDACTOR) { /* checking an actor - check to see if ValidActor is defined */ - if (objgetap(ctx->voccxmem, obj, PRP_VALIDACTOR, (objnum *)0, FALSE)) + if (objgetap(ctx->voccxmem, obj, PRP_VALIDACTOR, (objnum *)nullptr, FALSE)) { /* ValidActor is present - call ValidActor in the object itself */ runppr(ctx->voccxrun, obj, verprop, 0); @@ -4655,7 +4655,7 @@ void vocnoreach(voccxdef *ctx, objnum *list1, int cnt, int multi_flags, int multi_base_index, int multi_total_count) { /* see if the verb has a cantReach method - use it if so */ - if (objgetap(ctx->voccxmem, verb, PRP_NOREACH, (objnum *)0, FALSE)) + if (objgetap(ctx->voccxmem, verb, PRP_NOREACH, (objnum *)nullptr, FALSE)) { /* push arguments: (actor, dolist, iolist, prep) */ runpobj(ctx->voccxrun, prep); @@ -4712,7 +4712,7 @@ static void voc_get_spec_str(voccxdef *ctx, char vocw_id, found = FALSE; /* if there's a special word list, search it for this entry */ - if (ctx->voccxspp != 0) + if (ctx->voccxspp != nullptr) { char *p; char *endp; @@ -4833,7 +4833,7 @@ static int has_gen_num_adj(voccxdef *ctx, objnum objn) vocseadef search_ctx; /* scan the list of objects defined '#' as an adjective */ - for (v = vocffw(ctx, "#", 1, (char *)0, 0, PRP_ADJ, &search_ctx) ; + for (v = vocffw(ctx, "#", 1, (char *)nullptr, 0, PRP_ADJ, &search_ctx) ; v ; v = vocfnw(ctx, &search_ctx)) { /* if this is the object, return positive indication */ @@ -4878,7 +4878,7 @@ static int voc_disambig_hook(voccxdef *ctx, objnum verb, objnum actor, call_prop = (accprop == PRP_VALIDDO ? PRP_DISAMBIGDO : PRP_DISAMBIGIO); /* if the method isn't defined, we can skip this entirely */ - if (objgetap(ctx->voccxmem, verb, call_prop, (objnum *)0, FALSE) == 0) + if (objgetap(ctx->voccxmem, verb, call_prop, (objnum *)nullptr, FALSE) == 0) return VOC_DISAMBIG_CONT; /* push the "silent" flag */ @@ -5408,7 +5408,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, lstadv(&l, &len); } - vocout(&outlist[outpos], MCMONINV, 0, (char *)0, (char *)0); + vocout(&outlist[outpos], MCMONINV, 0, (char *)nullptr, (char *)nullptr); } else rundisc(ctx->voccxrun); /* discard non-list value */ @@ -5580,7 +5580,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, ? PRP_PARSEUNKNOWNDOBJ : PRP_PARSEUNKNOWNIOBJ); /* check if the verb defines this method */ - if (objgetap(ctx->voccxmem, cmdVerb, prp, (objnum *)0, FALSE)) + if (objgetap(ctx->voccxmem, cmdVerb, prp, (objnum *)nullptr, FALSE)) { uchar *lstp; uint lstlen; @@ -5976,7 +5976,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, * to reference this object, in case we need to complain. */ usrobj[0] = '\0'; - if (inlist[inpos].vocolfst != 0 && inlist[inpos].vocollst != 0) + if (inlist[inpos].vocolfst != nullptr && inlist[inpos].vocollst != nullptr) { for (p = inlist[inpos].vocolfst ; p <= inlist[inpos].vocollst ; p += strlen(p) + 1) @@ -6015,7 +6015,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, */ if ((cnt2 == 0 || (cnt2 == 1 && list2[0] == ctx->voccxnum)) - && inlist[inpos].vocolfst != 0 + && inlist[inpos].vocolfst != nullptr && inlist[inpos].vocolfst == inlist[inpos].vocollst && vocisdigit(*inlist[inpos].vocolfst)) { @@ -6261,7 +6261,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, * the player did, in fact, specify a number. */ for (found = FALSE, p = inlist[inpos].vocolfst ; - p != 0 && p <= inlist[inpos].vocollst ; + p != nullptr && p <= inlist[inpos].vocollst ; p += strlen(p) + 1) { /* did we find it? */ @@ -6534,7 +6534,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, } /* make sure output capturing is off */ - tiocapture(ctx->voccxtio, (mcmcxdef *)0, FALSE); + tiocapture(ctx->voccxtio, (mcmcxdef *)nullptr, FALSE); tioclrcapture(ctx->voccxtio); /* @@ -6722,7 +6722,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, memset(distypelist, 0, VOCBUFSIZ * sizeof(distypelist[0])); /* tokenize the sentence */ - diswordlist[wrdcnt] = 0; + diswordlist[wrdcnt] = nullptr; if (vocgtyp(ctx, diswordlist, distypelist, cmdbuf) || ctx->voccxunknown != 0) { @@ -6816,7 +6816,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, * disallow it, since they must be entering * something more complicated */ - if (diswordlist[next] != 0 + if (diswordlist[next] != nullptr && !vocspec(diswordlist[next], VOCW_ONE) && !vocspec(diswordlist[next], VOCW_ONES) && !vocspec(diswordlist[next], VOCW_THEN)) @@ -6893,7 +6893,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, ++cnt3; /* if we have a noun phrase, skip matching objs */ - if (disnounlist[i].vocolfst != 0) + if (disnounlist[i].vocolfst != nullptr) { int j; @@ -6967,7 +6967,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, for (i = 0 ; i < cnt2 ; ++i) { /* if we have a noun phrase, stop scanning */ - if (disnounlist[i].vocolfst != 0) + if (disnounlist[i].vocolfst != nullptr) break; } @@ -7081,7 +7081,7 @@ int vocdisambig(voccxdef *ctx, vocoldef *outlist, vocoldef *inlist, } /* terminate the output list */ - vocout(&outlist[outpos], MCMONINV, 0, (char *)0, (char *)0); + vocout(&outlist[outpos], MCMONINV, 0, (char *)nullptr, (char *)nullptr); /* * If we still have ambiguous objects, so indicate. This can only @@ -7117,7 +7117,7 @@ static int vocready(voccxdef *ctx, char *cmd[], int *typelist, int cur, int *next_start) { if (cur != -1 - && (cmd[cur] == (char *)0 + && (cmd[cur] == (char *)nullptr || vocspec(cmd[cur], VOCW_AND) || vocspec(cmd[cur], VOCW_THEN))) { if (ctx->voccxflg & VOCCXFDBG) @@ -7289,7 +7289,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, } /* enter a null last word */ - cmd[cnt] = 0; + cmd[cnt] = nullptr; /* generate the type list for the new list */ if (vocgtyp(ctx, cmd, typelist, cmdbuf)) @@ -7340,7 +7340,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, ++cur; /* see if there's anything left to parse */ - if (cmd[cur] == 0) + if (cmd[cur] == nullptr) { /* * if we've been off doing preparseCmd work, return to the @@ -7409,7 +7409,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, first_word = cur; /* make sure we have a verb */ - if ((cmd[cur] == (char *)0) || !(typelist[cur] & VOCT_VERB)) + if ((cmd[cur] == (char *)nullptr) || !(typelist[cur] & VOCT_VERB)) { /* unknown verb - handle it with parseUnknownVerb if possible */ if (!try_unknown_verb(ctx, cmdActor, &cmd[cur], &typelist[cur], @@ -7428,7 +7428,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, } vverb = cmd[cur++]; /* this is the verb */ vvlen = strlen(vverb); /* remember length of verb */ - vprep = 0; /* assume no verb-preposition */ + vprep = nullptr; /* assume no verb-preposition */ /* execute if the command is just a verb */ if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, @@ -7443,7 +7443,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, if (typelist[cur] & VOCT_PREP) { if (vocffw(ctx, vverb, vvlen, cmd[cur], (int)strlen(cmd[cur]), - PRP_VERB, (vocseadef *)0)) + PRP_VERB, (vocseadef *)nullptr)) { vprep = cmd[cur++]; if (vocready(ctx, cmd, typelist, cur, cmdActor, cmdPrep, @@ -7462,7 +7462,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, * follows. */ if ((v = vocffw(ctx, cmd[cur], (int)strlen(cmd[cur]), - (char *)0, 0, PRP_PREP, (vocseadef *)0)) != 0) + (char *)nullptr, 0, PRP_PREP, (vocseadef *)nullptr)) != nullptr) { int swap_ok; @@ -7601,12 +7601,12 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, char *p1 = cmd[cur++]; /* if this is the end of the sentence, add the prep to the verb */ - if (cmd[cur] == (char *)0 + if (cmd[cur] == (char *)nullptr || vocspec(cmd[cur], VOCW_AND) || vocspec(cmd[cur], VOCW_THEN)) { if (vocffw(ctx, vverb, vvlen, p1, (int)strlen(p1), PRP_VERB, - (vocseadef *)0) + (vocseadef *)nullptr) && !vprep) vprep = p1; else @@ -7650,9 +7650,9 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, * be an indirect object. */ if (cmd[cur] && (typelist[cur] & VOCT_PREP) && cmd[cur+1] - && vprep == 0 + && vprep == nullptr && vocffw(ctx, vverb, vvlen, p1, (int)strlen(p1), PRP_VERB, - (vocseadef *)0)) + (vocseadef *)nullptr)) { /* * check to make sure that the next word, which we're @@ -7662,7 +7662,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, * the prep */ if (vocgobj(ctx, cmd, typelist, cur, &next, - FALSE, iolist, FALSE, FALSE, 0) <= 0) + FALSE, iolist, FALSE, FALSE, nullptr) <= 0) { /* aggregate the first preposition into the verb */ vprep = p1; @@ -7678,9 +7678,9 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, if (cnt > 0) { cur = next; - v = vocffw(ctx, p1, (int)strlen(p1), (char *)0, 0, PRP_PREP, - (vocseadef *)0); - if (v == (vocwdef *)0) + v = vocffw(ctx, p1, (int)strlen(p1), (char *)nullptr, 0, PRP_PREP, + (vocseadef *)nullptr); + if (v == (vocwdef *)nullptr) { /* let parseUnknownVerb handle it */ if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], @@ -7707,7 +7707,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, else if ((typelist[cur] & VOCT_PREP) && vocffw(ctx, vverb, vvlen, cmd[cur], (int)strlen(cmd[cur]), PRP_VERB, - (vocseadef *)0) && !vprep) + (vocseadef *)nullptr) && !vprep) { vprep = cmd[cur++]; if (vocready(ctx, cmd, typelist, cur, cmdActor, @@ -7753,8 +7753,8 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, ? &dolist[0] : (iolist[0].vocolflg & VOCS_TRIMPREP) != 0 ? &iolist[0] - : 0; - if (np1 != 0) + : nullptr; + if (np1 != nullptr) { char namebuf[VOCBUFSIZ]; @@ -7819,14 +7819,14 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, if ((typelist[cur] & VOCT_PREP) && vocffw(ctx, vverb, vvlen, cmd[cur], (int)strlen(cmd[cur]), PRP_VERB, - (vocseadef *)0) && !vprep) + (vocseadef *)nullptr) && !vprep) { vprep = cmd[cur++]; } } /* the command should definitely be done now */ - if (cmd[cur] != 0) + if (cmd[cur] != nullptr) { /* let parseUnknownVerb handle it */ if (!try_unknown_verb(ctx, cmdActor, &cmd[first_word], @@ -7854,7 +7854,7 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, if (cmdPrep == MCMONINV && (v = vocffw(ctx, vverb, vvlen, vprep, (vprep ? (int)strlen(vprep) : 0), - PRP_VERB, (vocseadef *)0)) != 0) + PRP_VERB, (vocseadef *)nullptr)) != nullptr) { runppr(ctx->voccxrun, v->vocwobj, PRP_NILPREP, 0); if (runtostyp(ctx->voccxrun) == DAT_OBJECT) @@ -7866,8 +7866,8 @@ static int voc1cmd(voccxdef *ctx, char *cmd[], char *cmdbuf, /* if we didn't find anything with nilPrep, find "to" */ if (cmdPrep == MCMONINV) { - v = vocffw(ctx, "to", 2, (char *)0, 0, PRP_PREP, - (vocseadef *)0); + v = vocffw(ctx, "to", 2, (char *)nullptr, 0, PRP_PREP, + (vocseadef *)nullptr); if (v) cmdPrep = v->vocwobj; } @@ -8050,7 +8050,7 @@ int voccmd(voccxdef *ctx, char *cmd, uint cmdlen) /* find the THEN that ends the command, if there is one */ for (next = cur ; cur < wrdcnt && !vocspec(wordlist[cur], VOCW_THEN) ; ++cur) ; - wordlist[cur] = (char *)0; + wordlist[cur] = (char *)nullptr; /* process until we run out of work to do */ for (;;) @@ -8108,7 +8108,7 @@ int voccmd(voccxdef *ctx, char *cmd, uint cmdlen) void voc_stk_ini(voccxdef *ctx, uint siz) { /* allocate it if it's not already allocated */ - if (ctx->voc_stk_ptr == 0) + if (ctx->voc_stk_ptr == nullptr) { ctx->voc_stk_ptr = mchalo(ctx->voccxerr, siz, "voc_stk_ini"); ctx->voc_stk_end = ctx->voc_stk_ptr + siz; diff --git a/engines/glk/window_text_buffer.cpp b/engines/glk/window_text_buffer.cpp index f03d04e4a7c..d601558f529 100644 --- a/engines/glk/window_text_buffer.cpp +++ b/engines/glk/window_text_buffer.cpp @@ -41,7 +41,7 @@ TextBufferWindow::TextBufferWindow(Windows *windows, uint rock) : TextWindow(win _lastSeen(0), _scrollPos(0), _scrollMax(0), _scrollBack(SCROLLBACK), _width(-1), _height(-1), _inBuf(nullptr), _lineTerminators(nullptr), _echoLineInput(true), _ladjw(0), _radjw(0), _ladjn(0), _radjn(0), _numChars(0), _chars(nullptr), _attrs(nullptr), _spaced(0), _dashed(0), - _copyBuf(0), _copyPos(0) { + _copyBuf(nullptr), _copyPos(0) { _type = wintype_TextBuffer; _history.resize(HISTORYLEN); @@ -1600,8 +1600,8 @@ void TextBufferWindow::scrollResize() { _lines[i]._repaint = false; _lines[i]._lm = 0; _lines[i]._rm = 0; - _lines[i]._lPic = 0; - _lines[i]._rPic = 0; + _lines[i]._lPic = nullptr; + _lines[i]._rPic = nullptr; _lines[i]._lHyper = 0; _lines[i]._rHyper = 0; _lines[i]._len = 0; diff --git a/engines/glk/zcode/glk_interface.cpp b/engines/glk/zcode/glk_interface.cpp index 9b7ada7fc9c..29fb35989a2 100644 --- a/engines/glk/zcode/glk_interface.cpp +++ b/engines/glk/zcode/glk_interface.cpp @@ -516,7 +516,7 @@ void GlkInterface::showBeyondZorkTitle() { int saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; if (saveSlot == -1) { - winid_t win = glk_window_open(0, 0, 0, wintype_Graphics, 0); + winid_t win = glk_window_open(nullptr, 0, 0, wintype_Graphics, 0); if (glk_image_draw_scaled(win, 1, 0, 0, g_vm->_screen->w, g_vm->_screen->h)) _events->waitForPress(); diff --git a/engines/glk/zcode/processor.cpp b/engines/glk/zcode/processor.cpp index cb2d9f97d97..922588ee0de 100644 --- a/engines/glk/zcode/processor.cpp +++ b/engines/glk/zcode/processor.cpp @@ -455,7 +455,7 @@ int Processor::direct_call(zword addr) { saved_zargc = zargc; // Call routine directly - call(addr, 0, 0, 2); + call(addr, 0, nullptr, 2); // Restore operands and operand count for (i = 0; i < 8; i++) diff --git a/engines/glk/zcode/windows.cpp b/engines/glk/zcode/windows.cpp index 90f6b7eaee1..b7a85abd74e 100644 --- a/engines/glk/zcode/windows.cpp +++ b/engines/glk/zcode/windows.cpp @@ -49,14 +49,14 @@ void Windows::setup(bool isVersion6) { if (isVersion6) { // For graphic games we have a background window covering the entire screen for greater // flexibility of wher we draw pictures, and the lower and upper areas sit on top of them - _background = g_vm->glk_window_open(0, 0, 0, wintype_Graphics, 0); + _background = g_vm->glk_window_open(nullptr, 0, 0, wintype_Graphics, 0); _background->setBackgroundColor(0xffffff); Window &w = _windows[0]; w[X_SIZE] = g_vm->h_screen_width; w[Y_SIZE] = g_vm->h_screen_height; } else { - _lower = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + _lower = g_vm->glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 0); _upper = g_vm->glk_window_open(_lower, winmethod_Above | winmethod_Fixed, 0, wintype_TextGrid, 0); _lower.update();