Sfoglia il codice sorgente

* fixed support for custom hero portrait in the game
* fixed problems with non-hero/town defs not present in defobjinfo but present on map (occurring probably only in case of def substitution in map editor)
* fixed hopefully issues with picking bonus in pregame
* no arrows in options in pregame for fixed hero

Michał W. Urbańczyk 16 anni fa
parent
commit
c847d56a96
2 ha cambiato i file con 31 aggiunte e 13 eliminazioni
  1. 15 11
      CPreGame.cpp
  2. 16 2
      map.cpp

+ 15 - 11
CPreGame.cpp

@@ -505,11 +505,11 @@ void Options::OptionSwitch::press(bool down)
 					ourOpt->hero=-1;
 					CPG->ourOptions->showIcon(0,serialID,false);
 				}
-				if(ourOpt->bonus==bresource)
+				if(nCas < 0 && ourOpt->bonus==bresource)
 				{
 					ourOpt->bonus = brandom;
-					CPG->ourOptions->showIcon(1,serialID,false);
 				}
+				CPG->ourOptions->showIcon(1,serialID,false);
 			}
 			break;
 		}
@@ -538,23 +538,27 @@ void Options::OptionSwitch::press(bool down)
 		}
 	case 1: //bonus change
 		{
-			if (dir>0 && ourOpt->bonus==bresource)
-				ourOpt->bonus=brandom;
-			else if (dir<0 && ourOpt->bonus==brandom)
-				ourOpt->bonus=bresource;
-			else ourOpt->bonus=(Ebonus)(ourOpt->bonus+dir);
-			if (ourOpt->hero==-2 && ourOpt->bonus==bartifact) //no hero - can't be artifact
+			ourOpt->bonus += dir;
+
+			if (ourOpt->hero==-2 && !ourInf->heroesNames.size() && ourOpt->bonus==bartifact) //no hero - can't be artifact
 			{
-				if (dir>0)
+				if (dir<0)
 					ourOpt->bonus=brandom;
 				else ourOpt->bonus=bgold;
 			}
-			if (ourOpt->castle==-1 && ourOpt->bonus==bresource)
+
+			if(ourOpt->bonus > bresource)
+				ourOpt->bonus = brandom;
+			if(ourOpt->bonus < brandom)
+				ourOpt->bonus = bresource;
+
+			if (ourOpt->castle==-1 && ourOpt->bonus==bresource) //random castle - can't be resource
 			{
 				if (dir<0)
 					ourOpt->bonus=bgold;
 				else ourOpt->bonus=brandom;
 			}
+
 			break;
 		}
 	}
@@ -769,7 +773,7 @@ void Options::show()
 		poptions[poptions.size()-1]->nr=playersSoFar;
 		poptions[poptions.size()-1]->color=(Ecolor)i;
 
-		if(CPG->ret.playerInfos[playersSoFar].hero != -2)
+		if(CPG->ret.playerInfos[playersSoFar].hero == -1)
 		{
 			poptions[poptions.size()-1]->Hleft.show();
 			poptions[poptions.size()-1]->Hright.show();

+ 16 - 2
map.cpp

@@ -874,7 +874,7 @@ void Mapa::loadHero( CGObjectInstance * &nobj, unsigned char * bufor, int &i )
 
 	bool portrait=bufor[i]; ++i;
 	if (portrait)
-		nhi->portrait = readChar(bufor,i);
+		nhi->portrait = bufor[i++];
 	if(readChar(bufor,i))//true if hero has specified abilities
 	{
 		int howMany = readNormalNr(bufor,i); i+=4;
@@ -1309,7 +1309,21 @@ void Mapa::readDefInfo( unsigned char * bufor, int &i)
 		}
 		i+=16;
 		if(vinya->id!=34 && vinya->id!=70)
-			vinya->visitDir = VLC->dobjinfo->gobjs[vinya->id][vinya->subid]->visitDir;
+		{
+			CGDefInfo *h = VLC->dobjinfo->gobjs[vinya->id][vinya->subid];
+			if(!h) 
+			{
+				//remove fake entry
+				VLC->dobjinfo->gobjs[vinya->id].erase(vinya->subid);
+				if(VLC->dobjinfo->gobjs[vinya->id].size())
+					VLC->dobjinfo->gobjs.erase(vinya->id);
+				tlog2<<"\t\tWarning: no defobjinfo entry for object ID="<<vinya->id<<" subID=" << vinya->subid<<std::endl;
+			}
+			else
+			{
+				vinya->visitDir = VLC->dobjinfo->gobjs[vinya->id][vinya->subid]->visitDir;
+			}
+		}
 		else
 			vinya->visitDir = 0xff;
 		defy.push_back(vinya); // add this def to the vector