Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19

Thread: HP > 2^31 goes negative or zero; errors

  1. #1
    Senior Member
    Join Date
    Oct 2013
    Posts
    241

    Default HP > 2^31 goes negative or zero; errors

    r19197. First showed a negative value (signed int overflow), then repeatedly shows the following in the gcli (edit: which I now realize is charpane.ash), and shows zero in the (mafia) character pane. Sometimes returns to the negative display.

    Code:
    2148486140 is out of range, returning 0
    Division by zero (charpane.ash, line 2536)
      at addHP (charpane.ash:2573)
      at addSection (charpane.ash:2661)
      at bakeStats (charpane.ash:2754)
      at bakeBricks (charpane.ash:3874)
      at modifyPage (charpane.ash:4127)
      at main (charpane.ash:4140)2148486140 is out of range, returning 0
    Otherwise seems to work normally.

    I was curious what would happen when I reached that point. That's my answer.

    Vanilla KoL is showing "2144789018 / 2148486431" in the character pane.

    Also, sunuva…:

    Cannelloni cocoon: "Was silently nerfed to heal up to 1,000 HP instead of all HP on April 24, 2019." wiki

    Wow, that's huge.
    Last edited by fractalnavel; 04-30-2019 at 07:26 AM.

  2. #2
    Developer
    Join Date
    Aug 2009
    Posts
    2,917

    Default

    (actually, the out of range is returned by StringUtilities.parseInt, which is in turn called by CharPaneRequest.)

    I'm poking around because I'm curious how intrusive a change this'll be, but don't hold your breath.

  3. #3
    Developer
    Join Date
    Aug 2009
    Posts
    2,917

    Default

    I'd also like to know what api.php?what=status&for=testing yields, namely around the max HP readouts. JSON doesn't actually have a long type, although I guess our JSON library is okay with that.

  4. #4
    Developer
    Join Date
    Apr 2010
    Posts
    5,106

    Default

    (actually, the out of range is returned by StringUtilities.parseInt, which is in turn called by CharPaneRequest.)

    I'm poking around because I'm curious how intrusive a change this'll be, but don't hold your breath.
    Originally Posted by heeheehee View Post
    A thorough fix is hard, as I've looked at this before. Because AdventureResult will need to handle longs, you have to handle every use of an Item Number and similar entry to update to longs. Unless of course there is a simpler way that I didn't find. There are thousands!

  5. #5
    Developer
    Join Date
    Aug 2009
    Posts
    2,917

    Default

    Are there AdventureResults that contain HP or MP? Stats, yes, and Meat, yes, but I don't think that's true for HP / MP.

  6. #6
    Developer
    Join Date
    Apr 2010
    Posts
    5,106

    Default

    AdventureResult.HP and AdventureResult.MP

  7. #7
    Senior Member
    Join Date
    Oct 2013
    Posts
    241

    Default

    I'd also like to know what api.php?what=status&for=testing yields, namely around the max HP readouts.
    Originally Posted by heeheehee View Post
    Like this? (attached): api-php-23718-json.txt

  8. #8
    Developer
    Join Date
    Aug 2009
    Posts
    2,917

    Default

    Yeah, that's what I was looking for. That says your HP is less than 2^31 (which starts with 214748...). Is that accurate?
    Code:
    "hp":"2147398484",
    ...
    "maxhp":2147399416
    Also a little bit weird that the hp field is a string, but I guess that's just how it usually is.

    (also, Darzil: got it, it's most likely as invasive as you mention.)

  9. #9
    Senior Member
    Join Date
    Oct 2013
    Posts
    241

    Default

    Odd; I remember it being 2148... in vanilla KoL yesterday.

    Vanilla: Current max hp is 2176875415 in both character pane and api result. Well, sort of. Every time I refresh either the character pane or the api the last four digits change. Also changing are the last few digits of max mp and mus/mys/mox. It looks like a precision problem somewhere, which for integer types is - weird. Or, possibly more likely, some oddity in the calculations on the KoL side (floating point calcs someplace?). You can get the same effect by visiting the character sheet for #2422322 and reloading.

  10. #10
    Developer
    Join Date
    Aug 2009
    Posts
    2,917

    Default

    Do you have http://kol.coldfront.net/thekolwiki/index.php/Uncertain active? That compounded with lots of HP% effects could potentially explain that.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •