From 980f90283ada07a6be566939568cc7985d5ce8ce Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 7 Aug 2024 14:39:10 +1000 Subject: [PATCH] Add /skin singleplayer command --- src/Commands.c | 20 ++++++++++++++++++++ src/Http_Worker.c | 5 +++++ src/Platform.h | 4 +++- src/Platform_Dreamcast.c | 3 ++- src/Platform_GCWii.c | 3 ++- src/Platform_MacClassic.c | 3 ++- src/Platform_N64.c | 3 ++- src/Platform_NDS.c | 3 ++- src/Platform_PS1.c | 1 + src/Platform_PS2.c | 1 + src/Platform_PS3.c | 3 ++- src/Platform_PSP.c | 3 ++- src/Platform_PSVita.c | 3 ++- src/Platform_Posix.c | 3 ++- src/Platform_Saturn.c | 1 + src/Platform_Switch.c | 3 ++- src/Platform_WiiU.c | 3 ++- src/Platform_Windows.c | 3 ++- src/Platform_Xbox.c | 3 ++- src/Platform_Xbox360.c | 3 ++- 20 files changed, 59 insertions(+), 15 deletions(-) diff --git a/src/Commands.c b/src/Commands.c index 872bd4655..f6c0adbb7 100644 --- a/src/Commands.c +++ b/src/Commands.c @@ -253,6 +253,25 @@ static struct ChatCommand ModelCommand = { } }; +static void SkinCommand_Execute(const cc_string* args, int argsCount) { + if (argsCount) { + Entity_SetSkin(&Entities.CurPlayer->Base, args); + } else { + Chat_AddRaw("&e/client skin: &cYou didn't specify a skin name."); + } +} + +static struct ChatCommand SkinCommand = { + "Skin", SkinCommand_Execute, + COMMAND_FLAG_SINGLEPLAYER_ONLY | COMMAND_FLAG_UNSPLIT_ARGS, + { + "&a/client skin [name]", + "&eChanges to the skin to the given player", + "&a/client skin [url]", + "&eChanges skin to a URL linking directly to a .PNG", + } +}; + static void ClearDeniedCommand_Execute(const cc_string* args, int argsCount) { int count = TextureCache_ClearDenied(); Chat_Add1("Removed &e%i &fdenied texture pack URLs.", &count); @@ -724,6 +743,7 @@ static void OnInit(void) { Commands_Register(&RenderTypeCommand); Commands_Register(&ResolutionCommand); Commands_Register(&ModelCommand); + Commands_Register(&SkinCommand); Commands_Register(&TeleportCommand); Commands_Register(&ClearDeniedCommand); Commands_Register(&MotdCommand); diff --git a/src/Http_Worker.c b/src/Http_Worker.c index fda781d70..2737e5770 100644 --- a/src/Http_Worker.c +++ b/src/Http_Worker.c @@ -935,6 +935,11 @@ static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* urlStr) { res = HttpBackend_PerformRequest(&state); retried = true; } + if (res == ReturnCode_SocketDropped && !retried) { + Platform_LogConst("Resetting connection due to being dropped.."); + res = HttpBackend_PerformRequest(&state); + retried = true; + } if (res || !HttpClient_IsRedirect(req)) break; if (redirects >= 20) return HTTP_ERR_REDIRECTS; diff --git a/src/Platform.h b/src/Platform.h index b2df2b845..f17f41bc0 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -31,9 +31,11 @@ enum File_SeekFrom { FILE_SEEKFROM_BEGIN, FILE_SEEKFROM_CURRENT, FILE_SEEKFROM_E extern const cc_result ReturnCode_FileShareViolation; extern const cc_result ReturnCode_FileNotFound; +extern const cc_result ReturnCode_DirectoryExists; extern const cc_result ReturnCode_SocketInProgess; extern const cc_result ReturnCode_SocketWouldBlock; -extern const cc_result ReturnCode_DirectoryExists; +/* Result code for when a socket connection has been dropped by the other side */ +extern const cc_result ReturnCode_SocketDropped; /* Whether the launcher and game must both be run in the same process */ /* (e.g. can't start a separate process on Mobile or Consoles) */ diff --git a/src/Platform_Dreamcast.c b/src/Platform_Dreamcast.c index 048b27155..e7fcd2c8c 100644 --- a/src/Platform_Dreamcast.c +++ b/src/Platform_Dreamcast.c @@ -30,9 +30,10 @@ KOS_INIT_FLAGS(INIT_CONTROLLER | INIT_KEYBOARD | INIT_MOUSE | const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " Dreamcast"; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_GCWii.c b/src/Platform_GCWii.c index eb9146d2b..359895e9f 100644 --- a/src/Platform_GCWii.c +++ b/src/Platform_GCWii.c @@ -30,9 +30,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = -EINPROGRESS; // net_XYZ error results are negative const cc_result ReturnCode_SocketWouldBlock = -EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = -EPIPE; #ifdef HW_RVL const char* Platform_AppNameSuffix = " Wii"; diff --git a/src/Platform_MacClassic.c b/src/Platform_MacClassic.c index 1b726b358..0fee02958 100644 --- a/src/Platform_MacClassic.c +++ b/src/Platform_MacClassic.c @@ -23,9 +23,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; const cc_result ReturnCode_FileNotFound = fnfErr; +const cc_result ReturnCode_DirectoryExists = dupFNErr; const cc_result ReturnCode_SocketInProgess = 1000000; const cc_result ReturnCode_SocketWouldBlock = 1000000; -const cc_result ReturnCode_DirectoryExists = dupFNErr; +const cc_result ReturnCode_SocketDropped = 1000000; static long sysVersion; #if TARGET_CPU_68K diff --git a/src/Platform_N64.c b/src/Platform_N64.c index 34d99952b..e63f375d7 100644 --- a/src/Platform_N64.c +++ b/src/Platform_N64.c @@ -23,9 +23,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " N64"; cc_bool Platform_ReadonlyFilesystem = true; diff --git a/src/Platform_NDS.c b/src/Platform_NDS.c index c6046a868..8014b3cd6 100644 --- a/src/Platform_NDS.c +++ b/src/Platform_NDS.c @@ -36,9 +36,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " NDS"; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_PS1.c b/src/Platform_PS1.c index c5964e3fd..c117d0f6b 100644 --- a/src/Platform_PS1.c +++ b/src/Platform_PS1.c @@ -33,6 +33,7 @@ const cc_result ReturnCode_DirectoryExists = 99999; const cc_result ReturnCode_SocketInProgess = -1; const cc_result ReturnCode_SocketWouldBlock = -1; +const cc_result ReturnCode_SocketDropped = -1; const char* Platform_AppNameSuffix = " PS1"; cc_bool Platform_ReadonlyFilesystem = true; diff --git a/src/Platform_PS2.c b/src/Platform_PS2.c index d9bf753f5..8f2c5c00b 100644 --- a/src/Platform_PS2.c +++ b/src/Platform_PS2.c @@ -46,6 +46,7 @@ const cc_result ReturnCode_DirectoryExists = -8; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; +const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " PS2"; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_PS3.c b/src/Platform_PS3.c index f14c524d4..23826e877 100644 --- a/src/Platform_PS3.c +++ b/src/Platform_PS3.c @@ -35,9 +35,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = 0x80010006; // ENOENT; +const cc_result ReturnCode_DirectoryExists = 0x80010014; // EEXIST const cc_result ReturnCode_SocketInProgess = NET_EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = NET_EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = 0x80010014; // EEXIST +const cc_result ReturnCode_SocketDropped = NET_EPIPE; const char* Platform_AppNameSuffix = " PS3"; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_PSP.c b/src/Platform_PSP.c index d86b7db51..caf572106 100644 --- a/src/Platform_PSP.c +++ b/src/Platform_PSP.c @@ -24,9 +24,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " PSP"; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_PSVita.c b/src/Platform_PSVita.c index 9aa856400..28f668898 100644 --- a/src/Platform_PSVita.c +++ b/src/Platform_PSVita.c @@ -16,9 +16,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = SCE_NET_ERROR_EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = SCE_NET_ERROR_EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = SCE_NET_ERROR_EPIPE; static int epoll_id; static int stdout_fd; diff --git a/src/Platform_Posix.c b/src/Platform_Posix.c index cb1dcbb7a..488f9a6d7 100644 --- a/src/Platform_Posix.c +++ b/src/Platform_Posix.c @@ -32,9 +32,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = EPIPE; #define SUPPORTS_GETADDRINFO 1 #if defined CC_BUILD_ANDROID diff --git a/src/Platform_Saturn.c b/src/Platform_Saturn.c index e5df90d5d..48609dd4a 100644 --- a/src/Platform_Saturn.c +++ b/src/Platform_Saturn.c @@ -31,6 +31,7 @@ const cc_result ReturnCode_DirectoryExists = 99999; const cc_result ReturnCode_SocketInProgess = -1; const cc_result ReturnCode_SocketWouldBlock = -1; +const cc_result ReturnCode_SocketDropped = -1; const char* Platform_AppNameSuffix = " Saturn"; cc_bool Platform_ReadonlyFilesystem = true; diff --git a/src/Platform_Switch.c b/src/Platform_Switch.c index 10ae49081..e20cacb1b 100644 --- a/src/Platform_Switch.c +++ b/src/Platform_Switch.c @@ -29,9 +29,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; // not used const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " Switch"; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_WiiU.c b/src/Platform_WiiU.c index f3ea61b0f..4175c7730 100644 --- a/src/Platform_WiiU.c +++ b/src/Platform_WiiU.c @@ -41,9 +41,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " Wii U"; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_Windows.c b/src/Platform_Windows.c index ebc8f7a32..26d3a16d4 100644 --- a/src/Platform_Windows.c +++ b/src/Platform_Windows.c @@ -37,9 +37,10 @@ static BOOL (WINAPI *_CryptUnprotectData)(DATA_BLOB* dataIn, PWSTR* dataDescr, P static HANDLE heap; const cc_result ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION; const cc_result ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND; +const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS; const cc_result ReturnCode_SocketInProgess = WSAEINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = WSAEWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS; +const cc_result ReturnCode_SocketDropped = WSAECONNRESET; const char* Platform_AppNameSuffix = ""; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_Xbox.c b/src/Platform_Xbox.c index 52bb11053..92470dd32 100644 --- a/src/Platform_Xbox.c +++ b/src/Platform_Xbox.c @@ -19,9 +19,10 @@ const cc_result ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION; const cc_result ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND; +const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = ERROR_ALREADY_EXISTS; +const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " XBox"; cc_bool Platform_ReadonlyFilesystem; diff --git a/src/Platform_Xbox360.c b/src/Platform_Xbox360.c index 244a7968e..11605ea54 100644 --- a/src/Platform_Xbox360.c +++ b/src/Platform_Xbox360.c @@ -25,9 +25,10 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; +const cc_result ReturnCode_SocketDropped = EPIPE; const char* Platform_AppNameSuffix = " XBox 360"; cc_bool Platform_ReadonlyFilesystem;