• 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++ enumerator value '65536'

T

Tibia Demon

Guest
i got this error on visual studio while i was compiling latest tfs.
Code:
enumerator value '65536' cannot be represented as 'unsigned short'
the only thing i did was adding like 10 new combat to enums.h
i fixed the error by changing
to
C++:
enum CombatType_t : uint32_t
is it safe or it will affect anything else and cause crash if there is better solution please post it here.
i am using tfs 1.4.1
 
Solution
I was using search function in the github and haven't found anything else that could be relevant. But as I said, don't take my words for granted.
By the way, perhaps you could change the enumeration to 1, 2, 3, 4 etc. instead of the current 1 << 1, 1 << 2, 1 << 3, 1 << 4; and then leave the type as uint16_t.
I can't find any use of this. It makes perfect sense for condition statuses, because each condition (being poisoned, hasted, on mana shield etc.) can have a state of 0 or 1, so you can pack them all together in one integer, reserving one bit for each condition. But for damage type it doesn't make sense to me and I could not find any reason for this in the code.
i got this error on visual studio while i was compiling latest tfs.
Code:
enumerator value '65536' cannot be represented as 'unsigned short'
the only thing i did was adding like 10 new combat to enums.h
Those values are bit flags, means that each one reserves one bit. Hence you can only fit 16 combat statuses in an int16 or uint16.
Changing it to uint32 will allow you to store 32 statuses in there, but you probably have to change it in the protocol, both client and server side, so that all 4 bytes are sent and read, not just two.
 
Those values are bit flags, means that each one reserves one bit. Hence you can only fit 16 combat statuses in an int16 or uint16.
Changing it to uint32 will allow you to store 32 statuses in there, but you probably have to change it in the protocol, both client and server side, so that all 4 bytes are sent and read, not just two.
cant find anything in protocol but it work good in game. maybe this is the only change i need to do?
 
cant find anything in protocol but it work good in game. maybe this is the only change i need to do?
I thought it was for battle conditions, but now I see it's damage types, correct? Not sure why it's defined like bit flags rather than consecutive integers then, doesn't make sense to me. Is there any way damage can be of two types in the same time? 🤔
Anyway, did you add text color and effect animation for those new damage types here? This is what will be sent to the client.
And in the protocol I found this, but looks like it's only used by some "CombatAnalyzer". Not sure what it is, some new Tibia feature? You also have damage types names defined here which probably allows using them in lua scripts, and here for using in monster files.

At first glance, changing to uint32 might not break anything afterall, but you need someone familiar with tfs sources (which I'm not, honestly) to confirm.
 
Last edited:
I thought it was for battle conditions, but now I see it's damage types, correct? Not sure why it's defined like bit flags rather than consecutive integers then, doesn't make sense to me. Is there any way damage can be of two types in the same time? 🤔
Anyway, did you add text color and effect animation for those new damage types here? This is what will be sent to the client.
And in the protocol I found this, but looks like it's only used by some "CombatAnalyzer". Not sure what it is, some new Tibia feature? You also have damage types names defined here which probably allows using them in lua scripts, and here for using in monster files.

At first glance, changing to uint32 might not break anything afterall, but you need someone familiar with tfs sources (which I'm not, honestly) to confirm.
yes i have done all this ones up and this ones too
in game no bugs. i try in monsters and players and weapons and spells.
idk i am only scared if it crash anything later.
 
Last edited by a moderator:
I was using search function in the github and haven't found anything else that could be relevant. But as I said, don't take my words for granted.
By the way, perhaps you could change the enumeration to 1, 2, 3, 4 etc. instead of the current 1 << 1, 1 << 2, 1 << 3, 1 << 4; and then leave the type as uint16_t.
I can't find any use of this. It makes perfect sense for condition statuses, because each condition (being poisoned, hasted, on mana shield etc.) can have a state of 0 or 1, so you can pack them all together in one integer, reserving one bit for each condition. But for damage type it doesn't make sense to me and I could not find any reason for this in the code.
 
Solution
Back
Top