From 1b8e171944d5092a164205fd78d7ab8c1ed2587f Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 3 Nov 2019 10:09:03 -0800 Subject: GLK: ARCHETYPE: Janitorial --- engines/glk/archetype/parser.cpp | 35 +++++++++++++++++------------------ engines/glk/archetype/sys_object.cpp | 9 +++------ engines/glk/archetype/token.cpp | 9 +++------ 3 files changed, 23 insertions(+), 30 deletions(-) (limited to 'engines') diff --git a/engines/glk/archetype/parser.cpp b/engines/glk/archetype/parser.cpp index 8c1c47c6f5..4867cbb7f2 100644 --- a/engines/glk/archetype/parser.cpp +++ b/engines/glk/archetype/parser.cpp @@ -67,8 +67,7 @@ void normalize_string(const String &first, String &second) { j = 0; in_word = false; second = second + " "; - } - else { + } else { ++i; } @@ -102,24 +101,25 @@ void add_parse_word(TargetListType which_list, String &the_word, int the_object) the_word += '|'; - do { + for (;;) { bar = the_word.indexOf('|'); - if (bar != -1) { - pp = new ParseType(); - tempstr = the_word.left(bar - 1).left(g_vm->Abbreviate); + if (bar == -1) + break; - pp->word = NewConstStr(tempstr); - pp->word->toLowercase(); - the_word = String(the_word.c_str() + bar + 1); - pp->object = the_object; + pp = new ParseType(); + tempstr = the_word.left(bar).left(g_vm->Abbreviate); - np = new NodeType(); - np->key = pp->word->size(); - np->data = pp; + pp->word = NewConstStr(tempstr); + pp->word->toLowercase(); + the_word = String(the_word.c_str() + bar + 1); + pp->object = the_object; - insert_item(the_list, np); - } - } while (bar != 0); + np = new NodeType(); + np->key = pp->word->size(); + np->data = pp; + + insert_item(the_list, np); + } } static void parse_sentence_substitute(int start, ParsePtr pp, int &next_starting) { @@ -235,8 +235,7 @@ bool pop_object(int &intback, String &strback) { // parsed object intback = ((int)g_vm->Command[1] << 8) | ((int)g_vm->Command[2]); g_vm->Command.del(0, 4); - } - else { + } else { intback = -1; i = g_vm->Command.indexOf('%'); if (i < 0) diff --git a/engines/glk/archetype/sys_object.cpp b/engines/glk/archetype/sys_object.cpp index ebbe88202c..761d14ef60 100644 --- a/engines/glk/archetype/sys_object.cpp +++ b/engines/glk/archetype/sys_object.cpp @@ -127,8 +127,7 @@ void send_to_system(int transport, String &strmsg, ResultType &result, ContextTy if (convert_to(NUMERIC, result)) { g_vm->Abbreviate = result._data._numeric.acl_int; - } - else { + } else { wraperr("Warning: non-numeric abbreviation message sent to system"); cleanup(result); } @@ -155,8 +154,7 @@ void send_to_system(int transport, String &strmsg, ResultType &result, ContextTy default: break; } - } - else { + } else { add_parse_word(target_list, strmsg, the_caller); } @@ -273,8 +271,7 @@ void send_to_system(int transport, String &strmsg, ResultType &result, ContextTy if (stfile == nullptr) { g_vm->writeln("Error opening %s", strmsg.c_str()); cleanup(result); - } - else { + } else { save_game_state(stfile, g_vm->Object_List); result._kind = RESERVED; result._data._reserved.keyword = RW_TRUE; diff --git a/engines/glk/archetype/token.cpp b/engines/glk/archetype/token.cpp index 9d550a56d5..060dd1d79e 100644 --- a/engines/glk/archetype/token.cpp +++ b/engines/glk/archetype/token.cpp @@ -188,8 +188,7 @@ bool get_token(progfile &f) { case ';': if (!f.newlines) { state = START; - } - else { + } else { f.ttype = NEWLINE; f.tnum = (int)NEWLINE_CH; state = STOP; @@ -379,8 +378,7 @@ void write_token(AclType the_type, int the_number) { case IDENT: if (the_number < 0) { g_vm->write("an identifier"); - } - else { + } else { g_vm->write(": ", the_number); if (index_ident(the_number, the_id_ptr)) g_vm->write("\"%s\"", the_id_ptr->id_name); @@ -411,8 +409,7 @@ void write_token(AclType the_type, int the_number) { else if (index_xarray(g_vm->Literals, the_number, p)) { str_ptr = (StringPtr)p; g_vm->write("\"%s\"", str_ptr->c_str()); - } - else { + } else { g_vm->write(": ", the_number); } break; -- cgit v1.2.3