From 4d3808cfa067c3cc5971b51c156dec8f0b2e4c82 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Mon, 13 Apr 2009 18:52:20 +0000 Subject: [PATCH] * applied ubuntux's patches * fixed AmptyAI (it builds now) --- AI/EmptyAI/CEmptyAI.h | 2 + AI/GeniusAI/Makefile.am | 8 +++ AI/Makefile.am | 1 + CGameInterface.cpp | 5 ++ CGameState.cpp | 4 +- Makefile.am | 48 +------------- client/Makefile.am | 139 +++++++++++++++++++-------------------- configure.ac | 4 +- hch/CCreatureHandler.cpp | 3 +- lib/Makefile.am | 84 ++++++++++++----------- server/Makefile.am | 17 ++--- 11 files changed, 142 insertions(+), 173 deletions(-) create mode 100644 AI/GeniusAI/Makefile.am create mode 100644 AI/Makefile.am diff --git a/AI/EmptyAI/CEmptyAI.h b/AI/EmptyAI/CEmptyAI.h index 59006cb1a..ad7c58d9c 100644 --- a/AI/EmptyAI/CEmptyAI.h +++ b/AI/EmptyAI/CEmptyAI.h @@ -13,6 +13,8 @@ public: void showSelDialog(std::string text, std::vector & components, int askID){}; void tileRevealed(int3 pos){}; void tileHidden(int3 pos){}; + void showBlockingDialog(const std::string &text, const std::vector &components, ui32 askID, bool selection, bool cancel){}; + void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, boost::function &onEnd){}; void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector &skills, boost::function &callback); }; diff --git a/AI/GeniusAI/Makefile.am b/AI/GeniusAI/Makefile.am new file mode 100644 index 000000000..083761489 --- /dev/null +++ b/AI/GeniusAI/Makefile.am @@ -0,0 +1,8 @@ +pkglib_LTLIBRARIES = GeniusAI.la +GeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.a $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB) +GeniusAI_la_LDFLAGS = -L$(top_builddir)/lib -module +GeniusAI_la_SOURCES = \ + CGeniusAI.cpp \ + CGeniusAI.h \ + DLLMain.cpp + diff --git a/AI/Makefile.am b/AI/Makefile.am new file mode 100644 index 000000000..01e20a566 --- /dev/null +++ b/AI/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = GeniusAI diff --git a/CGameInterface.cpp b/CGameInterface.cpp index 5b4872f32..a38aa264e 100644 --- a/CGameInterface.cpp +++ b/CGameInterface.cpp @@ -27,6 +27,11 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname) getAI = (CGlobalAI*(*)())GetProcAddress(dll,"GetNewAI"); #else void *dll = dlopen(dllname.c_str(), RTLD_LOCAL | RTLD_LAZY); + if (!dll) + { + tlog1 << "Cannot open AI library ("<second.heroes.size();l++) + for(unsigned int l=0; lsecond.heroes.size();l++) { - for(int m=0; msecond.towns.size();m++) + for(unsigned int m=0; msecond.towns.size();m++) { int3 vistile = k->second.towns[m]->pos; vistile.x--; //tile next to the entrance if(vistile == k->second.heroes[l]->pos || k->second.heroes[l]->pos==k->second.towns[m]->pos) diff --git a/Makefile.am b/Makefile.am index 47c09bbac..bfcc18c20 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,49 +1,7 @@ ACLOCAL_AMFLAGS = -I aclocal/m4 EXTRA_DIST = aclocal/m4 -#bin_PROGRAMS = vcmi -#vcmi_LDADD = $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB) AM_CXXFLAGS = $(BOOST_CPPFLAGS) AM_LDFLAGS = $(BOOST_LDFLAGS) -SUBDIRS = lib client server -#vcmi_SOURCES = \ -# AdventureMapButton.cpp CGameState.cpp \ -# AdventureMapButton.h CGameState.h global.h \ -# AI_Base.h CHeroWindow.cpp int3.h \ -# CAdvmapInterface.cpp CHeroWindow.h map.cpp \ -# CAdvmapInterface.h CLua.cpp map.h \ -# CBattleInterface.cpp CLua.h mapHandler.cpp \ -# CBattleInterface.h CLuaHandler.cpp mapHandler.h \ -# CCallback.cpp CLuaHandler.h nodrze.h \ -# CCallback.h CMessage.cpp SDL_Extensions.cpp \ -# CCastleInterface.cpp CMessage.h SDL_Extensions.h \ -# CCastleInterface.h CMT.cpp SDL_framerate.cpp \ -# CConsoleHandler.cpp SDL_framerate.h \ -# CConsoleHandler.h CPathfinder.cpp \ -# CCursorHandler.cpp CPathfinder.h \ -# CCursorHandler.h CPlayerInterface.cpp StartInfo.h \ -# CGameInfo.cpp CPlayerInterface.h stdafx.cpp \ -# CGameInfo.h CPreGame.cpp stdafx.h \ -# CGameInterface.cpp CPreGame.h tchar_amigaos4.h \ -# CGameInterface.h timeHandler.h \ -# hch/CAbilityHandler.cpp hch/CDefObjInfoHandler.cpp \ -# hch/CAbilityHandler.h hch/CDefObjInfoHandler.h \ -# hch/CAmbarCendamo.cpp hch/CGeneralTextHandler.cpp \ -# hch/CAmbarCendamo.h hch/CGeneralTextHandler.h \ -# hch/CArtHandler.cpp hch/CHeroHandler.cpp hch/CSndHandler.cpp \ -# hch/CArtHandler.h hch/CHeroHandler.h hch/CSndHandler.h \ -# hch/CBuildingHandler.cpp hch/CLodHandler.cpp hch/CSpellHandler.cpp \ -# hch/CBuildingHandler.h hch/CLodHandler.h hch/CSpellHandler.h \ -# hch/CMusicHandler.cpp hch/CTownHandler.cpp \ -# hch/CMusicHandler.h hch/CTownHandler.h \ -# hch/CCreatureHandler.cpp hch/CObjectHandler.cpp hch/CVideoHandler.cpp \ -# hch/CCreatureHandler.h hch/CObjectHandler.h hch/CVideoHandler.h \ -# hch/CDefHandler.cpp hch/CPreGameTextHandler.cpp \ -# hch/CDefHandler.h hch/CPreGameTextHandler.h \ -#client/CBitmapHandler.cpp client/CCreatureAnimation.cpp client/Client.cpp client/Graphics.cpp \ -#client/CBitmapHandler.h client/CCreatureAnimation.h client/Client.h client/Graphics.h \ -#lib/VCMI_Lib.h lib/VCMI_Lib.cpp \ -# server/CScriptCallback.h server/CScriptCallback.cpp \ -# lib/Connection.cpp lib/Connection.h \ -# CThreadHelper.cpp CThreadHelper.h -# -# +SUBDIRS = lib client server AI + + diff --git a/client/Makefile.am b/client/Makefile.am index 9b65e74ab..470c5a378 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -1,73 +1,72 @@ -AUTOMAKE_OPTIONS=foreign bin_PROGRAMS = vcmiclient -#vcmi_LDADD = $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB) -#AM_CXXFLAGS = $(BOOST_CPPFLAGS) -vcmiclient_LDADD = $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB) -#vcmiclient_LDADD = $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB) + +vcmiclient_LDADD = $(top_builddir)/lib/libvcmi.a $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB) vcmiclient_LDFLAGS = -L$(top_builddir)/lib -vcmiclient_LDADD += -lvcmi vcmiclient_SOURCES = \ -../AdventureMapButton.cpp \ -../CAdvmapInterface.cpp \ -../CBattleInterface.cpp \ -./CBitmapHandler.cpp \ -../CCallback.cpp \ -../CCastleInterface.cpp \ -./CConfigHandler.cpp \ -./CCreatureAnimation.cpp \ -../CCursorHandler.cpp \ -../hch/CDefHandler.cpp \ -../CGameInfo.cpp \ -../CGameInterface.cpp \ -../CHeroWindow.cpp \ -./Client.cpp \ -../CMessage.cpp \ -../CMT.cpp \ -../hch/CMusicHandler.cpp \ -../CPlayerInterface.cpp \ -../CPreGame.cpp \ -../hch/CSndHandler.cpp \ -./CSpellWindow.cpp \ -../CThreadHelper.cpp \ -./Graphics.cpp \ -../mapHandler.cpp \ -./NetPacksClient.cpp \ -../SDL_Extensions.cpp \ -../SDL_framerate.cpp \ -../AdventureMapButton.h \ -../AI_Base.h \ -../CAdvmapInterface.h \ -../hch/CAmbarCendamo.h \ -../CBattleInterface.h \ -./CBitmapHandler.h \ -../hch/CBuildingHandler.h \ -../CCallback.h \ -../CCastleInterface.h \ -./CConfigHandler.h \ -./CCreatureAnimation.h \ -../CCursorHandler.h \ -../hch/CDefHandler.h \ -../CGameInfo.h \ -../CGameInterface.h \ -../hch/CHeroHandler.h \ -../CHeroWindow.h \ -./Client.h \ -../CMessage.h \ -../hch/CMusicHandler.h \ -../hch/CObjectHandler.h \ -../CPlayerInterface.h \ -../CPreGame.h \ -../hch/CSndHandler.h \ -./CSpellWindow.h \ -../CThreadHelper.h \ -./FunctionList.h \ -../global.h \ -./Graphics.h \ -../int3.h \ -../map.h \ -../mapHandler.h \ -../nodrze.h \ -../SDL_framerate.h \ -../StartInfo.h \ -../stdafx.h \ -../timeHandler.h + ../AI_Base.h \ + ../AdventureMapButton.cpp \ + ../AdventureMapButton.h \ + ../CAdvmapInterface.cpp \ + ../CAdvmapInterface.h \ + ../CBattleInterface.cpp \ + ../CBattleInterface.h \ + ../CCallback.cpp \ + ../CCallback.h \ + ../CCastleInterface.cpp \ + ../CCastleInterface.h \ + ../CCursorHandler.cpp \ + ../CCursorHandler.h \ + ../CGameInfo.cpp \ + ../CGameInfo.h \ + ../CGameInterface.cpp \ + ../CGameInterface.h \ + ../CHeroWindow.cpp \ + ../CHeroWindow.h \ + ../CMT.cpp \ + ../CMessage.cpp \ + ../CMessage.h \ + ../CPlayerInterface.cpp \ + ../CPlayerInterface.h \ + ../CPreGame.cpp \ + ../CPreGame.h \ + ../CThreadHelper.cpp \ + ../CThreadHelper.h \ + ../SDL_Extensions.cpp \ + ../SDL_Extensions.h \ + ../SDL_framerate.cpp \ + ../SDL_framerate.h \ + ../StartInfo.h \ + ../global.h \ + ../hch/CAmbarCendamo.h \ + ../hch/CBuildingHandler.h \ + ../hch/CDefHandler.cpp \ + ../hch/CDefHandler.h \ + ../hch/CHeroHandler.h \ + ../hch/CMusicHandler.cpp \ + ../hch/CMusicHandler.h \ + ../hch/CObjectHandler.h \ + ../hch/CSndHandler.cpp \ + ../hch/CSndHandler.h \ + ../hch/CVideoHandler.h \ + ../int3.h \ + ../map.h \ + ../mapHandler.cpp \ + ../mapHandler.h \ + ../nodrze.h \ + ../stdafx.h \ + ../tchar_amigaos4.h \ + ../timeHandler.h \ + ./CBitmapHandler.cpp \ + ./CBitmapHandler.h \ + ./CConfigHandler.cpp \ + ./CConfigHandler.h \ + ./CCreatureAnimation.cpp \ + ./CCreatureAnimation.h \ + ./CSpellWindow.cpp \ + ./CSpellWindow.h \ + ./Client.cpp \ + ./Client.h \ + ./FunctionList.h \ + ./Graphics.cpp \ + ./Graphics.h \ + ./NetPacksClient.cpp diff --git a/configure.ac b/configure.ac index 16316b18f..cfa456558 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_DISABLE_STATIC AC_PROG_LIBTOOL CFLAGS="-g" -CXXFLAGS="-g" +CXXFLAGS="-O1 -ggdb -Wall" AC_CHECK_LIB([stdc++], [main]) if test "x$GCC" = "xyes"; then stdcxx_name=`$CXX -print-file-name=libstdc++.so` @@ -64,4 +64,4 @@ AC_FUNC_MALLOC AC_FUNC_SELECT_ARGTYPES 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 AI/GeniusAI/Makefile) diff --git a/hch/CCreatureHandler.cpp b/hch/CCreatureHandler.cpp index 389b54759..a6e1230cc 100644 --- a/hch/CCreatureHandler.cpp +++ b/hch/CCreatureHandler.cpp @@ -389,9 +389,10 @@ void CCreatureHandler::loadCreatures() inp.seekg(0,std::ios::end); // na koniec int andame2 = inp.tellg(); // read length inp.seekg(0,std::ios::beg); // wracamy na poczatek - char * bufor = new char[andame2]; // allocate memory + char * bufor = new char[andame2+1]; // allocate memory inp.read((char*)bufor, andame2); // read map file to buffer inp.close(); + bufor[andame2] = 0; buf = std::string(bufor); delete [] bufor; diff --git a/lib/Makefile.am b/lib/Makefile.am index 98618a754..90239c56f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,45 +1,43 @@ noinst_LIBRARIES = libvcmi.a -#vcmi_LDADD = $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB) -#AM_CXXFLAGS = $(BOOST_CPPFLAGS) libvcmi_a_SOURCES = \ -../hch/CArtHandler.cpp \ -../hch/CBuildingHandler.cpp \ -../CConsoleHandler.cpp \ -../hch/CCreatureHandler.cpp \ -../hch/CDefObjInfoHandler.cpp \ -../CGameState.cpp \ -../hch/CGeneralTextHandler.cpp \ -../hch/CHeroHandler.cpp \ -../hch/CLodHandler.cpp \ -../hch/CObjectHandler.cpp \ -./Connection.cpp \ -../hch/CSpellHandler.cpp \ -../hch/CTownHandler.cpp \ -./IGameCallback.cpp \ -../map.cpp \ -./NetPacksLib.cpp \ -./RegisterTypes.cpp \ -../stdafx.cpp \ -./VCMI_Lib.cpp \ -./BattleAction.h \ -../hch/CArtHandler.h \ -../hch/CBuildingHandler.h \ -../CConsoleHandler.h \ -../hch/CCreatureHandler.h \ -../hch/CDefObjInfoHandler.h \ -../CGameState.h \ -../hch/CGeneralTextHandler.h \ -../hch/CHeroHandler.h \ -../hch/CLodHandler.h \ -../hch/CObjectHandler.h \ -./CondSh.h \ -./Connection.h \ -../hch/CSpellHandler.h \ -../hch/CTownHandler.h \ -./Herobonus.h \ -./IGameCallback.h \ -./Interprocess.h \ -../map.h \ -./NetPacks.h \ -./RegisterTypes.h \ -./VCMI_Lib.h + ../CConsoleHandler.cpp \ + ../CConsoleHandler.h \ + ../CGameState.cpp \ + ../CGameState.h \ + ../hch/CArtHandler.cpp \ + ../hch/CArtHandler.h \ + ../hch/CBuildingHandler.cpp \ + ../hch/CBuildingHandler.h \ + ../hch/CCreatureHandler.cpp \ + ../hch/CCreatureHandler.h \ + ../hch/CDefObjInfoHandler.cpp \ + ../hch/CDefObjInfoHandler.h \ + ../hch/CGeneralTextHandler.cpp \ + ../hch/CGeneralTextHandler.h \ + ../hch/CHeroHandler.cpp \ + ../hch/CHeroHandler.h \ + ../hch/CLodHandler.cpp \ + ../hch/CLodHandler.h \ + ../hch/CObjectHandler.cpp \ + ../hch/CObjectHandler.h \ + ../hch/CSpellHandler.cpp \ + ../hch/CSpellHandler.h \ + ../hch/CTownHandler.cpp \ + ../hch/CTownHandler.h \ + ../map.cpp \ + ../map.h \ + ../stdafx.cpp \ + ./BattleAction.h \ + ./CondSh.h \ + ./Connection.cpp \ + ./Connection.h \ + ./HeroBonus.h \ + ./IGameCallback.cpp \ + ./IGameCallback.h \ + ./Interprocess.h \ + ./NetPacks.h \ + ./NetPacksLib.cpp \ + ./RegisterTypes.cpp \ + ./RegisterTypes.h \ + ./VCMI_Lib.cpp \ + ./VCMI_Lib.h diff --git a/server/Makefile.am b/server/Makefile.am index 368ca7dd9..c051f39b3 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -1,13 +1,10 @@ -AUTOMAKE_OPTIONS=foreign bin_PROGRAMS = vcmiserver -vcmiserver_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) + +vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.a $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_THREAD_LIB) vcmiserver_LDFLAGS = -L$(top_builddir)/lib -vcmiserver_LDADD += -lvcmi vcmiserver_SOURCES = \ -./CGameHandler.cpp \ -./CVCMIServer.cpp \ -./NetPacksServer.cpp \ -./CGameHandler.h \ -./CVCMIServer.h + ./CGameHandler.cpp \ + ./CGameHandler.h \ + ./CVCMIServer.cpp \ + ./CVCMIServer.h \ + ./NetPacksServer.cpp