Merge branch 'master' into jgrpp
# Conflicts: # CMakeLists.txt # src/3rdparty/md5/md5.h # src/3rdparty/squirrel/squirrel/squtils.h # src/animated_tile.cpp # src/console_func.h # src/core/CMakeLists.txt # src/core/container_func.hpp # src/core/smallstack_type.hpp # src/crashlog.cpp # src/crashlog.h # src/debug.h # src/economy.cpp # src/gamelog.cpp # src/industry_gui.cpp # src/lang/catalan.txt # src/misc_gui.cpp # src/network/network_content.h # src/newgrf.cpp # src/newgrf.h # src/newgrf_config.cpp # src/newgrf_config.h # src/newgrf_gui.cpp # src/os/unix/font_unix.cpp # src/os/windows/crashlog_win.cpp # src/rail_cmd.cpp # src/saveload/animated_tile_sl.cpp # src/script/api/script_tilelist.cpp # src/settings.cpp # src/settingsgen/settingsgen.cpp # src/sl/oldloader_sl.cpp # src/station.cpp # src/station_cmd.cpp # src/stdafx.h # src/strgen/strgen.cpp # src/strgen/strgen_base.cpp # src/table/settings/gui_settings.ini # src/train_gui.cpp # src/vehicle.cpp # src/vehicle_base.h # src/vehicle_cmd.cpp # src/vehicle_gui_base.h # src/viewport_sprite_sorter.h
This commit is contained in:
@@ -172,7 +172,7 @@ const NetworkServerGameInfo *GetCurrentNetworkServerGameInfo()
|
||||
static void HandleIncomingNetworkGameInfoGRFConfig(GRFConfig *config, std::string name)
|
||||
{
|
||||
/* Find the matching GRF file */
|
||||
const GRFConfig *f = FindGRFConfig(config->ident.grfid, FGCM_EXACT, config->ident.md5sum);
|
||||
const GRFConfig *f = FindGRFConfig(config->ident.grfid, FGCM_EXACT, &config->ident.md5sum);
|
||||
if (f == nullptr) {
|
||||
AddGRFTextToList(config->name, name.empty() ? GetString(STR_CONFIG_ERROR_INVALID_GRF_UNKNOWN) : name);
|
||||
config->status = GCS_NOT_FOUND;
|
||||
@@ -528,9 +528,8 @@ void DeserializeNetworkGameInfoExtended(Packet *p, NetworkGameInfo *info)
|
||||
*/
|
||||
void SerializeGRFIdentifier(Packet *p, const GRFIdentifier *grf)
|
||||
{
|
||||
uint j;
|
||||
p->Send_uint32(grf->grfid);
|
||||
for (j = 0; j < sizeof(grf->md5sum); j++) {
|
||||
for (size_t j = 0; j < grf->md5sum.size(); j++) {
|
||||
p->Send_uint8(grf->md5sum[j]);
|
||||
}
|
||||
}
|
||||
@@ -542,9 +541,8 @@ void SerializeGRFIdentifier(Packet *p, const GRFIdentifier *grf)
|
||||
*/
|
||||
void DeserializeGRFIdentifier(Packet *p, GRFIdentifier *grf)
|
||||
{
|
||||
uint j;
|
||||
grf->grfid = p->Recv_uint32();
|
||||
for (j = 0; j < sizeof(grf->md5sum); j++) {
|
||||
for (size_t j = 0; j < grf->md5sum.size(); j++) {
|
||||
grf->md5sum[j] = p->Recv_uint8();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ const char *ContentInfo::GetTextfile(TextfileType type) const
|
||||
tmp = Game::GetScannerLibrary()->FindMainScript(this, true);
|
||||
break;
|
||||
case CONTENT_TYPE_NEWGRF: {
|
||||
const GRFConfig *gc = FindGRFConfig(BSWAP32(this->unique_id), FGCM_EXACT, this->md5sum);
|
||||
const GRFConfig *gc = FindGRFConfig(BSWAP32(this->unique_id), FGCM_EXACT, &this->md5sum);
|
||||
tmp = gc != nullptr ? gc->filename.c_str() : nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#ifndef NETWORK_CORE_TCP_CONTENT_TYPE_H
|
||||
#define NETWORK_CORE_TCP_CONTENT_TYPE_H
|
||||
|
||||
#include "../../3rdparty/md5/md5.h"
|
||||
|
||||
/** The values in the enum are important; they are used as database 'keys' */
|
||||
enum ContentType {
|
||||
CONTENT_TYPE_BEGIN = 1, ///< Helper to mark the begin of the types
|
||||
@@ -67,7 +69,7 @@ struct ContentInfo {
|
||||
std::string url; ///< URL related to the content
|
||||
std::string description; ///< Description of the content
|
||||
uint32 unique_id = 0; ///< Unique ID; either GRF ID or shortname
|
||||
byte md5sum[16] = {0}; ///< The MD5 checksum
|
||||
MD5Hash md5sum; ///< The MD5 checksum
|
||||
std::vector<ContentID> dependencies; ///< The dependencies (unique server side ids)
|
||||
StringList tags; ///< Tags associated with the content
|
||||
State state = State::UNSELECTED; ///< Whether the content info is selected (for download)
|
||||
|
||||
@@ -211,18 +211,14 @@ std::string GenerateCompanyPasswordHash(const std::string &password, const std::
|
||||
}
|
||||
|
||||
Md5 checksum;
|
||||
uint8 digest[16];
|
||||
MD5Hash digest;
|
||||
|
||||
/* Generate the MD5 hash */
|
||||
std::string salted_password_string = salted_password.str();
|
||||
checksum.Append(salted_password_string.data(), salted_password_string.size());
|
||||
checksum.Finish(digest);
|
||||
|
||||
std::ostringstream hashed_password;
|
||||
hashed_password << std::hex << std::setfill('0');
|
||||
for (int di = 0; di < 16; di++) hashed_password << std::setw(2) << (int)digest[di]; // Cast needed, otherwise interpreted as character to add
|
||||
|
||||
return hashed_password.str();
|
||||
return BytesToHexString(digest.data(), digest.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -408,7 +408,7 @@ std::string _network_server_name;
|
||||
NetworkJoinInfo _network_join;
|
||||
|
||||
/** Make sure the server ID length is the same as a md5 hash. */
|
||||
static_assert(NETWORK_SERVER_ID_LENGTH == 16 * 2 + 1);
|
||||
static_assert(NETWORK_SERVER_ID_LENGTH == MD5_HASH_BYTES * 2 + 1);
|
||||
|
||||
NetworkRecvStatus ClientNetworkGameSocketHandler::SendKeyPasswordPacket(PacketType packet_type, NetworkSharedSecrets &ss, const std::string &password, const std::string *payload)
|
||||
{
|
||||
@@ -867,7 +867,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(P
|
||||
DeserializeGRFIdentifier(p, &c);
|
||||
|
||||
/* Check whether we know this GRF */
|
||||
const GRFConfig *f = FindGRFConfig(c.grfid, FGCM_EXACT, c.md5sum);
|
||||
const GRFConfig *f = FindGRFConfig(c.grfid, FGCM_EXACT, &c.md5sum);
|
||||
if (f == nullptr) {
|
||||
/* We do not know this GRF, bail out of initialization */
|
||||
char buf[sizeof(c.md5sum) * 2 + 1];
|
||||
|
||||
@@ -37,7 +37,7 @@ ClientNetworkContentSocketHandler _network_content_client;
|
||||
/** Wrapper function for the HasProc */
|
||||
static bool HasGRFConfig(const ContentInfo *ci, bool md5sum)
|
||||
{
|
||||
return FindGRFConfig(BSWAP32(ci->unique_id), md5sum ? FGCM_EXACT : FGCM_ANY, md5sum ? ci->md5sum : nullptr) != nullptr;
|
||||
return FindGRFConfig(BSWAP32(ci->unique_id), md5sum ? FGCM_EXACT : FGCM_ANY, md5sum ? &ci->md5sum : nullptr) != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
|
||||
ci->description = p->Recv_string(NETWORK_CONTENT_DESC_LENGTH, SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE);
|
||||
|
||||
ci->unique_id = p->Recv_uint32();
|
||||
for (uint j = 0; j < sizeof(ci->md5sum); j++) {
|
||||
for (size_t j = 0; j < ci->md5sum.size(); j++) {
|
||||
ci->md5sum[j] = p->Recv_uint8();
|
||||
}
|
||||
|
||||
@@ -144,8 +144,7 @@ bool ClientNetworkContentSocketHandler::Receive_SERVER_INFO(Packet *p)
|
||||
|
||||
/* Do we already have a stub for this? */
|
||||
for (ContentInfo *ici : this->infos) {
|
||||
if (ici->type == ci->type && ici->unique_id == ci->unique_id &&
|
||||
memcmp(ci->md5sum, ici->md5sum, sizeof(ci->md5sum)) == 0) {
|
||||
if (ici->type == ci->type && ici->unique_id == ci->unique_id && ci->md5sum == ici->md5sum) {
|
||||
/* Preserve the name if possible */
|
||||
if (ci->name.empty()) ci->name = ici->name;
|
||||
if (ici->IsSelected()) ci->state = ici->state;
|
||||
@@ -265,7 +264,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
this->Connect();
|
||||
|
||||
const uint max_per_packet = std::min<uint>(255, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) /
|
||||
(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? /*sizeof(ContentInfo::md5sum)*/16 : 0))) - 1;
|
||||
(sizeof(uint8) + sizeof(uint32) + (send_md5sum ? MD5_HASH_BYTES : 0))) - 1;
|
||||
|
||||
uint offset = 0;
|
||||
|
||||
@@ -280,7 +279,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
p->Send_uint32(ci->unique_id);
|
||||
if (!send_md5sum) continue;
|
||||
|
||||
for (uint j = 0; j < sizeof(ci->md5sum); j++) {
|
||||
for (uint j = 0; j < ci->md5sum.size(); j++) {
|
||||
p->Send_uint8(ci->md5sum[j]);
|
||||
}
|
||||
}
|
||||
@@ -294,7 +293,7 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo
|
||||
bool found = false;
|
||||
for (ContentInfo *ci2 : this->infos) {
|
||||
if (ci->type == ci2->type && ci->unique_id == ci2->unique_id &&
|
||||
(!send_md5sum || memcmp(ci->md5sum, ci2->md5sum, sizeof(ci->md5sum)) == 0)) {
|
||||
(!send_md5sum || ci->md5sum == ci2->md5sum)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "core/tcp_content.h"
|
||||
#include "core/http.h"
|
||||
#include "../core/container_func.hpp"
|
||||
#include "../3rdparty/cpp-btree/btree_map.h"
|
||||
|
||||
/** Vector with content info */
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "../sortlist_type.h"
|
||||
#include "../stringfilter_type.h"
|
||||
#include "../querystring_gui.h"
|
||||
#include "../core/container_func.hpp"
|
||||
#include "../core/geometry_func.hpp"
|
||||
#include "../textfile_gui.h"
|
||||
#include "../fios.h"
|
||||
|
||||
@@ -124,7 +124,7 @@ void NetworkAfterNewGRFScan()
|
||||
for (GRFConfig *c = item->info.grfconfig; c != nullptr; c = c->next) {
|
||||
assert(HasBit(c->flags, GCF_COPY));
|
||||
|
||||
const GRFConfig *f = FindGRFConfig(c->ident.grfid, FGCM_EXACT, c->ident.md5sum);
|
||||
const GRFConfig *f = FindGRFConfig(c->ident.grfid, FGCM_EXACT, &c->ident.md5sum);
|
||||
if (f == nullptr) {
|
||||
/* Don't know the GRF (anymore), so mark game incompatible. */
|
||||
c->status = GCS_NOT_FOUND;
|
||||
|
||||
@@ -237,7 +237,7 @@ static void SurveyGrfs(nlohmann::json &survey)
|
||||
auto grfid = fmt::format("{:08x}", BSWAP32(c->ident.grfid));
|
||||
auto &grf = survey[grfid];
|
||||
|
||||
grf["md5sum"] = BytesToHexString(c->ident.md5sum, 16);
|
||||
grf["md5sum"] = BytesToHexString(c->ident.md5sum.data(), c->ident.md5sum.size());
|
||||
grf["status"] = c->status;
|
||||
|
||||
if ((c->palette & GRFP_GRF_MASK) == GRFP_GRF_UNSET) grf["palette"] = "unset";
|
||||
|
||||
Reference in New Issue
Block a user