blackdtools / Blackd-Proxy-CLASSIC

Blackd Proxy CLASSIC
MIT License
9 stars 7 forks source link

Creature ID's, can we stop referring to them as Double? #14

Closed divinity76 closed 9 years ago

divinity76 commented 9 years ago

edit: damn, i've been reading the wrong documentation; turns out, Long is Int32 in VB6 ; Some places in the code, we refer to creature IDs as Double (for instance, in MeleeAttack->targetID and TypeTileInfo->dblID), and some places, we refer to creature IDs as Long ( for instance, ReadRedSquare ) in some places, we have to do CLng(doubleID) and other places, Cdbl(LongID) because of this.. could we just drop that nonsense and agree on a single data type for creature IDs? (my vote would go to Long)

blackdtools commented 9 years ago

It might not be the optimal solution if you only think in saving a bunch of bytes in memory, but I prefer to handle creature IDs as double to avoid some weird problems with vb6 in the limit cases of the long type. If you see it being handled as something different in some points that it is usually because I am required to send it as long for some low level windows apis. You better not make changes there as you have very high chances of breaking something. It is very dangerous. Always do a lot of tests in critical changes like this, else I will get a flood of complains from users. For now I have peace there and I really prefer to don't fix what is not broken.

divinity76 commented 9 years ago

fair enough. also damn, i've been reading the wrong documentation; turns out, Long is Int32 in VB6, while it's Int64 in VB7+, my bad

blackdtools commented 9 years ago

yes, that is right: VB6 long is 4 bytes signed (-2147483648 to 2147483647) However Tibia ID is C++ 4 bytes unsigned (0 to 4294967295) So you get problems with big ids unless you store them in a double because I am afraid there is no unsigned 4 bytes type in VB6.