mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Large rewrite of adventure map objects:
- replaced CDefObjInfo with ObjectTemplate class - ObjectTempate is a direct member of objects instead of pointer with shared ownership across CMap, handler and game objects - simplified handling of objects that can change appearance (e.g. towns) - all object queries regarding object appearance/blockmaps use h3m pos instead of relative positions - removed need of modhandler::reload - cleanup of some old code
This commit is contained in:
		| @@ -789,91 +789,4 @@ void CModHandler::afterLoad() | ||||
|  | ||||
| 	std::ofstream file(*CResourceHandler::get()->getResourceName(ResourceID("config/modSettings.json")), std::ofstream::trunc); | ||||
| 	file << modSettings; | ||||
| 	reload(); | ||||
| } | ||||
|  | ||||
| void CModHandler::reload() | ||||
| { | ||||
| 	{ | ||||
| 		//recreate adventure map defs | ||||
| 		assert(!VLC->dobjinfo->gobjs[Obj::MONSTER].empty()); //make sure that at least some def info was found | ||||
|  | ||||
| 		const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::MONSTER].begin()->second; | ||||
|  | ||||
| 		for(auto & crea : VLC->creh->creatures) | ||||
| 		{ | ||||
| 			if (!vstd::contains(VLC->dobjinfo->gobjs[Obj::MONSTER], crea->idNumber)) // no obj info for this type | ||||
| 			{ | ||||
| 				auto  info = new CGDefInfo(*baseInfo); | ||||
| 				info->subid = crea->idNumber; | ||||
| 				info->name = crea->advMapDef; | ||||
|  | ||||
| 				VLC->dobjinfo->gobjs[Obj::MONSTER][crea->idNumber] = info; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	{ | ||||
| 		assert(!VLC->dobjinfo->gobjs[Obj::ARTIFACT].empty()); | ||||
|  | ||||
| 		const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::ARTIFACT].begin()->second; | ||||
|  | ||||
| 		for(auto & art : VLC->arth->artifacts) | ||||
| 		{ | ||||
| 			if (!vstd::contains(VLC->dobjinfo->gobjs[Obj::ARTIFACT], art->id)) // no obj info for this type | ||||
| 			{ | ||||
| 				auto  info = new CGDefInfo(*baseInfo); | ||||
| 				info->subid = art->id; | ||||
| 				info->name = art->advMapDef; | ||||
|  | ||||
| 				VLC->dobjinfo->gobjs[Obj::ARTIFACT][art->id] = info; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	{ | ||||
| 		assert(!VLC->dobjinfo->gobjs[Obj::TOWN].empty()); //make sure that at least some def info was found | ||||
|  | ||||
| 		const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::TOWN].begin()->second; | ||||
| 		auto & townInfos = VLC->dobjinfo->gobjs[Obj::TOWN]; | ||||
|  | ||||
| 		for(auto & faction : VLC->townh->factions) | ||||
| 		{ | ||||
| 			TFaction index = faction->index; | ||||
| 			CTown * town = faction->town; | ||||
| 			if (town) | ||||
| 			{ | ||||
| 				auto & cientInfo = town->clientInfo; | ||||
|  | ||||
| 				if (!vstd::contains(VLC->dobjinfo->gobjs[Obj::TOWN], index)) // no obj info for this type | ||||
| 				{ | ||||
| 					auto  info = new CGDefInfo(*baseInfo); | ||||
| 					info->subid = index; | ||||
|  | ||||
| 					townInfos[index] = info; | ||||
| 				} | ||||
| 				townInfos[index]->name = cientInfo.advMapCastle; | ||||
|  | ||||
| 				VLC->dobjinfo->villages[index] = new CGDefInfo(*townInfos[index]); | ||||
| 				VLC->dobjinfo->villages[index]->name = cientInfo.advMapVillage; | ||||
|  | ||||
| 				VLC->dobjinfo->capitols[index] = new CGDefInfo(*townInfos[index]); | ||||
| 				VLC->dobjinfo->capitols[index]->name = cientInfo.advMapCapitol; | ||||
|  | ||||
| 				for (int i = 0; i < town->dwellings.size(); ++i) | ||||
| 				{ | ||||
| 					const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::CREATURE_GENERATOR1][i]; //get same blockmap as first dwelling of tier i | ||||
|  | ||||
| 					for (auto cre : town->creatures[i]) //both unupgraded and upgraded get same dwelling | ||||
| 					{ | ||||
| 						auto  info = new CGDefInfo(*baseInfo); | ||||
| 						info->subid = cre; | ||||
| 						info->name = town->dwellings[i]; | ||||
| 						VLC->dobjinfo->gobjs[Obj::CREATURE_GENERATOR1][cre] = info; | ||||
|  | ||||
| 						VLC->objh->cregens[cre] = cre; //map of dwelling -> creature id | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user