1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-14 02:33:51 +02:00

improvements in reading h3ms, to be tested

This commit is contained in:
mateuszb 2007-08-26 16:02:36 +00:00
parent 2541422e92
commit 4162103cf1
2 changed files with 496 additions and 350 deletions

View File

@ -324,7 +324,7 @@ void CAmbarCendamo::deh3m()
} }
} }
} }
if(map.version>=RoE) if(map.version>RoE)
i+=4; i+=4;
unsigned char disp = 0; unsigned char disp = 0;
if(map.version>=SoD) if(map.version>=SoD)
@ -423,7 +423,7 @@ void CAmbarCendamo::deh3m()
else //omit a lot of rubbish in a strage way else //omit a lot of rubbish in a strage way
{ {
int lastFFpos=i; int lastFFpos=i;
while(i-lastFFpos<50) //i far in terrain bytes while(i-lastFFpos<200) //i far in terrain bytes
{ {
++i; ++i;
if(bufor[i]==0xff) if(bufor[i]==0xff)
@ -565,7 +565,7 @@ void CAmbarCendamo::deh3m()
spec->areGuarders = bufor[i]; ++i; spec->areGuarders = bufor[i]; ++i;
if(spec->areGuarders) if(spec->areGuarders)
{ {
spec->guarders = readCreatureSet(i); i+=28; spec->guarders = readCreatureSet(i); i+=( map.version == RoE ? 21 : 28);
} }
i+=4; i+=4;
} }
@ -600,7 +600,7 @@ void CAmbarCendamo::deh3m()
int gart = readNormalNr(i, 1); ++i; //number of gained artifacts int gart = readNormalNr(i, 1); ++i; //number of gained artifacts
for(int oo = 0; oo<gart; ++oo) for(int oo = 0; oo<gart; ++oo)
{ {
spec->artifacts.push_back(&(CGameInfo::mainObj->arth->artifacts[readNormalNr(i, 2)])); i+=2; spec->artifacts.push_back(&(CGameInfo::mainObj->arth->artifacts[readNormalNr(i, (map.version == RoE ? 1 : 2))])); i+=(map.version == RoE ? 1 : 2);
} }
int gspel = readNormalNr(i, 1); ++i; //number of gained spells int gspel = readNormalNr(i, 1); ++i; //number of gained spells
for(int oo = 0; oo<gspel; ++oo) for(int oo = 0; oo<gspel; ++oo)
@ -620,10 +620,13 @@ void CAmbarCendamo::deh3m()
case EDefType::HERO_DEF: case EDefType::HERO_DEF:
{ {
CHeroObjInfo * spec = new CHeroObjInfo; CHeroObjInfo * spec = new CHeroObjInfo;
if(map.version>RoE)
{
spec->bytes[0] = bufor[i]; ++i; spec->bytes[0] = bufor[i]; ++i;
spec->bytes[1] = bufor[i]; ++i; spec->bytes[1] = bufor[i]; ++i;
spec->bytes[2] = bufor[i]; ++i; spec->bytes[2] = bufor[i]; ++i;
spec->bytes[3] = bufor[i]; ++i; spec->bytes[3] = bufor[i]; ++i;
}
spec->player = bufor[i]; ++i; spec->player = bufor[i]; ++i;
int typeBuf = readNormalNr(i, 1); ++i; int typeBuf = readNormalNr(i, 1); ++i;
if(typeBuf==0xff) if(typeBuf==0xff)
@ -641,12 +644,20 @@ void CAmbarCendamo::deh3m()
} }
else else
spec->name = std::string(""); spec->name = std::string("");
if(map.version>RoE)
{
bool isExp = bufor[i]; ++i; //true if hore's experience is greater than 0 bool isExp = bufor[i]; ++i; //true if hore's experience is greater than 0
if(isExp) if(isExp)
{ {
spec->experience = readNormalNr(i); i+=4; spec->experience = readNormalNr(i); i+=4;
} }
else spec->experience = 0; else
spec->experience = 0;
}
else
{
spec->experience = readNormalNr(i); i+=4;
}
bool portrait=bufor[i]; ++i; bool portrait=bufor[i]; ++i;
if (portrait) if (portrait)
i++; //TODO read portrait nr, save, open i++; //TODO read portrait nr, save, open
@ -664,131 +675,139 @@ void CAmbarCendamo::deh3m()
spec->standardGarrison = standGarrison; spec->standardGarrison = standGarrison;
if(standGarrison) if(standGarrison)
{ {
spec->garrison = readCreatureSet(i); i+=28; //4 bytes per slot spec->garrison = readCreatureSet(i); i+= (map.version == RoE ? 21 : 28); //4 bytes per slot
} }
bool form = bufor[i]; ++i; //formation bool form = bufor[i]; ++i; //formation
spec->garrison.formation = form; spec->garrison.formation = form;
bool artSet = bufor[i]; ++i; //true if artifact set is not default (hero has some artifacts) bool artSet = bufor[i]; ++i; //true if artifact set is not default (hero has some artifacts)
int artmask = map.version == RoE ? 0xff : 0xffff;
int artidlen = map.version == RoE ? 1 : 2;
if(artSet) if(artSet)
{ {
//head art //1 //head art //1
int id = readNormalNr(i, 2); i+=2; int id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artHead = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artHead = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artHead = NULL; spec->artHead = NULL;
//shoulders art //2 //shoulders art //2
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artShoulders = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artShoulders = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artShoulders = NULL; spec->artShoulders = NULL;
//neck art //3 //neck art //3
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artNeck = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artNeck = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artNeck = NULL; spec->artNeck = NULL;
//right hand art //4 //right hand art //4
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artRhand = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artRhand = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artRhand = NULL; spec->artRhand = NULL;
//left hand art //5 //left hand art //5
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artLHand = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artLHand = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artLHand = NULL; spec->artLHand = NULL;
//torso art //6 //torso art //6
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artTorso = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artTorso = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artTorso = NULL; spec->artTorso = NULL;
//right hand ring //7 //right hand ring //7
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artRRing = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artRRing = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artRRing = NULL; spec->artRRing = NULL;
//left hand ring //8 //left hand ring //8
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artLRing = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artLRing = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artLRing = NULL; spec->artLRing = NULL;
//feet art //9 //feet art //9
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artFeet = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artFeet = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artFeet = NULL; spec->artFeet = NULL;
//misc1 art //10 //misc1 art //10
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artMisc1 = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artMisc1 = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artMisc1 = NULL; spec->artMisc1 = NULL;
//misc2 art //11 //misc2 art //11
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artMisc2 = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artMisc2 = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artMisc2 = NULL; spec->artMisc2 = NULL;
//misc3 art //12 //misc3 art //12
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artMisc3 = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artMisc3 = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artMisc3 = NULL; spec->artMisc3 = NULL;
//misc4 art //13 //misc4 art //13
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artMisc4 = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artMisc4 = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artMisc4 = NULL; spec->artMisc4 = NULL;
//machine1 art //14 //machine1 art //14
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artMach1 = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artMach1 = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artMach1 = NULL; spec->artMach1 = NULL;
//machine2 art //15 //machine2 art //15
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artMach2 = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artMach2 = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artMach2 = NULL; spec->artMach2 = NULL;
//machine3 art //16 //machine3 art //16
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artMach3 = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artMach3 = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artMach3 = NULL; spec->artMach3 = NULL;
//misc5 art //17 //misc5 art //17
id = readNormalNr(i, 2); i+=2; if(map.version>=SoD)
if(id!=0xffff) {
id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=artmask)
spec->artMisc5 = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artMisc5 = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artMisc5 = NULL; spec->artMisc5 = NULL;
}
//spellbook //spellbook
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=artidlen;
if(id!=0xffff) if(id!=artmask)
spec->artSpellBook = &(CGameInfo::mainObj->arth->artifacts[id]); spec->artSpellBook = &(CGameInfo::mainObj->arth->artifacts[id]);
else else
spec->artSpellBook = NULL; spec->artSpellBook = NULL;
//19 //???what is that? gap in file or what? //19 //???what is that? gap in file or what?
if(map.version>RoE)
i+=2; i+=2;
else
i+=1;
//bag artifacts //20 //bag artifacts //20
int amount = readNormalNr(i, 2); i+=2; //number of artifacts in hero's bag int amount = readNormalNr(i, 2); i+=2; //number of artifacts in hero's bag
if(amount>0) if(amount>0)
{ {
for(int ss=0; ss<amount; ++ss) for(int ss=0; ss<amount; ++ss)
{ {
id = readNormalNr(i, 2); i+=2; id = readNormalNr(i, artidlen); i+=2;
if(id!=0xffff) if(id!=artmask)
spec->artifacts.push_back(&(CGameInfo::mainObj->arth->artifacts[id])); spec->artifacts.push_back(&(CGameInfo::mainObj->arth->artifacts[id]));
else else
spec->artifacts.push_back(NULL); spec->artifacts.push_back(NULL);
@ -800,6 +819,8 @@ void CAmbarCendamo::deh3m()
spec->isGuarding = false; spec->isGuarding = false;
else else
spec->isGuarding = true; spec->isGuarding = true;
if(map.version>RoE)
{
bool hasBiography = bufor[i]; ++i; //true if hero has nonstandard (mapmaker defined) biography bool hasBiography = bufor[i]; ++i; //true if hero has nonstandard (mapmaker defined) biography
if(hasBiography) if(hasBiography)
{ {
@ -812,7 +833,10 @@ void CAmbarCendamo::deh3m()
} }
} }
spec->sex = !(bufor[i]); ++i; spec->sex = !(bufor[i]); ++i;
}
//spells //spells
if(map.version>RoE)
{
bool areSpells = bufor[i]; ++i; bool areSpells = bufor[i]; ++i;
if(areSpells) //TODO: sprawdziæ //seems to be ok - tow if(areSpells) //TODO: sprawdziæ //seems to be ok - tow
@ -831,15 +855,19 @@ void CAmbarCendamo::deh3m()
} }
} }
} }
}
//spells loaded //spells loaded
spec->defaultMianStats = bufor[i]; ++i; if(map.version>RoE)
if(spec->defaultMianStats) {
spec->defaultMainStats = bufor[i]; ++i;
if(spec->defaultMainStats)
{ {
spec->attack = bufor[i]; ++i; spec->attack = bufor[i]; ++i;
spec->defence = bufor[i]; ++i; spec->defence = bufor[i]; ++i;
spec->power = bufor[i]; ++i; spec->power = bufor[i]; ++i;
spec->knowledge = bufor[i]; ++i; spec->knowledge = bufor[i]; ++i;
} }
}
i+=16; i+=16;
nobj->info = spec; nobj->info = spec;
//////creating CHeroInstance //////creating CHeroInstance
@ -859,10 +887,13 @@ void CAmbarCendamo::deh3m()
case CREATURES_DEF: case CREATURES_DEF:
{ {
CCreatureObjInfo * spec = new CCreatureObjInfo; CCreatureObjInfo * spec = new CCreatureObjInfo;
if(map.version>RoE)
{
spec->bytes[0] = bufor[i]; ++i; spec->bytes[0] = bufor[i]; ++i;
spec->bytes[1] = bufor[i]; ++i; spec->bytes[1] = bufor[i]; ++i;
spec->bytes[2] = bufor[i]; ++i; spec->bytes[2] = bufor[i]; ++i;
spec->bytes[3] = bufor[i]; ++i; spec->bytes[3] = bufor[i]; ++i;
}
spec->number = readNormalNr(i, 2); i+=2; spec->number = readNormalNr(i, 2); i+=2;
spec->character = bufor[i]; ++i; spec->character = bufor[i]; ++i;
bool isMesTre = bufor[i]; ++i; //true if there is message or treasury bool isMesTre = bufor[i]; ++i; //true if there is message or treasury
@ -883,12 +914,22 @@ void CAmbarCendamo::deh3m()
spec->crytal = readNormalNr(i); i+=4; spec->crytal = readNormalNr(i); i+=4;
spec->gems = readNormalNr(i); i+=4; spec->gems = readNormalNr(i); i+=4;
spec->gold = readNormalNr(i); i+=4; spec->gold = readNormalNr(i); i+=4;
int artID = readNormalNr(i, 2); i+=2; int artID = readNormalNr(i, (map.version == RoE ? 1 : 2)); i+=(map.version == RoE ? 1 : 2);
if(map.version==RoE)
{
if(artID!=0xff)
spec->gainedArtifact = &(CGameInfo::mainObj->arth->artifacts[artID]);
else
spec->gainedArtifact = NULL;
}
else
{
if(artID!=0xffff) if(artID!=0xffff)
spec->gainedArtifact = &(CGameInfo::mainObj->arth->artifacts[artID]); spec->gainedArtifact = &(CGameInfo::mainObj->arth->artifacts[artID]);
else else
spec->gainedArtifact = NULL; spec->gainedArtifact = NULL;
} }
}
spec->neverFlees = bufor[i]; ++i; spec->neverFlees = bufor[i]; ++i;
spec->notGrowingTeam = bufor[i]; ++i; spec->notGrowingTeam = bufor[i]; ++i;
i+=2; i+=2;
@ -910,6 +951,8 @@ void CAmbarCendamo::deh3m()
case EDefType::SEERHUT_DEF: case EDefType::SEERHUT_DEF:
{ {
CSeerHutObjInfo * spec = new CSeerHutObjInfo; CSeerHutObjInfo * spec = new CSeerHutObjInfo;
if(map.version>RoE)
{
spec->missionType = bufor[i]; ++i; spec->missionType = bufor[i]; ++i;
switch(spec->missionType) switch(spec->missionType)
{ {
@ -1107,6 +1150,12 @@ void CAmbarCendamo::deh3m()
{ {
spec->completedText += bufor[i]; ++i; spec->completedText += bufor[i]; ++i;
} }
}
else //RoE
{
int artID = bufor[i]; ++i;
spec->m5arts.push_back(&(CGameInfo::mainObj->arth->artifacts[artID]));
}
unsigned char rewardType = bufor[i]; ++i; unsigned char rewardType = bufor[i]; ++i;
spec->rewardType = rewardType; spec->rewardType = rewardType;
@ -1155,7 +1204,7 @@ void CAmbarCendamo::deh3m()
} }
case 8: case 8:
{ {
int artid = readNormalNr(i, 2); i+=2; int artid = readNormalNr(i, (map.version == RoE ? 1 : 2)); i+=(map.version == RoE ? 1 : 2);
spec->r8art = &(CGameInfo::mainObj->arth->artifacts[artid]); spec->r8art = &(CGameInfo::mainObj->arth->artifacts[artid]);
break; break;
} }
@ -1225,8 +1274,13 @@ void CAmbarCendamo::deh3m()
CGarrisonObjInfo * spec = new CGarrisonObjInfo; CGarrisonObjInfo * spec = new CGarrisonObjInfo;
spec->player = bufor[i]; ++i; spec->player = bufor[i]; ++i;
i+=3; i+=3;
spec->units = readCreatureSet(i); i+=28; spec->units = readCreatureSet(i); i+= (map.version==RoE ? 21 : 28);
if(map.version > RoE)
{
spec->movableUnits = bufor[i]; ++i; spec->movableUnits = bufor[i]; ++i;
}
else
spec->movableUnits = true;
i+=8; i+=8;
nobj->info = spec; nobj->info = spec;
break; break;
@ -1246,7 +1300,7 @@ void CAmbarCendamo::deh3m()
if(areGuards) if(areGuards)
{ {
spec->areGuards = true; spec->areGuards = true;
spec->guards = readCreatureSet(i); i+=28; spec->guards = readCreatureSet(i); i+= (map.version == RoE ? 21 : 28) ;
} }
else else
spec->areGuards = false; spec->areGuards = false;
@ -1269,7 +1323,7 @@ void CAmbarCendamo::deh3m()
spec->areGuards = bufor[i]; ++i; spec->areGuards = bufor[i]; ++i;
if(spec->areGuards) if(spec->areGuards)
{ {
spec->guards = readCreatureSet(i); i+=28; spec->guards = readCreatureSet(i); i+= (map.version == RoE ? 21 : 28);
} }
i+=4; i+=4;
} }
@ -1313,7 +1367,7 @@ void CAmbarCendamo::deh3m()
bool stGarr = bufor[i]; ++i; //true if garrison isn't empty bool stGarr = bufor[i]; ++i; //true if garrison isn't empty
if(stGarr) if(stGarr)
{ {
spec->garrison = readCreatureSet(i); i+=28; spec->garrison = readCreatureSet(i); i+=( map.version > RoE ? 28 : 21 );
} }
spec->garrison.formation = bufor[i]; ++i; spec->garrison.formation = bufor[i]; ++i;
spec->unusualBuildins = bufor[i]; ++i; spec->unusualBuildins = bufor[i]; ++i;
@ -1330,6 +1384,8 @@ void CAmbarCendamo::deh3m()
} }
int ist = i; int ist = i;
if(map.version>RoE)
{
for(i; i<ist+9; ++i) for(i; i<ist+9; ++i)
{ {
unsigned char c = bufor[i]; unsigned char c = bufor[i];
@ -1342,6 +1398,7 @@ void CAmbarCendamo::deh3m()
} }
} }
} }
}
ist = i; ist = i;
for(i; i<ist+9; ++i) for(i; i<ist+9; ++i)
@ -1385,7 +1442,12 @@ void CAmbarCendamo::deh3m()
nce.gold = readNormalNr(i); i+=4; nce.gold = readNormalNr(i); i+=4;
nce.players = bufor[i]; ++i; nce.players = bufor[i]; ++i;
if(map.version > RoE)
{
nce.forHuman = bufor[i]; ++i; nce.forHuman = bufor[i]; ++i;
}
else
nce.forHuman = true;
nce.forComputer = bufor[i]; ++i; nce.forComputer = bufor[i]; ++i;
nce.firstShow = readNormalNr(i, 2); i+=2; nce.firstShow = readNormalNr(i, 2); i+=2;
nce.forEvery = bufor[i]; ++i; nce.forEvery = bufor[i]; ++i;
@ -1407,7 +1469,12 @@ void CAmbarCendamo::deh3m()
/////// castle events have been read /////////////////////////// /////// castle events have been read ///////////////////////////
if(map.version > RoE)
{
spec->alignment = bufor[i]; ++i; spec->alignment = bufor[i]; ++i;
}
else
spec->alignment = 0xff;
i+=3; i+=3;
nobj->info = spec; nobj->info = spec;
break; break;
@ -1441,7 +1508,7 @@ void CAmbarCendamo::deh3m()
spec->areGuarders = bufor[i]; ++i; spec->areGuarders = bufor[i]; ++i;
if(spec->areGuarders) if(spec->areGuarders)
{ {
spec->guarders = readCreatureSet(i); i+=28; spec->guarders = readCreatureSet(i); i+=( map.version == RoE ? 21 : 28 );
} }
i+=4; i+=4;
} }
@ -1464,7 +1531,7 @@ void CAmbarCendamo::deh3m()
spec->areGuarders = bufor[i]; ++i; spec->areGuarders = bufor[i]; ++i;
if(spec->areGuarders) if(spec->areGuarders)
{ {
spec->guarders = readCreatureSet(i); i+=28; spec->guarders = readCreatureSet(i); i+= (map.version == RoE ? 21 : 28);
} }
i+=4; i+=4;
} }
@ -1949,6 +2016,8 @@ EDefType CAmbarCendamo::getDefType(DefInfo &a)
CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number) CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
{ {
if(map.version>RoE)
{
CCreatureSet ret; CCreatureSet ret;
std::pair<CCreature *, int> ins; std::pair<CCreature *, int> ins;
if(number>0 && readNormalNr(pos, 2)!=0xffff) if(number>0 && readNormalNr(pos, 2)!=0xffff)
@ -2022,6 +2091,83 @@ CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
ret.slots.insert(tt); ret.slots.insert(tt);
} }
return ret; return ret;
}
else
{
CCreatureSet ret;
std::pair<CCreature *, int> ins;
if(number>0 && readNormalNr(pos, 1)!=0xff)
{
int rettt = readNormalNr(pos, 1);
if(rettt>220)
rettt = 256-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
ins.second = readNormalNr(pos+1, 2);
std::pair<int,std::pair<CCreature *, int> > tt(0,ins);
ret.slots.insert(tt);
}
if(number>1 && readNormalNr(pos+3, 1)!=0xff)
{
int rettt = readNormalNr(pos+3, 1);
if(rettt>220)
rettt = 256-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
ins.second = readNormalNr(pos+4, 2);
std::pair<int,std::pair<CCreature *, int> > tt(1,ins);
ret.slots.insert(tt);
}
if(number>2 && readNormalNr(pos+6, 1)!=0xff)
{
int rettt = readNormalNr(pos+6, 1);
if(rettt>220)
rettt = 256-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
ins.second = readNormalNr(pos+7, 2);
std::pair<int,std::pair<CCreature *, int> > tt(2,ins);
ret.slots.insert(tt);
}
if(number>3 && readNormalNr(pos+9, 1)!=0xff)
{
int rettt = readNormalNr(pos+9, 1);
if(rettt>220)
rettt = 256-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
ins.second = readNormalNr(pos+10, 2);
std::pair<int,std::pair<CCreature *, int> > tt(3,ins);
ret.slots.insert(tt);
}
if(number>4 && readNormalNr(pos+12, 1)!=0xff)
{
int rettt = readNormalNr(pos+12, 1);
if(rettt>220)
rettt = 256-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
ins.second = readNormalNr(pos+13, 2);
std::pair<int,std::pair<CCreature *, int> > tt(4,ins);
ret.slots.insert(tt);
}
if(number>5 && readNormalNr(pos+15, 1)!=0xff)
{
int rettt = readNormalNr(pos+15, 1);
if(rettt>220)
rettt = 256-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
ins.second = readNormalNr(pos+16, 2);
std::pair<int,std::pair<CCreature *, int> > tt(5,ins);
ret.slots.insert(tt);
}
if(number>6 && readNormalNr(pos+18, 1)!=0xff)
{
int rettt = readNormalNr(pos+18, 1);
if(rettt>220)
rettt = 256-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
ins.second = readNormalNr(pos+19, 2);
std::pair<int,std::pair<CCreature *, int> > tt(6,ins);
ret.slots.insert(tt);
}
return ret;
}
} }
void CAmbarCendamo::processMap(std::vector<std::string> & defsToUnpack) void CAmbarCendamo::processMap(std::vector<std::string> & defsToUnpack)

View File

@ -59,7 +59,7 @@ public:
unsigned int experience; //hero's experience points unsigned int experience; //hero's experience points
std::vector<CAbility *> abilities; //hero's abilities std::vector<CAbility *> abilities; //hero's abilities
std::vector<int> abilityLevels; //hero ability levels std::vector<int> abilityLevels; //hero ability levels
bool defaultMianStats; //if true attack, defence, power and knowledge are typical bool defaultMainStats; //if true attack, defence, power and knowledge are typical
}; };
class CCreatureObjInfo : public CSpecObjInfo class CCreatureObjInfo : public CSpecObjInfo