mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	- reordered files in cmake so files with long compile times will be
compiled first. - changed format of modSettings.json, VCMI should properly update file on the first run. - implemented property "defaultTavern" that acts as default value for "tavern" entry in hero class and town formats.
This commit is contained in:
		| @@ -4,10 +4,10 @@ cmake_minimum_required(VERSION 2.6) | ||||
| include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib ${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite) | ||||
|  | ||||
| set(VCAI_SRCS | ||||
|         AIUtility.cpp | ||||
|         Goals.cpp | ||||
|         main.cpp | ||||
|         VCAI.cpp | ||||
|         Goals.cpp | ||||
|         AIUtility.cpp | ||||
|         main.cpp | ||||
|         Fuzzy.cpp | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -136,14 +136,14 @@ add_definitions(-DM_LIB_DIR="${CMAKE_INSTALL_PREFIX}/${LIB_DIR}") | ||||
| SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/vcmi") | ||||
| SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||||
|  | ||||
| if (ENABLE_ERM) | ||||
|         add_subdirectory(scripting/erm) | ||||
| endif() | ||||
| add_subdirectory(lib) | ||||
| add_subdirectory(lib/minizip) | ||||
| add_subdirectory(client) | ||||
| add_subdirectory(lib/minizip) | ||||
| add_subdirectory(server) | ||||
| add_subdirectory(AI) | ||||
| if (ENABLE_ERM) | ||||
| 	add_subdirectory(scripting/erm) | ||||
| endif() | ||||
| if (ENABLE_EDITOR) | ||||
| 	add_subdirectory(editor) | ||||
| endif() | ||||
|   | ||||
| @@ -716,7 +716,6 @@ | ||||
| 			"defend": "BGORDFND.wav", | ||||
| 			"killed": "BGORKILL.wav", | ||||
| 			"move": "BGORMOVE.wav", | ||||
| 			"shoot": "BGORSHOT.wav", | ||||
| 			"wince": "BGORWNCE.wav" | ||||
| 		} | ||||
| 	}, | ||||
| @@ -1488,7 +1487,6 @@ | ||||
| 			"defend": "BGORDFND.wav", | ||||
| 			"killed": "BGORKILL.wav", | ||||
| 			"move": "BGORMOVE.wav", | ||||
| 			"shoot": "BGORSHOT.wav", | ||||
| 			"wince": "BGORWNCE.wav" | ||||
| 		} | ||||
| 	}, | ||||
|   | ||||
| @@ -6,9 +6,15 @@ include_directories(${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} ${SDLMIXER_INCLUD | ||||
| include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS}) | ||||
|  | ||||
| set(client_SRCS | ||||
|         CPreGame.cpp | ||||
|         Client.cpp | ||||
|         CPlayerInterface.cpp | ||||
|         CMT.cpp | ||||
|         GUIClasses.cpp | ||||
|         battle/CBattleInterface.cpp | ||||
|  | ||||
|         ../CCallback.cpp | ||||
|         battle/CBattleAnimations.cpp | ||||
|         battle/CBattleInterface.cpp | ||||
|         battle/CBattleInterfaceClasses.cpp | ||||
|         battle/CCreatureAnimation.cpp | ||||
|         gui/CGuiHandler.cpp | ||||
| @@ -28,17 +34,12 @@ set(client_SRCS | ||||
|         CGameInfo.cpp | ||||
|         CHeroWindow.cpp | ||||
|         CKingdomInterface.cpp | ||||
|         Client.cpp | ||||
|         CMessage.cpp | ||||
|         CMT.cpp | ||||
|         CMusicHandler.cpp | ||||
|         CPlayerInterface.cpp | ||||
|         CPreGame.cpp | ||||
|         CSpellWindow.cpp | ||||
|         CVideoHandler.cpp | ||||
|         CQuestLog.cpp | ||||
|         Graphics.cpp | ||||
|         GUIClasses.cpp | ||||
|         mapHandler.cpp | ||||
|         NetPacksClient.cpp | ||||
| ) | ||||
|   | ||||
| @@ -116,6 +116,7 @@ | ||||
| 			}, | ||||
|  | ||||
| 			"musicTheme" : "music/CstleTown", | ||||
| 			"defaultTavern" : 5, | ||||
|  | ||||
| 			"townBackground": "TBCSBACK.bmp", | ||||
| 			"guildWindow": "TPMAGECS.bmp", | ||||
|   | ||||
| @@ -120,6 +120,7 @@ | ||||
| 			}, | ||||
|  | ||||
| 			"musicTheme" : "music/ElemTown", | ||||
| 			"defaultTavern" : 5, | ||||
|  | ||||
| 			"townBackground": "TBELBACK.bmp", | ||||
| 			"guildWindow": "TPMAGEEL.bmp", | ||||
|   | ||||
| @@ -115,6 +115,7 @@ | ||||
| 			}, | ||||
|  | ||||
| 			"musicTheme" : "music/Dungeon", | ||||
| 			"defaultTavern" : 5, | ||||
|  | ||||
| 			"townBackground": "TBDNBACK.bmp", | ||||
| 			"guildWindow": "TPMAGEDN.bmp", | ||||
|   | ||||
| @@ -116,6 +116,7 @@ | ||||
| 			}, | ||||
|  | ||||
| 			"musicTheme" : "music/FortressTown", | ||||
| 			"defaultTavern" : 5, | ||||
|  | ||||
| 			"townBackground": "TBFRBACK.bmp", | ||||
| 			"guildWindow": "TPMAGEFR.bmp", | ||||
|   | ||||
| @@ -116,6 +116,7 @@ | ||||
| 			}, | ||||
|  | ||||
| 			"musicTheme" : "music/InfernoTown", | ||||
| 			"defaultTavern" : 5, | ||||
|  | ||||
| 			"townBackground": "TBINBACK.bmp", | ||||
| 			"guildWindow": "TPMAGEIN.bmp", | ||||
|   | ||||
| @@ -120,6 +120,7 @@ | ||||
| 			}, | ||||
|  | ||||
| 			"musicTheme" : "music/NecroTown", | ||||
| 			"defaultTavern" : 5, | ||||
|  | ||||
| 			"townBackground": "TBNCBACK.bmp", | ||||
| 			"guildWindow": "TPMAGENC.bmp", | ||||
|   | ||||
| @@ -120,6 +120,7 @@ | ||||
| 			}, | ||||
|  | ||||
| 			"musicTheme" : "music/Rampart", | ||||
| 			"defaultTavern" : 5, | ||||
|  | ||||
| 			"townBackground": "TBRMBACK.bmp", | ||||
| 			"guildWindow": "TPMAGERM.bmp", | ||||
|   | ||||
| @@ -114,6 +114,7 @@ | ||||
| 			}, | ||||
|  | ||||
| 			"musicTheme" : "music/Stronghold", | ||||
| 			"defaultTavern" : 5, | ||||
|  | ||||
| 			"townBackground": "TBSTBACK.bmp", | ||||
| 			"guildWindow": "TPMAGEST.bmp", | ||||
|   | ||||
| @@ -115,6 +115,7 @@ | ||||
| 			}, | ||||
|  | ||||
| 			"musicTheme" : "music/TowerTown", | ||||
| 			"defaultTavern" : 5, | ||||
|  | ||||
| 			"townBackground": "TBTWBACK.bmp", | ||||
| 			"guildWindow": "TPMAGETW.bmp", | ||||
|   | ||||
| @@ -3,6 +3,7 @@ | ||||
| 	{ | ||||
| 		"index": 0, | ||||
| 		"faction" : "castle", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH00.DEF",  "female" : "CH01.DEF" }, | ||||
| @@ -13,6 +14,7 @@ | ||||
| 	{ | ||||
| 		"index": 1, | ||||
| 		"faction" : "castle", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH00.DEF",  "female" : "CH01.DEF" }, | ||||
| @@ -23,6 +25,7 @@ | ||||
| 	{ | ||||
| 		"index": 2, | ||||
| 		"faction" : "rampart", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH02.DEF",  "female" : "CH03.DEF" }, | ||||
| @@ -33,6 +36,7 @@ | ||||
| 	{ | ||||
| 		"index": 3, | ||||
| 		"faction" : "rampart", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH02.DEF",  "female" : "CH03.DEF" }, | ||||
| @@ -43,6 +47,7 @@ | ||||
| 	{ | ||||
| 		"index": 4, | ||||
| 		"faction" : "tower", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH05.DEF",  "female" : "CH04.DEF" }, | ||||
| @@ -53,6 +58,7 @@ | ||||
| 	{ | ||||
| 		"index": 5, | ||||
| 		"faction" : "tower", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH05.DEF",  "female" : "CH04.DEF" }, | ||||
| @@ -63,6 +69,7 @@ | ||||
| 	{ | ||||
| 		"index": 6, | ||||
| 		"faction" : "inferno", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH06.DEF",  "female" : "CH07.DEF" }, | ||||
| @@ -73,6 +80,7 @@ | ||||
| 	{ | ||||
| 		"index": 7, | ||||
| 		"faction" : "inferno", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH06.DEF",  "female" : "CH07.DEF" }, | ||||
| @@ -83,6 +91,7 @@ | ||||
| 	{ | ||||
| 		"index": 8, | ||||
| 		"faction" : "necropolis", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH08.DEF",  "female" : "CH09.DEF" }, | ||||
| @@ -93,6 +102,7 @@ | ||||
| 	{ | ||||
| 		"index": 9, | ||||
| 		"faction" : "necropolis", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH08.DEF",  "female" : "CH09.DEF" }, | ||||
| @@ -103,6 +113,7 @@ | ||||
| 	{ | ||||
| 		"index": 10, | ||||
| 		"faction" : "dungeon", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH010.DEF", "female" : "CH11.DEF" }, | ||||
| @@ -113,6 +124,7 @@ | ||||
| 	{ | ||||
| 		"index": 11, | ||||
| 		"faction" : "dungeon", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH010.DEF", "female" : "CH11.DEF" }, | ||||
| @@ -123,6 +135,7 @@ | ||||
| 	{ | ||||
| 		"index": 12, | ||||
| 		"faction" : "stronghold", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH013.DEF", "female" : "CH012.DEF" }, | ||||
| @@ -133,6 +146,7 @@ | ||||
| 	{ | ||||
| 		"index": 13, | ||||
| 		"faction" : "stronghold", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH013.DEF", "female" : "CH012.DEF" }, | ||||
| @@ -143,6 +157,7 @@ | ||||
| 	{ | ||||
| 		"index": 14, | ||||
| 		"faction" : "fortress", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH014.DEF", "female" : "CH015.DEF" }, | ||||
| @@ -153,6 +168,7 @@ | ||||
| 	{ | ||||
| 		"index": 15, | ||||
| 		"faction" : "fortress", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH014.DEF", "female" : "CH015.DEF" }, | ||||
| @@ -163,6 +179,7 @@ | ||||
| 	{ | ||||
| 		"index": 16, | ||||
| 		"faction" : "conflux", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH16.DEF",  "female" : "CH17.DEF" }, | ||||
| @@ -173,6 +190,7 @@ | ||||
| 	{ | ||||
| 		"index": 17, | ||||
| 		"faction" : "conflux", | ||||
| 		"defaultTavern" : 5, | ||||
| 		"animation": | ||||
| 		{ | ||||
| 			"battle" : { "male" : "CH16.DEF",  "female" : "CH17.DEF" }, | ||||
|   | ||||
| @@ -109,7 +109,7 @@ | ||||
| 			"additionalProperties" : false, | ||||
| 			"required" : [ | ||||
| 				"adventureMap", "buildingsIcons", "buildings", "creatures", "guildWindow", "names", | ||||
| 				"hallBackground", "hallSlots", "horde", "mageGuild", "moatDamage", | ||||
| 				"hallBackground", "hallSlots", "horde", "mageGuild", "moatDamage", "defaultTavern", | ||||
| 				"musicTheme", "siege", "structures", "townBackground", "warMachine" | ||||
| 			], | ||||
| 			"description": "town", | ||||
| @@ -158,12 +158,18 @@ | ||||
| 					"additionalProperties" : { | ||||
| 						"type" : "number" | ||||
| 					} | ||||
| 				},				 | ||||
| 				"defaultTavern" : { | ||||
| 					"type" : "number", | ||||
| 					"description" : "Default chance for hero to appear in tavern, used only when value vas not set in tavern field", | ||||
| 					"minimum" : 0 | ||||
| 				}, | ||||
| 				"tavern" : { | ||||
| 					"type" : "object", | ||||
| 					"description" : "Hero classes available in tavern. Value indicates chance for hero of this class to appear", | ||||
| 					"additionalProperties" : { | ||||
| 						"type" : "number" | ||||
| 						"type" : "number", | ||||
| 						"minimum" : 0 | ||||
| 					} | ||||
| 				}, | ||||
| 				"names" : { | ||||
|   | ||||
| @@ -5,7 +5,7 @@ | ||||
| 	"description" : "Format used to define classes of heroes in VCMI", | ||||
| 	"required" : [ | ||||
| 		"animation", "faction", "highLevelChance", "lowLevelChance", | ||||
| 		"name", "primarySkills", "secondarySkills", "tavern" | ||||
| 		"name", "primarySkills", "secondarySkills", "tavern", "defaultTavern" | ||||
| 	], | ||||
|  | ||||
| 	"additionalProperties" : false, | ||||
| @@ -94,11 +94,18 @@ | ||||
| 				"type":"number" | ||||
| 			} | ||||
| 		}, | ||||
| 		"defaultTavern" : { | ||||
| 			"type" : "number", | ||||
| 			"description" : "Default chance for hero to appear in tavern, used only when value vas not set in tavern field", | ||||
| 			"minimum" : 0 | ||||
| 		}, | ||||
|  | ||||
| 		"tavern": { | ||||
| 			"type":"object", | ||||
| 			"description": "Chance for this hero to appear in tavern of this factions. Reversed version of field \"tavern\" from town format", | ||||
| 			"additionalProperties":{ | ||||
| 				"type":"number" | ||||
| 				"type":"number", | ||||
| 				"minimum" : 0 | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										2
									
								
								debian/control
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								debian/control
									
									
									
									
										vendored
									
									
								
							| @@ -2,7 +2,7 @@ Source: vcmi | ||||
| Section: games | ||||
| Priority: optional | ||||
| Maintainer: Ivan Savenko <saven.ivan@gmail.com> | ||||
| Build-Depends: debhelper (>= 8), cmake, libsdl-image1.2-dev, libsdl-ttf2.0-dev, libsdl-mixer1.2-dev (>= 1.2.8), zlib1g-dev, libavformat-dev, libswscale-dev, libboost-dev (>=1.46), libboost-program-options-dev (>=1.46), libboost-filesystem-dev (>=1.46), libboost-system-dev (>=1.46), libboost-thread-dev (>=1.46) | ||||
| Build-Depends: debhelper (>= 8), cmake, libsdl-image1.2-dev, libsdl-ttf2.0-dev, libsdl-mixer1.2-dev (>= 1.2.8), zlib1g-dev, libavformat-dev, libswscale-dev, libboost-dev (>=1.48), libboost-program-options-dev (>=1.48), libboost-filesystem-dev (>=1.48), libboost-system-dev (>=1.48), libboost-locale-dev (>=1.48), libboost-thread-dev (>=1.48) | ||||
| Standards-Version: 3.9.1 | ||||
| Homepage: http://vcmi.eu | ||||
|  | ||||
|   | ||||
| @@ -28,7 +28,7 @@ bool CModEntry::compareVersions(QString lesser, QString greater) | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| CModEntry::CModEntry(QVariantMap repository, QVariantMap localData, QVariant modSettings, QString modname): | ||||
| CModEntry::CModEntry(QVariantMap repository, QVariantMap localData, QVariantMap modSettings, QString modname): | ||||
|     repository(repository), | ||||
|     localData(localData), | ||||
|     modSettings(modSettings), | ||||
| @@ -41,7 +41,7 @@ bool CModEntry::isEnabled() const | ||||
| 	if (!isInstalled()) | ||||
| 		return false; | ||||
|  | ||||
| 	return modSettings.toBool(); | ||||
| 	return modSettings["active"].toBool(); | ||||
| } | ||||
|  | ||||
| bool CModEntry::isDisabled() const | ||||
| @@ -140,7 +140,13 @@ CModEntry CModList::getMod(QString modname) const | ||||
|  | ||||
| 	QVariantMap repo; | ||||
| 	QVariantMap local = localModList[modname].toMap(); | ||||
| 	QVariant settings = modSettings[modname]; | ||||
| 	QVariantMap settings; | ||||
|  | ||||
| 	QVariant conf = modSettings[modname]; | ||||
| 	if (conf.canConvert<QVariantMap>()) | ||||
| 		settings = modSettings[modname].toMap(); | ||||
| 	else | ||||
| 		settings.insert("active", conf); | ||||
|  | ||||
| 	for (auto entry : repositories) | ||||
| 	{ | ||||
|   | ||||
| @@ -22,11 +22,11 @@ class CModEntry | ||||
| 	// repository contains newest version only (if multiple are available) | ||||
| 	QVariantMap repository; | ||||
| 	QVariantMap localData; | ||||
| 	QVariant modSettings; | ||||
| 	QVariantMap modSettings; | ||||
|  | ||||
| 	QString modname; | ||||
| public: | ||||
| 	CModEntry(QVariantMap repository, QVariantMap localData, QVariant modSettings, QString modname); | ||||
| 	CModEntry(QVariantMap repository, QVariantMap localData, QVariantMap modSettings, QString modname); | ||||
|  | ||||
| 	// installed and enabled | ||||
| 	bool isEnabled() const; | ||||
| @@ -76,4 +76,4 @@ public: | ||||
|  | ||||
| 	// returns list of all available mods | ||||
| 	QVector<QString> getModList() const; | ||||
| }; | ||||
| }; | ||||
|   | ||||
| @@ -192,8 +192,10 @@ bool CModManager::doEnableMod(QString mod, bool on) | ||||
| { | ||||
| 	QVariant value(on); | ||||
| 	QVariantMap list = modSettings["activeMods"].toMap(); | ||||
| 	QVariantMap modData = list[mod].toMap(); | ||||
|  | ||||
| 	list.insert(mod, value); | ||||
| 	modData.insert("active", value); | ||||
| 	list.insert(mod, modData); | ||||
| 	modSettings.insert("activeMods", list); | ||||
|  | ||||
| 	modList->setModSettings(modSettings["activeMods"]); | ||||
|   | ||||
| @@ -108,6 +108,7 @@ CHeroClass *CHeroClassHandler::loadFromJson(const JsonNode & node) | ||||
| 		heroClass->secSkillProbability.push_back(node["secondarySkills"][secSkill].Float()); | ||||
| 	} | ||||
|  | ||||
| 	heroClass->defaultTavernChance = node["defaultTavern"].Float(); | ||||
| 	for(auto & tavern : node["tavern"].Struct()) | ||||
| 	{ | ||||
| 		int value = tavern.second.Float(); | ||||
| @@ -189,6 +190,24 @@ void CHeroClassHandler::loadObject(std::string scope, std::string name, const Js | ||||
| 	VLC->modh->identifiers.registerObject(scope, "heroClass", name, object->id); | ||||
| } | ||||
|  | ||||
| void CHeroClassHandler::afterLoadFinalization() | ||||
| { | ||||
| 	// for each pair <class, town> set selection probability if it was not set before in tavern entries | ||||
| 	for (CHeroClass * heroClass : heroClasses) | ||||
| 	{ | ||||
| 		for (CFaction * faction : VLC->townh->factions) | ||||
| 		{ | ||||
| 			if (!faction->town) | ||||
| 				continue; | ||||
| 			if (heroClass->selectionProbability.count(faction->index)) | ||||
| 				continue; | ||||
|  | ||||
| 			float chance = heroClass->defaultTavernChance * faction->town->defaultTavernChance; | ||||
| 			heroClass->selectionProbability[faction->index] = round(sqrt(chance)); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| std::vector<bool> CHeroClassHandler::getDefaultAllowed() const | ||||
| { | ||||
| 	return std::vector<bool>(heroClasses.size(), true); | ||||
|   | ||||
| @@ -103,6 +103,10 @@ public: | ||||
| 	TFaction faction; | ||||
| 	ui8 id; | ||||
|  | ||||
| 	// default chance for hero of specific class to appear in tavern, if field "tavern" was not set | ||||
| 	// resulting chance = sqrt(town.chance * heroClass.chance) | ||||
| 	ui32 defaultTavernChance; | ||||
|  | ||||
| 	std::vector<int> primarySkillInitial;  // initial primary skills | ||||
| 	std::vector<int> primarySkillLowLevel; // probability (%) of getting point of primary skill when getting level | ||||
| 	std::vector<int> primarySkillHighLevel;// same for high levels (> 10) | ||||
| @@ -121,7 +125,7 @@ public: | ||||
|  | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| 		h & identifier & name & faction & id;// & aggression; | ||||
| 		h & identifier & name & faction & id & defaultTavernChance;// & aggression; | ||||
| 		h & primarySkillInitial   & primarySkillLowLevel; | ||||
| 		h & primarySkillHighLevel & secSkillProbability; | ||||
| 		h & selectionProbability; | ||||
| @@ -162,6 +166,8 @@ public: | ||||
| 	void loadObject(std::string scope, std::string name, const JsonNode & data) override; | ||||
| 	void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override; | ||||
|  | ||||
| 	void afterLoadFinalization(); | ||||
|  | ||||
| 	std::vector<bool> getDefaultAllowed() const; | ||||
|  | ||||
| 	~CHeroClassHandler(); | ||||
|   | ||||
| @@ -5,6 +5,13 @@ include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIRECTORY} ${ | ||||
| include_directories(${Boost_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}) | ||||
|  | ||||
| set(lib_SRCS | ||||
| 		RegisterTypes.cpp | ||||
| 		IGameCallback.cpp | ||||
| 		CGameState.cpp | ||||
| 		CObjectHandler.cpp | ||||
| 		Connection.cpp | ||||
| 		NetPacksLib.cpp | ||||
|  | ||||
| 		filesystem/AdapterLoaders.cpp | ||||
| 		filesystem/CCompressedStream.cpp | ||||
| 		filesystem/CFilesystemLoader.cpp | ||||
| @@ -47,24 +54,18 @@ set(lib_SRCS | ||||
| 		CCreatureSet.cpp | ||||
| 		CDefObjInfoHandler.cpp | ||||
| 		CGameInterface.cpp | ||||
| 		CGameState.cpp | ||||
| 		CGeneralTextHandler.cpp | ||||
| 		CHeroHandler.cpp | ||||
| 		CModHandler.cpp | ||||
| 		CObjectHandler.cpp | ||||
| 		CObstacleInstance.cpp | ||||
| 		Connection.cpp | ||||
| 		CSpellHandler.cpp | ||||
| 		CThreadHelper.cpp | ||||
| 		CTownHandler.cpp | ||||
| 		GameConstants.cpp | ||||
| 		HeroBonus.cpp | ||||
| 		IGameCallback.cpp | ||||
| 		JsonDetail.cpp | ||||
| 		JsonNode.cpp | ||||
| 		NetPacksLib.cpp | ||||
| 		ResourceSet.cpp | ||||
| 		RegisterTypes.cpp | ||||
| 		VCMI_Lib.cpp | ||||
| 		VCMIDirs.cpp | ||||
| ) | ||||
|   | ||||
| @@ -445,17 +445,31 @@ std::vector <TModID> CModHandler::resolveDependencies(std::vector <TModID> input | ||||
| 	return output; | ||||
| } | ||||
|  | ||||
| static void updateModSettingsFormat(JsonNode & config) | ||||
| { | ||||
| 	for (auto & entry : config.Struct()) | ||||
| 	{ | ||||
| 		if (entry.second.getType() == JsonNode::DATA_BOOL) | ||||
| 		{ | ||||
| 			entry.second["active"].Bool() = entry.second.Bool(); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void CModHandler::initialize(std::vector<std::string> availableMods) | ||||
| { | ||||
| 	std::string confName = "config/modSettings.json"; | ||||
| 	JsonNode modConfig; | ||||
|  | ||||
| 	// Porbably new install. Create initial configuration | ||||
| 	// Probably new install. Create initial configuration | ||||
| 	if (!CResourceHandler::get()->existsResource(ResourceID(confName))) | ||||
| 		CResourceHandler::get()->createResource(confName); | ||||
| 	else | ||||
| 		modConfig = JsonNode(ResourceID(confName)); | ||||
|  | ||||
| 	// mod compatibility: check if modSettings has old, 0.94 format | ||||
| 	updateModSettingsFormat(modConfig["activeMods"]); | ||||
|  | ||||
| 	const JsonNode & modList = modConfig["activeMods"]; | ||||
| 	JsonNode resultingList; | ||||
|  | ||||
| @@ -473,12 +487,12 @@ void CModHandler::initialize(std::vector<std::string> availableMods) | ||||
| 			if (config.isNull()) | ||||
| 				continue; | ||||
|  | ||||
| 			if (!modList[name].isNull() && modList[name].Bool() == false ) | ||||
| 			if (!modList[name].isNull() && modList[name]["active"].Bool() == false ) | ||||
| 			{ | ||||
| 				resultingList[name].Bool() = false; | ||||
| 				resultingList[name]["active"].Bool() = false; | ||||
| 				continue; // disabled mod | ||||
| 			} | ||||
| 			resultingList[name].Bool() = true; | ||||
| 			resultingList[name]["active"].Bool() = true; | ||||
|  | ||||
| 			CModInfo & mod = allMods[name]; | ||||
|  | ||||
|   | ||||
| @@ -503,6 +503,7 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	town.defaultTavernChance = source["defaultTavern"].Float(); | ||||
| 	/// set chance of specific hero class to appear in this town | ||||
| 	for(auto &node : source["tavern"].Struct()) | ||||
| 	{ | ||||
|   | ||||
| @@ -148,6 +148,9 @@ public: | ||||
| 	ui16 primaryRes; | ||||
| 	ArtifactID warMachine; | ||||
| 	si32 moatDamage; | ||||
| 	// default chance for hero of specific class to appear in tavern, if field "tavern" was not set | ||||
| 	// resulting chance = sqrt(town.chance * heroClass.chance) | ||||
| 	ui32 defaultTavernChance; | ||||
|  | ||||
| 	// Client-only data. Should be moved away from lib | ||||
| 	struct ClientInfo | ||||
| @@ -197,7 +200,7 @@ public: | ||||
| 	template <typename Handler> void serialize(Handler &h, const int version) | ||||
| 	{ | ||||
| 		h & names & faction & creatures & dwellings & dwellingNames & buildings & hordeLvl & mageLevel | ||||
| 			& primaryRes & warMachine & clientInfo & moatDamage; | ||||
| 			& primaryRes & warMachine & clientInfo & moatDamage & defaultTavernChance; | ||||
|  | ||||
| 		auto findNull = [](const std::pair<BuildingID, ConstTransitivePtr<CBuilding>> &building) | ||||
| 		{ return building.second == nullptr; }; | ||||
|   | ||||
| @@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 2.6) | ||||
| include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_CURRENT_SOURCE_DIRECTORY}) | ||||
|  | ||||
| set(lib_SRCS | ||||
|         ERMInterpreter.cpp | ||||
|         ERMParser.cpp | ||||
|         ERMInterpreter.cpp | ||||
|         ERMScriptModule.cpp | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -6,8 +6,8 @@ include_directories(${Boost_INCLUDE_DIRS}) | ||||
|  | ||||
| set(server_SRCS | ||||
|         CGameHandler.cpp | ||||
|         CQuery.cpp | ||||
|         CVCMIServer.cpp | ||||
|         CQuery.cpp | ||||
|         NetPacksServer.cpp | ||||
| ) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user