fix multiple signals for onHealthChange, etc
This commit is contained in:
parent
ad76353073
commit
cc432f784b
|
@ -666,33 +666,67 @@ void ProtocolGame::parseHouseTextWindow(InputMessage& msg)
|
||||||
|
|
||||||
void ProtocolGame::parsePlayerStats(InputMessage& msg)
|
void ProtocolGame::parsePlayerStats(InputMessage& msg)
|
||||||
{
|
{
|
||||||
m_localPlayer->setStatistic(Otc::Health, msg.getU16());
|
double health = msg.getU16();
|
||||||
m_localPlayer->setStatistic(Otc::MaxHealth, msg.getU16());
|
double maxHealth = msg.getU16();
|
||||||
g_lua.callGlobalField("Game", "onHealthChange", m_localPlayer->getStatistic(Otc::Health), m_localPlayer->getStatistic(Otc::MaxHealth));
|
double freeCapacity = msg.getU32() / 100.0;
|
||||||
|
double experience = msg.getU32();
|
||||||
|
double level = msg.getU16();
|
||||||
|
double levelPercent = msg.getU8();
|
||||||
|
double mana = msg.getU16();
|
||||||
|
double maxMana = msg.getU16();
|
||||||
|
double magicLevel = msg.getU8();
|
||||||
|
double magicLevelPercent = msg.getU8();
|
||||||
|
double soul = msg.getU8();
|
||||||
|
double stamina = msg.getU16();
|
||||||
|
|
||||||
m_localPlayer->setStatistic(Otc::FreeCapacity, msg.getU32() / 100.0);
|
//TODO: move to game
|
||||||
g_lua.callGlobalField("Game", "onFreeCapacityChange", m_localPlayer->getStatistic(Otc::FreeCapacity));
|
if(m_localPlayer->getStatistic(Otc::Health) != health ||
|
||||||
|
m_localPlayer->getStatistic(Otc::MaxHealth) != maxHealth) {
|
||||||
|
m_localPlayer->setStatistic(Otc::Health, health);
|
||||||
|
m_localPlayer->setStatistic(Otc::MaxHealth, maxHealth);
|
||||||
|
g_lua.callGlobalField("Game", "onHealthChange", health, maxHealth);
|
||||||
|
}
|
||||||
|
|
||||||
m_localPlayer->setStatistic(Otc::Experience, msg.getU32());
|
if(m_localPlayer->getStatistic(Otc::FreeCapacity) != freeCapacity) {
|
||||||
g_lua.callGlobalField("Game", "onExperienceChange", m_localPlayer->getStatistic(Otc::Experience));
|
m_localPlayer->setStatistic(Otc::FreeCapacity, freeCapacity);
|
||||||
|
g_lua.callGlobalField("Game", "onFreeCapacityChange", freeCapacity);
|
||||||
|
}
|
||||||
|
|
||||||
m_localPlayer->setStatistic(Otc::Level, msg.getU16());
|
if(m_localPlayer->getStatistic(Otc::Experience) != experience) {
|
||||||
m_localPlayer->setStatistic(Otc::LevelPercent, msg.getU8());
|
m_localPlayer->setStatistic(Otc::Experience, experience);
|
||||||
g_lua.callGlobalField("Game", "onLevelChange", m_localPlayer->getStatistic(Otc::Level), m_localPlayer->getStatistic(Otc::LevelPercent));
|
g_lua.callGlobalField("Game", "onExperienceChange", experience);
|
||||||
|
}
|
||||||
|
|
||||||
m_localPlayer->setStatistic(Otc::Mana, msg.getU16());
|
if(m_localPlayer->getStatistic(Otc::Level) != level ||
|
||||||
m_localPlayer->setStatistic(Otc::MaxMana, msg.getU16());
|
m_localPlayer->getStatistic(Otc::LevelPercent) != levelPercent) {
|
||||||
g_lua.callGlobalField("Game", "onManaChange", m_localPlayer->getStatistic(Otc::Mana), m_localPlayer->getStatistic(Otc::MaxMana));
|
m_localPlayer->setStatistic(Otc::Level, level);
|
||||||
|
m_localPlayer->setStatistic(Otc::LevelPercent, levelPercent);
|
||||||
|
g_lua.callGlobalField("Game", "onLevelChange", level, levelPercent);
|
||||||
|
}
|
||||||
|
|
||||||
m_localPlayer->setStatistic(Otc::MagicLevel, msg.getU8());
|
if(m_localPlayer->getStatistic(Otc::Mana) != mana ||
|
||||||
m_localPlayer->setStatistic(Otc::MagicLevelPercent, msg.getU8());
|
m_localPlayer->getStatistic(Otc::MaxMana) != maxMana) {
|
||||||
g_lua.callGlobalField("Game", "onMagicLevelChange", m_localPlayer->getStatistic(Otc::MagicLevel), m_localPlayer->getStatistic(Otc::MagicLevelPercent));
|
m_localPlayer->setStatistic(Otc::Mana, mana);
|
||||||
|
m_localPlayer->setStatistic(Otc::MaxMana, maxMana);
|
||||||
|
g_lua.callGlobalField("Game", "onManaChange", mana, maxMana);
|
||||||
|
}
|
||||||
|
|
||||||
m_localPlayer->setStatistic(Otc::Soul, msg.getU8());
|
if(m_localPlayer->getStatistic(Otc::MagicLevel) != magicLevel ||
|
||||||
g_lua.callGlobalField("Game", "onSoulChange", m_localPlayer->getStatistic(Otc::Soul));
|
m_localPlayer->getStatistic(Otc::MagicLevelPercent) != magicLevelPercent) {
|
||||||
|
m_localPlayer->setStatistic(Otc::MagicLevel, magicLevel);
|
||||||
|
m_localPlayer->setStatistic(Otc::MagicLevelPercent, magicLevelPercent);
|
||||||
|
g_lua.callGlobalField("Game", "onMagicLevelChange", magicLevel, magicLevelPercent);
|
||||||
|
}
|
||||||
|
|
||||||
m_localPlayer->setStatistic(Otc::Stamina, msg.getU16());
|
if(m_localPlayer->getStatistic(Otc::Soul) != soul) {
|
||||||
g_lua.callGlobalField("Game", "onStaminaChange", m_localPlayer->getStatistic(Otc::Stamina));
|
m_localPlayer->setStatistic(Otc::Soul, soul);
|
||||||
|
g_lua.callGlobalField("Game", "onSoulChange", soul);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_localPlayer->getStatistic(Otc::Stamina) != stamina) {
|
||||||
|
m_localPlayer->setStatistic(Otc::Stamina, stamina);
|
||||||
|
g_lua.callGlobalField("Game", "onStaminaChange", stamina);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtocolGame::parsePlayerSkills(InputMessage& msg)
|
void ProtocolGame::parsePlayerSkills(InputMessage& msg)
|
||||||
|
|
Loading…
Reference in New Issue