-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
lua_terrainmap.hpp
64 lines (49 loc) · 1.8 KB
/
lua_terrainmap.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
Copyright (C) 2018 the Battle for Wesnoth Project https://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#pragma once
#include <cstddef>
#include <string>
#include "scripting/lua_common.hpp"
#include "map/location.hpp"
#include "map/map.hpp"
#include "terrain/translation.hpp"
#include "terrain/type_data.hpp"
struct lua_State;
class lua_unit;
struct map_location;
// Unlike the original gamemap, this offers 'raw' access to the data.
// The original gamemap uses terrain type data.
class mapgen_gamemap : public gamemap_base {
public:
explicit mapgen_gamemap(std::string_view data);
mapgen_gamemap(int w, int h, terrain_code);
void set_terrain(const map_location& loc, const terrain_code & terrain, const terrain_type_data::merge_mode mode = terrain_type_data::BOTH, bool replace_if_failed = false) override;
template<typename F>
void for_each_loc(const F& f) const
{
for (int x = 0; x < total_width(); ++x) {
for (int y = 0; y < total_height(); ++y) {
f({ x, y , wml_loc()});
}
}
}
};
int intf_terrain_mask(lua_State *L);
bool luaW_isterrainmap(lua_State* L, int index);
gamemap_base* luaW_toterrainmap(lua_State *L, int index);
gamemap_base& luaW_checkterrainmap(lua_State *L, int index);
void lua_terrainmap_setmetatable(lua_State *L);
int intf_terrainmap_create(lua_State *L);
int intf_terrainmap_get(lua_State *L);
int intf_replace_if_failed(lua_State* L);
namespace lua_terrainmap {
std::string register_metatables(lua_State *L);
}