add more info to 6xB4x46 version messages

This commit is contained in:
Martin Michelsen
2023-10-04 23:13:13 -07:00
parent 7e84a5cb6a
commit 15c08c0101
3 changed files with 20 additions and 31 deletions
+5 -1
View File
@@ -239,7 +239,11 @@ void Server::send_6xB4x46() const {
G_ServerVersionStrings_GC_Ep3_6xB4x46 cmd46;
cmd46.version_signature = VERSION_SIGNATURE;
cmd46.date_str1 = format_time(this->card_index->definitions_mtime() * 1000000);
cmd46.date_str2 = string_printf("Lobby/%08" PRIX32, l->lobby_id);
if (this->last_chosen_map) {
cmd46.date_str2 = string_printf("Lobby:%08" PRIX32 " Random:%08" PRIX32 "+%08" PRIX32 " Map:%08" PRIX32, l->lobby_id, this->random_crypt->seed(), this->random_crypt->absolute_offset(), this->last_chosen_map->map.map_number.load());
} else {
cmd46.date_str2 = string_printf("Lobby:%08" PRIX32 " Random:%08" PRIX32 "+%08" PRIX32, l->lobby_id, this->random_crypt->seed(), this->random_crypt->absolute_offset());
}
this->send(cmd46);
}
+7 -26
View File
@@ -23,31 +23,8 @@ PSOLFGEncryption::PSOLFGEncryption(
: stream(stream_length, 0),
offset(0),
end_offset(end_offset),
seed(seed) {}
PSOLFGEncryption::PSOLFGEncryption(const std::string& serialized) {
StringReader r(serialized);
this->offset = r.get_u32l();
this->end_offset = r.get_u32l();
this->seed = r.get_u32l();
size_t num_entries = r.get_u32l();
this->stream.reserve(num_entries);
while (this->stream.size() < num_entries) {
this->stream.emplace_back(r.get_u32l());
}
}
std::string PSOLFGEncryption::serialize() const {
StringWriter w;
w.put_u32l(this->offset);
w.put_u32l(this->end_offset);
w.put_u32l(this->seed);
w.put_u32l(this->stream.size());
for (uint32_t x : this->stream) {
w.put_u32l(x);
}
return std::move(w.str());
}
initial_seed(seed),
cycles(0) {}
uint32_t PSOLFGEncryption::next(bool advance) {
if (this->offset == this->end_offset) {
@@ -143,7 +120,7 @@ PSOV2Encryption::PSOV2Encryption(uint32_t seed)
: PSOLFGEncryption(seed, this->STREAM_LENGTH + 1, this->STREAM_LENGTH) {
uint32_t esi, ebx, edi, eax, edx, var1;
esi = 1;
ebx = this->seed;
ebx = this->initial_seed;
edi = 0x15;
this->stream[56] = ebx;
this->stream[55] = ebx;
@@ -160,6 +137,7 @@ PSOV2Encryption::PSOV2Encryption(uint32_t seed)
for (size_t x = 0; x < 5; x++) {
this->update_stream();
}
this->cycles = 0;
}
void PSOV2Encryption::update_stream() {
@@ -185,6 +163,7 @@ void PSOV2Encryption::update_stream() {
edx--;
}
this->offset = 1;
this->cycles++;
}
PSOEncryption::Type PSOV2Encryption::type() const {
@@ -222,6 +201,7 @@ PSOV3Encryption::PSOV3Encryption(uint32_t seed)
for (size_t x = 0; x < 4; x++) {
this->update_stream();
}
this->cycles = 0;
}
void PSOV3Encryption::update_stream() {
@@ -239,6 +219,7 @@ void PSOV3Encryption::update_stream() {
}
this->offset = 0;
this->cycles++;
}
PSOEncryption::Type PSOV3Encryption::type() const {
+8 -4
View File
@@ -39,8 +39,6 @@ protected:
class PSOLFGEncryption : public PSOEncryption {
public:
explicit PSOLFGEncryption(const std::string& serialized);
virtual void encrypt(void* data, size_t size, bool advance = true);
void encrypt_big_endian(void* data, size_t size, bool advance = true);
void encrypt_minus(void* data, size_t size, bool advance = true);
@@ -54,7 +52,12 @@ public:
uint32_t next(bool advance = true);
virtual std::string serialize() const;
inline uint32_t seed() const {
return this->initial_seed;
}
uint32_t absolute_offset() const {
return (this->cycles * this->end_offset) + this->offset;
}
protected:
PSOLFGEncryption(uint32_t seed, size_t stream_length, size_t end_offset);
@@ -64,7 +67,8 @@ protected:
std::vector<uint32_t> stream;
size_t offset;
size_t end_offset;
uint32_t seed;
uint32_t initial_seed;
size_t cycles;
};
class PSOV2Encryption : public PSOLFGEncryption {