Browse Source

Made all paths dependent on DATA_DIR, USER_DIR, BIN_DIR or LIB_DIR. Data access can now be separated from saved games and binaries.
Fixed a file handle leak.
Bumped revision to 0.74b (linux).
Reworked the build system to remove uneeded dependencies (linux).
Removed use of PATHSEPARATOR since Windows can use / too.

Frank Zago 16 years ago
parent
commit
1609b8fdb9

+ 1 - 1
AI/EmptyAI/Makefile.am

@@ -1,5 +1,5 @@
 pkglib_LTLIBRARIES = EmptyAI.la
-EmptyAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@
+EmptyAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
 EmptyAI_la_LDFLAGS = -L$(top_builddir)/lib -module
 EmptyAI_la_SOURCES = \
 	CEmptyAI.cpp \

+ 1 - 1
AI/EmptyAI/Makefile.in

@@ -218,7 +218,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 pkglib_LTLIBRARIES = EmptyAI.la
-EmptyAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@
+EmptyAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
 EmptyAI_la_LDFLAGS = -L$(top_builddir)/lib -module
 EmptyAI_la_SOURCES = \
 	CEmptyAI.cpp \

+ 1 - 1
AI/GeniusAI/Makefile.am

@@ -1,5 +1,5 @@
 pkglib_LTLIBRARIES = GeniusAI.la
-GeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@
+GeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
 GeniusAI_la_LDFLAGS = -L$(top_builddir)/lib -module
 GeniusAI_la_SOURCES = \
 	AIPriorities.cpp \

+ 1 - 1
AI/GeniusAI/Makefile.in

@@ -220,7 +220,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 pkglib_LTLIBRARIES = GeniusAI.la
-GeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@
+GeniusAI_la_LIBADD = $(top_builddir)/lib/libvcmi.la
 GeniusAI_la_LDFLAGS = -L$(top_builddir)/lib -module
 GeniusAI_la_SOURCES = \
 	AIPriorities.cpp \

+ 1 - 1
CGameInterface.cpp

@@ -39,7 +39,7 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
 	getName = (void(*)(char*))GetProcAddress(dll,"GetAiName");
 	getAI = (CGlobalAI*(*)())GetProcAddress(dll,"GetNewAI");
 #else
-	dllPath = "AI/"+dllname+".so";
+	dllPath = LIB_DIR "/" + dllname + ".so";
 	void *dll = dlopen(dllPath.c_str(), RTLD_LOCAL | RTLD_LAZY);
 	if (!dll)
 	{

+ 1 - 3
Makefile.am

@@ -1,7 +1,5 @@
 ACLOCAL_AMFLAGS = -I aclocal/m4
-EXTRA_DIST = aclocal/m4
-AM_CXXFLAGS = @BOOST_CPPFLAGS@
-AM_LDFLAGS = @BOOST_LDFLAGS@
+EXTRA_DIST = aclocal/m4 README.linux
 SUBDIRS = lib client server AI
 
 

+ 1 - 3
Makefile.in

@@ -206,9 +206,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 ACLOCAL_AMFLAGS = -I aclocal/m4
-EXTRA_DIST = aclocal/m4
-AM_CXXFLAGS = @BOOST_CPPFLAGS@
-AM_LDFLAGS = @BOOST_LDFLAGS@
+EXTRA_DIST = aclocal/m4 README.linux
 SUBDIRS = lib client server AI
 all: all-recursive
 

+ 32 - 25
README.linux

@@ -24,20 +24,19 @@ To compile, at least the following packages (and their development counterparts)
 On Ubuntu 9.04, run:
   sudo apt-get install g++ libsdl1.2debian-all libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev zlib1g-dev libavformat-dev libswscale-dev libboost1.37-dev
 
+Create a directory /YOUR_INSTALL_PATH/vcmi (such as
+/usr/local/share/games/vcmi) that will contain the game data files. The /vcmi at the end is necessary.
 
-Then do the usual 
-  ./configure
+Then run configure:
+  ./configure --datadir=/YOUR_INSTALL_PATH/ --bindir=/YOUR_INSTALL_PATH/vcmi --libdir=/YOUR_INSTALL_PATH/
 
-Note that on 64 bits linux, if the boost libraries are installed in /usr/lib64, configure will not find them and will fail. Until this is fixed, use:
-  ./configure --with-boost-libdir=/usr/lib64
+On 64 bits linux (such as OpenSUSE but not Ubuntu), if the boost
+libraries are installed in /usr/lib64, configure will not find them
+and will fail. Until this is fixed, add the following option to
+./configure: --with-boost-libdir=/usr/lib64
 
-Note: if you've not installed everything, some files will be missing, and you may want to hack your system (don't) such as:
-=============
-Another note on ubuntu(posible others to) - create symlincs to correct libnames in /usr/lib
-eg:
-sudo ln -s libswscale.so.0.7.1 libswscale.so
-sudo ln -s libavformat.so.52 libavformat.so
-=============
+If you want to use the Intel C++ compiler, add the following option to ./configure:
+  CXX="icc -diag-disable 383,981,1418,869,1563,2259,1782,444,271,1,10156,1419"
 
 Then build vcmi:
   make
@@ -47,37 +46,45 @@ That will generate vcmiclient, vcmiserver as well as 3 .so libraries.
 
 II. Installing Heroes of Might and Magic 3
 
-VCMI needs an installed version of Heroes III as well as WoG on top of it.
-The version of Heroes needed is (I think!) Shadow of Death or Complete.
- 
+VCMI needs an installed version of Heroes III as well as WoG on top of
+it.  The version of Heroes needed is (I think!) either Shadow of Death
+or Complete.
+
 Wog can be downloaded from: http://www.maps4heroes.com/heroes3/files/allinone_358f.zip
 
 Wine can be used to install both.
 
+Install Heroes 3 and Wog. Then move all the installed files into
+/YOUR_INSTALL_PATH/vcmi. For instance that will create
+/YOUR_INSTALL_PATH/vcmi/Data.
+
 Once both programs are installed, you can install VCMI.
 
