diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/entities.cpp | 22 | ||||
-rw-r--r-- | src/gameplay.cpp | 18 | ||||
-rw-r--r-- | src/inventory.cpp | 10 | ||||
-rw-r--r-- | src/ui.cpp | 182 | ||||
-rw-r--r-- | src/world.cpp | 170 |
5 files changed, 223 insertions, 179 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index 6d0f052..c047eff 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -581,17 +581,19 @@ void Mob::wander(int timeRun){ if(aggressive && !YAYA && player->loc.x + (width / 2) > loc.x && player->loc.x + (width / 2) < loc.x + width && player->loc.y + (height / 3) > loc.y && player->loc.y + (height / 3) < loc.y + height ){ - Arena *a = new Arena(currentWorld,player,this); - a->setStyle(""); - a->setBackground( WorldBGType::Forest ); - a->setBGM("assets/music/embark.wav"); + if ( !ui::dialogBoxExists ) { + Arena *a = new Arena(currentWorld,player,this); + a->setStyle(""); + a->setBackground( WorldBGType::Forest ); + a->setBGM("assets/music/embark.wav"); - ui::toggleWhiteFast(); - YAYA = true; - ui::waitForCover(); - YAYA = false; - currentWorld = a; - ui::toggleWhiteFast(); + ui::toggleWhiteFast(); + YAYA = true; + ui::waitForCover(); + YAYA = false; + currentWorld = a; + ui::toggleWhiteFast(); + } } switch(subtype){ diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 7d52629..075aec3 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -9,7 +9,6 @@ using namespace tinyxml2; extern Player *player; // main.cpp extern World *currentWorld; // main.cpp -extern float shit; extern Menu *currentMenu; extern Menu pauseMenu; extern Menu optionsMenu; @@ -23,7 +22,7 @@ std::vector<XMLElement *> dopt; void destroyEverything(void); -void segFault(){ +inline void segFault() { (*((int *)NULL))++; } @@ -210,6 +209,21 @@ CONT: return 0; } +void commonPageFunc( Mob *callee ) +{ + static bool lock = false; + + if ( !lock ) { + lock = true; + + ui::drawPage( callee->heyid ); + ui::waitForDialog(); + + callee->alive = false; + lock = false; + } +} + void commonTriggerFunc(Mob *callee){ static bool lock = false; XMLDocument xml; diff --git a/src/inventory.cpp b/src/inventory.cpp index 1390719..7ba5909 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -143,12 +143,12 @@ const char *getItemTexturePath(std::string name){ } GLuint getItemTexture(std::string name){ - for(auto &i : itemMap){ - if(i->name == name) - return Texture::loadTexture(i->texloc); + for ( int i = itemMap.size(); i--; ) { + if ( itemMap[i]->name == name ) + return itemtex[i]; } - - return Texture::loadTexture("assets/items/ITEM_TEST.png"); + DEBUG_printf("Failed to find texture for item %s!", name.c_str() ); + return 0; } float getItemWidth(std::string name){ @@ -6,7 +6,7 @@ #define SDL_KEY e.key.keysym.sym -extern std::vector<menuItem>optionsMenu; +extern std::vector<menuItem> optionsMenu; extern SDL_Window *window; @@ -82,6 +82,8 @@ Mix_Chunk *battleStart; Mix_Chunk *sanic; +static GLuint pageTex = 0; + void Menu::gotoParent(){ if(parent == NULL){ currentMenu = NULL; @@ -126,7 +128,6 @@ namespace ui { int fontTransInv = 255; - /* * Dialog stuff that needs to be 'public'. */ @@ -323,11 +324,9 @@ namespace ui { * Draw a string at the specified coordinates. */ - float putString(const float x,const float y,const char *s){ + float putString( const float x, const float y, std::string s ) { unsigned int i=0; - float xo=x,yo=y; - vec2 add; - //vec2 off = { (float)floor(x), (float)floor(y) }; + vec2 add, o = {x, y}; /* * Loop on each character: @@ -335,57 +334,67 @@ namespace ui { do{ if(i && ((i / 110.0) == (i / 110))){ - yo-=fontSize*1.05; - xo=x; + o.y -= fontSize * 1.05f; + o.x = x; if(s[i] == ' ') i++; } + if(i && (i / (float)textWrapLimit == i / textWrapLimit)){ - yo -= fontSize * 1.05; - xo = x; + o.y -= fontSize * 1.05f; + o.x = x; // skip a space if it's there since we just newline'd if(s[i] == ' ') i++; } - if(s[i] == '\n'){ - yo-=fontSize*1.05; - xo=x; - }else if(s[i] == '\r' || s[i] == '\t'){ - /*if(s[i] == '\n'){ - yo-=fontSize*1.05; - xo=x; - */}else if(s[i]==' '){ // Handle spaces - xo+=fontSize/2; - }else if(s[i]=='\b'){ // Handle backspaces? - xo-=add.x; - }else{ - add=putChar(floor(xo),floor(yo),s[i]); - xo+=add.x; - yo+=add.y; + + switch ( s[i] ) { + case '\n': + o.y -= fontSize * 1.05f; + o.x = x; + break; + case '\r': + break; + case '\t': + break; + case '\b': + o.x -= add.x; + break; + case ' ': + o.x += fontSize / 2; + break; + default: + add = putChar( floor(o.x), floor(o.y), s[i] ); + o.x += add.x; + o.y += add.y; + break; } + }while(s[++i]); - return xo; // i.e. the string width + return o.x; // i.e. the string width } - float putStringCentered(const float x,const float y,const char *s){ + float putStringCentered( const float x, const float y, std::string s ) { unsigned int i = 0; float width = 0; - do{ - if(s[i]=='\n'){ // Handle newlines + do { + switch ( s[i] ) { + case '\n': // TODO - }else if(s[i]==' '){ // Handle spaces - width+=fontSize/2; - }else if(s[i]=='\b'){ // Handle backspaces? - // Why? - // Cuz - }else{ - width+=ftexwh[i].x+fontSize*.1; + break; + case '\b': + break; + case ' ': + width += fontSize / 2; + break; + default: + width += ftexwh[i].x + fontSize * 0.1f; + break; } - }while(s[++i]); - + } while(s[++i]); putString(floor(x-width/2),y,s); return width; } @@ -395,28 +404,18 @@ namespace ui { * to this function. Passing a different string to the function will reset the counters. */ - static char *ret = NULL; - char *typeOut(char *str){ + std::string ret; + std::string typeOut(char *str){ static unsigned int sinc, // Acts as a delayer for the space between each character. linc=0, // Contains the number of letters that should be drawn. size=0; // Contains the full size of the current string. - //static char *ret = NULL; - - /* - * Create a well-sized buffer if we haven't yet. - */ - - if(!ret){ - ret = new char[512]; //(char *)calloc(512,sizeof(char)); - memset(ret,0,512*sizeof(char)); - } /* * Reset values if a new string is being passed. */ - if(strncmp(ret,str,linc-1)){ - memset(ret,0,512); // Zero the buffer + if(strncmp(ret.c_str(),str,linc-1)){ + ret.clear(); // Zero the buffer size=strlen(str); // Set the new target string size linc=0; // Reset the incrementers sinc=1; @@ -432,7 +431,7 @@ namespace ui { else if(++sinc==2){ sinc=0; - strncpy(ret+linc,str+linc,1); // Get next character + ret.append( 1, *(str + linc) ); if(linc<size) linc++; @@ -542,8 +541,7 @@ namespace ui { dialogBoxExists = true; dialogImportant = false; - if(ret) - ret[0] = '\0'; + ret.clear(); } @@ -604,9 +602,7 @@ namespace ui { dialogMerchant = true; textWrapLimit = 50; - // kill the string created by typeOut if it contains something - if(ret) - *ret = '\0'; + ret.clear(); } void merchantBox(){ @@ -669,12 +665,28 @@ namespace ui { } + void drawPage( std::string path ) { + pageTex = Texture::loadTexture( path ); + } + void draw(void){ unsigned char i; float x,y,tmp; - char *rtext; + std::string rtext; + + if ( pageTex ) { - if(dialogBoxExists){ + glEnable( GL_TEXTURE_2D); + glBindTexture( GL_TEXTURE_2D, pageTex ); + glBegin( GL_QUADS ); + glTexCoord2i( 0, 0 ); glVertex2i( offset.x - 300, SCREEN_HEIGHT - 100 ); + glTexCoord2i( 1, 0 ); glVertex2i( offset.x + 300, SCREEN_HEIGHT - 100 ); + glTexCoord2i( 1, 1 ); glVertex2i( offset.x + 300, SCREEN_HEIGHT - 600 ); + glTexCoord2i( 0, 1 ); glVertex2i( offset.x - 300, SCREEN_HEIGHT - 600 ); + glEnd(); + glDisable( GL_TEXTURE_2D); + + } else if (dialogBoxExists){ rtext=typeOut(dialogBoxText); @@ -690,7 +702,7 @@ namespace ui { } if(fadeIntensity == 255 || dialogPassive){ setFontSize(24); - putStringCentered(offset.x,offset.y,rtext); + putStringCentered(offset.x,offset.y,rtext.c_str()); setFontSize(16); } }else if(dialogMerchant){ @@ -702,11 +714,11 @@ namespace ui { glColor3ub(255,255,255); glBegin(GL_LINE_STRIP); - glVertex2f(x-1 ,y+1); + glVertex2f(x-1 ,y+1); glVertex2f(x+1+(SCREEN_WIDTH/3),y+1); glVertex2f(x+1+(SCREEN_WIDTH/3),y-1-SCREEN_HEIGHT*.6); glVertex2f(x-1,y-1-SCREEN_HEIGHT*.6); - glVertex2f(x-1,y+1); + glVertex2f(x - 1,y+1); glEnd(); glColor3ub(0,0,0); @@ -832,9 +844,8 @@ namespace ui { setFontColor(255,255,255); } - if(strcmp(rtext,dialogBoxText)){ + if ( rtext != dialogBoxText ) Mix_PlayChannel(1,dialogClick,0); - } }if(!fadeIntensity){ vec2 hub = { @@ -1230,6 +1241,13 @@ namespace ui { void dialogAdvance(void){ unsigned char i; + + if ( pageTex ) { + glDeleteTextures( 1, &pageTex ); + pageTex = 0; + return; + } + if(!typeOutDone){ typeOutDone = true; return; @@ -1299,7 +1317,7 @@ namespace ui { // mouse clicks case SDL_MOUSEBUTTONDOWN: // right click advances dialog - if ( ( e.button.button & SDL_BUTTON_RIGHT ) && dialogBoxExists ) + if ( ( e.button.button & SDL_BUTTON_RIGHT ) && (dialogBoxExists | pageTex) ) dialogAdvance(); // left click uses item if ( ( e.button.button & SDL_BUTTON_LEFT ) && !dialogBoxExists ) @@ -1344,7 +1362,7 @@ namespace ui { player->right = false; left = true; right = false; - if(currentWorld->toLeft){ + if ( !currentWorld->toLeft.empty() ) { oldpos = player->loc; if((tmp = currentWorld->goWorldLeft(player)) != currentWorld){ tmppos = player->loc; @@ -1366,7 +1384,7 @@ namespace ui { player->left = false; left = false; right = true; - if(currentWorld->toRight){ + if ( !currentWorld->toRight.empty() ) { oldpos = player->loc; if((tmp = currentWorld->goWorldRight(player)) != currentWorld){ tmppos = player->loc; @@ -1384,37 +1402,17 @@ namespace ui { case SDLK_s: break; case SDLK_w: - if(inBattle){ + if ( inBattle ) { tmp = currentWorld; - currentWorld = ((Arena *)currentWorld)->exitArena(player); - if(tmp != currentWorld){ - //delete &tmp; + currentWorld = ((Arena *)currentWorld)->exitArena( player ); + if ( tmp != currentWorld ) toggleBlackFast(); - } - }else{ - if((tmp = currentWorld->goInsideStructure(player)) != currentWorld) + } else if( (tmp = currentWorld->goInsideStructure( player )) != currentWorld ) currentWorld = tmp; - } break; case SDLK_i: - /*currentWorld=currentWorld->goWorldBack(player); // Go back a layer if possible - if(tmp!=currentWorld){ - currentWorld->detect(player); - player->vel.y=.2; - player->loc.y+=HLINE*5; - player->ground=false; - }*/ player->health -= 5; break; - case SDLK_k: - /*currentWorld=currentWorld->goWorldFront(player); // Go forward a layer if possible - if(tmp!=currentWorld){ - currentWorld->behind->detect(player); - player->vel.y=.2; - player->loc.y+=HLINE*5; - player->ground=false; - }*/ - break; case SDLK_LSHIFT: if(debug){ Mix_PlayChannel(1,sanic,-1); diff --git a/src/world.cpp b/src/world.cpp index c31f551..b1eb12e 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -23,7 +23,8 @@ using namespace tinyxml2; extern Player *player; // main.cpp? extern World *currentWorld; // main.cpp extern int commonAIFunc(NPC *); // entities.cpp -extern void commonTriggerFunc(Mob *); // entities.cpp +extern void commonTriggerFunc(Mob *); // gameplay.cpp +extern void commonPageFunc(Mob *); // gameplay.cpp extern bool inBattle; extern unsigned int tickCount; // main.cpp @@ -150,9 +151,6 @@ World:: World( void ) { bgmObj = NULL; - - toLeft = NULL; - toRight = NULL; } /** @@ -220,10 +218,6 @@ World:: Mix_FreeMusic(bgmObj); delete bgTex; - - delete[] toLeft; - delete[] toRight; - deleteEntities(); } @@ -308,6 +302,11 @@ update( Player *p, unsigned int delta ) p->loc.y += p->vel.y * delta; p->loc.x +=(p->vel.x * p->speed) * delta; + if ( p->loc.y > 5000 ) { + std::cout << "Too high for me m8." << std::endl; + abort(); + } + // update entity coords for ( auto &e : entity ) { e->loc.y += e->vel.y * delta; @@ -772,22 +771,28 @@ singleDetect( Entity *e ) if ( e->loc.y < worldData[i].groundHeight ) { - e->loc.y= worldData[i].groundHeight - .001 * deltaTime; - e->ground=true; - e->vel.y=0; + if ( worldData[i].groundHeight - e->loc.y > 30 ) { + int dir = e->vel.x > 0 ? -1 : 1; + e->loc.x += HLINE * 8 * dir; + e->loc.y = worldData[i + 8 * dir].groundHeight; + } else { + e->loc.y = worldData[i].groundHeight - .001 * deltaTime; + e->ground = true; + e->vel.y = 0; + } /* * Handle gravity if the entity is above the line. */ }else{ - if(e->type == STRUCTURET && e->loc.y > 2000){ e->loc.y = worldData[i].groundHeight; e->vel.y = 0; e->ground = true; return; - }else if(e->vel.y > -2)e->vel.y-=.003 * deltaTime; + } else if ( e->vel.y > -2 ) + e->vel.y -= .003 * deltaTime; } @@ -962,30 +967,23 @@ addParticle( float x, float y, float w, float h, float vx, float vy, Color color void World::addLight(vec2 loc, Color color){ Light l; - if(light.size() < 64){ + if ( light.size() < 64 ) { l.loc = loc; l.color = color; light.push_back(l); } } -char *World::setToLeft(const char *file){ - if(toLeft) - delete[] toLeft; - if(!file) - return (toLeft = NULL); - - strcpy((toLeft = new char[strlen(file) + 1]),file); - return toLeft; +std::string World:: +setToLeft( std::string file ) +{ + return (toLeft = file); } -char *World::setToRight(const char *file){ - if(toRight) - delete[] toRight; - if(!file) - return (toRight = NULL); - - strcpy((toRight = new char[strlen(file) + 1]),file); - return toRight; + +std::string World:: +setToRight( std::string file ) +{ + return (toRight = file); } //what is this clyne why are they differnet @@ -994,32 +992,36 @@ goWorldLeft( Player *p ) { World *tmp; - // check if player is at world edge - if(toLeft && p->loc.x < worldStart + HLINE * 15.0f){ + // check if player is at world edge + if( !toLeft.empty() && p->loc.x < worldStart + HLINE * 15.0f ) { - // load world (`toLeft` conditional confirms existance) + // load world (`toLeft` conditional confirms existance) tmp = loadWorldFromXML(toLeft); - // adjust player location - p->loc.x = -tmp->worldStart - (int)HLINE * -10.0f; + // adjust player location + p->loc.x = tmp->worldStart + HLINE * 20; p->loc.y = tmp->worldData[tmp->lineCount - 1].groundHeight; return tmp; } + return this; } -World *World::goWorldRight(Player *p){ +World *World:: +goWorldRight( Player *p ) +{ World *tmp; - if(toRight && p->loc.x + p->width > -worldStart - HLINE * 15){ + if( !toRight.empty() && p->loc.x + p->width > -worldStart - HLINE * 15 ) { tmp = loadWorldFromXML(toRight); - p->loc.x = tmp->worldStart + (int)HLINE * 10; + p->loc.x = tmp->worldStart - HLINE * -15.0f; p->loc.y = GROUND_HEIGHT_MINIMUM; return tmp; } + return this; } @@ -1027,14 +1029,19 @@ World *World:: goInsideStructure( Player *p ) { World *tmp; - char *current; - if(inside.empty()){ - for(auto &b : build){ - if(p->loc.x > b->loc.x && - p->loc.x + p->width < b->loc.x + b->width ){ - inside.push_back((std::string)(currentXML.c_str() + 4)); + std::string current; + + if ( inside.empty() ) { + for ( auto &b : build ) { + if ( p->loc.x > b->loc.x && + p->loc.x + p->width < b->loc.x + b->width ) { - tmp = loadWorldFromXML(b->inside.c_str()); + if ( b->inside.empty() ) + return this; + + inside.push_back(currentXML.c_str() + 4); + + tmp = loadWorldFromXML( b->inside ); ui::toggleBlackFast(); ui::waitForCover(); @@ -1043,11 +1050,11 @@ goInsideStructure( Player *p ) return tmp; } } - }else{ - strcpy((current = new char[strlen((const char *)(currentXML.c_str() + 4)) + 1]),(const char *)(currentXML.c_str() + 4)); - tmp = loadWorldFromXML(inside.back().c_str()); - for(auto &b : tmp->build){ - if(!strcmp(current,b->inside.c_str())){ + } else { + current = currentXML.c_str() + 4; + tmp = loadWorldFromXML( inside.back() ); + for ( auto &b : tmp->build ) { + if ( current == b->inside ) { inside.pop_back(); ui::toggleBlackFast(); @@ -1060,15 +1067,37 @@ goInsideStructure( Player *p ) return tmp; } } - delete[] current; } + return this; } -void World::addHole(unsigned int start,unsigned int end){ - unsigned int i; - for(i=start;i<end;i++){ +void World:: +addHole( unsigned int start, unsigned int end ) +{ + for ( unsigned int i = end; i-- > start; ) worldData[i].groundHeight = 0; +} + +void World:: +addHill( const ivec2 peak, const unsigned int width ) +{ + int start = peak.x - width / 2, end = start + width, offset; + const float thing = peak.y - worldData[start].groundHeight; + const float period = PI / width; + + if ( start < 0 ) { + offset = -start; + start = 0; + } + + if ( end > (signed)worldData.size() ) + end = worldData.size(); + + for ( int i = start; i < end; i++ ) { + worldData[i].groundHeight += thing * sin((i - start + offset) * period); + if ( worldData[i].groundHeight > peak.y ) + worldData[i].groundHeight = peak.y; } } @@ -1081,38 +1110,32 @@ getTheWidth( void ) const void World::save(void){ std::string data; - std::cout << "Setting save" << std::endl; std::string save = (std::string)currentXML + ".dat"; std::ofstream out (save,std::ios::out | std::ios::binary); std::cout<<"Saving to "<<save<<" ..."<<std::endl; - std::cout << "Saving npcs" << std::endl; for(auto &n : npc){ data.append(std::to_string(n->dialogIndex) + "\n"); data.append(std::to_string((int)n->loc.x) + "\n"); data.append(std::to_string((int)n->loc.y) + "\n"); } - std::cout << "Saving buildings" << std::endl; for(auto &b : build){ data.append(std::to_string((int)b->loc.x) + "\n"); data.append(std::to_string((int)b->loc.y) + "\n"); } - std::cout << "Saving mobs" << std::endl; for(auto &m : mob){ data.append(std::to_string((int)m->loc.x) + "\n"); data.append(std::to_string((int)m->loc.y) + "\n"); data.append(std::to_string((int)m->alive) + "\n"); } - std::cout << "Ending file" << std::endl; data.append("dOnE\0"); std::cout << "Writing to the file" << std::endl; out.write(data.c_str(),data.size()); - std::cout << "Closing file" << std::endl; out.close(); std::cout << "Done saving" << std::endl; } @@ -1374,18 +1397,18 @@ loadWorldFromXMLNoSave( std::string path ) { while(wxml){ name = wxml->Name(); - if(name == "link"){ + if ( name == "link" ) { if((ptr = wxml->Attribute("left"))) tmp->setToLeft(ptr); else if((ptr = wxml->Attribute("right"))) tmp->setToRight(ptr); else abort(); - }else if(name == "style"){ + } else if ( name == "style" ) { tmp->setStyle(wxml->StrAttribute("folder")); tmp->setBackground((WorldBGType)wxml->UnsignedAttribute("background")); tmp->setBGM(wxml->StrAttribute("bgm")); - }else if(name == "generation"){ + } else if ( name == "generation" ) { if(!strcmp(wxml->Attribute("type"),"Random")){ if(Indoor) ((IndoorWorld *)tmp)->generate(wxml->UnsignedAttribute("width")); @@ -1395,7 +1418,7 @@ loadWorldFromXMLNoSave( std::string path ) { } }else if(Indoor) abort(); - }else if(name == "mob"){ + } else if ( name == "mob" ) { unsigned int type; type = wxml->UnsignedAttribute("type"); if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR) @@ -1405,7 +1428,7 @@ loadWorldFromXMLNoSave( std::string path ) { if(wxml->QueryBoolAttribute("aggressive",&dialog) == XML_NO_ERROR) tmp->mob.back()->aggressive = dialog; - }else if(name == "npc"){ + } else if ( name == "npc" ) { const char *npcname; if(wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR) @@ -1425,7 +1448,7 @@ loadWorldFromXMLNoSave( std::string path ) { tmp->npc.back()->addAIFunc(commonAIFunc,false); else tmp->npc.back()->dialogIndex = 9999; - }else if(name == "structure"){ + } else if ( name == "structure" ) { tmp->addStructure((BUILD_SUB)wxml->UnsignedAttribute("type"), wxml->QueryFloatAttribute("x",&spawnx) != XML_NO_ERROR ? getRand() % tmp->getTheWidth() / 2.0f : @@ -1433,10 +1456,17 @@ loadWorldFromXMLNoSave( std::string path ) { 100, wxml->StrAttribute("texture"), wxml->StrAttribute("inside")); - }else if(name == "trigger"){ + } else if ( name == "trigger" ) { tmp->addMob(MS_TRIGGER,wxml->FloatAttribute("x"),0,commonTriggerFunc); tmp->mob.back()->heyid = wxml->Attribute("id"); - } + } else if ( name == "page" ) { + tmp->addMob( MS_PAGE, wxml->FloatAttribute("x"), 0, commonPageFunc ); + tmp->mob.back()->heyid = wxml->Attribute("id"); + } else if ( name == "hill" ) { + tmp->addHill( ivec2 { wxml->IntAttribute("peakx"), wxml->IntAttribute("peaky") }, wxml->UnsignedAttribute("width") ); + } else if ( name == "time") { + tickCount = std::stoi( wxml->GetText() ); + } wxml = wxml->NextSiblingElement(); } @@ -1459,13 +1489,13 @@ loadWorldFromXMLNoSave( std::string path ) { * READS DATA ABOUT STRUCTURE CONTAINED IN VILLAGE */ - if(name == "structure"){ + if ( name == "structure" ) { tmp->addStructure((BUILD_SUB)vil->UnsignedAttribute("type"), vil->QueryFloatAttribute("x", &spawnx) != XML_NO_ERROR ? randx : spawnx, 100, vil->StrAttribute("texture"), vil->StrAttribute("inside")); - }else if(name == "stall"){ + }else if ( name == "stall" ) { if(!strcmp(vil->Attribute("type"),"market")){ std::cout << "Market" << std::endl; tmp->addStructure((BUILD_SUB)70, |