mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-23 01:21:57 -05:00
Fix window titlebar showing path instead of username when autoloading maps in singleplayer
This commit is contained in:
parent
e52b670b6e
commit
383c3a6cb7
4 changed files with 16 additions and 10 deletions
|
@ -56,7 +56,7 @@ cc_bool Game_ViewBobbing, Game_HideGui, Game_DefaultZipMissing;
|
|||
cc_bool Game_BreakableLiquids, Game_ScreenshotRequested;
|
||||
struct GameVersion Game_Version;
|
||||
|
||||
static char usernameBuffer[FILENAME_SIZE];
|
||||
static char usernameBuffer[STRING_SIZE];
|
||||
static char mppassBuffer[STRING_SIZE];
|
||||
cc_string Game_Username = String_FromArray(usernameBuffer);
|
||||
cc_string Game_Mppass = String_FromArray(mppassBuffer);
|
||||
|
|
|
@ -67,6 +67,8 @@ static void SetupProgram(int argc, char** argv) {
|
|||
String_InitArray(Server.Address, ipBuffer);
|
||||
}
|
||||
|
||||
#define SP_HasDir(path) (String_IndexOf(&path, '/') >= 0 || String_IndexOf(&path, '\\') >= 0)
|
||||
|
||||
static int RunProgram(int argc, char** argv) {
|
||||
cc_string args[GAME_MAX_CMDARGS];
|
||||
cc_uint16 port;
|
||||
|
@ -90,6 +92,11 @@ static int RunProgram(int argc, char** argv) {
|
|||
args[0] = String_UNSAFE_SubstringAt(&args[0], 1);
|
||||
String_Copy(&Launcher_AutoHash, &args[0]);
|
||||
Launcher_Run();
|
||||
/* File path to auto load a map in singleplayer */
|
||||
} else if (argsCount == 1 && SP_HasDir(args[0]) && File_Exists(&args[0])) {
|
||||
Options_Get(LOPT_USERNAME, &Game_Username, DEFAULT_USERNAME);
|
||||
String_Copy(&SP_AutoloadMap, &args[0]); /* TODO: don't copy args? */
|
||||
RunGame();
|
||||
#endif
|
||||
} else if (argsCount == 1) {
|
||||
String_Copy(&Game_Username, &args[0]);
|
||||
|
|
14
src/Server.c
14
src/Server.c
|
@ -111,7 +111,9 @@ static void Ping_Reset(void) {
|
|||
/*########################################################################################################################*
|
||||
*-------------------------------------------------Singleplayer connection-------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#define SP_HasDir(path) (String_IndexOf(&path, '/') >= 0 || String_IndexOf(&path, '\\') >= 0)
|
||||
static char autoloadBuffer[FILENAME_SIZE];
|
||||
cc_string SP_AutoloadMap = String_FromArray(autoloadBuffer);
|
||||
|
||||
static void SPConnection_BeginConnect(void) {
|
||||
static const cc_string logName = String_FromConst("Singleplayer");
|
||||
cc_string path;
|
||||
|
@ -120,14 +122,8 @@ static void SPConnection_BeginConnect(void) {
|
|||
Game_UseCPEBlocks = Game_UseCPE;
|
||||
|
||||
/* For when user drops a map file onto ClassiCube.exe */
|
||||
path = Game_Username;
|
||||
if (SP_HasDir(path) && File_Exists(&path)) {
|
||||
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;
|
||||
if (SP_AutoloadMap.length) {
|
||||
Map_LoadFrom(&SP_AutoloadMap); return;
|
||||
}
|
||||
|
||||
Random_SeedFromCurrentTime(&rnd);
|
||||
|
|
|
@ -68,4 +68,7 @@ CC_VAR extern struct _ServerConnectionData {
|
|||
/* If user hasn't previously accepted url, displays a dialog asking to confirm downloading it */
|
||||
/* Otherwise just calls TexturePack_Extract */
|
||||
void Server_RetrieveTexturePack(const cc_string* url);
|
||||
|
||||
/* Path of map to automatically load in singleplayer */
|
||||
extern cc_string SP_AutoloadMap;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue