• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Damage, Health, and Mana showing negative values

Addams

OTMadness.com OTSes Services
Staff member
Board Moderator
Joined
Sep 29, 2009
Messages
2,920
Solutions
342
Reaction score
1,688
Location
Egypt
So I've successfully broken the int32 limits to int64 in TFS 1.5, but I can't find the right int data for these ones, I've been told that it's a compiler issue, and moving to Linux will just solve it but I wanted to get sure.
Looking at players or monsters shows negative health and mana values, Example:
player1.PNG
monster1.PNG
and attacking players or monsters shows negative damage values, Example:
player2.PNGmonster2.PNG
Healing mana or health shows negative values too, Example:
health healing.PNG
manahealing.png

The same happens for monsters healing too.
I have noticed that it mostly occurs when I am getting 2 times of damage or healing in a row, if I am healing myself and other player/players Sios me at the same moment then it occurs or if I am using mana rune and other player POT/mana rune me at the same moment it occurs.
Is it a compiler issue, a client-side issue or there are some int data to fix it?
 
Solution
Are you using latest TFS?
I believe I fixed the second issue(onLook) with not using string.format.

First issue is in protocolgame.cpp I belive
void ProtocolGame::sendTextMessage(const TextMessage& message)
C++:
case MESSAGE_DAMAGE_OTHERS: {
    msg.addPosition(message.position);
    msg.add<uint32_t>(message.primary.value);
    msg.addByte(message.primary.color);
    msg.add<uint32_t>(message.secondary.value);
    msg.addByte(message.secondary.color);
    break;
}

Normally damage messages is sent as uint32, but you need to change on client side to recieve it as uint64 aswell
Not complety sure but yes, it could be a windows issue since i have a similar situation when i run tests on my pc, i get decimal points on healing values while on linux works just fine, not on TFS 1.x tho
 
Not complety sure but yes, it could be a windows issue since i have a similar situation when i run tests on my pc, i get decimal points on healing values while on linux works just fine, not on TFS 1.x tho
Yes looks like a Windows issue, I will wait for someone else to confirm it.
I also forgot to mention that the MaxHealth and MaxMana on the first two screenshots aren't the correct ones too, Is it the same issue or a different one? These ones 1881317353 and 1881475072.
player1.PNG
monster1.PNG
 
Sent you PM
Thank you, I won't be able to move it there because of my partner's lack of experience as I clarified to you on PM, I really appreciate it tho.
I will still wait for someone to confirm stuff here in the thread and I will test some protocolgame.cpp changes by myself in the meanwhile, So this is still (unsolved).
 
Last edited:
Are you using latest TFS?
I believe I fixed the second issue(onLook) with not using string.format.

First issue is in protocolgame.cpp I belive
void ProtocolGame::sendTextMessage(const TextMessage& message)
C++:
case MESSAGE_DAMAGE_OTHERS: {
    msg.addPosition(message.position);
    msg.add<uint32_t>(message.primary.value);
    msg.addByte(message.primary.color);
    msg.add<uint32_t>(message.secondary.value);
    msg.addByte(message.secondary.color);
    break;
}

Normally damage messages is sent as uint32, but you need to change on client side to recieve it as uint64 aswell
 
Solution
Are you using latest TFS?
Yes, I am using the latest TFS.
I believe I fixed the second issue(onLook) with not using string.format.
What have you replaced string.format with? I've been trying different functions and I am still getting the wrong values, I even tried to change it all to self:sendTextMessage (Just to see the value)
manax.PNG
I am testing with a great number though, That could be the reason, I use untouched default_onLook.
Normally damage messages is sent as uint32, but you need to change on client side to recieve it as uint64 aswell
Thank you, I've made these changes and compiled, I will check if it's possible with one of the game_features in OTCv8 to receive uint64 to test it out.
 
Last edited:
this is how the default_onLook looks like for me
Lua:
        elseif thing:isCreature() then
            description = description .. "\nHealth: ".. thing:getHealth() .." / ".. thing:getMaxHealth()..""
            if thing:isPlayer() and thing:getMaxMana() > 0 then
                description = description .. ", Mana: ".. thing:getMana() .." / ".. thing:getMaxMana() ..""
            end
        end

Assuming you have changed all the getHealth etc to reflect uint64_t
 
this is how the default_onLook looks like for me
Lua:
        elseif thing:isCreature() then
            description = description .. "\nHealth: ".. thing:getHealth() .." / ".. thing:getMaxHealth()..""
            if thing:isPlayer() and thing:getMaxMana() > 0 then
                description = description .. ", Mana: ".. thing:getMana() .." / ".. thing:getMaxMana() ..""
            end
        end

Assuming you have changed all the getHealth etc to reflect uint64_t
Thank you, Everything works fine now.
 
Back
Top