mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
This commit is contained in:
parent
2b44da199c
commit
3397e202c8
|
@ -129,7 +129,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
int sel = WP(w,buildtrain_d).sel_index;
|
int sel = WP(w,buildtrain_d).sel_index;
|
||||||
int pos = w->vscroll.pos;
|
int pos = w->vscroll.pos;
|
||||||
EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
|
EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
|
||||||
int selected_id = -1;
|
EngineID selected_id = INVALID_ENGINE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (HASBIT(e->player_avail, _local_player)) {
|
if (HASBIT(e->player_avail, _local_player)) {
|
||||||
|
@ -145,7 +145,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
WP(w,buildtrain_d).sel_engine = selected_id;
|
WP(w,buildtrain_d).sel_engine = selected_id;
|
||||||
|
|
||||||
if (selected_id != -1) {
|
if (selected_id != INVALID_ENGINE) {
|
||||||
DrawAircraftPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
DrawAircraftPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,14 +162,14 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 5: { /* build */
|
case 5: { /* build */
|
||||||
int sel_eng = WP(w,buildtrain_d).sel_engine;
|
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
|
||||||
if (sel_eng != -1)
|
if (sel_eng != INVALID_ENGINE)
|
||||||
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT));
|
DoCommandP(w->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 6: { /* rename */
|
case 6: { /* rename */
|
||||||
int sel_eng = WP(w,buildtrain_d).sel_engine;
|
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
|
||||||
if (sel_eng != -1) {
|
if (sel_eng != INVALID_ENGINE) {
|
||||||
WP(w,buildtrain_d).rename_engine = sel_eng;
|
WP(w,buildtrain_d).rename_engine = sel_eng;
|
||||||
ShowQueryString(GetCustomEngineName(sel_eng),
|
ShowQueryString(GetCustomEngineName(sel_eng),
|
||||||
STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w->window_class, w->window_number);
|
STR_A039_RENAME_AIRCRAFT_TYPE, 31, 160, w->window_class, w->window_number);
|
||||||
|
|
|
@ -1323,7 +1323,7 @@ int LoadUnloadVehicle(Vehicle *v)
|
||||||
GoodsEntry *ge;
|
GoodsEntry *ge;
|
||||||
int t;
|
int t;
|
||||||
uint count, cap;
|
uint count, cap;
|
||||||
byte old_player;
|
PlayerID old_player;
|
||||||
bool completely_empty = true;
|
bool completely_empty = true;
|
||||||
|
|
||||||
assert(v->current_order.type == OT_LOADING);
|
assert(v->current_order.type == OT_LOADING);
|
||||||
|
@ -1560,8 +1560,8 @@ int32 CmdBuyShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
cost = CalculateCompanyValue(p) >> 2;
|
cost = CalculateCompanyValue(p) >> 2;
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
PlayerID* b = p->share_owners;
|
||||||
int i;
|
int i;
|
||||||
byte *b = p->share_owners;
|
|
||||||
|
|
||||||
while (*b != OWNER_SPECTATOR) b++; /* share owners is guaranteed to contain at least one OWNER_SPECTATOR */
|
while (*b != OWNER_SPECTATOR) b++; /* share owners is guaranteed to contain at least one OWNER_SPECTATOR */
|
||||||
*b = _current_player;
|
*b = _current_player;
|
||||||
|
@ -1602,7 +1602,7 @@ int32 CmdSellShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
cost = -(cost - (cost >> 7));
|
cost = -(cost - (cost >> 7));
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
byte *b = p->share_owners;
|
PlayerID* b = p->share_owners;
|
||||||
while (*b != _current_player) b++; /* share owners is guaranteed to contain player */
|
while (*b != _current_player) b++; /* share owners is guaranteed to contain player */
|
||||||
*b = OWNER_SPECTATOR;
|
*b = OWNER_SPECTATOR;
|
||||||
InvalidateWindow(WC_COMPANY, (int)p1);
|
InvalidateWindow(WC_COMPANY, (int)p1);
|
||||||
|
|
|
@ -1042,7 +1042,7 @@ static void ChopLumberMillTrees(Industry *i)
|
||||||
do {
|
do {
|
||||||
tile = TILE_MASK(tile);
|
tile = TILE_MASK(tile);
|
||||||
if (IsTileType(tile, MP_TREES)) {
|
if (IsTileType(tile, MP_TREES)) {
|
||||||
uint old_player = _current_player;
|
PlayerID old_player = _current_player;
|
||||||
/* found a tree */
|
/* found a tree */
|
||||||
|
|
||||||
_current_player = OWNER_NONE;
|
_current_player = OWNER_NONE;
|
||||||
|
@ -1662,7 +1662,7 @@ static void PlaceInitialIndustry(byte type, int amount)
|
||||||
|
|
||||||
if (_opt.diff.number_industries != 0)
|
if (_opt.diff.number_industries != 0)
|
||||||
{
|
{
|
||||||
byte old_player = _current_player;
|
PlayerID old_player = _current_player;
|
||||||
_current_player = OWNER_NONE;
|
_current_player = OWNER_NONE;
|
||||||
assert(num > 0);
|
assert(num > 0);
|
||||||
|
|
||||||
|
@ -1902,7 +1902,7 @@ static void ChangeIndustryProduction(Industry *i)
|
||||||
void IndustryMonthlyLoop(void)
|
void IndustryMonthlyLoop(void)
|
||||||
{
|
{
|
||||||
Industry *i;
|
Industry *i;
|
||||||
byte old_player = _current_player;
|
PlayerID old_player = _current_player;
|
||||||
_current_player = OWNER_NONE;
|
_current_player = OWNER_NONE;
|
||||||
|
|
||||||
FOR_ALL_INDUSTRIES(i) {
|
FOR_ALL_INDUSTRIES(i) {
|
||||||
|
|
|
@ -380,7 +380,7 @@ void CDECL ModifyTile(TileIndex tile, uint flags, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & (MP_MAPOWNER|MP_MAPOWNER_CURRENT)) {
|
if (flags & (MP_MAPOWNER|MP_MAPOWNER_CURRENT)) {
|
||||||
byte x = _current_player;
|
PlayerID x = _current_player;
|
||||||
if (flags & MP_MAPOWNER) x = va_arg(va, int);
|
if (flags & MP_MAPOWNER) x = va_arg(va, int);
|
||||||
_m[tile].m1 = x;
|
_m[tile].m1 = x;
|
||||||
}
|
}
|
||||||
|
|
|
@ -583,19 +583,19 @@ void ShowErrorMessage(StringID msg_1, StringID msg_2, int x, int y)
|
||||||
|
|
||||||
void ShowEstimatedCostOrIncome(int32 cost, int x, int y)
|
void ShowEstimatedCostOrIncome(int32 cost, int x, int y)
|
||||||
{
|
{
|
||||||
int msg = STR_0805_ESTIMATED_COST;
|
StringID msg = STR_0805_ESTIMATED_COST;
|
||||||
|
|
||||||
if (cost < 0) {
|
if (cost < 0) {
|
||||||
cost = -cost;
|
cost = -cost;
|
||||||
msg = STR_0807_ESTIMATED_INCOME;
|
msg = STR_0807_ESTIMATED_INCOME;
|
||||||
}
|
}
|
||||||
SetDParam(0, cost);
|
SetDParam(0, cost);
|
||||||
ShowErrorMessage(-1, msg, x, y);
|
ShowErrorMessage(INVALID_STRING_ID, msg, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost)
|
void ShowCostOrIncomeAnimation(int x, int y, int z, int32 cost)
|
||||||
{
|
{
|
||||||
int msg;
|
StringID msg;
|
||||||
Point pt = RemapCoords(x,y,z);
|
Point pt = RemapCoords(x,y,z);
|
||||||
|
|
||||||
msg = STR_0801_COST;
|
msg = STR_0801_COST;
|
||||||
|
@ -712,7 +712,7 @@ static void DrawStationCoverageText(const AcceptedCargo accepts,
|
||||||
void DrawStationCoverageAreaText(int sx, int sy, uint mask, int rad) {
|
void DrawStationCoverageAreaText(int sx, int sy, uint mask, int rad) {
|
||||||
int x = _thd.pos.x;
|
int x = _thd.pos.x;
|
||||||
int y = _thd.pos.y;
|
int y = _thd.pos.y;
|
||||||
uint accepts[NUM_CARGO];
|
AcceptedCargo accepts;
|
||||||
if (x != -1) {
|
if (x != -1) {
|
||||||
GetAcceptanceAroundTiles(accepts, TileVirtXY(x, y), _thd.size.x / 16, _thd.size.y / 16 , rad);
|
GetAcceptanceAroundTiles(accepts, TileVirtXY(x, y), _thd.size.x / 16, _thd.size.y / 16 , rad);
|
||||||
DrawStationCoverageText(accepts, sx, sy, mask);
|
DrawStationCoverageText(accepts, sx, sy, mask);
|
||||||
|
|
|
@ -35,7 +35,7 @@ typedef struct Packet {
|
||||||
|
|
||||||
typedef struct CommandPacket {
|
typedef struct CommandPacket {
|
||||||
struct CommandPacket *next;
|
struct CommandPacket *next;
|
||||||
byte player; /// player that is executing the command (PlayerID)
|
PlayerID player; /// player that is executing the command
|
||||||
uint32 cmd; /// command being executed
|
uint32 cmd; /// command being executed
|
||||||
uint32 p1; /// parameter p1
|
uint32 p1; /// parameter p1
|
||||||
uint32 p2; /// parameter p2
|
uint32 p2; /// parameter p2
|
||||||
|
|
|
@ -373,7 +373,7 @@ static inline void SetNewsDisplayValue(byte item, byte val)
|
||||||
static void ShowNewspaper(NewsItem *ni)
|
static void ShowNewspaper(NewsItem *ni)
|
||||||
{
|
{
|
||||||
Window *w;
|
Window *w;
|
||||||
int sound;
|
SoundFx sound;
|
||||||
int top;
|
int top;
|
||||||
ni->flags &= ~(NF_NOEXPIRE | NF_FORCE_BIG);
|
ni->flags &= ~(NF_NOEXPIRE | NF_FORCE_BIG);
|
||||||
ni->duration = 555;
|
ni->duration = 555;
|
||||||
|
|
|
@ -789,7 +789,7 @@ static bool LoadOldIndustry(LoadgameState *ls, int num)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint _current_player_id;
|
static PlayerID _current_player_id;
|
||||||
static uint16 _old_inaugurated_year;
|
static uint16 _old_inaugurated_year;
|
||||||
static int32 _old_yearly;
|
static int32 _old_yearly;
|
||||||
|
|
||||||
|
|
|
@ -867,7 +867,7 @@ void StateGameLoop(void)
|
||||||
} else {
|
} else {
|
||||||
// All these actions has to be done from OWNER_NONE
|
// All these actions has to be done from OWNER_NONE
|
||||||
// for multiplayer compatibility
|
// for multiplayer compatibility
|
||||||
uint p = _current_player;
|
PlayerID p = _current_player;
|
||||||
_current_player = OWNER_NONE;
|
_current_player = OWNER_NONE;
|
||||||
|
|
||||||
AnimateAnimatedTiles();
|
AnimateAnimatedTiles();
|
||||||
|
|
|
@ -691,7 +691,7 @@ static const WindowDesc _other_player_company_desc = {
|
||||||
void ShowPlayerCompany(PlayerID player)
|
void ShowPlayerCompany(PlayerID player)
|
||||||
{
|
{
|
||||||
Window *w;
|
Window *w;
|
||||||
w = AllocateWindowDescFront((byte)player == _local_player ? &_my_player_company_desc : &_other_player_company_desc, player);
|
w = AllocateWindowDescFront(player == _local_player ? &_my_player_company_desc : &_other_player_company_desc, player);
|
||||||
if (w)
|
if (w)
|
||||||
w->caption_color = w->window_number;
|
w->caption_color = w->window_number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ void InvalidatePlayerWindows(const Player *p)
|
||||||
bool CheckPlayerHasMoney(int32 cost)
|
bool CheckPlayerHasMoney(int32 cost)
|
||||||
{
|
{
|
||||||
if (cost > 0) {
|
if (cost > 0) {
|
||||||
uint pid = _current_player;
|
PlayerID pid = _current_player;
|
||||||
if (pid < MAX_PLAYERS && cost > GetPlayer(pid)->player_money) {
|
if (pid < MAX_PLAYERS && cost > GetPlayer(pid)->player_money) {
|
||||||
SetDParam(0, cost);
|
SetDParam(0, cost);
|
||||||
_error_message = STR_0003_NOT_ENOUGH_CASH_REQUIRES;
|
_error_message = STR_0003_NOT_ENOUGH_CASH_REQUIRES;
|
||||||
|
@ -284,7 +284,7 @@ bool CheckOwnership(PlayerID owner)
|
||||||
|
|
||||||
bool CheckTileOwnership(TileIndex tile)
|
bool CheckTileOwnership(TileIndex tile)
|
||||||
{
|
{
|
||||||
byte owner = GetTileOwner(tile);
|
PlayerID owner = GetTileOwner(tile);
|
||||||
|
|
||||||
assert(owner <= OWNER_WATER);
|
assert(owner <= OWNER_WATER);
|
||||||
|
|
||||||
|
|
|
@ -412,7 +412,7 @@ static void DrawNewRoadVehWindow(Window *w)
|
||||||
int sel = WP(w,buildtrain_d).sel_index;
|
int sel = WP(w,buildtrain_d).sel_index;
|
||||||
int pos = w->vscroll.pos;
|
int pos = w->vscroll.pos;
|
||||||
EngineID engine_id = ROAD_ENGINES_INDEX;
|
EngineID engine_id = ROAD_ENGINES_INDEX;
|
||||||
int selected_id = -1;
|
EngineID selected_id = INVALID_ENGINE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (HASBIT(e->player_avail, _local_player)) {
|
if (HASBIT(e->player_avail, _local_player)) {
|
||||||
|
@ -427,7 +427,7 @@ static void DrawNewRoadVehWindow(Window *w)
|
||||||
} while (++engine_id, ++e,--num);
|
} while (++engine_id, ++e,--num);
|
||||||
|
|
||||||
WP(w,buildtrain_d).sel_engine = selected_id;
|
WP(w,buildtrain_d).sel_engine = selected_id;
|
||||||
if (selected_id != -1) {
|
if (selected_id != INVALID_ENGINE) {
|
||||||
DrawRoadVehPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
DrawRoadVehPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,14 +465,14 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 5: { /* build */
|
case 5: { /* build */
|
||||||
int sel_eng = WP(w,buildtrain_d).sel_engine;
|
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
|
||||||
if (sel_eng != -1)
|
if (sel_eng != INVALID_ENGINE)
|
||||||
DoCommandP(w->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE));
|
DoCommandP(w->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 6: { /* rename */
|
case 6: { /* rename */
|
||||||
int sel_eng = WP(w,buildtrain_d).sel_engine;
|
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
|
||||||
if (sel_eng != -1) {
|
if (sel_eng != INVALID_ENGINE) {
|
||||||
WP(w,buildtrain_d).rename_engine = sel_eng;
|
WP(w,buildtrain_d).rename_engine = sel_eng;
|
||||||
ShowQueryString(GetCustomEngineName(sel_eng),
|
ShowQueryString(GetCustomEngineName(sel_eng),
|
||||||
STR_9036_RENAME_ROAD_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number);
|
STR_9036_RENAME_ROAD_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number);
|
||||||
|
|
12
ship_gui.c
12
ship_gui.c
|
@ -352,7 +352,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
|
||||||
int sel = WP(w,buildtrain_d).sel_index;
|
int sel = WP(w,buildtrain_d).sel_index;
|
||||||
int pos = w->vscroll.pos;
|
int pos = w->vscroll.pos;
|
||||||
EngineID engine_id = SHIP_ENGINES_INDEX;
|
EngineID engine_id = SHIP_ENGINES_INDEX;
|
||||||
int selected_id = -1;
|
EngineID selected_id = INVALID_ENGINE;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (HASBIT(e->player_avail, _local_player)) {
|
if (HASBIT(e->player_avail, _local_player)) {
|
||||||
|
@ -368,7 +368,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
WP(w,buildtrain_d).sel_engine = selected_id;
|
WP(w,buildtrain_d).sel_engine = selected_id;
|
||||||
|
|
||||||
if (selected_id != -1) {
|
if (selected_id != INVALID_ENGINE) {
|
||||||
DrawShipPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
DrawShipPurchaseInfo(2, w->widget[4].top + 1, selected_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,14 +384,14 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case 5: { /* build */
|
case 5: { /* build */
|
||||||
int sel_eng = WP(w,buildtrain_d).sel_engine;
|
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
|
||||||
if (sel_eng != -1)
|
if (sel_eng != INVALID_ENGINE)
|
||||||
DoCommandP(w->window_number, sel_eng, 0, CcBuildShip, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP));
|
DoCommandP(w->window_number, sel_eng, 0, CcBuildShip, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 6: { /* rename */
|
case 6: { /* rename */
|
||||||
int sel_eng = WP(w,buildtrain_d).sel_engine;
|
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
|
||||||
if (sel_eng != -1) {
|
if (sel_eng != INVALID_ENGINE) {
|
||||||
WP(w,buildtrain_d).rename_engine = sel_eng;
|
WP(w,buildtrain_d).rename_engine = sel_eng;
|
||||||
ShowQueryString(GetCustomEngineName(sel_eng),
|
ShowQueryString(GetCustomEngineName(sel_eng),
|
||||||
STR_9838_RENAME_SHIP_TYPE, 31, 160, w->window_class, w->window_number);
|
STR_9838_RENAME_SHIP_TYPE, 31, 160, w->window_class, w->window_number);
|
||||||
|
|
2
signs.h
2
signs.h
|
@ -11,7 +11,7 @@ typedef struct SignStruct {
|
||||||
int32 x;
|
int32 x;
|
||||||
int32 y;
|
int32 y;
|
||||||
byte z;
|
byte z;
|
||||||
byte owner; // placed by this player. Anyone can delete them though.
|
PlayerID owner; // placed by this player. Anyone can delete them though.
|
||||||
// OWNER_NONE for gray signs from old games.
|
// OWNER_NONE for gray signs from old games.
|
||||||
|
|
||||||
uint16 index;
|
uint16 index;
|
||||||
|
|
|
@ -123,11 +123,11 @@ enum {
|
||||||
CA_AIR_INTER = 8,
|
CA_AIR_INTER = 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
void ModifyStationRatingAround(TileIndex tile, byte owner, int amount, uint radius);
|
void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius);
|
||||||
|
|
||||||
TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st);
|
TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st);
|
||||||
|
|
||||||
void ShowStationViewWindow(int station);
|
void ShowStationViewWindow(StationID station);
|
||||||
void UpdateAllStationVirtCoord(void);
|
void UpdateAllStationVirtCoord(void);
|
||||||
|
|
||||||
VARDEF SortStruct *_station_sort;
|
VARDEF SortStruct *_station_sort;
|
||||||
|
|
|
@ -179,13 +179,12 @@ static byte FindCatchmentRadius(Station *st)
|
||||||
|
|
||||||
#define CHECK_STATIONS_ERR ((Station*)-1)
|
#define CHECK_STATIONS_ERR ((Station*)-1)
|
||||||
|
|
||||||
static Station *GetStationAround(TileIndex tile, int w, int h, int closest_station)
|
static Station* GetStationAround(TileIndex tile, int w, int h, StationID closest_station)
|
||||||
{
|
{
|
||||||
// check around to see if there's any stations there
|
// check around to see if there's any stations there
|
||||||
BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
|
BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
|
||||||
if (IsTileType(tile_cur, MP_STATION)) {
|
if (IsTileType(tile_cur, MP_STATION)) {
|
||||||
int t;
|
StationID t = _m[tile_cur].m2;
|
||||||
t = _m[tile_cur].m2;
|
|
||||||
{
|
{
|
||||||
Station *st = GetStation(t);
|
Station *st = GetStation(t);
|
||||||
// you cannot take control of an oilrig!!
|
// you cannot take control of an oilrig!!
|
||||||
|
@ -193,7 +192,7 @@ static Station *GetStationAround(TileIndex tile, int w, int h, int closest_stati
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (closest_station == -1) {
|
if (closest_station == INVALID_STATION) {
|
||||||
closest_station = t;
|
closest_station = t;
|
||||||
} else if (closest_station != t) {
|
} else if (closest_station != t) {
|
||||||
_error_message = STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING;
|
_error_message = STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING;
|
||||||
|
@ -201,7 +200,7 @@ static Station *GetStationAround(TileIndex tile, int w, int h, int closest_stati
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
END_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
|
END_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
|
||||||
return (closest_station == -1) ? NULL : GetStation(closest_station);
|
return (closest_station == INVALID_STATION) ? NULL : GetStation(closest_station);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st)
|
TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st)
|
||||||
|
@ -424,7 +423,7 @@ done:
|
||||||
}
|
}
|
||||||
#undef M
|
#undef M
|
||||||
|
|
||||||
static Station *GetClosestStationFromTile(TileIndex tile, uint threshold, byte owner)
|
static Station* GetClosestStationFromTile(TileIndex tile, uint threshold, PlayerID owner)
|
||||||
{
|
{
|
||||||
Station* best_station = NULL;
|
Station* best_station = NULL;
|
||||||
Station* st;
|
Station* st;
|
||||||
|
@ -755,7 +754,7 @@ static int32 ClearTile_Station(TileIndex tile, byte flags);
|
||||||
|
|
||||||
// Tries to clear the given area. Returns the cost in case of success.
|
// Tries to clear the given area. Returns the cost in case of success.
|
||||||
// Or an error code if it failed.
|
// Or an error code if it failed.
|
||||||
int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *station)
|
int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station)
|
||||||
{
|
{
|
||||||
int32 cost = 0, ret;
|
int32 cost = 0, ret;
|
||||||
|
|
||||||
|
@ -810,17 +809,17 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
|
||||||
}
|
}
|
||||||
|
|
||||||
// if station is set, then we have special handling to allow building on top of already existing stations.
|
// if station is set, then we have special handling to allow building on top of already existing stations.
|
||||||
// so station points to -1 if we can build on any station. or it points to a station if we're only allowed to build
|
// so station points to INVALID_STATION if we can build on any station. or it points to a station if we're only allowed to build
|
||||||
// on exactly that station.
|
// on exactly that station.
|
||||||
if (station != NULL && IsTileType(tile_cur, MP_STATION)) {
|
if (station != NULL && IsTileType(tile_cur, MP_STATION)) {
|
||||||
if (_m[tile_cur].m5 >= 8) {
|
if (_m[tile_cur].m5 >= 8) {
|
||||||
_error_message = ClearTile_Station(tile_cur, DC_AUTO); // get error message
|
_error_message = ClearTile_Station(tile_cur, DC_AUTO); // get error message
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
} else {
|
} else {
|
||||||
int st = _m[tile_cur].m2;
|
StationID st = _m[tile_cur].m2;
|
||||||
if (*station == -1)
|
if (*station == INVALID_STATION) {
|
||||||
*station = st;
|
*station = st;
|
||||||
else if (*station != st) {
|
} else if (*station != st) {
|
||||||
_error_message = STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING;
|
_error_message = STR_3006_ADJOINS_MORE_THAN_ONE_EXISTING;
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -952,7 +951,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
TileIndex tile_org;
|
TileIndex tile_org;
|
||||||
int w_org, h_org;
|
int w_org, h_org;
|
||||||
int32 cost, ret;
|
int32 cost, ret;
|
||||||
int est;
|
StationID est;
|
||||||
int plat_len, numtracks;
|
int plat_len, numtracks;
|
||||||
int direction;
|
int direction;
|
||||||
uint finalvalues[3];
|
uint finalvalues[3];
|
||||||
|
@ -986,7 +985,7 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
finalvalues[2] = h_org;
|
finalvalues[2] = h_org;
|
||||||
|
|
||||||
// Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station)
|
// Make sure the area below consists of clear tiles. (OR tiles belonging to a certain rail station)
|
||||||
est = -1;
|
est = INVALID_STATION;
|
||||||
// If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug
|
// If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug
|
||||||
// for detail info, see: https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365
|
// for detail info, see: https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365
|
||||||
if (CmdFailed(ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags&~DC_EXEC, 5 << direction, _patches.nonuniform_stations ? &est : NULL))) return CMD_ERROR;
|
if (CmdFailed(ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags&~DC_EXEC, 5 << direction, _patches.nonuniform_stations ? &est : NULL))) return CMD_ERROR;
|
||||||
|
@ -1190,8 +1189,9 @@ int32 CmdRemoveFromRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32
|
||||||
// determine the number of platforms for the station
|
// determine the number of platforms for the station
|
||||||
uint GetStationPlatforms(const Station *st, TileIndex tile)
|
uint GetStationPlatforms(const Station *st, TileIndex tile)
|
||||||
{
|
{
|
||||||
uint t;
|
TileIndex t;
|
||||||
int dir,delta;
|
TileIndexDiff delta;
|
||||||
|
int dir;
|
||||||
int len;
|
int len;
|
||||||
assert(TileBelongsToRailStation(st, tile));
|
assert(TileBelongsToRailStation(st, tile));
|
||||||
|
|
||||||
|
@ -2137,7 +2137,7 @@ static void DrawTile_Station(TileInfo *ti)
|
||||||
uint32 relocation = 0;
|
uint32 relocation = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
uint owner = GetTileOwner(ti->tile);
|
PlayerID owner = GetTileOwner(ti->tile);
|
||||||
image_or_modificator = PALETTE_TO_GREY; /* NOTE: possible bug in ttd here? */
|
image_or_modificator = PALETTE_TO_GREY; /* NOTE: possible bug in ttd here? */
|
||||||
if (owner < MAX_PLAYERS)
|
if (owner < MAX_PLAYERS)
|
||||||
image_or_modificator = PLAYER_SPRITE_COLOR(owner);
|
image_or_modificator = PLAYER_SPRITE_COLOR(owner);
|
||||||
|
@ -2680,7 +2680,7 @@ void StationMonthlyLoop(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModifyStationRatingAround(TileIndex tile, byte owner, int amount, uint radius)
|
void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius)
|
||||||
{
|
{
|
||||||
Station *st;
|
Station *st;
|
||||||
GoodsEntry *ge;
|
GoodsEntry *ge;
|
||||||
|
|
|
@ -112,7 +112,7 @@ static void GlobalSortStationList(void)
|
||||||
DEBUG(misc, 1) ("Resorting global station list...");
|
DEBUG(misc, 1) ("Resorting global station list...");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MakeSortedStationList(byte owner)
|
static void MakeSortedStationList(PlayerID owner)
|
||||||
{
|
{
|
||||||
SortStruct *firstelement;
|
SortStruct *firstelement;
|
||||||
uint32 n = 0;
|
uint32 n = 0;
|
||||||
|
@ -137,25 +137,25 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch(e->event) {
|
switch(e->event) {
|
||||||
case WE_PAINT: {
|
case WE_PAINT: {
|
||||||
|
const PlayerID owner = w->window_number;
|
||||||
uint32 i;
|
uint32 i;
|
||||||
const byte window_number = (byte)w->window_number;
|
|
||||||
|
|
||||||
// resort station window if stations have been added/removed
|
// resort station window if stations have been added/removed
|
||||||
if (_global_station_sort_dirty)
|
if (_global_station_sort_dirty)
|
||||||
GlobalSortStationList();
|
GlobalSortStationList();
|
||||||
|
|
||||||
if (_station_sort_dirty[window_number]) { // resort in case of a station rename.
|
if (_station_sort_dirty[owner]) { // resort in case of a station rename.
|
||||||
MakeSortedStationList(window_number);
|
MakeSortedStationList(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stations are stored as a cummulative index, eg 25, 41, 43. This means
|
// stations are stored as a cummulative index, eg 25, 41, 43. This means
|
||||||
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 stations
|
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 stations
|
||||||
i = (window_number == 0) ? 0 : _num_station_sort[window_number-1];
|
i = (owner == 0) ? 0 : _num_station_sort[owner - 1];
|
||||||
SetVScrollCount(w, _num_station_sort[window_number] - i);
|
SetVScrollCount(w, _num_station_sort[owner] - i);
|
||||||
|
|
||||||
/* draw widgets, with player's name in the caption */
|
/* draw widgets, with player's name in the caption */
|
||||||
{
|
{
|
||||||
Player *p = GetPlayer(window_number);
|
const Player* p = GetPlayer(owner);
|
||||||
SetDParam(0, p->name_1);
|
SetDParam(0, p->name_1);
|
||||||
SetDParam(1, p->name_2);
|
SetDParam(1, p->name_2);
|
||||||
SetDParam(2, w->vscroll.count);
|
SetDParam(2, w->vscroll.count);
|
||||||
|
@ -175,12 +175,12 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
i += w->vscroll.pos; // offset from sorted station list of current player
|
i += w->vscroll.pos; // offset from sorted station list of current player
|
||||||
assert(i < _num_station_sort[window_number]); // at least one station must exist
|
assert(i < _num_station_sort[owner]); // at least one station must exist
|
||||||
|
|
||||||
while (i < _num_station_sort[window_number]) { // do until max number of stations of owner
|
while (i < _num_station_sort[owner]) { // do until max number of stations of owner
|
||||||
st = GetStation(_station_sort[i].index);
|
st = GetStation(_station_sort[i].index);
|
||||||
|
|
||||||
assert(st->xy && st->owner == window_number);
|
assert(st->xy && st->owner == owner);
|
||||||
|
|
||||||
SetDParam(0, st->index);
|
SetDParam(0, st->index);
|
||||||
SetDParam(1, st->facilities);
|
SetDParam(1, st->facilities);
|
||||||
|
@ -210,7 +210,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
|
||||||
id_v += w->vscroll.pos;
|
id_v += w->vscroll.pos;
|
||||||
|
|
||||||
{
|
{
|
||||||
const byte owner = (byte)w->window_number;
|
const PlayerID owner = w->window_number;
|
||||||
Station *st;
|
Station *st;
|
||||||
id_v += (owner == 0) ? 0 : _num_station_sort[owner - 1]; // first element in list
|
id_v += (owner == 0) ? 0 : _num_station_sort[owner - 1]; // first element in list
|
||||||
|
|
||||||
|
@ -316,11 +316,11 @@ static void DrawStationViewWindow(Window *w)
|
||||||
int x,y;
|
int x,y;
|
||||||
int pos;
|
int pos;
|
||||||
StringID str;
|
StringID str;
|
||||||
uint16 station_id;
|
StationID station_id;
|
||||||
|
|
||||||
station_id = w->window_number;
|
station_id = w->window_number;
|
||||||
|
|
||||||
st = GetStation(w->window_number);
|
st = GetStation(station_id);
|
||||||
|
|
||||||
num = 1;
|
num = 1;
|
||||||
for(i=0; i!=NUM_CARGO; i++) {
|
for(i=0; i!=NUM_CARGO; i++) {
|
||||||
|
@ -533,7 +533,7 @@ static const WindowDesc _station_view_desc = {
|
||||||
StationViewWndProc
|
StationViewWndProc
|
||||||
};
|
};
|
||||||
|
|
||||||
void ShowStationViewWindow(int station)
|
void ShowStationViewWindow(StationID station)
|
||||||
{
|
{
|
||||||
Window *w;
|
Window *w;
|
||||||
byte color;
|
byte color;
|
||||||
|
|
2
town.h
2
town.h
|
@ -32,7 +32,7 @@ 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
|
PlayerID exclusivity; // which player has exslusivity
|
||||||
uint8 exclusive_counter; // months till the exclusivity expires
|
uint8 exclusive_counter; // months till the exclusivity expires
|
||||||
int16 ratings[MAX_PLAYERS];
|
int16 ratings[MAX_PLAYERS];
|
||||||
|
|
||||||
|
|
|
@ -782,7 +782,7 @@ bool GrowTown(Town *t)
|
||||||
TileIndex tile;
|
TileIndex tile;
|
||||||
const TileIndexDiffC *ptr;
|
const TileIndexDiffC *ptr;
|
||||||
TileInfo ti;
|
TileInfo ti;
|
||||||
byte old_player;
|
PlayerID old_player;
|
||||||
|
|
||||||
static const TileIndexDiffC _town_coord_mod[] = {
|
static const TileIndexDiffC _town_coord_mod[] = {
|
||||||
{-1, 0},
|
{-1, 0},
|
||||||
|
@ -1578,7 +1578,7 @@ static void TownActionRoadRebuild(Town *t, int action)
|
||||||
static bool DoBuildStatueOfCompany(TileIndex tile)
|
static bool DoBuildStatueOfCompany(TileIndex tile)
|
||||||
{
|
{
|
||||||
TileInfo ti;
|
TileInfo ti;
|
||||||
byte old;
|
PlayerID old;
|
||||||
int32 r;
|
int32 r;
|
||||||
|
|
||||||
FindLandscapeHeightByTile(&ti, tile);
|
FindLandscapeHeightByTile(&ti, tile);
|
||||||
|
|
15
train_gui.c
15
train_gui.c
|
@ -173,7 +173,7 @@ void CcCloneTrain(bool success, uint tile, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,
|
static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,
|
||||||
int *selected_id, byte railtype, byte show_max, bool is_engine)
|
EngineID* selected_id, byte railtype, byte show_max, bool is_engine)
|
||||||
{
|
{
|
||||||
EngineID i;
|
EngineID i;
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
|
||||||
int pos = w->vscroll.pos;
|
int pos = w->vscroll.pos;
|
||||||
int x = 1;
|
int x = 1;
|
||||||
int y = 15;
|
int y = 15;
|
||||||
int selected_id = -1;
|
EngineID selected_id = INVALID_ENGINE;
|
||||||
|
|
||||||
/* Ensure that custom engines which substituted wagons
|
/* Ensure that custom engines which substituted wagons
|
||||||
* are sorted correctly.
|
* are sorted correctly.
|
||||||
|
@ -241,7 +241,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
WP(w,buildtrain_d).sel_engine = selected_id;
|
WP(w,buildtrain_d).sel_engine = selected_id;
|
||||||
|
|
||||||
if (selected_id != -1) {
|
if (selected_id != INVALID_ENGINE) {
|
||||||
const RailVehicleInfo *rvi = RailVehInfo(selected_id);
|
const RailVehicleInfo *rvi = RailVehInfo(selected_id);
|
||||||
|
|
||||||
if (!(rvi->flags & RVI_WAGON)) {
|
if (!(rvi->flags & RVI_WAGON)) {
|
||||||
|
@ -265,14 +265,13 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case 5: {
|
case 5: {
|
||||||
int sel_eng;
|
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
|
||||||
sel_eng = WP(w,buildtrain_d).sel_engine;
|
if (sel_eng != INVALID_ENGINE)
|
||||||
if (sel_eng != -1)
|
|
||||||
DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->flags & RVI_WAGON) ? CcBuildWagon : CcBuildLoco, CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
|
DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->flags & RVI_WAGON) ? CcBuildWagon : CcBuildLoco, CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
|
||||||
} break;
|
} break;
|
||||||
case 6: { /* rename */
|
case 6: { /* rename */
|
||||||
int sel_eng = WP(w,buildtrain_d).sel_engine;
|
EngineID sel_eng = WP(w,buildtrain_d).sel_engine;
|
||||||
if (sel_eng != -1) {
|
if (sel_eng != INVALID_ENGINE) {
|
||||||
WP(w,buildtrain_d).rename_engine = sel_eng;
|
WP(w,buildtrain_d).rename_engine = sel_eng;
|
||||||
ShowQueryString(GetCustomEngineName(sel_eng),
|
ShowQueryString(GetCustomEngineName(sel_eng),
|
||||||
STR_886A_RENAME_TRAIN_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number);
|
STR_886A_RENAME_TRAIN_VEHICLE_TYPE, 31, 160, w->window_class, w->window_number);
|
||||||
|
|
|
@ -334,7 +334,7 @@ void UpdateVehiclePosHash(Vehicle *v, int x, int y)
|
||||||
/* remove from hash table? */
|
/* remove from hash table? */
|
||||||
if (old_hash != NULL) {
|
if (old_hash != NULL) {
|
||||||
Vehicle *last = NULL;
|
Vehicle *last = NULL;
|
||||||
int idx = *old_hash;
|
VehicleID idx = *old_hash;
|
||||||
while ((u = GetVehicle(idx)) != v) {
|
while ((u = GetVehicle(idx)) != v) {
|
||||||
idx = u->next_hash;
|
idx = u->next_hash;
|
||||||
assert(idx != INVALID_VEHICLE);
|
assert(idx != INVALID_VEHICLE);
|
||||||
|
@ -1458,7 +1458,7 @@ int32 ReplaceVehicle(Vehicle *v)
|
||||||
(that is needed, because this CMD is called automaticly) */
|
(that is needed, because this CMD is called automaticly) */
|
||||||
if ( p->money64 < (int32)(p->engine_renew_money + build_cost + rear_engine_cost - v->value)) {
|
if ( p->money64 < (int32)(p->engine_renew_money + build_cost + rear_engine_cost - v->value)) {
|
||||||
if (( _local_player == v->owner ) && ( v->unitnumber != 0 )) { //v->unitnumber = 0 for train cars
|
if (( _local_player == v->owner ) && ( v->unitnumber != 0 )) { //v->unitnumber = 0 for train cars
|
||||||
int message;
|
StringID message;
|
||||||
SetDParam(0, v->unitnumber);
|
SetDParam(0, v->unitnumber);
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_Train: message = STR_TRAIN_AUTORENEW_FAILED; break;
|
case VEH_Train: message = STR_TRAIN_AUTORENEW_FAILED; break;
|
||||||
|
|
4
window.h
4
window.h
|
@ -352,8 +352,8 @@ assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
|
||||||
typedef struct {
|
typedef struct {
|
||||||
byte railtype;
|
byte railtype;
|
||||||
byte sel_index;
|
byte sel_index;
|
||||||
int16 sel_engine;
|
EngineID sel_engine;
|
||||||
int16 rename_engine;
|
EngineID rename_engine;
|
||||||
} buildtrain_d;
|
} buildtrain_d;
|
||||||
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildtrain_d));
|
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(buildtrain_d));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue