mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	- moved ParseBonus to JsonNode.cpp (linkage errors)
- fixes to CMakeLists - vcmi can be compiled and started with cmake - gcc\clang warnings fixes
This commit is contained in:
		| @@ -8,5 +8,5 @@ set(emptyAI_SRCS | ||||
|         exp_funcs.cpp | ||||
| ) | ||||
|  | ||||
| add_library(emptyAI SHARED ${emptyAI_SRCS}) | ||||
| target_link_libraries(emptyAI vcmi) | ||||
| add_library(EmptyAI SHARED ${emptyAI_SRCS}) | ||||
| target_link_libraries(EmptyAI vcmi) | ||||
|   | ||||
| @@ -2391,7 +2391,7 @@ void VCAI::answerQuery(int queryID, int selection) | ||||
| 	BNLOG("I'll answer the query %d giving the choice %d", queryID % selection); | ||||
| 	if(queryID != -1) | ||||
| 	{ | ||||
| 		int requestID = cb->selectionMade(selection, queryID); | ||||
| 		cb->selectionMade(selection, queryID); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
|   | ||||
| @@ -7,9 +7,12 @@ INCLUDE(CheckLibraryExists) | ||||
| # where to look for cmake modules | ||||
| set(CMAKE_MODULE_PATH ${CMAKE_HOME_DIRECTORY}/cmake_modules) | ||||
|  | ||||
| set(CMAKE_BUILD_TYPE Debug) | ||||
| # enable Release mode but only if it was not set | ||||
| if (NOT CMAKE_BUILD_TYPE) | ||||
| 	set(CMAKE_BUILD_TYPE Release) | ||||
| endif() | ||||
|  | ||||
| find_package(Boost COMPONENTS program_options filesystem system thread iostreams REQUIRED) | ||||
| find_package(Boost 1.46.0 COMPONENTS program_options filesystem system thread iostreams REQUIRED) | ||||
| find_package(SDL REQUIRED) | ||||
| find_package(SDL_image REQUIRED) | ||||
| find_package(SDL_mixer REQUIRED) | ||||
| @@ -29,7 +32,7 @@ if(HAVE_DL_LIB) | ||||
| endif() | ||||
|  | ||||
| if(CMAKE_CXX_COMPILER MATCHES ".*clang") | ||||
|     set(CMAKE_COMPILER_IS_CLANGXX 1) | ||||
|     set(CMAKE_COMPILER_IS_CLANGXX ON) | ||||
| endif() | ||||
|  | ||||
| if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) | ||||
| @@ -37,12 +40,13 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) | ||||
| endif() | ||||
|  | ||||
| #define required constants | ||||
| add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share") | ||||
| add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/lib/vcmi") | ||||
| add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/bin") | ||||
| add_definitions(-DM_DATA_DIR="${CMAKE_INSTALL_PREFIX}/share/vcmi") | ||||
| add_definitions(-DM_BIN_DIR="${CMAKE_INSTALL_PREFIX}/bin") | ||||
| add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/lib/vcmi") | ||||
|  | ||||
| add_subdirectory(lib) | ||||
| add_subdirectory(client) | ||||
| add_subdirectory(server) | ||||
| add_subdirectory(AI) | ||||
| add_subdirectory(Scripting/ERM) | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/BattleInterface ${CMAKE_CURRENT_ | ||||
| include_directories(${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} ${SDLMIXER_INCLUDE_DIR} ${SDLTTF_INCLUDE_DIR}) | ||||
| include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIR}) | ||||
|  | ||||
|  | ||||
| set(client_SRCS | ||||
|         ../CCallback.cpp | ||||
|         BattleInterface/CBattleAnimations.cpp | ||||
| @@ -44,7 +43,6 @@ set(client_SRCS | ||||
|         GUIClasses.cpp | ||||
|         mapHandler.cpp | ||||
|         NetPacksClient.cpp | ||||
|         SDL_framerate.cpp | ||||
| ) | ||||
|  | ||||
| IF(UNIX) | ||||
| @@ -53,4 +51,4 @@ ELSEIF(WIN32) | ||||
|     add_executable(vcmiclient WIN32 ${client_SRCS}) | ||||
| ENDIF() | ||||
|  | ||||
| target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES}) | ||||
| target_link_libraries(vcmiclient vcmi ${Boost_LIBRARIES} ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY} ${ZLIB_LIBRARIES} ${FFMPEG_LIBRARIES} ${RT_LIB} ${DL_LIB}) | ||||
|   | ||||
| @@ -141,8 +141,10 @@ void CQuestMinimap::showAll(SDL_Surface * to) | ||||
|  | ||||
| CQuestLog::CQuestLog (const std::vector<QuestInfo> & Quests) : | ||||
| 	CWindowObject(PLAYER_COLORED, "QuestLog.pcx"), | ||||
| 	quests (Quests), slider (NULL), | ||||
| 	questIndex(0), currentQuest(NULL) | ||||
| 	questIndex(0), | ||||
| 	currentQuest(NULL), | ||||
| 	quests (Quests), | ||||
| 	slider(NULL) | ||||
| { | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	init(); | ||||
|   | ||||
| @@ -5787,8 +5787,7 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGTownInstance * town): | ||||
|     CWindowObject(RCLICK_POPUP | PLAYER_COLORED, "TOWNQVBK", toScreen(position)) | ||||
| { | ||||
| 	InfoAboutTown iah; | ||||
| 	bool gotInfo = LOCPLINT->cb->getTownInfo(town, iah); | ||||
| 	assert(gotInfo); | ||||
| 	LOCPLINT->cb->getTownInfo(town, iah); | ||||
|  | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	new CTownTooltip(Point(9, 10), iah); | ||||
| @@ -5798,8 +5797,7 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGHeroInstance * hero): | ||||
|     CWindowObject(RCLICK_POPUP | PLAYER_COLORED, "HEROQVBK", toScreen(position)) | ||||
| { | ||||
| 	InfoAboutHero iah; | ||||
| 	bool gotInfo = LOCPLINT->cb->getHeroInfo(hero, iah); | ||||
| 	assert(gotInfo); | ||||
| 	LOCPLINT->cb->getHeroInfo(hero, iah); | ||||
|  | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	new CHeroTooltip(Point(9, 10), iah); | ||||
| @@ -5809,8 +5807,7 @@ CInfoBoxPopup::CInfoBoxPopup(Point position, const CGGarrison * garr): | ||||
|     CWindowObject(RCLICK_POPUP | PLAYER_COLORED, "TOWNQVBK", toScreen(position)) | ||||
| { | ||||
| 	InfoAboutTown iah; | ||||
| 	bool gotInfo = LOCPLINT->cb->getTownInfo(garr, iah); | ||||
| 	assert(gotInfo); | ||||
| 	LOCPLINT->cb->getTownInfo(garr, iah); | ||||
|  | ||||
| 	OBJ_CONSTRUCTION_CAPTURING_ALL; | ||||
| 	new CArmyTooltip(Point(9, 10), iah); | ||||
|   | ||||
| @@ -51,39 +51,20 @@ namespace Colors | ||||
| template<typename IntType> | ||||
| std::string makeNumberShort(IntType number) //the output is a string containing at most 5 characters [4 if positive] (eg. intead 10000 it gives 10k) | ||||
| { | ||||
| 	int initialLength; | ||||
| 	bool negative = (number < 0); | ||||
| 	std::ostringstream ost, rets; | ||||
| 	ost<<number; | ||||
| 	initialLength = ost.str().size(); | ||||
| 	if (abs(number) < 1000) | ||||
| 		return boost::lexical_cast<std::string>(number); | ||||
|  | ||||
| 	if(negative) | ||||
| 	std::string symbols = "kMGTPE"; | ||||
| 	auto iter = symbols.begin(); | ||||
|  | ||||
| 	while (number >= 1000) | ||||
| 	{ | ||||
| 		if(initialLength <= 4) | ||||
| 			return ost.str(); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		if(initialLength <= 5) | ||||
| 			return ost.str(); | ||||
| 	} | ||||
| 		number /= 1000; | ||||
| 		iter++; | ||||
|  | ||||
| 	//make the number int | ||||
| 	char symbol[] = {'G', 'M', 'k'}; | ||||
|  | ||||
| 	if(negative) number = (-number); //absolute value | ||||
|  | ||||
| 	for(int divisor = 1000000000, it = 0; divisor > 1; divisor /= 1000, ++it) | ||||
| 	{ | ||||
| 		if(number >= divisor) | ||||
| 		{ | ||||
| 			if(negative) rets <<'-'; | ||||
| 			rets << (number / divisor) << symbol[it]; | ||||
| 			return rets.str(); | ||||
| 		assert(iter != symbols.end());//should be enough even for int64 | ||||
| 	} | ||||
| 	} | ||||
|  | ||||
| 	throw std::runtime_error("We shouldn't be here - makeNumberShort"); | ||||
| 	return boost::lexical_cast<std::string>(number) + *iter; | ||||
| } | ||||
|  | ||||
| typedef void (*TColorPutter)(Uint8 *&ptr, const Uint8 & R, const Uint8 & G, const Uint8 & B); | ||||
|   | ||||
| @@ -6304,7 +6304,7 @@ void CGKeymasterTent::onHeroVisit( const CGHeroInstance * h ) const | ||||
|  | ||||
| void CGBorderGuard::initObj() | ||||
| { | ||||
| 	ui32 m13489val = subID; //store color as quest info | ||||
| 	//ui32 m13489val = subID; //store color as quest info | ||||
| 	blockVisit = true; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -53,6 +53,7 @@ std::vector<BattleHex> CObstacleInstance::getAffectedTiles() const | ||||
| 		return getInfo().getBlocked(pos); | ||||
| 	default: | ||||
| 		assert(0); | ||||
| 		return std::vector<BattleHex>(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -105,6 +106,7 @@ bool SpellCreatedObstacle::visibleForSide(ui8 side, bool hasNativeStack) const | ||||
| 		return casterSide == side  ||  visibleForAnotherSide  ||  hasNativeStack; | ||||
| 	default: | ||||
| 		assert(0); | ||||
| 		return false; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -121,6 +123,7 @@ std::vector<BattleHex> SpellCreatedObstacle::getAffectedTiles() const | ||||
| 		//TODO Fire Wall | ||||
| 	default: | ||||
| 		assert(0); | ||||
| 		return std::vector<BattleHex>(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,8 +1,7 @@ | ||||
| #include "StdInc.h" | ||||
| #include "JsonNode.h" | ||||
|  | ||||
|  | ||||
| class Bonus; | ||||
| #include "HeroBonus.h" | ||||
|  | ||||
| const JsonNode JsonNode::nullNode; | ||||
|  | ||||
| @@ -873,3 +872,22 @@ JsonValidator::JsonValidator(JsonNode &root, const JsonNode &schema, bool Minimi | ||||
| 		addMessage("Schema not found!"); | ||||
| 	tlog3<<errors; | ||||
| } | ||||
|  | ||||
| Bonus * ParseBonus (const JsonVector &ability_vec) //TODO: merge with AddAbility, create universal parser for all bonus properties | ||||
| { | ||||
| 	Bonus * b = new Bonus(); | ||||
| 	std::string type = ability_vec[0].String(); | ||||
| 	auto it = bonusNameMap.find(type); | ||||
| 	if (it == bonusNameMap.end()) | ||||
| 	{ | ||||
| 		tlog1 << "Error: invalid ability type " << type << " in creatures.txt" << std::endl; | ||||
| 		return b; | ||||
| 	} | ||||
| 	b->type = it->second; | ||||
| 	b->val = ability_vec[1].Float(); | ||||
| 	b->subtype = ability_vec[2].Float(); | ||||
| 	b->additionalInfo = ability_vec[3].Float(); | ||||
| 	b->duration = Bonus::PERMANENT; | ||||
| 	b->turnsRemain = 0; | ||||
| 	return b; | ||||
| } | ||||
|   | ||||
| @@ -1,12 +1,10 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include "HeroBonus.h" | ||||
|  | ||||
| class JsonNode; | ||||
| typedef std::map <std::string, JsonNode> JsonMap; | ||||
| typedef std::vector <JsonNode> JsonVector; | ||||
|  | ||||
| class Bonus; | ||||
| struct Bonus; | ||||
|  | ||||
| class DLL_LINKAGE JsonNode | ||||
| { | ||||
| @@ -199,23 +197,4 @@ public: | ||||
| 	JsonValidator(JsonNode &root, const JsonNode &schema, bool minimize=false); | ||||
| }; | ||||
|  | ||||
| //Bonus * ParseBonus (const JsonVector &ability_vec); | ||||
|  | ||||
| static Bonus * ParseBonus (const JsonVector &ability_vec) //TODO: merge with AddAbility, create universal parser for all bonus properties | ||||
| { | ||||
| 	Bonus * b = new Bonus(); | ||||
| 	std::string type = ability_vec[0].String(); | ||||
| 	auto it = bonusNameMap.find(type); | ||||
| 	if (it == bonusNameMap.end()) | ||||
| 	{ | ||||
| 		tlog1 << "Error: invalid ability type " << type << " in creatures.txt" << std::endl; | ||||
| 		return b; | ||||
| 	} | ||||
| 	b->type = it->second; | ||||
| 	b->val = ability_vec[1].Float(); | ||||
| 	b->subtype = ability_vec[2].Float(); | ||||
| 	b->additionalInfo = ability_vec[3].Float(); | ||||
| 	b->duration = Bonus::PERMANENT; | ||||
| 	b->turnsRemain = 0; | ||||
| 	return b; | ||||
| } | ||||
| DLL_LINKAGE Bonus * ParseBonus (const JsonVector &ability_vec); | ||||
|   | ||||
| @@ -16,4 +16,4 @@ ELSEIF(WIN32) | ||||
|     add_executable(vcmiserver WIN32 ${server_SRCS}) | ||||
| ENDIF() | ||||
|  | ||||
| target_link_libraries(vcmiserver vcmi ${Boost_LIBRARIES}) | ||||
| target_link_libraries(vcmiserver vcmi ${Boost_LIBRARIES} ${RT_LIB} ${DL_LIB}) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user