Parcourir la source

wczytuje już znaczną część obiektów, ale wymaga jeszcze poprawy

poprawiony bug z niewczytywaniem jednego z czarów
mateuszb il y a 18 ans
Parent
commit
8ec8a522ea
6 fichiers modifiés avec 145 ajouts et 7 suppressions
  1. 118 5
      CAmbarCendamo.cpp
  2. 1 1
      CAmbarCendamo.h
  3. 13 0
      CCastleHandler.h
  4. 12 0
      CObjectHandler.h
  5. 1 1
      CSpellHandler.cpp
  6. BIN
      h3m.txt

+ 118 - 5
CAmbarCendamo.cpp

@@ -415,6 +415,9 @@ void CAmbarCendamo::deh3m()
 		nobj.z = bufor[i++];
 		nobj.defNumber = readNormalNr(i, 4); i+=4;
 		i+=5;
+		EDefType uu = getDefType(map.defy[nobj.defNumber]);
+		int j = map.defy[nobj.defNumber].bytes[16];
+		int p = 99;
 		switch(getDefType(map.defy[nobj.defNumber]))
 		{
 		case EDefType::EVENTOBJ_DEF: //for event - objects
@@ -1095,10 +1098,11 @@ void CAmbarCendamo::deh3m()
 					if(areGuards)
 					{
 						spec->areGuards = true;
-						spec->guards = readCreatureSet(i);
+						spec->guards = readCreatureSet(i); i+=28;
 					}
 					else
 						spec->areGuards = false;
+					i+=4;
 				}
 				nobj.info = spec;
 				break;
@@ -1143,7 +1147,7 @@ void CAmbarCendamo::deh3m()
 				if(hasName)
 				{
 					int len = readNormalNr(i); i+=4;
-					for(iny gg=0; gg<len; ++gg)
+					for(int gg=0; gg<len; ++gg)
 					{
 						spec->name += bufor[i]; ++i;
 					}
@@ -1154,6 +1158,109 @@ void CAmbarCendamo::deh3m()
 					spec->garrison = readCreatureSet(i); i+=28;
 				}
 				spec->garrison.formation = bufor[i]; ++i;
+				spec->unusualBuildins = bufor[i]; ++i;
+				if(spec->unusualBuildins)
+				{
+					for(int ff=0; ff<12; ++ff)
+					{
+						spec->buildingSettings[ff] = bufor[i]; ++i;
+					}
+				}
+				else
+				{
+					spec->hasFort = bufor[i]; ++i;
+				}
+
+				int ist = i;
+				for(i; i<ist+9; ++i)
+				{
+					unsigned char c = bufor[i];
+					for(int yy=0; yy<8; ++yy)
+					{
+						if((i-ist)*8+yy < CGameInfo::mainObj->spellh->spells.size())
+						{
+							if(c == (c|((unsigned char)intPow(2, yy))))
+								spec->obligatorySpells.push_back(&(CGameInfo::mainObj->spellh->spells[(i-ist)*8+yy]));
+						}
+					}
+				}
+
+				ist = i;
+				for(i; i<ist+9; ++i)
+				{
+					unsigned char c = bufor[i];
+					for(int yy=0; yy<8; ++yy)
+					{
+						if((i-ist)*8+yy < CGameInfo::mainObj->spellh->spells.size())
+						{
+							if(c != (c|((unsigned char)intPow(2, yy))))
+								spec->possibleSpells.push_back(&(CGameInfo::mainObj->spellh->spells[(i-ist)*8+yy]));
+						}
+					}
+				}
+
+				/////// reading castle events //////////////////////////////////
+
+				int numberOfEvent = readNormalNr(i); i+=4;
+
+				CCastleEvent nce;
+				int nameLen = readNormalNr(i); i+=4;
+				for(int ll=0; ll<nameLen; ++ll)
+				{
+					nce.name += bufor[i]; ++i;
+				}
+
+				int messLen = readNormalNr(i); i+=4;
+				for(int ll=0; ll<messLen; ++ll)
+				{
+					nce.message += bufor[i]; ++i;
+				}
+
+				nce.wood = readNormalNr(i); i+=4;
+				nce.mercury = readNormalNr(i); i+=4;
+				nce.ore = readNormalNr(i); i+=4;
+				nce.sulfur = readNormalNr(i); i+=4;
+				nce.crystal = readNormalNr(i); i+=4;
+				nce.gems = readNormalNr(i); i+=4;
+				nce.gold = readNormalNr(i); i+=4;
+
+				nce.players = bufor[i]; ++i;
+				nce.forHuman = bufor[i]; ++i;
+				nce.forComputer = bufor[i]; ++i;
+				nce.firstShow = readNormalNr(i, 2); i+=2;
+				nce.forEvery = bufor[i]; ++i;
+
+				i+=17;
+
+				for(int kk=0; kk<6; ++kk)
+				{
+					nce.bytes[kk] = bufor[i]; ++i;
+				}
+
+				for(int vv=0; vv<7; ++vv)
+				{
+					nce.gen[vv] = readNormalNr(i, 2);
+				}
+
+				/////// castle events have been read ///////////////////////////
+
+				i+=4;
+				nobj.info = spec;
+				break;
+			}
+		case EDefType::MINE_DEF:
+			{
+				CMineObjInfo * spec = new CMineObjInfo;
+				spec->player = bufor[i]; ++i;
+				i+=3;
+				nobj.info = spec;
+				break;
+			}
+		case EDefType::SHRINE_DEF:
+			{
+				CShrineObjInfo * spec = new CShrineObjInfo;
+				spec->spell = bufor[i]; i+=4;
+				nobj.info = spec;
 				break;
 			}
 		} //end of main switch
