@@ -185,6 +185,27 @@ void RuntimePatches::DetermineActivePatches(std::vector<std::string>& patches) {
185
185
#endif
186
186
}
187
187
188
+ void RuntimePatches::OnResetGameObjects () {
189
+ #ifdef NO_RUNTIME_PATCHES
190
+ // no-op
191
+ return ;
192
+ #endif
193
+ if (Player::game_config.patch_powermode .Get ()) {
194
+ Player::game_config.new_game .Set (true );
195
+ Main_Data::game_variables->Set (PowerMode2003::PM_VAR_CR0, FileFinder::HasSavegame () ? 1 : 0 );
196
+ }
197
+ }
198
+
199
+ void RuntimePatches::OnLoadSavegame () {
200
+ #ifdef NO_RUNTIME_PATCHES
201
+ // no-op
202
+ return ;
203
+ #endif
204
+ if (Player::game_config.patch_powermode .Get ()) {
205
+ Main_Data::game_variables->Set (PowerMode2003::PM_VAR_CR0, FileFinder::HasSavegame () ? 1 : 0 );
206
+ }
207
+ }
208
+
188
209
void RuntimePatches::OnVariableChanged (int variable_id) {
189
210
#ifdef NO_RUNTIME_PATCHES
190
211
// no-op
@@ -195,6 +216,7 @@ void RuntimePatches::OnVariableChanged(int variable_id) {
195
216
PowerMode2003::HandleVariableHooks (variable_id);
196
217
}
197
218
}
219
+
198
220
void RuntimePatches::OnVariableChanged (std::initializer_list<int > variable_ids) {
199
221
#ifdef NO_RUNTIME_PATCHES
200
222
// no-op
@@ -436,6 +458,27 @@ bool RuntimePatches::GuardRevamp::OverrideDamageAdjustment(int& dmg, const Game_
436
458
}
437
459
438
460
namespace RuntimePatches ::PowerMode2003 {
461
+ void HandleCommands () {
462
+ int op = Main_Data::game_variables->Get (PM_VAR_CR0);
463
+ if (op == 255 && FileFinder::HasSavegame ()) {
464
+ Scene::instance->SetRequestedScene (std::make_shared<Scene_Load>());
465
+ } else if (op == 254 ) {
466
+ Player::exit_flag = true ;
467
+ }
468
+ Main_Data::game_variables->Set (PM_VAR_CR0, FileFinder::HasSavegame () ? 1 : 0 );
469
+ }
470
+
471
+ void HandleMouse () {
472
+ #if !defined(USE_MOUSE_OR_TOUCH) || !defined(SUPPORT_MOUSE_OR_TOUCH)
473
+ Output::Warning (" PowerMode2003: Mouse input is not supported on this platform" );
474
+ return ;
475
+ #endif
476
+ Point mouse_pos = Input::GetMousePosition ();
477
+ Main_Data::game_variables->Set (PM_VAR_MCOORDX, mouse_pos.x );
478
+ Main_Data::game_variables->Set (PM_VAR_MCOORDY, mouse_pos.y );
479
+
480
+ }
481
+
439
482
void HandleKeyboard () {
440
483
#if !defined(SUPPORT_KEYBOARD)
441
484
Output::Warning (" PowerMode2003: Keyboard input is not supported on this platform" );
@@ -511,17 +554,6 @@ namespace RuntimePatches::PowerMode2003 {
511
554
}
512
555
}
513
556
514
- void RuntimePatches::PowerMode2003::Init () {
515
- #ifdef NO_RUNTIME_PATCHES
516
- // no-op
517
- return ;
518
- #endif
519
- if (Player::game_config.patch_powermode .Get ()) {
520
- Player::game_config.new_game .Set (true );
521
- Main_Data::game_variables->Set (PM_VAR_CR0, FileFinder::HasSavegame () ? 1 : 0 );
522
- }
523
- }
524
-
525
557
void RuntimePatches::PowerMode2003::HandleVariableHooks (int var_id) {
526
558
#ifdef NO_RUNTIME_PATCHES
527
559
// no-op
@@ -530,24 +562,12 @@ void RuntimePatches::PowerMode2003::HandleVariableHooks(int var_id) {
530
562
#endif
531
563
switch (var_id) {
532
564
case PM_VAR_CR0:
533
- {
534
- int op = Main_Data::game_variables->Get (PM_VAR_CR0);
535
- if (op == 255 && FileFinder::HasSavegame ()) {
536
- Scene::instance->SetRequestedScene (std::make_shared<Scene_Load>());
537
- } else if (op == 254 ) {
538
- Player::exit_flag = true ;
539
- }
540
- Main_Data::game_variables->Set (PM_VAR_CR0, FileFinder::HasSavegame () ? 1 : 0 );
565
+ HandleCommands ();
541
566
break ;
542
- }
543
567
case PM_VAR_MCOORDY:
544
- {
545
- Point mouse_pos = Input::GetMousePosition ();
546
- Main_Data::game_variables->Set (PM_VAR_MCOORDX, mouse_pos.x );
547
- Main_Data::game_variables->Set (PM_VAR_MCOORDY, mouse_pos.y );
568
+ HandleMouse ();
548
569
Game_Map::SetNeedRefreshForVarChange (PM_VAR_MCOORDX);
549
570
break ;
550
- }
551
571
case PM_VAR_KEY:
552
572
HandleKeyboard ();
553
573
break ;
0 commit comments