-Download the windows VCMI release (at time of writing: http://vcmi.antypika.aplus.pl/forum/dload.php?action=download&id=11) and extract it in a private directory. Then move some files to your Heroes3 directory:
-  mv sprites /PATH_TO_H3_DIR/Sprites
-  mv Data/* /PATH_TO_H3_DIR/Data
-  mv Fonts Games /PATH_TO_H3_DIR/
+Download the windows VCMI release (at time of writing: 
+http://vcmi.antypika.aplu...=download&id=14)
+and extract it in a private directory. Populate /YOUR_INSTALL_PATH/vcmi:
+
+  mv sprites /YOUR_INSTALL_PATH/vcmi/Sprites
+  mv Data/* /YOUR_INSTALL_PATH/vcmi/Data
+  mv Fonts Games /YOUR_INSTALL_PATH/vcmi/
 
 If you also have the original linux version of Heroes, you can also install the videos:
-  cp -a /PATH_TO_CDROM/data/video /PATH_TO_H3_DIR/Data
+  cp -a /PATH_TO_CDROM/data/video /YOUR_INSTALL_PATH/vcmi/Data
 
 
 III. Installing VCMI
 
 Since VCMI is still in development, there's no install procedure, although something like 
   DESTDIR=/path/to/heroes3 make install
-might work.
+will work.
+
+For development puposes, it's better to use links. Go
+to /YOUR_INSTALL_PATH/vcmi, and type:
 
-For development puposes, it's better to use links. Go to your new Heroes3 directory, and type:
   ln -s /PATH_TO_VCMI/client/vcmiclient
   ln -s /PATH_TO_VCMI/server/vcmiserver
   ln -s /PATH_TO_VCMI/config
-  ln -s /PATH_TO_VCMI/AI/GeniusAI/.libs AI
-
-And start ./vcmiclient
-  
+  ln -s /PATH_TO_VCMI/AI/GeniusAI/.libs/GeniusAI.so
 
 
+And start ./vcmiclient

+ 1 - 1
client/CAdvmapInterface.cpp

@@ -85,7 +85,7 @@ CMinimap::CMinimap(bool draw)
 	SDL_SetColorKey(radar,SDL_SRCCOLORKEY,SDL_MapRGB(radar->format,0,255,255));
 
 	//radar = CDefHandler::giveDef("RADAR.DEF");
-	std::ifstream is("config/minimap.txt",std::ifstream::in);
+	std::ifstream is(DATA_DIR "/config/minimap.txt",std::ifstream::in);
 	for (int i=0;i<TERRAIN_TYPES;i++)
 	{
 		std::pair<int,SDL_Color> vinya;

+ 2 - 2
client/CBitmapHandler.cpp

@@ -187,7 +187,7 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey)
 	if(e->offset<0)
 	{
 		fname.replace(fname.find_first_of('.'),fname.find_first_of('.')+4,".BMP");
-		fname = "Data/"+fname;
+		fname = DATA_DIR "/Data/" + fname;
 		FILE * f = fopen(fname.c_str(),"r");
 		if(f)
 		{
@@ -259,4 +259,4 @@ SDL_Surface * BitmapHandler::loadBitmap(std::string fname, bool setKey)
 		SDL_SetColorKey(ret,SDL_SRCCOLORKEY,SDL_MapRGB(ret->format, c.r, c.g, c.b));
 	}
 	return ret;
-}
+}

+ 1 - 1
client/CConfigHandler.cpp

@@ -344,7 +344,7 @@ CConfigHandler::~CConfigHandler(void)
 void config::CConfigHandler::init()
 {
 	std::vector<char> settings;
-	std::ifstream ifs("config/settings.txt");
+	std::ifstream ifs(DATA_DIR "/config/settings.txt");
 	if(!ifs)
 	{
 		tlog1 << "Cannot open config/settings.txt !\n";

+ 9 - 9
client/CMT.cpp

@@ -92,11 +92,11 @@ void init()
 
 	TTF_Init();
 	atexit(TTF_Quit);
-	TNRB16 = TTF_OpenFont("Fonts" PATHSEPARATOR "tnrb.ttf",16);
-	GEOR13 = TTF_OpenFont("Fonts" PATHSEPARATOR "georgia.ttf",13);
-	GEOR16 = TTF_OpenFont("Fonts" PATHSEPARATOR "georgia.ttf",16);
-	GEORXX = TTF_OpenFont("Fonts" PATHSEPARATOR "tnrb.ttf",22);
-	GEORM = TTF_OpenFont("Fonts" PATHSEPARATOR "georgia.ttf",10);
+	TNRB16 = TTF_OpenFont(DATA_DIR "/Fonts/tnrb.ttf",16);
+	GEOR13 = TTF_OpenFont(DATA_DIR "/Fonts/georgia.ttf",13);
+	GEOR16 = TTF_OpenFont(DATA_DIR "/Fonts/georgia.ttf",16);
+	GEORXX = TTF_OpenFont(DATA_DIR "/Fonts/tnrb.ttf",22);
+	GEORM = TTF_OpenFont(DATA_DIR "/Fonts/georgia.ttf",10);
 	if(! (TNRB16 && GEOR16 && GEORXX && GEORM))
 	{
 		tlog1 << "One of the fonts couldn't be loaded!\n";
@@ -106,7 +106,7 @@ void init()
 
 	{
 		//read system options
-		CLoadFile settings("config" PATHSEPARATOR "sysopts.bin");
+		CLoadFile settings(DATA_DIR "/config/sysopts.bin");
 		if(settings.sfile)
 		{
 			settings >> GDefaultOptions;
@@ -326,7 +326,7 @@ void processCommand(const std::string &message)
 		boost::filesystem::create_directory("Extracted_txts");
 		tlog0<<"Command accepted. Opening .lod file...\t";
 		CLodHandler * txth = new CLodHandler;
-		txth->init(std::string(DATA_DIR "Data" PATHSEPARATOR "H3bitmap.lod"),"");
+		txth->init(std::string(DATA_DIR "/Data/H3bitmap.lod"),"");
 		tlog0<<"done.\nScanning .lod file\n";
 		int curp=0;
 		std::string pattern = ".TXT", pom;
@@ -335,7 +335,7 @@ void processCommand(const std::string &message)
 			pom = txth->entries[i].nameStr;
 			if(boost::algorithm::find_last(pom,pattern))
 			{
-				txth->extractFile(std::string("Extracted_txts" PATHSEPARATOR)+pom,pom);
+				txth->extractFile(std::string(DATA_DIR "/Extracted_txts/")+pom,pom);
 			}
 			if(i%8) continue;
 			int p2 = ((float)i/(float)txth->entries.size())*(float)100;
@@ -533,4 +533,4 @@ void startGame(StartInfo * options)
 		client->run();
 		//boost::thread t(boost::bind(&CClient::run,&cl));
 	}
-}
+}

+ 3 - 3
client/CPlayerInterface.cpp

@@ -1563,12 +1563,12 @@ void SystemOptions::setMapScrollingSpeed( int newSpeed )
 
 void SystemOptions::settingsChanged()
 {
-	CSaveFile settings("config" PATHSEPARATOR "sysopts.bin");
+	CSaveFile settings(DATA_DIR "/config/sysopts.bin");
 
 	if(settings.sfile)
 		settings << *this;
 	else
-		tlog1 << "Cannot save settings to config" PATHSEPARATOR "sysopts.bin!\n";
+		tlog1 << "Cannot save settings to config/sysopts.bin!\n";
 }
 
 void SystemOptions::apply()
@@ -1593,4 +1593,4 @@ SystemOptions::SystemOptions()
 	animSpeed = 2;
 	printMouseShadow = true;
 	showQueue = true;
-}
+}

+ 4 - 4
client/CPreGame.cpp

@@ -418,7 +418,7 @@ void SelectionTab::getFiles(std::vector<FileInfo> &out, const std::string &dirna
 	{
 		tlog1 << "Cannot find " << dirname << " directory!\n";
 	}
-	fs::path tie( (fs::initial_path<fs::path>())/dirname );
+	fs::path tie(dirname);
 	fs::directory_iterator end_iter;
 	for ( fs::directory_iterator file (tie); file!=end_iter; ++file )
 	{
@@ -497,14 +497,14 @@ SelectionTab::SelectionTab(EState Type, const boost::function<void(CMapInfo *)>
 	switch(type)
 	{
 	case newGame:
-		getFiles(toParse, "Maps", "h3m");
+		getFiles(toParse, DATA_DIR "/Maps", "h3m");
 		parseMaps(toParse);
 		positions = 18;
 		break;
 
 	case loadGame:
 	case saveGame:
-		getFiles(toParse, "Games", "vlgm1");
+		getFiles(toParse, USER_DIR "/Games", "vlgm1");
 		parseGames(toParse);
 		if(type == loadGame)
 		{
@@ -548,7 +548,7 @@ SelectionTab::SelectionTab(EState Type, const boost::function<void(CMapInfo *)>
 	switch(type)
 	{
 	case newGame:
-		selectFName("Maps/Arrogance.h3m");
+		selectFName(DATA_DIR "Maps/Arrogance.h3m");
 		break;
 	case loadGame:
 		select(0);

+ 8 - 8
client/Graphics.cpp

@@ -160,7 +160,7 @@ void Graphics::loadPaletteAndColors()
 
 	neutralColorPalette = new SDL_Color[32];
 	std::ifstream ncp;
-	ncp.open("config/NEUTRAL.PAL", std::ios::binary);
+	ncp.open(DATA_DIR "/config/NEUTRAL.PAL", std::ios::binary);
 	for(int i=0; i<32; ++i)
 	{
 		ncp.read((char*)&neutralColorPalette[i].r,1);
@@ -182,7 +182,7 @@ void Graphics::loadPaletteAndColors()
 	}
 	neutralColor->r = 0x84; neutralColor->g = 0x84; neutralColor->b = 0x84; neutralColor->unused = 0x0;//gray
 
-	std::ifstream bback("config/mageBg.txt");
+	std::ifstream bback(DATA_DIR "/config/mageBg.txt");
 	while(!bback.eof())
 	{
 		bback >> pals;
@@ -193,7 +193,7 @@ void Graphics::loadPaletteAndColors()
 
 void Graphics::initializeBattleGraphics()
 {
-	std::ifstream bback("config/battleBack.txt");
+	std::ifstream bback(DATA_DIR "/config/battleBack.txt");
 	battleBacks.resize(26);
 	for(int i=1; i<26; ++i) //25 - number of terrains battle can be fought on
 	{
@@ -207,7 +207,7 @@ void Graphics::initializeBattleGraphics()
 	}
 
 	//initializing battle hero animation
-	std::ifstream bher("config/battleHeroes.txt");
+	std::ifstream bher(DATA_DIR "/config/battleHeroes.txt");
 	int numberofh;
 	bher>>numberofh;
 	battleHeroes.resize(numberofh);
@@ -218,7 +218,7 @@ void Graphics::initializeBattleGraphics()
 
 	//initialization of AC->def name mapping
 	std::ifstream acd;
-	acd.open("config/AC_desc.txt", std::ios::binary);
+	acd.open(DATA_DIR "/config/AC_desc.txt", std::ios::binary);
 	if(!acd.is_open())
 	{
 		tlog1<<"lack of config/AC_desc.txt file!"<<std::endl;
@@ -292,7 +292,7 @@ Graphics::Graphics()
 	tasks += GET_DEF_ESS(abils82,"SECSK82.DEF");
 	tasks += GET_DEF_ESS(spellscr,"SPELLSCR.DEF");
 
-	std::ifstream ifs("config/cr_bgs.txt"); 
+	std::ifstream ifs(DATA_DIR "/config/cr_bgs.txt"); 
 	int id;
 	std::string name;
 	while(!ifs.eof())
@@ -322,7 +322,7 @@ Graphics::Graphics()
 }
 void Graphics::loadHeroPortraits()
 {	
-	std::ifstream of("config/portrety.txt");
+	std::ifstream of(DATA_DIR "/config/portrety.txt");
 	int numberOfPortraits;
 	of>>numberOfPortraits;
 	for (int j=0; j<numberOfPortraits; j++)
@@ -662,4 +662,4 @@ int Font::getWidth(const char *text ) const
 	}
 
 	return ret;
-}
+}

+ 2 - 2
client/Makefile.am

@@ -1,7 +1,7 @@
 bin_PROGRAMS = vcmiclient
 
-vcmiclient_LDADD = $(top_builddir)/lib/libvcmi.la @SDL_LIBS@ @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ @FFMPEG_LIBS@
-vcmiclient_CXXFLAGS = @CXXFLAGS@ @SDL_CXXFLAGS@ @FFMPEG_CXXFLAGS@
+vcmiclient_LDADD = $(top_builddir)/lib/libvcmi.la @SDL_LIBS@ @FFMPEG_LIBS@
+vcmiclient_CXXFLAGS = @SDL_CXXFLAGS@ @FFMPEG_CXXFLAGS@
 vcmiclient_LDFLAGS = -L$(top_builddir)/lib
 vcmiclient_SOURCES =  \
 	../AI_Base.h \

+ 2 - 2
client/Makefile.in

@@ -238,8 +238,8 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-vcmiclient_LDADD = $(top_builddir)/lib/libvcmi.la @SDL_LIBS@ @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ @FFMPEG_LIBS@
-vcmiclient_CXXFLAGS = @CXXFLAGS@ @SDL_CXXFLAGS@ @FFMPEG_CXXFLAGS@
+vcmiclient_LDADD = $(top_builddir)/lib/libvcmi.la @SDL_LIBS@ @FFMPEG_LIBS@
+vcmiclient_CXXFLAGS = @SDL_CXXFLAGS@ @FFMPEG_CXXFLAGS@
 vcmiclient_LDFLAGS = -L$(top_builddir)/lib
 vcmiclient_SOURCES = \
 	../AI_Base.h \

+ 2 - 2
client/NetPacksClient.cpp

@@ -541,7 +541,7 @@ void YourTurn::applyCl( CClient *cl )
 
 void SaveGame::applyCl(CClient *cl)
 {
-	CSaveFile save("Games" PATHSEPARATOR + fname + ".vcgm1");
+	CSaveFile save("Games/" + fname + ".vcgm1");
 	save << *cl;
 }
 
@@ -639,4 +639,4 @@ void TradeComponents::applyCl(CClient *cl)
 		default: 
 			tlog2 << "Shop type not supported! \n";
 	}
-}
+}

+ 12 - 10
configure

@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for vcmi 0.73b.
+# Generated by GNU Autoconf 2.63 for vcmi 0.74b.
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
 # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
@@ -743,8 +743,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='vcmi'
 PACKAGE_TARNAME='vcmi'
-PACKAGE_VERSION='0.73b'
-PACKAGE_STRING='vcmi 0.73b'
+PACKAGE_VERSION='0.74b'
+PACKAGE_STRING='vcmi 0.74b'
 PACKAGE_BUGREPORT=''
 
 # Factoring default headers for most tests.
@@ -1490,7 +1490,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures vcmi 0.73b to adapt to many kinds of systems.
+\`configure' configures vcmi 0.74b to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1560,7 +1560,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of vcmi 0.73b:";;
+     short | recursive ) echo "Configuration of vcmi 0.74b:";;
    esac
   cat <<\_ACEOF
 
@@ -1687,7 +1687,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-vcmi configure 0.73b
+vcmi configure 0.74b
 generated by GNU Autoconf 2.63
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1701,7 +1701,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by vcmi $as_me 0.73b, which was
+It was created by vcmi $as_me 0.74b, which was
 generated by GNU Autoconf 2.63.  Invocation command line was
 
   $ $0 $@
@@ -2417,7 +2417,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='vcmi'
- VERSION='0.73b'
+ VERSION='0.74b'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -15237,6 +15237,8 @@ if test "x$GXX" = "xyes" -a "x$enable_debug" = "xyes" ; then
    CXXFLAGS="-O0 -ggdb -Wall -Wcast-align -Wpointer-arith"
 fi
 
+CXXFLAGS="$CXXFLAGS -DDATA_DIR=\\\"\$(pkgdatadir)\\\" -DBIN_DIR=\\\"\$(bindir)\\\" -DLIB_DIR=\\\"\$(pkglibdir)\\\""
+
 # Check for Boost libraries
 
 
@@ -18598,7 +18600,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by vcmi $as_me 0.73b, which was
+This file was extended by vcmi $as_me 0.74b, which was
 generated by GNU Autoconf 2.63.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -18652,7 +18654,7 @@ Report bugs to <[email protected]>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_version="\\
-vcmi config.status 0.73b
+vcmi config.status 0.74b
 configured by $0, generated by GNU Autoconf 2.63,
   with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 

+ 3 - 1
configure.ac

@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.60)
-AC_INIT(vcmi, 0.73b)			# Follow NAME_VER in global.h
+AC_INIT(vcmi, 0.74b)			# Follow NAME_VER in global.h
 AM_INIT_AUTOMAKE
 AC_CONFIG_MACRO_DIR([aclocal/m4])
 
@@ -25,6 +25,8 @@ if test "x$GXX" = "xyes" -a "x$enable_debug" = "xyes" ; then
    CXXFLAGS="-O0 -ggdb -Wall -Wcast-align -Wpointer-arith"
 fi
 
+CXXFLAGS="$CXXFLAGS -DDATA_DIR=\\\"\$(pkgdatadir)\\\" -DBIN_DIR=\\\"\$(bindir)\\\" -DLIB_DIR=\\\"\$(pkglibdir)\\\""
+
 # Check for Boost libraries
 AX_BOOST_BASE([1.36])
 AX_BOOST_SYSTEM

+ 19 - 5
global.h

@@ -26,14 +26,28 @@ extern std::string NAME_AFFIX; //client / server
 #define CONSOLE_LOGGING_LEVEL 5
 #define FILE_LOGGING_LEVEL 6
 
+/* 
+ * DATA_DIR contains the game data (Data/, MP3/, ...).
+ * USER_DIR is where to save games (Games/).
+ * BIN_DIR is where the vcmiclient/vcmiserver binaries reside (linux only) 
+ * LIB_DIR is where the AI libraries reside (linux only) 
+ */
 #ifdef _WIN32
-#define PATHSEPARATOR "\\"
-#define DATA_DIR ""
+#define DATA_DIR "."
+#define USER_DIR "."
 #define SERVER_NAME "VCMI_server.exe"
 #else
-#define PATHSEPARATOR "/"
-#define DATA_DIR ""
-#define SERVER_NAME "./vcmiserver"
+#ifndef DATA_DIR
+#error DATA_DIR undefined.
+#endif
+#ifndef BIN_DIR
+#error BIN_DIR undefined.
+#endif
+#ifndef LIB_DIR
+#error LIB_DIR undefined.
+#endif
+#define USER_DIR DATA_DIR		// TODO: should be $HOME/.vcmi
+#define SERVER_NAME BIN_DIR "/vcmiserver"
 #endif
 
 /*

+ 1 - 1
hch/CBuildingHandler.cpp

@@ -99,7 +99,7 @@ void CBuildingHandler::loadBuildings()
 	/////done reading BUILDING.TXT*****************************
 
 	char line[100]; //bufor
-	std::ifstream ofs("config/hall.txt");
+	std::ifstream ofs(DATA_DIR "/config/hall.txt");
 	int castles;
 	ofs>>castles;
 	for(int i=0;i<castles;i++)

+ 8 - 8
hch/CCreatureHandler.cpp

@@ -172,7 +172,7 @@ void CCreatureHandler::loadCreatures()
 	bool useCreAbilsFromZCRTRAIT = true;
 
 	////////////reading cr_abils.txt ///////////////////
-	std::ifstream abils("config" PATHSEPARATOR "cr_abils.txt", std::ios::in | std::ios::binary); //this file is not in lod
+	std::ifstream abils(DATA_DIR "/config/cr_abils.txt", std::ios::in | std::ios::binary); //this file is not in lod
 	const int MAX_LINE_SIZE = 1000;
 	char abilLine[MAX_LINE_SIZE+1];
 	for(int i=0; i<5; ++i) //removing 5 comment lines
@@ -402,7 +402,7 @@ void CCreatureHandler::loadCreatures()
 
 	tlog5 << "\t\tReading config/crerefnam.txt" << std::endl;
 	//loading reference names
-	std::ifstream ifs("config/crerefnam.txt");
+	std::ifstream ifs(DATA_DIR "/config/crerefnam.txt");
 	int tempi;
 	std::string temps;
 	for (;;)
@@ -419,7 +419,7 @@ void CCreatureHandler::loadCreatures()
 		levelCreatures.insert(std::pair<int,std::vector<CCreature*> >(i,std::vector<CCreature*>()));
 
 	tlog5 << "\t\tReading config/monsters.txt" << std::endl;
-	ifs.open("config/monsters.txt");
+	ifs.open(DATA_DIR "/config/monsters.txt");
 	{
 		while(!ifs.eof())
 		{
@@ -436,7 +436,7 @@ void CCreatureHandler::loadCreatures()
 	ifs.clear();
 
 	tlog5 << "\t\tReading config/cr_factions.txt" << std::endl;
-	ifs.open("config/cr_factions.txt");
+	ifs.open(DATA_DIR "/config/cr_factions.txt");
 	while(!ifs.eof())
 	{
 		int id, fact;
@@ -447,7 +447,7 @@ void CCreatureHandler::loadCreatures()
 	ifs.clear();
 
 	tlog5 << "\t\tReading config/cr_upgrade_list.txt" << std::endl;
-	ifs.open("config/cr_upgrade_list.txt");
+	ifs.open(DATA_DIR "/config/cr_upgrade_list.txt");
 	while(!ifs.eof())
 	{
 		int id, up;
@@ -459,7 +459,7 @@ void CCreatureHandler::loadCreatures()
 
 	//loading unit animation def names
 	tlog5 << "\t\tReading config/CREDEFS.TXT" << std::endl;
-	std::ifstream inp("config/CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
+	std::ifstream inp(DATA_DIR "/config/CREDEFS.TXT", std::ios::in | std::ios::binary); //this file is not in lod
 	inp.seekg(0,std::ios::end); // na koniec
 	int andame2 = inp.tellg();  // read length
 	inp.seekg(0,std::ios::beg); // wracamy na poczatek
@@ -507,7 +507,7 @@ void CCreatureHandler::loadCreatures()
 	//loading id to projectile mapping
 
 	tlog5 << "\t\tReading config/cr_shots.txt" << std::endl;
-	std::ifstream inp2("config" PATHSEPARATOR "cr_shots.txt", std::ios::in | std::ios::binary); //this file is not in lod
+	std::ifstream inp2(DATA_DIR "/config/cr_shots.txt", std::ios::in | std::ios::binary); //this file is not in lod
 	char dump [200];
 	inp2.getline(dump, 200);
 	while(true)
@@ -529,7 +529,7 @@ void CCreatureHandler::loadCreatures()
 	//reading factionToTurretCreature
 
 	tlog5 << "\t\tReading config/cr_to_turret.txt" << std::endl;
-	std::ifstream inp3("config" PATHSEPARATOR "cr_to_turret.txt", std::ios::in | std::ios::binary); //this file is not in lod
+	std::ifstream inp3(DATA_DIR "/config/cr_to_turret.txt", std::ios::in | std::ios::binary); //this file is not in lod
 	std::string dump2;
 	inp3 >> dump2 >> dump2;
 	for(int g=0; g<F_NUMBER; ++g)

+ 8 - 8
hch/CHeroHandler.cpp

@@ -134,7 +134,7 @@ CHeroHandler::CHeroHandler()
 void CHeroHandler::loadWallPositions()
 {
 	std::ifstream inp;
-	inp.open("config" PATHSEPARATOR "wall_pos.txt", std::ios_base::in|std::ios_base::binary);
+	inp.open(DATA_DIR "/config/wall_pos.txt", std::ios_base::in|std::ios_base::binary);
 	if(!inp.is_open())
 	{
 		tlog1<<"missing file: config/wall_pos.txt"<<std::endl;
@@ -164,7 +164,7 @@ void CHeroHandler::loadWallPositions()
 void CHeroHandler::loadObstacles()
 {
 	std::ifstream inp;
-	inp.open("config" PATHSEPARATOR "obstacles.txt", std::ios_base::in|std::ios_base::binary);
+	inp.open(DATA_DIR "/config/obstacles.txt", std::ios_base::in|std::ios_base::binary);
 	if(!inp.is_open())
 	{
 		tlog1<<"missing file: config/obstacles.txt"<<std::endl;
@@ -197,7 +197,7 @@ void CHeroHandler::loadObstacles()
 void CHeroHandler::loadPuzzleInfo()
 {
 	std::ifstream inp;
-	inp.open("config" PATHSEPARATOR "puzzle_map.txt", std::ios_base::in|std::ios_base::binary);
+	inp.open(DATA_DIR "/config/puzzle_map.txt", std::ios_base::in|std::ios_base::binary);
 	if(!inp.is_open())
 	{
 		tlog1<<"missing file: config/puzzle_map.txt"<<std::endl;
@@ -306,7 +306,7 @@ void CHeroHandler::loadHeroes()
 	//loading initial secondary skills
 	{
 		std::ifstream inp;
-		inp.open("config" PATHSEPARATOR "heroes_sec_skills.txt", std::ios_base::in|std::ios_base::binary);
+		inp.open(DATA_DIR "/config/heroes_sec_skills.txt", std::ios_base::in|std::ios_base::binary);
 		if(!inp.is_open())
 		{
 			tlog1<<"missing file: config/heroes_sec_skills.txt"<<std::endl;
@@ -338,7 +338,7 @@ void CHeroHandler::loadHeroes()
 		std::ifstream inp;
 		std::istringstream iss;
 		dump.clear();
-		inp.open("config" PATHSEPARATOR "hero_spells.txt");
+		inp.open(DATA_DIR "/config/hero_spells.txt");
 		while(inp)
 		{
 			getline(inp, dump);
@@ -517,7 +517,7 @@ ui64 CHeroHandler::reqExp (unsigned int level)
 void CHeroHandler::initTerrainCosts()
 {
 	std::ifstream inp;
-	inp.open("config" PATHSEPARATOR "TERCOSTS.TXT", std::ios_base::in|std::ios_base::binary);
+	inp.open(DATA_DIR "/config/TERCOSTS.TXT", std::ios_base::in|std::ios_base::binary);
 
 	if(!inp.is_open())
 	{
@@ -544,7 +544,7 @@ void CHeroHandler::initTerrainCosts()
 void CHeroHandler::loadNativeTerrains()
 {
 	std::ifstream inp;
-	inp.open("config" PATHSEPARATOR "native_terrains.txt", std::ios_base::in|std::ios_base::binary);
+	inp.open(DATA_DIR "/config/native_terrains.txt", std::ios_base::in|std::ios_base::binary);
 
 	if(!inp.is_open())
 	{
@@ -574,4 +574,4 @@ CHero::CHero()
 CHero::~CHero()
 {
 
-}
+}

+ 3 - 4
hch/CLodHandler.cpp

@@ -55,12 +55,11 @@ unsigned char * CLodHandler::giveFile(std::string defName, int * length)
 	if (ourEntry->offset<0) //file is in the sprites/ folder; no compression
 	{
 		unsigned char * outp = new unsigned char[ourEntry->realSize];
-		char name[30];memset(name,0,30);
-		strcat(name, myDir.c_str());
-		strcat(name, PATHSEPARATOR);
-		strcat(name,ourEntry->nameStr.c_str());
+		char name[30];
+		sprintf(name, "%s/%s/%s", DATA_DIR, myDir.c_str(), ourEntry->nameStr.c_str());
 		FILE * f = fopen(name,"rb");
 		int result = fread(outp,1,ourEntry->realSize,f);
+		fclose(f);
 		mutex->unlock();
 		if(result<0) {tlog1<<"Error in file reading: "<<name<<std::endl;delete[] outp; return NULL;}
 		else

+ 5 - 5
hch/CMusicHandler.cpp

@@ -88,7 +88,7 @@ void CSoundHandler::init()
 
 	if (initialized)
 		// Load sounds
-		sndh = new CSndHandler(std::string(DATA_DIR "Data" PATHSEPARATOR "Heroes3.snd"));
+		sndh = new CSndHandler(std::string(DATA_DIR "/Data/Heroes3.snd"));
 }
 
 void CSoundHandler::release()
@@ -151,7 +151,7 @@ soundBase::soundID CSoundHandler::getSoundID(std::string &fileName)
 void CSoundHandler::initCreaturesSounds(std::vector<CCreature> &creatures)
 {
 	tlog5 << "\t\tReading config/cr_sounds.txt" << std::endl;
-	std::ifstream ifs("config/cr_sounds.txt");
+	std::ifstream ifs(DATA_DIR "/config/cr_sounds.txt");
 	std::string line;
 
 	while(getline(ifs, line))
@@ -225,7 +225,7 @@ void CSoundHandler::initCreaturesSounds(std::vector<CCreature> &creatures)
 void CSoundHandler::initSpellsSounds(std::vector<CSpell> &spells)
 {
 	tlog5 << "\t\tReading config/sp_sounds.txt" << std::endl;
-	std::ifstream ifs("config/sp_sounds.txt");
+	std::ifstream ifs(DATA_DIR "/config/sp_sounds.txt");
 	std::string line;
 
 	while(getline(ifs, line))
@@ -345,7 +345,7 @@ void CMusicHandler::playMusic(musicBase::musicID musicID, int loop)
 	if (!initialized)
 		return;
 
-	std::string filename = DATA_DIR "Mp3" PATHSEPARATOR;
+	std::string filename = DATA_DIR "/Mp3/";
 	filename += musics[musicID];
 
 	musicMutex.lock();
@@ -442,4 +442,4 @@ int CMusicHandler::PlayMusic(Mix_Music *music, int loops)
 		tlog1 << "Unable to play music (" << Mix_GetError() << ")" << std::endl;
 
 	return ret;
-}
+}

+ 3 - 3
hch/CObjectHandler.cpp

@@ -132,7 +132,7 @@ void CObjectHandler::loadObjects()
 		{
 			cregens[i]=-1;
 		}
-		std::ifstream ifs("config/cregens.txt");
+		std::ifstream ifs(DATA_DIR "/config/cregens.txt");
 		while(!ifs.eof())
 		{
 			int dw, cr;
@@ -143,7 +143,7 @@ void CObjectHandler::loadObjects()
 	}
 
 	std::ifstream istr;
-	istr.open("config/bankconfig.txt", std::ios_base::binary);
+	istr.open(DATA_DIR "/config/bankconfig.txt", std::ios_base::binary);
 	if(!istr.is_open())
 	{
 		tlog1 << "No config/bankconfig.txt file !!!\n";
@@ -4752,4 +4752,4 @@ void CGRefugeeCamp::reset(ui32 val)
 	VLC->creh->creatures[creatures[creid].second[0]].growth;
 	available[0] = new Component (Component::CREATURE, creid, 0, 0);
 	*/
-}
+}

