mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-06 02:10:28 +00:00
GLK: QUEST: gcc compilation fixes
This commit is contained in:
parent
defc19ada4
commit
643ee33a3d
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 ++)
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -96,6 +96,9 @@ void Quest::playGame() {
|
||||
case evtype_Redraw:
|
||||
draw_banner();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user