mirror of
https://github.com/vcmi/vcmi.git
synced 2025-09-16 09:26:28 +02:00
AI dynamic library load in linux. Autoconf/automake project updated, to recompile use autoreconf -f -i; automake; ./configure
This commit is contained in:
@@ -1007,14 +1007,25 @@ void CBattleLogic::PrintBattleAction(const BattleAction &action) // for debug pu
|
|||||||
message += boost::lexical_cast<std::string>(action.additionalInfo);
|
message += boost::lexical_cast<std::string>(action.additionalInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||||
GetConsoleScreenBufferInfo(hConsole, &csbi);
|
GetConsoleScreenBufferInfo(hConsole, &csbi);
|
||||||
|
|
||||||
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
|
SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
|
||||||
|
|
||||||
|
#else
|
||||||
|
std::string color;
|
||||||
|
color = "\x1b[1;40;32m";
|
||||||
|
std::cout << color;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::cout << message.c_str() << std::flush;
|
std::cout << message.c_str() << std::flush;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
SetConsoleTextAttribute(hConsole, csbi.wAttributes);
|
SetConsoleTextAttribute(hConsole, csbi.wAttributes);
|
||||||
}
|
#else
|
||||||
|
color = "\x1b[0m";
|
||||||
|
std::cout << color;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@@ -14,6 +14,10 @@
|
|||||||
|
|
||||||
#pragma warning (disable: 4100)
|
#pragma warning (disable: 4100)
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define strcpy_s(a, b, c) strncpy(a, c, b)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace GeniusAI {
|
namespace GeniusAI {
|
||||||
|
|
||||||
class CBattleHelper
|
class CBattleHelper
|
||||||
|
@@ -40,16 +40,16 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
|
|||||||
//int len = dllname.size()+1;
|
//int len = dllname.size()+1;
|
||||||
getName = (void(*)(char*))GetProcAddress(dll,"GetAiName");
|
getName = (void(*)(char*))GetProcAddress(dll,"GetAiName");
|
||||||
getAI = (CGlobalAI*(*)())GetProcAddress(dll,"GetNewAI");
|
getAI = (CGlobalAI*(*)())GetProcAddress(dll,"GetNewAI");
|
||||||
getName(temp);
|
|
||||||
#else
|
#else
|
||||||
|
void *dll = dlopen(dllname.c_str(), RTLD_LOCAL | RTLD_LAZY);
|
||||||
|
getName = (void(*)(char*))dlsym(dll,"GetAiName");
|
||||||
|
getAI = (CGlobalAI*(*)())dlsym(dll,"GetNewAI");
|
||||||
; //TODO: handle AI library on Linux
|
; //TODO: handle AI library on Linux
|
||||||
#endif
|
#endif
|
||||||
|
getName(temp);
|
||||||
tlog0 << "Loaded .dll with AI named " << temp << std::endl;
|
tlog0 << "Loaded .dll with AI named " << temp << std::endl;
|
||||||
#if _WIN32
|
|
||||||
ret = getAI();
|
ret = getAI();
|
||||||
#else
|
|
||||||
//ret = new CEmptyAI();
|
|
||||||
#endif
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
//CGlobalAI::CGlobalAI()
|
//CGlobalAI::CGlobalAI()
|
||||||
|
@@ -3,7 +3,7 @@ EXTRA_DIST = aclocal/m4
|
|||||||
#bin_PROGRAMS = vcmi
|
#bin_PROGRAMS = vcmi
|
||||||
#vcmi_LDADD = $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB)
|
#vcmi_LDADD = $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB)
|
||||||
AM_CXXFLAGS = $(BOOST_CPPFLAGS)
|
AM_CXXFLAGS = $(BOOST_CPPFLAGS)
|
||||||
SUBDIRS = lib client server
|
SUBDIRS = lib client server AI
|
||||||
#vcmi_SOURCES = \
|
#vcmi_SOURCES = \
|
||||||
# AdventureMapButton.cpp CGameState.cpp \
|
# AdventureMapButton.cpp CGameState.cpp \
|
||||||
# AdventureMapButton.h CGameState.h global.h \
|
# AdventureMapButton.h CGameState.h global.h \
|
||||||
|
6377
aclocal.m4
vendored
6377
aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
@@ -57,6 +57,9 @@
|
|||||||
/* define if the Boost::Thread library is available */
|
/* define if the Boost::Thread library is available */
|
||||||
#undef HAVE_BOOST_THREAD
|
#undef HAVE_BOOST_THREAD
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
#undef HAVE_DLFCN_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||||
#undef HAVE_FCNTL_H
|
#undef HAVE_FCNTL_H
|
||||||
|
|
||||||
|
@@ -14,7 +14,9 @@ AX_BOOST_FILESYSTEM
|
|||||||
AX_BOOST_THREAD
|
AX_BOOST_THREAD
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_CPP
|
AC_PROG_CPP
|
||||||
AC_PROG_RANLIB
|
AC_ENABLE_SHARED
|
||||||
|
AC_DISABLE_STATIC
|
||||||
|
AC_PROG_LIBTOOL
|
||||||
|
|
||||||
CFLAGS="-g"
|
CFLAGS="-g"
|
||||||
CXXFLAGS="-g"
|
CXXFLAGS="-g"
|
||||||
@@ -75,4 +77,4 @@ AC_FUNC_SELECT_ARGTYPES
|
|||||||
AC_CHECK_FUNCS([lua_pushhstring lua_calchash],, AC_MSG_ERROR([Lua required fuctions not found]))
|
AC_CHECK_FUNCS([lua_pushhstring lua_calchash],, AC_MSG_ERROR([Lua required fuctions not found]))
|
||||||
AC_CHECK_FUNCS([atexit memset pow select sqrt])
|
AC_CHECK_FUNCS([atexit memset pow select sqrt])
|
||||||
|
|
||||||
AC_OUTPUT(Makefile lib/Makefile client/Makefile server/Makefile)
|
AC_OUTPUT(Makefile lib/Makefile client/Makefile server/Makefile AI/Makefile)
|
||||||
|
Reference in New Issue
Block a user