| 534 | |
| 535 | |
| 536 | int LuaHandle::ScriptGetCallInInfo(lua_State* L) { |
| 537 | std::vector<std::string> list; |
| 538 | eventHandler.GetEventList(list); |
| 539 | |
| 540 | const LuaCallInDB::InfoMap& ciInfoMap = luaCallInDB.GetInfoMap(); |
| 541 | LuaCallInDB::InfoMap::const_iterator it; |
| 542 | |
| 543 | if (lua_israwstring(L, 1)) { |
| 544 | const std::string ciName = lua_tostring(L, 1); |
| 545 | const bool wantAll = lua_isboolean(L, 2) && lua_tobool(L, 2); |
| 546 | if (wantAll || L2H(L)->CanUseCallIn(ciName)) { |
| 547 | it = ciInfoMap.find(ciName); |
| 548 | if (it != ciInfoMap.end()) { |
| 549 | PushCallInInfo(L, it->second); |
| 550 | } |
| 551 | } |
| 552 | else { |
| 553 | return luaL_pushnil(L); |
| 554 | } |
| 555 | } |
| 556 | else { |
| 557 | const bool wantAll = lua_isboolean(L, 1) && lua_tobool(L, 1); |
| 558 | lua_createtable(L, 0, ciInfoMap.size()); |
| 559 | for (it = ciInfoMap.begin(); it != ciInfoMap.end(); ++it) { |
| 560 | const LuaCallInDB::CallInInfo& ciInfo = it->second; |
| 561 | if (wantAll || L2H(L)->CanUseCallIn(ciInfo.name)) { |
| 562 | lua_pushstring(L, ciInfo.name.c_str()); |
| 563 | PushCallInInfo(L, ciInfo); |
| 564 | lua_rawset(L, -3); |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | return 1; |
| 570 | } |
| 571 | |
| 572 | |
| 573 | int LuaHandle::ScriptCanUseCallIn(lua_State* L) { |
nothing calls this directly
no test coverage detected