1
0

2 Revīzijas c6f03c64a0 ... c11fe5be60

Autors SHA1 Ziņojums Datums
  Lekuru c11fe5be60 Add constant for maximum slots inside a match 4 mēneši atpakaļ
  Lekuru 5024f350af Fix logout packet implementation 4 mēneši atpakaļ
2 mainītis faili ar 12 papildinājumiem un 8 dzēšanām
  1. 1 0
      src/App/Osu/BanchoNetworking.cpp
  2. 11 8
      src/App/Osu/BanchoProtocol.cpp

+ 1 - 0
src/App/Osu/BanchoNetworking.cpp

@@ -61,6 +61,7 @@ void disconnect() {
         Packet packet;
         write<u16>(&packet, LOGOUT);
         write<u8>(&packet, 0);
+        write<u32>(&packet, 4);
         write<u32>(&packet, 0);
 
         CURL *curl = curl_easy_init();

+ 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);
         }
     }