Browse Source

- fixes crash on giving banned skills to hero (partial #1427)
- fixes hover text for prisons - they should not display name of imprisoned hero
- missing bits for launcher, Linux-specific

Ivan Savenko 12 years ago
parent
commit
0a627698d8
5 changed files with 38 additions and 18 deletions
  1. 10 6
      README.linux
  2. 2 0
      launcher/CMakeLists.txt
  3. 10 8
      lib/CHeroHandler.cpp
  4. 15 4
      lib/CObjectHandler.cpp
  5. 1 0
      lib/CObjectHandler.h

+ 10 - 6
README.linux

@@ -2,7 +2,6 @@ This readme covers VCMI compilation on Unix-like systems.
 
 To run the game you will need:
 1) Heroes 3 data files (SoD or Complete editions);
-2) Unofficial WoG addon
 2) VCMI data pack (http://download.vcmi.eu/core.zip)
 All of them can be installed manually or using vcmibuilder script
 
@@ -11,7 +10,7 @@ http://wiki.vcmi.eu/index.php?title=Installation_on_Linux#Preparing_data
 
 I. Prerequisites
 
-To compile, at least the following packages (and their development counterparts) are needed to build:
+To compile, the following packages (and their development counterparts) are needed to build:
 	* libstdc++ devel
 	* CMake build system
 	* SDL and SDL-devel
@@ -19,6 +18,7 @@ To compile, at least the following packages (and their development counterparts)
 	* SDL_image and SDL_image-devel
 	* SDL_ttf and SDL_ttf-devel
 	* zlib and zlib-devel
+	* (optional) Qt 5, widget and network modules
 	* the ffmpeg libraries (libavformat and libswscale). Their name could be libavformat-devel and libswscale-devel, or ffmpeg-libs-devel or similar names.
 	* boost c++ libraries v1.46+ (www.boost.org):
 		- program-options
@@ -47,7 +47,11 @@ III. Compilation
 
 Run configure:
   mkdir build && cd build
-  cmake ../src -DCMAKE_BUILD_TYPE=Debug (to enable debugging)
+  cmake ../src <any other options, see below>
+
+Additional options that you may want to use:
+To enable debugging: -DCMAKE_BUILD_TYPE=Debug
+To enable launcher: -DENABLE_LAUNCHER=Yes
 
 Notice:
 The ../src/ is not a typo, it will place makefile scripts into the build dir 
@@ -60,14 +64,14 @@ That will generate vcmiclient, vcmiserver as well as 3 .so libraries.
 
 III. Installing binaries
 
-To install VCMI type (as root):
-  make install
+To install VCMI you can use "make install" command however generation of distribution-specific packages is usually a better idea. In most cases this can be achieved using tool called "checkinstall"
 
-For development puposes, it's better to use links instead.
+If you're compiling vcmi for development puposes, it's better to use links instead.
 Go to /BIN_PATH/, and type:
 
   ln -s .../trunk/build/client/vcmiclient
   ln -s .../trunk/build/server/vcmiserver
+  ln -s .../trunk/build/launcher/vcmilauncher
   
 Go to /LIB_PATH/vcmi, and type:
 

+ 2 - 0
launcher/CMakeLists.txt

@@ -54,5 +54,7 @@ target_link_libraries(vcmilauncher vcmi ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIB
 
 if (NOT APPLE) # Already inside bundle
     install(TARGETS vcmilauncher DESTINATION ${BIN_DIR})
+	# copy whole directory but .svn control files
+	install(DIRECTORY icons DESTINATION ${DATA_DIR}/launcher PATTERN ".svn" EXCLUDE)
 endif()
 

+ 10 - 8
lib/CHeroHandler.cpp

@@ -23,21 +23,23 @@
 
 SecondarySkill CHeroClass::chooseSecSkill(const std::set<SecondarySkill> & possibles) const //picks secondary skill out from given possibilities
 {
-	if(possibles.size()==1)
-		return *possibles.begin();
 	int totalProb = 0;
 	for(auto & possible : possibles)
 	{
 		totalProb += secSkillProbability[possible];
 	}
-	int ran = rand()%totalProb;
-	for(auto & possible : possibles)
+	if (totalProb != 0) // may trigger if set contains only banned skills (0 probability)
 	{
-		ran -= secSkillProbability[possible];
-		if(ran<0)
-			return possible;
+		int ran = rand()%totalProb;
+		for(auto & possible : possibles)
+		{
+			ran -= secSkillProbability[possible];
+			if(ran<0)
+				return possible;
+		}
 	}
-	throw std::runtime_error("Cannot pick secondary skill!");
+	// FIXME: select randomly? How H3 handles such rare situation?
+	return *possibles.begin();
 }
 
 EAlignment::EAlignment CHeroClass::getAlignment() const

+ 15 - 4
lib/CObjectHandler.cpp

@@ -828,10 +828,6 @@ void CGHeroInstance::initHero()
 		commander->giveStackExp (exp); //after our exp is set
 	}
 
-	hoverName = VLC->generaltexth->allTexts[15];
-	boost::algorithm::replace_first(hoverName,"%s",name);
-	boost::algorithm::replace_first(hoverName,"%s", type->heroClass->name);
-
 	if (mana < 0)
 		mana = manaLimit();
 }
@@ -969,6 +965,21 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
 	}
 }
 
+const std::string & CGHeroInstance::getHoverText() const
+{
+	if(ID != Obj::PRISON)
+	{
+		hoverName = VLC->generaltexth->allTexts[15];
+		boost::algorithm::replace_first(hoverName,"%s",name);
+		boost::algorithm::replace_first(hoverName,"%s", type->heroClass->name);
+		return hoverName;
+	}
+	else
+		hoverName = VLC->generaltexth->names[ID];
+
+	return hoverName;
+}
+
 const std::string & CGHeroInstance::getBiography() const
 {
 	if (biography.length())

+ 1 - 0
lib/CObjectHandler.h

@@ -431,6 +431,7 @@ public:
 
 	void initObj() override;
 	void onHeroVisit(const CGHeroInstance * h) const override;
+	const std::string & getHoverText() const override;
 protected:
 	void setPropertyDer(ui8 what, ui32 val) override;//synchr
 };