| 3229 | } |
| 3230 | |
| 3231 | bool Game_Interpreter::CommandKeyInputProc(lcf::rpg::EventCommand const& com) { // code 11610 |
| 3232 | int var_id = com.parameters[0]; |
| 3233 | bool wait = com.parameters[1] != 0; |
| 3234 | |
| 3235 | if (wait) { |
| 3236 | // While waiting the variable is reset to 0 each frame. |
| 3237 | Main_Data::game_variables->Set(var_id, 0); |
| 3238 | Game_Map::SetNeedRefreshForVarChange(var_id); |
| 3239 | } |
| 3240 | |
| 3241 | if (wait && Game_Message::IsMessageActive()) { |
| 3242 | return false; |
| 3243 | } |
| 3244 | |
| 3245 | _keyinput = {}; |
| 3246 | _keyinput.wait = wait; |
| 3247 | _keyinput.variable = var_id; |
| 3248 | |
| 3249 | const size_t param_size = com.parameters.size(); |
| 3250 | |
| 3251 | // Maniac Patch aware check functions for parameters that handle |
| 3252 | // keyboard and mouse through a bitmask |
| 3253 | bool is_maniac = Player::IsPatchManiac(); |
| 3254 | auto check_key = [&](auto idx, bool handle_maniac = false) { |
| 3255 | if (param_size <= idx) { |
| 3256 | return false; |
| 3257 | } |
| 3258 | if (handle_maniac && is_maniac) { |
| 3259 | return (com.parameters[idx] & 1) != 0; |
| 3260 | } else { |
| 3261 | return com.parameters[idx] != 0; |
| 3262 | } |
| 3263 | }; |
| 3264 | |
| 3265 | _keyinput.keys[Keys::eDecision] = check_key(3u, true); |
| 3266 | _keyinput.keys[Keys::eCancel] = check_key(4u, true); |
| 3267 | |
| 3268 | // All engines support older versions of the command depending on the |
| 3269 | // length of the parameter list |
| 3270 | if (Player::IsRPG2k()) { |
| 3271 | if (param_size < 6 || Player::IsRPG2kLegacy()) { |
| 3272 | // For Rpg2k <1.50 (later versions got individual key checks) |
| 3273 | if (com.parameters[2] != 0) { |
| 3274 | _keyinput.keys[Keys::eDown] = true; |
| 3275 | _keyinput.keys[Keys::eLeft] = true; |
| 3276 | _keyinput.keys[Keys::eRight] = true; |
| 3277 | _keyinput.keys[Keys::eUp] = true; |
| 3278 | } |
| 3279 | } else { |
| 3280 | // For Rpg2k >=1.50 |
| 3281 | _keyinput.keys[Keys::eShift] = com.parameters[5] != 0; |
| 3282 | _keyinput.keys[Keys::eDown] = check_key(6u); |
| 3283 | _keyinput.keys[Keys::eLeft] = check_key(7u); |
| 3284 | _keyinput.keys[Keys::eRight] = check_key(8u); |
| 3285 | _keyinput.keys[Keys::eUp] = check_key(9u); |
| 3286 | } |
| 3287 | } else { |
| 3288 | if (param_size != 10 || Player::IsRPG2k3Legacy()) { |
nothing calls this directly
no test coverage detected