Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2000:
[Freeciv-Dev] (unfinished)patch: improved trade and commodities.ruleset
Home

[Freeciv-Dev] (unfinished)patch: improved trade and commodities.ruleset

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (unfinished)patch: improved trade and commodities.ruleset
From: sebauer@xxxxxxxxxxx (Sebastian Bauer)
Date: Sat, 25 Mar 2000 22:53:06 +0100

Hi,

I'm actually working on the civ2 like trade (commodities.ruleset)
The idea was by Jeff, he also created the commodities.ruleset.

You can find that (alpha) patch at:
# ftp://ftp.freeciv.org/freeciv/incoming/#imprv-trade.diff.gz

Atm it is not useable at all for gtk and xaw client (only for the
mui one) so I guess nobody can test it really. But I would be
pleased if you have a look at it (to tell me if things are not
so good how I've done it and maybe also adapt the other clients,
Jeff already told me that he would do the Xaw version).

New file common/commodity.c
It is very small and I don't now if this is really necessary
to put the things in a separate file (it consists only of
some access functions of the commodity array and other helpers)

Changed all necessary files (ruleset, packets...) to support
the new ruleset. New packet PACKET_RULESET_COMMODITY added.


New entries in struct city:
  int demand_commodities[MAX_TRADE_ROUTES];
  int supply_commodities[MAX_TRADE_ROUTES];
  struct trade_route trade_routes[MAX_TRADE_ROUTES];
  struct incoming_supply incoming_supplies[MAX_INCOMING_SUPPLIES];
  (the old trade field has been removed)

demand_commodities consits of all commodities the city needs.
supply_commodities consits of all commodities the city have.
The commodities are random generated (where the generation needs
to be improved probably).

Within the trade_routes all finished and unfinished trade routes
are stored. An unfinsihed trade route is a route which has no
destination (the caravan unit hasn't arrived the goal city yet,
the city id memeber in 0 then).

Within incoming_supplies all incoming supplies from other city
are stored.

New entry in struct unit:
  int commodity_assigned
When a caravan unit is build in a city it is set to 0 (which
means unassigned). The commodity a caravan unit carries can be
set from the client side via a new PACKET_UNIT_ASSIGN_COMMODITY.
At the moment it is only possible if no commodity has assigned
before (and the caravan is in its homecity).

There are two differnt types (depending on the assigned commodity)
of trade routes a caravan can establish: commodity trade routes
and supply trade routes. 

Commodity trade routes are established if the caravan got a
"real" commodity assigned (which is one of the commodities the city
supplies). Once a commodity has been assigned it can never be
used again (except the caravan dies, helps to build a wonder
or if it is bribed). Like the old style trade if you establish
the routes you get a revenue and ongoing trade bonus for this.
But if the commodity which is carried by the caravan matches
one of demanding commodites the bonus increaes.

Supply trade routes are establies if the caravan gets a supply
commodity assigned. With supply trade routes the building
city can send supplies (food, shields, trade) to other cities.
The supplies are sent then per turn.
The supply routes can also be canceld by the player.

I have tried to comment the code and functions, so I hope it
should not be a problem to understand the code. Otherwise ask me,
please.

Problems and TODO:
 - civ1 and old save game compatiblity (maybe by writing a special
   commodities.ruleset)
 - implement saving and loading of the new trade system
 - actually the supply routes do nothing (expect food supply route),
   I don't know when the production and trade shields should be added.
   Also if a supply route would lead to negative values the route
   should be removed. But I've no idea how to to this (I've haven't
   tought about it enough, maybe there is a easy solution). The problem
   is if the supply route is removed the matching incoming supply from
   the other city must be removed (and this already could have proccessed
   the end turn calcs and used the extra supply). I would be appreciate
   for any helps.
 - clean up the code and maybe creating a new server source file for
   the trade stuff?
 - new dialog which show all known cities and what they supply and demand
 - the popit window (ctrl + left click) should show it, too
 - some smaller things
 - any other things which I missed?

I also uploaded a screenshot of the mui client's citywindow
(#ftp://ftp.freeciv.org/freeciv/incoming/#imprv-trade.png)

I removed the trade button and now display the information inside the
window (get_city_trade_text() is used for the text).

The patch also prepare the gui-gtk and gui-xaw are a little bit. But
I don't know if they compile correctly after appling the patch.

bye,
Sebastian Bauer




[Prev in Thread] Current Thread [Next in Thread]