mirror of https://github.com/OpenTTD/OpenTTD
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
parent
c126ce110e
commit
2b27073156
1
ai/ai.c
1
ai/ai.c
|
@ -30,7 +30,6 @@ static void AI_DequeueCommands(PlayerID player)
|
|||
while ((com = entry_com) != NULL) {
|
||||
_current_player = player;
|
||||
|
||||
/* Copy the DP back in place */
|
||||
_cmd_text = com->text;
|
||||
DoCommandP(com->tile, com->p1, com->p2, com->callback, com->procc);
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ static void AiHandleReplaceTrain(Player *p)
|
|||
tile = v->tile;
|
||||
|
||||
if (!CmdFailed(DoCommand(0, v->index, 2, DC_EXEC, CMD_SELL_RAIL_WAGON)) &&
|
||||
!CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE)) ) {
|
||||
!CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE))) {
|
||||
VehicleID veh = _new_vehicle_id;
|
||||
AiRestoreVehicleOrders(GetVehicle(veh), orderbak);
|
||||
DoCommand(0, veh, 0, DC_EXEC, CMD_START_STOP_TRAIN);
|
||||
|
@ -345,7 +345,7 @@ static void AiHandleReplaceRoadVeh(Player *p)
|
|||
tile = v->tile;
|
||||
|
||||
if (!CmdFailed(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH)) &&
|
||||
!CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH))) {
|
||||
!CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH))) {
|
||||
VehicleID veh = _new_vehicle_id;
|
||||
|
||||
AiRestoreVehicleOrders(GetVehicle(veh), orderbak);
|
||||
|
@ -374,7 +374,7 @@ static void AiHandleReplaceAircraft(Player *p)
|
|||
tile = v->tile;
|
||||
|
||||
if (!CmdFailed(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT)) &&
|
||||
!CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT)) ) {
|
||||
!CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) {
|
||||
VehicleID veh = _new_vehicle_id;
|
||||
AiRestoreVehicleOrders(GetVehicle(veh), orderbak);
|
||||
DoCommand(0, veh, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
|
||||
|
|
|
@ -286,14 +286,15 @@ int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
|
|||
int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
|
||||
{
|
||||
int ret, ret2;
|
||||
if (p->ainew.tbt == AI_TRAIN)
|
||||
if (p->ainew.tbt == AI_TRAIN) {
|
||||
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
|
||||
|
||||
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
|
||||
if (CmdFailed(ret)) return ret;
|
||||
// Try to build the road from the depot
|
||||
ret2 = AI_DoCommand(tile + TileOffsByDir(direction), DiagDirToRoadBits(ReverseDiagDir(direction)), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||
// If it fails, ignore it..
|
||||
if (CmdFailed(ret2)) return ret;
|
||||
return ret + ret2;
|
||||
} else {
|
||||
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
|
||||
if (CmdFailed(ret)) return ret;
|
||||
// Try to build the road from the depot
|
||||
ret2 = AI_DoCommand(tile + TileOffsByDir(direction), DiagDirToRoadBits(ReverseDiagDir(direction)), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
|
||||
// If it fails, ignore it..
|
||||
if (CmdFailed(ret2)) return ret;
|
||||
return ret + ret2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,12 +425,13 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
|
|||
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
||||
}
|
||||
} else {
|
||||
if (!(IsRoad(parent->path.node.tile) && IsTileType(parent->path.node.tile, MP_TUNNELBRIDGE))) {
|
||||
if (!IsRoad(parent->path.node.tile) || !IsTileType(parent->path.node.tile, MP_TUNNELBRIDGE)) {
|
||||
r = GetRoadFoundation(parent_tileh, AiNew_GetRoadDirection(parent->path.parent->node.tile, parent->path.node.tile, current->tile));
|
||||
if (r >= 15 || r == 0)
|
||||
if (r >= 15 || r == 0) {
|
||||
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
|
||||
else
|
||||
} else {
|
||||
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,35 +16,20 @@ int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
|
|||
// 4 = dig down-left
|
||||
// 5 = dig up-right
|
||||
|
||||
int x1, x2, x3;
|
||||
int y1, y2, y3;
|
||||
uint x1 = TileX(tile_a);
|
||||
uint x2 = TileX(tile_b);
|
||||
uint x3 = TileX(tile_c);
|
||||
|
||||
x1 = TileX(tile_a);
|
||||
x2 = TileX(tile_b);
|
||||
x3 = TileX(tile_c);
|
||||
|
||||
y1 = TileY(tile_a);
|
||||
y2 = TileY(tile_b);
|
||||
y3 = TileY(tile_c);
|
||||
uint y1 = TileY(tile_a);
|
||||
uint y2 = TileY(tile_b);
|
||||
uint y3 = TileY(tile_c);
|
||||
|
||||
if (y1 == y2 && y2 == y3) return 0;
|
||||
if (x1 == x2 && x2 == x3) return 1;
|
||||
if (y2 > y1) {
|
||||
if (x2 > x3) return 2;
|
||||
else return 4;
|
||||
}
|
||||
if (x2 > x1) {
|
||||
if (y2 > y3) return 2;
|
||||
else return 5;
|
||||
}
|
||||
if (y1 > y2) {
|
||||
if (x2 > x3) return 5;
|
||||
else return 3;
|
||||
}
|
||||
if (x1 > x2) {
|
||||
if (y2 > y3) return 4;
|
||||
else return 3;
|
||||
}
|
||||
if (y2 > y1) return x2 > x3 ? 2 : 4;
|
||||
if (x2 > x1) return y2 > y3 ? 2 : 5;
|
||||
if (y1 > y2) return x2 > x3 ? 5 : 3;
|
||||
if (x1 > x2) return y2 > y3 ? 4 : 3;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -87,11 +72,14 @@ DiagDirection AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b)
|
|||
return DIAGDIR_NE;
|
||||
}
|
||||
|
||||
|
||||
// This functions looks up if this vehicle is special for this AI
|
||||
// and returns his flag
|
||||
uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v) {
|
||||
int i;
|
||||
for (i=0;i<AI_MAX_SPECIAL_VEHICLES;i++) {
|
||||
uint AiNew_GetSpecialVehicleFlag(Player* p, Vehicle* v)
|
||||
{
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
|
||||
if (p->ainew.special_vehicles[i].veh_id == v->index) {
|
||||
return p->ainew.special_vehicles[i].flag;
|
||||
}
|
||||
|
@ -101,16 +89,22 @@ uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag) {
|
||||
int i, new_id = -1;
|
||||
for (i=0;i<AI_MAX_SPECIAL_VEHICLES;i++) {
|
||||
|
||||
bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
|
||||
{
|
||||
int new_id = -1;
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
|
||||
if (p->ainew.special_vehicles[i].veh_id == v->index) {
|
||||
p->ainew.special_vehicles[i].flag |= flag;
|
||||
return true;
|
||||
}
|
||||
if (new_id == -1 && p->ainew.special_vehicles[i].veh_id == 0 &&
|
||||
p->ainew.special_vehicles[i].flag == 0)
|
||||
if (new_id == -1 &&
|
||||
p->ainew.special_vehicles[i].veh_id == 0 &&
|
||||
p->ainew.special_vehicles[i].flag == 0) {
|
||||
new_id = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Out of special_vehicle spots :s
|
||||
|
|
|
@ -1244,9 +1244,11 @@ static void AiNew_State_StartVehicle(Player *p)
|
|||
// Repays money
|
||||
static void AiNew_State_RepayMoney(Player *p)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<AI_LOAN_REPAY;i++)
|
||||
uint i;
|
||||
|
||||
for (i = 0; i < AI_LOAN_REPAY; i++) {
|
||||
AI_DoCommand(0, 0, 0, DC_EXEC, CMD_DECREASE_LOAN);
|
||||
}
|
||||
p->ainew.state = AI_STATE_ACTION_DONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1929,16 +1929,14 @@ static uint GetNumHelipads(const AirportFTAClass *Airport)
|
|||
|
||||
static bool AirportFindFreeHelipad(Vehicle *v, const AirportFTAClass *Airport)
|
||||
{
|
||||
Station *st;
|
||||
AirportFTA *temp;
|
||||
|
||||
// if an airport doesn't have helipads, use terminals
|
||||
if (Airport->helipads == NULL) return AirportFindFreeTerminal(v, Airport);
|
||||
|
||||
// if there are more helicoptergroups, pick one, just as in AirportFindFreeTerminal()
|
||||
if (Airport->helipads[0] > 1) {
|
||||
st = GetStation(v->u.air.targetairport);
|
||||
temp = Airport->layout[v->u.air.pos].next_in_chain;
|
||||
const Station* st = GetStation(v->u.air.targetairport);
|
||||
const AirportFTA* temp = Airport->layout[v->u.air.pos].next_in_chain;
|
||||
|
||||
while (temp != NULL) {
|
||||
if (temp->heading == 255) {
|
||||
if (!HASBITS(st->airport_flags, temp->block)) {
|
||||
|
|
|
@ -279,7 +279,7 @@ static void AircraftRefitWndProc(Window *w, WindowEvent *e)
|
|||
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT)))
|
||||
DeleteWindow(w);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -695,8 +695,7 @@ static int GetVehicleFromAircraftDepotWndPt(const Window *w, int x, int y, Vehic
|
|||
|
||||
row = (y - 14) / 24;
|
||||
ym = (y - 14) % 24;
|
||||
if (row >= w->vscroll.cap)
|
||||
return 1;
|
||||
if (row >= w->vscroll.cap) return 1;
|
||||
|
||||
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt;
|
||||
|
||||
|
@ -811,14 +810,14 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e)
|
|||
}
|
||||
break;
|
||||
|
||||
case WE_PLACE_OBJ: {
|
||||
case WE_PLACE_OBJ:
|
||||
ClonePlaceObj(w);
|
||||
} break;
|
||||
break;
|
||||
|
||||
case WE_ABORT_PLACE_OBJ: {
|
||||
case WE_ABORT_PLACE_OBJ:
|
||||
CLRBIT(w->click_state, 8);
|
||||
InvalidateWidget(w, 8);
|
||||
} break;
|
||||
break;
|
||||
|
||||
// check if a vehicle in a depot was clicked..
|
||||
case WE_MOUSELOOP: {
|
||||
|
@ -924,7 +923,8 @@ void ShowAircraftDepotWindow(TileIndex tile)
|
|||
}
|
||||
}
|
||||
|
||||
static void DrawSmallOrderList(const Vehicle *v, int x, int y) {
|
||||
static void DrawSmallOrderList(const Vehicle* v, int x, int y)
|
||||
{
|
||||
const Order *order;
|
||||
int sel, i = 0;
|
||||
|
||||
|
@ -1068,22 +1068,19 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
|||
|
||||
case 7: { /* Matrix to show vehicles */
|
||||
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG;
|
||||
const Vehicle* v;
|
||||
|
||||
if (id_v >= w->vscroll.cap) return; // click out of bounds
|
||||
|
||||
id_v += w->vscroll.pos;
|
||||
|
||||
{
|
||||
Vehicle *v;
|
||||
if (id_v >= vl->list_length) return; // click out of list bound
|
||||
|
||||
if (id_v >= vl->list_length) return; // click out of list bound
|
||||
v = GetVehicle(vl->sort_list[id_v].index);
|
||||
|
||||
v = GetVehicle(vl->sort_list[id_v].index);
|
||||
assert(v->type == VEH_Aircraft && v->subtype <= 2);
|
||||
|
||||
assert(v->type == VEH_Aircraft && v->subtype <= 2);
|
||||
|
||||
ShowAircraftViewWindow(v);
|
||||
}
|
||||
ShowAircraftViewWindow(v);
|
||||
} break;
|
||||
|
||||
case 9: /* Build new Vehicle */
|
||||
|
@ -1092,9 +1089,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
|||
break;
|
||||
|
||||
case 10:
|
||||
if (!IsWindowOfPrototype(w, _player_aircraft_widgets))
|
||||
break;
|
||||
|
||||
if (!IsWindowOfPrototype(w, _player_aircraft_widgets)) break;
|
||||
ShowReplaceVehicleWindow(VEH_Aircraft);
|
||||
break;
|
||||
|
||||
|
|
84
airport.c
84
airport.c
|
@ -32,8 +32,9 @@ static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
|
|||
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
|
||||
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA);
|
||||
static byte AirportTestFTA(const AirportFTAClass *Airport);
|
||||
/*static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report);
|
||||
static byte AirportBlockToString(uint32 block);*/
|
||||
#if 0
|
||||
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report);
|
||||
#endif
|
||||
|
||||
void InitializeAirports(void)
|
||||
{
|
||||
|
@ -272,7 +273,9 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
|||
// print out full information
|
||||
// true -- full info including heading, block, etc
|
||||
// false -- short info, only position and next position
|
||||
//AirportPrintOut(Airport, false);
|
||||
#if 0
|
||||
AirportPrintOut(Airport, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void AirportFTAClass_Destructor(AirportFTAClass *Airport)
|
||||
|
@ -393,28 +396,45 @@ static const char* const _airport_heading_strings[] = {
|
|||
"DUMMY" // extra heading for 255
|
||||
};
|
||||
|
||||
|
||||
static uint AirportBlockToString(uint32 block)
|
||||
{
|
||||
uint i = 0;
|
||||
if (block & 0xffff0000) { block >>= 16; i += 16; }
|
||||
if (block & 0x0000ff00) { block >>= 8; i += 8; }
|
||||
if (block & 0x000000f0) { block >>= 4; i += 4; }
|
||||
if (block & 0x0000000c) { block >>= 2; i += 2; }
|
||||
if (block & 0x00000002) { i += 1; }
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report)
|
||||
{
|
||||
AirportFTA *temp;
|
||||
uint16 i;
|
||||
byte heading;
|
||||
uint i;
|
||||
|
||||
printf("(P = Current Position; NP = Next Position)\n");
|
||||
for (i = 0; i < Airport->nofelements; i++) {
|
||||
temp = &Airport->layout[i];
|
||||
const AirportFTA* temp = &Airport->layout[i];
|
||||
|
||||
if (full_report) {
|
||||
heading = (temp->heading == 255) ? MAX_HEADINGS+1 : temp->heading;
|
||||
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", temp->position, temp->next_position,
|
||||
_airport_heading_strings[heading], AirportBlockToString(temp->block));
|
||||
heading = (temp->heading == 255) ? MAX_HEADINGS + 1 : temp->heading;
|
||||
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n",
|
||||
temp->position, temp->next_position,
|
||||
_airport_heading_strings[heading], AirportBlockToString(temp->block)
|
||||
);
|
||||
} else {
|
||||
printf("P:%2d NP:%2d", temp->position, temp->next_position);
|
||||
}
|
||||
while (temp->next_in_chain != NULL) {
|
||||
temp = temp->next_in_chain;
|
||||
if (full_report) {
|
||||
heading = (temp->heading == 255) ? MAX_HEADINGS+1 : temp->heading;
|
||||
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n", temp->position, temp->next_position,
|
||||
_airport_heading_strings[heading], AirportBlockToString(temp->block));
|
||||
heading = (temp->heading == 255) ? MAX_HEADINGS + 1 : temp->heading;
|
||||
printf("Pos:%2d NPos:%2d Heading:%15s Block:%2d\n",
|
||||
temp->position, temp->next_position,
|
||||
_airport_heading_strings[heading], AirportBlockToString(temp->block)
|
||||
);
|
||||
} else {
|
||||
printf("P:%2d NP:%2d", temp->position, temp->next_position);
|
||||
}
|
||||
|
@ -422,43 +442,25 @@ static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_repo
|
|||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static byte AirportBlockToString(uint32 block)
|
||||
{
|
||||
byte i = 0;
|
||||
if (block & 0xffff0000) { block >>= 16; i += 16; }
|
||||
if (block & 0x0000ff00) { block >>= 8; i += 8; }
|
||||
if (block & 0x000000f0) { block >>= 4; i += 4; }
|
||||
if (block & 0x0000000c) { block >>= 2; i += 2; }
|
||||
if (block & 0x00000002) { i += 1; }
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
const AirportFTAClass* GetAirport(const byte airport_type)
|
||||
{
|
||||
AirportFTAClass *Airport = NULL;
|
||||
//FIXME -- AircraftNextAirportPos_and_Order -> Needs something nicer, don't like this code
|
||||
// needs constant change if more airports are added
|
||||
switch (airport_type) {
|
||||
case AT_SMALL: Airport = CountryAirport; break;
|
||||
case AT_LARGE: Airport = CityAirport; break;
|
||||
case AT_METROPOLITAN: Airport = MetropolitanAirport; break;
|
||||
case AT_HELIPORT: Airport = Heliport; break;
|
||||
case AT_OILRIG: Airport = Oilrig; break;
|
||||
case AT_INTERNATIONAL: Airport = InternationalAirport; break;
|
||||
case AT_COMMUTER: Airport = CommuterAirport; break;
|
||||
case AT_HELIDEPOT: Airport = HeliDepot; break;
|
||||
case AT_INTERCON: Airport = IntercontinentalAirport; break;
|
||||
case AT_HELISTATION: Airport = HeliStation; break;
|
||||
default:
|
||||
#ifdef DEBUG__
|
||||
printf("Airport AircraftNextAirportPos_and_Order not yet implemented\n");
|
||||
#endif
|
||||
assert(airport_type <= AT_HELISTATION);
|
||||
default: NOT_REACHED();
|
||||
case AT_SMALL: return CountryAirport;
|
||||
case AT_LARGE: return CityAirport;
|
||||
case AT_METROPOLITAN: return MetropolitanAirport;
|
||||
case AT_HELIPORT: return Heliport;
|
||||
case AT_OILRIG: return Oilrig;
|
||||
case AT_INTERNATIONAL: return InternationalAirport;
|
||||
case AT_COMMUTER: return CommuterAirport;
|
||||
case AT_HELIDEPOT: return HeliDepot;
|
||||
case AT_INTERCON: return IntercontinentalAirport;
|
||||
case AT_HELISTATION: return HeliStation;
|
||||
}
|
||||
return Airport;
|
||||
}
|
||||
|
||||
const AirportMovingData *GetAirportMovingData(byte airport_type, byte position)
|
||||
|
|
|
@ -88,10 +88,9 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
|
|||
_place_proc(e->place.tile);
|
||||
break;
|
||||
|
||||
case WE_PLACE_DRAG: {
|
||||
case WE_PLACE_DRAG:
|
||||
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_PLACE_MOUSEUP:
|
||||
if (e->place.pt.x != -1) {
|
||||
|
@ -186,7 +185,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
|||
if (_station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
||||
|
||||
DrawWindowWidgets(w);
|
||||
// strings such as 'Size' and 'Coverage Area'
|
||||
// strings such as 'Size' and 'Coverage Area'
|
||||
DrawStringCentered(74, 16, STR_SMALL_AIRPORTS, 0);
|
||||
DrawStringCentered(74, 54, STR_LARGE_AIRPORTS, 0);
|
||||
DrawStringCentered(74, 92, STR_HUB_AIRPORTS, 0);
|
||||
|
|
140
console.c
140
console.c
|
@ -109,31 +109,35 @@ static void IConsoleWndProc(Window* w, WindowEvent* e)
|
|||
SetWindowDirty(w);
|
||||
break;
|
||||
case WKC_SHIFT | WKC_PAGEUP:
|
||||
if (_iconsole_scroll - (w->height / ICON_LINE_HEIGHT) - 1 < 0)
|
||||
if (_iconsole_scroll - (w->height / ICON_LINE_HEIGHT) - 1 < 0) {
|
||||
_iconsole_scroll = 0;
|
||||
else
|
||||
} else {
|
||||
_iconsole_scroll -= (w->height / ICON_LINE_HEIGHT) - 1;
|
||||
}
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
case WKC_SHIFT | WKC_PAGEDOWN:
|
||||
if (_iconsole_scroll + (w->height / ICON_LINE_HEIGHT) - 1 > ICON_BUFFER)
|
||||
if (_iconsole_scroll + (w->height / ICON_LINE_HEIGHT) - 1 > ICON_BUFFER) {
|
||||
_iconsole_scroll = ICON_BUFFER;
|
||||
else
|
||||
} else {
|
||||
_iconsole_scroll += (w->height / ICON_LINE_HEIGHT) - 1;
|
||||
}
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
case WKC_SHIFT | WKC_UP:
|
||||
if (_iconsole_scroll <= 0)
|
||||
if (_iconsole_scroll <= 0) {
|
||||
_iconsole_scroll = 0;
|
||||
else
|
||||
} else {
|
||||
--_iconsole_scroll;
|
||||
}
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
case WKC_SHIFT | WKC_DOWN:
|
||||
if (_iconsole_scroll >= ICON_BUFFER)
|
||||
if (_iconsole_scroll >= ICON_BUFFER) {
|
||||
_iconsole_scroll = ICON_BUFFER;
|
||||
else
|
||||
} else {
|
||||
++_iconsole_scroll;
|
||||
}
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
case WKC_BACKQUOTE:
|
||||
|
@ -182,8 +186,9 @@ static void IConsoleWndProc(Window* w, WindowEvent* e)
|
|||
InsertTextBufferChar(&_iconsole_cmdline, e->keypress.ascii);
|
||||
IConsoleResetHistoryPos();
|
||||
SetWindowDirty(w);
|
||||
} else
|
||||
} else {
|
||||
e->keypress.cont = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -565,40 +570,41 @@ void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *
|
|||
* three types, just with different variables. Yes, templates would be handy. It was
|
||||
* either this define or an even more ugly void* magic function
|
||||
*/
|
||||
#define IConsoleAddSorted(_base, item_new, IConsoleType, type) \
|
||||
{ \
|
||||
IConsoleType *item, *item_before; \
|
||||
/* first command */ \
|
||||
if (_base == NULL) { \
|
||||
_base = item_new; \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
item_before = NULL; \
|
||||
item = _base; \
|
||||
\
|
||||
/* BEGIN - Alphabetically insert the commands into the linked list */ \
|
||||
while (item != NULL) { \
|
||||
int i = strcmp(item->name, item_new->name); \
|
||||
if (i == 0) { \
|
||||
IConsoleError(type " with this name already exists; insertion aborted"); \
|
||||
free(item_new); \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
if (i > 0) break; /* insert at this position */ \
|
||||
\
|
||||
item_before = item; \
|
||||
item = item->next; \
|
||||
} \
|
||||
\
|
||||
if (item_before == NULL) { \
|
||||
_base = item_new; \
|
||||
} else \
|
||||
item_before->next = item_new; \
|
||||
\
|
||||
item_new->next = item; \
|
||||
/* END - Alphabetical insert */ \
|
||||
#define IConsoleAddSorted(_base, item_new, IConsoleType, type) \
|
||||
{ \
|
||||
IConsoleType *item, *item_before; \
|
||||
/* first command */ \
|
||||
if (_base == NULL) { \
|
||||
_base = item_new; \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
item_before = NULL; \
|
||||
item = _base; \
|
||||
\
|
||||
/* BEGIN - Alphabetically insert the commands into the linked list */ \
|
||||
while (item != NULL) { \
|
||||
int i = strcmp(item->name, item_new->name); \
|
||||
if (i == 0) { \
|
||||
IConsoleError(type " with this name already exists; insertion aborted"); \
|
||||
free(item_new); \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
if (i > 0) break; /* insert at this position */ \
|
||||
\
|
||||
item_before = item; \
|
||||
item = item->next; \
|
||||
} \
|
||||
\
|
||||
if (item_before == NULL) { \
|
||||
_base = item_new; \
|
||||
} else { \
|
||||
item_before->next = item_new; \
|
||||
} \
|
||||
\
|
||||
item_new->next = item; \
|
||||
/* END - Alphabetical insert */ \
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -853,12 +859,12 @@ static void IConsoleVarSetValue(const IConsoleVar *var, uint32 value)
|
|||
* @param *var the variable in question
|
||||
* @param *value the new value
|
||||
*/
|
||||
static void IConsoleVarSetStringvalue(const IConsoleVar *var, char *value)
|
||||
static void IConsoleVarSetStringvalue(const IConsoleVar* var, const char* value)
|
||||
{
|
||||
if (var->type != ICONSOLE_VAR_STRING || var->addr == NULL) return;
|
||||
|
||||
IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_PRE_ACTION);
|
||||
ttd_strlcpy((char*)var->addr, (char*)value, var->size);
|
||||
ttd_strlcpy(var->addr, value, var->size);
|
||||
IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_POST_ACTION);
|
||||
IConsoleVarPrintSetValue(var); // print out the new value, giving feedback
|
||||
return;
|
||||
|
@ -1098,8 +1104,10 @@ void IConsoleCmdExec(const char *cmdstr)
|
|||
|
||||
if (_stdlib_con_developer) {
|
||||
uint i;
|
||||
for (i = 0; tokens[i] != NULL; i++)
|
||||
|
||||
for (i = 0; tokens[i] != NULL; i++) {
|
||||
IConsolePrintF(_icolour_dbg, "condbg: token %d is: '%s'", i, tokens[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (tokens[0] == '\0') return; // don't execute empty commands
|
||||
|
@ -1107,31 +1115,33 @@ void IConsoleCmdExec(const char *cmdstr)
|
|||
* First try commands, then aliases, and finally variables. Execute
|
||||
* the found action taking into account its hooking code
|
||||
*/
|
||||
cmd = IConsoleCmdGet(tokens[0]);
|
||||
if (cmd != NULL) {
|
||||
cmd = IConsoleCmdGet(tokens[0]);
|
||||
if (cmd != NULL) {
|
||||
if (IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_ACCESS)) {
|
||||
IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_PRE_ACTION);
|
||||
if (cmd->proc(t_index, tokens)) { // index started with 0
|
||||
IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_POST_ACTION);
|
||||
} else cmd->proc(0, NULL); // if command failed, give help
|
||||
} else {
|
||||
cmd->proc(0, NULL); // if command failed, give help
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
t_index--; // ignore the variable-name for comfort for both aliases and variaables
|
||||
alias = IConsoleAliasGet(tokens[0]);
|
||||
if (alias != NULL) {
|
||||
IConsoleAliasExec(alias, t_index, &tokens[1]);
|
||||
return;
|
||||
}
|
||||
t_index--; // ignore the variable-name for comfort for both aliases and variaables
|
||||
alias = IConsoleAliasGet(tokens[0]);
|
||||
if (alias != NULL) {
|
||||
IConsoleAliasExec(alias, t_index, &tokens[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
var = IConsoleVarGet(tokens[0]);
|
||||
if (var != NULL) {
|
||||
if (IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_ACCESS))
|
||||
IConsoleVarExec(var, t_index, &tokens[1]);
|
||||
var = IConsoleVarGet(tokens[0]);
|
||||
if (var != NULL) {
|
||||
if (IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_ACCESS)) {
|
||||
IConsoleVarExec(var, t_index, &tokens[1]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
IConsoleError("command or variable not found");
|
||||
IConsoleError("command or variable not found");
|
||||
}
|
||||
|
|
|
@ -191,8 +191,9 @@ DEF_CONSOLE_CMD(ConSave)
|
|||
|
||||
if (SaveOrLoad(buf, SL_SAVE) != SL_OK) {
|
||||
IConsolePrint(_icolour_err, "SaveMap failed");
|
||||
} else
|
||||
} else {
|
||||
IConsolePrintF(_icolour_def, "Map sucessfully saved to %s", buf);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -247,8 +248,9 @@ DEF_CONSOLE_CMD(ConLoad)
|
|||
} break;
|
||||
default: IConsolePrintF(_icolour_err, "%s: Not a savegame.", file);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
|
||||
}
|
||||
|
||||
FiosFreeSavegameList();
|
||||
return true;
|
||||
|
@ -272,8 +274,9 @@ DEF_CONSOLE_CMD(ConRemove)
|
|||
if (item != NULL) {
|
||||
if (!FiosDelete(item->name))
|
||||
IConsolePrintF(_icolour_err, "%s: Failed to delete file", file);
|
||||
} else
|
||||
} else {
|
||||
IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
|
||||
}
|
||||
|
||||
FiosFreeSavegameList();
|
||||
return true;
|
||||
|
@ -323,8 +326,9 @@ DEF_CONSOLE_CMD(ConChangeDirectory)
|
|||
break;
|
||||
default: IConsolePrintF(_icolour_err, "%s: Not a directory.", file);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
|
||||
}
|
||||
|
||||
FiosFreeSavegameList();
|
||||
return true;
|
||||
|
@ -408,8 +412,9 @@ DEF_CONSOLE_CMD(ConBan)
|
|||
banip = inet_ntoa(*(struct in_addr *)&ci->client_ip);
|
||||
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
|
||||
IConsolePrint(_icolour_def, "Client banned");
|
||||
} else
|
||||
} else {
|
||||
IConsolePrint(_icolour_def, "Client not online, banned IP");
|
||||
}
|
||||
|
||||
/* Add user to ban-list */
|
||||
for (index = 0; index < lengthof(_network_ban_list); index++) {
|
||||
|
@ -481,8 +486,9 @@ DEF_CONSOLE_CMD(ConPauseGame)
|
|||
if (_pause == 0) {
|
||||
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
|
||||
IConsolePrint(_icolour_def, "Game paused.");
|
||||
} else
|
||||
} else {
|
||||
IConsolePrint(_icolour_def, "Game is already paused.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -497,8 +503,9 @@ DEF_CONSOLE_CMD(ConUnPauseGame)
|
|||
if (_pause != 0) {
|
||||
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
|
||||
IConsolePrint(_icolour_def, "Game unpaused.");
|
||||
} else
|
||||
} else {
|
||||
IConsolePrint(_icolour_def, "Game is already unpaused.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -519,8 +526,16 @@ DEF_CONSOLE_CMD(ConRcon)
|
|||
|
||||
DEF_CONSOLE_CMD(ConStatus)
|
||||
{
|
||||
static const char *stat_str[] = {"inactive", "authorized", "waiting", "loading map", "map done", "ready", "active"};
|
||||
const char *status;
|
||||
static const char* const stat_str[] = {
|
||||
"inactive",
|
||||
"authorized",
|
||||
"waiting",
|
||||
"loading map",
|
||||
"map done",
|
||||
"ready",
|
||||
"active"
|
||||
};
|
||||
|
||||
const NetworkClientState *cs;
|
||||
|
||||
if (argc == 0) {
|
||||
|
@ -531,8 +546,9 @@ DEF_CONSOLE_CMD(ConStatus)
|
|||
FOR_ALL_CLIENTS(cs) {
|
||||
int lag = NetworkCalculateLag(cs);
|
||||
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
|
||||
const char* status;
|
||||
|
||||
status = (cs->status <= STATUS_ACTIVE) ? stat_str[cs->status] : "unknown";
|
||||
status = (cs->status <= lengthof(stat_str) ? stat_str[cs->status] : "unknown");
|
||||
IConsolePrintF(8, "Client #%1d name: '%s' status: '%s' frame-lag: %3d company: %1d IP: %s unique-id: '%s'",
|
||||
cs->index, ci->client_name, status, lag, ci->client_playas, GetPlayerIP(ci), ci->unique_id);
|
||||
}
|
||||
|
@ -558,7 +574,8 @@ DEF_CONSOLE_CMD(ConServerInfo)
|
|||
return true;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_HOOK(ConHookValidateMaxClientsCount) {
|
||||
DEF_CONSOLE_HOOK(ConHookValidateMaxClientsCount)
|
||||
{
|
||||
/* XXX - hardcoded, string limiation -- TrueLight
|
||||
* XXX - also see network.c:NetworkStartup ~1356 */
|
||||
if (_network_game_info.clients_max > 10) {
|
||||
|
@ -569,7 +586,8 @@ DEF_CONSOLE_HOOK(ConHookValidateMaxClientsCount) {
|
|||
return true;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_HOOK(ConHookValidateMaxCompaniesCount) {
|
||||
DEF_CONSOLE_HOOK(ConHookValidateMaxCompaniesCount)
|
||||
{
|
||||
if (_network_game_info.companies_max > MAX_PLAYERS) {
|
||||
_network_game_info.companies_max = MAX_PLAYERS;
|
||||
IConsoleError("Maximum companies out of bounds, truncating to limit.");
|
||||
|
@ -578,7 +596,8 @@ DEF_CONSOLE_HOOK(ConHookValidateMaxCompaniesCount) {
|
|||
return true;
|
||||
}
|
||||
|
||||
DEF_CONSOLE_HOOK(ConHookValidateMaxSpectatorsCount) {
|
||||
DEF_CONSOLE_HOOK(ConHookValidateMaxSpectatorsCount)
|
||||
{
|
||||
/* XXX @see ConHookValidateMaxClientsCount */
|
||||
if (_network_game_info.spectators_max > 10) {
|
||||
_network_game_info.spectators_max = 10;
|
||||
|
@ -621,8 +640,9 @@ DEF_CONSOLE_CMD(ConKick)
|
|||
|
||||
if (ci != NULL) {
|
||||
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
|
||||
} else
|
||||
} else {
|
||||
IConsoleError("Client not found");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -974,7 +994,9 @@ DEF_CONSOLE_CMD(ConDebugLevel)
|
|||
|
||||
if (argc == 1) {
|
||||
IConsolePrintF(_icolour_def, "Current debug-level: '%s'", GetDebugString());
|
||||
} else SetDebugString(argv[1]);
|
||||
} else {
|
||||
SetDebugString(argv[1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1126,8 +1148,9 @@ DEF_CONSOLE_CMD(ConSay)
|
|||
|
||||
if (!_network_server) {
|
||||
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0 /* param does not matter */, argv[1]);
|
||||
} else
|
||||
} else {
|
||||
NetworkServer_HandleChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, argv[1], NETWORK_SERVER_INDEX);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1176,8 +1199,9 @@ DEF_CONSOLE_CMD(ConSayPlayer)
|
|||
|
||||
if (!_network_server) {
|
||||
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2]);
|
||||
} else
|
||||
} else {
|
||||
NetworkServer_HandleChat(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2], NETWORK_SERVER_INDEX);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1194,8 +1218,9 @@ DEF_CONSOLE_CMD(ConSayClient)
|
|||
|
||||
if (!_network_server) {
|
||||
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2]);
|
||||
} else
|
||||
} else {
|
||||
NetworkServer_HandleChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2], NETWORK_SERVER_INDEX);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1314,8 +1339,9 @@ DEF_CONSOLE_CMD(ConPatch)
|
|||
|
||||
if (argc == 2) {
|
||||
IConsoleGetPatchSetting(argv[1]);
|
||||
} else
|
||||
} else {
|
||||
IConsoleSetPatchSetting(argv[1], argv[2]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
6
depot.c
6
depot.c
|
@ -41,8 +41,7 @@ Depot *GetDepotByTile(TileIndex tile)
|
|||
Depot *depot;
|
||||
|
||||
FOR_ALL_DEPOTS(depot) {
|
||||
if (depot->xy == tile)
|
||||
return depot;
|
||||
if (depot->xy == tile) return depot;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -67,8 +66,7 @@ Depot *AllocateDepot(void)
|
|||
}
|
||||
|
||||
/* Check if we can add a block to the pool */
|
||||
if (AddBlockToPool(&_depot_pool))
|
||||
return AllocateDepot();
|
||||
if (AddBlockToPool(&_depot_pool)) return AllocateDepot();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
27
depot.h
27
depot.h
|
@ -90,21 +90,20 @@ static inline bool IsTileDepotType(TileIndex tile, TransportType type)
|
|||
|
||||
|
||||
/**
|
||||
Find out if the slope of the tile is suitable to build a depot of given direction
|
||||
@param direction The direction in which the depot's exit points. Starts with 0 as NE and goes Clockwise
|
||||
@param tileh The slope of the tile in question
|
||||
@return true if the construction is possible
|
||||
* Find out if the slope of the tile is suitable to build a depot of given direction
|
||||
* @param direction The direction in which the depot's exit points. Starts with 0 as NE and goes Clockwise
|
||||
* @param tileh The slope of the tile in question
|
||||
* @return true if the construction is possible
|
||||
|
||||
|
||||
This is checked by the ugly 0x4C >> direction magic, which does the following:
|
||||
0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
|
||||
So: for direction (only the significant bits are shown)<p>
|
||||
00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
|
||||
01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
|
||||
02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
|
||||
03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
|
||||
So ((0x4C >> p2) & tileh) determines whether the depot can be built on the current tileh
|
||||
*/
|
||||
* This is checked by the ugly 0x4C >> direction magic, which does the following:
|
||||
* 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
|
||||
* So: for direction (only the significant bits are shown)<p>
|
||||
* 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
|
||||
* 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
|
||||
* 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
|
||||
* 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
|
||||
* So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
|
||||
*/
|
||||
static inline bool CanBuildDepotByTileh(uint32 direction, Slope tileh)
|
||||
{
|
||||
return ((0x4C >> direction) & tileh) != 0;
|
||||
|
|
|
@ -599,8 +599,9 @@ static void DisasterTick_4(Vehicle *v)
|
|||
} while (tile != tile_org);
|
||||
v->dest_tile = tile;
|
||||
v->age = 0;
|
||||
} else
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// The plane which will shoot down the UFO
|
||||
|
@ -664,8 +665,7 @@ static void DisasterTick_5_and_6(Vehicle *v)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(v->tick_counter&1))
|
||||
return;
|
||||
if (!(v->tick_counter & 1)) return;
|
||||
|
||||
tile = v->tile + TileOffsByDir(DirToDiagDir(v->direction));
|
||||
if (IsValidTile(tile) &&
|
||||
|
@ -715,11 +715,9 @@ static void Disaster0_Init(void)
|
|||
Station *st;
|
||||
int x;
|
||||
|
||||
if (v == NULL)
|
||||
return;
|
||||
if (v == NULL) return;
|
||||
|
||||
/* Pick a random place, unless we find
|
||||
a small airport */
|
||||
/* Pick a random place, unless we find a small airport */
|
||||
x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
|
||||
|
||||
FOR_ALL_STATIONS(st) {
|
||||
|
@ -747,8 +745,7 @@ static void Disaster1_Init(void)
|
|||
Vehicle *v = ForceAllocateSpecialVehicle(), *u;
|
||||
int x;
|
||||
|
||||
if (v == NULL)
|
||||
return;
|
||||
if (v == NULL) return;
|
||||
|
||||
x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
|
||||
|
||||
|
@ -776,17 +773,15 @@ static void Disaster2_Init(void)
|
|||
FOR_ALL_INDUSTRIES(i) {
|
||||
if (i->xy != 0 &&
|
||||
i->type == IT_OIL_REFINERY &&
|
||||
(found==NULL || CHANCE16(1,2))) {
|
||||
(found == NULL || CHANCE16(1, 2))) {
|
||||
found = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == NULL)
|
||||
return;
|
||||
if (found == NULL) return;
|
||||
|
||||
v = ForceAllocateSpecialVehicle();
|
||||
if (v == NULL)
|
||||
return;
|
||||
if (v == NULL) return;
|
||||
|
||||
x = (MapSizeX() + 9) * TILE_SIZE - 1;
|
||||
y = TileY(found->xy) * TILE_SIZE + 37;
|
||||
|
@ -817,12 +812,10 @@ static void Disaster3_Init(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (found == NULL)
|
||||
return;
|
||||
if (found == NULL) return;
|
||||
|
||||
v = ForceAllocateSpecialVehicle();
|
||||
if (v == NULL)
|
||||
return;
|
||||
if (v == NULL) return;
|
||||
|
||||
x = -16 * TILE_SIZE;
|
||||
y = TileY(found->xy) * TILE_SIZE + 37;
|
||||
|
|
61
economy.c
61
economy.c
|
@ -32,16 +32,16 @@
|
|||
|
||||
// Score info
|
||||
const ScoreInfo _score_info[] = {
|
||||
{SCORE_VEHICLES, 120, 100},
|
||||
{SCORE_STATIONS, 80, 100},
|
||||
{SCORE_MIN_PROFIT, 10000, 100},
|
||||
{SCORE_MIN_INCOME, 50000, 50},
|
||||
{SCORE_MAX_INCOME, 100000, 100},
|
||||
{SCORE_DELIVERED, 40000, 400},
|
||||
{SCORE_CARGO, 8, 50},
|
||||
{SCORE_MONEY, 10000000, 50},
|
||||
{SCORE_LOAN, 250000, 50},
|
||||
{SCORE_TOTAL, 0, 0}
|
||||
{ SCORE_VEHICLES, 120, 100 },
|
||||
{ SCORE_STATIONS, 80, 100 },
|
||||
{ SCORE_MIN_PROFIT, 10000, 100 },
|
||||
{ SCORE_MIN_INCOME, 50000, 50 },
|
||||
{ SCORE_MAX_INCOME, 100000, 100 },
|
||||
{ SCORE_DELIVERED, 40000, 400 },
|
||||
{ SCORE_CARGO, 8, 50 },
|
||||
{ SCORE_MONEY, 10000000, 50 },
|
||||
{ SCORE_LOAN, 250000, 50 },
|
||||
{ SCORE_TOTAL, 0, 0 }
|
||||
};
|
||||
|
||||
int _score_part[MAX_PLAYERS][NUM_SCORE];
|
||||
|
@ -102,8 +102,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
|||
uint num = 0;
|
||||
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->owner != owner)
|
||||
continue;
|
||||
if (v->owner != owner) continue;
|
||||
if ((v->type == VEH_Train && IsFrontEngine(v)) ||
|
||||
v->type == VEH_Road ||
|
||||
(v->type == VEH_Aircraft && v->subtype <= 2) ||
|
||||
|
@ -114,8 +113,9 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
|||
if (min_profit_first == true) {
|
||||
min_profit = v->profit_last_year;
|
||||
min_profit_first = false;
|
||||
} else if (min_profit > v->profit_last_year)
|
||||
} else if (min_profit > v->profit_last_year) {
|
||||
min_profit = v->profit_last_year;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,10 +229,10 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
|||
}
|
||||
|
||||
if (update) {
|
||||
p->old_economy[0].performance_history = score;
|
||||
UpdateCompanyHQ(p, score);
|
||||
p->old_economy[0].company_value = CalculateCompanyValue(p);
|
||||
}
|
||||
p->old_economy[0].performance_history = score;
|
||||
UpdateCompanyHQ(p, score);
|
||||
p->old_economy[0].company_value = CalculateCompanyValue(p);
|
||||
}
|
||||
|
||||
InvalidateWindow(WC_PERFORMANCE_DETAIL, 0);
|
||||
return score;
|
||||
|
@ -249,8 +249,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
|||
|
||||
for (s = _subsidies; s != endof(_subsidies); s++) {
|
||||
if (s->cargo_type != CT_INVALID && s->age >= 12) {
|
||||
if (GetStation(s->to)->owner == old_player)
|
||||
s->cargo_type = CT_INVALID;
|
||||
if (GetStation(s->to)->owner == old_player) s->cargo_type = CT_INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -290,18 +289,10 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
|||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->owner == new_player) {
|
||||
switch (v->type) {
|
||||
case VEH_Train:
|
||||
if (IsFrontEngine(v)) num_train++;
|
||||
break;
|
||||
case VEH_Road:
|
||||
num_road++;
|
||||
break;
|
||||
case VEH_Ship:
|
||||
num_ship++;
|
||||
break;
|
||||
case VEH_Aircraft:
|
||||
if (v->subtype <= 2) num_aircraft++;
|
||||
break;
|
||||
case VEH_Train: if (IsFrontEngine(v)) num_train++; break;
|
||||
case VEH_Road: num_road++; break;
|
||||
case VEH_Ship: num_ship++; break;
|
||||
case VEH_Aircraft: if (v->subtype <= 2) num_aircraft++; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -339,8 +330,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
|||
if (new_player != OWNER_SPECTATOR) {
|
||||
Window *w;
|
||||
for (w = _windows; w != _last_window; w++) {
|
||||
if (w->caption_color == old_player)
|
||||
w->caption_color = new_player;
|
||||
if (w->caption_color == old_player) w->caption_color = new_player;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -352,8 +342,9 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
|||
FOR_ALL_PLAYERS(p) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
/* 'Sell' the share if this player has any */
|
||||
if (p->share_owners[i] == _current_player)
|
||||
if (p->share_owners[i] == _current_player) {
|
||||
p->share_owners[i] = OWNER_SPECTATOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
p = GetPlayer(_current_player);
|
||||
|
@ -1211,7 +1202,7 @@ static int32 DeliverGoods(int num_pieces, CargoID cargo_type, StationID source,
|
|||
Station *s_from, *s_to;
|
||||
int32 profit;
|
||||
|
||||
assert(num_pieces > 0);
|
||||
assert(num_pieces > 0);
|
||||
|
||||
// Update player statistics
|
||||
{
|
||||
|
|
32
economy.h
32
economy.h
|
@ -30,27 +30,27 @@ typedef struct Subsidy {
|
|||
|
||||
|
||||
enum {
|
||||
SCORE_VEHICLES = 0,
|
||||
SCORE_STATIONS = 1,
|
||||
SCORE_MIN_PROFIT = 2,
|
||||
SCORE_MIN_INCOME = 3,
|
||||
SCORE_MAX_INCOME = 4,
|
||||
SCORE_DELIVERED = 5,
|
||||
SCORE_CARGO = 6,
|
||||
SCORE_MONEY = 7,
|
||||
SCORE_LOAN = 8,
|
||||
SCORE_TOTAL = 9, // This must always be the last entry
|
||||
SCORE_VEHICLES = 0,
|
||||
SCORE_STATIONS = 1,
|
||||
SCORE_MIN_PROFIT = 2,
|
||||
SCORE_MIN_INCOME = 3,
|
||||
SCORE_MAX_INCOME = 4,
|
||||
SCORE_DELIVERED = 5,
|
||||
SCORE_CARGO = 6,
|
||||
SCORE_MONEY = 7,
|
||||
SCORE_LOAN = 8,
|
||||
SCORE_TOTAL = 9, // This must always be the last entry
|
||||
|
||||
NUM_SCORE = 10, // How many scores are there..
|
||||
NUM_SCORE = 10, // How many scores are there..
|
||||
|
||||
SCORE_MAX = 1000, // The max score that can be in the performance history
|
||||
// the scores together of score_info is allowed to be more!
|
||||
SCORE_MAX = 1000 // The max score that can be in the performance history
|
||||
// the scores together of score_info is allowed to be more!
|
||||
};
|
||||
|
||||
typedef struct ScoreInfo {
|
||||
byte id; // Unique ID of the score
|
||||
int needed; // How much you need to get the perfect score
|
||||
int score; // How much score it will give
|
||||
byte id; // Unique ID of the score
|
||||
int needed; // How much you need to get the perfect score
|
||||
int score; // How much score it will give
|
||||
} ScoreInfo;
|
||||
|
||||
extern const ScoreInfo _score_info[];
|
||||
|
|
30
elrail.c
30
elrail.c
|
@ -84,6 +84,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
|||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case MP_TUNNELBRIDGE:
|
||||
if (IsTunnel(t)) {
|
||||
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
||||
|
@ -104,15 +105,18 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
|||
return DiagDirToAxis(GetBridgeRampDirection(t)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y;
|
||||
}
|
||||
}
|
||||
|
||||
case MP_STREET:
|
||||
if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return 0;
|
||||
if (GetRailTypeCrossing(t) != RAILTYPE_ELECTRIC) return 0;
|
||||
return GetCrossingRailBits(t);
|
||||
|
||||
case MP_STATION:
|
||||
if (!IsRailwayStation(t)) return 0;
|
||||
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
||||
if (!IsStationTileElectrifiable(t)) return 0;
|
||||
return TrackToTrackBits(GetRailStationTrack(t));
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
@ -124,17 +128,22 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
|||
*/
|
||||
static void AdjustTileh(TileIndex tile, Slope* tileh)
|
||||
{
|
||||
if (IsTunnelTile(tile)) *tileh = SLOPE_FLAT;
|
||||
if (IsBridgeTile(tile) && IsBridgeRamp(tile)) {
|
||||
if (*tileh != SLOPE_FLAT) {
|
||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||
if (IsTunnel(tile)) {
|
||||
*tileh = SLOPE_FLAT;
|
||||
} else {
|
||||
switch (GetBridgeRampDirection(tile)) {
|
||||
case DIAGDIR_NE: *tileh = SLOPE_NE; break;
|
||||
case DIAGDIR_SE: *tileh = SLOPE_SE; break;
|
||||
case DIAGDIR_SW: *tileh = SLOPE_SW; break;
|
||||
case DIAGDIR_NW: *tileh = SLOPE_NW; break;
|
||||
default: break;
|
||||
if (IsBridgeRamp(tile)) {
|
||||
if (*tileh != SLOPE_FLAT) {
|
||||
*tileh = SLOPE_FLAT;
|
||||
} else {
|
||||
switch (GetBridgeRampDirection(tile)) {
|
||||
case DIAGDIR_NE: *tileh = SLOPE_NE; break;
|
||||
case DIAGDIR_SE: *tileh = SLOPE_SE; break;
|
||||
case DIAGDIR_SW: *tileh = SLOPE_SW; break;
|
||||
case DIAGDIR_NW: *tileh = SLOPE_NW; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,11 +255,12 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
|||
In that case, we try the any of the allowed ones. if they don't exist either, don't draw
|
||||
anything. Note that the preferred PPPs still contain the end-of-line markers.
|
||||
Remove those (simply by ANDing with allowed, since these markers are never allowed) */
|
||||
if ( (PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i];
|
||||
if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i];
|
||||
|
||||
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
|
||||
for (k = 0; k < DIR_END; k++) {
|
||||
byte temp = PPPorder[i][GetTLG(ti->tile)][k];
|
||||
|
||||
if (HASBIT(PPPallowed[i], temp)) {
|
||||
uint x = ti->x + x_pcp_offsets[i] + x_ppp_offsets[temp];
|
||||
uint y = ti->y + y_pcp_offsets[i] + y_ppp_offsets[temp];
|
||||
|
|
2
engine.c
2
engine.c
|
@ -249,7 +249,7 @@ void EnginesDailyLoop(void)
|
|||
DeleteWindowById(WC_ENGINE_PREVIEW, i);
|
||||
e->preview_player++;
|
||||
}
|
||||
} else if (e->preview_player != 0xFF) {
|
||||
} else if (e->preview_player != 0xFF) {
|
||||
PlayerID best_player = GetBestPlayer(e->preview_player);
|
||||
|
||||
if (best_player == OWNER_SPECTATOR) {
|
||||
|
|
4
engine.h
4
engine.h
|
@ -159,8 +159,8 @@ VARDEF Engine _engines[TOTAL_NUM_ENGINES];
|
|||
|
||||
static inline Engine* GetEngine(EngineID i)
|
||||
{
|
||||
assert(i < lengthof(_engines));
|
||||
return &_engines[i];
|
||||
assert(i < lengthof(_engines));
|
||||
return &_engines[i];
|
||||
}
|
||||
|
||||
VARDEF StringID _engine_name_strings[TOTAL_NUM_ENGINES];
|
||||
|
|
4
fileio.c
4
fileio.c
|
@ -133,9 +133,9 @@ bool FiosCheckFileExists(const char *filename)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (f == NULL)
|
||||
if (f == NULL) {
|
||||
return false;
|
||||
else {
|
||||
} else {
|
||||
fclose(f);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -315,8 +315,8 @@ static int32 ClearTile_Industry(TileIndex tile, byte flags)
|
|||
*/
|
||||
if ((_current_player != OWNER_WATER && _game_mode != GM_EDITOR &&
|
||||
!_cheats.magic_bulldozer.value) ||
|
||||
(_current_player == OWNER_WATER && i->type == IT_OIL_RIG) ) {
|
||||
SetDParam(0, STR_4802_COAL_MINE + i->type);
|
||||
(_current_player == OWNER_WATER && i->type == IT_OIL_RIG)) {
|
||||
SetDParam(0, STR_4802_COAL_MINE + i->type);
|
||||
return_cmd_error(STR_4800_IN_THE_WAY);
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ static inline void ResetIndustryConstructionStage(TileIndex tile)
|
|||
typedef struct IndustryTypeSolver {
|
||||
IndustryGfx MinGfx;
|
||||
IndustryGfx MaxGfx;
|
||||
} IndustryTypeSolver;
|
||||
} IndustryTypeSolver;
|
||||
|
||||
static const IndustryTypeSolver industry_gfx_Solver [IT_END] = {
|
||||
{ 0, 6}, //IT_COAL_MINE
|
||||
|
|
|
@ -87,8 +87,9 @@ static void SelectGameWndProc(Window *w, WindowEvent *e)
|
|||
#ifdef ENABLE_NETWORK
|
||||
if (!_network_available) {
|
||||
ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||
} else
|
||||
} else {
|
||||
ShowNetworkGameWindow();
|
||||
}
|
||||
#else
|
||||
ShowErrorMessage(INVALID_STRING_ID ,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||
#endif
|
||||
|
|
|
@ -90,10 +90,11 @@ void HandleOnEditText(WindowEvent *e)
|
|||
// Inform the player of this action
|
||||
snprintf(msg, sizeof(msg), "%d", money);
|
||||
|
||||
if (!_network_server)
|
||||
if (!_network_server) {
|
||||
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_PLAYER, id + 1, msg);
|
||||
else
|
||||
} else {
|
||||
NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_PLAYER, id + 1, msg, NETWORK_SERVER_INDEX);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4: /* Game-Password and Company-Password */
|
||||
|
@ -2273,7 +2274,8 @@ static WindowDesc _main_status_desc = {
|
|||
|
||||
extern void UpdateAllStationVirtCoord(void);
|
||||
|
||||
static void MainWindowWndProc(Window *w, WindowEvent *e) {
|
||||
static void MainWindowWndProc(Window* w, WindowEvent* e)
|
||||
{
|
||||
int off_x;
|
||||
|
||||
switch (e->event) {
|
||||
|
|
|
@ -146,8 +146,9 @@ int32 CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
DeleteName(p->name_1);
|
||||
p->name_1 = str;
|
||||
MarkWholeScreenDirty();
|
||||
} else
|
||||
} else {
|
||||
DeleteName(str);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -180,8 +181,9 @@ int32 CmdChangePresidentName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
DoCommand(0, 0, 0, DC_EXEC, CMD_CHANGE_COMPANY_NAME);
|
||||
}
|
||||
MarkWholeScreenDirty();
|
||||
} else
|
||||
} else {
|
||||
DeleteName(str);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -269,8 +271,9 @@ int32 CmdChangeDifficultyLevel(TileIndex tile, uint32 flags, uint32 p1, uint32 p
|
|||
if (p1 != (uint32)-1L) {
|
||||
((int*)&_opt_ptr->diff)[p1] = p2;
|
||||
_opt_ptr->diff_level = 3; // custom difficulty level
|
||||
} else
|
||||
} else {
|
||||
_opt_ptr->diff_level = p2;
|
||||
}
|
||||
|
||||
/* If we are a network-client, update the difficult setting (if it is open).
|
||||
* Use this instead of just dirtying the window because we need to load in
|
||||
|
|
19
misc_gui.c
19
misc_gui.c
|
@ -915,13 +915,14 @@ int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we)
|
|||
case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME:
|
||||
if (MoveTextBufferPos(&string->text, we->keypress.keycode))
|
||||
InvalidateWidget(w, wid);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
if (IsValidAsciiChar(we->keypress.ascii)) {
|
||||
if (InsertTextBufferChar(&string->text, we->keypress.ascii))
|
||||
InvalidateWidget(w, wid);
|
||||
} else // key wasn't caught
|
||||
} else { // key wasn't caught
|
||||
we->keypress.cont = true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1507,8 +1508,7 @@ static void SelectScenarioWndProc(Window* w, WindowEvent* e)
|
|||
const int list_start = 45;
|
||||
|
||||
switch (e->event) {
|
||||
case WE_PAINT:
|
||||
{
|
||||
case WE_PAINT: {
|
||||
int y,pos;
|
||||
const FiosItem *item;
|
||||
|
||||
|
@ -1556,15 +1556,14 @@ static void SelectScenarioWndProc(Window* w, WindowEvent* e)
|
|||
break;
|
||||
|
||||
case 6: /* Click the listbox */
|
||||
if (e->click.pt.y < list_start)
|
||||
if (e->click.pt.y < list_start) {
|
||||
GenRandomNewGame(Random(), InteractiveRandom());
|
||||
else {
|
||||
char *name;
|
||||
} else {
|
||||
int y = (e->click.pt.y - list_start) / 10;
|
||||
const char* name;
|
||||
const FiosItem *file;
|
||||
|
||||
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count)
|
||||
return;
|
||||
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) return;
|
||||
|
||||
file = _fios_list + y;
|
||||
|
||||
|
@ -1578,8 +1577,6 @@ static void SelectScenarioWndProc(Window* w, WindowEvent* e)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case WE_DESTROY:
|
||||
break;
|
||||
|
||||
case WE_RESIZE: {
|
||||
/* Widget 3 and 4 have to go with halve speed, make it so obiwan */
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
/*
|
||||
* qtmidi.h
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef MUSIC_MACOSX_QUICKTIME_H
|
||||
#define MUSIC_MACOSX_QUICKTIME_H
|
||||
|
|
21
namegen.c
21
namegen.c
|
@ -279,11 +279,10 @@ static byte MakeFinnishTownName(char *buf, uint32 seed)
|
|||
// Select randomly if town name should consists of one or two parts.
|
||||
if (SeedChance(0, 15, seed) >= 10) {
|
||||
strcat(buf, name_finnish_real[SeedChance( 2, lengthof(name_finnish_real), seed)]);
|
||||
}
|
||||
// A two-part name by combining one of name_finnish_1 + "la"/"lä"
|
||||
// The reason for not having the contents of name_finnish_{1,2} in the same table is
|
||||
// that the ones in name_finnish_2 are not good for this purpose.
|
||||
else if (SeedChance(0, 15, seed) >= 5) {
|
||||
} else if (SeedChance(0, 15, seed) >= 5) {
|
||||
// A two-part name by combining one of name_finnish_1 + "la"/"lä"
|
||||
// The reason for not having the contents of name_finnish_{1,2} in the same table is
|
||||
// that the ones in name_finnish_2 are not good for this purpose.
|
||||
uint sel = SeedChance( 0, lengthof(name_finnish_1), seed);
|
||||
char *last;
|
||||
strcat(buf, name_finnish_1[sel]);
|
||||
|
@ -297,10 +296,9 @@ static byte MakeFinnishTownName(char *buf, uint32 seed)
|
|||
} else {
|
||||
strcat(buf, "lä");
|
||||
}
|
||||
}
|
||||
// A two-part name by combining one of name_finnish_{1,2} + name_finnish_3.
|
||||
// Why aren't name_finnish_{1,2} just one table? See above.
|
||||
else {
|
||||
} else {
|
||||
// A two-part name by combining one of name_finnish_{1,2} + name_finnish_3.
|
||||
// Why aren't name_finnish_{1,2} just one table? See above.
|
||||
uint sel = SeedChance(2,
|
||||
lengthof(name_finnish_1) + lengthof(name_finnish_2), seed);
|
||||
if (sel >= lengthof(name_finnish_1)) {
|
||||
|
@ -424,10 +422,11 @@ static byte MakeCzechTownName(char *buf, uint32 seed)
|
|||
// Always drop a postfix.
|
||||
postfix += lengthof(name_czech_subst_postfix);
|
||||
}
|
||||
if (postfix < lengthof(name_czech_subst_postfix))
|
||||
if (postfix < lengthof(name_czech_subst_postfix)) {
|
||||
choose |= CZC_POSTFIX;
|
||||
else
|
||||
} else {
|
||||
choose |= CZC_NOPOSTFIX;
|
||||
}
|
||||
|
||||
// Localize the array segment containing a good gender
|
||||
for (ending = 0; ending < (int) lengthof(name_czech_subst_ending); ending++) {
|
||||
|
|
123
network.c
123
network.c
|
@ -54,9 +54,9 @@ NetworkClientInfo *NetworkFindClientInfoFromIndex(uint16 client_index)
|
|||
{
|
||||
NetworkClientInfo *ci;
|
||||
|
||||
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++)
|
||||
if (ci->client_index == client_index)
|
||||
return ci;
|
||||
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) {
|
||||
if (ci->client_index == client_index) return ci;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ NetworkClientState *NetworkFindClientStateFromIndex(uint16 client_index)
|
|||
{
|
||||
NetworkClientState *cs;
|
||||
|
||||
for (cs = _clients; cs != &_clients[MAX_CLIENT_INFO]; cs++)
|
||||
if (cs->index == client_index)
|
||||
return cs;
|
||||
for (cs = _clients; cs != &_clients[MAX_CLIENT_INFO]; cs++) {
|
||||
if (cs->index == client_index) return cs;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -93,10 +93,12 @@ NetworkClientState *NetworkFindClientStateFromIndex(uint16 client_index)
|
|||
void NetworkGetClientName(char *client_name, size_t size, const NetworkClientState *cs)
|
||||
{
|
||||
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs);
|
||||
if (*ci->client_name == '\0')
|
||||
|
||||
if (ci->client_name[0] == '\0') {
|
||||
snprintf(client_name, size, "Client #%4d", cs->index);
|
||||
else
|
||||
} else {
|
||||
ttd_strlcpy(client_name, ci->client_name, size);
|
||||
}
|
||||
}
|
||||
|
||||
byte NetworkSpectatorCount(void)
|
||||
|
@ -218,7 +220,8 @@ static void ServerStartError(const char *error)
|
|||
NetworkError(STR_NETWORK_ERR_SERVER_START);
|
||||
}
|
||||
|
||||
static void NetworkClientError(byte res, NetworkClientState *cs) {
|
||||
static void NetworkClientError(byte res, NetworkClientState* cs)
|
||||
{
|
||||
// First, send a CLIENT_ERROR to the server, so he knows we are
|
||||
// disconnection (and why!)
|
||||
NetworkErrorCode errorno;
|
||||
|
@ -234,9 +237,9 @@ static void NetworkClientError(byte res, NetworkClientState *cs) {
|
|||
}
|
||||
|
||||
switch (res) {
|
||||
case NETWORK_RECV_STATUS_DESYNC: errorno = NETWORK_ERROR_DESYNC; break;
|
||||
case NETWORK_RECV_STATUS_DESYNC: errorno = NETWORK_ERROR_DESYNC; break;
|
||||
case NETWORK_RECV_STATUS_SAVEGAME: errorno = NETWORK_ERROR_SAVEGAME_FAILED; break;
|
||||
default: errorno = NETWORK_ERROR_GENERAL;
|
||||
default: errorno = NETWORK_ERROR_GENERAL; break;
|
||||
}
|
||||
// This means we fucked up and the server closed the connection
|
||||
if (res != NETWORK_RECV_STATUS_SERVER_ERROR && res != NETWORK_RECV_STATUS_SERVER_FULL &&
|
||||
|
@ -254,7 +257,7 @@ static void NetworkClientError(byte res, NetworkClientState *cs) {
|
|||
|
||||
/** Retrieve a string representation of an internal error number
|
||||
* @param buf buffer where the error message will be stored
|
||||
* @param err NetworkErrorCode (integer)
|
||||
* @param err NetworkErrorCode
|
||||
* @return returns a pointer to the error message (buf) */
|
||||
char *GetNetworkErrorMsg(char *buf, NetworkErrorCode err)
|
||||
{
|
||||
|
@ -274,7 +277,7 @@ char *GetNetworkErrorMsg(char *buf, NetworkErrorCode err)
|
|||
STR_NETWORK_ERR_CLIENT_PLAYER_MISMATCH,
|
||||
STR_NETWORK_ERR_CLIENT_KICKED,
|
||||
STR_NETWORK_ERR_CLIENT_CHEATER,
|
||||
STR_NETWORK_ERR_CLIENT_SERVER_FULL,
|
||||
STR_NETWORK_ERR_CLIENT_SERVER_FULL
|
||||
};
|
||||
|
||||
if (err >= lengthof(network_error_strings)) err = 0;
|
||||
|
@ -992,10 +995,11 @@ static void NetworkInitGameInfo(void)
|
|||
memset(ci, 0, sizeof(*ci));
|
||||
|
||||
ci->client_index = NETWORK_SERVER_INDEX;
|
||||
if (_network_dedicated)
|
||||
if (_network_dedicated) {
|
||||
ci->client_playas = OWNER_SPECTATOR;
|
||||
else
|
||||
} else {
|
||||
ci->client_playas = _local_player + 1;
|
||||
}
|
||||
ttd_strlcpy(ci->client_name, _network_player_name, sizeof(ci->client_name));
|
||||
ttd_strlcpy(ci->unique_id, _network_unique_id, sizeof(ci->unique_id));
|
||||
}
|
||||
|
@ -1127,23 +1131,26 @@ static bool NetworkReceive(void)
|
|||
if (n == -1 && !_network_server) NetworkError(STR_NETWORK_ERR_LOSTCONNECTION);
|
||||
|
||||
// accept clients..
|
||||
if (_network_server && FD_ISSET(_listensocket, &read_fd))
|
||||
if (_network_server && FD_ISSET(_listensocket, &read_fd)) {
|
||||
NetworkAcceptClients();
|
||||
}
|
||||
|
||||
// read stuff from clients
|
||||
FOR_ALL_CLIENTS(cs) {
|
||||
cs->writable = !!FD_ISSET(cs->socket, &write_fd);
|
||||
if (FD_ISSET(cs->socket, &read_fd)) {
|
||||
if (_network_server)
|
||||
if (_network_server) {
|
||||
NetworkServer_ReadPackets(cs);
|
||||
else {
|
||||
} else {
|
||||
byte res;
|
||||
|
||||
// The client already was quiting!
|
||||
if (cs->quited) return false;
|
||||
if ((res = NetworkClient_ReadPackets(cs)) != NETWORK_RECV_STATUS_OKAY) {
|
||||
|
||||
res = NetworkClient_ReadPackets(cs);
|
||||
if (res != NETWORK_RECV_STATUS_OKAY) {
|
||||
// The client made an error of which we can not recover
|
||||
// close the client and drop back to main menu
|
||||
|
||||
NetworkClientError(res, cs);
|
||||
return false;
|
||||
}
|
||||
|
@ -1336,38 +1343,40 @@ void NetworkStartUp(void)
|
|||
{
|
||||
DEBUG(net, 3) ("[NET][Core] Starting network...");
|
||||
|
||||
#if defined(__MORPHOS__) || defined(__AMIGA__)
|
||||
#if defined(__MORPHOS__) || defined(__AMIGA__)
|
||||
/*
|
||||
* IMPORTANT NOTE: SocketBase needs to be initialized before we use _any_
|
||||
* network related function, else: crash.
|
||||
*/
|
||||
{
|
||||
DEBUG(misc,3) ("[NET][Core] Loading bsd socket library");
|
||||
if (!(SocketBase = OpenLibrary("bsdsocket.library", 4))) {
|
||||
DEBUG(net, 0) ("[NET][Core] Error: couldn't open bsdsocket.library version 4. Network not available.");
|
||||
_network_available = false;
|
||||
return;
|
||||
}
|
||||
DEBUG(misc,3) ("[NET][Core] Loading bsd socket library");
|
||||
SocketBase = OpenLibrary("bsdsocket.library", 4);
|
||||
if (SocketBase == NULL) {
|
||||
DEBUG(net, 0) ("[NET][Core] Error: couldn't open bsdsocket.library version 4. Network not available.");
|
||||
_network_available = false;
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(__AMIGA__)
|
||||
// for usleep() implementation (only required for legacy AmigaOS builds)
|
||||
if ( (TimerPort = CreateMsgPort()) ) {
|
||||
if ( (TimerRequest = (struct timerequest *) CreateIORequest(TimerPort, sizeof(struct timerequest))) ) {
|
||||
if ( OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest *) TimerRequest, 0) == 0 ) {
|
||||
if ( !(TimerBase = TimerRequest->tr_node.io_Device) ) {
|
||||
// free ressources...
|
||||
DEBUG(net, 0) ("[NET][Core] Error: couldn't initialize timer. Network not available.");
|
||||
_network_available = false;
|
||||
return;
|
||||
}
|
||||
#if defined(__AMIGA__)
|
||||
// for usleep() implementation (only required for legacy AmigaOS builds)
|
||||
TimerPort = CreateMsgPort();
|
||||
if (TimerPort != NULL) {
|
||||
TimerRequest = (struct timerequest*)CreateIORequest(TimerPort, sizeof(struct timerequest);
|
||||
if (TimerRequest != NULL) {
|
||||
if (OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest*)TimerRequest, 0) == 0) {
|
||||
TimerBase = TimerRequest->tr_node.io_Device;
|
||||
if (TimerBase == NULL) {
|
||||
// free ressources...
|
||||
DEBUG(net, 0) ("[NET][Core] Error: couldn't initialize timer. Network not available.");
|
||||
_network_available = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // __AMIGA__
|
||||
}
|
||||
#endif // __MORPHOS__ / __AMIGA__
|
||||
#endif // __AMIGA__
|
||||
#endif // __MORPHOS__ / __AMIGA__
|
||||
|
||||
// Network is available
|
||||
// Network is available
|
||||
_network_available = true;
|
||||
_network_dedicated = false;
|
||||
_network_last_advertise_frame = 0;
|
||||
|
@ -1412,26 +1421,20 @@ void NetworkShutDown(void)
|
|||
|
||||
_network_available = false;
|
||||
|
||||
#if defined(__MORPHOS__) || defined(__AMIGA__)
|
||||
{
|
||||
// free allocated ressources
|
||||
#if defined(__AMIGA__)
|
||||
if (TimerBase) { CloseDevice((struct IORequest *) TimerRequest); }
|
||||
if (TimerRequest) { DeleteIORequest(TimerRequest); }
|
||||
if (TimerPort) { DeleteMsgPort(TimerPort); }
|
||||
#endif
|
||||
#if defined(__MORPHOS__) || defined(__AMIGA__)
|
||||
// free allocated ressources
|
||||
#if defined(__AMIGA__)
|
||||
if (TimerBase != NULL) CloseDevice((struct IORequest*)TimerRequest); // XXX This smells wrong
|
||||
if (TimerRequest != NULL) DeleteIORequest(TimerRequest);
|
||||
if (TimerPort != NULL) DeleteMsgPort(TimerPort);
|
||||
#endif
|
||||
|
||||
if (SocketBase) {
|
||||
CloseLibrary(SocketBase);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (SocketBase != NULL) CloseLibrary(SocketBase);
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
{
|
||||
WSACleanup();
|
||||
}
|
||||
#endif
|
||||
#if defined(WIN32)
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ENABLE_NETWORK */
|
||||
|
|
|
@ -178,8 +178,9 @@ bool NetworkSend_Packets(NetworkClientState *cs)
|
|||
cs->packet_queue = p->next;
|
||||
free(p);
|
||||
p = cs->packet_queue;
|
||||
} else
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -192,8 +193,7 @@ bool NetworkSend_Packets(NetworkClientState *cs)
|
|||
uint8 NetworkRecv_uint8(NetworkClientState *cs, Packet *packet)
|
||||
{
|
||||
/* Don't allow reading from a closed socket */
|
||||
if (cs->quited)
|
||||
return 0;
|
||||
if (cs->quited) return 0;
|
||||
|
||||
/* Check if variable is within packet-size */
|
||||
if (packet->pos + 1 > packet->size) {
|
||||
|
@ -209,8 +209,7 @@ uint16 NetworkRecv_uint16(NetworkClientState *cs, Packet *packet)
|
|||
uint16 n;
|
||||
|
||||
/* Don't allow reading from a closed socket */
|
||||
if (cs->quited)
|
||||
return 0;
|
||||
if (cs->quited) return 0;
|
||||
|
||||
/* Check if variable is within packet-size */
|
||||
if (packet->pos + 2 > packet->size) {
|
||||
|
@ -228,8 +227,7 @@ uint32 NetworkRecv_uint32(NetworkClientState *cs, Packet *packet)
|
|||
uint32 n;
|
||||
|
||||
/* Don't allow reading from a closed socket */
|
||||
if (cs->quited)
|
||||
return 0;
|
||||
if (cs->quited) return 0;
|
||||
|
||||
/* Check if variable is within packet-size */
|
||||
if (packet->pos + 4 > packet->size) {
|
||||
|
@ -249,8 +247,7 @@ uint64 NetworkRecv_uint64(NetworkClientState *cs, Packet *packet)
|
|||
uint64 n;
|
||||
|
||||
/* Don't allow reading from a closed socket */
|
||||
if (cs->quited)
|
||||
return 0;
|
||||
if (cs->quited) return 0;
|
||||
|
||||
/* Check if variable is within packet-size */
|
||||
if (packet->pos + 8 > packet->size) {
|
||||
|
@ -388,13 +385,13 @@ Packet *NetworkRecv_Packet(NetworkClientState *cs, NetworkRecvStatus *status)
|
|||
// Add a command to the local command queue
|
||||
void NetworkAddCommandQueue(NetworkClientState *cs, CommandPacket *cp)
|
||||
{
|
||||
CommandPacket *new_cp = malloc(sizeof(CommandPacket));
|
||||
CommandPacket* new_cp = malloc(sizeof(*new_cp));
|
||||
|
||||
*new_cp = *cp;
|
||||
|
||||
if (cs->command_queue == NULL)
|
||||
if (cs->command_queue == NULL) {
|
||||
cs->command_queue = new_cp;
|
||||
else {
|
||||
} else {
|
||||
CommandPacket *c = cs->command_queue;
|
||||
while (c->next != NULL) c = c->next;
|
||||
c->next = new_cp;
|
||||
|
@ -443,9 +440,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
|
|||
|
||||
// And we queue it for delivery to the clients
|
||||
FOR_ALL_CLIENTS(cs) {
|
||||
if (cs->status > STATUS_AUTH) {
|
||||
NetworkAddCommandQueue(cs, c);
|
||||
}
|
||||
if (cs->status > STATUS_AUTH) NetworkAddCommandQueue(cs, c);
|
||||
}
|
||||
|
||||
// Only the server gets the callback, because clients should not get them
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#ifdef ENABLE_NETWORK
|
||||
|
||||
//
|
||||
// This file handles the GameList
|
||||
// Also, it handles the request to a server for data about the server
|
||||
|
||||
|
@ -33,8 +32,11 @@ NetworkGameList *NetworkGameListAddItem(uint32 ip, uint16 port)
|
|||
item->ip = ip;
|
||||
item->port = port;
|
||||
|
||||
if (prev_item == NULL) {_network_game_list = item;}
|
||||
else {prev_item->next = item;}
|
||||
if (prev_item == NULL) {
|
||||
_network_game_list = item;
|
||||
} else {
|
||||
prev_item->next = item;
|
||||
}
|
||||
DEBUG(net, 4) ("[NET][GameList] Added server to list");
|
||||
|
||||
UpdateNetworkGameWindow(false);
|
||||
|
@ -51,8 +53,11 @@ void NetworkGameListRemoveItem(NetworkGameList *remove)
|
|||
prev_item = NULL;
|
||||
for (item = _network_game_list; item != NULL; item = item->next) {
|
||||
if (remove == item) {
|
||||
if (prev_item == NULL) {_network_game_list = remove->next;}
|
||||
else {prev_item->next = remove->next;}
|
||||
if (prev_item == NULL) {
|
||||
_network_game_list = remove->next;
|
||||
} else {
|
||||
prev_item->next = remove->next;
|
||||
}
|
||||
|
||||
free(remove);
|
||||
DEBUG(net, 4) ("[NET][GameList] Removed server from list");
|
||||
|
|
|
@ -628,8 +628,11 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
|
|||
if (item == nd->map || (pos == 0 && nd->map == NULL))
|
||||
GfxFillRect(11, y - 1, 258, y + 10, 155); // show highlighted item with a different colour
|
||||
|
||||
if (pos == 0) DrawString(14, y, STR_4010_GENERATE_RANDOM_NEW_GAME, 9);
|
||||
else DoDrawString(item->title, 14, y, _fios_colors[item->type] );
|
||||
if (pos == 0) {
|
||||
DrawString(14, y, STR_4010_GENERATE_RANDOM_NEW_GAME, 9);
|
||||
} else {
|
||||
DoDrawString(item->title, 14, y, _fios_colors[item->type] );
|
||||
}
|
||||
pos++;
|
||||
y += NSSWND_ROWSIZE;
|
||||
|
||||
|
@ -1262,7 +1265,9 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e)
|
|||
if (sel-- == 0) { // Selected item, highlight it
|
||||
GfxFillRect(1, y, 150 - 2, y + CLNWND_ROWSIZE - 1, 0);
|
||||
colour = 0xC;
|
||||
} else colour = 0x10;
|
||||
} else {
|
||||
colour = 0x10;
|
||||
}
|
||||
|
||||
DoDrawString(_clientlist_action[i], 4, y, colour);
|
||||
}
|
||||
|
@ -1320,8 +1325,9 @@ static void ClientListWndProc(Window *w, WindowEvent *e)
|
|||
if (_selected_clientlist_item == i++) { // Selected item, highlight it
|
||||
GfxFillRect(1, y, 248, y + CLNWND_ROWSIZE - 1, 0);
|
||||
colour = 0xC;
|
||||
} else
|
||||
} else {
|
||||
colour = 0x10;
|
||||
}
|
||||
|
||||
if (ci->client_index == NETWORK_SERVER_INDEX) {
|
||||
DrawString(4, y, STR_NETWORK_SERVER, colour);
|
||||
|
@ -1362,8 +1368,9 @@ static void ClientListWndProc(Window *w, WindowEvent *e)
|
|||
_selected_clientlist_y = e->mouseover.pt.y;
|
||||
if (e->mouseover.pt.y > CLNWND_OFFSET) {
|
||||
_selected_clientlist_item = (e->mouseover.pt.y - CLNWND_OFFSET) / CLNWND_ROWSIZE;
|
||||
} else
|
||||
} else {
|
||||
_selected_clientlist_item = 255;
|
||||
}
|
||||
|
||||
// Repaint
|
||||
SetWindowDirty(w);
|
||||
|
|
141
network_server.c
141
network_server.c
|
@ -84,8 +84,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
|
|||
NetworkPopulateCompanyInfo();
|
||||
|
||||
FOR_ALL_PLAYERS(player) {
|
||||
if (!player->is_active)
|
||||
continue;
|
||||
if (!player->is_active) continue;
|
||||
|
||||
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
|
||||
|
||||
|
@ -102,21 +101,24 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
|
|||
|
||||
/* Send 1 if there is a passord for the company else send 0 */
|
||||
if (_network_player_info[player->index].password[0] != '\0') {
|
||||
NetworkSend_uint8 (p, 1);
|
||||
NetworkSend_uint8(p, 1);
|
||||
} else {
|
||||
NetworkSend_uint8 (p, 0);
|
||||
NetworkSend_uint8(p, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++)
|
||||
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++) {
|
||||
NetworkSend_uint16(p, _network_player_info[player->index].num_vehicle[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < NETWORK_STATION_TYPES; i++)
|
||||
for (i = 0; i < NETWORK_STATION_TYPES; i++) {
|
||||
NetworkSend_uint16(p, _network_player_info[player->index].num_station[i]);
|
||||
}
|
||||
|
||||
if (_network_player_info[player->index].players[0] == '\0')
|
||||
if (_network_player_info[player->index].players[0] == '\0') {
|
||||
NetworkSend_string(p, "<none>");
|
||||
else
|
||||
} else {
|
||||
NetworkSend_string(p, _network_player_info[player->index].players);
|
||||
}
|
||||
|
||||
NetworkSend_Packet(p, cs);
|
||||
}
|
||||
|
@ -240,8 +242,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WAIT)
|
|||
|
||||
// Count how many players are waiting in the queue
|
||||
FOR_ALL_CLIENTS(new_cs) {
|
||||
if (new_cs->status == STATUS_MAP_WAIT)
|
||||
waiting++;
|
||||
if (new_cs->status == STATUS_MAP_WAIT) waiting++;
|
||||
}
|
||||
|
||||
p = NetworkSend_Init(PACKET_SERVER_WAIT);
|
||||
|
@ -578,13 +579,11 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
|
|||
|
||||
#if defined(WITH_REV) || defined(WITH_REV_HACK)
|
||||
// Check if the client has revision control enabled
|
||||
if (strcmp(NOREV_STRING, client_revision) != 0) {
|
||||
if (strcmp(_network_game_info.server_revision, client_revision) != 0) {
|
||||
// Different revisions!!
|
||||
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
|
||||
|
||||
return;
|
||||
}
|
||||
if (strcmp(NOREV_STRING, client_revision) != 0 &&
|
||||
strcmp(_network_game_info.server_revision, client_revision) != 0) {
|
||||
// Different revisions!!
|
||||
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -629,20 +628,20 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
|
|||
|
||||
// We now want a password from the client
|
||||
// else we do not allow him in!
|
||||
if (_network_game_info.use_password)
|
||||
if (_network_game_info.use_password) {
|
||||
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_GAME_PASSWORD);
|
||||
else {
|
||||
} else {
|
||||
if (ci->client_playas > 0 && ci->client_playas <= MAX_PLAYERS && _network_player_info[ci->client_playas - 1].password[0] != '\0') {
|
||||
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure companies to who people try to join are not autocleaned */
|
||||
if (playas >= 1 && playas <= MAX_PLAYERS)
|
||||
if (playas >= 1 && playas <= MAX_PLAYERS) {
|
||||
_network_player_info[playas-1].months_empty = 0;
|
||||
}
|
||||
}
|
||||
|
||||
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
|
||||
|
@ -1113,8 +1112,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_RCON)
|
|||
char pass[NETWORK_PASSWORD_LENGTH];
|
||||
char command[NETWORK_RCONCOMMAND_LENGTH];
|
||||
|
||||
if (_network_game_info.rcon_password[0] == '\0')
|
||||
return;
|
||||
if (_network_game_info.rcon_password[0] == '\0') return;
|
||||
|
||||
NetworkRecv_string(cs, p, pass, sizeof(pass));
|
||||
NetworkRecv_string(cs, p, command, sizeof(command));
|
||||
|
@ -1209,13 +1207,16 @@ void NetworkPopulateCompanyInfo(void)
|
|||
GetString(_network_player_info[p->index].company_name, STR_JUST_STRING);
|
||||
|
||||
// Check the income
|
||||
if (_cur_year - 1 == p->inaugurated_year)
|
||||
if (_cur_year - 1 == p->inaugurated_year) {
|
||||
// The player is here just 1 year, so display [2], else display[1]
|
||||
for (i = 0; i < 13; i++)
|
||||
for (i = 0; i < 13; i++) {
|
||||
_network_player_info[p->index].income -= p->yearly_expenses[2][i];
|
||||
else
|
||||
for (i = 0; i < 13; i++)
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < 13; i++) {
|
||||
_network_player_info[p->index].income -= p->yearly_expenses[1][i];
|
||||
}
|
||||
}
|
||||
|
||||
// Set some general stuff
|
||||
_network_player_info[p->index].inaugurated_year = p->inaugurated_year;
|
||||
|
@ -1226,44 +1227,48 @@ void NetworkPopulateCompanyInfo(void)
|
|||
|
||||
// Go through all vehicles and count the type of vehicles
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->owner < MAX_PLAYERS)
|
||||
switch (v->type) {
|
||||
case VEH_Train:
|
||||
if (IsFrontEngine(v))
|
||||
_network_player_info[v->owner].num_vehicle[0]++;
|
||||
break;
|
||||
case VEH_Road:
|
||||
if (v->cargo_type != CT_PASSENGERS)
|
||||
_network_player_info[v->owner].num_vehicle[1]++;
|
||||
else
|
||||
_network_player_info[v->owner].num_vehicle[2]++;
|
||||
break;
|
||||
case VEH_Aircraft:
|
||||
if (v->subtype <= 2)
|
||||
_network_player_info[v->owner].num_vehicle[3]++;
|
||||
break;
|
||||
case VEH_Ship:
|
||||
_network_player_info[v->owner].num_vehicle[4]++;
|
||||
break;
|
||||
case VEH_Special:
|
||||
case VEH_Disaster:
|
||||
break;
|
||||
}
|
||||
if (v->owner >= MAX_PLAYERS) continue;
|
||||
switch (v->type) {
|
||||
case VEH_Train:
|
||||
if (IsFrontEngine(v)) {
|
||||
_network_player_info[v->owner].num_vehicle[0]++;
|
||||
}
|
||||
break;
|
||||
|
||||
case VEH_Road:
|
||||
if (v->cargo_type != CT_PASSENGERS) {
|
||||
_network_player_info[v->owner].num_vehicle[1]++;
|
||||
} else {
|
||||
_network_player_info[v->owner].num_vehicle[2]++;
|
||||
}
|
||||
break;
|
||||
|
||||
case VEH_Aircraft:
|
||||
if (v->subtype <= 2) {
|
||||
_network_player_info[v->owner].num_vehicle[3]++;
|
||||
}
|
||||
break;
|
||||
|
||||
case VEH_Ship:
|
||||
_network_player_info[v->owner].num_vehicle[4]++;
|
||||
break;
|
||||
|
||||
case VEH_Special:
|
||||
case VEH_Disaster:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Go through all stations and count the types of stations
|
||||
FOR_ALL_STATIONS(s) {
|
||||
if (s->owner < MAX_PLAYERS) {
|
||||
if ((s->facilities & FACIL_TRAIN))
|
||||
_network_player_info[s->owner].num_station[0]++;
|
||||
if ((s->facilities & FACIL_TRUCK_STOP))
|
||||
_network_player_info[s->owner].num_station[1]++;
|
||||
if ((s->facilities & FACIL_BUS_STOP))
|
||||
_network_player_info[s->owner].num_station[2]++;
|
||||
if ((s->facilities & FACIL_AIRPORT))
|
||||
_network_player_info[s->owner].num_station[3]++;
|
||||
if ((s->facilities & FACIL_DOCK))
|
||||
_network_player_info[s->owner].num_station[4]++;
|
||||
NetworkPlayerInfo* npi = &_network_player_info[s->owner];
|
||||
|
||||
if (s->facilities & FACIL_TRAIN) npi->num_station[0]++;
|
||||
if (s->facilities & FACIL_TRUCK_STOP) npi->num_station[1]++;
|
||||
if (s->facilities & FACIL_BUS_STOP) npi->num_station[2]++;
|
||||
if (s->facilities & FACIL_AIRPORT) npi->num_station[3]++;
|
||||
if (s->facilities & FACIL_DOCK) npi->num_station[4]++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1295,8 +1300,7 @@ void NetworkUpdateClientInfo(uint16 client_index)
|
|||
|
||||
ci = NetworkFindClientInfoFromIndex(client_index);
|
||||
|
||||
if (ci == NULL)
|
||||
return;
|
||||
if (ci == NULL) return;
|
||||
|
||||
FOR_ALL_CLIENTS(cs) {
|
||||
SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, ci);
|
||||
|
@ -1330,8 +1334,7 @@ static void NetworkAutoCleanCompanies(void)
|
|||
Player *p;
|
||||
bool clients_in_company[MAX_PLAYERS];
|
||||
|
||||
if (!_network_autoclean_companies)
|
||||
return;
|
||||
if (!_network_autoclean_companies) return;
|
||||
|
||||
memset(clients_in_company, 0, sizeof(clients_in_company));
|
||||
|
||||
|
@ -1352,8 +1355,7 @@ static void NetworkAutoCleanCompanies(void)
|
|||
/* Go through all the comapnies */
|
||||
FOR_ALL_PLAYERS(p) {
|
||||
/* Skip the non-active once */
|
||||
if (!p->is_active || p->is_ai)
|
||||
continue;
|
||||
if (!p->is_active || p->is_ai) continue;
|
||||
|
||||
if (!clients_in_company[p->index]) {
|
||||
/* The company is empty for one month more */
|
||||
|
@ -1430,10 +1432,11 @@ bool NetworkServer_ReadPackets(NetworkClientState *cs)
|
|||
NetworkRecvStatus res;
|
||||
while ((p = NetworkRecv_Packet(cs, &res)) != NULL) {
|
||||
byte type = NetworkRecv_uint8(cs, p);
|
||||
if (type < PACKET_END && _network_server_packet[type] != NULL && !cs->quited)
|
||||
if (type < PACKET_END && _network_server_packet[type] != NULL && !cs->quited) {
|
||||
_network_server_packet[type](cs, p);
|
||||
else
|
||||
} else {
|
||||
DEBUG(net, 0)("[NET][Server] Received invalid packet type %d", type);
|
||||
}
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
|
|
@ -141,10 +141,9 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_RESPONSE)
|
|||
snprintf(item->info.hostname, sizeof(item->info.hostname), "%s", inet_ntoa(client_addr->sin_addr));
|
||||
|
||||
/* Check if we are allowed on this server based on the revision-match */
|
||||
item->info.compatible = (
|
||||
strcmp(item->info.server_revision, _openttd_revision) == 0 ||
|
||||
strcmp(item->info.server_revision, NOREV_STRING) == 0) ? true : false;
|
||||
|
||||
item->info.compatible =
|
||||
strcmp(item->info.server_revision, _openttd_revision) == 0 ||
|
||||
strcmp(item->info.server_revision, NOREV_STRING) == 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -163,8 +162,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
int i;
|
||||
|
||||
// Just a fail-safe.. should never happen
|
||||
if (!_network_udp_server)
|
||||
return;
|
||||
if (!_network_udp_server) return;
|
||||
|
||||
packet = NetworkSend_Init(PACKET_UDP_SERVER_DETAIL_INFO);
|
||||
|
||||
|
@ -178,13 +176,12 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
/* Go through all the players */
|
||||
FOR_ALL_PLAYERS(player) {
|
||||
/* Skip non-active players */
|
||||
if (!player->is_active)
|
||||
continue;
|
||||
if (!player->is_active) continue;
|
||||
|
||||
current++;
|
||||
|
||||
/* Send the information */
|
||||
NetworkSend_uint8 (packet, current);
|
||||
NetworkSend_uint8(packet, current);
|
||||
|
||||
NetworkSend_string(packet, _network_player_info[player->index].company_name);
|
||||
NetworkSend_uint8 (packet, _network_player_info[player->index].inaugurated_year);
|
||||
|
@ -193,11 +190,11 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
NetworkSend_uint64(packet, _network_player_info[player->index].income);
|
||||
NetworkSend_uint16(packet, _network_player_info[player->index].performance);
|
||||
|
||||
/* Send 1 if there is a passord for the company else send 0 */
|
||||
/* Send 1 if there is a passord for the company else send 0 */
|
||||
if (_network_player_info[player->index].password[0] != '\0') {
|
||||
NetworkSend_uint8 (packet, 1);
|
||||
NetworkSend_uint8(packet, 1);
|
||||
} else {
|
||||
NetworkSend_uint8 (packet, 0);
|
||||
NetworkSend_uint8(packet, 0);
|
||||
}
|
||||
|
||||
for (i = 0; i < NETWORK_VEHICLE_TYPES; i++)
|
||||
|
@ -209,7 +206,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
/* Find the clients that are connected to this player */
|
||||
FOR_ALL_CLIENTS(cs) {
|
||||
ci = DEREF_CLIENT_INFO(cs);
|
||||
if ((ci->client_playas - 1) == player->index) {
|
||||
if (ci->client_playas - 1 == player->index) {
|
||||
/* The uint8 == 1 indicates that a client is following */
|
||||
NetworkSend_uint8(packet, 1);
|
||||
NetworkSend_string(packet, ci->client_name);
|
||||
|
@ -219,7 +216,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
}
|
||||
/* Also check for the server itself */
|
||||
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
|
||||
if ((ci->client_playas - 1) == player->index) {
|
||||
if (ci->client_playas - 1 == player->index) {
|
||||
/* The uint8 == 1 indicates that a client is following */
|
||||
NetworkSend_uint8(packet, 1);
|
||||
NetworkSend_string(packet, ci->client_name);
|
||||
|
@ -234,7 +231,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
/* And check if we have any spectators */
|
||||
FOR_ALL_CLIENTS(cs) {
|
||||
ci = DEREF_CLIENT_INFO(cs);
|
||||
if ((ci->client_playas - 1) > MAX_PLAYERS) {
|
||||
if (ci->client_playas - 1 > MAX_PLAYERS) {
|
||||
/* The uint8 == 1 indicates that a client is following */
|
||||
NetworkSend_uint8(packet, 1);
|
||||
NetworkSend_string(packet, ci->client_name);
|
||||
|
@ -244,7 +241,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
}
|
||||
/* Also check for the server itself */
|
||||
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
|
||||
if ((ci->client_playas - 1) > MAX_PLAYERS) {
|
||||
if (ci->client_playas - 1 > MAX_PLAYERS) {
|
||||
/* The uint8 == 1 indicates that a client is following */
|
||||
NetworkSend_uint8(packet, 1);
|
||||
NetworkSend_string(packet, ci->client_name);
|
||||
|
@ -260,7 +257,8 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
|||
free(packet);
|
||||
}
|
||||
|
||||
DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_RESPONSE_LIST) {
|
||||
DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_RESPONSE_LIST)
|
||||
{
|
||||
int i;
|
||||
struct in_addr ip;
|
||||
uint16 port;
|
||||
|
@ -286,13 +284,15 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_RESPONSE_LIST) {
|
|||
}
|
||||
}
|
||||
|
||||
DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_ACK_REGISTER) {
|
||||
DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_ACK_REGISTER)
|
||||
{
|
||||
_network_advertise_retries = 0;
|
||||
DEBUG(net, 2)("[NET][UDP] We are advertised on the master-server!");
|
||||
|
||||
if (!_network_advertise)
|
||||
if (!_network_advertise) {
|
||||
/* We are advertised, but we don't want to! */
|
||||
NetworkUDPRemoveAdvertise();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -440,8 +440,7 @@ void NetworkUDPReceive(SOCKET udp)
|
|||
int packet_len;
|
||||
|
||||
// If p is NULL, malloc him.. this prevents unneeded mallocs
|
||||
if (p == NULL)
|
||||
p = malloc(sizeof(Packet));
|
||||
if (p == NULL) p = malloc(sizeof(*p));
|
||||
|
||||
packet_len = sizeof(p->buffer);
|
||||
client_len = sizeof(client_addr);
|
||||
|
@ -470,15 +469,12 @@ void NetworkUDPReceive(SOCKET udp)
|
|||
// Broadcast to all ips
|
||||
static void NetworkUDPBroadCast(SOCKET udp)
|
||||
{
|
||||
int i;
|
||||
struct sockaddr_in out_addr;
|
||||
Packet *p;
|
||||
Packet* p = NetworkSend_Init(PACKET_UDP_CLIENT_FIND_SERVER);
|
||||
uint i;
|
||||
|
||||
// Init the packet
|
||||
p = NetworkSend_Init(PACKET_UDP_CLIENT_FIND_SERVER);
|
||||
for (i = 0; _broadcast_list[i] != 0; i++) {
|
||||
struct sockaddr_in out_addr;
|
||||
|
||||
i = 0;
|
||||
while (_broadcast_list[i] != 0) {
|
||||
out_addr.sin_family = AF_INET;
|
||||
out_addr.sin_port = htons(_network_server_port);
|
||||
out_addr.sin_addr.s_addr = _broadcast_list[i];
|
||||
|
@ -486,8 +482,6 @@ static void NetworkUDPBroadCast(SOCKET udp)
|
|||
DEBUG(net, 6)("[NET][UDP] Broadcasting to %s", inet_ntoa(out_addr.sin_addr));
|
||||
|
||||
NetworkSendUDP_Packet(udp, p, &out_addr);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
|
10
newgrf.c
10
newgrf.c
|
@ -2467,17 +2467,19 @@ static void ParamSet(byte *buf, int len)
|
|||
break;
|
||||
|
||||
case 0x05:
|
||||
if ((int32)src2 < 0)
|
||||
if ((int32)src2 < 0) {
|
||||
res = src1 >> -(int32)src2;
|
||||
else
|
||||
} else {
|
||||
res = src1 << src2;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x06:
|
||||
if ((int32)src2 < 0)
|
||||
if ((int32)src2 < 0) {
|
||||
res = (int32)src1 >> -(int32)src2;
|
||||
else
|
||||
} else {
|
||||
res = (int32)src1 << src2;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x07: /* Bitwise AND */
|
||||
|
|
18
npf.c
18
npf.c
|
@ -213,9 +213,7 @@ static uint NPFSlopeCost(AyStarNode* current)
|
|||
*/
|
||||
static void NPFMarkTile(TileIndex tile)
|
||||
{
|
||||
#ifdef NO_DEBUG_MESSAGES
|
||||
return;
|
||||
#else
|
||||
#ifndef NO_DEBUG_MESSAGES
|
||||
if (_debug_npf_level < 1 || _networking) return;
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_RAILWAY:
|
||||
|
@ -806,14 +804,12 @@ NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir,
|
|||
_npf_aystar.EndNodeCheck = NPFFindStationOrTile;
|
||||
_npf_aystar.FoundEndNode = NPFSaveTargetData;
|
||||
_npf_aystar.GetNeighbours = NPFFollowTrack;
|
||||
if (type == TRANSPORT_RAIL)
|
||||
_npf_aystar.CalculateG = NPFRailPathCost;
|
||||
else if (type == TRANSPORT_ROAD)
|
||||
_npf_aystar.CalculateG = NPFRoadPathCost;
|
||||
else if (type == TRANSPORT_WATER)
|
||||
_npf_aystar.CalculateG = NPFWaterPathCost;
|
||||
else
|
||||
assert(0);
|
||||
switch (type) {
|
||||
default: NOT_REACHED();
|
||||
case TRANSPORT_RAIL: _npf_aystar.CalculateG = NPFRailPathCost; break;
|
||||
case TRANSPORT_ROAD: _npf_aystar.CalculateG = NPFRoadPathCost; break;
|
||||
case TRANSPORT_WATER: _npf_aystar.CalculateG = NPFWaterPathCost; break;
|
||||
}
|
||||
|
||||
/* Initialize target */
|
||||
target.station_index = INVALID_STATION; /* We will initialize dest_coords inside the loop below */
|
||||
|
|
28
openttd.c
28
openttd.c
|
@ -148,9 +148,9 @@ static void showhelp(void)
|
|||
" -G seed = Set random seed\n"
|
||||
" -n [ip#player:port] = Start networkgame\n"
|
||||
" -D = Start dedicated server\n"
|
||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
|
||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
|
||||
" -f = Fork into the background (dedicated only)\n"
|
||||
#endif
|
||||
#endif
|
||||
" -i = Force to use the DOS palette\n"
|
||||
" (use this if you see a lot of pink)\n"
|
||||
" -c config_file = Use 'config_file' instead of 'openttd.cfg'\n"
|
||||
|
@ -335,11 +335,11 @@ int ttd_main(int argc, char* argv[])
|
|||
// a letter means: it accepts that param (e.g.: -h)
|
||||
// a ':' behind it means: it need a param (e.g.: -m<driver>)
|
||||
// a '::' behind it means: it can optional have a param (e.g.: -d<debug>)
|
||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
|
||||
optformat = "bm:s:v:hDfn::eit:d::r:g::G:c:";
|
||||
#else
|
||||
optformat = "bm:s:v:hDn::eit:d::r:g::G:c:"; // no fork option
|
||||
#endif
|
||||
optformat = "bm:s:v:hDn::eit:d::r:g::G:c:"
|
||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
|
||||
"f"
|
||||
#endif
|
||||
;
|
||||
|
||||
MyGetOptInit(&mgo, argc-1, argv+1, optformat);
|
||||
while ((i = MyGetOpt(&mgo)) != -1) {
|
||||
|
@ -373,8 +373,9 @@ int ttd_main(int argc, char* argv[])
|
|||
if (mgo.opt != NULL) {
|
||||
strcpy(_file_to_saveload.name, mgo.opt);
|
||||
_switch_mode = SM_LOAD;
|
||||
} else
|
||||
} else {
|
||||
_switch_mode = SM_NEWGAME;
|
||||
}
|
||||
break;
|
||||
case 'G': _random_seeds[0][0] = atoi(mgo.opt); break;
|
||||
case 'c': _config_file = strdup(mgo.opt); break;
|
||||
|
@ -1298,7 +1299,7 @@ bool AfterLoadGame(void)
|
|||
break;
|
||||
|
||||
case MP_STATION:
|
||||
if (IsRailwayStation(t)) {
|
||||
if (IsRailwayStation(t)) {
|
||||
SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
|
||||
}
|
||||
break;
|
||||
|
@ -1339,9 +1340,7 @@ bool AfterLoadGame(void)
|
|||
* replaced, shall keep their old length. In all prior versions, just default
|
||||
* to false */
|
||||
if (CheckSavegameVersionOldStyle(16, 1)) {
|
||||
FOR_ALL_PLAYERS(p) {
|
||||
p->renew_keep_length = false;
|
||||
}
|
||||
FOR_ALL_PLAYERS(p) p->renew_keep_length = false;
|
||||
}
|
||||
|
||||
/* In version 17, ground type is moved from m2 to m4 for depots and
|
||||
|
@ -1396,10 +1395,11 @@ bool AfterLoadGame(void)
|
|||
}
|
||||
|
||||
// Clear PBS reservation on track
|
||||
if (!IsTileDepotType(tile, TRANSPORT_RAIL))
|
||||
if (!IsTileDepotType(tile, TRANSPORT_RAIL)) {
|
||||
SB(_m[tile].m4, 4, 4, 0);
|
||||
else
|
||||
} else {
|
||||
CLRBIT(_m[tile].m3, 6);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear PBS reservation on crossing
|
||||
|
|
13
order.h
13
order.h
|
@ -49,9 +49,9 @@ enum OrderFlagMasks {
|
|||
};
|
||||
|
||||
/** Order flags bits - these are for the *BIT macros
|
||||
* for descrption of flags, see OrderFlagMasks
|
||||
* @see OrderFlagMasks
|
||||
*/
|
||||
* for descrption of flags, see OrderFlagMasks
|
||||
* @see OrderFlagMasks
|
||||
*/
|
||||
enum {
|
||||
OFB_TRANSFER = 0,
|
||||
OFB_UNLOAD = 1,
|
||||
|
@ -72,9 +72,10 @@ enum {
|
|||
|
||||
|
||||
/* If you change this, keep in mind that it is saved on 3 places:
|
||||
- Load_ORDR, all the global orders
|
||||
- Vehicle -> current_order
|
||||
- REF_SHEDULE (all REFs are currently limited to 16 bits!!) */
|
||||
* - Load_ORDR, all the global orders
|
||||
* - Vehicle -> current_order
|
||||
* - REF_SHEDULE (all REFs are currently limited to 16 bits!!)
|
||||
*/
|
||||
typedef struct Order {
|
||||
uint8 type;
|
||||
uint8 flags;
|
||||
|
|
19
order_cmd.c
19
order_cmd.c
|
@ -568,9 +568,10 @@ int32 CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
|
||||
order = GetVehicleOrder(v, sel_ord);
|
||||
if (order->type != OT_GOTO_STATION &&
|
||||
(order->type != OT_GOTO_DEPOT || p2 == OFB_UNLOAD) &&
|
||||
(order->type != OT_GOTO_WAYPOINT || p2 != OFB_NON_STOP))
|
||||
(order->type != OT_GOTO_DEPOT || p2 == OFB_UNLOAD) &&
|
||||
(order->type != OT_GOTO_WAYPOINT || p2 != OFB_NON_STOP)) {
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
switch (p2) {
|
||||
|
@ -902,11 +903,15 @@ void CheckOrders(const Vehicle* v)
|
|||
}
|
||||
|
||||
/* Check if the last and the first order are the same */
|
||||
if (v->num_orders > 1 &&
|
||||
v->orders->type == GetLastVehicleOrder(v)->type &&
|
||||
v->orders->flags == GetLastVehicleOrder(v)->flags &&
|
||||
v->orders->station == GetLastVehicleOrder(v)->station)
|
||||
problem_type = 2;
|
||||
if (v->num_orders > 1) {
|
||||
const Order* last = GetLastVehicleOrder(v);
|
||||
|
||||
if (v->orders->type == last->type &&
|
||||
v->orders->flags == last->flags &&
|
||||
v->orders->station == last->station) {
|
||||
problem_type = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do we only have 1 station in our order list? */
|
||||
if (n_st < 2 && problem_type == -1) problem_type = 0;
|
||||
|
|
26
order_gui.c
26
order_gui.c
|
@ -398,31 +398,24 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
|
|||
Vehicle *v = GetVehicle(w->window_number);
|
||||
switch (e->click.widget) {
|
||||
case 2: { /* orders list */
|
||||
int sel;
|
||||
sel = (e->click.pt.y - 15) / 10;
|
||||
int sel = (e->click.pt.y - 15) / 10;
|
||||
|
||||
if ((uint)sel >= w->vscroll.cap)
|
||||
return;
|
||||
if ((uint)sel >= w->vscroll.cap) return;
|
||||
|
||||
sel += w->vscroll.pos;
|
||||
|
||||
if (_ctrl_pressed && sel < v->num_orders) {
|
||||
const Order *ord = GetVehicleOrder(v, sel);
|
||||
int xy = 0;
|
||||
TileIndex xy;
|
||||
|
||||
switch (ord->type) {
|
||||
case OT_GOTO_STATION: /* station order */
|
||||
xy = GetStation(ord->station)->xy ;
|
||||
break;
|
||||
case OT_GOTO_DEPOT: /* goto depot order */
|
||||
xy = GetDepot(ord->station)->xy;
|
||||
break;
|
||||
case OT_GOTO_WAYPOINT: /* goto waypoint order */
|
||||
xy = GetWaypoint(ord->station)->xy;
|
||||
case OT_GOTO_STATION: xy = GetStation(ord->station)->xy ; break;
|
||||
case OT_GOTO_DEPOT: xy = GetDepot(ord->station)->xy; break;
|
||||
case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->station)->xy; break;
|
||||
default: xy = 0; break;
|
||||
}
|
||||
|
||||
if (xy)
|
||||
ScrollMainWindowToTile(xy);
|
||||
|
||||
if (xy != 0) ScrollMainWindowToTile(xy);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -518,7 +511,6 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
|
|||
w->vscroll.cap = (w->widget[2].bottom - w->widget[2].top) / 10;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static const Widget _orders_train_widgets[] = {
|
||||
|
|
15
os2.c
15
os2.c
|
@ -64,10 +64,11 @@ int compare_FiosItems(const void *a, const void *b)
|
|||
|
||||
static void append_path(char *out, const char *path, const char *file)
|
||||
{
|
||||
if (path[2] == '\\' && path[3] == '\0')
|
||||
if (path[2] == '\\' && path[3] == '\0') {
|
||||
sprintf(out, "%s%s", path, file);
|
||||
else
|
||||
} else {
|
||||
sprintf(out, "%s\\%s", path, file);
|
||||
}
|
||||
}
|
||||
|
||||
// Get a list of savegames
|
||||
|
@ -347,10 +348,11 @@ char *FiosBrowseTo(const FiosItem *item)
|
|||
|
||||
case FIOS_TYPE_PARENT:
|
||||
s = strrchr(path, '\\');
|
||||
if (s != path + 2)
|
||||
if (s != path + 2) {
|
||||
s[0] = '\0';
|
||||
else
|
||||
} else {
|
||||
s[1] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case FIOS_TYPE_DIR:
|
||||
|
@ -406,10 +408,7 @@ void FiosMakeSavegameName(char *buf, const char *name, size_t size)
|
|||
const char* extension;
|
||||
const char* period;
|
||||
|
||||
if (_game_mode == GM_EDITOR)
|
||||
extension = ".scn";
|
||||
else
|
||||
extension = ".sav";
|
||||
extension = (_game_mode == GM_EDITOR ? ".scn" : ".sav");
|
||||
|
||||
// Don't append the extension, if it is already there
|
||||
period = strrchr(name, '.');
|
||||
|
|
11
player.h
11
player.h
|
@ -238,12 +238,11 @@ static inline bool HasRailtypeAvail(const Player *p, RailType Railtype)
|
|||
static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_current_player)->avail_railtypes, rail);}
|
||||
|
||||
/** Returns the "best" railtype a player can build.
|
||||
* As the AI doesn't know what the BEST one is, we
|
||||
* have our own priority list here. When adding
|
||||
* new railtypes, modify this function
|
||||
* @param p the player "in action"
|
||||
* @return The "best" railtype a player has available
|
||||
*/
|
||||
* As the AI doesn't know what the BEST one is, we have our own priority list
|
||||
* here. When adding new railtypes, modify this function
|
||||
* @param p the player "in action"
|
||||
* @return The "best" railtype a player has available
|
||||
*/
|
||||
static inline RailType GetBestRailtype(const Player* p)
|
||||
{
|
||||
if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV;
|
||||
|
|
|
@ -79,9 +79,9 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
|
|||
// draw max loan aligned to loan below (y += 10)
|
||||
SetDParam64(0, (uint64)_economy.max_loan);
|
||||
DrawString(202, y+10, STR_MAX_LOAN, 0);
|
||||
|
||||
} else
|
||||
} else {
|
||||
y = 15;
|
||||
}
|
||||
|
||||
DrawString(2, y, STR_7026_BANK_BALANCE, 0);
|
||||
SetDParam64(0, p->money64);
|
||||
|
@ -524,8 +524,9 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
|
|||
|
||||
/* Spectators cannot do anything of course */
|
||||
if (_local_player == OWNER_SPECTATOR) dis |= (1 << 9) | (1 << 10);
|
||||
} else /* shares are not allowed, disable buy/sell buttons */
|
||||
} else { /* shares are not allowed, disable buy/sell buttons */
|
||||
dis |= (1 << 9) | (1 << 10);
|
||||
}
|
||||
}
|
||||
|
||||
SetDParam(0, p->name_1);
|
||||
|
|
84
players.c
84
players.c
|
@ -220,10 +220,11 @@ static void SubtractMoneyFromAnyPlayer(Player *p, int32 cost)
|
|||
|
||||
p->yearly_expenses[0][_yearly_expenses_type] += cost;
|
||||
|
||||
if ( ( 1 << _yearly_expenses_type ) & (1<<7|1<<8|1<<9|1<<10))
|
||||
if (HASBIT(1<<7|1<<8|1<<9|1<<10, _yearly_expenses_type)) {
|
||||
p->cur_economy.income -= cost;
|
||||
else if (( 1 << _yearly_expenses_type ) & (1<<2|1<<3|1<<4|1<<5|1<<6|1<<11))
|
||||
} else if (HASBIT(1<<2|1<<3|1<<4|1<<5|1<<6|1<<11, _yearly_expenses_type)) {
|
||||
p->cur_economy.expenses -= cost;
|
||||
}
|
||||
|
||||
InvalidatePlayerWindows(p);
|
||||
}
|
||||
|
@ -231,31 +232,31 @@ static void SubtractMoneyFromAnyPlayer(Player *p, int32 cost)
|
|||
void SubtractMoneyFromPlayer(int32 cost)
|
||||
{
|
||||
PlayerID pid = _current_player;
|
||||
if (pid < MAX_PLAYERS)
|
||||
SubtractMoneyFromAnyPlayer(GetPlayer(pid), cost);
|
||||
|
||||
if (pid < MAX_PLAYERS) SubtractMoneyFromAnyPlayer(GetPlayer(pid), cost);
|
||||
}
|
||||
|
||||
void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost)
|
||||
{
|
||||
Player *p = GetPlayer(player);
|
||||
byte m = p->player_money_fraction;
|
||||
|
||||
p->player_money_fraction = m - (byte)cost;
|
||||
cost >>= 8;
|
||||
if (p->player_money_fraction > m)
|
||||
cost++;
|
||||
if (cost != 0)
|
||||
SubtractMoneyFromAnyPlayer(p, cost);
|
||||
if (p->player_money_fraction > m) cost++;
|
||||
if (cost != 0) SubtractMoneyFromAnyPlayer(p, cost);
|
||||
}
|
||||
|
||||
// the player_money field is kept as it is, but money64 contains the actual amount of money.
|
||||
void UpdatePlayerMoney32(Player *p)
|
||||
{
|
||||
if (p->money64 < -2000000000)
|
||||
if (p->money64 < -2000000000) {
|
||||
p->player_money = -2000000000;
|
||||
else if (p->money64 > 2000000000)
|
||||
} else if (p->money64 > 2000000000) {
|
||||
p->player_money = 2000000000;
|
||||
else
|
||||
} else {
|
||||
p->player_money = (int32)p->money64;
|
||||
}
|
||||
}
|
||||
|
||||
void GetNameOfOwner(PlayerID owner, TileIndex tile)
|
||||
|
@ -263,15 +264,17 @@ void GetNameOfOwner(PlayerID owner, TileIndex tile)
|
|||
SetDParam(2, owner);
|
||||
|
||||
if (owner != OWNER_TOWN) {
|
||||
if (owner >= 8)
|
||||
if (owner >= MAX_PLAYERS) {
|
||||
SetDParam(0, STR_0150_SOMEONE);
|
||||
else {
|
||||
} else {
|
||||
const Player* p = GetPlayer(owner);
|
||||
|
||||
SetDParam(0, p->name_1);
|
||||
SetDParam(1, p->name_2);
|
||||
}
|
||||
} else {
|
||||
Town *t = ClosestTownFromTile(tile, (uint)-1);
|
||||
const Town* t = ClosestTownFromTile(tile, (uint)-1);
|
||||
|
||||
SetDParam(0, STR_TOWN);
|
||||
SetDParam(1, t->index);
|
||||
}
|
||||
|
@ -282,8 +285,7 @@ bool CheckOwnership(PlayerID owner)
|
|||
{
|
||||
assert(owner <= OWNER_WATER);
|
||||
|
||||
if (owner == _current_player)
|
||||
return true;
|
||||
if (owner == _current_player) return true;
|
||||
_error_message = STR_013B_OWNED_BY;
|
||||
GetNameOfOwner(owner, 0);
|
||||
return false;
|
||||
|
@ -295,8 +297,7 @@ bool CheckTileOwnership(TileIndex tile)
|
|||
|
||||
assert(owner <= OWNER_WATER);
|
||||
|
||||
if (owner == _current_player)
|
||||
return true;
|
||||
if (owner == _current_player) return true;
|
||||
_error_message = STR_013B_OWNED_BY;
|
||||
|
||||
// no need to get the name of the owner unless we're the local player (saves some time)
|
||||
|
@ -313,12 +314,10 @@ static void GenerateCompanyName(Player *p)
|
|||
uint32 strp;
|
||||
char buffer[100];
|
||||
|
||||
if (p->name_1 != STR_SV_UNNAMED)
|
||||
return;
|
||||
if (p->name_1 != STR_SV_UNNAMED) return;
|
||||
|
||||
tile = p->last_build_coordinate;
|
||||
if (tile == 0)
|
||||
return;
|
||||
if (tile == 0) return;
|
||||
|
||||
t = ClosestTownFromTile(tile, (uint)-1);
|
||||
|
||||
|
@ -329,8 +328,7 @@ static void GenerateCompanyName(Player *p)
|
|||
verify_name:;
|
||||
// No player must have this name already
|
||||
FOR_ALL_PLAYERS(pp) {
|
||||
if (pp->name_1 == str && pp->name_2 == strp)
|
||||
goto bad_town_name;
|
||||
if (pp->name_1 == str && pp->name_2 == strp) goto bad_town_name;
|
||||
}
|
||||
|
||||
GetString(buffer, str);
|
||||
|
@ -423,11 +421,8 @@ static byte GeneratePlayerColor(void)
|
|||
}
|
||||
|
||||
// Return the first available color
|
||||
i = 0;
|
||||
for (;;) {
|
||||
if (colors[i] != 0xFF)
|
||||
return colors[i];
|
||||
i++;
|
||||
for (i = 0;; i++) {
|
||||
if (colors[i] != 0xFF) return colors[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -851,8 +846,9 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
}
|
||||
#ifdef ENABLE_NETWORK
|
||||
if (_network_server) {
|
||||
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at server-side
|
||||
* in network_server.c:838, function DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
|
||||
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
|
||||
* server-side in network_server.c:838, function
|
||||
* DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
|
||||
NetworkClientInfo *ci = &_network_client_info[pid];
|
||||
ci->client_playas = p->index + 1;
|
||||
NetworkUpdateClientInfo(ci->client_index);
|
||||
|
@ -878,16 +874,16 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
_local_player = player_backup;
|
||||
}
|
||||
}
|
||||
} else if (_network_server) { // Creating player failed, defer client to spectator
|
||||
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at server-side
|
||||
* in network_server.c:838, function DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
|
||||
} else if (_network_server) {
|
||||
// Creating player failed, defer client to spectator
|
||||
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
|
||||
* server-side in network_server.c:838, function
|
||||
* DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
|
||||
NetworkClientInfo *ci = &_network_client_info[pid];
|
||||
ci->client_playas = OWNER_SPECTATOR;
|
||||
NetworkUpdateClientInfo(ci->client_index);
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif /* ENABLE_NETWORK */
|
||||
}
|
||||
} break;
|
||||
|
||||
case 1: /* Make a new AI player */
|
||||
|
@ -941,7 +937,7 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const StringID _endgame_perf_titles[16] = {
|
||||
static const StringID _endgame_perf_titles[] = {
|
||||
STR_0213_BUSINESSMAN,
|
||||
STR_0213_BUSINESSMAN,
|
||||
STR_0213_BUSINESSMAN,
|
||||
|
@ -957,13 +953,12 @@ static const StringID _endgame_perf_titles[16] = {
|
|||
STR_0217_MAGNATE,
|
||||
STR_0218_MOGUL,
|
||||
STR_0218_MOGUL,
|
||||
STR_0219_TYCOON_OF_THE_CENTURY,
|
||||
STR_0219_TYCOON_OF_THE_CENTURY
|
||||
};
|
||||
|
||||
StringID EndGameGetPerformanceTitleFromValue(uint value)
|
||||
{
|
||||
value = minu(value, 1000) >> 6;
|
||||
if (value >= lengthof(_endgame_perf_titles)) value = lengthof(_endgame_perf_titles) - 1;
|
||||
value = minu(value / 64, lengthof(_endgame_perf_titles) - 1);
|
||||
|
||||
return _endgame_perf_titles[value];
|
||||
}
|
||||
|
@ -971,12 +966,11 @@ StringID EndGameGetPerformanceTitleFromValue(uint value)
|
|||
/* Return true if any cheat has been used, false otherwise */
|
||||
static bool CheatHasBeenUsed(void)
|
||||
{
|
||||
const Cheat* cht = (Cheat*) &_cheats;
|
||||
const Cheat* cht = (Cheat*)&_cheats;
|
||||
const Cheat* cht_last = &cht[sizeof(_cheats) / sizeof(Cheat)];
|
||||
|
||||
for (; cht != cht_last; cht++) {
|
||||
if (cht->been_used)
|
||||
return true;
|
||||
if (cht->been_used) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1109,7 +1103,7 @@ void LoadFromHighScore(void)
|
|||
}
|
||||
|
||||
/* Initialize end of game variable (when to show highscore chart) */
|
||||
_patches.ending_date = 2051;
|
||||
_patches.ending_date = 2051;
|
||||
}
|
||||
|
||||
// Save/load of players
|
||||
|
|
46
rail.h
46
rail.h
|
@ -164,8 +164,8 @@ typedef struct RailtypeInfo {
|
|||
SpriteID total_offset;
|
||||
|
||||
/**
|
||||
* Bridge offset
|
||||
*/
|
||||
* Bridge offset
|
||||
*/
|
||||
SpriteID bridge_offset;
|
||||
|
||||
/**
|
||||
|
@ -263,20 +263,28 @@ static inline Trackdir TrackToTrackdir(Track track) { return (Trackdir)track; }
|
|||
* Returns a TrackdirBit mask that contains the two TrackdirBits that
|
||||
* correspond with the given Track (one for each direction).
|
||||
*/
|
||||
static inline TrackdirBits TrackToTrackdirBits(Track track) { Trackdir td = TrackToTrackdir(track); return (TrackdirBits)(TrackdirToTrackdirBits(td) | TrackdirToTrackdirBits(ReverseTrackdir(td)));}
|
||||
static inline TrackdirBits TrackToTrackdirBits(Track track)
|
||||
{
|
||||
Trackdir td = TrackToTrackdir(track);
|
||||
return (TrackdirBits)(TrackdirToTrackdirBits(td) | TrackdirToTrackdirBits(ReverseTrackdir(td)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Discards all directional information from the given TrackdirBits. Any
|
||||
* Track which is present in either direction will be present in the result.
|
||||
*/
|
||||
static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits) { return (TrackBits)(bits | (bits >> 8)); }
|
||||
static inline TrackBits TrackdirBitsToTrackBits(TrackdirBits bits)
|
||||
{
|
||||
return (TrackBits)(bits | (bits >> 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a trackdir to the trackdir that you will end up on if you go straight
|
||||
* ahead. This will be the same trackdir for diagonal trackdirs, but a
|
||||
* different (alternating) one for straight trackdirs
|
||||
*/
|
||||
static inline Trackdir NextTrackdir(Trackdir trackdir) {
|
||||
static inline Trackdir NextTrackdir(Trackdir trackdir)
|
||||
{
|
||||
extern const Trackdir _next_trackdir[TRACKDIR_END];
|
||||
return _next_trackdir[trackdir];
|
||||
}
|
||||
|
@ -284,7 +292,8 @@ static inline Trackdir NextTrackdir(Trackdir trackdir) {
|
|||
/**
|
||||
* Maps a track to all tracks that make 90 deg turns with it.
|
||||
*/
|
||||
static inline TrackBits TrackCrossesTracks(Track track) {
|
||||
static inline TrackBits TrackCrossesTracks(Track track)
|
||||
{
|
||||
extern const TrackBits _track_crosses_tracks[TRACK_END];
|
||||
return _track_crosses_tracks[track];
|
||||
}
|
||||
|
@ -293,7 +302,8 @@ static inline TrackBits TrackCrossesTracks(Track track) {
|
|||
* Maps a trackdir to the (4-way) direction the tile is exited when following
|
||||
* that trackdir.
|
||||
*/
|
||||
static inline DiagDirection TrackdirToExitdir(Trackdir trackdir) {
|
||||
static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
|
||||
{
|
||||
extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END];
|
||||
return _trackdir_to_exitdir[trackdir];
|
||||
}
|
||||
|
@ -302,7 +312,8 @@ static inline DiagDirection TrackdirToExitdir(Trackdir trackdir) {
|
|||
* Maps a track and an (4-way) dir to the trackdir that represents the track
|
||||
* with the exit in the given direction.
|
||||
*/
|
||||
static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir) {
|
||||
static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir)
|
||||
{
|
||||
extern const Trackdir _track_exitdir_to_trackdir[TRACK_END][DIAGDIR_END];
|
||||
return _track_exitdir_to_trackdir[track][diagdir];
|
||||
}
|
||||
|
@ -311,7 +322,8 @@ static inline Trackdir TrackExitdirToTrackdir(Track track, DiagDirection diagdir
|
|||
* Maps a track and an (4-way) dir to the trackdir that represents the track
|
||||
* with the exit in the given direction.
|
||||
*/
|
||||
static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdir) {
|
||||
static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdir)
|
||||
{
|
||||
extern const Trackdir _track_enterdir_to_trackdir[TRACK_END][DIAGDIR_END];
|
||||
return _track_enterdir_to_trackdir[track][diagdir];
|
||||
}
|
||||
|
@ -320,7 +332,8 @@ static inline Trackdir TrackEnterdirToTrackdir(Track track, DiagDirection diagdi
|
|||
* Maps a track and a full (8-way) direction to the trackdir that represents
|
||||
* the track running in the given direction.
|
||||
*/
|
||||
static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir) {
|
||||
static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir)
|
||||
{
|
||||
extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
|
||||
return _track_direction_to_trackdir[track][dir];
|
||||
}
|
||||
|
@ -329,7 +342,8 @@ static inline Trackdir TrackDirectionToTrackdir(Track track, Direction dir) {
|
|||
* Maps a (4-way) direction to the diagonal trackdir that runs in that
|
||||
* direction.
|
||||
*/
|
||||
static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir) {
|
||||
static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir)
|
||||
{
|
||||
extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
|
||||
return _dir_to_diag_trackdir[diagdir];
|
||||
}
|
||||
|
@ -411,11 +425,11 @@ static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
|
|||
*/
|
||||
static inline bool TracksOverlap(TrackBits bits)
|
||||
{
|
||||
/* With no, or only one track, there is no overlap */
|
||||
if (bits == 0 || KILL_FIRST_BIT(bits) == 0) return false;
|
||||
/* We know that there are at least two tracks present. When there are more
|
||||
* than 2 tracks, they will surely overlap. When there are two, they will
|
||||
* always overlap unless they are lower & upper or right & left. */
|
||||
/* With no, or only one track, there is no overlap */
|
||||
if (bits == 0 || KILL_FIRST_BIT(bits) == 0) return false;
|
||||
/* We know that there are at least two tracks present. When there are more
|
||||
* than 2 tracks, they will surely overlap. When there are two, they will
|
||||
* always overlap unless they are lower & upper or right & left. */
|
||||
return bits != TRACK_BIT_HORZ && bits != TRACK_BIT_VERT;
|
||||
}
|
||||
|
||||
|
|
37
rail_cmd.c
37
rail_cmd.c
|
@ -467,8 +467,9 @@ static int32 ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileIndex end
|
|||
SETBIT(*trackdir, 3); // reverse the direction
|
||||
trdx = -trdx;
|
||||
trdy = -trdy;
|
||||
} else // other direction is invalid too, invalid drag
|
||||
} else { // other direction is invalid too, invalid drag
|
||||
return CMD_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// (for diagonal tracks, this is already made sure of by above test), but:
|
||||
|
@ -517,8 +518,9 @@ static int32 CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32
|
|||
if (CmdFailed(ret)) {
|
||||
if ((_error_message != STR_1007_ALREADY_BUILT) && (mode == 0)) break;
|
||||
_error_message = INVALID_STRING_ID;
|
||||
} else
|
||||
} else {
|
||||
total_cost += ret;
|
||||
}
|
||||
|
||||
if (tile == end_tile) break;
|
||||
|
||||
|
@ -644,13 +646,13 @@ int32 CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
_error_message = STR_1005_NO_SUITABLE_RAILROAD_TRACK;
|
||||
|
||||
{
|
||||
/* See if this is a valid track combination for signals, (ie, no overlap) */
|
||||
TrackBits trackbits = GetTrackBits(tile);
|
||||
/* See if this is a valid track combination for signals, (ie, no overlap) */
|
||||
TrackBits trackbits = GetTrackBits(tile);
|
||||
if (KILL_FIRST_BIT(trackbits) != 0 && /* More than one track present */
|
||||
trackbits != TRACK_BIT_HORZ &&
|
||||
trackbits != TRACK_BIT_VERT
|
||||
)
|
||||
trackbits != TRACK_BIT_VERT) {
|
||||
return CMD_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||
|
@ -740,8 +742,7 @@ static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint3
|
|||
|
||||
/* for vertical/horizontal tracks, double the given signals density
|
||||
* since the original amount will be too dense (shorter tracks) */
|
||||
if (!IsDiagonalTrack(track))
|
||||
signal_density *= 2;
|
||||
if (!IsDiagonalTrack(track)) signal_density *= 2;
|
||||
|
||||
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR;
|
||||
|
||||
|
@ -754,8 +755,9 @@ static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint3
|
|||
|
||||
// copy signal/semaphores style (independent of CTRL)
|
||||
semaphores = (GetSignalVariant(tile) == SIG_ELECTRIC ? 0 : 8);
|
||||
} else // no signals exist, drag a two-way signal stretch
|
||||
} else { // no signals exist, drag a two-way signal stretch
|
||||
signals = SignalOnTrack(track);
|
||||
}
|
||||
|
||||
/* signal_ctr - amount of tiles already processed
|
||||
* signals_density - patch setting to put signal on every Nth tile (double space on |, -- tracks)
|
||||
|
@ -768,7 +770,7 @@ static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint3
|
|||
signal_ctr = total_cost = 0;
|
||||
for (;;) {
|
||||
// only build/remove signals with the specified density
|
||||
if ((signal_ctr % signal_density) == 0 ) {
|
||||
if (signal_ctr % signal_density == 0) {
|
||||
ret = DoCommand(tile, TrackdirToTrack(trackdir) | semaphores, signals, flags, (mode == 1) ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS);
|
||||
|
||||
/* Abort placement for any other error than NOT_SUITABLE_TRACK
|
||||
|
@ -811,11 +813,12 @@ int32 CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
{
|
||||
Track track = (Track)(p1 & 0x7);
|
||||
|
||||
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicle(tile))
|
||||
return CMD_ERROR;
|
||||
|
||||
if (!HasSignalOnTrack(tile, track)) // no signals on track?
|
||||
if (!ValParamTrackOrientation(track) ||
|
||||
!IsTileType(tile, MP_RAILWAY) ||
|
||||
!EnsureNoVehicle(tile) ||
|
||||
!HasSignalOnTrack(tile, track)) {
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
/* Only water can remove signals from anyone */
|
||||
if (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR;
|
||||
|
@ -1238,8 +1241,7 @@ static void DrawTrackBits(TileInfo* ti, TrackBits track, bool flat)
|
|||
foundation = GetRailFoundation(ti->tileh, track);
|
||||
}
|
||||
|
||||
if (foundation != 0)
|
||||
DrawFoundation(ti, foundation);
|
||||
if (foundation != 0) DrawFoundation(ti, foundation);
|
||||
|
||||
// DrawFoundation() modifies ti.
|
||||
// Default sloped sprites..
|
||||
|
@ -1317,7 +1319,6 @@ static void DrawTile_Track(TileInfo *ti)
|
|||
|
||||
/* draw signals also? */
|
||||
if (GetRailTileType(ti->tile) == RAIL_TILE_SIGNALS) DrawSignals(ti->tile, rails);
|
||||
|
||||
} else {
|
||||
/* draw depots / waypoints */
|
||||
const DrawTrackSeqStruct *drss;
|
||||
|
@ -1531,7 +1532,7 @@ static void *SignalVehicleCheckProc(Vehicle *v, void *data)
|
|||
if (tile != dest->tile) return NULL;
|
||||
|
||||
/* Are we on the same piece of track? */
|
||||
if (dest->track & (v->u.rail.track + (v->u.rail.track << 8))) return v;
|
||||
if (dest->track & v->u.rail.track * 0x101) return v;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -147,9 +147,9 @@ void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
|||
|
||||
static void PlaceRail_Station(TileIndex tile)
|
||||
{
|
||||
if (_remove_button_clicked)
|
||||
if (_remove_button_clicked) {
|
||||
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
|
||||
else if (_railstation.dragdrop) {
|
||||
} else if (_railstation.dragdrop) {
|
||||
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
|
||||
VpSetPlaceSizingLimit(_patches.station_spread);
|
||||
} else {
|
||||
|
@ -470,8 +470,9 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
|
|||
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
|
||||
} else if (e->place.userdata == VPM_X_AND_Y_LIMITED) {
|
||||
HandleStationPlacement(start_tile, end_tile);
|
||||
} else
|
||||
} else {
|
||||
DoRailroadTrack(e->place.userdata & 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -272,7 +272,6 @@ RailType GetTileRailType(TileIndex tile, Trackdir trackdir);
|
|||
|
||||
|
||||
typedef enum RailGroundType {
|
||||
RAIL_MAP2LO_GROUND_MASK = 0xF,
|
||||
RAIL_GROUND_BARREN = 0,
|
||||
RAIL_GROUND_GRASS = 1,
|
||||
RAIL_GROUND_FENCE_NW = 2,
|
||||
|
|
27
road_cmd.c
27
road_cmd.c
|
@ -254,7 +254,7 @@ static uint32 CheckRoadSlope(Slope tileh, RoadBits* pieces, RoadBits existing)
|
|||
|
||||
// foundation is used. Whole tile is leveled up
|
||||
if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == 0) {
|
||||
return existing ? 0 : _price.terraform;
|
||||
return existing != 0 ? 0 : _price.terraform;
|
||||
}
|
||||
|
||||
// partly leveled up tile, only if there's no road on that tile
|
||||
|
@ -802,7 +802,8 @@ static void DrawTile_Road(TileInfo *ti)
|
|||
if (image & PALETTE_MODIFIER_COLOR) image |= ormod;
|
||||
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
||||
|
||||
AddSortableSpriteToDraw(image, ti->x | drss->subcoord_x,
|
||||
AddSortableSpriteToDraw(
|
||||
image, ti->x | drss->subcoord_x,
|
||||
ti->y | drss->subcoord_y, drss->width, drss->height, 0x14, ti->z
|
||||
);
|
||||
}
|
||||
|
@ -894,9 +895,6 @@ static const Roadside _town_road_types_2[][2] = {
|
|||
|
||||
static void TileLoop_Road(TileIndex tile)
|
||||
{
|
||||
Town *t;
|
||||
int grp;
|
||||
|
||||
switch (_opt.landscape) {
|
||||
case LT_HILLY:
|
||||
if (IsOnSnow(tile) != (GetTileZ(tile) > _opt.snow_line)) {
|
||||
|
@ -916,15 +914,15 @@ static void TileLoop_Road(TileIndex tile)
|
|||
if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) return;
|
||||
|
||||
if (!HasRoadWorks(tile)) {
|
||||
t = ClosestTownFromTile(tile, (uint)-1);
|
||||
const Town* t = ClosestTownFromTile(tile, (uint)-1);
|
||||
int grp = 0;
|
||||
|
||||
grp = 0;
|
||||
if (t != NULL) {
|
||||
grp = GetTownRadiusGroup(t, tile);
|
||||
|
||||
// Show an animation to indicate road work
|
||||
if (t->road_build_months != 0 &&
|
||||
!(DistanceManhattan(t->xy, tile) >= 8 && grp == 0) &&
|
||||
(DistanceManhattan(t->xy, tile) < 8 || grp != 0) &&
|
||||
GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) {
|
||||
if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicle(tile) && CHANCE16(1, 20)) {
|
||||
StartRoadWorks(tile);
|
||||
|
@ -989,7 +987,7 @@ static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode)
|
|||
case TRANSPORT_ROAD:
|
||||
switch (GetRoadTileType(tile)) {
|
||||
case ROAD_TILE_NORMAL:
|
||||
return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile)] * 0x101;
|
||||
return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile)] * 0x101;
|
||||
|
||||
case ROAD_TILE_CROSSING: {
|
||||
uint32 r = (GetCrossingRoadAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
||||
|
@ -1001,7 +999,6 @@ static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode)
|
|||
default:
|
||||
case ROAD_TILE_DEPOT:
|
||||
return (DiagDirToAxis(GetRoadDepotDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1048,11 +1045,11 @@ static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
|
|||
break;
|
||||
|
||||
case ROAD_TILE_DEPOT:
|
||||
if (v->type == VEH_Road && v->u.road.frame == 11) {
|
||||
if (_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) {
|
||||
RoadVehEnterDepot(v);
|
||||
return 4;
|
||||
}
|
||||
if (v->type == VEH_Road &&
|
||||
v->u.road.frame == 11 &&
|
||||
_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) {
|
||||
RoadVehEnterDepot(v);
|
||||
return 4;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -418,8 +418,9 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
|
|||
if (_station_show_coverage) {
|
||||
int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4;
|
||||
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
||||
} else
|
||||
} else {
|
||||
SetTileSelectSize(1, 1);
|
||||
}
|
||||
|
||||
image = (w->window_class == WC_BUS_STATION) ? 0x47 : 0x43;
|
||||
|
||||
|
|
|
@ -1625,7 +1625,6 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
|
|||
void OnNewDay_RoadVeh(Vehicle *v)
|
||||
{
|
||||
int32 cost;
|
||||
Station *st;
|
||||
|
||||
if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v);
|
||||
if (v->u.road.blocked_ctr == 0) CheckVehicleBreakdown(v);
|
||||
|
@ -1646,19 +1645,19 @@ void OnNewDay_RoadVeh(Vehicle *v)
|
|||
|
||||
/* update destination */
|
||||
if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot == NULL && !(v->vehstatus & VS_CRASHED)) {
|
||||
RoadStop *rs;
|
||||
RoadStop *best = NULL;
|
||||
|
||||
st = GetStation(v->current_order.station);
|
||||
rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK);
|
||||
Station* st = GetStation(v->current_order.station);
|
||||
RoadStop* rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK);
|
||||
RoadStop* best = NULL;
|
||||
|
||||
if (rs != NULL) {
|
||||
if (DistanceManhattan(v->tile, st->xy) < 16) {
|
||||
uint dist, badness;
|
||||
uint minbadness = UINT_MAX;
|
||||
|
||||
DEBUG(ms, 2) ("Multistop: Attempting to obtain a slot for vehicle %d (index %d) at station %d (0x%X)", v->unitnumber,
|
||||
v->index, st->index, st->xy);
|
||||
DEBUG(ms, 2) (
|
||||
"Multistop: Attempting to obtain a slot for vehicle %d (index %d) at station %d (0x%X)",
|
||||
v->unitnumber, v->index, st->index, st->xy
|
||||
);
|
||||
/* Now we find the nearest road stop that has a free slot */
|
||||
for (; rs != NULL; rs = rs->next) {
|
||||
dist = RoadFindPathToStop(v, rs->xy);
|
||||
|
|
|
@ -109,7 +109,6 @@ static void RoadVehRefitWndProc(Window *w, WindowEvent *e)
|
|||
WP(w,refit_d).sel = y / 10;
|
||||
SetWindowDirty(w);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -163,8 +162,8 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
|
|||
StringID str;
|
||||
|
||||
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2);
|
||||
if (!_patches.servint_roadveh) // disable service-scroller when interval is set to disabled
|
||||
w->disabled_state |= (1 << 5) | (1 << 6);
|
||||
// disable service-scroller when interval is set to disabled
|
||||
if (!_patches.servint_roadveh) w->disabled_state |= (1 << 5) | (1 << 6);
|
||||
|
||||
SetDParam(0, v->string_id);
|
||||
SetDParam(1, v->unitnumber);
|
||||
|
@ -352,8 +351,9 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
|
|||
if (v->num_orders == 0) {
|
||||
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
||||
SetDParam(0, v->cur_speed / 2);
|
||||
} else
|
||||
} else {
|
||||
str = STR_EMPTY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -565,8 +565,7 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e)
|
|||
break;
|
||||
|
||||
case WE_RESIZE: {
|
||||
if (e->sizing.diff.y == 0)
|
||||
break;
|
||||
if (e->sizing.diff.y == 0) break;
|
||||
|
||||
w->vscroll.cap += e->sizing.diff.y / 14;
|
||||
w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
|
||||
|
@ -632,8 +631,7 @@ static void DrawRoadDepotWindow(Window *w)
|
|||
/* determine amount of items for scroller */
|
||||
num = 0;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->type == VEH_Road && IsRoadVehInDepot(v) && v->tile == tile)
|
||||
num++;
|
||||
if (v->type == VEH_Road && IsRoadVehInDepot(v) && v->tile == tile) num++;
|
||||
}
|
||||
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
|
||||
|
||||
|
@ -675,12 +673,10 @@ static int GetVehicleFromRoadDepotWndPt(const Window *w, int x, int y, Vehicle *
|
|||
|
||||
xt = x / 56;
|
||||
xm = x % 56;
|
||||
if (xt >= w->hscroll.cap)
|
||||
return 1;
|
||||
if (xt >= w->hscroll.cap) return 1;
|
||||
|
||||
row = (y - 14) / 14;
|
||||
if (row >= w->vscroll.cap)
|
||||
return 1;
|
||||
if (row >= w->vscroll.cap) return 1;
|
||||
|
||||
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt;
|
||||
|
||||
|
@ -707,7 +703,10 @@ static void RoadDepotClickVeh(Window *w, int x, int y)
|
|||
if (mode > 0) return;
|
||||
|
||||
// share / copy orders
|
||||
if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = v; return; }
|
||||
if (_thd.place_mode && mode <= 0) {
|
||||
_place_clicked_vehicle = v;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case 0: // start dragging of vehicle
|
||||
|
@ -791,14 +790,14 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
|
|||
}
|
||||
} break;
|
||||
|
||||
case WE_PLACE_OBJ: {
|
||||
case WE_PLACE_OBJ:
|
||||
ClonePlaceObj(w);
|
||||
} break;
|
||||
break;
|
||||
|
||||
case WE_ABORT_PLACE_OBJ: {
|
||||
case WE_ABORT_PLACE_OBJ:
|
||||
CLRBIT(w->click_state, 8);
|
||||
InvalidateWidget(w, 8);
|
||||
} break;
|
||||
break;
|
||||
|
||||
// check if a vehicle in a depot was clicked..
|
||||
case WE_MOUSELOOP: {
|
||||
|
@ -833,7 +832,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
|
|||
|
||||
case 4:
|
||||
if (!HASBIT(w->disabled_state, 4) &&
|
||||
WP(w,traindepot_d).sel != INVALID_VEHICLE) {
|
||||
WP(w,traindepot_d).sel != INVALID_VEHICLE) {
|
||||
Vehicle *v;
|
||||
|
||||
HandleButtonClick(w, 4);
|
||||
|
@ -848,22 +847,21 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
|
|||
_backup_orders_tile = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
WP(w,traindepot_d).sel = INVALID_VEHICLE;
|
||||
SetWindowDirty(w);
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_RESIZE: {
|
||||
case WE_RESIZE:
|
||||
/* Update the scroll + matrix */
|
||||
w->vscroll.cap += e->sizing.diff.y / 14;
|
||||
w->hscroll.cap += e->sizing.diff.x / 56;
|
||||
w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
|
||||
|
||||
} break;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static const Widget _road_depot_widgets[] = {
|
||||
|
@ -893,10 +891,9 @@ static const WindowDesc _road_depot_desc = {
|
|||
|
||||
void ShowRoadDepotWindow(TileIndex tile)
|
||||
{
|
||||
Window *w;
|
||||
Window* w = AllocateWindowDescFront(&_road_depot_desc, tile);
|
||||
|
||||
w = AllocateWindowDescFront(&_road_depot_desc, tile);
|
||||
if (w) {
|
||||
if (w != NULL) {
|
||||
w->caption_color = GetTileOwner(w->window_number);
|
||||
w->hscroll.cap = 5;
|
||||
w->vscroll.cap = 3;
|
||||
|
@ -959,26 +956,24 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
|||
SetVScrollCount(w, vl->list_length);
|
||||
|
||||
// disable 'Sort By' tooltip on Unsorted sorting criteria
|
||||
if (vl->sort_type == SORT_BY_UNSORTED)
|
||||
w->disabled_state |= (1 << 3);
|
||||
if (vl->sort_type == SORT_BY_UNSORTED) w->disabled_state |= (1 << 3);
|
||||
|
||||
/* draw the widgets */
|
||||
{
|
||||
const Player *p = GetPlayer(owner);
|
||||
if (station == INVALID_STATION) {
|
||||
/* Company Name -- (###) Road vehicles */
|
||||
SetDParam(0, p->name_1);
|
||||
SetDParam(1, p->name_2);
|
||||
SetDParam(2, w->vscroll.count);
|
||||
w->widget[1].unkA = STR_9001_ROAD_VEHICLES;
|
||||
} else {
|
||||
/* Station Name -- (###) Road vehicles */
|
||||
SetDParam(0, station);
|
||||
SetDParam(1, w->vscroll.count);
|
||||
w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES;
|
||||
}
|
||||
DrawWindowWidgets(w);
|
||||
if (station == INVALID_STATION) {
|
||||
const Player* p = GetPlayer(owner);
|
||||
|
||||
/* Company Name -- (###) Road vehicles */
|
||||
SetDParam(0, p->name_1);
|
||||
SetDParam(1, p->name_2);
|
||||
SetDParam(2, w->vscroll.count);
|
||||
w->widget[1].unkA = STR_9001_ROAD_VEHICLES;
|
||||
} else {
|
||||
/* Station Name -- (###) Road vehicles */
|
||||
SetDParam(0, station);
|
||||
SetDParam(1, w->vscroll.count);
|
||||
w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES;
|
||||
}
|
||||
DrawWindowWidgets(w);
|
||||
/* draw sorting criteria string */
|
||||
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
||||
/* draw arrow pointing up/down for ascending/descending sorting */
|
||||
|
@ -1029,22 +1024,19 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
|||
return;
|
||||
case 7: { /* Matrix to show vehicles */
|
||||
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
|
||||
const Vehicle* v;
|
||||
|
||||
if (id_v >= w->vscroll.cap) return; // click out of bounds
|
||||
|
||||
id_v += w->vscroll.pos;
|
||||
|
||||
{
|
||||
Vehicle *v;
|
||||
if (id_v >= vl->list_length) return; // click out of list bound
|
||||
|
||||
if (id_v >= vl->list_length) return; // click out of list bound
|
||||
v = GetVehicle(vl->sort_list[id_v].index);
|
||||
|
||||
v = GetVehicle(vl->sort_list[id_v].index);
|
||||
assert(v->type == VEH_Road && v->owner == owner);
|
||||
|
||||
assert(v->type == VEH_Road && v->owner == owner);
|
||||
|
||||
ShowRoadVehViewWindow(v);
|
||||
}
|
||||
ShowRoadVehViewWindow(v);
|
||||
} break;
|
||||
|
||||
case 9: /* Build new Vehicle */
|
||||
|
@ -1053,9 +1045,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
|||
break;
|
||||
|
||||
case 10: {
|
||||
if (!IsWindowOfPrototype(w, _player_roadveh_widgets))
|
||||
break;
|
||||
|
||||
if (!IsWindowOfPrototype(w, _player_roadveh_widgets)) break;
|
||||
ShowReplaceVehicleWindow(VEH_Road);
|
||||
break;
|
||||
}
|
||||
|
@ -1070,8 +1060,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
|||
_sorting.roadveh.criteria = vl->sort_type;
|
||||
|
||||
// enable 'Sort By' if a sorter criteria is chosen
|
||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
||||
CLRBIT(w->disabled_state, 3);
|
||||
if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3);
|
||||
}
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
|
|
12
saveload.c
12
saveload.c
|
@ -566,7 +566,7 @@ void SlArray(void *array, uint length, VarType conv)
|
|||
* as a byte-type. So detect this, and adjust array size accordingly */
|
||||
if (!_sl.save && _sl_version == 0) {
|
||||
if (conv == SLE_INT16 || conv == SLE_UINT16 || conv == SLE_STRINGID ||
|
||||
conv == SLE_INT32 || conv == SLE_UINT32) {
|
||||
conv == SLE_INT32 || conv == SLE_UINT32) {
|
||||
length *= SlCalcConvFileLen(conv);
|
||||
conv = SLE_INT8;
|
||||
}
|
||||
|
@ -1408,8 +1408,11 @@ static void* SaveFileToDisk(void *arg)
|
|||
_sl.excpt_uninit();
|
||||
|
||||
fprintf(stderr, "Save game failed: %s.", _sl.excpt_msg);
|
||||
if (arg != NULL) OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_ERROR);
|
||||
else SaveFileError();
|
||||
if (arg != NULL) {
|
||||
OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_ERROR);
|
||||
} else {
|
||||
SaveFileError();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1633,8 +1636,7 @@ int GetSavegameType(char *file)
|
|||
if (fread(&hdr, sizeof(hdr), 1, f) != 1) {
|
||||
printf("Savegame is obsolete or invalid format.\n");
|
||||
mode = SL_LOAD; // don't try to get filename, just show name as it is written
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// see if we have any loader for this type.
|
||||
for (fmt = _saveload_formats; fmt != endof(_saveload_formats); fmt++) {
|
||||
if (fmt->tag == hdr) {
|
||||
|
|
20
settings.c
20
settings.c
|
@ -238,10 +238,11 @@ static IniFile *ini_load(const char *filename)
|
|||
|
||||
// it's a group?
|
||||
if (s[0] == '[') {
|
||||
if (e[-1] != ']')
|
||||
if (e[-1] != ']') {
|
||||
ShowInfoF("ini: invalid group name '%s'\n", buffer);
|
||||
else
|
||||
} else {
|
||||
e--;
|
||||
}
|
||||
s++; // skip [
|
||||
group = ini_group_alloc(ini, s, e - s);
|
||||
if (comment_size) {
|
||||
|
@ -341,8 +342,9 @@ static bool ini_save(const char *filename, IniFile *ini)
|
|||
//*Don't give an equal sign to list items that don't have a parameter */
|
||||
if (group->type == IGT_LIST && *item->value == '\0') {
|
||||
fprintf(f, "%s\n", item->name);
|
||||
} else
|
||||
} else {
|
||||
fprintf(f, "%s = %s\n", item->name, item->value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ini->comment) fputs(ini->comment, f);
|
||||
|
@ -609,8 +611,12 @@ static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val)
|
|||
{
|
||||
const SettingDescBase *sdb = &sd->desc;
|
||||
|
||||
if (sdb->cmd != SDT_BOOLX && sdb->cmd != SDT_NUMX &&
|
||||
sdb->cmd != SDT_ONEOFMANY && sdb->cmd != SDT_MANYOFMANY) return;
|
||||
if (sdb->cmd != SDT_BOOLX &&
|
||||
sdb->cmd != SDT_NUMX &&
|
||||
sdb->cmd != SDT_ONEOFMANY &&
|
||||
sdb->cmd != SDT_MANYOFMANY) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* We cannot know the maximum value of a bitset variable, so just have faith */
|
||||
if (sdb->cmd != SDT_MANYOFMANY) {
|
||||
|
@ -1559,8 +1565,8 @@ void SetPatchValue(uint index, const Patches *object, int32 value)
|
|||
Write_ValidateSetting(var, sd, value);
|
||||
|
||||
if (_game_mode != GM_MENU) {
|
||||
void *var2 = ini_get_variable(&sd->save, &_patches_newgame);
|
||||
Write_ValidateSetting(var2, sd, value);
|
||||
void* var2 = ini_get_variable(&sd->save, &_patches_newgame);
|
||||
Write_ValidateSetting(var2, sd, value);
|
||||
}
|
||||
} else {
|
||||
DoCommandP(0, index, value, NULL, CMD_CHANGE_PATCH_SETTING);
|
||||
|
|
46
ship_gui.c
46
ship_gui.c
|
@ -114,7 +114,7 @@ static void ShipRefitWndProc(Window *w, WindowEvent *e)
|
|||
if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo, NULL, CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP)))
|
||||
DeleteWindow(w);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -159,8 +159,8 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
|
|||
StringID str;
|
||||
|
||||
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2);
|
||||
if (!_patches.servint_ships) // disable service-scroller when interval is set to disabled
|
||||
w->disabled_state |= (1 << 5) | (1 << 6);
|
||||
// disable service-scroller when interval is set to disabled
|
||||
if (!_patches.servint_ships) w->disabled_state |= (1 << 5) | (1 << 6);
|
||||
|
||||
SetDParam(0, v->string_id);
|
||||
SetDParam(1, v->unitnumber);
|
||||
|
@ -448,7 +448,8 @@ static void ShowBuildShipWindow(TileIndex tile)
|
|||
}
|
||||
|
||||
|
||||
static void ShipViewWndProc(Window *w, WindowEvent *e) {
|
||||
static void ShipViewWndProc(Window* w, WindowEvent* e)
|
||||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
Vehicle *v = GetVehicle(w->window_number);
|
||||
|
@ -460,8 +461,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
|
|||
disabled = 0;
|
||||
}
|
||||
|
||||
if (v->owner != _local_player)
|
||||
disabled |= 1<<8 | 1<<7;
|
||||
if (v->owner != _local_player) disabled |= 1<<8 | 1<<7;
|
||||
w->disabled_state = disabled;
|
||||
|
||||
/* draw widgets & caption */
|
||||
|
@ -497,8 +497,9 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
|
|||
if (v->num_orders == 0) {
|
||||
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
||||
SetDParam(0, v->cur_speed / 2);
|
||||
} else
|
||||
} else {
|
||||
str = STR_EMPTY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -616,8 +617,7 @@ static void DrawShipDepotWindow(Window *w)
|
|||
/* determine amount of items for scroller */
|
||||
num = 0;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->type == VEH_Ship && IsShipInDepot(v) && v->tile == tile)
|
||||
num++;
|
||||
if (v->type == VEH_Ship && IsShipInDepot(v) && v->tile == tile) num++;
|
||||
}
|
||||
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
|
||||
|
||||
|
@ -659,13 +659,11 @@ static int GetVehicleFromShipDepotWndPt(const Window *w, int x, int y, Vehicle *
|
|||
|
||||
xt = x / 90;
|
||||
xm = x % 90;
|
||||
if (xt >= w->hscroll.cap)
|
||||
return 1;
|
||||
if (xt >= w->hscroll.cap) return 1;
|
||||
|
||||
row = (y - 14) / 24;
|
||||
ym = (y - 14) % 24;
|
||||
if (row >= w->vscroll.cap)
|
||||
return 1;
|
||||
if (row >= w->vscroll.cap) return 1;
|
||||
|
||||
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt;
|
||||
|
||||
|
@ -681,7 +679,6 @@ static int GetVehicleFromShipDepotWndPt(const Window *w, int x, int y, Vehicle *
|
|||
}
|
||||
|
||||
return 1; /* outside */
|
||||
|
||||
}
|
||||
|
||||
static void ShipDepotClick(Window *w, int x, int y)
|
||||
|
@ -690,7 +687,10 @@ static void ShipDepotClick(Window *w, int x, int y)
|
|||
int mode = GetVehicleFromShipDepotWndPt(w, x, y, &v);
|
||||
|
||||
// share / copy orders
|
||||
if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = v; return; }
|
||||
if (_thd.place_mode && mode <= 0) {
|
||||
_place_clicked_vehicle = v;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case 1: // invalid
|
||||
|
@ -1035,22 +1035,19 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
|||
return;
|
||||
case 7: { /* Matrix to show vehicles */
|
||||
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG;
|
||||
const Vehicle* v;
|
||||
|
||||
if (id_v >= w->vscroll.cap) return; // click out of bounds
|
||||
|
||||
id_v += w->vscroll.pos;
|
||||
|
||||
{
|
||||
Vehicle *v;
|
||||
if (id_v >= vl->list_length) return; // click out of list bound
|
||||
|
||||
if (id_v >= vl->list_length) return; // click out of list bound
|
||||
v = GetVehicle(vl->sort_list[id_v].index);
|
||||
|
||||
v = GetVehicle(vl->sort_list[id_v].index);
|
||||
assert(v->type == VEH_Ship);
|
||||
|
||||
assert(v->type == VEH_Ship);
|
||||
|
||||
ShowShipViewWindow(v);
|
||||
}
|
||||
ShowShipViewWindow(v);
|
||||
} break;
|
||||
|
||||
case 9: /* Build new Vehicle */
|
||||
|
@ -1075,8 +1072,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
|||
_sorting.ship.criteria = vl->sort_type;
|
||||
|
||||
// enable 'Sort By' if a sorter criteria is chosen
|
||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
||||
CLRBIT(w->disabled_state, 3);
|
||||
if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3);
|
||||
}
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
|
|
|
@ -83,29 +83,35 @@ static const char *CocoaSoundStart(const char * const *parm)
|
|||
desc.componentFlagsMask = 0;
|
||||
|
||||
comp = FindNextComponent (NULL, &desc);
|
||||
if (comp == NULL)
|
||||
if (comp == NULL) {
|
||||
return "cocoa_s: Failed to start CoreAudio: FindNextComponent returned NULL";
|
||||
}
|
||||
|
||||
/* Open & initialize the default output audio unit */
|
||||
if (OpenAComponent(comp, &_outputAudioUnit) != noErr)
|
||||
if (OpenAComponent(comp, &_outputAudioUnit) != noErr) {
|
||||
return "cocoa_s: Failed to start CoreAudio: OpenAComponent";
|
||||
}
|
||||
|
||||
if (AudioUnitInitialize(_outputAudioUnit) != noErr)
|
||||
if (AudioUnitInitialize(_outputAudioUnit) != noErr) {
|
||||
return "cocoa_s: Failed to start CoreAudio: AudioUnitInitialize";
|
||||
}
|
||||
|
||||
/* Set the input format of the audio unit. */
|
||||
if (AudioUnitSetProperty(_outputAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &requestedDesc, sizeof(requestedDesc)) != noErr)
|
||||
if (AudioUnitSetProperty(_outputAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &requestedDesc, sizeof(requestedDesc)) != noErr) {
|
||||
return "cocoa_s: Failed to start CoreAudio: AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)";
|
||||
}
|
||||
|
||||
/* Set the audio callback */
|
||||
callback.inputProc = audioCallback;
|
||||
callback.inputProcRefCon = NULL;
|
||||
if (AudioUnitSetProperty(_outputAudioUnit, kAudioUnitProperty_SetInputCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)) != noErr)
|
||||
if (AudioUnitSetProperty(_outputAudioUnit, kAudioUnitProperty_SetInputCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)) != noErr) {
|
||||
return "cocoa_s: Failed to start CoreAudio: AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)";
|
||||
}
|
||||
|
||||
/* Finally, start processing of the audio unit */
|
||||
if (AudioOutputUnitStart(_outputAudioUnit) != noErr)
|
||||
if (AudioOutputUnitStart(_outputAudioUnit) != noErr) {
|
||||
return "cocoa_s: Failed to start CoreAudio: AudioOutputUnitStart";
|
||||
}
|
||||
|
||||
/* We're running! */
|
||||
return NULL;
|
||||
|
@ -119,7 +125,7 @@ static void CocoaSoundStop(void)
|
|||
DEBUG(driver, 1)("cocoa_s: CocoaSoundStop");
|
||||
|
||||
/* stop processing the audio unit */
|
||||
if(AudioOutputUnitStop(_outputAudioUnit) != noErr) {
|
||||
if (AudioOutputUnitStop(_outputAudioUnit) != noErr) {
|
||||
DEBUG(driver, 1)("cocoa_s: Core_CloseAudio: AudioOutputUnitStop failed");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1600,17 +1600,17 @@ static const byte _airport_sections_international[] = {
|
|||
|
||||
// Intercontinental Airport (vlarge) - 4 runways
|
||||
static const byte _airport_sections_intercontinental[] = {
|
||||
102, 120, 89, 89, 89, 89, 89, 89, 118,
|
||||
120, 22, 22, 22, 22, 22, 22, 119, 117,
|
||||
87, 54, 87, 8, 8, 8, 8, 51, 117,
|
||||
87, 162, 87, 85, 116, 116, 8, 9, 10,
|
||||
102, 120, 89, 89, 89, 89, 89, 89, 118,
|
||||
120, 22, 22, 22, 22, 22, 22, 119, 117,
|
||||
87, 54, 87, 8, 8, 8, 8, 51, 117,
|
||||
87, 162, 87, 85, 116, 116, 8, 9, 10,
|
||||
87, 8, 8, 11, 31, 11, 8, 160, 32,
|
||||
32, 160, 8, 11, 27, 11, 8, 8, 10,
|
||||
87, 8, 8, 11, 30, 11, 8, 8, 10,
|
||||
87, 142, 8, 11, 29, 11, 10, 163, 10,
|
||||
87, 164, 87, 8, 8, 8, 10, 37, 117,
|
||||
87, 120, 89, 89, 89, 89, 89, 89, 119,
|
||||
121, 22, 22, 22, 22, 22, 22, 119, 37
|
||||
87, 120, 89, 89, 89, 89, 89, 89, 119,
|
||||
121, 22, 22, 22, 22, 22, 22, 119, 37
|
||||
};
|
||||
|
||||
|
||||
|
@ -2204,23 +2204,20 @@ static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode)
|
|||
{
|
||||
switch (mode) {
|
||||
case TRANSPORT_RAIL:
|
||||
if (IsRailwayStation(tile)) {
|
||||
if (IsStationTileBlocked(tile)) return 0;
|
||||
|
||||
if (IsRailwayStation(tile) && !IsStationTileBlocked(tile)) {
|
||||
return TrackToTrackBits(GetRailStationTrack(tile)) * 0x101;
|
||||
}
|
||||
break;
|
||||
|
||||
case TRANSPORT_WATER:
|
||||
// buoy is coded as a station, it is always on open water
|
||||
// (0x3F, all tracks available)
|
||||
if (IsBuoy_(tile)) return 0x3F * 0x101;
|
||||
if (IsBuoy_(tile)) return TRACK_BIT_ALL * 0x101;
|
||||
break;
|
||||
|
||||
case TRANSPORT_ROAD:
|
||||
if (IsRoadStopTile(tile))
|
||||
if (IsRoadStopTile(tile)) {
|
||||
return (DiagDirToAxis(GetRoadStopDir(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2549,10 +2546,11 @@ static void UpdateStationRating(Station *st)
|
|||
|
||||
index = st->index;
|
||||
|
||||
if (waiting_changed)
|
||||
if (waiting_changed) {
|
||||
InvalidateWindow(WC_STATION_VIEW, index);
|
||||
else
|
||||
} else {
|
||||
InvalidateWindowWidget(WC_STATION_VIEW, index, 5);
|
||||
}
|
||||
}
|
||||
|
||||
/* called for every station each tick */
|
||||
|
|
|
@ -890,7 +890,7 @@ static uint32 MyHashStr(uint32 hash, const char *s)
|
|||
{
|
||||
for (; *s != '\0'; s++) {
|
||||
hash = ROL(hash, 3) ^ *s;
|
||||
if (hash & 1) hash = (hash >> 1) ^ 0xDEADBEEF; else hash >>= 1;
|
||||
hash = (hash & 1 ? hash >> 1 ^ 0xDEADBEEF : hash >> 1);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
@ -914,7 +914,7 @@ static void MakeHashOfStrings(void)
|
|||
|
||||
s = ls->name;
|
||||
hash ^= i * 0x717239;
|
||||
if (hash & 1) hash = (hash >> 1) ^ 0xDEADBEEF; else hash >>= 1;
|
||||
hash = (hash & 1 ? hash >> 1 ^ 0xDEADBEEF : hash >> 1);
|
||||
hash = MyHashStr(hash, s + 1);
|
||||
|
||||
s = ls->english;
|
||||
|
@ -922,7 +922,7 @@ static void MakeHashOfStrings(void)
|
|||
if (cs->flags & C_DONTCOUNT) continue;
|
||||
|
||||
hash ^= (cs - _cmd_structs) * 0x1234567;
|
||||
if (hash & 1) hash = (hash >> 1) ^ 0xF00BAA4; else hash >>= 1;
|
||||
hash = (hash & 1 ? hash >> 1 ^ 0xF00BAA4 : hash >> 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,9 +235,9 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e)
|
|||
break;
|
||||
|
||||
case WE_PLACE_MOUSEUP:
|
||||
if (e->click.pt.x != -1) {
|
||||
if ((e->place.userdata & 0xF) == VPM_X_AND_Y) // dragged actions
|
||||
GUIPlaceProcDragXY(e);
|
||||
if (e->click.pt.x != -1 &&
|
||||
(e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
|
||||
GUIPlaceProcDragXY(e);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
4
tile.h
4
tile.h
|
@ -46,7 +46,7 @@ static inline void SetTileHeight(TileIndex tile, uint height)
|
|||
|
||||
static inline uint TilePixelHeight(TileIndex tile)
|
||||
{
|
||||
return TileHeight(tile) * 8;
|
||||
return TileHeight(tile) * TILE_HEIGHT;
|
||||
}
|
||||
|
||||
static inline TileType GetTileType(TileIndex tile)
|
||||
|
@ -59,7 +59,7 @@ static inline void SetTileType(TileIndex tile, TileType type)
|
|||
{
|
||||
assert(tile < MapSize());
|
||||
/* VOID tiles (and no others) are exactly allowed at the lower left and right
|
||||
*edges of the map */
|
||||
* edges of the map */
|
||||
assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) == (type == MP_VOID));
|
||||
SB(_m[tile].type_height, 4, 4, type);
|
||||
}
|
||||
|
|
|
@ -697,9 +697,9 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
|
|||
|
||||
if (IsTileType(tile, MP_STREET)) {
|
||||
/* Don't allow building over roads of other cities */
|
||||
if (IsTileOwner(tile, OWNER_TOWN) && GetTownByTile(tile) != t)
|
||||
if (IsTileOwner(tile, OWNER_TOWN) && GetTownByTile(tile) != t) {
|
||||
_grow_town_result = -1;
|
||||
else if (_game_mode == GM_EDITOR) {
|
||||
} else if (_game_mode == GM_EDITOR) {
|
||||
/* If we are in the SE, and this road-piece has no town owner yet, it just found an
|
||||
* owner :) (happy happy happy road now) */
|
||||
SetTileOwner(tile, OWNER_TOWN);
|
||||
|
|
89
train_gui.c
89
train_gui.c
|
@ -134,8 +134,7 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
|||
{
|
||||
Vehicle *v,*found;
|
||||
|
||||
if (!success)
|
||||
return;
|
||||
if (!success) return;
|
||||
|
||||
// find a locomotive in the depot.
|
||||
found = NULL;
|
||||
|
@ -143,8 +142,7 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
|||
if (v->type == VEH_Train && IsFrontEngine(v) &&
|
||||
v->tile == tile &&
|
||||
v->u.rail.track == 0x80) {
|
||||
if (found != NULL) // must be exactly one.
|
||||
return;
|
||||
if (found != NULL) return; // must be exactly one.
|
||||
found = v;
|
||||
}
|
||||
}
|
||||
|
@ -191,8 +189,7 @@ static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,
|
|||
!HASBIT(e->player_avail, _local_player))
|
||||
continue;
|
||||
|
||||
if (*sel == 0)
|
||||
*selected_id = i;
|
||||
if (*sel == 0) *selected_id = i;
|
||||
|
||||
if (IS_INT_INSIDE(--*pos, -show_max, 0)) {
|
||||
DrawString(*x + 59, *y + 2, GetCustomEngineName(i), *sel == 0 ? 0xC : 0x10);
|
||||
|
@ -208,8 +205,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
|
|||
switch (e->event) {
|
||||
case WE_PAINT:
|
||||
|
||||
if (w->window_number == 0)
|
||||
SETBIT(w->disabled_state, 5);
|
||||
if (w->window_number == 0) SETBIT(w->disabled_state, 5);
|
||||
|
||||
{
|
||||
int count = 0;
|
||||
|
@ -218,9 +214,10 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
|
|||
|
||||
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
|
||||
const Engine *e = GetEngine(i);
|
||||
if (HasPowerOnRail(e->railtype, railtype)
|
||||
&& HASBIT(e->player_avail, _local_player))
|
||||
if (HasPowerOnRail(e->railtype, railtype) &&
|
||||
HASBIT(e->player_avail, _local_player)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
SetVScrollCount(w, count);
|
||||
}
|
||||
|
@ -416,7 +413,7 @@ static void DrawTrainDepotWindow(Window *w)
|
|||
hnum = 8;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->type == VEH_Train &&
|
||||
(IsFrontEngine(v) || IsFreeWagon(v)) &&
|
||||
(IsFrontEngine(v) || IsFreeWagon(v)) &&
|
||||
v->tile == tile &&
|
||||
v->u.rail.track == 0x80) {
|
||||
num++;
|
||||
|
@ -562,20 +559,16 @@ static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head)
|
|||
|
||||
v = GetVehicle(sel);
|
||||
|
||||
if (v == wagon)
|
||||
return;
|
||||
if (v == wagon) return;
|
||||
|
||||
if (wagon == NULL) {
|
||||
if (head != NULL)
|
||||
wagon = GetLastVehicleInChain(head);
|
||||
if (head != NULL) wagon = GetLastVehicleInChain(head);
|
||||
} else {
|
||||
wagon = GetPrevVehicleInChain(wagon);
|
||||
if (wagon == NULL)
|
||||
return;
|
||||
if (wagon == NULL) return;
|
||||
}
|
||||
|
||||
if (wagon == v)
|
||||
return;
|
||||
if (wagon == v) return;
|
||||
|
||||
DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE));
|
||||
}
|
||||
|
@ -589,7 +582,10 @@ static void TrainDepotClickTrain(Window *w, int x, int y)
|
|||
mode = GetVehicleFromTrainDepotWndPt(w, x, y, &gdvp);
|
||||
|
||||
// share / copy orders
|
||||
if (_thd.place_mode && mode <= 0) { _place_clicked_vehicle = gdvp.head; return; }
|
||||
if (_thd.place_mode && mode <= 0) {
|
||||
_place_clicked_vehicle = gdvp.head;
|
||||
return;
|
||||
}
|
||||
|
||||
v = gdvp.wagon;
|
||||
|
||||
|
@ -680,17 +676,17 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
|
|||
}
|
||||
break;
|
||||
|
||||
}
|
||||
} break;
|
||||
|
||||
case WE_PLACE_OBJ: {
|
||||
ClonePlaceObj(w);
|
||||
}
|
||||
} break;
|
||||
|
||||
case WE_ABORT_PLACE_OBJ: {
|
||||
case WE_PLACE_OBJ:
|
||||
ClonePlaceObj(w);
|
||||
break;
|
||||
|
||||
case WE_ABORT_PLACE_OBJ:
|
||||
CLRBIT(w->click_state, 9);
|
||||
InvalidateWidget(w, 9);
|
||||
} break;
|
||||
break;
|
||||
|
||||
// check if a vehicle in a depot was clicked..
|
||||
case WE_MOUSELOOP: {
|
||||
|
@ -994,8 +990,9 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
|
|||
if (v->num_orders == 0) {
|
||||
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
||||
SetDParam(0, v->u.rail.last_speed);
|
||||
} else
|
||||
} else {
|
||||
str = STR_EMPTY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1308,8 +1305,7 @@ do_change_service_int:
|
|||
break;
|
||||
|
||||
case WE_RESIZE:
|
||||
if (e->sizing.diff.y == 0)
|
||||
break;
|
||||
if (e->sizing.diff.y == 0) break;
|
||||
|
||||
w->vscroll.cap += e->sizing.diff.y / 14;
|
||||
w->widget[4].unkA = (w->vscroll.cap << 8) + 1;
|
||||
|
@ -1418,8 +1414,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
|||
SetVScrollCount(w, vl->list_length);
|
||||
|
||||
// disable 'Sort By' tooltip on Unsorted sorting criteria
|
||||
if (vl->sort_type == SORT_BY_UNSORTED)
|
||||
w->disabled_state |= (1 << 3);
|
||||
if (vl->sort_type == SORT_BY_UNSORTED) w->disabled_state |= (1 << 3);
|
||||
|
||||
/* draw the widgets */
|
||||
{
|
||||
|
@ -1454,10 +1449,11 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
|||
DrawVehicleProfitButton(v, x, y + 13);
|
||||
|
||||
SetDParam(0, v->unitnumber);
|
||||
if (IsTileDepotType(v->tile, TRANSPORT_RAIL) && (v->vehstatus & VS_HIDDEN))
|
||||
if (IsTileDepotType(v->tile, TRANSPORT_RAIL) && (v->vehstatus & VS_HIDDEN)) {
|
||||
str = STR_021F;
|
||||
else
|
||||
} else {
|
||||
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
|
||||
}
|
||||
DrawString(x, y + 2, str, 0);
|
||||
|
||||
SetDParam(0, v->profit_this_year);
|
||||
|
@ -1489,22 +1485,19 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
|||
|
||||
case 7: { /* Matrix to show vehicles */
|
||||
uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
|
||||
const Vehicle* v;
|
||||
|
||||
if (id_v >= w->vscroll.cap) return; // click out of bounds
|
||||
|
||||
id_v += w->vscroll.pos;
|
||||
|
||||
{
|
||||
Vehicle *v;
|
||||
if (id_v >= vl->list_length) return; // click out of list bound
|
||||
|
||||
if (id_v >= vl->list_length) return; // click out of list bound
|
||||
v = GetVehicle(vl->sort_list[id_v].index);
|
||||
|
||||
v = GetVehicle(vl->sort_list[id_v].index);
|
||||
assert(v->type == VEH_Train && IsFrontEngine(v) && v->owner == owner);
|
||||
|
||||
assert(v->type == VEH_Train && IsFrontEngine(v) && v->owner == owner);
|
||||
|
||||
ShowTrainViewWindow(v);
|
||||
}
|
||||
ShowTrainViewWindow(v);
|
||||
} break;
|
||||
|
||||
case 9: /* Build new Vehicle */
|
||||
|
@ -1512,13 +1505,10 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
|||
ShowBuildTrainWindow(0);
|
||||
break;
|
||||
|
||||
case 10: {
|
||||
if (!IsWindowOfPrototype(w, _player_trains_widgets))
|
||||
break;
|
||||
|
||||
case 10:
|
||||
if (IsWindowOfPrototype(w, _player_trains_widgets)) break;
|
||||
ShowReplaceVehicleWindow(VEH_Train);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
} break;
|
||||
|
@ -1531,8 +1521,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
|||
_sorting.train.criteria = vl->sort_type;
|
||||
|
||||
// enable 'Sort By' if a sorter criteria is chosen
|
||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
||||
CLRBIT(w->disabled_state, 3);
|
||||
if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3);
|
||||
}
|
||||
SetWindowDirty(w);
|
||||
break;
|
||||
|
@ -1592,7 +1581,7 @@ void ShowPlayerTrains(PlayerID player, StationID station)
|
|||
} else {
|
||||
w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player);
|
||||
}
|
||||
if (w) {
|
||||
if (w != NULL) {
|
||||
w->caption_color = player;
|
||||
w->hscroll.cap = 10 * 29;
|
||||
w->vscroll.cap = 7; // maximum number of vehicles shown
|
||||
|
|
|
@ -142,8 +142,9 @@ static uint32 CheckBridgeSlope(Axis direction, Slope tileh, bool is_start_tile)
|
|||
}
|
||||
|
||||
// slope foundations
|
||||
if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION | BRIDGE_PARTLY_LEVELED_FOUNDATION, tileh))
|
||||
if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION | BRIDGE_PARTLY_LEVELED_FOUNDATION, tileh)) {
|
||||
return _price.terraform;
|
||||
}
|
||||
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
|
17
unix.c
17
unix.c
|
@ -302,10 +302,11 @@ char *FiosBrowseTo(const FiosItem *item)
|
|||
switch (item->type) {
|
||||
case FIOS_TYPE_PARENT:
|
||||
s = strrchr(path, '/');
|
||||
if (s != path)
|
||||
if (s != path) {
|
||||
s[0] = '\0';
|
||||
else
|
||||
} else {
|
||||
s[1] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case FIOS_TYPE_DIR:
|
||||
|
@ -351,8 +352,9 @@ StringID FiosGetDescText(const char **path, uint32 *tot)
|
|||
|
||||
if (statvfs(*path, &s) == 0) {
|
||||
free = (uint64)s.f_frsize * s.f_bavail >> 20;
|
||||
} else
|
||||
} else {
|
||||
return STR_4006_UNABLE_TO_READ_DRIVE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (tot != NULL) *tot = free;
|
||||
|
@ -364,10 +366,7 @@ void FiosMakeSavegameName(char *buf, const char *name, size_t size)
|
|||
const char* extension;
|
||||
const char* period;
|
||||
|
||||
if (_game_mode == GM_EDITOR)
|
||||
extension = ".scn";
|
||||
else
|
||||
extension = ".sav";
|
||||
extension = (_game_mode == GM_EDITOR ? ".scn" : ".sav");
|
||||
|
||||
// Don't append the extension, if it is already there
|
||||
period = strrchr(name, '.');
|
||||
|
@ -458,8 +457,8 @@ int CDECL main(int argc, char* argv[])
|
|||
|
||||
#ifdef WITH_COCOA
|
||||
cocoaSetupAutoreleasePool();
|
||||
/* This is passed if we are launched by double-clicking */
|
||||
if (argc >= 2 && strncmp (argv[1], "-psn", 4) == 0) {
|
||||
/* This is passed if we are launched by double-clicking */
|
||||
if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
|
||||
argv[1] = NULL;
|
||||
argc = 1;
|
||||
cocoaSetWorkingDirectory();
|
||||
|
|
|
@ -51,8 +51,7 @@ void UpdateCompanyHQ(Player *p, uint score)
|
|||
byte val;
|
||||
TileIndex tile = p->location_of_house;
|
||||
|
||||
if (tile == 0)
|
||||
return;
|
||||
if (tile == 0) return;
|
||||
|
||||
(val = 0, score < 170) ||
|
||||
(val++, score < 350) ||
|
||||
|
@ -110,21 +109,24 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
|||
|
||||
switch (GetUnmovableType(ti->tile)) {
|
||||
case UNMOVABLE_TRANSMITTER:
|
||||
case UNMOVABLE_LIGHTHOUSE:
|
||||
{
|
||||
const DrawTileUnmovableStruct *dtus;
|
||||
case UNMOVABLE_LIGHTHOUSE: {
|
||||
const DrawTileUnmovableStruct* dtus;
|
||||
|
||||
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
||||
DrawClearLandTile(ti, 2);
|
||||
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
||||
DrawClearLandTile(ti, 2);
|
||||
|
||||
dtus = &_draw_tile_unmovable_data[GetUnmovableType(ti->tile)];
|
||||
dtus = &_draw_tile_unmovable_data[GetUnmovableType(ti->tile)];
|
||||
|
||||
image = dtus->image;
|
||||
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
||||
image = dtus->image;
|
||||
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
||||
|
||||
AddSortableSpriteToDraw(
|
||||
image, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
|
||||
dtus->width, dtus->height, dtus->z_size, ti->z
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
AddSortableSpriteToDraw(image, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
|
||||
dtus->width, dtus->height, dtus->z_size, ti->z);
|
||||
} break;
|
||||
case UNMOVABLE_STATUE:
|
||||
DrawGroundSprite(SPR_CONCRETE_GROUND);
|
||||
|
||||
|
@ -133,6 +135,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
|||
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
||||
AddSortableSpriteToDraw(image, ti->x, ti->y, 16, 16, 25, ti->z);
|
||||
break;
|
||||
|
||||
case UNMOVABLE_OWNED_LAND:
|
||||
DrawClearLandTile(ti, 0);
|
||||
|
||||
|
@ -140,32 +143,34 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
|||
PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)) + PALETTE_MODIFIER_COLOR + SPR_BOUGHT_LAND,
|
||||
ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2, 1, 1, 10, GetSlopeZ(ti->x + TILE_SIZE / 2, ti->y + TILE_SIZE / 2)
|
||||
);
|
||||
|
||||
break;
|
||||
default:
|
||||
{
|
||||
const DrawTileSeqStruct *dtss;
|
||||
const DrawTileSprites *t;
|
||||
|
||||
assert(IsCompanyHQ(ti->tile));
|
||||
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
||||
default: {
|
||||
const DrawTileSeqStruct* dtss;
|
||||
const DrawTileSprites* t;
|
||||
|
||||
ormod = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
|
||||
assert(IsCompanyHQ(ti->tile));
|
||||
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
||||
|
||||
t = &_unmovable_display_datas[GetCompanyHQSection(ti->tile)];
|
||||
DrawGroundSprite(t->ground_sprite | ormod);
|
||||
ormod = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
|
||||
|
||||
foreach_draw_tile_seq(dtss, t->seq) {
|
||||
image = dtss->image;
|
||||
if (_display_opt & DO_TRANS_BUILDINGS) {
|
||||
MAKE_TRANSPARENT(image);
|
||||
} else {
|
||||
image |= ormod;
|
||||
}
|
||||
AddSortableSpriteToDraw(image, ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||
dtss->width, dtss->height, dtss->unk, ti->z + dtss->delta_z);
|
||||
t = &_unmovable_display_datas[GetCompanyHQSection(ti->tile)];
|
||||
DrawGroundSprite(t->ground_sprite | ormod);
|
||||
|
||||
foreach_draw_tile_seq(dtss, t->seq) {
|
||||
image = dtss->image;
|
||||
if (_display_opt & DO_TRANS_BUILDINGS) {
|
||||
MAKE_TRANSPARENT(image);
|
||||
} else {
|
||||
image |= ormod;
|
||||
}
|
||||
} break;
|
||||
AddSortableSpriteToDraw(
|
||||
image, ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||
dtss->width, dtss->height, dtss->unk, ti->z + dtss->delta_z
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ typedef struct Patches {
|
|||
uint32 npf_buoy_penalty; /* The penalty for going over (through) a buoy */
|
||||
uint32 npf_water_curve_penalty; /* The penalty for curves */
|
||||
uint32 npf_road_curve_penalty; /* The penalty for curves */
|
||||
uint32 npf_crossing_penalty; /* The penalty for level crossings */
|
||||
uint32 npf_crossing_penalty; /* The penalty for level crossings */
|
||||
|
||||
bool population_in_label; // Show the population of a town in his label?
|
||||
|
||||
|
|
29
vehicle.c
29
vehicle.c
|
@ -481,7 +481,7 @@ Vehicle *GetPrevVehicleInChain(const Vehicle *v)
|
|||
|
||||
u = GetFirstVehicleInChain(v);
|
||||
|
||||
// Check to see if this is the first
|
||||
// Check to see if this is the first
|
||||
if (v == u) return NULL;
|
||||
|
||||
do {
|
||||
|
@ -637,7 +637,9 @@ static bool CanFillVehicle_FullLoadAny(Vehicle *v)
|
|||
|
||||
//if the aircraft carries passengers and is NOT full, then
|
||||
//continue loading, no matter how much mail is in
|
||||
if ((v->type == VEH_Aircraft) && (v->cargo_type == CT_PASSENGERS) && (v->cargo_cap != v->cargo_count)) {
|
||||
if (v->type == VEH_Aircraft &&
|
||||
v->cargo_type == CT_PASSENGERS &&
|
||||
v->cargo_cap != v->cargo_count) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -648,9 +650,14 @@ static bool CanFillVehicle_FullLoadAny(Vehicle *v)
|
|||
|
||||
if (v->cargo_cap != 0) {
|
||||
uint32 mask = 1 << v->cargo_type;
|
||||
if (v->cargo_cap == v->cargo_count) full |= mask; else not_full |= mask;
|
||||
|
||||
if (v->cargo_cap == v->cargo_count) {
|
||||
full |= mask;
|
||||
} else {
|
||||
not_full |= mask;
|
||||
}
|
||||
}
|
||||
} while ( (v=v->next) != NULL);
|
||||
} while ((v = v->next) != NULL);
|
||||
|
||||
// continue loading if there is a non full cargo type and no cargo type that is full
|
||||
return not_full && (full & ~not_full) == 0;
|
||||
|
@ -670,13 +677,11 @@ bool CanFillVehicle(Vehicle *v)
|
|||
))) {
|
||||
|
||||
// If patch is active, use alternative CanFillVehicle-function
|
||||
if (_patches.full_load_any)
|
||||
return CanFillVehicle_FullLoadAny(v);
|
||||
if (_patches.full_load_any) return CanFillVehicle_FullLoadAny(v);
|
||||
|
||||
do {
|
||||
if (v->cargo_count != v->cargo_cap)
|
||||
return true;
|
||||
} while ( (v=v->next) != NULL);
|
||||
if (v->cargo_count != v->cargo_cap) return true;
|
||||
} while ((v = v->next) != NULL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -754,14 +759,12 @@ void ViewportAddVehicles(DrawPixelInfo *dpi)
|
|||
veh = v->next_hash;
|
||||
}
|
||||
|
||||
if (x == x2)
|
||||
break;
|
||||
if (x == x2) break;
|
||||
x = (x + 1) & 0x3F;
|
||||
}
|
||||
x = xb;
|
||||
|
||||
if (y == y2)
|
||||
break;
|
||||
if (y == y2) break;
|
||||
y = (y + 0x40) & ((0x3F) << 6);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ enum {
|
|||
typedef struct VehicleAir {
|
||||
uint16 crashed_counter;
|
||||
byte pos;
|
||||
byte previous_pos;
|
||||
byte previous_pos;
|
||||
StationID targetairport;
|
||||
byte state;
|
||||
} VehicleAir;
|
||||
|
|
|
@ -362,18 +362,21 @@ static int PollEvent(void)
|
|||
if (_patches.autosave_on_exit) {
|
||||
DoExitSave();
|
||||
return 0;
|
||||
} else
|
||||
} else {
|
||||
AskExitGame();
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN: /* Toggle full-screen on ALT + ENTER/F */
|
||||
if ((ev.key.keysym.mod & (KMOD_ALT | KMOD_META)) &&
|
||||
(ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_f)) {
|
||||
ToggleFullScreen(!_fullscreen);
|
||||
} else
|
||||
} else {
|
||||
_pressed_key = ConvertSdlKeyIntoMy(&ev.key.keysym);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
|
|
@ -252,8 +252,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
|||
UINT nChanged = RealizePalette(hDC);
|
||||
SelectPalette(hDC, hOldPalette, TRUE);
|
||||
ReleaseDC(hwnd, hDC);
|
||||
if (nChanged)
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
if (nChanged) InvalidateRect(hwnd, NULL, FALSE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -263,9 +262,9 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
|||
} else if (_patches.autosave_on_exit) {
|
||||
DoExitSave();
|
||||
_exit_game = true;
|
||||
} else
|
||||
} else {
|
||||
AskExitGame();
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
|
@ -787,8 +786,9 @@ static void Win32GdiMainLoop(void)
|
|||
#endif
|
||||
!_networking && _game_mode != GM_MENU)
|
||||
_fast_forward |= 2;
|
||||
} else if (_fast_forward & 2)
|
||||
} else if (_fast_forward & 2) {
|
||||
_fast_forward = 0;
|
||||
}
|
||||
|
||||
cur_ticks = GetTickCount();
|
||||
if ((_fast_forward && !_pause) || cur_ticks > next_tick)
|
||||
|
@ -809,14 +809,14 @@ static void Win32GdiMainLoop(void)
|
|||
(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
|
||||
(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
|
||||
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
|
||||
} else
|
||||
} else {
|
||||
_dirkeys = 0;
|
||||
}
|
||||
|
||||
GameLoop();
|
||||
_cursor.delta.x = _cursor.delta.y = 0;
|
||||
|
||||
if (_force_full_redraw)
|
||||
MarkWholeScreenDirty();
|
||||
if (_force_full_redraw) MarkWholeScreenDirty();
|
||||
|
||||
GdiFlush();
|
||||
_screen.dst_ptr = _wnd.buffer_bits;
|
||||
|
|
31
viewport.c
31
viewport.c
|
@ -1660,8 +1660,8 @@ static void CheckClickOnLandscape(const ViewPort *vp, int x, int y)
|
|||
|
||||
static void SafeShowTrainViewWindow(const Vehicle* v)
|
||||
{
|
||||
if (!IsFrontEngine(v)) v = GetFirstVehicleInChain(v);
|
||||
ShowTrainViewWindow(v);
|
||||
if (!IsFrontEngine(v)) v = GetFirstVehicleInChain(v);
|
||||
ShowTrainViewWindow(v);
|
||||
}
|
||||
|
||||
static void Nop(const Vehicle* v) {}
|
||||
|
@ -1955,25 +1955,28 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
|
|||
h = myabs(dy) + 16;
|
||||
|
||||
if (TileVirtXY(thd->selstart.x, thd->selstart.y) == TileVirtXY(x, y)) { // check if we're only within one tile
|
||||
if (method == VPM_RAILDIRS)
|
||||
if (method == VPM_RAILDIRS) {
|
||||
b = GetAutorailHT(x, y);
|
||||
else // rect for autosignals on one tile
|
||||
} else { // rect for autosignals on one tile
|
||||
b = HT_RECT;
|
||||
}
|
||||
} else if (h == 16) { // Is this in X direction?
|
||||
if (dx == 16) // 2x1 special handling
|
||||
if (dx == 16) { // 2x1 special handling
|
||||
b = (Check2x1AutoRail(3)) | HT_LINE;
|
||||
else if (dx == -16)
|
||||
} else if (dx == -16) {
|
||||
b = (Check2x1AutoRail(2)) | HT_LINE;
|
||||
else
|
||||
} else {
|
||||
b = HT_LINE | HT_DIR_X;
|
||||
}
|
||||
y = thd->selstart.y;
|
||||
} else if (w == 16) { // Or Y direction?
|
||||
if (dy == 16) // 2x1 special handling
|
||||
if (dy == 16) { // 2x1 special handling
|
||||
b = (Check2x1AutoRail(1)) | HT_LINE;
|
||||
else if (dy == -16) // 2x1 other direction
|
||||
} else if (dy == -16) { // 2x1 other direction
|
||||
b = (Check2x1AutoRail(0)) | HT_LINE;
|
||||
else
|
||||
} else {
|
||||
b = HT_LINE | HT_DIR_Y;
|
||||
}
|
||||
x = thd->selstart.x;
|
||||
} else if (w > h * 2) { // still count as x dir?
|
||||
b = HT_LINE | HT_DIR_X;
|
||||
|
@ -2082,7 +2085,11 @@ void VpSelectTilesWithMethod(int x, int y, int method)
|
|||
break;
|
||||
|
||||
case VPM_X_OR_Y:
|
||||
if (myabs(sy - y) < myabs(sx - x)) y = sy; else x = sx;
|
||||
if (myabs(sy - y) < myabs(sx - x)) {
|
||||
y = sy;
|
||||
} else {
|
||||
x = sx;
|
||||
}
|
||||
break;
|
||||
|
||||
case VPM_X_AND_Y:
|
||||
|
@ -2196,5 +2203,5 @@ void SetObjectToPlace(CursorID icon, byte mode, WindowClass window_class, Window
|
|||
|
||||
void ResetObjectToPlace(void)
|
||||
{
|
||||
SetObjectToPlace(SPR_CURSOR_MOUSE, 0, 0, 0);
|
||||
SetObjectToPlace(SPR_CURSOR_MOUSE, VHM_NONE, 0, 0);
|
||||
}
|
||||
|
|
|
@ -337,7 +337,6 @@ static int32 ClearTile_Water(TileIndex tile, byte flags)
|
|||
|
||||
case WATER_DEPOT:
|
||||
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
|
||||
|
||||
return RemoveShipDepot(tile, flags);
|
||||
|
||||
default:
|
||||
|
|
66
waypoint.c
66
waypoint.c
|
@ -34,8 +34,7 @@ static void WaypointPoolNewBlock(uint start_item)
|
|||
{
|
||||
Waypoint *wp;
|
||||
|
||||
FOR_ALL_WAYPOINTS_FROM(wp, start_item)
|
||||
wp->index = start_item++;
|
||||
FOR_ALL_WAYPOINTS_FROM(wp, start_item) wp->index = start_item++;
|
||||
}
|
||||
|
||||
/* Initialize the town-pool */
|
||||
|
@ -50,7 +49,7 @@ static Waypoint* AllocateWaypoint(void)
|
|||
if (wp->xy == 0) {
|
||||
uint index = wp->index;
|
||||
|
||||
memset(wp, 0, sizeof(Waypoint));
|
||||
memset(wp, 0, sizeof(*wp));
|
||||
wp->index = index;
|
||||
|
||||
return wp;
|
||||
|
@ -58,8 +57,7 @@ static Waypoint* AllocateWaypoint(void)
|
|||
}
|
||||
|
||||
/* Check if we can add a block to the pool */
|
||||
if (AddBlockToPool(&_waypoint_pool))
|
||||
return AllocateWaypoint();
|
||||
if (AddBlockToPool(&_waypoint_pool)) return AllocateWaypoint();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -88,8 +86,7 @@ void UpdateAllWaypointSigns(void)
|
|||
Waypoint *wp;
|
||||
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
if (wp->xy)
|
||||
UpdateWaypointSign(wp);
|
||||
if (wp->xy != 0) UpdateWaypointSign(wp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,8 +103,7 @@ static void MakeDefaultWaypointName(Waypoint* wp)
|
|||
|
||||
/* Find an unused waypoint number belonging to this town */
|
||||
FOR_ALL_WAYPOINTS(local_wp) {
|
||||
if (wp == local_wp)
|
||||
continue;
|
||||
if (wp == local_wp) continue;
|
||||
|
||||
if (local_wp->xy && local_wp->string == STR_NULL && local_wp->town_index == wp->town_index)
|
||||
used_waypoint[local_wp->town_cn] = true;
|
||||
|
@ -124,11 +120,12 @@ static void MakeDefaultWaypointName(Waypoint* wp)
|
|||
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile)
|
||||
{
|
||||
Waypoint *wp, *best = NULL;
|
||||
uint thres = 8, cur_dist;
|
||||
uint thres = 8;
|
||||
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
if (wp->deleted && wp->xy) {
|
||||
cur_dist = DistanceManhattan(tile, wp->xy);
|
||||
if (wp->deleted && wp->xy != 0) {
|
||||
uint cur_dist = DistanceManhattan(tile, wp->xy);
|
||||
|
||||
if (cur_dist < thres) {
|
||||
thres = cur_dist;
|
||||
best = wp;
|
||||
|
@ -190,15 +187,13 @@ int32 CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK);
|
||||
}
|
||||
|
||||
if (!CheckTileOwnership(tile))
|
||||
return CMD_ERROR;
|
||||
|
||||
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
||||
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
||||
|
||||
tileh = GetTileSlope(tile, NULL);
|
||||
if (tileh != SLOPE_FLAT) {
|
||||
if (!_patches.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))
|
||||
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
|
||||
if (tileh != SLOPE_FLAT &&
|
||||
(!_patches.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) {
|
||||
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
|
||||
}
|
||||
|
||||
/* Check if there is an already existing, deleted, waypoint close to us that we can reuse. */
|
||||
|
@ -255,8 +250,7 @@ static void DoDeleteWaypoint(Waypoint *wp)
|
|||
order.station = wp->index;
|
||||
DeleteDestinationFromVehicleOrder(order);
|
||||
|
||||
if (wp->string != STR_NULL)
|
||||
DeleteName(wp->string);
|
||||
if (wp->string != STR_NULL) DeleteName(wp->string);
|
||||
|
||||
RedrawWaypointSign(wp);
|
||||
}
|
||||
|
@ -268,9 +262,7 @@ void WaypointsDailyLoop(void)
|
|||
|
||||
/* Check if we need to delete a waypoint */
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
if (wp->deleted && !--wp->deleted) {
|
||||
DoDeleteWaypoint(wp);
|
||||
}
|
||||
if (wp->deleted != 0 && --wp->deleted == 0) DoDeleteWaypoint(wp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,14 +272,12 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
|
|||
Waypoint *wp;
|
||||
|
||||
/* Make sure it's a waypoint */
|
||||
if (!IsTileType(tile, MP_RAILWAY) || !IsRailWaypoint(tile))
|
||||
return CMD_ERROR;
|
||||
|
||||
if (!CheckTileOwnership(tile) && !(_current_player == OWNER_WATER))
|
||||
return CMD_ERROR;
|
||||
|
||||
if (!EnsureNoVehicle(tile))
|
||||
if (!IsTileType(tile, MP_RAILWAY) ||
|
||||
!IsRailWaypoint(tile) ||
|
||||
(!CheckTileOwnership(tile) && _current_player != OWNER_WATER) ||
|
||||
!EnsureNoVehicle(tile)) {
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
wp = GetWaypointByTile(tile);
|
||||
|
@ -327,19 +317,17 @@ int32 CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||
{
|
||||
Waypoint *wp;
|
||||
StringID str;
|
||||
|
||||
if (!IsWaypointIndex(p1)) return CMD_ERROR;
|
||||
|
||||
if (_cmd_text[0] != '\0') {
|
||||
str = AllocateNameUnique(_cmd_text, 0);
|
||||
if (str == 0)
|
||||
return CMD_ERROR;
|
||||
StringID str = AllocateNameUnique(_cmd_text, 0);
|
||||
|
||||
if (str == 0) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
wp = GetWaypoint(p1);
|
||||
if (wp->string != STR_NULL)
|
||||
DeleteName(wp->string);
|
||||
if (wp->string != STR_NULL) DeleteName(wp->string);
|
||||
|
||||
wp->string = str;
|
||||
wp->town_cn = 0;
|
||||
|
@ -352,8 +340,7 @@ int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
} else {
|
||||
if (flags & DC_EXEC) {
|
||||
wp = GetWaypoint(p1);
|
||||
if (wp->string != STR_NULL)
|
||||
DeleteName(wp->string);
|
||||
if (wp->string != STR_NULL) DeleteName(wp->string);
|
||||
|
||||
MakeDefaultWaypointName(wp);
|
||||
UpdateWaypointSign(wp);
|
||||
|
@ -395,8 +382,7 @@ void FixOldWaypoints(void)
|
|||
|
||||
/* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */
|
||||
FOR_ALL_WAYPOINTS(wp) {
|
||||
if (wp->xy == 0)
|
||||
continue;
|
||||
if (wp->xy == 0) continue;
|
||||
|
||||
wp->town_index = ClosestTownFromTile(wp->xy, (uint)-1)->index;
|
||||
wp->town_cn = 0;
|
||||
|
|
31
win32.c
31
win32.c
|
@ -50,8 +50,8 @@ bool LoadLibraryList(Function proc[], const char* dll)
|
|||
HMODULE lib = LoadLibrary(dll);
|
||||
|
||||
if (lib == NULL) return false;
|
||||
while (true) {
|
||||
FARPROC p;
|
||||
for (;;) {
|
||||
FARPROC p;
|
||||
|
||||
while (*dll++ != '\0');
|
||||
if (*dll == '\0') break;
|
||||
|
@ -108,10 +108,7 @@ static void MakeCRCTable(uint32 *table) {
|
|||
for (i = 0; i != 256; i++) {
|
||||
crc = i;
|
||||
for (j = 8; j != 0; j--) {
|
||||
if (crc & 1)
|
||||
crc = (crc >> 1) ^ poly;
|
||||
else
|
||||
crc >>= 1;
|
||||
src = (crc & 1 ? (crc >> 1) ^ poly : crc >> 1);
|
||||
}
|
||||
table[i] = crc;
|
||||
}
|
||||
|
@ -369,10 +366,11 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM l
|
|||
case 12: // Close
|
||||
ExitProcess(0);
|
||||
case 13: { // Emergency save
|
||||
if (DoEmergencySave(wnd))
|
||||
if (DoEmergencySave(wnd)) {
|
||||
MessageBoxA(wnd, _save_succeeded, "Save successful", MB_ICONINFORMATION);
|
||||
else
|
||||
} else {
|
||||
MessageBoxA(wnd, "Save failed", "Save failed", MB_ICONINFORMATION);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 14: { // Submit crash report
|
||||
|
@ -904,10 +902,11 @@ char *FiosBrowseTo(const FiosItem *item)
|
|||
|
||||
case FIOS_TYPE_PARENT:
|
||||
s = strrchr(path, '\\');
|
||||
if (s != path + 2)
|
||||
if (s != path + 2) {
|
||||
s[0] = '\0';
|
||||
else
|
||||
} else {
|
||||
s[1] = '\0';
|
||||
}
|
||||
break;
|
||||
|
||||
case FIOS_TYPE_DIR:
|
||||
|
@ -955,8 +954,9 @@ StringID FiosGetDescText(const char **path, uint32 *tot)
|
|||
if (tot != NULL && GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) {
|
||||
*tot = ((spc * bps) * (uint64)nfc) >> 20;
|
||||
sid = STR_4005_BYTES_FREE;
|
||||
} else
|
||||
} else {
|
||||
sid = STR_4006_UNABLE_TO_READ_DRIVE;
|
||||
}
|
||||
|
||||
SetErrorMode(sem); // reset previous setting
|
||||
return sid;
|
||||
|
@ -967,10 +967,7 @@ void FiosMakeSavegameName(char *buf, const char *name, size_t size)
|
|||
const char* extension;
|
||||
const char* period;
|
||||
|
||||
if (_game_mode == GM_EDITOR)
|
||||
extension = ".scn";
|
||||
else
|
||||
extension = ".sav";
|
||||
extension = (_game_mode == GM_EDITOR ? ".scn" : ".sav");
|
||||
|
||||
// Don't append the extension, if it is already there
|
||||
period = strrchr(name, '.');
|
||||
|
@ -1091,9 +1088,9 @@ void CreateConsole(void)
|
|||
|
||||
void ShowInfo(const char *str)
|
||||
{
|
||||
if (_has_console)
|
||||
if (_has_console) {
|
||||
puts(str);
|
||||
else {
|
||||
} else {
|
||||
bool old;
|
||||
|
||||
ReleaseCapture();
|
||||
|
|
30
window.c
30
window.c
|
@ -43,8 +43,7 @@ static void DispatchLeftClickEvent(Window* w, int x, int y)
|
|||
wi = &w->widget[e.click.widget];
|
||||
|
||||
/* don't allow any interaction if the button has been disabled */
|
||||
if (HASBIT(w->disabled_state, e.click.widget))
|
||||
return;
|
||||
if (HASBIT(w->disabled_state, e.click.widget)) return;
|
||||
|
||||
if (wi->type & 0xE0) {
|
||||
/* special widget handling for buttons*/
|
||||
|
@ -230,13 +229,14 @@ void DeleteWindow(Window *w)
|
|||
{
|
||||
WindowClass wc;
|
||||
WindowNumber wn;
|
||||
ViewPort *vp;
|
||||
Window *v;
|
||||
int count;
|
||||
|
||||
if (w == NULL) return;
|
||||
|
||||
if (_thd.place_mode != 0 && _thd.window_class == w->window_class && _thd.window_number == w->window_number) {
|
||||
if (_thd.place_mode != VHM_NONE &&
|
||||
_thd.window_class == w->window_class &&
|
||||
_thd.window_number == w->window_number) {
|
||||
ResetObjectToPlace();
|
||||
}
|
||||
|
||||
|
@ -247,11 +247,10 @@ void DeleteWindow(Window *w)
|
|||
|
||||
w = FindWindowById(wc, wn);
|
||||
|
||||
vp = w->viewport;
|
||||
w->viewport = NULL;
|
||||
if (vp != NULL) {
|
||||
_active_viewports &= ~(1 << (vp - _viewports));
|
||||
vp->width = 0;
|
||||
if (w->viewport != NULL) {
|
||||
CLRBIT(_active_viewports, w->viewport - _viewports);
|
||||
w->viewport->width = 0;
|
||||
w->viewport = NULL;
|
||||
}
|
||||
|
||||
SetWindowDirty(w);
|
||||
|
@ -647,8 +646,11 @@ Window *AllocateWindowDesc(const WindowDesc *desc)
|
|||
pt = GetAutoPlacePosition(desc->width, desc->height);
|
||||
} else {
|
||||
if (pt.x == WDP_CENTER) pt.x = (_screen.width - desc->width) >> 1;
|
||||
if (pt.y == WDP_CENTER) pt.y = (_screen.height - desc->height) >> 1;
|
||||
else if(pt.y < 0) pt.y = _screen.height + pt.y; // if y is negative, it's from the bottom of the screen
|
||||
if (pt.y == WDP_CENTER) {
|
||||
pt.y = (_screen.height - desc->height) >> 1;
|
||||
} else if (pt.y < 0) {
|
||||
pt.y = _screen.height + pt.y; // if y is negative, it's from the bottom of the screen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1618,8 +1620,9 @@ void DeleteAllNonVitalWindows(void)
|
|||
if (w->flags4 & WF_STICKY) {
|
||||
DeleteWindow(w);
|
||||
w = _windows;
|
||||
} else
|
||||
} else {
|
||||
w++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1634,8 +1637,9 @@ int PositionMainToolbar(Window *w)
|
|||
{
|
||||
DEBUG(misc, 1) ("Repositioning Main Toolbar...");
|
||||
|
||||
if (w == NULL || w->window_class != WC_MAIN_TOOLBAR)
|
||||
if (w == NULL || w->window_class != WC_MAIN_TOOLBAR) {
|
||||
w = FindWindowById(WC_MAIN_TOOLBAR, 0);
|
||||
}
|
||||
|
||||
switch (_patches.toolbar_pos) {
|
||||
case 1: w->left = (_screen.width - w->width) >> 1; break;
|
||||
|
|
Loading…
Reference in New Issue