]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/SelectItem.cpp
store an application handle in each state
[l2e.git] / src / battle / states / SelectItem.cpp
index 35a0c61ca9262bf2deebb68f6805133d9aa7f04a..fe6ce7b3ba7dc9fa8e1addc5382883012317e3d0 100644 (file)
@@ -24,11 +24,11 @@ using graphics::Frame;
 namespace battle {
 
 void SelectItem::OnEnterState(Application &c, SDL_Surface *screen) {
-       ctrl = &c;
+
 }
 
 void SelectItem::OnExitState(Application &c, SDL_Surface *screen) {
-       ctrl = 0;
+
 }
 
 void SelectItem::OnResumeState(Application &ctrl, SDL_Surface *screen) {
@@ -64,19 +64,19 @@ void SelectItem::HandleEvents(const Input &input) {
                                ac.SetType(AttackChoice::ITEM);
                                ac.SetItem(item);
                                battle->NextHero();
-                               ctrl->PopState();
+                               Ctrl().PopState();
                        } else {
                                if (item->GetTargetingMode().TargetsSingle()) {
                                        ac.Selection().SetSingle();
                                } else {
                                        ac.Selection().SetMultiple();
                                }
-                               ctrl->PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().itemTargetCursor));
+                               Ctrl().PushState(new SelectTarget(battle, parent, &ac.Selection(), battle->Res().itemTargetCursor));
                        }
                }
        }
        if (input.JustPressed(Input::ACTION_B)) {
-               ctrl->PopState(); // return control to parent
+               Ctrl().PopState(); // return control to parent
        }
        if (input.JustPressed(Input::PAD_UP)) {
                battle->ItemMenu().PreviousRow();