[UPDATED RELEASE] - Escort Contracts OXP - 1.5.6 (07/05/12)

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6312
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post 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.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

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

Post by Zireael »

Sounds like an overflow?
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6312
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post by Diziet Sma »

That was pretty much my take on it.. should have been a straight 287Cr job.. some kind of rounding problem, perhaps?
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
User avatar
Keeper
---- E L I T E ----
---- E L I T E ----
Posts: 273
Joined: Fri Feb 01, 2013 7:44 am
Location: Indian Hills, Nevada, USA

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

Post by Keeper »

Hmm. I've never seen this. Do you see this happen in 1.5.9?
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6312
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post by Diziet Sma »

Yes.. this was with 1.5.9.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
User avatar
Keeper
---- E L I T E ----
---- E L I T E ----
Posts: 273
Joined: Fri Feb 01, 2013 7:44 am
Location: Indian Hills, Nevada, USA

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

Post 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?
Last edited by Keeper on Sat Jul 12, 2014 11:22 am, edited 1 time in total.
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6312
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post 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.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
User avatar
Keeper
---- E L I T E ----
---- E L I T E ----
Posts: 273
Joined: Fri Feb 01, 2013 7:44 am
Location: Indian Hills, Nevada, USA

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

Post 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?
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

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

Post 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.
vaxon
Dangerous
Dangerous
Posts: 109
Joined: Tue Jul 10, 2007 1:26 pm

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

Post 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.
User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6312
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

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

Post 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!)
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
User avatar
Keeper
---- E L I T E ----
---- E L I T E ----
Posts: 273
Joined: Fri Feb 01, 2013 7:44 am
Location: Indian Hills, Nevada, USA

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

Post 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.
User avatar
Holmes177
Competent
Competent
Posts: 56
Joined: Tue Apr 22, 2014 11:34 am

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

Post 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?
User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 546
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

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

Post 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.
OS : Arch Linux 64-bit - rolling release

OXPs : My user page

Retired, reachable at [email protected]
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

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

Post 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
Post Reply