diff --git a/src/Constants.h b/src/Constants.h index c00954368..51db28b8c 100644 --- a/src/Constants.h +++ b/src/Constants.h @@ -80,4 +80,6 @@ enum SKIN_TYPE { SKIN_64x32, SKIN_64x64, SKIN_64x64_SLIM, SKIN_INVALID = 0xF0 }; #define RESOURCE_SERVER "http://static.classicube.net" /* Webpage where users can register for a new account */ #define REGISTERNEW_URL "https://www.classicube.net/acc/register/" + +#define DEFAULT_USERNAME "Singleplayer" #endif diff --git a/src/Http_Worker.c b/src/Http_Worker.c index 810a01b11..c4a7b5670 100644 --- a/src/Http_Worker.c +++ b/src/Http_Worker.c @@ -396,6 +396,8 @@ static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) { /* must be at least CURL_ERROR_SIZE (256) in size */ req->error = Mem_TryAllocCleared(257, 1); _curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, req->error); + /* TODO stackalloc instead and then copy to dynamic array later? */ + /* probably not worth the extra complexity though */ req->_capacity = 0; http_curProgress = HTTP_PROGRESS_FETCHING_DATA; diff --git a/src/LScreens.c b/src/LScreens.c index ed923c6c4..c03a5b39a 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -753,7 +753,7 @@ static void MainScreen_Resume(void* w) { } static void MainScreen_Singleplayer(void* w) { - static const cc_string defUser = String_FromConst("Singleplayer"); + static const cc_string defUser = String_FromConst(DEFAULT_USERNAME); const cc_string* user = &MainScreen.iptUsername.text; if (!user->length) user = &defUser; diff --git a/src/Program.c b/src/Program.c index 3b2105220..ca83a9521 100644 --- a/src/Program.c +++ b/src/Program.c @@ -81,7 +81,7 @@ static int RunProgram(int argc, char** argv) { if (argsCount == 0) { #ifdef CC_BUILD_WEB - String_AppendConst(&Game_Username, "WebTest!"); + String_AppendConst(&Game_Username, DEFAULT_USERNAME); RunGame(); #else Launcher_Run(); diff --git a/src/Server.c b/src/Server.c index 4100695a3..46aabce95 100644 --- a/src/Server.c +++ b/src/Server.c @@ -24,6 +24,7 @@ #include "Platform.h" #include "Input.h" #include "Errors.h" +#include "Options.h" static char nameBuffer[STRING_SIZE]; static char motdBuffer[STRING_SIZE]; @@ -121,7 +122,12 @@ static void SPConnection_BeginConnect(void) { /* For when user drops a map file onto ClassiCube.exe */ path = Game_Username; if (SP_HasDir(path) && File_Exists(&path)) { - Map_LoadFrom(&path); return; + Map_LoadFrom(&path); + Options_Get(LOPT_USERNAME, &Game_Username, DEFAULT_USERNAME); + /* TODO Entity_SetNameSkin function? */ + Entity_SetName(&LocalPlayer_Instance.Base, &Game_Username); + Entity_SetSkin(&LocalPlayer_Instance.Base, &Game_Username); + return; } Random_SeedFromCurrentTime(&rnd);