mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Use ArtifactID instead of int when possible
This commit is contained in:
		| @@ -122,7 +122,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState) | ||||
| 	// If clicked on spellbook, open it only if no artifact is held at the moment. | ||||
| 	if(ourArt && !down && previousState && !ourOwner->commonInfo->src.AOH) | ||||
| 	{ | ||||
| 		if(ourArt->artType->id == 0) | ||||
| 		if(ourArt->artType->id == ArtifactID::SPELLBOOK) | ||||
| 		{ | ||||
| 			auto   spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), ourOwner->curHero, LOCPLINT, LOCPLINT->battleInt); | ||||
| 			GH.pushInt(spellWindow); | ||||
| @@ -131,7 +131,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState) | ||||
|  | ||||
| 	if (!down && previousState) | ||||
| 	{ | ||||
| 		if(ourArt && ourArt->artType->id == 0) //spellbook | ||||
| 		if(ourArt && ourArt->artType->id == ArtifactID::SPELLBOOK) | ||||
| 			return; //this is handled separately | ||||
|  | ||||
| 		if(!ourOwner->commonInfo->src.AOH) //nothing has been clicked | ||||
| @@ -139,7 +139,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState) | ||||
| 			if(ourArt  //to prevent selecting empty slots (bugfix to what GrayFace reported) | ||||
| 				&&  ourOwner->curHero->tempOwner == LOCPLINT->playerID)//can't take art from another player | ||||
| 			{ | ||||
| 				if(ourArt->artType->id == 3) //catapult cannot be highlighted | ||||
| 				if(ourArt->artType->id == ArtifactID::CATAPULT) //catapult cannot be highlighted | ||||
| 				{ | ||||
| 					std::vector<CComponent *> catapult(1, new CComponent(CComponent::artifact, 3, 0)); | ||||
| 					LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[312], catapult); //The Catapult must be equipped. | ||||
| @@ -380,7 +380,7 @@ void CArtPlace::setArtifact(const CArtifactInstance *art) | ||||
| 		else | ||||
| 			text = '{' + ourArt->artType->Name() + "}\n\n" + artDesc; //workaround for new artifacts with single name, turns it to H3-style | ||||
|  | ||||
| 		if(art->artType->id == 1) //spell scroll | ||||
| 		if(art->artType->id == ArtifactID::SPELL_SCROLL) | ||||
| 		{ | ||||
| 			// we expect scroll description to be like this: This scroll contains the [spell name] spell which is added into your spell book for as long as you carry the scroll. | ||||
| 			// so we want to replace text in [...] with a spell name | ||||
|   | ||||
| @@ -815,7 +815,7 @@ void CCastleBuildings::enterMagesGuild() | ||||
| 			CFunctionList<void()> onYes = [this]{ openMagesGuild(); }; | ||||
| 			CFunctionList<void()> onNo = onYes; | ||||
| 			onYes += [hero]{ LOCPLINT->cb->buyArtifact(hero, ArtifactID::SPELLBOOK); }; | ||||
| 			std::vector<CComponent*> components(1, new CComponent(CComponent::artifact,0,0)); | ||||
| 			std::vector<CComponent*> components(1, new CComponent(CComponent::artifact,ArtifactID::SPELLBOOK,0)); | ||||
|  | ||||
| 			LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[214], onYes, onNo, true, components); | ||||
| 		} | ||||
|   | ||||
| @@ -1460,7 +1460,7 @@ void CAltarWindow::showAll(SDL_Surface * to) | ||||
| bool CAltarWindow::putOnAltar(CTradeableItem* altarSlot, const CArtifactInstance *art) | ||||
| { | ||||
| 	int artID = art->artType->id; | ||||
| 	if(artID != 1 && artID < 7) //special art | ||||
| 	if(artID != ArtifactID::SPELL_SCROLL && artID < 7) //special art | ||||
| 	{ | ||||
|         logGlobal->warnStream() << "Cannot put special artifact on altar!"; | ||||
| 		return false; | ||||
|   | ||||
| @@ -78,7 +78,7 @@ CArtifact::~CArtifact() | ||||
|  | ||||
| int CArtifact::getArtClassSerial() const | ||||
| { | ||||
| 	if(id == 1) | ||||
| 	if(id == ArtifactID::SPELL_SCROLL) | ||||
| 		return 4; | ||||
| 	switch(aClass) | ||||
| 	{ | ||||
|   | ||||
| @@ -779,6 +779,7 @@ public: | ||||
| 		FIRST_AID_TENT = 6, | ||||
| 		//CENTAUR_AXE = 7, | ||||
| 		//BLACKSHARD_OF_THE_DEAD_KNIGHT = 8, | ||||
| 		TITANS_THUNDER = 135, | ||||
| 		//CORNUCOPIA = 140, | ||||
| 		ART_SELECTION = 144, | ||||
| 		ART_LOCK = 145, | ||||
|   | ||||
| @@ -909,7 +909,7 @@ DLL_LINKAGE void MoveArtifact::applyGs( CGameState *gs ) | ||||
| 	a->move(src, dst); | ||||
|  | ||||
| 	//TODO what'll happen if Titan's thunder is equipped by pickin git up or the start of game? | ||||
| 	if (a->artType->id == 135 && dst.slot == ArtifactPosition::RIGHT_HAND) //Titan's Thunder creates new spellbook on equip | ||||
| 	if (a->artType->id == ArtifactID::TITANS_THUNDER && dst.slot == ArtifactPosition::RIGHT_HAND) //Titan's Thunder creates new spellbook on equip | ||||
| 	{ | ||||
| 		auto hPtr = boost::get<ConstTransitivePtr<CGHeroInstance> >(&dst.artHolder); | ||||
| 		if(hPtr) | ||||
|   | ||||
| @@ -1229,7 +1229,7 @@ void CMapLoaderH3M::readObjects() | ||||
| 				if(objTempl.id == Obj::SPELL_SCROLL) | ||||
| 				{ | ||||
| 					spellID = reader.readUInt32(); | ||||
| 					artID = 1; | ||||
| 					artID = ArtifactID::SPELL_SCROLL; | ||||
| 				} | ||||
| 				else if(objTempl.id == Obj::ARTIFACT) | ||||
| 				{ | ||||
|   | ||||
| @@ -522,7 +522,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer | ||||
| 				MoveArtifact ma; | ||||
| 				ma.src = ArtifactLocation (finishingBattle->loserHero, artSlot.first); | ||||
| 				const CArtifactInstance * art =  ma.src.getArt(); | ||||
| 				if (art && !art->artType->isBig() && art->artType->id != 0) // don't move war machines or locked arts (spellbook) | ||||
| 				if (art && !art->artType->isBig() && art->artType->id != ArtifactID::SPELLBOOK) // don't move war machines or locked arts (spellbook) | ||||
| 				{ | ||||
| 					arts.push_back (art->artType->id); | ||||
| 					ma.dst = ArtifactLocation (finishingBattle->winnerHero, art->firstAvailableSlot(finishingBattle->winnerHero)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user