diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-02-26 07:49:33 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-02-26 07:49:33 -0500 |
commit | 26d71799f37bc325b6db0214268f4e72eb970ee9 (patch) | |
tree | 41306f63fc17fd176d720df8dfb90dde6bdc5159 /src/world.cpp | |
parent | 8f4cada7bf1068a9a3063636f7008cbe52875924 (diff) |
village cleanup?
Diffstat (limited to 'src/world.cpp')
-rw-r--r-- | src/world.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/world.cpp b/src/world.cpp index 2df0712..303d53b 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -999,13 +999,13 @@ void World::detect(Player *p){ } for(auto &v : village){ - if(p->loc.x > v.start.x && p->loc.x < v.end.x){ - if(!v.in){ - ui::passiveImportantText(5000,"Welcome to %s",v.name.c_str()); - v.in = true; + if(p->loc.x > v->start.x && p->loc.x < v->end.x){ + if(!v->in){ + ui::passiveImportantText(5000,"Welcome to %s",v->name.c_str()); + v->in = true; } }else{ - v.in = false; + v->in = false; } } @@ -1614,8 +1614,11 @@ World *loadWorldFromXMLNoSave(const char *path){ wxml = wxml->NextSiblingElement(); } + Village *vptr; + if(vil){ - tmp->village.push_back(vil->Attribute("name")); + tmp->village.push_back(new Village(vil->Attribute("name"), tmp)); + vptr = tmp->village.back(); vil = vil->FirstChildElement(); } @@ -1627,22 +1630,22 @@ World *loadWorldFromXMLNoSave(const char *path){ /** * READS DATA ABOUT STRUCTURE CONTAINED IN VILLAGE */ + if(!strcmp(name,"structure")){ ptr = vil->Attribute("inside"); tmp->addStructure((BUILD_SUB)vil->UnsignedAttribute("type"), - vil->QueryFloatAttribute("x", &spawnx) != XML_NO_ERROR ? - randx : spawnx, + vil->QueryFloatAttribute("x", &spawnx) != XML_NO_ERROR ? randx : spawnx, 100, (char*)vil->Attribute("texture"), ptr); - tmp->village.back().build.push_back(tmp->build.back()); + vptr->build.push_back(tmp->build.back()); } - if(tmp->village.back().build.back()->loc.x < tmp->village.back().start.x){ - tmp->village.back().start.x = tmp->village.back().build.back()->loc.x; + if(vptr->build.back()->loc.x < vptr->start.x){ + vptr->start.x = vptr->build.back()->loc.x; } - if(tmp->village.back().build.back()->loc.x + tmp->village.back().build.back()->width > tmp->village.back().end.x){ - tmp->village.back().end.x = tmp->village.back().build.back()->loc.x + tmp->village.back().build.back()->width; + if(vptr->build.back()->loc.x + vptr->build.back()->width > vptr->end.x){ + vptr->end.x = vptr->build.back()->loc.x + vptr->build.back()->width; } //go to the next element in the village block @@ -1657,3 +1660,10 @@ World *loadWorldFromXMLNoSave(const char *path){ return tmp; } + +Village::Village(const char *meme, World *w){ + name = meme; + start.x = w->getTheWidth() / 2.0f; + end.x = -start.x; + in = false; +} |