MCPcopy Create free account
hub / github.com/EQEmu/EQEmu / LuaCheckHandin

Method LuaCheckHandin

zone/lua_npc.cpp:855–928  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

853}
854
855bool Lua_NPC::LuaCheckHandin(
856 Lua_Client c,
857 luabind::adl::object handin_table,
858 luabind::adl::object required_table,
859 luabind::adl::object items_table
860)
861{
862 Lua_Safe_Call_Bool();
863
864 if (
865 luabind::type(handin_table) != LUA_TTABLE ||
866 luabind::type(required_table) != LUA_TTABLE ||
867 luabind::type(items_table) != LUA_TTABLE
868 ) {
869 return false;
870 }
871
872 std::map<std::string, uint32> handin_map;
873 std::map<std::string, uint32> required_map;
874 std::vector<EQ::ItemInstance *> items;
875
876 for (luabind::iterator i(handin_table), end; i != end; i++) {
877 std::string key;
878 if (luabind::type(i.key()) == LUA_TSTRING) {
879 key = luabind::object_cast<std::string>(i.key());
880 }
881 else if (luabind::type(i.key()) == LUA_TNUMBER) {
882 key = fmt::format("{}", luabind::object_cast<int>(i.key()));
883 }
884 else {
885 LogError("Handin key type [{}] not supported", luabind::type(i.key()));
886 }
887
888 if (!key.empty()) {
889 handin_map[key] = luabind::object_cast<uint32>(handin_table[i.key()]);
890 LogNpcHandinDetail("Handin key [{}] value [{}]", key, handin_map[key]);
891 }
892 }
893
894 for (luabind::iterator i(required_table), end; i != end; i++) {
895 std::string key;
896 if (luabind::type(i.key()) == LUA_TSTRING) {
897 key = luabind::object_cast<std::string>(i.key());
898 }
899 else if (luabind::type(i.key()) == LUA_TNUMBER) {
900 key = fmt::format("{}", luabind::object_cast<int>(i.key()));
901 }
902 else {
903 LogError("Required key type [{}] not supported", luabind::type(i.key()));
904 }
905
906 if (!key.empty()) {
907 required_map[key] = luabind::object_cast<uint32>(required_table[i.key()]);
908 LogNpcHandinDetail("Required key [{}] value [{}]", key, required_map[key]);
909 }
910 }
911
912 for (luabind::iterator i(items_table), end; i != end; i++) {

Callers

nothing calls this directly

Calls 8

CheckHandinMethod · 0.80
typeFunction · 0.50
keyMethod · 0.45
emptyMethod · 0.45
GetItemMethod · 0.45
GetNameMethod · 0.45
GetIDMethod · 0.45
GetSerialNumberMethod · 0.45

Tested by

no test coverage detected