Yet another code cleanup

This commit is contained in:
mathusummut
2018-11-03 15:26:37 +01:00
parent 8db9ad9e9f
commit 0cfe7e81d1
312 changed files with 140658 additions and 141390 deletions

View File

@@ -174,6 +174,6 @@ namespace Shared {
}
}//end namespace
} //end namespace
#endif

View File

@@ -140,6 +140,6 @@ namespace Shared {
};
}
}//end namespace
} //end namespace
#endif

View File

@@ -337,6 +337,6 @@ namespace Shared {
}
}//end namespace
} //end namespace
#endif

View File

@@ -29,6 +29,6 @@ namespace Shared {
const std::string LastCompatibleVersionString = LAST_COMPATIBLE_VERSION;
const std::string G3DViewerVersionString = G3D_VIEWER_VERSION;
const std::string MapEditorVersionString = MAP_EDITOR_VERSION;
}//end namespace
} //end namespace
#endif

View File

@@ -191,6 +191,6 @@ namespace Shared {
};
}
}//end namespace
} //end namespace
#endif

View File

@@ -169,6 +169,6 @@ namespace Shared {
};
}
}//end namespace
} //end namespace
#endif

View File

@@ -79,6 +79,6 @@ namespace Shared {
};
}
}//end namespace
} //end namespace
#endif

View File

@@ -400,6 +400,6 @@ namespace Shared {
};
}
}//end namespace
} //end namespace
#endif

View File

@@ -110,7 +110,7 @@ typedef unsigned long long uint64;
#endif
}}//end namespace
}} //end namespace
// =======================================================

View File

@@ -60,6 +60,6 @@ public:
SoundFactory *getSoundFactory(const string &name);
};
}}//end namespace
}} //end namespace
#endif

View File

@@ -106,6 +106,6 @@ namespace Shared {
void* getGlProcAddress(const char *procName);
}
}//end namespace
} //end namespace
#endif

View File

@@ -737,12 +737,4 @@ int mainSetup(int argc, char **argv) {
return 0;
}
#define MAIN_FUNCTION(X) int main(int argc, char **argv) { \
int result = mainSetup(argc,argv); \
if(result == 0) { \
result = X(argc, argv); \
} \
return result; \
}
#endif

View File

