Jelajahi Sumber

* [bugfix] naprawa crashbuga przy wczytywaniu warunków porażki
* [bugfix] naprawa crashbuga przy zczytywaniu bohatera z portretem
* [bugfix] naprawa crashbuga przy zczytywaniu bohatera z wojskiem
* [bugfix] naprawa crashbuga przy zczytywaniu zdarzenia ze straznikami
* przełącznik w CMT decydujący czy ma wczytać mapę o ustalonej nazwie, czy też tę wybraną
* logi przy zczytywaniu oiektów, żeby widać bylo gdzie się psuje - jak wszystkie nie-ermowe mapy będą działać to skasuj
* zamykanie pliku z mapą

Michał W. Urbańczyk 18 tahun lalu
induk
melakukan
c1c15e9a1e
5 mengubah file dengan 26 tambahan dan 10 penghapusan
  1. 16 7
      CAmbarCendamo.cpp
  2. 1 1
      CArtHandler.h
  3. 6 1
      CMT.cpp
  4. 1 1
      CSpellHandler.h
  5. 2 0
      nodrze.h

+ 16 - 7
CAmbarCendamo.cpp

@@ -256,17 +256,20 @@ void CAmbarCendamo::deh3m()
 			  map.lossCondition.castlePos.x=bufor[i++];
 			  map.lossCondition.castlePos.y=bufor[i++];
 			  map.lossCondition.castlePos.z=bufor[i++];
+			  break;
 		  }
 	case lossHero:
 		  {
 			  map.lossCondition.heroPos.x=bufor[i++];
 			  map.lossCondition.heroPos.y=bufor[i++];
 			  map.lossCondition.heroPos.z=bufor[i++];
+			  break;
 		  }
 	case timeExpires:
 		{
 			map.lossCondition.timeLimit = readNormalNr(i++,2);
 			i++;
+			 break;
 		}
 	}
 	map.howManyTeams=bufor[i++]; //read number of teams
@@ -310,8 +313,8 @@ void CAmbarCendamo::deh3m()
 					CGameInfo::mainObj->arth->artifacts[(i-ist)*8+yy].isAllowed = false;
 			}
 		}
-	}
-	//allowed artifacts have been read
+	}//allowed artifacts have been read
+
 	//reading allowed spells (9 bytes)
 	ist=i; //starting i for loop
 	for(i; i<ist+9; ++i)
@@ -470,13 +473,17 @@ void CAmbarCendamo::deh3m()
 	int howManyObjs = readNormalNr(i, 4); i+=4;
 	for(int ww=0; ww<howManyObjs; ++ww) //comment this line to turn loading objects off
 	{
-		//std::cout << "object nr "<<ww<<std::endl;
+		std::cout << "object nr "<<ww<<"\ti= "<<i<<std::endl;
 		CObjectInstance nobj; //we will read this object
 		nobj.id = CGameInfo::mainObj->objh->objInstances.size();
 		nobj.x = bufor[i++];
 		nobj.y = bufor[i++];
 		nobj.z = bufor[i++];
 		nobj.defNumber = readNormalNr(i, 4); i+=4;
+
+		if (((nobj.x==0)&&(nobj.y==0)) || nobj.x>map.width || nobj.y>map.height || nobj.z>1 || nobj.defNumber>map.defy.size())
+			std::cout << "Alarm!!! Obiekt "<<ww<<" jest kopniety (lub wystaje poza mape)\n";
+
 		i+=5;
 		unsigned char buff [30];
 		for(int ccc=0; ccc<30; ++ccc)
@@ -508,7 +515,7 @@ void CAmbarCendamo::deh3m()
 					spec->areGuarders = bufor[i]; ++i;
 					if(spec->areGuarders)
 					{
-						spec->guarders = readCreatureSet(i); i+=32;
+						spec->guarders = readCreatureSet(i); i+=28;
 					}
 					i+=4;
 				}
