|
@@ -8,6 +8,9 @@
|
|
// Null array for returning empty structures when trying to read more data out of a Packet than expected.
|
|
// Null array for returning empty structures when trying to read more data out of a Packet than expected.
|
|
u8 NULL_ARRAY[NULL_ARRAY_SIZE] = {0};
|
|
u8 NULL_ARRAY[NULL_ARRAY_SIZE] = {0};
|
|
|
|
|
|
|
|
+// Amount of slots inside a multi lobby
|
|
|
|
+const int MAX_SLOTS = 16;
|
|
|
|
+
|
|
Room::Room() {
|
|
Room::Room() {
|
|
// 0-initialized room means we're not in multiplayer at the moment
|
|
// 0-initialized room means we're not in multiplayer at the moment
|
|
}
|
|
}
|
|
@@ -33,13 +36,13 @@ Room::Room(Packet *packet) {
|
|
map_md5 = hash_str.toUtf8();
|
|
map_md5 = hash_str.toUtf8();
|
|
|
|
|
|
nb_players = 0;
|
|
nb_players = 0;
|
|
- for(int i = 0; i < 16; i++) {
|
|
|
|
|
|
+ for(int i = 0; i < MAX_SLOTS; i++) {
|
|
slots[i].status = read<u8>(packet);
|
|
slots[i].status = read<u8>(packet);
|
|
}
|
|
}
|
|
- for(int i = 0; i < 16; i++) {
|
|
|
|
|
|
+ for(int i = 0; i < MAX_SLOTS; i++) {
|
|
slots[i].team = read<u8>(packet);
|
|
slots[i].team = read<u8>(packet);
|
|
}
|
|
}
|
|
- for(int s = 0; s < 16; s++) {
|
|
|
|
|
|
+ for(int s = 0; s < MAX_SLOTS; s++) {
|
|
if(!slots[s].is_locked()) {
|
|
if(!slots[s].is_locked()) {
|
|
nb_open_slots++;
|
|
nb_open_slots++;
|
|
}
|
|
}
|
|
@@ -56,7 +59,7 @@ Room::Room(Packet *packet) {
|
|
team_type = read<u8>(packet);
|
|
team_type = read<u8>(packet);
|
|
freemods = read<u8>(packet);
|
|
freemods = read<u8>(packet);
|
|
if(freemods) {
|
|
if(freemods) {
|
|
- for(int i = 0; i < 16; i++) {
|
|
|
|
|
|
+ for(int i = 0; i < MAX_SLOTS; i++) {
|
|
slots[i].mods = read<u32>(packet);
|
|
slots[i].mods = read<u32>(packet);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -74,13 +77,13 @@ void Room::pack(Packet *packet) {
|
|
write_string(packet, map_name.toUtf8());
|
|
write_string(packet, map_name.toUtf8());
|
|
write<u32>(packet, map_id);
|
|
write<u32>(packet, map_id);
|
|
write_string(packet, map_md5.toUtf8());
|
|
write_string(packet, map_md5.toUtf8());
|
|
- for(int i = 0; i < 16; i++) {
|
|
|
|
|
|
+ for(int i = 0; i < MAX_SLOTS; i++) {
|
|
write<u8>(packet, slots[i].status);
|
|
write<u8>(packet, slots[i].status);
|
|
}
|
|
}
|
|
- for(int i = 0; i < 16; i++) {
|
|
|
|
|
|
+ for(int i = 0; i < MAX_SLOTS; i++) {
|
|
write<u8>(packet, slots[i].team);
|
|
write<u8>(packet, slots[i].team);
|
|
}
|
|
}
|
|
- for(int s = 0; s < 16; s++) {
|
|
|
|
|
|
+ for(int s = 0; s < MAX_SLOTS; s++) {
|
|
if(slots[s].has_player()) {
|
|
if(slots[s].has_player()) {
|
|
write<u32>(packet, slots[s].player_id);
|
|
write<u32>(packet, slots[s].player_id);
|
|
}
|
|
}
|
|
@@ -92,7 +95,7 @@ void Room::pack(Packet *packet) {
|
|
write<u8>(packet, team_type);
|
|
write<u8>(packet, team_type);
|
|
write<u8>(packet, freemods);
|
|
write<u8>(packet, freemods);
|
|
if(freemods) {
|
|
if(freemods) {
|
|
- for(int i = 0; i < 16; i++) {
|
|
|
|
|
|
+ for(int i = 0; i < MAX_SLOTS; i++) {
|
|
write<u32>(packet, slots[i].mods);
|
|
write<u32>(packet, slots[i].mods);
|
|
}
|
|
}
|
|
}
|
|
}
|