diff options
author | Aki <please@ignore.pl> | 2022-04-06 21:28:00 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-04-06 21:53:47 +0200 |
commit | 947910fc3c541ffdab3b042cfa3a3926b64f0ba3 (patch) | |
tree | a4d6b261d0edaa516d34b3fcb4baa8f84381adad /StarsEx/Starshatter.cpp | |
parent | a793e933b1e7e5b62fe4e15403e1d5fb33dc2dd4 (diff) | |
download | starshatter-947910fc3c541ffdab3b042cfa3a3926b64f0ba3.zip starshatter-947910fc3c541ffdab3b042cfa3a3926b64f0ba3.tar.gz starshatter-947910fc3c541ffdab3b042cfa3a3926b64f0ba3.tar.bz2 |
Streamlined instance management for Game and derived classes
Diffstat (limited to 'StarsEx/Starshatter.cpp')
-rw-r--r-- | StarsEx/Starshatter.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/StarsEx/Starshatter.cpp b/StarsEx/Starshatter.cpp index 65c7d13..23ba839 100644 --- a/StarsEx/Starshatter.cpp +++ b/StarsEx/Starshatter.cpp @@ -121,7 +121,7 @@ Mission* quick_mission = 0; int Starshatter::keymap[256]; int Starshatter::keyalt[256]; -Starshatter* Starshatter::instance = 0; +Starshatter* Starshatter::instance {nullptr}; static Mission* current_mission = 0; static Mission* cutscene_mission = 0; @@ -158,7 +158,8 @@ lens_flare(true), corona(true), nebula(true), dust(0), load_step(0), load_progress(0), chat_mode(0), exit_time(1.2), cutscene(0) { - if (!instance) + if (instance != nullptr) + throw "Starshatter may have only one instance"; instance = this; app_name = "Starshatter: The Open Source Project"; @@ -311,7 +312,8 @@ Starshatter::~Starshatter() delete input; delete head_tracker; - instance = 0; + if (instance == this) + instance = nullptr; } void |