diff options
author | Paul Gilbert | 2019-09-29 15:05:58 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-09-29 15:08:52 -0700 |
commit | 643ee33a3deab293c8377ce278866c0e6b241fab (patch) | |
tree | 0e25407d50e6fa48e3995e1481d3e88647c2319c /engines/glk | |
parent | defc19ada4f94d727531a78f0fa1574c328ef06d (diff) | |
download | scummvm-rg350-643ee33a3deab293c8377ce278866c0e6b241fab.tar.gz scummvm-rg350-643ee33a3deab293c8377ce278866c0e6b241fab.tar.bz2 scummvm-rg350-643ee33a3deab293c8377ce278866c0e6b241fab.zip |
GLK: QUEST: gcc compilation fixes
Diffstat (limited to 'engines/glk')
-rw-r--r-- | engines/glk/quest/geas_file.cpp | 46 | ||||
-rw-r--r-- | engines/glk/quest/geas_glk.cpp | 17 | ||||
-rw-r--r-- | engines/glk/quest/geas_runner.cpp | 10 | ||||
-rw-r--r-- | engines/glk/quest/geas_state.cpp | 2 | ||||
-rw-r--r-- | engines/glk/quest/geas_util.cpp | 4 | ||||
-rw-r--r-- | engines/glk/quest/geas_util.h | 4 | ||||
-rw-r--r-- | engines/glk/quest/quest.cpp | 3 | ||||
-rw-r--r-- | engines/glk/quest/streams.cpp | 5 | ||||
-rw-r--r-- | engines/glk/quest/streams.h | 2 |
9 files changed, 49 insertions, 44 deletions
diff --git a/engines/glk/quest/geas_file.cpp b/engines/glk/quest/geas_file.cpp index 05c78e3e08..187c7cc101 100644 --- a/engines/glk/quest/geas_file.cpp +++ b/engines/glk/quest/geas_file.cpp @@ -89,8 +89,6 @@ bool GeasFile::obj_has_property(String objname, String propname) const { return get_obj_property(objname, propname, tmp); } -Common::WriteStream &operator<< (Common::WriteStream &, const Set<String> &); - /** * Currently only works for actual objects, not rooms or the game */ @@ -130,7 +128,7 @@ void GeasFile::get_obj_keys(String obj, Set<String> &rv) const { vstring params = split_param(param_contents(tok)); for (uint j = 0; j < params.size(); j ++) { cerr << " handling parameter <" << params[j] << ">\n"; - uint k = params[j].find('='); + int k = params[j].find('='); // SENSITIVE? if (starts_with(params[j], "not ")) { rv.insert(trim(params[j].substr(4))); @@ -189,7 +187,7 @@ void GeasFile::get_type_keys(String typen, Set<String> &rv) const { else if (tok == "action") { cerr << " action, skipping\n"; } else { - uint ch = line.find('='); + int ch = line.find('='); if (ch != -1) { rv.insert(trim(line.substr(0, ch))); cerr << " adding <" << trim(line.substr(0, ch)) << ">\n"; @@ -262,7 +260,7 @@ bool GeasFile::get_obj_property(String objname, String propname, String &string_ Common::Array<String> props = split_param(param_contents(tok)); for (uint j = 0; j < props.size(); j ++) { //cerr << " g_o_p: Comparing against <" << props[j] << ">\n"; - uint index; + int index; if (props[j] == propname) { //cerr << " g_o_p: Present but empty, blanking\n"; string_rv = ""; @@ -296,6 +294,7 @@ void GeasFile::get_type_property(String typenamex, String propname, bool &bool_r String line = block->data[i]; //cerr << " Comparing vs. line <" << line << ">\n"; uint c1, c2; + int p; String tok = first_token(line, c1, c2); // SENSITIVE? @@ -307,11 +306,11 @@ void GeasFile::get_type_property(String typenamex, String propname, bool &bool_r bool_rv = true; string_rv = ""; } else { - c1 = line.find('='); - if (c1 != -1) { - tok = trim(line.substr(0, c1)); + p = line.find('='); + if (p != -1) { + tok = trim(line.substr(0, p)); if (tok == propname) { - string_rv = trim(line.substr(c1 + 1)); + string_rv = trim(line.substr(p + 1)); bool_rv = true; } } @@ -517,8 +516,7 @@ void GeasFile::register_block(String blockname, String blocktype) { String errdesc = "Trying to register block of named <" + blockname + "> of type <" + blocktype + "> when there is already one, of type <" + obj_types[blockname] + ">"; - debug_print(errdesc); - throw errdesc; + error("%s", errdesc.c_str()); } obj_types[blockname] = blocktype; } @@ -526,14 +524,14 @@ void GeasFile::register_block(String blockname, String blocktype) { String GeasFile::static_svar_lookup(String varname) const { cerr << "static_svar_lookup(" << varname << ")" << endl; //varname = lcase (varname); - for (uint i = 0; i < size("variable"); i ++) + for (uint i = 0; i < size("variable"); i++) { //if (blocks[i].lname == varname) if (ci_equal(blocks[i].name, varname)) { String rv; String tok; uint c1, c2; bool found_typeline = false; - for (uint j = 0; j < blocks[i].data.size(); j ++) { + for (uint j = 0; j < blocks[i].data.size(); j++) { String line = blocks[i].data[j]; tok = first_token(line, c1, c2); // SENSITIVE? @@ -541,26 +539,27 @@ String GeasFile::static_svar_lookup(String varname) const { tok = next_token(line, c1, c2); // SENSITIVE? if (tok == "numeric") - throw String("Trying to evaluate int var '" + varname + - "' as String"); + error("Trying to evaluate int var '%s' as String", varname.c_str()); // SENSITIVE? if (tok != "String") - throw String("Bad variable type " + tok); + error("Bad variable type %s", tok.c_str()); found_typeline = true; } // SENSITIVE? else if (tok == "value") { tok = next_token(line, c1, c2); if (!is_param(tok)) - throw String("Expected param after value in " + line); + error("Expected param after value in %s", line.c_str()); rv = param_contents(tok); } } if (!found_typeline) - throw String(varname + " is a numeric variable"); + error("%s is a numeric variable", varname.c_str()); cerr << "static_svar_lookup(" << varname << ") -> \"" << rv << "\"" << endl; return rv; } + } + debug_print("Variable <" + varname + "> not found."); return ""; } @@ -581,17 +580,16 @@ String GeasFile::static_ivar_lookup(String varname) const { tok = next_token(line, c1, c2); // SENSITIVE? if (tok == "String") - throw String("Trying to evaluate String var '" + varname + - "' as numeric"); + error("Trying to evaluate String var '%s' as numeric", varname.c_str()); // SENSITIVE? if (tok != "numeric") - throw String("Bad variable type " + tok); + error("Bad variable type %s", tok.c_str()); } // SENSITIVE? else if (tok == "value") { tok = next_token(line, c1, c2); if (!is_param(tok)) - throw String("Expected param after value in " + line); + error("Expected param after value in %s", line.c_str()); rv = param_contents(tok); } } @@ -610,7 +608,7 @@ String GeasFile::static_eval(String input) const { for (j = i + 1; j < input.length() && input[j] != '#'; j ++) ; if (j == input.length()) - throw String("Error processing '" + input + "', odd hashes"); + error("Error processing '%s', odd hashes", input.c_str()); uint k; for (k = i + 1; k < j && input[k] != ':'; k ++) ; @@ -643,7 +641,7 @@ String GeasFile::static_eval(String input) const { for (j = i; j < input.length() && input[j] != '%'; j ++) ; if (j == input.length()) - throw String("Error processing '" + input + "', unmatched %"); + error("Error processing '%s', unmatched %%", input.c_str()); rv += static_ivar_lookup(input.substr(i + 1, j - i - 2)); i = j; } else diff --git a/engines/glk/quest/geas_glk.cpp b/engines/glk/quest/geas_glk.cpp index 571be78edc..a71a775f1a 100644 --- a/engines/glk/quest/geas_glk.cpp +++ b/engines/glk/quest/geas_glk.cpp @@ -56,17 +56,14 @@ void draw_banner() { g_vm->glk_window_move_cursor(bannerwin, 1, 0); if (g_vm->banner.empty()) - g_vm->glk_put_string_stream(stream, (char *)"Geas 0.4"); + g_vm->glk_put_string_stream(stream, "Geas 0.4"); else - g_vm->glk_put_string_stream(stream, (char *)g_vm->banner.c_str()); + g_vm->glk_put_string_stream(stream, g_vm->banner.c_str()); } } void glk_put_cstring(const char *s) { - /* The cast to remove const is necessary because g_vm->glk_put_string - * receives a "char *" despite the fact that it could equally well use - * "const char *". */ - g_vm->glk_put_string((char *)s); + g_vm->glk_put_string(s); } GeasResult GeasGlkInterface::print_normal(const String &s) { @@ -152,14 +149,14 @@ String GeasGlkInterface::get_string() { } uint GeasGlkInterface::make_choice(String label, Common::Array<String> v) { - size_t n; + uint n; g_vm->glk_window_clear(inputwin); glk_put_cstring(label.c_str()); g_vm->glk_put_char(0x0a); n = v.size(); - for (size_t i = 0; i < n; ++i) { + for (uint i = 0; i < n; ++i) { StringStream t; String s; t << i + 1; @@ -176,13 +173,13 @@ uint GeasGlkInterface::make_choice(String label, Common::Array<String> v) { t << n; t >> s; s1 = "Choose [1-" + s + "]> "; - g_vm->glk_put_string_stream(inputwinstream, (char *)(s1.c_str())); + g_vm->glk_put_string_stream(inputwinstream, s1.c_str()); int choice = atoi(get_string().c_str()); if (choice < 1) { choice = 1; } - if ((size_t)choice > n) { + if ((uint)choice > n) { choice = n; } diff --git a/engines/glk/quest/geas_runner.cpp b/engines/glk/quest/geas_runner.cpp index 9d4fd32846..665f27d672 100644 --- a/engines/glk/quest/geas_runner.cpp +++ b/engines/glk/quest/geas_runner.cpp @@ -28,7 +28,7 @@ #include "glk/quest/geas_impl.h" #include "glk/quest/quest.h" #include "glk/quest/streams.h" -#include "glk/quest/String.h" +#include "glk/quest/string.h" namespace Glk { namespace Quest { @@ -744,7 +744,7 @@ void geas_implementation::set_game(const String &fname) { continue; // SENSITIVE? if (tok == "multiplayer") - throw String("Error: geas is single player only."); + error("Error: geas is single player only."); gi->debug_print("Unexpected game type " + s); } // SENSITIVE? @@ -1239,7 +1239,7 @@ match_rv geas_implementation::match_command(String input, uint ichar, String act achar ++; } if (achar == action.length()) - throw String("Unpaired hashes in command String " + action); + error("Unpaired hashes in command String %s", action.c_str()); //rv.bindings.push_back (varname); int index = rv.bindings.size(); rv.bindings.push_back(match_binding(varname, ichar)); @@ -2491,7 +2491,7 @@ void geas_implementation::run_script(String s, String &rv) { return; } bool is_while = (tok == "while"); - uint start_cond = c2, end_cond = (uint) -1; + int start_cond = c2, end_cond = -1; while ((tok = next_token(s, c1, c2)) != "") { // SENSITIVE? if (tok == "do") { @@ -3444,7 +3444,7 @@ String geas_implementation::eval_string(String s) { } */ //if (j == rv.size()) - if (j == -1) { + if (j == (uint)-1) { gi->debug_print("Unmatched $s in " + s); return rv + s.substr(i); } diff --git a/engines/glk/quest/geas_state.cpp b/engines/glk/quest/geas_state.cpp index 985b4e935e..3a9b4115c8 100644 --- a/engines/glk/quest/geas_state.cpp +++ b/engines/glk/quest/geas_state.cpp @@ -72,7 +72,7 @@ public: ofstream ofs; ofs.open(savename.c_str()); if (!ofs.is_open()) - throw String("Unable to open \"" + savename + "\""); + error("Unable to open \"%s\"", savename.c_str()); ofs << "QUEST300" << char(0) << gamename << char(0); String tmp = o.str(); for (uint i = 0; i < tmp.size(); i ++) diff --git a/engines/glk/quest/geas_util.cpp b/engines/glk/quest/geas_util.cpp index bc5eaac177..56ea70feef 100644 --- a/engines/glk/quest/geas_util.cpp +++ b/engines/glk/quest/geas_util.cpp @@ -66,7 +66,7 @@ int eval_int(String s) { //cerr << "symbol == " << symbol << "; find --> " // << String("+-*/").find (symbol) << endl; - if (String("+-*/").find(symbol) == String::npos) + if (String("+-*/").find(symbol) == (int)String::npos) return arg1; ++ index; @@ -171,7 +171,7 @@ String lcase(String s) { Common::Array<String> split_param(String s) { Common::Array<String> rv; - uint c1 = 0, c2; + int c1 = 0, c2; for (;;) { c2 = s.find(';', c1); diff --git a/engines/glk/quest/geas_util.h b/engines/glk/quest/geas_util.h index 2cedadde02..d63004ed56 100644 --- a/engines/glk/quest/geas_util.h +++ b/engines/glk/quest/geas_util.h @@ -24,7 +24,7 @@ #define GLK_QUEST_GEAS_UTIL #include "glk/quest/read_file.h" -#include "common/stream.h" +#include "glk/quest/streams.h" namespace Glk { namespace Quest { @@ -73,7 +73,7 @@ template<class T> Common::WriteStream &operator<<(Common::WriteStream &o, Common template <class KEYTYPE, class VALTYPE> bool has(Common::HashMap<KEYTYPE, VALTYPE, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> m, KEYTYPE key) { return m.contains(key); -}; +} class Logger { public: diff --git a/engines/glk/quest/quest.cpp b/engines/glk/quest/quest.cpp index cbddedaba8..8536f691bb 100644 --- a/engines/glk/quest/quest.cpp +++ b/engines/glk/quest/quest.cpp @@ -96,6 +96,9 @@ void Quest::playGame() { case evtype_Redraw: draw_banner(); break; + + default: + break; } } } diff --git a/engines/glk/quest/streams.cpp b/engines/glk/quest/streams.cpp index 1b49d2a6ec..bd64df31f2 100644 --- a/engines/glk/quest/streams.cpp +++ b/engines/glk/quest/streams.cpp @@ -60,6 +60,11 @@ Common::WriteStream &operator<<(Common::WriteStream &ws, const String &s) { return ws; } +Common::WriteStream &operator<<(Common::WriteStream &ws, const char *s) { + ws.write(s, strlen(s)); + return ws; +} + Common::WriteStream &operator<<(Common::WriteStream &ws, char c) { ws.writeByte(c); return ws; diff --git a/engines/glk/quest/streams.h b/engines/glk/quest/streams.h index 3a8d2a4a60..8bfa6ae351 100644 --- a/engines/glk/quest/streams.h +++ b/engines/glk/quest/streams.h @@ -75,9 +75,11 @@ extern const char endl; #define cerr (*g_cerr) Common::WriteStream &operator<<(Common::WriteStream &, const String &); +Common::WriteStream &operator<<(Common::WriteStream &, const char *); Common::WriteStream &operator<<(Common::WriteStream &, char); Common::WriteStream &operator<<(Common::WriteStream &, int); Common::WriteStream &operator<<(Common::WriteStream &, uint); +Common::WriteStream &operator<<(Common::WriteStream &, size_t); } // End of namespace Quest } // End of namespace Glk |