@@ -35,122 +35,123 @@ using namespace Shared::PlatformCommon;
using std::string;
using std::exception;
namespace Shared { namespace Platform {
namespace Shared {
namespace Platform {
class game_runtime_error : public runtime_error {
protected:
bool noStackTrace;
public:
game_runtime_error(const string& __arg,bool noStackTrace=false);
class game_runtime_error : public runtime_error {
protected:
bool noStackTrace;
public:
game_runtime_error(const string& __arg,bool noStackTrace=false);
bool wantStackTrace() const { return !noStackTrace; }
};
bool wantStackTrace() const { return !noStackTrace; }
};
#ifndef WIN32
// =====================================================
// class PlatformExceptionHandler
// =====================================================
#ifndef WIN32
// =====================================================
// class PlatformExceptionHandler
// =====================================================
class PlatformExceptionHandler {
public:
static string application_binary;
static bool disableBacktrace;
static string getStackTrace();
class PlatformExceptionHandler {
public:
static string application_binary;
static bool disableBacktrace;
static string getStackTrace();
virtual ~PlatformExceptionHandler() {}
void install(string dumpFileName) {}
virtual void handle()=0;
#if defined(__WIN32__) && !defined(__GNUC__)
virtual void handle(LPEXCEPTION_POINTERS pointers)=0;
#endif
};
virtual ~PlatformExceptionHandler() {}
void install(string dumpFileName) {}
virtual void handle()=0;
#if defined(__WIN32__) && !defined(__GNUC__)
virtual void handle(LPEXCEPTION_POINTERS pointers)=0;
#endif
};
// =====================================================
// Misc
// =====================================================
void message(const string &message,bool isNonGraphicalModeEnabled, const string &writepath);
void exceptionMessage(const exception &excp);
// =====================================================
// Misc
// =====================================================
void message(const string &message,bool isNonGraphicalModeEnabled, const string &writepath);
void exceptionMessage(const exception &excp);
string getCommandLine();
string getCommandLine();
// WINDOWS
#else
// WINDOWS
#else
// =====================================================
// class PlatformExceptionHandler
// =====================================================
// =====================================================
// class PlatformExceptionHandler
// =====================================================
class PlatformExceptionHandler {
private:
static PlatformExceptionHandler *thisPointer;
class PlatformExceptionHandler {
private:
static PlatformExceptionHandler *thisPointer;
private:
static LONG WINAPI handler(LPEXCEPTION_POINTERS pointers);
string dumpFileName;
private:
static LONG WINAPI handler(LPEXCEPTION_POINTERS pointers);
string dumpFileName;
public:
static string application_binary;
static bool disableBacktrace;
static string getStackTrace();
public:
static string application_binary;
static bool disableBacktrace;
static string getStackTrace();
void install(string dumpFileName);
virtual void handle()=0;
#if !defined(__GNUC__)
virtual void handle(LPEXCEPTION_POINTERS pointers)=0;
#endif
static string codeToStr(DWORD code);
};
void install(string dumpFileName);
virtual void handle()=0;
#if !defined(__GNUC__)
virtual void handle(LPEXCEPTION_POINTERS pointers)=0;
#endif
static string codeToStr(DWORD code);
};
LONG WINAPI UnhandledExceptionFilter2(struct _EXCEPTION_POINTERS *ExceptionInfo);
LONG WINAPI UnhandledExceptionFilter2(struct _EXCEPTION_POINTERS *ExceptionInfo);
// =====================================================
// Misc
// =====================================================
LPWSTR Ansi2WideString(LPCSTR lpaszString);
std::string utf8_encode(const std::wstring &wstr);
std::wstring utf8_decode(const std::string &str);
std::string getRegKey(const std::string& location, const std::string& name);
// =====================================================
// Misc
// =====================================================
LPWSTR Ansi2WideString(LPCSTR lpaszString);
std::string utf8_encode(const std::wstring &wstr);
std::wstring utf8_decode(const std::string &str);
std::string getRegKey(const std::string& location, const std::string& name);
void message(string message, bool isNonGraphicalModeEnabled,const string &writepath);
void exceptionMessage(const exception &excp);
string getCommandLine();
void init_win32();
void done_win32();
void ontop_win32(int width, int height);
void message(string message, bool isNonGraphicalModeEnabled,const string &writepath);
void exceptionMessage(const exception &excp);
string getCommandLine();
void init_win32();
void done_win32();
void ontop_win32(int width, int height);
void CheckPacketThrottling();
void CheckPacketThrottling();
// The following is used for stacking tracing for windows based exceptions
#if !defined(_DEBUG) && !defined(__GNUC__)
// The following is used for stacking tracing for windows based exceptions
#if !defined(_DEBUG) && !defined(__GNUC__)
// easy safe strings
#define MAXSTRLEN 260
typedef char stringType[MAXSTRLEN];
// easy safe strings
#define MAXSTRLEN 260
typedef char stringType[MAXSTRLEN];
inline void vformatstring(char *d, const char *fmt, va_list v, int len = MAXSTRLEN) { _vsnprintf(d, len, fmt, v); d[len-1] = 0; }
inline char *copystring(char *d, const char *s, size_t len = MAXSTRLEN) { strncpy(d, s, len); d[len-1] = 0; return d; }
inline char *concatstring(char *d, const char *s, size_t len = MAXSTRLEN) { size_t used = strlen(d); return used < len ? copystring(d+used, s, len-used) : d; }
inline void vformatstring(char *d, const char *fmt, va_list v, int len = MAXSTRLEN) { _vsnprintf(d, len, fmt, v); d[len-1] = 0; }
inline char *copystring(char *d, const char *s, size_t len = MAXSTRLEN) { strncpy(d, s, len); d[len-1] = 0; return d; }
inline char *concatstring(char *d, const char *s, size_t len = MAXSTRLEN) { size_t used = strlen(d); return used < len ? copystring(d+used, s, len-used) : d; }
struct stringformatter {
char *buf;
stringformatter(char *buf): buf((char *)buf) {}
void operator()(const char *fmt, ...) {
va_list v;
va_start(v, fmt);
vformatstring(buf, fmt, v);
va_end(v);
}
};
struct stringformatter {
char *buf;
stringformatter(char *buf): buf((char *)buf) {}
void operator()(const char *fmt, ...) {
va_list v;
va_start(v, fmt);
vformatstring(buf, fmt, v);
va_end(v);
}
};
#define formatstring(d) stringformatter((char *)d)
#define defformatstring(d) stringType d; formatstring(d)
#define defvformatstring(d,last,fmt) stringType d; { va_list ap; va_start(ap, last); vformatstring(d, fmt, ap); va_end(ap); }
#define formatstring(d) stringformatter((char *)d)
#define defformatstring(d) stringType d; formatstring(d)
#define defvformatstring(d,last,fmt) stringType d; { va_list ap; va_start(ap, last); vformatstring(d, fmt, ap); va_end(ap); }
#endif
#endif
}}//end namespace
#endif
#endif
}
} //end namespace
#endif

View File

@@ -559,6 +559,6 @@ namespace Shared {
};
}
}//end namespace
} //end namespace
#endif

View File

@@ -324,6 +324,6 @@ namespace Shared {
bool isAllowedInputTextKey(wchar_t &key);
}
}//end namespace
} //end namespace
#endif

View File

@@ -71,6 +71,6 @@ namespace Shared {
};
}
}//end namespace
} //end namespace
#endif