forked from teamnwah/openmw-tes3coop
[General] Move server's version printing method to Utils
This commit is contained in:
parent
08f34e5356
commit
61b1a59814
3 changed files with 38 additions and 38 deletions
|
@ -29,41 +29,6 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
void printVersion(string version, Version::Version ver, int protocol)
|
|
||||||
{
|
|
||||||
cout << "TES3:MP dedicated server " << version;
|
|
||||||
cout << " (";
|
|
||||||
#if defined(_WIN32)
|
|
||||||
cout << "Windows";
|
|
||||||
#elif defined(__linux)
|
|
||||||
cout << "Linux";
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
cout << "OS X";
|
|
||||||
#else
|
|
||||||
cout << "Unknown OS";
|
|
||||||
#endif
|
|
||||||
cout << " ";
|
|
||||||
#ifdef __x86_64__
|
|
||||||
cout << "64-bit";
|
|
||||||
#elif defined(__i386__) || defined(_M_I86)
|
|
||||||
cout << "32-bit";
|
|
||||||
#elif defined(__ARM_ARCH)
|
|
||||||
cout << "ARMv" << __ARM_ARCH << " ";
|
|
||||||
#ifdef __aarch64__
|
|
||||||
cout << "64-bit";
|
|
||||||
#else
|
|
||||||
cout << "32-bit";
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
cout << "Unknown architecture";
|
|
||||||
#endif
|
|
||||||
cout << ")" << endl;
|
|
||||||
cout << "Protocol version: " << protocol << endl;
|
|
||||||
cout << "Commit hash: " << ver.mCommitHash.substr(0, 10) << endl;
|
|
||||||
|
|
||||||
cout << "------------------------------------------------------------" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ENABLE_BREAKPAD
|
#ifdef ENABLE_BREAKPAD
|
||||||
google_breakpad::ExceptionHandler *pHandler = 0;
|
google_breakpad::ExceptionHandler *pHandler = 0;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
@ -230,9 +195,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
vector<string> plugins (Utils::split(mgr.getString("plugins", "Plugins"), ','));
|
vector<string> plugins (Utils::split(mgr.getString("plugins", "Plugins"), ','));
|
||||||
|
|
||||||
|
Utils::printVersion("TES3MP dedicated server", TES3MP_VERSION, version.mCommitHash, TES3MP_PROTO_VERSION);
|
||||||
printVersion(TES3MP_VERSION, version, TES3MP_PROTO_VERSION);
|
|
||||||
|
|
||||||
|
|
||||||
setenv("AMXFILE", moddir.c_str(), 1);
|
setenv("AMXFILE", moddir.c_str(), 1);
|
||||||
setenv("MOD_DIR", moddir.c_str(), 1); // hack for lua
|
setenv("MOD_DIR", moddir.c_str(), 1); // hack for lua
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <boost/crc.hpp>
|
#include <boost/crc.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
@ -149,6 +150,41 @@ unsigned int ::Utils::crc32Checksum(const std::string &file)
|
||||||
return crc32.checksum();
|
return crc32.checksum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Utils::printVersion(std::string appName, std::string version, std::string commitHash, int protocol)
|
||||||
|
{
|
||||||
|
cout << appName << " " << version;
|
||||||
|
cout << " (";
|
||||||
|
#if defined(_WIN32)
|
||||||
|
cout << "Windows";
|
||||||
|
#elif defined(__linux)
|
||||||
|
cout << "Linux";
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
cout << "OS X";
|
||||||
|
#else
|
||||||
|
cout << "Unknown OS";
|
||||||
|
#endif
|
||||||
|
cout << " ";
|
||||||
|
#ifdef __x86_64__
|
||||||
|
cout << "64-bit";
|
||||||
|
#elif defined(__i386__) || defined(_M_I86)
|
||||||
|
cout << "32-bit";
|
||||||
|
#elif defined(__ARM_ARCH)
|
||||||
|
cout << "ARMv" << __ARM_ARCH << " ";
|
||||||
|
#ifdef __aarch64__
|
||||||
|
cout << "64-bit";
|
||||||
|
#else
|
||||||
|
cout << "32-bit";
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
cout << "Unknown architecture";
|
||||||
|
#endif
|
||||||
|
cout << ")" << endl;
|
||||||
|
cout << "Protocol version: " << protocol << endl;
|
||||||
|
cout << "Commit hash: " << commitHash.substr(0, 10) << endl;
|
||||||
|
|
||||||
|
cout << "------------------------------------------------------------" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
void Utils::printWithWidth(ostringstream &sstr, string str, size_t width)
|
void Utils::printWithWidth(ostringstream &sstr, string str, size_t width)
|
||||||
{
|
{
|
||||||
sstr << left << setw(width) << setfill(' ') << str;
|
sstr << left << setw(width) << setfill(' ') << str;
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace Utils
|
||||||
|
|
||||||
unsigned int crc32Checksum(const std::string &file);
|
unsigned int crc32Checksum(const std::string &file);
|
||||||
|
|
||||||
|
void printVersion(std::string appName, std::string version, std::string commitHash, int protocol);
|
||||||
|
|
||||||
void printWithWidth(std::ostringstream &sstr, std::string str, size_t width);
|
void printWithWidth(std::ostringstream &sstr, std::string str, size_t width);
|
||||||
std::string intToHexStr(unsigned val);
|
std::string intToHexStr(unsigned val);
|
||||||
|
|
Loading…
Reference in a new issue