mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-07 10:23:53 +00:00
[Lua] Resolve stoi Exception (#2736)
* [Lua] Resolve stoi Exception * Change fallback for wp, not really needed for safety * Change to Strings::ToInt
This commit is contained in:
parent
8031bf0bcb
commit
6a9228ed6e
@ -763,3 +763,10 @@ std::string Strings::Random(size_t length)
|
||||
std::generate_n(str.begin(), length, randchar);
|
||||
return str;
|
||||
}
|
||||
|
||||
// a wrapper for stoi which will return a fallback if the string
|
||||
// fails to cast to a number
|
||||
int Strings::ToInt(const std::string &s, int fallback)
|
||||
{
|
||||
return Strings::IsNumber(s) ? std::stoi(s) : fallback;
|
||||
}
|
||||
|
||||
@ -86,6 +86,7 @@ class Strings {
|
||||
public:
|
||||
static bool Contains(std::vector<std::string> container, std::string element);
|
||||
static bool Contains(const std::string& subject, const std::string& search);
|
||||
static int ToInt(const std::string &s, int fallback = 0);
|
||||
static bool IsNumber(const std::string &s);
|
||||
static bool IsFloat(const std::string &s);
|
||||
static const std::string ToLower(std::string s);
|
||||
|
||||
@ -120,12 +120,12 @@ void handle_npc_event_hp(
|
||||
if(extra_data == 1) {
|
||||
lua_pushinteger(L, -1);
|
||||
lua_setfield(L, -2, "hp_event");
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "inc_hp_event");
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "hp_event");
|
||||
lua_pushinteger(L, -1);
|
||||
lua_setfield(L, -2, "inc_hp_event");
|
||||
@ -191,7 +191,7 @@ void handle_npc_task_accepted(
|
||||
l_client_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "task_id");
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ void handle_npc_popup(
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "popup_id");
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ void handle_npc_waypoint(
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data, -1));
|
||||
lua_setfield(L, -2, "wp");
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ void handle_npc_hate(
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
|
||||
lua_pushboolean(L, std::stoi(data) == 0 ? false : true);
|
||||
lua_pushboolean(L, Strings::ToInt(data) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "joined");
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ void handle_npc_signal(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "signal");
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ void handle_npc_payload(
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "payload_id");
|
||||
|
||||
lua_pushstring(L, sep.argplus[1]);
|
||||
@ -309,13 +309,13 @@ void handle_npc_death(
|
||||
lua_setfield(L, -2, "other");
|
||||
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "killer_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "damage");
|
||||
|
||||
int spell_id = std::stoi(sep.arg[2]);
|
||||
int spell_id = Strings::ToInt(sep.arg[2]);
|
||||
if(IsValidSpell(spell_id)) {
|
||||
Lua_Spell l_spell(&spells[spell_id]);
|
||||
luabind::adl::object l_spell_o = luabind::adl::object(L, l_spell);
|
||||
@ -328,7 +328,7 @@ void handle_npc_death(
|
||||
lua_setfield(L, -2, "spell");
|
||||
}
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[3]));
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
|
||||
if (extra_pointers && extra_pointers->size() >= 1)
|
||||
@ -357,7 +357,7 @@ void handle_npc_cast(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
int spell_id = std::stoi(data);
|
||||
int spell_id = Strings::ToInt(data);
|
||||
if(IsValidSpell(spell_id)) {
|
||||
Lua_Spell l_spell(&spells[spell_id]);
|
||||
luabind::adl::object l_spell_o = luabind::adl::object(L, l_spell);
|
||||
@ -522,13 +522,13 @@ void handle_player_environmental_damage(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "env_damage");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "env_damage_type");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "env_final_damage");
|
||||
}
|
||||
|
||||
@ -542,19 +542,19 @@ void handle_player_death(
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
Mob *o = entity_list.GetMobID(std::stoi(sep.arg[0]));
|
||||
Mob *o = entity_list.GetMobID(Strings::ToInt(sep.arg[0]));
|
||||
Lua_Mob l_mob(o);
|
||||
luabind::adl::object l_mob_o = luabind::adl::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "killer_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "damage");
|
||||
|
||||
int spell_id = std::stoi(sep.arg[3]);
|
||||
int spell_id = Strings::ToInt(sep.arg[3]);
|
||||
if(IsValidSpell(spell_id)) {
|
||||
Lua_Spell l_spell(&spells[spell_id]);
|
||||
luabind::adl::object l_spell_o = luabind::adl::object(L, l_spell);
|
||||
@ -567,7 +567,7 @@ void handle_player_death(
|
||||
lua_setfield(L, -2, "spell");
|
||||
}
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[4]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[4]));
|
||||
lua_setfield(L, -2, "skill");
|
||||
}
|
||||
|
||||
@ -655,7 +655,7 @@ void handle_player_signal(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "signal");
|
||||
}
|
||||
|
||||
@ -669,7 +669,7 @@ void handle_player_payload(
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "payload_id");
|
||||
|
||||
lua_pushstring(L, sep.argplus[1]);
|
||||
@ -684,7 +684,7 @@ void handle_player_popup_response(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "popup_id");
|
||||
}
|
||||
|
||||
@ -712,7 +712,7 @@ void handle_player_cast(
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
int spell_id = std::stoi(sep.arg[0]);
|
||||
int spell_id = Strings::ToInt(sep.arg[0]);
|
||||
if(IsValidSpell(spell_id)) {
|
||||
Lua_Spell l_spell(&spells[spell_id]);
|
||||
luabind::adl::object l_spell_o = luabind::adl::object(L, l_spell);
|
||||
@ -725,10 +725,10 @@ void handle_player_cast(
|
||||
|
||||
lua_setfield(L, -2, "spell");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "caster_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "caster_level");
|
||||
}
|
||||
|
||||
@ -740,7 +740,7 @@ void handle_player_task_fail(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "task_id");
|
||||
}
|
||||
|
||||
@ -754,22 +754,22 @@ void handle_player_zone(
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "from_zone_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "from_instance_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "from_instance_version");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[3]));
|
||||
lua_setfield(L, -2, "zone_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[4]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[4]));
|
||||
lua_setfield(L, -2, "instance_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[5]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[5]));
|
||||
lua_setfield(L, -2, "instance_version");
|
||||
}
|
||||
|
||||
@ -829,10 +829,10 @@ void handle_player_task_stage_complete(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "task_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "activity_id");
|
||||
}
|
||||
|
||||
@ -857,13 +857,13 @@ void handle_player_task_update(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "count");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "activity_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "task_id");
|
||||
}
|
||||
|
||||
@ -944,7 +944,7 @@ void handle_player_respawn(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "option");
|
||||
|
||||
lua_pushboolean(L, extra_data == 1 ? true : false);
|
||||
@ -987,10 +987,10 @@ void handle_player_use_skill(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "skill_level");
|
||||
}
|
||||
|
||||
@ -1022,10 +1022,10 @@ void handle_player_combine_validate(
|
||||
int zone_id = -1;
|
||||
int tradeskill_id = -1;
|
||||
if (strcmp(sep.arg[0], "check_zone") == 0) {
|
||||
zone_id = std::stoi(sep.arg[1]);
|
||||
zone_id = Strings::ToInt(sep.arg[1]);
|
||||
}
|
||||
else if (strcmp(sep.arg[0], "check_tradeskill") == 0) {
|
||||
tradeskill_id = std::stoi(sep.arg[1]);
|
||||
tradeskill_id = Strings::ToInt(sep.arg[1]);
|
||||
}
|
||||
|
||||
lua_pushinteger(L, zone_id);
|
||||
@ -1087,7 +1087,7 @@ void handle_player_quest_combine(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "container_slot");
|
||||
}
|
||||
|
||||
@ -1099,7 +1099,7 @@ void handle_player_consider(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "entity_id");
|
||||
}
|
||||
|
||||
@ -1111,7 +1111,7 @@ void handle_player_consider_corpse(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "corpse_entity_id");
|
||||
}
|
||||
|
||||
@ -1138,16 +1138,16 @@ void handle_player_aa_buy(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "aa_cost");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "aa_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "aa_previous_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[3]));
|
||||
lua_setfield(L, -2, "aa_next_id");
|
||||
}
|
||||
|
||||
@ -1159,7 +1159,7 @@ void handle_player_aa_gain(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "aa_gained");
|
||||
}
|
||||
|
||||
@ -1211,16 +1211,16 @@ void handle_player_bot_create(
|
||||
lua_pushstring(L, sep.arg[0]);
|
||||
lua_setfield(L, -2, "bot_name");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "bot_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "bot_race");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[3]));
|
||||
lua_setfield(L, -2, "bot_class");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[4]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[4]));
|
||||
lua_setfield(L, -2, "bot_gender");
|
||||
}
|
||||
|
||||
@ -1495,16 +1495,16 @@ void handle_spell_event(
|
||||
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "caster_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "tics_remaining");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "caster_level");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[3]));
|
||||
lua_setfield(L, -2, "buff_slot");
|
||||
|
||||
Lua_Spell l_spell(spell_id);
|
||||
@ -1553,10 +1553,10 @@ void handle_player_equip_item(
|
||||
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[0]));
|
||||
lua_pushnumber(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "item_quantity");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[1]));
|
||||
lua_pushnumber(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "slot_id");
|
||||
|
||||
Lua_ItemInst l_item(extra_data);
|
||||
@ -1644,16 +1644,16 @@ void handle_player_skill_up(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "skill_value");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "skill_max");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[3]));
|
||||
lua_setfield(L, -2, "is_tradeskill");
|
||||
}
|
||||
|
||||
@ -1666,13 +1666,13 @@ void handle_player_language_skill_up(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "skill_value");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "skill_max");
|
||||
}
|
||||
|
||||
@ -1685,19 +1685,19 @@ void handle_player_alt_currency_merchant(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "currency_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "npc_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "merchant_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[3]));
|
||||
lua_setfield(L, -2, "item_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[4]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[4]));
|
||||
lua_setfield(L, -2, "item_cost");
|
||||
}
|
||||
|
||||
@ -1710,19 +1710,19 @@ void handle_player_merchant(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "npc_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "merchant_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "item_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[3]));
|
||||
lua_setfield(L, -2, "item_quantity");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[4]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[4]));
|
||||
lua_setfield(L, -2, "item_cost");
|
||||
}
|
||||
|
||||
@ -1748,7 +1748,7 @@ void handle_player_augment_insert(
|
||||
lua_pushinteger(L, std::stoul(sep.arg[0]));
|
||||
lua_setfield(L, -2, "item_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "item_slot");
|
||||
|
||||
lua_pushinteger(L, std::stoul(sep.arg[2]));
|
||||
@ -1780,7 +1780,7 @@ void handle_player_augment_remove(
|
||||
lua_pushinteger(L, std::stoul(sep.arg[0]));
|
||||
lua_setfield(L, -2, "item_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "item_slot");
|
||||
|
||||
lua_pushinteger(L, std::stoul(sep.arg[2]));
|
||||
@ -1817,7 +1817,7 @@ void handle_bot_cast(
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
int spell_id = std::stoi(sep.arg[0]);
|
||||
int spell_id = Strings::ToInt(sep.arg[0]);
|
||||
if (IsValidSpell(spell_id)) {
|
||||
Lua_Spell l_spell(&spells[spell_id]);
|
||||
luabind::adl::object l_spell_o = luabind::adl::object(L, l_spell);
|
||||
@ -1830,10 +1830,10 @@ void handle_bot_cast(
|
||||
|
||||
lua_setfield(L, -2, "spell");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "caster_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[2]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[2]));
|
||||
lua_setfield(L, -2, "caster_level");
|
||||
}
|
||||
|
||||
@ -1851,7 +1851,7 @@ void handle_bot_combat(
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
|
||||
lua_pushboolean(L, std::stoi(data) == 0 ? false : true);
|
||||
lua_pushboolean(L, Strings::ToInt(data) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "joined");
|
||||
}
|
||||
|
||||
@ -1866,16 +1866,16 @@ void handle_bot_death(
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
Mob *o = entity_list.GetMobID(std::stoi(sep.arg[0]));
|
||||
Mob *o = entity_list.GetMobID(Strings::ToInt(sep.arg[0]));
|
||||
Lua_Mob l_mob(o);
|
||||
luabind::adl::object l_mob_o = luabind::adl::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "damage");
|
||||
|
||||
int spell_id = std::stoi(sep.arg[2]);
|
||||
int spell_id = Strings::ToInt(sep.arg[2]);
|
||||
if (IsValidSpell(spell_id)) {
|
||||
Lua_Spell l_spell(&spells[spell_id]);
|
||||
luabind::adl::object l_spell_o = luabind::adl::object(L, l_spell);
|
||||
@ -1888,7 +1888,7 @@ void handle_bot_death(
|
||||
lua_setfield(L, -2, "spell");
|
||||
}
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[3]));
|
||||
lua_setfield(L, -2, "skill");
|
||||
}
|
||||
|
||||
@ -1906,7 +1906,7 @@ void handle_bot_popup_response(
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "popup_id");
|
||||
}
|
||||
|
||||
@ -1940,7 +1940,7 @@ void handle_bot_signal(
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_pushinteger(L, Strings::ToInt(data));
|
||||
lua_setfield(L, -2, "signal");
|
||||
}
|
||||
|
||||
@ -1955,7 +1955,7 @@ void handle_bot_payload(
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "payload_id");
|
||||
|
||||
lua_pushstring(L, sep.argplus[1]);
|
||||
@ -2073,10 +2073,10 @@ void handle_bot_use_skill(
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
lua_pushinteger(L, std::stoi(sep.arg[0]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[0]));
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
|
||||
lua_pushinteger(L, std::stoi(sep.arg[1]));
|
||||
lua_pushinteger(L, Strings::ToInt(sep.arg[1]));
|
||||
lua_setfield(L, -2, "skill_level");
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user