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) {
|
while ((com = entry_com) != NULL) {
|
||||||
_current_player = player;
|
_current_player = player;
|
||||||
|
|
||||||
/* Copy the DP back in place */
|
|
||||||
_cmd_text = com->text;
|
_cmd_text = com->text;
|
||||||
DoCommandP(com->tile, com->p1, com->p2, com->callback, com->procc);
|
DoCommandP(com->tile, com->p1, com->p2, com->callback, com->procc);
|
||||||
|
|
||||||
|
|
|
@ -286,9 +286,9 @@ int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
|
||||||
int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
|
int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
|
||||||
{
|
{
|
||||||
int ret, ret2;
|
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);
|
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
|
||||||
|
} else {
|
||||||
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
|
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);
|
||||||
if (CmdFailed(ret)) return ret;
|
if (CmdFailed(ret)) return ret;
|
||||||
// Try to build the road from the depot
|
// Try to build the road from the depot
|
||||||
|
@ -297,3 +297,4 @@ int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte f
|
||||||
if (CmdFailed(ret2)) return ret;
|
if (CmdFailed(ret2)) return ret;
|
||||||
return ret + ret2;
|
return ret + ret2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -425,16 +425,17 @@ static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current,
|
||||||
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
||||||
}
|
}
|
||||||
} else {
|
} 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));
|
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;
|
res += AI_PATHFINDER_TILE_GOES_UP_PENALTY;
|
||||||
else
|
} else {
|
||||||
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
res += AI_PATHFINDER_FOUNDATION_PENALTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Are we part of a tunnel?
|
// Are we part of a tunnel?
|
||||||
if ((AI_PATHFINDER_FLAG_TUNNEL & current->user_data[0]) != 0) {
|
if ((AI_PATHFINDER_FLAG_TUNNEL & current->user_data[0]) != 0) {
|
||||||
|
|
|
@ -16,35 +16,20 @@ int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c)
|
||||||
// 4 = dig down-left
|
// 4 = dig down-left
|
||||||
// 5 = dig up-right
|
// 5 = dig up-right
|
||||||
|
|
||||||
int x1, x2, x3;
|
uint x1 = TileX(tile_a);
|
||||||
int y1, y2, y3;
|
uint x2 = TileX(tile_b);
|
||||||
|
uint x3 = TileX(tile_c);
|
||||||
|
|
||||||
x1 = TileX(tile_a);
|
uint y1 = TileY(tile_a);
|
||||||
x2 = TileX(tile_b);
|
uint y2 = TileY(tile_b);
|
||||||
x3 = TileX(tile_c);
|
uint y3 = TileY(tile_c);
|
||||||
|
|
||||||
y1 = TileY(tile_a);
|
|
||||||
y2 = TileY(tile_b);
|
|
||||||
y3 = TileY(tile_c);
|
|
||||||
|
|
||||||
if (y1 == y2 && y2 == y3) return 0;
|
if (y1 == y2 && y2 == y3) return 0;
|
||||||
if (x1 == x2 && x2 == x3) return 1;
|
if (x1 == x2 && x2 == x3) return 1;
|
||||||
if (y2 > y1) {
|
if (y2 > y1) return x2 > x3 ? 2 : 4;
|
||||||
if (x2 > x3) return 2;
|
if (x2 > x1) return y2 > y3 ? 2 : 5;
|
||||||
else return 4;
|
if (y1 > y2) return x2 > x3 ? 5 : 3;
|
||||||
}
|
if (x1 > x2) return y2 > y3 ? 4 : 3;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -87,10 +72,13 @@ DiagDirection AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b)
|
||||||
return DIAGDIR_NE;
|
return DIAGDIR_NE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This functions looks up if this vehicle is special for this AI
|
// This functions looks up if this vehicle is special for this AI
|
||||||
// and returns his flag
|
// and returns his flag
|
||||||
uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v) {
|
uint AiNew_GetSpecialVehicleFlag(Player* p, Vehicle* v)
|
||||||
int i;
|
{
|
||||||
|
uint i;
|
||||||
|
|
||||||
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
|
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
|
||||||
if (p->ainew.special_vehicles[i].veh_id == v->index) {
|
if (p->ainew.special_vehicles[i].veh_id == v->index) {
|
||||||
return p->ainew.special_vehicles[i].flag;
|
return p->ainew.special_vehicles[i].flag;
|
||||||
|
@ -101,17 +89,23 @@ uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag) {
|
|
||||||
int i, new_id = -1;
|
bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
|
||||||
|
{
|
||||||
|
int new_id = -1;
|
||||||
|
uint i;
|
||||||
|
|
||||||
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
|
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
|
||||||
if (p->ainew.special_vehicles[i].veh_id == v->index) {
|
if (p->ainew.special_vehicles[i].veh_id == v->index) {
|
||||||
p->ainew.special_vehicles[i].flag |= flag;
|
p->ainew.special_vehicles[i].flag |= flag;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (new_id == -1 && p->ainew.special_vehicles[i].veh_id == 0 &&
|
if (new_id == -1 &&
|
||||||
p->ainew.special_vehicles[i].flag == 0)
|
p->ainew.special_vehicles[i].veh_id == 0 &&
|
||||||
|
p->ainew.special_vehicles[i].flag == 0) {
|
||||||
new_id = i;
|
new_id = i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Out of special_vehicle spots :s
|
// Out of special_vehicle spots :s
|
||||||
if (new_id == -1) {
|
if (new_id == -1) {
|
||||||
|
|
|
@ -1244,9 +1244,11 @@ static void AiNew_State_StartVehicle(Player *p)
|
||||||
// Repays money
|
// Repays money
|
||||||
static void AiNew_State_RepayMoney(Player *p)
|
static void AiNew_State_RepayMoney(Player *p)
|
||||||
{
|
{
|
||||||
int i;
|
uint i;
|
||||||
for (i=0;i<AI_LOAN_REPAY;i++)
|
|
||||||
|
for (i = 0; i < AI_LOAN_REPAY; i++) {
|
||||||
AI_DoCommand(0, 0, 0, DC_EXEC, CMD_DECREASE_LOAN);
|
AI_DoCommand(0, 0, 0, DC_EXEC, CMD_DECREASE_LOAN);
|
||||||
|
}
|
||||||
p->ainew.state = AI_STATE_ACTION_DONE;
|
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)
|
static bool AirportFindFreeHelipad(Vehicle *v, const AirportFTAClass *Airport)
|
||||||
{
|
{
|
||||||
Station *st;
|
|
||||||
AirportFTA *temp;
|
|
||||||
|
|
||||||
// if an airport doesn't have helipads, use terminals
|
// if an airport doesn't have helipads, use terminals
|
||||||
if (Airport->helipads == NULL) return AirportFindFreeTerminal(v, Airport);
|
if (Airport->helipads == NULL) return AirportFindFreeTerminal(v, Airport);
|
||||||
|
|
||||||
// if there are more helicoptergroups, pick one, just as in AirportFindFreeTerminal()
|
// if there are more helicoptergroups, pick one, just as in AirportFindFreeTerminal()
|
||||||
if (Airport->helipads[0] > 1) {
|
if (Airport->helipads[0] > 1) {
|
||||||
st = GetStation(v->u.air.targetairport);
|
const Station* st = GetStation(v->u.air.targetairport);
|
||||||
temp = Airport->layout[v->u.air.pos].next_in_chain;
|
const AirportFTA* temp = Airport->layout[v->u.air.pos].next_in_chain;
|
||||||
|
|
||||||
while (temp != NULL) {
|
while (temp != NULL) {
|
||||||
if (temp->heading == 255) {
|
if (temp->heading == 255) {
|
||||||
if (!HASBITS(st->airport_flags, temp->block)) {
|
if (!HASBITS(st->airport_flags, temp->block)) {
|
||||||
|
|
|
@ -695,8 +695,7 @@ static int GetVehicleFromAircraftDepotWndPt(const Window *w, int x, int y, Vehic
|
||||||
|
|
||||||
row = (y - 14) / 24;
|
row = (y - 14) / 24;
|
||||||
ym = (y - 14) % 24;
|
ym = (y - 14) % 24;
|
||||||
if (row >= w->vscroll.cap)
|
if (row >= w->vscroll.cap) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt;
|
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt;
|
||||||
|
|
||||||
|
@ -811,14 +810,14 @@ static void AircraftDepotWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_OBJ: {
|
case WE_PLACE_OBJ:
|
||||||
ClonePlaceObj(w);
|
ClonePlaceObj(w);
|
||||||
} break;
|
break;
|
||||||
|
|
||||||
case WE_ABORT_PLACE_OBJ: {
|
case WE_ABORT_PLACE_OBJ:
|
||||||
CLRBIT(w->click_state, 8);
|
CLRBIT(w->click_state, 8);
|
||||||
InvalidateWidget(w, 8);
|
InvalidateWidget(w, 8);
|
||||||
} break;
|
break;
|
||||||
|
|
||||||
// check if a vehicle in a depot was clicked..
|
// check if a vehicle in a depot was clicked..
|
||||||
case WE_MOUSELOOP: {
|
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;
|
const Order *order;
|
||||||
int sel, i = 0;
|
int sel, i = 0;
|
||||||
|
|
||||||
|
@ -1068,14 +1068,12 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case 7: { /* Matrix to show vehicles */
|
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;
|
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
|
if (id_v >= w->vscroll.cap) return; // click out of bounds
|
||||||
|
|
||||||
id_v += w->vscroll.pos;
|
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);
|
||||||
|
@ -1083,7 +1081,6 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
assert(v->type == VEH_Aircraft && v->subtype <= 2);
|
assert(v->type == VEH_Aircraft && v->subtype <= 2);
|
||||||
|
|
||||||
ShowAircraftViewWindow(v);
|
ShowAircraftViewWindow(v);
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 9: /* Build new Vehicle */
|
case 9: /* Build new Vehicle */
|
||||||
|
@ -1092,9 +1089,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 10:
|
case 10:
|
||||||
if (!IsWindowOfPrototype(w, _player_aircraft_widgets))
|
if (!IsWindowOfPrototype(w, _player_aircraft_widgets)) break;
|
||||||
break;
|
|
||||||
|
|
||||||
ShowReplaceVehicleWindow(VEH_Aircraft);
|
ShowReplaceVehicleWindow(VEH_Aircraft);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
108
airport.c
108
airport.c
|
@ -32,8 +32,9 @@ static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
|
||||||
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
|
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
|
||||||
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA);
|
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA);
|
||||||
static byte AirportTestFTA(const AirportFTAClass *Airport);
|
static byte AirportTestFTA(const AirportFTAClass *Airport);
|
||||||
/*static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report);
|
#if 0
|
||||||
static byte AirportBlockToString(uint32 block);*/
|
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report);
|
||||||
|
#endif
|
||||||
|
|
||||||
void InitializeAirports(void)
|
void InitializeAirports(void)
|
||||||
{
|
{
|
||||||
|
@ -272,7 +273,9 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
||||||
// print out full information
|
// print out full information
|
||||||
// true -- full info including heading, block, etc
|
// true -- full info including heading, block, etc
|
||||||
// false -- short info, only position and next position
|
// false -- short info, only position and next position
|
||||||
//AirportPrintOut(Airport, false);
|
#if 0
|
||||||
|
AirportPrintOut(Airport, false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void AirportFTAClass_Destructor(AirportFTAClass *Airport)
|
static void AirportFTAClass_Destructor(AirportFTAClass *Airport)
|
||||||
|
@ -393,40 +396,10 @@ static const char* const _airport_heading_strings[] = {
|
||||||
"DUMMY" // extra heading for 255
|
"DUMMY" // extra heading for 255
|
||||||
};
|
};
|
||||||
|
|
||||||
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report)
|
|
||||||
|
static uint AirportBlockToString(uint32 block)
|
||||||
{
|
{
|
||||||
AirportFTA *temp;
|
uint i = 0;
|
||||||
uint16 i;
|
|
||||||
byte heading;
|
|
||||||
|
|
||||||
printf("(P = Current Position; NP = Next Position)\n");
|
|
||||||
for (i = 0; i < Airport->nofelements; i++) {
|
|
||||||
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));
|
|
||||||
} 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));
|
|
||||||
} else {
|
|
||||||
printf("P:%2d NP:%2d", temp->position, temp->next_position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static byte AirportBlockToString(uint32 block)
|
|
||||||
{
|
|
||||||
byte i = 0;
|
|
||||||
if (block & 0xffff0000) { block >>= 16; i += 16; }
|
if (block & 0xffff0000) { block >>= 16; i += 16; }
|
||||||
if (block & 0x0000ff00) { block >>= 8; i += 8; }
|
if (block & 0x0000ff00) { block >>= 8; i += 8; }
|
||||||
if (block & 0x000000f0) { block >>= 4; i += 4; }
|
if (block & 0x000000f0) { block >>= 4; i += 4; }
|
||||||
|
@ -434,31 +407,60 @@ static byte AirportBlockToString(uint32 block)
|
||||||
if (block & 0x00000002) { i += 1; }
|
if (block & 0x00000002) { i += 1; }
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report)
|
||||||
|
{
|
||||||
|
byte heading;
|
||||||
|
uint i;
|
||||||
|
|
||||||
|
printf("(P = Current Position; NP = Next Position)\n");
|
||||||
|
for (i = 0; i < Airport->nofelements; 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)
|
||||||
|
);
|
||||||
|
} 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)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
printf("P:%2d NP:%2d", temp->position, temp->next_position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const AirportFTAClass* GetAirport(const byte airport_type)
|
const AirportFTAClass* GetAirport(const byte airport_type)
|
||||||
{
|
{
|
||||||
AirportFTAClass *Airport = NULL;
|
|
||||||
//FIXME -- AircraftNextAirportPos_and_Order -> Needs something nicer, don't like this code
|
//FIXME -- AircraftNextAirportPos_and_Order -> Needs something nicer, don't like this code
|
||||||
// needs constant change if more airports are added
|
// needs constant change if more airports are added
|
||||||
switch (airport_type) {
|
switch (airport_type) {
|
||||||
case AT_SMALL: Airport = CountryAirport; break;
|
default: NOT_REACHED();
|
||||||
case AT_LARGE: Airport = CityAirport; break;
|
case AT_SMALL: return CountryAirport;
|
||||||
case AT_METROPOLITAN: Airport = MetropolitanAirport; break;
|
case AT_LARGE: return CityAirport;
|
||||||
case AT_HELIPORT: Airport = Heliport; break;
|
case AT_METROPOLITAN: return MetropolitanAirport;
|
||||||
case AT_OILRIG: Airport = Oilrig; break;
|
case AT_HELIPORT: return Heliport;
|
||||||
case AT_INTERNATIONAL: Airport = InternationalAirport; break;
|
case AT_OILRIG: return Oilrig;
|
||||||
case AT_COMMUTER: Airport = CommuterAirport; break;
|
case AT_INTERNATIONAL: return InternationalAirport;
|
||||||
case AT_HELIDEPOT: Airport = HeliDepot; break;
|
case AT_COMMUTER: return CommuterAirport;
|
||||||
case AT_INTERCON: Airport = IntercontinentalAirport; break;
|
case AT_HELIDEPOT: return HeliDepot;
|
||||||
case AT_HELISTATION: Airport = HeliStation; break;
|
case AT_INTERCON: return IntercontinentalAirport;
|
||||||
default:
|
case AT_HELISTATION: return HeliStation;
|
||||||
#ifdef DEBUG__
|
|
||||||
printf("Airport AircraftNextAirportPos_and_Order not yet implemented\n");
|
|
||||||
#endif
|
|
||||||
assert(airport_type <= AT_HELISTATION);
|
|
||||||
}
|
}
|
||||||
return Airport;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AirportMovingData *GetAirportMovingData(byte airport_type, byte position)
|
const AirportMovingData *GetAirportMovingData(byte airport_type, byte position)
|
||||||
|
|
|
@ -88,10 +88,9 @@ static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
|
||||||
_place_proc(e->place.tile);
|
_place_proc(e->place.tile);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_DRAG: {
|
case WE_PLACE_DRAG:
|
||||||
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
|
VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
|
||||||
return;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case WE_PLACE_MOUSEUP:
|
case WE_PLACE_MOUSEUP:
|
||||||
if (e->place.pt.x != -1) {
|
if (e->place.pt.x != -1) {
|
||||||
|
|
42
console.c
42
console.c
|
@ -109,31 +109,35 @@ static void IConsoleWndProc(Window* w, WindowEvent* e)
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case WKC_SHIFT | WKC_PAGEUP:
|
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;
|
_iconsole_scroll = 0;
|
||||||
else
|
} else {
|
||||||
_iconsole_scroll -= (w->height / ICON_LINE_HEIGHT) - 1;
|
_iconsole_scroll -= (w->height / ICON_LINE_HEIGHT) - 1;
|
||||||
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case WKC_SHIFT | WKC_PAGEDOWN:
|
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;
|
_iconsole_scroll = ICON_BUFFER;
|
||||||
else
|
} else {
|
||||||
_iconsole_scroll += (w->height / ICON_LINE_HEIGHT) - 1;
|
_iconsole_scroll += (w->height / ICON_LINE_HEIGHT) - 1;
|
||||||
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case WKC_SHIFT | WKC_UP:
|
case WKC_SHIFT | WKC_UP:
|
||||||
if (_iconsole_scroll <= 0)
|
if (_iconsole_scroll <= 0) {
|
||||||
_iconsole_scroll = 0;
|
_iconsole_scroll = 0;
|
||||||
else
|
} else {
|
||||||
--_iconsole_scroll;
|
--_iconsole_scroll;
|
||||||
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case WKC_SHIFT | WKC_DOWN:
|
case WKC_SHIFT | WKC_DOWN:
|
||||||
if (_iconsole_scroll >= ICON_BUFFER)
|
if (_iconsole_scroll >= ICON_BUFFER) {
|
||||||
_iconsole_scroll = ICON_BUFFER;
|
_iconsole_scroll = ICON_BUFFER;
|
||||||
else
|
} else {
|
||||||
++_iconsole_scroll;
|
++_iconsole_scroll;
|
||||||
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case WKC_BACKQUOTE:
|
case WKC_BACKQUOTE:
|
||||||
|
@ -182,8 +186,9 @@ static void IConsoleWndProc(Window* w, WindowEvent* e)
|
||||||
InsertTextBufferChar(&_iconsole_cmdline, e->keypress.ascii);
|
InsertTextBufferChar(&_iconsole_cmdline, e->keypress.ascii);
|
||||||
IConsoleResetHistoryPos();
|
IConsoleResetHistoryPos();
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
} else
|
} else {
|
||||||
e->keypress.cont = true;
|
e->keypress.cont = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,8 +599,9 @@ void IConsoleVarHookAdd(const char *name, IConsoleHookTypes type, IConsoleHook *
|
||||||
\
|
\
|
||||||
if (item_before == NULL) { \
|
if (item_before == NULL) { \
|
||||||
_base = item_new; \
|
_base = item_new; \
|
||||||
} else \
|
} else { \
|
||||||
item_before->next = item_new; \
|
item_before->next = item_new; \
|
||||||
|
} \
|
||||||
\
|
\
|
||||||
item_new->next = item; \
|
item_new->next = item; \
|
||||||
/* END - Alphabetical insert */ \
|
/* END - Alphabetical insert */ \
|
||||||
|
@ -853,12 +859,12 @@ static void IConsoleVarSetValue(const IConsoleVar *var, uint32 value)
|
||||||
* @param *var the variable in question
|
* @param *var the variable in question
|
||||||
* @param *value the new value
|
* @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;
|
if (var->type != ICONSOLE_VAR_STRING || var->addr == NULL) return;
|
||||||
|
|
||||||
IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_PRE_ACTION);
|
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);
|
IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_POST_ACTION);
|
||||||
IConsoleVarPrintSetValue(var); // print out the new value, giving feedback
|
IConsoleVarPrintSetValue(var); // print out the new value, giving feedback
|
||||||
return;
|
return;
|
||||||
|
@ -1098,9 +1104,11 @@ void IConsoleCmdExec(const char *cmdstr)
|
||||||
|
|
||||||
if (_stdlib_con_developer) {
|
if (_stdlib_con_developer) {
|
||||||
uint i;
|
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]);
|
IConsolePrintF(_icolour_dbg, "condbg: token %d is: '%s'", i, tokens[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tokens[0] == '\0') return; // don't execute empty commands
|
if (tokens[0] == '\0') return; // don't execute empty commands
|
||||||
/* 2. Determine type of command (cmd, alias or variable) and execute
|
/* 2. Determine type of command (cmd, alias or variable) and execute
|
||||||
|
@ -1113,7 +1121,9 @@ void IConsoleCmdExec(const char *cmdstr)
|
||||||
IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_PRE_ACTION);
|
IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_PRE_ACTION);
|
||||||
if (cmd->proc(t_index, tokens)) { // index started with 0
|
if (cmd->proc(t_index, tokens)) { // index started with 0
|
||||||
IConsoleHookHandle(&cmd->hook, ICONSOLE_HOOK_POST_ACTION);
|
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;
|
||||||
}
|
}
|
||||||
|
@ -1127,9 +1137,9 @@ void IConsoleCmdExec(const char *cmdstr)
|
||||||
|
|
||||||
var = IConsoleVarGet(tokens[0]);
|
var = IConsoleVarGet(tokens[0]);
|
||||||
if (var != NULL) {
|
if (var != NULL) {
|
||||||
if (IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_ACCESS))
|
if (IConsoleHookHandle(&var->hook, ICONSOLE_HOOK_ACCESS)) {
|
||||||
IConsoleVarExec(var, t_index, &tokens[1]);
|
IConsoleVarExec(var, t_index, &tokens[1]);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,8 +191,9 @@ DEF_CONSOLE_CMD(ConSave)
|
||||||
|
|
||||||
if (SaveOrLoad(buf, SL_SAVE) != SL_OK) {
|
if (SaveOrLoad(buf, SL_SAVE) != SL_OK) {
|
||||||
IConsolePrint(_icolour_err, "SaveMap failed");
|
IConsolePrint(_icolour_err, "SaveMap failed");
|
||||||
} else
|
} else {
|
||||||
IConsolePrintF(_icolour_def, "Map sucessfully saved to %s", buf);
|
IConsolePrintF(_icolour_def, "Map sucessfully saved to %s", buf);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,8 +248,9 @@ DEF_CONSOLE_CMD(ConLoad)
|
||||||
} break;
|
} break;
|
||||||
default: IConsolePrintF(_icolour_err, "%s: Not a savegame.", file);
|
default: IConsolePrintF(_icolour_err, "%s: Not a savegame.", file);
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
|
IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
|
||||||
|
}
|
||||||
|
|
||||||
FiosFreeSavegameList();
|
FiosFreeSavegameList();
|
||||||
return true;
|
return true;
|
||||||
|
@ -272,8 +274,9 @@ DEF_CONSOLE_CMD(ConRemove)
|
||||||
if (item != NULL) {
|
if (item != NULL) {
|
||||||
if (!FiosDelete(item->name))
|
if (!FiosDelete(item->name))
|
||||||
IConsolePrintF(_icolour_err, "%s: Failed to delete file", file);
|
IConsolePrintF(_icolour_err, "%s: Failed to delete file", file);
|
||||||
} else
|
} else {
|
||||||
IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
|
IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
|
||||||
|
}
|
||||||
|
|
||||||
FiosFreeSavegameList();
|
FiosFreeSavegameList();
|
||||||
return true;
|
return true;
|
||||||
|
@ -323,8 +326,9 @@ DEF_CONSOLE_CMD(ConChangeDirectory)
|
||||||
break;
|
break;
|
||||||
default: IConsolePrintF(_icolour_err, "%s: Not a directory.", file);
|
default: IConsolePrintF(_icolour_err, "%s: Not a directory.", file);
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
|
IConsolePrintF(_icolour_err, "%s: No such file or directory.", file);
|
||||||
|
}
|
||||||
|
|
||||||
FiosFreeSavegameList();
|
FiosFreeSavegameList();
|
||||||
return true;
|
return true;
|
||||||
|
@ -408,8 +412,9 @@ DEF_CONSOLE_CMD(ConBan)
|
||||||
banip = inet_ntoa(*(struct in_addr *)&ci->client_ip);
|
banip = inet_ntoa(*(struct in_addr *)&ci->client_ip);
|
||||||
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
|
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
|
||||||
IConsolePrint(_icolour_def, "Client banned");
|
IConsolePrint(_icolour_def, "Client banned");
|
||||||
} else
|
} else {
|
||||||
IConsolePrint(_icolour_def, "Client not online, banned IP");
|
IConsolePrint(_icolour_def, "Client not online, banned IP");
|
||||||
|
}
|
||||||
|
|
||||||
/* Add user to ban-list */
|
/* Add user to ban-list */
|
||||||
for (index = 0; index < lengthof(_network_ban_list); index++) {
|
for (index = 0; index < lengthof(_network_ban_list); index++) {
|
||||||
|
@ -481,8 +486,9 @@ DEF_CONSOLE_CMD(ConPauseGame)
|
||||||
if (_pause == 0) {
|
if (_pause == 0) {
|
||||||
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
|
DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
|
||||||
IConsolePrint(_icolour_def, "Game paused.");
|
IConsolePrint(_icolour_def, "Game paused.");
|
||||||
} else
|
} else {
|
||||||
IConsolePrint(_icolour_def, "Game is already paused.");
|
IConsolePrint(_icolour_def, "Game is already paused.");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -497,8 +503,9 @@ DEF_CONSOLE_CMD(ConUnPauseGame)
|
||||||
if (_pause != 0) {
|
if (_pause != 0) {
|
||||||
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
|
DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
|
||||||
IConsolePrint(_icolour_def, "Game unpaused.");
|
IConsolePrint(_icolour_def, "Game unpaused.");
|
||||||
} else
|
} else {
|
||||||
IConsolePrint(_icolour_def, "Game is already unpaused.");
|
IConsolePrint(_icolour_def, "Game is already unpaused.");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -519,8 +526,16 @@ DEF_CONSOLE_CMD(ConRcon)
|
||||||
|
|
||||||
DEF_CONSOLE_CMD(ConStatus)
|
DEF_CONSOLE_CMD(ConStatus)
|
||||||
{
|
{
|
||||||
static const char *stat_str[] = {"inactive", "authorized", "waiting", "loading map", "map done", "ready", "active"};
|
static const char* const stat_str[] = {
|
||||||
const char *status;
|
"inactive",
|
||||||
|
"authorized",
|
||||||
|
"waiting",
|
||||||
|
"loading map",
|
||||||
|
"map done",
|
||||||
|
"ready",
|
||||||
|
"active"
|
||||||
|
};
|
||||||
|
|
||||||
const NetworkClientState *cs;
|
const NetworkClientState *cs;
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
|
@ -531,8 +546,9 @@ DEF_CONSOLE_CMD(ConStatus)
|
||||||
FOR_ALL_CLIENTS(cs) {
|
FOR_ALL_CLIENTS(cs) {
|
||||||
int lag = NetworkCalculateLag(cs);
|
int lag = NetworkCalculateLag(cs);
|
||||||
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(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'",
|
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);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_CONSOLE_HOOK(ConHookValidateMaxClientsCount) {
|
DEF_CONSOLE_HOOK(ConHookValidateMaxClientsCount)
|
||||||
|
{
|
||||||
/* XXX - hardcoded, string limiation -- TrueLight
|
/* XXX - hardcoded, string limiation -- TrueLight
|
||||||
* XXX - also see network.c:NetworkStartup ~1356 */
|
* XXX - also see network.c:NetworkStartup ~1356 */
|
||||||
if (_network_game_info.clients_max > 10) {
|
if (_network_game_info.clients_max > 10) {
|
||||||
|
@ -569,7 +586,8 @@ DEF_CONSOLE_HOOK(ConHookValidateMaxClientsCount) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_CONSOLE_HOOK(ConHookValidateMaxCompaniesCount) {
|
DEF_CONSOLE_HOOK(ConHookValidateMaxCompaniesCount)
|
||||||
|
{
|
||||||
if (_network_game_info.companies_max > MAX_PLAYERS) {
|
if (_network_game_info.companies_max > MAX_PLAYERS) {
|
||||||
_network_game_info.companies_max = MAX_PLAYERS;
|
_network_game_info.companies_max = MAX_PLAYERS;
|
||||||
IConsoleError("Maximum companies out of bounds, truncating to limit.");
|
IConsoleError("Maximum companies out of bounds, truncating to limit.");
|
||||||
|
@ -578,7 +596,8 @@ DEF_CONSOLE_HOOK(ConHookValidateMaxCompaniesCount) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_CONSOLE_HOOK(ConHookValidateMaxSpectatorsCount) {
|
DEF_CONSOLE_HOOK(ConHookValidateMaxSpectatorsCount)
|
||||||
|
{
|
||||||
/* XXX @see ConHookValidateMaxClientsCount */
|
/* XXX @see ConHookValidateMaxClientsCount */
|
||||||
if (_network_game_info.spectators_max > 10) {
|
if (_network_game_info.spectators_max > 10) {
|
||||||
_network_game_info.spectators_max = 10;
|
_network_game_info.spectators_max = 10;
|
||||||
|
@ -621,8 +640,9 @@ DEF_CONSOLE_CMD(ConKick)
|
||||||
|
|
||||||
if (ci != NULL) {
|
if (ci != NULL) {
|
||||||
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
|
SEND_COMMAND(PACKET_SERVER_ERROR)(NetworkFindClientStateFromIndex(index), NETWORK_ERROR_KICKED);
|
||||||
} else
|
} else {
|
||||||
IConsoleError("Client not found");
|
IConsoleError("Client not found");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -974,7 +994,9 @@ DEF_CONSOLE_CMD(ConDebugLevel)
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
IConsolePrintF(_icolour_def, "Current debug-level: '%s'", GetDebugString());
|
IConsolePrintF(_icolour_def, "Current debug-level: '%s'", GetDebugString());
|
||||||
} else SetDebugString(argv[1]);
|
} else {
|
||||||
|
SetDebugString(argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1126,8 +1148,9 @@ DEF_CONSOLE_CMD(ConSay)
|
||||||
|
|
||||||
if (!_network_server) {
|
if (!_network_server) {
|
||||||
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0 /* param does not matter */, argv[1]);
|
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);
|
NetworkServer_HandleChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, argv[1], NETWORK_SERVER_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1176,8 +1199,9 @@ DEF_CONSOLE_CMD(ConSayPlayer)
|
||||||
|
|
||||||
if (!_network_server) {
|
if (!_network_server) {
|
||||||
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2]);
|
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);
|
NetworkServer_HandleChat(NETWORK_ACTION_CHAT_PLAYER, DESTTYPE_PLAYER, atoi(argv[1]), argv[2], NETWORK_SERVER_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1194,8 +1218,9 @@ DEF_CONSOLE_CMD(ConSayClient)
|
||||||
|
|
||||||
if (!_network_server) {
|
if (!_network_server) {
|
||||||
SEND_COMMAND(PACKET_CLIENT_CHAT)(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2]);
|
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);
|
NetworkServer_HandleChat(NETWORK_ACTION_CHAT_CLIENT, DESTTYPE_CLIENT, atoi(argv[1]), argv[2], NETWORK_SERVER_INDEX);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1314,8 +1339,9 @@ DEF_CONSOLE_CMD(ConPatch)
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
IConsoleGetPatchSetting(argv[1]);
|
IConsoleGetPatchSetting(argv[1]);
|
||||||
} else
|
} else {
|
||||||
IConsoleSetPatchSetting(argv[1], argv[2]);
|
IConsoleSetPatchSetting(argv[1], argv[2]);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
6
depot.c
6
depot.c
|
@ -41,8 +41,7 @@ Depot *GetDepotByTile(TileIndex tile)
|
||||||
Depot *depot;
|
Depot *depot;
|
||||||
|
|
||||||
FOR_ALL_DEPOTS(depot) {
|
FOR_ALL_DEPOTS(depot) {
|
||||||
if (depot->xy == tile)
|
if (depot->xy == tile) return depot;
|
||||||
return depot;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -67,8 +66,7 @@ Depot *AllocateDepot(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we can add a block to the pool */
|
/* Check if we can add a block to the pool */
|
||||||
if (AddBlockToPool(&_depot_pool))
|
if (AddBlockToPool(&_depot_pool)) return AllocateDepot();
|
||||||
return AllocateDepot();
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
25
depot.h
25
depot.h
|
@ -90,20 +90,19 @@ 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
|
* 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 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
|
* @param tileh The slope of the tile in question
|
||||||
@return true if the construction is possible
|
* @return true if the construction is possible
|
||||||
|
|
||||||
|
* This is checked by the ugly 0x4C >> direction magic, which does the following:
|
||||||
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)
|
||||||
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>
|
||||||
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>
|
||||||
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>
|
||||||
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>
|
||||||
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>
|
||||||
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
|
||||||
So ((0x4C >> p2) & tileh) determines whether the depot can be built on the current tileh
|
|
||||||
*/
|
*/
|
||||||
static inline bool CanBuildDepotByTileh(uint32 direction, Slope tileh)
|
static inline bool CanBuildDepotByTileh(uint32 direction, Slope tileh)
|
||||||
{
|
{
|
||||||
|
|
|
@ -599,9 +599,10 @@ static void DisasterTick_4(Vehicle *v)
|
||||||
} while (tile != tile_org);
|
} while (tile != tile_org);
|
||||||
v->dest_tile = tile;
|
v->dest_tile = tile;
|
||||||
v->age = 0;
|
v->age = 0;
|
||||||
} else
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The plane which will shoot down the UFO
|
// The plane which will shoot down the UFO
|
||||||
static void DisasterTick_4b(Vehicle *v)
|
static void DisasterTick_4b(Vehicle *v)
|
||||||
|
@ -664,8 +665,7 @@ static void DisasterTick_5_and_6(Vehicle *v)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(v->tick_counter&1))
|
if (!(v->tick_counter & 1)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
tile = v->tile + TileOffsByDir(DirToDiagDir(v->direction));
|
tile = v->tile + TileOffsByDir(DirToDiagDir(v->direction));
|
||||||
if (IsValidTile(tile) &&
|
if (IsValidTile(tile) &&
|
||||||
|
@ -715,11 +715,9 @@ static void Disaster0_Init(void)
|
||||||
Station *st;
|
Station *st;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (v == NULL)
|
if (v == NULL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
/* Pick a random place, unless we find
|
/* Pick a random place, unless we find a small airport */
|
||||||
a small airport */
|
|
||||||
x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
|
x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
|
||||||
|
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
|
@ -747,8 +745,7 @@ static void Disaster1_Init(void)
|
||||||
Vehicle *v = ForceAllocateSpecialVehicle(), *u;
|
Vehicle *v = ForceAllocateSpecialVehicle(), *u;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
if (v == NULL)
|
if (v == NULL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
|
x = TileX(Random()) * TILE_SIZE + TILE_SIZE / 2;
|
||||||
|
|
||||||
|
@ -781,12 +778,10 @@ static void Disaster2_Init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == NULL)
|
if (found == NULL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
v = ForceAllocateSpecialVehicle();
|
v = ForceAllocateSpecialVehicle();
|
||||||
if (v == NULL)
|
if (v == NULL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
x = (MapSizeX() + 9) * TILE_SIZE - 1;
|
x = (MapSizeX() + 9) * TILE_SIZE - 1;
|
||||||
y = TileY(found->xy) * TILE_SIZE + 37;
|
y = TileY(found->xy) * TILE_SIZE + 37;
|
||||||
|
@ -817,12 +812,10 @@ static void Disaster3_Init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == NULL)
|
if (found == NULL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
v = ForceAllocateSpecialVehicle();
|
v = ForceAllocateSpecialVehicle();
|
||||||
if (v == NULL)
|
if (v == NULL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
x = -16 * TILE_SIZE;
|
x = -16 * TILE_SIZE;
|
||||||
y = TileY(found->xy) * TILE_SIZE + 37;
|
y = TileY(found->xy) * TILE_SIZE + 37;
|
||||||
|
|
31
economy.c
31
economy.c
|
@ -102,8 +102,7 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
||||||
uint num = 0;
|
uint num = 0;
|
||||||
|
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->owner != owner)
|
if (v->owner != owner) continue;
|
||||||
continue;
|
|
||||||
if ((v->type == VEH_Train && IsFrontEngine(v)) ||
|
if ((v->type == VEH_Train && IsFrontEngine(v)) ||
|
||||||
v->type == VEH_Road ||
|
v->type == VEH_Road ||
|
||||||
(v->type == VEH_Aircraft && v->subtype <= 2) ||
|
(v->type == VEH_Aircraft && v->subtype <= 2) ||
|
||||||
|
@ -114,11 +113,12 @@ int UpdateCompanyRatingAndValue(Player *p, bool update)
|
||||||
if (min_profit_first == true) {
|
if (min_profit_first == true) {
|
||||||
min_profit = v->profit_last_year;
|
min_profit = v->profit_last_year;
|
||||||
min_profit_first = false;
|
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;
|
min_profit = v->profit_last_year;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_score_part[owner][SCORE_VEHICLES] = num;
|
_score_part[owner][SCORE_VEHICLES] = num;
|
||||||
/* Don't allow negative min_profit to show */
|
/* Don't allow negative min_profit to show */
|
||||||
|
@ -249,8 +249,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
||||||
|
|
||||||
for (s = _subsidies; s != endof(_subsidies); s++) {
|
for (s = _subsidies; s != endof(_subsidies); s++) {
|
||||||
if (s->cargo_type != CT_INVALID && s->age >= 12) {
|
if (s->cargo_type != CT_INVALID && s->age >= 12) {
|
||||||
if (GetStation(s->to)->owner == old_player)
|
if (GetStation(s->to)->owner == old_player) s->cargo_type = CT_INVALID;
|
||||||
s->cargo_type = CT_INVALID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,18 +289,10 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->owner == new_player) {
|
if (v->owner == new_player) {
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_Train:
|
case VEH_Train: if (IsFrontEngine(v)) num_train++; break;
|
||||||
if (IsFrontEngine(v)) num_train++;
|
case VEH_Road: num_road++; break;
|
||||||
break;
|
case VEH_Ship: num_ship++; break;
|
||||||
case VEH_Road:
|
case VEH_Aircraft: if (v->subtype <= 2) num_aircraft++; break;
|
||||||
num_road++;
|
|
||||||
break;
|
|
||||||
case VEH_Ship:
|
|
||||||
num_ship++;
|
|
||||||
break;
|
|
||||||
case VEH_Aircraft:
|
|
||||||
if (v->subtype <= 2) num_aircraft++;
|
|
||||||
break;
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -339,8 +330,7 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
||||||
if (new_player != OWNER_SPECTATOR) {
|
if (new_player != OWNER_SPECTATOR) {
|
||||||
Window *w;
|
Window *w;
|
||||||
for (w = _windows; w != _last_window; w++) {
|
for (w = _windows; w != _last_window; w++) {
|
||||||
if (w->caption_color == old_player)
|
if (w->caption_color == old_player) w->caption_color = new_player;
|
||||||
w->caption_color = new_player;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,10 +342,11 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) {
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
/* 'Sell' the share if this player has any */
|
/* '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->share_owners[i] = OWNER_SPECTATOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
p = GetPlayer(_current_player);
|
p = GetPlayer(_current_player);
|
||||||
/* Sell all the shares that people have on this company */
|
/* Sell all the shares that people have on this company */
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
|
|
|
@ -43,7 +43,7 @@ enum {
|
||||||
|
|
||||||
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
|
SCORE_MAX = 1000 // The max score that can be in the performance history
|
||||||
// the scores together of score_info is allowed to be more!
|
// the scores together of score_info is allowed to be more!
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
14
elrail.c
14
elrail.c
|
@ -84,6 +84,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MP_TUNNELBRIDGE:
|
case MP_TUNNELBRIDGE:
|
||||||
if (IsTunnel(t)) {
|
if (IsTunnel(t)) {
|
||||||
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
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;
|
return DiagDirToAxis(GetBridgeRampDirection(t)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case MP_STREET:
|
case MP_STREET:
|
||||||
if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return 0;
|
if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return 0;
|
||||||
if (GetRailTypeCrossing(t) != RAILTYPE_ELECTRIC) return 0;
|
if (GetRailTypeCrossing(t) != RAILTYPE_ELECTRIC) return 0;
|
||||||
return GetCrossingRailBits(t);
|
return GetCrossingRailBits(t);
|
||||||
|
|
||||||
case MP_STATION:
|
case MP_STATION:
|
||||||
if (!IsRailwayStation(t)) return 0;
|
if (!IsRailwayStation(t)) return 0;
|
||||||
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
||||||
if (!IsStationTileElectrifiable(t)) return 0;
|
if (!IsStationTileElectrifiable(t)) return 0;
|
||||||
return TrackToTrackBits(GetRailStationTrack(t));
|
return TrackToTrackBits(GetRailStationTrack(t));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -124,8 +128,11 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
||||||
*/
|
*/
|
||||||
static void AdjustTileh(TileIndex tile, Slope* tileh)
|
static void AdjustTileh(TileIndex tile, Slope* tileh)
|
||||||
{
|
{
|
||||||
if (IsTunnelTile(tile)) *tileh = SLOPE_FLAT;
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
if (IsBridgeTile(tile) && IsBridgeRamp(tile)) {
|
if (IsTunnel(tile)) {
|
||||||
|
*tileh = SLOPE_FLAT;
|
||||||
|
} else {
|
||||||
|
if (IsBridgeRamp(tile)) {
|
||||||
if (*tileh != SLOPE_FLAT) {
|
if (*tileh != SLOPE_FLAT) {
|
||||||
*tileh = SLOPE_FLAT;
|
*tileh = SLOPE_FLAT;
|
||||||
} else {
|
} else {
|
||||||
|
@ -139,6 +146,8 @@ static void AdjustTileh(TileIndex tile, Slope* tileh)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Draws wires and, if required, pylons on a given tile
|
/** Draws wires and, if required, pylons on a given tile
|
||||||
* @param ti The Tileinfo to draw the tile for
|
* @param ti The Tileinfo to draw the tile for
|
||||||
|
@ -251,6 +260,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
|
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
|
||||||
for (k = 0; k < DIR_END; k++) {
|
for (k = 0; k < DIR_END; k++) {
|
||||||
byte temp = PPPorder[i][GetTLG(ti->tile)][k];
|
byte temp = PPPorder[i][GetTLG(ti->tile)][k];
|
||||||
|
|
||||||
if (HASBIT(PPPallowed[i], temp)) {
|
if (HASBIT(PPPallowed[i], temp)) {
|
||||||
uint x = ti->x + x_pcp_offsets[i] + x_ppp_offsets[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];
|
uint y = ti->y + y_pcp_offsets[i] + y_ppp_offsets[temp];
|
||||||
|
|
4
fileio.c
4
fileio.c
|
@ -133,9 +133,9 @@ bool FiosCheckFileExists(const char *filename)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
return false;
|
return false;
|
||||||
else {
|
} else {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,9 @@ static void SelectGameWndProc(Window *w, WindowEvent *e)
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
if (!_network_available) {
|
if (!_network_available) {
|
||||||
ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
ShowErrorMessage(INVALID_STRING_ID, STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||||
} else
|
} else {
|
||||||
ShowNetworkGameWindow();
|
ShowNetworkGameWindow();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
ShowErrorMessage(INVALID_STRING_ID ,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
ShowErrorMessage(INVALID_STRING_ID ,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -90,10 +90,11 @@ void HandleOnEditText(WindowEvent *e)
|
||||||
// Inform the player of this action
|
// Inform the player of this action
|
||||||
snprintf(msg, sizeof(msg), "%d", money);
|
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);
|
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);
|
NetworkServer_HandleChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_PLAYER, id + 1, msg, NETWORK_SERVER_INDEX);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: /* Game-Password and Company-Password */
|
case 4: /* Game-Password and Company-Password */
|
||||||
|
@ -2273,7 +2274,8 @@ static WindowDesc _main_status_desc = {
|
||||||
|
|
||||||
extern void UpdateAllStationVirtCoord(void);
|
extern void UpdateAllStationVirtCoord(void);
|
||||||
|
|
||||||
static void MainWindowWndProc(Window *w, WindowEvent *e) {
|
static void MainWindowWndProc(Window* w, WindowEvent* e)
|
||||||
|
{
|
||||||
int off_x;
|
int off_x;
|
||||||
|
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
|
|
|
@ -146,8 +146,9 @@ int32 CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
DeleteName(p->name_1);
|
DeleteName(p->name_1);
|
||||||
p->name_1 = str;
|
p->name_1 = str;
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
} else
|
} else {
|
||||||
DeleteName(str);
|
DeleteName(str);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
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);
|
DoCommand(0, 0, 0, DC_EXEC, CMD_CHANGE_COMPANY_NAME);
|
||||||
}
|
}
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
} else
|
} else {
|
||||||
DeleteName(str);
|
DeleteName(str);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -269,8 +271,9 @@ int32 CmdChangeDifficultyLevel(TileIndex tile, uint32 flags, uint32 p1, uint32 p
|
||||||
if (p1 != (uint32)-1L) {
|
if (p1 != (uint32)-1L) {
|
||||||
((int*)&_opt_ptr->diff)[p1] = p2;
|
((int*)&_opt_ptr->diff)[p1] = p2;
|
||||||
_opt_ptr->diff_level = 3; // custom difficulty level
|
_opt_ptr->diff_level = 3; // custom difficulty level
|
||||||
} else
|
} else {
|
||||||
_opt_ptr->diff_level = p2;
|
_opt_ptr->diff_level = p2;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we are a network-client, update the difficult setting (if it is open).
|
/* 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
|
* Use this instead of just dirtying the window because we need to load in
|
||||||
|
|
17
misc_gui.c
17
misc_gui.c
|
@ -920,9 +920,10 @@ int HandleEditBoxKey(Window *w, querystr_d *string, int wid, WindowEvent *we)
|
||||||
if (IsValidAsciiChar(we->keypress.ascii)) {
|
if (IsValidAsciiChar(we->keypress.ascii)) {
|
||||||
if (InsertTextBufferChar(&string->text, we->keypress.ascii))
|
if (InsertTextBufferChar(&string->text, we->keypress.ascii))
|
||||||
InvalidateWidget(w, wid);
|
InvalidateWidget(w, wid);
|
||||||
} else // key wasn't caught
|
} else { // key wasn't caught
|
||||||
we->keypress.cont = true;
|
we->keypress.cont = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1507,8 +1508,7 @@ static void SelectScenarioWndProc(Window* w, WindowEvent* e)
|
||||||
const int list_start = 45;
|
const int list_start = 45;
|
||||||
|
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
case WE_PAINT:
|
case WE_PAINT: {
|
||||||
{
|
|
||||||
int y,pos;
|
int y,pos;
|
||||||
const FiosItem *item;
|
const FiosItem *item;
|
||||||
|
|
||||||
|
@ -1556,15 +1556,14 @@ static void SelectScenarioWndProc(Window* w, WindowEvent* e)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: /* Click the listbox */
|
case 6: /* Click the listbox */
|
||||||
if (e->click.pt.y < list_start)
|
if (e->click.pt.y < list_start) {
|
||||||
GenRandomNewGame(Random(), InteractiveRandom());
|
GenRandomNewGame(Random(), InteractiveRandom());
|
||||||
else {
|
} else {
|
||||||
char *name;
|
|
||||||
int y = (e->click.pt.y - list_start) / 10;
|
int y = (e->click.pt.y - list_start) / 10;
|
||||||
|
const char* name;
|
||||||
const FiosItem *file;
|
const FiosItem *file;
|
||||||
|
|
||||||
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count)
|
if (y < 0 || (y += w->vscroll.pos) >= w->vscroll.count) return;
|
||||||
return;
|
|
||||||
|
|
||||||
file = _fios_list + y;
|
file = _fios_list + y;
|
||||||
|
|
||||||
|
@ -1578,8 +1577,6 @@ static void SelectScenarioWndProc(Window* w, WindowEvent* e)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WE_DESTROY:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WE_RESIZE: {
|
case WE_RESIZE: {
|
||||||
/* Widget 3 and 4 have to go with halve speed, make it so obiwan */
|
/* Widget 3 and 4 have to go with halve speed, make it so obiwan */
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
/*
|
/* $Id$ */
|
||||||
* qtmidi.h
|
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MUSIC_MACOSX_QUICKTIME_H
|
#ifndef MUSIC_MACOSX_QUICKTIME_H
|
||||||
#define MUSIC_MACOSX_QUICKTIME_H
|
#define MUSIC_MACOSX_QUICKTIME_H
|
||||||
|
|
11
namegen.c
11
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.
|
// Select randomly if town name should consists of one or two parts.
|
||||||
if (SeedChance(0, 15, seed) >= 10) {
|
if (SeedChance(0, 15, seed) >= 10) {
|
||||||
strcat(buf, name_finnish_real[SeedChance( 2, lengthof(name_finnish_real), seed)]);
|
strcat(buf, name_finnish_real[SeedChance( 2, lengthof(name_finnish_real), seed)]);
|
||||||
}
|
} else if (SeedChance(0, 15, seed) >= 5) {
|
||||||
// A two-part name by combining one of name_finnish_1 + "la"/"lä"
|
// 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
|
// 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.
|
// that the ones in name_finnish_2 are not good for this purpose.
|
||||||
else if (SeedChance(0, 15, seed) >= 5) {
|
|
||||||
uint sel = SeedChance( 0, lengthof(name_finnish_1), seed);
|
uint sel = SeedChance( 0, lengthof(name_finnish_1), seed);
|
||||||
char *last;
|
char *last;
|
||||||
strcat(buf, name_finnish_1[sel]);
|
strcat(buf, name_finnish_1[sel]);
|
||||||
|
@ -297,10 +296,9 @@ static byte MakeFinnishTownName(char *buf, uint32 seed)
|
||||||
} else {
|
} else {
|
||||||
strcat(buf, "lä");
|
strcat(buf, "lä");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
// A two-part name by combining one of name_finnish_{1,2} + name_finnish_3.
|
// 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.
|
// Why aren't name_finnish_{1,2} just one table? See above.
|
||||||
else {
|
|
||||||
uint sel = SeedChance(2,
|
uint sel = SeedChance(2,
|
||||||
lengthof(name_finnish_1) + lengthof(name_finnish_2), seed);
|
lengthof(name_finnish_1) + lengthof(name_finnish_2), seed);
|
||||||
if (sel >= lengthof(name_finnish_1)) {
|
if (sel >= lengthof(name_finnish_1)) {
|
||||||
|
@ -424,10 +422,11 @@ static byte MakeCzechTownName(char *buf, uint32 seed)
|
||||||
// Always drop a postfix.
|
// Always drop a postfix.
|
||||||
postfix += lengthof(name_czech_subst_postfix);
|
postfix += lengthof(name_czech_subst_postfix);
|
||||||
}
|
}
|
||||||
if (postfix < lengthof(name_czech_subst_postfix))
|
if (postfix < lengthof(name_czech_subst_postfix)) {
|
||||||
choose |= CZC_POSTFIX;
|
choose |= CZC_POSTFIX;
|
||||||
else
|
} else {
|
||||||
choose |= CZC_NOPOSTFIX;
|
choose |= CZC_NOPOSTFIX;
|
||||||
|
}
|
||||||
|
|
||||||
// Localize the array segment containing a good gender
|
// Localize the array segment containing a good gender
|
||||||
for (ending = 0; ending < (int) lengthof(name_czech_subst_ending); ending++) {
|
for (ending = 0; ending < (int) lengthof(name_czech_subst_ending); ending++) {
|
||||||
|
|
73
network.c
73
network.c
|
@ -54,9 +54,9 @@ NetworkClientInfo *NetworkFindClientInfoFromIndex(uint16 client_index)
|
||||||
{
|
{
|
||||||
NetworkClientInfo *ci;
|
NetworkClientInfo *ci;
|
||||||
|
|
||||||
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++)
|
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) {
|
||||||
if (ci->client_index == client_index)
|
if (ci->client_index == client_index) return ci;
|
||||||
return ci;
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -81,9 +81,9 @@ NetworkClientState *NetworkFindClientStateFromIndex(uint16 client_index)
|
||||||
{
|
{
|
||||||
NetworkClientState *cs;
|
NetworkClientState *cs;
|
||||||
|
|
||||||
for (cs = _clients; cs != &_clients[MAX_CLIENT_INFO]; cs++)
|
for (cs = _clients; cs != &_clients[MAX_CLIENT_INFO]; cs++) {
|
||||||
if (cs->index == client_index)
|
if (cs->index == client_index) return cs;
|
||||||
return cs;
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -93,11 +93,13 @@ NetworkClientState *NetworkFindClientStateFromIndex(uint16 client_index)
|
||||||
void NetworkGetClientName(char *client_name, size_t size, const NetworkClientState *cs)
|
void NetworkGetClientName(char *client_name, size_t size, const NetworkClientState *cs)
|
||||||
{
|
{
|
||||||
const NetworkClientInfo *ci = DEREF_CLIENT_INFO(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);
|
snprintf(client_name, size, "Client #%4d", cs->index);
|
||||||
else
|
} else {
|
||||||
ttd_strlcpy(client_name, ci->client_name, size);
|
ttd_strlcpy(client_name, ci->client_name, size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
byte NetworkSpectatorCount(void)
|
byte NetworkSpectatorCount(void)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +220,8 @@ static void ServerStartError(const char *error)
|
||||||
NetworkError(STR_NETWORK_ERR_SERVER_START);
|
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
|
// First, send a CLIENT_ERROR to the server, so he knows we are
|
||||||
// disconnection (and why!)
|
// disconnection (and why!)
|
||||||
NetworkErrorCode errorno;
|
NetworkErrorCode errorno;
|
||||||
|
@ -236,7 +239,7 @@ static void NetworkClientError(byte res, NetworkClientState *cs) {
|
||||||
switch (res) {
|
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;
|
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
|
// This means we fucked up and the server closed the connection
|
||||||
if (res != NETWORK_RECV_STATUS_SERVER_ERROR && res != NETWORK_RECV_STATUS_SERVER_FULL &&
|
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
|
/** Retrieve a string representation of an internal error number
|
||||||
* @param buf buffer where the error message will be stored
|
* @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) */
|
* @return returns a pointer to the error message (buf) */
|
||||||
char *GetNetworkErrorMsg(char *buf, NetworkErrorCode err)
|
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_PLAYER_MISMATCH,
|
||||||
STR_NETWORK_ERR_CLIENT_KICKED,
|
STR_NETWORK_ERR_CLIENT_KICKED,
|
||||||
STR_NETWORK_ERR_CLIENT_CHEATER,
|
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;
|
if (err >= lengthof(network_error_strings)) err = 0;
|
||||||
|
@ -992,10 +995,11 @@ static void NetworkInitGameInfo(void)
|
||||||
memset(ci, 0, sizeof(*ci));
|
memset(ci, 0, sizeof(*ci));
|
||||||
|
|
||||||
ci->client_index = NETWORK_SERVER_INDEX;
|
ci->client_index = NETWORK_SERVER_INDEX;
|
||||||
if (_network_dedicated)
|
if (_network_dedicated) {
|
||||||
ci->client_playas = OWNER_SPECTATOR;
|
ci->client_playas = OWNER_SPECTATOR;
|
||||||
else
|
} else {
|
||||||
ci->client_playas = _local_player + 1;
|
ci->client_playas = _local_player + 1;
|
||||||
|
}
|
||||||
ttd_strlcpy(ci->client_name, _network_player_name, sizeof(ci->client_name));
|
ttd_strlcpy(ci->client_name, _network_player_name, sizeof(ci->client_name));
|
||||||
ttd_strlcpy(ci->unique_id, _network_unique_id, sizeof(ci->unique_id));
|
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);
|
if (n == -1 && !_network_server) NetworkError(STR_NETWORK_ERR_LOSTCONNECTION);
|
||||||
|
|
||||||
// accept clients..
|
// accept clients..
|
||||||
if (_network_server && FD_ISSET(_listensocket, &read_fd))
|
if (_network_server && FD_ISSET(_listensocket, &read_fd)) {
|
||||||
NetworkAcceptClients();
|
NetworkAcceptClients();
|
||||||
|
}
|
||||||
|
|
||||||
// read stuff from clients
|
// read stuff from clients
|
||||||
FOR_ALL_CLIENTS(cs) {
|
FOR_ALL_CLIENTS(cs) {
|
||||||
cs->writable = !!FD_ISSET(cs->socket, &write_fd);
|
cs->writable = !!FD_ISSET(cs->socket, &write_fd);
|
||||||
if (FD_ISSET(cs->socket, &read_fd)) {
|
if (FD_ISSET(cs->socket, &read_fd)) {
|
||||||
if (_network_server)
|
if (_network_server) {
|
||||||
NetworkServer_ReadPackets(cs);
|
NetworkServer_ReadPackets(cs);
|
||||||
else {
|
} else {
|
||||||
byte res;
|
byte res;
|
||||||
|
|
||||||
// The client already was quiting!
|
// The client already was quiting!
|
||||||
if (cs->quited) return false;
|
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
|
// The client made an error of which we can not recover
|
||||||
// close the client and drop back to main menu
|
// close the client and drop back to main menu
|
||||||
|
|
||||||
NetworkClientError(res, cs);
|
NetworkClientError(res, cs);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1341,9 +1348,9 @@ void NetworkStartUp(void)
|
||||||
* IMPORTANT NOTE: SocketBase needs to be initialized before we use _any_
|
* IMPORTANT NOTE: SocketBase needs to be initialized before we use _any_
|
||||||
* network related function, else: crash.
|
* network related function, else: crash.
|
||||||
*/
|
*/
|
||||||
{
|
|
||||||
DEBUG(misc,3) ("[NET][Core] Loading bsd socket library");
|
DEBUG(misc,3) ("[NET][Core] Loading bsd socket library");
|
||||||
if (!(SocketBase = OpenLibrary("bsdsocket.library", 4))) {
|
SocketBase = OpenLibrary("bsdsocket.library", 4);
|
||||||
|
if (SocketBase == NULL) {
|
||||||
DEBUG(net, 0) ("[NET][Core] Error: couldn't open bsdsocket.library version 4. Network not available.");
|
DEBUG(net, 0) ("[NET][Core] Error: couldn't open bsdsocket.library version 4. Network not available.");
|
||||||
_network_available = false;
|
_network_available = false;
|
||||||
return;
|
return;
|
||||||
|
@ -1351,10 +1358,13 @@ void NetworkStartUp(void)
|
||||||
|
|
||||||
#if defined(__AMIGA__)
|
#if defined(__AMIGA__)
|
||||||
// for usleep() implementation (only required for legacy AmigaOS builds)
|
// for usleep() implementation (only required for legacy AmigaOS builds)
|
||||||
if ( (TimerPort = CreateMsgPort()) ) {
|
TimerPort = CreateMsgPort();
|
||||||
if ( (TimerRequest = (struct timerequest *) CreateIORequest(TimerPort, sizeof(struct timerequest))) ) {
|
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) {
|
if (OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest*)TimerRequest, 0) == 0) {
|
||||||
if ( !(TimerBase = TimerRequest->tr_node.io_Device) ) {
|
TimerBase = TimerRequest->tr_node.io_Device;
|
||||||
|
if (TimerBase == NULL) {
|
||||||
// free ressources...
|
// free ressources...
|
||||||
DEBUG(net, 0) ("[NET][Core] Error: couldn't initialize timer. Network not available.");
|
DEBUG(net, 0) ("[NET][Core] Error: couldn't initialize timer. Network not available.");
|
||||||
_network_available = false;
|
_network_available = false;
|
||||||
|
@ -1364,7 +1374,6 @@ void NetworkStartUp(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // __AMIGA__
|
#endif // __AMIGA__
|
||||||
}
|
|
||||||
#endif // __MORPHOS__ / __AMIGA__
|
#endif // __MORPHOS__ / __AMIGA__
|
||||||
|
|
||||||
// Network is available
|
// Network is available
|
||||||
|
@ -1413,24 +1422,18 @@ void NetworkShutDown(void)
|
||||||
_network_available = false;
|
_network_available = false;
|
||||||
|
|
||||||
#if defined(__MORPHOS__) || defined(__AMIGA__)
|
#if defined(__MORPHOS__) || defined(__AMIGA__)
|
||||||
{
|
|
||||||
// free allocated ressources
|
// free allocated ressources
|
||||||
#if defined(__AMIGA__)
|
#if defined(__AMIGA__)
|
||||||
if (TimerBase) { CloseDevice((struct IORequest *) TimerRequest); }
|
if (TimerBase != NULL) CloseDevice((struct IORequest*)TimerRequest); // XXX This smells wrong
|
||||||
if (TimerRequest) { DeleteIORequest(TimerRequest); }
|
if (TimerRequest != NULL) DeleteIORequest(TimerRequest);
|
||||||
if (TimerPort) { DeleteMsgPort(TimerPort); }
|
if (TimerPort != NULL) DeleteMsgPort(TimerPort);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SocketBase) {
|
if (SocketBase != NULL) CloseLibrary(SocketBase);
|
||||||
CloseLibrary(SocketBase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
{
|
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,9 +178,10 @@ bool NetworkSend_Packets(NetworkClientState *cs)
|
||||||
cs->packet_queue = p->next;
|
cs->packet_queue = p->next;
|
||||||
free(p);
|
free(p);
|
||||||
p = cs->packet_queue;
|
p = cs->packet_queue;
|
||||||
} else
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -192,8 +193,7 @@ bool NetworkSend_Packets(NetworkClientState *cs)
|
||||||
uint8 NetworkRecv_uint8(NetworkClientState *cs, Packet *packet)
|
uint8 NetworkRecv_uint8(NetworkClientState *cs, Packet *packet)
|
||||||
{
|
{
|
||||||
/* Don't allow reading from a closed socket */
|
/* Don't allow reading from a closed socket */
|
||||||
if (cs->quited)
|
if (cs->quited) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Check if variable is within packet-size */
|
/* Check if variable is within packet-size */
|
||||||
if (packet->pos + 1 > packet->size) {
|
if (packet->pos + 1 > packet->size) {
|
||||||
|
@ -209,8 +209,7 @@ uint16 NetworkRecv_uint16(NetworkClientState *cs, Packet *packet)
|
||||||
uint16 n;
|
uint16 n;
|
||||||
|
|
||||||
/* Don't allow reading from a closed socket */
|
/* Don't allow reading from a closed socket */
|
||||||
if (cs->quited)
|
if (cs->quited) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Check if variable is within packet-size */
|
/* Check if variable is within packet-size */
|
||||||
if (packet->pos + 2 > packet->size) {
|
if (packet->pos + 2 > packet->size) {
|
||||||
|
@ -228,8 +227,7 @@ uint32 NetworkRecv_uint32(NetworkClientState *cs, Packet *packet)
|
||||||
uint32 n;
|
uint32 n;
|
||||||
|
|
||||||
/* Don't allow reading from a closed socket */
|
/* Don't allow reading from a closed socket */
|
||||||
if (cs->quited)
|
if (cs->quited) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Check if variable is within packet-size */
|
/* Check if variable is within packet-size */
|
||||||
if (packet->pos + 4 > packet->size) {
|
if (packet->pos + 4 > packet->size) {
|
||||||
|
@ -249,8 +247,7 @@ uint64 NetworkRecv_uint64(NetworkClientState *cs, Packet *packet)
|
||||||
uint64 n;
|
uint64 n;
|
||||||
|
|
||||||
/* Don't allow reading from a closed socket */
|
/* Don't allow reading from a closed socket */
|
||||||
if (cs->quited)
|
if (cs->quited) return 0;
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Check if variable is within packet-size */
|
/* Check if variable is within packet-size */
|
||||||
if (packet->pos + 8 > 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
|
// Add a command to the local command queue
|
||||||
void NetworkAddCommandQueue(NetworkClientState *cs, CommandPacket *cp)
|
void NetworkAddCommandQueue(NetworkClientState *cs, CommandPacket *cp)
|
||||||
{
|
{
|
||||||
CommandPacket *new_cp = malloc(sizeof(CommandPacket));
|
CommandPacket* new_cp = malloc(sizeof(*new_cp));
|
||||||
|
|
||||||
*new_cp = *cp;
|
*new_cp = *cp;
|
||||||
|
|
||||||
if (cs->command_queue == NULL)
|
if (cs->command_queue == NULL) {
|
||||||
cs->command_queue = new_cp;
|
cs->command_queue = new_cp;
|
||||||
else {
|
} else {
|
||||||
CommandPacket *c = cs->command_queue;
|
CommandPacket *c = cs->command_queue;
|
||||||
while (c->next != NULL) c = c->next;
|
while (c->next != NULL) c = c->next;
|
||||||
c->next = new_cp;
|
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
|
// And we queue it for delivery to the clients
|
||||||
FOR_ALL_CLIENTS(cs) {
|
FOR_ALL_CLIENTS(cs) {
|
||||||
if (cs->status > STATUS_AUTH) {
|
if (cs->status > STATUS_AUTH) NetworkAddCommandQueue(cs, c);
|
||||||
NetworkAddCommandQueue(cs, c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only the server gets the callback, because clients should not get them
|
// Only the server gets the callback, because clients should not get them
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
|
|
||||||
//
|
|
||||||
// This file handles the GameList
|
// This file handles the GameList
|
||||||
// Also, it handles the request to a server for data about the server
|
// 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->ip = ip;
|
||||||
item->port = port;
|
item->port = port;
|
||||||
|
|
||||||
if (prev_item == NULL) {_network_game_list = item;}
|
if (prev_item == NULL) {
|
||||||
else {prev_item->next = item;}
|
_network_game_list = item;
|
||||||
|
} else {
|
||||||
|
prev_item->next = item;
|
||||||
|
}
|
||||||
DEBUG(net, 4) ("[NET][GameList] Added server to list");
|
DEBUG(net, 4) ("[NET][GameList] Added server to list");
|
||||||
|
|
||||||
UpdateNetworkGameWindow(false);
|
UpdateNetworkGameWindow(false);
|
||||||
|
@ -51,8 +53,11 @@ void NetworkGameListRemoveItem(NetworkGameList *remove)
|
||||||
prev_item = NULL;
|
prev_item = NULL;
|
||||||
for (item = _network_game_list; item != NULL; item = item->next) {
|
for (item = _network_game_list; item != NULL; item = item->next) {
|
||||||
if (remove == item) {
|
if (remove == item) {
|
||||||
if (prev_item == NULL) {_network_game_list = remove->next;}
|
if (prev_item == NULL) {
|
||||||
else {prev_item->next = remove->next;}
|
_network_game_list = remove->next;
|
||||||
|
} else {
|
||||||
|
prev_item->next = remove->next;
|
||||||
|
}
|
||||||
|
|
||||||
free(remove);
|
free(remove);
|
||||||
DEBUG(net, 4) ("[NET][GameList] Removed server from list");
|
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))
|
if (item == nd->map || (pos == 0 && nd->map == NULL))
|
||||||
GfxFillRect(11, y - 1, 258, y + 10, 155); // show highlighted item with a different colour
|
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);
|
if (pos == 0) {
|
||||||
else DoDrawString(item->title, 14, y, _fios_colors[item->type] );
|
DrawString(14, y, STR_4010_GENERATE_RANDOM_NEW_GAME, 9);
|
||||||
|
} else {
|
||||||
|
DoDrawString(item->title, 14, y, _fios_colors[item->type] );
|
||||||
|
}
|
||||||
pos++;
|
pos++;
|
||||||
y += NSSWND_ROWSIZE;
|
y += NSSWND_ROWSIZE;
|
||||||
|
|
||||||
|
@ -1262,7 +1265,9 @@ static void ClientListPopupWndProc(Window *w, WindowEvent *e)
|
||||||
if (sel-- == 0) { // Selected item, highlight it
|
if (sel-- == 0) { // Selected item, highlight it
|
||||||
GfxFillRect(1, y, 150 - 2, y + CLNWND_ROWSIZE - 1, 0);
|
GfxFillRect(1, y, 150 - 2, y + CLNWND_ROWSIZE - 1, 0);
|
||||||
colour = 0xC;
|
colour = 0xC;
|
||||||
} else colour = 0x10;
|
} else {
|
||||||
|
colour = 0x10;
|
||||||
|
}
|
||||||
|
|
||||||
DoDrawString(_clientlist_action[i], 4, y, colour);
|
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
|
if (_selected_clientlist_item == i++) { // Selected item, highlight it
|
||||||
GfxFillRect(1, y, 248, y + CLNWND_ROWSIZE - 1, 0);
|
GfxFillRect(1, y, 248, y + CLNWND_ROWSIZE - 1, 0);
|
||||||
colour = 0xC;
|
colour = 0xC;
|
||||||
} else
|
} else {
|
||||||
colour = 0x10;
|
colour = 0x10;
|
||||||
|
}
|
||||||
|
|
||||||
if (ci->client_index == NETWORK_SERVER_INDEX) {
|
if (ci->client_index == NETWORK_SERVER_INDEX) {
|
||||||
DrawString(4, y, STR_NETWORK_SERVER, colour);
|
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;
|
_selected_clientlist_y = e->mouseover.pt.y;
|
||||||
if (e->mouseover.pt.y > CLNWND_OFFSET) {
|
if (e->mouseover.pt.y > CLNWND_OFFSET) {
|
||||||
_selected_clientlist_item = (e->mouseover.pt.y - CLNWND_OFFSET) / CLNWND_ROWSIZE;
|
_selected_clientlist_item = (e->mouseover.pt.y - CLNWND_OFFSET) / CLNWND_ROWSIZE;
|
||||||
} else
|
} else {
|
||||||
_selected_clientlist_item = 255;
|
_selected_clientlist_item = 255;
|
||||||
|
}
|
||||||
|
|
||||||
// Repaint
|
// Repaint
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
|
|
|
@ -84,8 +84,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
|
||||||
NetworkPopulateCompanyInfo();
|
NetworkPopulateCompanyInfo();
|
||||||
|
|
||||||
FOR_ALL_PLAYERS(player) {
|
FOR_ALL_PLAYERS(player) {
|
||||||
if (!player->is_active)
|
if (!player->is_active) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
|
p = NetworkSend_Init(PACKET_SERVER_COMPANY_INFO);
|
||||||
|
|
||||||
|
@ -107,16 +106,19 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_COMPANY_INFO)
|
||||||
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]);
|
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]);
|
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>");
|
NetworkSend_string(p, "<none>");
|
||||||
else
|
} else {
|
||||||
NetworkSend_string(p, _network_player_info[player->index].players);
|
NetworkSend_string(p, _network_player_info[player->index].players);
|
||||||
|
}
|
||||||
|
|
||||||
NetworkSend_Packet(p, cs);
|
NetworkSend_Packet(p, cs);
|
||||||
}
|
}
|
||||||
|
@ -240,8 +242,7 @@ DEF_SERVER_SEND_COMMAND(PACKET_SERVER_WAIT)
|
||||||
|
|
||||||
// Count how many players are waiting in the queue
|
// Count how many players are waiting in the queue
|
||||||
FOR_ALL_CLIENTS(new_cs) {
|
FOR_ALL_CLIENTS(new_cs) {
|
||||||
if (new_cs->status == STATUS_MAP_WAIT)
|
if (new_cs->status == STATUS_MAP_WAIT) waiting++;
|
||||||
waiting++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p = NetworkSend_Init(PACKET_SERVER_WAIT);
|
p = NetworkSend_Init(PACKET_SERVER_WAIT);
|
||||||
|
@ -578,14 +579,12 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
|
||||||
|
|
||||||
#if defined(WITH_REV) || defined(WITH_REV_HACK)
|
#if defined(WITH_REV) || defined(WITH_REV_HACK)
|
||||||
// Check if the client has revision control enabled
|
// Check if the client has revision control enabled
|
||||||
if (strcmp(NOREV_STRING, client_revision) != 0) {
|
if (strcmp(NOREV_STRING, client_revision) != 0 &&
|
||||||
if (strcmp(_network_game_info.server_revision, client_revision) != 0) {
|
strcmp(_network_game_info.server_revision, client_revision) != 0) {
|
||||||
// Different revisions!!
|
// Different revisions!!
|
||||||
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
|
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NetworkRecv_string(cs, p, name, sizeof(name));
|
NetworkRecv_string(cs, p, name, sizeof(name));
|
||||||
|
@ -629,21 +628,21 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
|
||||||
|
|
||||||
// We now want a password from the client
|
// We now want a password from the client
|
||||||
// else we do not allow him in!
|
// 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);
|
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') {
|
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);
|
SEND_COMMAND(PACKET_SERVER_NEED_PASSWORD)(cs, NETWORK_COMPANY_PASSWORD);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
|
SEND_COMMAND(PACKET_SERVER_WELCOME)(cs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure companies to who people try to join are not autocleaned */
|
/* 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;
|
_network_player_info[playas-1].months_empty = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
|
DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
|
||||||
{
|
{
|
||||||
|
@ -1113,8 +1112,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_RCON)
|
||||||
char pass[NETWORK_PASSWORD_LENGTH];
|
char pass[NETWORK_PASSWORD_LENGTH];
|
||||||
char command[NETWORK_RCONCOMMAND_LENGTH];
|
char command[NETWORK_RCONCOMMAND_LENGTH];
|
||||||
|
|
||||||
if (_network_game_info.rcon_password[0] == '\0')
|
if (_network_game_info.rcon_password[0] == '\0') return;
|
||||||
return;
|
|
||||||
|
|
||||||
NetworkRecv_string(cs, p, pass, sizeof(pass));
|
NetworkRecv_string(cs, p, pass, sizeof(pass));
|
||||||
NetworkRecv_string(cs, p, command, sizeof(command));
|
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);
|
GetString(_network_player_info[p->index].company_name, STR_JUST_STRING);
|
||||||
|
|
||||||
// Check the income
|
// 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]
|
// 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];
|
_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];
|
_network_player_info[p->index].income -= p->yearly_expenses[1][i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set some general stuff
|
// Set some general stuff
|
||||||
_network_player_info[p->index].inaugurated_year = p->inaugurated_year;
|
_network_player_info[p->index].inaugurated_year = p->inaugurated_year;
|
||||||
|
@ -1226,25 +1227,32 @@ void NetworkPopulateCompanyInfo(void)
|
||||||
|
|
||||||
// Go through all vehicles and count the type of vehicles
|
// Go through all vehicles and count the type of vehicles
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->owner < MAX_PLAYERS)
|
if (v->owner >= MAX_PLAYERS) continue;
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_Train:
|
case VEH_Train:
|
||||||
if (IsFrontEngine(v))
|
if (IsFrontEngine(v)) {
|
||||||
_network_player_info[v->owner].num_vehicle[0]++;
|
_network_player_info[v->owner].num_vehicle[0]++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_Road:
|
case VEH_Road:
|
||||||
if (v->cargo_type != CT_PASSENGERS)
|
if (v->cargo_type != CT_PASSENGERS) {
|
||||||
_network_player_info[v->owner].num_vehicle[1]++;
|
_network_player_info[v->owner].num_vehicle[1]++;
|
||||||
else
|
} else {
|
||||||
_network_player_info[v->owner].num_vehicle[2]++;
|
_network_player_info[v->owner].num_vehicle[2]++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_Aircraft:
|
case VEH_Aircraft:
|
||||||
if (v->subtype <= 2)
|
if (v->subtype <= 2) {
|
||||||
_network_player_info[v->owner].num_vehicle[3]++;
|
_network_player_info[v->owner].num_vehicle[3]++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_Ship:
|
case VEH_Ship:
|
||||||
_network_player_info[v->owner].num_vehicle[4]++;
|
_network_player_info[v->owner].num_vehicle[4]++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_Special:
|
case VEH_Special:
|
||||||
case VEH_Disaster:
|
case VEH_Disaster:
|
||||||
break;
|
break;
|
||||||
|
@ -1254,16 +1262,13 @@ void NetworkPopulateCompanyInfo(void)
|
||||||
// Go through all stations and count the types of stations
|
// Go through all stations and count the types of stations
|
||||||
FOR_ALL_STATIONS(s) {
|
FOR_ALL_STATIONS(s) {
|
||||||
if (s->owner < MAX_PLAYERS) {
|
if (s->owner < MAX_PLAYERS) {
|
||||||
if ((s->facilities & FACIL_TRAIN))
|
NetworkPlayerInfo* npi = &_network_player_info[s->owner];
|
||||||
_network_player_info[s->owner].num_station[0]++;
|
|
||||||
if ((s->facilities & FACIL_TRUCK_STOP))
|
if (s->facilities & FACIL_TRAIN) npi->num_station[0]++;
|
||||||
_network_player_info[s->owner].num_station[1]++;
|
if (s->facilities & FACIL_TRUCK_STOP) npi->num_station[1]++;
|
||||||
if ((s->facilities & FACIL_BUS_STOP))
|
if (s->facilities & FACIL_BUS_STOP) npi->num_station[2]++;
|
||||||
_network_player_info[s->owner].num_station[2]++;
|
if (s->facilities & FACIL_AIRPORT) npi->num_station[3]++;
|
||||||
if ((s->facilities & FACIL_AIRPORT))
|
if (s->facilities & FACIL_DOCK) npi->num_station[4]++;
|
||||||
_network_player_info[s->owner].num_station[3]++;
|
|
||||||
if ((s->facilities & FACIL_DOCK))
|
|
||||||
_network_player_info[s->owner].num_station[4]++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1295,8 +1300,7 @@ void NetworkUpdateClientInfo(uint16 client_index)
|
||||||
|
|
||||||
ci = NetworkFindClientInfoFromIndex(client_index);
|
ci = NetworkFindClientInfoFromIndex(client_index);
|
||||||
|
|
||||||
if (ci == NULL)
|
if (ci == NULL) return;
|
||||||
return;
|
|
||||||
|
|
||||||
FOR_ALL_CLIENTS(cs) {
|
FOR_ALL_CLIENTS(cs) {
|
||||||
SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, ci);
|
SEND_COMMAND(PACKET_SERVER_CLIENT_INFO)(cs, ci);
|
||||||
|
@ -1330,8 +1334,7 @@ static void NetworkAutoCleanCompanies(void)
|
||||||
Player *p;
|
Player *p;
|
||||||
bool clients_in_company[MAX_PLAYERS];
|
bool clients_in_company[MAX_PLAYERS];
|
||||||
|
|
||||||
if (!_network_autoclean_companies)
|
if (!_network_autoclean_companies) return;
|
||||||
return;
|
|
||||||
|
|
||||||
memset(clients_in_company, 0, sizeof(clients_in_company));
|
memset(clients_in_company, 0, sizeof(clients_in_company));
|
||||||
|
|
||||||
|
@ -1352,8 +1355,7 @@ static void NetworkAutoCleanCompanies(void)
|
||||||
/* Go through all the comapnies */
|
/* Go through all the comapnies */
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) {
|
||||||
/* Skip the non-active once */
|
/* Skip the non-active once */
|
||||||
if (!p->is_active || p->is_ai)
|
if (!p->is_active || p->is_ai) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!clients_in_company[p->index]) {
|
if (!clients_in_company[p->index]) {
|
||||||
/* The company is empty for one month more */
|
/* The company is empty for one month more */
|
||||||
|
@ -1430,10 +1432,11 @@ bool NetworkServer_ReadPackets(NetworkClientState *cs)
|
||||||
NetworkRecvStatus res;
|
NetworkRecvStatus res;
|
||||||
while ((p = NetworkRecv_Packet(cs, &res)) != NULL) {
|
while ((p = NetworkRecv_Packet(cs, &res)) != NULL) {
|
||||||
byte type = NetworkRecv_uint8(cs, p);
|
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);
|
_network_server_packet[type](cs, p);
|
||||||
else
|
} else {
|
||||||
DEBUG(net, 0)("[NET][Server] Received invalid packet type %d", type);
|
DEBUG(net, 0)("[NET][Server] Received invalid packet type %d", type);
|
||||||
|
}
|
||||||
free(p);
|
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));
|
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 */
|
/* Check if we are allowed on this server based on the revision-match */
|
||||||
item->info.compatible = (
|
item->info.compatible =
|
||||||
strcmp(item->info.server_revision, _openttd_revision) == 0 ||
|
strcmp(item->info.server_revision, _openttd_revision) == 0 ||
|
||||||
strcmp(item->info.server_revision, NOREV_STRING) == 0) ? true : false;
|
strcmp(item->info.server_revision, NOREV_STRING) == 0;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,8 +162,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Just a fail-safe.. should never happen
|
// Just a fail-safe.. should never happen
|
||||||
if (!_network_udp_server)
|
if (!_network_udp_server) return;
|
||||||
return;
|
|
||||||
|
|
||||||
packet = NetworkSend_Init(PACKET_UDP_SERVER_DETAIL_INFO);
|
packet = NetworkSend_Init(PACKET_UDP_SERVER_DETAIL_INFO);
|
||||||
|
|
||||||
|
@ -178,8 +176,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
||||||
/* Go through all the players */
|
/* Go through all the players */
|
||||||
FOR_ALL_PLAYERS(player) {
|
FOR_ALL_PLAYERS(player) {
|
||||||
/* Skip non-active players */
|
/* Skip non-active players */
|
||||||
if (!player->is_active)
|
if (!player->is_active) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
current++;
|
current++;
|
||||||
|
|
||||||
|
@ -209,7 +206,7 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
||||||
/* Find the clients that are connected to this player */
|
/* Find the clients that are connected to this player */
|
||||||
FOR_ALL_CLIENTS(cs) {
|
FOR_ALL_CLIENTS(cs) {
|
||||||
ci = DEREF_CLIENT_INFO(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 */
|
/* The uint8 == 1 indicates that a client is following */
|
||||||
NetworkSend_uint8(packet, 1);
|
NetworkSend_uint8(packet, 1);
|
||||||
NetworkSend_string(packet, ci->client_name);
|
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 */
|
/* Also check for the server itself */
|
||||||
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
|
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 */
|
/* The uint8 == 1 indicates that a client is following */
|
||||||
NetworkSend_uint8(packet, 1);
|
NetworkSend_uint8(packet, 1);
|
||||||
NetworkSend_string(packet, ci->client_name);
|
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 */
|
/* And check if we have any spectators */
|
||||||
FOR_ALL_CLIENTS(cs) {
|
FOR_ALL_CLIENTS(cs) {
|
||||||
ci = DEREF_CLIENT_INFO(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 */
|
/* The uint8 == 1 indicates that a client is following */
|
||||||
NetworkSend_uint8(packet, 1);
|
NetworkSend_uint8(packet, 1);
|
||||||
NetworkSend_string(packet, ci->client_name);
|
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 */
|
/* Also check for the server itself */
|
||||||
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
|
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 */
|
/* The uint8 == 1 indicates that a client is following */
|
||||||
NetworkSend_uint8(packet, 1);
|
NetworkSend_uint8(packet, 1);
|
||||||
NetworkSend_string(packet, ci->client_name);
|
NetworkSend_string(packet, ci->client_name);
|
||||||
|
@ -260,7 +257,8 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIENT_DETAIL_INFO)
|
||||||
free(packet);
|
free(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_RESPONSE_LIST) {
|
DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_MASTER_RESPONSE_LIST)
|
||||||
|
{
|
||||||
int i;
|
int i;
|
||||||
struct in_addr ip;
|
struct in_addr ip;
|
||||||
uint16 port;
|
uint16 port;
|
||||||
|
@ -286,14 +284,16 @@ 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;
|
_network_advertise_retries = 0;
|
||||||
DEBUG(net, 2)("[NET][UDP] We are advertised on the master-server!");
|
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! */
|
/* We are advertised, but we don't want to! */
|
||||||
NetworkUDPRemoveAdvertise();
|
NetworkUDPRemoveAdvertise();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// The layout for the receive-functions by UDP
|
// The layout for the receive-functions by UDP
|
||||||
|
@ -440,8 +440,7 @@ void NetworkUDPReceive(SOCKET udp)
|
||||||
int packet_len;
|
int packet_len;
|
||||||
|
|
||||||
// If p is NULL, malloc him.. this prevents unneeded mallocs
|
// If p is NULL, malloc him.. this prevents unneeded mallocs
|
||||||
if (p == NULL)
|
if (p == NULL) p = malloc(sizeof(*p));
|
||||||
p = malloc(sizeof(Packet));
|
|
||||||
|
|
||||||
packet_len = sizeof(p->buffer);
|
packet_len = sizeof(p->buffer);
|
||||||
client_len = sizeof(client_addr);
|
client_len = sizeof(client_addr);
|
||||||
|
@ -470,15 +469,12 @@ void NetworkUDPReceive(SOCKET udp)
|
||||||
// Broadcast to all ips
|
// Broadcast to all ips
|
||||||
static void NetworkUDPBroadCast(SOCKET udp)
|
static void NetworkUDPBroadCast(SOCKET udp)
|
||||||
{
|
{
|
||||||
int i;
|
Packet* p = NetworkSend_Init(PACKET_UDP_CLIENT_FIND_SERVER);
|
||||||
|
uint i;
|
||||||
|
|
||||||
|
for (i = 0; _broadcast_list[i] != 0; i++) {
|
||||||
struct sockaddr_in out_addr;
|
struct sockaddr_in out_addr;
|
||||||
Packet *p;
|
|
||||||
|
|
||||||
// Init the packet
|
|
||||||
p = NetworkSend_Init(PACKET_UDP_CLIENT_FIND_SERVER);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while (_broadcast_list[i] != 0) {
|
|
||||||
out_addr.sin_family = AF_INET;
|
out_addr.sin_family = AF_INET;
|
||||||
out_addr.sin_port = htons(_network_server_port);
|
out_addr.sin_port = htons(_network_server_port);
|
||||||
out_addr.sin_addr.s_addr = _broadcast_list[i];
|
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));
|
DEBUG(net, 6)("[NET][UDP] Broadcasting to %s", inet_ntoa(out_addr.sin_addr));
|
||||||
|
|
||||||
NetworkSendUDP_Packet(udp, p, &out_addr);
|
NetworkSendUDP_Packet(udp, p, &out_addr);
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(p);
|
free(p);
|
||||||
|
|
10
newgrf.c
10
newgrf.c
|
@ -2467,17 +2467,19 @@ static void ParamSet(byte *buf, int len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x05:
|
case 0x05:
|
||||||
if ((int32)src2 < 0)
|
if ((int32)src2 < 0) {
|
||||||
res = src1 >> -(int32)src2;
|
res = src1 >> -(int32)src2;
|
||||||
else
|
} else {
|
||||||
res = src1 << src2;
|
res = src1 << src2;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x06:
|
case 0x06:
|
||||||
if ((int32)src2 < 0)
|
if ((int32)src2 < 0) {
|
||||||
res = (int32)src1 >> -(int32)src2;
|
res = (int32)src1 >> -(int32)src2;
|
||||||
else
|
} else {
|
||||||
res = (int32)src1 << src2;
|
res = (int32)src1 << src2;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x07: /* Bitwise AND */
|
case 0x07: /* Bitwise AND */
|
||||||
|
|
18
npf.c
18
npf.c
|
@ -213,9 +213,7 @@ static uint NPFSlopeCost(AyStarNode* current)
|
||||||
*/
|
*/
|
||||||
static void NPFMarkTile(TileIndex tile)
|
static void NPFMarkTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
#ifdef NO_DEBUG_MESSAGES
|
#ifndef NO_DEBUG_MESSAGES
|
||||||
return;
|
|
||||||
#else
|
|
||||||
if (_debug_npf_level < 1 || _networking) return;
|
if (_debug_npf_level < 1 || _networking) return;
|
||||||
switch (GetTileType(tile)) {
|
switch (GetTileType(tile)) {
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
|
@ -806,14 +804,12 @@ NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir,
|
||||||
_npf_aystar.EndNodeCheck = NPFFindStationOrTile;
|
_npf_aystar.EndNodeCheck = NPFFindStationOrTile;
|
||||||
_npf_aystar.FoundEndNode = NPFSaveTargetData;
|
_npf_aystar.FoundEndNode = NPFSaveTargetData;
|
||||||
_npf_aystar.GetNeighbours = NPFFollowTrack;
|
_npf_aystar.GetNeighbours = NPFFollowTrack;
|
||||||
if (type == TRANSPORT_RAIL)
|
switch (type) {
|
||||||
_npf_aystar.CalculateG = NPFRailPathCost;
|
default: NOT_REACHED();
|
||||||
else if (type == TRANSPORT_ROAD)
|
case TRANSPORT_RAIL: _npf_aystar.CalculateG = NPFRailPathCost; break;
|
||||||
_npf_aystar.CalculateG = NPFRoadPathCost;
|
case TRANSPORT_ROAD: _npf_aystar.CalculateG = NPFRoadPathCost; break;
|
||||||
else if (type == TRANSPORT_WATER)
|
case TRANSPORT_WATER: _npf_aystar.CalculateG = NPFWaterPathCost; break;
|
||||||
_npf_aystar.CalculateG = NPFWaterPathCost;
|
}
|
||||||
else
|
|
||||||
assert(0);
|
|
||||||
|
|
||||||
/* Initialize target */
|
/* Initialize target */
|
||||||
target.station_index = INVALID_STATION; /* We will initialize dest_coords inside the loop below */
|
target.station_index = INVALID_STATION; /* We will initialize dest_coords inside the loop below */
|
||||||
|
|
18
openttd.c
18
openttd.c
|
@ -335,11 +335,11 @@ int ttd_main(int argc, char* argv[])
|
||||||
// a letter means: it accepts that param (e.g.: -h)
|
// 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 need a param (e.g.: -m<driver>)
|
||||||
// a '::' behind it means: it can optional have a param (e.g.: -d<debug>)
|
// a '::' behind it means: it can optional have a param (e.g.: -d<debug>)
|
||||||
|
optformat = "bm:s:v:hDn::eit:d::r:g::G:c:"
|
||||||
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
|
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && !defined(WIN32)
|
||||||
optformat = "bm:s:v:hDfn::eit:d::r:g::G:c:";
|
"f"
|
||||||
#else
|
|
||||||
optformat = "bm:s:v:hDn::eit:d::r:g::G:c:"; // no fork option
|
|
||||||
#endif
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
MyGetOptInit(&mgo, argc-1, argv+1, optformat);
|
MyGetOptInit(&mgo, argc-1, argv+1, optformat);
|
||||||
while ((i = MyGetOpt(&mgo)) != -1) {
|
while ((i = MyGetOpt(&mgo)) != -1) {
|
||||||
|
@ -373,8 +373,9 @@ int ttd_main(int argc, char* argv[])
|
||||||
if (mgo.opt != NULL) {
|
if (mgo.opt != NULL) {
|
||||||
strcpy(_file_to_saveload.name, mgo.opt);
|
strcpy(_file_to_saveload.name, mgo.opt);
|
||||||
_switch_mode = SM_LOAD;
|
_switch_mode = SM_LOAD;
|
||||||
} else
|
} else {
|
||||||
_switch_mode = SM_NEWGAME;
|
_switch_mode = SM_NEWGAME;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'G': _random_seeds[0][0] = atoi(mgo.opt); break;
|
case 'G': _random_seeds[0][0] = atoi(mgo.opt); break;
|
||||||
case 'c': _config_file = strdup(mgo.opt); break;
|
case 'c': _config_file = strdup(mgo.opt); break;
|
||||||
|
@ -1339,9 +1340,7 @@ bool AfterLoadGame(void)
|
||||||
* replaced, shall keep their old length. In all prior versions, just default
|
* replaced, shall keep their old length. In all prior versions, just default
|
||||||
* to false */
|
* to false */
|
||||||
if (CheckSavegameVersionOldStyle(16, 1)) {
|
if (CheckSavegameVersionOldStyle(16, 1)) {
|
||||||
FOR_ALL_PLAYERS(p) {
|
FOR_ALL_PLAYERS(p) p->renew_keep_length = false;
|
||||||
p->renew_keep_length = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* In version 17, ground type is moved from m2 to m4 for depots and
|
/* In version 17, ground type is moved from m2 to m4 for depots and
|
||||||
|
@ -1396,11 +1395,12 @@ bool AfterLoadGame(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear PBS reservation on track
|
// Clear PBS reservation on track
|
||||||
if (!IsTileDepotType(tile, TRANSPORT_RAIL))
|
if (!IsTileDepotType(tile, TRANSPORT_RAIL)) {
|
||||||
SB(_m[tile].m4, 4, 4, 0);
|
SB(_m[tile].m4, 4, 4, 0);
|
||||||
else
|
} else {
|
||||||
CLRBIT(_m[tile].m3, 6);
|
CLRBIT(_m[tile].m3, 6);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Clear PBS reservation on crossing
|
// Clear PBS reservation on crossing
|
||||||
if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile))
|
if (IsTileType(tile, MP_STREET) && IsLevelCrossing(tile))
|
||||||
|
|
7
order.h
7
order.h
|
@ -72,9 +72,10 @@ enum {
|
||||||
|
|
||||||
|
|
||||||
/* If you change this, keep in mind that it is saved on 3 places:
|
/* If you change this, keep in mind that it is saved on 3 places:
|
||||||
- Load_ORDR, all the global orders
|
* - Load_ORDR, all the global orders
|
||||||
- Vehicle -> current_order
|
* - Vehicle -> current_order
|
||||||
- REF_SHEDULE (all REFs are currently limited to 16 bits!!) */
|
* - REF_SHEDULE (all REFs are currently limited to 16 bits!!)
|
||||||
|
*/
|
||||||
typedef struct Order {
|
typedef struct Order {
|
||||||
uint8 type;
|
uint8 type;
|
||||||
uint8 flags;
|
uint8 flags;
|
||||||
|
|
15
order_cmd.c
15
order_cmd.c
|
@ -569,8 +569,9 @@ int32 CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
order = GetVehicleOrder(v, sel_ord);
|
order = GetVehicleOrder(v, sel_ord);
|
||||||
if (order->type != OT_GOTO_STATION &&
|
if (order->type != OT_GOTO_STATION &&
|
||||||
(order->type != OT_GOTO_DEPOT || p2 == OFB_UNLOAD) &&
|
(order->type != OT_GOTO_DEPOT || p2 == OFB_UNLOAD) &&
|
||||||
(order->type != OT_GOTO_WAYPOINT || p2 != OFB_NON_STOP))
|
(order->type != OT_GOTO_WAYPOINT || p2 != OFB_NON_STOP)) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
switch (p2) {
|
switch (p2) {
|
||||||
|
@ -902,11 +903,15 @@ void CheckOrders(const Vehicle* v)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the last and the first order are the same */
|
/* Check if the last and the first order are the same */
|
||||||
if (v->num_orders > 1 &&
|
if (v->num_orders > 1) {
|
||||||
v->orders->type == GetLastVehicleOrder(v)->type &&
|
const Order* last = GetLastVehicleOrder(v);
|
||||||
v->orders->flags == GetLastVehicleOrder(v)->flags &&
|
|
||||||
v->orders->station == GetLastVehicleOrder(v)->station)
|
if (v->orders->type == last->type &&
|
||||||
|
v->orders->flags == last->flags &&
|
||||||
|
v->orders->station == last->station) {
|
||||||
problem_type = 2;
|
problem_type = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Do we only have 1 station in our order list? */
|
/* Do we only have 1 station in our order list? */
|
||||||
if (n_st < 2 && problem_type == -1) problem_type = 0;
|
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);
|
Vehicle *v = GetVehicle(w->window_number);
|
||||||
switch (e->click.widget) {
|
switch (e->click.widget) {
|
||||||
case 2: { /* orders list */
|
case 2: { /* orders list */
|
||||||
int sel;
|
int sel = (e->click.pt.y - 15) / 10;
|
||||||
sel = (e->click.pt.y - 15) / 10;
|
|
||||||
|
|
||||||
if ((uint)sel >= w->vscroll.cap)
|
if ((uint)sel >= w->vscroll.cap) return;
|
||||||
return;
|
|
||||||
|
|
||||||
sel += w->vscroll.pos;
|
sel += w->vscroll.pos;
|
||||||
|
|
||||||
if (_ctrl_pressed && sel < v->num_orders) {
|
if (_ctrl_pressed && sel < v->num_orders) {
|
||||||
const Order *ord = GetVehicleOrder(v, sel);
|
const Order *ord = GetVehicleOrder(v, sel);
|
||||||
int xy = 0;
|
TileIndex xy;
|
||||||
|
|
||||||
switch (ord->type) {
|
switch (ord->type) {
|
||||||
case OT_GOTO_STATION: /* station order */
|
case OT_GOTO_STATION: xy = GetStation(ord->station)->xy ; break;
|
||||||
xy = GetStation(ord->station)->xy ;
|
case OT_GOTO_DEPOT: xy = GetDepot(ord->station)->xy; break;
|
||||||
break;
|
case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->station)->xy; break;
|
||||||
case OT_GOTO_DEPOT: /* goto depot order */
|
default: xy = 0; break;
|
||||||
xy = GetDepot(ord->station)->xy;
|
|
||||||
break;
|
|
||||||
case OT_GOTO_WAYPOINT: /* goto waypoint order */
|
|
||||||
xy = GetWaypoint(ord->station)->xy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xy)
|
if (xy != 0) ScrollMainWindowToTile(xy);
|
||||||
ScrollMainWindowToTile(xy);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,7 +511,6 @@ static void OrdersWndProc(Window *w, WindowEvent *e)
|
||||||
w->vscroll.cap = (w->widget[2].bottom - w->widget[2].top) / 10;
|
w->vscroll.cap = (w->widget[2].bottom - w->widget[2].top) / 10;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Widget _orders_train_widgets[] = {
|
static const Widget _orders_train_widgets[] = {
|
||||||
|
|
15
os2.c
15
os2.c
|
@ -64,11 +64,12 @@ int compare_FiosItems(const void *a, const void *b)
|
||||||
|
|
||||||
static void append_path(char *out, const char *path, const char *file)
|
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);
|
sprintf(out, "%s%s", path, file);
|
||||||
else
|
} else {
|
||||||
sprintf(out, "%s\\%s", path, file);
|
sprintf(out, "%s\\%s", path, file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get a list of savegames
|
// Get a list of savegames
|
||||||
FiosItem *FiosGetSavegameList(int *num, int mode)
|
FiosItem *FiosGetSavegameList(int *num, int mode)
|
||||||
|
@ -347,10 +348,11 @@ char *FiosBrowseTo(const FiosItem *item)
|
||||||
|
|
||||||
case FIOS_TYPE_PARENT:
|
case FIOS_TYPE_PARENT:
|
||||||
s = strrchr(path, '\\');
|
s = strrchr(path, '\\');
|
||||||
if (s != path + 2)
|
if (s != path + 2) {
|
||||||
s[0] = '\0';
|
s[0] = '\0';
|
||||||
else
|
} else {
|
||||||
s[1] = '\0';
|
s[1] = '\0';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIOS_TYPE_DIR:
|
case FIOS_TYPE_DIR:
|
||||||
|
@ -406,10 +408,7 @@ void FiosMakeSavegameName(char *buf, const char *name, size_t size)
|
||||||
const char* extension;
|
const char* extension;
|
||||||
const char* period;
|
const char* period;
|
||||||
|
|
||||||
if (_game_mode == GM_EDITOR)
|
extension = (_game_mode == GM_EDITOR ? ".scn" : ".sav");
|
||||||
extension = ".scn";
|
|
||||||
else
|
|
||||||
extension = ".sav";
|
|
||||||
|
|
||||||
// Don't append the extension, if it is already there
|
// Don't append the extension, if it is already there
|
||||||
period = strrchr(name, '.');
|
period = strrchr(name, '.');
|
||||||
|
|
5
player.h
5
player.h
|
@ -238,9 +238,8 @@ static inline bool HasRailtypeAvail(const Player *p, RailType Railtype)
|
||||||
static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_current_player)->avail_railtypes, rail);}
|
static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_current_player)->avail_railtypes, rail);}
|
||||||
|
|
||||||
/** Returns the "best" railtype a player can build.
|
/** Returns the "best" railtype a player can build.
|
||||||
* As the AI doesn't know what the BEST one is, we
|
* As the AI doesn't know what the BEST one is, we have our own priority list
|
||||||
* have our own priority list here. When adding
|
* here. When adding new railtypes, modify this function
|
||||||
* new railtypes, modify this function
|
|
||||||
* @param p the player "in action"
|
* @param p the player "in action"
|
||||||
* @return The "best" railtype a player has available
|
* @return The "best" railtype a player has available
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -79,9 +79,9 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
|
||||||
// draw max loan aligned to loan below (y += 10)
|
// draw max loan aligned to loan below (y += 10)
|
||||||
SetDParam64(0, (uint64)_economy.max_loan);
|
SetDParam64(0, (uint64)_economy.max_loan);
|
||||||
DrawString(202, y+10, STR_MAX_LOAN, 0);
|
DrawString(202, y+10, STR_MAX_LOAN, 0);
|
||||||
|
} else {
|
||||||
} else
|
|
||||||
y = 15;
|
y = 15;
|
||||||
|
}
|
||||||
|
|
||||||
DrawString(2, y, STR_7026_BANK_BALANCE, 0);
|
DrawString(2, y, STR_7026_BANK_BALANCE, 0);
|
||||||
SetDParam64(0, p->money64);
|
SetDParam64(0, p->money64);
|
||||||
|
@ -524,9 +524,10 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
/* Spectators cannot do anything of course */
|
/* Spectators cannot do anything of course */
|
||||||
if (_local_player == OWNER_SPECTATOR) dis |= (1 << 9) | (1 << 10);
|
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);
|
dis |= (1 << 9) | (1 << 10);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetDParam(0, p->name_1);
|
SetDParam(0, p->name_1);
|
||||||
SetDParam(1, p->name_2);
|
SetDParam(1, p->name_2);
|
||||||
|
|
80
players.c
80
players.c
|
@ -220,10 +220,11 @@ static void SubtractMoneyFromAnyPlayer(Player *p, int32 cost)
|
||||||
|
|
||||||
p->yearly_expenses[0][_yearly_expenses_type] += 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;
|
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;
|
p->cur_economy.expenses -= cost;
|
||||||
|
}
|
||||||
|
|
||||||
InvalidatePlayerWindows(p);
|
InvalidatePlayerWindows(p);
|
||||||
}
|
}
|
||||||
|
@ -231,47 +232,49 @@ static void SubtractMoneyFromAnyPlayer(Player *p, int32 cost)
|
||||||
void SubtractMoneyFromPlayer(int32 cost)
|
void SubtractMoneyFromPlayer(int32 cost)
|
||||||
{
|
{
|
||||||
PlayerID pid = _current_player;
|
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)
|
void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost)
|
||||||
{
|
{
|
||||||
Player *p = GetPlayer(player);
|
Player *p = GetPlayer(player);
|
||||||
byte m = p->player_money_fraction;
|
byte m = p->player_money_fraction;
|
||||||
|
|
||||||
p->player_money_fraction = m - (byte)cost;
|
p->player_money_fraction = m - (byte)cost;
|
||||||
cost >>= 8;
|
cost >>= 8;
|
||||||
if (p->player_money_fraction > m)
|
if (p->player_money_fraction > m) cost++;
|
||||||
cost++;
|
if (cost != 0) SubtractMoneyFromAnyPlayer(p, cost);
|
||||||
if (cost != 0)
|
|
||||||
SubtractMoneyFromAnyPlayer(p, cost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// the player_money field is kept as it is, but money64 contains the actual amount of money.
|
// the player_money field is kept as it is, but money64 contains the actual amount of money.
|
||||||
void UpdatePlayerMoney32(Player *p)
|
void UpdatePlayerMoney32(Player *p)
|
||||||
{
|
{
|
||||||
if (p->money64 < -2000000000)
|
if (p->money64 < -2000000000) {
|
||||||
p->player_money = -2000000000;
|
p->player_money = -2000000000;
|
||||||
else if (p->money64 > 2000000000)
|
} else if (p->money64 > 2000000000) {
|
||||||
p->player_money = 2000000000;
|
p->player_money = 2000000000;
|
||||||
else
|
} else {
|
||||||
p->player_money = (int32)p->money64;
|
p->player_money = (int32)p->money64;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GetNameOfOwner(PlayerID owner, TileIndex tile)
|
void GetNameOfOwner(PlayerID owner, TileIndex tile)
|
||||||
{
|
{
|
||||||
SetDParam(2, owner);
|
SetDParam(2, owner);
|
||||||
|
|
||||||
if (owner != OWNER_TOWN) {
|
if (owner != OWNER_TOWN) {
|
||||||
if (owner >= 8)
|
if (owner >= MAX_PLAYERS) {
|
||||||
SetDParam(0, STR_0150_SOMEONE);
|
SetDParam(0, STR_0150_SOMEONE);
|
||||||
else {
|
} else {
|
||||||
const Player* p = GetPlayer(owner);
|
const Player* p = GetPlayer(owner);
|
||||||
|
|
||||||
SetDParam(0, p->name_1);
|
SetDParam(0, p->name_1);
|
||||||
SetDParam(1, p->name_2);
|
SetDParam(1, p->name_2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Town *t = ClosestTownFromTile(tile, (uint)-1);
|
const Town* t = ClosestTownFromTile(tile, (uint)-1);
|
||||||
|
|
||||||
SetDParam(0, STR_TOWN);
|
SetDParam(0, STR_TOWN);
|
||||||
SetDParam(1, t->index);
|
SetDParam(1, t->index);
|
||||||
}
|
}
|
||||||
|
@ -282,8 +285,7 @@ bool CheckOwnership(PlayerID owner)
|
||||||
{
|
{
|
||||||
assert(owner <= OWNER_WATER);
|
assert(owner <= OWNER_WATER);
|
||||||
|
|
||||||
if (owner == _current_player)
|
if (owner == _current_player) return true;
|
||||||
return true;
|
|
||||||
_error_message = STR_013B_OWNED_BY;
|
_error_message = STR_013B_OWNED_BY;
|
||||||
GetNameOfOwner(owner, 0);
|
GetNameOfOwner(owner, 0);
|
||||||
return false;
|
return false;
|
||||||
|
@ -295,8 +297,7 @@ bool CheckTileOwnership(TileIndex tile)
|
||||||
|
|
||||||
assert(owner <= OWNER_WATER);
|
assert(owner <= OWNER_WATER);
|
||||||
|
|
||||||
if (owner == _current_player)
|
if (owner == _current_player) return true;
|
||||||
return true;
|
|
||||||
_error_message = STR_013B_OWNED_BY;
|
_error_message = STR_013B_OWNED_BY;
|
||||||
|
|
||||||
// no need to get the name of the owner unless we're the local player (saves some time)
|
// 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;
|
uint32 strp;
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
|
|
||||||
if (p->name_1 != STR_SV_UNNAMED)
|
if (p->name_1 != STR_SV_UNNAMED) return;
|
||||||
return;
|
|
||||||
|
|
||||||
tile = p->last_build_coordinate;
|
tile = p->last_build_coordinate;
|
||||||
if (tile == 0)
|
if (tile == 0) return;
|
||||||
return;
|
|
||||||
|
|
||||||
t = ClosestTownFromTile(tile, (uint)-1);
|
t = ClosestTownFromTile(tile, (uint)-1);
|
||||||
|
|
||||||
|
@ -329,8 +328,7 @@ static void GenerateCompanyName(Player *p)
|
||||||
verify_name:;
|
verify_name:;
|
||||||
// No player must have this name already
|
// No player must have this name already
|
||||||
FOR_ALL_PLAYERS(pp) {
|
FOR_ALL_PLAYERS(pp) {
|
||||||
if (pp->name_1 == str && pp->name_2 == strp)
|
if (pp->name_1 == str && pp->name_2 == strp) goto bad_town_name;
|
||||||
goto bad_town_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetString(buffer, str);
|
GetString(buffer, str);
|
||||||
|
@ -423,11 +421,8 @@ static byte GeneratePlayerColor(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the first available color
|
// Return the first available color
|
||||||
i = 0;
|
for (i = 0;; i++) {
|
||||||
for (;;) {
|
if (colors[i] != 0xFF) return colors[i];
|
||||||
if (colors[i] != 0xFF)
|
|
||||||
return colors[i];
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,8 +846,9 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
if (_network_server) {
|
if (_network_server) {
|
||||||
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at server-side
|
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at
|
||||||
* in network_server.c:838, function DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
|
* server-side in network_server.c:838, function
|
||||||
|
* DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) */
|
||||||
NetworkClientInfo *ci = &_network_client_info[pid];
|
NetworkClientInfo *ci = &_network_client_info[pid];
|
||||||
ci->client_playas = p->index + 1;
|
ci->client_playas = p->index + 1;
|
||||||
NetworkUpdateClientInfo(ci->client_index);
|
NetworkUpdateClientInfo(ci->client_index);
|
||||||
|
@ -878,16 +874,16 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
_local_player = player_backup;
|
_local_player = player_backup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_network_server) { // Creating player failed, defer client to spectator
|
} else if (_network_server) {
|
||||||
/* XXX - UGLY! p2 (pid) is mis-used to fetch the client-id, done at server-side
|
// Creating player failed, defer client to spectator
|
||||||
* 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];
|
NetworkClientInfo *ci = &_network_client_info[pid];
|
||||||
ci->client_playas = OWNER_SPECTATOR;
|
ci->client_playas = OWNER_SPECTATOR;
|
||||||
NetworkUpdateClientInfo(ci->client_index);
|
NetworkUpdateClientInfo(ci->client_index);
|
||||||
}
|
|
||||||
#else
|
|
||||||
}
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 1: /* Make a new AI player */
|
case 1: /* Make a new AI player */
|
||||||
|
@ -941,7 +937,7 @@ int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const StringID _endgame_perf_titles[16] = {
|
static const StringID _endgame_perf_titles[] = {
|
||||||
STR_0213_BUSINESSMAN,
|
STR_0213_BUSINESSMAN,
|
||||||
STR_0213_BUSINESSMAN,
|
STR_0213_BUSINESSMAN,
|
||||||
STR_0213_BUSINESSMAN,
|
STR_0213_BUSINESSMAN,
|
||||||
|
@ -957,13 +953,12 @@ static const StringID _endgame_perf_titles[16] = {
|
||||||
STR_0217_MAGNATE,
|
STR_0217_MAGNATE,
|
||||||
STR_0218_MOGUL,
|
STR_0218_MOGUL,
|
||||||
STR_0218_MOGUL,
|
STR_0218_MOGUL,
|
||||||
STR_0219_TYCOON_OF_THE_CENTURY,
|
STR_0219_TYCOON_OF_THE_CENTURY
|
||||||
};
|
};
|
||||||
|
|
||||||
StringID EndGameGetPerformanceTitleFromValue(uint value)
|
StringID EndGameGetPerformanceTitleFromValue(uint value)
|
||||||
{
|
{
|
||||||
value = minu(value, 1000) >> 6;
|
value = minu(value / 64, lengthof(_endgame_perf_titles) - 1);
|
||||||
if (value >= lengthof(_endgame_perf_titles)) value = lengthof(_endgame_perf_titles) - 1;
|
|
||||||
|
|
||||||
return _endgame_perf_titles[value];
|
return _endgame_perf_titles[value];
|
||||||
}
|
}
|
||||||
|
@ -975,8 +970,7 @@ static bool CheatHasBeenUsed(void)
|
||||||
const Cheat* cht_last = &cht[sizeof(_cheats) / sizeof(Cheat)];
|
const Cheat* cht_last = &cht[sizeof(_cheats) / sizeof(Cheat)];
|
||||||
|
|
||||||
for (; cht != cht_last; cht++) {
|
for (; cht != cht_last; cht++) {
|
||||||
if (cht->been_used)
|
if (cht->been_used) return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
32
rail.h
32
rail.h
|
@ -263,20 +263,28 @@ static inline Trackdir TrackToTrackdir(Track track) { return (Trackdir)track; }
|
||||||
* Returns a TrackdirBit mask that contains the two TrackdirBits that
|
* Returns a TrackdirBit mask that contains the two TrackdirBits that
|
||||||
* correspond with the given Track (one for each direction).
|
* 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
|
* Discards all directional information from the given TrackdirBits. Any
|
||||||
* Track which is present in either direction will be present in the result.
|
* 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
|
* 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
|
* ahead. This will be the same trackdir for diagonal trackdirs, but a
|
||||||
* different (alternating) one for straight trackdirs
|
* 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];
|
extern const Trackdir _next_trackdir[TRACKDIR_END];
|
||||||
return _next_trackdir[trackdir];
|
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.
|
* 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];
|
extern const TrackBits _track_crosses_tracks[TRACK_END];
|
||||||
return _track_crosses_tracks[track];
|
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
|
* Maps a trackdir to the (4-way) direction the tile is exited when following
|
||||||
* that trackdir.
|
* that trackdir.
|
||||||
*/
|
*/
|
||||||
static inline DiagDirection TrackdirToExitdir(Trackdir trackdir) {
|
static inline DiagDirection TrackdirToExitdir(Trackdir trackdir)
|
||||||
|
{
|
||||||
extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END];
|
extern const DiagDirection _trackdir_to_exitdir[TRACKDIR_END];
|
||||||
return _trackdir_to_exitdir[trackdir];
|
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
|
* Maps a track and an (4-way) dir to the trackdir that represents the track
|
||||||
* with the exit in the given direction.
|
* 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];
|
extern const Trackdir _track_exitdir_to_trackdir[TRACK_END][DIAGDIR_END];
|
||||||
return _track_exitdir_to_trackdir[track][diagdir];
|
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
|
* Maps a track and an (4-way) dir to the trackdir that represents the track
|
||||||
* with the exit in the given direction.
|
* 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];
|
extern const Trackdir _track_enterdir_to_trackdir[TRACK_END][DIAGDIR_END];
|
||||||
return _track_enterdir_to_trackdir[track][diagdir];
|
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
|
* Maps a track and a full (8-way) direction to the trackdir that represents
|
||||||
* the track running in the given direction.
|
* 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];
|
extern const Trackdir _track_direction_to_trackdir[TRACK_END][DIR_END];
|
||||||
return _track_direction_to_trackdir[track][dir];
|
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
|
* Maps a (4-way) direction to the diagonal trackdir that runs in that
|
||||||
* direction.
|
* direction.
|
||||||
*/
|
*/
|
||||||
static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir) {
|
static inline Trackdir DiagdirToDiagTrackdir(DiagDirection diagdir)
|
||||||
|
{
|
||||||
extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
|
extern const Trackdir _dir_to_diag_trackdir[DIAGDIR_END];
|
||||||
return _dir_to_diag_trackdir[diagdir];
|
return _dir_to_diag_trackdir[diagdir];
|
||||||
}
|
}
|
||||||
|
|
33
rail_cmd.c
33
rail_cmd.c
|
@ -467,9 +467,10 @@ static int32 ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileIndex end
|
||||||
SETBIT(*trackdir, 3); // reverse the direction
|
SETBIT(*trackdir, 3); // reverse the direction
|
||||||
trdx = -trdx;
|
trdx = -trdx;
|
||||||
trdy = -trdy;
|
trdy = -trdy;
|
||||||
} else // other direction is invalid too, invalid drag
|
} else { // other direction is invalid too, invalid drag
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// (for diagonal tracks, this is already made sure of by above test), but:
|
// (for diagonal tracks, this is already made sure of by above test), but:
|
||||||
// for non-diagonal tracks, check if the start and end tile are on 1 line
|
// for non-diagonal tracks, check if the start and end tile are on 1 line
|
||||||
|
@ -517,8 +518,9 @@ static int32 CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||||
if (CmdFailed(ret)) {
|
if (CmdFailed(ret)) {
|
||||||
if ((_error_message != STR_1007_ALREADY_BUILT) && (mode == 0)) break;
|
if ((_error_message != STR_1007_ALREADY_BUILT) && (mode == 0)) break;
|
||||||
_error_message = INVALID_STRING_ID;
|
_error_message = INVALID_STRING_ID;
|
||||||
} else
|
} else {
|
||||||
total_cost += ret;
|
total_cost += ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (tile == end_tile) break;
|
if (tile == end_tile) break;
|
||||||
|
|
||||||
|
@ -648,10 +650,10 @@ int32 CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
TrackBits trackbits = GetTrackBits(tile);
|
TrackBits trackbits = GetTrackBits(tile);
|
||||||
if (KILL_FIRST_BIT(trackbits) != 0 && /* More than one track present */
|
if (KILL_FIRST_BIT(trackbits) != 0 && /* More than one track present */
|
||||||
trackbits != TRACK_BIT_HORZ &&
|
trackbits != TRACK_BIT_HORZ &&
|
||||||
trackbits != TRACK_BIT_VERT
|
trackbits != TRACK_BIT_VERT) {
|
||||||
)
|
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
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
|
/* for vertical/horizontal tracks, double the given signals density
|
||||||
* since the original amount will be too dense (shorter tracks) */
|
* since the original amount will be too dense (shorter tracks) */
|
||||||
if (!IsDiagonalTrack(track))
|
if (!IsDiagonalTrack(track)) signal_density *= 2;
|
||||||
signal_density *= 2;
|
|
||||||
|
|
||||||
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR;
|
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)
|
// copy signal/semaphores style (independent of CTRL)
|
||||||
semaphores = (GetSignalVariant(tile) == SIG_ELECTRIC ? 0 : 8);
|
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);
|
signals = SignalOnTrack(track);
|
||||||
|
}
|
||||||
|
|
||||||
/* signal_ctr - amount of tiles already processed
|
/* signal_ctr - amount of tiles already processed
|
||||||
* signals_density - patch setting to put signal on every Nth tile (double space on |, -- tracks)
|
* 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;
|
signal_ctr = total_cost = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// only build/remove signals with the specified density
|
// 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);
|
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
|
/* 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);
|
Track track = (Track)(p1 & 0x7);
|
||||||
|
|
||||||
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicle(tile))
|
if (!ValParamTrackOrientation(track) ||
|
||||||
return CMD_ERROR;
|
!IsTileType(tile, MP_RAILWAY) ||
|
||||||
|
!EnsureNoVehicle(tile) ||
|
||||||
if (!HasSignalOnTrack(tile, track)) // no signals on track?
|
!HasSignalOnTrack(tile, track)) {
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Only water can remove signals from anyone */
|
/* Only water can remove signals from anyone */
|
||||||
if (_current_player != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR;
|
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);
|
foundation = GetRailFoundation(ti->tileh, track);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (foundation != 0)
|
if (foundation != 0) DrawFoundation(ti, foundation);
|
||||||
DrawFoundation(ti, foundation);
|
|
||||||
|
|
||||||
// DrawFoundation() modifies ti.
|
// DrawFoundation() modifies ti.
|
||||||
// Default sloped sprites..
|
// Default sloped sprites..
|
||||||
|
@ -1317,7 +1319,6 @@ static void DrawTile_Track(TileInfo *ti)
|
||||||
|
|
||||||
/* draw signals also? */
|
/* draw signals also? */
|
||||||
if (GetRailTileType(ti->tile) == RAIL_TILE_SIGNALS) DrawSignals(ti->tile, rails);
|
if (GetRailTileType(ti->tile) == RAIL_TILE_SIGNALS) DrawSignals(ti->tile, rails);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* draw depots / waypoints */
|
/* draw depots / waypoints */
|
||||||
const DrawTrackSeqStruct *drss;
|
const DrawTrackSeqStruct *drss;
|
||||||
|
@ -1531,7 +1532,7 @@ static void *SignalVehicleCheckProc(Vehicle *v, void *data)
|
||||||
if (tile != dest->tile) return NULL;
|
if (tile != dest->tile) return NULL;
|
||||||
|
|
||||||
/* Are we on the same piece of track? */
|
/* 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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,9 +147,9 @@ void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
static void PlaceRail_Station(TileIndex tile)
|
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));
|
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);
|
VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
|
||||||
VpSetPlaceSizingLimit(_patches.station_spread);
|
VpSetPlaceSizingLimit(_patches.station_spread);
|
||||||
} else {
|
} else {
|
||||||
|
@ -470,9 +470,10 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
|
||||||
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
|
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) {
|
} else if (e->place.userdata == VPM_X_AND_Y_LIMITED) {
|
||||||
HandleStationPlacement(start_tile, end_tile);
|
HandleStationPlacement(start_tile, end_tile);
|
||||||
} else
|
} else {
|
||||||
DoRailroadTrack(e->place.userdata & 1);
|
DoRailroadTrack(e->place.userdata & 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_ABORT_PLACE_OBJ:
|
case WE_ABORT_PLACE_OBJ:
|
||||||
|
|
|
@ -272,7 +272,6 @@ RailType GetTileRailType(TileIndex tile, Trackdir trackdir);
|
||||||
|
|
||||||
|
|
||||||
typedef enum RailGroundType {
|
typedef enum RailGroundType {
|
||||||
RAIL_MAP2LO_GROUND_MASK = 0xF,
|
|
||||||
RAIL_GROUND_BARREN = 0,
|
RAIL_GROUND_BARREN = 0,
|
||||||
RAIL_GROUND_GRASS = 1,
|
RAIL_GROUND_GRASS = 1,
|
||||||
RAIL_GROUND_FENCE_NW = 2,
|
RAIL_GROUND_FENCE_NW = 2,
|
||||||
|
|
21
road_cmd.c
21
road_cmd.c
|
@ -254,7 +254,7 @@ static uint32 CheckRoadSlope(Slope tileh, RoadBits* pieces, RoadBits existing)
|
||||||
|
|
||||||
// foundation is used. Whole tile is leveled up
|
// foundation is used. Whole tile is leveled up
|
||||||
if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == 0) {
|
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
|
// 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 (image & PALETTE_MODIFIER_COLOR) image |= ormod;
|
||||||
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
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
|
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)
|
static void TileLoop_Road(TileIndex tile)
|
||||||
{
|
{
|
||||||
Town *t;
|
|
||||||
int grp;
|
|
||||||
|
|
||||||
switch (_opt.landscape) {
|
switch (_opt.landscape) {
|
||||||
case LT_HILLY:
|
case LT_HILLY:
|
||||||
if (IsOnSnow(tile) != (GetTileZ(tile) > _opt.snow_line)) {
|
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 (GetRoadTileType(tile) == ROAD_TILE_DEPOT) return;
|
||||||
|
|
||||||
if (!HasRoadWorks(tile)) {
|
if (!HasRoadWorks(tile)) {
|
||||||
t = ClosestTownFromTile(tile, (uint)-1);
|
const Town* t = ClosestTownFromTile(tile, (uint)-1);
|
||||||
|
int grp = 0;
|
||||||
|
|
||||||
grp = 0;
|
|
||||||
if (t != NULL) {
|
if (t != NULL) {
|
||||||
grp = GetTownRadiusGroup(t, tile);
|
grp = GetTownRadiusGroup(t, tile);
|
||||||
|
|
||||||
// Show an animation to indicate road work
|
// Show an animation to indicate road work
|
||||||
if (t->road_build_months != 0 &&
|
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)) {
|
GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) {
|
||||||
if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicle(tile) && CHANCE16(1, 20)) {
|
if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicle(tile) && CHANCE16(1, 20)) {
|
||||||
StartRoadWorks(tile);
|
StartRoadWorks(tile);
|
||||||
|
@ -1001,7 +999,6 @@ static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode)
|
||||||
default:
|
default:
|
||||||
case ROAD_TILE_DEPOT:
|
case ROAD_TILE_DEPOT:
|
||||||
return (DiagDirToAxis(GetRoadDepotDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
return (DiagDirToAxis(GetRoadDepotDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1048,12 +1045,12 @@ static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROAD_TILE_DEPOT:
|
case ROAD_TILE_DEPOT:
|
||||||
if (v->type == VEH_Road && v->u.road.frame == 11) {
|
if (v->type == VEH_Road &&
|
||||||
if (_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) {
|
v->u.road.frame == 11 &&
|
||||||
|
_roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) {
|
||||||
RoadVehEnterDepot(v);
|
RoadVehEnterDepot(v);
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
|
|
|
@ -418,8 +418,9 @@ static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
|
||||||
if (_station_show_coverage) {
|
if (_station_show_coverage) {
|
||||||
int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4;
|
int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : 4;
|
||||||
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
|
||||||
} else
|
} else {
|
||||||
SetTileSelectSize(1, 1);
|
SetTileSelectSize(1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
image = (w->window_class == WC_BUS_STATION) ? 0x47 : 0x43;
|
image = (w->window_class == WC_BUS_STATION) ? 0x47 : 0x43;
|
||||||
|
|
||||||
|
|
|
@ -1625,7 +1625,6 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
|
||||||
void OnNewDay_RoadVeh(Vehicle *v)
|
void OnNewDay_RoadVeh(Vehicle *v)
|
||||||
{
|
{
|
||||||
int32 cost;
|
int32 cost;
|
||||||
Station *st;
|
|
||||||
|
|
||||||
if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v);
|
if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v);
|
||||||
if (v->u.road.blocked_ctr == 0) CheckVehicleBreakdown(v);
|
if (v->u.road.blocked_ctr == 0) CheckVehicleBreakdown(v);
|
||||||
|
@ -1646,19 +1645,19 @@ void OnNewDay_RoadVeh(Vehicle *v)
|
||||||
|
|
||||||
/* update destination */
|
/* update destination */
|
||||||
if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot == NULL && !(v->vehstatus & VS_CRASHED)) {
|
if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot == NULL && !(v->vehstatus & VS_CRASHED)) {
|
||||||
RoadStop *rs;
|
Station* st = GetStation(v->current_order.station);
|
||||||
|
RoadStop* rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK);
|
||||||
RoadStop* best = NULL;
|
RoadStop* best = NULL;
|
||||||
|
|
||||||
st = GetStation(v->current_order.station);
|
|
||||||
rs = GetPrimaryRoadStop(st, v->cargo_type == CT_PASSENGERS ? RS_BUS : RS_TRUCK);
|
|
||||||
|
|
||||||
if (rs != NULL) {
|
if (rs != NULL) {
|
||||||
if (DistanceManhattan(v->tile, st->xy) < 16) {
|
if (DistanceManhattan(v->tile, st->xy) < 16) {
|
||||||
uint dist, badness;
|
uint dist, badness;
|
||||||
uint minbadness = UINT_MAX;
|
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,
|
DEBUG(ms, 2) (
|
||||||
v->index, st->index, st->xy);
|
"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 */
|
/* Now we find the nearest road stop that has a free slot */
|
||||||
for (; rs != NULL; rs = rs->next) {
|
for (; rs != NULL; rs = rs->next) {
|
||||||
dist = RoadFindPathToStop(v, rs->xy);
|
dist = RoadFindPathToStop(v, rs->xy);
|
||||||
|
|
|
@ -109,7 +109,6 @@ static void RoadVehRefitWndProc(Window *w, WindowEvent *e)
|
||||||
WP(w,refit_d).sel = y / 10;
|
WP(w,refit_d).sel = y / 10;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,8 +162,8 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
|
||||||
StringID str;
|
StringID str;
|
||||||
|
|
||||||
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2);
|
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2);
|
||||||
if (!_patches.servint_roadveh) // disable service-scroller when interval is set to disabled
|
// disable service-scroller when interval is set to disabled
|
||||||
w->disabled_state |= (1 << 5) | (1 << 6);
|
if (!_patches.servint_roadveh) w->disabled_state |= (1 << 5) | (1 << 6);
|
||||||
|
|
||||||
SetDParam(0, v->string_id);
|
SetDParam(0, v->string_id);
|
||||||
SetDParam(1, v->unitnumber);
|
SetDParam(1, v->unitnumber);
|
||||||
|
@ -352,8 +351,9 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e)
|
||||||
if (v->num_orders == 0) {
|
if (v->num_orders == 0) {
|
||||||
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
||||||
SetDParam(0, v->cur_speed / 2);
|
SetDParam(0, v->cur_speed / 2);
|
||||||
} else
|
} else {
|
||||||
str = STR_EMPTY;
|
str = STR_EMPTY;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -565,8 +565,7 @@ static void NewRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_RESIZE: {
|
case WE_RESIZE: {
|
||||||
if (e->sizing.diff.y == 0)
|
if (e->sizing.diff.y == 0) break;
|
||||||
break;
|
|
||||||
|
|
||||||
w->vscroll.cap += e->sizing.diff.y / 14;
|
w->vscroll.cap += e->sizing.diff.y / 14;
|
||||||
w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
|
w->widget[2].unkA = (w->vscroll.cap << 8) + 1;
|
||||||
|
@ -632,8 +631,7 @@ static void DrawRoadDepotWindow(Window *w)
|
||||||
/* determine amount of items for scroller */
|
/* determine amount of items for scroller */
|
||||||
num = 0;
|
num = 0;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->type == VEH_Road && IsRoadVehInDepot(v) && v->tile == tile)
|
if (v->type == VEH_Road && IsRoadVehInDepot(v) && v->tile == tile) num++;
|
||||||
num++;
|
|
||||||
}
|
}
|
||||||
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
|
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;
|
xt = x / 56;
|
||||||
xm = x % 56;
|
xm = x % 56;
|
||||||
if (xt >= w->hscroll.cap)
|
if (xt >= w->hscroll.cap) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
row = (y - 14) / 14;
|
row = (y - 14) / 14;
|
||||||
if (row >= w->vscroll.cap)
|
if (row >= w->vscroll.cap) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt;
|
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;
|
if (mode > 0) return;
|
||||||
|
|
||||||
// share / copy orders
|
// 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) {
|
switch (mode) {
|
||||||
case 0: // start dragging of vehicle
|
case 0: // start dragging of vehicle
|
||||||
|
@ -791,14 +790,14 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case WE_PLACE_OBJ: {
|
case WE_PLACE_OBJ:
|
||||||
ClonePlaceObj(w);
|
ClonePlaceObj(w);
|
||||||
} break;
|
break;
|
||||||
|
|
||||||
case WE_ABORT_PLACE_OBJ: {
|
case WE_ABORT_PLACE_OBJ:
|
||||||
CLRBIT(w->click_state, 8);
|
CLRBIT(w->click_state, 8);
|
||||||
InvalidateWidget(w, 8);
|
InvalidateWidget(w, 8);
|
||||||
} break;
|
break;
|
||||||
|
|
||||||
// check if a vehicle in a depot was clicked..
|
// check if a vehicle in a depot was clicked..
|
||||||
case WE_MOUSELOOP: {
|
case WE_MOUSELOOP: {
|
||||||
|
@ -848,22 +847,21 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e)
|
||||||
_backup_orders_tile = 0;
|
_backup_orders_tile = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
WP(w,traindepot_d).sel = INVALID_VEHICLE;
|
WP(w,traindepot_d).sel = INVALID_VEHICLE;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_RESIZE: {
|
case WE_RESIZE:
|
||||||
/* Update the scroll + matrix */
|
/* Update the scroll + matrix */
|
||||||
w->vscroll.cap += e->sizing.diff.y / 14;
|
w->vscroll.cap += e->sizing.diff.y / 14;
|
||||||
w->hscroll.cap += e->sizing.diff.x / 56;
|
w->hscroll.cap += e->sizing.diff.x / 56;
|
||||||
w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
|
w->widget[5].unkA = (w->vscroll.cap << 8) + w->hscroll.cap;
|
||||||
|
break;
|
||||||
} break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Widget _road_depot_widgets[] = {
|
static const Widget _road_depot_widgets[] = {
|
||||||
|
@ -893,10 +891,9 @@ static const WindowDesc _road_depot_desc = {
|
||||||
|
|
||||||
void ShowRoadDepotWindow(TileIndex tile)
|
void ShowRoadDepotWindow(TileIndex tile)
|
||||||
{
|
{
|
||||||
Window *w;
|
Window* w = AllocateWindowDescFront(&_road_depot_desc, tile);
|
||||||
|
|
||||||
w = AllocateWindowDescFront(&_road_depot_desc, tile);
|
if (w != NULL) {
|
||||||
if (w) {
|
|
||||||
w->caption_color = GetTileOwner(w->window_number);
|
w->caption_color = GetTileOwner(w->window_number);
|
||||||
w->hscroll.cap = 5;
|
w->hscroll.cap = 5;
|
||||||
w->vscroll.cap = 3;
|
w->vscroll.cap = 3;
|
||||||
|
@ -959,13 +956,12 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
SetVScrollCount(w, vl->list_length);
|
SetVScrollCount(w, vl->list_length);
|
||||||
|
|
||||||
// disable 'Sort By' tooltip on Unsorted sorting criteria
|
// disable 'Sort By' tooltip on Unsorted sorting criteria
|
||||||
if (vl->sort_type == SORT_BY_UNSORTED)
|
if (vl->sort_type == SORT_BY_UNSORTED) w->disabled_state |= (1 << 3);
|
||||||
w->disabled_state |= (1 << 3);
|
|
||||||
|
|
||||||
/* draw the widgets */
|
/* draw the widgets */
|
||||||
{
|
|
||||||
const Player *p = GetPlayer(owner);
|
|
||||||
if (station == INVALID_STATION) {
|
if (station == INVALID_STATION) {
|
||||||
|
const Player* p = GetPlayer(owner);
|
||||||
|
|
||||||
/* Company Name -- (###) Road vehicles */
|
/* Company Name -- (###) Road vehicles */
|
||||||
SetDParam(0, p->name_1);
|
SetDParam(0, p->name_1);
|
||||||
SetDParam(1, p->name_2);
|
SetDParam(1, p->name_2);
|
||||||
|
@ -978,7 +974,6 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES;
|
w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES;
|
||||||
}
|
}
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
}
|
|
||||||
/* draw sorting criteria string */
|
/* draw sorting criteria string */
|
||||||
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
||||||
/* draw arrow pointing up/down for ascending/descending sorting */
|
/* draw arrow pointing up/down for ascending/descending sorting */
|
||||||
|
@ -1029,14 +1024,12 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
return;
|
return;
|
||||||
case 7: { /* Matrix to show vehicles */
|
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;
|
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
|
if (id_v >= w->vscroll.cap) return; // click out of bounds
|
||||||
|
|
||||||
id_v += w->vscroll.pos;
|
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);
|
||||||
|
@ -1044,7 +1037,6 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
assert(v->type == VEH_Road && v->owner == owner);
|
assert(v->type == VEH_Road && v->owner == owner);
|
||||||
|
|
||||||
ShowRoadVehViewWindow(v);
|
ShowRoadVehViewWindow(v);
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 9: /* Build new Vehicle */
|
case 9: /* Build new Vehicle */
|
||||||
|
@ -1053,9 +1045,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 10: {
|
case 10: {
|
||||||
if (!IsWindowOfPrototype(w, _player_roadveh_widgets))
|
if (!IsWindowOfPrototype(w, _player_roadveh_widgets)) break;
|
||||||
break;
|
|
||||||
|
|
||||||
ShowReplaceVehicleWindow(VEH_Road);
|
ShowReplaceVehicleWindow(VEH_Road);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1070,8 +1060,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
_sorting.roadveh.criteria = vl->sort_type;
|
_sorting.roadveh.criteria = vl->sort_type;
|
||||||
|
|
||||||
// enable 'Sort By' if a sorter criteria is chosen
|
// enable 'Sort By' if a sorter criteria is chosen
|
||||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3);
|
||||||
CLRBIT(w->disabled_state, 3);
|
|
||||||
}
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
10
saveload.c
10
saveload.c
|
@ -1408,8 +1408,11 @@ static void* SaveFileToDisk(void *arg)
|
||||||
_sl.excpt_uninit();
|
_sl.excpt_uninit();
|
||||||
|
|
||||||
fprintf(stderr, "Save game failed: %s.", _sl.excpt_msg);
|
fprintf(stderr, "Save game failed: %s.", _sl.excpt_msg);
|
||||||
if (arg != NULL) OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_ERROR);
|
if (arg != NULL) {
|
||||||
else SaveFileError();
|
OTTD_SendThreadMessage(MSG_OTTD_SAVETHREAD_ERROR);
|
||||||
|
} else {
|
||||||
|
SaveFileError();
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1633,8 +1636,7 @@ int GetSavegameType(char *file)
|
||||||
if (fread(&hdr, sizeof(hdr), 1, f) != 1) {
|
if (fread(&hdr, sizeof(hdr), 1, f) != 1) {
|
||||||
printf("Savegame is obsolete or invalid format.\n");
|
printf("Savegame is obsolete or invalid format.\n");
|
||||||
mode = SL_LOAD; // don't try to get filename, just show name as it is written
|
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.
|
// see if we have any loader for this type.
|
||||||
for (fmt = _saveload_formats; fmt != endof(_saveload_formats); fmt++) {
|
for (fmt = _saveload_formats; fmt != endof(_saveload_formats); fmt++) {
|
||||||
if (fmt->tag == hdr) {
|
if (fmt->tag == hdr) {
|
||||||
|
|
16
settings.c
16
settings.c
|
@ -238,10 +238,11 @@ static IniFile *ini_load(const char *filename)
|
||||||
|
|
||||||
// it's a group?
|
// it's a group?
|
||||||
if (s[0] == '[') {
|
if (s[0] == '[') {
|
||||||
if (e[-1] != ']')
|
if (e[-1] != ']') {
|
||||||
ShowInfoF("ini: invalid group name '%s'\n", buffer);
|
ShowInfoF("ini: invalid group name '%s'\n", buffer);
|
||||||
else
|
} else {
|
||||||
e--;
|
e--;
|
||||||
|
}
|
||||||
s++; // skip [
|
s++; // skip [
|
||||||
group = ini_group_alloc(ini, s, e - s);
|
group = ini_group_alloc(ini, s, e - s);
|
||||||
if (comment_size) {
|
if (comment_size) {
|
||||||
|
@ -341,10 +342,11 @@ static bool ini_save(const char *filename, IniFile *ini)
|
||||||
//*Don't give an equal sign to list items that don't have a parameter */
|
//*Don't give an equal sign to list items that don't have a parameter */
|
||||||
if (group->type == IGT_LIST && *item->value == '\0') {
|
if (group->type == IGT_LIST && *item->value == '\0') {
|
||||||
fprintf(f, "%s\n", item->name);
|
fprintf(f, "%s\n", item->name);
|
||||||
} else
|
} else {
|
||||||
fprintf(f, "%s = %s\n", item->name, item->value);
|
fprintf(f, "%s = %s\n", item->name, item->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ini->comment) fputs(ini->comment, f);
|
if (ini->comment) fputs(ini->comment, f);
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
@ -609,8 +611,12 @@ static void Write_ValidateSetting(void *ptr, const SettingDesc *sd, int32 val)
|
||||||
{
|
{
|
||||||
const SettingDescBase *sdb = &sd->desc;
|
const SettingDescBase *sdb = &sd->desc;
|
||||||
|
|
||||||
if (sdb->cmd != SDT_BOOLX && sdb->cmd != SDT_NUMX &&
|
if (sdb->cmd != SDT_BOOLX &&
|
||||||
sdb->cmd != SDT_ONEOFMANY && sdb->cmd != SDT_MANYOFMANY) return;
|
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 */
|
/* We cannot know the maximum value of a bitset variable, so just have faith */
|
||||||
if (sdb->cmd != SDT_MANYOFMANY) {
|
if (sdb->cmd != SDT_MANYOFMANY) {
|
||||||
|
|
36
ship_gui.c
36
ship_gui.c
|
@ -159,8 +159,8 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
|
||||||
StringID str;
|
StringID str;
|
||||||
|
|
||||||
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2);
|
w->disabled_state = v->owner == _local_player ? 0 : (1 << 2);
|
||||||
if (!_patches.servint_ships) // disable service-scroller when interval is set to disabled
|
// disable service-scroller when interval is set to disabled
|
||||||
w->disabled_state |= (1 << 5) | (1 << 6);
|
if (!_patches.servint_ships) w->disabled_state |= (1 << 5) | (1 << 6);
|
||||||
|
|
||||||
SetDParam(0, v->string_id);
|
SetDParam(0, v->string_id);
|
||||||
SetDParam(1, v->unitnumber);
|
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) {
|
switch (e->event) {
|
||||||
case WE_PAINT: {
|
case WE_PAINT: {
|
||||||
Vehicle *v = GetVehicle(w->window_number);
|
Vehicle *v = GetVehicle(w->window_number);
|
||||||
|
@ -460,8 +461,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
|
||||||
disabled = 0;
|
disabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v->owner != _local_player)
|
if (v->owner != _local_player) disabled |= 1<<8 | 1<<7;
|
||||||
disabled |= 1<<8 | 1<<7;
|
|
||||||
w->disabled_state = disabled;
|
w->disabled_state = disabled;
|
||||||
|
|
||||||
/* draw widgets & caption */
|
/* draw widgets & caption */
|
||||||
|
@ -497,8 +497,9 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) {
|
||||||
if (v->num_orders == 0) {
|
if (v->num_orders == 0) {
|
||||||
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
||||||
SetDParam(0, v->cur_speed / 2);
|
SetDParam(0, v->cur_speed / 2);
|
||||||
} else
|
} else {
|
||||||
str = STR_EMPTY;
|
str = STR_EMPTY;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,8 +617,7 @@ static void DrawShipDepotWindow(Window *w)
|
||||||
/* determine amount of items for scroller */
|
/* determine amount of items for scroller */
|
||||||
num = 0;
|
num = 0;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->type == VEH_Ship && IsShipInDepot(v) && v->tile == tile)
|
if (v->type == VEH_Ship && IsShipInDepot(v) && v->tile == tile) num++;
|
||||||
num++;
|
|
||||||
}
|
}
|
||||||
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
|
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;
|
xt = x / 90;
|
||||||
xm = x % 90;
|
xm = x % 90;
|
||||||
if (xt >= w->hscroll.cap)
|
if (xt >= w->hscroll.cap) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
row = (y - 14) / 24;
|
row = (y - 14) / 24;
|
||||||
ym = (y - 14) % 24;
|
ym = (y - 14) % 24;
|
||||||
if (row >= w->vscroll.cap)
|
if (row >= w->vscroll.cap) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
pos = (row + w->vscroll.pos) * w->hscroll.cap + xt;
|
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 */
|
return 1; /* outside */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ShipDepotClick(Window *w, int x, int y)
|
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);
|
int mode = GetVehicleFromShipDepotWndPt(w, x, y, &v);
|
||||||
|
|
||||||
// share / copy orders
|
// 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) {
|
switch (mode) {
|
||||||
case 1: // invalid
|
case 1: // invalid
|
||||||
|
@ -1035,14 +1035,12 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
return;
|
return;
|
||||||
case 7: { /* Matrix to show vehicles */
|
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;
|
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
|
if (id_v >= w->vscroll.cap) return; // click out of bounds
|
||||||
|
|
||||||
id_v += w->vscroll.pos;
|
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);
|
||||||
|
@ -1050,7 +1048,6 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
assert(v->type == VEH_Ship);
|
assert(v->type == VEH_Ship);
|
||||||
|
|
||||||
ShowShipViewWindow(v);
|
ShowShipViewWindow(v);
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 9: /* Build new Vehicle */
|
case 9: /* Build new Vehicle */
|
||||||
|
@ -1075,8 +1072,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
_sorting.ship.criteria = vl->sort_type;
|
_sorting.ship.criteria = vl->sort_type;
|
||||||
|
|
||||||
// enable 'Sort By' if a sorter criteria is chosen
|
// enable 'Sort By' if a sorter criteria is chosen
|
||||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3);
|
||||||
CLRBIT(w->disabled_state, 3);
|
|
||||||
}
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -83,29 +83,35 @@ static const char *CocoaSoundStart(const char * const *parm)
|
||||||
desc.componentFlagsMask = 0;
|
desc.componentFlagsMask = 0;
|
||||||
|
|
||||||
comp = FindNextComponent (NULL, &desc);
|
comp = FindNextComponent (NULL, &desc);
|
||||||
if (comp == NULL)
|
if (comp == NULL) {
|
||||||
return "cocoa_s: Failed to start CoreAudio: FindNextComponent returned NULL";
|
return "cocoa_s: Failed to start CoreAudio: FindNextComponent returned NULL";
|
||||||
|
}
|
||||||
|
|
||||||
/* Open & initialize the default output audio unit */
|
/* 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";
|
return "cocoa_s: Failed to start CoreAudio: OpenAComponent";
|
||||||
|
}
|
||||||
|
|
||||||
if (AudioUnitInitialize(_outputAudioUnit) != noErr)
|
if (AudioUnitInitialize(_outputAudioUnit) != noErr) {
|
||||||
return "cocoa_s: Failed to start CoreAudio: AudioUnitInitialize";
|
return "cocoa_s: Failed to start CoreAudio: AudioUnitInitialize";
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the input format of the audio unit. */
|
/* 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)";
|
return "cocoa_s: Failed to start CoreAudio: AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)";
|
||||||
|
}
|
||||||
|
|
||||||
/* Set the audio callback */
|
/* Set the audio callback */
|
||||||
callback.inputProc = audioCallback;
|
callback.inputProc = audioCallback;
|
||||||
callback.inputProcRefCon = NULL;
|
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)";
|
return "cocoa_s: Failed to start CoreAudio: AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)";
|
||||||
|
}
|
||||||
|
|
||||||
/* Finally, start processing of the audio unit */
|
/* Finally, start processing of the audio unit */
|
||||||
if (AudioOutputUnitStart(_outputAudioUnit) != noErr)
|
if (AudioOutputUnitStart(_outputAudioUnit) != noErr) {
|
||||||
return "cocoa_s: Failed to start CoreAudio: AudioOutputUnitStart";
|
return "cocoa_s: Failed to start CoreAudio: AudioOutputUnitStart";
|
||||||
|
}
|
||||||
|
|
||||||
/* We're running! */
|
/* We're running! */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -2204,23 +2204,20 @@ static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode)
|
||||||
{
|
{
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case TRANSPORT_RAIL:
|
case TRANSPORT_RAIL:
|
||||||
if (IsRailwayStation(tile)) {
|
if (IsRailwayStation(tile) && !IsStationTileBlocked(tile)) {
|
||||||
if (IsStationTileBlocked(tile)) return 0;
|
|
||||||
|
|
||||||
return TrackToTrackBits(GetRailStationTrack(tile)) * 0x101;
|
return TrackToTrackBits(GetRailStationTrack(tile)) * 0x101;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRANSPORT_WATER:
|
case TRANSPORT_WATER:
|
||||||
// buoy is coded as a station, it is always on open water
|
// buoy is coded as a station, it is always on open water
|
||||||
// (0x3F, all tracks available)
|
if (IsBuoy_(tile)) return TRACK_BIT_ALL * 0x101;
|
||||||
if (IsBuoy_(tile)) return 0x3F * 0x101;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRANSPORT_ROAD:
|
case TRANSPORT_ROAD:
|
||||||
if (IsRoadStopTile(tile))
|
if (IsRoadStopTile(tile)) {
|
||||||
return (DiagDirToAxis(GetRoadStopDir(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
return (DiagDirToAxis(GetRoadStopDir(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -2549,11 +2546,12 @@ static void UpdateStationRating(Station *st)
|
||||||
|
|
||||||
index = st->index;
|
index = st->index;
|
||||||
|
|
||||||
if (waiting_changed)
|
if (waiting_changed) {
|
||||||
InvalidateWindow(WC_STATION_VIEW, index);
|
InvalidateWindow(WC_STATION_VIEW, index);
|
||||||
else
|
} else {
|
||||||
InvalidateWindowWidget(WC_STATION_VIEW, index, 5);
|
InvalidateWindowWidget(WC_STATION_VIEW, index, 5);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* called for every station each tick */
|
/* called for every station each tick */
|
||||||
static void StationHandleSmallTick(Station *st)
|
static void StationHandleSmallTick(Station *st)
|
||||||
|
|
|
@ -890,7 +890,7 @@ static uint32 MyHashStr(uint32 hash, const char *s)
|
||||||
{
|
{
|
||||||
for (; *s != '\0'; s++) {
|
for (; *s != '\0'; s++) {
|
||||||
hash = ROL(hash, 3) ^ *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;
|
return hash;
|
||||||
}
|
}
|
||||||
|
@ -914,7 +914,7 @@ static void MakeHashOfStrings(void)
|
||||||
|
|
||||||
s = ls->name;
|
s = ls->name;
|
||||||
hash ^= i * 0x717239;
|
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);
|
hash = MyHashStr(hash, s + 1);
|
||||||
|
|
||||||
s = ls->english;
|
s = ls->english;
|
||||||
|
@ -922,7 +922,7 @@ static void MakeHashOfStrings(void)
|
||||||
if (cs->flags & C_DONTCOUNT) continue;
|
if (cs->flags & C_DONTCOUNT) continue;
|
||||||
|
|
||||||
hash ^= (cs - _cmd_structs) * 0x1234567;
|
hash ^= (cs - _cmd_structs) * 0x1234567;
|
||||||
if (hash & 1) hash = (hash >> 1) ^ 0xF00BAA4; else hash >>= 1;
|
hash = (hash & 1 ? hash >> 1 ^ 0xF00BAA4 : hash >> 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,8 +235,8 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_PLACE_MOUSEUP:
|
case WE_PLACE_MOUSEUP:
|
||||||
if (e->click.pt.x != -1) {
|
if (e->click.pt.x != -1 &&
|
||||||
if ((e->place.userdata & 0xF) == VPM_X_AND_Y) // dragged actions
|
(e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
|
||||||
GUIPlaceProcDragXY(e);
|
GUIPlaceProcDragXY(e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
2
tile.h
2
tile.h
|
@ -46,7 +46,7 @@ static inline void SetTileHeight(TileIndex tile, uint height)
|
||||||
|
|
||||||
static inline uint TilePixelHeight(TileIndex tile)
|
static inline uint TilePixelHeight(TileIndex tile)
|
||||||
{
|
{
|
||||||
return TileHeight(tile) * 8;
|
return TileHeight(tile) * TILE_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TileType GetTileType(TileIndex tile)
|
static inline TileType GetTileType(TileIndex tile)
|
||||||
|
|
|
@ -697,9 +697,9 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
|
||||||
|
|
||||||
if (IsTileType(tile, MP_STREET)) {
|
if (IsTileType(tile, MP_STREET)) {
|
||||||
/* Don't allow building over roads of other cities */
|
/* 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;
|
_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
|
/* 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) */
|
* owner :) (happy happy happy road now) */
|
||||||
SetTileOwner(tile, OWNER_TOWN);
|
SetTileOwner(tile, OWNER_TOWN);
|
||||||
|
|
73
train_gui.c
73
train_gui.c
|
@ -134,8 +134,7 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
Vehicle *v,*found;
|
Vehicle *v,*found;
|
||||||
|
|
||||||
if (!success)
|
if (!success) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// find a locomotive in the depot.
|
// find a locomotive in the depot.
|
||||||
found = NULL;
|
found = NULL;
|
||||||
|
@ -143,8 +142,7 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
if (v->type == VEH_Train && IsFrontEngine(v) &&
|
if (v->type == VEH_Train && IsFrontEngine(v) &&
|
||||||
v->tile == tile &&
|
v->tile == tile &&
|
||||||
v->u.rail.track == 0x80) {
|
v->u.rail.track == 0x80) {
|
||||||
if (found != NULL) // must be exactly one.
|
if (found != NULL) return; // must be exactly one.
|
||||||
return;
|
|
||||||
found = v;
|
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))
|
!HASBIT(e->player_avail, _local_player))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (*sel == 0)
|
if (*sel == 0) *selected_id = i;
|
||||||
*selected_id = i;
|
|
||||||
|
|
||||||
if (IS_INT_INSIDE(--*pos, -show_max, 0)) {
|
if (IS_INT_INSIDE(--*pos, -show_max, 0)) {
|
||||||
DrawString(*x + 59, *y + 2, GetCustomEngineName(i), *sel == 0 ? 0xC : 0x10);
|
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) {
|
switch (e->event) {
|
||||||
case WE_PAINT:
|
case WE_PAINT:
|
||||||
|
|
||||||
if (w->window_number == 0)
|
if (w->window_number == 0) SETBIT(w->disabled_state, 5);
|
||||||
SETBIT(w->disabled_state, 5);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -218,10 +214,11 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
|
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
|
||||||
const Engine *e = GetEngine(i);
|
const Engine *e = GetEngine(i);
|
||||||
if (HasPowerOnRail(e->railtype, railtype)
|
if (HasPowerOnRail(e->railtype, railtype) &&
|
||||||
&& HASBIT(e->player_avail, _local_player))
|
HASBIT(e->player_avail, _local_player)) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SetVScrollCount(w, count);
|
SetVScrollCount(w, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,20 +559,16 @@ static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head)
|
||||||
|
|
||||||
v = GetVehicle(sel);
|
v = GetVehicle(sel);
|
||||||
|
|
||||||
if (v == wagon)
|
if (v == wagon) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (wagon == NULL) {
|
if (wagon == NULL) {
|
||||||
if (head != NULL)
|
if (head != NULL) wagon = GetLastVehicleInChain(head);
|
||||||
wagon = GetLastVehicleInChain(head);
|
|
||||||
} else {
|
} else {
|
||||||
wagon = GetPrevVehicleInChain(wagon);
|
wagon = GetPrevVehicleInChain(wagon);
|
||||||
if (wagon == NULL)
|
if (wagon == NULL) return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wagon == v)
|
if (wagon == v) return;
|
||||||
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));
|
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);
|
mode = GetVehicleFromTrainDepotWndPt(w, x, y, &gdvp);
|
||||||
|
|
||||||
// share / copy orders
|
// 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;
|
v = gdvp.wagon;
|
||||||
|
|
||||||
|
@ -683,14 +679,14 @@ static void TrainDepotWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case WE_PLACE_OBJ: {
|
case WE_PLACE_OBJ:
|
||||||
ClonePlaceObj(w);
|
ClonePlaceObj(w);
|
||||||
} break;
|
break;
|
||||||
|
|
||||||
case WE_ABORT_PLACE_OBJ: {
|
case WE_ABORT_PLACE_OBJ:
|
||||||
CLRBIT(w->click_state, 9);
|
CLRBIT(w->click_state, 9);
|
||||||
InvalidateWidget(w, 9);
|
InvalidateWidget(w, 9);
|
||||||
} break;
|
break;
|
||||||
|
|
||||||
// check if a vehicle in a depot was clicked..
|
// check if a vehicle in a depot was clicked..
|
||||||
case WE_MOUSELOOP: {
|
case WE_MOUSELOOP: {
|
||||||
|
@ -994,8 +990,9 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
|
||||||
if (v->num_orders == 0) {
|
if (v->num_orders == 0) {
|
||||||
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
str = STR_NO_ORDERS + _patches.vehicle_speed;
|
||||||
SetDParam(0, v->u.rail.last_speed);
|
SetDParam(0, v->u.rail.last_speed);
|
||||||
} else
|
} else {
|
||||||
str = STR_EMPTY;
|
str = STR_EMPTY;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1308,8 +1305,7 @@ do_change_service_int:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_RESIZE:
|
case WE_RESIZE:
|
||||||
if (e->sizing.diff.y == 0)
|
if (e->sizing.diff.y == 0) break;
|
||||||
break;
|
|
||||||
|
|
||||||
w->vscroll.cap += e->sizing.diff.y / 14;
|
w->vscroll.cap += e->sizing.diff.y / 14;
|
||||||
w->widget[4].unkA = (w->vscroll.cap << 8) + 1;
|
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);
|
SetVScrollCount(w, vl->list_length);
|
||||||
|
|
||||||
// disable 'Sort By' tooltip on Unsorted sorting criteria
|
// disable 'Sort By' tooltip on Unsorted sorting criteria
|
||||||
if (vl->sort_type == SORT_BY_UNSORTED)
|
if (vl->sort_type == SORT_BY_UNSORTED) w->disabled_state |= (1 << 3);
|
||||||
w->disabled_state |= (1 << 3);
|
|
||||||
|
|
||||||
/* draw the widgets */
|
/* draw the widgets */
|
||||||
{
|
{
|
||||||
|
@ -1454,10 +1449,11 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
DrawVehicleProfitButton(v, x, y + 13);
|
DrawVehicleProfitButton(v, x, y + 13);
|
||||||
|
|
||||||
SetDParam(0, v->unitnumber);
|
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;
|
str = STR_021F;
|
||||||
else
|
} else {
|
||||||
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
|
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
|
||||||
|
}
|
||||||
DrawString(x, y + 2, str, 0);
|
DrawString(x, y + 2, str, 0);
|
||||||
|
|
||||||
SetDParam(0, v->profit_this_year);
|
SetDParam(0, v->profit_this_year);
|
||||||
|
@ -1489,14 +1485,12 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case 7: { /* Matrix to show vehicles */
|
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;
|
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
|
if (id_v >= w->vscroll.cap) return; // click out of bounds
|
||||||
|
|
||||||
id_v += w->vscroll.pos;
|
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);
|
||||||
|
@ -1504,7 +1498,6 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
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;
|
} break;
|
||||||
|
|
||||||
case 9: /* Build new Vehicle */
|
case 9: /* Build new Vehicle */
|
||||||
|
@ -1512,13 +1505,10 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
ShowBuildTrainWindow(0);
|
ShowBuildTrainWindow(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 10: {
|
case 10:
|
||||||
if (!IsWindowOfPrototype(w, _player_trains_widgets))
|
if (IsWindowOfPrototype(w, _player_trains_widgets)) break;
|
||||||
break;
|
|
||||||
|
|
||||||
ShowReplaceVehicleWindow(VEH_Train);
|
ShowReplaceVehicleWindow(VEH_Train);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -1531,8 +1521,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
_sorting.train.criteria = vl->sort_type;
|
_sorting.train.criteria = vl->sort_type;
|
||||||
|
|
||||||
// enable 'Sort By' if a sorter criteria is chosen
|
// enable 'Sort By' if a sorter criteria is chosen
|
||||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
if (vl->sort_type != SORT_BY_UNSORTED) CLRBIT(w->disabled_state, 3);
|
||||||
CLRBIT(w->disabled_state, 3);
|
|
||||||
}
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
@ -1592,7 +1581,7 @@ void ShowPlayerTrains(PlayerID player, StationID station)
|
||||||
} else {
|
} else {
|
||||||
w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player);
|
w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | player);
|
||||||
}
|
}
|
||||||
if (w) {
|
if (w != NULL) {
|
||||||
w->caption_color = player;
|
w->caption_color = player;
|
||||||
w->hscroll.cap = 10 * 29;
|
w->hscroll.cap = 10 * 29;
|
||||||
w->vscroll.cap = 7; // maximum number of vehicles shown
|
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
|
// 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 _price.terraform;
|
||||||
|
}
|
||||||
|
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
13
unix.c
13
unix.c
|
@ -302,10 +302,11 @@ char *FiosBrowseTo(const FiosItem *item)
|
||||||
switch (item->type) {
|
switch (item->type) {
|
||||||
case FIOS_TYPE_PARENT:
|
case FIOS_TYPE_PARENT:
|
||||||
s = strrchr(path, '/');
|
s = strrchr(path, '/');
|
||||||
if (s != path)
|
if (s != path) {
|
||||||
s[0] = '\0';
|
s[0] = '\0';
|
||||||
else
|
} else {
|
||||||
s[1] = '\0';
|
s[1] = '\0';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIOS_TYPE_DIR:
|
case FIOS_TYPE_DIR:
|
||||||
|
@ -351,9 +352,10 @@ StringID FiosGetDescText(const char **path, uint32 *tot)
|
||||||
|
|
||||||
if (statvfs(*path, &s) == 0) {
|
if (statvfs(*path, &s) == 0) {
|
||||||
free = (uint64)s.f_frsize * s.f_bavail >> 20;
|
free = (uint64)s.f_frsize * s.f_bavail >> 20;
|
||||||
} else
|
} else {
|
||||||
return STR_4006_UNABLE_TO_READ_DRIVE;
|
return STR_4006_UNABLE_TO_READ_DRIVE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (tot != NULL) *tot = free;
|
if (tot != NULL) *tot = free;
|
||||||
return STR_4005_BYTES_FREE;
|
return STR_4005_BYTES_FREE;
|
||||||
|
@ -364,10 +366,7 @@ void FiosMakeSavegameName(char *buf, const char *name, size_t size)
|
||||||
const char* extension;
|
const char* extension;
|
||||||
const char* period;
|
const char* period;
|
||||||
|
|
||||||
if (_game_mode == GM_EDITOR)
|
extension = (_game_mode == GM_EDITOR ? ".scn" : ".sav");
|
||||||
extension = ".scn";
|
|
||||||
else
|
|
||||||
extension = ".sav";
|
|
||||||
|
|
||||||
// Don't append the extension, if it is already there
|
// Don't append the extension, if it is already there
|
||||||
period = strrchr(name, '.');
|
period = strrchr(name, '.');
|
||||||
|
|
|
@ -51,8 +51,7 @@ void UpdateCompanyHQ(Player *p, uint score)
|
||||||
byte val;
|
byte val;
|
||||||
TileIndex tile = p->location_of_house;
|
TileIndex tile = p->location_of_house;
|
||||||
|
|
||||||
if (tile == 0)
|
if (tile == 0) return;
|
||||||
return;
|
|
||||||
|
|
||||||
(val = 0, score < 170) ||
|
(val = 0, score < 170) ||
|
||||||
(val++, score < 350) ||
|
(val++, score < 350) ||
|
||||||
|
@ -110,8 +109,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
||||||
|
|
||||||
switch (GetUnmovableType(ti->tile)) {
|
switch (GetUnmovableType(ti->tile)) {
|
||||||
case UNMOVABLE_TRANSMITTER:
|
case UNMOVABLE_TRANSMITTER:
|
||||||
case UNMOVABLE_LIGHTHOUSE:
|
case UNMOVABLE_LIGHTHOUSE: {
|
||||||
{
|
|
||||||
const DrawTileUnmovableStruct* dtus;
|
const DrawTileUnmovableStruct* dtus;
|
||||||
|
|
||||||
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
|
||||||
|
@ -122,9 +120,13 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
||||||
image = dtus->image;
|
image = dtus->image;
|
||||||
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
||||||
|
|
||||||
AddSortableSpriteToDraw(image, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
|
AddSortableSpriteToDraw(
|
||||||
dtus->width, dtus->height, dtus->z_size, ti->z);
|
image, ti->x | dtus->subcoord_x, ti->y | dtus->subcoord_y,
|
||||||
} break;
|
dtus->width, dtus->height, dtus->z_size, ti->z
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case UNMOVABLE_STATUE:
|
case UNMOVABLE_STATUE:
|
||||||
DrawGroundSprite(SPR_CONCRETE_GROUND);
|
DrawGroundSprite(SPR_CONCRETE_GROUND);
|
||||||
|
|
||||||
|
@ -133,6 +135,7 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
||||||
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
|
||||||
AddSortableSpriteToDraw(image, ti->x, ti->y, 16, 16, 25, ti->z);
|
AddSortableSpriteToDraw(image, ti->x, ti->y, 16, 16, 25, ti->z);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UNMOVABLE_OWNED_LAND:
|
case UNMOVABLE_OWNED_LAND:
|
||||||
DrawClearLandTile(ti, 0);
|
DrawClearLandTile(ti, 0);
|
||||||
|
|
||||||
|
@ -140,10 +143,9 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
||||||
PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)) + PALETTE_MODIFIER_COLOR + SPR_BOUGHT_LAND,
|
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)
|
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;
|
break;
|
||||||
default:
|
|
||||||
{
|
default: {
|
||||||
const DrawTileSeqStruct* dtss;
|
const DrawTileSeqStruct* dtss;
|
||||||
const DrawTileSprites* t;
|
const DrawTileSprites* t;
|
||||||
|
|
||||||
|
@ -162,10 +164,13 @@ static void DrawTile_Unmovable(TileInfo *ti)
|
||||||
} else {
|
} else {
|
||||||
image |= ormod;
|
image |= ormod;
|
||||||
}
|
}
|
||||||
AddSortableSpriteToDraw(image, ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
AddSortableSpriteToDraw(
|
||||||
dtss->width, dtss->height, dtss->unk, ti->z + dtss->delta_z);
|
image, ti->x + dtss->delta_x, ti->y + dtss->delta_y,
|
||||||
|
dtss->width, dtss->height, dtss->unk, ti->z + dtss->delta_z
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
vehicle.c
23
vehicle.c
|
@ -637,7 +637,9 @@ static bool CanFillVehicle_FullLoadAny(Vehicle *v)
|
||||||
|
|
||||||
//if the aircraft carries passengers and is NOT full, then
|
//if the aircraft carries passengers and is NOT full, then
|
||||||
//continue loading, no matter how much mail is in
|
//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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,7 +650,12 @@ static bool CanFillVehicle_FullLoadAny(Vehicle *v)
|
||||||
|
|
||||||
if (v->cargo_cap != 0) {
|
if (v->cargo_cap != 0) {
|
||||||
uint32 mask = 1 << v->cargo_type;
|
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);
|
||||||
|
|
||||||
|
@ -670,12 +677,10 @@ bool CanFillVehicle(Vehicle *v)
|
||||||
))) {
|
))) {
|
||||||
|
|
||||||
// If patch is active, use alternative CanFillVehicle-function
|
// If patch is active, use alternative CanFillVehicle-function
|
||||||
if (_patches.full_load_any)
|
if (_patches.full_load_any) return CanFillVehicle_FullLoadAny(v);
|
||||||
return CanFillVehicle_FullLoadAny(v);
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (v->cargo_count != v->cargo_cap)
|
if (v->cargo_count != v->cargo_cap) return true;
|
||||||
return true;
|
|
||||||
} while ((v = v->next) != NULL);
|
} while ((v = v->next) != NULL);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -754,14 +759,12 @@ void ViewportAddVehicles(DrawPixelInfo *dpi)
|
||||||
veh = v->next_hash;
|
veh = v->next_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x == x2)
|
if (x == x2) break;
|
||||||
break;
|
|
||||||
x = (x + 1) & 0x3F;
|
x = (x + 1) & 0x3F;
|
||||||
}
|
}
|
||||||
x = xb;
|
x = xb;
|
||||||
|
|
||||||
if (y == y2)
|
if (y == y2) break;
|
||||||
break;
|
|
||||||
y = (y + 0x40) & ((0x3F) << 6);
|
y = (y + 0x40) & ((0x3F) << 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,18 +362,21 @@ static int PollEvent(void)
|
||||||
if (_patches.autosave_on_exit) {
|
if (_patches.autosave_on_exit) {
|
||||||
DoExitSave();
|
DoExitSave();
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else {
|
||||||
AskExitGame();
|
AskExitGame();
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYDOWN: /* Toggle full-screen on ALT + ENTER/F */
|
case SDL_KEYDOWN: /* Toggle full-screen on ALT + ENTER/F */
|
||||||
if ((ev.key.keysym.mod & (KMOD_ALT | KMOD_META)) &&
|
if ((ev.key.keysym.mod & (KMOD_ALT | KMOD_META)) &&
|
||||||
(ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_f)) {
|
(ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_f)) {
|
||||||
ToggleFullScreen(!_fullscreen);
|
ToggleFullScreen(!_fullscreen);
|
||||||
} else
|
} else {
|
||||||
_pressed_key = ConvertSdlKeyIntoMy(&ev.key.keysym);
|
_pressed_key = ConvertSdlKeyIntoMy(&ev.key.keysym);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -252,8 +252,7 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
UINT nChanged = RealizePalette(hDC);
|
UINT nChanged = RealizePalette(hDC);
|
||||||
SelectPalette(hDC, hOldPalette, TRUE);
|
SelectPalette(hDC, hOldPalette, TRUE);
|
||||||
ReleaseDC(hwnd, hDC);
|
ReleaseDC(hwnd, hDC);
|
||||||
if (nChanged)
|
if (nChanged) InvalidateRect(hwnd, NULL, FALSE);
|
||||||
InvalidateRect(hwnd, NULL, FALSE);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,9 +262,9 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
|
||||||
} else if (_patches.autosave_on_exit) {
|
} else if (_patches.autosave_on_exit) {
|
||||||
DoExitSave();
|
DoExitSave();
|
||||||
_exit_game = true;
|
_exit_game = true;
|
||||||
} else
|
} else {
|
||||||
AskExitGame();
|
AskExitGame();
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
|
@ -787,8 +786,9 @@ static void Win32GdiMainLoop(void)
|
||||||
#endif
|
#endif
|
||||||
!_networking && _game_mode != GM_MENU)
|
!_networking && _game_mode != GM_MENU)
|
||||||
_fast_forward |= 2;
|
_fast_forward |= 2;
|
||||||
} else if (_fast_forward & 2)
|
} else if (_fast_forward & 2) {
|
||||||
_fast_forward = 0;
|
_fast_forward = 0;
|
||||||
|
}
|
||||||
|
|
||||||
cur_ticks = GetTickCount();
|
cur_ticks = GetTickCount();
|
||||||
if ((_fast_forward && !_pause) || cur_ticks > next_tick)
|
if ((_fast_forward && !_pause) || cur_ticks > next_tick)
|
||||||
|
@ -809,14 +809,14 @@ static void Win32GdiMainLoop(void)
|
||||||
(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
|
(GetAsyncKeyState(VK_UP) < 0 ? 2 : 0) +
|
||||||
(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
|
(GetAsyncKeyState(VK_RIGHT) < 0 ? 4 : 0) +
|
||||||
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
|
(GetAsyncKeyState(VK_DOWN) < 0 ? 8 : 0);
|
||||||
} else
|
} else {
|
||||||
_dirkeys = 0;
|
_dirkeys = 0;
|
||||||
|
}
|
||||||
|
|
||||||
GameLoop();
|
GameLoop();
|
||||||
_cursor.delta.x = _cursor.delta.y = 0;
|
_cursor.delta.x = _cursor.delta.y = 0;
|
||||||
|
|
||||||
if (_force_full_redraw)
|
if (_force_full_redraw) MarkWholeScreenDirty();
|
||||||
MarkWholeScreenDirty();
|
|
||||||
|
|
||||||
GdiFlush();
|
GdiFlush();
|
||||||
_screen.dst_ptr = _wnd.buffer_bits;
|
_screen.dst_ptr = _wnd.buffer_bits;
|
||||||
|
|
27
viewport.c
27
viewport.c
|
@ -1955,25 +1955,28 @@ static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int meth
|
||||||
h = myabs(dy) + 16;
|
h = myabs(dy) + 16;
|
||||||
|
|
||||||
if (TileVirtXY(thd->selstart.x, thd->selstart.y) == TileVirtXY(x, y)) { // check if we're only within one tile
|
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);
|
b = GetAutorailHT(x, y);
|
||||||
else // rect for autosignals on one tile
|
} else { // rect for autosignals on one tile
|
||||||
b = HT_RECT;
|
b = HT_RECT;
|
||||||
|
}
|
||||||
} else if (h == 16) { // Is this in X direction?
|
} 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;
|
b = (Check2x1AutoRail(3)) | HT_LINE;
|
||||||
else if (dx == -16)
|
} else if (dx == -16) {
|
||||||
b = (Check2x1AutoRail(2)) | HT_LINE;
|
b = (Check2x1AutoRail(2)) | HT_LINE;
|
||||||
else
|
} else {
|
||||||
b = HT_LINE | HT_DIR_X;
|
b = HT_LINE | HT_DIR_X;
|
||||||
|
}
|
||||||
y = thd->selstart.y;
|
y = thd->selstart.y;
|
||||||
} else if (w == 16) { // Or Y direction?
|
} else if (w == 16) { // Or Y direction?
|
||||||
if (dy == 16) // 2x1 special handling
|
if (dy == 16) { // 2x1 special handling
|
||||||
b = (Check2x1AutoRail(1)) | HT_LINE;
|
b = (Check2x1AutoRail(1)) | HT_LINE;
|
||||||
else if (dy == -16) // 2x1 other direction
|
} else if (dy == -16) { // 2x1 other direction
|
||||||
b = (Check2x1AutoRail(0)) | HT_LINE;
|
b = (Check2x1AutoRail(0)) | HT_LINE;
|
||||||
else
|
} else {
|
||||||
b = HT_LINE | HT_DIR_Y;
|
b = HT_LINE | HT_DIR_Y;
|
||||||
|
}
|
||||||
x = thd->selstart.x;
|
x = thd->selstart.x;
|
||||||
} else if (w > h * 2) { // still count as x dir?
|
} else if (w > h * 2) { // still count as x dir?
|
||||||
b = HT_LINE | HT_DIR_X;
|
b = HT_LINE | HT_DIR_X;
|
||||||
|
@ -2082,7 +2085,11 @@ void VpSelectTilesWithMethod(int x, int y, int method)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VPM_X_OR_Y:
|
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;
|
break;
|
||||||
|
|
||||||
case VPM_X_AND_Y:
|
case VPM_X_AND_Y:
|
||||||
|
@ -2196,5 +2203,5 @@ void SetObjectToPlace(CursorID icon, byte mode, WindowClass window_class, Window
|
||||||
|
|
||||||
void ResetObjectToPlace(void)
|
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:
|
case WATER_DEPOT:
|
||||||
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
|
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
|
||||||
|
|
||||||
return RemoveShipDepot(tile, flags);
|
return RemoveShipDepot(tile, flags);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
64
waypoint.c
64
waypoint.c
|
@ -34,8 +34,7 @@ static void WaypointPoolNewBlock(uint start_item)
|
||||||
{
|
{
|
||||||
Waypoint *wp;
|
Waypoint *wp;
|
||||||
|
|
||||||
FOR_ALL_WAYPOINTS_FROM(wp, start_item)
|
FOR_ALL_WAYPOINTS_FROM(wp, start_item) wp->index = start_item++;
|
||||||
wp->index = start_item++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the town-pool */
|
/* Initialize the town-pool */
|
||||||
|
@ -50,7 +49,7 @@ static Waypoint* AllocateWaypoint(void)
|
||||||
if (wp->xy == 0) {
|
if (wp->xy == 0) {
|
||||||
uint index = wp->index;
|
uint index = wp->index;
|
||||||
|
|
||||||
memset(wp, 0, sizeof(Waypoint));
|
memset(wp, 0, sizeof(*wp));
|
||||||
wp->index = index;
|
wp->index = index;
|
||||||
|
|
||||||
return wp;
|
return wp;
|
||||||
|
@ -58,8 +57,7 @@ static Waypoint* AllocateWaypoint(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we can add a block to the pool */
|
/* Check if we can add a block to the pool */
|
||||||
if (AddBlockToPool(&_waypoint_pool))
|
if (AddBlockToPool(&_waypoint_pool)) return AllocateWaypoint();
|
||||||
return AllocateWaypoint();
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -88,8 +86,7 @@ void UpdateAllWaypointSigns(void)
|
||||||
Waypoint *wp;
|
Waypoint *wp;
|
||||||
|
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
if (wp->xy)
|
if (wp->xy != 0) UpdateWaypointSign(wp);
|
||||||
UpdateWaypointSign(wp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +103,7 @@ static void MakeDefaultWaypointName(Waypoint* wp)
|
||||||
|
|
||||||
/* Find an unused waypoint number belonging to this town */
|
/* Find an unused waypoint number belonging to this town */
|
||||||
FOR_ALL_WAYPOINTS(local_wp) {
|
FOR_ALL_WAYPOINTS(local_wp) {
|
||||||
if (wp == local_wp)
|
if (wp == local_wp) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
if (local_wp->xy && local_wp->string == STR_NULL && local_wp->town_index == wp->town_index)
|
if (local_wp->xy && local_wp->string == STR_NULL && local_wp->town_index == wp->town_index)
|
||||||
used_waypoint[local_wp->town_cn] = true;
|
used_waypoint[local_wp->town_cn] = true;
|
||||||
|
@ -124,11 +120,12 @@ static void MakeDefaultWaypointName(Waypoint* wp)
|
||||||
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile)
|
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile)
|
||||||
{
|
{
|
||||||
Waypoint *wp, *best = NULL;
|
Waypoint *wp, *best = NULL;
|
||||||
uint thres = 8, cur_dist;
|
uint thres = 8;
|
||||||
|
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
if (wp->deleted && wp->xy) {
|
if (wp->deleted && wp->xy != 0) {
|
||||||
cur_dist = DistanceManhattan(tile, wp->xy);
|
uint cur_dist = DistanceManhattan(tile, wp->xy);
|
||||||
|
|
||||||
if (cur_dist < thres) {
|
if (cur_dist < thres) {
|
||||||
thres = cur_dist;
|
thres = cur_dist;
|
||||||
best = wp;
|
best = wp;
|
||||||
|
@ -190,14 +187,12 @@ int32 CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK);
|
return_cmd_error(STR_1005_NO_SUITABLE_RAILROAD_TRACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckTileOwnership(tile))
|
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
||||||
return CMD_ERROR;
|
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
tileh = GetTileSlope(tile, NULL);
|
tileh = GetTileSlope(tile, NULL);
|
||||||
if (tileh != SLOPE_FLAT) {
|
if (tileh != SLOPE_FLAT &&
|
||||||
if (!_patches.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))
|
(!_patches.build_on_slopes || IsSteepSlope(tileh) || !(tileh & (0x3 << axis)) || !(tileh & ~(0x3 << axis)))) {
|
||||||
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
|
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,8 +250,7 @@ static void DoDeleteWaypoint(Waypoint *wp)
|
||||||
order.station = wp->index;
|
order.station = wp->index;
|
||||||
DeleteDestinationFromVehicleOrder(order);
|
DeleteDestinationFromVehicleOrder(order);
|
||||||
|
|
||||||
if (wp->string != STR_NULL)
|
if (wp->string != STR_NULL) DeleteName(wp->string);
|
||||||
DeleteName(wp->string);
|
|
||||||
|
|
||||||
RedrawWaypointSign(wp);
|
RedrawWaypointSign(wp);
|
||||||
}
|
}
|
||||||
|
@ -268,9 +262,7 @@ void WaypointsDailyLoop(void)
|
||||||
|
|
||||||
/* Check if we need to delete a waypoint */
|
/* Check if we need to delete a waypoint */
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
if (wp->deleted && !--wp->deleted) {
|
if (wp->deleted != 0 && --wp->deleted == 0) DoDeleteWaypoint(wp);
|
||||||
DoDeleteWaypoint(wp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,14 +272,12 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
|
||||||
Waypoint *wp;
|
Waypoint *wp;
|
||||||
|
|
||||||
/* Make sure it's a waypoint */
|
/* Make sure it's a waypoint */
|
||||||
if (!IsTileType(tile, MP_RAILWAY) || !IsRailWaypoint(tile))
|
if (!IsTileType(tile, MP_RAILWAY) ||
|
||||||
return CMD_ERROR;
|
!IsRailWaypoint(tile) ||
|
||||||
|
(!CheckTileOwnership(tile) && _current_player != OWNER_WATER) ||
|
||||||
if (!CheckTileOwnership(tile) && !(_current_player == OWNER_WATER))
|
!EnsureNoVehicle(tile)) {
|
||||||
return CMD_ERROR;
|
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile))
|
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
wp = GetWaypointByTile(tile);
|
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)
|
int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
Waypoint *wp;
|
Waypoint *wp;
|
||||||
StringID str;
|
|
||||||
|
|
||||||
if (!IsWaypointIndex(p1)) return CMD_ERROR;
|
if (!IsWaypointIndex(p1)) return CMD_ERROR;
|
||||||
|
|
||||||
if (_cmd_text[0] != '\0') {
|
if (_cmd_text[0] != '\0') {
|
||||||
str = AllocateNameUnique(_cmd_text, 0);
|
StringID str = AllocateNameUnique(_cmd_text, 0);
|
||||||
if (str == 0)
|
|
||||||
return CMD_ERROR;
|
if (str == 0) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
wp = GetWaypoint(p1);
|
wp = GetWaypoint(p1);
|
||||||
if (wp->string != STR_NULL)
|
if (wp->string != STR_NULL) DeleteName(wp->string);
|
||||||
DeleteName(wp->string);
|
|
||||||
|
|
||||||
wp->string = str;
|
wp->string = str;
|
||||||
wp->town_cn = 0;
|
wp->town_cn = 0;
|
||||||
|
@ -352,8 +340,7 @@ int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
} else {
|
} else {
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
wp = GetWaypoint(p1);
|
wp = GetWaypoint(p1);
|
||||||
if (wp->string != STR_NULL)
|
if (wp->string != STR_NULL) DeleteName(wp->string);
|
||||||
DeleteName(wp->string);
|
|
||||||
|
|
||||||
MakeDefaultWaypointName(wp);
|
MakeDefaultWaypointName(wp);
|
||||||
UpdateWaypointSign(wp);
|
UpdateWaypointSign(wp);
|
||||||
|
@ -395,8 +382,7 @@ void FixOldWaypoints(void)
|
||||||
|
|
||||||
/* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */
|
/* Convert the old 'town_or_string', to 'string' / 'town' / 'town_cn' */
|
||||||
FOR_ALL_WAYPOINTS(wp) {
|
FOR_ALL_WAYPOINTS(wp) {
|
||||||
if (wp->xy == 0)
|
if (wp->xy == 0) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
wp->town_index = ClosestTownFromTile(wp->xy, (uint)-1)->index;
|
wp->town_index = ClosestTownFromTile(wp->xy, (uint)-1)->index;
|
||||||
wp->town_cn = 0;
|
wp->town_cn = 0;
|
||||||
|
|
29
win32.c
29
win32.c
|
@ -50,7 +50,7 @@ bool LoadLibraryList(Function proc[], const char* dll)
|
||||||
HMODULE lib = LoadLibrary(dll);
|
HMODULE lib = LoadLibrary(dll);
|
||||||
|
|
||||||
if (lib == NULL) return false;
|
if (lib == NULL) return false;
|
||||||
while (true) {
|
for (;;) {
|
||||||
FARPROC p;
|
FARPROC p;
|
||||||
|
|
||||||
while (*dll++ != '\0');
|
while (*dll++ != '\0');
|
||||||
|
@ -108,10 +108,7 @@ static void MakeCRCTable(uint32 *table) {
|
||||||
for (i = 0; i != 256; i++) {
|
for (i = 0; i != 256; i++) {
|
||||||
crc = i;
|
crc = i;
|
||||||
for (j = 8; j != 0; j--) {
|
for (j = 8; j != 0; j--) {
|
||||||
if (crc & 1)
|
src = (crc & 1 ? (crc >> 1) ^ poly : crc >> 1);
|
||||||
crc = (crc >> 1) ^ poly;
|
|
||||||
else
|
|
||||||
crc >>= 1;
|
|
||||||
}
|
}
|
||||||
table[i] = crc;
|
table[i] = crc;
|
||||||
}
|
}
|
||||||
|
@ -369,10 +366,11 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM l
|
||||||
case 12: // Close
|
case 12: // Close
|
||||||
ExitProcess(0);
|
ExitProcess(0);
|
||||||
case 13: { // Emergency save
|
case 13: { // Emergency save
|
||||||
if (DoEmergencySave(wnd))
|
if (DoEmergencySave(wnd)) {
|
||||||
MessageBoxA(wnd, _save_succeeded, "Save successful", MB_ICONINFORMATION);
|
MessageBoxA(wnd, _save_succeeded, "Save successful", MB_ICONINFORMATION);
|
||||||
else
|
} else {
|
||||||
MessageBoxA(wnd, "Save failed", "Save failed", MB_ICONINFORMATION);
|
MessageBoxA(wnd, "Save failed", "Save failed", MB_ICONINFORMATION);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 14: { // Submit crash report
|
case 14: { // Submit crash report
|
||||||
|
@ -904,10 +902,11 @@ char *FiosBrowseTo(const FiosItem *item)
|
||||||
|
|
||||||
case FIOS_TYPE_PARENT:
|
case FIOS_TYPE_PARENT:
|
||||||
s = strrchr(path, '\\');
|
s = strrchr(path, '\\');
|
||||||
if (s != path + 2)
|
if (s != path + 2) {
|
||||||
s[0] = '\0';
|
s[0] = '\0';
|
||||||
else
|
} else {
|
||||||
s[1] = '\0';
|
s[1] = '\0';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIOS_TYPE_DIR:
|
case FIOS_TYPE_DIR:
|
||||||
|
@ -955,8 +954,9 @@ StringID FiosGetDescText(const char **path, uint32 *tot)
|
||||||
if (tot != NULL && GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) {
|
if (tot != NULL && GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) {
|
||||||
*tot = ((spc * bps) * (uint64)nfc) >> 20;
|
*tot = ((spc * bps) * (uint64)nfc) >> 20;
|
||||||
sid = STR_4005_BYTES_FREE;
|
sid = STR_4005_BYTES_FREE;
|
||||||
} else
|
} else {
|
||||||
sid = STR_4006_UNABLE_TO_READ_DRIVE;
|
sid = STR_4006_UNABLE_TO_READ_DRIVE;
|
||||||
|
}
|
||||||
|
|
||||||
SetErrorMode(sem); // reset previous setting
|
SetErrorMode(sem); // reset previous setting
|
||||||
return sid;
|
return sid;
|
||||||
|
@ -967,10 +967,7 @@ void FiosMakeSavegameName(char *buf, const char *name, size_t size)
|
||||||
const char* extension;
|
const char* extension;
|
||||||
const char* period;
|
const char* period;
|
||||||
|
|
||||||
if (_game_mode == GM_EDITOR)
|
extension = (_game_mode == GM_EDITOR ? ".scn" : ".sav");
|
||||||
extension = ".scn";
|
|
||||||
else
|
|
||||||
extension = ".sav";
|
|
||||||
|
|
||||||
// Don't append the extension, if it is already there
|
// Don't append the extension, if it is already there
|
||||||
period = strrchr(name, '.');
|
period = strrchr(name, '.');
|
||||||
|
@ -1091,9 +1088,9 @@ void CreateConsole(void)
|
||||||
|
|
||||||
void ShowInfo(const char *str)
|
void ShowInfo(const char *str)
|
||||||
{
|
{
|
||||||
if (_has_console)
|
if (_has_console) {
|
||||||
puts(str);
|
puts(str);
|
||||||
else {
|
} else {
|
||||||
bool old;
|
bool old;
|
||||||
|
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
|
|
28
window.c
28
window.c
|
@ -43,8 +43,7 @@ static void DispatchLeftClickEvent(Window* w, int x, int y)
|
||||||
wi = &w->widget[e.click.widget];
|
wi = &w->widget[e.click.widget];
|
||||||
|
|
||||||
/* don't allow any interaction if the button has been disabled */
|
/* don't allow any interaction if the button has been disabled */
|
||||||
if (HASBIT(w->disabled_state, e.click.widget))
|
if (HASBIT(w->disabled_state, e.click.widget)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
if (wi->type & 0xE0) {
|
if (wi->type & 0xE0) {
|
||||||
/* special widget handling for buttons*/
|
/* special widget handling for buttons*/
|
||||||
|
@ -230,13 +229,14 @@ void DeleteWindow(Window *w)
|
||||||
{
|
{
|
||||||
WindowClass wc;
|
WindowClass wc;
|
||||||
WindowNumber wn;
|
WindowNumber wn;
|
||||||
ViewPort *vp;
|
|
||||||
Window *v;
|
Window *v;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
if (w == NULL) return;
|
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();
|
ResetObjectToPlace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,11 +247,10 @@ void DeleteWindow(Window *w)
|
||||||
|
|
||||||
w = FindWindowById(wc, wn);
|
w = FindWindowById(wc, wn);
|
||||||
|
|
||||||
vp = w->viewport;
|
if (w->viewport != NULL) {
|
||||||
|
CLRBIT(_active_viewports, w->viewport - _viewports);
|
||||||
|
w->viewport->width = 0;
|
||||||
w->viewport = NULL;
|
w->viewport = NULL;
|
||||||
if (vp != NULL) {
|
|
||||||
_active_viewports &= ~(1 << (vp - _viewports));
|
|
||||||
vp->width = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
|
@ -647,8 +646,11 @@ Window *AllocateWindowDesc(const WindowDesc *desc)
|
||||||
pt = GetAutoPlacePosition(desc->width, desc->height);
|
pt = GetAutoPlacePosition(desc->width, desc->height);
|
||||||
} else {
|
} else {
|
||||||
if (pt.x == WDP_CENTER) pt.x = (_screen.width - desc->width) >> 1;
|
if (pt.x == WDP_CENTER) pt.x = (_screen.width - desc->width) >> 1;
|
||||||
if (pt.y == WDP_CENTER) pt.y = (_screen.height - desc->height) >> 1;
|
if (pt.y == WDP_CENTER) {
|
||||||
else if(pt.y < 0) pt.y = _screen.height + pt.y; // if y is negative, it's from the bottom of the screen
|
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,10 +1620,11 @@ void DeleteAllNonVitalWindows(void)
|
||||||
if (w->flags4 & WF_STICKY) {
|
if (w->flags4 & WF_STICKY) {
|
||||||
DeleteWindow(w);
|
DeleteWindow(w);
|
||||||
w = _windows;
|
w = _windows;
|
||||||
} else
|
} else {
|
||||||
w++;
|
w++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Delete all always on-top windows to get an empty screen */
|
/* Delete all always on-top windows to get an empty screen */
|
||||||
void HideVitalWindows(void)
|
void HideVitalWindows(void)
|
||||||
|
@ -1634,8 +1637,9 @@ int PositionMainToolbar(Window *w)
|
||||||
{
|
{
|
||||||
DEBUG(misc, 1) ("Repositioning Main Toolbar...");
|
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);
|
w = FindWindowById(WC_MAIN_TOOLBAR, 0);
|
||||||
|
}
|
||||||
|
|
||||||
switch (_patches.toolbar_pos) {
|
switch (_patches.toolbar_pos) {
|
||||||
case 1: w->left = (_screen.width - w->width) >> 1; break;
|
case 1: w->left = (_screen.width - w->width) >> 1; break;
|
||||||
|
|
Loading…
Reference in New Issue