void ProtocolGame::AddPlayerStats(NetworkMessage& msg)
{
msg.addByte(0xA0);
int32_t temp;
bool usePercents = !player->getStorageValue(1444, temp);
if(usePercents)
{
msg.add<uint16_t>((uint16_t)std::floor(player->getHealth() * 100 / std::max(player->getMaxHealth(), 1)));
msg.add<uint16_t>(100);
}
else
{
msg.add<uint16_t>(player->getHealth());
msg.add<uint16_t>(player->getMaxHealth());
}
msg.add<uint32_t>(player->getFreeCapacity());
msg.add<uint32_t>(std::min<uint32_t>(player->getExperience(), 0x7FFFFFFF));
msg.add<uint16_t>(player->getLevel());
msg.addByte(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT));
if (player->getPlayerInfo(PLAYERINFO_MAXMANA) > 0) {
msg.add<uint16_t>(player->getMana() * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA));
msg.add<uint16_t>(100);
} else {
msg.add<uint16_t>(0);
msg.add<uint16_t>(0);
}
msg.addByte(std::min<uint32_t>(player->getMagicLevel(), std::numeric_limits<uint8_t>::max()));
msg.addByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVELPERCENT));
msg.addByte(player->getSoul());
msg.add<uint16_t>(player->getStaminaMinutes());
}