GLK: Use nullptr

Using clang-tidy modernize-use-nullptr
This commit is contained in:
Orgad Shaneh 2021-11-13 23:40:25 +02:00 committed by Filippos Karapetis
parent 2c23cf985f
commit 0111a08560
134 changed files with 2516 additions and 2516 deletions

View file

@ -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();

View file

@ -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

View file

@ -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);

View file

@ -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;
}

View file

@ -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:

View file

@ -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);

View file

@ -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;
}

View file

@ -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
};
/*

View file

@ -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++) {

View file

@ -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;
/*

View file

@ -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);

View file

@ -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. */

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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)

View file

@ -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;

View file

@ -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}
};

View file

@ -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)

View file

@ -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) {

View file

@ -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;
}

View file

@ -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, "<Sigh> $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();

View file

@ -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 */

View file

@ -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);

View file

@ -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 <fname>.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);
}

View file

@ -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;
}

View file

@ -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]);

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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.");
}

View file

@ -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,

View file

@ -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;
}

View file

@ -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");

View file

@ -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 */
}

View file

@ -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 */

View file

@ -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;
}

View file

@ -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 */

View file

@ -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;

View file

@ -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");

View file

@ -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]);
}

View file

@ -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);

View file

@ -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<VERB %d, CHECK, GLOBAL:>\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<VERB %d, CHECK, in LOCATION:>\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<VERB %d, CHECK, in Parameter #%d:>\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*/

View file

@ -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));

View file

@ -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);
}

View file

@ -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)

View file

@ -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)

View file

@ -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);

View file

@ -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));

View file

@ -27,7 +27,7 @@ namespace Alan3 {
/* PUBLIC DATA */
int eventQueueSize = 0;
EventQueueEntry *eventQueue = NULL;
EventQueueEntry *eventQueue = nullptr;
int eventQueueTop = 0;
EventEntry *events;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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++)
;

View file

@ -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();

View file

@ -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));

View file

@ -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. */

View file

@ -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);

View file

@ -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(&parameters1[i]); i++) {
if (isEndOfArray(&parameters2[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))

View file

@ -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 = &parameterPositions[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

View file

@ -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;

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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,

View file

@ -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;
}

View file

@ -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;

View file

@ -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);
}

View file

@ -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 = "<If you are the creator of this piece of Interactive Fiction, \
please help debug this Alan system error. Collect *all* the sources, and, if possible, an \
exact transcript of the commands that led to this error, in a zip-file and send \
@ -81,7 +81,7 @@ it to support@alanif.se. Thank you!>";
/*======================================================================*/
void apperr(const char *description) {
if (handler == NULL) {
if (handler == nullptr) {
const char *blurb = "<If you are playing this piece of Interactive Fiction, \
please help the author to debug this programming error. Send an exact \
transcript of the commands that led to this error to the author. Thank you! \
@ -93,7 +93,7 @@ If you *are* the author, then you have to figure this out before releasing the g
/*======================================================================*/
void playererr(CONTEXT, const char *description) {
if (handler == NULL) {
if (handler == nullptr) {
const char *blurb = "<You have probably done something that is not exactly right.>";
runtimeError(context, "PLAYER ERROR: ", description, blurb);
} else

View file

@ -32,7 +32,7 @@ namespace Alan3 {
/* PUBLIC DATA */
/* List of parsed words, index into dictionary */
Word *playerWords = NULL;
Word *playerWords = nullptr;
int currentWordIndex; /* An index into the list of playerWords */
int firstWord, lastWord; /* Index for the first and last words for this command */
@ -55,7 +55,7 @@ void ensureSpaceForPlayerWords(int size) {
if (playerWordsLength < size + 1) {
playerWords = (Word *)realloc(playerWords, newLength * sizeof(Word));
if (playerWords == NULL)
if (playerWords == nullptr)
syserr("Out of memory in 'ensureSpaceForPlayerWords()'");
playerWordsLength = newLength;
}

View file

@ -84,7 +84,7 @@ bool Archetype::initialize() {
NullStr = NewConstStr("null");
// GLK window
_mainWindow = glk_window_open(0, 0, 0, wintype_TextBuffer);
_mainWindow = glk_window_open(nullptr, 0, 0, wintype_TextBuffer);
glk_set_window(_mainWindow);
// Check for savegame to load

View file

@ -83,7 +83,7 @@ void Comprehend::runGame() {
}
void Comprehend::initialize() {
_bottomWindow = (TextBufferWindow *)glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
_bottomWindow = (TextBufferWindow *)glk_window_open(nullptr, 0, 0, wintype_TextBuffer, 1);
glk_set_window(_bottomWindow);
showGraphics();

View file

@ -198,7 +198,7 @@ void DebuggerDumper::dumpFunction(uint functionNum) {
print("[%.4x] (%u instructions)\n", functionNum, func.size());
for (uint i = 0; i < func.size(); i++) {
Common::String line = dumpInstruction(_game, NULL, &func[i]);
Common::String line = dumpInstruction(_game, nullptr, &func[i]);
print("%s\n", line.c_str());
}

View file

@ -41,13 +41,13 @@ Word *dict_find_word_by_string(ComprehendGame *game,
uint i;
if (!string)
return NULL;
return nullptr;
for (i = 0; i < game->_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,

View file

@ -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:

View file

@ -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;

View file

@ -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

View file

@ -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;
}

View file

@ -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;

View file

@ -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)) {

View file

@ -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);
}

File diff suppressed because it is too large Load diff

View file

@ -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;
}
}

View file

@ -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);

View file

@ -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);

File diff suppressed because it is too large Load diff

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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 <http://users.skynet.be/sky39147/>.
*/
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

View file

@ -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) */

View file

@ -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();

View file

@ -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;

View file

@ -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. */

View file

@ -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<String> &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<String> &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<String> &rv) const {
void GeasFile::get_type_keys(String typen, Set<String> &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;
}

View file

@ -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);

View file

@ -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<Common::Array<String> > geas_implementation::get_places(String roo
Common::Array<Common::Array<String> > 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<Common::Array<String> > 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;

Some files were not shown because too many files have changed in this diff Show more