1
0
Ver Fonte

Add constant for maximum slots inside a match

Lekuru há 4 meses atrás
pai
commit
c11fe5be60
1 ficheiros alterados com 11 adições e 8 exclusões
  1. 11 8
      src/App/Osu/BanchoProtocol.cpp

+ 11 - 8
src/App/Osu/BanchoProtocol.cpp

@@ -8,6 +8,9 @@
 // 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};
 
+// Amount of slots inside a multi lobby
+const int MAX_SLOTS = 16;
+
 Room::Room() {
     // 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();
 
     nb_players = 0;
-    for(int i = 0; i < 16; i++) {
+    for(int i = 0; i < MAX_SLOTS; i++) {
         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);
     }
-    for(int s = 0; s < 16; s++) {
+    for(int s = 0; s < MAX_SLOTS; s++) {
         if(!slots[s].is_locked()) {
             nb_open_slots++;
         }
@@ -56,7 +59,7 @@ Room::Room(Packet *packet) {
     team_type = read<u8>(packet);
     freemods = read<u8>(packet);
     if(freemods) {
-        for(int i = 0; i < 16; i++) {
+        for(int i = 0; i < MAX_SLOTS; i++) {
             slots[i].mods = read<u32>(packet);
         }
     }
@@ -74,13 +77,13 @@ void Room::pack(Packet *packet) {
     write_string(packet, map_name.toUtf8());
     write<u32>(packet, map_id);
     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);
     }
-    for(int i = 0; i < 16; i++) {
+    for(int i = 0; i < MAX_SLOTS; i++) {
         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()) {
             write<u32>(packet, slots[s].player_id);
         }
@@ -92,7 +95,7 @@ void Room::pack(Packet *packet) {
     write<u8>(packet, team_type);
     write<u8>(packet, freemods);
     if(freemods) {
-        for(int i = 0; i < 16; i++) {
+        for(int i = 0; i < MAX_SLOTS; i++) {
             write<u32>(packet, slots[i].mods);
         }
     }