Clément Wolf преди 1 месец
родител
ревизия
e57dedcb2c
променени са 65 файла, в които са добавени 823 реда и са изтрити 850 реда
  1. 64 64
      src/App/Osu/Bancho.cpp
  2. 3 5
      src/App/Osu/Bancho.h
  3. 148 153
      src/App/Osu/BanchoAes.cpp
  4. 1 1
      src/App/Osu/BanchoAes.h
  5. 1 1
      src/App/Osu/BanchoLeaderboard.cpp
  6. 2 2
      src/App/Osu/BanchoLeaderboard.h
  7. 19 19
      src/App/Osu/BanchoNetworking.cpp
  8. 4 4
      src/App/Osu/BanchoNetworking.h
  9. 81 81
      src/App/Osu/BanchoProtocol.cpp
  10. 51 53
      src/App/Osu/BanchoProtocol.h
  11. 7 7
      src/App/Osu/BanchoSubmitter.cpp
  12. 3 3
      src/App/Osu/BanchoUsers.cpp
  13. 14 14
      src/App/Osu/BanchoUsers.h
  14. 2 2
      src/App/Osu/Beatmap.h
  15. 1 1
      src/App/Osu/Chat.cpp
  16. 1 1
      src/App/Osu/Chat.h
  17. 15 15
      src/App/Osu/Collections.cpp
  18. 168 168
      src/App/Osu/Database.cpp
  19. 1 1
      src/App/Osu/Database.h
  20. 6 6
      src/App/Osu/DatabaseBeatmap.cpp
  21. 6 6
      src/App/Osu/Downloader.cpp
  22. 2 2
      src/App/Osu/Downloader.h
  23. 8 8
      src/App/Osu/HUD.cpp
  24. 2 2
      src/App/Osu/HUD.h
  25. 3 3
      src/App/Osu/Lobby.cpp
  26. 4 4
      src/App/Osu/Lobby.h
  27. 1 1
      src/App/Osu/MainMenu.cpp
  28. 4 4
      src/App/Osu/ModSelector.cpp
  29. 2 2
      src/App/Osu/ModSelector.h
  30. 25 25
      src/App/Osu/Replay.cpp
  31. 9 9
      src/App/Osu/Replay.h
  32. 10 10
      src/App/Osu/RichPresence.cpp
  33. 44 44
      src/App/Osu/RoomScreen.cpp
  34. 5 5
      src/App/Osu/RoomScreen.h
  35. 3 3
      src/App/Osu/SongBrowser.cpp
  36. 1 1
      src/App/Osu/SongBrowser.h
  37. 4 4
      src/App/Osu/UIAvatar.cpp
  38. 2 2
      src/App/Osu/UIAvatar.h
  39. 1 1
      src/App/Osu/UIModSelectorModButton.cpp
  40. 7 7
      src/App/Osu/UISongBrowserScoreButton.cpp
  41. 2 2
      src/App/Osu/UISongBrowserScoreButton.h
  42. 3 3
      src/App/Osu/UISongBrowserUserButton.cpp
  43. 6 6
      src/App/Osu/UIUserContextMenu.cpp
  44. 4 4
      src/App/Osu/UIUserContextMenu.h
  45. 1 1
      src/App/Osu/UpdateHandler.cpp
  46. 7 7
      src/App/Osu/score.h
  47. 3 3
      src/Engine/DiscordInterface.cpp
  48. 7 8
      src/Engine/File.h
  49. 4 12
      src/Engine/Graphics.h
  50. 1 1
      src/Engine/Image.cpp
  51. 2 2
      src/Engine/Main/main_SDL.cpp
  52. 2 2
      src/Engine/Main/main_Windows.cpp
  53. 4 4
      src/Engine/Platform/File.cpp
  54. 1 1
      src/Engine/Platform/LinuxTimer.cpp
  55. 2 2
      src/Engine/Platform/LinuxTimer.h
  56. 3 3
      src/Engine/Platform/MacOSTimer.cpp
  57. 4 4
      src/Engine/Platform/MacOSTimer.h
  58. 1 1
      src/Engine/Platform/WinTimer.cpp
  59. 2 2
      src/Engine/Platform/WinTimer.h
  60. 3 3
      src/Engine/Timer.h
  61. 5 5
      src/Engine/VulkanInterface.cpp
  62. 2 2
      src/Engine/VulkanInterface.h
  63. 2 2
      src/GUI/Windows/VisualProfiler.h
  64. 3 26
      src/Util/cbase.h
  65. 14 0
      src/Util/types.h

+ 64 - 64
src/App/Osu/Bancho.cpp

@@ -46,7 +46,7 @@ bool Bancho::submit_scores() {
     }
 }
 
