1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +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:
Vadim Glazunov 2009-01-31 02:36:44 +00:00
parent f28c76984c
commit a560e9069a
7 changed files with 6407 additions and 10 deletions

View File

@ -1007,14 +1007,25 @@ void CBattleLogic::PrintBattleAction(const BattleAction &action) // for debug pu
message += boost::lexical_cast<std::string>(action.additionalInfo);
}
#ifdef _WIN32
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hConsole, &csbi);
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;
#ifdef _WIN32
SetConsoleTextAttribute(hConsole, csbi.wAttributes);
}
#else
color = "\x1b[0m";
std::cout << color;
#endif
}

View File

@ -14,6 +14,10 @@
#pragma warning (disable: 4100)
#ifdef __GNUC__
#define strcpy_s(a, b, c) strncpy(a, c, b)
#endif
namespace GeniusAI {
class CBattleHelper

View File

@ -40,16 +40,16 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
//int len = dllname.size()+1;
getName = (void(*)(char*))GetProcAddress(dll,"GetAiName");
getAI = (CGlobalAI*(*)())GetProcAddress(dll,"GetNewAI");
getName(temp);
#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
#endif
getName(temp);
tlog0 << "Loaded .dll with AI named " << temp << std::endl;
#if _WIN32
ret = getAI();
#else
//ret = new CEmptyAI();
#endif
return ret;
}
//CGlobalAI::CGlobalAI()

View File

@ -3,7 +3,7 @@ EXTRA_DIST = aclocal/m4
#bin_PROGRAMS = vcmi
#vcmi_LDADD = $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB)
AM_CXXFLAGS = $(BOOST_CPPFLAGS)
SUBDIRS = lib client server
SUBDIRS = lib client server AI
#vcmi_SOURCES = \
# AdventureMapButton.cpp CGameState.cpp \
# AdventureMapButton.h CGameState.h global.h \

6377
aclocal.m4 vendored

File diff suppressed because it is too large Load Diff

View File

@ -57,6 +57,9 @@
/* define if the Boost::Thread library is available */
#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. */
#undef HAVE_FCNTL_H

View File

@ -14,7 +14,9 @@ AX_BOOST_FILESYSTEM
AX_BOOST_THREAD
AC_PROG_CC
AC_PROG_CPP
AC_PROG_RANLIB
AC_ENABLE_SHARED
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
CFLAGS="-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([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)