summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--saveload.c2
-rw-r--r--station_cmd.c10
-rw-r--r--town.h2
-rw-r--r--town_cmd.c21
-rw-r--r--town_gui.c8
-rw-r--r--ttd.c23
6 files changed, 43 insertions, 23 deletions
diff --git a/saveload.c b/saveload.c
index 4c9693dba..139d86d63 100644
--- a/saveload.c
+++ b/saveload.c
@@ -9,7 +9,7 @@
enum {
SAVEGAME_MAJOR_VERSION = 4,
- SAVEGAME_MINOR_VERSION = 0,
+ SAVEGAME_MINOR_VERSION = 1,
SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION
};
diff --git a/station_cmd.c b/station_cmd.c
index c5528d906..03e92d380 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -302,7 +302,6 @@ static void StationInitialize(Station *st, TileIndex tile)
st->delete_ctr = 0;
st->facilities = 0;
- st->blocked_months = 0;
st->last_vehicle = INVALID_VEHICLE;
for(i=0,ge=st->goods; i!=NUM_CARGO; i++, ge++) {
@@ -2184,13 +2183,6 @@ void OnTick_Station()
void StationMonthlyLoop()
{
- Station *st;
-
- FOR_ALL_STATIONS(st) {
- if (st->blocked_months != 0)
- st->blocked_months--;
- }
-
}
@@ -2272,7 +2264,7 @@ uint MoveGoodsToStation(uint tile, int w, int h, int type, uint amount)
if (around[i] == 0xFF) {
st = DEREF_STATION(st_index);
if ((st->had_vehicle_of_type & HVOT_BUOY) == 0 &&
- st->blocked_months == 0 &&
+ ( !st->town->exclusive_counter || (st->town->exclusivity == st->owner) ) && // check exclusive transport rights
st->goods[type].rating != 0 &&
(!_patches.selectgoods || st->goods[type].last_speed) && // if last_speed is 0, no vehicle has been there.
((st->facilities & (byte)~FACIL_BUS_STOP)!=0 || type==CT_PASSENGERS) && // if we have other fac. than a bus stop, or the cargo is passengers
diff --git a/town.h b/town.h
index 1a59c247e..f3bdbe419 100644
--- a/town.h
+++ b/town.h
@@ -29,6 +29,8 @@ struct Town {
// Player ratings as well as a mask that determines which players have a rating.
byte have_ratings;
uint8 unwanted[MAX_PLAYERS]; // how many months companies aren't wanted by towns (bribe)
+ uint8 exclusivity; // which player has exslusivity
+ uint8 exclusive_counter; // months till the exclusivity expires
int16 ratings[MAX_PLAYERS];
// Maximum amount of passengers and mail that can be transported.
diff --git a/town_cmd.c b/town_cmd.c
index e68fd9dd2..719ba2b8b 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -863,6 +863,8 @@ static void DoCreateTown(Town *t, TileIndex tile)
t->ratings[i] = 500;
t->have_ratings = 0;
+ t->exclusivity = (byte)-1;
+ t->exclusive_counter = 0;
t->statues = 0;
CreateTownName(t);
@@ -1471,13 +1473,8 @@ static void TownActionFundBuildings(Town *t, int action)
static void TownActionBuyRights(Town *t, int action)
{
- Station *st;
-
- FOR_ALL_STATIONS(st) {
- if (st->xy && st->town == t && st->owner < 8 &&
- st->owner != _current_player)
- st->blocked_months = 12;
- }
+ t->exclusive_counter = 12;
+ t->exclusivity = _current_player;
ModifyStationRatingAround(t->xy, _current_player, 130, 17);
}
@@ -1739,6 +1736,10 @@ void TownsMonthlyLoop()
if (t->road_build_months != 0)
t->road_build_months--;
+ if (t->exclusive_counter != 0)
+ if(--t->exclusive_counter==0)
+ t->exclusivity = (byte)-1;
+
UpdateTownGrowRate(t);
UpdateTownAmounts(t);
UpdateTownUnwanted(t);
@@ -1827,8 +1828,10 @@ static const byte _town_desc[] = {
SLE_VAR(Town,fund_buildings_months, SLE_UINT8),
SLE_VAR(Town,road_build_months, SLE_UINT8),
- // reserve extra space in savegame here. (currently 32 bytes)
- SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 4, 2, 255),
+ SLE_VAR(Town,exclusivity, SLE_UINT8),
+ SLE_VAR(Town,exclusive_counter, SLE_UINT8),
+ // reserve extra space in savegame here. (currently 30 bytes)
+ SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 30, 2, 255),
SLE_END()
};
diff --git a/town_gui.c b/town_gui.c
index 2b867607b..6a9a284c5 100644
--- a/town_gui.c
+++ b/town_gui.c
@@ -109,9 +109,9 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e)
// Draw list of players
y = 25;
FOR_ALL_PLAYERS(p) {
- if (p->is_active && HASBIT(t->have_ratings, p->index)) {
- DrawPlayerIcon(p->index, 2, y);
-
+ if (p->is_active && (HASBIT(t->have_ratings, p->index) || t->exclusivity==p->index)) {
+ if(t->exclusivity==p->index) DrawPlayerIcon(p->index, 2, y);
+
SET_DPARAM16(0, p->name_1);
SET_DPARAM32(1, p->name_2);
SET_DPARAM16(2, GetPlayerNameString(p->index, 3));
@@ -133,7 +133,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e)
So we'll just shift the rating one back if player is AI and all is fine
*/
SET_DPARAM16((IS_HUMAN_PLAYER(p->index) ? 4 : 3), str);
- DrawString(19, y, STR_2024, 0);
+ DrawString(19, y, STR_2024, (t->exclusivity==p->index)?3:0);
y+=10;
}
}
diff --git a/ttd.c b/ttd.c
index 8f6d281ef..33cd72fcc 100644
--- a/ttd.c
+++ b/ttd.c
@@ -1039,6 +1039,24 @@ void CheckIsPlayerActive()
}
}
+// since savegame version 4.1, exclusive transport rights are stored at towns
+void UpdateExclusiveRights()
+{
+ Town *t;
+ FOR_ALL_TOWNS(t) if (t->xy != 0) {
+ t->exclusivity=(byte)-1;
+ }
+
+ /* FIXME old exclusive rights status is not being imported.
+ could be implemented this way:
+ 1.) Go through all stations
+ Build an array town_blocked[ town_id ][ player_id ]
+ that stores if at least one station in that town is blocked for a player
+ 2.) Go through that array, if you find a town that is not blocked for
+ one player, but for all others, then give him exclusivity.
+ */
+}
+
extern void UpdateOldAircraft();
bool AfterLoadGame(uint version)
@@ -1051,6 +1069,11 @@ bool AfterLoadGame(uint version)
ConvertTownOwner();
}
+ // from version 4.1 of the savegame, exclusive rights are stored at towns
+ if (version <= 0x400) {
+ UpdateExclusiveRights();
+ }
+
// convert road side to my format.
if (_opt.road_side) _opt.road_side = 1;