+ 1 - 1
hch/CSpellHandler.cpp

@@ -267,7 +267,7 @@ void CSpellHandler::loadSpells()
 	}
 	//loading of additional spell traits
 	std::ifstream ast;
-	ast.open("config/spell_info.txt", std::ios::binary);
+	ast.open(DATA_DIR "/config/spell_info.txt", std::ios::binary);
 	if(!ast.is_open())
 	{
 		tlog1<<"lack of config/spell_info.txt file!"<<std::endl;

+ 10 - 10
hch/CTownHandler.cpp

@@ -49,7 +49,7 @@ void CTownHandler::loadNames()
 	for(int x=0;x<towns.size();x++)
 		towns[x].basicCreatures.resize(7);
 
-	of.open("config/basicCres.txt");
+	of.open(DATA_DIR "/config/basicCres.txt");
 	while(!of.eof())
 	{
 		int tid, lid, cid; //town,level,creature
@@ -63,7 +63,7 @@ void CTownHandler::loadNames()
 	for(int x=0;x<towns.size();x++)
 		towns[x].upgradedCreatures.resize(7);
 
-	of.open("config/creatures_upgr.txt");
+	of.open(DATA_DIR "/config/creatures_upgr.txt");
 	while(!of.eof())
 	{
 		int tid, lid, cid; //town,level,creature
@@ -74,7 +74,7 @@ void CTownHandler::loadNames()
 	of.close();
 	of.clear();
 
-	of.open("config/building_horde.txt");
+	of.open(DATA_DIR "/config/building_horde.txt");
 	while(!of.eof())
 	{
 		int tid, lid, cid; //town,horde serial,creature level
@@ -84,7 +84,7 @@ void CTownHandler::loadNames()
 	of.close();
 	of.clear();
 
-	of.open("config/mageLevel.txt");
+	of.open(DATA_DIR "/config/mageLevel.txt");
 	of >> si;
 	for(itr=0; itr<si; itr++)
 	{
@@ -93,7 +93,7 @@ void CTownHandler::loadNames()
 	of.close();
 	of.clear();
 
-	of.open("config/requirements.txt");
+	of.open(DATA_DIR "/config/requirements.txt");
 	while(!of.eof())
 	{
 		int ile, town, build, pom;
@@ -125,7 +125,7 @@ void CTownHandler::loadNames()
 void CTownHandler::loadStructures()
 {
 	//read buildings coords
-	std::ifstream of("config/buildings.txt");
+	std::ifstream of(DATA_DIR "/config/buildings.txt");
 	while(!of.eof())
 	{
 		Structure *vinya = new Structure;
@@ -143,7 +143,7 @@ void CTownHandler::loadStructures()
 	of.clear();
 
 	//read building priorities
-	of.open("config/buildings2.txt");
+	of.open(DATA_DIR "/config/buildings2.txt");
 	int format, idt;
 	std::string s;
 	of >> format >> idt;
@@ -176,7 +176,7 @@ void CTownHandler::loadStructures()
 	of.clear();
 
 	//read borders and areas names
-	of.open("config/buildings3.txt");
+	of.open(DATA_DIR "/config/buildings3.txt");
 	while(!of.eof())
 	{
 		std::map<int,std::map<int, Structure*> >::iterator i;
@@ -202,7 +202,7 @@ void CTownHandler::loadStructures()
 
 	//read groups
 	int itr = 0;
-	of.open("config/buildings4.txt");
+	of.open(DATA_DIR "/config/buildings4.txt");
 	of >> format;
 	if(format!=1)
 	{
@@ -293,4 +293,4 @@ const std::vector<std::string> & CTown::Names() const
 		return names;
 	else 
 		return VLC->generaltexth->townNames[typeID];
-}
+}

+ 4 - 4
hch/CVideoHandler.cpp

@@ -359,7 +359,7 @@ void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update )
 
 CVideoPlayer::CVideoPlayer()
 {
-	vidh = new CVidHandler(std::string(DATA_DIR "Data" PATHSEPARATOR "VIDEO.VID"));
+	vidh = new CVidHandler(std::string(DATA_DIR "/Data/VIDEO.VID"));
 	current = NULL;
 }
 
@@ -573,7 +573,7 @@ CVideoPlayer::CVideoPlayer()
 	// Register our protocol 'lod' so we can directly read from mmaped memory
 	av_register_protocol(&lod_protocol);
 
-	vidh = new CVidHandler(std::string(DATA_DIR "Data" PATHSEPARATOR "VIDEO.VID"));
+	vidh = new CVidHandler(std::string(DATA_DIR "/Data/VIDEO.VID"));
 }
 
 // loop = to loop through the video
@@ -600,8 +600,8 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 		}
 	} else {
 		// File is not in a container
-		if (av_open_input_file(&format, (DATA_DIR "Data/video/" + fname).c_str(), NULL, 0, NULL)!=0) {
-			// tlog1 << "Video file not found: " DATA_DIR "Data/video/" + fname << std::endl;
+		if (av_open_input_file(&format, (DATA_DIR "/Data/video/" + fname).c_str(), NULL, 0, NULL)!=0) {
+			// tlog1 << "Video file not found: " DATA_DIR "/Data/video/" + fname << std::endl;
 			return false;
 		}
 	}

+ 3 - 3
lib/CGameState.cpp

@@ -1302,7 +1302,7 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
 	/******************RESOURCES****************************************************/
 	//TODO: computer player should receive other amount of resource than computer (depending on difficulty)
 	std::vector<int> startres;
-	std::ifstream tis("config/startres.txt");
+	std::ifstream tis(DATA_DIR "/config/startres.txt");
 	int k;
 	for (int j=0;j<scenarioOps->difficulty;j++)
 	{
@@ -1325,7 +1325,7 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
 			(*i).second.resources[x] = startres[x];
 	}
 
-	tis.open("config/resources.txt");
+	tis.open(DATA_DIR "/config/resources.txt");
 	tis >> k;
 	int pom;
 	for(int i=0;i<k;i++)
@@ -3058,4 +3058,4 @@ PlayerState::PlayerState()
  : color(-1), currentSelection(0xffffffff)
 {
 
-}
+}

+ 2 - 2
lib/Connection.cpp

@@ -174,7 +174,7 @@ void CConnection::close()
 }
 
 CSaveFile::CSaveFile( const std::string &fname )
-	:sfile(new std::ofstream(fname.c_str(),std::ios::binary))
+	:sfile(new std::ofstream((USER_DIR "/" + fname).c_str(),std::ios::binary))
 {
 	registerTypes(*this);
 	if(!(*sfile))
@@ -267,4 +267,4 @@ ui16 CTypeList::getTypeID( const std::type_info *type )
 		return i->second;
 	else
 		return 0;
-}
+}

+ 1 - 0
lib/Makefile.am

@@ -1,4 +1,5 @@
 pkglib_LTLIBRARIES = libvcmi.la
+libvcmi_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lz -lpthread
 libvcmi_la_CXXFLAGS = @SDL_CXXFLAGS@
 libvcmi_la_SOURCES = \
 	../CConsoleHandler.cpp \

+ 2 - 1
lib/Makefile.in

@@ -59,7 +59,7 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 am__installdirs = "$(DESTDIR)$(pkglibdir)"
 pkglibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(pkglib_LTLIBRARIES)
-libvcmi_la_LIBADD =
+libvcmi_la_DEPENDENCIES =
 am_libvcmi_la_OBJECTS = libvcmi_la-CConsoleHandler.lo \
 	libvcmi_la-CArtHandler.lo libvcmi_la-CBuildingHandler.lo \
 	libvcmi_la-CCreatureHandler.lo \
@@ -228,6 +228,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 pkglib_LTLIBRARIES = libvcmi.la
+libvcmi_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @BOOST_IOSTREAMS_LIB@ -lz -lpthread
 libvcmi_la_CXXFLAGS = @SDL_CXXFLAGS@
 libvcmi_la_SOURCES = \
 	../CConsoleHandler.cpp \

+ 3 - 3
lib/VCMI_Lib.cpp

@@ -239,11 +239,11 @@ LibClasses::LibClasses()
 	//load .lod archives
 	timeHandler pomtime;
 	spriteh = new CLodHandler();
-	spriteh->init("Data" PATHSEPARATOR "H3sprite.lod","Sprites");
+	spriteh->init(DATA_DIR "/Data/H3sprite.lod", DATA_DIR "/Sprites");
 	bitmaph = new CLodHandler;
-	bitmaph->init("Data" PATHSEPARATOR "H3bitmap.lod","Data");
+	bitmaph->init(DATA_DIR "/Data/H3bitmap.lod", DATA_DIR "/Data");
 	tlog0<<"Loading .lod files: "<<pomtime.getDif()<<std::endl;
 
 	//init pointers to handlers
 	makeNull();
-}
+}

