Otclient  14/8/2020
mapio.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #include "map.h"
24 #include "tile.h"
25 #include "game.h"
26 
32 #include <framework/xml/tinyxml.h>
33 #include <framework/ui/uiwidget.h>
34 
35 void Map::loadOtbm(const std::string& fileName)
36 {
37  try {
38  if(!g_things.isOtbLoaded())
39  stdext::throw_exception("OTB isn't loaded yet to load a map.");
40 
41  FileStreamPtr fin = g_resources.openFile(fileName);
42  if(!fin)
43  stdext::throw_exception(stdext::format("Unable to load map '%s'", fileName));
44  fin->cache();
45 
46  char identifier[4];
47  if(fin->read(identifier, 1, 4) < 4)
48  stdext::throw_exception("Could not read file identifier");
49 
50  if(memcmp(identifier, "OTBM", 4) != 0 && memcmp(identifier, "\0\0\0\0", 4) != 0)
51  stdext::throw_exception(stdext::format("Invalid file identifier detected: %s", identifier));
52 
53  BinaryTreePtr root = fin->getBinaryTree();
54  if(root->getU8())
55  stdext::throw_exception("could not read root property!");
56 
57  uint32 headerVersion = root->getU32();
58  if(headerVersion > 3)
59  stdext::throw_exception(stdext::format("Unknown OTBM version detected: %u.", headerVersion));
60 
61  setWidth(root->getU16());
62  setHeight(root->getU16());
63 
64  uint32 headerMajorItems = root->getU8();
65  if(headerMajorItems > g_things.getOtbMajorVersion()) {
66  stdext::throw_exception(stdext::format("This map was saved with different OTB version. read %d what it's supposed to be: %d",
67  headerMajorItems, g_things.getOtbMajorVersion()));
68  }
69 
70  root->skip(3);
71  uint32 headerMinorItems = root->getU32();
72  if(headerMinorItems > g_things.getOtbMinorVersion()) {
73  g_logger.warning(stdext::format("This map needs an updated OTB. read %d what it's supposed to be: %d or less",
74  headerMinorItems, g_things.getOtbMinorVersion()));
75  }
76 
77  BinaryTreePtr node = root->getChildren()[0];
78  if(node->getU8() != OTBM_MAP_DATA)
79  stdext::throw_exception("Could not read root data node");
80 
81  while(node->canRead()) {
82  uint8 attribute = node->getU8();
83  std::string tmp = node->getString();
84  switch (attribute) {
86  setDescription(tmp);
87  break;
89  setSpawnFile(fileName.substr(0, fileName.rfind('/') + 1) + tmp);
90  break;
92  setHouseFile(fileName.substr(0, fileName.rfind('/') + 1) + tmp);
93  break;
94  default:
95  stdext::throw_exception(stdext::format("Invalid attribute '%d'", (int)attribute));
96  }
97  }
98 
99  for(const BinaryTreePtr& nodeMapData : node->getChildren()) {
100  uint8 mapDataType = nodeMapData->getU8();
101  if(mapDataType == OTBM_TILE_AREA) {
102  Position basePos;
103  basePos.x = nodeMapData->getU16();
104  basePos.y = nodeMapData->getU16();
105  basePos.z = nodeMapData->getU8();
106 
107  for(const BinaryTreePtr &nodeTile : nodeMapData->getChildren()) {
108  uint8 type = nodeTile->getU8();
109  if(unlikely(type != OTBM_TILE && type != OTBM_HOUSETILE))
110  stdext::throw_exception(stdext::format("invalid node tile type %d", (int)type));
111 
112  HousePtr house = nullptr;
113  uint32 flags = TILESTATE_NONE;
114  Position pos = basePos + nodeTile->getPoint();
115 
116  if(type == OTBM_HOUSETILE) {
117  uint32 hId = nodeTile->getU32();
118  TilePtr tile = getOrCreateTile(pos);
119  if(!(house = g_houses.getHouse(hId))) {
120  house = HousePtr(new House(hId));
121  g_houses.addHouse(house);
122  }
123  house->setTile(tile);
124  }
125 
126  while(nodeTile->canRead()) {
127  uint8 tileAttr = nodeTile->getU8();
128  switch(tileAttr) {
129  case OTBM_ATTR_TILE_FLAGS: {
130  uint32 _flags = nodeTile->getU32();
132  flags |= TILESTATE_PROTECTIONZONE;
133  else if((_flags & TILESTATE_OPTIONALZONE) == TILESTATE_OPTIONALZONE)
134  flags |= TILESTATE_OPTIONALZONE;
135  else if((_flags & TILESTATE_HARDCOREZONE) == TILESTATE_HARDCOREZONE)
136  flags |= TILESTATE_HARDCOREZONE;
137 
138  if((_flags & TILESTATE_NOLOGOUT) == TILESTATE_NOLOGOUT)
139  flags |= TILESTATE_NOLOGOUT;
140 
141  if((_flags & TILESTATE_REFRESH) == TILESTATE_REFRESH)
142  flags |= TILESTATE_REFRESH;
143  break;
144  }
145  case OTBM_ATTR_ITEM: {
146  addThing(Item::createFromOtb(nodeTile->getU16()), pos);
147  break;
148  }
149  default: {
150  stdext::throw_exception(stdext::format("invalid tile attribute %d at pos %s",
151  (int)tileAttr, stdext::to_string(pos)));
152  }
153  }
154  }
155 
156  for(const BinaryTreePtr& nodeItem : nodeTile->getChildren()) {
157  if(unlikely(nodeItem->getU8() != OTBM_ITEM))
158  stdext::throw_exception("invalid item node");
159 
160  ItemPtr item = Item::createFromOtb(nodeItem->getU16());
161  item->unserializeItem(nodeItem);
162 
163  if(item->isContainer()) {
164  for(const BinaryTreePtr& containerItem : nodeItem->getChildren()) {
165  if(containerItem->getU8() != OTBM_ITEM)
166  stdext::throw_exception("invalid container item node");
167 
168  ItemPtr cItem = Item::createFromOtb(containerItem->getU16());
169  cItem->unserializeItem(containerItem);
170  item->addContainerItem(cItem);
171  }
172  }
173 
174  if(house && item->isMoveable()) {
175  g_logger.warning(stdext::format("Moveable item found in house: %d at pos %s - escaping...", item->getId(), stdext::to_string(pos)));
176  item.reset();
177  }
178 
179  addThing(item, pos);
180  }
181 
182  if(const TilePtr& tile = getTile(pos)) {
183  if(house)
184  tile->setFlag(TILESTATE_HOUSE);
185  tile->setFlag(flags);
186  }
187  }
188  } else if(mapDataType == OTBM_TOWNS) {
189  TownPtr town = nullptr;
190  for(const BinaryTreePtr &nodeTown : nodeMapData->getChildren()) {
191  if(nodeTown->getU8() != OTBM_TOWN)
192  stdext::throw_exception("invalid town node.");
193 
194  uint32 townId = nodeTown->getU32();
195  std::string townName = nodeTown->getString();
196 
197  Position townCoords;
198  townCoords.x = nodeTown->getU16();
199  townCoords.y = nodeTown->getU16();
200  townCoords.z = nodeTown->getU8();
201 
202  if(!(town = g_towns.getTown(townId)))
203  g_towns.addTown(TownPtr(new Town(townId, townName, townCoords)));
204  }
205  g_towns.sort();
206  } else if(mapDataType == OTBM_WAYPOINTS && headerVersion > 1) {
207  for(const BinaryTreePtr &nodeWaypoint : nodeMapData->getChildren()) {
208  if(nodeWaypoint->getU8() != OTBM_WAYPOINT)
209  stdext::throw_exception("invalid waypoint node.");
210 
211  std::string name = nodeWaypoint->getString();
212 
213  Position waypointPos;
214  waypointPos.x = nodeWaypoint->getU16();
215  waypointPos.y = nodeWaypoint->getU16();
216  waypointPos.z = nodeWaypoint->getU8();
217 
218  if(waypointPos.isValid() && !name.empty() && m_waypoints.find(waypointPos) == m_waypoints.end())
219  m_waypoints.insert(std::make_pair(waypointPos, name));
220  }
221  } else
222  stdext::throw_exception(stdext::format("Unknown map data node %d", (int)mapDataType));
223  }
224 
225  fin->close();
226  } catch(std::exception& e) {
227  g_logger.error(stdext::format("Failed to load '%s': %s", fileName, e.what()));
228  }
229 }
230 
231 void Map::saveOtbm(const std::string& fileName)
232 {
233  try {
234  FileStreamPtr fin = g_resources.createFile(fileName);
235  if(!fin)
236  stdext::throw_exception(stdext::format("failed to open file '%s' for write", fileName));
237 
238  fin->cache();
239  std::string dir;
240  if(fileName.find_last_of('/') == std::string::npos)
241  dir = g_resources.getWorkDir();
242  else
243  dir = fileName.substr(0, fileName.find_last_of('/'));
244 
245  uint32 version = 0;
247  version = 1;
248  else
249  version = 2;
250 
253  std::string::size_type sep_pos;
254  std::string houseFile = getHouseFile();
255  std::string spawnFile = getSpawnFile();
256  std::string cpyf;
257 
258  if((sep_pos = fileName.rfind('.')) != std::string::npos && stdext::ends_with(fileName, ".otbm"))
259  cpyf = fileName.substr(0, sep_pos);
260 
261  if(houseFile.empty())
262  houseFile = cpyf + "-houses.xml";
263 
264  if(spawnFile.empty())
265  spawnFile = cpyf + "-spawns.xml";
266 
268  if((sep_pos = spawnFile.rfind('/')) != std::string::npos)
269  spawnFile = spawnFile.substr(sep_pos + 1);
270 
271  if((sep_pos = houseFile.rfind('/')) != std::string::npos)
272  houseFile = houseFile.substr(sep_pos + 1);
273 
274  fin->addU32(0); // file version
275  OutputBinaryTreePtr root(new OutputBinaryTree(fin));
276  {
277  root->addU32(version);
278 
279  Size mapSize = getSize();
280  root->addU16(mapSize.width());
281  root->addU16(mapSize.height());
282 
283  root->addU32(g_things.getOtbMajorVersion());
284  root->addU32(g_things.getOtbMinorVersion());
285 
286  root->startNode(OTBM_MAP_DATA);
287  {
288  root->addU8(OTBM_ATTR_DESCRIPTION);
289  root->addString(m_attribs.get<std::string>(OTBM_ATTR_DESCRIPTION));
290 
291  root->addU8(OTBM_ATTR_SPAWN_FILE);
292  root->addString(spawnFile);
293 
294  root->addU8(OTBM_ATTR_HOUSE_FILE);
295  root->addString(houseFile);
296 
297  int px = -1, py = -1, pz =-1;
298  bool firstNode = true;
299 
300  for(uint8_t z = 0; z <= Otc::MAX_Z; ++z) {
301  for(const auto& it : m_tileBlocks[z]) {
302  const TileBlock& block = it.second;
303  for(const TilePtr& tile : block.getTiles()) {
304  if(unlikely(!tile || tile->isEmpty()))
305  continue;
306 
307  const Position& pos = tile->getPosition();
308  if(unlikely(!pos.isValid()))
309  continue;
310 
311  if(pos.x < px || pos.x >= px + 256
312  || pos.y < py || pos.y >= py + 256
313  || pos.z != pz) {
314  if(!firstNode)
315  root->endNode();
316 
317  firstNode = false;
318  root->startNode(OTBM_TILE_AREA);
319 
320  px = pos.x & 0xFF00;
321  py = pos.y & 0xFF00;
322  pz = pos.z;
323  root->addPos(px, py, pz);
324  }
325 
326  root->startNode(tile->isHouseTile() ? OTBM_HOUSETILE : OTBM_TILE);
327  root->addPoint(Point(pos.x, pos.y) & 0xFF);
328  if(tile->isHouseTile())
329  root->addU32(tile->getHouseId());
330 
331  if(tile->getFlags()) {
332  root->addU8(OTBM_ATTR_TILE_FLAGS);
333  root->addU32(tile->getFlags());
334  }
335 
336  const auto& itemList = tile->getItems();
337  const ItemPtr& ground = tile->getGround();
338  if(ground) {
339  // Those types are called "complex" needs other stuff to be written.
340  // For containers, there is container items, for depot, depot it and so on.
341  if(!ground->isContainer() && !ground->isDepot()
342  && !ground->isDoor() && !ground->isTeleport()) {
343  root->addU8(OTBM_ATTR_ITEM);
344  root->addU16(ground->getServerId());
345  } else
346  ground->serializeItem(root);
347  }
348  for(const ItemPtr& item : itemList)
349  if(!item->isGround())
350  item->serializeItem(root);
351 
352  root->endNode(); // OTBM_TILE
353  }
354  }
355  }
356 
357  if(!firstNode)
358  root->endNode(); // OTBM_TILE_AREA
359 
360  root->startNode(OTBM_TOWNS);
361  for(const TownPtr& town : g_towns.getTowns()) {
362  root->startNode(OTBM_TOWN);
363 
364  root->addU32(town->getId());
365  root->addString(town->getName());
366 
367  Position townPos = town->getPos();
368  root->addPos(townPos.x, townPos.y, townPos.z);
369  root->endNode();
370  }
371  root->endNode();
372 
373  if(version > 1) {
374  root->startNode(OTBM_WAYPOINTS);
375  for(const auto& it : m_waypoints) {
376  root->startNode(OTBM_WAYPOINT);
377  root->addString(it.second);
378 
379  Position pos = it.first;
380  root->addPos(pos.x, pos.y, pos.z);
381  root->endNode();
382  }
383  root->endNode();
384  }
385  }
386  root->endNode(); // OTBM_MAP_DATA
387  }
388  root->endNode();
389 
390  fin->flush();
391  fin->close();
392  } catch(std::exception& e) {
393  g_logger.error(stdext::format("Failed to save '%s': %s", fileName, e.what()));
394  }
395 }
396 
397 bool Map::loadOtcm(const std::string& fileName)
398 {
399  try {
400  FileStreamPtr fin = g_resources.openFile(fileName);
401  if(!fin)
402  stdext::throw_exception("unable to open file");
403 
404  fin->cache();
405 
406  uint32 signature = fin->getU32();
407  if(signature != OTCM_SIGNATURE)
408  stdext::throw_exception("invalid otcm file");
409 
410  uint16 start = fin->getU16();
411  uint16 version = fin->getU16();
412  fin->getU32(); // flags
413 
414  switch(version) {
415  case 1: {
416  fin->getString(); // description
417  uint32 datSignature = fin->getU32();
418  fin->getU16(); // protocol version
419  fin->getString(); // world name
420 
421  if(datSignature != g_things.getDatSignature())
422  g_logger.warning("otcm map loaded was created with a different dat signature");
423 
424  break;
425  }
426  default:
427  stdext::throw_exception("otcm version not supported");
428  }
429 
430  fin->seek(start);
431 
432  while(true) {
433  Position pos;
434 
435  pos.x = fin->getU16();
436  pos.y = fin->getU16();
437  pos.z = fin->getU8();
438 
439  // end of file
440  if(!pos.isValid())
441  break;
442 
443  const TilePtr& tile = g_map.createTile(pos);
444 
445  int stackPos = 0;
446  while(true) {
447  int id = fin->getU16();
448 
449  // end of tile
450  if(id == 0xFFFF)
451  break;
452 
453  int countOrSubType = fin->getU8();
454 
455  ItemPtr item = Item::create(id);
456  item->setCountOrSubType(countOrSubType);
457 
458  if(item->isValid())
459  tile->addThing(item, stackPos++);
460  }
461 
463  }
464 
465  fin->close();
466 
467  return true;
468  } catch(stdext::exception& e) {
469  g_logger.error(stdext::format("failed to load OTCM map: %s", e.what()));
470  return false;
471  }
472 }
473 
474 void Map::saveOtcm(const std::string& fileName)
475 {
476  try {
477  stdext::timer saveTimer;
478 
479  FileStreamPtr fin = g_resources.createFile(fileName);
480  fin->cache();
481 
482  //TODO: compression flag with zlib
483  uint32 flags = 0;
484 
485  // header
486  fin->addU32(OTCM_SIGNATURE);
487  fin->addU16(0); // data start, will be overwritten later
488  fin->addU16(OTCM_VERSION);
489  fin->addU32(flags);
490 
491  // version 1 header
492  fin->addString("OTCM 1.0"); // map description
495  fin->addString(g_game.getWorldName());
496 
497  // go back and rewrite where the map data starts
498  uint32 start = fin->tell();
499  fin->seek(4);
500  fin->addU16(start);
501  fin->seek(start);
502 
503  for(uint8_t z = 0; z <= Otc::MAX_Z; ++z) {
504  for(const auto& it : m_tileBlocks[z]) {
505  const TileBlock& block = it.second;
506  for(const TilePtr& tile : block.getTiles()) {
507  if(!tile || tile->isEmpty())
508  continue;
509 
510  Position pos = tile->getPosition();
511  fin->addU16(pos.x);
512  fin->addU16(pos.y);
513  fin->addU8(pos.z);
514 
515  for(const ThingPtr& thing : tile->getThings()) {
516  if(thing->isItem()) {
517  ItemPtr item = thing->static_self_cast<Item>();
518  fin->addU16(item->getId());
519  fin->addU8(item->getCountOrSubType());
520  }
521  }
522 
523  // end of tile
524  fin->addU16(0xFFFF);
525  }
526  }
527  }
528 
529  // end of file
530  Position invalidPos;
531  fin->addU16(invalidPos.x);
532  fin->addU16(invalidPos.y);
533  fin->addU8(invalidPos.z);
534 
535  fin->flush();
536 
537  fin->close();
538  } catch(stdext::exception& e) {
539  g_logger.error(stdext::format("failed to save OTCM map: %s", e.what()));
540  }
541 }
542 
543 /* vim: set ts=4 sw=4 et: */
binarytree.h
ThingTypeManager::getDatSignature
uint32 getDatSignature()
Definition: thingtypemanager.h:66
FileStream::seek
void seek(uint pos)
Definition: filestream.cpp:142
TownPtr
stdext::shared_object_ptr< Town > TownPtr
Definition: declarations.h:76
Item::isContainer
bool isContainer()
Definition: item.h:129
stdext::timer
Definition: time.h:36
Item::serializeItem
void serializeItem(const OutputBinaryTreePtr &out)
Definition: item.cpp:185
eventdispatcher.h
stdext::packed_storage::get
T get(Key id) const
Definition: packed_storage.h:80
g_map
Map g_map
Definition: map.cpp:36
Item::getId
uint32 getId()
Definition: item.h:97
unlikely
#define unlikely(x)
Definition: compiler.h:71
FileStream::close
void close()
Definition: filestream.cpp:78
z
gc sort z
Definition: CMakeLists.txt:176
OTBM_ATTR_SPAWN_FILE
@ OTBM_ATTR_SPAWN_FILE
Definition: map.h:48
Item::setCountOrSubType
void setCountOrSubType(int value)
Definition: item.h:89
FileStream::addU32
void addU32(uint32 v)
Definition: filestream.cpp:377
Position::x
int x
Definition: position.h:243
OTBM_MAP_DATA
@ OTBM_MAP_DATA
Definition: map.h:70
Position::isValid
bool isValid() const
Definition: position.h:182
Map::setDescription
void setDescription(const std::string &desc)
Definition: map.h:158
Tile::addThing
void addThing(const ThingPtr &thing, int stackPos)
Definition: tile.cpp:166
uint32
uint32_t uint32
Definition: types.h:35
Map::loadOtbm
void loadOtbm(const std::string &fileName)
Definition: mapio.cpp:35
Map::setHouseFile
void setHouseFile(const std::string &file)
Definition: map.h:156
Map::saveOtbm
void saveOtbm(const std::string &fileName)
Definition: mapio.cpp:231
resourcemanager.h
OTCM_VERSION
@ OTCM_VERSION
Definition: map.h:89
tinyxml.h
Map::loadOtcm
bool loadOtcm(const std::string &fileName)
Definition: mapio.cpp:397
Map::getHouseFile
std::string getHouseFile()
Definition: map.h:164
Item::unserializeItem
void unserializeItem(const BinaryTreePtr &in)
Definition: item.cpp:119
Logger::error
void error(const std::string &what)
Definition: logger.h:54
Game::getClientVersion
int getClientVersion()
Definition: game.h:316
TILESTATE_NONE
@ TILESTATE_NONE
Definition: tile.h:35
Map::getTile
const TilePtr & getTile(const Position &pos)
Definition: map.cpp:310
OTCM_SIGNATURE
@ OTCM_SIGNATURE
Definition: map.h:88
OTBM_TOWNS
@ OTBM_TOWNS
Definition: map.h:80
OTBM_HOUSETILE
@ OTBM_HOUSETILE
Definition: map.h:82
g_game
Game g_game
Definition: game.cpp:37
Point
TPoint< int > Point
Definition: point.h:86
Position::y
int y
Definition: position.h:244
uiwidget.h
TileBlock
Definition: map.h:101
FileStream::getString
std::string getString()
Definition: filestream.cpp:309
OTBM_WAYPOINTS
@ OTBM_WAYPOINTS
Definition: map.h:83
stdext::format
std::string format()
Definition: format.h:82
OTBM_TOWN
@ OTBM_TOWN
Definition: map.h:81
TSize::width
int width() const
Definition: size.h:43
OTBM_ATTR_TILE_FLAGS
@ OTBM_ATTR_TILE_FLAGS
Definition: map.h:40
Position::z
short z
Definition: position.h:245
FileStream::addString
void addString(const std::string &v)
Definition: filestream.cpp:448
uint16
uint16_t uint16
Definition: types.h:36
g_resources
ResourceManager g_resources
Definition: resourcemanager.cpp:32
OTBM_WAYPOINT
@ OTBM_WAYPOINT
Definition: map.h:84
TownManager::sort
void sort()
Definition: towns.cpp:76
Item::isValid
bool isValid()
Definition: item.cpp:114
HouseManager::getHouse
HousePtr getHouse(uint32 houseId)
Definition: houses.cpp:123
FileStream::cache
void cache()
Definition: filestream.cpp:58
FileStream::getU16
uint16 getU16()
Definition: filestream.cpp:199
FileStream::getBinaryTree
BinaryTreePtr getBinaryTree()
Definition: filestream.cpp:334
g_logger
Logger g_logger
Definition: logger.cpp:35
TileBlock::getTiles
const std::array< TilePtr, BLOCK_SIZE *BLOCK_SIZE > & getTiles() const
Definition: map.h:121
OTBM_TILE_AREA
@ OTBM_TILE_AREA
Definition: map.h:72
stdext::shared_object_ptr::reset
void reset()
Definition: shared_object.h:79
stdext::shared_object::static_self_cast
stdext::shared_object_ptr< T > static_self_cast()
Definition: shared_object.h:50
TILESTATE_PROTECTIONZONE
@ TILESTATE_PROTECTIONZONE
Definition: tile.h:36
Map::addThing
void addThing(const ThingPtr &thing, const Position &pos, int stackPos=-1)
Definition: map.cpp:107
Position
Definition: position.h:33
Item::createFromOtb
static ItemPtr createFromOtb(int id)
Definition: item.cpp:58
ThingTypeManager::isOtbLoaded
bool isOtbLoaded()
Definition: thingtypemanager.h:73
HouseManager::addHouse
void addHouse(const HousePtr &house)
Definition: houses.cpp:110
Map::createTile
const TilePtr & createTile(const Position &pos)
Definition: map.cpp:265
Map::saveOtcm
void saveOtcm(const std::string &fileName)
Definition: mapio.cpp:474
HousePtr
stdext::shared_object_ptr< House > HousePtr
Definition: declarations.h:75
Item::getServerId
uint16 getServerId()
Definition: item.h:99
TownManager::getTown
const TownPtr & getTown(uint32 townId)
Definition: towns.cpp:52
Map::setWidth
void setWidth(uint16 w)
Definition: map.h:161
map.h
TILESTATE_HOUSE
@ TILESTATE_HOUSE
Definition: tile.h:44
OTBM_ATTR_ITEM
@ OTBM_ATTR_ITEM
Definition: map.h:46
FileStream::read
int read(void *buffer, uint size, uint nmemb=1)
Definition: filestream.cpp:109
ThingTypeManager::getOtbMinorVersion
uint32 getOtbMinorVersion()
Definition: thingtypemanager.h:68
Map::setHeight
void setHeight(uint16 h)
Definition: map.h:162
Otc::MAX_Z
@ MAX_Z
Definition: const.h:33
Item::isDoor
bool isDoor()
Definition: item.h:130
ResourceManager::getWorkDir
std::string getWorkDir()
Definition: resourcemanager.h:76
stdext::throw_exception
void throw_exception(const std::string &what)
Throws a generic exception.
Definition: exception.h:43
stdext::ends_with
bool ends_with(const std::string &str, const std::string &test)
Definition: string.cpp:258
Map::getOrCreateTile
const TilePtr & getOrCreateTile(const Position &pos)
Definition: map.cpp:294
Item::isMoveable
bool isMoveable()
Definition: item.cpp:256
Town
Definition: towns.h:29
Item::isDepot
bool isDepot()
Definition: item.h:128
OutputBinaryTree
Definition: binarytree.h:66
Item::create
static ItemPtr create(int id)
Definition: item.cpp:51
ResourceManager::openFile
FileStreamPtr openFile(const std::string &fileName)
Definition: resourcemanager.cpp:232
stdext::to_string
std::string to_string(const T &t)
Definition: string.h:35
House
Definition: houses.h:41
TownManager::getTowns
TownList getTowns()
Definition: towns.h:60
Item
Definition: item.h:76
filestream.h
stdext::exception::what
virtual const char * what() const
Definition: exception.h:37
Map::getSize
Size getSize()
Definition: map.h:166
g_towns
TownManager g_towns
Definition: towns.cpp:25
TILESTATE_NOLOGOUT
@ TILESTATE_NOLOGOUT
Definition: tile.h:39
TSize::height
int height() const
Definition: size.h:44
FileStream::tell
uint tell()
Definition: filestream.cpp:167
Map::notificateTileUpdate
void notificateTileUpdate(const Position &pos)
Definition: map.cpp:62
Map::setSpawnFile
void setSpawnFile(const std::string &file)
Definition: map.h:157
Map::getSpawnFile
std::string getSpawnFile()
Definition: map.h:165
stdext::shared_object_ptr< FileStream >
OTBM_ATTR_DESCRIPTION
@ OTBM_ATTR_DESCRIPTION
Definition: map.h:38
ThingTypeManager::getOtbMajorVersion
uint32 getOtbMajorVersion()
Definition: thingtypemanager.h:67
OTBM_ITEM
@ OTBM_ITEM
Definition: map.h:74
OTBM_ATTR_HOUSE_FILE
@ OTBM_ATTR_HOUSE_FILE
Definition: map.h:50
FileStream::getU32
uint32 getU32()
Definition: filestream.cpp:215
FileStream::flush
void flush()
Definition: filestream.cpp:90
game.h
OTBM_TILE
@ OTBM_TILE
Definition: map.h:73
Game::getWorldName
std::string getWorldName()
Definition: game.h:346
TownManager::addTown
void addTown(const TownPtr &town)
Definition: towns.cpp:39
ClientVersion820
@ ClientVersion820
Definition: itemtype.h:96
TILESTATE_OPTIONALZONE
@ TILESTATE_OPTIONALZONE
Definition: tile.h:38
FileStream::addU8
void addU8(uint8 v)
Definition: filestream.cpp:354
Item::addContainerItem
void addContainerItem(const ItemPtr &i)
Definition: item.h:142
TILESTATE_HARDCOREZONE
@ TILESTATE_HARDCOREZONE
Definition: tile.h:40
ResourceManager::createFile
FileStreamPtr createFile(const std::string &fileName)
Definition: resourcemanager.cpp:250
tile.h
Item::isTeleport
bool isTeleport()
Definition: item.h:131
TSize< int >
FileStream::getU8
uint8 getU8()
Definition: filestream.cpp:183
g_things
ThingTypeManager g_things
Definition: thingtypemanager.cpp:38
g_houses
HouseManager g_houses
Definition: houses.cpp:27
Item::getCountOrSubType
int getCountOrSubType()
Definition: item.h:94
uint8
uint8_t uint8
Definition: types.h:37
application.h
Logger::warning
void warning(const std::string &what)
Definition: logger.h:53
TILESTATE_REFRESH
@ TILESTATE_REFRESH
Definition: tile.h:41
FileStream::addU16
void addU16(uint16 v)
Definition: filestream.cpp:365
stdext::exception
Definition: exception.h:31