Page 11 of 16

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Mon Jun 30, 2014 2:28 pm
by Diziet Sma
I completed an escort mission tonight, and when I went to get paid, had a strange-looking amount displayed on-screen.

Image

After which, when I hit the spacebar, according to the manifest, my bank account had gone from over 80,000 credits to zero.. so I killed the game without saving.

Image

We've seen these NaN things before with this OXP, but I thought that had all been fixed.

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Mon Jun 30, 2014 2:35 pm
by Zireael
Sounds like an overflow?

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Mon Jun 30, 2014 2:40 pm
by Diziet Sma
That was pretty much my take on it.. should have been a straight 287Cr job.. some kind of rounding problem, perhaps?

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Sat Jul 12, 2014 6:11 am
by Keeper
Hmm. I've never seen this. Do you see this happen in 1.5.9?

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Sat Jul 12, 2014 8:50 am
by Diziet Sma
Yes.. this was with 1.5.9.

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Sat Jul 12, 2014 10:17 am
by Keeper
Hmm. I'm guessing then that {silly nonsense deleted} would at least solve the problem with it erasing your bank account because of the weird decimals. I don't think that would solve the weird amount display to begin with, though. Would it work to edit Escort_Contracts.js line 80 to be something like {more silly nonsense}? Would that force mission_ec_payment not to have a decimal value, or should .toFixed() get added to the other variables there?

Why it's coming up with a decimal value in the first place is the real mystery. There's absolutely no reason why that should happen. Bug in Oolite?

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Sat Jul 12, 2014 10:22 am
by Diziet Sma
It's only happened the once, to date.. on the second attempt at the same mission, everything worked as it should.. not that I've done much escort work of late..

As for your other questions, I'll leave those for cim or someone more knowledgeable to answer.

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Sat Jul 12, 2014 11:14 am
by Keeper
Oh, that wouldn't work at all, because toFixed turns the number into a string. It could be used to help the display, but wouldn't solve that weird banking issue, I guess. Hmm. Well, the contractbaseprice (line 187) was not using Math.round, whereas contractactualprice and killsbonus were, so maybe that's where the problem lies. But contractbaseprice is only used to set up contractactualprice, which does have Math.round on it, so that couldn't be the problem... hmmmmm.

Only thing I can figure is that somehow Oolite corrupted the missionkills. I think this should solve it, changing line 80 to

Code: Select all

    this.ec_payment = Math.round(this.ec_contractactualprice + (this.ec_missionkills * this.ec_killsbonus));
which should ensure that your payment amount is a whole integer. This also should fix the display on the mission screen.

Does that sound right, programming gurus?

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Sat Jul 12, 2014 12:14 pm
by cim
Math.round() won't help - call it on something which isn't a number, and it'll return NaN, which is exactly what you don't want. Decimal places aren't the problem anyway.

Code: Select all

parseInt(this.ec_contractactualprice + (this.ec_missionkills * this.ec_killsbonus))
would guarantee that the value was an integer, but it might still be integer NaN, so that doesn't necessarily help here (and shouldn't be necessary)

I suspect the problem is that while the mission is running, ec_contractactualprice is (supposed to be) a number, but the F4 mission screen puts an array into the same variable name. Similarly for ec_killsbonus. The result of doing this (two element ec_cap array, two element ec_kb array) is ...

Code: Select all

[287,211] + ([20,15] * 3)
is ... 287,211NaN.

I would advise rewriting the script a bit so that you use different this. variables on the F4 screen and for the in-mission parameters, and don't save them to the same mission variables either. The F4 screen is only saving to mission variables for string expansion when printed: you can use some temporary mission variables for that - or, better, use the option to pass a custom dictionary to expandMissionText and don't touch mission variables at all at that stage.

Having a variable that's sometimes a number and sometimes an array is going to cause problems. I suspect there's something going on with the array variable being saved to the mission variable in playerWillSaveGame (which converts it to a string) and then being read back as a string which can't properly be treated as a number, but it'll be easier to rename the variables than to try to debug that.

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Thu Jul 24, 2014 4:58 pm
by vaxon
Just a minor nitpick.
Usually no ITHA line is displayed when there are no contracts, but sometimes I get "ITHA escort contracts (0 availabe)" in the F4 screen.

BTW, I've also seen these NaN eroors, but looks like this happens only when you take a contract and then save and exit the game.
Once you've loaded it and completed the contract, you get NaN.
Otherwise, this has never happened to me, so I never take one before saving/exiting the game.

Thanks,
V.

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Fri Jul 25, 2014 7:29 am
by Diziet Sma
vaxon wrote:
BTW, I've also seen these NaN eroors, but looks like this happens only when you take a contract and then save and exit the game.
Once you've loaded it and completed the contract, you get NaN.
Otherwise, this has never happened to me, so I never take one before saving/exiting the game.
Thanks for that, it definitely explains what happened, and why it doesn't happen more often.. (it should be enough of a clue for the bug to be fixed now, too!)

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Tue Jul 29, 2014 5:01 am
by Keeper
I think I have fixed the NaN problem actually. I just haven't tested it.

Yeah, that "Contracts available: 0" thing is mysterious. It shouldn't happen, as there's code to repress the menu entry when the value is zero, and that code usually works. Sometimes, though, it just doesn't, for whatever reason. It doesn't break anything, so... whatever.

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Mon Aug 04, 2014 7:00 pm
by Holmes177
Same thing happened to me yesterday that Diziet Sma experienced. I had saved & exited the game, and when mission was complete I had those same, crazy results in payment & zero credits. I also get the contracts available (0) on occasion.

Question: can you save, but not exit the game & have the mission work correctly?

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Fri Aug 29, 2014 11:21 pm
by Lone_Wolf
png loading errors with v 1.5.9 , oxz version

Code: Select all

00:58:46.026 [texture.load.png.warning]: ----- A PNG loading warning occurred for /home/panoramix/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.CaptMurphy.EscortContracts.oxz/Images/welcomeCom.png: iCCP: known incorrect sRGB profile.
00:58:46.124 [texture.load.png.warning]: ----- A PNG loading warning occurred for /home/panoramix/GNUstep/Library/ApplicationSupport/Oolite/ManagedAddOns/oolite.oxp.CaptMurphy.EscortContracts.oxz/Textures/EscortsMedallion_normals&Parallax.png: iCCP: known incorrect sRGB profile.
Please correct them like this : (start in the oxz main folder)

Code: Select all

cd /path/to/oxz/folder
cd Images
convert welcomeCom.png welcomeCom.png
cd ../Textures
convert EscortsMedallion_normals\&Parallax.png EscortsMedallion_normals\&Parallax.png
see here for details



Sidenote :
all scripts in Scripts folder still have version 1.5.6 , this makes it harder to see which version is installed in latest log.

Re: [UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/

Posted: Sat Aug 30, 2014 8:21 am
by cim
Lone_Wolf wrote:
Sidenote :
all scripts in Scripts folder still have version 1.5.6 , this makes it harder to see which version is installed in latest log.
A useful feature here for future maintenance: if you don't specify the version at all in the script file, Oolite will fill it in automatically from the manifest.plist