🚫 👂 🐆

This commit is contained in:
MarcEricMartel
2023-12-09 12:02:04 -05:00
parent 63d70be488
commit 9aaad6426c
11 changed files with 130 additions and 74 deletions

View File

@@ -198,7 +198,7 @@ void netprot::Serialize(Sync* sync, char* buf[], uint32_t* buflen) {
(uint8_t)((vec[2] >> 8) & 0xFF),
(uint8_t)(vec[2] & 0xFF) };
memcpy(*buf + sizeof(uint64_t) * 2 + sizeof(uint32_t) + sizeof(uint16_t) + 2, vec8, sizeof(uint32_t) * 3);
memcpy(*buf + sizeof(uint64_t) * 2 + sizeof(uint32_t) + sizeof(uint16_t) + 1, vec8, sizeof(uint32_t) * 3);
uint32_t hp;
@@ -210,6 +210,8 @@ void netprot::Serialize(Sync* sync, char* buf[], uint32_t* buflen) {
(uint8_t)((hp >> 8) & 0xFF),
(uint8_t)(hp & 0xFF) };
memcpy(*buf + sizeof(uint64_t) * 2 + sizeof(uint32_t) * 4 + sizeof(uint16_t) + 1, hp8, sizeof(float));
*buflen = sizeof(uint64_t) * 2 + sizeof(uint32_t) * 4 + sizeof(uint16_t) + sizeof(float) + 1;
}
@@ -218,7 +220,8 @@ void netprot::Serialize(TeamInfo* tinfo, char* buf[], uint32_t* buflen) {
size_t namesize = std::strlen(tinfo->name) + 1;
memcpy(*buf + 1, &tinfo->name, namesize);
strcpy(*buf + 1, namesize, tinfo->name);
uint64_t tid = tinfo->id;
uint8_t tid8[sizeof(uint64_t)] = {
(uint8_t)((tid >> 56) & 0xFF),
@@ -241,7 +244,8 @@ void netprot::Serialize(LoginInfo* linfo, char* buf[], uint32_t* buflen) {
size_t namesize = std::strlen(linfo->name) + 1;
memcpy(*buf + 1, &linfo->name, namesize);
strcpy(*buf + 1, namesize, linfo->name);
uint64_t sid = linfo->sid;
uint8_t sid8[sizeof(uint64_t)] = {
(uint8_t)((sid >> 56) & 0xFF),
@@ -278,7 +282,8 @@ void netprot::Serialize(PlayerInfo* pinfo, char* buf[], uint32_t* buflen) {
size_t namesize = std::strlen(pinfo->name) + 1;
memcpy(*buf + 1, &pinfo->name, namesize);
strcpy(*buf + 1, namesize, pinfo->name);
uint64_t id = pinfo->id;
uint8_t id8[sizeof(uint64_t)] = {
(uint8_t)((id >> 56) & 0xFF),
@@ -703,7 +708,7 @@ bool netprot::Deserialize(Sync* sync, char* buf, uint32_t* buflen) {
uint8_t subvec[3 * sizeof(uint32_t)] = { 0,0,0,0,0,0,0,0,0,0,0,0 };
memcpy(subvec, &buf[2 + sizeof(uint64_t) * 2 + sizeof(uint32_t) + sizeof(uint16_t)], sizeof(uint8_t) * 12);
memcpy(subvec, &buf[1 + sizeof(uint64_t) * 2 + sizeof(uint32_t) + sizeof(uint16_t)], sizeof(uint8_t) * 12);
uint32_t vec[3] = {
(uint32_t)subvec[0] << 24 |
(uint32_t)subvec[1] << 16 |
@@ -722,7 +727,7 @@ bool netprot::Deserialize(Sync* sync, char* buf, uint32_t* buflen) {
uint8_t hp8[4];
memcpy(&hp8, &buf[2 + sizeof(uint64_t) * 2 + sizeof(uint32_t) * 4 + sizeof(uint16_t)], sizeof(uint32_t));
memcpy(&hp8, &buf[1 + sizeof(uint64_t) * 2 + sizeof(uint32_t) * 4 + sizeof(uint16_t)], sizeof(uint32_t));
uint32_t hp = (uint32_t)hp8[0] << 24 |
(uint32_t)hp8[1] << 16 |
@@ -731,7 +736,7 @@ bool netprot::Deserialize(Sync* sync, char* buf, uint32_t* buflen) {
memcpy(&sync->hp, &hp, sizeof(float));
*buflen = sizeof(uint64_t) * 2 + sizeof(uint32_t) * 4 + sizeof(uint16_t) + sizeof(float);
*buflen = 1 + sizeof(uint64_t) * 2 + sizeof(uint32_t) * 4 + sizeof(uint16_t) + sizeof(float);
return true;
}
@@ -745,7 +750,7 @@ bool netprot::Deserialize(TeamInfo* tinfo, char* buf, uint32_t* buflen) {
if (namesize > 32)
return false;
memcpy(&tinfo->name, &buf[1], namesize);
strcpy(tinfo->name, namesize, &buf[1]);
uint8_t diff[sizeof(uint64_t)] = { 0,0,0,0,0,0,0,0 };
memcpy(diff, &buf[namesize + 1], sizeof(uint64_t));
@@ -773,7 +778,7 @@ bool netprot::Deserialize(LoginInfo* linfo, char* buf, uint32_t* buflen) {
if (namesize > 32)
return false;
memcpy(&linfo->name, &buf[1], namesize);
strcpy(linfo->name, namesize, &buf[1]);
uint8_t diff[sizeof(uint64_t)] = { 0,0,0,0,0,0,0,0 };
memcpy(diff, &buf[namesize + 1], sizeof(uint64_t));
@@ -812,7 +817,7 @@ bool netprot::Deserialize(PlayerInfo* pinfo, char* buf, uint32_t* buflen) {
if (namesize > 32)
return false;
memcpy(&pinfo->name, &buf[1], namesize);
strcpy(pinfo->name, namesize, &buf[1]);
uint8_t diff[sizeof(uint64_t)] = { 0,0,0,0,0,0,0,0 };
memcpy(diff, &buf[namesize + 1], sizeof(uint64_t));