+ 2 - 2
lib/map.cpp

@@ -23,7 +23,7 @@ static std::set<si32> convertBuildings(const std::set<si32> h3m, int castleID)
 {
 	std::map<int,int> mapa;
 	std::set<si32> ret;
-	std::ifstream b5("config/buildings5.txt");
+	std::ifstream b5(DATA_DIR "/config/buildings5.txt");
 	while(!b5.eof())
 	{
 		int a, b;
@@ -2153,4 +2153,4 @@ void CMapInfo::init(const std::string &fname, const unsigned char *map )
 	int i = 0;
 	initFromMemory(map, i);
 	countPlayers();
-}
+}

+ 1 - 1
mapHandler.cpp

@@ -442,7 +442,7 @@ void CMapHandler::init()
 	offsetX = (mapW - (2*frameW+1)*32)/2;
 	offsetY = (mapH - (2*frameH+1)*32)/2;
 
-	std::ifstream ifs("config/townsDefs.txt");
+	std::ifstream ifs(DATA_DIR "/config/townsDefs.txt");
 	int ccc;
 	ifs>>ccc;
 	for(int i=0;i<ccc*2;i++)

+ 4 - 4
server/CGameHandler.cpp

@@ -996,7 +996,7 @@ void CGameHandler::setupBattle( BattleInfo * curB, int3 tile, const CCreatureSet
 
 	//reading battleStartpos
 	std::ifstream positions;
-	positions.open("config" PATHSEPARATOR "battleStartpos.txt", std::ios_base::in|std::ios_base::binary);
+	positions.open(DATA_DIR "/config/battleStartpos.txt", std::ios_base::in|std::ios_base::binary);
 	if(!positions.is_open())
 	{
 		tlog1<<"Unable to open battleStartpos.txt!"<<std::endl;
@@ -1840,14 +1840,14 @@ void CGameHandler::save( const std::string &fname )
 
 	{
 		tlog0 << "Serializing game info...\n";
-		CSaveFile save(std::string("Games") + PATHSEPARATOR + fname + ".vlgm1");
+		CSaveFile save(std::string("Games/") + fname + ".vlgm1");
 		char hlp[8] = "VCMISVG";
 		save << hlp << static_cast<CMapHeader&>(*gs->map) << gs->scenarioOps->difficulty << *VLC << gs;
 	}
 
 	{
 		tlog0 << "Serializing server info...\n";
-		CSaveFile save(std::string("Games") + PATHSEPARATOR + fname + ".vsgm1");
+		CSaveFile save(std::string("Games/") + fname + ".vsgm1");
 		save << *this;
 	}
 	tlog0 << "Game has been succesfully saved!\n";
@@ -3374,4 +3374,4 @@ void CGameHandler::engageIntoBattle( ui8 player )
 	pb.player = player;
 	pb.reason = PlayerBlocked::UPCOMING_BATTLE;
 	sendAndApply(&pb);
-}
+}

+ 1 - 1
server/CVCMIServer.cpp

@@ -246,7 +246,7 @@ int main(int argc, char** argv)
 	}
 	tlog0 << "Port " << port << " will be used." << std::endl;
 	CLodHandler h3bmp;
-	h3bmp.init("Data" PATHSEPARATOR "H3bitmap.lod","Data");
+	h3bmp.init(DATA_DIR "/Data/H3bitmap.lod", DATA_DIR "/Data");
 	initDLL(console,logfile);
 	srand ( (unsigned int)time(NULL) );
 	try

+ 1 - 1
server/Makefile.am

@@ -1,6 +1,6 @@
 bin_PROGRAMS = vcmiserver
 
-vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ -lz
+vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.la
 vcmiserver_LDFLAGS = -L$(top_builddir)/lib
 vcmiserver_SOURCES = \
 	CGameHandler.cpp \

+ 1 - 1
server/Makefile.in

@@ -213,7 +213,7 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.la @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ -lz
+vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.la
 vcmiserver_LDFLAGS = -L$(top_builddir)/lib
 vcmiserver_SOURCES = \
 	CGameHandler.cpp \