cli tweaks
- case insensitive difficulty/shotmode - remove dumprestable - '-' shortcut for stdin
This commit is contained in:
parent
44d2ab8f6c
commit
84021e78bd
7 changed files with 21 additions and 29 deletions
11
src/cli.c
11
src/cli.c
|
@ -40,7 +40,6 @@ int cli_args(int argc, char **argv, CLIAction *a) {
|
|||
/* {{"sname", required_argument, 0, 'n'}, "Select stage by %s", "NAME"},*/
|
||||
{{"shotmode", required_argument, 0, 's'}, "Select a shotmode (marisaA/youmuA/marisaB/youmuB)", "SMODE"},
|
||||
{{"dumpstages", no_argument, 0, 'u'}, "Print a list of all stages in the game", 0},
|
||||
{{"dumprestables", no_argument, 0, 't'}, "Print information about the resource hashtables", 0},
|
||||
#endif
|
||||
{{"help", no_argument, 0, 'h'}, "Display this help."},
|
||||
{{0,0,0,0},0,0}
|
||||
|
@ -64,6 +63,11 @@ int cli_args(int argc, char **argv, CLIAction *a) {
|
|||
}
|
||||
*ptr = 0;
|
||||
|
||||
// on OS X, programs get passed some strange parameter when they are run from bundles.
|
||||
for(int i = 0; i < argc; i++) {
|
||||
if(strstartswith(argv[i],"-psn_"))
|
||||
argv[i][0] = 0;
|
||||
}
|
||||
|
||||
int c;
|
||||
int stageid = -1;
|
||||
|
@ -92,12 +96,9 @@ int cli_args(int argc, char **argv, CLIAction *a) {
|
|||
case 'u':
|
||||
a->type = CLI_DumpStages;
|
||||
break;
|
||||
case 't':
|
||||
a->type = CLI_DumpResTables;
|
||||
break;
|
||||
case 'd':
|
||||
for(int i = D_Easy ; i <= NUM_SELECTABLE_DIFFICULTIES; i++) {
|
||||
if(strcmp(optarg,difficulty_name(i)) == 0) {
|
||||
if(strcasecmp(optarg,difficulty_name(i)) == 0) {
|
||||
a->diff = i;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,7 @@ typedef enum {
|
|||
CLI_PlayReplay,
|
||||
CLI_SelectStage,
|
||||
CLI_DumpStages,
|
||||
CLI_DumpResTables,
|
||||
CLI_Quit,
|
||||
|
||||
CLI_ARGC = 4
|
||||
} CLIActionType;
|
||||
|
||||
typedef struct CLIAction CLIAction;
|
||||
|
|
|
@ -178,11 +178,6 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if(a.type == CLI_DumpResTables) {
|
||||
print_resource_hashtables();
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_warn("Compiled with DEBUG flag!");
|
||||
|
||||
if(a.type == CLI_SelectStage) {
|
||||
|
|
|
@ -563,7 +563,7 @@ int plrmode_repr(char *out, size_t outsize, Character pchar, ShotMode pshot) {
|
|||
|
||||
switch(pchar) {
|
||||
case Marisa : plr = "marisa" ; break;
|
||||
case Youmu : plr = "youmu" ; break;
|
||||
case Youmu : plr = "youmu" ; break;
|
||||
default : plr = "wtf" ; break;
|
||||
}
|
||||
|
||||
|
@ -578,13 +578,13 @@ int plrmode_repr(char *out, size_t outsize, Character pchar, ShotMode pshot) {
|
|||
|
||||
// Inverse of plrmode_repr. Sets cha/shot according to name. Returns 0 iff the name is valid.
|
||||
int plrmode_parse(const char *name, Character *cha, ShotMode *shot) {
|
||||
if(!strcmp(name,"marisaA")) {
|
||||
if(!strcasecmp(name,"marisaA")) {
|
||||
*cha = Marisa; *shot = MarisaLaser;
|
||||
} else if(!strcmp(name,"marisaB")) {
|
||||
} else if(!strcasecmp(name,"marisaB")) {
|
||||
*cha = Marisa; *shot = MarisaStar;
|
||||
} else if(!strcmp(name,"youmuA")) {
|
||||
} else if(!strcasecmp(name,"youmuA")) {
|
||||
*cha = Youmu; *shot = YoumuOpposite;
|
||||
} else if(!strcmp(name,"youmuB")) {
|
||||
} else if(!strcasecmp(name,"youmuB")) {
|
||||
*cha = Youmu; *shot = YoumuHoming;
|
||||
} else {
|
||||
return 1;
|
||||
|
|
13
src/replay.c
13
src/replay.c
|
@ -479,7 +479,7 @@ int replay_read(Replay *rpy, SDL_RWops *file, ReplayReadMode mode) {
|
|||
#undef PRINTPROP
|
||||
|
||||
char* replay_getpath(const char *name, bool ext) {
|
||||
return ext ? strfmt("%s/%s.%s", get_replays_path(), name, REPLAY_EXTENSION) :
|
||||
return ext ? strfmt("%s/%s.%s", get_replays_path(), name, REPLAY_EXTENSION) :
|
||||
strfmt("%s/%s", get_replays_path(), name);
|
||||
}
|
||||
|
||||
|
@ -510,8 +510,15 @@ int replay_load(Replay *rpy, const char *name, ReplayReadMode mode) {
|
|||
}
|
||||
|
||||
log_info("replay_load(): loading %s (mode %i)", p, mode);
|
||||
|
||||
SDL_RWops *file = SDL_RWFromFile(p, "rb");
|
||||
SDL_RWops *file;
|
||||
#ifndef __WINDOWS__
|
||||
if(!strcmp(name,"-"))
|
||||
file = SDL_RWFromFP(stdin,false);
|
||||
else
|
||||
file = SDL_RWFromFile(p, "rb");
|
||||
#else
|
||||
file = SDL_RWFromFile(p, "rb");
|
||||
#endif
|
||||
|
||||
if(!(mode & REPLAY_READ_RAWPATH)) {
|
||||
free(p);
|
||||
|
|
|
@ -448,9 +448,3 @@ void free_resources(bool all) {
|
|||
|
||||
free_fonts();
|
||||
}
|
||||
|
||||
void print_resource_hashtables(void) {
|
||||
for(ResourceType type = 0; type < RES_NUMTYPES; ++type) {
|
||||
hashtable_print_stringkeys(get_handler(type)->mapping);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,8 +120,6 @@ void resource_util_strip_ext(char *path);
|
|||
char* resource_util_basename(const char *prefix, const char *path);
|
||||
const char* resource_util_filename(const char *path);
|
||||
|
||||
void print_resource_hashtables(void);
|
||||
|
||||
bool resource_sdl_event(SDL_Event *evt);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue