Skip to content

Commit f860eff

Browse files
committed
Move command to ControlVariables
1 parent 1daf444 commit f860eff

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

src/game_interpreter.cpp

+27-28
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,6 @@ bool Game_Interpreter::ExecuteCommand(lcf::rpg::EventCommand const& com) {
821821
return CommandManiacSetGameOption(com);
822822
case Cmd::Maniac_CallCommand:
823823
return CommandManiacCallCommand(com);
824-
case static_cast<Game_Interpreter::Cmd>(2054): //Cmd::EasyRpg_GetTime
825-
return CommandGetTime(com);
826824
default:
827825
return true;
828826
}
@@ -1074,6 +1072,33 @@ bool Game_Interpreter::CommandControlSwitches(lcf::rpg::EventCommand const& com)
10741072
}
10751073

10761074
bool Game_Interpreter::CommandControlVariables(lcf::rpg::EventCommand const& com) { // code 10220
1075+
1076+
if (!com.string.empty()){
1077+
std::string periodName = Utils::LowerCase(ToString(com.string));
1078+
int32_t outputVariable = ValueOrVariable(com.parameters[0], com.parameters[1]);
1079+
1080+
std::time_t t = std::time(nullptr);
1081+
std::tm* tm = std::localtime(&t);
1082+
1083+
int32_t dateOutput{};
1084+
1085+
if (periodName == "getyear") dateOutput = tm->tm_year + 1900;
1086+
if (periodName == "getmonth") dateOutput = tm->tm_mon + 1;
1087+
if (periodName == "getday") dateOutput = tm->tm_mday;
1088+
if (periodName == "gethour") dateOutput = tm->tm_hour;
1089+
if (periodName == "getminute") dateOutput = tm->tm_min;
1090+
if (periodName == "getsecond") dateOutput = tm->tm_sec;
1091+
if (periodName == "getweekday") dateOutput = tm->tm_wday + 1;
1092+
if (periodName == "getyearday") dateOutput = tm->tm_yday + 1;
1093+
if (periodName == "getdaylightsavings") dateOutput = tm->tm_isdst + 1;
1094+
if (periodName == "gettimestamp") dateOutput = t;
1095+
1096+
Main_Data::game_variables->Set(outputVariable, dateOutput);
1097+
Game_Map::SetNeedRefresh(true);
1098+
1099+
return true;
1100+
}
1101+
10771102
int value = 0;
10781103
int operand = com.parameters[4];
10791104

@@ -4645,32 +4670,6 @@ bool Game_Interpreter::CommandManiacCallCommand(lcf::rpg::EventCommand const&) {
46454670
return true;
46464671
}
46474672

4648-
bool Game_Interpreter::CommandGetTime(lcf::rpg::EventCommand const& com) {
4649-
4650-
std::string periodName = Utils::LowerCase(ToString(com.string));
4651-
int32_t outputVariable = ValueOrVariable(com.parameters[0], com.parameters[1]);
4652-
4653-
std::time_t t = std::time(nullptr);
4654-
std::tm* tm = std::localtime(&t);
4655-
4656-
int32_t dateOutput{};
4657-
4658-
if (periodName == "getyear") dateOutput = tm->tm_year + 1900;
4659-
if (periodName == "getmonth") dateOutput = tm->tm_mon + 1;
4660-
if (periodName == "getday") dateOutput = tm->tm_mday;
4661-
if (periodName == "gethour") dateOutput = tm->tm_hour;
4662-
if (periodName == "getminute") dateOutput = tm->tm_min;
4663-
if (periodName == "getsecond") dateOutput = tm->tm_sec;
4664-
if (periodName == "getweekday") dateOutput = tm->tm_wday +1;
4665-
if (periodName == "getyearday") dateOutput = tm->tm_yday +1;
4666-
if (periodName == "gettimestamp") dateOutput = t;
4667-
4668-
Main_Data::game_variables->Set(outputVariable, dateOutput);
4669-
Game_Map::SetNeedRefresh(true);
4670-
4671-
return true;
4672-
}
4673-
46744673
Game_Interpreter& Game_Interpreter::GetForegroundInterpreter() {
46754674
return Game_Battle::IsBattleRunning()
46764675
? Game_Battle::GetInterpreter()

0 commit comments

Comments
 (0)