MCPcopy Create free account
hub / github.com/NetHack/NetHack / get_table_region

Function get_table_region

src/sp_lev.c:5281–5316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5279}
5280
5281staticfn int
5282get_table_region(
5283 lua_State *L,
5284 const char *name,
5285 lua_Integer *x1, lua_Integer *y1,
5286 lua_Integer *x2, lua_Integer *y2,
5287 boolean optional)
5288{
5289 lua_Integer arrlen;
5290
5291 lua_getfield(L, 1, name);
5292 if (optional && lua_type(L, -1) == LUA_TNIL) {
5293 lua_pop(L, 1);
5294 return 1;
5295 }
5296
5297 luaL_checktype(L, -1, LUA_TTABLE);
5298
5299 lua_len(L, -1);
5300 arrlen = lua_tointeger(L, -1);
5301 lua_pop(L, 1);
5302 if (arrlen != 4) {
5303 nhl_error(L, "Not a region");
5304 /*NOTREACHED*/
5305 lua_pop(L, 1);
5306 return 0;
5307 }
5308
5309 *x1 = get_table_intarray_entry(L, -1, 1);
5310 *y1 = get_table_intarray_entry(L, -1, 2);
5311 *x2 = get_table_intarray_entry(L, -1, 3);
5312 *y2 = get_table_intarray_entry(L, -1, 4);
5313
5314 lua_pop(L, 1);
5315 return 1;
5316}
5317
5318boolean
5319get_coord(lua_State *L, int i, lua_Integer *x, lua_Integer *y)

Callers 4

lspo_replace_terrainFunction · 0.85
l_get_lregionFunction · 0.85
lspo_exclusionFunction · 0.85

Calls 2

nhl_errorFunction · 0.85
get_table_intarray_entryFunction · 0.85

Tested by

no test coverage detected