iomap_otbm.h

main 159 lines · 4.1 KB Raw
Alex Alex Commit Map Editor 18/10/2026 23:40
1//////////////////////////////////////////////////////////////////////
2// This file is part of Remere's Map Editor
3//////////////////////////////////////////////////////////////////////
4// Remere's Map Editor is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Remere's Map Editor is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//////////////////////////////////////////////////////////////////////
17
18#ifndef RME_OTBM_MAP_IO_H_
19#define RME_OTBM_MAP_IO_H_
20
21#include "iomap.h"
22
23// Pragma pack is VERY important since otherwise it won't be able to load the structs correctly
24#pragma pack(1)
25
26enum OTBM_ItemAttribute {
27 OTBM_ATTR_DESCRIPTION = 1,
28 OTBM_ATTR_EXT_FILE = 2,
29 OTBM_ATTR_TILE_FLAGS = 3,
30 OTBM_ATTR_ACTION_ID = 4,
31 OTBM_ATTR_UNIQUE_ID = 5,
32 OTBM_ATTR_TEXT = 6,
33 OTBM_ATTR_DESC = 7,
34 OTBM_ATTR_TELE_DEST = 8,
35 OTBM_ATTR_ITEM = 9,
36 OTBM_ATTR_DEPOT_ID = 10,
37 OTBM_ATTR_EXT_SPAWN_FILE = 11,
38 OTBM_ATTR_RUNE_CHARGES = 12,
39 OTBM_ATTR_EXT_HOUSE_FILE = 13,
40 OTBM_ATTR_HOUSEDOORID = 14,
41 OTBM_ATTR_COUNT = 15,
42 OTBM_ATTR_DURATION = 16,
43 OTBM_ATTR_DECAYING_STATE = 17,
44 OTBM_ATTR_WRITTENDATE = 18,
45 OTBM_ATTR_WRITTENBY = 19,
46 OTBM_ATTR_SLEEPERGUID = 20,
47 OTBM_ATTR_SLEEPSTART = 21,
48 OTBM_ATTR_CHARGES = 22,
49
50 // Canary RME (parse without loading only)
51 OTBM_ATTR_EXT_SPAWN_NPC_FILE = 23,
52
53 OTBM_ATTR_PODIUMOUTFIT = 40,
54 OTBM_ATTR_TIER = 41,
55 OTBM_ATTR_ATTRIBUTE_MAP = 128
56};
57
58enum OTBM_NodeTypes_t {
59 OTBM_ROOTV1 = 1,
60 OTBM_MAP_DATA = 2,
61 OTBM_ITEM_DEF = 3,
62 OTBM_TILE_AREA = 4,
63 OTBM_TILE = 5,
64 OTBM_ITEM = 6,
65 OTBM_TILE_SQUARE = 7,
66 OTBM_TILE_REF = 8,
67 OTBM_SPAWNS = 9,
68 OTBM_SPAWN_AREA = 10,
69 OTBM_MONSTER = 11,
70 OTBM_TOWNS = 12,
71 OTBM_TOWN = 13,
72 OTBM_HOUSETILE = 14,
73 OTBM_WAYPOINTS = 15,
74 OTBM_WAYPOINT = 16,
75
76 // Canary RME (unused)
77 // OTBM_SPAWN_NPC_AREA = 17,
78 // OTBM_SPAWNS_NPC = 18,
79};
80
81enum PodiumFlags : uint8_t {
82 PODIUM_SHOW_PLATFORM = 1 << 0, // show the platform below the outfit
83 PODIUM_SHOW_OUTFIT = 1 << 1, // show outfit
84 PODIUM_SHOW_MOUNT = 1 << 2 // show mount
85};
86
87struct OTBM_root_header {
88 uint32_t version;
89 uint16_t width;
90 uint16_t height;
91 uint32_t majorVersionItems;
92 uint32_t minorVersionItems;
93};
94
95struct OTBM_TeleportDest {
96 uint16_t x;
97 uint16_t y;
98 uint8_t z;
99};
100
101struct OTBM_Tile_area_coords {
102 uint16_t x;
103 uint16_t y;
104 uint8_t z;
105};
106
107struct OTBM_Tile_coords {
108 uint8_t x;
109 uint8_t y;
110};
111
112struct OTBM_TownTemple_coords {
113 uint16_t x;
114 uint16_t y;
115 uint8_t z;
116};
117
118struct OTBM_HouseTile_coords {
119 uint8_t x;
120 uint8_t y;
121 uint32_t houseid;
122};
123
124#pragma pack()
125
126class IOMapOTBM : public IOMap {
127public:
128 IOMapOTBM(MapVersion ver) {
129 version = ver;
130 }
131 ~IOMapOTBM() { }
132
133 static bool getVersionInfo(const FileName& identifier, MapVersion& out_ver);
134
135 virtual bool loadMap(Map& map, const FileName& identifier);
136 virtual bool saveMap(Map& map, const FileName& identifier);
137
138protected:
139 static bool getVersionInfo(NodeFileReadHandle* f, MapVersion& out_ver);
140
141 virtual bool loadMap(Map& map, NodeFileReadHandle& handle);
142 bool loadSpawns(Map& map, const FileName& dir);
143 bool loadSpawns(Map& map, pugi::xml_document& doc);
144 bool loadHouses(Map& map, const FileName& dir);
145 bool loadHouses(Map& map, pugi::xml_document& doc);
146 bool loadWaypoints(Map& map, const FileName& dir);
147 bool loadWaypoints(Map& map, pugi::xml_document& doc);
148
149 virtual bool saveMap(Map& map, NodeFileWriteHandle& handle);
150 bool saveSpawns(Map& map, const FileName& dir);
151 bool saveSpawns(Map& map, pugi::xml_document& doc);
152 bool saveHouses(Map& map, const FileName& dir);
153 bool saveHouses(Map& map, pugi::xml_document& doc);
154 bool saveWaypoints(Map& map, const FileName& dir);
155 bool saveWaypoints(Map& map, pugi::xml_document& doc);
156};
157
158#endif
159
Top