MCPcopy Create free account
hub / github.com/EasyRPG/Player / ParseCommandLine

Method ParseCommandLine

src/player.cpp:433–683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

431}
432
433Game_Config Player::ParseCommandLine() {
434 debug_flag = false;
435 hide_title_flag = false;
436 exit_flag = false;
437 reset_flag = false;
438 load_game_id = -1;
439 party_x_position = -1;
440 party_y_position = -1;
441 start_map_id = -1;
442 no_rtp_flag = false;
443 no_audio_flag = false;
444 is_easyrpg_project = false;
445 Game_Battle::battle_test.enabled = false;
446
447 std::stringstream ss;
448 for (size_t i = 1; i < arguments.size(); ++i) {
449 ss << arguments[i] << " ";
450 }
451 command_line = ss.str();
452
453 CmdlineParser cp(arguments);
454 auto cfg = Game_Config::Create(cp);
455
456 bool battletest_handled = false;
457
458 cp.Rewind();
459 if (!cp.Done()) {
460 // BattleTest argument handling in a RPG_RT compatible way is very ugly because the arguments do not follow
461 // directly. Try to parse it and afterwards rewind the parser to parse the rest.
462 CmdlineArg arg;
463 long li_value = 0;
464
465 // Legacy BattleTest handling: When BattleTest is argument 1, then the values are:
466 // - arg4: troop_id
467 // - arg5-7: formation, condition, terrain_id (2k3 only)
468 // - arg2-3 are unrelated ("ShowTitle Window")
469 if (cp.ParseNext(arg, 6, {"battletest"})) {
470 Game_Battle::battle_test.enabled = true;
471 Game_Battle::battle_test.troop_id = 0;
472
473 // Starting from 3 to reach arg4 from arg1
474 if (arg.NumValues() >= 3) {
475 if (arg.ParseValue(2, li_value)) {
476 Game_Battle::battle_test.troop_id = li_value;
477 }
478 }
479
480 if (arg.NumValues() >= 6) {
481 if (arg.ParseValue(3, li_value)) {
482 Game_Battle::battle_test.formation = static_cast<lcf::rpg::System::BattleFormation>(li_value);
483 }
484 if (arg.ParseValue(4, li_value)) {
485 Game_Battle::battle_test.condition = static_cast<lcf::rpg::System::BattleCondition>(li_value);
486 }
487 if (arg.ParseValue(5, li_value)) {
488 Game_Battle::battle_test.terrain_id = static_cast<lcf::rpg::System::BattleFormation>(li_value);
489 }
490 }

Callers

nothing calls this directly

Calls 12

ParseNextMethod · 0.80
NumValuesMethod · 0.80
ParseValueMethod · 0.80
RewindByMethod · 0.80
ValueMethod · 0.80
SkipNextMethod · 0.80
sizeMethod · 0.45
RewindMethod · 0.45
DoneMethod · 0.45
SetMethod · 0.45
CreateMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected