From 4b4e8f0a1ece65a0a2022fc7a79635391c18bfe2 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 29 May 2016 19:05:11 +0000 Subject: [PATCH] (svn r27591) [1.6] -Backport from trunk: - Change: Performance improvement for dedicated servers by skipping drawing calls earlier in the process [FS#6402] (r27579) - Fix: Vehicles could not be hidden from the purchase list when they were in exclusive preview [FS#6454] (r27578) - Fix: Dock and roadstop picker, client list and town authority window did not auto-resize according to their content when they were positioned at the bottom of the screen [FS#6386] (r27577) - Fix: Various incorrect but uncritical size computations in the content client [FS#6449] (r27576, r27570) --- src/dock_gui.cpp | 2 +- src/engine.cpp | 2 +- src/network/network_content.cpp | 13 ++++++------- src/network/network_gui.cpp | 2 +- src/road_gui.cpp | 2 +- src/town_gui.cpp | 2 +- src/vehicle_base.h | 4 ++++ src/window.cpp | 4 ++++ 8 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index f6699daeff..979f763619 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -433,7 +433,7 @@ public: * Never make the window smaller to avoid oscillating if the size change affects the acceptance. * (This is the case, if making the window bigger moves the mouse into the window.) */ if (top > bottom) { - ResizeWindow(this, 0, top - bottom); + ResizeWindow(this, 0, top - bottom, false); } } diff --git a/src/engine.cpp b/src/engine.cpp index f8fc0ee6aa..9f9abcde0e 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -879,7 +879,7 @@ CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 { Engine *e = Engine::GetIfValid(GB(p2, 0, 31)); if (e == NULL || _current_company >= MAX_COMPANIES) return CMD_ERROR; - if ((e->flags & ENGINE_AVAILABLE) == 0 || !HasBit(e->company_avail, _current_company)) return CMD_ERROR; + if (!IsEngineBuildable(e->index, e->type, _current_company)) return CMD_ERROR; if ((flags & DC_EXEC) != 0) { SB(e->company_hidden, _current_company, 1, GB(p2, 31, 1)); diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 174dbdafe6..e998aaeaf1 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -57,7 +57,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p) ci->filesize = p->Recv_uint32(); p->Recv_string(ci->name, lengthof(ci->name)); - p->Recv_string(ci->version, lengthof(ci->name)); + p->Recv_string(ci->version, lengthof(ci->version)); p->Recv_string(ci->url, lengthof(ci->url)); p->Recv_string(ci->description, lengthof(ci->description), SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE); @@ -220,10 +220,9 @@ void ClientNetworkContentSocketHandler::RequestContentList(uint count, const Con while (count > 0) { /* We can "only" send a limited number of IDs in a single packet. * A packet begins with the packet size and a byte for the type. - * Then this packet adds a byte for the content type and a uint16 - * for the count in this packet. The rest of the packet can be - * used for the IDs. */ - uint p_count = min(count, (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(byte) - sizeof(uint16)) / sizeof(uint32)); + * Then this packet adds a uint16 for the count in this packet. + * The rest of the packet can be used for the IDs. */ + uint p_count = min(count, (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16)) / sizeof(uint32)); Packet *p = new Packet(PACKET_CONTENT_CLIENT_INFO_ID); p->Send_uint16(p_count); @@ -249,9 +248,9 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo this->Connect(); - /* 20 is sizeof(uint32) + sizeof(md5sum (byte[16])) */ assert(cv->Length() < 255); - assert(cv->Length() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) / (send_md5sum ? 20 : sizeof(uint32))); + assert(cv->Length() < (SEND_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) / + (sizeof(uint8) + sizeof(uint32) + (send_md5sum ? /*sizeof(ContentInfo::md5sum)*/16 : 0))); Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID); p->Send_uint8(cv->Length()); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 795d28e139..7c04ad4e02 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1892,7 +1892,7 @@ struct NetworkClientListWindow : Window { int diff = (num + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM) - (this->GetWidget(WID_CL_PANEL)->current_y); /* If height is changed */ if (diff != 0) { - ResizeWindow(this, 0, diff); + ResizeWindow(this, 0, diff, false); return false; } return true; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 92c660e8a3..d3737c16dc 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1002,7 +1002,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { * Never make the window smaller to avoid oscillating if the size change affects the acceptance. * (This is the case, if making the window bigger moves the mouse into the window.) */ if (top > bottom) { - ResizeWindow(this, 0, top - bottom); + ResizeWindow(this, 0, top - bottom, false); } } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 222549ff73..142966b694 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -177,7 +177,7 @@ public: y = y + WD_FRAMERECT_BOTTOM - nwid->pos_y; // Compute needed size of the widget. if (y > nwid->current_y) { /* If the company list is too big to fit, mark ourself dirty and draw again. */ - ResizeWindow(this, 0, y - nwid->current_y); + ResizeWindow(this, 0, y - nwid->current_y, false); } } diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 59584da788..f923c2d791 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -23,6 +23,7 @@ #include "transport_type.h" #include "group_type.h" #include "base_consist.h" +#include "network/network.h" #include #include @@ -1072,6 +1073,9 @@ struct SpecializedVehicle : public Vehicle { */ inline void UpdateViewport(bool force_update, bool update_delta) { + /* Skip updating sprites on dedicated servers without screen */ + if (_network_dedicated) return; + /* Explicitly choose method to call to prevent vtable dereference - * it gives ~3% runtime improvements in games with many vehicles */ if (update_delta) ((T *)this)->T::UpdateDeltaXY(this->direction); diff --git a/src/window.cpp b/src/window.cpp index 1fce1f3a8d..bc92416b62 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -3031,6 +3031,10 @@ void UpdateWindows() w->ProcessHighlightedInvalidations(); } + /* Skip the actual drawing on dedicated servers without screen. + * But still empty the invalidation queues above. */ + if (_network_dedicated) return; + static int we4_timer = 0; int t = we4_timer + 1;