Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non hard-coded commodities #109

Merged
merged 39 commits into from
Sep 13, 2014
Merged

Non hard-coded commodities #109

merged 39 commits into from
Sep 13, 2014

Conversation

cim--
Copy link
Member

@cim-- cim-- commented Aug 25, 2014

This is probably ready for a bit of testing in a branch.

Note: will currently break Mac build because the OOCommodities.m and OOCommodityMarket.m files aren't in the XCode project.

Features:

  • Looks pretty much like 1.80 without OXPs (a few quantities and prices are slightly different because the new algorithm can't deliberately use overflow)
  • prices not restricted to multiples of 0.4 up to 102.0
  • per-station and per-trade good buy/sell limits
  • secondary stations can optionally mark smugglers as offenders
  • import and export legality can be changed by OXP either generally or per-station for each good
  • able to add extra goods by OXP (F8 now scrollable if necessary)
  • best import/export prices no longer only at RI/PA pairs for OXP goods
  • trade-good scripts for more customisable setting of quantity, price, legality, etc. per-good, per-station and/or per-system
  • sorting and filtering on F8 screen
  • legality information on F8 screen
  • hermit markets now reflect their clients
  • extra (mostly OXP) information on goods on F8 F8 screen (GUI_SCREEN_MARKETINFO)
  • F8 F8 screen can buy/sell/change good
  • "full" buy/sell will stop at the total contracted volume for a good (repeat to carry on)

Loads 1.80 savegames fine as far as I can tell, though doesn't produce savegames that 1.80 will read properly.

OXP compatibility:

  • Old stations will get a default "no trade" market rather than attempting to parse commodities.plist. Whether this is worth fixing depends on how many station OXPs get updated before 1.82
  • OXPs which change illegal-goods.plist will find that no longer works. That's only New Cargoes, so far as I know, and anyway, the documentation did warn against doing that.
  • OXPs expecting a fixed commodity list are probably okay in that the names haven't changed - but the non-canonical names (e.g. liquorWines rather than liquor_wines) aren't supported
  • JS commodity properties from the old pricing algorithm no longer exist
  • Obviously OXPs making assumptions about the number, price, name, etc. of cargo are going to be more-or-less broken.
  • Cargo contracts should survive the transition, though the JS side of that script needed some updating.
  • Uses new properties and plists, rather than changing meaning of existing ones, so a single OXP which defines the correct properties for both this and 1.80 is possible.

(This won't compile, and probably will stay that way for a few commits)
(Doesn't work yet in all sorts of ways, of course)
Station and player commodities preserved over load/save properly

System market actually used for the main station now
New JS method
systemInfo.samplePrice(commodity)
 - get a sample price for a trade good in an arbitrary system
Saves changing oolite-contracts-cargo for every change in the algorithm
More than we need for the rock hermits, but should give OXPers a bit of flexibility
...okay, I think this branch is now (inevitable bugs aside) back to
providing about the same core functionality as it did before I started
poking at it. Onwards...
 - capacity can now be set per-station per-good
 - import and export legality per station
 - market_monitored = no; shortcut to make all goods legal
Works okay with keyboard - needs more work with mouse
@Zireael07
Copy link

Whee, I think I will make a Cargoes OXP as soon as this lands!

best import/export prices no longer only at RI/PA pairs for OXP goods

Does that mean we're getting the 8-loop?

@cim--
Copy link
Member Author

cim-- commented Aug 26, 2014

It means you can implement one in an OXP (in theory, anyway: I haven't extensively tested that bit of the pricing algorithm yet)

Give the "pirate" and "chaotic" rock hermits (both quite rare) slightly
different markets, and the chance to find some interesting but low
capacity deals.
Legality column is a placeholder
Now on F8 F8.
Can buy and sell from the market info screen, and cycle goods with up/down
Can't change filter or sort settings from marketinfo - it just uses what
you had selected
Shift-buy/shift-sell will stop at the contracted level
@cim--
Copy link
Member Author

cim-- commented Sep 7, 2014

Okay, I think this is about feature-complete, at least for now. Could people compile and test to make sure I've not missed anything, please.

@AnotherCommander
Copy link
Member

Windows compiles OK here. Just an observation, because I am not sure how it is supposed to work: Copying the food entry in trade-goods.plist into something like "Different food" and without changing anything else, does not give me any quantity of "Different food" in any of the save games I tried. Attempted duplicating lots of other goods entries, but I never seem to be getting any quantity of those modified goods in the main station. Is that how it is supposed to be? If so, how can I make it have a starting quantity like, say, normal food or computers etc?

@AnotherCommander
Copy link
Member

OK, it seems to generate quantities fine if I jump out and back in. I guess the reason it doesn't generate the goods on load game is because the market is already defined in the savefile and does not contain any of these extra quantities. If this is correct, then I guess all works fine here.

@cim--
Copy link
Member Author

cim-- commented Sep 7, 2014

Yes, when loading an existing save game the market will already be defined - but new goods will get generated anyway. At the moment, though, OOCommodityMarket:347 automatically zeroes the quantity of any good that wasn't in the save file. That may not actually be necessary - I think it's left over from when loadStationMarket and loadPlayerMarket were the same function.

Taking that out would cause it to generate quantities for new goods immediately.

@cim--
Copy link
Member Author

cim-- commented Sep 12, 2014

I think this is about as done as it's going to get - shall we merge it?

@AnotherCommander
Copy link
Member

Affirmative from my side.

cim-- added a commit that referenced this pull request Sep 13, 2014
@cim-- cim-- merged commit fa805ce into master Sep 13, 2014
@AnotherCommander AnotherCommander deleted the commodities-plist branch October 19, 2014 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants