diff --git a/src/Game.c b/src/Game.c index ee9e1520c..c38294047 100644 --- a/src/Game.c +++ b/src/Game.c @@ -58,13 +58,10 @@ float Game_RawHotbarScale, Game_RawChatScale, Game_RawInventoryScale; static struct ScheduledTask Game_Tasks[6]; static int Game_TasksCount, entTaskI; -static char Game_UsernameBuffer[FILENAME_SIZE]; -static char Game_MppassBuffer[STRING_SIZE]; -static char Game_HashBuffer[STRING_SIZE]; - -String Game_Username = String_FromArray(Game_UsernameBuffer); -String Game_Mppass = String_FromArray(Game_MppassBuffer); -String Game_Hash = String_FromArray(Game_HashBuffer); +static char usernameBuffer[FILENAME_SIZE]; +static char mppassBuffer[STRING_SIZE]; +String Game_Username = String_FromArray(usernameBuffer); +String Game_Mppass = String_FromArray(mppassBuffer); const char* const FpsLimit_Names[FPS_LIMIT_COUNT] = { "LimitVSync", "Limit30FPS", "Limit60FPS", "Limit120FPS", "Limit144FPS", "LimitNone", diff --git a/src/Game.h b/src/Game.h index da78c273c..940fc7b48 100644 --- a/src/Game.h +++ b/src/Game.h @@ -23,8 +23,7 @@ extern struct RayTracer Game_SelectedPos; extern cc_bool Game_UseCPEBlocks; extern String Game_Username; -extern String Game_Mppass; -extern String Game_Hash; +extern String Game_Mppass; extern int Game_ViewDistance; extern int Game_MaxViewDistance; diff --git a/src/LScreens.c b/src/LScreens.c index 1e44aaa23..239726ca3 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -3,7 +3,6 @@ #include "LWeb.h" #include "Launcher.h" #include "Gui.h" -#include "Game.h" #include "Drawer2D.h" #include "ExtMath.h" #include "Platform.h" @@ -878,9 +877,9 @@ static void MainScreen_TickFetchServers(struct MainScreen* s) { if (FetchServersTask.Base.success) { s->signingIn = false; - if (Game_Hash.length) { - Launcher_ConnectToServer(&Game_Hash); - Game_Hash.length = 0; + if (Launcher_AutoHash.length) { + Launcher_ConnectToServer(&Launcher_AutoHash); + Launcher_AutoHash.length = 0; } else { Launcher_SetScreen(ServersScreen_MakeInstance()); } diff --git a/src/Launcher.c b/src/Launcher.c index c4baa7b8e..06c03e0ea 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -28,6 +28,8 @@ static cc_bool pendingRedraw; static struct FontDesc logoFont; cc_bool Launcher_ShouldExit, Launcher_ShouldUpdate; +static char hashBuffer[STRING_SIZE]; +String Launcher_AutoHash = String_FromArray(hashBuffer); static void Launcher_ApplyUpdate(void); void Launcher_SetScreen(struct LScreen* screen) { diff --git a/src/Launcher.h b/src/Launcher.h index 5c64d75a2..a2436f882 100644 --- a/src/Launcher.h +++ b/src/Launcher.h @@ -26,6 +26,8 @@ extern struct FontDesc Launcher_HintFont; extern cc_bool Launcher_ShouldExit; /* Whether game should be updated on exit. */ extern cc_bool Launcher_ShouldUpdate; +/* (optional) Hash of the server the game should automatically try to connect to after signing in. */ +extern String Launcher_AutoHash; /* Base colour of pixels before any widgets are drawn. */ extern BitmapCol Launcher_BackgroundCol; diff --git a/src/Options.c b/src/Options.c index 6697b1c47..41377037d 100644 --- a/src/Options.c +++ b/src/Options.c @@ -3,7 +3,6 @@ #include "Funcs.h" #include "Platform.h" #include "Stream.h" -#include "Chat.h" #include "Errors.h" #include "Utils.h" #include "Logger.h" diff --git a/src/Program.c b/src/Program.c index 4f7befe9c..10c8273e9 100644 --- a/src/Program.c +++ b/src/Program.c @@ -124,7 +124,7 @@ static int Program_Run(int argc, char** argv) { /* :hash to auto join server with the given hash */ if (args[0].buffer[0] == ':') { args[0] = String_UNSAFE_SubstringAt(&args[0], 1); - String_Copy(&Game_Hash, &args[0]); + String_Copy(&Launcher_AutoHash, &args[0]); Launcher_Run(); return 0; } diff --git a/src/Utils.c b/src/Utils.c index 77d337fe5..9e6c5e94b 100644 --- a/src/Utils.c +++ b/src/Utils.c @@ -1,7 +1,5 @@ #include "Utils.h" #include "Bitmap.h" -#include "PackedCol.h" -#include "Chat.h" #include "Platform.h" #include "Stream.h" #include "Errors.h" @@ -183,7 +181,7 @@ int Convert_ToBase64(const cc_uint8* src, int len, char* dst) { return (int)(dst - beg); } -CC_NOINLINE static int Convert_DecodeBase64(char c) { +CC_NOINLINE static int DecodeBase64(char c) { if (c >= 'A' && c <= 'Z') return (c - 'A'); if (c >= 'a' && c <= 'z') return (c - 'a') + 26; if (c >= '0' && c <= '9') return (c - '0') + 52; @@ -202,16 +200,16 @@ int Convert_FromBase64(const char* src, int len, cc_uint8* dst) { /* 4 chars to 3 bytes */ /* stops on any invalid chars (also handles = padding) */ for (; len >= 4; len -= 4, src += 4) { - a = Convert_DecodeBase64(src[0]); - b = Convert_DecodeBase64(src[1]); + a = DecodeBase64(src[0]); + b = DecodeBase64(src[1]); if (a == -1 || b == -1) break; *dst++ = (a << 2) | (b >> 4); - c = Convert_DecodeBase64(src[2]); + c = DecodeBase64(src[2]); if (c == -1) break; *dst++ = (b << 4) | (c >> 2); - d = Convert_DecodeBase64(src[3]); + d = DecodeBase64(src[3]); if (d == -1) break; *dst++ = (c << 6) | (d ); } diff --git a/src/Vorbis.c b/src/Vorbis.c index 9b5a93e55..adceea512 100644 --- a/src/Vorbis.c +++ b/src/Vorbis.c @@ -2,7 +2,6 @@ #include "Logger.h" #include "Platform.h" #include "Event.h" -#include "Block.h" #include "ExtMath.h" #include "Funcs.h" #include "Errors.h"