💩
This commit is contained in:
		| @@ -29,13 +29,13 @@ void netprot::Serialize(Input* in, char* buf[], uint32_t* buflen) { | ||||
|  | ||||
| 	Keys keys = in->keys; | ||||
| 	uint8_t keys8 = // Reste un bit. | ||||
| 		keys.forward & 0b10000000 | | ||||
| 		keys.backward & 0b01000000 | | ||||
| 		keys.left & 0b00100000 | | ||||
| 		keys.right & 0b00010000 | | ||||
| 		keys.jump & 0b00001000 | | ||||
| 		keys.shoot & 0b00000100 | | ||||
| 		keys.block & 0b00000010; | ||||
| 		(keys.forward? 0b10000000: 0) | | ||||
| 		(keys.backward? 0b01000000: 0) | | ||||
| 		(keys.left? 0b00100000: 0) | | ||||
| 		(keys.right? 0b00010000: 0) | | ||||
| 		(keys.jump? 0b00001000: 0) | | ||||
| 		(keys.shoot? 0b00000100: 0) | | ||||
| 		(keys.block? 0b00000010: 0); | ||||
|  | ||||
| 	memcpy(*buf + sizeof(uint64_t) * 2 + 1, &keys8, sizeof(uint8_t)); | ||||
|  | ||||
| @@ -431,6 +431,8 @@ bool netprot::Deserialize(Input* in, char* buf, uint32_t *buflen) { | ||||
| 		(uint64_t)diff[5] << 16 | | ||||
| 		(uint64_t)diff[6] << 8 | | ||||
| 		(uint64_t)diff[7]; | ||||
| 	 | ||||
| 	std::cout << in->timestamp << ": "; | ||||
|  | ||||
| 	memcpy(diff, &buf[1 + sizeof(uint64_t)], sizeof(uint64_t)); | ||||
| 	in->sid = | ||||
| @@ -443,6 +445,8 @@ bool netprot::Deserialize(Input* in, char* buf, uint32_t *buflen) { | ||||
| 		(uint64_t)diff[6] << 8 | | ||||
| 		(uint64_t)diff[7]; | ||||
|  | ||||
| 	std::cout << in->sid << ": "; | ||||
|  | ||||
| 	uint8_t keys = 0; | ||||
| 	memcpy(&keys, &buf[1 + sizeof(uint64_t) * 2], sizeof(uint8_t)); | ||||
| 	in->keys.forward = keys & 0b10000000; | ||||
| @@ -453,6 +457,16 @@ bool netprot::Deserialize(Input* in, char* buf, uint32_t *buflen) { | ||||
| 	in->keys.shoot = keys & 0b00000100; | ||||
| 	in->keys.block = keys & 0b00000010; | ||||
|  | ||||
| 	std::cout << (int)keys << ": " | ||||
| 		<< (in->keys.forward ? "F" : "_") | ||||
| 		<< (in->keys.backward ? "B" : "_") | ||||
| 		<< (in->keys.left ? "L" : "_") | ||||
| 		<< (in->keys.right ? "R" : "_") | ||||
| 		<< (in->keys.jump ? "J" : "_") | ||||
| 		<< (in->keys.shoot ? "S" : "_") | ||||
| 		<< (in->keys.block ? "B" : "_") | ||||
| 		<< ": "; | ||||
|  | ||||
| 	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(uint8_t) * 12); | ||||
| 	uint32_t vec[3] = { | ||||
| @@ -471,6 +485,8 @@ bool netprot::Deserialize(Input* in, char* buf, uint32_t *buflen) { | ||||
|  | ||||
| 	memcpy(&in->direction, vec, sizeof(uint32_t) * 3); | ||||
|  | ||||
| 	in->direction.Afficher(); | ||||
|  | ||||
| 	*buflen = sizeof(uint64_t) * 2 + 2 + sizeof(uint32_t) * 3; | ||||
|  | ||||
| 	return true; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user