mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Fix hero generation in main town
This commit is contained in:
		| @@ -43,18 +43,22 @@ PlayerParams::PlayerParams(MapController & ctrl, int playerId, QWidget *parent) | ||||
|  | ||||
| 	//load towns | ||||
| 	int foundMainTown = -1; | ||||
| 	for(int i = 0; i < controller.map()->towns.size(); ++i) | ||||
| 	for(int i = 0, townIndex = 0; i < controller.map()->objects.size(); ++i) | ||||
| 	{ | ||||
| 		if(auto town = controller.map()->towns[i]) | ||||
| 		if(auto town = dynamic_cast<CGTownInstance*>(controller.map()->objects[i].get())) | ||||
| 		{ | ||||
| 			auto * ctown = town->town; | ||||
| 			if(!ctown) | ||||
| 				ctown = VLC->townh->randomTown; | ||||
| 			if(ctown && ctown->faction && town->getOwner().getNum() == playerColor) | ||||
| 			if(ctown && town->getOwner().getNum() == playerColor) | ||||
| 			{ | ||||
| 				if(playerInfo.hasMainTown && playerInfo.posOfMainTown == town->pos) | ||||
| 					foundMainTown = i; | ||||
| 				ui->mainTown->addItem(QString::fromStdString(town->getObjectName()), QVariant::fromValue(i)); | ||||
| 					foundMainTown = townIndex; | ||||
| 				auto name = town->name + ", (random)"; | ||||
| 				if(ctown->faction) | ||||
| 					name = town->getObjectName(); | ||||
| 				ui->mainTown->addItem(tr(name.c_str()), QVariant::fromValue(i)); | ||||
| 				++townIndex; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| @@ -122,7 +126,7 @@ void PlayerParams::on_mainTown_activated(int index) | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		auto town = controller.map()->towns.at(ui->mainTown->currentData().toInt()); | ||||
| 		auto town = controller.map()->objects.at(ui->mainTown->currentData().toInt()); | ||||
| 		playerInfo.hasMainTown = true; | ||||
| 		playerInfo.posOfMainTown = town->pos; | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user