Michał W. Urbańczyk 15 years ago
parent
commit
c6653949e1
8 changed files with 31 additions and 9 deletions
  1. 5 0
      client/CMT.cpp
  2. 1 0
      client/mapHandler.cpp
  3. 1 1
      global.h
  4. 1 6
      hch/CDefObjInfoHandler.h
  5. 1 1
      hch/CVideoHandler.cpp
  6. 20 0
      lib/CGameState.cpp
  7. 1 0
      lib/CGameState.h
  8. 1 1
      lib/Connection.h

+ 5 - 0
client/CMT.cpp

@@ -49,6 +49,7 @@
 #include "SDL_syswm.h"
 #endif
 #include <boost/foreach.hpp>
+#include "../hch/CDefObjInfoHandler.h"
 
 #if __MINGW32__
 #undef main
@@ -591,6 +592,10 @@ static void listenForEvents()
 
 			delete ev;
 
+			delete CGI->dobjinfo;
+			CGI->dobjinfo = new CDefObjInfoHandler;
+			CGI->dobjinfo->load();
+
 			GH.curInt = CGP;
 			GH.defActionsDef = 63;
 			continue;

+ 1 - 0
client/mapHandler.cpp

@@ -397,6 +397,7 @@ void CMapHandler::init()
 		}
 		else 
 			n = CGI->state->capitols[i%ccc];
+
 		ifs >> n->name;
 		if(!n)
 			tlog1 << "*HUGE* Warning - missing town def for " << i << std::endl;

+ 1 - 1
global.h

@@ -24,7 +24,7 @@ typedef si64 expType;
 #define THC
 #endif
 
-#define NAME_VER ("VCMI 0.81d")
+#define NAME_VER ("VCMI 0.81e")
 extern std::string NAME; //full name
 extern std::string NAME_AFFIX; //client / server
 #define CONSOLE_LOGGING_LEVEL 5

+ 1 - 6
hch/CDefObjInfoHandler.h

@@ -59,12 +59,7 @@ public:
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 		h & gobjs;
-
-		if(!h.saving) //recrete castles map
-			for(std::map<int,std::map<int,CGDefInfo*> >::iterator i=gobjs.begin(); i!=gobjs.end(); i++)
-				for(std::map<int,CGDefInfo*>::iterator j=i->second.begin(); j!=i->second.end(); j++)
-					if(j->second->id == TOWNI_TYPE)
-						castles[j->second->subid]=j->second;
+		h & castles;
 	}
 };
 

+ 1 - 1
hch/CVideoHandler.cpp

@@ -311,7 +311,7 @@ bool CSmackPlayer::open( std::string name )
 	buffer = new char[data->width*data->height*2];
 	buf = buffer+data->width*(data->height-1)*2;	// adjust pointer position for later use by 'SmackToBuffer'
 
-	ptrVolumePan(data, 0xfe000, 3640 * GDefaultOptions.musicVolume / 11, 0x8000); //set volume
+	//ptrVolumePan(data, 0xfe000, 3640 * GDefaultOptions.musicVolume / 11, 0x8000); //set volume
 	return true;
 }
 

+ 20 - 0
lib/CGameState.cpp

@@ -1188,6 +1188,10 @@ CGameState::~CGameState()
 	//delete scenarioOps;
 	delete applierGs;
 	delete objCaller;
+
+	//TODO: delete properly that definfos
+	villages.clear();
+	capitols.clear();
 }
 
 void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
@@ -1966,8 +1970,24 @@ void CGameState::loadTownDInfos()
 	{
 		villages[i] = new CGDefInfo(*VLC->dobjinfo->castles[i]);
 		forts[i] = VLC->dobjinfo->castles[i];
+		map->defy.push_back(forts[i]);
 		capitols[i] = new CGDefInfo(*VLC->dobjinfo->castles[i]);
 	}
+
+	std::ifstream ifs(DATA_DIR "/config/townsDefs.txt");
+	int ccc;
+	ifs>>ccc;
+	for(int i=0; i < ccc*2; i++)
+	{
+		CGDefInfo *n;
+		if(i<ccc)
+			n = villages[i];
+		else 
+			n = capitols[i%ccc];
+
+		ifs >> n->name;
+		map->defy.push_back(n);
+	}
 }
 
 void CGameState::getNeighbours(const TerrainTile &srct, int3 tile, std::vector<int3> &vec, const boost::logic::tribool &onLand, bool limitCoastSailing)

+ 1 - 0
lib/CGameState.h

@@ -446,6 +446,7 @@ public:
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 		h & scenarioOps & seed & currentPlayer & day & map & players & hpool & globalEffects & campaign;
+		h & villages & forts & capitols;
 		if(!h.saving)
 		{
 			loadTownDInfos();

+ 1 - 1
lib/Connection.h

@@ -23,7 +23,7 @@
 #include <boost/mpl/identity.hpp>
 #include <boost/any.hpp>
 
-const ui32 version = 725;
+const ui32 version = 726;
 class CConnection;
 class CGObjectInstance;
 class CGameState;