diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index bd19fe4253..8396d56485 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -782,8 +782,8 @@ DEF_CONSOLE_CMD(ConNetworkConnect) /* From a user pov 0 is a new company, internally it's different and all * companies are offset by one to ease up on users (eg companies 1-8 not 0-7) */ if (_network_playas != COMPANY_SPECTATOR) { + if (_network_playas > MAX_COMPANIES) return false; _network_playas--; - if (!IsValidCompanyID(_network_playas)) return false; } } if (port != NULL) { diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 73c1be9b9f..4324423522 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -123,11 +123,11 @@ public: this->DrawWidgets(); /* Draw nice progress bar :) */ - DrawFrameRect(20, 18, 20 + (int)((this->width - 40) * this->downloaded_bytes / this->total_bytes), 28, COLOUR_MAUVE, FR_NONE); + DrawFrameRect(20, 18, 20 + (int)((this->width - 40LL) * this->downloaded_bytes / this->total_bytes), 28, COLOUR_MAUVE, FR_NONE); SetDParam(0, this->downloaded_bytes); SetDParam(1, this->total_bytes); - SetDParam(2, this->downloaded_bytes * 100 / this->total_bytes); + SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes); DrawStringCentered(this->width / 2, 35, STR_CONTENT_DOWNLOAD_PROGRESS_SIZE, TC_GREY); if (this->downloaded_bytes == this->total_bytes) { diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp index 8d897d9bd8..c897b7dcaf 100644 --- a/src/network/network_gamelist.cpp +++ b/src/network/network_gamelist.cpp @@ -44,6 +44,7 @@ static void NetworkGameListHandleDelayedInsert() NetworkGameList *item = NetworkGameListAddItem(ins_item->ip, ins_item->port); if (item != NULL) { + ClearGRFConfigList(&item->info.grfconfig); if (StrEmpty(item->info.server_name)) { memset(&item->info, 0, sizeof(item->info)); strecpy(item->info.server_name, ins_item->info.server_name, lastof(item->info.server_name)); diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 43f3382eb9..42a54a15e2 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -259,7 +259,7 @@ StringIDToGRFIDMapping _string_to_grf_mapping; StringID MapGRFStringID(uint32 grfid, StringID str) { /* StringID table for TextIDs 0x4E->0x6D */ - static StringID units_volume[] = { + static const StringID units_volume[] = { STR_NOTHING, STR_PASSENGERS, STR_TONS, STR_BAGS, STR_LITERS, STR_ITEMS, STR_CRATES, STR_TONS, STR_TONS, STR_TONS, STR_TONS, STR_BAGS, diff --git a/src/road_gui.cpp b/src/road_gui.cpp index d3cfd92091..180ffb4e32 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -602,7 +602,7 @@ struct BuildRoadToolbarWindow : Window { _place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3)); DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), - (_ctrl_pressed || _remove_button_clicked) ? + _remove_button_clicked ? CMD_REMOVE_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) : CMD_BUILD_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound1D); break; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index e601e57e98..e6313a7b34 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -538,17 +538,6 @@ void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, } } -static inline void MergePoint(Rect *rect, TileIndex tile) -{ - int x = TileX(tile); - int y = TileY(tile); - - if (rect->left > x) rect->left = x; - if (rect->bottom > y) rect->bottom = y; - if (rect->right < x) rect->right = x; - if (rect->top < y) rect->top = y; -} - /** Update the acceptance for a station. * @param st Station to update * @param show_msg controls whether to display a message that acceptance was changed. @@ -558,56 +547,17 @@ static void UpdateStationAcceptance(Station *st, bool show_msg) /* Don't update acceptance for a buoy */ if (st->IsBuoy()) return; - Rect rect; - rect.left = MapSizeX(); - rect.bottom = MapSizeY(); - rect.right = 0; - rect.top = 0; - /* old accepted goods types */ uint old_acc = GetAcceptanceMask(st); - /* Put all the tiles that span an area in the table. */ - if (st->train_tile != INVALID_TILE) { - MergePoint(&rect, st->train_tile); - MergePoint(&rect, st->train_tile + TileDiffXY(st->trainst_w - 1, st->trainst_h - 1)); - } - - if (st->airport_tile != INVALID_TILE) { - const AirportFTAClass *afc = st->Airport(); - - MergePoint(&rect, st->airport_tile); - MergePoint(&rect, st->airport_tile + TileDiffXY(afc->size_x - 1, afc->size_y - 1)); - } - - if (st->dock_tile != INVALID_TILE) { - MergePoint(&rect, st->dock_tile); - if (IsDockTile(st->dock_tile)) { - MergePoint(&rect, st->dock_tile + TileOffsByDiagDir(GetDockDirection(st->dock_tile))); - } // else OilRig - } - - for (const RoadStop *rs = st->bus_stops; rs != NULL; rs = rs->next) { - MergePoint(&rect, rs->xy); - } - - for (const RoadStop *rs = st->truck_stops; rs != NULL; rs = rs->next) { - MergePoint(&rect, rs->xy); - } - /* And retrieve the acceptance. */ AcceptedCargo accepts; - assert((rect.right >= rect.left) == !st->rect.IsEmpty()); - if (rect.right >= rect.left) { - assert(rect.left == st->rect.left); - assert(rect.top == st->rect.bottom); - assert(rect.right == st->rect.right); - assert(rect.bottom == st->rect.top); + if (!st->rect.IsEmpty()) { GetAcceptanceAroundTiles( accepts, - TileXY(rect.left, rect.bottom), - rect.right - rect.left + 1, - rect.top - rect.bottom + 1, + TileXY(st->rect.left, st->rect.top), + st->rect.right - st->rect.left + 1, + st->rect.bottom - st->rect.top + 1, st->GetCatchmentRadius() ); } else { diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 9423ea6f9c..30ddd67f08 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2603,7 +2603,6 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold) Town *town = GetTown(tid); assert(town->IsValid()); - assert(town == CalcClosestTownFromTile(tile)); if (DistanceManhattan(tile, town->xy) >= threshold) town = NULL; diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 29dab40b40..e31b4a2214 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -4325,14 +4325,28 @@ static void TrainLocoHandler(Vehicle *v, bool mode) } else { TrainCheckIfLineEnds(v); /* Loop until the train has finished moving. */ - do { + for (;;) { j -= adv_spd; TrainController(v, NULL); /* Don't continue to move if the train crashed. */ if (CheckTrainCollision(v)) break; /* 192 spd used for going straight, 256 for going diagonally. */ adv_spd = (v->direction & 1) ? 192 : 256; - } while (j >= adv_spd); + + /* No more moving this tick */ + if (j < adv_spd || v->cur_speed == 0) break; + + OrderType order_type = v->current_order.GetType(); + /* Do not skip waypoints (incl. 'via' stations) when passing through at full speed. */ + if ((order_type == OT_GOTO_WAYPOINT && + v->dest_tile == v->tile) || + (order_type == OT_GOTO_STATION && + (v->current_order.GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) && + IsTileType(v->tile, MP_STATION) && + v->current_order.GetDestination() == GetStationIndex(v->tile))) { + ProcessOrders(v); + } + } SetLastSpeed(v, v->cur_speed); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 98cb45734f..877be02990 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1514,6 +1514,7 @@ void Vehicle::BeginLoading() InvalidateWindow(WC_STATION_VIEW, this->last_station_visited); GetStation(this->last_station_visited)->MarkTilesDirty(true); + this->cur_speed = 0; this->MarkDirty(); }