Merge branch 'master' into jgrpp
# Conflicts: # src/network/network_server.cpp
This commit is contained in:
18
.github/workflows/ci-build.yml
vendored
18
.github/workflows/ci-build.yml
vendored
@@ -30,15 +30,10 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- name: Clang - Debug
|
- name: Clang
|
||||||
compiler: clang-15
|
compiler: clang-15
|
||||||
cxxcompiler: clang++-15
|
cxxcompiler: clang++-15
|
||||||
libraries: libsdl2-dev
|
libraries: libsdl2-dev
|
||||||
- name: Clang - Release
|
|
||||||
compiler: clang-15
|
|
||||||
cxxcompiler: clang++-15
|
|
||||||
libraries: libsdl2-dev
|
|
||||||
extra-cmake-parameters: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_USE_ASSERTS=OFF
|
|
||||||
- name: GCC - SDL2
|
- name: GCC - SDL2
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
cxxcompiler: g++
|
cxxcompiler: g++
|
||||||
@@ -66,10 +61,16 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- arch: arm64
|
- name: arm64 - Debug
|
||||||
|
arch: arm64
|
||||||
full_arch: arm64
|
full_arch: arm64
|
||||||
|
extra-cmake-parameters: -DCMAKE_BUILD_TYPE=Debug
|
||||||
|
- name: arm64 - Release
|
||||||
|
arch: arm64
|
||||||
|
full_arch: arm64
|
||||||
|
extra-cmake-parameters: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_USE_ASSERTS=OFF
|
||||||
|
|
||||||
name: Mac OS (${{ matrix.arch }})
|
name: Mac OS (${{ matrix.name }})
|
||||||
|
|
||||||
uses: ./.github/workflows/ci-macos.yml
|
uses: ./.github/workflows/ci-macos.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
@@ -77,6 +78,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
arch: ${{ matrix.arch }}
|
arch: ${{ matrix.arch }}
|
||||||
full_arch: ${{ matrix.full_arch }}
|
full_arch: ${{ matrix.full_arch }}
|
||||||
|
extra-cmake-parameters: ${{ matrix.extra-cmake-parameters }}
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
strategy:
|
strategy:
|
||||||
|
5
.github/workflows/ci-macos.yml
vendored
5
.github/workflows/ci-macos.yml
vendored
@@ -9,6 +9,10 @@ on:
|
|||||||
full_arch:
|
full_arch:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
extra-cmake-parameters:
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CTEST_OUTPUT_ON_FAILURE: 1
|
CTEST_OUTPUT_ON_FAILURE: 1
|
||||||
@@ -78,6 +82,7 @@ jobs:
|
|||||||
-DCMAKE_OSX_ARCHITECTURES=${{ inputs.full_arch }} \
|
-DCMAKE_OSX_ARCHITECTURES=${{ inputs.full_arch }} \
|
||||||
-DVCPKG_TARGET_TRIPLET=${{ inputs.arch }}-osx \
|
-DVCPKG_TARGET_TRIPLET=${{ inputs.arch }}-osx \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${{ runner.temp }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${{ runner.temp }}/vcpkg/scripts/buildsystems/vcpkg.cmake \
|
||||||
|
${{ inputs.extra-cmake-parameters }} \
|
||||||
# EOF
|
# EOF
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
1
.github/workflows/preview.yml
vendored
1
.github/workflows/preview.yml
vendored
@@ -7,6 +7,7 @@ on:
|
|||||||
- synchronize
|
- synchronize
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- release/**
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||||
|
@@ -56,11 +56,14 @@ foreach(ENUM IN LISTS ENUM_LINES)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check for enum match
|
# Check for enum match
|
||||||
if("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN} *\{")
|
if("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN}( *: *[^ ]*)? *\{")
|
||||||
# REGEX REPLACE does a REGEX MATCHALL and fails if an empty string is matched
|
# REGEX REPLACE does a REGEX MATCHALL and fails if an empty string is matched
|
||||||
string(REGEX MATCH "[^ ]*" RESULT "${LINE}")
|
string(REGEX MATCH "[^ ]*" RESULT "${LINE}")
|
||||||
string(REPLACE "${RESULT}" "" RM_INDENT "${LINE}")
|
string(REPLACE "${RESULT}" "" RM_INDENT "${LINE}")
|
||||||
|
|
||||||
|
string(REGEX MATCH " *: *[^ ]*" RESULT "${LINE}")
|
||||||
|
string(REPLACE "${RESULT}" "" LINE "${LINE}")
|
||||||
|
|
||||||
set(ACTIVE 1)
|
set(ACTIVE 1)
|
||||||
if(ACTIVE_COMMENT GREATER 0)
|
if(ACTIVE_COMMENT GREATER 0)
|
||||||
string(APPEND ${PLACE_HOLDER} "\n${COMMENT}")
|
string(APPEND ${PLACE_HOLDER} "\n${COMMENT}")
|
||||||
|
@@ -118,21 +118,20 @@ struct PacketWriter : SaveFilter {
|
|||||||
/**
|
/**
|
||||||
* Transfer all packets from here to the network's queue while holding
|
* Transfer all packets from here to the network's queue while holding
|
||||||
* the lock on our mutex.
|
* the lock on our mutex.
|
||||||
* @param socket The network socket to write to.
|
|
||||||
* @return True iff the last packet of the map has been sent.
|
* @return True iff the last packet of the map has been sent.
|
||||||
*/
|
*/
|
||||||
bool TransferToNetworkQueue(ServerNetworkGameSocketHandler *socket)
|
bool TransferToNetworkQueue()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(this->mutex);
|
std::lock_guard<std::mutex> lock(this->mutex);
|
||||||
|
|
||||||
if (this->map_size_packet) {
|
if (this->map_size_packet) {
|
||||||
/* Don't queue the PACKET_SERVER_MAP_SIZE before the corresponding PACKET_SERVER_MAP_BEGIN */
|
/* Don't queue the PACKET_SERVER_MAP_SIZE before the corresponding PACKET_SERVER_MAP_BEGIN */
|
||||||
socket->SendPrependPacket(std::move(this->map_size_packet), PACKET_SERVER_MAP_BEGIN);
|
this->cs->SendPrependPacket(std::move(this->map_size_packet), PACKET_SERVER_MAP_BEGIN);
|
||||||
}
|
}
|
||||||
bool last_packet = false;
|
bool last_packet = false;
|
||||||
for (auto &p : this->packets) {
|
for (auto &p : this->packets) {
|
||||||
if (p->GetPacketType() == PACKET_SERVER_MAP_DONE) last_packet = true;
|
if (p->GetPacketType() == PACKET_SERVER_MAP_DONE) last_packet = true;
|
||||||
socket->SendPacket(std::move(p));
|
this->cs->SendPacket(std::move(p));
|
||||||
|
|
||||||
}
|
}
|
||||||
this->packets.clear();
|
this->packets.clear();
|
||||||
@@ -142,13 +141,13 @@ struct PacketWriter : SaveFilter {
|
|||||||
|
|
||||||
void Write(byte *buf, size_t size) override
|
void Write(byte *buf, size_t size) override
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(this->mutex);
|
||||||
|
|
||||||
/* We want to abort the saving when the socket is closed. */
|
/* We want to abort the saving when the socket is closed. */
|
||||||
if (this->cs == nullptr) SlError(STR_NETWORK_ERROR_LOSTCONNECTION);
|
if (this->cs == nullptr) SlError(STR_NETWORK_ERROR_LOSTCONNECTION);
|
||||||
|
|
||||||
if (this->current == nullptr) this->current = std::make_unique<Packet>(PACKET_SERVER_MAP_DATA, TCP_MTU);
|
if (this->current == nullptr) this->current = std::make_unique<Packet>(PACKET_SERVER_MAP_DATA, TCP_MTU);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(this->mutex);
|
|
||||||
|
|
||||||
byte *bufe = buf + size;
|
byte *bufe = buf + size;
|
||||||
while (buf != bufe) {
|
while (buf != bufe) {
|
||||||
size_t written = this->current->Send_binary_until_full(buf, bufe);
|
size_t written = this->current->Send_binary_until_full(buf, bufe);
|
||||||
@@ -165,11 +164,11 @@ struct PacketWriter : SaveFilter {
|
|||||||
|
|
||||||
void Finish() override
|
void Finish() override
|
||||||
{
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(this->mutex);
|
||||||
|
|
||||||
/* We want to abort the saving when the socket is closed. */
|
/* We want to abort the saving when the socket is closed. */
|
||||||
if (this->cs == nullptr) SlError(STR_NETWORK_ERROR_LOSTCONNECTION);
|
if (this->cs == nullptr) SlError(STR_NETWORK_ERROR_LOSTCONNECTION);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(this->mutex);
|
|
||||||
|
|
||||||
/* Make sure the last packet is flushed. */
|
/* Make sure the last packet is flushed. */
|
||||||
if (this->current != nullptr) this->packets.push_back(std::move(this->current));
|
if (this->current != nullptr) this->packets.push_back(std::move(this->current));
|
||||||
|
|
||||||
@@ -489,6 +488,17 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendDesyncLog(const std::strin
|
|||||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck()
|
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck()
|
||||||
{
|
{
|
||||||
auto p = std::make_unique<Packet>(PACKET_SERVER_CHECK_NEWGRFS, TCP_MTU);
|
auto p = std::make_unique<Packet>(PACKET_SERVER_CHECK_NEWGRFS, TCP_MTU);
|
||||||
|
|
||||||
|
/* Invalid packet when status is anything but STATUS_INACTIVE. */
|
||||||
|
if (this->status != STATUS_INACTIVE) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET);
|
||||||
|
|
||||||
|
this->status = STATUS_NEWGRFS_CHECK;
|
||||||
|
|
||||||
|
if (_grfconfig == nullptr) {
|
||||||
|
/* There are no NewGRFs, continue with the game password. */
|
||||||
|
return this->SendNeedGamePassword();
|
||||||
|
}
|
||||||
|
|
||||||
const GRFConfig *c;
|
const GRFConfig *c;
|
||||||
uint grf_count = 0;
|
uint grf_count = 0;
|
||||||
|
|
||||||
@@ -508,15 +518,16 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck()
|
|||||||
/** Request the game password. */
|
/** Request the game password. */
|
||||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedGamePassword()
|
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedGamePassword()
|
||||||
{
|
{
|
||||||
|
/* Invalid packet when status is anything but STATUS_NEWGRFS_CHECK. */
|
||||||
|
if (this->status != STATUS_NEWGRFS_CHECK) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET);
|
||||||
|
|
||||||
|
this->status = STATUS_AUTH_GAME;
|
||||||
|
|
||||||
if (_settings_client.network.server_password.empty()) {
|
if (_settings_client.network.server_password.empty()) {
|
||||||
/* Do not actually need a game password, continue with the company password. */
|
/* Do not actually need a game password, continue with the company password. */
|
||||||
return this->SendNeedCompanyPassword();
|
return this->SendNeedCompanyPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invalid packet when status is STATUS_AUTH_GAME or higher */
|
|
||||||
if (this->status >= STATUS_AUTH_GAME) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET);
|
|
||||||
|
|
||||||
this->status = STATUS_AUTH_GAME;
|
|
||||||
/* Reset 'lag' counters */
|
/* Reset 'lag' counters */
|
||||||
this->last_frame = this->last_frame_server = _frame_counter;
|
this->last_frame = this->last_frame_server = _frame_counter;
|
||||||
|
|
||||||
@@ -533,15 +544,16 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedGamePassword()
|
|||||||
/** Request the company password. */
|
/** Request the company password. */
|
||||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedCompanyPassword()
|
NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedCompanyPassword()
|
||||||
{
|
{
|
||||||
|
/* Invalid packet when status is anything but STATUS_AUTH_GAME. */
|
||||||
|
if (this->status != STATUS_AUTH_GAME) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET);
|
||||||
|
|
||||||
|
this->status = STATUS_AUTH_COMPANY;
|
||||||
|
|
||||||
NetworkClientInfo *ci = this->GetInfo();
|
NetworkClientInfo *ci = this->GetInfo();
|
||||||
if (!Company::IsValidID(ci->client_playas) || _network_company_states[ci->client_playas].password.empty()) {
|
if (!Company::IsValidID(ci->client_playas) || _network_company_states[ci->client_playas].password.empty()) {
|
||||||
return this->SendWelcome();
|
return this->SendWelcome();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Invalid packet when status is STATUS_AUTH_COMPANY or higher */
|
|
||||||
if (this->status >= STATUS_AUTH_COMPANY) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET);
|
|
||||||
|
|
||||||
this->status = STATUS_AUTH_COMPANY;
|
|
||||||
/* Reset 'lag' counters */
|
/* Reset 'lag' counters */
|
||||||
this->last_frame = this->last_frame_server = _frame_counter;
|
this->last_frame = this->last_frame_server = _frame_counter;
|
||||||
|
|
||||||
@@ -555,10 +567,11 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNeedCompanyPassword()
|
|||||||
/** Send the client a welcome message with some basic information. */
|
/** Send the client a welcome message with some basic information. */
|
||||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome()
|
NetworkRecvStatus ServerNetworkGameSocketHandler::SendWelcome()
|
||||||
{
|
{
|
||||||
/* Invalid packet when status is AUTH or higher */
|
/* Invalid packet when status is anything but STATUS_AUTH_COMPANY. */
|
||||||
if (this->status >= STATUS_AUTHORIZED) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET);
|
if (this->status != STATUS_AUTH_COMPANY) return this->CloseConnection(NETWORK_RECV_STATUS_MALFORMED_PACKET);
|
||||||
|
|
||||||
this->status = STATUS_AUTHORIZED;
|
this->status = STATUS_AUTHORIZED;
|
||||||
|
|
||||||
/* Reset 'lag' counters */
|
/* Reset 'lag' counters */
|
||||||
this->last_frame = this->last_frame_server = _frame_counter;
|
this->last_frame = this->last_frame_server = _frame_counter;
|
||||||
|
|
||||||
@@ -659,7 +672,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendMap()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->status == STATUS_MAP) {
|
if (this->status == STATUS_MAP) {
|
||||||
bool last_packet = this->savegame->TransferToNetworkQueue(this);
|
bool last_packet = this->savegame->TransferToNetworkQueue();
|
||||||
if (last_packet) {
|
if (last_packet) {
|
||||||
/* Done reading, make sure saving is done as well */
|
/* Done reading, make sure saving is done as well */
|
||||||
this->savegame->Destroy();
|
this->savegame->Destroy();
|
||||||
@@ -1015,13 +1028,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet &p)
|
|||||||
/* Make sure companies to which people try to join are not autocleaned */
|
/* Make sure companies to which people try to join are not autocleaned */
|
||||||
if (Company::IsValidID(playas)) _network_company_states[playas].months_empty = 0;
|
if (Company::IsValidID(playas)) _network_company_states[playas].months_empty = 0;
|
||||||
|
|
||||||
this->status = STATUS_NEWGRFS_CHECK;
|
|
||||||
|
|
||||||
if (_grfconfig == nullptr) {
|
|
||||||
/* Continue asking for the game password. */
|
|
||||||
return this->SendNeedGamePassword();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this->SendNewGRFCheck();
|
return this->SendNewGRFCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -180,7 +180,7 @@ public:
|
|||||||
TrackdirBits dirs = follower.m_new_td_bits;
|
TrackdirBits dirs = follower.m_new_td_bits;
|
||||||
const TrackdirBits dirs_without_90_degree = dirs & ~TrackdirCrossesTrackdirs(dir);
|
const TrackdirBits dirs_without_90_degree = dirs & ~TrackdirCrossesTrackdirs(dir);
|
||||||
if (dirs_without_90_degree != TRACKDIR_BIT_NONE) dirs = dirs_without_90_degree;
|
if (dirs_without_90_degree != TRACKDIR_BIT_NONE) dirs = dirs_without_90_degree;
|
||||||
const int strip_amount = _random.Next(CountBits(dirs));
|
const int strip_amount = RandomRange(CountBits(dirs));
|
||||||
for (int s = 0; s < strip_amount; ++s) RemoveFirstTrackdir(&dirs);
|
for (int s = 0; s < strip_amount; ++s) RemoveFirstTrackdir(&dirs);
|
||||||
return { follower.m_new_tile, FindFirstTrackdir(dirs) };
|
return { follower.m_new_tile, FindFirstTrackdir(dirs) };
|
||||||
}
|
}
|
||||||
|
@@ -303,8 +303,8 @@ protected:
|
|||||||
this->stations_per_cargo_type_no_rating = 0;
|
this->stations_per_cargo_type_no_rating = 0;
|
||||||
|
|
||||||
for (const Station *st : Station::Iterate()) {
|
for (const Station *st : Station::Iterate()) {
|
||||||
if (st->owner == owner || (st->owner == OWNER_NONE && HasStationInUse(st->index, true, owner))) {
|
if ((this->filter.facilities & st->facilities) != 0) { // only stations with selected facilities
|
||||||
if (this->filter.facilities & st->facilities) { // only stations with selected facilities
|
if (st->owner == owner || (st->owner == OWNER_NONE && HasStationInUse(st->index, true, owner))) {
|
||||||
bool has_rating = false;
|
bool has_rating = false;
|
||||||
/* Add to the station/cargo counts. */
|
/* Add to the station/cargo counts. */
|
||||||
for (CargoID j = 0; j < NUM_CARGO; j++) {
|
for (CargoID j = 0; j < NUM_CARGO; j++) {
|
||||||
|
@@ -526,9 +526,9 @@ cat = SC_BASIC
|
|||||||
var = gui.liveries
|
var = gui.liveries
|
||||||
type = SLE_UINT8
|
type = SLE_UINT8
|
||||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN
|
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN
|
||||||
def = 2
|
def = LIT_ALL
|
||||||
min = 0
|
min = LIT_NONE
|
||||||
max = 2
|
max = LIT_ALL
|
||||||
str = STR_CONFIG_SETTING_LIVERIES
|
str = STR_CONFIG_SETTING_LIVERIES
|
||||||
strhelp = STR_CONFIG_SETTING_LIVERIES_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_LIVERIES_HELPTEXT
|
||||||
strval = STR_CONFIG_SETTING_LIVERIES_NONE
|
strval = STR_CONFIG_SETTING_LIVERIES_NONE
|
||||||
|
Reference in New Issue
Block a user