(svn r122) Change: exclusive transport rights are now stored per town instead of per station
Exclusive rights from old savegames will be reset.
--- a/saveload.c Mon Aug 23 20:38:42 2004 +0000
+++ b/saveload.c Mon Aug 23 21:04:39 2004 +0000
@@ -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
};
--- a/station_cmd.c Mon Aug 23 20:38:42 2004 +0000
+++ b/station_cmd.c Mon Aug 23 21:04:39 2004 +0000
@@ -302,7 +302,6 @@
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 StationMonthlyLoop()
{
- Station *st;
-
- FOR_ALL_STATIONS(st) {
- if (st->blocked_months != 0)
- st->blocked_months--;
- }
-
}
@@ -2272,7 +2264,7 @@
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
--- a/town.h Mon Aug 23 20:38:42 2004 +0000
+++ b/town.h Mon Aug 23 21:04:39 2004 +0000
@@ -29,6 +29,8 @@
// 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.
--- a/town_cmd.c Mon Aug 23 20:38:42 2004 +0000
+++ b/town_cmd.c Mon Aug 23 21:04:39 2004 +0000
@@ -863,6 +863,8 @@
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 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 @@
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 @@
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()
};
--- a/town_gui.c Mon Aug 23 20:38:42 2004 +0000
+++ b/town_gui.c Mon Aug 23 21:04:39 2004 +0000
@@ -109,9 +109,9 @@
// 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 @@
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;
}
}
--- a/ttd.c Mon Aug 23 20:38:42 2004 +0000
+++ b/ttd.c Mon Aug 23 21:04:39 2004 +0000
@@ -1039,6 +1039,24 @@
}
}
+// 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 @@
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;