Page 1 of 2

NaN gold

Posted: Sun Jul 17, 2011 9:52 pm
by bricks
I can't really say when this onset. Once when I checked my character sheet, my gold showed up as nan, and then later at the Ring of Blood I noticed that my gold now showed up as nan on the main screen, too. Couldn't spend it, and when I saved and quit, I came back with 0 gold. Trying to transmogrify anything threw an LUA error, as did saving and quitting. b30, OSX, dwarf doomed.

Edit: Also get errors when I try to pick up money off the ground and check my character sheet.

Edit2: Going into the console and redefining game.player.money fixed it. Looks like money got undefined somehow.

Edit3: It seems to be a bug with the transmogrification chest? After using it on a staff, I got an error, my money was back to nan, and it looks like my fortress is just not getting energy.

Edit4: Was able to reset Fortress energy and money, and now no more errors. Hopefully this will last.

Edit5: Ugh. At least I caught it in the act this time. It all starts when transmogrifying a cursed halfing rough leather sling, which gave me nan gold.

Re: NaN gold

Posted: Sun Jul 17, 2011 11:21 pm
by madmonk
The VM has changed from standard to Luajit2.

Loading an old savegame on a new VM will break.

Start again! I had to as well.

Re: NaN gold

Posted: Mon Jul 18, 2011 12:14 am
by bricks
Erm, great to hear, but I have no idea what that means. :lol: Guess I'll reinstall and start a new character...

Re: NaN gold

Posted: Mon Jul 18, 2011 4:18 am
by Hirumakai
I also ran into this bug in b30 with a new character.

Basically I had a transmutation using the transmogrification chest report that I received nan gold. I had a level 17 Dwarven Wyrmic transmuting a cloak on the ground in the Shalore starting dungeon. was on a cloak. (I generally go hit the bosses in the starting dungeons for the Blood of Life in the 15-20 level range).

You can save once, but upon reload, 0.0 gold is reported. But if you try to buy something or go to save, it runs into lua errors dealing with the NaN nature of the gold amount. So basically game breaking.

Edit: This was on a MacBook Pro running OS 10.6.8

Re: NaN gold

Posted: Mon Jul 18, 2011 7:11 am
by darkgod
I'd like a savefile please

Re: NaN gold

Posted: Mon Jul 18, 2011 4:28 pm
by bricks
Hmm, both of our character were dwarves around the same level and on OSX. Interesting, wonder if it is tied to Power is Money and the way our OSes handle NaN. I've since cheated to fix the character, but I'll send you a save next time I catch it in the act. It hasn't happened in a while.

Re: NaN gold

Posted: Mon Jul 18, 2011 10:30 pm
by Hirumakai
That character did not have Money is Power. I believe it is more likely to stem from a bug in the transmogrification code, since I saw a NaN in the log when transmuting, at which point the problems seemed to start.

I've sent a PM to Darkgod with a link to my save.

Did your character have the transmogrification chest and had been using it?

Re: NaN gold

Posted: Mon Jul 18, 2011 10:58 pm
by madmonk
When I had the problem that is exactly when it started. Using the transmog chest. Resolved in my case by a clean compile and a new character.

Re: NaN gold

Posted: Mon Jul 18, 2011 11:22 pm
by bricks
Yes, happened after getting the transmo chest. Happened again, too. I think it's time to start over...

Re: NaN gold

Posted: Thu Jul 21, 2011 7:04 pm
by Jules
I hit this too, whilst transmogrifying some purple weapon in an ambush.

The lua errors are caused by 'money' and 'shertul_energy' being missing from the savefile - adding them back in manually to the appropriate objects fixes the symptom. I don't know what it was about the object I transmogrified that broken it - a divide by zero in the code which calculates item values, perhaps?

Re: NaN gold

Posted: Sun Jul 24, 2011 10:40 pm
by darkgod
Perhaps fixed

Re: NaN gold

Posted: Wed Jul 27, 2011 9:30 pm
by bricks
I'm still getting this bug :( (b31). It only seems to show up after loading a save, too, though I can't be certain. Sending you the savefile, DG.

Re: NaN gold

Posted: Thu Jul 28, 2011 9:00 am
by lukep
got the bug too. b31 OSX Thaloren Cursed, I noticed it in Daikara when I was level 19.

Re: NaN gold

Posted: Fri Jul 29, 2011 4:53 am
by lukep
Got a more specific situation for it now. Ring of Blood, I had 280-something gold on the next to last level, went down, next to the orb then saved. When I tried to use the orb, I had nan gold.

EDIT: it was from transmorgrifying a cursed bloodhexed iron pickaxe. reproducible, and I'm keeping a copy of the save (from before it happened).

Re: NaN gold

Posted: Fri Jul 29, 2011 6:01 am
by Jules
I spent some time looking at this bug.

I expect you'll find it's not the pickaxe - load that save and transmogrify *anything* and it will go to NaN. At least, that's what it was like with my save file.

You can paper over the bug by setting game.player.money and game.player.quests["shertul-fortress"].shertul_energy explicitly (with lua console, or savefile edit) and, in my experience, it will be OK for a while and then break again.

I think this is a very strange luajit bug, because I was able to make it go away by adding the following lines to the transmogrifier transmo_inven code:

Code: Select all

					print("Entering transmo_use")
					print("  o:getPrice = ",o:getPrice(),type(o:getPrice()))
					print("  self.pricemod(o) = ",self.pricemod(o),type(self.pricemod(o)))
					print("  o.getNumber = ",o:getNumber(),type(o:getNumber()))
					print("  min = ",math.min(o:getPrice() * self.pricemod(o), 25),type(math.min(o:getPrice() * self.pricemod(o), 25)))
					print("  calculation = ",math.min(o:getPrice() * self.pricemod(o), 25) * o:getNumber())
					local price = math.min(o:getPrice() * self.pricemod(o), 25) * o:getNumber()
					print("  price = ",price)
Note that the only thing I added is a bunch of print statements to force it to evaluate those numbers first, I haven't changed anything. One of those will come out as 'nan' and that seems to 'flush' the bug and makes price calculate correctly.

It's not completely straightforward to try this out on a saved game, as the code for transmo_inven is saved with the object in your savefile; you have to manually copy it over in the lua console.

I'm really hoping it's fixed in luajit2beta8 which DG is using in SVN now, because I'm mystified. And if there is some weird bug with loading/saving numbers there is no reason to think it will only affect this subroutine, we could get weird bugs anywhere.