erratas dans la sérialisation

This commit is contained in:
MarcEricMartel
2023-10-24 09:17:21 -04:00
parent ffeb95d953
commit cf6e58cd95
3 changed files with 19 additions and 10 deletions

View File

@@ -37,7 +37,7 @@ void netprot::Serialize(Input* in, char* buf[], uint32_t* buflen) {
keys.shoot & 0b00000100 |
keys.block & 0b00000010 ;
memcpy(*buf + sizeof(uint64_t) + 2, &keys8, sizeof(uint8_t));
memcpy(*buf + sizeof(uint64_t) * 2 + 1, &keys8, sizeof(uint8_t));
uint32_t vec[3];
memcpy(vec, &in->direction, sizeof(Vector3f)); // Pour d<>naturer les floats.
@@ -56,13 +56,13 @@ void netprot::Serialize(Input* in, char* buf[], uint32_t* buflen) {
(vec[2] >> 8) & 0xFF,
vec[2] & 0xFF};
memcpy(*buf + sizeof(uint64_t) + 3, vec8, sizeof(uint32_t) * 3);
memcpy(*buf + sizeof(uint64_t) * 2 + 2, vec8, sizeof(uint32_t) * 3);
*buflen = sizeof(uint64_t) + 3 + sizeof(uint32_t) * 3;
*buflen = sizeof(uint64_t) * 2 + 2 + sizeof(uint32_t) * 3;
}
void netprot::Serialize(Output* out, char* buf[], uint32_t* buflen) {
}
void netprot::Serialize(Sync* sync, char* buf[], uint32_t* buflen) {
@@ -308,7 +308,7 @@ bool netprot::Deserialize(Input* in, char* buf, const uint32_t buflen) {
(uint64_t)diff[7];
uint8_t keys = 0;
memcpy(&keys, &buf[2 + sizeof(uint64_t)], sizeof(uint8_t));
memcpy(&keys, &buf[1 + sizeof(uint64_t) * 2], sizeof(uint8_t));
in->keys.forward = keys && 0b10000000;
in->keys.backward = keys && 0b01000000;
in->keys.left = keys && 0b00100000;
@@ -318,7 +318,7 @@ bool netprot::Deserialize(Input* in, char* buf, const uint32_t buflen) {
in->keys.block = keys && 0b00000010;
uint8_t subvec[3 * sizeof(uint32_t)] = { 0,0,0,0,0,0,0,0,0,0,0,0 };
memcpy(subvec, &buf[3 + sizeof(uint64_t)], sizeof(uint8_t) * 12);
memcpy(subvec, &buf[2 + sizeof(uint64_t) * 2], sizeof(uint8_t) * 12);
uint32_t vec[3] = {
(uint32_t)subvec[0] << 24 |
(uint32_t)subvec[1] << 16 |