@@ -1216,10 +1323,14 @@ EDefType CAmbarCendamo::getDefType(DefInfo &a)
 		return EDefType::GARRISON_DEF; //handled
 	case 34:
 		return EDefType::HERO_DEF; //handled
-	case 54:
+	case 53: case 17: case 18: case 19: case 20: //cases 17 - 20 - tests
+		return EDefType::MINE_DEF; //handled
+	case 54: case 71: case 72: case 73: case 74: case 75:
 		return EDefType::CREATURES_DEF; //handled
 	case 59:
 		return EDefType::SIGN_DEF; //handled
+	case 77:
+		return EDefType::TOWN_DEF; //can be problematic, but handled
 	case 79:
 		return EDefType::RESOURCE_DEF; //handled
 	case 81:
@@ -1228,14 +1339,16 @@ EDefType CAmbarCendamo::getDefType(DefInfo &a)
 		return EDefType::SEERHUT_DEF; //handled
 	case 91:
 		return EDefType::SIGN_DEF; //handled
+	case 88: case 89: case 90:
+		return SHRINE_DEF; //handled
 	case 98:
-		return EDefType::TOWN_DEF;
+		return EDefType::TOWN_DEF; //handled
 	case 113:
 		return EDefType::WITCHHUT_DEF; //handled
 	case 219:
 		return EDefType::GARRISON_DEF; //handled
 	default:
-		return EDefType::TERRAINOBJ_DEF;
+		return EDefType::TERRAINOBJ_DEF; // nothing to be handled
 	}
 }
 

+ 1 - 1
CAmbarCendamo.h

@@ -10,7 +10,7 @@
 #include "CSemiDefHandler.h"
 #include "CCreatureHandler.h"
 
-enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF, EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF, ARTIFACT_DEF, WITCHHUT_DEF, SCHOLAR_DEF};
+enum EDefType {TOWN_DEF, HERO_DEF, CREATURES_DEF, SEERHUT_DEF, RESOURCE_DEF, TERRAINOBJ_DEF, EVENTOBJ_DEF, SIGN_DEF, GARRISON_DEF, ARTIFACT_DEF, WITCHHUT_DEF, SCHOLAR_DEF, MINE_DEF, SHRINE_DEF};
 
 class CAmbarCendamo 
 {

+ 13 - 0
CCastleHandler.h

@@ -9,6 +9,16 @@
 class CCastleEvent
 {
 public:
+	std::string name, message;
+	int wood, mercury, ore, sulfur, crystal, gems, gold; //gain / loss of resources
+	unsigned char players; //players for whom this event can be applied
+	bool forHuman, forComputer;
+	int firstShow; //postpone of first encounter time in days
+	int forEvery; //every n days this event will occure
+
+	unsigned char bytes[6]; //build specific buildings (raw format, similar to town's)
+
+	int gen[7]; //additional creatures in i-th level dwelling
 };
 
 class CCastleObjInfo : public CSpecObjInfo //castle class
@@ -18,6 +28,9 @@ public:
 	std::vector<CBuilding> buildings; //buildings we can build in this castle
 	std::vector<bool> isBuild; //isBuild[i] is true, when building buildings[i] has been built
 	std::vector<bool> isLocked; //isLocked[i] is true, when building buildings[i] canot be built
+	bool unusualBuildins; //if true, intrepret bytes below
+	unsigned char buildingSettings[12]; //raw format for two vectors above (greatly depends on town type)
+	bool hasFort; //used only if unusualBuildings is false
 	CHero * visitingHero;
 	CHero * garnisonHero;
 

+ 12 - 0
CObjectHandler.h

@@ -178,6 +178,18 @@ public:
 	std::string message;
 };
 
+class CMineObjInfo : public CSpecObjInfo
+{
+public:
+	unsigned char player; //FF - nobody, 0 - 7
+};
+
+class CShrineObjInfo : public CSpecObjInfo
+{
+public:
+	unsigned char spell; //number of spell or 255
+};
+
 class CObject //typical object that can be encountered on a map
 {
 public:

+ 1 - 1
CSpellHandler.cpp

@@ -42,7 +42,7 @@ void CSpellHandler::loadSpells()
 			{
 				if(buf[i]=='\r')
 					++hmcr;
-				if(hmcr==4)
+				if(hmcr==3)
 					break;
 			}
 			++i;

BIN
h3m.txt