@@ -586,7 +593,9 @@ void CAmbarCendamo::deh3m()
 					spec->experience = readNormalNr(i); i+=4;
 				}
 				else spec->experience = 0;
-				++i; //TODO - czy tu na pewno nie ma istotnej informacji?
+				bool portrait=bufor[i]; ++i;
+				if (portrait)
+					i++; //TODO read portrait nr, save, open
 				bool nonstandardAbilities = bufor[i]; ++i; //true if hero has specified abilities
 				if(nonstandardAbilities)
 				{
@@ -601,7 +610,7 @@ void CAmbarCendamo::deh3m()
 				spec->standardGarrison = standGarrison;
 				if(standGarrison)
 				{
-					spec->garrison = readCreatureSet(i); i+=7;
+					spec->garrison = readCreatureSet(i); i+=28; //4 bytes per slot
 				}
 				bool form = bufor[i]; ++i; //formation
 				spec->garrison.formation = form;
@@ -752,7 +761,7 @@ void CAmbarCendamo::deh3m()
 				//spells
 				bool areSpells = bufor[i]; ++i;
 
-				if(areSpells) //TODO: sprawdziæ
+				if(areSpells) //TODO: sprawdziæ //seems to be ok - tow
 				{
 					int ist = i;
 					for(i; i<ist+9; ++i)

+ 1 - 1
CArtHandler.h

@@ -9,6 +9,7 @@ enum EartClass {SartClass=0, TartClass, NartClass, JartClass, RartClass}; //arti
 class CArtifact //container for artifacts
 {
 public:
+	bool isAllowed; //true if we can use this artifact (map information)
 	std::string name;
 	std::string description;
 	std::string desc2;
@@ -17,7 +18,6 @@ public:
 	bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4, misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso, lHand, rHand, neck, shoulders, head;
 	EartClass aClass;
 	int number;
-	bool isAllowed; //true if we can use this artifact (map information)
 };
 
 class CArtHandler //handles artifacts

+ 6 - 1
CMT.cpp

@@ -325,13 +325,18 @@ int _tmain(int argc, _TCHAR* argv[])
 		{
 			mapstr+=pom;
 		}
+		gzclose(map);
 		unsigned char *initTable = new unsigned char[mapstr.size()];
 		for(int ss=0; ss<mapstr.size(); ++ss)
 		{
 			initTable[ss] = mapstr[ss];
 		}
+#define CHOOSE
+#ifdef CHOOSE
 		CAmbarCendamo * ac = new CAmbarCendamo(initTable); //4gryf
-		//CAmbarCendamo * ac = new CAmbarCendamo("4gryf"); //4gryf
+#else
+		CAmbarCendamo * ac = new CAmbarCendamo("5gryf"); //4gryf
+#endif
 		CMapHeader * mmhh = new CMapHeader(ac->bufor); //czytanie nag³ówka
 		cgi->ac = ac;
 		THC std::cout<<"Reading file: "<<tmh.getDif()<<std::endl;

+ 1 - 1
CSpellHandler.h

@@ -7,6 +7,7 @@
 class CSpell
 {
 public:
+	bool isAllowed; //true if we can use this spell (depends on map)
 	std::string name;
 	std::string abbName; //abbreviated name
 	int level;
@@ -28,7 +29,6 @@ public:
 	std::string noneTip, basTip, advTip, expTip; //descriptions of spell
 	std::string attributes; //reference only attributes
 	bool combatSpell; //is this spell combat (true) or adventure (false)
-	bool isAllowed; //true if we can use this spell (depends on map)
 };
 
 class CSpellHandler

+ 2 - 0
nodrze.h

@@ -3,6 +3,8 @@
 
 //don't look here, it's a horrible, partially working implementation of RB trees
 
+//ignore comment above, it is simply TowDragon's envy. Everything (without removing) is working fine
+
 #include <iostream>
 #include <string>