Derlexy
Intermediate OT User
- Joined
- Jun 29, 2011
- Messages
- 219
- Reaction score
- 101
Hello guys, i need your help once again...
I've added a new type of mana in my server (i call it spirit). Now, i have to send it to my client, to be able to read and show it. I found this function that seems to do it (send player stats to the client), and tried to add some more bytes like this:
Original:
With my changes:
As you can see, i just added this at the end:
I compiled the server and i got no errors. But when i try to run the server, i get the following:
What am I missing? I forget to do something in another place?
Im currently using Nostalrius distro, that is TFS 1.2 based. Repository here: GitHub - Ezzz-dev/Nostalrius: Nostalrius is a 7.7 Tibia Clone Project based on The Forgotten Server 1.2 and CipSoft files. (https://github.com/Ezzz-dev/Nostalrius)
I've added a new type of mana in my server (i call it spirit). Now, i have to send it to my client, to be able to read and show it. I found this function that seems to do it (send player stats to the client), and tried to add some more bytes like this:
Original:
C++:
void ProtocolGame::AddPlayerStats(NetworkMessage& msg)
{
msg.addByte(0xA0);
msg.add<uint16_t>(std::min<int32_t>(player->getHealth(), std::numeric_limits<uint16_t>::max()));
msg.add<uint16_t>(std::min<int32_t>(player->getMaxHealth(), std::numeric_limits<uint16_t>::max()));
msg.add<uint16_t>(static_cast<uint16_t>(player->getFreeCapacity() / 100.));
if (player->getExperience() >= std::numeric_limits<uint32_t>::max()) {
msg.add<uint32_t>(0);
} else {
msg.add<uint32_t>(static_cast<uint32_t>(player->getExperience()));
}
msg.add<uint16_t>(static_cast<uint16_t>(player->getLevel()));
msg.addByte(player->getLevelPercent());
msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
msg.add<uint16_t>(std::min<int32_t>(player->getMaxMana(), std::numeric_limits<uint16_t>::max()));
msg.addByte(std::min<uint32_t>(player->getMagicLevel(), std::numeric_limits<uint8_t>::max()));
msg.addByte(player->getMagicLevelPercent());
msg.addByte(player->getSoul());
}
With my changes:
C++:
void ProtocolGame::AddPlayerStats(NetworkMessage& msg)
{
msg.addByte(0xA0);
msg.add<uint16_t>(std::min<int32_t>(player->getHealth(), std::numeric_limits<uint16_t>::max()));
msg.add<uint16_t>(std::min<int32_t>(player->getMaxHealth(), std::numeric_limits<uint16_t>::max()));
msg.add<uint16_t>(static_cast<uint16_t>(player->getFreeCapacity() / 100.));
if (player->getExperience() >= std::numeric_limits<uint32_t>::max()) {
msg.add<uint32_t>(0);
} else {
msg.add<uint32_t>(static_cast<uint32_t>(player->getExperience()));
}
msg.add<uint16_t>(static_cast<uint16_t>(player->getLevel()));
msg.addByte(player->getLevelPercent());
msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
msg.add<uint16_t>(std::min<int32_t>(player->getMaxMana(), std::numeric_limits<uint16_t>::max()));
msg.addByte(std::min<uint32_t>(player->getMagicLevel(), std::numeric_limits<uint8_t>::max()));
msg.addByte(player->getMagicLevelPercent());
msg.addByte(player->getSoul());
msg.add<uint16_t>(std::min<int32_t>(player->getSpirit(), std::numeric_limits<uint16_t>::max()));
msg.add<uint16_t>(std::min<int32_t>(player->getMaxSpirit(), std::numeric_limits<uint16_t>::max()));
}
As you can see, i just added this at the end:
C++:
msg.add<uint16_t>(std::min<int32_t>(player->getSpirit(), std::numeric_limits<uint16_t>::max()));
msg.add<uint16_t>(std::min<int32_t>(player->getMaxSpirit(), std::numeric_limits<uint16_t>::max()));
I compiled the server and i got no errors. But when i try to run the server, i get the following:
What am I missing? I forget to do something in another place?
Im currently using Nostalrius distro, that is TFS 1.2 based. Repository here: GitHub - Ezzz-dev/Nostalrius: Nostalrius is a 7.7 Tibia Clone Project based on The Forgotten Server 1.2 and CipSoft files. (https://github.com/Ezzz-dev/Nostalrius)