mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 01:21:57 -05:00
Fix when starting the game via dropping a map file onto it, your in-game player used file path for name/skin instead of default username (Thanks Neonium)
This commit is contained in:
parent
6755047052
commit
8deb8044e9
5 changed files with 13 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue