[3.3.x] Severe bug -- pricing system

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PowerWyrm
    Prophet
    • Apr 2008
    • 2986

    [3.3.x] Severe bug -- pricing system

    Guess I found a really nasty bug...

    Was looking at BM items when I saw some Ring of the Dog priced at 999999999 au. After saving the game and loading it again, the ring was priced at 0 gold.

    So I launched the game in debug mode and found the explanation. In object_power(), object flags which contribute to pval will give a power boost stored in the extra_stat_bonus variable. For each pval, the boost is calculated as pval * pval_mult... which is of course negative for any negative pval. Some objects like Rings of the Dog or Amulets of Inertia have a single negative pval. The resulting extra_stat_bonus is then negative. However, extra power is added for objects with high ability bonuses using extra_stat_bonus as an index in a static array:

    Code:
    pwr += ability_power[extra_stat_bonus / 10];
    With extra_stat_bonus negative, the index is out of bounds! The result is completely random, and could even crash on some machines...
    PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
  • Magnate
    Angband Devteam member
    • May 2007
    • 5110

    #2
    Bugs like this always amaze me - rings of the dog can't be that unusual in the BM, so how come nobody's come across it before??

    Well spotted - thanks.

    Opened as #1592
    "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

    Comment

    Working...
    😀
    😂
    🥰
    😘
    🤢
    😎
    😞
    😡
    👍
    👎