-void update_channel(UString name, UString topic, int32_t nb_members) {
+void update_channel(UString name, UString topic, i32 nb_members) {
     Channel *chan;
     auto name_str = std::string(name.toUtf8());
     auto it = chat_channels.find(name_str);
@@ -72,12 +72,12 @@ void update_channel(UString name, UString topic, int32_t nb_members) {
     chan->nb_members = nb_members;
 }
 
-MD5Hash md5(uint8_t *msg, size_t msg_len) {
+MD5Hash md5(u8 *msg, size_t msg_len) {
     MD5 hasher;
     hasher.update(msg, msg_len);
     hasher.finalize();
 
-    uint8_t *digest = hasher.getDigest();
+    u8 *digest = hasher.getDigest();
     MD5Hash out;
     for(int i = 0; i < 16; i++) {
         out.hash[i * 2] = "0123456789abcdef"[digest[i] >> 4];
@@ -187,7 +187,7 @@ UString get_disk_uuid() {
 
 void handle_packet(Packet *packet) {
     if(packet->id == USER_ID) {
-        bancho.user_id = read_int32(packet);
+        bancho.user_id = read_u32(packet);
         if(bancho.user_id > 0) {
             debugLog("Logged in as user #%d.\n", bancho.user_id);
             bancho.osu->m_optionsMenu->logInButton->setText("Disconnect");
@@ -259,7 +259,7 @@ void handle_packet(Packet *packet) {
         UString sender = read_string(packet);
         UString text = read_string(packet);
         UString recipient = read_string(packet);
-        int32_t sender_id = read_int32(packet);
+        i32 sender_id = read_u32(packet);
 
         bancho.osu->m_chat->addMessage(recipient, ChatMessage{
                                                       .tms = time(NULL),
@@ -270,44 +270,44 @@ void handle_packet(Packet *packet) {
     } else if(packet->id == PONG) {
         // (nothing to do)
     } else if(packet->id == USER_STATS) {
-        int32_t stats_user_id = read_int32(packet);
-        uint8_t action = read_byte(packet);
+        i32 stats_user_id = read_u32(packet);
+        u8 action = read_u8(packet);
 
         UserInfo *user = get_user_info(stats_user_id);
         user->action = (Action)action;
         user->info_text = read_string(packet);
         user->map_md5 = read_string(packet);
-        user->mods = read_int32(packet);
-        user->mode = (GameMode)read_byte(packet);
-        user->map_id = read_int32(packet);
-        user->ranked_score = read_int64(packet);
-        user->accuracy = read_float32(packet);
-        user->plays = read_int32(packet);
-        user->total_score = read_int64(packet);
-        user->global_rank = read_int32(packet);
-        user->pp = read_short(packet);
+        user->mods = read_u32(packet);
+        user->mode = (GameMode)read_u8(packet);
+        user->map_id = read_u32(packet);
+        user->ranked_score = read_u64(packet);
+        user->accuracy = read_f32(packet);
+        user->plays = read_u32(packet);
+        user->total_score = read_u64(packet);
+        user->global_rank = read_u32(packet);
+        user->pp = read_u16(packet);
 
         if(stats_user_id == bancho.user_id) {
             bancho.osu->m_songBrowser2->m_userButton->updateUserStats();
         }
     } else if(packet->id == USER_LOGOUT) {
-        int32_t logged_out_id = read_int32(packet);
-        read_byte(packet);
+        i32 logged_out_id = read_u32(packet);
+        read_u8(packet);
         if(logged_out_id == bancho.user_id) {
             debugLog("Logged out.\n");
             disconnect();
         }
     } else if(packet->id == SPECTATOR_JOINED) {
-        int32_t spectator_id = read_int32(packet);
+        i32 spectator_id = read_u32(packet);
         debugLog("Spectator joined: user id %d\n", spectator_id);
     } else if(packet->id == SPECTATOR_LEFT) {
-        int32_t spectator_id = read_int32(packet);
+        i32 spectator_id = read_u32(packet);
         debugLog("Spectator left: user id %d\n", spectator_id);
     } else if(packet->id == VERSION_UPDATE) {
         disconnect();
         bancho.osu->getNotificationOverlay()->addNotification("Server uses an unsupported protocol version.");
     } else if(packet->id == SPECTATOR_CANT_SPECTATE) {
-        int32_t spectator_id = read_int32(packet);
+        i32 spectator_id = read_u32(packet);
         debugLog("Spectator can't spectate: user id %d\n", spectator_id);
     } else if(packet->id == GET_ATTENTION) {
         // (nothing to do)
@@ -329,7 +329,7 @@ void handle_packet(Packet *packet) {
         auto room = new Room(packet);
         bancho.osu->m_lobby->addRoom(room);
     } else if(packet->id == ROOM_CLOSED) {
-        int32_t room_id = read_int32(packet);
+        i32 room_id = read_u32(packet);
         bancho.osu->m_lobby->removeRoom(room_id);
     } else if(packet->id == ROOM_JOIN_SUCCESS) {
         auto room = Room(packet);
@@ -338,10 +338,10 @@ void handle_packet(Packet *packet) {
         bancho.osu->getNotificationOverlay()->addNotification("Failed to join room.");
         bancho.osu->m_lobby->on_room_join_failed();
     } else if(packet->id == FELLOW_SPECTATOR_JOINED) {
-        uint32_t spectator_id = read_int32(packet);
+        u32 spectator_id = read_u32(packet);
         (void)spectator_id;  // (spectating not implemented; nothing to do)
     } else if(packet->id == FELLOW_SPECTATOR_LEFT) {
-        uint32_t spectator_id = read_int32(packet);
+        u32 spectator_id = read_u32(packet);
         (void)spectator_id;  // (spectating not implemented; nothing to do)
     } else if(packet->id == MATCH_STARTED) {
         auto room = Room(packet);
@@ -353,7 +353,7 @@ void handle_packet(Packet *packet) {
     } else if(packet->id == MATCH_ALL_PLAYERS_LOADED) {
         bancho.osu->m_room->on_all_players_loaded();
     } else if(packet->id == MATCH_PLAYER_FAILED) {
-        int32_t slot_id = read_int32(packet);
+        i32 slot_id = read_u32(packet);
         bancho.osu->m_room->on_player_failed(slot_id);
     } else if(packet->id == MATCH_FINISHED) {
         bancho.osu->m_room->on_match_finished();
@@ -371,7 +371,7 @@ void handle_packet(Packet *packet) {
     } else if(packet->id == CHANNEL_INFO) {
         UString channel_name = read_string(packet);
         UString channel_topic = read_string(packet);
-        int32_t nb_members = read_int32(packet);
+        i32 nb_members = read_u32(packet);
         update_channel(channel_name, channel_topic, nb_members);
     } else if(packet->id == LEFT_CHANNEL) {
         UString name = read_string(packet);
@@ -379,21 +379,21 @@ void handle_packet(Packet *packet) {
     } else if(packet->id == CHANNEL_AUTO_JOIN) {
         UString channel_name = read_string(packet);
         UString channel_topic = read_string(packet);
-        int32_t nb_members = read_int32(packet);
+        i32 nb_members = read_u32(packet);
         update_channel(channel_name, channel_topic, nb_members);
     } else if(packet->id == PRIVILEGES) {
-        read_int32(packet);
+        read_u32(packet);
         // (nothing to do)
     } else if(packet->id == FRIENDS_LIST) {
         friends.clear();
 
-        uint16_t nb_friends = read_short(packet);
+        u16 nb_friends = read_u16(packet);
         for(int i = 0; i < nb_friends; i++) {
-            uint32_t friend_id = read_int32(packet);
+            u32 friend_id = read_u32(packet);
             friends.push_back(friend_id);
         }
     } else if(packet->id == PROTOCOL_VERSION) {
-        int protocol_version = read_int32(packet);
+        int protocol_version = read_u32(packet);
         if(protocol_version != 19) {
             disconnect();
             bancho.osu->getNotificationOverlay()->addNotification("Server uses an unsupported protocol version.");
@@ -405,7 +405,7 @@ void handle_packet(Packet *packet) {
             bancho.server_icon_url = urls[0];
         }
     } else if(packet->id == MATCH_PLAYER_SKIPPED) {
-        int32_t user_id = read_int32(packet);
+        i32 user_id = read_u32(packet);
         bancho.osu->m_room->on_player_skip(user_id);
 
         // I'm not sure the server ever sends MATCH_SKIP... So, double-checking here.
@@ -421,20 +421,20 @@ void handle_packet(Packet *packet) {
             bancho.osu->m_room->on_all_players_skipped();
         }
     } else if(packet->id == USER_PRESENCE) {
-        int32_t presence_user_id = read_int32(packet);
+        i32 presence_user_id = read_u32(packet);
         UString presence_username = read_string(packet);
 
         UserInfo *user = get_user_info(presence_user_id);
         user->name = presence_username;
-        user->utc_offset = read_byte(packet);
-        user->country = read_byte(packet);
-        user->privileges = read_byte(packet);
-        user->longitude = read_float32(packet);
-        user->latitude = read_float32(packet);
-        user->global_rank = read_int32(packet);
+        user->utc_offset = read_u8(packet);
+        user->country = read_u8(packet);
+        user->privileges = read_u8(packet);
+        user->longitude = read_f32(packet);
+        user->latitude = read_f32(packet);
+        user->global_rank = read_u32(packet);
     } else if(packet->id == RESTART) {
         // XXX: wait 'ms' milliseconds before reconnecting
-        int32_t ms = read_int32(packet);
+        i32 ms = read_u32(packet);
         (void)ms;
 
         // Some servers send "restart" packets when password is incorrect
@@ -447,7 +447,7 @@ void handle_packet(Packet *packet) {
         UString text = read_string(packet);
         UString recipient = read_string(packet);
         (void)recipient;
-        int32_t sender_id = read_int32(packet);
+        i32 sender_id = read_u32(packet);
         bancho.osu->m_chat->addMessage(recipient, ChatMessage{
                                                       .tms = time(NULL),
                                                       .author_id = sender_id,
@@ -463,23 +463,23 @@ void handle_packet(Packet *packet) {
         debugLog("Room changed password to %s\n", new_password.toUtf8());
         bancho.room.password = new_password;
     } else if(packet->id == SILENCE_END) {
-        int32_t delta = read_int32(packet);
+        i32 delta = read_u32(packet);
         debugLog("Silence ends in %d seconds.\n", delta);
         // XXX: Prevent user from sending messages while silenced
     } else if(packet->id == USER_SILENCED) {
-        int32_t user_id = read_int32(packet);
+        i32 user_id = read_u32(packet);
         debugLog("User #%d silenced.\n", user_id);
     } else if(packet->id == USER_DM_BLOCKED) {
         read_string(packet);
         read_string(packet);
         UString blocked = read_string(packet);
-        read_int32(packet);
+        read_u32(packet);
         debugLog("Blocked %s.\n", blocked.toUtf8());
     } else if(packet->id == TARGET_IS_SILENCED) {
         read_string(packet);
         read_string(packet);
         UString blocked = read_string(packet);
-        read_int32(packet);
+        read_u32(packet);
         debugLog("Silenced %s.\n", blocked.toUtf8());
     } else if(packet->id == VERSION_UPDATE_FORCED) {
         disconnect();
@@ -499,14 +499,14 @@ Packet build_login_packet() {
     // username\npasswd_md5\nosu_version|utc_offset|display_city|client_hashes|pm_private\n
     Packet packet;
 
-    write_bytes(&packet, (uint8_t *)bancho.username.toUtf8(), bancho.username.lengthUtf8());
-    write_byte(&packet, '\n');
+    write_bytes(&packet, (u8 *)bancho.username.toUtf8(), bancho.username.lengthUtf8());
+    write_u8(&packet, '\n');
 
-    write_bytes(&packet, (uint8_t *)bancho.pw_md5.hash, 32);
-    write_byte(&packet, '\n');
+    write_bytes(&packet, (u8 *)bancho.pw_md5.hash, 32);
+    write_u8(&packet, '\n');
 
-    write_bytes(&packet, (uint8_t *)OSU_VERSION, strlen(OSU_VERSION));
-    write_byte(&packet, '|');
+    write_bytes(&packet, (u8 *)OSU_VERSION, strlen(OSU_VERSION));
+    write_u8(&packet, '|');
 
     // UTC offset
     time_t now = time(NULL);
@@ -514,15 +514,15 @@ Packet build_login_packet() {
     auto local_time = localtime(&now);
     int utc_offset = difftime(mktime(local_time), mktime(gmt)) / 3600;
     if(utc_offset < 0) {
-        write_byte(&packet, '-');
+        write_u8(&packet, '-');
         utc_offset *= -1;
     }
-    write_byte(&packet, '0' + utc_offset);
-    write_byte(&packet, '|');
+    write_u8(&packet, '0' + utc_offset);
+    write_u8(&packet, '|');
 
     // Don't dox the user's city
-    write_byte(&packet, '0');
-    write_byte(&packet, '|');
+    write_u8(&packet, '0');
+    write_u8(&packet, '|');
 
     char osu_path[PATH_MAX] = {0};
 #ifdef _WIN32
@@ -531,30 +531,30 @@ Packet build_login_packet() {
     readlink("/proc/self/exe", osu_path, PATH_MAX - 1);
 #endif
 
-    MD5Hash osu_path_md5 = md5((uint8_t *)osu_path, strlen(osu_path));
+    MD5Hash osu_path_md5 = md5((u8 *)osu_path, strlen(osu_path));
 
     // XXX: Should get MAC addresses from network adapters
     // NOTE: Not sure how the MD5 is computed - does it include final "." ?
     const char *adapters = "runningunderwine";
-    MD5Hash adapters_md5 = md5((uint8_t *)adapters, strlen(adapters));
+    MD5Hash adapters_md5 = md5((u8 *)adapters, strlen(adapters));
 
     // XXX: Should remove '|' from the disk UUID just to be safe
     bancho.disk_uuid = get_disk_uuid();
-    MD5Hash disk_md5 = md5((uint8_t *)bancho.disk_uuid.toUtf8(), bancho.disk_uuid.lengthUtf8());
+    MD5Hash disk_md5 = md5((u8 *)bancho.disk_uuid.toUtf8(), bancho.disk_uuid.lengthUtf8());
 
     // XXX: Not implemented, I'm lazy so just reusing disk signature
     bancho.install_id = bancho.disk_uuid;
-    MD5Hash install_md5 = md5((uint8_t *)bancho.install_id.toUtf8(), bancho.install_id.lengthUtf8());
+    MD5Hash install_md5 = md5((u8 *)bancho.install_id.toUtf8(), bancho.install_id.lengthUtf8());
     ;
 
     bancho.client_hashes = UString::format("%s:%s:%s:%s:%s:", osu_path_md5.hash, adapters, adapters_md5.hash,
                                            install_md5.hash, disk_md5.hash);
-    write_bytes(&packet, (uint8_t *)bancho.client_hashes.toUtf8(), bancho.client_hashes.lengthUtf8());
+    write_bytes(&packet, (u8 *)bancho.client_hashes.toUtf8(), bancho.client_hashes.lengthUtf8());
 
     // Allow PMs from strangers
-    write_byte(&packet, '|');
-    write_byte(&packet, '0');
+    write_u8(&packet, '|');
+    write_u8(&packet, '0');
 
-    write_byte(&packet, '\n');
+    write_u8(&packet, '\n');
     return packet;
 }

+ 3 - 5
src/App/Osu/Bancho.h

@@ -1,6 +1,4 @@
 #pragma once
-#include <stdint.h>
-
 #include <unordered_map>
 
 #include "BanchoProtocol.h"
@@ -20,7 +18,7 @@ struct Bancho {
 
     Osu *osu = nullptr;
     UString endpoint;
-    int32_t user_id = 0;
+    i32 user_id = 0;
     UString username;
     MD5Hash pw_md5;
     Room room;
@@ -54,10 +52,10 @@ struct Bancho {
 struct Channel {
     UString name;
     UString topic;
-    uint32_t nb_members;
+    u32 nb_members;
 };
 
-MD5Hash md5(uint8_t *msg, size_t msg_len);
+MD5Hash md5(u8 *msg, size_t msg_len);
 
 void handle_packet(Packet *packet);
 

+ 148 - 153
src/App/Osu/BanchoAes.cpp

@@ -6,167 +6,162 @@
 #include "BanchoNetworking.h"
 #include "UString.h"
 
-uint8_t r_con[] = {1,  2,  4,   8,  16,  32,  64, 128, 27,  54,  108, 216, 171, 77,  154,
-                   47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145};
-uint8_t S[] = {99,  124, 119, 123, 242, 107, 111, 197, 48,  1,   103, 43,  254, 215, 171, 118, 202, 130, 201, 125,
-               250, 89,  71,  240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38,  54,  63,  247, 204,
-               52,  165, 229, 241, 113, 216, 49,  21,  4,   199, 35,  195, 24,  150, 5,   154, 7,   18,  128, 226,
-               235, 39,  178, 117, 9,   131, 44,  26,  27,  110, 90,  160, 82,  59,  214, 179, 41,  227, 47,  132,
-               83,  209, 0,   237, 32,  252, 177, 91,  106, 203, 190, 57,  74,  76,  88,  207, 208, 239, 170, 251,
-               67,  77,  51,  133, 69,  249, 2,   127, 80,  60,  159, 168, 81,  163, 64,  143, 146, 157, 56,  245,
-               188, 182, 218, 33,  16,  255, 243, 210, 205, 12,  19,  236, 95,  151, 68,  23,  196, 167, 126, 61,
-               100, 93,  25,  115, 96,  129, 79,  220, 34,  42,  144, 136, 70,  238, 184, 20,  222, 94,  11,  219,
-               224, 50,  58,  10,  73,  6,   36,  92,  194, 211, 172, 98,  145, 149, 228, 121, 231, 200, 55,  109,
-               141, 213, 78,  169, 108, 86,  244, 234, 101, 122, 174, 8,   186, 120, 37,  46,  28,  166, 180, 198,
-               232, 221, 116, 31,  75,  189, 139, 138, 112, 62,  181, 102, 72,  3,   246, 14,  97,  53,  87,  185,
-               134, 193, 29,  158, 225, 248, 152, 17,  105, 217, 142, 148, 155, 30,  135, 233, 206, 85,  40,  223,
-               140, 161, 137, 13,  191, 230, 66,  104, 65,  153, 45,  15,  176, 84,  187, 22};
-uint32_t T1[] = {
-    3328402341, 4168907908, 4000806809, 4135287693, 4294111757, 3597364157, 3731845041, 2445657428, 1613770832,
-    33620227,   3462883241, 1445669757, 3892248089, 3050821474, 1303096294, 3967186586, 2412431941, 528646813,
-    2311702848, 4202528135, 4026202645, 2992200171, 2387036105, 4226871307, 1101901292, 3017069671, 1604494077,
-    1169141738, 597466303,  1403299063, 3832705686, 2613100635, 1974974402, 3791519004, 1033081774, 1277568618,
-    1815492186, 2118074177, 4126668546, 2211236943, 1748251740, 1369810420, 3521504564, 4193382664, 3799085459,
-    2883115123, 1647391059, 706024767,  134480908,  2512897874, 1176707941, 2646852446, 806885416,  932615841,
-    168101135,  798661301,  235341577,  605164086,  461406363,  3756188221, 3454790438, 1311188841, 2142417613,
-    3933566367, 302582043,  495158174,  1479289972, 874125870,  907746093,  3698224818, 3025820398, 1537253627,
-    2756858614, 1983593293, 3084310113, 2108928974, 1378429307, 3722699582, 1580150641, 327451799,  2790478837,
-    3117535592, 0,          3253595436, 1075847264, 3825007647, 2041688520, 3059440621, 3563743934, 2378943302,
-    1740553945, 1916352843, 2487896798, 2555137236, 2958579944, 2244988746, 3151024235, 3320835882, 1336584933,
-    3992714006, 2252555205, 2588757463, 1714631509, 293963156,  2319795663, 3925473552, 67240454,   4269768577,
-    2689618160, 2017213508, 631218106,  1269344483, 2723238387, 1571005438, 2151694528, 93294474,   1066570413,
-    563977660,  1882732616, 4059428100, 1673313503, 2008463041, 2950355573, 1109467491, 537923632,  3858759450,
-    4260623118, 3218264685, 2177748300, 403442708,  638784309,  3287084079, 3193921505, 899127202,  2286175436,
-    773265209,  2479146071, 1437050866, 4236148354, 2050833735, 3362022572, 3126681063, 840505643,  3866325909,
-    3227541664, 427917720,  2655997905, 2749160575, 1143087718, 1412049534, 999329963,  193497219,  2353415882,
-    3354324521, 1807268051, 672404540,  2816401017, 3160301282, 369822493,  2916866934, 3688947771, 1681011286,
-    1949973070, 336202270,  2454276571, 201721354,  1210328172, 3093060836, 2680341085, 3184776046, 1135389935,
-    3294782118, 965841320,  831886756,  3554993207, 4068047243, 3588745010, 2345191491, 1849112409, 3664604599,
-    26054028,   2983581028, 2622377682, 1235855840, 3630984372, 2891339514, 4092916743, 3488279077, 3395642799,
-    4101667470, 1202630377, 268961816,  1874508501, 4034427016, 1243948399, 1546530418, 941366308,  1470539505,
-    1941222599, 2546386513, 3421038627, 2715671932, 3899946140, 1042226977, 2521517021, 1639824860, 227249030,
-    260737669,  3765465232, 2084453954, 1907733956, 3429263018, 2420656344, 100860677,  4160157185, 470683154,
-    3261161891, 1781871967, 2924959737, 1773779408, 394692241,  2579611992, 974986535,  664706745,  3655459128,
-    3958962195, 731420851,  571543859,  3530123707, 2849626480, 126783113,  865375399,  765172662,  1008606754,
-    361203602,  3387549984, 2278477385, 2857719295, 1344809080, 2782912378, 59542671,   1503764984, 160008576,
-    437062935,  1707065306, 3622233649, 2218934982, 3496503480, 2185314755, 697932208,  1512910199, 504303377,
-    2075177163, 2824099068, 1841019862, 739644986};
-uint32_t T2[] = {
-    2781242211, 2230877308, 2582542199, 2381740923, 234877682,  3184946027, 2984144751, 1418839493, 1348481072,
-    50462977,   2848876391, 2102799147, 434634494,  1656084439, 3863849899, 2599188086, 1167051466, 2636087938,
-    1082771913, 2281340285, 368048890,  3954334041, 3381544775, 201060592,  3963727277, 1739838676, 4250903202,
-    3930435503, 3206782108, 4149453988, 2531553906, 1536934080, 3262494647, 484572669,  2923271059, 1783375398,
-    1517041206, 1098792767, 49674231,   1334037708, 1550332980, 4098991525, 886171109,  150598129,  2481090929,
-    1940642008, 1398944049, 1059722517, 201851908,  1385547719, 1699095331, 1587397571, 674240536,  2704774806,
-    252314885,  3039795866, 151914247,  908333586,  2602270848, 1038082786, 651029483,  1766729511, 3447698098,
-    2682942837, 454166793,  2652734339, 1951935532, 775166490,  758520603,  3000790638, 4004797018, 4217086112,
-    4137964114, 1299594043, 1639438038, 3464344499, 2068982057, 1054729187, 1901997871, 2534638724, 4121318227,
-    1757008337, 0,          750906861,  1614815264, 535035132,  3363418545, 3988151131, 3201591914, 1183697867,
-    3647454910, 1265776953, 3734260298, 3566750796, 3903871064, 1250283471, 1807470800, 717615087,  3847203498,
-    384695291,  3313910595, 3617213773, 1432761139, 2484176261, 3481945413, 283769337,  100925954,  2180939647,
-    4037038160, 1148730428, 3123027871, 3813386408, 4087501137, 4267549603, 3229630528, 2315620239, 2906624658,
-    3156319645, 1215313976, 82966005,   3747855548, 3245848246, 1974459098, 1665278241, 807407632,  451280895,
-    251524083,  1841287890, 1283575245, 337120268,  891687699,  801369324,  3787349855, 2721421207, 3431482436,
-    959321879,  1469301956, 4065699751, 2197585534, 1199193405, 2898814052, 3887750493, 724703513,  2514908019,
-    2696962144, 2551808385, 3516813135, 2141445340, 1715741218, 2119445034, 2872807568, 2198571144, 3398190662,
-    700968686,  3547052216, 1009259540, 2041044702, 3803995742, 487983883,  1991105499, 1004265696, 1449407026,
-    1316239930, 504629770,  3683797321, 168560134,  1816667172, 3837287516, 1570751170, 1857934291, 4014189740,
-    2797888098, 2822345105, 2754712981, 936633572,  2347923833, 852879335,  1133234376, 1500395319, 3084545389,
-    2348912013, 1689376213, 3533459022, 3762923945, 3034082412, 4205598294, 133428468,  634383082,  2949277029,
-    2398386810, 3913789102, 403703816,  3580869306, 2297460856, 1867130149, 1918643758, 607656988,  4049053350,
-    3346248884, 1368901318, 600565992,  2090982877, 2632479860, 557719327,  3717614411, 3697393085, 2249034635,
-    2232388234, 2430627952, 1115438654, 3295786421, 2865522278, 3633334344, 84280067,   33027830,   303828494,
-    2747425121, 1600795957, 4188952407, 3496589753, 2434238086, 1486471617, 658119965,  3106381470, 953803233,
-    334231800,  3005978776, 857870609,  3151128937, 1890179545, 2298973838, 2805175444, 3056442267, 574365214,
-    2450884487, 550103529,  1233637070, 4289353045, 2018519080, 2057691103, 2399374476, 4166623649, 2148108681,
-    387583245,  3664101311, 836232934,  3330556482, 3100665960, 3280093505, 2955516313, 2002398509, 287182607,
-    3413881008, 4238890068, 3597515707, 975967766};
-uint32_t T3[] = {
-    1671808611, 2089089148, 2006576759, 2072901243, 4061003762, 1807603307, 1873927791, 3310653893, 810573872,
-    16974337,   1739181671, 729634347,  4263110654, 3613570519, 2883997099, 1989864566, 3393556426, 2191335298,
-    3376449993, 2106063485, 4195741690, 1508618841, 1204391495, 4027317232, 2917941677, 3563566036, 2734514082,
-    2951366063, 2629772188, 2767672228, 1922491506, 3227229120, 3082974647, 4246528509, 2477669779, 644500518,
-    911895606,  1061256767, 4144166391, 3427763148, 878471220,  2784252325, 3845444069, 4043897329, 1905517169,
-    3631459288, 827548209,  356461077,  67897348,   3344078279, 593839651,  3277757891, 405286936,  2527147926,
-    84871685,   2595565466, 118033927,  305538066,  2157648768, 3795705826, 3945188843, 661212711,  2999812018,
-    1973414517, 152769033,  2208177539, 745822252,  439235610,  455947803,  1857215598, 1525593178, 2700827552,
-    1391895634, 994932283,  3596728278, 3016654259, 695947817,  3812548067, 795958831,  2224493444, 1408607827,
-    3513301457, 0,          3979133421, 543178784,  4229948412, 2982705585, 1542305371, 1790891114, 3410398667,
-    3201918910, 961245753,  1256100938, 1289001036, 1491644504, 3477767631, 3496721360, 4012557807, 2867154858,
-    4212583931, 1137018435, 1305975373, 861234739,  2241073541, 1171229253, 4178635257, 33948674,   2139225727,
-    1357946960, 1011120188, 2679776671, 2833468328, 1374921297, 2751356323, 1086357568, 2408187279, 2460827538,
-    2646352285, 944271416,  4110742005, 3168756668, 3066132406, 3665145818, 560153121,  271589392,  4279952895,
-    4077846003, 3530407890, 3444343245, 202643468,  322250259,  3962553324, 1608629855, 2543990167, 1154254916,
-    389623319,  3294073796, 2817676711, 2122513534, 1028094525, 1689045092, 1575467613, 422261273,  1939203699,
-    1621147744, 2174228865, 1339137615, 3699352540, 577127458,  712922154,  2427141008, 2290289544, 1187679302,
-    3995715566, 3100863416, 339486740,  3732514782, 1591917662, 186455563,  3681988059, 3762019296, 844522546,
-    978220090,  169743370,  1239126601, 101321734,  611076132,  1558493276, 3260915650, 3547250131, 2901361580,
-    1655096418, 2443721105, 2510565781, 3828863972, 2039214713, 3878868455, 3359869896, 928607799,  1840765549,
-    2374762893, 3580146133, 1322425422, 2850048425, 1823791212, 1459268694, 4094161908, 3928346602, 1706019429,
-    2056189050, 2934523822, 135794696,  3134549946, 2022240376, 628050469,  779246638,  472135708,  2800834470,
-    3032970164, 3327236038, 3894660072, 3715932637, 1956440180, 522272287,  1272813131, 3185336765, 2340818315,
-    2323976074, 1888542832, 1044544574, 3049550261, 1722469478, 1222152264, 50660867,   4127324150, 236067854,
-    1638122081, 895445557,  1475980887, 3117443513, 2257655686, 3243809217, 489110045,  2662934430, 3778599393,
-    4162055160, 2561878936, 288563729,  1773916777, 3648039385, 2391345038, 2493985684, 2612407707, 505560094,
-    2274497927, 3911240169, 3460925390, 1442818645, 678973480,  3749357023, 2358182796, 2717407649, 2306869641,
-    219617805,  3218761151, 3862026214, 1120306242, 1756942440, 1103331905, 2578459033, 762796589,  252780047,
-    2966125488, 1425844308, 3151392187, 372911126};
-uint32_t T4[] = {
-    1667474886, 2088535288, 2004326894, 2071694838, 4075949567, 1802223062, 1869591006, 3318043793, 808472672,
-    16843522,   1734846926, 724270422,  4278065639, 3621216949, 2880169549, 1987484396, 3402253711, 2189597983,
-    3385409673, 2105378810, 4210693615, 1499065266, 1195886990, 4042263547, 2913856577, 3570689971, 2728590687,
-    2947541573, 2627518243, 2762274643, 1920112356, 3233831835, 3082273397, 4261223649, 2475929149, 640051788,
-    909531756,  1061110142, 4160160501, 3435941763, 875846760,  2779116625, 3857003729, 4059105529, 1903268834,
-    3638064043, 825316194,  353713962,  67374088,   3351728789, 589522246,  3284360861, 404236336,  2526454071,
-    84217610,   2593830191, 117901582,  303183396,  2155911963, 3806477791, 3958056653, 656894286,  2998062463,
-    1970642922, 151591698,  2206440989, 741110872,  437923380,  454765878,  1852748508, 1515908788, 2694904667,
-    1381168804, 993742198,  3604373943, 3014905469, 690584402,  3823320797, 791638366,  2223281939, 1398011302,
-    3520161977, 0,          3991743681, 538992704,  4244381667, 2981218425, 1532751286, 1785380564, 3419096717,
-    3200178535, 960056178,  1246420628, 1280103576, 1482221744, 3486468741, 3503319995, 4025428677, 2863326543,
-    4227536621, 1128514950, 1296947098, 859002214,  2240123921, 1162203018, 4193849577, 33687044,   2139062782,
-    1347481760, 1010582648, 2678045221, 2829640523, 1364325282, 2745433693, 1077985408, 2408548869, 2459086143,
-    2644360225, 943212656,  4126475505, 3166494563, 3065430391, 3671750063, 555836226,  269496352,  4294908645,
-    4092792573, 3537006015, 3452783745, 202118168,  320025894,  3974901699, 1600119230, 2543297077, 1145359496,
-    387397934,  3301201811, 2812801621, 2122220284, 1027426170, 1684319432, 1566435258, 421079858,  1936954854,
-    1616945344, 2172753945, 1330631070, 3705438115, 572679748,  707427924,  2425400123, 2290647819, 1179044492,
-    4008585671, 3099120491, 336870440,  3739122087, 1583276732, 185277718,  3688593069, 3772791771, 842159716,
-    976899700,  168435220,  1229577106, 101059084,  606366792,  1549591736, 3267517855, 3553849021, 2897014595,
-    1650632388, 2442242105, 2509612081, 3840161747, 2038008818, 3890688725, 3368567691, 926374254,  1835907034,
-    2374863873, 3587531953, 1313788572, 2846482505, 1819063512, 1448540844, 4109633523, 3941213647, 1701162954,
-    2054852340, 2930698567, 134748176,  3132806511, 2021165296, 623210314,  774795868,  471606328,  2795958615,
-    3031746419, 3334885783, 3907527627, 3722280097, 1953799400, 522133822,  1263263126, 3183336545, 2341176845,
-    2324333839, 1886425312, 1044267644, 3048588401, 1718004428, 1212733584, 50529542,   4143317495, 235803164,
-    1633788866, 892690282,  1465383342, 3115962473, 2256965911, 3250673817, 488449850,  2661202215, 3789633753,
-    4177007595, 2560144171, 286339874,  1768537042, 3654906025, 2391705863, 2492770099, 2610673197, 505291324,
-    2273808917, 3924369609, 3469625735, 1431699370, 673740880,  3755965093, 2358021891, 2711746649, 2307489801,
-    218961690,  3217021541, 3873845719, 1111672452, 1751693520, 1094828930, 2576986153, 757954394,  252645662,
-    2964376443, 1414855848, 3149649517, 370555436};
+u8 r_con[] = {1,  2,  4,   8,  16,  32,  64, 128, 27,  54,  108, 216, 171, 77,  154,
+              47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145};
+u8 S[] = {99,  124, 119, 123, 242, 107, 111, 197, 48,  1,   103, 43,  254, 215, 171, 118, 202, 130, 201, 125, 250, 89,
+          71,  240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38,  54,  63,  247, 204, 52,  165, 229, 241,
+          113, 216, 49,  21,  4,   199, 35,  195, 24,  150, 5,   154, 7,   18,  128, 226, 235, 39,  178, 117, 9,   131,
+          44,  26,  27,  110, 90,  160, 82,  59,  214, 179, 41,  227, 47,  132, 83,  209, 0,   237, 32,  252, 177, 91,
+          106, 203, 190, 57,  74,  76,  88,  207, 208, 239, 170, 251, 67,  77,  51,  133, 69,  249, 2,   127, 80,  60,
+          159, 168, 81,  163, 64,  143, 146, 157, 56,  245, 188, 182, 218, 33,  16,  255, 243, 210, 205, 12,  19,  236,
+          95,  151, 68,  23,  196, 167, 126, 61,  100, 93,  25,  115, 96,  129, 79,  220, 34,  42,  144, 136, 70,  238,
+          184, 20,  222, 94,  11,  219, 224, 50,  58,  10,  73,  6,   36,  92,  194, 211, 172, 98,  145, 149, 228, 121,
+          231, 200, 55,  109, 141, 213, 78,  169, 108, 86,  244, 234, 101, 122, 174, 8,   186, 120, 37,  46,  28,  166,
+          180, 198, 232, 221, 116, 31,  75,  189, 139, 138, 112, 62,  181, 102, 72,  3,   246, 14,  97,  53,  87,  185,
+          134, 193, 29,  158, 225, 248, 152, 17,  105, 217, 142, 148, 155, 30,  135, 233, 206, 85,  40,  223, 140, 161,
+          137, 13,  191, 230, 66,  104, 65,  153, 45,  15,  176, 84,  187, 22};
+u32 T1[] = {3328402341, 4168907908, 4000806809, 4135287693, 4294111757, 3597364157, 3731845041, 2445657428, 1613770832,
+            33620227,   3462883241, 1445669757, 3892248089, 3050821474, 1303096294, 3967186586, 2412431941, 528646813,
+            2311702848, 4202528135, 4026202645, 2992200171, 2387036105, 4226871307, 1101901292, 3017069671, 1604494077,
+            1169141738, 597466303,  1403299063, 3832705686, 2613100635, 1974974402, 3791519004, 1033081774, 1277568618,
+            1815492186, 2118074177, 4126668546, 2211236943, 1748251740, 1369810420, 3521504564, 4193382664, 3799085459,
+            2883115123, 1647391059, 706024767,  134480908,  2512897874, 1176707941, 2646852446, 806885416,  932615841,
+            168101135,  798661301,  235341577,  605164086,  461406363,  3756188221, 3454790438, 1311188841, 2142417613,
+            3933566367, 302582043,  495158174,  1479289972, 874125870,  907746093,  3698224818, 3025820398, 1537253627,
+            2756858614, 1983593293, 3084310113, 2108928974, 1378429307, 3722699582, 1580150641, 327451799,  2790478837,
+            3117535592, 0,          3253595436, 1075847264, 3825007647, 2041688520, 3059440621, 3563743934, 2378943302,
+            1740553945, 1916352843, 2487896798, 2555137236, 2958579944, 2244988746, 3151024235, 3320835882, 1336584933,
+            3992714006, 2252555205, 2588757463, 1714631509, 293963156,  2319795663, 3925473552, 67240454,   4269768577,
+            2689618160, 2017213508, 631218106,  1269344483, 2723238387, 1571005438, 2151694528, 93294474,   1066570413,
+            563977660,  1882732616, 4059428100, 1673313503, 2008463041, 2950355573, 1109467491, 537923632,  3858759450,
+            4260623118, 3218264685, 2177748300, 403442708,  638784309,  3287084079, 3193921505, 899127202,  2286175436,
+            773265209,  2479146071, 1437050866, 4236148354, 2050833735, 3362022572, 3126681063, 840505643,  3866325909,
+            3227541664, 427917720,  2655997905, 2749160575, 1143087718, 1412049534, 999329963,  193497219,  2353415882,
+            3354324521, 1807268051, 672404540,  2816401017, 3160301282, 369822493,  2916866934, 3688947771, 1681011286,
+            1949973070, 336202270,  2454276571, 201721354,  1210328172, 3093060836, 2680341085, 3184776046, 1135389935,
+            3294782118, 965841320,  831886756,  3554993207, 4068047243, 3588745010, 2345191491, 1849112409, 3664604599,
+            26054028,   2983581028, 2622377682, 1235855840, 3630984372, 2891339514, 4092916743, 3488279077, 3395642799,
+            4101667470, 1202630377, 268961816,  1874508501, 4034427016, 1243948399, 1546530418, 941366308,  1470539505,
+            1941222599, 2546386513, 3421038627, 2715671932, 3899946140, 1042226977, 2521517021, 1639824860, 227249030,
+            260737669,  3765465232, 2084453954, 1907733956, 3429263018, 2420656344, 100860677,  4160157185, 470683154,
+            3261161891, 1781871967, 2924959737, 1773779408, 394692241,  2579611992, 974986535,  664706745,  3655459128,
+            3958962195, 731420851,  571543859,  3530123707, 2849626480, 126783113,  865375399,  765172662,  1008606754,
+            361203602,  3387549984, 2278477385, 2857719295, 1344809080, 2782912378, 59542671,   1503764984, 160008576,
+            437062935,  1707065306, 3622233649, 2218934982, 3496503480, 2185314755, 697932208,  1512910199, 504303377,
+            2075177163, 2824099068, 1841019862, 739644986};
+u32 T2[] = {2781242211, 2230877308, 2582542199, 2381740923, 234877682,  3184946027, 2984144751, 1418839493, 1348481072,
+            50462977,   2848876391, 2102799147, 434634494,  1656084439, 3863849899, 2599188086, 1167051466, 2636087938,
+            1082771913, 2281340285, 368048890,  3954334041, 3381544775, 201060592,  3963727277, 1739838676, 4250903202,
+            3930435503, 3206782108, 4149453988, 2531553906, 1536934080, 3262494647, 484572669,  2923271059, 1783375398,
+            1517041206, 1098792767, 49674231,   1334037708, 1550332980, 4098991525, 886171109,  150598129,  2481090929,
+            1940642008, 1398944049, 1059722517, 201851908,  1385547719, 1699095331, 1587397571, 674240536,  2704774806,
+            252314885,  3039795866, 151914247,  908333586,  2602270848, 1038082786, 651029483,  1766729511, 3447698098,
+            2682942837, 454166793,  2652734339, 1951935532, 775166490,  758520603,  3000790638, 4004797018, 4217086112,
+            4137964114, 1299594043, 1639438038, 3464344499, 2068982057, 1054729187, 1901997871, 2534638724, 4121318227,
+            1757008337, 0,          750906861,  1614815264, 535035132,  3363418545, 3988151131, 3201591914, 1183697867,
+            3647454910, 1265776953, 3734260298, 3566750796, 3903871064, 1250283471, 1807470800, 717615087,  3847203498,
+            384695291,  3313910595, 3617213773, 1432761139, 2484176261, 3481945413, 283769337,  100925954,  2180939647,
+            4037038160, 1148730428, 3123027871, 3813386408, 4087501137, 4267549603, 3229630528, 2315620239, 2906624658,
+            3156319645, 1215313976, 82966005,   3747855548, 3245848246, 1974459098, 1665278241, 807407632,  451280895,
+            251524083,  1841287890, 1283575245, 337120268,  891687699,  801369324,  3787349855, 2721421207, 3431482436,
+            959321879,  1469301956, 4065699751, 2197585534, 1199193405, 2898814052, 3887750493, 724703513,  2514908019,
+            2696962144, 2551808385, 3516813135, 2141445340, 1715741218, 2119445034, 2872807568, 2198571144, 3398190662,
+            700968686,  3547052216, 1009259540, 2041044702, 3803995742, 487983883,  1991105499, 1004265696, 1449407026,
+            1316239930, 504629770,  3683797321, 168560134,  1816667172, 3837287516, 1570751170, 1857934291, 4014189740,
+            2797888098, 2822345105, 2754712981, 936633572,  2347923833, 852879335,  1133234376, 1500395319, 3084545389,
+            2348912013, 1689376213, 3533459022, 3762923945, 3034082412, 4205598294, 133428468,  634383082,  2949277029,
+            2398386810, 3913789102, 403703816,  3580869306, 2297460856, 1867130149, 1918643758, 607656988,  4049053350,
+            3346248884, 1368901318, 600565992,  2090982877, 2632479860, 557719327,  3717614411, 3697393085, 2249034635,
+            2232388234, 2430627952, 1115438654, 3295786421, 2865522278, 3633334344, 84280067,   33027830,   303828494,
+            2747425121, 1600795957, 4188952407, 3496589753, 2434238086, 1486471617, 658119965,  3106381470, 953803233,
+            334231800,  3005978776, 857870609,  3151128937, 1890179545, 2298973838, 2805175444, 3056442267, 574365214,
+            2450884487, 550103529,  1233637070, 4289353045, 2018519080, 2057691103, 2399374476, 4166623649, 2148108681,
+            387583245,  3664101311, 836232934,  3330556482, 3100665960, 3280093505, 2955516313, 2002398509, 287182607,
+            3413881008, 4238890068, 3597515707, 975967766};
+u32 T3[] = {1671808611, 2089089148, 2006576759, 2072901243, 4061003762, 1807603307, 1873927791, 3310653893, 810573872,
+            16974337,   1739181671, 729634347,  4263110654, 3613570519, 2883997099, 1989864566, 3393556426, 2191335298,
+            3376449993, 2106063485, 4195741690, 1508618841, 1204391495, 4027317232, 2917941677, 3563566036, 2734514082,
+            2951366063, 2629772188, 2767672228, 1922491506, 3227229120, 3082974647, 4246528509, 2477669779, 644500518,
+            911895606,  1061256767, 4144166391, 3427763148, 878471220,  2784252325, 3845444069, 4043897329, 1905517169,
+            3631459288, 827548209,  356461077,  67897348,   3344078279, 593839651,  3277757891, 405286936,  2527147926,
+            84871685,   2595565466, 118033927,  305538066,  2157648768, 3795705826, 3945188843, 661212711,  2999812018,
+            1973414517, 152769033,  2208177539, 745822252,  439235610,  455947803,  1857215598, 1525593178, 2700827552,
+            1391895634, 994932283,  3596728278, 3016654259, 695947817,  3812548067, 795958831,  2224493444, 1408607827,
+            3513301457, 0,          3979133421, 543178784,  4229948412, 2982705585, 1542305371, 1790891114, 3410398667,
+            3201918910, 961245753,  1256100938, 1289001036, 1491644504, 3477767631, 3496721360, 4012557807, 2867154858,
+            4212583931, 1137018435, 1305975373, 861234739,  2241073541, 1171229253, 4178635257, 33948674,   2139225727,
+            1357946960, 1011120188, 2679776671, 2833468328, 1374921297, 2751356323, 1086357568, 2408187279, 2460827538,
+            2646352285, 944271416,  4110742005, 3168756668, 3066132406, 3665145818, 560153121,  271589392,  4279952895,
+            4077846003, 3530407890, 3444343245, 202643468,  322250259,  3962553324, 1608629855, 2543990167, 1154254916,
+            389623319,  3294073796, 2817676711, 2122513534, 1028094525, 1689045092, 1575467613, 422261273,  1939203699,
+            1621147744, 2174228865, 1339137615, 3699352540, 577127458,  712922154,  2427141008, 2290289544, 1187679302,
+            3995715566, 3100863416, 339486740,  3732514782, 1591917662, 186455563,  3681988059, 3762019296, 844522546,
+            978220090,  169743370,  1239126601, 101321734,  611076132,  1558493276, 3260915650, 3547250131, 2901361580,
+            1655096418, 2443721105, 2510565781, 3828863972, 2039214713, 3878868455, 3359869896, 928607799,  1840765549,
+            2374762893, 3580146133, 1322425422, 2850048425, 1823791212, 1459268694, 4094161908, 3928346602, 1706019429,
+            2056189050, 2934523822, 135794696,  3134549946, 2022240376, 628050469,  779246638,  472135708,  2800834470,
+            3032970164, 3327236038, 3894660072, 3715932637, 1956440180, 522272287,  1272813131, 3185336765, 2340818315,
+            2323976074, 1888542832, 1044544574, 3049550261, 1722469478, 1222152264, 50660867,   4127324150, 236067854,
+            1638122081, 895445557,  1475980887, 3117443513, 2257655686, 3243809217, 489110045,  2662934430, 3778599393,
+            4162055160, 2561878936, 288563729,  1773916777, 3648039385, 2391345038, 2493985684, 2612407707, 505560094,
+            2274497927, 3911240169, 3460925390, 1442818645, 678973480,  3749357023, 2358182796, 2717407649, 2306869641,
+            219617805,  3218761151, 3862026214, 1120306242, 1756942440, 1103331905, 2578459033, 762796589,  252780047,
+            2966125488, 1425844308, 3151392187, 372911126};
+u32 T4[] = {1667474886, 2088535288, 2004326894, 2071694838, 4075949567, 1802223062, 1869591006, 3318043793, 808472672,
+            16843522,   1734846926, 724270422,  4278065639, 3621216949, 2880169549, 1987484396, 3402253711, 2189597983,
+            3385409673, 2105378810, 4210693615, 1499065266, 1195886990, 4042263547, 2913856577, 3570689971, 2728590687,
+            2947541573, 2627518243, 2762274643, 1920112356, 3233831835, 3082273397, 4261223649, 2475929149, 640051788,
+            909531756,  1061110142, 4160160501, 3435941763, 875846760,  2779116625, 3857003729, 4059105529, 1903268834,
+            3638064043, 825316194,  353713962,  67374088,   3351728789, 589522246,  3284360861, 404236336,  2526454071,
+            84217610,   2593830191, 117901582,  303183396,  2155911963, 3806477791, 3958056653, 656894286,  2998062463,
+            1970642922, 151591698,  2206440989, 741110872,  437923380,  454765878,  1852748508, 1515908788, 2694904667,
+            1381168804, 993742198,  3604373943, 3014905469, 690584402,  3823320797, 791638366,  2223281939, 1398011302,
+            3520161977, 0,          3991743681, 538992704,  4244381667, 2981218425, 1532751286, 1785380564, 3419096717,
+            3200178535, 960056178,  1246420628, 1280103576, 1482221744, 3486468741, 3503319995, 4025428677, 2863326543,
+            4227536621, 1128514950, 1296947098, 859002214,  2240123921, 1162203018, 4193849577, 33687044,   2139062782,
+            1347481760, 1010582648, 2678045221, 2829640523, 1364325282, 2745433693, 1077985408, 2408548869, 2459086143,
+            2644360225, 943212656,  4126475505, 3166494563, 3065430391, 3671750063, 555836226,  269496352,  4294908645,
+            4092792573, 3537006015, 3452783745, 202118168,  320025894,  3974901699, 1600119230, 2543297077, 1145359496,
+            387397934,  3301201811, 2812801621, 2122220284, 1027426170, 1684319432, 1566435258, 421079858,  1936954854,
+            1616945344, 2172753945, 1330631070, 3705438115, 572679748,  707427924,  2425400123, 2290647819, 1179044492,
+            4008585671, 3099120491, 336870440,  3739122087, 1583276732, 185277718,  3688593069, 3772791771, 842159716,
+            976899700,  168435220,  1229577106, 101059084,  606366792,  1549591736, 3267517855, 3553849021, 2897014595,
+            1650632388, 2442242105, 2509612081, 3840161747, 2038008818, 3890688725, 3368567691, 926374254,  1835907034,
+            2374863873, 3587531953, 1313788572, 2846482505, 1819063512, 1448540844, 4109633523, 3941213647, 1701162954,
+            2054852340, 2930698567, 134748176,  3132806511, 2021165296, 623210314,  774795868,  471606328,  2795958615,
+            3031746419, 3334885783, 3907527627, 3722280097, 1953799400, 522133822,  1263263126, 3183336545, 2341176845,
+            2324333839, 1886425312, 1044267644, 3048588401, 1718004428, 1212733584, 50529542,   4143317495, 235803164,
+            1633788866, 892690282,  1465383342, 3115962473, 2256965911, 3250673817, 488449850,  2661202215, 3789633753,
+            4177007595, 2560144171, 286339874,  1768537042, 3654906025, 2391705863, 2492770099, 2610673197, 505291324,
+            2273808917, 3924369609, 3469625735, 1431699370, 673740880,  3755965093, 2358021891, 2711746649, 2307489801,
+            218961690,  3217021541, 3873845719, 1111672452, 1751693520, 1094828930, 2576986153, 757954394,  252645662,
+            2964376443, 1414855848, 3149649517, 370555436};
 
-uint32_t **aes_init_key(uint8_t *key) {
-    uint32_t **k_e = new uint32_t *[15];
+u32 **aes_init_key(u8 *key) {
+    u32 **k_e = new u32 *[15];
     for(int i = 0; i < 15; i++) {
-        k_e[i] = new uint32_t[8];
+        k_e[i] = new u32[8];
         for(int j = 0; j < 8; j++) {
             k_e[i][j] = 0;
         }
     }
 
-    uint32_t tk[8];
+    u32 tk[8];
     for(int i = 0; i < 8; i++) {
         tk[i] = (key[i * 4] << 24) | (key[i * 4 + 1] << 16) | (key[i * 4 + 2] << 8) | (key[i * 4 + 3]);
     }
 
-    uint8_t t = 0;
-    uint8_t j = 0;
+    u8 t = 0;
+    u8 j = 0;
     while(j < 8 && t < 120) {
         k_e[t / 8][t % 8] = tk[j];
         j++;
         t++;
     }
 
-    uint8_t r_con_index = 0;
+    u8 r_con_index = 0;
     while(t < 120) {
-        uint32_t tt = tk[7];
+        u32 tt = tk[7];
         tk[0] = tk[0] ^ (S[(tt >> 16) & 0xFF] << 24) ^ (S[(tt >> 8) & 0xFF] << 16) ^ (S[tt & 0xFF] << 8) ^
                 (S[(tt >> 24) & 0xFF]) ^ (r_con[r_con_index] << 24);
         r_con_index++;
@@ -196,16 +191,16 @@ uint32_t **aes_init_key(uint8_t *key) {
     return k_e;
 }
 
-void aes_free_key(uint32_t **key) {
+void aes_free_key(u32 **key) {
     for(int i = 0; i < 15; i++) {
         delete key[i];
     }
     delete key;
 }
 
-void aes_encrypt_block(uint8_t *in, uint8_t *out, uint32_t **k_e) {
-    uint32_t a[8];
-    uint32_t b[8];
+void aes_encrypt_block(u8 *in, u8 *out, u32 **k_e) {
+    u32 a[8];
+    u32 b[8];
     for(int i = 0; i < 8; i++) {
         b[i] = (in[i * 4] << 24 | in[i * 4 + 1] << 16 | in[i * 4 + 2] << 8 | in[i * 4 + 3]) ^ k_e[0][i];
     }
@@ -222,7 +217,7 @@ void aes_encrypt_block(uint8_t *in, uint8_t *out, uint32_t **k_e) {
     }
 
     for(int i = 0; i < 8; i++) {
-        uint32_t tt = k_e[14][i];
+        u32 tt = k_e[14][i];
         out[i * 4 + 0] = (S[(b[(i + 0) % 8] >> 24) & 0xFF] ^ (tt >> 24)) & 0xFF;
         out[i * 4 + 1] = (S[(b[(i + 1) % 8] >> 16) & 0xFF] ^ (tt >> 16)) & 0xFF;
         out[i * 4 + 2] = (S[(b[(i + 3) % 8] >> 8) & 0xFF] ^ (tt >> 8)) & 0xFF;
@@ -230,20 +225,20 @@ void aes_encrypt_block(uint8_t *in, uint8_t *out, uint32_t **k_e) {
     }
 }
 
-uint8_t *encrypt(const uint8_t *iv, uint8_t *msg, size_t s_msg, size_t *s_out) {
+u8 *encrypt(const u8 *iv, u8 *msg, size_t s_msg, size_t *s_out) {
     auto key_str = UString::format("osu!-scoreburgr---------%d", OSU_VERSION_DATEONLY);
-    uint32_t **key = aes_init_key((uint8_t *)key_str.toUtf8());
+    u32 **key = aes_init_key((u8 *)key_str.toUtf8());
 
     int bytes_encrypted = 0;
     int bytes_to_encrypt = s_msg;
-    uint8_t padding = (32 - (bytes_to_encrypt % 32));
+    u8 padding = (32 - (bytes_to_encrypt % 32));
 
     *s_out = bytes_to_encrypt + padding;
-    uint8_t *out = new uint8_t[*s_out];
+    u8 *out = new u8[*s_out];
 
     int keep_going = 1;
     while(keep_going) {
-        uint8_t block[32] = {0};
+        u8 block[32] = {0};
 
         int nb = bytes_to_encrypt > 32 ? 32 : bytes_to_encrypt;
         memcpy(block, msg, nb);

+ 1 - 1
src/App/Osu/BanchoAes.h

@@ -1,4 +1,4 @@
 #pragma once
 #include <stdint.h>
 
-uint8_t *encrypt(const uint8_t *iv, uint8_t *msg, size_t s_msg, size_t *s_out);
+u8 *encrypt(const u8 *iv, u8 *msg, size_t s_msg, size_t *s_out);

+ 1 - 1
src/App/Osu/BanchoLeaderboard.cpp

@@ -127,7 +127,7 @@ void fetch_online_scores(DatabaseBeatmap *beatmap) {
     request.type = GET_MAP_LEADERBOARD;
     request.path = path;
     request.mime = NULL;
-    request.extra = (uint8_t *)strdup(beatmap->getMD5Hash().hash);
+    request.extra = (u8 *)strdup(beatmap->getMD5Hash().hash);
 
     send_api_request(request);
 }

+ 2 - 2
src/App/Osu/BanchoLeaderboard.h

@@ -5,8 +5,8 @@
 struct OnlineMapInfo {
     long ranked_status;
     bool server_has_osz2;
-    uint32_t beatmap_id;
-    uint32_t beatmap_set_id;
+    u32 beatmap_id;
+    u32 beatmap_set_id;
     int nb_scores;
 };
 

+ 19 - 19
src/App/Osu/BanchoNetworking.cpp

@@ -51,9 +51,9 @@ void disconnect() {
     // This is a blocking call, but we *do* want this to block when quitting the game.
     if(bancho.is_online()) {
         Packet packet;
-        write_short(&packet, LOGOUT);
-        write_byte(&packet, 0);
-        write_int32(&packet, 0);
+        write_u16(&packet, LOGOUT);
+        write_u8(&packet, 0);
+        write_u32(&packet, 0);
 
         CURL *curl = curl_easy_init();
         auto version_header = UString::format("x-mcosu-ver: %s", bancho.neosu_version.toUtf8());
@@ -136,7 +136,7 @@ void reconnect() {
     }
 
     const char *pw = cv_password.toUtf8();  // cv_password needs to stay in scope!
-    bancho.pw_md5 = md5((uint8_t *)pw, strlen(pw));
+    bancho.pw_md5 = md5((u8 *)pw, strlen(pw));
 
     bancho.username = convar->getConVarByName("name")->getString();
     bancho.endpoint = convar->getConVarByName("mp_server")->getString();
@@ -155,7 +155,7 @@ size_t curl_write(void *contents, size_t size, size_t nmemb, void *userp) {
     size_t realsize = size * nmemb;
     Packet *mem = (Packet *)userp;
 
-    uint8_t *ptr = (uint8_t *)realloc(mem->memory, mem->size + realsize + 1);
+    u8 *ptr = (u8 *)realloc(mem->memory, mem->size + realsize + 1);
     if(!ptr) {
         /* out of memory! */
         debugLog("not enough memory (realloc returned NULL)\n");
@@ -177,7 +177,7 @@ static void send_api_request(CURL *curl, APIRequest api_out) {
     response.id = api_out.type;
     response.extra = api_out.extra;
     response.extra_int = api_out.extra_int;
-    response.memory = (uint8_t *)malloc(2048);
+    response.memory = (u8 *)malloc(2048);
 
     struct curl_slist *chunk = NULL;
     auto query_url = UString::format("https://osu.%s%s", bancho.endpoint.toUtf8(), api_out.path.toUtf8());
@@ -213,7 +213,7 @@ static void send_api_request(CURL *curl, APIRequest api_out) {
 
 static void send_bancho_packet(CURL *curl, Packet outgoing) {
     Packet response;
-    response.memory = (uint8_t *)malloc(2048);
+    response.memory = (u8 *)malloc(2048);
 
     struct curl_slist *chunk = NULL;
     auto version_header = UString::format("x-mcosu-ver: %s", bancho.neosu_version.toUtf8());
@@ -276,9 +276,9 @@ static void send_bancho_packet(CURL *curl, Packet outgoing) {
     }
 
     while(response.pos < response.size) {
-        uint16_t packet_id = read_short(&response);
+        u16 packet_id = read_u16(&response);
         response.pos++;
-        uint32_t packet_len = read_int32(&response);
+        u32 packet_len = read_u32(&response);
         if(packet_len > 10485760) {
             debugLog("Received a packet over 10Mb! Dropping response.\n");
             goto end;
@@ -286,7 +286,7 @@ static void send_bancho_packet(CURL *curl, Packet outgoing) {
 
         Packet incoming = {
             .id = packet_id,
-            .memory = (uint8_t *)malloc(packet_len),
+            .memory = (u8 *)malloc(packet_len),
             .size = packet_len,
             .pos = 0,
         };
@@ -345,9 +345,9 @@ static void *do_networking(void *data) {
             free(login.memory);
             pthread_mutex_lock(&outgoing_mutex);
         } else if(should_ping && outgoing.pos == 0) {
-            write_short(&outgoing, PING);
-            write_byte(&outgoing, 0);
-            write_int32(&outgoing, 0);
+            write_u16(&outgoing, PING);
+            write_u8(&outgoing, 0);
+            write_u32(&outgoing, 0);
 
             // Polling gets slower over time, but resets when we receive new data
             if(seconds_between_pings < 30.0) {
@@ -362,9 +362,9 @@ static void *do_networking(void *data) {
 
             // DEBUG: If we're not sending the right amount of bytes, bancho.py just
             // chugs along! To try to detect it faster, we'll send two packets per request.
-            write_short(&out, PING);
-            write_byte(&out, 0);
-            write_int32(&out, 0);
+            write_u16(&out, PING);
+            write_u8(&out, 0);
+            write_u32(&out, 0);
 
             send_bancho_packet(curl, out);
             free(out.memory);
@@ -497,9 +497,9 @@ void send_packet(Packet &packet) {
 
     // We're not sending it immediately, instead we just add it to the pile of
     // packets to send
-    write_short(&outgoing, packet.id);
-    write_byte(&outgoing, 0);
-    write_int32(&outgoing, packet.pos);
+    write_u16(&outgoing, packet.id);
+    write_u8(&outgoing, 0);
+    write_u32(&outgoing, packet.pos);
     write_bytes(&outgoing, packet.memory, packet.pos);
 
     pthread_mutex_unlock(&outgoing_mutex);

+ 4 - 4
src/App/Osu/BanchoNetworking.h

@@ -29,15 +29,15 @@ struct APIRequest {
     APIRequestType type;
     UString path = "";
     curl_mime *mime = NULL;
-    uint8_t *extra = nullptr;
-    uint32_t extra_int = 0;  // lazy
+    u8 *extra = nullptr;
+    u32 extra_int = 0;  // lazy
 };
 
 struct ReplayExtraInfo {
     MD5Hash diff2_md5;
-    int32_t mod_flags;
+    i32 mod_flags;
     UString username;
-    int32_t player_id;
+    i32 player_id;
 };
 
 void disconnect();

+ 81 - 81
src/App/Osu/BanchoProtocol.cpp

@@ -10,13 +10,13 @@ Room::Room() {
 }
 
 Room::Room(Packet *packet) {
-    id = read_short(packet);
-    in_progress = read_byte(packet);
-    match_type = read_byte(packet);
-    mods = read_int32(packet);
+    id = read_u16(packet);
+    in_progress = read_u8(packet);
+    match_type = read_u8(packet);
+    mods = read_u32(packet);
     name = read_string(packet);
 
-    has_password = read_byte(packet) > 0;
+    has_password = read_u8(packet) > 0;
     if(has_password) {
         // Discard password. It should be an empty string, but just in case, read it properly.
         packet->pos--;
@@ -24,17 +24,17 @@ Room::Room(Packet *packet) {
     }
 
     map_name = read_string(packet);
-    map_id = read_int32(packet);
+    map_id = read_u32(packet);
 
     auto hash_str = read_string(packet);
     map_md5 = hash_str.toUtf8();
 
     nb_players = 0;
     for(int i = 0; i < 16; i++) {
-        slots[i].status = read_byte(packet);
+        slots[i].status = read_u8(packet);
     }
     for(int i = 0; i < 16; i++) {
-        slots[i].team = read_byte(packet);
+        slots[i].team = read_u8(packet);
     }
     for(int s = 0; s < 16; s++) {
         if(!slots[s].is_locked()) {
@@ -42,64 +42,64 @@ Room::Room(Packet *packet) {
         }
 
         if(slots[s].has_player()) {
-            slots[s].player_id = read_int32(packet);
+            slots[s].player_id = read_u32(packet);
             nb_players++;
         }
     }
 
-    host_id = read_int32(packet);
-    mode = read_byte(packet);
-    win_condition = read_byte(packet);
-    team_type = read_byte(packet);
-    freemods = read_byte(packet);
+    host_id = read_u32(packet);
+    mode = read_u8(packet);
+    win_condition = read_u8(packet);
+    team_type = read_u8(packet);
+    freemods = read_u8(packet);
     if(freemods) {
         for(int i = 0; i < 16; i++) {
-            slots[i].mods = read_int32(packet);
+            slots[i].mods = read_u32(packet);
         }
     }
 
-    seed = read_int32(packet);
+    seed = read_u32(packet);
 }
 
 void Room::pack(Packet *packet) {
-    write_short(packet, id);
-    write_byte(packet, in_progress);
-    write_byte(packet, match_type);
-    write_int32(packet, mods);
+    write_u16(packet, id);
+    write_u8(packet, in_progress);
+    write_u8(packet, match_type);
+    write_u32(packet, mods);
     write_string(packet, name.toUtf8());
     write_string(packet, password.toUtf8());
     write_string(packet, map_name.toUtf8());
-    write_int32(packet, map_id);
+    write_u32(packet, map_id);
     write_string(packet, map_md5.toUtf8());
     for(int i = 0; i < 16; i++) {
-        write_byte(packet, slots[i].status);
+        write_u8(packet, slots[i].status);
     }
     for(int i = 0; i < 16; i++) {
-        write_byte(packet, slots[i].team);
+        write_u8(packet, slots[i].team);
     }
     for(int s = 0; s < 16; s++) {
         if(slots[s].has_player()) {
-            write_int32(packet, slots[s].player_id);
+            write_u32(packet, slots[s].player_id);
         }
     }
 
-    write_int32(packet, host_id);
-    write_byte(packet, mode);
-    write_byte(packet, win_condition);
-    write_byte(packet, team_type);
-    write_byte(packet, freemods);
+    write_u32(packet, host_id);
+    write_u8(packet, mode);
+    write_u8(packet, win_condition);
+    write_u8(packet, team_type);
+    write_u8(packet, freemods);
     if(freemods) {
         for(int i = 0; i < 16; i++) {
-            write_int32(packet, slots[i].mods);
+            write_u32(packet, slots[i].mods);
         }
     }
 
-    write_int32(packet, seed);
+    write_u32(packet, seed);
 }
 
 bool Room::is_host() { return host_id == bancho.user_id; }
 
-void read_bytes(Packet *packet, uint8_t *bytes, size_t n) {
+void read_bytes(Packet *packet, u8 *bytes, size_t n) {
     if(packet->pos + n > packet->size) {
         packet->pos = packet->size + 1;
         return;
@@ -108,37 +108,37 @@ void read_bytes(Packet *packet, uint8_t *bytes, size_t n) {
     packet->pos += n;
 }
 
-uint8_t read_byte(Packet *packet) {
-    uint8_t byte = 0;
+u8 read_u8(Packet *packet) {
+    u8 byte = 0;
     read_bytes(packet, &byte, 1);
     return byte;
 }
 
-uint16_t read_short(Packet *packet) {
-    uint16_t s = 0;
-    read_bytes(packet, (uint8_t *)&s, 2);
+u16 read_u16(Packet *packet) {
+    u16 s = 0;
+    read_bytes(packet, (u8 *)&s, 2);
     return s;
 }
 
-uint32_t read_int32(Packet *packet) {
-    uint32_t i = 0;
-    read_bytes(packet, (uint8_t *)&i, 4);
+u32 read_u32(Packet *packet) {
+    u32 i = 0;
+    read_bytes(packet, (u8 *)&i, 4);
     return i;
 }
 
-uint64_t read_int64(Packet *packet) {
-    uint64_t i = 0;
-    read_bytes(packet, (uint8_t *)&i, 8);
+u64 read_u64(Packet *packet) {
+    u64 i = 0;
+    read_bytes(packet, (u8 *)&i, 8);
     return i;
 }
 
-uint32_t read_uleb128(Packet *packet) {
-    uint32_t result = 0;
-    uint32_t shift = 0;
-    uint8_t byte = 0;
+u32 read_uleb128(Packet *packet) {
+    u32 result = 0;
+    u32 shift = 0;
+    u8 byte = 0;
 
     do {
-        byte = read_byte(packet);
+        byte = read_u8(packet);
         result |= (byte & 0x7f) << shift;
         shift += 7;
     } while(byte & 0x80);
@@ -146,24 +146,24 @@ uint32_t read_uleb128(Packet *packet) {
     return result;
 }
 
-float read_float32(Packet *packet) {
+float read_f32(Packet *packet) {
     float f = 0;
-    read_bytes(packet, (uint8_t *)&f, 4);
+    read_bytes(packet, (u8 *)&f, 4);
     return f;
 }
 
-double read_float64(Packet *packet) {
+double read_f64(Packet *packet) {
     double f = 0;
-    read_bytes(packet, (uint8_t *)&f, 8);
+    read_bytes(packet, (u8 *)&f, 8);
     return f;
 }
 
 UString read_string(Packet *packet) {
-    uint8_t empty_check = read_byte(packet);
+    u8 empty_check = read_u8(packet);
     if(empty_check == 0) return UString("");
 
-    uint32_t len = read_uleb128(packet);
-    uint8_t *str = new uint8_t[len + 1];
+    u32 len = read_uleb128(packet);
+    u8 *str = new u8[len + 1];
     read_bytes(packet, str, len);
     str[len] = '\0';
 
@@ -174,11 +174,11 @@ UString read_string(Packet *packet) {
 }
 
 std::string read_stdstring(Packet *packet) {
-    uint8_t empty_check = read_byte(packet);
+    u8 empty_check = read_u8(packet);
     if(empty_check == 0) return std::string();
 
-    uint32_t len = read_uleb128(packet);
-    uint8_t *str = new uint8_t[len + 1];
+    u32 len = read_uleb128(packet);
+    u8 *str = new u8[len + 1];
     read_bytes(packet, str, len);
 
     std::string str_out((const char *)str, len);
@@ -190,30 +190,30 @@ std::string read_stdstring(Packet *packet) {
 MD5Hash read_hash(Packet *packet) {
     MD5Hash hash;
 
-    uint8_t empty_check = read_byte(packet);
+    u8 empty_check = read_u8(packet);
     if(empty_check == 0) return hash;
 
-    uint32_t len = read_uleb128(packet);
+    u32 len = read_uleb128(packet);
     if(len > 32) {
         len = 32;
     }
 
-    read_bytes(packet, (uint8_t *)hash.hash, len);
+    read_bytes(packet, (u8 *)hash.hash, len);
     hash.hash[len] = '\0';
     return hash;
 }
 
 void skip_string(Packet *packet) {
-    uint8_t empty_check = read_byte(packet);
+    u8 empty_check = read_u8(packet);
     if(empty_check == 0) {
         return;
     }
 
-    uint32_t len = read_uleb128(packet);
+    u32 len = read_uleb128(packet);
     packet->pos += len;
 }
 
-void write_bytes(Packet *packet, uint8_t *bytes, size_t n) {
+void write_bytes(Packet *packet, u8 *bytes, size_t n) {
     if(packet->pos + n > packet->size) {
         packet->memory = (unsigned char *)realloc(packet->memory, packet->size + n + 128);
         packet->size += n + 128;
@@ -224,46 +224,46 @@ void write_bytes(Packet *packet, uint8_t *bytes, size_t n) {
     packet->pos += n;
 }
 
-void write_byte(Packet *packet, uint8_t b) { write_bytes(packet, &b, 1); }
+void write_u8(Packet *packet, u8 b) { write_bytes(packet, &b, 1); }
 
-void write_short(Packet *packet, uint16_t s) { write_bytes(packet, (uint8_t *)&s, 2); }
+void write_u16(Packet *packet, u16 s) { write_bytes(packet, (u8 *)&s, 2); }
 
-void write_int32(Packet *packet, uint32_t i) { write_bytes(packet, (uint8_t *)&i, 4); }
+void write_u32(Packet *packet, u32 i) { write_bytes(packet, (u8 *)&i, 4); }
 
-void write_int64(Packet *packet, uint64_t i) { write_bytes(packet, (uint8_t *)&i, 8); }
+void write_u64(Packet *packet, u64 i) { write_bytes(packet, (u8 *)&i, 8); }
 
-void write_uleb128(Packet *packet, uint32_t num) {
+void write_uleb128(Packet *packet, u32 num) {
     if(num == 0) {
-        uint8_t zero = 0;
-        write_byte(packet, zero);
+        u8 zero = 0;
+        write_u8(packet, zero);
         return;
     }
 
     while(num != 0) {
-        uint8_t next = num & 0x7F;
+        u8 next = num & 0x7F;
         num >>= 7;
         if(num != 0) {
             next |= 0x80;
         }
-        write_byte(packet, next);
+        write_u8(packet, next);
     }
 }
 
-void write_float32(Packet *packet, float f) { write_bytes(packet, (uint8_t *)&f, 4); }
+void write_f32(Packet *packet, float f) { write_bytes(packet, (u8 *)&f, 4); }
 
-void write_float64(Packet *packet, double f) { write_bytes(packet, (uint8_t *)&f, 8); }
+void write_f64(Packet *packet, double f) { write_bytes(packet, (u8 *)&f, 8); }
 
 void write_string(Packet *packet, const char *str) {
     if(!str || str[0] == '\0') {
-        uint8_t zero = 0;
-        write_byte(packet, zero);
+        u8 zero = 0;
+        write_u8(packet, zero);
         return;
     }
 
-    uint8_t empty_check = 11;
-    write_byte(packet, empty_check);
+    u8 empty_check = 11;
+    write_u8(packet, empty_check);
 
-    uint32_t len = strlen(str);
+    u32 len = strlen(str);
     write_uleb128(packet, len);
-    write_bytes(packet, (uint8_t *)str, len);
+    write_bytes(packet, (u8 *)str, len);
 }

+ 51 - 53
src/App/Osu/BanchoProtocol.h

@@ -1,8 +1,6 @@
 #pragma once
-#include <stddef.h>
-#include <stdint.h>
-
 #include "UString.h"
+#include "types.h"
 
 enum Action {
     IDLE = 0,
@@ -137,20 +135,20 @@ enum OutgoingPackets {
 };
 
 struct Packet {
-    uint16_t id = 0;
-    uint8_t *memory = nullptr;
+    u16 id = 0;
+    u8 *memory = nullptr;
     size_t size = 0;
     size_t pos = 0;
-    uint8_t *extra = nullptr;
-    uint32_t extra_int = 0;  // lazy
+    u8 *extra = nullptr;
+    u32 extra_int = 0;  // lazy
 };
 
 struct Slot {
     // From ROOM_CREATED, ROOM_UPDATED
-    uint8_t status = 0;  // bitfield of [quit, complete, playing, no_map, ready, not_ready, locked, open]
-    uint8_t team = 0;
-    uint32_t player_id = 0;
-    uint32_t mods = 0;
+    u8 status = 0;  // bitfield of [quit, complete, playing, no_map, ready, not_ready, locked, open]
+    u8 team = 0;
+    u32 player_id = 0;
+    u32 mods = 0;
 
     // From MATCH_PLAYER_SKIPPED
     bool skipped = false;
@@ -159,19 +157,19 @@ struct Slot {
     bool died = false;
 
     // From MATCH_SCORE_UPDATED
-    int32_t last_update_tms = 0;
-    uint16_t num300 = 0;
-    uint16_t num100 = 0;
-    uint16_t num50 = 0;
-    uint16_t num_geki = 0;
-    uint16_t num_katu = 0;
-    uint16_t num_miss = 0;
-    int32_t total_score = 0;
-    uint16_t current_combo = 0;
-    uint16_t max_combo = 0;
-    uint8_t is_perfect = 0;
-    uint8_t current_hp = 0;
-    uint8_t tag = 0;
+    i32 last_update_tms = 0;
+    u16 num300 = 0;
+    u16 num100 = 0;
+    u16 num50 = 0;
+    u16 num_geki = 0;
+    u16 num_katu = 0;
+    u16 num_miss = 0;
+    i32 total_score = 0;
+    u16 current_combo = 0;
+    u16 max_combo = 0;
+    u8 is_perfect = 0;
+    u8 current_hp = 0;
+    u8 tag = 0;
     double sv2_combo = 0.0;
     double sv2_bonus = 0.0;
 
@@ -203,11 +201,11 @@ class Room {
     Room();
     Room(Packet *packet);
 
-    uint16_t id = 0;
-    uint8_t in_progress = 0;
-    uint8_t match_type = 0;
-    uint32_t mods = 0;
-    uint32_t seed = 0;
+    u16 id = 0;
+    u8 in_progress = 0;
+    u8 match_type = 0;
+    u32 mods = 0;
+    u32 seed = 0;
     bool all_players_loaded = false;
     bool all_players_skipped = false;
     bool player_loaded = false;
@@ -218,16 +216,16 @@ class Room {
 
     UString map_name = "";
     MD5Hash map_md5;
-    int32_t map_id = 0;
+    i32 map_id = 0;
 
-    uint8_t mode = 0;
-    uint8_t win_condition = 0;
-    uint8_t team_type = 0;
-    uint8_t freemods = 0;
+    u8 mode = 0;
+    u8 win_condition = 0;
+    u8 team_type = 0;
+    u8 freemods = 0;
 
-    int32_t host_id = 0;
-    uint8_t nb_players = 0;
-    uint8_t nb_open_slots = 0;
+    i32 host_id = 0;
+    u8 nb_players = 0;
+    u8 nb_open_slots = 0;
     Slot slots[16];
 
     bool all_players_ready() {
@@ -243,25 +241,25 @@ class Room {
     void pack(Packet *packet);
 };
 
-void read_bytes(Packet *packet, uint8_t *bytes, size_t n);
-uint8_t read_byte(Packet *packet);
-uint16_t read_short(Packet *packet);
-uint32_t read_int32(Packet *packet);
-uint64_t read_int64(Packet *packet);
-uint32_t read_uleb128(Packet *packet);
-float read_float32(Packet *packet);
-double read_float64(Packet *packet);
+void read_bytes(Packet *packet, u8 *bytes, size_t n);
+u8 read_u8(Packet *packet);
+u16 read_u16(Packet *packet);
+u32 read_u32(Packet *packet);
+u64 read_u64(Packet *packet);
+f32 read_f32(Packet *packet);
+f64 read_f64(Packet *packet);
+u32 read_uleb128(Packet *packet);
 UString read_string(Packet *packet);
 std::string read_stdstring(Packet *packet);
 void skip_string(Packet *packet);
 MD5Hash read_hash(Packet *packet);
 
-void write_bytes(Packet *packet, uint8_t *bytes, size_t n);
-void write_byte(Packet *packet, uint8_t b);
-void write_short(Packet *packet, uint16_t s);
-void write_int32(Packet *packet, uint32_t i);
-void write_int64(Packet *packet, uint64_t i);
-void write_uleb128(Packet *packet, uint32_t num);
-void write_float32(Packet *packet, float f);
-void write_float64(Packet *packet, double f);
+void write_bytes(Packet *packet, u8 *bytes, size_t n);
+void write_u8(Packet *packet, u8 b);
+void write_u16(Packet *packet, u16 s);
+void write_u32(Packet *packet, u32 i);
+void write_u64(Packet *packet, u64 i);
+void write_f32(Packet *packet, f32 f);
+void write_f64(Packet *packet, f64 f);
+void write_uleb128(Packet *packet, u32 num);
 void write_string(Packet *packet, const char *str);

+ 7 - 7
src/App/Osu/BanchoSubmitter.cpp

@@ -22,13 +22,13 @@ void submit_score(FinishedScore score) {
     if(!bancho.set_fposu_flag) score.modsLegacy &= ~ModFlags::FPoSu;
     if(!bancho.set_mirror_flag) score.modsLegacy &= ~ModFlags::Mirror;
 
-    uint8_t *compressed_data = NULL;
+    u8 *compressed_data = NULL;
 
     char score_time[80];
     struct tm *timeinfo = localtime((const time_t *)&score.unixTimestamp);
     strftime(score_time, sizeof(score_time), "%y%m%d%H%M%S", timeinfo);
 
-    uint8_t iv[32];
+    u8 iv[32];
 #ifdef _WIN32
     HCRYPTPROV hCryptProv;
     CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
@@ -108,8 +108,8 @@ void submit_score(FinishedScore score) {
     }
     {
         size_t s_client_hashes_encrypted = 0;
-        uint8_t *client_hashes_encrypted = encrypt(iv, (uint8_t *)bancho.client_hashes.toUtf8(),
-                                                   bancho.client_hashes.lengthUtf8(), &s_client_hashes_encrypted);
+        u8 *client_hashes_encrypted = encrypt(iv, (u8 *)bancho.client_hashes.toUtf8(),
+                                              bancho.client_hashes.lengthUtf8(), &s_client_hashes_encrypted);
         const char *client_hashes_b64 =
             (const char *)base64_encode(client_hashes_encrypted, s_client_hashes_encrypted, NULL);
         part = curl_mime_addpart(request.mime);
@@ -133,7 +133,7 @@ void submit_score(FinishedScore score) {
             idiot_check.append(UString::format("0%d%s", OSU_VERSION_DATEONLY, score_time));
             idiot_check.append(bancho.client_hashes);
 
-            auto idiot_hash = md5((uint8_t *)idiot_check.toUtf8(), idiot_check.lengthUtf8());
+            auto idiot_hash = md5((u8 *)idiot_check.toUtf8(), idiot_check.lengthUtf8());
             score_data.append(":");
             score_data.append(idiot_hash.hash);
         }
@@ -154,8 +154,8 @@ void submit_score(FinishedScore score) {
         score_data.append(":mcosu");  // anticheat flags
 
         size_t s_score_data_encrypted = 0;
-        uint8_t *score_data_encrypted =
-            encrypt(iv, (uint8_t *)score_data.toUtf8(), score_data.lengthUtf8(), &s_score_data_encrypted);
+        u8 *score_data_encrypted =
+            encrypt(iv, (u8 *)score_data.toUtf8(), score_data.lengthUtf8(), &s_score_data_encrypted);
         const char *score_data_b64 = (const char *)base64_encode(score_data_encrypted, s_score_data_encrypted, NULL);
 
         part = curl_mime_addpart(request.mime);

+ 3 - 3
src/App/Osu/BanchoUsers.cpp

@@ -1,9 +1,9 @@
 #include "BanchoUsers.h"
 
-std::unordered_map<uint32_t, UserInfo*> online_users;
-std::vector<uint32_t> friends;
+std::unordered_map<u32, UserInfo*> online_users;
+std::vector<u32> friends;
 
-UserInfo* get_user_info(uint32_t user_id, bool fetch) {
+UserInfo* get_user_info(u32 user_id, bool fetch) {
     auto it = online_users.find(user_id);
     if(it != online_users.end()) {
         return it->second;

+ 14 - 14
src/App/Osu/BanchoUsers.h

@@ -5,34 +5,34 @@
 #include "UString.h"
 
 struct UserInfo {
-    uint32_t user_id = 0;
+    u32 user_id = 0;
 
     // Presence (via USER_PRESENCE_REQUEST or USER_PRESENCE_REQUEST_ALL)
     UString name;
-    uint8_t utc_offset = 0;
-    uint8_t country = 0;
-    uint8_t privileges = 0;
+    u8 utc_offset = 0;
+    u8 country = 0;
+    u8 privileges = 0;
     float longitude = 0.f;
     float latitude = 0.f;
-    int32_t global_rank = 0;
+    i32 global_rank = 0;
 
     // Stats (via USER_STATS_REQUEST)
     Action action = UNKNOWN;
     GameMode mode = STANDARD;
     UString info_text = UString("Loading...");
     UString map_md5;
-    int32_t map_id = 0;
-    uint32_t mods = 0;
-    int64_t total_score = 0;
-    int64_t ranked_score = 0;
-    int32_t plays = 0;
-    uint16_t pp = 0.f;
+    i32 map_id = 0;
+    u32 mods = 0;
+    i64 total_score = 0;
+    i64 ranked_score = 0;
+    i32 plays = 0;
+    u16 pp = 0.f;
     float accuracy = 0.f;
 
     bool is_friend();
 };
 
-extern std::unordered_map<uint32_t, UserInfo*> online_users;
-extern std::vector<uint32_t> friends;
+extern std::unordered_map<u32, UserInfo*> online_users;
+extern std::vector<u32> friends;
 
-UserInfo* get_user_info(uint32_t user_id, bool fetch = false);
+UserInfo* get_user_info(u32 user_id, bool fetch = false);

+ 2 - 2
src/App/Osu/Beatmap.h

@@ -188,8 +188,8 @@ class Beatmap {
     std::vector<Replay::Frame> live_replay;
     double last_event_time = 0.0;
     long last_event_ms = 0;
-    uint8_t current_keys = 0;
-    uint8_t last_keys = 0;
+    u8 current_keys = 0;
+    u8 last_keys = 0;
 
     // replay replaying
     // current_keys, last_keys also reused

+ 1 - 1
src/App/Osu/Chat.cpp

@@ -243,7 +243,7 @@ void Chat::onKeyDown(KeyboardEvent &key) {
             write_string(&packet, (char *)bancho.username.toUtf8());
             write_string(&packet, (char *)m_input_box->getText().toUtf8());
             write_string(&packet, (char *)m_selected_channel->name.toUtf8());
-            write_int32(&packet, bancho.user_id);
+            write_u32(&packet, bancho.user_id);
             send_packet(packet);
 
             // Server doesn't echo the message back

+ 1 - 1
src/App/Osu/Chat.h

@@ -11,7 +11,7 @@ class UIButton;
 
 struct ChatMessage {
     time_t tms;
-    int32_t author_id;
+    i32 author_id;
     UString author_name;
     UString text;
 };

+ 15 - 15
src/App/Osu/Collections.cpp

@@ -100,8 +100,8 @@ bool load_collections() {
     peppy_collections_path.append("collection.db");
     Packet peppy_collections = load_db(peppy_collections_path);
     if(peppy_collections.size > 0) {
-        uint32_t version = read_int32(&peppy_collections);
-        uint32_t nb_collections = read_int32(&peppy_collections);
+        u32 version = read_u32(&peppy_collections);
+        u32 nb_collections = read_u32(&peppy_collections);
 
         if(version > osu_database_version) {
             debugLog("osu!stable collection.db version more recent than neosu, loading might fail.\n");
@@ -109,7 +109,7 @@ bool load_collections() {
 
         for(int c = 0; c < nb_collections; c++) {
             auto name = read_stdstring(&peppy_collections);
-            uint32_t nb_maps = read_int32(&peppy_collections);
+            u32 nb_maps = read_u32(&peppy_collections);
 
             auto collection = get_or_create_collection(name);
             collection->maps.reserve(nb_maps);
@@ -126,8 +126,8 @@ bool load_collections() {
 
     auto neosu_collections = load_db("collections.db");
     if(neosu_collections.size > 0) {
-        uint32_t version = read_int32(&neosu_collections);
-        uint32_t nb_collections = read_int32(&neosu_collections);
+        u32 version = read_u32(&neosu_collections);
+        u32 nb_collections = read_u32(&neosu_collections);
 
         if(version > COLLECTIONS_DB_VERSION) {
             debugLog("neosu collections.db version is too recent! Cannot load it without stuff breaking.\n");
@@ -140,9 +140,9 @@ bool load_collections() {
             auto name = read_stdstring(&neosu_collections);
             auto collection = get_or_create_collection(name);
 
-            uint32_t nb_deleted_maps = 0;
+            u32 nb_deleted_maps = 0;
             if(version >= 20240429) {
-                nb_deleted_maps = read_int32(&neosu_collections);
+                nb_deleted_maps = read_u32(&neosu_collections);
             }
 
             collection->deleted_maps.reserve(nb_deleted_maps);
@@ -157,7 +157,7 @@ bool load_collections() {
                 collection->deleted_maps.push_back(map_hash);
             }
 
-            uint32_t nb_maps = read_int32(&neosu_collections);
+            u32 nb_maps = read_u32(&neosu_collections);
             collection->maps.reserve(collection->maps.size() + nb_maps);
             collection->neosu_maps.reserve(nb_maps);
 
@@ -198,22 +198,22 @@ bool save_collections() {
     const double startTime = engine->getTimeReal();
 
     Packet db;
-    write_int32(&db, COLLECTIONS_DB_VERSION);
+    write_u32(&db, COLLECTIONS_DB_VERSION);
 
-    uint32_t nb_collections = collections.size();
-    write_int32(&db, nb_collections);
+    u32 nb_collections = collections.size();
+    write_u32(&db, nb_collections);
 
     for(auto collection : collections) {
         write_string(&db, collection->name.c_str());
 
-        uint32_t nb_deleted = collection->deleted_maps.size();
-        write_int32(&db, nb_deleted);
+        u32 nb_deleted = collection->deleted_maps.size();
+        write_u32(&db, nb_deleted);
         for(auto map : collection->deleted_maps) {
             write_string(&db, map.hash);
         }
 
-        uint32_t nb_neosu = collection->neosu_maps.size();
-        write_int32(&db, nb_neosu);
+        u32 nb_neosu = collection->neosu_maps.size();
+        write_u32(&db, nb_neosu);
         for(auto map : collection->neosu_maps) {
             write_string(&db, map.hash);
         }

+ 168 - 168
src/App/Osu/Database.cpp

@@ -71,9 +71,9 @@ ConVar osu_user_switcher_include_legacy_scores_for_names("osu_user_switcher_incl
                                                          FCVAR_NONE);
 
 TIMINGPOINT read_timing_point(Packet *packet) {
-    const double bpm = read_float64(packet);
-    const double offset = read_float64(packet);
-    const bool timingChange = (bool)read_byte(packet);
+    const double bpm = read_f64(packet);
+    const double offset = read_f64(packet);
+    const bool timingChange = (bool)read_u8(packet);
     return (struct TIMINGPOINT){bpm, offset, timingChange};
 }
 
@@ -88,7 +88,7 @@ Packet load_db(std::string path) {
         size_t dblen = ftell(dbfile);
         rewind(dbfile);
 
-        db.memory = (uint8_t *)malloc(dblen);
+        db.memory = (u8 *)malloc(dblen);
         db.size = dblen;
         fread(db.memory, dblen, 1, dbfile);
         fclose(dbfile);
@@ -464,7 +464,7 @@ int Database::addScore(MD5Hash beatmapMD5Hash, FinishedScore score) {
     if(osu_scores_save_immediately.getBool()) saveScores();
 
     // XXX: this is blocking main thread
-    uint8_t *compressed_replay = NULL;
+    u8 *compressed_replay = NULL;
     size_t s_compressed_replay = 0;
     Replay::compress_frames(score.replay, &compressed_replay, &s_compressed_replay);
     if(s_compressed_replay > 0) {
@@ -521,7 +521,7 @@ void Database::addScoreRaw(const MD5Hash &beatmapMD5Hash, const FinishedScore &s
     }
 }
 
-void Database::deleteScore(MD5Hash beatmapMD5Hash, uint64_t scoreUnixTimestamp) {
+void Database::deleteScore(MD5Hash beatmapMD5Hash, u64 scoreUnixTimestamp) {
     for(int i = 0; i < m_scores[beatmapMD5Hash].size(); i++) {
         if(m_scores[beatmapMD5Hash][i].unixTimestamp == scoreUnixTimestamp) {
             m_scores[beatmapMD5Hash].erase(m_scores[beatmapMD5Hash].begin() + i);
@@ -754,13 +754,13 @@ unsigned long long Database::getRequiredScoreForLevel(int level) {
     // https://zxq.co/ripple/ocl/src/branch/master/level.go
     if(level <= 100) {
         if(level > 1)
-            return (uint64_t)std::floor(5000 / 3 * (4 * std::pow(level, 3) - 3 * std::pow(level, 2) - level) +
-                                        std::floor(1.25 * std::pow(1.8, (double)(level - 60))));
+            return (u64)std::floor(5000 / 3 * (4 * std::pow(level, 3) - 3 * std::pow(level, 2) - level) +
+                                   std::floor(1.25 * std::pow(1.8, (double)(level - 60))));
 
         return 1;
     }
 
-    return (uint64_t)26931190829 + (uint64_t)100000000000 * (uint64_t)(level - 100);
+    return (u64)26931190829 + (u64)100000000000 * (u64)(level - 100);
 }
 
 int Database::getLevelForScore(unsigned long long score, int maxLevel) {
@@ -956,12 +956,12 @@ void Database::loadDB(Packet *db, bool &fallbackToRawLoad) {
     m_importTimer->start();
 
     // read header
-    m_iVersion = read_int32(db);
-    m_iFolderCount = read_int32(db);
-    read_byte(db);
-    read_int64(db) /* timestamp */;
+    m_iVersion = read_u32(db);
+    m_iFolderCount = read_u32(db);
+    read_u8(db);
+    read_u64(db) /* timestamp */;
     auto playerName = read_stdstring(db);
-    m_iNumBeatmapsToLoad = read_int32(db);
+    m_iNumBeatmapsToLoad = read_u32(db);
 
     debugLog("Database: version = %i, folderCount = %i, playerName = %s, numDiffs = %i\n", m_iVersion, m_iFolderCount,
              playerName.c_str(), m_iNumBeatmapsToLoad);
@@ -1017,7 +1017,7 @@ void Database::loadDB(Packet *db, bool &fallbackToRawLoad) {
             // no idea why peppy decided to change the wiki version from 20191107 to 20191106, because that's not what
             // stable is doing. the correct version is still 20191107
 
-            /*unsigned int size = */ read_int32(db);  // size in bytes of the beatmap entry
+            /*unsigned int size = */ read_u32(db);  // size in bytes of the beatmap entry
         }
 
         std::string artistName = read_stdstring(db);
@@ -1034,25 +1034,25 @@ void Database::loadDB(Packet *db, bool &fallbackToRawLoad) {
         auto hash_str = read_stdstring(db);
         MD5Hash md5hash = hash_str.c_str();
         std::string osuFileName = read_stdstring(db);
-        /*unsigned char rankedStatus = */ read_byte(db);
-        unsigned short numCircles = read_short(db);
-        unsigned short numSliders = read_short(db);
-        unsigned short numSpinners = read_short(db);
-        long long lastModificationTime = read_int64(db);
-        float AR = read_float32(db);
-        float CS = read_float32(db);
-        float HP = read_float32(db);
-        float OD = read_float32(db);
-        double sliderMultiplier = read_float64(db);
-
-        unsigned int numOsuStandardStarRatings = read_int32(db);
+        /*unsigned char rankedStatus = */ read_u8(db);
+        unsigned short numCircles = read_u16(db);
+        unsigned short numSliders = read_u16(db);
+        unsigned short numSpinners = read_u16(db);
+        long long lastModificationTime = read_u64(db);
+        float AR = read_f32(db);
+        float CS = read_f32(db);
+        float HP = read_f32(db);
+        float OD = read_f32(db);
+        double sliderMultiplier = read_f64(db);
+
+        unsigned int numOsuStandardStarRatings = read_u32(db);
         // debugLog("%i star ratings for osu!standard\n", numOsuStandardStarRatings);
         float numOsuStandardStars = 0.0f;
         for(int s = 0; s < numOsuStandardStarRatings; s++) {
-            read_byte(db);  // ObjType
-            unsigned int mods = read_int32(db);
-            read_byte(db);  // ObjType
-            double starRating = read_float64(db);
+            read_u8(db);  // ObjType
+            unsigned int mods = read_u32(db);
+            read_u8(db);  // ObjType
+            double starRating = read_f64(db);
             // debugLog("%f stars for %u\n", starRating, mods);
 
             if(mods == 0) numOsuStandardStars = starRating;
@@ -1066,63 +1066,63 @@ void Database::loadDB(Packet *db, bool &fallbackToRawLoad) {
             if(result != m_starsCache.end()) numOsuStandardStars = result->second.starsNomod;
         }
 
-        unsigned int numTaikoStarRatings = read_int32(db);
+        unsigned int numTaikoStarRatings = read_u32(db);
         // debugLog("%i star ratings for taiko\n", numTaikoStarRatings);
         for(int s = 0; s < numTaikoStarRatings; s++) {
-            read_byte(db);  // ObjType
-            read_int32(db);
-            read_byte(db);  // ObjType
-            read_float64(db);
+            read_u8(db);  // ObjType
+            read_u32(db);
+            read_u8(db);  // ObjType
+            read_f64(db);
         }
 
-        unsigned int numCtbStarRatings = read_int32(db);
+        unsigned int numCtbStarRatings = read_u32(db);
         // debugLog("%i star ratings for ctb\n", numCtbStarRatings);
         for(int s = 0; s < numCtbStarRatings; s++) {
-            read_byte(db);  // ObjType
-            read_int32(db);
-            read_byte(db);  // ObjType
-            read_float64(db);
+            read_u8(db);  // ObjType
+            read_u32(db);
+            read_u8(db);  // ObjType
+            read_f64(db);
         }
 
-        unsigned int numManiaStarRatings = read_int32(db);
+        unsigned int numManiaStarRatings = read_u32(db);
         // debugLog("%i star ratings for mania\n", numManiaStarRatings);
         for(int s = 0; s < numManiaStarRatings; s++) {
-            read_byte(db);  // ObjType
-            read_int32(db);
-            read_byte(db);  // ObjType
-            read_float64(db);
+            read_u8(db);  // ObjType
+            read_u32(db);
+            read_u8(db);  // ObjType
+            read_f64(db);
         }
 
-        /*unsigned int drainTime = */ read_int32(db);  // seconds
-        int duration = read_int32(db);                 // milliseconds
-        duration = duration >= 0 ? duration : 0;       // sanity clamp
-        int previewTime = read_int32(db);
+        /*unsigned int drainTime = */ read_u32(db);  // seconds
+        int duration = read_u32(db);                 // milliseconds
+        duration = duration >= 0 ? duration : 0;     // sanity clamp
+        int previewTime = read_u32(db);
 
         // debugLog("drainTime = %i sec, duration = %i ms, previewTime = %i ms\n", drainTime, duration, previewTime);
 
-        unsigned int numTimingPoints = read_int32(db);
+        unsigned int numTimingPoints = read_u32(db);
         // debugLog("%i timingpoints\n", numTimingPoints);
         std::vector<TIMINGPOINT> timingPoints;
         for(int t = 0; t < numTimingPoints; t++) {
             timingPoints.push_back(read_timing_point(db));
         }
 
-        int beatmapID = read_int32(db);     // fucking bullshit, this is NOT an unsigned integer as is described on the
-                                            // wiki, it can and is -1 sometimes
-        int beatmapSetID = read_int32(db);  // same here
-        /*unsigned int threadID = */ read_int32(db);
+        int beatmapID = read_u32(db);     // fucking bullshit, this is NOT an unsigned integer as is described on the
+                                          // wiki, it can and is -1 sometimes
+        int beatmapSetID = read_u32(db);  // same here
+        /*unsigned int threadID = */ read_u32(db);
 
-        /*unsigned char osuStandardGrade = */ read_byte(db);
-        /*unsigned char taikoGrade = */ read_byte(db);
-        /*unsigned char ctbGrade = */ read_byte(db);
-        /*unsigned char maniaGrade = */ read_byte(db);
+        /*unsigned char osuStandardGrade = */ read_u8(db);
+        /*unsigned char taikoGrade = */ read_u8(db);
+        /*unsigned char ctbGrade = */ read_u8(db);
+        /*unsigned char maniaGrade = */ read_u8(db);
         // debugLog("beatmapID = %i, beatmapSetID = %i, threadID = %i, osuStandardGrade = %i, taikoGrade = %i, ctbGrade
         // = %i, maniaGrade = %i\n", beatmapID, beatmapSetID, threadID, osuStandardGrade, taikoGrade, ctbGrade,
         // maniaGrade);
 
-        short localOffset = read_short(db);
-        float stackLeniency = read_float32(db);
-        unsigned char mode = read_byte(db);
+        short localOffset = read_u16(db);
+        float stackLeniency = read_f32(db);
+        unsigned char mode = read_u8(db);
         // debugLog("localOffset = %i, stackLeniency = %f, mode = %i\n", localOffset, stackLeniency, mode);
 
         auto songSource = read_stdstring(db);
@@ -1131,29 +1131,29 @@ void Database::loadDB(Packet *db, bool &fallbackToRawLoad) {
         trim(&songTags);
         // debugLog("songSource = %s, songTags = %s\n", songSource.toUtf8(), songTags.toUtf8());
 
-        short onlineOffset = read_short(db);
+        short onlineOffset = read_u16(db);
         skip_string(db);  // song title font
-        /*bool unplayed = */ read_byte(db);
-        /*long long lastTimePlayed = */ read_int64(db);
-        /*bool isOsz2 = */ read_byte(db);
+        /*bool unplayed = */ read_u8(db);
+        /*long long lastTimePlayed = */ read_u64(db);
+        /*bool isOsz2 = */ read_u8(db);
 
         // somehow, some beatmaps may have spaces at the start/end of their
         // path, breaking the Windows API (e.g. https://osu.ppy.sh/s/215347)
         auto path = read_stdstring(db);
         trim(&path);
 
-        /*long long lastOnlineCheck = */ read_int64(db);
+        /*long long lastOnlineCheck = */ read_u64(db);
         // debugLog("onlineOffset = %i, songTitleFont = %s, unplayed = %i, lastTimePlayed = %lu, isOsz2 = %i, path = %s,
         // lastOnlineCheck = %lu\n", onlineOffset, songTitleFont.toUtf8(), (int)unplayed, lastTimePlayed, (int)isOsz2,
         // path.c_str(), lastOnlineCheck);
 
-        /*bool ignoreBeatmapSounds = */ read_byte(db);
-        /*bool ignoreBeatmapSkin = */ read_byte(db);
-        /*bool disableStoryboard = */ read_byte(db);
-        /*bool disableVideo = */ read_byte(db);
-        /*bool visualOverride = */ read_byte(db);
-        /*int lastEditTime = */ read_int32(db);
-        /*unsigned char maniaScrollSpeed = */ read_byte(db);
+        /*bool ignoreBeatmapSounds = */ read_u8(db);
+        /*bool ignoreBeatmapSkin = */ read_u8(db);
+        /*bool disableStoryboard = */ read_u8(db);
+        /*bool disableVideo = */ read_u8(db);
+        /*bool visualOverride = */ read_u8(db);
+        /*int lastEditTime = */ read_u32(db);
+        /*unsigned char maniaScrollSpeed = */ read_u8(db);
         // debugLog("ignoreBeatmapSounds = %i, ignoreBeatmapSkin = %i, disableStoryboard = %i, disableVideo = %i,
         // visualOverride = %i, maniaScrollSpeed = %i\n", (int)ignoreBeatmapSounds, (int)ignoreBeatmapSkin,
         // (int)disableStoryboard, (int)disableVideo, (int)visualOverride, maniaScrollSpeed);
@@ -1501,18 +1501,18 @@ void Database::loadStars() {
     if(cache.size > 0) {
         m_starsCache.clear();
 
-        const int cacheVersion = read_int32(&cache);
+        const int cacheVersion = read_u32(&cache);
 
         if(cacheVersion <= starsCacheVersion) {
             skip_string(&cache);  // ignore md5
-            const int64_t numStarsCacheEntries = read_int64(&cache);
+            const i64 numStarsCacheEntries = read_u64(&cache);
 
             debugLog("Stars cache: version = %i, numStarsCacheEntries = %i\n", cacheVersion, numStarsCacheEntries);
 
-            for(int64_t i = 0; i < numStarsCacheEntries; i++) {
+            for(i64 i = 0; i < numStarsCacheEntries; i++) {
                 auto hash_str = read_stdstring(&cache);
                 const MD5Hash beatmapMD5Hash = hash_str.c_str();
-                const float starsNomod = read_float32(&cache);
+                const float starsNomod = read_f32(&cache);
 
                 STARS_CACHE_ENTRY entry;
                 { entry.starsNomod = starsNomod; }
@@ -1532,7 +1532,7 @@ void Database::saveStars() {
     const int starsCacheVersion = 20221108;
 
     // count
-    int64_t numStarsCacheEntries = 0;
+    i64 numStarsCacheEntries = 0;
     for(DatabaseBeatmap *beatmap : m_databaseBeatmaps) {
         for(DatabaseBeatmap *diff2 : beatmap->getDifficulties()) {
             if(diff2->getStarsNomod() > 0.0f && diff2->getStarsNomod() != 0.0001f) numStarsCacheEntries++;
@@ -1546,14 +1546,14 @@ void Database::saveStars() {
 
     // write
     Packet cache;
-    write_int32(&cache, starsCacheVersion);
+    write_u32(&cache, starsCacheVersion);
     write_string(&cache, "00000000000000000000000000000000");
-    write_int64(&cache, numStarsCacheEntries);
+    write_u64(&cache, numStarsCacheEntries);
     for(DatabaseBeatmap *beatmap : m_databaseBeatmaps) {
         for(DatabaseBeatmap *diff2 : beatmap->getDifficulties()) {
             if(diff2->getStarsNomod() > 0.0f && diff2->getStarsNomod() != 0.0001f) {
                 write_string(&cache, diff2->getMD5Hash().hash);
-                write_float32(&cache, diff2->getStarsNomod());
+                write_f32(&cache, diff2->getStarsNomod());
             }
         }
     }
@@ -1584,14 +1584,14 @@ void Database::loadScores() {
         if(db.size > 0) {
             customScoresFileSize = db.size;
 
-            const uint32_t dbVersion = read_int32(&db);
-            const uint32_t numBeatmaps = read_int32(&db);
+            const u32 dbVersion = read_u32(&db);
+            const u32 numBeatmaps = read_u32(&db);
             debugLog("Custom scores: version = %u, numBeatmaps = %u\n", dbVersion, numBeatmaps);
 
             if(dbVersion <= LiveScore::VERSION) {
                 for(int b = 0; b < numBeatmaps; b++) {
                     auto hash_str = read_stdstring(&db);
-                    const int numScores = read_int32(&db);
+                    const int numScores = read_u32(&db);
 
                     if(hash_str.size() < 32) {
                         if(Osu::debug->getBool()) {
@@ -1617,57 +1617,57 @@ void Database::loadScores() {
                         sc.numCircles = -1;
                         sc.perfect = false;
 
-                        const unsigned char gamemode = read_byte(&db);  // NOTE: abused as isImportedLegacyScore flag
-                        sc.version = read_int32(&db);
+                        const unsigned char gamemode = read_u8(&db);  // NOTE: abused as isImportedLegacyScore flag
+                        sc.version = read_u32(&db);
 
                         if(dbVersion == 20210103 && sc.version > 20190103) {
-                            sc.isImportedLegacyScore = read_byte(&db);
+                            sc.isImportedLegacyScore = read_u8(&db);
                         } else if(dbVersion > 20210103 && sc.version > 20190103) {
                             // HACKHACK: for explanation see hackIsImportedLegacyScoreFlag
                             sc.isImportedLegacyScore = (gamemode & hackIsImportedLegacyScoreFlag);
                         }
 
-                        sc.unixTimestamp = read_int64(&db);
+                        sc.unixTimestamp = read_u64(&db);
 
                         // default
                         sc.playerName = read_stdstring(&db);
 
-                        sc.num300s = read_short(&db);
-                        sc.num100s = read_short(&db);
-                        sc.num50s = read_short(&db);
-                        sc.numGekis = read_short(&db);
-                        sc.numKatus = read_short(&db);
-                        sc.numMisses = read_short(&db);
+                        sc.num300s = read_u16(&db);
+                        sc.num100s = read_u16(&db);
+                        sc.num50s = read_u16(&db);
+                        sc.numGekis = read_u16(&db);
+                        sc.numKatus = read_u16(&db);
+                        sc.numMisses = read_u16(&db);
 
-                        sc.score = read_int64(&db);
-                        sc.comboMax = read_short(&db);
-                        sc.modsLegacy = read_int32(&db);
+                        sc.score = read_u64(&db);
+                        sc.comboMax = read_u16(&db);
+                        sc.modsLegacy = read_u32(&db);
 
                         // custom
-                        sc.numSliderBreaks = read_short(&db);
-                        sc.pp = read_float32(&db);
-                        sc.unstableRate = read_float32(&db);
-                        sc.hitErrorAvgMin = read_float32(&db);
-                        sc.hitErrorAvgMax = read_float32(&db);
-                        sc.starsTomTotal = read_float32(&db);
-                        sc.starsTomAim = read_float32(&db);
-                        sc.starsTomSpeed = read_float32(&db);
-                        sc.speedMultiplier = read_float32(&db);
-                        sc.CS = read_float32(&db);
-                        sc.AR = read_float32(&db);
-                        sc.OD = read_float32(&db);
-                        sc.HP = read_float32(&db);
+                        sc.numSliderBreaks = read_u16(&db);
+                        sc.pp = read_f32(&db);
+                        sc.unstableRate = read_f32(&db);
+                        sc.hitErrorAvgMin = read_f32(&db);
+                        sc.hitErrorAvgMax = read_f32(&db);
+                        sc.starsTomTotal = read_f32(&db);
+                        sc.starsTomAim = read_f32(&db);
+                        sc.starsTomSpeed = read_f32(&db);
+                        sc.speedMultiplier = read_f32(&db);
+                        sc.CS = read_f32(&db);
+                        sc.AR = read_f32(&db);
+                        sc.OD = read_f32(&db);
+                        sc.HP = read_f32(&db);
 
                         if(sc.version > 20180722) {
-                            sc.maxPossibleCombo = read_int32(&db);
-                            sc.numHitObjects = read_int32(&db);
-                            sc.numCircles = read_int32(&db);
+                            sc.maxPossibleCombo = read_u32(&db);
+                            sc.numHitObjects = read_u32(&db);
+                            sc.numCircles = read_u32(&db);
                             sc.perfect = sc.comboMax >= sc.maxPossibleCombo;
                         }
 
                         if(sc.version >= 20240412) {
                             sc.has_replay = true;
-                            sc.online_score_id = read_int32(&db);
+                            sc.online_score_id = read_u32(&db);
                             sc.server = read_stdstring(&db);
                         }
 
@@ -1704,8 +1704,8 @@ void Database::loadScores() {
         // point directly to neosu, which would break legacy score db loading
         // here since there is no magic number)
         if(db.size > 0 && db.size != customScoresFileSize) {
-            const int dbVersion = read_int32(&db);
-            const int numBeatmaps = read_int32(&db);
+            const int dbVersion = read_u32(&db);
+            const int numBeatmaps = read_u32(&db);
 
             debugLog("Legacy scores: version = %i, numBeatmaps = %i\n", dbVersion, numBeatmaps);
 
@@ -1723,7 +1723,7 @@ void Database::loadScores() {
                 }
 
                 const MD5Hash md5hash = hash_str.c_str();
-                const int numScores = read_int32(&db);
+                const int numScores = read_u32(&db);
 
                 if(Osu::debug->getBool())
                     debugLog("Beatmap[%i]: md5hash = %s, numScores = %i\n", b, md5hash.toUtf8(), numScores);
@@ -1750,27 +1750,27 @@ void Database::loadScores() {
                     sc.numHitObjects = -1;
                     sc.numCircles = -1;
 
-                    const unsigned char gamemode = read_byte(&db);
-                    sc.version = read_int32(&db);
+                    const unsigned char gamemode = read_u8(&db);
+                    sc.version = read_u32(&db);
                     skip_string(&db);  // beatmap hash (already have it)
 
                     sc.playerName = read_stdstring(&db);
                     skip_string(&db);  // replay hash (don't use it)
 
-                    sc.num300s = read_short(&db);
-                    sc.num100s = read_short(&db);
-                    sc.num50s = read_short(&db);
-                    sc.numGekis = read_short(&db);
-                    sc.numKatus = read_short(&db);
-                    sc.numMisses = read_short(&db);
+                    sc.num300s = read_u16(&db);
+                    sc.num100s = read_u16(&db);
+                    sc.num50s = read_u16(&db);
+                    sc.numGekis = read_u16(&db);
+                    sc.numKatus = read_u16(&db);
+                    sc.numMisses = read_u16(&db);
 
-                    int32_t score = read_int32(&db);
+                    i32 score = read_u32(&db);
                     sc.score = (score < 0 ? 0 : score);
 
-                    sc.comboMax = read_short(&db);
-                    sc.perfect = read_byte(&db);
+                    sc.comboMax = read_u16(&db);
+                    sc.perfect = read_u8(&db);
 
-                    sc.modsLegacy = read_int32(&db);
+                    sc.modsLegacy = read_u32(&db);
                     sc.speedMultiplier = 1.0f;
                     if(sc.modsLegacy & ModFlags::HalfTime)
                         sc.speedMultiplier = 0.75f;
@@ -1779,12 +1779,12 @@ void Database::loadScores() {
 
                     skip_string(&db);  // hp graph
 
-                    uint64_t full_tms = read_int64(&db);
+                    u64 full_tms = read_u64(&db);
                     sc.unixTimestamp = (full_tms - 621355968000000000) / 10000000;
                     sc.legacyReplayTimestamp = full_tms - 504911232000000000;
 
                     // Always -1, but let's skip it properly just in case
-                    int32_t old_replay_size = read_int32(&db);
+                    i32 old_replay_size = read_u32(&db);
                     if(old_replay_size > 0) {
                         db.pos += old_replay_size;
                     }
@@ -1793,12 +1793,12 @@ void Database::loadScores() {
                     sc.has_replay = true;
 
                     if(sc.version >= 20140721)
-                        sc.online_score_id = read_int64(&db);
+                        sc.online_score_id = read_u64(&db);
                     else if(sc.version >= 20121008)
-                        sc.online_score_id = read_int32(&db);
+                        sc.online_score_id = read_u32(&db);
 
                     if(sc.modsLegacy & ModFlags::Target) /*double totalAccuracy = */
-                        read_float64(&db);
+                        read_f64(&db);
 
                     if(gamemode == 0) {  // gamemode filter (osu!standard)
                         // runtime
@@ -1861,8 +1861,8 @@ void Database::saveScores() {
 
     // write header
     Packet db;
-    write_int32(&db, LiveScore::VERSION);
-    write_int32(&db, numBeatmaps);
+    write_u32(&db, LiveScore::VERSION);
+    write_u32(&db, numBeatmaps);
 
     // write scores for each beatmap
     for(auto &beatmap : m_scores) {
@@ -1874,55 +1874,55 @@ void Database::saveScores() {
         if(numNonLegacyScores == 0) continue;
 
         write_string(&db, beatmap.first.hash);  // beatmap md5 hash
-        write_int32(&db, numNonLegacyScores);   // numScores
+        write_u32(&db, numNonLegacyScores);     // numScores
 
         for(auto &score : beatmap.second) {
             if(score.isLegacyScore) continue;
 
-            uint8_t gamemode = 0;
+            u8 gamemode = 0;
             if(score.version > 20190103 && score.isImportedLegacyScore) gamemode = hackIsImportedLegacyScoreFlag;
-            write_byte(&db, gamemode);
+            write_u8(&db, gamemode);
 
-            write_int32(&db, score.version);
-            write_int64(&db, score.unixTimestamp);
+            write_u32(&db, score.version);
+            write_u64(&db, score.unixTimestamp);
 
             // default
             write_string(&db, score.playerName.c_str());
 
-            write_short(&db, score.num300s);
-            write_short(&db, score.num100s);
-            write_short(&db, score.num50s);
-            write_short(&db, score.numGekis);
-            write_short(&db, score.numKatus);
-            write_short(&db, score.numMisses);
+            write_u16(&db, score.num300s);
+            write_u16(&db, score.num100s);
+            write_u16(&db, score.num50s);
+            write_u16(&db, score.numGekis);
+            write_u16(&db, score.numKatus);
+            write_u16(&db, score.numMisses);
 
-            write_int64(&db, score.score);
-            write_short(&db, score.comboMax);
-            write_int32(&db, score.modsLegacy);
+            write_u64(&db, score.score);
+            write_u16(&db, score.comboMax);
+            write_u32(&db, score.modsLegacy);
 
             // custom
-            write_short(&db, score.numSliderBreaks);
-            write_float32(&db, score.pp);
-            write_float32(&db, score.unstableRate);
-            write_float32(&db, score.hitErrorAvgMin);
-            write_float32(&db, score.hitErrorAvgMax);
-            write_float32(&db, score.starsTomTotal);
-            write_float32(&db, score.starsTomAim);
-            write_float32(&db, score.starsTomSpeed);
-            write_float32(&db, score.speedMultiplier);
-            write_float32(&db, score.CS);
-            write_float32(&db, score.AR);
-            write_float32(&db, score.OD);
-            write_float32(&db, score.HP);
+            write_u16(&db, score.numSliderBreaks);
+            write_f32(&db, score.pp);
+            write_f32(&db, score.unstableRate);
+            write_f32(&db, score.hitErrorAvgMin);
+            write_f32(&db, score.hitErrorAvgMax);
+            write_f32(&db, score.starsTomTotal);
+            write_f32(&db, score.starsTomAim);
+            write_f32(&db, score.starsTomSpeed);
+            write_f32(&db, score.speedMultiplier);
+            write_f32(&db, score.CS);
+            write_f32(&db, score.AR);
+            write_f32(&db, score.OD);
+            write_f32(&db, score.HP);
 
             if(score.version > 20180722) {
-                write_int32(&db, score.maxPossibleCombo);
-                write_int32(&db, score.numHitObjects);
-                write_int32(&db, score.numCircles);
+                write_u32(&db, score.maxPossibleCombo);
+                write_u32(&db, score.numHitObjects);
+                write_u32(&db, score.numCircles);
             }
 
             if(score.version >= 20240412) {
-                write_int32(&db, score.online_score_id);
+                write_u32(&db, score.online_score_id);
                 write_string(&db, score.server.c_str());
             }
 

+ 1 - 1
src/App/Osu/Database.h

@@ -63,7 +63,7 @@ class Database {
     DatabaseBeatmap *addBeatmap(std::string beatmapFolderPath);
 
     int addScore(MD5Hash beatmapMD5Hash, FinishedScore score);
-    void deleteScore(MD5Hash beatmapMD5Hash, uint64_t scoreUnixTimestamp);
+    void deleteScore(MD5Hash beatmapMD5Hash, u64 scoreUnixTimestamp);
     void sortScores(MD5Hash beatmapMD5Hash);
     void forceScoreUpdateOnNextCalculatePlayerStats() { m_bDidScoresChangeForStats = true; }
     void forceScoresSaveOnNextShutdown() { m_bDidScoresChangeForSave = true; }

+ 6 - 6
src/App/Osu/DatabaseBeatmap.cpp

@@ -950,7 +950,7 @@ bool DatabaseBeatmap::loadMetadata(DatabaseBeatmap *databaseBeatmap) {
     {
         File file(!databaseBeatmap->m_bFilePathIsInMemoryBeatmap ? databaseBeatmap->m_sFilePath : "");
 
-        const uint8_t *beatmapFile = NULL;
+        const u8 *beatmapFile = NULL;
         size_t beatmapFileSize = 0;
         {
             if(!databaseBeatmap->m_bFilePathIsInMemoryBeatmap) {
@@ -959,13 +959,13 @@ bool DatabaseBeatmap::loadMetadata(DatabaseBeatmap *databaseBeatmap) {
                     beatmapFileSize = file.getFileSize();
                 }
             } else {
-                beatmapFile = (uint8_t *)databaseBeatmap->m_sFilePath.c_str();
+                beatmapFile = (u8 *)databaseBeatmap->m_sFilePath.c_str();
                 beatmapFileSize = databaseBeatmap->m_sFilePath.size();
             }
         }
 
         if(beatmapFile != NULL) {
-            auto hash = md5((uint8_t *)beatmapFile, beatmapFileSize);
+            auto hash = md5((u8 *)beatmapFile, beatmapFileSize);
             databaseBeatmap->m_sMD5Hash = MD5Hash(hash.toUtf8());
         }
     }
@@ -1364,9 +1364,9 @@ DatabaseBeatmap::LOAD_GAMEPLAY_RESULT DatabaseBeatmap::loadGameplay(DatabaseBeat
     // build hitobjects from the primitive data we loaded from the osu file
     {
         struct Helper {
-            static inline uint32_t pcgHash(uint32_t input) {
-                const uint32_t state = input * 747796405u + 2891336453u;
-                const uint32_t word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
+            static inline u32 pcgHash(u32 input) {
+                const u32 state = input * 747796405u + 2891336453u;
+                const u32 word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u;
                 return (word >> 22u) ^ word;
             }
         };

+ 6 - 6
src/App/Osu/Downloader.cpp

@@ -14,7 +14,7 @@
 
 struct DownloadResult {
     std::string url;
-    std::vector<uint8_t> data;
+    std::vector<u8> data;
     float progress = 0.f;
     int response_code = 0;
 };
@@ -103,7 +103,7 @@ void* do_downloads(void* arg) {
             pthread_mutex_lock(&threads_mtx);
             result->progress = 1.f;
             result->response_code = response_code;
-            result->data = std::vector<uint8_t>(response.memory, response.memory + response.size);
+            result->data = std::vector<u8>(response.memory, response.memory + response.size);
             pthread_mutex_unlock(&threads_mtx);
         } else {
             debugLog("Failed to download %s: %s\n", url.c_str(), curl_easy_strerror(res));
@@ -113,7 +113,7 @@ void* do_downloads(void* arg) {
             if(response_code == 429) {
                 result->progress = 0.f;
             } else {
-                result->data = std::vector<uint8_t>(response.memory, response.memory + response.size);
+                result->data = std::vector<u8>(response.memory, response.memory + response.size);
                 result->progress = -1.f;
             }
             pthread_mutex_unlock(&threads_mtx);
@@ -146,7 +146,7 @@ end_thread:
     return NULL;
 }
 
-void download(const char* url, float* progress, std::vector<uint8_t>& out, int* response_code) {
+void download(const char* url, float* progress, std::vector<u8>& out, int* response_code) {
     char* hostname = NULL;
     bool download_found = false;
     DownloadThread* matching_thread = nullptr;
@@ -218,7 +218,7 @@ end:
     curl_url_cleanup(urlu);
 }
 
-void download_beatmapset(uint32_t set_id, float* progress) {
+void download_beatmapset(u32 set_id, float* progress) {
     // Check if we already have downloaded it
     std::stringstream ss;
     ss << MCENGINE_DATA_DIR "maps/" << std::to_string(set_id) << "/";
@@ -228,7 +228,7 @@ void download_beatmapset(uint32_t set_id, float* progress) {
         return;
     }
 
-    std::vector<uint8_t> data;
+    std::vector<u8> data;
     auto mirror = convar->getConVarByName("beatmap_mirror")->getString();
     mirror.append(UString::format("%d", set_id));
     int response_code = 0;

+ 2 - 2
src/App/Osu/Downloader.h

@@ -6,8 +6,8 @@ void abort_downloads();
 // Downloads `url` and stores downloaded file data into `out`
 // When file is fully downloaded, `progress` is 1 and `out` is not NULL
 // When download fails, `progress` is -1
-void download(const char *url, float *progress, std::vector<uint8_t> &out, int *response_code);
+void download(const char *url, float *progress, std::vector<u8> &out, int *response_code);
 
 // Downloads and extracts given beatmapset
 // When download/extraction fails, `progress` is -1
-void download_beatmapset(uint32_t set_id, float *progress);
+void download_beatmapset(u32 set_id, float *progress);

+ 8 - 8
src/App/Osu/HUD.cpp

@@ -1431,12 +1431,12 @@ std::vector<SCORE_ENTRY> HUD::getCurrentScores() {
             if(slot->player_id == bancho.user_id) {
                 // Update local player slot instantly
                 // (not including fields that won't be used for the HUD)
-                slot->num300 = (uint16_t)m_osu->getScore()->getNum300s();
-                slot->num100 = (uint16_t)m_osu->getScore()->getNum100s();
-                slot->num50 = (uint16_t)m_osu->getScore()->getNum50s();
-                slot->num_miss = (uint16_t)m_osu->getScore()->getNumMisses();
-                slot->current_combo = (uint16_t)m_osu->getScore()->getCombo();
-                slot->total_score = (int32_t)m_osu->getScore()->getScore();
+                slot->num300 = (u16)m_osu->getScore()->getNum300s();
+                slot->num100 = (u16)m_osu->getScore()->getNum100s();
+                slot->num50 = (u16)m_osu->getScore()->getNum50s();
+                slot->num_miss = (u16)m_osu->getScore()->getNumMisses();
+                slot->current_combo = (u16)m_osu->getScore()->getCombo();
+                slot->total_score = (i32)m_osu->getScore()->getScore();
                 slot->current_hp = beatmap->getHealth() * 200;
             }
 
@@ -1463,8 +1463,8 @@ std::vector<SCORE_ENTRY> HUD::getCurrentScores() {
             }
 
             // hit_score != total_score: total_score also accounts for spinner bonus & mods
-            uint64_t hit_score = 300 * slot->num300 + 100 * slot->num100 + 50 * slot->num50;
-            uint64_t max_score = 300 * (slot->num300 + slot->num100 + slot->num50 + slot->num_miss);
+            u64 hit_score = 300 * slot->num300 + 100 * slot->num100 + 50 * slot->num50;
+            u64 max_score = 300 * (slot->num300 + slot->num100 + slot->num50 + slot->num_miss);
             scoreEntry.accuracy = max_score > 0 ? hit_score / max_score : 0.f;
 
             scores.push_back(std::move(scoreEntry));

+ 2 - 2
src/App/Osu/HUD.h

@@ -25,8 +25,8 @@ class CBaseUIContainer;
 
 struct SCORE_ENTRY {
     UString name;
-    int32_t entry_id = 0;
-    uint32_t player_id = 0;
+    i32 entry_id = 0;
+    u32 player_id = 0;
 
     int combo;
     unsigned long long score;

+ 3 - 3
src/App/Osu/Lobby.cpp

@@ -196,10 +196,10 @@ void Lobby::addRoom(Room* room) {
     updateLayout(getSize());
 }
 
-void Lobby::joinRoom(uint32_t id, UString password) {
+void Lobby::joinRoom(u32 id, UString password) {
     Packet packet;
     packet.id = JOIN_ROOM;
-    write_int32(&packet, id);
+    write_u32(&packet, id);
     write_string(&packet, password.toUtf8());
     send_packet(packet);
 
@@ -229,7 +229,7 @@ void Lobby::updateRoom(Room room) {
     addRoom(new_room);
 }
 
-void Lobby::removeRoom(uint32_t room_id) {
+void Lobby::removeRoom(u32 room_id) {
     for(auto room : rooms) {
         if(room->id == room_id) {
             auto it = std::find(rooms.begin(), rooms.end(), room);

+ 4 - 4
src/App/Osu/Lobby.h

@@ -22,7 +22,7 @@ struct RoomUIElement : CBaseUIScrollView {
     UIButton* join_btn;
     CBaseUIScrollView* ui;
     Lobby* m_multi;
-    int32_t room_id;
+    i32 room_id;
     bool has_password;
 
     void updateLayout(Vector2 pos, Vector2 size);
@@ -42,9 +42,9 @@ class Lobby : public OsuScreen {
     virtual CBaseUIContainer* setVisible(bool visible);
 
     void addRoom(Room* room);
-    void joinRoom(uint32_t id, UString password);
+    void joinRoom(u32 id, UString password);
     void updateRoom(Room room);
-    void removeRoom(uint32_t room_id);
+    void removeRoom(u32 room_id);
     void updateLayout(Vector2 newResolution);
 
     void on_create_room_clicked();
@@ -55,6 +55,6 @@ class Lobby : public OsuScreen {
     std::vector<Room*> rooms;
     UIButton* m_create_room_btn;
     CBaseUIScrollView* m_list;
-    int32_t room_to_join;
+    i32 room_to_join;
     McFont* font;
 };

+ 1 - 1
src/App/Osu/MainMenu.cpp

@@ -307,7 +307,7 @@ void MainMenu::draw(Graphics *g) {
         icon_path.append("/server_icon");
 
         float progress = -1.f;
-        std::vector<uint8_t> data;
+        std::vector<u8> data;
         int response_code;
         download(bancho.server_icon_url.toUtf8(), &progress, data, &response_code);
         if(progress == -1.f) bancho.server_icon_url = "";

+ 4 - 4
src/App/Osu/ModSelector.cpp

@@ -1188,7 +1188,7 @@ void ModSelector::resetModsUserInitiated() {
 
             Packet packet;
             packet.id = MATCH_CHANGE_MODS;
-            write_int32(&packet, bancho.room.slots[i].mods);
+            write_u32(&packet, bancho.room.slots[i].mods);
             send_packet(packet);
 
             m_osu->m_room->updateLayout(m_osu->getScreenSize());
@@ -1228,8 +1228,8 @@ void ModSelector::resetMods() {
     }
 }
 
-uint32_t ModSelector::getModFlags() {
-    uint32_t flags = 0;
+u32 ModSelector::getModFlags() {
+    u32 flags = 0;
 
     if(m_modButtonDoubletime->isOn()) flags |= ModFlags::DoubleTime;
     if(m_modButtonDoubletime->getState() == 1) flags |= ModFlags::Nightcore;
@@ -1251,7 +1251,7 @@ uint32_t ModSelector::getModFlags() {
     return flags;
 }
 
-void ModSelector::enableModsFromFlags(uint32_t flags) {
+void ModSelector::enableModsFromFlags(u32 flags) {
     if(flags & ModFlags::DoubleTime) {
         m_modButtonDoubletime->setOn(true, true);
         if(flags & ModFlags::Nightcore) {

+ 2 - 2
src/App/Osu/ModSelector.h

@@ -48,8 +48,8 @@ class ModSelector : public OsuScreen {
     void toggleAuto();
     void resetModsUserInitiated();
     void resetMods();
-    uint32_t getModFlags();
-    void enableModsFromFlags(uint32_t flags);
+    u32 getModFlags();
+    void enableModsFromFlags(u32 flags);
 
     void setWaitForF1KeyUp(bool waitForF1KeyUp) { m_bWaitForF1KeyUp = waitForF1KeyUp; }
 

+ 25 - 25
src/App/Osu/Replay.cpp

@@ -46,7 +46,7 @@ Replay::BEATMAP_VALUES Replay::getBeatmapValuesForModsLegacy(int modsLegacy, flo
     return v;
 }
 
-std::vector<Replay::Frame> Replay::get_frames(uint8_t* replay_data, int32_t replay_size) {
+std::vector<Replay::Frame> Replay::get_frames(u8* replay_data, i32 replay_size) {
     std::vector<Replay::Frame> replay_frames;
     if(replay_size <= 0) return replay_frames;
 
@@ -60,7 +60,7 @@ std::vector<Replay::Frame> Replay::get_frames(uint8_t* replay_data, int32_t repl
     long cur_music_pos = 0;
     std::stringstream ss;
     std::string frame_str;
-    uint8_t outbuf[BUFSIZ];
+    u8 outbuf[BUFSIZ];
     strm.next_in = replay_data;
     strm.avail_in = replay_size;
     do {
@@ -93,7 +93,7 @@ end:
     return replay_frames;
 }
 
-void Replay::compress_frames(const std::vector<Replay::Frame>& frames, uint8_t** compressed, size_t* s_compressed) {
+void Replay::compress_frames(const std::vector<Replay::Frame>& frames, u8** compressed, size_t* s_compressed) {
     lzma_stream stream = LZMA_STREAM_INIT;
     lzma_options_lzma options;
     lzma_lzma_preset(&options, LZMA_PRESET_DEFAULT);
@@ -116,17 +116,17 @@ void Replay::compress_frames(const std::vector<Replay::Frame>& frames, uint8_t**
     replay_string.append("-12345|0.0000|0.0000|0,");
 
     *s_compressed = replay_string.length();
-    *compressed = (uint8_t*)malloc(*s_compressed);
+    *compressed = (u8*)malloc(*s_compressed);
 
     stream.avail_in = replay_string.length();
-    stream.next_in = (const uint8_t*)replay_string.c_str();
+    stream.next_in = (const u8*)replay_string.c_str();
     stream.avail_out = *s_compressed;
     stream.next_out = *compressed;
     do {
         ret = lzma_code(&stream, LZMA_FINISH);
         if(ret == LZMA_OK) {
             *s_compressed *= 2;
-            *compressed = (uint8_t*)realloc(*compressed, *s_compressed);
+            *compressed = (u8*)realloc(*compressed, *s_compressed);
             stream.avail_out = *s_compressed - stream.total_out;
             stream.next_out = *compressed + stream.total_out;
         } else if(ret != LZMA_STREAM_END) {
@@ -142,39 +142,39 @@ void Replay::compress_frames(const std::vector<Replay::Frame>& frames, uint8_t**
     lzma_end(&stream);
 }
 
-Replay::Info Replay::from_bytes(uint8_t* data, int s_data) {
+Replay::Info Replay::from_bytes(u8* data, int s_data) {
     Replay::Info info;
 
     Packet replay;
     replay.memory = data;
     replay.size = s_data;
 
-    info.gamemode = read_byte(&replay);
+    info.gamemode = read_u8(&replay);
     if(info.gamemode != 0) {
         debugLog("Replay has unexpected gamemode %d!", info.gamemode);
         return info;
     }
 
-    info.osu_version = read_int32(&replay);
+    info.osu_version = read_u32(&replay);
     info.diff2_md5 = read_string(&replay);
     info.username = read_string(&replay);
     info.replay_md5 = read_string(&replay);
-    info.num300s = read_short(&replay);
-    info.num100s = read_short(&replay);
-    info.num50s = read_short(&replay);
-    info.numGekis = read_short(&replay);
-    info.numKatus = read_short(&replay);
-    info.numMisses = read_short(&replay);
-    info.score = read_int32(&replay);
-    info.comboMax = read_short(&replay);
-    info.perfect = read_byte(&replay);
-    info.mod_flags = read_int32(&replay);
+    info.num300s = read_u16(&replay);
+    info.num100s = read_u16(&replay);
+    info.num50s = read_u16(&replay);
+    info.numGekis = read_u16(&replay);
+    info.numKatus = read_u16(&replay);
+    info.numMisses = read_u16(&replay);
+    info.score = read_u32(&replay);
+    info.comboMax = read_u16(&replay);
+    info.perfect = read_u8(&replay);
+    info.mod_flags = read_u32(&replay);
     info.life_bar_graph = read_string(&replay);
-    info.timestamp = read_int64(&replay) / 10;
+    info.timestamp = read_u64(&replay) / 10;
 
-    int32_t replay_size = read_int32(&replay);
+    i32 replay_size = read_u32(&replay);
     if(replay_size <= 0) return info;
-    auto replay_data = new uint8_t[replay_size];
+    auto replay_data = new u8[replay_size];
     read_bytes(&replay, replay_data, replay_size);
     info.frames = Replay::get_frames(replay_data, replay_size);
     delete[] replay_data;
@@ -195,7 +195,7 @@ bool Replay::load_from_disk(FinishedScore* score) {
         size_t s_full_replay = ftell(replay_file);
         rewind(replay_file);
 
-        uint8_t* full_replay = new uint8_t[s_full_replay];
+        u8* full_replay = new u8[s_full_replay];
         fread(full_replay, s_full_replay, 1, replay_file);
         fclose(replay_file);
         auto info = Replay::from_bytes(full_replay, s_full_replay);
@@ -212,7 +212,7 @@ bool Replay::load_from_disk(FinishedScore* score) {
         size_t s_compressed_replay = ftell(replay_file);
         rewind(replay_file);
 
-        uint8_t* compressed_replay = new uint8_t[s_compressed_replay];
+        u8* compressed_replay = new u8[s_compressed_replay];
         fread(compressed_replay, s_compressed_replay, 1, replay_file);
         fclose(replay_file);
         score->replay = Replay::get_frames(compressed_replay, s_compressed_replay);
@@ -251,7 +251,7 @@ void Replay::load_and_watch(FinishedScore score) {
             request.path = UString::format("/web/osu-getreplay.php?u=%s&h=%s&m=0&c=%d", bancho.username.toUtf8(),
                                            bancho.pw_md5.toUtf8(), score.online_score_id);
             request.mime = NULL;
-            request.extra = (uint8_t*)score_cpy;
+            request.extra = (u8*)score_cpy;
             send_api_request(request);
 
             bancho.osu->m_notificationOverlay->addNotification("Downloading replay...");

+ 9 - 9
src/App/Osu/Replay.h

@@ -12,7 +12,7 @@ struct Frame {
     float x;  // 0 - 512
     float y;  // 0 - 384
 
-    uint8_t key_flags;
+    u8 key_flags;
 };
 
 enum KeyFlags {
@@ -36,8 +36,8 @@ struct BEATMAP_VALUES {
 };
 
 struct Info {
-    uint8_t gamemode;
-    uint32_t osu_version;
+    u8 gamemode;
+    u32 osu_version;
     UString diff2_md5;
     UString username;
     UString replay_md5;
@@ -47,21 +47,21 @@ struct Info {
     int numGekis;
     int numKatus;
     int numMisses;
-    int32_t score;
+    i32 score;
     int comboMax;
     bool perfect;
-    int32_t mod_flags;
+    i32 mod_flags;
     UString life_bar_graph;
-    int64_t timestamp;
+    i64 timestamp;
     std::vector<Frame> frames;
 };
 
 BEATMAP_VALUES getBeatmapValuesForModsLegacy(int modsLegacy, float legacyAR, float legacyCS, float legacyOD,
                                              float legacyHP);
 
-Info from_bytes(uint8_t* data, int s_data);
-std::vector<Frame> get_frames(uint8_t* replay_data, int32_t replay_size);
-void compress_frames(const std::vector<Frame>& frames, uint8_t** compressed, size_t* s_compressed);
+Info from_bytes(u8* data, int s_data);
+std::vector<Frame> get_frames(u8* replay_data, i32 replay_size);
+void compress_frames(const std::vector<Frame>& frames, u8** compressed, size_t* s_compressed);
 bool load_from_disk(FinishedScore* score);
 void load_and_watch(FinishedScore score);
 

+ 10 - 10
src/App/Osu/RichPresence.cpp

@@ -42,7 +42,7 @@ void RichPresence::setBanchoStatus(Osu *osu, const char *info_text, Action actio
     if(osu == NULL) return;
 
     MD5Hash map_md5("");
-    uint32_t map_id = 0;
+    u32 map_id = 0;
 
     auto selected_beatmap = osu->getSelectedBeatmap();
     if(selected_beatmap != nullptr) {
@@ -61,18 +61,18 @@ void RichPresence::setBanchoStatus(Osu *osu, const char *info_text, Action actio
 
     Packet packet;
     packet.id = CHANGE_ACTION;
-    write_byte(&packet, action);
+    write_u8(&packet, action);
     write_string(&packet, fancy_text);
     write_string(&packet, map_md5.hash);
-    write_int32(&packet, osu->m_modSelector->getModFlags());
-    write_byte(&packet, 0);  // osu!std
-    write_int32(&packet, map_id);
+    write_u32(&packet, osu->m_modSelector->getModFlags());
+    write_u8(&packet, 0);  // osu!std
+    write_u32(&packet, map_id);
     send_packet(packet);
 }
 
 void RichPresence::updateBanchoMods() {
     MD5Hash map_md5("");
-    uint32_t map_id = 0;
+    u32 map_id = 0;
 
     auto selected_beatmap = bancho.osu->getSelectedBeatmap();
     if(selected_beatmap != nullptr) {
@@ -85,12 +85,12 @@ void RichPresence::updateBanchoMods() {
 
     Packet packet;
     packet.id = CHANGE_ACTION;
-    write_byte(&packet, last_action);
+    write_u8(&packet, last_action);
     write_string(&packet, last_status.toUtf8());
     write_string(&packet, map_md5.hash);
-    write_int32(&packet, bancho.osu->m_modSelector->getModFlags());
-    write_byte(&packet, 0);  // osu!std
-    write_int32(&packet, map_id);
+    write_u32(&packet, bancho.osu->m_modSelector->getModFlags());
+    write_u8(&packet, 0);  // osu!std
+    write_u32(&packet, map_id);
     send_packet(packet);
 
     // Servers like akatsuki send different leaderboards based on what mods

+ 44 - 44
src/App/Osu/RoomScreen.cpp

@@ -221,7 +221,7 @@ void RoomScreen::draw(Graphics *g) {
 
     auto search = mapset_by_mapid.find(bancho.room.map_id);
     if(search == mapset_by_mapid.end()) return;
-    uint32_t set_id = search->second;
+    u32 set_id = search->second;
     if(set_id == 0) {
         auto error_str = UString::format("Could not find beatmapset for map ID %d", bancho.room.map_id);
         m_map_title->setText(error_str);
@@ -402,7 +402,7 @@ void RoomScreen::updateSettingsLayout(Vector2 newResolution) {
     // Ready button
     int nb_ready = 0;
     bool is_ready = false;
-    for(uint8_t i = 0; i < 16; i++) {
+    for(u8 i = 0; i < 16; i++) {
         if(bancho.room.slots[i].has_player() && bancho.room.slots[i].is_ready()) {
             nb_ready++;
             if(bancho.room.slots[i].player_id == bancho.user_id) {
@@ -498,7 +498,7 @@ void RoomScreen::ragequit() {
 }
 
 void RoomScreen::process_beatmapset_info_response(Packet packet) {
-    uint32_t map_id = packet.extra_int;
+    u32 map_id = packet.extra_int;
     if(packet.size == 0) {
         bancho.osu->m_room->mapset_by_mapid[map_id] = 0;
         return;
@@ -588,7 +588,7 @@ void RoomScreen::on_map_change(bool download) {
             request.type = GET_BEATMAPSET_INFO;
             request.path = path;
             request.mime = NULL;
-            request.extra_int = (uint32_t)bancho.room.map_id;
+            request.extra_int = (u32)bancho.room.map_id;
 
             send_api_request(request);
 
@@ -699,29 +699,29 @@ void RoomScreen::on_match_started(Room room) {
 }
 
 void RoomScreen::on_match_score_updated(Packet *packet) {
-    int32_t update_tms = read_int32(packet);
-    uint8_t slot_id = read_byte(packet);
+    i32 update_tms = read_u32(packet);
+    u8 slot_id = read_u8(packet);
     if(slot_id > 15) return;
 
     auto slot = &bancho.room.slots[slot_id];
     slot->last_update_tms = update_tms;
-    slot->num300 = read_short(packet);
-    slot->num100 = read_short(packet);
-    slot->num50 = read_short(packet);
-    slot->num_geki = read_short(packet);
-    slot->num_katu = read_short(packet);
-    slot->num_miss = read_short(packet);
-    slot->total_score = read_int32(packet);
-    slot->max_combo = read_short(packet);
-    slot->current_combo = read_short(packet);
-    slot->is_perfect = read_byte(packet);
-    slot->current_hp = read_byte(packet);
-    slot->tag = read_byte(packet);
-
-    bool is_scorev2 = read_byte(packet);
+    slot->num300 = read_u16(packet);
+    slot->num100 = read_u16(packet);
+    slot->num50 = read_u16(packet);
+    slot->num_geki = read_u16(packet);
+    slot->num_katu = read_u16(packet);
+    slot->num_miss = read_u16(packet);
+    slot->total_score = read_u32(packet);
+    slot->max_combo = read_u16(packet);
+    slot->current_combo = read_u16(packet);
+    slot->is_perfect = read_u8(packet);
+    slot->current_hp = read_u8(packet);
+    slot->tag = read_u8(packet);
+
+    bool is_scorev2 = read_u8(packet);
     if(is_scorev2) {
-        slot->sv2_combo = read_float64(packet);
-        slot->sv2_bonus = read_float64(packet);
+        slot->sv2_combo = read_f64(packet);
+        slot->sv2_bonus = read_f64(packet);
     }
 
     bancho.osu->m_hud->updateScoreboard(true);
@@ -732,7 +732,7 @@ void RoomScreen::on_all_players_loaded() {
     m_osu->m_chat->updateVisibility();
 }
 
-void RoomScreen::on_player_failed(int32_t slot_id) {
+void RoomScreen::on_player_failed(i32 slot_id) {
     if(slot_id < 0 || slot_id > 15) return;
     bancho.room.slots[slot_id].died = true;
 }
@@ -749,7 +749,7 @@ void RoomScreen::on_match_finished() {
 
 void RoomScreen::on_all_players_skipped() { bancho.room.all_players_skipped = true; }
 
-void RoomScreen::on_player_skip(int32_t user_id) {
+void RoomScreen::on_player_skip(i32 user_id) {
     for(int i = 0; i < 16; i++) {
         if(bancho.room.slots[i].player_id == user_id) {
             bancho.room.slots[i].skipped = true;
@@ -775,31 +775,31 @@ void RoomScreen::onClientScoreChange(bool force) {
     Packet packet;
     packet.id = UPDATE_MATCH_SCORE;
 
-    write_int32(&packet, (int32_t)m_osu->getSelectedBeatmap()->getTime());
+    write_u32(&packet, (i32)m_osu->getSelectedBeatmap()->getTime());
 
-    uint8_t slot_id = 0;
-    for(uint8_t i = 0; i < 16; i++) {
+    u8 slot_id = 0;
+    for(u8 i = 0; i < 16; i++) {
         if(bancho.room.slots[i].player_id == bancho.user_id) {
             slot_id = i;
             break;
         }
     }
-    write_byte(&packet, slot_id);
-
-    write_short(&packet, (uint16_t)m_osu->getScore()->getNum300s());
-    write_short(&packet, (uint16_t)m_osu->getScore()->getNum100s());
-    write_short(&packet, (uint16_t)m_osu->getScore()->getNum50s());
-    write_short(&packet, (uint16_t)m_osu->getScore()->getNum300gs());
-    write_short(&packet, (uint16_t)m_osu->getScore()->getNum100ks());
-    write_short(&packet, (uint16_t)m_osu->getScore()->getNumMisses());
-    write_int32(&packet, (int32_t)m_osu->getScore()->getScore());
-    write_short(&packet, (uint16_t)m_osu->getScore()->getCombo());
-    write_short(&packet, (uint16_t)m_osu->getScore()->getComboMax());
-    write_byte(&packet, m_osu->getScore()->getNumSliderBreaks() == 0 && m_osu->getScore()->getNumMisses() == 0 &&
-                            m_osu->getScore()->getNum50s() == 0 && m_osu->getScore()->getNum100s() == 0);
-    write_byte(&packet, m_osu->getSelectedBeatmap()->getHealth() * 200);
-    write_byte(&packet, 0);  // 4P, not supported
-    write_byte(&packet, m_osu->getModScorev2());
+    write_u8(&packet, slot_id);
+
+    write_u16(&packet, (u16)m_osu->getScore()->getNum300s());
+    write_u16(&packet, (u16)m_osu->getScore()->getNum100s());
+    write_u16(&packet, (u16)m_osu->getScore()->getNum50s());
+    write_u16(&packet, (u16)m_osu->getScore()->getNum300gs());
+    write_u16(&packet, (u16)m_osu->getScore()->getNum100ks());
+    write_u16(&packet, (u16)m_osu->getScore()->getNumMisses());
+    write_u32(&packet, (i32)m_osu->getScore()->getScore());
+    write_u16(&packet, (u16)m_osu->getScore()->getCombo());
+    write_u16(&packet, (u16)m_osu->getScore()->getComboMax());
+    write_u8(&packet, m_osu->getScore()->getNumSliderBreaks() == 0 && m_osu->getScore()->getNumMisses() == 0 &&
+                          m_osu->getScore()->getNum50s() == 0 && m_osu->getScore()->getNum100s() == 0);
+    write_u8(&packet, m_osu->getSelectedBeatmap()->getHealth() * 200);
+    write_u8(&packet, 0);  // 4P, not supported
+    write_u8(&packet, m_osu->getModScorev2());
     send_packet(packet);
 
     last_packet_tms = time(NULL);
@@ -811,7 +811,7 @@ void RoomScreen::onReadyButtonClick() {
 
     int nb_ready = 0;
     bool is_ready = false;
-    for(uint8_t i = 0; i < 16; i++) {
+    for(u8 i = 0; i < 16; i++) {
         if(bancho.room.slots[i].has_player() && bancho.room.slots[i].is_ready()) {
             nb_ready++;
             if(bancho.room.slots[i].player_id == bancho.user_id) {

+ 5 - 5
src/App/Osu/RoomScreen.h

@@ -16,9 +16,9 @@ class UIContextMenu;
 
 class UIModList : public CBaseUIContainer {
    public:
-    UIModList(uint32_t *flags) : CBaseUIContainer(0, 0, 0, 0, "mod_list") { m_flags = flags; }
+    UIModList(u32 *flags) : CBaseUIContainer(0, 0, 0, 0, "mod_list") { m_flags = flags; }
 
-    uint32_t *m_flags;
+    u32 *m_flags;
 
     virtual void draw(Graphics *g) override;
     virtual bool isVisible() override;
@@ -47,10 +47,10 @@ class RoomScreen : public OsuScreen {
     void on_match_started(Room room);
     void on_match_score_updated(Packet *packet);
     void on_all_players_loaded();
-    void on_player_failed(int32_t slot_id);
+    void on_player_failed(i32 slot_id);
     void on_match_finished();
     void on_all_players_skipped();
-    void on_player_skip(int32_t user_id);
+    void on_player_skip(i32 user_id);
     void on_match_aborted();
     void onClientScoreChange(bool force = false);
     void onReadyButtonClick();
@@ -65,7 +65,7 @@ class RoomScreen : public OsuScreen {
     void set_new_password(UString new_password);
     void onFreemodCheckboxChanged(CBaseUICheckbox *checkbox);
 
-    std::unordered_map<uint32_t, uint32_t> mapset_by_mapid;
+    std::unordered_map<u32, u32> mapset_by_mapid;
 
     CBaseUILabel *map_label = nullptr;
     CBaseUILabel *mods_label = nullptr;

+ 3 - 3
src/App/Osu/SongBrowser.cpp

@@ -3956,7 +3956,7 @@ void SongBrowser::onCollectionButtonContextMenu(UISongBrowserCollectionButton *c
     }
 }
 
-void SongBrowser::highlightScore(uint64_t unixTimestamp) {
+void SongBrowser::highlightScore(u64 unixTimestamp) {
     for(size_t i = 0; i < m_scoreButtonCache.size(); i++) {
         if(m_scoreButtonCache[i]->getScore().unixTimestamp == unixTimestamp) {
             m_scoreBrowser->scrollToElement(m_scoreButtonCache[i], 0, 10);
@@ -4136,13 +4136,13 @@ void SongBrowser::recreateCollectionsButtons() {
         if(collection->maps.empty()) continue;
 
         std::vector<UISongBrowserButton *> folder;
-        std::vector<uint32_t> matched_sets;
+        std::vector<u32> matched_sets;
 
         for(auto &map : collection->maps) {
             auto it = hashToSongButton.find(map);
             if(it == hashToSongButton.end()) continue;
 
-            uint32_t set_id = 0;
+            u32 set_id = 0;
             auto song_button = it->second;
             const std::vector<UISongBrowserButton *> &songButtonChildren = song_button->getChildren();
             std::vector<UISongBrowserButton *> matching_diffs;

+ 1 - 1
src/App/Osu/SongBrowser.h

@@ -114,7 +114,7 @@ class SongBrowser : public ScreenBackable {
     void onSongButtonContextMenu(UISongBrowserSongButton *songButton, UString text, int id);
     void onCollectionButtonContextMenu(UISongBrowserCollectionButton *collectionButton, UString text, int id);
 
-    void highlightScore(uint64_t unixTimestamp);
+    void highlightScore(u64 unixTimestamp);
     void selectRandomBeatmap();
     void playNextRandomBeatmap() {
         selectRandomBeatmap();

+ 4 - 4
src/App/Osu/UIAvatar.cpp

@@ -16,11 +16,11 @@
 #include "UIUserContextMenu.h"
 
 // Returns true when avatar is fully downloaded
-bool download_avatar(uint32_t user_id) {
+bool download_avatar(u32 user_id) {
     if(user_id == 0) return false;
 
     // XXX: clear blacklist when changing endpoint
-    static std::vector<uint32_t> blacklist;
+    static std::vector<u32> blacklist;
     for(auto bl : blacklist) {
         if(user_id == bl) {
             return false;
@@ -35,7 +35,7 @@ bool download_avatar(uint32_t user_id) {
     }
 
     float progress = -1.f;
-    std::vector<uint8_t> data;
+    std::vector<u8> data;
     auto img_url = UString::format("https://a.%s/%d", bancho.endpoint.toUtf8(), user_id);
     int response_code;
     download(img_url.toUtf8(), &progress, data, &response_code);
@@ -56,7 +56,7 @@ bool download_avatar(uint32_t user_id) {
     return true;
 }
 
-UIAvatar::UIAvatar(uint32_t player_id, float xPos, float yPos, float xSize, float ySize)
+UIAvatar::UIAvatar(u32 player_id, float xPos, float yPos, float xSize, float ySize)
     : CBaseUIButton(xPos, yPos, xSize, ySize, "avatar", "") {
     m_player_id = player_id;
 

+ 2 - 2
src/App/Osu/UIAvatar.h

@@ -5,14 +5,14 @@
 
 class UIAvatar : public CBaseUIButton {
    public:
-    UIAvatar(uint32_t player_id, float xPos, float yPos, float xSize, float ySize);
+    UIAvatar(u32 player_id, float xPos, float yPos, float xSize, float ySize);
     ~UIAvatar();
 
     virtual void draw(Graphics *g, float alpha = 1.f);
 
     void onAvatarClicked(CBaseUIButton *btn);
 
-    uint32_t m_player_id;
+    u32 m_player_id;
     std::string avatar_path;
     Image *avatar = nullptr;
     bool on_screen = false;

+ 1 - 1
src/App/Osu/UIModSelectorModButton.cpp

@@ -138,7 +138,7 @@ void UIModSelectorModButton::onClicked() {
             debugLog("Sending mod change to server.\n");
             Packet packet;
             packet.id = MATCH_CHANGE_MODS;
-            write_int32(&packet, bancho.room.slots[i].mods);
+            write_u32(&packet, bancho.room.slots[i].mods);
             send_packet(packet);
 
             m_osu->m_room->on_room_updated(bancho.room);

+ 7 - 7
src/App/Osu/UISongBrowserScoreButton.cpp

@@ -455,16 +455,16 @@ void UISongBrowserScoreButton::resetHighlight() {
 
 void UISongBrowserScoreButton::updateElapsedTimeString() {
     if(m_iScoreUnixTimestamp > 0) {
-        const uint64_t curUnixTime =
+        const u64 curUnixTime =
             std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch())
                 .count();
-        const uint64_t delta = curUnixTime - m_iScoreUnixTimestamp;
+        const u64 delta = curUnixTime - m_iScoreUnixTimestamp;
 
-        const uint64_t deltaInSeconds = delta;
-        const uint64_t deltaInMinutes = delta / 60;
-        const uint64_t deltaInHours = deltaInMinutes / 60;
-        const uint64_t deltaInDays = deltaInHours / 24;
-        const uint64_t deltaInYears = deltaInDays / 365;
+        const u64 deltaInSeconds = delta;
+        const u64 deltaInMinutes = delta / 60;
+        const u64 deltaInHours = deltaInMinutes / 60;
+        const u64 deltaInDays = deltaInHours / 24;
+        const u64 deltaInYears = deltaInDays / 365;
 
         if(deltaInHours < 96 || m_style == STYLE::TOP_RANKS) {
             if(deltaInDays > 364)

+ 2 - 2
src/App/Osu/UISongBrowserScoreButton.h

@@ -40,7 +40,7 @@ class UISongBrowserScoreButton : public CBaseUIButton {
     void setIndex(int index) { m_iScoreIndexNumber = index; }
 
     inline FinishedScore getScore() const { return m_score; }
-    inline uint64_t getScoreUnixTimestamp() const { return m_score.unixTimestamp; }
+    inline u64 getScoreUnixTimestamp() const { return m_score.unixTimestamp; }
     inline unsigned long long getScoreScore() const { return m_score.score; }
     inline float getScorePP() const { return m_score.pp; }
 
@@ -91,7 +91,7 @@ class UISongBrowserScoreButton : public CBaseUIButton {
     FinishedScore m_score;
 
     int m_iScoreIndexNumber;
-    uint64_t m_iScoreUnixTimestamp;
+    u64 m_iScoreUnixTimestamp;
 
     FinishedScore::Grade m_scoreGrade;
 

+ 3 - 3
src/App/Osu/UISongBrowserUserButton.cpp

@@ -236,8 +236,8 @@ void UISongBrowserUserButton::updateUserStats() {
 
         int level = Database::getLevelForScore(my->total_score);
         float percentToNextLevel = 1.f;
-        uint32_t score_for_current_level = Database::getRequiredScoreForLevel(level);
-        uint32_t score_for_next_level = Database::getRequiredScoreForLevel(level + 1);
+        u32 score_for_current_level = Database::getRequiredScoreForLevel(level);
+        u32 score_for_next_level = Database::getRequiredScoreForLevel(level + 1);
         if(score_for_next_level > score_for_current_level) {
             percentToNextLevel = (float)(my->total_score - score_for_current_level) /
                                  (float)(score_for_next_level - score_for_current_level);
@@ -250,7 +250,7 @@ void UISongBrowserUserButton::updateUserStats() {
             .numScoresWithPP = 0,
             .level = level,
             .percentToNextLevel = percentToNextLevel,
-            .totalScore = (uint32_t)my->total_score,
+            .totalScore = (u32)my->total_score,
         };
     }
 

+ 6 - 6
src/App/Osu/UIUserContextMenu.cpp

@@ -26,7 +26,7 @@ void UIUserContextMenuScreen::stealFocus() {
     close();
 }
 
-void UIUserContextMenuScreen::open(uint32_t user_id) {
+void UIUserContextMenuScreen::open(u32 user_id) {
     if(!bancho.is_online()) return;
 
     close();
@@ -96,12 +96,12 @@ void UIUserContextMenuScreen::on_action(UString text, int user_action) {
     if(user_action == UA_TRANSFER_HOST) {
         Packet packet;
         packet.id = TRANSFER_HOST;
-        write_int32(&packet, slot_number);
+        write_u32(&packet, slot_number);
         send_packet(packet);
     } else if(user_action == KICK) {
         Packet packet;
         packet.id = MATCH_LOCK;
-        write_int32(&packet, slot_number);
+        write_u32(&packet, slot_number);
         send_packet(packet);  // kick by locking the slot
         send_packet(packet);  // unlock the slot
     } else if(user_action == START_CHAT) {
@@ -113,13 +113,13 @@ void UIUserContextMenuScreen::on_action(UString text, int user_action) {
     } else if(user_action == UA_ADD_FRIEND) {
         Packet packet;
         packet.id = FRIEND_ADD;
-        write_int32(&packet, m_user_id);
+        write_u32(&packet, m_user_id);
         send_packet(packet);
         friends.push_back(m_user_id);
     } else if(user_action == UA_REMOVE_FRIEND) {
         Packet packet;
         packet.id = FRIEND_REMOVE;
-        write_int32(&packet, m_user_id);
+        write_u32(&packet, m_user_id);
         send_packet(packet);
 
         auto it = std::find(friends.begin(), friends.end(), m_user_id);
@@ -131,7 +131,7 @@ void UIUserContextMenuScreen::on_action(UString text, int user_action) {
     menu->setVisible(false);
 }
 
-UIUserLabel::UIUserLabel(Osu *osu, uint32_t user_id, UString username) : CBaseUILabel() {
+UIUserLabel::UIUserLabel(Osu *osu, u32 user_id, UString username) : CBaseUILabel() {
     m_user_id = user_id;
     setText(username);
     setDrawFrame(false);

+ 4 - 4
src/App/Osu/UIUserContextMenu.h

@@ -23,19 +23,19 @@ class UIUserContextMenuScreen : public OsuScreen {
     virtual void onResolutionChange(Vector2 newResolution);
     virtual void stealFocus();
 
-    void open(uint32_t user_id);
+    void open(u32 user_id);
     void close();
     void on_action(UString text, int user_action);
 
-    uint32_t m_user_id;
+    u32 m_user_id;
     UIContextMenu *menu = nullptr;
 };
 
 class UIUserLabel : public CBaseUILabel {
    public:
-    UIUserLabel(Osu *osu, uint32_t user_id, UString username);
+    UIUserLabel(Osu *osu, u32 user_id, UString username);
 
     virtual void onMouseUpInside();
 
-    uint32_t m_user_id;
+    u32 m_user_id;
 };

+ 1 - 1
src/App/Osu/UpdateHandler.cpp

@@ -185,7 +185,7 @@ void UpdateHandler::_installUpdate(std::string zipFilePath) {
         m_status = STATUS::STATUS_ERROR;
         return;
     }
-    const uint8_t *content = f.readFile();
+    const u8 *content = f.readFile();
 
     // initialize zip
     mz_zip_archive zip_archive;

+ 7 - 7
src/App/Osu/score.h

@@ -26,22 +26,22 @@ struct FinishedScore {
     bool isImportedLegacyScore;  // used for identifying imported osu! scores (which were previously legacy scores,
                                  // so they don't have any
                                  // numSliderBreaks/unstableRate/hitErrorAvgMin/hitErrorAvgMax)
-    uint32_t version;
-    uint64_t unixTimestamp;
+    u32 version;
+    u64 unixTimestamp;
 
-    uint32_t player_id = 0;
+    u32 player_id = 0;
     std::string playerName;
     bool passed = false;
     bool ragequit = false;
     Grade grade = Grade::N;
     DatabaseBeatmap *diff2;
-    uint64_t play_time_ms = 0;
+    u64 play_time_ms = 0;
 
     std::string server;
-    uint64_t online_score_id = 0;
+    u64 online_score_id = 0;
     bool has_replay = false;
     std::vector<Replay::Frame> replay;
-    uint64_t legacyReplayTimestamp = 0;
+    u64 legacyReplayTimestamp = 0;
 
     int num300s;
     int num100s;
@@ -123,7 +123,7 @@ struct FinishedScore {
 
 class LiveScore {
    public:
-    static const uint32_t VERSION = 20240412;
+    static const u32 VERSION = 20240412;
 
     enum class HIT {
         // score

+ 3 - 3
src/Engine/DiscordInterface.cpp

@@ -94,9 +94,9 @@ void DiscordInterface::setRichPresence(UString key, UString value, bool pool) {
         m_sPresenceDetails = value;
         m_presence.details = m_sPresenceDetails.toUtf8();
     } else if(key == "startTimestamp")
-        m_presence.startTimestamp = (int64_t)value.toLong();
+        m_presence.startTimestamp = (i64)value.toLong();
     else if(key == "endTimestamp")
-        m_presence.endTimestamp = (int64_t)value.toLong();
+        m_presence.endTimestamp = (i64)value.toLong();
     else if(key == "largeImageKey" && value.length() <= 32) {
         m_sPresenceLargeImageKey = value;
         m_presence.largeImageKey = m_sPresenceLargeImageKey.toUtf8();
@@ -126,7 +126,7 @@ void DiscordInterface::setRichPresence(UString key, UString value, bool pool) {
         m_sPresenceSpectateSecret = value;
         m_presence.spectateSecret = m_sPresenceSpectateSecret.toUtf8();
     } else if(key == "instance")
-        m_presence.instance = (int8_t)value.toInt();
+        m_presence.instance = (i8)value.toInt();
 
     if(!pool) Discord_UpdatePresence(&m_presence);
 

+ 7 - 8
src/Engine/File.h

@@ -27,12 +27,11 @@ class File {
     bool canRead() const;
     bool canWrite() const;
 
-    void write(const uint8_t *buffer, size_t size);
+    void write(const u8 *buffer, size_t size);
 
     std::string readLine();
     std::string readString();
-    const uint8_t *
-    readFile();  // WARNING: this is NOT a null-terminated string! DO NOT USE THIS with UString/std::string!
+    const u8 *readFile();  // WARNING: this is NOT a null-terminated string! DO NOT USE THIS with UString/std::string!
     size_t getFileSize() const;
 
    private:
@@ -46,10 +45,10 @@ class BaseFile {
     virtual bool canRead() const = 0;
     virtual bool canWrite() const = 0;
 
-    virtual void write(const uint8_t *buffer, size_t size) = 0;
+    virtual void write(const u8 *buffer, size_t size) = 0;
 
     virtual std::string readLine() = 0;
-    virtual const uint8_t *readFile() = 0;
+    virtual const u8 *readFile() = 0;
     virtual size_t getFileSize() const = 0;
 };
 
@@ -62,10 +61,10 @@ class StdFile : public BaseFile {
     bool canRead() const;
     bool canWrite() const;
 
-    void write(const uint8_t *buffer, size_t size);
+    void write(const u8 *buffer, size_t size);
 
     std::string readLine();
-    const uint8_t *readFile();
+    const u8 *readFile();
     size_t getFileSize() const;
 
    private:
@@ -79,7 +78,7 @@ class StdFile : public BaseFile {
     size_t m_iFileSize;
 
     // full reader
-    std::vector<uint8_t> m_fullBuffer;
+    std::vector<u8> m_fullBuffer;
 };
 
 #endif

+ 4 - 12
src/Engine/Graphics.h

@@ -1,14 +1,8 @@
-//================ Copyright (c) 2012, PG, All rights reserved. =================//
-//
-// Purpose:		top level graphics interface
-//
-// $NoKeywords: $graphics
-//===============================================================================//
+#pragma once
 
-#ifndef GRAPHICS_H
-#define GRAPHICS_H
+#include "types.h"
+// ^ import order matters
 
-#include <cstdint>
 #include <stack>
 #include <vector>
 
@@ -25,7 +19,7 @@ class Shader;
 class RenderTarget;
 class VertexArrayObject;
 
-typedef uint32_t Color;
+typedef u32 Color;
 
 class Graphics {
    public:
@@ -223,5 +217,3 @@ class Graphics {
     Matrix4 m_3dSceneWorldMatrix;
     Matrix4 m_3dSceneProjectionMatrix;
 };
-
-#endif

+ 1 - 1
src/Engine/Image.cpp

@@ -120,7 +120,7 @@ bool Image::loadRawImage() {
         if(m_bInterrupted)  // cancellation point
             return false;
 
-        const uint8_t *data = file.readFile();
+        const u8 *data = file.readFile();
         if(data == NULL) {
             printf("Image Error: Couldn't readFile() file %s\n", m_sFilePath.c_str());
             return false;

+ 2 - 2
src/Engine/Main/main_SDL.cpp

@@ -62,7 +62,7 @@ ConVar sdl_joystick_zr_threshold("sdl_joystick_zr_threshold", -0.5f, FCVAR_NONE)
 int mainSDL(int argc, char *argv[], SDLEnvironment *customSDLEnvironment) {
     SDLEnvironment *environment = customSDLEnvironment;
 
-    uint32_t flags = SDL_INIT_VIDEO;
+    u32 flags = SDL_INIT_VIDEO;
 
 #ifdef MCENGINE_SDL_JOYSTICK
 
@@ -93,7 +93,7 @@ int mainSDL(int argc, char *argv[], SDLEnvironment *customSDLEnvironment) {
 
 #endif
 
-    uint32_t windowFlags =
+    u32 windowFlags =
         SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN | SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS | SDL_WINDOW_FOREIGN;
 
 #if defined(MCENGINE_FEATURE_OPENGL) || defined(MCENGINE_FEATURE_OPENGLES)

+ 2 - 2
src/Engine/Main/main_Windows.cpp

@@ -852,13 +852,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
 
     #pragma pack(1)
 
-            enum class IPC_STATE : uint8_t
+            enum class IPC_STATE : u8
             {
                     IDLE,
                     MESSAGE
             };
 
-            enum class IPC_MESSAGE_TYPE : uint8_t
+            enum class IPC_MESSAGE_TYPE : u8
             {
                     URL
             };

+ 4 - 4
src/Engine/Platform/File.cpp

@@ -25,7 +25,7 @@ bool File::canRead() const { return m_file->canRead(); }
 
 bool File::canWrite() const { return m_file->canWrite(); }
 
-void File::write(const uint8_t *buffer, size_t size) { m_file->write(buffer, size); }
+void File::write(const u8 *buffer, size_t size) { m_file->write(buffer, size); }
 
 std::string File::readLine() { return m_file->readLine(); }
 
@@ -36,7 +36,7 @@ std::string File::readString() {
     return std::string((const char *)readFile(), size);
 }
 
-const uint8_t *File::readFile() { return m_file->readFile(); }
+const u8 *File::readFile() { return m_file->readFile(); }
 
 size_t File::getFileSize() const { return m_file->getFileSize(); }
 
@@ -107,7 +107,7 @@ bool StdFile::canRead() const { return m_bReady && m_ifstream.good() && m_bRead;
 
 bool StdFile::canWrite() const { return m_bReady && m_ofstream.good() && !m_bRead; }
 
-void StdFile::write(const uint8_t *buffer, size_t size) {
+void StdFile::write(const u8 *buffer, size_t size) {
     if(!canWrite()) return;
 
     m_ofstream.write((const char *)buffer, size);
@@ -126,7 +126,7 @@ std::string StdFile::readLine() {
     return line;
 }
 
-const uint8_t *StdFile::readFile() {
+const u8 *StdFile::readFile() {
     if(File::debug->getBool()) debugLog("StdFile::readFile() on %s\n", m_sFilePath.c_str());
 
     if(m_fullBuffer.size() > 0) return &m_fullBuffer[0];

+ 1 - 1
src/Engine/Platform/LinuxTimer.cpp

@@ -50,7 +50,7 @@ void LinuxTimer::update() {
 
     const timespec elapsed = diff(m_startTime, t);
     m_elapsedTime = elapsed.tv_sec + (double)elapsed.tv_nsec / 1000000000.0;
-    m_elapsedTimeMS = ((uint64_t)elapsed.tv_sec * (uint64_t)1000) + ((uint64_t)elapsed.tv_nsec / (uint64_t)1000000);
+    m_elapsedTimeMS = ((u64)elapsed.tv_sec * (u64)1000) + ((u64)elapsed.tv_nsec / (u64)1000000);
 
     m_currentTime = t;
 }

+ 2 - 2
src/Engine/Platform/LinuxTimer.h

@@ -24,7 +24,7 @@ class LinuxTimer : public BaseTimer {
 
     virtual inline double getDelta() const override { return m_delta; }
     virtual inline double getElapsedTime() const override { return m_elapsedTime; }
-    virtual inline uint64_t getElapsedTimeMS() const override { return m_elapsedTimeMS; }
+    virtual inline u64 getElapsedTimeMS() const override { return m_elapsedTimeMS; }
 
    private:
     timespec m_startTime;
@@ -32,7 +32,7 @@ class LinuxTimer : public BaseTimer {
 
     double m_delta;
     double m_elapsedTime;
-    uint64_t m_elapsedTimeMS;
+    u64 m_elapsedTimeMS;
 };
 
 #endif

+ 3 - 3
src/Engine/Platform/MacOSTimer.cpp

@@ -30,12 +30,12 @@ void MacOSTimer::start() {
 }
 
 void MacOSTimer::update() {
-    const uint64_t nowTime = mach_absolute_time();
+    const u64 nowTime = mach_absolute_time();
 
     m_delta = (((nowTime - m_currentTime) * m_timebaseInfo.numer) / m_timebaseInfo.denom) / 1000000000.0;
     m_elapsedTime = (((nowTime - m_startTime) * m_timebaseInfo.numer) / m_timebaseInfo.denom) / 1000000000.0;
-    m_elapsedTimeMS = (((nowTime - m_startTime) * (uint64_t)m_timebaseInfo.numer) / (uint64_t)m_timebaseInfo.denom) /
-                      (uint64_t)1000000;
+    m_elapsedTimeMS =
+        (((nowTime - m_startTime) * (u64)m_timebaseInfo.numer) / (u64)m_timebaseInfo.denom) / (u64)1000000;
     m_currentTime = nowTime;
 }
 

+ 4 - 4
src/Engine/Platform/MacOSTimer.h

@@ -25,16 +25,16 @@ class MacOSTimer : public BaseTimer {
 
     virtual inline double getDelta() const override { return m_delta; }
     virtual inline double getElapsedTime() const override { return m_elapsedTime; }
-    virtual inline uint64_t getElapsedTimeMS() const override { return m_elapsedTimeMS; }
+    virtual inline u64 getElapsedTimeMS() const override { return m_elapsedTimeMS; }
 
    private:
     mach_timebase_info_data_t m_timebaseInfo;
-    uint64_t m_currentTime;
-    uint64_t m_startTime;
+    u64 m_currentTime;
+    u64 m_startTime;
 
     double m_delta;
     double m_elapsedTime;
-    uint64_t m_elapsedTimeMS;
+    u64 m_elapsedTimeMS;
 };
 
 #endif

+ 1 - 1
src/Engine/Platform/WinTimer.cpp

@@ -39,7 +39,7 @@ void WinTimer::update() {
 
     m_delta = (double)(nowTime.QuadPart - m_currentTime.QuadPart) * m_secondsPerTick;
     m_elapsedTime = (double)(nowTime.QuadPart - m_startTime.QuadPart) * m_secondsPerTick;
-    m_elapsedTimeMS = (uint64_t)(((nowTime.QuadPart - m_startTime.QuadPart) * 1000) / m_ticksPerSecond);
+    m_elapsedTimeMS = (u64)(((nowTime.QuadPart - m_startTime.QuadPart) * 1000) / m_ticksPerSecond);
     m_currentTime = nowTime;
 }
 

+ 2 - 2
src/Engine/Platform/WinTimer.h

@@ -28,7 +28,7 @@ class WinTimer : public BaseTimer {
 
     virtual inline double getDelta() const override { return m_delta; }
     virtual inline double getElapsedTime() const override { return m_elapsedTime; }
-    virtual inline uint64_t getElapsedTimeMS() const override { return m_elapsedTimeMS; }
+    virtual inline u64 getElapsedTimeMS() const override { return m_elapsedTimeMS; }
 
    private:
     double m_secondsPerTick;
@@ -39,7 +39,7 @@ class WinTimer : public BaseTimer {
 
     double m_delta;
     double m_elapsedTime;
-    uint64_t m_elapsedTimeMS;
+    u64 m_elapsedTimeMS;
 };
 
 #endif

+ 3 - 3
src/Engine/Timer.h

@@ -8,7 +8,7 @@
 #ifndef TIMER_H
 #define TIMER_H
 
-#include "cbase.h"  // for uint64_t
+#include "cbase.h"  // for u64
 
 class BaseTimer {
    public:
@@ -19,7 +19,7 @@ class BaseTimer {
 
     virtual double getDelta() const = 0;
     virtual double getElapsedTime() const = 0;
-    virtual uint64_t getElapsedTimeMS() const = 0;
+    virtual u64 getElapsedTimeMS() const = 0;
 };
 
 class Timer {
@@ -32,7 +32,7 @@ class Timer {
 
     inline double getDelta() const { return m_timer->getDelta(); }
     inline double getElapsedTime() const { return m_timer->getElapsedTime(); }
-    inline uint64_t getElapsedTimeMS() const { return m_timer->getElapsedTimeMS(); }
+    inline u64 getElapsedTimeMS() const { return m_timer->getElapsedTimeMS(); }
 
    private:
     BaseTimer *m_timer;

+ 5 - 5
src/Engine/VulkanInterface.cpp

@@ -65,7 +65,7 @@ VulkanInterface::VulkanInterface() {
     VkPhysicalDeviceFeatures enabledDeviceFeatures = {};
 
     // list all available layers
-    uint32_t layerCount;
+    u32 layerCount;
     vkEnumerateInstanceLayerProperties(&layerCount, NULL);
     std::vector<VkLayerProperties> availableLayers(layerCount);
     vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
@@ -144,8 +144,8 @@ VulkanInterface::VulkanInterface() {
         debugLog("Vulkan Device #%i: Driver Version: %d\n", i, deviceProperties.driverVersion);
         debugLog("Vulkan Device #%i: Device Name:    %s\n", i, deviceProperties.deviceName);
         debugLog("Vulkan Device #%i: Device Type:    %d\n", i, deviceProperties.deviceType);
-        debugLog("Vulkan Device #%i: API Version:    %d.%d.%d\n", i, (uint32_t)deviceProperties.apiVersion >> 22,
-                 ((uint32_t)deviceProperties.apiVersion >> 12) & 0x3ff, (uint32_t)deviceProperties.apiVersion & 0xfff);
+        debugLog("Vulkan Device #%i: API Version:    %d.%d.%d\n", i, (u32)deviceProperties.apiVersion >> 22,
+                 ((u32)deviceProperties.apiVersion >> 12) & 0x3ff, (u32)deviceProperties.apiVersion & 0xfff);
     }
 
     // and select a device
@@ -155,7 +155,7 @@ VulkanInterface::VulkanInterface() {
 
     // get queue family properties
     std::vector<VkQueueFamilyProperties> queueFamilyProperties;
-    uint32_t queueFamilyPropertyCount = 0;
+    u32 queueFamilyPropertyCount = 0;
     vkGetPhysicalDeviceQueueFamilyProperties(m_physicalDevice, &queueFamilyPropertyCount, NULL);
     if(queueFamilyPropertyCount < 1) {
         engine->showMessageError(
@@ -180,7 +180,7 @@ VulkanInterface::VulkanInterface() {
 
         // get index of first VK_QUEUE_GRAPHICS_BIT queue, default to 0 (first available queue)
         deviceQueueCreateInfo.queueFamilyIndex = 0;
-        for(uint32_t i = 0; i < queueFamilyProperties.size(); i++) {
+        for(u32 i = 0; i < queueFamilyProperties.size(); i++) {
             if(queueFamilyProperties[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
                 debugLog("Vulkan: Selecting queue %i.\n", i);
                 m_iQueueFamilyIndex = i;

+ 2 - 2
src/Engine/VulkanInterface.h

@@ -42,7 +42,7 @@ class VulkanInterface {
 
     void finish();
 
-    inline uint32_t getQueueFamilyIndex() const { return m_iQueueFamilyIndex; }
+    inline u32 getQueueFamilyIndex() const { return m_iQueueFamilyIndex; }
     inline bool isReady() const { return m_bReady; }
 
 #ifdef MCENGINE_FEATURE_VULKAN
@@ -56,7 +56,7 @@ class VulkanInterface {
 
    private:
     bool m_bReady;
-    uint32_t m_iQueueFamilyIndex;
+    u32 m_iQueueFamilyIndex;
 
 #ifdef MCENGINE_FEATURE_VULKAN
 

+ 2 - 2
src/GUI/Windows/VisualProfiler.h

@@ -62,7 +62,7 @@ class VisualProfiler : public CBaseUIElement {
     struct SPIKE {
         NODE node;
         double timeLastFrame;
-        uint32_t id;
+        u32 id;
     };
 
     struct GROUP {
@@ -103,7 +103,7 @@ class VisualProfiler : public CBaseUIElement {
 
     SPIKE m_spike;
     std::vector<SPIKE> m_spikeNodes;
-    uint32_t m_spikeIDCounter;
+    u32 m_spikeIDCounter;
 
     McFont *m_font;
     McFont *m_fontConsole;

+ 3 - 26
src/Util/cbase.h

@@ -1,12 +1,4 @@
-//================ Copyright (c) 2012, PG, All rights reserved. =================//
-//
-// Purpose:		CBASE - all global stuff goes in here
-//
-// $NoKeywords: $base
-//===============================================================================//
-
-#ifndef CBASE_H
-#define CBASE_H
+#pragma once
 
 // STD INCLUDES
 
@@ -27,6 +19,8 @@
 #include <unordered_set>
 #include <vector>
 
+#include "types.h"
+
 // ENGINE INCLUDES
 
 #include "EngineFeatures.h"
@@ -47,21 +41,6 @@
 
 typedef unsigned char COLORPART;
 
-/*
-#ifndef DWORD
-typedef unsigned long 	DWORD;
-#endif
-#ifndef WORD
-typedef unsigned short	WORD;
-#endif
-#ifndef BYTE
-typedef unsigned char	BYTE;
-#endif
-#ifndef UINT8
-typedef unsigned char 	UINT8;
-#endif
-*/
-
 #define SAFE_DELETE(p)  \
     {                   \
         if(p) {         \
@@ -143,5 +122,3 @@ inline bool isInt(float f) { return (f == static_cast<float>(static_cast<int>(f)
 inline unsigned long &floatBits(float &f) { return *reinterpret_cast<unsigned long *>(&f); }
 
 inline bool isFinite(float f) { return ((floatBits(f) & 0x7F800000) != 0x7F800000); }
-
-#endif

+ 14 - 0
src/Util/types.h

@@ -0,0 +1,14 @@
+#pragma once
+#include <stddef.h>
+#include <stdint.h>
+
+typedef int8_t i8;
+typedef int16_t i16;
+typedef int32_t i32;
+typedef int64_t i64;
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+typedef float f32;
+typedef double f64;