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

Function can_do_extcmd

src/cmd.c:462–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462staticfn boolean
463can_do_extcmd(const struct ext_func_tab *extcmd)
464{
465 int ecflags = extcmd->flags;
466
467 if (gl.luacore && nhcb_counts[NHCB_CMD_BEFORE]) {
468 lua_getglobal(gl.luacore, "nh_callback_run");
469 lua_pushstring(gl.luacore, nhcb_name[NHCB_CMD_BEFORE]);
470 lua_pushstring(gl.luacore, extcmd->ef_txt);
471 nhl_pcall_handle(gl.luacore, 2, 1, "can_do_extcmd", NHLpa_panic);
472 if (!lua_toboolean(gl.luacore, -1)) {
473 lua_settop(gl.luacore, 0);
474 return FALSE;
475 }
476 lua_settop(gl.luacore, 0);
477 }
478
479 if (!wizard && (ecflags & WIZMODECMD)) {
480 pline(unavailcmd, extcmd->ef_txt);
481 return FALSE;
482 } else if (u.uburied && !(ecflags & IFBURIED)) {
483 You_cant("do that while you are buried!");
484 return FALSE;
485 } else if (iflags.debug_fuzzer && (ecflags & NOFUZZERCMD)) {
486 return FALSE;
487 }
488 return TRUE;
489}
490
491/* here after # - now read a full-word command */
492int

Callers 2

doextcmdFunction · 0.85
rhackFunction · 0.85

Calls 3

nhl_pcall_handleFunction · 0.85
You_cantFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected