diff --git a/source/network/NetTurnManager.cpp b/source/network/NetTurnManager.cpp index 23843b5256..d01bc6b917 100644 --- a/source/network/NetTurnManager.cpp +++ b/source/network/NetTurnManager.cpp @@ -31,12 +31,11 @@ #include "ps/Pyrogenesis.h" #include "ps/Replay.h" #include "ps/SavedGame.h" +#include "ps/Util.h" #include "scriptinterface/ScriptInterface.h" #include "simulation2/Simulation2.h" -#include #include -#include const u32 DEFAULT_TURN_LENGTH_MP = 500; const u32 DEFAULT_TURN_LENGTH_SP = 200; @@ -49,15 +48,6 @@ static const int COMMAND_DELAY = 2; #define NETTURN_LOG(args) #endif -static std::string Hexify(const std::string& s) -{ - std::stringstream str; - str << std::hex; - for (size_t i = 0; i < s.size(); ++i) - str << std::setfill('0') << std::setw(2) << (int)(unsigned char)s[i]; - return str.str(); -} - CNetTurnManager::CNetTurnManager(CSimulation2& simulation, u32 defaultTurnLength, int clientId, IReplayLogger& replay) : m_Simulation2(simulation), m_CurrentTurn(0), m_ReadyTurn(1), m_TurnLength(defaultTurnLength), m_DeltaSimTime(0), m_PlayerId(-1), m_ClientId(clientId), m_HasSyncError(false), m_Replay(replay), diff --git a/source/ps/Replay.cpp b/source/ps/Replay.cpp index c6b2d7213f..f380bd3ab7 100644 --- a/source/ps/Replay.cpp +++ b/source/ps/Replay.cpp @@ -39,18 +39,7 @@ #include "simulation2/helpers/SimulationCommand.h" #include -#include #include -#include - -static std::string Hexify(const std::string& s) -{ - std::stringstream str; - str << std::hex; - for (size_t i = 0; i < s.size(); ++i) - str << std::setfill('0') << std::setw(2) << (int)(unsigned char)s[i]; - return str.str(); -} CReplayLogger::CReplayLogger(ScriptInterface& scriptInterface) : m_ScriptInterface(scriptInterface), m_Stream(NULL) diff --git a/source/ps/Util.cpp b/source/ps/Util.cpp index a539fcdf1c..2294e4f334 100644 --- a/source/ps/Util.cpp +++ b/source/ps/Util.cpp @@ -422,3 +422,12 @@ void WriteBigScreenshot(const VfsPath& extension, int tiles) free(tile_data); } + +std::string Hexify(const std::string& s) +{ + std::stringstream str; + str << std::hex; + for (const char& c : s) + str << std::setfill('0') << std::setw(2) << (int)(unsigned char)c; + return str.str(); +} diff --git a/source/ps/Util.h b/source/ps/Util.h index accda37b61..4bf67239ad 100644 --- a/source/ps/Util.h +++ b/source/ps/Util.h @@ -22,15 +22,17 @@ struct Tex; -extern void WriteSystemInfo(); +void WriteSystemInfo(); -extern const wchar_t* ErrorString(int err); +const wchar_t* ErrorString(int err); -extern OsPath createDateIndexSubdirectory(const OsPath& parentDir); +OsPath createDateIndexSubdirectory(const OsPath& parentDir); -extern void WriteScreenshot(const VfsPath& extension); -extern void WriteBigScreenshot(const VfsPath& extension, int tiles); +void WriteScreenshot(const VfsPath& extension); +void WriteBigScreenshot(const VfsPath& extension, int tiles); -extern Status tex_write(Tex* t, const VfsPath& filename); +Status tex_write(Tex* t, const VfsPath& filename); + +std::string Hexify(const std::string& s); #endif // PS_UTIL_H diff --git a/source/simulation2/Simulation2.cpp b/source/simulation2/Simulation2.cpp index 252f1d2624..8c90b9c139 100644 --- a/source/simulation2/Simulation2.cpp +++ b/source/simulation2/Simulation2.cpp @@ -46,15 +46,6 @@ #include -static std::string Hexify(const std::string& s) // TODO: shouldn't duplicate this function in so many places -{ - std::stringstream str; - str << std::hex; - for (size_t i = 0; i < s.size(); ++i) - str << std::setfill('0') << std::setw(2) << (int)(unsigned char)s[i]; - return str.str(); -} - class CSimulation2Impl { public: