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