mirror of https://github.com/OpenTTD/OpenTTD
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
Exclusive rights from old savegames will be reset.release/0.4.5
parent
1d1d14ebd3
commit
770f86bbbe
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SAVEGAME_MAJOR_VERSION = 4,
|
SAVEGAME_MAJOR_VERSION = 4,
|
||||||
SAVEGAME_MINOR_VERSION = 0,
|
SAVEGAME_MINOR_VERSION = 1,
|
||||||
|
|
||||||
SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION
|
SAVEGAME_LOADABLE_VERSION = (SAVEGAME_MAJOR_VERSION << 8) + SAVEGAME_MINOR_VERSION
|
||||||
};
|
};
|
||||||
|
|
|
@ -302,7 +302,6 @@ static void StationInitialize(Station *st, TileIndex tile)
|
||||||
st->delete_ctr = 0;
|
st->delete_ctr = 0;
|
||||||
st->facilities = 0;
|
st->facilities = 0;
|
||||||
|
|
||||||
st->blocked_months = 0;
|
|
||||||
st->last_vehicle = INVALID_VEHICLE;
|
st->last_vehicle = INVALID_VEHICLE;
|
||||||
|
|
||||||
for(i=0,ge=st->goods; i!=NUM_CARGO; i++, ge++) {
|
for(i=0,ge=st->goods; i!=NUM_CARGO; i++, ge++) {
|
||||||
|
@ -2184,13 +2183,6 @@ void OnTick_Station()
|
||||||
|
|
||||||
void StationMonthlyLoop()
|
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) {
|
if (around[i] == 0xFF) {
|
||||||
st = DEREF_STATION(st_index);
|
st = DEREF_STATION(st_index);
|
||||||
if ((st->had_vehicle_of_type & HVOT_BUOY) == 0 &&
|
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 &&
|
st->goods[type].rating != 0 &&
|
||||||
(!_patches.selectgoods || st->goods[type].last_speed) && // if last_speed is 0, no vehicle has been there.
|
(!_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
|
((st->facilities & (byte)~FACIL_BUS_STOP)!=0 || type==CT_PASSENGERS) && // if we have other fac. than a bus stop, or the cargo is passengers
|
||||||
|
|
2
town.h
2
town.h
|
@ -29,6 +29,8 @@ struct Town {
|
||||||
// Player ratings as well as a mask that determines which players have a rating.
|
// Player ratings as well as a mask that determines which players have a rating.
|
||||||
byte have_ratings;
|
byte have_ratings;
|
||||||
uint8 unwanted[MAX_PLAYERS]; // how many months companies aren't wanted by towns (bribe)
|
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];
|
int16 ratings[MAX_PLAYERS];
|
||||||
|
|
||||||
// Maximum amount of passengers and mail that can be transported.
|
// Maximum amount of passengers and mail that can be transported.
|
||||||
|
|
21
town_cmd.c
21
town_cmd.c
|
@ -863,6 +863,8 @@ static void DoCreateTown(Town *t, TileIndex tile)
|
||||||
t->ratings[i] = 500;
|
t->ratings[i] = 500;
|
||||||
|
|
||||||
t->have_ratings = 0;
|
t->have_ratings = 0;
|
||||||
|
t->exclusivity = (byte)-1;
|
||||||
|
t->exclusive_counter = 0;
|
||||||
t->statues = 0;
|
t->statues = 0;
|
||||||
|
|
||||||
CreateTownName(t);
|
CreateTownName(t);
|
||||||
|
@ -1471,13 +1473,8 @@ static void TownActionFundBuildings(Town *t, int action)
|
||||||
|
|
||||||
static void TownActionBuyRights(Town *t, int action)
|
static void TownActionBuyRights(Town *t, int action)
|
||||||
{
|
{
|
||||||
Station *st;
|
t->exclusive_counter = 12;
|
||||||
|
t->exclusivity = _current_player;
|
||||||
FOR_ALL_STATIONS(st) {
|
|
||||||
if (st->xy && st->town == t && st->owner < 8 &&
|
|
||||||
st->owner != _current_player)
|
|
||||||
st->blocked_months = 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
ModifyStationRatingAround(t->xy, _current_player, 130, 17);
|
ModifyStationRatingAround(t->xy, _current_player, 130, 17);
|
||||||
}
|
}
|
||||||
|
@ -1739,6 +1736,10 @@ void TownsMonthlyLoop()
|
||||||
if (t->road_build_months != 0)
|
if (t->road_build_months != 0)
|
||||||
t->road_build_months--;
|
t->road_build_months--;
|
||||||
|
|
||||||
|
if (t->exclusive_counter != 0)
|
||||||
|
if(--t->exclusive_counter==0)
|
||||||
|
t->exclusivity = (byte)-1;
|
||||||
|
|
||||||
UpdateTownGrowRate(t);
|
UpdateTownGrowRate(t);
|
||||||
UpdateTownAmounts(t);
|
UpdateTownAmounts(t);
|
||||||
UpdateTownUnwanted(t);
|
UpdateTownUnwanted(t);
|
||||||
|
@ -1827,8 +1828,10 @@ static const byte _town_desc[] = {
|
||||||
SLE_VAR(Town,fund_buildings_months, SLE_UINT8),
|
SLE_VAR(Town,fund_buildings_months, SLE_UINT8),
|
||||||
SLE_VAR(Town,road_build_months, SLE_UINT8),
|
SLE_VAR(Town,road_build_months, SLE_UINT8),
|
||||||
|
|
||||||
// reserve extra space in savegame here. (currently 32 bytes)
|
SLE_VAR(Town,exclusivity, SLE_UINT8),
|
||||||
SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 4, 2, 255),
|
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()
|
SLE_END()
|
||||||
};
|
};
|
||||||
|
|
|
@ -109,9 +109,9 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e)
|
||||||
// Draw list of players
|
// Draw list of players
|
||||||
y = 25;
|
y = 25;
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) {
|
||||||
if (p->is_active && HASBIT(t->have_ratings, p->index)) {
|
if (p->is_active && (HASBIT(t->have_ratings, p->index) || t->exclusivity==p->index)) {
|
||||||
DrawPlayerIcon(p->index, 2, y);
|
if(t->exclusivity==p->index) DrawPlayerIcon(p->index, 2, y);
|
||||||
|
|
||||||
SET_DPARAM16(0, p->name_1);
|
SET_DPARAM16(0, p->name_1);
|
||||||
SET_DPARAM32(1, p->name_2);
|
SET_DPARAM32(1, p->name_2);
|
||||||
SET_DPARAM16(2, GetPlayerNameString(p->index, 3));
|
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
|
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);
|
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;
|
y+=10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
23
ttd.c
23
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();
|
extern void UpdateOldAircraft();
|
||||||
|
|
||||||
bool AfterLoadGame(uint version)
|
bool AfterLoadGame(uint version)
|
||||||
|
@ -1051,6 +1069,11 @@ bool AfterLoadGame(uint version)
|
||||||
ConvertTownOwner();
|
ConvertTownOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from version 4.1 of the savegame, exclusive rights are stored at towns
|
||||||
|
if (version <= 0x400) {
|
||||||
|
UpdateExclusiveRights();
|
||||||
|
}
|
||||||
|
|
||||||
// convert road side to my format.
|
// convert road side to my format.
|
||||||
if (_opt.road_side) _opt.road_side = 1;
|
if (_opt.road_side) _opt.road_side = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue