-
-
Save anonymous/447f75e2af90d067ee46 to your computer and use it in GitHub Desktop.
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
commit 2bd6621d894f5835a8d38abf95466a4584af59fe | |
Author: Ilya Zhuravlev <zhuravlevilya@ya.ru> | |
Date: Thu Feb 20 22:53:18 2014 +0400 | |
Make it kinda run. | |
diff --git a/client/CMT.cpp b/client/CMT.cpp | |
index 6cfa8a0..162d0d3 100644 | |
--- a/client/CMT.cpp | |
+++ b/client/CMT.cpp | |
@@ -52,6 +52,8 @@ | |
#undef main | |
#endif | |
+#include <stdlib.h> | |
+ | |
namespace po = boost::program_options; | |
/* | |
@@ -284,6 +286,7 @@ int main(int argc, char** argv) | |
logConfig.configureDefault(); | |
logGlobal->infoStream() <<"Creating console "<<pomtime.getDiff(); | |
+ setenv("LANG", "C", 1); | |
// Init filesystem and settings | |
preinitDLL(::console); | |
settings.init(); | |
@@ -361,7 +364,8 @@ int main(int argc, char** argv) | |
//we can properly play intro only in the main thread, so we have to move loading to the separate thread | |
- boost::thread loading(init); | |
+ // boost::thread loading(init); | |
+ init(); | |
if(!gNoGUI ) | |
{ | |
@@ -371,7 +375,7 @@ int main(int argc, char** argv) | |
} | |
CSDL_Ext::update(screen); | |
- loading.join(); | |
+ // loading.join(); | |
logGlobal->infoStream()<<"Initialization of VCMI (together): "<<total.getDiff(); | |
if(!vm.count("battle")) | |
diff --git a/client/Client.cpp b/client/Client.cpp | |
index be50f9f..c694d26 100644 | |
--- a/client/Client.cpp | |
+++ b/client/Client.cpp | |
@@ -37,7 +37,6 @@ | |
#include "CMT.h" | |
extern std::string NAME; | |
-namespace intpr = boost::interprocess; | |
/* | |
* Client.cpp, part of VCMI engine | |
@@ -792,19 +791,13 @@ void CServerHandler::waitForServer() | |
startServer(); | |
th.update(); | |
- intpr::scoped_lock<intpr::interprocess_mutex> slock(shared->sr->mutex); | |
- while(!shared->sr->ready) | |
- { | |
- shared->sr->cond.wait(slock); | |
- } | |
if(verbose) | |
logNetwork->infoStream() << "Waiting for server: " << th.getDiff(); | |
} | |
CConnection * CServerHandler::connectToServer() | |
{ | |
- if(!shared->sr->ready) | |
- waitForServer(); | |
+ waitForServer(); | |
th.update(); //put breakpoint here to attach to server before it does something stupid | |
CConnection *ret = justConnectToServer(settings["server"]["server"].String(), port); | |
@@ -818,20 +811,12 @@ CConnection * CServerHandler::connectToServer() | |
CServerHandler::CServerHandler(bool runServer /*= false*/) | |
{ | |
serverThread = nullptr; | |
- shared = nullptr; | |
port = boost::lexical_cast<std::string>(settings["server"]["port"].Float()); | |
verbose = true; | |
- | |
- boost::interprocess::shared_memory_object::remove("vcmi_memory"); //if the application has previously crashed, the memory may not have been removed. to avoid problems - try to destroy it | |
- try | |
- { | |
- shared = new SharedMem(); | |
- } HANDLE_EXCEPTIONC(logNetwork->errorStream() << "Cannot open interprocess memory: ";) | |
} | |
CServerHandler::~CServerHandler() | |
{ | |
- delete shared; | |
delete serverThread; //detaches, not kills thread | |
} | |
@@ -840,6 +825,7 @@ void CServerHandler::callServer() | |
setThreadName("CServerHandler::callServer"); | |
std::string logName = VCMIDirs::get().userCachePath() + "/server_log.txt"; | |
std::string comm = VCMIDirs::get().serverPath() + " --port=" + port + " > " + logName; | |
+ setenv("LD_LIBRARY_PATH", "/data/data/is.xyz.vcmi/files/", 1); | |
int result = std::system(comm.c_str()); | |
if (result == 0) | |
logNetwork->infoStream() << "Server closed correctly"; | |
diff --git a/client/Client.h b/client/Client.h | |
index 8ebb49d..107d411 100644 | |
--- a/client/Client.h | |
+++ b/client/Client.h | |
@@ -38,7 +38,9 @@ private: | |
public: | |
CStopWatch th; | |
boost::thread *serverThread; //thread that called system to run server | |
+#if 0 | |
SharedMem *shared; //interprocess memory (for waiting for server) | |
+#endif | |
bool verbose; //whether to print log msgs | |
std::string port; //port number in text form | |
diff --git a/lib/CGeneralTextHandler.cpp b/lib/CGeneralTextHandler.cpp | |
index e232155..dc0f2a8 100644 | |
--- a/lib/CGeneralTextHandler.cpp | |
+++ b/lib/CGeneralTextHandler.cpp | |
@@ -1,7 +1,7 @@ | |
#include "StdInc.h" | |
#include "CGeneralTextHandler.h" | |
-#include <boost/locale.hpp> | |
+// #include <boost/locale.hpp> | |
#include "filesystem/Filesystem.h" | |
#include "CConfigHandler.h" | |
@@ -110,17 +110,20 @@ std::string Unicode::toUnicode(const std::string &text) | |
std::string Unicode::toUnicode(const std::string &text, const std::string &encoding) | |
{ | |
- return boost::locale::conv::to_utf<char>(text, encoding); | |
+ return text; | |
+ // TODO return boost::locale::conv::to_utf<char>(text, encoding); | |
} | |
std::string Unicode::fromUnicode(const std::string & text) | |
{ | |
- return fromUnicode(text, getSelectedEncoding()); | |
+ return text; | |
+ // TODO return fromUnicode(text, getSelectedEncoding()); | |
} | |
std::string Unicode::fromUnicode(const std::string &text, const std::string &encoding) | |
{ | |
- return boost::locale::conv::from_utf<char>(text, encoding); | |
+ return text; | |
+ // TODO return boost::locale::conv::from_utf<char>(text, encoding); | |
} | |
//Helper for string -> float conversion | |
diff --git a/lib/VCMIDirs.cpp b/lib/VCMIDirs.cpp | |
index 3e42b31..3a5e31d 100644 | |
--- a/lib/VCMIDirs.cpp | |
+++ b/lib/VCMIDirs.cpp | |
@@ -126,7 +126,7 @@ std::string VCMIDirs::libraryName(std::string basename) const | |
std::string VCMIDirs::userDataPath() const | |
{ | |
if (getenv("HOME") != nullptr ) | |
- return std::string(getenv("HOME")) + "/.vcmi"; | |
+ return std::string(getenv("HOME")); | |
return "."; | |
} | |
diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp | |
index 36051cc..93d884a 100644 | |
--- a/lib/VCMI_Lib.cpp | |
+++ b/lib/VCMI_Lib.cpp | |
@@ -34,13 +34,14 @@ LibClasses * VLC = nullptr; | |
DLL_LINKAGE void preinitDLL(CConsoleHandler *Console) | |
{ | |
+ std::cout << "called preinitDLL" << std::endl; | |
console = Console; | |
VLC = new LibClasses; | |
- try | |
+ //try | |
{ | |
VLC->loadFilesystem(); | |
} | |
- HANDLE_EXCEPTION; | |
+ //HANDLE_EXCEPTION; | |
} | |
DLL_LINKAGE void loadDLLClasses() | |
diff --git a/lib/logging/CLogger.cpp b/lib/logging/CLogger.cpp | |
index b3a6f06..413a71d 100644 | |
--- a/lib/logging/CLogger.cpp | |
+++ b/lib/logging/CLogger.cpp | |
@@ -1,3 +1,5 @@ | |
+#include <android/log.h> | |
+ | |
#include "StdInc.h" | |
#include "CLogger.h" | |
@@ -387,6 +389,9 @@ void CLogConsoleTarget::write(const LogRecord & record) | |
if(threshold > record.level) return; | |
std::string message = formatter.format(record); | |
+ | |
+ __android_log_print(ANDROID_LOG_INFO, "VCMI", "%s", message.c_str()); | |
+ | |
bool printToStdErr = record.level >= ELogLevel::WARN; | |
if(console) | |
{ | |
diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp | |
index fe51e36..3da6ec9 100644 | |
--- a/server/CVCMIServer.cpp | |
+++ b/server/CVCMIServer.cpp | |
@@ -33,7 +33,7 @@ | |
#include "../lib/UnlockGuard.h" | |
#if defined(__GNUC__) && !defined (__MINGW32__) | |
-#include <execinfo.h> | |
+// #include <execinfo.h> | |
#endif | |
std::string NAME_AFFIX = "server"; | |
@@ -41,7 +41,6 @@ std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX | |
using namespace boost; | |
using namespace boost::asio; | |
using namespace boost::asio::ip; | |
-namespace intpr = boost::interprocess; | |
bool end2 = false; | |
int port = 3030; | |
@@ -392,28 +391,11 @@ void CVCMIServer::newPregame() | |
void CVCMIServer::start() | |
{ | |
ServerReady *sr = nullptr; | |
- intpr::mapped_region *mr; | |
- try | |
- { | |
- intpr::shared_memory_object smo(intpr::open_only,"vcmi_memory",intpr::read_write); | |
- smo.truncate(sizeof(ServerReady)); | |
- mr = new intpr::mapped_region(smo,intpr::read_write); | |
- sr = reinterpret_cast<ServerReady*>(mr->get_address()); | |
- } | |
- catch(...) | |
- { | |
- intpr::shared_memory_object smo(intpr::create_only,"vcmi_memory",intpr::read_write); | |
- smo.truncate(sizeof(ServerReady)); | |
- mr = new intpr::mapped_region(smo,intpr::read_write); | |
- sr = new(mr->get_address())ServerReady(); | |
- } | |
boost::system::error_code error; | |
logNetwork->infoStream()<<"Listening for connections at port " << acceptor->local_endpoint().port(); | |
auto s = new tcp::socket(acceptor->get_io_service()); | |
boost::thread acc(boost::bind(vaccept,acceptor,s,&error)); | |
- sr->setToTrueAndNotify(); | |
- delete mr; | |
acc.join(); | |
if (error) | |
@@ -538,6 +520,7 @@ static void handleCommandOptions(int argc, char *argv[]) | |
#if defined(__GNUC__) && !defined (__MINGW32__) | |
void handleLinuxSignal(int sig) | |
{ | |
+#if 0 | |
const int STACKTRACE_SIZE = 100; | |
void * buffer[STACKTRACE_SIZE]; | |
int ptrCount = backtrace(buffer, STACKTRACE_SIZE); | |
@@ -557,6 +540,7 @@ void handleLinuxSignal(int sig) | |
} | |
free(strings); | |
} | |
+#endif | |
_exit(EXIT_FAILURE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment