diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 353d66fa9f..cf159ac242 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -1072,6 +1072,33 @@ bool Game_Interpreter::CommandControlSwitches(lcf::rpg::EventCommand const& com) } bool Game_Interpreter::CommandControlVariables(lcf::rpg::EventCommand const& com) { // code 10220 + + if (!com.string.empty()){ + std::string periodName = Utils::LowerCase(ToString(com.string)); + int32_t outputVariable = ValueOrVariable(com.parameters[0], com.parameters[1]); + + std::time_t t = std::time(nullptr); + std::tm* tm = std::localtime(&t); + + int32_t dateOutput{}; + + if (periodName == "getyear") dateOutput = tm->tm_year + 1900; + if (periodName == "getmonth") dateOutput = tm->tm_mon + 1; + if (periodName == "getday") dateOutput = tm->tm_mday; + if (periodName == "gethour") dateOutput = tm->tm_hour; + if (periodName == "getminute") dateOutput = tm->tm_min; + if (periodName == "getsecond") dateOutput = tm->tm_sec; + if (periodName == "getweekday") dateOutput = tm->tm_wday + 1; + if (periodName == "getyearday") dateOutput = tm->tm_yday + 1; + if (periodName == "getdaylightsavings") dateOutput = tm->tm_isdst + 1; + if (periodName == "gettimestamp") dateOutput = t; + + Main_Data::game_variables->Set(outputVariable, dateOutput); + Game_Map::SetNeedRefresh(true); + + return true; + } + int value = 0; int operand = com.parameters[4]; diff --git a/src/game_interpreter.h b/src/game_interpreter.h index a436cbfaed..085fda3e7c 100644 --- a/src/game_interpreter.h +++ b/src/game_interpreter.h @@ -284,6 +284,7 @@ class Game_Interpreter bool CommandManiacChangePictureId(lcf::rpg::EventCommand const& com); bool CommandManiacSetGameOption(lcf::rpg::EventCommand const& com); bool CommandManiacCallCommand(lcf::rpg::EventCommand const& com); + bool CommandGetTime(lcf::rpg::EventCommand const& com); int DecodeInt(lcf::DBArray::const_iterator& it); const std::string DecodeString(lcf::DBArray::const_iterator& it);