Replaced TAISEI_SANIC with --frameskip/-f
and fixed some more cli issues
This commit is contained in:
parent
b9d0e28fa0
commit
d41bb02753
5 changed files with 36 additions and 15 deletions
31
src/cli.c
31
src/cli.c
|
@ -39,6 +39,7 @@ int cli_args(int argc, char **argv, CLIAction *a) {
|
|||
{{"diff", required_argument, 0, 'd'}, "Select a difficulty (Easy/Normal/Hard/Lunatic)", "DIFF"},
|
||||
/* {{"sname", required_argument, 0, 'n'}, "Select stage by %s", "NAME"},*/
|
||||
{{"shotmode", required_argument, 0, 's'}, "Select a shotmode (marisaA/youmuA/marisaB/youmuB)", "SMODE"},
|
||||
{{"frameskip", optional_argument, 0, 'f'}, "Disable FPS limiter, render only every %s frame", "FRAME"},
|
||||
{{"dumpstages", no_argument, 0, 'u'}, "Print a list of all stages in the game", 0},
|
||||
#endif
|
||||
{{"help", no_argument, 0, 'h'}, "Display this help."},
|
||||
|
@ -56,9 +57,15 @@ int cli_args(int argc, char **argv, CLIAction *a) {
|
|||
opts[i] = taisei_opts[i].opt;
|
||||
*ptr = opts[i].val;
|
||||
ptr++;
|
||||
|
||||
if(opts[i].has_arg != no_argument) {
|
||||
*ptr = ':';
|
||||
ptr++;
|
||||
|
||||
if(opts[i].has_arg == optional_argument) {
|
||||
*ptr = ':';
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
*ptr = 0;
|
||||
|
@ -80,7 +87,8 @@ int cli_args(int argc, char **argv, CLIAction *a) {
|
|||
ShotMode shot = INVALID_SHOT;
|
||||
|
||||
while((c = getopt_long(argc, argv, optc, opts, 0)) != -1) {
|
||||
char *endptr;
|
||||
char *endptr = NULL;
|
||||
|
||||
switch(c) {
|
||||
case 'h':
|
||||
case '?':
|
||||
|
@ -96,9 +104,9 @@ int cli_args(int argc, char **argv, CLIAction *a) {
|
|||
a->type = CLI_SelectStage;
|
||||
break;
|
||||
case 'i':
|
||||
stageid = strtol(optarg,&endptr, 16);
|
||||
if(*optarg == 0 || *endptr != 0)
|
||||
log_fatal("stage id '%s' is not a number", optarg);
|
||||
stageid = strtol(optarg, &endptr, 16);
|
||||
if(!*optarg || endptr == optarg)
|
||||
log_fatal("Stage id '%s' is not a number", optarg);
|
||||
break;
|
||||
case 'u':
|
||||
a->type = CLI_DumpStages;
|
||||
|
@ -121,6 +129,21 @@ int cli_args(int argc, char **argv, CLIAction *a) {
|
|||
if(plrmode_parse(optarg,&cha,&shot))
|
||||
log_fatal("Invalid shotmode '%s'",optarg);
|
||||
break;
|
||||
case 'f':
|
||||
a->frameskip = 1;
|
||||
|
||||
if(optarg) {
|
||||
a->frameskip = strtol(optarg, &endptr, 10);
|
||||
|
||||
if(endptr == optarg) {
|
||||
log_fatal("Frameskip value '%s' is not a number", optarg);
|
||||
}
|
||||
|
||||
if(a->frameskip < 0) {
|
||||
a->frameskip = INT_MAX;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
log_fatal("Unknown option (this shouldn’t happen)");
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ struct CLIAction {
|
|||
char *filename;
|
||||
int stageid;
|
||||
int diff;
|
||||
int frameskip;
|
||||
|
||||
Character plrcha;
|
||||
ShotMode plrshot;
|
||||
|
|
14
src/global.c
14
src/global.c
|
@ -9,24 +9,20 @@
|
|||
|
||||
Global global;
|
||||
|
||||
void init_global(void) {
|
||||
void init_global(CLIAction *cli) {
|
||||
memset(&global, 0, sizeof(global));
|
||||
|
||||
tsrand_init(&global.rand_game, time(0));
|
||||
tsrand_init(&global.rand_visual, time(0));
|
||||
|
||||
tsrand_switch(&global.rand_visual);
|
||||
|
||||
memset(&resources, 0, sizeof(Resources));
|
||||
|
||||
memset(&global.replay, 0, sizeof(Replay));
|
||||
|
||||
global.replaymode = REPLAY_RECORD;
|
||||
global.frameskip = cli->frameskip;
|
||||
|
||||
if(global.frameskip = getenvint("TAISEI_SANIC")) {
|
||||
if(global.frameskip < 0) {
|
||||
global.frameskip = INT_MAX;
|
||||
}
|
||||
|
||||
log_warn("FPS limiter disabled by environment. Gotta go fast! (frameskip = %i)", global.frameskip);
|
||||
if(global.frameskip) {
|
||||
log_warn("FPS limiter disabled. Gotta go fast! (frameskip = %i)", global.frameskip);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "color.h"
|
||||
#include "audio.h"
|
||||
#include "rwops/all.h"
|
||||
#include "cli.h"
|
||||
|
||||
#define FILE_PREFIX PREFIX "/share/taisei/"
|
||||
#define CONFIG_FILE "config"
|
||||
|
@ -128,6 +129,6 @@ typedef struct {
|
|||
|
||||
extern Global global;
|
||||
|
||||
void init_global(void);
|
||||
void init_global(CLIAction *cli);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -159,7 +159,7 @@ int main(int argc, char **argv) {
|
|||
log_lib_versions();
|
||||
|
||||
init_sdl();
|
||||
init_global();
|
||||
init_global(&a);
|
||||
video_init();
|
||||
init_resources();
|
||||
draw_loading_screen();
|
||||
|
|
Loading…
Reference in a new issue