How opentibiabr/remeres-map-editor works
1. This repository is a cross-platform C++ desktop map editor for OpenTibia/Tibia servers. Its core responsibility is editing game maps, tile contents, houses, spawns, zones, and related metadata, then saving/loading them in OpenTibia-specific formats.
2. The application shell is split into a traditional editor UI layer and a stateful editor core. application, editor, map_window, map_tab, palette_window, main_toolbar, main_menubar, and the various property/dialog windows form the user-facing shell, while preferences and settings hold persistent editor configuration.
3. The central domain model is the map world itself: map, tile, item, house, town, zones, waypoints, selection, and copybuffer. These types represent the editable state that the UI manipulates and that the persistence layer reads/writes.
4. Editing behavior is organized around a large brush/tool subsystem. The brush base class and its many variants (ground, doodad, wall, carpet, raw, table, house, house_exit, monster, npc, spawn_*, zone, waypoint, eraser, monster/npc palettes, etc.) encapsulate placement and transformation logic. The palette windows select which brush/tool is active.
5. Rendering is a separate layer centered on gl_renderer, map_display, map_drawer, graphics, light_drawer, and minimap support. The editor appears to use OpenGL for map visualization, with auxiliary rendering for icons, overlays, and a minimap. UI images and toolbar icons are stored as XPM assets.
6. Game-content metadata is data-driven and loaded from the data/ tree. XML files under data/materials, data/items, data/clients.xml, and data/menubar.xml define tilesets, brush groups, item definitions, client-specific material catalogs, and menu structure. This makes the editor’s content palette and item behavior configurable without recompiling.
7. Persistence is handled by dedicated map-format adapters and file helpers. iomap_otbm, iomap_otmm, filehandle, templates, and the templatemap* files isolate version-specific map serialization/deserialization. bitmap_to_map_converter adds an import path from images into map structure.
8. The Lua subsystem is a major extension boundary. lua_engine, lua_script_manager, lua_script, lua_dialog, and the many lua_api_* modules expose map, item, brush, geometry, HTTP, JSON, noise, and selection operations to scripts. The scripts/ directory contains shipped automation and generator scripts such as cave/forest/river/maze/dungeon generators, visualizers, counters, and exporters.
9. There is also a live/networked editing subsystem. live_server, live_client, live_peer, live_socket, net_connection, live_action, and rme_net suggest support for synchronized or remote editing sessions. live_tab and related UI classes provide the user-facing entry point for this mode.
10. Several supporting subsystems round out the editor: items, materials, client_assets, sprite_appearances, sprites, monster, npc, spawn_*, and outfit handle game-data interpretation; actions and actions_history_window implement undo/redo; properties_window and specialized property dialogs edit object attributes; minimap_window and dat_debug_view aid inspection and debugging.
11. The repository is strongly build- and distribution-oriented. It uses CMake, CMake presets, and vcpkg for dependency management, with platform-specific CI workflows, Docker support, and Visual Studio project files. The docs/compiling folder documents supported build targets on Linux, Windows, and WSL.
12. Architecturally, the key data flow is: load client/material definitions and map files → populate the core map model → render the model in the UI → edit through brushes/tools and actions → persist back through the format adapters, with optional Lua automation and live network synchronization as side channels.
Main entry points: map.cpp Map · brush.cpp Brush Base · editor.cpp Editor · map_drawer.cpp Map Drawer
Components 31
UI Shell
Editor windows, tabs, palettes, and commands.
- Application · Top-level application bootstrap and lifecycle.
source/application.cpp - Editor · Coordinates editor state and actions.
source/editor.cpp - Map Window · Primary map workspace and tabbed editing surface.
source/map_window.cpp - Palette · Tool and brush selection panel.
source/palette_window.cpp - Properties · Object property editing and dialogs.
source/properties_window.cpp - Preferences · Persistent editor preferences.
source/preferences.cpp
Map Core
Editable world state and selection history.
- Map · Main editable map and global structure.
source/map.cpp - Tile · Per-position map cell contents and flags.
source/tile.cpp - Item · Placeable map item and attributes.
source/item.cpp - Selection · Current selected region and objects.
source/selection.cpp - Copy Buffer · Clipboard-like temporary map data.
source/copybuffer.cpp
Brushes
Placement and transformation tools.
- Brush Base · Shared placement and transform behavior.
source/brush.cpp - Ground · Ground and terrain placement brush.
source/ground_brush.cpp - Doodad · Decorative object placement brush.
source/doodad_brush.cpp - House · House-area editing brush.
source/house_brush.cpp - Zone · Zone painting and region tagging brush.
source/zone_brush.cpp
Rendering
Map visualization and overlays.
- GL Renderer · OpenGL-backed map rendering pipeline.
source/gl_renderer.cpp - Map Display · Interactive map viewport and overlays.
source/map_display.cpp - Map Drawer · Composes tiles, items, and decorations for display.
source/map_drawer.cpp - Light Drawer · Lighting and shading overlay rendering.
source/light_drawer.cpp
Persistence
Map formats, templates, and import/export.
- OTBM · OpenTibia map serialization adapter.
source/iomap_otbm.cpp - OTMM · Alternative map serialization adapter.
source/iomap_otmm.cpp - Templates · Template and version-specific map helpers.
source/templates.h - Bitmap Import · Converts bitmap input into map structure.
source/bitmap_to_map_converter.cpp
Extensions
Lua automation and live editing.
- Lua Engine · Embedded scripting runtime and bindings host.
source/lua/lua_engine.cpp - Script Manager · Loads, tracks, and runs shipped scripts.
source/lua/lua_script_manager.cpp - Live Server · Remote or synchronized editing server side.
source/live_server.cpp - Live Client · Client side live editing connection.
source/live_client.cpp
Data & Assets
XML-driven content definitions and bundled art.
- Materials · Loaded brush and tileset material definitions.
source/materials.cpp - Client Assets · Client-specific assets and appearance metadata.
source/client_assets.cpp - Sprites · Sprite and appearance data access.
source/sprites.h
Connections 33
- Application → Editor: starts · Bootstraps the editor controller.
- Editor → Map Window: hosts · Creates and manages the main workspace.
- Editor → Palette: hosts · Provides tool selection UI.
- Editor → Properties: hosts · Opens object inspectors and dialogs.
- Editor → Preferences: loads · Reads and stores persistent UI/editor settings.
- Map Window → Map: edits · Primary workspace manipulates the map model.
- Palette → Brush Base: selects · Chooses the active brush/tool.
- Brush Base → Ground: specializes · Terrain-focused brush variant.
- Brush Base → Doodad: specializes · Decoration-focused brush variant.
- Brush Base → House: specializes · House editing brush variant.
- Brush Base → Zone: specializes · Zone editing brush variant.
- Brush Base → Map: applies to · Brushes mutate the core world model.
- Map → Tile: contains · Map is composed of tiles.
- Tile → Item: contains · Tiles store items and attributes.
- Map → Selection: tracks · Selection state references map content.
- Selection → Copy Buffer: copies to · Selected content can be buffered for paste.
- GL Renderer → Map Display: feeds · Renderer supplies viewport drawing.
- Map Display → Map Drawer: uses · Viewport delegates composition to drawer.
- Map Drawer → Map: renders · Draws the world model.
- Map Drawer → Light Drawer: overlays · Adds lighting and overlay pass.
- OTBM → Map: loads/saves · Primary OTBM persistence boundary.
- OTMM → Map: loads/saves · Alternative OTMM persistence boundary.
- Templates → OTBM: supports · Template helpers inform map format handling.
- Templates → OTMM: supports · Template helpers inform map format handling.
- Bitmap Import → Map: imports into · Converts images into map structure.
- Lua Engine → Map: scripts · Lua scripts can inspect and mutate the map.
- Script Manager → Lua Engine: runs · Coordinates script loading and execution.
- Live Server → Live Client: syncs with · Remote editing connection boundary.
- Live Client → Map: syncs · Live editing changes affect the map model.
- Materials → Brush Base: configures · XML-driven materials define brush/group catalogs.
- Materials → Client Assets: aligns · Client-specific definitions drive asset interpretation.
- Client Assets → Sprites: uses · Appearance metadata is resolved against sprite data.
- Properties → Item: edits · Property dialogs adjust object attributes.