Bugs in mod return values fixed

This commit is contained in:
KimLS
2017-06-16 23:12:54 -07:00
parent 233ce5cf03
commit 8df8d7c3f6
5 changed files with 67 additions and 67 deletions
+8 -4
View File
@@ -398,19 +398,23 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) {
}
if (isrezzexp) {
if (RuleI(Character, ShowExpValues) > 0) Message(MT_Experience, "You regain %s experience from resurrection. %s", exp_amount_message.c_str(), exp_percent_message.c_str());
if (RuleI(Character, ShowExpValues) > 0)
Message(MT_Experience, "You regain %s experience from resurrection. %s", exp_amount_message.c_str(), exp_percent_message.c_str());
else Message_StringID(MT_Experience, REZ_REGAIN);
} else {
if (membercount > 1) {
if (RuleI(Character, ShowExpValues) > 0) Message(MT_Experience, "You have gained %s party experience! %s", exp_amount_message.c_str(), exp_percent_message.c_str());
if (RuleI(Character, ShowExpValues) > 0)
Message(MT_Experience, "You have gained %s party experience! %s", exp_amount_message.c_str(), exp_percent_message.c_str());
else Message_StringID(MT_Experience, GAIN_GROUPXP);
}
else if (IsRaidGrouped()) {
if (RuleI(Character, ShowExpValues) > 0) Message(MT_Experience, "You have gained %s raid experience! %s", exp_amount_message.c_str(), exp_percent_message.c_str());
if (RuleI(Character, ShowExpValues) > 0)
Message(MT_Experience, "You have gained %s raid experience! %s", exp_amount_message.c_str(), exp_percent_message.c_str());
else Message_StringID(MT_Experience, GAIN_RAIDEXP);
}
else {
if (RuleI(Character, ShowExpValues) > 0) Message(MT_Experience, "You have gained %s experience! %s", exp_amount_message.c_str(), exp_percent_message.c_str());
if (RuleI(Character, ShowExpValues) > 0)
Message(MT_Experience, "You have gained %s experience! %s", exp_amount_message.c_str(), exp_percent_message.c_str());
else Message_StringID(MT_Experience, GAIN_XP);
}
}
+20 -43
View File
@@ -181,7 +181,6 @@ void GetExtraAttackOptions(luabind::adl::object &ret, ExtraAttackOptions *opts)
void LuaMod::MeleeMitigation(Mob *self, Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault) {
int start = lua_gettop(L);
ignoreDefault = false;
try {
if (!m_has_melee_mitigation) {
@@ -233,7 +232,6 @@ void LuaMod::MeleeMitigation(Mob *self, Mob *attacker, DamageHitInfo &hit, Extra
void LuaMod::ApplyDamageTable(Mob *self, DamageHitInfo &hit, bool &ignoreDefault) {
int start = lua_gettop(L);
ignoreDefault = false;
try {
if (!m_has_apply_damage_table) {
@@ -278,14 +276,12 @@ void LuaMod::ApplyDamageTable(Mob *self, DamageHitInfo &hit, bool &ignoreDefault
}
}
bool LuaMod::AvoidDamage(Mob *self, Mob *other, DamageHitInfo &hit, bool &ignoreDefault) {
void LuaMod::AvoidDamage(Mob *self, Mob *other, DamageHitInfo &hit, bool &returnValue, bool &ignoreDefault) {
int start = lua_gettop(L);
ignoreDefault = false;
bool retval = false;
try {
if (!m_has_avoid_damage) {
return retval;
return;
}
lua_getfield(L, LUA_REGISTRYINDEX, package_name_.c_str());
@@ -304,7 +300,7 @@ bool LuaMod::AvoidDamage(Mob *self, Mob *other, DamageHitInfo &hit, bool &ignore
std::string error = lua_tostring(L, -1);
parser_->AddError(error);
lua_pop(L, 1);
return retval;
return;
}
if (lua_type(L, -1) == LUA_TTABLE) {
@@ -316,7 +312,7 @@ bool LuaMod::AvoidDamage(Mob *self, Mob *other, DamageHitInfo &hit, bool &ignore
auto returnValueObj = ret["ReturnValue"];
if (luabind::type(returnValueObj) == LUA_TBOOLEAN) {
retval = luabind::object_cast<bool>(returnValueObj);
returnValue = luabind::object_cast<bool>(returnValueObj);
}
GetDamageHitInfo(ret, hit);
@@ -331,18 +327,14 @@ bool LuaMod::AvoidDamage(Mob *self, Mob *other, DamageHitInfo &hit, bool &ignore
if (n > 0) {
lua_pop(L, n);
}
return retval;
}
bool LuaMod::CheckHitChance(Mob *self, Mob* other, DamageHitInfo &hit, bool &ignoreDefault) {
void LuaMod::CheckHitChance(Mob *self, Mob* other, DamageHitInfo &hit, bool &returnValue, bool &ignoreDefault) {
int start = lua_gettop(L);
ignoreDefault = false;
bool retval = false;
try {
if (!m_has_check_hit_chance) {
return retval;
return;
}
lua_getfield(L, LUA_REGISTRYINDEX, package_name_.c_str());
@@ -361,7 +353,7 @@ bool LuaMod::CheckHitChance(Mob *self, Mob* other, DamageHitInfo &hit, bool &ign
std::string error = lua_tostring(L, -1);
parser_->AddError(error);
lua_pop(L, 1);
return retval;
return;
}
if (lua_type(L, -1) == LUA_TTABLE) {
@@ -373,7 +365,7 @@ bool LuaMod::CheckHitChance(Mob *self, Mob* other, DamageHitInfo &hit, bool &ign
auto returnValueObj = ret["ReturnValue"];
if (luabind::type(returnValueObj) == LUA_TBOOLEAN) {
retval = luabind::object_cast<bool>(returnValueObj);
returnValue = luabind::object_cast<bool>(returnValueObj);
}
GetDamageHitInfo(ret, hit);
@@ -388,14 +380,11 @@ bool LuaMod::CheckHitChance(Mob *self, Mob* other, DamageHitInfo &hit, bool &ign
if (n > 0) {
lua_pop(L, n);
}
return retval;
}
void LuaMod::CommonOutgoingHitSuccess(Mob *self, Mob *other, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault)
{
int start = lua_gettop(L);
ignoreDefault = false;
try {
if (!m_has_common_outgoing_hit_success) {
@@ -446,7 +435,6 @@ void LuaMod::CommonOutgoingHitSuccess(Mob *self, Mob *other, DamageHitInfo &hit,
void LuaMod::TryCriticalHit(Mob *self, Mob *defender, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault) {
int start = lua_gettop(L);
ignoreDefault = false;
try {
if (!m_has_try_critical_hit) {
@@ -495,15 +483,13 @@ void LuaMod::TryCriticalHit(Mob *self, Mob *defender, DamageHitInfo &hit, ExtraA
}
}
uint32 LuaMod::GetRequiredAAExperience(Client *self, bool &ignoreDefault)
void LuaMod::GetRequiredAAExperience(Client *self, uint32 &returnValue, bool &ignoreDefault)
{
int start = lua_gettop(L);
ignoreDefault = false;
uint32 retval = 0;
try {
if (!m_has_get_required_aa_experience) {
return retval;
return;
}
lua_getfield(L, LUA_REGISTRYINDEX, package_name_.c_str());
@@ -518,7 +504,7 @@ uint32 LuaMod::GetRequiredAAExperience(Client *self, bool &ignoreDefault)
std::string error = lua_tostring(L, -1);
parser_->AddError(error);
lua_pop(L, 1);
return retval;
return;
}
if (lua_type(L, -1) == LUA_TTABLE) {
@@ -530,7 +516,7 @@ uint32 LuaMod::GetRequiredAAExperience(Client *self, bool &ignoreDefault)
auto returnValueObj = ret["ReturnValue"];
if (luabind::type(returnValueObj) == LUA_TNUMBER) {
retval = luabind::object_cast<uint32>(returnValueObj);
returnValue = luabind::object_cast<uint32>(returnValueObj);
}
}
}
@@ -543,18 +529,14 @@ uint32 LuaMod::GetRequiredAAExperience(Client *self, bool &ignoreDefault)
if (n > 0) {
lua_pop(L, n);
}
return retval;
}
uint32 LuaMod::GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault) {
void LuaMod::GetEXPForLevel(Client *self, uint16 level, uint32 &returnValue, bool &ignoreDefault) {
int start = lua_gettop(L);
ignoreDefault = false;
uint32 retval = 0;
try {
if (!m_has_get_exp_for_level) {
return retval;
return;
}
lua_getfield(L, LUA_REGISTRYINDEX, package_name_.c_str());
@@ -570,7 +552,7 @@ uint32 LuaMod::GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault) {
std::string error = lua_tostring(L, -1);
parser_->AddError(error);
lua_pop(L, 1);
return retval;
return;
}
if (lua_type(L, -1) == LUA_TTABLE) {
@@ -582,7 +564,7 @@ uint32 LuaMod::GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault) {
auto returnValueObj = ret["ReturnValue"];
if (luabind::type(returnValueObj) == LUA_TNUMBER) {
retval = luabind::object_cast<uint32>(returnValueObj);
returnValue = luabind::object_cast<uint32>(returnValueObj);
}
}
}
@@ -595,19 +577,16 @@ uint32 LuaMod::GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault) {
if (n > 0) {
lua_pop(L, n);
}
return retval;
}
uint32 LuaMod::GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault)
void LuaMod::GetExperienceForKill(Client *self, Mob *against, uint32 &returnValue, bool &ignoreDefault)
{
int start = lua_gettop(L);
ignoreDefault = false;
uint32 retval = 0;
try {
if (!m_has_get_experience_for_kill) {
return retval;
return;
}
lua_getfield(L, LUA_REGISTRYINDEX, package_name_.c_str());
@@ -624,7 +603,7 @@ uint32 LuaMod::GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefa
std::string error = lua_tostring(L, -1);
parser_->AddError(error);
lua_pop(L, 1);
return retval;
return;
}
if (lua_type(L, -1) == LUA_TTABLE) {
@@ -636,7 +615,7 @@ uint32 LuaMod::GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefa
auto returnValueObj = ret["ReturnValue"];
if (luabind::type(returnValueObj) == LUA_TNUMBER) {
retval = luabind::object_cast<uint32>(returnValueObj);
returnValue = luabind::object_cast<uint32>(returnValueObj);
}
}
}
@@ -649,6 +628,4 @@ uint32 LuaMod::GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefa
if (n > 0) {
lua_pop(L, n);
}
return retval;
}
+5 -5
View File
@@ -19,13 +19,13 @@ public:
void MeleeMitigation(Mob *self, Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault);
void ApplyDamageTable(Mob *self, DamageHitInfo &hit, bool &ignoreDefault);
bool AvoidDamage(Mob *self, Mob *other, DamageHitInfo &hit, bool &ignoreDefault);
bool CheckHitChance(Mob *self, Mob* other, DamageHitInfo &hit, bool &ignoreDefault);
void AvoidDamage(Mob *self, Mob *other, DamageHitInfo &hit, bool &returnValue, bool &ignoreDefault);
void CheckHitChance(Mob *self, Mob* other, DamageHitInfo &hit, bool &returnValue, bool &ignoreDefault);
void CommonOutgoingHitSuccess(Mob *self, Mob* other, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault);
void TryCriticalHit(Mob *self, Mob *defender, DamageHitInfo &hit, ExtraAttackOptions *opts, bool &ignoreDefault);
uint32 GetRequiredAAExperience(Client *self, bool &ignoreDefault);
uint32 GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault);
uint32 GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault);
void GetRequiredAAExperience(Client *self, uint32 &returnValue, bool &ignoreDefault);
void GetEXPForLevel(Client *self, uint16 level, uint32 &returnValue, bool &ignoreDefault);
void GetExperienceForKill(Client *self, Mob *against, uint32 &returnValue, bool &ignoreDefault);
private:
LuaParser *parser_;
lua_State *L;
+8 -8
View File
@@ -1312,7 +1312,7 @@ bool LuaParser::AvoidDamage(Mob *self, Mob *other, DamageHitInfo &hit, bool & ig
{
bool retval = false;
for (auto &mod : mods_) {
retval = mod.AvoidDamage(self, other, hit, ignoreDefault);
mod.AvoidDamage(self, other, hit, retval, ignoreDefault);
}
return retval;
}
@@ -1321,7 +1321,7 @@ bool LuaParser::CheckHitChance(Mob *self, Mob *other, DamageHitInfo &hit, bool &
{
bool retval = false;
for (auto &mod : mods_) {
retval = mod.CheckHitChance(self, other, hit, ignoreDefault);
mod.CheckHitChance(self, other, hit, retval, ignoreDefault);
}
return retval;
}
@@ -1342,27 +1342,27 @@ void LuaParser::CommonOutgoingHitSuccess(Mob *self, Mob *other, DamageHitInfo &h
uint32 LuaParser::GetRequiredAAExperience(Client *self, bool &ignoreDefault)
{
uint32 retval = false;
uint32 retval = 0;
for (auto &mod : mods_) {
retval = mod.GetRequiredAAExperience(self, ignoreDefault);
mod.GetRequiredAAExperience(self, retval, ignoreDefault);
}
return retval;
}
uint32 LuaParser::GetEXPForLevel(Client *self, uint16 level, bool &ignoreDefault)
{
uint32 retval = false;
uint32 retval = 0;
for (auto &mod : mods_) {
retval = mod.GetEXPForLevel(self, level, ignoreDefault);
mod.GetEXPForLevel(self, level, retval, ignoreDefault);
}
return retval;
}
uint32 LuaParser::GetExperienceForKill(Client *self, Mob *against, bool &ignoreDefault)
{
uint32 retval = false;
uint32 retval = 0;
for (auto &mod : mods_) {
retval = mod.GetExperienceForKill(self, against, ignoreDefault);
mod.GetExperienceForKill(self, against, retval, ignoreDefault);
}
return retval;
}