Changeset - r121:ae177290c657
[Not reviewed]
master
0 6 0
dominik - 20 years ago 2004-08-23 21:04:39
dominik@openttd.org
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
Exclusive rights from old savegames will be reset.
6 files changed with 43 insertions and 23 deletions:
0 comments (0 inline, 0 general)
saveload.c
Show inline comments
 
@@ -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
 
};
station_cmd.c
Show inline comments
 
@@ -302,7 +302,6 @@ static void StationInitialize(Station *s
 
	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
 
				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
town.h
Show inline comments
 
@@ -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.
town_cmd.c
Show inline comments
 
@@ -863,6 +863,8 @@ static void DoCreateTown(Town *t, TileIn
 
		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
 

	
 
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()
 
};
town_gui.c
Show inline comments
 
@@ -109,9 +109,9 @@ static void TownAuthorityWndProc(Window 
 
			// 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 
 
							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;
 
				}
 
			}
ttd.c
Show inline comments
 
@@ -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;
 

	
0 comments (0 inline, 0 general)