Merge branch 'master' into jgrpp

# Conflicts:
#	regression/regression/result.txt
#	src/autoreplace_cmd.cpp
#	src/industry_gui.cpp
#	src/landscape.cpp
#	src/network/network_content.cpp
#	src/newgrf_roadstop.cpp
#	src/pathfinder/yapf/yapf_ship.cpp
#	src/road_gui.cpp
#	src/saveload/ai_sl.cpp
#	src/saveload/saveload.h
#	src/saveload/vehicle_sl.cpp
#	src/station.cpp
#	src/station_gui.cpp
#	src/video/cocoa/cocoa_ogl.h
#	src/video/sdl2_opengl_v.h
#	src/video/video_driver.hpp
#	src/video/win32_v.h
#	src/widget_type.h
#	src/widgets/dropdown.cpp
#	src/widgets/dropdown_type.h
#	src/window.cpp
This commit is contained in:
Jonathan G Rennison
2024-02-19 18:50:33 +00:00
119 changed files with 4346 additions and 2129 deletions

View File

@@ -191,7 +191,7 @@ void HttpThread()
/* Setup our (C-style) callback function which we pipe back into the callback. */
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, +[](char *ptr, size_t size, size_t nmemb, void *userdata) -> size_t {
Debug(net, 4, "HTTP callback: {} bytes", size * nmemb);
Debug(net, 6, "HTTP callback: {} bytes", size * nmemb);
HTTPThreadSafeCallback *callback = static_cast<HTTPThreadSafeCallback *>(userdata);
/* Copy the buffer out of CURL. OnReceiveData() will free it when done. */

View File

@@ -165,7 +165,7 @@ void NetworkHTTPRequest::WinHttpCallback(DWORD code, void *info, DWORD length)
} break;
case WINHTTP_CALLBACK_STATUS_READ_COMPLETE:
Debug(net, 4, "HTTP callback: {} bytes", length);
Debug(net, 6, "HTTP callback: {} bytes", length);
this->callback.OnReceiveData(UniqueBuffer<char>(std::unique_ptr<char[]>(static_cast<char *>(info)), length));

View File

@@ -1054,6 +1054,9 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet
/* Say we received the map and loaded it correctly! */
SendMapOk();
/* As we skipped switch-mode, update the time we "switched". */
_switch_mode_time = std::chrono::steady_clock::now();
ShowClientList();
/* New company/spectator (invalid company) or company we want to join is not active

View File

@@ -331,7 +331,7 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uin
this->isCancelled = false;
if (_settings_client.network.no_http_content_downloads || fallback) {
if (fallback) {
this->DownloadSelectedContentFallback(content);
} else {
this->DownloadSelectedContentHTTP(content);
@@ -617,10 +617,6 @@ void ClientNetworkContentSocketHandler::OnReceiveData(UniqueBuffer<char> data)
return;
}
this->lastActivity = std::chrono::steady_clock::now();
this->lastActivity = std::chrono::steady_clock::now();
if (this->http_response_index == -1) {
if (data != nullptr) {
/* Append the rest of the response. */
@@ -807,7 +803,6 @@ void ClientNetworkContentSocketHandler::Connect()
*/
NetworkRecvStatus ClientNetworkContentSocketHandler::CloseConnection(bool)
{
this->isCancelled = true;
NetworkContentSocketHandler::CloseConnection();
if (this->sock == INVALID_SOCKET) return NETWORK_RECV_STATUS_OKAY;
@@ -818,6 +813,15 @@ NetworkRecvStatus ClientNetworkContentSocketHandler::CloseConnection(bool)
return NETWORK_RECV_STATUS_OKAY;
}
/**
* Cancel the current download.
*/
void ClientNetworkContentSocketHandler::Cancel(void)
{
this->isCancelled = true;
this->CloseConnection();
}
/**
* Check whether we received/can send some data from/to the content server and
* when that's the case handle it appropriately
@@ -826,6 +830,7 @@ void ClientNetworkContentSocketHandler::SendReceive()
{
if (this->sock == INVALID_SOCKET || this->isConnecting) return;
/* Close the connection to the content server after inactivity; there can still be downloads pending via HTTP. */
if (std::chrono::steady_clock::now() > this->lastActivity + IDLE_TIMEOUT) {
this->CloseConnection();
return;

View File

@@ -115,6 +115,7 @@ public:
void Connect();
void SendReceive();
NetworkRecvStatus CloseConnection(bool error = true) override;
void Cancel();
void RequestContentList(ContentType type);
void RequestContentList(uint count, const ContentID *content_ids);

View File

@@ -292,7 +292,7 @@ public:
{
if (widget == WID_NCDS_CANCELOK) {
if (this->downloaded_bytes != this->total_bytes) {
_network_content_client.CloseConnection();
_network_content_client.Cancel();
this->Close();
} else {
/* If downloading succeeded, close the online content window. This will close

View File

@@ -1518,7 +1518,7 @@ private:
wi_rect.bottom = pt.y;
w->dd_client_id = client_id;
ShowDropDownListAt(w, std::move(list), -1, WID_CL_MATRIX, wi_rect, COLOUR_GREY, true);
ShowDropDownListAt(w, std::move(list), -1, WID_CL_MATRIX, wi_rect, COLOUR_GREY, DDMF_INSTANT_CLOSE);
}
/**
@@ -1540,7 +1540,7 @@ private:
wi_rect.bottom = pt.y;
w->dd_company_id = company_id;
ShowDropDownListAt(w, std::move(list), -1, WID_CL_MATRIX, wi_rect, COLOUR_GREY, true);
ShowDropDownListAt(w, std::move(list), -1, WID_CL_MATRIX, wi_rect, COLOUR_GREY, DDMF_INSTANT_CLOSE);
}
/**
* Chat button on a Client is clicked.