GLK: Avoid global constructors

This commit is contained in:
Paweł Kołodziejski 2022-05-29 19:05:51 +02:00
parent da67efb306
commit e632a94cd4
No known key found for this signature in database
GPG Key ID: 0BDADC9E74440FF7
3 changed files with 12 additions and 15 deletions

View File

@ -32,9 +32,6 @@ 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 *) 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);
@ -96,18 +93,19 @@ bool GeasFile::obj_has_property(String objname, String propname) const {
//Set<String, CI_LESS> GeasFile::get_obj_keys (String obj) const
Set<String> GeasFile::get_obj_keys(String obj) const {
//Set<String, CI_LESS> rv;
reserved_words obj_tag_property("look", "examine", "speak", "take", "alias", "prefix", "suffix", "detail", "displaytype", "gender", "article", "hidden", "invisible", (char *) nullptr);
Set<String> rv;
get_obj_keys(obj, rv);
get_obj_keys(obj, rv, obj_tag_property);
return rv;
}
void GeasFile::get_obj_keys(String obj, Set<String> &rv) const {
void GeasFile::get_obj_keys(String obj, Set<String> &rv, const reserved_words &obj_tag_property) const {
cerr << "get_obj_keys (gf, <" << obj << ">)\n";
//Set<String> rv;
uint c1, c2;
String tok, line;
reserved_words *rw = nullptr;
const reserved_words *rw = nullptr;
const GeasBlock *gb = find_by_name("object", obj);
rw = &obj_tag_property;

View File

@ -80,7 +80,7 @@ struct GeasFile {
const GeasBlock &block(String type, uint index) const;
uint size(String type) const;
void read_into(const Common::Array<String> &, String, uint, bool, const reserved_words &, const reserved_words &);
void read_into(const Common::Array<String> &, String, uint, bool, const reserved_words &, const reserved_words &, const reserved_words &);
@ -98,7 +98,7 @@ struct GeasFile {
bool type_of_type(String subtype, String supertype) const;
Set<String> get_obj_keys(String obj) const;
void get_obj_keys(String, Set<String> &) const;
void get_obj_keys(String, Set<String> &, const reserved_words &obj_tag_property) const;
void get_type_keys(String, Set<String> &) const;
bool obj_has_action(String objname, String propname) const;

View File

@ -131,13 +131,11 @@ bool is_end_define(String s) {
extern Common::Array<String> split_lines(String data);
// FIXME: This requires global constructor
reserved_words dir_tag_property("north", "south", "east", "west", "northwest", "northeast", "southeast", "southwest", "up", "down", "out", (char *) nullptr);
void GeasFile::read_into(const Common::Array<String> &in_data,
String in_parent, uint cur_line, bool recurse,
const reserved_words &props,
const reserved_words &actions) {
const reserved_words &actions,
const reserved_words &dir_tag_property) {
//cerr << "r_i: Reading in from" << cur_line << ": " << in_data[cur_line] << endl;
//output.push_back (GeasBlock());
//GeasBlock &out_block = output[output.size() - 1];
@ -302,6 +300,7 @@ GeasFile::GeasFile(const Common::Array<String> &v, GeasInterface *_gi) : gi(_gi)
reserved_words recursive_passes("game", "room", (char *) nullptr),
object_passes("game", "room", "objects", (char *) nullptr);
reserved_words dir_tag_property("north", "south", "east", "west", "northwest", "northeast", "southeast", "southwest", "up", "down", "out", (char *) nullptr);
//Common::Array <GeasBlock> outv;
for (uint pass = 0; pass < sizeof(pass_names) / sizeof(*pass_names);
@ -333,14 +332,14 @@ GeasFile::GeasFile(const Common::Array<String> &v, GeasInterface *_gi) : gi(_gi)
// SENSITIVE?
if (blocktype == this_pass)
read_into(v, "", i, recursive, props, actions);
read_into(v, "", i, recursive, props, actions, dir_tag_property);
} else if (depth == 2 && blocktype == this_pass) {
// SENSITIVE?
if (this_pass == "object" && parenttype == "room")
read_into(v, parentname, i, false, props, actions);
read_into(v, parentname, i, false, props, actions, dir_tag_property);
// SENSITIVE?
else if (this_pass == "variable" && parenttype == "game")
read_into(v, "", i, false, props, actions);
read_into(v, "", i, false, props, actions, dir_tag_property);
}
} else if (is_end_define(v[i]))
-- depth;