| 4470 | } |
| 4471 | |
| 4472 | DISABLE_WARNING_UNREACHABLE_CODE |
| 4473 | |
| 4474 | /* gold(500, 3,5); */ |
| 4475 | /* gold(500, {5, 6}); */ |
| 4476 | /* gold({ amount = 500, x = 2, y = 5 });*/ |
| 4477 | /* gold({ amount = 500, coord = {2, 5} });*/ |
| 4478 | /* gold(); */ |
| 4479 | int |
| 4480 | lspo_gold(lua_State *L) |
| 4481 | { |
| 4482 | int argc = lua_gettop(L); |
| 4483 | coordxy x, y; |
| 4484 | long amount; |
| 4485 | long gcoord; |
| 4486 | lua_Integer gldx, gldy; |
| 4487 | |
| 4488 | create_des_coder(); |
| 4489 | |
| 4490 | if (argc == 3) { |
| 4491 | amount = luaL_checkinteger(L, 1); |
| 4492 | x = gldx = luaL_checkinteger(L, 2); |
| 4493 | y = gldy = luaL_checkinteger(L, 3); |
| 4494 | } else if (argc == 2 && lua_type(L, 2) == LUA_TTABLE) { |
| 4495 | amount = luaL_checkinteger(L, 1); |
| 4496 | (void) get_coord(L, 2, &gldx, &gldy); |
| 4497 | x = gldx; |
| 4498 | y = gldy; |
| 4499 | } else if (argc == 0 || (argc == 1 && lua_type(L, 1) == LUA_TTABLE)) { |
| 4500 | lcheck_param_table(L); |
| 4501 | |
| 4502 | amount = get_table_int_opt(L, "amount", -1); |
| 4503 | get_table_xy_or_coord(L, &gldx, &gldy); |
| 4504 | x = gldx, y = gldy; |
| 4505 | } else { |
| 4506 | nhl_error(L, "Wrong parameters"); |
| 4507 | /*NOTREACHED*/ |
| 4508 | return 0; |
| 4509 | } |
| 4510 | |
| 4511 | if (x == -1 && y == -1) |
| 4512 | gcoord = SP_COORD_PACK_RANDOM(0); |
| 4513 | else |
| 4514 | gcoord = SP_COORD_PACK(gldx, gldy); |
| 4515 | |
| 4516 | get_location_coord(&x, &y, DRY, gc.coder->croom, gcoord); |
| 4517 | if (amount < 0) |
| 4518 | amount = rnd(200); |
| 4519 | mkgold(amount, x, y); |
| 4520 | |
| 4521 | return 0; |
| 4522 | } |
| 4523 | |
| 4524 | RESTORE_WARNING_UNREACHABLE_CODE |
| 4525 |
nothing calls this directly
no test coverage detected