Announcement: Be excellent to each other.


Caravel Forum : DROD RPG Boards : RPG Bugs : Healing too much kills (Literally)
New Topic New Poll Post Reply
Poster Message
Insane
Level: Master Delver
Avatar
Rank Points: 154
Registered: 08-06-2005
IP: Logged
icon Healing too much kills (+1)  
Right,

If you heal too much, your hp drops below zero and you die. I know this is an integer overflow, but shouldn't there be some sort of protection against actually "dieing" by healing?

To reproduce:

Click here to view the secret text


-Insane
09-22-2008 at 06:30 PM
View Profile Send Private Message to User Visit Homepage Show all user's posts This architect's holds Quote Reply
TFMurphy
Level: Smitemaster
Rank Points: 3117
Registered: 06-11-2007
IP: Logged
icon Re: Healing too much kills (+1)  
Hmmm... not really. You're applying this via scripting, which is just standard variable manipulation. I suppose you could say that it's a special variable and could be subjected to different rules, but I'm not so sure it's a good idea or not.

There *is* overflow protection for health *potions* - you'll note that picking up a potion won't kill you if your HP is near max.
09-22-2008 at 06:39 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
NiroZ
Level: Smitemaster
Rank Points: 1302
Registered: 02-12-2006
IP: Logged
icon Re: Healing too much kills (0)  
There is a max hp?
09-23-2008 at 04:58 AM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Mechadragon
Level: Delver
Rank Points: 61
Registered: 10-30-2004
IP: Logged
icon Re: Healing too much kills (+1)  
NiroZ wrote:
There is a max hp?
What happens with computers is that when a variable is declared it's only allocated a certain amount of memory; that way two variables can't push into each other's space and cause very bad things to happen.
As this is done as a number of bytes, numbers expressed as integers are typically capped between -2^4k and +2^4k, k an integer. The negative numbers are expressed by flipping all the bits of the equivalent positive number, and to ensure they don't collide positive numbers can't go above 01111111... In fact, adding 1 to this number will thus make it the largest negative number, this is why integer overflow exists.
09-23-2008 at 05:05 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Briareos
Level: Smitemaster
Avatar
Rank Points: 3516
Registered: 08-07-2005
IP: Logged
icon Re: Healing too much kills (0)  
But usually overflow isn't your only option - you can also just clamp the value at it's maximum instead of letting it overflow...

____________________________
"I'm not anti-anything, I'm anti-everything, it fits better." - Sole
R.I.P. Robert Feldhoff (1962-2009) :(
09-23-2008 at 08:42 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
Insane
Level: Master Delver
Avatar
Rank Points: 154
Registered: 08-06-2005
IP: Logged
icon Re: Healing too much kills (0)  
Shouldn't overflow be clamped for every variable though, not just HP? Clamping all the variable would solve the problem here as well.

There are only a few situations I can think of where integer overflow is a good thing, and they all deal with unsigned bytes, eg. a brainfsck interpreter, and I hardly think an architect would use overflow as an element in a script when dealing with such large numbers, especially negatives.

-Insane
09-23-2008 at 12:09 PM
View Profile Send Private Message to User Visit Homepage Show all user's posts This architect's holds Quote Reply
TFMurphy
Level: Smitemaster
Rank Points: 3117
Registered: 06-11-2007
IP: Logged
icon Re: Healing too much kills (+1)  
Glance over at the Scripting Database topic in the DROD Architecture forum, and you'll find that the scripting engine is powerful enough to, say, code a reasonable pseudo-RNG, which is an example of an algorithm that definitely deals with large numbers and overflow. We don't have the option of unsigned integers, but we also don't have the option of toggling overflow for when it might actually be useful.

Workarounds exist for both, but I find trying to script overflow modulus in an environment where overflow either errors or clamps the value to be quite a bit more taxing than scripting clamping in an environment where overflow is allowed. You can script your own clamping against overflow for multiplication, addition and subtraction in just a few lines (though it'd be a few more if you don't know the sign of both values you're multiplying, but still easier than scripting overflow in an environment where you're not allowed to.)

In any case, I'd hope an architect would be careful when using such large numbers whatever the reason anyways, whether overflow is a possibility or not.
09-23-2008 at 12:41 PM
View Profile Send Private Message to User Show all user's posts This architect's holds Quote Reply
Beef Row
Level: Smiter
Rank Points: 471
Registered: 12-28-2005
IP: Logged
icon Re: Healing too much kills (+1)  
TFMurphy wrote:
In any case, I'd hope an architect would be careful when using such large numbers whatever the reason anyways, whether overflow is a possibility or not.

Ah, but you assume a sane architect, while the architect you are currently dealing with is clearly Insane.

____________________________
"Now I will repeatedly apply the happy-face rule"
09-23-2008 at 04:19 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Healing too much kills (+1)  
I don't want to force clamping all var values, but I agree HP is a special case, and I'll fix this to clamp it at the max value rather than overflowing in a patch.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
09-23-2008 at 04:30 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Mechadragon
Level: Delver
Rank Points: 61
Registered: 10-30-2004
IP: Logged
icon Re: Healing too much kills (0)  
What kind of crazy hold do you expect to get 2.15 billion hp in, in the first place?
09-24-2008 at 01:33 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
Insane
Level: Master Delver
Avatar
Rank Points: 154
Registered: 08-06-2005
IP: Logged
icon Re: Healing too much kills (0)  
Mechadragon wrote:
What kind of crazy hold do you expect to get 2.15 billion hp in, in the first place?

Gives me ideas... ;)
09-24-2008 at 07:54 PM
View Profile Send Private Message to User Visit Homepage Show all user's posts This architect's holds Quote Reply
Mechadragon
Level: Delver
Rank Points: 61
Registered: 10-30-2004
IP: Logged
icon Re: Healing too much kills (+1)  
Insane wrote:
Mechadragon wrote:
What kind of crazy hold do you expect to get 2.15 billion hp in, in the first place?

Gives me ideas... ;)
A DROD/Disgaea crossover? Don't leave us in suspense!
09-25-2008 at 04:27 AM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD RPG Boards : RPG Bugs : Healing too much kills (Literally)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.