parent
bb16c6d97c
commit
83599238d1
|
@ -29,6 +29,12 @@
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "common/misc.h"
|
#include "common/misc.h"
|
||||||
#include "common/restext.h"
|
#include "common/restext.h"
|
||||||
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
||||||
|
#if PLATFORM_WINDOWS
|
||||||
|
#include <windows.h>
|
||||||
|
#include "app/system_windows.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Doxygen main page */
|
/* Doxygen main page */
|
||||||
|
@ -71,8 +77,6 @@ The current layout is the following:
|
||||||
- src/script - link with the CBot library
|
- src/script - link with the CBot library
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/resources/resourcemanager.h"
|
|
||||||
|
|
||||||
//! Entry point to the program
|
//! Entry point to the program
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
@ -80,6 +84,26 @@ extern "C"
|
||||||
int SDL_MAIN_FUNC(int argc, char *argv[])
|
int SDL_MAIN_FUNC(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
CLogger logger; // single istance of logger
|
CLogger logger; // single istance of logger
|
||||||
|
|
||||||
|
// Workaround for character encoding in argv on Windows
|
||||||
|
#if PLATFORM_WINDOWS
|
||||||
|
int wargc;
|
||||||
|
wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &wargc);
|
||||||
|
if(wargv == nullptr)
|
||||||
|
{
|
||||||
|
logger.Error("CommandLineToArgvW failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
argv = new char*[wargc];
|
||||||
|
for(int i = 0; i < wargc; i++) {
|
||||||
|
std::wstring warg = wargv[i];
|
||||||
|
std::string arg = CSystemUtilsWindows::UTF8_Encode(warg);
|
||||||
|
argv[i] = new char[arg.length()+1];
|
||||||
|
strcpy(argv[i], arg.c_str());
|
||||||
|
}
|
||||||
|
LocalFree(wargv);
|
||||||
|
#endif
|
||||||
|
|
||||||
CResourceManager manager(argv[0]);
|
CResourceManager manager(argv[0]);
|
||||||
|
|
||||||
// Initialize static string arrays
|
// Initialize static string arrays
|
||||||
|
@ -128,6 +152,12 @@ int SDL_MAIN_FUNC(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Info("Exiting with code %d\n", code);
|
logger.Info("Exiting with code %d\n", code);
|
||||||
|
|
||||||
|
#if PLATFORM_WINDOWS
|
||||||
|
// See the workaround above
|
||||||
|
delete[] argv;
|
||||||
|
#endif
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,9 @@ public:
|
||||||
|
|
||||||
virtual std::string GetSaveDir() override;
|
virtual std::string GetSaveDir() override;
|
||||||
|
|
||||||
private:
|
public:
|
||||||
std::string UTF8_Encode(const std::wstring &wstr);
|
static std::string UTF8_Encode(const std::wstring &wstr);
|
||||||
std::wstring UTF8_Decode(const std::string &str);
|
static std::wstring UTF8_Decode(const std::string &str);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
long long m_counterFrequency;
|
long long m_counterFrequency;
|
||||||
|
|
Loading…
Reference in New Issue