MCPcopy Index your code
hub / github.com/NetHack/NetHack / get_coord

Function get_coord

src/sp_lev.c:5318–5366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5316}
5317
5318boolean
5319get_coord(lua_State *L, int i, lua_Integer *x, lua_Integer *y)
5320{
5321 boolean ret = FALSE;
5322 int ltyp = lua_type(L, i);
5323
5324 if (ltyp == LUA_TTABLE) {
5325 int arrlen;
5326 boolean gotx = FALSE;
5327
5328 lua_getfield(L, i, "x");
5329 if (!lua_isnil(L, -1)) {
5330 *x = luaL_checkinteger(L, -1);
5331 gotx = TRUE;
5332 }
5333 lua_pop(L, 1);
5334
5335 if (gotx) {
5336 lua_getfield(L, i, "y");
5337 if (!lua_isnil(L, -1)) {
5338 *y = luaL_checkinteger(L, -1);
5339 lua_pop(L, 1);
5340 ret = TRUE;
5341 } else {
5342 nhl_error(L, "Not a coordinate");
5343 /*NOTREACHED*/
5344 return FALSE;
5345 }
5346 } else {
5347 lua_len(L, i);
5348 arrlen = lua_tointeger(L, -1);
5349 lua_pop(L, 1);
5350 if (arrlen != 2) {
5351 nhl_error(L, "Not a coordinate");
5352 /*NOTREACHED*/
5353 return FALSE;
5354 }
5355
5356 *x = get_table_intarray_entry(L, i, 1);
5357 *y = get_table_intarray_entry(L, i, 2);
5358
5359 return TRUE;
5360 }
5361 } else if (ltyp != LUA_TNIL) {
5362 /* non-existent coord is ok */
5363 nhl_error(L, "non-table coord specified");
5364 }
5365 return ret;
5366}
5367
5368RESTORE_WARNING_UNREACHABLE_CODE
5369

Callers 9

nhl_get_xy_paramsFunction · 0.85
get_table_xy_or_coordFunction · 0.85
lspo_monsterFunction · 0.85
lspo_objectFunction · 0.85
lspo_engravingFunction · 0.85
lspo_trapFunction · 0.85
lspo_goldFunction · 0.85
lspo_featureFunction · 0.85
lspo_terrainFunction · 0.85

Calls 2

nhl_errorFunction · 0.85
get_table_intarray_entryFunction · 0.85

Tested by

no test coverage detected