Skip to content

Commit

Permalink
WAGE: Put lists into typedefs
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Jan 9, 2016
1 parent 9b8e502 commit 3906c36
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion engines/wage/combat.cpp
Expand Up @@ -139,7 +139,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
hat.addTokens(kTokOffer, npc->_losingOffer + 1);
}

Common::List<Obj *> *objs = &npc->_currentScene->_objs;
ObjList *objs = &npc->_currentScene->_objs;
if (npc->_inventory.size() < npc->_maximumCarriedObjects) {
int cnt = 0;
for (ObjList::const_iterator it = objs->begin(); it != objs->end(); ++it, ++cnt) {
Expand Down
4 changes: 2 additions & 2 deletions engines/wage/entities.cpp
Expand Up @@ -138,12 +138,12 @@ void Scene::paint(Graphics::Surface *surface, int x, int y) {

_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);

for (Common::List<Obj *>::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
for (ObjList::const_iterator it = _objs.begin(); it != _objs.end(); ++it) {
debug(2, "paining Obj: %s", (*it)->_name.c_str());
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
}

for (Common::List<Chr *>::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
for (ChrList::const_iterator it = _chrs.begin(); it != _chrs.end(); ++it) {
debug(2, "paining Chr: %s", (*it)->_name.c_str());
(*it)->_design->paint(surface, ((WageEngine *)g_engine)->_world->_patterns, x, y);
}
Expand Down
7 changes: 4 additions & 3 deletions engines/wage/entities.h
Expand Up @@ -64,6 +64,7 @@ typedef Common::Array<Weapon *> WeaponArray;
typedef Common::Array<Obj *> ObjArray;
typedef Common::Array<Chr *> ChrArray;
typedef Common::List<Obj *> ObjList;
typedef Common::List<Chr *> ChrList;

enum StatVariable {
/** The base physical accuracy of the player. */
Expand Down Expand Up @@ -212,7 +213,7 @@ class Chr : public Designed {
String _dyingWords;

Scene *_currentScene;
Common::Array<Obj *> _inventory;
ObjArray _inventory;

Obj *_armor[NUMBER_OF_ARMOR_TYPES];

Expand Down Expand Up @@ -342,8 +343,8 @@ class Scene : public Designed {
int _worldY;
bool _visited;

Common::List<Obj *> _objs;
Common::List<Chr *> _chrs;
ObjList _objs;
ChrList _chrs;

Scene();
Scene(String name, Common::SeekableReadStream *data);
Expand Down
4 changes: 2 additions & 2 deletions engines/wage/gui.cpp
Expand Up @@ -639,12 +639,12 @@ Designed *Gui::getClickTarget(int x, int y) {
_bordersDirty = true;
}

for (Common::List<Obj *>::const_iterator it = _scene->_objs.begin(); it != _scene->_objs.end(); ++it) {
for (ObjList::const_iterator it = _scene->_objs.begin(); it != _scene->_objs.end(); ++it) {
if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
return *it;
}

for (Common::List<Chr *>::const_iterator it = _scene->_chrs.begin(); it != _scene->_chrs.end(); ++it) {
for (ChrList::const_iterator it = _scene->_chrs.begin(); it != _scene->_chrs.end(); ++it) {
if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
return *it;
}
Expand Down
12 changes: 6 additions & 6 deletions engines/wage/script.cpp
Expand Up @@ -588,17 +588,17 @@ bool Script::compare(Operand *o1, Operand *o2, int comparator) {
case kCompEqNumNum:
return o1->_value.number == o2->_value.number;
case kCompEqObjScene:
for (Common::List<Obj *>::const_iterator it = o2->_value.scene->_objs.begin(); it != o2->_value.scene->_objs.end(); ++it)
for (ObjList::const_iterator it = o2->_value.scene->_objs.begin(); it != o2->_value.scene->_objs.end(); ++it)
if (*it == o1->_value.obj)
return true;
return false;
case kCompEqChrScene:
for (Common::List<Chr *>::const_iterator it = o2->_value.scene->_chrs.begin(); it != o2->_value.scene->_chrs.end(); ++it)
for (ChrList::const_iterator it = o2->_value.scene->_chrs.begin(); it != o2->_value.scene->_chrs.end(); ++it)
if (*it == o1->_value.chr)
return true;
return false;
case kCompEqObjChr:
for (Common::Array<Obj *>::const_iterator it = o2->_value.chr->_inventory.begin(); it != o2->_value.chr->_inventory.end(); ++it)
for (ObjArray::const_iterator it = o2->_value.chr->_inventory.begin(); it != o2->_value.chr->_inventory.end(); ++it)
if (*it == o1->_value.obj)
return true;
return false;
Expand Down Expand Up @@ -988,9 +988,9 @@ void Script::handleLookCommand() {
}

Common::String *Script::getGroundItemsList(Scene *scene) {
Common::Array<Obj *> objs;
ObjArray objs;

for (Common::List<Obj *>::const_iterator it = scene->_objs.begin(); it != scene->_objs.end(); ++it)
for (ObjList::const_iterator it = scene->_objs.begin(); it != scene->_objs.end(); ++it)
if ((*it)->_type != Obj::IMMOBILE_OBJECT)
objs.push_back(*it);

Expand All @@ -1002,7 +1002,7 @@ Common::String *Script::getGroundItemsList(Scene *scene) {
return NULL;
}

void Script::appendObjNames(Common::String &str, Common::Array<Obj *> &objs) {
void Script::appendObjNames(Common::String &str, ObjArray &objs) {
for (uint i = 0; i < objs.size(); i++) {
Obj *obj = objs[i];

Expand Down
2 changes: 1 addition & 1 deletion engines/wage/script.h
Expand Up @@ -174,7 +174,7 @@ class Script {
void handleMoveCommand(Scene::Directions dir, const char *dirName);
void handleLookCommand();
Common::String *getGroundItemsList(Scene *scene);
void appendObjNames(Common::String &str, Common::Array<Obj *> &objs);
void appendObjNames(Common::String &str, ObjArray &objs);
void handleInventoryCommand();
void handleStatusCommand();
void handleRestCommand();
Expand Down
2 changes: 1 addition & 1 deletion engines/wage/wage.cpp
Expand Up @@ -370,7 +370,7 @@ void WageEngine::processTurnInternal(Common::String *textInput, Designed *clickI
_running = NULL;
_offer = NULL;

for (Common::List<Chr *>::const_iterator it = playerScene->_chrs.begin(); it != playerScene->_chrs.end(); ++it) {
for (ChrList::const_iterator it = playerScene->_chrs.begin(); it != playerScene->_chrs.end(); ++it) {
if (!(*it)->_playerCharacter) {
_monster = *it;
shouldEncounter = true;
Expand Down
4 changes: 2 additions & 2 deletions engines/wage/world.h
Expand Up @@ -81,8 +81,8 @@ class World {
Common::HashMap<String, Chr *> _chrs;
Common::HashMap<String, Sound *> _sounds;
Common::Array<Scene *> _orderedScenes;
Common::Array<Obj *> _orderedObjs;
Common::Array<Chr *> _orderedChrs;
ObjArray _orderedObjs;
ChrArray _orderedChrs;
Common::Array<Sound *> _orderedSounds;
Patterns _patterns;
Scene *_storageScene;
Expand Down

0 comments on commit 3906c36

Please sign in to comment.