-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: get rid of global game variables
- Loading branch information
Showing
28 changed files
with
177 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "IGame.h" | ||
|
||
#include "IW3/GameIW3.h" | ||
#include "IW4/GameIW4.h" | ||
#include "IW5/GameIW5.h" | ||
#include "T5/GameT5.h" | ||
#include "T6/GameT6.h" | ||
|
||
#include <cassert> | ||
|
||
IGame* IGame::GetGameById(GameId gameId) | ||
{ | ||
static IGame* games[static_cast<unsigned>(GameId::COUNT)]{ | ||
new IW3::Game(), | ||
new IW4::Game(), | ||
new IW5::Game(), | ||
new T5::Game(), | ||
new T6::Game(), | ||
}; | ||
|
||
assert(static_cast<unsigned>(gameId) < static_cast<unsigned>(GameId::COUNT)); | ||
auto* result = games[static_cast<unsigned>(gameId)]; | ||
assert(result); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
#pragma once | ||
#include "Game/IGame.h" | ||
|
||
class GameIW3 final : public IGame | ||
namespace IW3 | ||
{ | ||
public: | ||
GameId GetId() override; | ||
std::string GetFullName() override; | ||
std::string GetShortName() override; | ||
void AddZone(Zone* zone) override; | ||
void RemoveZone(Zone* zone) override; | ||
std::vector<Zone*> GetZones() override; | ||
const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() override; | ||
class Game final : public IGame | ||
{ | ||
public: | ||
[[nodiscard]] GameId GetId() const override; | ||
[[nodiscard]] const std::string& GetFullName() const override; | ||
[[nodiscard]] const std::string& GetShortName() const override; | ||
void AddZone(Zone* zone) override; | ||
void RemoveZone(Zone* zone) override; | ||
[[nodiscard]] const std::vector<Zone*>& GetZones() const override; | ||
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override; | ||
|
||
private: | ||
std::vector<Zone*> m_zones; | ||
}; | ||
|
||
extern GameIW3 g_GameIW3; | ||
private: | ||
std::vector<Zone*> m_zones; | ||
}; | ||
} // namespace IW3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
#pragma once | ||
#include "Game/IGame.h" | ||
|
||
class GameIW4 final : public IGame | ||
namespace IW4 | ||
{ | ||
public: | ||
GameId GetId() override; | ||
std::string GetFullName() override; | ||
std::string GetShortName() override; | ||
void AddZone(Zone* zone) override; | ||
void RemoveZone(Zone* zone) override; | ||
std::vector<Zone*> GetZones() override; | ||
const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() override; | ||
class Game final : public IGame | ||
{ | ||
public: | ||
[[nodiscard]] GameId GetId() const override; | ||
[[nodiscard]] const std::string& GetFullName() const override; | ||
[[nodiscard]] const std::string& GetShortName() const override; | ||
void AddZone(Zone* zone) override; | ||
void RemoveZone(Zone* zone) override; | ||
[[nodiscard]] const std::vector<Zone*>& GetZones() const override; | ||
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override; | ||
|
||
private: | ||
std::vector<Zone*> m_zones; | ||
}; | ||
|
||
extern GameIW4 g_GameIW4; | ||
private: | ||
std::vector<Zone*> m_zones; | ||
}; | ||
} // namespace IW4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
#pragma once | ||
#include "Game/IGame.h" | ||
|
||
class GameIW5 final : public IGame | ||
namespace IW5 | ||
{ | ||
public: | ||
GameId GetId() override; | ||
std::string GetFullName() override; | ||
std::string GetShortName() override; | ||
void AddZone(Zone* zone) override; | ||
void RemoveZone(Zone* zone) override; | ||
std::vector<Zone*> GetZones() override; | ||
const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() override; | ||
class Game final : public IGame | ||
{ | ||
public: | ||
[[nodiscard]] GameId GetId() const override; | ||
[[nodiscard]] const std::string& GetFullName() const override; | ||
[[nodiscard]] const std::string& GetShortName() const override; | ||
void AddZone(Zone* zone) override; | ||
void RemoveZone(Zone* zone) override; | ||
[[nodiscard]] const std::vector<Zone*>& GetZones() const override; | ||
[[nodiscard]] const std::vector<GameLanguagePrefix>& GetLanguagePrefixes() const override; | ||
|
||
private: | ||
std::vector<Zone*> m_zones; | ||
}; | ||
|
||
extern GameIW5 g_GameIW5; | ||
private: | ||
std::vector<Zone*> m_zones; | ||
}; | ||
} // namespace IW5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.