Fix some typos
This commit is contained in:
parent
dff7b7d90d
commit
b075bbf0c1
5 changed files with 41 additions and 41 deletions
|
@ -40,9 +40,9 @@ static lg::log_domain log_scripting_lua_mapgen("scripting/lua/mapgen");
|
|||
#define ERR_LMG LOG_STREAM(err, log_scripting_lua_mapgen)
|
||||
//general helper functions for parsing
|
||||
|
||||
struct inalid_lua_argument : public std::exception
|
||||
struct invalid_lua_argument : public std::exception
|
||||
{
|
||||
explicit inalid_lua_argument(const std::string& msg) : errormessage_(msg) {}
|
||||
explicit invalid_lua_argument(const std::string& msg) : errormessage_(msg) {}
|
||||
const char* what() const noexcept { return errormessage_.c_str(); }
|
||||
|
||||
private:
|
||||
|
@ -589,7 +589,7 @@ public:
|
|||
};
|
||||
|
||||
// todo: maybe invent a gerneral macro for this string_switch implementation.
|
||||
enum filter_keys { F_AND, F_OR, F_NAND, F_NOR, F_X, F_Y, F_FIND_IN, F_ADJACENT, F_TERRAIN, F_RADUIS, F_FORMULA, F_CACHED };
|
||||
enum filter_keys { F_AND, F_OR, F_NAND, F_NOR, F_X, F_Y, F_FIND_IN, F_ADJACENT, F_TERRAIN, F_RADIUS, F_FORMULA, F_CACHED };
|
||||
//todoc++14: std::unordered_map doesn'tsupport herterogrnous lookup.
|
||||
//todo consider renaming and -> all ,or ->any, nor -> none, nand -> notall
|
||||
static const std::unordered_map<std::string, filter_keys> keys {
|
||||
|
@ -604,14 +604,14 @@ static const std::unordered_map<std::string, filter_keys> keys {
|
|||
{ "terrain", F_TERRAIN },
|
||||
{ "cached", F_CACHED },
|
||||
{ "formula", F_FORMULA },
|
||||
{ "radius", F_RADUIS }
|
||||
{ "radius", F_RADIUS }
|
||||
};
|
||||
|
||||
std::unique_ptr<filter_impl> build_filter(lua_State* L, int res_index, knows_sets_t& ks)
|
||||
{
|
||||
LOG_LMG << "buildfilter: start\n";
|
||||
if(!lua_istable(L, -1)) {
|
||||
throw inalid_lua_argument("buildfilter: expected table");
|
||||
throw invalid_lua_argument("buildfilter: expected table");
|
||||
}
|
||||
lua_rawgeti(L, -1, 1);
|
||||
std::string s = std::string(luaW_tostring(L, -1));
|
||||
|
@ -619,7 +619,7 @@ std::unique_ptr<filter_impl> build_filter(lua_State* L, int res_index, knows_set
|
|||
auto it = keys.find(s);
|
||||
if(it == keys.end()) {
|
||||
//fixme use proper exception type.
|
||||
throw inalid_lua_argument(std::string("buildfilter: invalid filter type ") + s);
|
||||
throw invalid_lua_argument(std::string("buildfilter: invalid filter type ") + s);
|
||||
}
|
||||
auto key = it->second;
|
||||
lua_pop(L, 1);
|
||||
|
@ -643,7 +643,7 @@ std::unique_ptr<filter_impl> build_filter(lua_State* L, int res_index, knows_set
|
|||
return std::make_unique<adjacent_filter>(L, res_index, ks);
|
||||
case F_TERRAIN:
|
||||
return std::make_unique<terrain_filter>(L, res_index, ks);
|
||||
case F_RADUIS:
|
||||
case F_RADIUS:
|
||||
return std::make_unique<radius_filter>(L, res_index, ks);
|
||||
case F_CACHED:
|
||||
return std::make_unique<cached_filter>(L, res_index, ks);
|
||||
|
@ -790,7 +790,7 @@ static lua_mapgen::filter* luaW_push_mgfilter(lua_State *L, T&&... params)
|
|||
/**
|
||||
* Create a filter.
|
||||
*/
|
||||
int intf_terainfilter_create(lua_State *L)
|
||||
int intf_terrainfilter_create(lua_State *L)
|
||||
{
|
||||
try {
|
||||
int res_index = 0;
|
||||
|
@ -804,7 +804,7 @@ int intf_terainfilter_create(lua_State *L)
|
|||
luaW_push_mgfilter(L, std::move(res));
|
||||
return 1;
|
||||
}
|
||||
catch(const inalid_lua_argument& e) {
|
||||
catch(const invalid_lua_argument& e) {
|
||||
return luaL_argerror(L, 1, e.what());
|
||||
}
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ int intf_terainfilter_create(lua_State *L)
|
|||
* - Arg 2: string containing the name of the property.
|
||||
* - Ret 1: something containing the attribute.
|
||||
*/
|
||||
static int impl_terainfilter_get(lua_State *L)
|
||||
static int impl_terrainfilter_get(lua_State *L)
|
||||
{
|
||||
lua_mapgen::filter& f = luaW_check_mgfilter(L, 1);
|
||||
UNUSED(f);
|
||||
|
@ -829,7 +829,7 @@ static int impl_terainfilter_get(lua_State *L)
|
|||
* - Arg 2: string containing the name of the property.
|
||||
* - Arg 3: something containing the attribute.
|
||||
*/
|
||||
static int impl_terainfilter_set(lua_State *L)
|
||||
static int impl_terrainfilter_set(lua_State *L)
|
||||
{
|
||||
lua_mapgen::filter& f = luaW_check_mgfilter(L, 1);
|
||||
UNUSED(f);
|
||||
|
@ -852,7 +852,7 @@ static int intf_clearcache(lua_State *L)
|
|||
/**
|
||||
* Destroys a map object before it is collected (__gc metamethod).
|
||||
*/
|
||||
static int impl_terainfilter_collect(lua_State *L)
|
||||
static int impl_terrainfilter_collect(lua_State *L)
|
||||
{
|
||||
lua_mapgen::filter& f = luaW_check_mgfilter(L, 1);
|
||||
f.~filter();
|
||||
|
@ -868,15 +868,15 @@ namespace lua_terrainfilter {
|
|||
cmd_out << "Adding terrainmamap metatable...\n";
|
||||
|
||||
luaL_newmetatable(L, terrinfilterKey);
|
||||
lua_pushcfunction(L, impl_terainfilter_collect);
|
||||
lua_pushcfunction(L, impl_terrainfilter_collect);
|
||||
lua_setfield(L, -2, "__gc");
|
||||
lua_pushcfunction(L, impl_terainfilter_get);
|
||||
lua_pushcfunction(L, impl_terrainfilter_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
lua_pushcfunction(L, impl_terainfilter_set);
|
||||
lua_pushcfunction(L, impl_terrainfilter_set);
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
lua_pushstring(L, "terrain_filter");
|
||||
lua_setfield(L, -2, "__metatable");
|
||||
// terainmap methods
|
||||
// terrainmap methods
|
||||
lua_pushcfunction(L, intf_clearcache);
|
||||
lua_setfield(L, -2, "clear_cache");
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ lua_mapgen::filter& luaW_check_mgfilter(lua_State *L, int index);
|
|||
|
||||
void lua_mgfilter_setmetatable(lua_State *L);
|
||||
|
||||
int intf_terainfilter_create(lua_State *L);
|
||||
int intf_terrainfilter_create(lua_State *L);
|
||||
|
||||
int intf_mg_get_locations(lua_State* L);
|
||||
int intf_mg_get_tiles_radius(lua_State* L);
|
||||
|
|
|
@ -30,7 +30,7 @@ static lg::log_domain log_scripting_lua("scripting/lua");
|
|||
#define LOG_LUA LOG_STREAM(info, log_scripting_lua)
|
||||
#define ERR_LUA LOG_STREAM(err, log_scripting_lua)
|
||||
|
||||
static const char terrinmapKey[] = "terrainmap";
|
||||
static const char terrainmapKey[] = "terrainmap";
|
||||
static const char maplocationKey[] = "special_locations";
|
||||
|
||||
using std::string_view;
|
||||
|
@ -92,8 +92,8 @@ int impl_slocs_get(lua_State* L)
|
|||
//todo: calling map.special_locations[1] will return the underlying map
|
||||
// object instead of the first starting position, because the lua
|
||||
// special locations is actually a table with the map object at
|
||||
// index 1. The probably easiest way to fix this inconsitency is
|
||||
// to just disallow all integerindicies here.
|
||||
// index 1. The probably easiest way to fix this inconsistency is
|
||||
// to just disallow all integer indices here.
|
||||
mapgen_gamemap& m = luaW_check_slocs(L, 1);
|
||||
string_view id = luaL_checkstring(L, 2);
|
||||
auto res = m.special_location(std::string(id));
|
||||
|
@ -193,7 +193,7 @@ map_location mapgen_gamemap::special_location(const std::string& id) const
|
|||
|
||||
bool luaW_isterrainmap(lua_State* L, int index)
|
||||
{
|
||||
return luaL_testudata(L, index, terrinmapKey) != nullptr;
|
||||
return luaL_testudata(L, index, terrainmapKey) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,7 +216,7 @@ mapgen_gamemap& luaW_checkterrainmap(lua_State *L, int index)
|
|||
|
||||
void lua_terrainmap_setmetatable(lua_State *L)
|
||||
{
|
||||
luaL_setmetatable(L, terrinmapKey);
|
||||
luaL_setmetatable(L, terrainmapKey);
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
|
@ -229,13 +229,13 @@ mapgen_gamemap* luaW_pushmap(lua_State *L, T&&... params)
|
|||
|
||||
/**
|
||||
* Create a map.
|
||||
* - Arg 1: string descripbing the map data.
|
||||
* - Arg 1: string describing the map data.
|
||||
* - or:
|
||||
* - Arg 1: int, width
|
||||
* - Arg 2: int, height
|
||||
* - Arg 3: string, terrain
|
||||
*/
|
||||
int intf_terainmap_create(lua_State *L)
|
||||
int intf_terrainmap_create(lua_State *L)
|
||||
{
|
||||
if(lua_isnumber(L, 1) && lua_isnumber(L, 2)) {
|
||||
int w = lua_tonumber(L, 1);
|
||||
|
@ -254,7 +254,7 @@ int intf_terainmap_create(lua_State *L)
|
|||
/**
|
||||
* Destroys a map object before it is collected (__gc metamethod).
|
||||
*/
|
||||
static int impl_terainmap_collect(lua_State *L)
|
||||
static int impl_terrainmap_collect(lua_State *L)
|
||||
{
|
||||
mapgen_gamemap *u = static_cast<mapgen_gamemap*>(lua_touserdata(L, 1));
|
||||
u->mapgen_gamemap::~mapgen_gamemap();
|
||||
|
@ -267,7 +267,7 @@ static int impl_terainmap_collect(lua_State *L)
|
|||
* - Arg 2: string containing the name of the property.
|
||||
* - Ret 1: something containing the attribute.
|
||||
*/
|
||||
static int impl_terainmap_get(lua_State *L)
|
||||
static int impl_terrainmap_get(lua_State *L)
|
||||
{
|
||||
mapgen_gamemap& tm = luaW_checkterrainmap(L, 1);
|
||||
char const *m = luaL_checkstring(L, 2);
|
||||
|
@ -293,7 +293,7 @@ static int impl_terainmap_get(lua_State *L)
|
|||
* - Arg 2: string containing the name of the property.
|
||||
* - Arg 3: something containing the attribute.
|
||||
*/
|
||||
static int impl_terainmap_set(lua_State *L)
|
||||
static int impl_terrainmap_set(lua_State *L)
|
||||
{
|
||||
mapgen_gamemap& tm = luaW_checkterrainmap(L, 1);
|
||||
UNUSED(tm);
|
||||
|
@ -397,11 +397,11 @@ static std::vector<gamemap::overlay_rule> read_rules_vector(lua_State *L, int in
|
|||
return rules;
|
||||
}
|
||||
/**
|
||||
* Reaplces part of the map.
|
||||
* Replaces part of the map.
|
||||
* - Arg 1: map location.
|
||||
* - Arg 2: map data string.
|
||||
* - Arg 3: table for optional named arguments
|
||||
* - is_odd: boolen, if Arg2 has the odd mapo format (as if it was cut from a odd map location)
|
||||
* - is_odd: boolean, if Arg2 has the odd map format (as if it was cut from a odd map location)
|
||||
* - ignore_special_locations: boolean
|
||||
* - rules: table of tables
|
||||
*/
|
||||
|
@ -448,18 +448,18 @@ namespace lua_terrainmap {
|
|||
{
|
||||
std::ostringstream cmd_out;
|
||||
|
||||
cmd_out << "Adding terrainmamap metatable...\n";
|
||||
cmd_out << "Adding terrainmap metatable...\n";
|
||||
|
||||
luaL_newmetatable(L, terrinmapKey);
|
||||
lua_pushcfunction(L, impl_terainmap_collect);
|
||||
luaL_newmetatable(L, terrainmapKey);
|
||||
lua_pushcfunction(L, impl_terrainmap_collect);
|
||||
lua_setfield(L, -2, "__gc");
|
||||
lua_pushcfunction(L, impl_terainmap_get);
|
||||
lua_pushcfunction(L, impl_terrainmap_get);
|
||||
lua_setfield(L, -2, "__index");
|
||||
lua_pushcfunction(L, impl_terainmap_set);
|
||||
lua_pushcfunction(L, impl_terrainmap_set);
|
||||
lua_setfield(L, -2, "__newindex");
|
||||
lua_pushstring(L, "terainmap");
|
||||
lua_pushstring(L, "terrainmap");
|
||||
lua_setfield(L, -2, "__metatable");
|
||||
// terainmap methods
|
||||
// terrainmap methods
|
||||
lua_pushcfunction(L, intf_set_terrain);
|
||||
lua_setfield(L, -2, "set_terrain");
|
||||
lua_pushcfunction(L, intf_get_terrain);
|
||||
|
@ -471,7 +471,7 @@ namespace lua_terrainmap {
|
|||
lua_pushcfunction(L, &mapgen_gamemap::intf_mg_terrain_mask);
|
||||
lua_setfield(L, -2, "terrain_mask");
|
||||
|
||||
cmd_out << "Adding terrainmamap2 metatable...\n";
|
||||
cmd_out << "Adding terrainmap2 metatable...\n";
|
||||
|
||||
luaL_newmetatable(L, maplocationKey);
|
||||
lua_pushcfunction(L, impl_slocs_get);
|
||||
|
|
|
@ -26,7 +26,7 @@ struct map_location;
|
|||
|
||||
// this clas is similar to the orginal gamemap class but they have no 'is' rlation:
|
||||
// mapgen_gamemap, unlike gamemap offers 'raw' access to the data
|
||||
// gamemap, unlike mapgen_gamemap uses terain type data.
|
||||
// gamemap, unlike mapgen_gamemap uses terrain type data.
|
||||
class mapgen_gamemap
|
||||
{
|
||||
public:
|
||||
|
@ -118,7 +118,7 @@ void lua_terrainmap_setmetatable(lua_State *L);
|
|||
|
||||
mapgen_gamemap* luaW_pushmap(lua_State *L, mapgen_gamemap&& u);
|
||||
|
||||
int intf_terainmap_create(lua_State *L);
|
||||
int intf_terrainmap_create(lua_State *L);
|
||||
|
||||
namespace lua_terrainmap {
|
||||
std::string register_metatables(lua_State *L);
|
||||
|
|
|
@ -222,8 +222,8 @@ mapgen_lua_kernel::mapgen_lua_kernel(const config* vars)
|
|||
static luaL_Reg const callbacks[] {
|
||||
{ "find_path", &intf_find_path },
|
||||
{ "random", &intf_random },
|
||||
{ "create_filter", &intf_terainfilter_create },
|
||||
{ "create_map", &intf_terainmap_create },
|
||||
{ "create_filter", &intf_terrainfilter_create },
|
||||
{ "create_map", &intf_terrainmap_create },
|
||||
{ "default_generate_height_map", &intf_default_generate_height_map },
|
||||
{ "generate_default_map", &intf_default_generate },
|
||||
{ "get_variable", &dispatch<&mapgen_lua_kernel::intf_get_variable> },
|
||||
|
|
Loading…
Add table
Reference in a new issue