Ir para conteúdo

gparisio

Campones
  • Total de itens

    1
  • Registro em

  • Última visita

Sobre gparisio

gparisio's Achievements

  1. ow vei eu num encontro a seguinte parte: void Game::updateTile(const Position& pos){SpectatorVec list;SpectatorVec::iterator i;getSpectators(Range(pos), list);for(i = list.begin(); i != list.end(); ++i)(*i)->onTileUpdated(pos);}#endif //SG_LVLDOOR#ifdef TLM_BEDbool Game::loadBeds(std::string file) { xmlDocPtr doc; doc = xmlParseFile(file.c_str()); if (doc){ xmlNodePtr root, p, tmp; root = xmlDocGetRootElement(doc); if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { xmlFreeDoc(doc); return -1; } tmp = root->children; int x,y,z,id; while(tmp){ if (strcmp((char*) tmp->name, "bed")==0){ x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); id = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id")); Position mainPos(x, y, z); Item *mainItem = Item::CreateItem(id); Tile *mainTile = getTile(mainPos.x, mainPos.y, mainPos.z); if (mainTile && mainItem){ Position nextPos(x, y, z); Item *nextItem = Item::CreateItem(id+1); if (id == BED_ID1 || id == BED_ID3 || id == BED_ID7 || id == BED_ID8){ nextPos.y++; } else if(id == BED_ID2 || id == BED_ID4 || id == BED_ID9 || id == BED_ID10){ nextPos.x++; } Tile *nextTile = getTile(nextPos.x, nextPos.y, nextPos.z); if (nextTile && nextItem){ mainTile->addThing(mainItem); mainItem->pos = mainPos; nextTile->addThing(nextItem); nextItem->pos = nextPos; } } } tmp = tmp->next; } xmlFreeDoc(doc); return 0; } return -1;}std::string Game::getBedSleeper(const Position pos){ std::string file="data/world/beds.xml"; xmlDocPtr doc; doc = xmlParseFile(file.c_str()); if (doc){ xmlNodePtr root, tmp; root = xmlDocGetRootElement(doc); if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { xmlFreeDoc(doc); return "Nobody"; } tmp = root->children; while(tmp){ if (strcmp((const char*) tmp->name, "bed")==0){ int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); int z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); if (x == pos.x && y == pos.y && z == pos.z){ return (const char*)xmlGetProp(tmp, (const xmlChar *)"name"); } } tmp = tmp->next; } xmlFreeDoc(doc); } return "Nobody";}unsigned int Game::getBedID(const Position pos){ std::string file="data/world/beds.xml"; xmlDocPtr doc; doc = xmlParseFile(file.c_str()); if (doc){ xmlNodePtr root, tmp; root = xmlDocGetRootElement(doc); if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { xmlFreeDoc(doc); return 0; } tmp = root->children; while(tmp){ if (strcmp((const char*) tmp->name, "bed")==0){ int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); int z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); if (x == pos.x && y == pos.y && z == pos.z){ return atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id")); } } tmp = tmp->next; } xmlFreeDoc(doc); } return 0;}bool Game::changeBed(const Position pos, unsigned int oldid, std::string sleepname){ Tile *maintile = getTile(pos.x,pos.y,pos.z); Item *mainitem = dynamic_cast<Item*>(maintile->getThingByStackPos(maintile->getThingCount()-1)); if (mainitem && maintile->isPz()){ Position tilePos(pos.x, pos.y, pos.z); if (oldid == BED_ID1 || oldid == BED_ID3 || oldid == BED_ID7 || oldid == BED_ID8){ tilePos.y++; } else if(oldid == BED_ID2 || oldid == BED_ID4 || oldid == BED_ID9 || oldid == BED_ID10){ tilePos.x++; } Tile *nexttile = getTile(tilePos.x,tilePos.y,tilePos.z); Item *nextitem = dynamic_cast<Item*>(nexttile->getThingByStackPos(maintile->getThingCount()-1)); if (nextitem && nexttile->isPz()){ if (oldid == BED_ID1 || oldid == BED_ID3){ mainitem->setID(oldid+8); } else if(oldid == BED_ID2){ mainitem->setID(BED_ID10); } else if(oldid == BED_ID4){ mainitem->setID(BED_ID9); } else if(oldid == BED_ID7 || oldid == BED_ID8){ mainitem->setID(oldid-8); } else if(oldid == BED_ID9){ mainitem->setID(BED_ID4); } else if(oldid == BED_ID10){ mainitem->setID(BED_ID2); } nextitem->setID(mainitem->getID()+1); SpectatorVec list; SpectatorVec::iterator it; getSpectators(Range(tilePos, true), list); //players for(it = list.begin(); it != list.end(); ++it) { if(dynamic_cast<Player*>(*it)) { (*it)->onTileUpdated(pos); (*it)->onTileUpdated(tilePos); } } //Player *player = dynamic_cast<Player*>(player); //player->onTileUpdated(pos); //player->onTileUpdated(tilePos); std::string file="data/world/beds.xml"; xmlDocPtr doc; doc = xmlParseFile(file.c_str()); if (doc){ xmlNodePtr root, tmp; root = xmlDocGetRootElement(doc); if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { xmlFreeDoc(doc); return false; } Position bedPos[1000];// 1000 = number of beds unsigned int id[1000]; std::string name[1000]; int i = 0; tmp = root->children; while(tmp){ if (strcmp((const char*) tmp->name, "bed")==0){ i++; bedPos.x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x" )); bedPos.y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y" )); bedPos.z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z" )); id = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "id" )); name = (const char*) xmlGetProp(tmp, (const xmlChar*) "name"); if (bedPos == pos){ id = mainitem->getID(); name = sleepname; } } tmp = tmp->next; } doc = xmlNewDoc((const xmlChar*)"1.0"); doc->children = xmlNewDocNode(doc, NULL, (const xmlChar*)"beds", NULL); root = doc->children; std::stringstream sb; for(int x = 1; x <= i; x++){ tmp = xmlNewNode(NULL,(const xmlChar*)"bed"); sb << bedPos[x].x; xmlSetProp(tmp, (const xmlChar*) "x" , (const xmlChar*)sb.str().c_str()); sb.str(""); sb << bedPos[x].y; xmlSetProp(tmp, (const xmlChar*) "y" , (const xmlChar*)sb.str().c_str()); sb.str(""); sb << bedPos[x].z; xmlSetProp(tmp, (const xmlChar*) "z" , (const xmlChar*)sb.str().c_str()); sb.str(""); sb << id[x]; xmlSetProp(tmp, (const xmlChar*) "id", (const xmlChar*)sb.str().c_str()); sb.str(""); sb << name[x]; xmlSetProp(tmp, (const xmlChar*) "name", (const xmlChar*)sb.str().c_str()); sb.str(""); xmlAddChild(root, tmp); } xmlSaveFile(file.c_str(), doc); xmlFreeDoc(doc); return true; }return false;}}}Position Game::getBedPos(std::string name){ std::string file="data/world/beds.xml"; xmlDocPtr doc; doc = xmlParseFile(file.c_str()); if (doc){ xmlNodePtr root, tmp; root = xmlDocGetRootElement(doc); if (xmlStrcmp(root->name, (const xmlChar*)"beds")) { xmlFreeDoc(doc); return Position(0xFFFF,0xFFFF,0xFF); } tmp = root->children; while(tmp){ if (strcmp((const char*) tmp->name, "bed")==0){ std::string sleepname = (const char*)xmlGetProp(tmp, (const xmlChar *)"name"); if (sleepname == name){ int x = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "x")); int y = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "y")); int z = atoi((const char*) xmlGetProp(tmp, (const xmlChar*) "z")); return Position(x,y,z); } } tmp = tmp->next; } xmlFreeDoc(doc); } return Position(0xFFFF,0xFFFF,0xFF);}#endif onde ela esta???
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...