diff --git a/command.c b/command.c index 5b3da5be20..0e12d45f59 100644 --- a/command.c +++ b/command.c @@ -14,19 +14,7 @@ * If not, see . */ -#include "command.h" -#include -#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -#include "netplay.h" -#endif - -#include "general.h" -#include "runloop.h" -#include "compat/strl.h" -#include "compat/posix_string.h" -#include -#include #include #include @@ -35,6 +23,23 @@ #include #endif +#include +#include +#include +#include +#include + +#include + +#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) +#include "netplay.h" +#endif + +#include "command.h" + +#include "general.h" +#include "runloop.h" + #define DEFAULT_NETWORK_CMD_PORT 55355 #define STDIN_BUF_SIZE 4096 @@ -215,19 +220,31 @@ static const struct cmd_map map[] = { { "MENU_B", RETRO_DEVICE_ID_JOYPAD_B }, }; +#define COMMAND_EXT_GLSL 0x7c976537U +#define COMMAND_EXT_GLSLP 0x0f840c87U +#define COMMAND_EXT_CG 0x0059776fU +#define COMMAND_EXT_CGP 0x0b8865bfU + static bool cmd_set_shader(const char *arg) { char msg[PATH_MAX_LENGTH] = {0}; enum rarch_shader_type type = RARCH_SHADER_NONE; const char *ext = path_get_extension(arg); + uint32_t ext_hash = djb2_calculate(ext); - if (strcmp(ext, "glsl") == 0 || strcmp(ext, "glslp") == 0) - type = RARCH_SHADER_GLSL; - else if (strcmp(ext, "cg") == 0 || strcmp(ext, "cgp") == 0) - type = RARCH_SHADER_CG; - - if (type == RARCH_SHADER_NONE) - return false; + switch (ext_hash) + { + case COMMAND_EXT_GLSL: + case COMMAND_EXT_GLSLP: + type = RARCH_SHADER_GLSL; + break; + case COMMAND_EXT_CG: + case COMMAND_EXT_CGP: + type = RARCH_SHADER_CG; + break; + default: + return false; + } snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg); rarch_main_msg_queue_push(msg, 1, 120, true); @@ -247,7 +264,7 @@ static bool command_get_arg(const char *tok, for (i = 0; i < ARRAY_SIZE(map); i++) { - if (strcmp(tok, map[i].str) == 0) + if (!strcmp(tok, map[i].str)) { if (arg) *arg = NULL;