23#ifndef CORSIX_TH_TH_MAP_H_
24#define CORSIX_TH_TH_MAP_H_
119 enum class key : uint32_t {
176 operator uint32_t()
const;
263 void save(
const std::string& filename);
283 return current_temperature_theme;
384 template <
typename T>
387 x = (T)32 * (
x_ - y);
388 y = (T)16 * (
x_ + y);
392 template <
typename T>
395 x = y / (T)32 +
x_ / (T)64;
396 y = y / (T)32 -
x_ / (T)64;
407 void draw_north_wall(
const map_tile* tile,
int tile_x,
int tile_y,
419 bool layer_exists(uint16_t layer,
int& height)
const;
423 void read_tile_index(
const uint8_t*
pData,
int&
iX,
int&
iY)
const;
424 void write_tile_index(uint8_t*
pData,
int iX,
int iY)
const;
441 void make_adjacency_matrix();
444 void make_purchase_matrix();
447 void update_purchase_matrix();
449 int count_parcel_tiles(
int iParcelId)
const;
460 int initial_camera_x[4]{};
461 int initial_camera_y[4]{};
465 int current_temperature_index{};
467 int* parcel_tile_counts{};
471 bool* parcel_adjacency_matrix{};
474 bool* purchasable_matrix{};
514 inline operator bool()
const {
return tile !=
nullptr; }
530 inline int tile_x()
const {
return world_x; }
531 inline int tile_y()
const {
return world_y; }
537 return (
static_cast<int>(direction) - 1) * (1 - container->
get_width());
552 static const int margin_top = 150;
553 static const int margin_left = 110;
554 static const int margin_right = 110;
555 static const int margin_bottom = 150;
563 int x_relative_to_screen{};
564 int y_relative_to_screen{};
566 const int screen_offset_x;
567 const int screen_offset_y;
568 const int screen_width;
569 const int screen_height;
574 int scanline_count{};
577 void advance_until_visible();
596 inline operator bool()
const {
return tile != end_tile; }
600 inline int x()
const {
return x_relative_to_screen; }
601 inline int y()
const {
return y_relative_to_screen; }
613 int x_relative_to_screen;
614 int y_relative_to_screen;
std::vector< std::pair< int, int > > set_parcel_owner(int iParcelId, int iOwner)
Change the owner of a particular parcel.
Definition th_map.cpp:660
~level_map()
Definition th_map.cpp:255
void update_shadows()
Definition th_map.cpp:1451
bool set_size(int iWidth, int iHeight)
Definition th_map.cpp:273
bool load_from_th_file(const uint8_t *pData, size_t iDataLength, map_load_object_callback_fn fnObjectCallback, void *pCallbackToken)
Definition th_map.cpp:382
int get_parcel_owner(int iParcelId) const
Get the owner of a particular parcel of land.
Definition th_map.cpp:1274
bool are_parcels_adjacent(int iParcel1, int iParcel2)
Query if two parcels are directly connected.
Definition th_map.cpp:799
void set_temperature_display(temperature_theme eTempDisplay)
Definition th_map.cpp:1286
void set_player_count(int count)
Definition th_map.cpp:817
int get_parcel_count() const
Get the number of plots of land in this map.
Definition th_map.h:295
void update_temperatures(uint16_t iAirTemperature, uint16_t iRadiatorTemperature)
Definition th_map.cpp:1346
static void screen_to_world(T &x, T &y)
Convert absolute screen coordinates to world (tile) coordinates.
Definition th_map.h:393
bool is_parcel_purchasable(int iParcelId, int iPlayer)
Query if a given player is in a position to purchase a given parcel.
Definition th_map.cpp:808
static void world_to_screen(T &x, T &y)
Convert world (tile) coordinates to absolute screen coordinates.
Definition th_map.h:385
bool load_blank()
Definition th_map.cpp:347
drawable * hit_test(int iTestX, int iTestY) const
Perform a hit-test against the animations attached to the map.
Definition th_map.cpp:1208
bool get_player_heliport_tile(int iPlayer, int *pX, int *pY) const
Definition th_map.cpp:844
void set_all_wall_draw_flags(uint8_t iFlags)
Set the draw flags on all wall blocks.
Definition th_map.cpp:935
void draw(render_target *pCanvas, int iScreenX, int iScreenY, int iWidth, int iHeight, int iCanvasX, int iCanvasY) const
Draw the map (and any attached animations)
Definition th_map.cpp:1022
int get_tile_owner(const map_tile *pNode) const
Definition th_map.cpp:1269
map_tile * get_tile_unchecked(int iX, int iY)
Definition th_map.cpp:921
void set_player_camera_tile(int iPlayer, int iX, int iY)
Definition th_map.cpp:863
temperature_theme get_temperature_display() const
Definition th_map.h:282
void set_block_sheet(sprite_sheet *pSheet)
Set the sprite sheet to be used for drawing the map.
Definition th_map.cpp:933
uint16_t get_tile_temperature(const map_tile *pNode) const
Definition th_map.cpp:1282
void save(const std::string &filename)
Definition th_map.cpp:531
int get_width() const
Get the map width (in tiles)
Definition th_map.h:289
void set_player_heliport_tile(int iPlayer, int iX, int iY)
Definition th_map.cpp:870
int get_parcel_tile_count(int iParcelId) const
Get the number of tiles inside a given parcel.
Definition th_map.cpp:877
map_tile * get_tile(int iX, int iY)
Definition th_map.cpp:897
void depersist(lua_persist_reader *pReader)
Definition th_map.cpp:1558
const map_tile * get_original_tile(int iX, int iY) const
Definition th_map.cpp:913
void persist(lua_persist_writer *pWriter) const
Definition th_map.cpp:1481
int get_player_count() const
Definition th_map.h:297
void set_overlay(map_overlay *pOverlay, bool bTakeOwnership)
Definition th_map.cpp:265
void update_pathfinding()
Definition th_map.cpp:1402
const map_tile * get_original_tile_unchecked(int iX, int iY) const
Definition th_map.cpp:929
int get_height() const
Get the map height (in tiles)
Definition th_map.h:292
bool get_player_camera_tile(int iPlayer, int *pX, int *pY) const
Definition th_map.cpp:825
Generic linked list class (for inheriting from)
Definition th.h:30
Interface used for depersisting Lua objects.
Definition persist_lua.h:107
Interface used for persisting Lua objects.
Definition persist_lua.h:44
Definition th_map_overlays.h:35
Utility class for re-iterating a scanline visited by a map_tile_iterator.
Definition th_map.h:581
int x() const
Definition th_map.h:600
const map_tile * get_next_tile()
Definition th_map.h:602
map_scanline_iterator operator=(const map_scanline_iterator &iterator)
Definition th_map.cpp:1841
map_scanline_iterator & operator++()
Definition th_map.cpp:1832
int y() const
Definition th_map.h:601
map_scanline_iterator()
Definition th_map.cpp:1801
const map_tile * get_tile()
Definition th_map.h:605
const map_tile * operator->() const
Definition th_map.h:599
const map_tile * get_previous_tile()
Definition th_map.h:603
Utility class for iterating over map tiles within a screen rectangle.
Definition th_map.h:493
const level_map * get_map()
Definition th_map.h:533
int tile_x() const
Definition th_map.h:530
bool is_last_on_scanline() const
Returns true if the next tile will be on a different scanline.
Definition th_map.cpp:1796
int tile_y_position_on_screen() const
Definition th_map.h:528
int get_scanline_count()
Definition th_map.h:535
map_tile_iterator()=delete
map_tile_iterator & operator++()
Advances the iterator to the next tile.
Definition th_map.cpp:1731
const map_tile * get_map_tile()
Definition th_map.h:534
int tile_x_position_on_screen() const
Definition th_map.h:524
int get_tile_step()
Definition th_map.h:536
const map_tile * operator->() const
Accessor for the current tile.
Definition th_map.h:520
int tile_y() const
Definition th_map.h:531
Definition th_gfx_sdl.h:247
Sheet of sprites.
Definition th_gfx_sdl.h:504
bool buildable_w
Can build on the west side of the tile.
Definition th_map.h:163
bool can_travel_s
Pathfinding: Can walk to the south.
Definition th_map.h:146
bool buildable_s
Can build on the south side of the tile.
Definition th_map.h:162
bool passable_if_not_for_blueprint
Definition th_map.h:150
bool hospital
World: Tile is inside a hospital building.
Definition th_map.h:148
key
Definition th_map.h:119
@ passable_if_not_for_blueprint_mask
bool do_not_idle
World: Humanoids should not idle on tile.
Definition th_map.h:157
bool & operator[](map_tile_flags::key key)
Get/set the flag with the given key.
Definition th_map.cpp:82
bool can_travel_n
Pathfinding: Can walk to the north.
Definition th_map.h:144
bool buildable_n
Can build on the north side of the tile.
Definition th_map.h:160
bool door_north
World: Door on north wall of tile.
Definition th_map.h:155
bool buildable
Player: Can build on this tile.
Definition th_map.h:149
bool tall_north
Shadows: Wall-like object on north wall.
Definition th_map.h:158
bool shadow_half
Rendering: Put block 75 over floor.
Definition th_map.h:152
bool shadow_wall
Rendering: Put block 156 over east wall.
Definition th_map.h:154
bool room
World: Tile is inside a room.
Definition th_map.h:151
bool buildable_e
Can build on the east side of the tile.
Definition th_map.h:161
bool tall_west
Shadows: Wall-like object on west wall.
Definition th_map.h:159
bool can_travel_e
Pathfinding: Can walk to the east.
Definition th_map.h:145
bool can_travel_w
Pathfinding: Can walk to the west.
Definition th_map.h:147
map_tile_flags & operator=(uint32_t raw)
Definition th_map.cpp:52
bool shadow_full
Rendering: Put block 74 over floor.
Definition th_map.h:153
bool door_west
World: Door on west wall of tile.
Definition th_map.h:156
bool passable
Pathfinding: Can walk on this tile.
Definition th_map.h:143
uint16_t aiTemperature[2]
Definition th_map.h:226
std::uint8_t raw[raw_length]
raw data from map file for debugging
Definition th_map.h:237
std::list< object_type > objects
objects in this tile
Definition th_map.h:232
link_list entities
Definition th_map.h:199
link_list oEarlyEntities
Linked list for entities rendered in an early (right-to-left) pass.
Definition th_map.h:202
uint16_t iParcelId
Definition th_map.h:216
uint16_t tile_layers[tile_layer::num_tile_layers]
Definition th_map.h:212
static constexpr int raw_length
Definition th_map.h:234
uint16_t iRoomId
Rooms have an ID, with room #0 being the corridor (and the outside).
Definition th_map.h:219
map_tile_flags flags
Flags for information and object type.
Definition th_map.h:229
tile_layer
Definition th_map.h:185
@ north_wall
Definition th_map.h:187
@ west_wall
Definition th_map.h:188
@ ground
Definition th_map.h:186
@ num_tile_layers
Number of layers in a tile.
Definition th_map.h:191
@ ui
Definition th_map.h:189
temperature_theme
Definition th_map.h:179
@ multi_colour
Different colours (blue, green, red)
@ red
Default warmth colouring (red gradients)
@ yellow_red
Gradients of yellow, orange, and red.
map_scanline_iterator_direction
Definition th_map.h:477
object_type
Definition th_map.h:46
void(* map_load_object_callback_fn)(void *, int, int, object_type, uint8_t)
Prototype for object callbacks from THMap::loadFromTHFile.
Definition th_map.h:249