2007-09-02 15:36:54 +03:00
|
|
|
#include "stdafx.h"
|
2007-06-06 19:12:12 +03:00
|
|
|
#include "CAmbarCendamo.h"
|
|
|
|
#include "CSemiDefHandler.h"
|
2007-08-30 13:11:53 +03:00
|
|
|
#include "../CGameInfo.h"
|
2007-06-11 20:21:27 +03:00
|
|
|
#include "CObjectHandler.h"
|
2007-06-13 23:17:48 +03:00
|
|
|
#include "CCastleHandler.h"
|
2007-09-05 18:56:35 +03:00
|
|
|
#include "CTownHandler.h"
|
2007-08-29 15:18:31 +03:00
|
|
|
#include "CDefObjInfoHandler.h"
|
2007-08-30 13:11:53 +03:00
|
|
|
#include "../SDL_Extensions.h"
|
2007-07-07 14:09:25 +03:00
|
|
|
#include "boost\filesystem.hpp"
|
2007-09-14 16:11:10 +03:00
|
|
|
#include "../CGameState.h"
|
2007-08-29 15:18:31 +03:00
|
|
|
#include "CLodHandler.h"
|
2007-06-06 19:12:12 +03:00
|
|
|
#include <set>
|
2007-07-14 16:27:13 +03:00
|
|
|
#include <iomanip>
|
|
|
|
#include <sstream>
|
2007-10-27 22:38:48 +03:00
|
|
|
#include "../CLua.h"
|
2007-06-09 21:14:41 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
unsigned int intPow(unsigned int a, unsigned int b)
|
2007-06-09 21:14:41 +03:00
|
|
|
{
|
2007-06-09 23:23:44 +03:00
|
|
|
unsigned int ret=1;
|
2007-06-09 21:14:41 +03:00
|
|
|
for(int i=0; i<b; ++i)
|
|
|
|
ret*=a;
|
|
|
|
return ret;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
unsigned char reverse(unsigned char arg)
|
|
|
|
{
|
|
|
|
unsigned char ret = 0;
|
|
|
|
for (int i=0; i<8;i++)
|
|
|
|
{
|
|
|
|
if(((arg)&(1<<i))>>i)
|
|
|
|
{
|
|
|
|
ret |= (128>>i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2007-07-09 08:57:30 +03:00
|
|
|
CAmbarCendamo::CAmbarCendamo (unsigned char * map)
|
|
|
|
{
|
|
|
|
bufor=map;
|
|
|
|
}
|
2007-06-06 19:12:12 +03:00
|
|
|
CAmbarCendamo::CAmbarCendamo (const char * tie)
|
|
|
|
{
|
|
|
|
is = new std::ifstream();
|
|
|
|
is -> open(tie,std::ios::binary);
|
|
|
|
is->seekg(0,std::ios::end); // na koniec
|
|
|
|
andame = is->tellg(); // read length
|
|
|
|
is->seekg(0,std::ios::beg); // wracamy na poczatek
|
|
|
|
bufor = new unsigned char[andame]; // allocate memory
|
|
|
|
is->read((char*)bufor, andame); // read map file to buffer
|
2007-06-22 16:50:16 +03:00
|
|
|
is->close();
|
2007-06-08 17:58:04 +03:00
|
|
|
delete is;
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
|
|
|
CAmbarCendamo::~CAmbarCendamo ()
|
|
|
|
{// free memory
|
|
|
|
for (int ii=0;ii<map.width;ii++)
|
|
|
|
delete map.terrain[ii] ;
|
|
|
|
delete map.terrain;
|
|
|
|
delete bufor;
|
|
|
|
}
|
|
|
|
void CAmbarCendamo::teceDef()
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
//for (int i=0; i<map.defy.size(); i++)
|
|
|
|
//{
|
|
|
|
// std::ofstream * of = new std::ofstream(map.defy[i].name.c_str());
|
|
|
|
// for (int j=0;j<46;j++)
|
|
|
|
// {
|
|
|
|
// (*of) << map.defy[i].bytes[j]<<std::endl;
|
|
|
|
// }
|
|
|
|
// of->close();
|
|
|
|
// delete of;
|
|
|
|
//}
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
|
|
|
void CAmbarCendamo::deh3m()
|
|
|
|
{
|
2007-06-07 16:43:30 +03:00
|
|
|
THC timeHandler th;
|
2007-06-06 19:12:12 +03:00
|
|
|
map.version = (Eformat)bufor[0]; //wersja mapy
|
2007-06-22 16:50:16 +03:00
|
|
|
map.areAnyPLayers = bufor[4]; //invalid on some maps
|
2007-06-06 19:12:12 +03:00
|
|
|
map.height = map.width = bufor[5]; // wymiary mapy
|
|
|
|
map.twoLevel = bufor[9]; //czy sa lochy
|
|
|
|
map.terrain = new TerrainTile*[map.width]; // allocate memory
|
|
|
|
for (int ii=0;ii<map.width;ii++)
|
|
|
|
map.terrain[ii] = new TerrainTile[map.height]; // allocate memory
|
|
|
|
if (map.twoLevel)
|
|
|
|
{
|
|
|
|
map.undergroungTerrain = new TerrainTile*[map.width]; // allocate memory
|
|
|
|
for (int ii=0;ii<map.width;ii++)
|
|
|
|
map.undergroungTerrain[ii] = new TerrainTile[map.height]; // allocate memory
|
|
|
|
}
|
|
|
|
int length = bufor[10]; //name length
|
|
|
|
int i=14, pom;
|
|
|
|
while (i-14<length) //read name
|
|
|
|
map.name+=bufor[i++];
|
|
|
|
length = bufor[i] + bufor[i+1]*256; //description length
|
|
|
|
i+=4;
|
|
|
|
for (pom=0;pom<length;pom++)
|
|
|
|
map.description+=bufor[i++];
|
|
|
|
map.difficulty = bufor[i++]; // reading map difficulty
|
2007-08-23 20:38:00 +03:00
|
|
|
if(map.version != Eformat::RoE)
|
|
|
|
{
|
|
|
|
map.levelLimit = bufor[i++]; // hero level limit
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
map.levelLimit = 0;
|
|
|
|
}
|
2007-06-06 19:12:12 +03:00
|
|
|
for (pom=0;pom<8;pom++)
|
|
|
|
{
|
|
|
|
map.players[pom].canHumanPlay = bufor[i++];
|
|
|
|
map.players[pom].canComputerPlay = bufor[i++];
|
2007-06-22 16:50:16 +03:00
|
|
|
if ((!(map.players[pom].canHumanPlay || map.players[pom].canComputerPlay)))
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
switch(map.version)
|
|
|
|
{
|
|
|
|
case Eformat::SoD: case Eformat::WoG:
|
|
|
|
i+=13;
|
|
|
|
break;
|
|
|
|
case Eformat::AB:
|
|
|
|
i+=12;
|
|
|
|
break;
|
|
|
|
case Eformat::RoE:
|
|
|
|
i+=6;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-06 19:12:12 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
map.players[pom].AITactic = bufor[i++];
|
2007-08-23 20:38:00 +03:00
|
|
|
|
|
|
|
if(map.version == Eformat::SoD || map.version == Eformat::WoG)
|
|
|
|
i++;
|
|
|
|
|
|
|
|
map.players[pom].allowedFactions = 0;
|
|
|
|
map.players[pom].allowedFactions += bufor[i++];
|
|
|
|
if(map.version != Eformat::RoE)
|
2007-06-06 19:12:12 +03:00
|
|
|
map.players[pom].allowedFactions += (bufor[i++])*256;
|
2007-08-23 20:38:00 +03:00
|
|
|
|
2007-06-06 19:12:12 +03:00
|
|
|
map.players[pom].isFactionRandom = bufor[i++];
|
2007-06-07 04:46:25 +03:00
|
|
|
map.players[pom].hasMainTown = bufor[i++];
|
|
|
|
if (map.players[pom].hasMainTown)
|
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
if(map.version != Eformat::RoE)
|
|
|
|
{
|
|
|
|
map.players[pom].generateHeroAtMainTown = bufor[i++];
|
|
|
|
map.players[pom].generateHero = bufor[i++];
|
|
|
|
}
|
2007-06-07 04:46:25 +03:00
|
|
|
map.players[pom].posOfMainTown.x = bufor[i++];
|
|
|
|
map.players[pom].posOfMainTown.y = bufor[i++];
|
|
|
|
map.players[pom].posOfMainTown.z = bufor[i++];
|
2007-08-23 20:38:00 +03:00
|
|
|
|
|
|
|
|
2007-06-07 04:46:25 +03:00
|
|
|
}
|
2007-08-27 17:15:03 +03:00
|
|
|
map.players[pom].p8= bufor[i++];
|
|
|
|
map.players[pom].p9= bufor[i++];
|
|
|
|
if(map.players[pom].p9!=0xff)
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
map.players[pom].mainHeroPortrait = bufor[i++];
|
|
|
|
int nameLength = bufor[i++];
|
|
|
|
i+=3;
|
|
|
|
for (int pp=0;pp<nameLength;pp++)
|
|
|
|
map.players[pom].mainHeroName+=bufor[i++];
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
2007-08-23 20:38:00 +03:00
|
|
|
|
|
|
|
if(map.version != Eformat::RoE)
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
i++; ////unknown byte
|
|
|
|
int heroCount = bufor[i++];
|
2007-06-06 19:12:12 +03:00
|
|
|
i+=3;
|
2007-08-23 20:38:00 +03:00
|
|
|
for (int pp=0;pp<heroCount;pp++)
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
SheroName vv;
|
|
|
|
vv.heroID=bufor[i++];
|
|
|
|
int hnl = bufor[i++];
|
|
|
|
i+=3;
|
|
|
|
for (int zz=0;zz<hnl;zz++)
|
|
|
|
{
|
|
|
|
vv.heroName+=bufor[i++];
|
|
|
|
}
|
|
|
|
map.players[pom].heroesNames.push_back(vv);
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
map.victoryCondition = (EvictoryConditions)bufor[i++];
|
|
|
|
if (map.victoryCondition != winStandard) //specific victory conditions
|
|
|
|
{
|
|
|
|
int nr;
|
|
|
|
switch (map.victoryCondition) //read victory conditions
|
|
|
|
{
|
|
|
|
case artifact:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new VicCon0();
|
|
|
|
((VicCon0*)map.vicConDetails)->ArtifactID = bufor[i+2];
|
2007-08-24 18:00:13 +03:00
|
|
|
nr=(map.version==RoE ? 1 : 2);
|
2007-06-06 19:12:12 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case gatherTroop:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new VicCon1();
|
|
|
|
int temp1 = bufor[i+2];
|
|
|
|
int temp2 = bufor[i+3];
|
|
|
|
((VicCon1*)map.vicConDetails)->monsterID = bufor[i+2];
|
2007-08-24 18:00:13 +03:00
|
|
|
((VicCon1*)map.vicConDetails)->neededQuantity=readNormalNr(i+(map.version==RoE ? 3 : 4));
|
|
|
|
nr=(map.version==RoE ? 5 : 6);
|
2007-06-06 19:12:12 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case gatherResource:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new VicCon2();
|
|
|
|
((VicCon2*)map.vicConDetails)->resourceID = bufor[i+2];
|
|
|
|
((VicCon2*)map.vicConDetails)->neededQuantity=readNormalNr(i+3);
|
|
|
|
nr=5;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case buildCity:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new VicCon3();
|
|
|
|
((VicCon3*)map.vicConDetails)->posOfCity.x = bufor[i+2];
|
|
|
|
((VicCon3*)map.vicConDetails)->posOfCity.y = bufor[i+3];
|
|
|
|
((VicCon3*)map.vicConDetails)->posOfCity.z = bufor[i+4];
|
|
|
|
((VicCon3*)map.vicConDetails)->councilNeededLevel = bufor[i+5];
|
|
|
|
((VicCon3*)map.vicConDetails)->fortNeededLevel = bufor[i+6];
|
|
|
|
nr=5;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case buildGrail:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new VicCon4();
|
|
|
|
if (bufor[i+4]>2)
|
|
|
|
((VicCon4*)map.vicConDetails)->anyLocation = true;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
((VicCon4*)map.vicConDetails)->whereBuildGrail.x = bufor[i+2];
|
|
|
|
((VicCon4*)map.vicConDetails)->whereBuildGrail.y = bufor[i+3];
|
|
|
|
((VicCon4*)map.vicConDetails)->whereBuildGrail.z = bufor[i+4];
|
|
|
|
}
|
|
|
|
nr=3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case beatHero:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new VicCon5();
|
|
|
|
((VicCon5*)map.vicConDetails)->locationOfHero.x = bufor[i+2];
|
|
|
|
((VicCon5*)map.vicConDetails)->locationOfHero.y = bufor[i+3];
|
|
|
|
((VicCon5*)map.vicConDetails)->locationOfHero.z = bufor[i+4];
|
|
|
|
nr=3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case captureCity:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new VicCon6();
|
|
|
|
((VicCon6*)map.vicConDetails)->locationOfTown.x = bufor[i+2];
|
|
|
|
((VicCon6*)map.vicConDetails)->locationOfTown.y = bufor[i+3];
|
|
|
|
((VicCon6*)map.vicConDetails)->locationOfTown.z = bufor[i+4];
|
|
|
|
nr=3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case beatMonster:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new VicCon7();
|
|
|
|
((VicCon7*)map.vicConDetails)->locationOfMonster.x = bufor[i+2];
|
|
|
|
((VicCon7*)map.vicConDetails)->locationOfMonster.y = bufor[i+3];
|
|
|
|
((VicCon7*)map.vicConDetails)->locationOfMonster.z = bufor[i+4];
|
|
|
|
nr=3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case takeDwellings:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new CspecificVictoryConidtions();
|
2007-08-23 20:38:00 +03:00
|
|
|
nr=0;
|
2007-06-06 19:12:12 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case takeMines:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new CspecificVictoryConidtions();
|
2007-08-23 20:38:00 +03:00
|
|
|
nr=0;
|
2007-06-06 19:12:12 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case transportItem:
|
|
|
|
{
|
|
|
|
map.vicConDetails = new VicCona();
|
|
|
|
((VicCona*)map.vicConDetails)->artifactID = bufor[i+2];
|
|
|
|
((VicCona*)map.vicConDetails)->destinationPlace.x = bufor[i+3];
|
|
|
|
((VicCona*)map.vicConDetails)->destinationPlace.y = bufor[i+4];
|
|
|
|
((VicCona*)map.vicConDetails)->destinationPlace.z = bufor[i+5];
|
|
|
|
nr=3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
map.vicConDetails->allowNormalVictory = bufor[i++];
|
|
|
|
map.vicConDetails->appliesToAI = bufor[i++];
|
|
|
|
i+=nr;
|
|
|
|
}
|
|
|
|
map.lossCondition.typeOfLossCon = (ElossCon)bufor[i++];
|
|
|
|
switch (map.lossCondition.typeOfLossCon) //read loss conditions
|
|
|
|
{
|
|
|
|
case lossCastle:
|
|
|
|
{
|
|
|
|
map.lossCondition.castlePos.x=bufor[i++];
|
|
|
|
map.lossCondition.castlePos.y=bufor[i++];
|
|
|
|
map.lossCondition.castlePos.z=bufor[i++];
|
2007-07-10 05:46:38 +03:00
|
|
|
break;
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
|
|
|
case lossHero:
|
|
|
|
{
|
|
|
|
map.lossCondition.heroPos.x=bufor[i++];
|
|
|
|
map.lossCondition.heroPos.y=bufor[i++];
|
|
|
|
map.lossCondition.heroPos.z=bufor[i++];
|
2007-07-10 05:46:38 +03:00
|
|
|
break;
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
|
|
|
case timeExpires:
|
|
|
|
{
|
|
|
|
map.lossCondition.timeLimit = readNormalNr(i++,2);
|
2007-06-07 20:45:56 +03:00
|
|
|
i++;
|
2007-07-10 05:46:38 +03:00
|
|
|
break;
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
|
|
|
}
|
2007-06-07 20:45:56 +03:00
|
|
|
map.howManyTeams=bufor[i++]; //read number of teams
|
|
|
|
if(map.howManyTeams>0) //read team numbers
|
|
|
|
{
|
|
|
|
for(int rr=0; rr<8; ++rr)
|
|
|
|
{
|
|
|
|
map.players[rr].team=bufor[i++];
|
|
|
|
}
|
|
|
|
}
|
2007-06-09 21:14:41 +03:00
|
|
|
//reading allowed heroes (20 bytes)
|
2007-08-23 20:38:00 +03:00
|
|
|
int ist;
|
|
|
|
|
|
|
|
ist=i; //starting i for loop
|
|
|
|
for(i; i<ist+ (map.version == Eformat::RoE ? 16 : 20) ; ++i)
|
2007-06-09 21:14:41 +03:00
|
|
|
{
|
|
|
|
unsigned char c = bufor[i];
|
2007-06-09 23:42:53 +03:00
|
|
|
for(int yy=0; yy<8; ++yy)
|
2007-06-09 21:14:41 +03:00
|
|
|
{
|
|
|
|
if((i-ist)*8+yy < CGameInfo::mainObj->heroh->heroes.size())
|
|
|
|
{
|
2007-06-09 23:42:53 +03:00
|
|
|
if(c == (c|((unsigned char)intPow(2, yy))))
|
2007-07-16 13:03:54 +03:00
|
|
|
CGameInfo::mainObj->heroh->heroes[(i-ist)*8+yy]->isAllowed = true;
|
2007-06-09 21:14:41 +03:00
|
|
|
else
|
2007-07-16 13:03:54 +03:00
|
|
|
CGameInfo::mainObj->heroh->heroes[(i-ist)*8+yy]->isAllowed = false;
|
2007-06-09 21:14:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
2007-08-25 20:51:32 +03:00
|
|
|
i+=4;
|
|
|
|
unsigned char disp = 0;
|
|
|
|
if(map.version>=SoD)
|
2007-08-23 20:38:00 +03:00
|
|
|
{
|
2007-08-25 20:51:32 +03:00
|
|
|
disp = bufor[i++];
|
|
|
|
for(int g=0; g<disp; ++g)
|
|
|
|
{
|
|
|
|
i+=2;
|
|
|
|
int lenbuf = readNormalNr(i); i+=4;
|
|
|
|
i+=lenbuf+1;
|
|
|
|
}
|
2007-08-23 20:38:00 +03:00
|
|
|
}
|
2007-08-25 20:51:32 +03:00
|
|
|
//allowed heroes have been read
|
|
|
|
unsigned char aaa1=bufor[i], aaa2=bufor[i+1], aaa3=bufor[i+2];
|
|
|
|
i+=31; //omitting 0s
|
2007-06-09 23:23:44 +03:00
|
|
|
//reading allowed artifacts //18 bytes
|
2007-08-23 20:38:00 +03:00
|
|
|
if(map.version!=RoE)
|
2007-06-09 23:23:44 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
ist=i; //starting i for loop
|
|
|
|
for(i; i<ist+18; ++i)
|
2007-06-09 23:23:44 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
unsigned char c = bufor[i];
|
|
|
|
for(int yy=0; yy<8; ++yy)
|
2007-06-09 23:23:44 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
if((i-ist)*8+yy < CGameInfo::mainObj->arth->artifacts.size())
|
|
|
|
{
|
|
|
|
if(c != (c|((unsigned char)intPow(2, yy))))
|
|
|
|
CGameInfo::mainObj->arth->artifacts[(i-ist)*8+yy].isAllowed = true;
|
|
|
|
else
|
|
|
|
CGameInfo::mainObj->arth->artifacts[(i-ist)*8+yy].isAllowed = false;
|
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
}
|
2007-08-23 20:38:00 +03:00
|
|
|
}//allowed artifacts have been read
|
|
|
|
}
|
2007-07-10 05:46:38 +03:00
|
|
|
|
2007-06-09 23:23:44 +03:00
|
|
|
//reading allowed spells (9 bytes)
|
2007-08-23 20:38:00 +03:00
|
|
|
if(map.version>=SoD)
|
2007-06-09 23:23:44 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
ist=i; //starting i for loop
|
|
|
|
for(i; i<ist+9; ++i)
|
2007-06-09 23:23:44 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
unsigned char c = bufor[i];
|
|
|
|
for(int yy=0; yy<8; ++yy)
|
2007-06-09 23:23:44 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
if((i-ist)*8+yy < CGameInfo::mainObj->spellh->spells.size())
|
|
|
|
{
|
|
|
|
if(c != (c|((unsigned char)intPow(2, yy))))
|
|
|
|
CGameInfo::mainObj->spellh->spells[(i-ist)*8+yy].isAllowed = true;
|
|
|
|
else
|
|
|
|
CGameInfo::mainObj->spellh->spells[(i-ist)*8+yy].isAllowed = false;
|
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
}
|
|
|
|
}
|
2007-08-23 20:38:00 +03:00
|
|
|
//allowed spells have been read
|
|
|
|
//allowed hero's abilities (4 bytes)
|
|
|
|
ist=i; //starting i for loop
|
|
|
|
for(i; i<ist+4; ++i)
|
2007-06-09 23:23:44 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
unsigned char c = bufor[i];
|
|
|
|
for(int yy=0; yy<8; ++yy)
|
2007-06-09 23:23:44 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
if((i-ist)*8+yy < CGameInfo::mainObj->abilh->abilities.size())
|
|
|
|
{
|
|
|
|
if(c != (c|((unsigned char)intPow(2, yy))))
|
|
|
|
CGameInfo::mainObj->abilh->abilities[(i-ist)*8+yy]->isAllowed = true;
|
|
|
|
else
|
|
|
|
CGameInfo::mainObj->abilh->abilities[(i-ist)*8+yy]->isAllowed = false;
|
|
|
|
}
|
2007-06-09 23:23:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//allowed hero's abilities have been read
|
|
|
|
|
2007-07-09 14:40:39 +03:00
|
|
|
THC std::cout<<"Reading header: "<<th.getDif()<<std::endl;
|
2007-06-06 19:12:12 +03:00
|
|
|
int rumNr = readNormalNr(i,4);i+=4;
|
|
|
|
for (int it=0;it<rumNr;it++)
|
|
|
|
{
|
|
|
|
Rumor ourRumor;
|
|
|
|
int nameL = readNormalNr(i,4);i+=4; //read length of name of rumor
|
|
|
|
for (int zz=0; zz<nameL; zz++)
|
|
|
|
ourRumor.name+=bufor[i++];
|
|
|
|
nameL = readNormalNr(i,4);i+=4; //read length of rumor
|
|
|
|
for (int zz=0; zz<nameL; zz++)
|
|
|
|
ourRumor.text+=bufor[i++];
|
|
|
|
map.rumors.push_back(ourRumor); //add to our list
|
|
|
|
}
|
2007-07-09 14:40:39 +03:00
|
|
|
THC std::cout<<"Reading rumors: "<<th.getDif()<<std::endl;
|
2007-08-23 20:38:00 +03:00
|
|
|
switch(map.version)
|
|
|
|
{
|
|
|
|
case WoG: case SoD: case AB:
|
2007-08-25 20:51:32 +03:00
|
|
|
if(bufor[i]=='\0') //omit 156 bytes of rubbish
|
|
|
|
{
|
|
|
|
i+=156;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else //omit a lot of rubbish in a strage way
|
|
|
|
{
|
|
|
|
int lastFFpos=i;
|
2007-08-26 19:02:36 +03:00
|
|
|
while(i-lastFFpos<200) //i far in terrain bytes
|
2007-08-25 20:51:32 +03:00
|
|
|
{
|
|
|
|
++i;
|
|
|
|
if(bufor[i]==0xff)
|
|
|
|
{
|
|
|
|
lastFFpos=i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i=lastFFpos;
|
|
|
|
|
|
|
|
while(bufor[i-1]!=0 || bufor[i]>8 || bufor[i+2]>4 || bufor[i+1]==0) //back to terrain bytes
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2007-08-23 20:38:00 +03:00
|
|
|
break;
|
|
|
|
case RoE:
|
|
|
|
i+=0;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-06 19:12:12 +03:00
|
|
|
for (int c=0; c<map.width; c++) // reading terrain
|
|
|
|
{
|
|
|
|
for (int z=0; z<map.height; z++)
|
|
|
|
{
|
|
|
|
map.terrain[z][c].tertype = (EterrainType)(bufor[i++]);
|
|
|
|
map.terrain[z][c].terview = bufor[i++];
|
|
|
|
map.terrain[z][c].nuine = (Eriver)bufor[i++];
|
|
|
|
map.terrain[z][c].rivDir = bufor[i++];
|
|
|
|
map.terrain[z][c].malle = (Eroad)bufor[i++];
|
|
|
|
map.terrain[z][c].roadDir = bufor[i++];
|
|
|
|
map.terrain[z][c].siodmyTajemniczyBajt = bufor[i++];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (map.twoLevel) // read underground terrain
|
|
|
|
{
|
2007-06-09 05:32:43 +03:00
|
|
|
for (int c=0; c<map.width; c++) // reading terrain
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-06-09 05:32:43 +03:00
|
|
|
for (int z=0; z<map.height; z++)
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
|
|
|
map.undergroungTerrain[z][c].tertype = (EterrainType)(bufor[i++]);
|
|
|
|
map.undergroungTerrain[z][c].terview = bufor[i++];
|
|
|
|
map.undergroungTerrain[z][c].nuine = (Eriver)bufor[i++];
|
|
|
|
map.undergroungTerrain[z][c].rivDir = bufor[i++];
|
|
|
|
map.undergroungTerrain[z][c].malle = (Eroad)bufor[i++];
|
|
|
|
map.undergroungTerrain[z][c].roadDir = bufor[i++];
|
|
|
|
map.undergroungTerrain[z][c].siodmyTajemniczyBajt = bufor[i++];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-07-09 14:40:39 +03:00
|
|
|
THC std::cout<<"Reading terrain: "<<th.getDif()<<std::endl;
|
2007-06-06 19:12:12 +03:00
|
|
|
int defAmount = bufor[i]; // liczba defow
|
2007-06-11 20:21:27 +03:00
|
|
|
defAmount = readNormalNr(i);
|
2007-06-07 16:43:30 +03:00
|
|
|
i+=4;
|
2007-07-02 14:23:42 +03:00
|
|
|
|
|
|
|
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
|
|
|
int srmask = 0xff000000;
|
|
|
|
int sgmask = 0x00ff0000;
|
|
|
|
int sbmask = 0x0000ff00;
|
|
|
|
int samask = 0x000000ff;
|
|
|
|
#else
|
|
|
|
int srmask = 0x000000ff;
|
|
|
|
int sgmask = 0x0000ff00;
|
|
|
|
int sbmask = 0x00ff0000;
|
|
|
|
int samask = 0xff000000;
|
|
|
|
#endif
|
|
|
|
SDL_Surface * alphaTransSurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 12, 12, 32, srmask, sgmask, sbmask, samask);
|
2007-07-07 14:09:25 +03:00
|
|
|
std::vector<std::string> defsToUnpack;
|
2007-06-06 19:12:12 +03:00
|
|
|
for (int idd = 0 ; idd<defAmount; idd++) // reading defs
|
|
|
|
{
|
2007-06-07 16:43:30 +03:00
|
|
|
int nameLength = readNormalNr(i,4);i+=4;
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * vinya = new CGDefInfo(); // info about new def
|
2007-06-07 16:43:30 +03:00
|
|
|
for (int cd=0;cd<nameLength;cd++)
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
vinya->name += bufor[i++];
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
//for (int v=0; v<42; v++) // read info
|
|
|
|
//{
|
|
|
|
// vinya->bytes[v] = bufor[i++];
|
|
|
|
//}
|
2007-07-07 14:09:25 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
vinya->name);
|
2007-07-07 14:09:25 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
vinya->isOnDefList = false;
|
2007-07-07 14:09:25 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
//vinya->printPriority = pit->priority;
|
2007-10-27 22:38:48 +03:00
|
|
|
vinya->isOnDefList = true;
|
2007-07-07 14:09:25 +03:00
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
unsigned char bytes[12];
|
|
|
|
for (int v=0; v<12; v++) // read info
|
|
|
|
{
|
|
|
|
bytes[v] = bufor[i++];
|
|
|
|
}
|
|
|
|
vinya->terrainAllowed = readNormalNr(i,2);i+=2;
|
|
|
|
vinya->terrainMenu = readNormalNr(i,2);i+=2;
|
|
|
|
vinya->id = readNormalNr(i,4);i+=4;
|
|
|
|
vinya->subid = readNormalNr(i,4);i+=4;
|
|
|
|
vinya->type = bufor[i++];
|
|
|
|
vinya->printPriority = bufor[i++];
|
|
|
|
for (int zi=0; zi<6; zi++)
|
|
|
|
{
|
|
|
|
vinya->blockMap[zi] = reverse(bytes[zi]);
|
|
|
|
}
|
|
|
|
for (int zi=0; zi<6; zi++)
|
|
|
|
{
|
|
|
|
vinya->visitMap[zi] = reverse(bytes[6+zi]);
|
|
|
|
}
|
|
|
|
i+=16;
|
2007-06-06 19:12:12 +03:00
|
|
|
map.defy.push_back(vinya); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(vinya->name);
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
2007-07-09 14:40:39 +03:00
|
|
|
THC std::cout<<"Reading defs: "<<th.getDif()<<std::endl;
|
2007-06-11 20:21:27 +03:00
|
|
|
////loading objects
|
2007-06-15 23:11:52 +03:00
|
|
|
int howManyObjs = readNormalNr(i, 4); i+=4;
|
2007-06-17 19:59:14 +03:00
|
|
|
for(int ww=0; ww<howManyObjs; ++ww) //comment this line to turn loading objects off
|
2007-06-11 20:21:27 +03:00
|
|
|
{
|
2007-07-16 17:42:44 +03:00
|
|
|
//std::cout << "object nr "<<ww<<"\ti= "<<i<<std::endl;
|
2007-10-27 22:38:48 +03:00
|
|
|
CGObjectInstance * nobj = new CGObjectInstance(); //we will read this object
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->id = CGameInfo::mainObj->objh->objInstances.size();
|
|
|
|
nobj->pos.x = bufor[i++];
|
|
|
|
nobj->pos.y = bufor[i++];
|
|
|
|
nobj->pos.z = bufor[i++];
|
2007-10-27 22:38:48 +03:00
|
|
|
|
|
|
|
int tempd = readNormalNr(i, 4); i+=4;
|
|
|
|
nobj->defInfo = map.defy[tempd];
|
2007-10-28 19:56:16 +02:00
|
|
|
nobj->ID = nobj->defInfo->id;
|
|
|
|
nobj->subID = nobj->defInfo->subid;
|
2007-10-27 22:38:48 +03:00
|
|
|
//nobj->defInfo = readNormalNr(i, 4); i+=4;
|
|
|
|
//nobj->defObjInfoNumber = -1;
|
|
|
|
//nobj->isHero = false;
|
|
|
|
//nobj->moveDir = 0;
|
|
|
|
//nobj->isStanding = true;
|
2007-11-19 00:58:28 +02:00
|
|
|
//nobj->state->owner = 254; //a lot of objs will never have an owner
|
2007-07-10 05:46:38 +03:00
|
|
|
|
2007-07-12 21:04:02 +03:00
|
|
|
//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";
|
2007-07-10 05:46:38 +03:00
|
|
|
|
2007-06-12 23:09:23 +03:00
|
|
|
i+=5;
|
2007-06-17 19:59:14 +03:00
|
|
|
unsigned char buff [30];
|
|
|
|
for(int ccc=0; ccc<30; ++ccc)
|
|
|
|
{
|
|
|
|
buff[ccc] = bufor[i+ccc];
|
|
|
|
}
|
2007-10-27 22:38:48 +03:00
|
|
|
EDefType uu = getDefType(nobj->defInfo);
|
2007-10-28 19:56:16 +02:00
|
|
|
int j = nobj->defInfo->id;
|
2007-06-16 23:12:08 +03:00
|
|
|
int p = 99;
|
2007-10-27 22:38:48 +03:00
|
|
|
switch(uu)
|
2007-06-12 23:09:23 +03:00
|
|
|
{
|
2007-06-13 23:17:48 +03:00
|
|
|
case EDefType::EVENTOBJ_DEF: //for event - objects
|
2007-06-12 23:09:23 +03:00
|
|
|
{
|
2007-06-13 23:17:48 +03:00
|
|
|
CEventObjInfo * spec = new CEventObjInfo;
|
2007-06-12 23:09:23 +03:00
|
|
|
bool guardMess;
|
|
|
|
guardMess = bufor[i]; ++i;
|
|
|
|
if(guardMess)
|
|
|
|
{
|
|
|
|
int messLong = readNormalNr(i, 4); i+=4;
|
|
|
|
if(messLong>0)
|
|
|
|
{
|
2007-06-13 23:17:48 +03:00
|
|
|
spec->isMessage = true;
|
2007-06-12 23:09:23 +03:00
|
|
|
for(int yy=0; yy<messLong; ++yy)
|
|
|
|
{
|
2007-06-13 23:17:48 +03:00
|
|
|
spec->message +=bufor[i+yy];
|
2007-06-12 23:09:23 +03:00
|
|
|
}
|
|
|
|
i+=messLong;
|
|
|
|
}
|
2007-06-13 23:17:48 +03:00
|
|
|
spec->areGuarders = bufor[i]; ++i;
|
|
|
|
if(spec->areGuarders)
|
2007-06-12 23:09:23 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->guarders = readCreatureSet(i); i+=( map.version == RoE ? 21 : 28);
|
2007-06-12 23:09:23 +03:00
|
|
|
}
|
2007-06-17 19:59:14 +03:00
|
|
|
i+=4;
|
2007-06-12 23:09:23 +03:00
|
|
|
}
|
2007-06-13 23:17:48 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isMessage = false;
|
|
|
|
spec->areGuarders = false;
|
|
|
|
spec->message = std::string("");
|
|
|
|
}
|
|
|
|
spec->gainedExp = readNormalNr(i, 4); i+=4;
|
|
|
|
spec->manaDiff = readNormalNr(i, 4); i+=4;
|
|
|
|
spec->moraleDiff = readNormalNr(i, 1, true); ++i;
|
|
|
|
spec->luckDiff = readNormalNr(i, 1, true); ++i;
|
|
|
|
spec->wood = readNormalNr(i); i+=4;
|
|
|
|
spec->mercury = readNormalNr(i); i+=4;
|
|
|
|
spec->ore = readNormalNr(i); i+=4;
|
|
|
|
spec->sulfur = readNormalNr(i); i+=4;
|
|
|
|
spec->crystal = readNormalNr(i); i+=4;
|
|
|
|
spec->gems = readNormalNr(i); i+=4;
|
|
|
|
spec->gold = readNormalNr(i); i+=4;
|
|
|
|
spec->attack = readNormalNr(i, 1); ++i;
|
|
|
|
spec->defence = readNormalNr(i, 1); ++i;
|
|
|
|
spec->power = readNormalNr(i, 1); ++i;
|
|
|
|
spec->knowledge = readNormalNr(i, 1); ++i;
|
|
|
|
int gabn; //number of gained abilities
|
|
|
|
gabn = readNormalNr(i, 1); ++i;
|
|
|
|
for(int oo = 0; oo<gabn; ++oo)
|
|
|
|
{
|
2007-07-16 17:42:44 +03:00
|
|
|
spec->abilities.push_back((CGameInfo::mainObj->abilh)->abilities[readNormalNr(i, 1)]); ++i;
|
2007-06-13 23:17:48 +03:00
|
|
|
spec->abilityLevels.push_back(readNormalNr(i, 1)); ++i;
|
|
|
|
}
|
|
|
|
int gart = readNormalNr(i, 1); ++i; //number of gained artifacts
|
|
|
|
for(int oo = 0; oo<gart; ++oo)
|
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->artifacts.push_back(&(CGameInfo::mainObj->arth->artifacts[readNormalNr(i, (map.version == RoE ? 1 : 2))])); i+=(map.version == RoE ? 1 : 2);
|
2007-06-13 23:17:48 +03:00
|
|
|
}
|
|
|
|
int gspel = readNormalNr(i, 1); ++i; //number of gained spells
|
|
|
|
for(int oo = 0; oo<gspel; ++oo)
|
|
|
|
{
|
|
|
|
spec->spells.push_back(&(CGameInfo::mainObj->spellh->spells[readNormalNr(i, 1)])); ++i;
|
|
|
|
}
|
|
|
|
int gcre = readNormalNr(i, 1); ++i; //number of gained creatures
|
|
|
|
spec->creatures = readCreatureSet(i, gcre); i+=4*gcre;
|
|
|
|
i+=8;
|
|
|
|
spec->availableFor = readNormalNr(i, 1); ++i;
|
|
|
|
spec->computerActivate = readNormalNr(i, 1); ++i;
|
|
|
|
spec->humanActivate = readNormalNr(i, 1); ++i;
|
|
|
|
i+=4;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-13 23:17:48 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::HERO_DEF:
|
|
|
|
{
|
|
|
|
CHeroObjInfo * spec = new CHeroObjInfo;
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
|
|
|
{
|
|
|
|
spec->bytes[0] = bufor[i]; ++i;
|
|
|
|
spec->bytes[1] = bufor[i]; ++i;
|
|
|
|
spec->bytes[2] = bufor[i]; ++i;
|
|
|
|
spec->bytes[3] = bufor[i]; ++i;
|
|
|
|
}
|
2007-06-13 23:17:48 +03:00
|
|
|
spec->player = bufor[i]; ++i;
|
2007-07-31 16:09:34 +03:00
|
|
|
int typeBuf = readNormalNr(i, 1); ++i;
|
|
|
|
if(typeBuf==0xff)
|
|
|
|
spec->type = NULL;
|
|
|
|
else
|
|
|
|
spec->type = CGameInfo::mainObj->heroh->heroes[typeBuf];
|
2007-06-13 23:17:48 +03:00
|
|
|
bool isName = bufor[i]; ++i; //true if hero has nonstandard name
|
|
|
|
if(isName)
|
|
|
|
{
|
|
|
|
int length = readNormalNr(i, 4); i+=4;
|
|
|
|
for(int gg=0; gg<length; ++gg)
|
|
|
|
{
|
|
|
|
spec->name+=bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
spec->name = std::string("");
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
|
|
|
{
|
|
|
|
bool isExp = bufor[i]; ++i; //true if hore's experience is greater than 0
|
|
|
|
if(isExp)
|
|
|
|
{
|
|
|
|
spec->experience = readNormalNr(i); i+=4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
spec->experience = 0;
|
|
|
|
}
|
|
|
|
else
|
2007-06-13 23:17:48 +03:00
|
|
|
{
|
|
|
|
spec->experience = readNormalNr(i); i+=4;
|
|
|
|
}
|
2007-07-10 05:46:38 +03:00
|
|
|
bool portrait=bufor[i]; ++i;
|
|
|
|
if (portrait)
|
|
|
|
i++; //TODO read portrait nr, save, open
|
2007-06-14 20:07:26 +03:00
|
|
|
bool nonstandardAbilities = bufor[i]; ++i; //true if hero has specified abilities
|
2007-06-13 23:17:48 +03:00
|
|
|
if(nonstandardAbilities)
|
|
|
|
{
|
|
|
|
int howMany = readNormalNr(i); i+=4;
|
|
|
|
for(int yy=0; yy<howMany; ++yy)
|
|
|
|
{
|
2007-07-16 17:42:44 +03:00
|
|
|
spec->abilities.push_back(CGameInfo::mainObj->abilh->abilities[readNormalNr(i, 1)]); ++i;
|
2007-06-13 23:17:48 +03:00
|
|
|
spec->abilityLevels.push_back(readNormalNr(i, 1)); ++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool standGarrison = bufor[i]; ++i; //true if hero has nonstandard garrison
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->standardGarrison = standGarrison;
|
2007-06-13 23:17:48 +03:00
|
|
|
if(standGarrison)
|
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->garrison = readCreatureSet(i); i+= (map.version == RoE ? 21 : 28); //4 bytes per slot
|
2007-06-13 23:17:48 +03:00
|
|
|
}
|
|
|
|
bool form = bufor[i]; ++i; //formation
|
|
|
|
spec->garrison.formation = form;
|
2007-06-14 20:07:26 +03:00
|
|
|
bool artSet = bufor[i]; ++i; //true if artifact set is not default (hero has some artifacts)
|
2007-08-26 19:02:36 +03:00
|
|
|
int artmask = map.version == RoE ? 0xff : 0xffff;
|
|
|
|
int artidlen = map.version == RoE ? 1 : 2;
|
2007-06-14 20:07:26 +03:00
|
|
|
if(artSet)
|
|
|
|
{
|
2007-06-14 23:40:08 +03:00
|
|
|
//head art //1
|
2007-08-26 19:02:36 +03:00
|
|
|
int id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artHead = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artHead = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//shoulders art //2
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artShoulders = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artShoulders = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//neck art //3
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artNeck = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artNeck = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//right hand art //4
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artRhand = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artRhand = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//left hand art //5
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artLHand = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artLHand = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//torso art //6
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artTorso = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artTorso = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//right hand ring //7
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artRRing = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artRRing = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//left hand ring //8
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artLRing = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artLRing = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//feet art //9
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artFeet = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artFeet = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//misc1 art //10
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artMisc1 = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artMisc1 = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//misc2 art //11
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artMisc2 = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artMisc2 = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//misc3 art //12
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artMisc3 = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artMisc3 = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//misc4 art //13
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artMisc4 = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artMisc4 = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//machine1 art //14
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artMach1 = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artMach1 = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//machine2 art //15
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artMach2 = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artMach2 = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//machine3 art //16
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 20:07:26 +03:00
|
|
|
spec->artMach3 = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artMach3 = NULL;
|
2007-06-14 23:40:08 +03:00
|
|
|
//misc5 art //17
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>=SoD)
|
|
|
|
{
|
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
|
|
|
spec->artMisc5 = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artMisc5 = NULL;
|
|
|
|
}
|
2007-06-14 23:40:08 +03:00
|
|
|
//spellbook
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=artidlen;
|
|
|
|
if(id!=artmask)
|
2007-06-14 23:40:08 +03:00
|
|
|
spec->artSpellBook = &(CGameInfo::mainObj->arth->artifacts[id]);
|
|
|
|
else
|
|
|
|
spec->artSpellBook = NULL;
|
|
|
|
//19 //???what is that? gap in file or what?
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
|
|
|
i+=2;
|
|
|
|
else
|
|
|
|
i+=1;
|
2007-06-14 23:40:08 +03:00
|
|
|
//bag artifacts //20
|
|
|
|
int amount = readNormalNr(i, 2); i+=2; //number of artifacts in hero's bag
|
|
|
|
if(amount>0)
|
|
|
|
{
|
|
|
|
for(int ss=0; ss<amount; ++ss)
|
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
id = readNormalNr(i, artidlen); i+=2;
|
|
|
|
if(id!=artmask)
|
2007-06-14 23:40:08 +03:00
|
|
|
spec->artifacts.push_back(&(CGameInfo::mainObj->arth->artifacts[id]));
|
|
|
|
else
|
|
|
|
spec->artifacts.push_back(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} //artifacts
|
|
|
|
spec->guardRange = readNormalNr(i, 1); ++i;
|
|
|
|
if(spec->guardRange == 0xff)
|
|
|
|
spec->isGuarding = false;
|
|
|
|
else
|
|
|
|
spec->isGuarding = true;
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
2007-06-14 23:40:08 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
bool hasBiography = bufor[i]; ++i; //true if hero has nonstandard (mapmaker defined) biography
|
|
|
|
if(hasBiography)
|
2007-06-14 23:40:08 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
int length = readNormalNr(i); i+=4;
|
|
|
|
int iStart = i;
|
|
|
|
i+=length;
|
|
|
|
for(int bb=0; bb<length; ++bb)
|
|
|
|
{
|
|
|
|
spec->biography+=bufor[iStart+bb];
|
|
|
|
}
|
2007-06-14 23:40:08 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->sex = !(bufor[i]); ++i;
|
2007-06-14 23:40:08 +03:00
|
|
|
}
|
|
|
|
//spells
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
2007-06-14 23:40:08 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
bool areSpells = bufor[i]; ++i;
|
|
|
|
|
|
|
|
if(areSpells) //TODO: sprawdzi� //seems to be ok - tow
|
2007-06-14 23:40:08 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
int ist = i;
|
|
|
|
for(i; i<ist+9; ++i)
|
2007-06-14 23:40:08 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
unsigned char c = bufor[i];
|
|
|
|
for(int yy=0; yy<8; ++yy)
|
2007-06-14 23:40:08 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
if((i-ist)*8+yy < CGameInfo::mainObj->spellh->spells.size())
|
|
|
|
{
|
|
|
|
if(c == (c|((unsigned char)intPow(2, yy))))
|
|
|
|
spec->spells.push_back(&(CGameInfo::mainObj->spellh->spells[(i-ist)*8+yy]));
|
|
|
|
}
|
2007-06-14 23:40:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-06-14 20:07:26 +03:00
|
|
|
}
|
2007-06-14 23:40:08 +03:00
|
|
|
//spells loaded
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->defaultMainStats = bufor[i]; ++i;
|
|
|
|
if(spec->defaultMainStats)
|
|
|
|
{
|
|
|
|
spec->attack = bufor[i]; ++i;
|
|
|
|
spec->defence = bufor[i]; ++i;
|
|
|
|
spec->power = bufor[i]; ++i;
|
|
|
|
spec->knowledge = bufor[i]; ++i;
|
|
|
|
}
|
2007-09-14 16:11:10 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->attack = -1;
|
|
|
|
spec->defence = -1;
|
|
|
|
spec->power = -1;
|
|
|
|
spec->knowledge = -1;
|
|
|
|
}
|
|
|
|
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
|
|
|
i+=16;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-08-12 20:48:05 +03:00
|
|
|
//////creating CHeroInstance
|
2007-10-27 22:38:48 +03:00
|
|
|
CGHeroInstance * nhi = new CGHeroInstance;
|
|
|
|
(*(static_cast<CGObjectInstance*>(nhi))) = *nobj;
|
|
|
|
delete nobj;
|
|
|
|
nobj=nhi;
|
2007-09-15 21:04:12 +03:00
|
|
|
spec->myInstance = nhi;
|
2007-10-27 22:38:48 +03:00
|
|
|
//nobj->isHero = true;
|
|
|
|
(static_cast<CGHeroInstance*>(nobj))->moveDir = 4;
|
2007-08-12 20:48:05 +03:00
|
|
|
nhi->exp = spec->experience;
|
|
|
|
nhi->level = CGI->heroh->level(nhi->exp);
|
2007-09-14 16:11:10 +03:00
|
|
|
nhi->primSkills.resize(PRIMARY_SKILLS);
|
|
|
|
nhi->primSkills[0] = spec->attack;
|
|
|
|
nhi->primSkills[1] = spec->defence;
|
|
|
|
nhi->primSkills[2] = spec->power;
|
|
|
|
nhi->primSkills[3] = spec->knowledge;
|
2007-08-12 20:48:05 +03:00
|
|
|
nhi->mana = spec->knowledge * 10;
|
|
|
|
nhi->movement = -1;
|
|
|
|
nhi->name = spec->name;
|
2007-11-19 00:58:28 +02:00
|
|
|
nhi->setOwner(spec->player);
|
2007-08-12 20:48:05 +03:00
|
|
|
nhi->pos = nobj->pos;
|
|
|
|
nhi->type = spec->type;
|
|
|
|
nhi->army = spec->garrison;
|
2007-09-14 16:11:10 +03:00
|
|
|
nhi->portrait = -1; // TODO: przypisywac portret
|
2007-08-12 20:48:05 +03:00
|
|
|
CGI->heroh->heroInstances.push_back(nhi);
|
2007-06-15 19:50:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CREATURES_DEF:
|
|
|
|
{
|
|
|
|
CCreatureObjInfo * spec = new CCreatureObjInfo;
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
|
|
|
{
|
|
|
|
spec->bytes[0] = bufor[i]; ++i;
|
|
|
|
spec->bytes[1] = bufor[i]; ++i;
|
|
|
|
spec->bytes[2] = bufor[i]; ++i;
|
|
|
|
spec->bytes[3] = bufor[i]; ++i;
|
|
|
|
}
|
2007-06-15 19:50:02 +03:00
|
|
|
spec->number = readNormalNr(i, 2); i+=2;
|
|
|
|
spec->character = bufor[i]; ++i;
|
|
|
|
bool isMesTre = bufor[i]; ++i; //true if there is message or treasury
|
|
|
|
if(isMesTre)
|
|
|
|
{
|
|
|
|
int messLength = readNormalNr(i); i+=4;
|
|
|
|
if(messLength>0)
|
|
|
|
{
|
|
|
|
for(int tt=0; tt<messLength; ++tt)
|
|
|
|
{
|
|
|
|
spec->message += bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
spec->wood = readNormalNr(i); i+=4;
|
|
|
|
spec->mercury = readNormalNr(i); i+=4;
|
|
|
|
spec->ore = readNormalNr(i); i+=4;
|
|
|
|
spec->sulfur = readNormalNr(i); i+=4;
|
|
|
|
spec->crytal = readNormalNr(i); i+=4;
|
|
|
|
spec->gems = readNormalNr(i); i+=4;
|
|
|
|
spec->gold = readNormalNr(i); i+=4;
|
2007-08-26 19:02:36 +03:00
|
|
|
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;
|
|
|
|
}
|
2007-06-15 19:50:02 +03:00
|
|
|
else
|
2007-08-26 19:02:36 +03:00
|
|
|
{
|
|
|
|
if(artID!=0xffff)
|
|
|
|
spec->gainedArtifact = &(CGameInfo::mainObj->arth->artifacts[artID]);
|
|
|
|
else
|
|
|
|
spec->gainedArtifact = NULL;
|
|
|
|
}
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
|
|
|
spec->neverFlees = bufor[i]; ++i;
|
|
|
|
spec->notGrowingTeam = bufor[i]; ++i;
|
|
|
|
i+=2;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-15 19:50:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::SIGN_DEF:
|
|
|
|
{
|
|
|
|
CSignObjInfo * spec = new CSignObjInfo;
|
|
|
|
int length = readNormalNr(i); i+=4;
|
|
|
|
for(int rr=0; rr<length; ++rr)
|
|
|
|
{
|
|
|
|
spec->message += bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
i+=4;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-15 19:50:02 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::SEERHUT_DEF:
|
|
|
|
{
|
|
|
|
CSeerHutObjInfo * spec = new CSeerHutObjInfo;
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->missionType = bufor[i]; ++i;
|
|
|
|
switch(spec->missionType)
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
case 0:
|
|
|
|
i+=3;
|
|
|
|
continue;
|
|
|
|
case 1:
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->m1level = readNormalNr(i); i+=4;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
case 2:
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->m2attack = bufor[i]; ++i;
|
|
|
|
spec->m2defence = bufor[i]; ++i;
|
|
|
|
spec->m2power = bufor[i]; ++i;
|
|
|
|
spec->m2knowledge = bufor[i]; ++i;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
case 3:
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->m3bytes[0] = bufor[i]; ++i;
|
|
|
|
spec->m3bytes[1] = bufor[i]; ++i;
|
|
|
|
spec->m3bytes[2] = bufor[i]; ++i;
|
|
|
|
spec->m3bytes[3] = bufor[i]; ++i;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
case 4:
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->m4bytes[0] = bufor[i]; ++i;
|
|
|
|
spec->m4bytes[1] = bufor[i]; ++i;
|
|
|
|
spec->m4bytes[2] = bufor[i]; ++i;
|
|
|
|
spec->m4bytes[3] = bufor[i]; ++i;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
case 5:
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
int artNumber = bufor[i]; ++i;
|
|
|
|
for(int yy=0; yy<artNumber; ++yy)
|
|
|
|
{
|
|
|
|
int artid = readNormalNr(i, 2); i+=2;
|
|
|
|
spec->m5arts.push_back(&(CGameInfo::mainObj->arth->artifacts[artid]));
|
|
|
|
}
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
case 6:
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
int typeNumber = bufor[i]; ++i;
|
|
|
|
for(int hh=0; hh<typeNumber; ++hh)
|
|
|
|
{
|
|
|
|
int creType = readNormalNr(i, 2); i+=2;
|
|
|
|
int creNumb = readNormalNr(i, 2); i+=2;
|
|
|
|
spec->m6cre.push_back(&(CGameInfo::mainObj->creh->creatures[creType]));
|
|
|
|
spec->m6number.push_back(creNumb);
|
|
|
|
}
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
case 7:
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->m7wood = readNormalNr(i); i+=4;
|
|
|
|
spec->m7mercury = readNormalNr(i); i+=4;
|
|
|
|
spec->m7ore = readNormalNr(i); i+=4;
|
|
|
|
spec->m7sulfur = readNormalNr(i); i+=4;
|
|
|
|
spec->m7crystal = readNormalNr(i); i+=4;
|
|
|
|
spec->m7gems = readNormalNr(i); i+=4;
|
|
|
|
spec->m7gold = readNormalNr(i); i+=4;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
case 8:
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
int heroType = bufor[i]; ++i;
|
|
|
|
spec->m8hero = CGameInfo::mainObj->heroh->heroes[heroType];
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
case 9:
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->m9player = bufor[i]; ++i;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
}//internal switch end (seer huts)
|
|
|
|
|
|
|
|
int len1 = readNormalNr(i); i+=4;
|
|
|
|
for(int ee=0; ee<len1; ++ee)
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->firstVisitText += bufor[i]; ++i;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
|
|
|
|
int len2 = readNormalNr(i); i+=4;
|
|
|
|
for(int ee=0; ee<len2; ++ee)
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->nextVisitText += bufor[i]; ++i;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
|
|
|
|
int len3 = readNormalNr(i); i+=4;
|
|
|
|
for(int ee=0; ee<len3; ++ee)
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->completedText += bufor[i]; ++i;
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
else //RoE
|
2007-06-15 19:50:02 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
int artID = bufor[i]; ++i;
|
|
|
|
spec->m5arts.push_back(&(CGameInfo::mainObj->arth->artifacts[artID]));
|
2007-06-15 19:50:02 +03:00
|
|
|
}
|
2007-06-14 23:40:08 +03:00
|
|
|
|
2007-06-15 23:11:52 +03:00
|
|
|
unsigned char rewardType = bufor[i]; ++i;
|
|
|
|
spec->rewardType = rewardType;
|
|
|
|
|
|
|
|
switch(rewardType)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
spec->r1exp = readNormalNr(i); i+=4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
spec->r2mana = readNormalNr(i); i+=4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
spec->r3morale = bufor[i]; ++i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
spec->r4luck = bufor[i]; ++i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
spec->r5type = bufor[i]; ++i;
|
|
|
|
spec->r5amount = readNormalNr(i, 3); i+=3;
|
2007-06-17 19:59:14 +03:00
|
|
|
i+=1;
|
2007-06-15 23:11:52 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
spec->r6type = bufor[i]; ++i;
|
|
|
|
spec->r6amount = bufor[i]; ++i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
int abid = bufor[i]; ++i;
|
2007-07-16 17:42:44 +03:00
|
|
|
spec->r7ability = CGameInfo::mainObj->abilh->abilities[abid];
|
2007-06-15 23:11:52 +03:00
|
|
|
spec->r7level = bufor[i]; ++i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 8:
|
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
int artid = readNormalNr(i, (map.version == RoE ? 1 : 2)); i+=(map.version == RoE ? 1 : 2);
|
2007-06-15 23:11:52 +03:00
|
|
|
spec->r8art = &(CGameInfo::mainObj->arth->artifacts[artid]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
int spellid = bufor[i]; ++i;
|
|
|
|
spec->r9spell = &(CGameInfo::mainObj->spellh->spells[spellid]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 10:
|
|
|
|
{
|
|
|
|
int creid = readNormalNr(i, 2); i+=2;
|
|
|
|
spec->r10creature = &(CGameInfo::mainObj->creh->creatures[creid]);
|
|
|
|
spec->r10amount = readNormalNr(i, 2); i+=2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}// end of internal switch
|
|
|
|
i+=2;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-15 23:11:52 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::WITCHHUT_DEF:
|
|
|
|
{
|
|
|
|
CWitchHutObjInfo * spec = new CWitchHutObjInfo;
|
|
|
|
ist=i; //starting i for loop
|
|
|
|
for(i; i<ist+4; ++i)
|
|
|
|
{
|
|
|
|
unsigned char c = bufor[i];
|
|
|
|
for(int yy=0; yy<8; ++yy)
|
|
|
|
{
|
|
|
|
if((i-ist)*8+yy < CGameInfo::mainObj->abilh->abilities.size())
|
|
|
|
{
|
|
|
|
if(c == (c|((unsigned char)intPow(2, yy))))
|
2007-07-16 17:42:44 +03:00
|
|
|
spec->allowedAbilities.push_back(CGameInfo::mainObj->abilh->abilities[(i-ist)*8+yy]);
|
2007-06-15 23:11:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-15 23:11:52 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::SCHOLAR_DEF:
|
|
|
|
{
|
|
|
|
CScholarObjInfo * spec = new CScholarObjInfo;
|
|
|
|
spec->bonusType = bufor[i]; ++i;
|
|
|
|
switch(spec->bonusType)
|
|
|
|
{
|
|
|
|
case 0xff:
|
|
|
|
++i;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
spec->r0type = bufor[i]; ++i;
|
|
|
|
break;
|
|
|
|
case 1:
|
2007-07-16 17:42:44 +03:00
|
|
|
spec->r1 = CGameInfo::mainObj->abilh->abilities[bufor[i]]; ++i;
|
2007-06-15 23:11:52 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
spec->r2 = &(CGameInfo::mainObj->spellh->spells[bufor[i]]); ++i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=6;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-15 23:11:52 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::GARRISON_DEF:
|
|
|
|
{
|
|
|
|
CGarrisonObjInfo * spec = new CGarrisonObjInfo;
|
|
|
|
spec->player = bufor[i]; ++i;
|
|
|
|
i+=3;
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->units = readCreatureSet(i); i+= (map.version==RoE ? 21 : 28);
|
|
|
|
if(map.version > RoE)
|
|
|
|
{
|
|
|
|
spec->movableUnits = bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
spec->movableUnits = true;
|
2007-06-15 23:11:52 +03:00
|
|
|
i+=8;
|
2007-11-19 00:58:28 +02:00
|
|
|
nobj->setOwner(spec->player);
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-15 23:11:52 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::ARTIFACT_DEF:
|
|
|
|
{
|
|
|
|
CArtifactObjInfo * spec = new CArtifactObjInfo;
|
|
|
|
bool areSettings = bufor[i]; ++i;
|
|
|
|
if(areSettings)
|
|
|
|
{
|
|
|
|
int messLength = readNormalNr(i, 4); i+=4;
|
|
|
|
for(int hh=0; hh<messLength; ++hh)
|
|
|
|
{
|
|
|
|
spec->message += bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
bool areGuards = bufor[i]; ++i;
|
|
|
|
if(areGuards)
|
|
|
|
{
|
|
|
|
spec->areGuards = true;
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->guards = readCreatureSet(i); i+= (map.version == RoE ? 21 : 28) ;
|
2007-06-15 23:11:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
spec->areGuards = false;
|
2007-06-16 23:12:08 +03:00
|
|
|
i+=4;
|
2007-06-15 23:11:52 +03:00
|
|
|
}
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-15 23:11:52 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::RESOURCE_DEF:
|
|
|
|
{
|
|
|
|
CResourceObjInfo * spec = new CResourceObjInfo;
|
|
|
|
bool isMessGuard = bufor[i]; ++i;
|
|
|
|
if(isMessGuard)
|
|
|
|
{
|
|
|
|
int messLength = readNormalNr(i); i+=4;
|
|
|
|
for(int mm=0; mm<messLength; ++mm)
|
|
|
|
{
|
|
|
|
spec->message+=bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
spec->areGuards = bufor[i]; ++i;
|
|
|
|
if(spec->areGuards)
|
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->guards = readCreatureSet(i); i+= (map.version == RoE ? 21 : 28);
|
2007-06-15 23:11:52 +03:00
|
|
|
}
|
|
|
|
i+=4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->areGuards = false;
|
|
|
|
}
|
|
|
|
spec->amount = readNormalNr(i); i+=4;
|
|
|
|
i+=4;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-12 23:09:23 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-06-16 17:08:01 +03:00
|
|
|
case EDefType::TOWN_DEF:
|
|
|
|
{
|
|
|
|
CCastleObjInfo * spec = new CCastleObjInfo;
|
2007-08-24 18:00:13 +03:00
|
|
|
if(map.version!=RoE)
|
|
|
|
{
|
|
|
|
spec->bytes[0] = bufor[i]; ++i;
|
|
|
|
spec->bytes[1] = bufor[i]; ++i;
|
|
|
|
spec->bytes[2] = bufor[i]; ++i;
|
|
|
|
spec->bytes[3] = bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->bytes[0] = 0;
|
|
|
|
spec->bytes[1] = 0;
|
|
|
|
spec->bytes[2] = 0;
|
|
|
|
spec->bytes[3] = 0;
|
|
|
|
}
|
2007-06-16 17:08:01 +03:00
|
|
|
spec->player = bufor[i]; ++i;
|
|
|
|
|
|
|
|
bool hasName = bufor[i]; ++i;
|
|
|
|
if(hasName)
|
|
|
|
{
|
|
|
|
int len = readNormalNr(i); i+=4;
|
2007-06-16 23:12:08 +03:00
|
|
|
for(int gg=0; gg<len; ++gg)
|
2007-06-16 17:08:01 +03:00
|
|
|
{
|
|
|
|
spec->name += bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool stGarr = bufor[i]; ++i; //true if garrison isn't empty
|
|
|
|
if(stGarr)
|
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->garrison = readCreatureSet(i); i+=( map.version > RoE ? 28 : 21 );
|
2007-06-16 17:08:01 +03:00
|
|
|
}
|
|
|
|
spec->garrison.formation = bufor[i]; ++i;
|
2007-06-16 23:12:08 +03:00
|
|
|
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;
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
2007-06-16 23:12:08 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
for(i; i<ist+9; ++i)
|
2007-06-16 23:12:08 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
unsigned char c = bufor[i];
|
|
|
|
for(int yy=0; yy<8; ++yy)
|
2007-06-16 23:12:08 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
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]));
|
|
|
|
}
|
2007-06-16 23:12:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2007-06-17 19:59:14 +03:00
|
|
|
for(int gh = 0; gh<numberOfEvent; ++gh)
|
2007-06-16 23:12:08 +03:00
|
|
|
{
|
2007-06-17 19:59:14 +03:00
|
|
|
CCastleEvent nce;
|
|
|
|
int nameLen = readNormalNr(i); i+=4;
|
|
|
|
for(int ll=0; ll<nameLen; ++ll)
|
|
|
|
{
|
|
|
|
nce.name += bufor[i]; ++i;
|
|
|
|
}
|
2007-06-16 23:12:08 +03:00
|
|
|
|
2007-06-17 19:59:14 +03:00
|
|
|
int messLen = readNormalNr(i); i+=4;
|
|
|
|
for(int ll=0; ll<messLen; ++ll)
|
|
|
|
{
|
|
|
|
nce.message += bufor[i]; ++i;
|
|
|
|
}
|
2007-06-16 23:12:08 +03:00
|
|
|
|
2007-06-17 19:59:14 +03:00
|
|
|
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;
|
2007-06-16 23:12:08 +03:00
|
|
|
|
2007-06-17 19:59:14 +03:00
|
|
|
nce.players = bufor[i]; ++i;
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version > RoE)
|
|
|
|
{
|
|
|
|
nce.forHuman = bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nce.forHuman = true;
|
2007-06-17 19:59:14 +03:00
|
|
|
nce.forComputer = bufor[i]; ++i;
|
|
|
|
nce.firstShow = readNormalNr(i, 2); i+=2;
|
|
|
|
nce.forEvery = bufor[i]; ++i;
|
2007-06-16 23:12:08 +03:00
|
|
|
|
2007-06-17 19:59:14 +03:00
|
|
|
i+=17;
|
2007-06-16 23:12:08 +03:00
|
|
|
|
2007-06-17 19:59:14 +03:00
|
|
|
for(int kk=0; kk<6; ++kk)
|
|
|
|
{
|
|
|
|
nce.bytes[kk] = bufor[i]; ++i;
|
|
|
|
}
|
2007-06-16 23:12:08 +03:00
|
|
|
|
2007-06-17 19:59:14 +03:00
|
|
|
for(int vv=0; vv<7; ++vv)
|
|
|
|
{
|
2007-07-09 18:02:08 +03:00
|
|
|
nce.gen[vv] = readNormalNr(i, 2); i+=2;
|
2007-06-17 19:59:14 +03:00
|
|
|
}
|
2007-07-09 18:02:08 +03:00
|
|
|
i+=4;
|
2007-06-17 19:59:14 +03:00
|
|
|
spec->events.push_back(nce);
|
2007-06-16 23:12:08 +03:00
|
|
|
}
|
2007-09-13 16:34:59 +03:00
|
|
|
spec->x = nobj->pos.x;
|
|
|
|
spec->y = nobj->pos.y;
|
|
|
|
spec->z = nobj->pos.z;
|
2007-06-16 23:12:08 +03:00
|
|
|
|
|
|
|
/////// castle events have been read ///////////////////////////
|
|
|
|
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version > RoE)
|
|
|
|
{
|
|
|
|
spec->alignment = bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
spec->alignment = 0xff;
|
2007-06-17 19:59:14 +03:00
|
|
|
i+=3;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-09-05 18:56:35 +03:00
|
|
|
//////////// rewriting info to CTownInstance class /////////////////////
|
2007-10-27 22:38:48 +03:00
|
|
|
CGTownInstance * nt = new CGTownInstance();
|
|
|
|
(*(static_cast<CGObjectInstance*>(nt))) = *nobj;
|
|
|
|
delete nobj;
|
|
|
|
nobj = nt;
|
|
|
|
|
2007-11-19 00:58:28 +02:00
|
|
|
nt->setOwner(spec->player);
|
2007-10-27 22:38:48 +03:00
|
|
|
nt->town = &CGI->townh->towns[CTownHandler::getTypeByDefName(nobj->defInfo->name)];
|
2007-09-05 18:56:35 +03:00
|
|
|
nt->builded = 0;
|
|
|
|
nt->destroyed = 0;
|
|
|
|
nt->name = spec->name;
|
|
|
|
nt->garrison = spec->garrison;
|
2007-10-14 15:11:18 +03:00
|
|
|
nt->garrisonHero = NULL;// spec->garnisonHero is not readed - TODO: readit
|
2007-09-05 18:56:35 +03:00
|
|
|
nt->pos = int3(spec->x, spec->y, spec->z);
|
|
|
|
nt->possibleSpells = spec->possibleSpells;
|
|
|
|
nt->obligatorySpells = spec->obligatorySpells;
|
2007-10-11 23:13:13 +03:00
|
|
|
nt->availableSpells = std::vector<CSpell*>();
|
|
|
|
nt->creatureIncome = std::vector<int>();
|
|
|
|
nt->creaturesLeft = std::vector<int>();
|
2007-09-18 16:30:26 +03:00
|
|
|
CGI->townh->townInstances.push_back(nt);
|
2007-06-16 23:12:08 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-06-17 19:59:14 +03:00
|
|
|
case EDefType::PLAYERONLY_DEF:
|
2007-06-16 23:12:08 +03:00
|
|
|
{
|
2007-06-17 19:59:14 +03:00
|
|
|
CPlayerOnlyObjInfo * spec = new CPlayerOnlyObjInfo;
|
2007-06-16 23:12:08 +03:00
|
|
|
spec->player = bufor[i]; ++i;
|
|
|
|
i+=3;
|
2007-11-19 00:58:28 +02:00
|
|
|
nobj->setOwner(spec->player);
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-16 23:12:08 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::SHRINE_DEF:
|
|
|
|
{
|
|
|
|
CShrineObjInfo * spec = new CShrineObjInfo;
|
|
|
|
spec->spell = bufor[i]; i+=4;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-16 17:08:01 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-06-17 19:59:14 +03:00
|
|
|
case EDefType::SPELLSCROLL_DEF:
|
|
|
|
{
|
|
|
|
CSpellScrollObjinfo * spec = new CSpellScrollObjinfo;
|
|
|
|
bool messg = bufor[i]; ++i;
|
|
|
|
if(messg)
|
|
|
|
{
|
|
|
|
int mLength = readNormalNr(i); i+=4;
|
|
|
|
for(int vv=0; vv<mLength; ++vv)
|
|
|
|
{
|
|
|
|
spec->message += bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
spec->areGuarders = bufor[i]; ++i;
|
|
|
|
if(spec->areGuarders)
|
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->guarders = readCreatureSet(i); i+=( map.version == RoE ? 21 : 28 );
|
2007-06-17 19:59:14 +03:00
|
|
|
}
|
|
|
|
i+=4;
|
|
|
|
}
|
|
|
|
spec->spell = &(CGameInfo::mainObj->spellh->spells[bufor[i]]); ++i;
|
|
|
|
i+=3;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-17 19:59:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::PANDORA_DEF:
|
|
|
|
{
|
|
|
|
CPandorasBoxObjInfo * spec = new CPandorasBoxObjInfo;
|
|
|
|
bool messg = bufor[i]; ++i;
|
|
|
|
if(messg)
|
|
|
|
{
|
|
|
|
int mLength = readNormalNr(i); i+=4;
|
|
|
|
for(int vv=0; vv<mLength; ++vv)
|
|
|
|
{
|
|
|
|
spec->message += bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
spec->areGuarders = bufor[i]; ++i;
|
|
|
|
if(spec->areGuarders)
|
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
spec->guarders = readCreatureSet(i); i+= (map.version == RoE ? 21 : 28);
|
2007-06-17 19:59:14 +03:00
|
|
|
}
|
|
|
|
i+=4;
|
|
|
|
}
|
|
|
|
////// copied form event handling (seems to be similar)
|
|
|
|
spec->gainedExp = readNormalNr(i, 4); i+=4;
|
|
|
|
spec->manaDiff = readNormalNr(i, 4); i+=4;
|
|
|
|
spec->moraleDiff = readNormalNr(i, 1, true); ++i;
|
|
|
|
spec->luckDiff = readNormalNr(i, 1, true); ++i;
|
|
|
|
spec->wood = readNormalNr(i); i+=4;
|
|
|
|
spec->mercury = readNormalNr(i); i+=4;
|
|
|
|
spec->ore = readNormalNr(i); i+=4;
|
|
|
|
spec->sulfur = readNormalNr(i); i+=4;
|
|
|
|
spec->crystal = readNormalNr(i); i+=4;
|
|
|
|
spec->gems = readNormalNr(i); i+=4;
|
|
|
|
spec->gold = readNormalNr(i); i+=4;
|
|
|
|
spec->attack = readNormalNr(i, 1); ++i;
|
|
|
|
spec->defence = readNormalNr(i, 1); ++i;
|
|
|
|
spec->power = readNormalNr(i, 1); ++i;
|
|
|
|
spec->knowledge = readNormalNr(i, 1); ++i;
|
|
|
|
int gabn; //number of gained abilities
|
|
|
|
gabn = readNormalNr(i, 1); ++i;
|
|
|
|
for(int oo = 0; oo<gabn; ++oo)
|
|
|
|
{
|
2007-07-16 17:42:44 +03:00
|
|
|
spec->abilities.push_back((CGameInfo::mainObj->abilh)->abilities[readNormalNr(i, 1)]); ++i;
|
2007-06-17 19:59:14 +03:00
|
|
|
spec->abilityLevels.push_back(readNormalNr(i, 1)); ++i;
|
|
|
|
}
|
|
|
|
int gart = readNormalNr(i, 1); ++i; //number of gained artifacts
|
|
|
|
for(int oo = 0; oo<gart; ++oo)
|
|
|
|
{
|
|
|
|
spec->artifacts.push_back(&(CGameInfo::mainObj->arth->artifacts[readNormalNr(i, 2)])); i+=2;
|
|
|
|
}
|
|
|
|
int gspel = readNormalNr(i, 1); ++i; //number of gained spells
|
|
|
|
for(int oo = 0; oo<gspel; ++oo)
|
|
|
|
{
|
|
|
|
spec->spells.push_back(&(CGameInfo::mainObj->spellh->spells[readNormalNr(i, 1)])); ++i;
|
|
|
|
}
|
|
|
|
int gcre = readNormalNr(i, 1); ++i; //number of gained creatures
|
|
|
|
spec->creatures = readCreatureSet(i, gcre); i+=4*gcre;
|
|
|
|
i+=8;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-17 19:59:14 +03:00
|
|
|
///////end of copied fragment
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::GRAIL_DEF:
|
|
|
|
{
|
|
|
|
CGrailObjInfo * spec = new CGrailObjInfo;
|
|
|
|
spec->radius = readNormalNr(i); i+=4;
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-17 19:59:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::CREGEN_DEF:
|
|
|
|
{
|
|
|
|
CCreGenObjInfo * spec = new CCreGenObjInfo;
|
|
|
|
spec->player = bufor[i]; ++i;
|
|
|
|
i+=3;
|
|
|
|
for(int ggg=0; ggg<4; ++ggg)
|
|
|
|
{
|
|
|
|
spec->bytes[ggg] = bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
if((spec->bytes[0] == '\0') && (spec->bytes[1] == '\0') && (spec->bytes[2] == '\0') && (spec->bytes[3] == '\0'))
|
|
|
|
{
|
|
|
|
spec->asCastle = false;
|
|
|
|
spec->castles[0] = bufor[i]; ++i;
|
|
|
|
spec->castles[1] = bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->asCastle = true;
|
|
|
|
}
|
2007-11-19 00:58:28 +02:00
|
|
|
nobj->setOwner(spec->player);
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-17 19:59:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::CREGEN2_DEF:
|
|
|
|
{
|
|
|
|
CCreGen2ObjInfo * spec = new CCreGen2ObjInfo;
|
|
|
|
spec->player = bufor[i]; ++i;
|
|
|
|
i+=3;
|
|
|
|
for(int ggg=0; ggg<4; ++ggg)
|
|
|
|
{
|
|
|
|
spec->bytes[ggg] = bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
if((spec->bytes[0] == '\0') && (spec->bytes[1] == '\0') && (spec->bytes[2] == '\0') && (spec->bytes[3] == '\0'))
|
|
|
|
{
|
|
|
|
spec->asCastle = false;
|
|
|
|
spec->castles[0] = bufor[i]; ++i;
|
|
|
|
spec->castles[1] = bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->asCastle = true;
|
|
|
|
}
|
|
|
|
spec->minLevel = bufor[i]; ++i;
|
|
|
|
spec->maxLevel = bufor[i]; ++i;
|
2007-08-06 16:09:41 +03:00
|
|
|
if(spec->maxLevel>7)
|
|
|
|
spec->maxLevel = 7;
|
|
|
|
if(spec->minLevel<1)
|
|
|
|
spec->minLevel = 1;
|
2007-11-19 00:58:28 +02:00
|
|
|
nobj->setOwner(spec->player);
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-17 19:59:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::CREGEN3_DEF:
|
|
|
|
{
|
|
|
|
CCreGen3ObjInfo * spec = new CCreGen3ObjInfo;
|
|
|
|
spec->player = bufor[i]; ++i;
|
|
|
|
i+=3;
|
|
|
|
spec->minLevel = bufor[i]; ++i;
|
|
|
|
spec->maxLevel = bufor[i]; ++i;
|
2007-08-06 16:09:41 +03:00
|
|
|
if(spec->maxLevel>7)
|
|
|
|
spec->maxLevel = 7;
|
|
|
|
if(spec->minLevel<1)
|
|
|
|
spec->minLevel = 1;
|
2007-11-19 00:58:28 +02:00
|
|
|
nobj->setOwner(spec->player);
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-17 19:59:14 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::BORDERGUARD_DEF:
|
|
|
|
{
|
|
|
|
CBorderGuardObjInfo * spec = new CBorderGuardObjInfo;
|
|
|
|
spec->missionType = bufor[i]; ++i;
|
|
|
|
switch(spec->missionType)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
spec->m1level = readNormalNr(i); i+=4;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
spec->m2attack = bufor[i]; ++i;
|
|
|
|
spec->m2defence = bufor[i]; ++i;
|
|
|
|
spec->m2power = bufor[i]; ++i;
|
|
|
|
spec->m2knowledge = bufor[i]; ++i;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
spec->m3bytes[0] = bufor[i]; ++i;
|
|
|
|
spec->m3bytes[1] = bufor[i]; ++i;
|
|
|
|
spec->m3bytes[2] = bufor[i]; ++i;
|
|
|
|
spec->m3bytes[3] = bufor[i]; ++i;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
spec->m4bytes[0] = bufor[i]; ++i;
|
|
|
|
spec->m4bytes[1] = bufor[i]; ++i;
|
|
|
|
spec->m4bytes[2] = bufor[i]; ++i;
|
|
|
|
spec->m4bytes[3] = bufor[i]; ++i;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
int artNumber = bufor[i]; ++i;
|
|
|
|
for(int yy=0; yy<artNumber; ++yy)
|
|
|
|
{
|
|
|
|
int artid = readNormalNr(i, 2); i+=2;
|
|
|
|
spec->m5arts.push_back(&(CGameInfo::mainObj->arth->artifacts[artid]));
|
|
|
|
}
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
int typeNumber = bufor[i]; ++i;
|
|
|
|
for(int hh=0; hh<typeNumber; ++hh)
|
|
|
|
{
|
|
|
|
int creType = readNormalNr(i, 2); i+=2;
|
|
|
|
int creNumb = readNormalNr(i, 2); i+=2;
|
|
|
|
spec->m6cre.push_back(&(CGameInfo::mainObj->creh->creatures[creType]));
|
|
|
|
spec->m6number.push_back(creNumb);
|
|
|
|
}
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
spec->m7wood = readNormalNr(i); i+=4;
|
|
|
|
spec->m7mercury = readNormalNr(i); i+=4;
|
|
|
|
spec->m7ore = readNormalNr(i); i+=4;
|
|
|
|
spec->m7sulfur = readNormalNr(i); i+=4;
|
|
|
|
spec->m7crystal = readNormalNr(i); i+=4;
|
|
|
|
spec->m7gems = readNormalNr(i); i+=4;
|
|
|
|
spec->m7gold = readNormalNr(i); i+=4;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 8:
|
|
|
|
{
|
|
|
|
int heroType = bufor[i]; ++i;
|
2007-07-16 13:03:54 +03:00
|
|
|
spec->m8hero = CGameInfo::mainObj->heroh->heroes[heroType];
|
2007-06-17 19:59:14 +03:00
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
spec->m9player = bufor[i]; ++i;
|
|
|
|
int limit = readNormalNr(i); i+=4;
|
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
spec->isDayLimit = false;
|
|
|
|
spec->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->isDayLimit = true;
|
|
|
|
spec->lastDay = limit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}//internal switch end (seer huts)
|
|
|
|
|
|
|
|
int len1 = readNormalNr(i); i+=4;
|
|
|
|
for(int ee=0; ee<len1; ++ee)
|
|
|
|
{
|
|
|
|
spec->firstVisitText += bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
int len2 = readNormalNr(i); i+=4;
|
|
|
|
for(int ee=0; ee<len2; ++ee)
|
|
|
|
{
|
|
|
|
spec->nextVisitText += bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
int len3 = readNormalNr(i); i+=4;
|
|
|
|
for(int ee=0; ee<len3; ++ee)
|
|
|
|
{
|
|
|
|
spec->completedText += bufor[i]; ++i;
|
|
|
|
}
|
2007-08-08 22:28:56 +03:00
|
|
|
nobj->info = spec;
|
2007-06-17 19:59:14 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-06-15 19:50:02 +03:00
|
|
|
} //end of main switch
|
2007-06-13 23:17:48 +03:00
|
|
|
CGameInfo::mainObj->objh->objInstances.push_back(nobj);
|
2007-06-11 20:21:27 +03:00
|
|
|
//TODO - doko�czy�, du�o do zrobienia - trzeba patrze�, co def niesie
|
2007-06-15 19:50:02 +03:00
|
|
|
}//*/ //end of loading objects; commented to make application work until it will be finished
|
2007-06-11 20:21:27 +03:00
|
|
|
////objects loaded
|
2007-06-18 23:05:42 +03:00
|
|
|
|
2007-07-13 18:10:27 +03:00
|
|
|
processMap(defsToUnpack);
|
|
|
|
std::vector<CDefHandler *> dhandlers = CGameInfo::mainObj->spriteh->extractManyFiles(defsToUnpack);
|
|
|
|
for (int i=0;i<dhandlers.size();i++)
|
2007-10-27 22:38:48 +03:00
|
|
|
map.defy[i]->handler=dhandlers[i];
|
2007-07-13 18:10:27 +03:00
|
|
|
for(int vv=0; vv<map.defy.size(); ++vv)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
if(map.defy[vv]->handler->alphaTransformed)
|
2007-07-13 18:10:27 +03:00
|
|
|
continue;
|
2007-10-27 22:38:48 +03:00
|
|
|
for(int yy=0; yy<map.defy[vv]->handler->ourImages.size(); ++yy)
|
2007-07-13 18:10:27 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
map.defy[vv]->handler->ourImages[yy].bitmap = CSDL_Ext::alphaTransform(map.defy[vv]->handler->ourImages[yy].bitmap);
|
|
|
|
SDL_Surface * bufs = CSDL_Ext::secondAlphaTransform(map.defy[vv]->handler->ourImages[yy].bitmap, alphaTransSurf);
|
|
|
|
SDL_FreeSurface(map.defy[vv]->handler->ourImages[yy].bitmap);
|
|
|
|
map.defy[vv]->handler->ourImages[yy].bitmap = bufs;
|
|
|
|
map.defy[vv]->handler->alphaTransformed = true;
|
2007-07-13 18:10:27 +03:00
|
|
|
}
|
|
|
|
}
|
2007-11-03 18:46:08 +02:00
|
|
|
|
2007-07-13 18:10:27 +03:00
|
|
|
SDL_FreeSurface(alphaTransSurf);
|
|
|
|
|
2007-08-11 17:58:07 +03:00
|
|
|
//assigning defobjinfos
|
|
|
|
|
|
|
|
for(int ww=0; ww<CGI->objh->objInstances.size(); ++ww)
|
|
|
|
{
|
|
|
|
for(int h=0; h<CGI->dobjinfo->objs.size(); ++h)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
if(CGI->dobjinfo->objs[h].defName==CGI->objh->objInstances[ww]->defInfo->name)
|
2007-08-11 17:58:07 +03:00
|
|
|
{
|
|
|
|
CGI->objh->objInstances[ww]->defObjInfoNumber = h;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//assigned
|
|
|
|
|
2007-06-18 23:05:42 +03:00
|
|
|
//loading events
|
|
|
|
int numberOfEvents = readNormalNr(i); i+=4;
|
|
|
|
for(int yyoo=0; yyoo<numberOfEvents; ++yyoo)
|
|
|
|
{
|
|
|
|
CMapEvent ne;
|
|
|
|
ne.name = std::string();
|
|
|
|
ne.message = std::string();
|
|
|
|
int nameLen = readNormalNr(i); i+=4;
|
|
|
|
for(int qq=0; qq<nameLen; ++qq)
|
|
|
|
{
|
|
|
|
ne.name += bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
int messLen = readNormalNr(i); i+=4;
|
|
|
|
for(int qq=0; qq<messLen; ++qq)
|
|
|
|
{
|
|
|
|
ne.message +=bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
ne.wood = readNormalNr(i); i+=4;
|
|
|
|
ne.mercury = readNormalNr(i); i+=4;
|
|
|
|
ne.ore = readNormalNr(i); i+=4;
|
|
|
|
ne.sulfur = readNormalNr(i); i+=4;
|
|
|
|
ne.crystal = readNormalNr(i); i+=4;
|
|
|
|
ne.gems = readNormalNr(i); i+=4;
|
|
|
|
ne.gold = readNormalNr(i); i+=4;
|
|
|
|
ne.players = bufor[i]; ++i;
|
|
|
|
ne.humanAffected = bufor[i]; ++i;
|
|
|
|
ne.computerAffected = bufor[i]; ++i;
|
|
|
|
ne.firstOccurence = bufor[i]; ++i;
|
|
|
|
ne.nextOccurence = bufor[i]; ++i;
|
|
|
|
i+=18;
|
|
|
|
map.events.push_back(ne);
|
|
|
|
}
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
2007-06-13 23:17:48 +03:00
|
|
|
int CAmbarCendamo::readNormalNr (int pos, int bytCon, bool cyclic)
|
2007-06-06 19:12:12 +03:00
|
|
|
{
|
|
|
|
int ret=0;
|
|
|
|
int amp=1;
|
|
|
|
for (int i=0; i<bytCon; i++)
|
|
|
|
{
|
|
|
|
ret+=bufor[pos+i]*amp;
|
|
|
|
amp*=256;
|
|
|
|
}
|
2007-06-13 23:17:48 +03:00
|
|
|
if(cyclic && bytCon<4 && ret>=amp/2)
|
|
|
|
{
|
|
|
|
ret = ret-amp;
|
|
|
|
}
|
2007-06-06 19:12:12 +03:00
|
|
|
return ret;
|
|
|
|
}
|
2007-06-11 20:21:27 +03:00
|
|
|
|
2007-06-06 19:12:12 +03:00
|
|
|
void CAmbarCendamo::loadDefs()
|
|
|
|
{
|
|
|
|
std::set<int> loadedTypes;
|
|
|
|
for (int i=0; i<map.width; i++)
|
|
|
|
{
|
|
|
|
for (int j=0; j<map.width; j++)
|
|
|
|
{
|
2007-06-09 05:32:43 +03:00
|
|
|
if (loadedTypes.find(map.terrain[i][j].tertype)==loadedTypes.end())
|
|
|
|
{
|
2007-07-12 14:41:31 +03:00
|
|
|
CDefHandler *sdh = CGI->spriteh->giveDef(CSemiDefHandler::nameFromType(map.terrain[i][j].tertype).c_str());
|
2007-06-09 05:32:43 +03:00
|
|
|
loadedTypes.insert(map.terrain[i][j].tertype);
|
|
|
|
defs.push_back(sdh);
|
|
|
|
}
|
2007-06-17 19:59:14 +03:00
|
|
|
if (map.twoLevel && loadedTypes.find(map.undergroungTerrain[i][j].tertype)==loadedTypes.end())
|
2007-06-09 05:32:43 +03:00
|
|
|
{
|
2007-07-12 14:41:31 +03:00
|
|
|
CDefHandler *sdh = CGI->spriteh->giveDef(CSemiDefHandler::nameFromType(map.undergroungTerrain[i][j].tertype).c_str());
|
2007-06-09 05:32:43 +03:00
|
|
|
loadedTypes.insert(map.undergroungTerrain[i][j].tertype);
|
|
|
|
defs.push_back(sdh);
|
|
|
|
}
|
2007-06-06 19:12:12 +03:00
|
|
|
}
|
|
|
|
}
|
2007-06-12 21:17:33 +03:00
|
|
|
}
|
|
|
|
|
2007-10-27 22:38:48 +03:00
|
|
|
EDefType CAmbarCendamo::getDefType(CGDefInfo * a)
|
2007-06-12 21:17:33 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
switch(a->id)
|
2007-06-12 21:17:33 +03:00
|
|
|
{
|
2007-06-17 19:59:14 +03:00
|
|
|
case 5: case 65: case 66: case 67: case 68: case 69:
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::ARTIFACT_DEF; //handled
|
2007-06-17 19:59:14 +03:00
|
|
|
case 6:
|
|
|
|
return EDefType::PANDORA_DEF; //hanled
|
2007-06-12 21:17:33 +03:00
|
|
|
case 26:
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::EVENTOBJ_DEF; //handled
|
2007-06-12 21:17:33 +03:00
|
|
|
case 33:
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::GARRISON_DEF; //handled
|
2007-07-11 20:47:09 +03:00
|
|
|
case 34: case 70: case 62: //70 - random hero //62 - prison
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::HERO_DEF; //handled
|
2007-06-17 19:59:14 +03:00
|
|
|
case 36:
|
|
|
|
return EDefType::GRAIL_DEF; //hanled
|
2007-07-09 18:02:08 +03:00
|
|
|
case 53: case 17: case 18: case 19: case 20: case 42: case 87: case 220://cases 17 - 20 and 42 - tests
|
2007-06-17 19:59:14 +03:00
|
|
|
return EDefType::PLAYERONLY_DEF; //handled
|
|
|
|
case 54: case 71: case 72: case 73: case 74: case 75: case 162: case 163: case 164:
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::CREATURES_DEF; //handled
|
2007-06-15 19:50:02 +03:00
|
|
|
case 59:
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::SIGN_DEF; //handled
|
2007-06-16 23:12:08 +03:00
|
|
|
case 77:
|
|
|
|
return EDefType::TOWN_DEF; //can be problematic, but handled
|
2007-06-17 19:59:14 +03:00
|
|
|
case 79: case 76:
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::RESOURCE_DEF; //handled
|
|
|
|
case 81:
|
|
|
|
return EDefType::SCHOLAR_DEF; //handled
|
2007-06-12 21:17:33 +03:00
|
|
|
case 83:
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::SEERHUT_DEF; //handled
|
2007-06-12 21:17:33 +03:00
|
|
|
case 91:
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::SIGN_DEF; //handled
|
2007-06-16 23:12:08 +03:00
|
|
|
case 88: case 89: case 90:
|
|
|
|
return SHRINE_DEF; //handled
|
2007-06-17 19:59:14 +03:00
|
|
|
case 93:
|
|
|
|
return SPELLSCROLL_DEF; //handled
|
2007-06-12 21:17:33 +03:00
|
|
|
case 98:
|
2007-06-16 23:12:08 +03:00
|
|
|
return EDefType::TOWN_DEF; //handled
|
2007-06-15 23:11:52 +03:00
|
|
|
case 113:
|
|
|
|
return EDefType::WITCHHUT_DEF; //handled
|
2007-06-17 19:59:14 +03:00
|
|
|
case 215:
|
|
|
|
return EDefType::BORDERGUARD_DEF; //handled by analogy to seer huts ;]
|
|
|
|
case 216:
|
|
|
|
return EDefType::CREGEN2_DEF; //handled
|
|
|
|
case 217:
|
|
|
|
return EDefType::CREGEN_DEF; //handled
|
|
|
|
case 218:
|
|
|
|
return EDefType::CREGEN3_DEF; //handled
|
2007-06-12 21:17:33 +03:00
|
|
|
case 219:
|
2007-06-15 23:11:52 +03:00
|
|
|
return EDefType::GARRISON_DEF; //handled
|
2007-06-12 23:09:23 +03:00
|
|
|
default:
|
2007-06-16 23:12:08 +03:00
|
|
|
return EDefType::TERRAINOBJ_DEF; // nothing to be handled
|
2007-06-12 21:17:33 +03:00
|
|
|
}
|
2007-06-13 23:17:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
CCreatureSet CAmbarCendamo::readCreatureSet(int pos, int number)
|
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
if(map.version>RoE)
|
2007-06-13 23:17:48 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
CCreatureSet ret;
|
|
|
|
std::pair<CCreature *, int> ins;
|
|
|
|
if(number>0 && readNormalNr(pos, 2)!=0xffff)
|
|
|
|
{
|
|
|
|
int rettt = readNormalNr(pos, 2);
|
|
|
|
if(rettt>32768)
|
|
|
|
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
|
|
|
|
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
|
|
|
|
ins.second = readNormalNr(pos+2, 2);
|
|
|
|
std::pair<int,std::pair<CCreature *, int> > tt(0,ins);
|
|
|
|
ret.slots.insert(tt);
|
|
|
|
}
|
|
|
|
if(number>1 && readNormalNr(pos+4, 2)!=0xffff)
|
|
|
|
{
|
|
|
|
int rettt = readNormalNr(pos+4, 2);
|
|
|
|
if(rettt>32768)
|
|
|
|
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
|
|
|
|
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
|
|
|
|
ins.second = readNormalNr(pos+6, 2);
|
|
|
|
std::pair<int,std::pair<CCreature *, int> > tt(1,ins);
|
|
|
|
ret.slots.insert(tt);
|
|
|
|
}
|
|
|
|
if(number>2 && readNormalNr(pos+8, 2)!=0xffff)
|
|
|
|
{
|
|
|
|
int rettt = readNormalNr(pos+8, 2);
|
|
|
|
if(rettt>32768)
|
|
|
|
rettt = 65536-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(2,ins);
|
|
|
|
ret.slots.insert(tt);
|
|
|
|
}
|
|
|
|
if(number>3 && readNormalNr(pos+12, 2)!=0xffff)
|
|
|
|
{
|
|
|
|
int rettt = readNormalNr(pos+12, 2);
|
|
|
|
if(rettt>32768)
|
|
|
|
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
|
|
|
|
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
|
|
|
|
ins.second = readNormalNr(pos+14, 2);
|
|
|
|
std::pair<int,std::pair<CCreature *, int> > tt(3,ins);
|
|
|
|
ret.slots.insert(tt);
|
|
|
|
}
|
|
|
|
if(number>4 && readNormalNr(pos+16, 2)!=0xffff)
|
|
|
|
{
|
|
|
|
int rettt = readNormalNr(pos+16, 2);
|
|
|
|
if(rettt>32768)
|
|
|
|
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
|
|
|
|
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
|
|
|
|
ins.second = readNormalNr(pos+18, 2);
|
|
|
|
std::pair<int,std::pair<CCreature *, int> > tt(4,ins);
|
|
|
|
ret.slots.insert(tt);
|
|
|
|
}
|
|
|
|
if(number>5 && readNormalNr(pos+20, 2)!=0xffff)
|
|
|
|
{
|
|
|
|
int rettt = readNormalNr(pos+20, 2);
|
|
|
|
if(rettt>32768)
|
|
|
|
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
|
|
|
|
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
|
|
|
|
ins.second = readNormalNr(pos+22, 2);
|
|
|
|
std::pair<int,std::pair<CCreature *, int> > tt(5,ins);
|
|
|
|
ret.slots.insert(tt);
|
|
|
|
}
|
|
|
|
if(number>6 && readNormalNr(pos+24, 2)!=0xffff)
|
|
|
|
{
|
|
|
|
int rettt = readNormalNr(pos+24, 2);
|
|
|
|
if(rettt>32768)
|
|
|
|
rettt = 65536-rettt+CGameInfo::mainObj->creh->creatures.size()-16;
|
|
|
|
ins.first = &(CGameInfo::mainObj->creh->creatures[rettt]);
|
|
|
|
ins.second = readNormalNr(pos+26, 2);
|
|
|
|
std::pair<int,std::pair<CCreature *, int> > tt(6,ins);
|
|
|
|
ret.slots.insert(tt);
|
|
|
|
}
|
|
|
|
return ret;
|
2007-06-13 23:17:48 +03:00
|
|
|
}
|
2007-08-26 19:02:36 +03:00
|
|
|
else
|
2007-06-13 23:17:48 +03:00
|
|
|
{
|
2007-08-26 19:02:36 +03:00
|
|
|
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;
|
2007-06-13 23:17:48 +03:00
|
|
|
}
|
|
|
|
}
|
2007-07-13 14:27:58 +03:00
|
|
|
|
2007-07-13 18:10:27 +03:00
|
|
|
void CAmbarCendamo::processMap(std::vector<std::string> & defsToUnpack)
|
2007-07-13 14:27:58 +03:00
|
|
|
{
|
2007-07-13 18:10:27 +03:00
|
|
|
resDefNames.push_back("AVTRNDM0.DEF");
|
|
|
|
resDefNames.push_back("AVTWOOD0.DEF");
|
|
|
|
resDefNames.push_back("AVTMERC0.DEF");
|
|
|
|
resDefNames.push_back("AVTORE0.DEF");
|
|
|
|
resDefNames.push_back("AVTSULF0.DEF");
|
|
|
|
resDefNames.push_back("AVTCRYS0.DEF");
|
|
|
|
resDefNames.push_back("AVTGEMS0.DEF");
|
|
|
|
resDefNames.push_back("AVTGOLD0.DEF");
|
|
|
|
resDefNames.push_back("ZMITHR.DEF");
|
2007-07-14 16:27:13 +03:00
|
|
|
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector<CGDefInfo*> resDefNumbers;
|
2007-07-14 16:27:13 +03:00
|
|
|
for(int hh=0; hh<resDefNames.size(); ++hh)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
resDefNumbers.push_back(NULL);
|
2007-07-14 16:27:13 +03:00
|
|
|
for(int k=0; k<map.defy.size(); ++k)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
std::string buf = map.defy[k]->name;
|
2007-07-14 16:27:13 +03:00
|
|
|
std::transform(buf.begin(), buf.end(), buf.begin(), (int(*)(int))toupper);
|
|
|
|
if(resDefNames[hh] == buf)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
resDefNumbers[resDefNumbers.size()-1] = map.defy[k];
|
2007-07-14 16:27:13 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::vector<std::string> creDefNames;
|
|
|
|
for(int dd=0; dd<140; ++dd) //we do not use here WoG units
|
|
|
|
{
|
|
|
|
creDefNames.push_back(CGI->dobjinfo->objs[dd+1184].defName);
|
|
|
|
}
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector<CGDefInfo*> creDefNumbers;
|
2007-07-14 16:27:13 +03:00
|
|
|
for(int ee=0; ee<creDefNames.size(); ++ee)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
creDefNumbers.push_back(NULL);
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
std::vector<std::string> artDefNames;
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector<CGDefInfo* > artDefNumbers;
|
2007-07-15 19:39:07 +03:00
|
|
|
for(int bb=0; bb<162; ++bb)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-07-15 19:39:07 +03:00
|
|
|
if(CGI->arth->artifacts[CGI->dobjinfo->objs[bb+213].subtype].aClass!=EartClass::SartClass)
|
2007-10-27 22:38:48 +03:00
|
|
|
artDefNames.push_back(CGI->dobjinfo->objs[bb+213].defName);
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
for(int ee=0; ee<artDefNames.size(); ++ee)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
artDefNumbers.push_back(NULL);
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
2007-07-15 19:39:07 +03:00
|
|
|
|
|
|
|
std::vector<std::string> art1DefNames;
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector<CGDefInfo*> art1DefNumbers;
|
2007-07-15 19:39:07 +03:00
|
|
|
for(int bb=0; bb<162; ++bb)
|
|
|
|
{
|
|
|
|
if(CGI->arth->artifacts[CGI->dobjinfo->objs[bb+213].subtype].aClass==EartClass::TartClass)
|
|
|
|
art1DefNames.push_back(CGI->dobjinfo->objs[bb+213].defName);
|
|
|
|
}
|
|
|
|
for(int ee=0; ee<art1DefNames.size(); ++ee)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
art1DefNumbers.push_back(NULL);
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> art2DefNames;
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector<CGDefInfo*> art2DefNumbers;
|
2007-07-15 19:39:07 +03:00
|
|
|
for(int bb=0; bb<162; ++bb)
|
|
|
|
{
|
|
|
|
if(CGI->arth->artifacts[CGI->dobjinfo->objs[bb+213].subtype].aClass==EartClass::NartClass)
|
|
|
|
art2DefNames.push_back(CGI->dobjinfo->objs[bb+213].defName);
|
|
|
|
}
|
|
|
|
for(int ee=0; ee<art2DefNames.size(); ++ee)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
art2DefNumbers.push_back(NULL);
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> art3DefNames;
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector<CGDefInfo*> art3DefNumbers;
|
2007-07-15 19:39:07 +03:00
|
|
|
for(int bb=0; bb<162; ++bb)
|
|
|
|
{
|
|
|
|
if(CGI->arth->artifacts[CGI->dobjinfo->objs[bb+213].subtype].aClass==EartClass::JartClass)
|
|
|
|
art3DefNames.push_back(CGI->dobjinfo->objs[bb+213].defName);
|
|
|
|
}
|
|
|
|
for(int ee=0; ee<art3DefNames.size(); ++ee)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
art3DefNumbers.push_back(NULL);
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> art4DefNames;
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector<CGDefInfo*> art4DefNumbers;
|
2007-07-15 19:39:07 +03:00
|
|
|
for(int bb=0; bb<162; ++bb)
|
|
|
|
{
|
|
|
|
if(CGI->arth->artifacts[CGI->dobjinfo->objs[bb+213].subtype].aClass==EartClass::RartClass)
|
|
|
|
art4DefNames.push_back(CGI->dobjinfo->objs[bb+213].defName);
|
|
|
|
}
|
|
|
|
for(int ee=0; ee<art4DefNames.size(); ++ee)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
art4DefNumbers.push_back(NULL);
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
2007-07-14 16:27:13 +03:00
|
|
|
|
2007-08-01 17:06:04 +03:00
|
|
|
std::vector<std::string> town0DefNames; //without fort
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector<CGDefInfo*> town0DefNumbers;
|
2007-08-01 17:06:04 +03:00
|
|
|
std::vector<std::string> town1DefNames; //with fort
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector<CGDefInfo*> town1DefNumbers;
|
2007-08-01 17:06:04 +03:00
|
|
|
|
2007-08-03 16:56:36 +03:00
|
|
|
for(int dd=0; dd<F_NUMBER; ++dd)
|
2007-08-01 17:06:04 +03:00
|
|
|
{
|
|
|
|
town1DefNames.push_back(CGI->dobjinfo->objs[dd+385].defName);
|
2007-10-27 22:38:48 +03:00
|
|
|
town1DefNumbers.push_back(NULL);
|
2007-08-01 17:06:04 +03:00
|
|
|
}
|
2007-08-03 16:56:36 +03:00
|
|
|
|
|
|
|
std::vector< std::vector<std::string> > creGenNames;
|
2007-10-27 22:38:48 +03:00
|
|
|
std::vector< std::vector<CGDefInfo*> > creGenNumbers;
|
2007-08-03 16:56:36 +03:00
|
|
|
creGenNames.resize(F_NUMBER);
|
|
|
|
creGenNumbers.resize(F_NUMBER);
|
|
|
|
|
|
|
|
for(int ff=0; ff<F_NUMBER-1; ++ff)
|
|
|
|
{
|
|
|
|
for(int dd=0; dd<7; ++dd)
|
|
|
|
{
|
|
|
|
creGenNames[ff].push_back(CGI->dobjinfo->objs[395+7*ff+dd].defName);
|
2007-10-27 22:38:48 +03:00
|
|
|
creGenNumbers[ff].push_back(NULL);
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int dd=0; dd<7; ++dd)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
creGenNumbers[8].push_back(NULL);
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
creGenNames[F_NUMBER-1].push_back(CGI->dobjinfo->objs[457].defName);
|
|
|
|
creGenNames[F_NUMBER-1].push_back(CGI->dobjinfo->objs[452].defName);
|
|
|
|
creGenNames[F_NUMBER-1].push_back(CGI->dobjinfo->objs[455].defName);
|
|
|
|
creGenNames[F_NUMBER-1].push_back(CGI->dobjinfo->objs[454].defName);
|
|
|
|
creGenNames[F_NUMBER-1].push_back(CGI->dobjinfo->objs[453].defName);
|
|
|
|
creGenNames[F_NUMBER-1].push_back(CGI->dobjinfo->objs[458].defName);
|
|
|
|
creGenNames[F_NUMBER-1].push_back(CGI->dobjinfo->objs[459].defName);
|
2007-08-11 17:58:07 +03:00
|
|
|
|
2007-10-27 22:38:48 +03:00
|
|
|
for(int b=0; b<CGI->scenarioOps.playerInfos.size(); ++b) // choosing random player alignment
|
2007-08-11 17:58:07 +03:00
|
|
|
{
|
|
|
|
if(CGI->scenarioOps.playerInfos[b].castle==-1)
|
|
|
|
CGI->scenarioOps.playerInfos[b].castle = rand()%F_NUMBER;
|
|
|
|
}
|
2007-08-01 17:06:04 +03:00
|
|
|
|
2007-07-14 16:27:13 +03:00
|
|
|
//variables initialized
|
2007-07-13 18:10:27 +03:00
|
|
|
for(int j=0; j<CGI->objh->objInstances.size(); ++j)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * curDef = CGI->objh->objInstances[j]->defInfo;
|
2007-07-13 18:10:27 +03:00
|
|
|
switch(getDefType(curDef))
|
|
|
|
{
|
|
|
|
case EDefType::RESOURCE_DEF:
|
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==76) //resource to specify
|
2007-07-13 18:10:27 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 79;
|
|
|
|
nxt->subid = rand()%7;
|
|
|
|
if(resDefNumbers[nxt->subid+1]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = resDefNumbers[nxt->subid+1];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = resDefNames[nxt->subid+1];
|
2007-07-13 18:10:27 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-13 18:10:27 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-13 18:10:27 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-13 18:10:27 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(resDefNumbers[nxt->subid+1]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
resDefNumbers[nxt->subid+1] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
2007-07-13 18:10:27 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-07-14 16:27:13 +03:00
|
|
|
case EDefType::CREATURES_DEF:
|
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==72) //random monster lvl 1
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 54;
|
|
|
|
nxt->subid = 14*(rand()%9)+rand()%2;
|
|
|
|
if(creDefNumbers[nxt->subid]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creDefNumbers[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creDefNames[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-14 16:27:13 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creDefNumbers[nxt->subid]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creDefNumbers[nxt->subid] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==73) //random monster lvl 2
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 54;
|
|
|
|
nxt->subid = 14*(rand()%9)+rand()%2+2;
|
|
|
|
if(creDefNumbers[nxt->subid]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creDefNumbers[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creDefNames[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-14 16:27:13 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creDefNumbers[nxt->subid]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creDefNumbers[nxt->subid] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==74) //random monster lvl 3
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo *nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 54;
|
|
|
|
nxt->subid = 14*(rand()%9)+rand()%2+4;
|
|
|
|
if(creDefNumbers[nxt->subid]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creDefNumbers[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creDefNames[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-14 16:27:13 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creDefNumbers[nxt->subid]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creDefNumbers[nxt->subid] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==75) //random monster lvl 4
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 54;
|
|
|
|
nxt->subid = 14*(rand()%9)+rand()%2+6;
|
|
|
|
if(creDefNumbers[nxt->subid]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creDefNumbers[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creDefNames[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-14 16:27:13 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creDefNumbers[nxt->subid]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creDefNumbers[nxt->subid] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==162) //random monster lvl 5
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 54;
|
|
|
|
nxt->subid = 14*(rand()%9)+rand()%2+8;
|
|
|
|
if(creDefNumbers[nxt->subid]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creDefNumbers[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creDefNames[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-14 16:27:13 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creDefNumbers[nxt->subid]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creDefNumbers[nxt->subid] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==163) //random monster lvl 6
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo* nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 54;
|
|
|
|
nxt->subid = 14*(rand()%9)+rand()%2+10;
|
|
|
|
if(creDefNumbers[nxt->subid]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creDefNumbers[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creDefNames[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-14 16:27:13 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creDefNumbers[nxt->subid]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creDefNumbers[nxt->subid] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==164) //random monster lvl 7
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 54;
|
|
|
|
nxt->subid = 14*(rand()%9)+rand()%2+12;
|
|
|
|
if(creDefNumbers[nxt->subid]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creDefNumbers[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creDefNames[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-14 16:27:13 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creDefNumbers[nxt->subid]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creDefNumbers[nxt->subid] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==71) //random monster (any level)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 54;
|
|
|
|
nxt->subid = rand()%126;
|
|
|
|
if(creDefNumbers[nxt->subid]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creDefNumbers[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creDefNames[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-14 16:27:13 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creDefNumbers[nxt->subid]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creDefNumbers[nxt->subid] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} //end of case
|
|
|
|
case EDefType::ARTIFACT_DEF:
|
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==65) //random atrifact (any class)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo *nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 5;
|
|
|
|
nxt->subid = rand()%artDefNames.size();
|
|
|
|
if(artDefNumbers[nxt->subid]!=NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = artDefNumbers[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = artDefNames[nxt->subid];
|
2007-07-14 16:27:13 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-14 16:27:13 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(artDefNumbers[nxt->subid]==NULL)
|
2007-07-14 16:27:13 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
artDefNumbers[nxt->subid] = nxt;
|
2007-07-14 16:27:13 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==66) //random atrifact (treasure)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo* nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 5;
|
|
|
|
nxt->subid = rand()%art1DefNames.size();
|
|
|
|
if(art1DefNumbers[nxt->subid]!=NULL)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = art1DefNumbers[nxt->subid];
|
2007-07-15 19:39:07 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = art1DefNames[nxt->subid];
|
2007-07-15 19:39:07 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-15 19:39:07 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(art1DefNumbers[nxt->subid]==NULL)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
art1DefNumbers[nxt->subid] = nxt;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==67) //random atrifact (minor)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo *nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 5;
|
|
|
|
nxt->subid = rand()%art2DefNames.size();
|
|
|
|
if(art2DefNumbers[nxt->subid]!=NULL)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = art2DefNumbers[nxt->subid];
|
2007-07-15 19:39:07 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = art2DefNames[nxt->subid];
|
2007-07-15 19:39:07 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-15 19:39:07 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(art2DefNumbers[nxt->subid]==NULL)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
art2DefNumbers[nxt->subid] = nxt;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==68) //random atrifact (major)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo* nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 5;
|
|
|
|
nxt->subid = rand()%art3DefNames.size();
|
|
|
|
if(art3DefNumbers[nxt->subid]!=NULL)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = art3DefNumbers[nxt->subid];
|
2007-07-15 19:39:07 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = art3DefNames[nxt->subid];
|
2007-07-15 19:39:07 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-15 19:39:07 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(art3DefNumbers[nxt->subid]==NULL)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
art3DefNumbers[nxt->subid] =nxt;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==69) //random atrifact (relic)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo *nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 5;
|
|
|
|
nxt->subid = rand()%art4DefNames.size();
|
|
|
|
if(art4DefNumbers[nxt->subid]!=NULL)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = art4DefNumbers[nxt->subid];
|
2007-07-15 19:39:07 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = art4DefNames[nxt->subid];
|
2007-07-15 19:39:07 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-07-15 19:39:07 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(art4DefNumbers[nxt->subid]==NULL)
|
2007-07-15 19:39:07 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
art4DefNumbers[nxt->subid] = nxt;
|
2007-07-15 19:39:07 +03:00
|
|
|
}
|
|
|
|
}
|
2007-07-14 16:27:13 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-08-01 17:06:04 +03:00
|
|
|
case EDefType::TOWN_DEF:
|
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
if(curDef->id==77) //random town
|
2007-08-01 17:06:04 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo* nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 98;
|
2007-08-08 22:28:56 +03:00
|
|
|
if(((CCastleObjInfo*)CGI->objh->objInstances[j]->info)->player==0xff)
|
2007-08-01 17:06:04 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->subid = rand()%town1DefNames.size();
|
2007-08-01 17:06:04 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-08-08 22:28:56 +03:00
|
|
|
if(CGI->scenarioOps.getIthPlayersSettings(((CCastleObjInfo*)CGI->objh->objInstances[j]->info)->player).castle>-1)
|
2007-08-01 17:06:04 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->subid = CGI->scenarioOps.getIthPlayersSettings(((CCastleObjInfo*)CGI->objh->objInstances[j]->info)->player).castle;
|
2007-08-01 17:06:04 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->subid = rand()%town1DefNames.size();
|
2007-08-01 17:06:04 +03:00
|
|
|
}
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
if(town1DefNumbers[nxt->subid]!=NULL)
|
2007-08-01 17:06:04 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = town1DefNumbers[nxt->subid];
|
2007-08-01 17:06:04 +03:00
|
|
|
continue;
|
|
|
|
}
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = town1DefNames[nxt->subid];
|
2007-08-01 17:06:04 +03:00
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-08-01 17:06:04 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-08-01 17:06:04 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-08-01 17:06:04 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(town1DefNumbers[nxt->subid]==NULL)
|
2007-08-01 17:06:04 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
town1DefNumbers[nxt->subid] = nxt;
|
2007-08-01 17:06:04 +03:00
|
|
|
}
|
2007-10-14 15:11:18 +03:00
|
|
|
for (int ij=0;ij<CGI->townh->townInstances.size();ij++) // wyharatac gdy bedzie dziedziczenie
|
|
|
|
{
|
|
|
|
if (CGI->townh->townInstances[ij]->pos==CGI->objh->objInstances[j]->pos)
|
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->townh->townInstances[ij]->town = &CGI->townh->towns[nxt->subid];
|
2007-10-14 15:11:18 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-08-01 17:06:04 +03:00
|
|
|
}
|
|
|
|
//((CCastleObjInfo*)CGI->objh->objInstances[j].info)
|
|
|
|
break;
|
|
|
|
}
|
2007-10-13 21:49:43 +03:00
|
|
|
case EDefType::HERO_DEF:
|
|
|
|
{
|
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
CGI->objh->objInstances[j]->defInfo->name);
|
2007-10-13 21:49:43 +03:00
|
|
|
|
2007-10-27 22:38:48 +03:00
|
|
|
CGI->objh->objInstances[j]->defInfo->printPriority = 0;
|
2007-10-13 21:49:43 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGI->objh->objInstances[j]->defInfo->isOnDefList = false;
|
2007-10-13 21:49:43 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGI->objh->objInstances[j]->defInfo->isOnDefList = true;
|
2007-10-13 21:49:43 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-07-14 16:27:13 +03:00
|
|
|
} //end of main switch
|
|
|
|
} //end of main loop
|
2007-08-03 16:56:36 +03:00
|
|
|
for(int j=0; j<CGI->objh->objInstances.size(); ++j) //for creature dwellings on map (they are town type dependent)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * curDef = CGI->objh->objInstances[j]->defInfo;
|
2007-08-03 16:56:36 +03:00
|
|
|
switch(getDefType(curDef))
|
|
|
|
{
|
|
|
|
case EDefType::CREGEN_DEF:
|
|
|
|
{
|
2007-08-08 22:28:56 +03:00
|
|
|
if(((CCreGenObjInfo*)CGI->objh->objInstances[j]->info)->asCastle)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo *nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 17;
|
2007-08-03 16:56:36 +03:00
|
|
|
for(int vv=0; vv<CGI->objh->objInstances.size(); ++vv)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
if(getDefType(CGI->objh->objInstances[vv]->defInfo)==EDefType::TOWN_DEF)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
|
|
|
if(
|
2007-08-08 22:28:56 +03:00
|
|
|
((CCastleObjInfo*)CGI->objh->objInstances[vv]->info)->bytes[0]==((CCreGenObjInfo*)CGI->objh->objInstances[j]->info)->bytes[0]
|
|
|
|
&& ((CCastleObjInfo*)CGI->objh->objInstances[vv]->info)->bytes[1]==((CCreGenObjInfo*)CGI->objh->objInstances[j]->info)->bytes[1]
|
|
|
|
&& ((CCastleObjInfo*)CGI->objh->objInstances[vv]->info)->bytes[2]==((CCreGenObjInfo*)CGI->objh->objInstances[j]->info)->bytes[2]
|
|
|
|
&& ((CCastleObjInfo*)CGI->objh->objInstances[vv]->info)->bytes[3]==((CCreGenObjInfo*)CGI->objh->objInstances[j]->info)->bytes[3])
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
|
|
|
for(int mm=0; mm<town1DefNames.size(); ++mm)
|
|
|
|
{
|
|
|
|
std::transform(town1DefNames[mm].begin(), town1DefNames[mm].end(), town1DefNames[mm].begin(), (int(*)(int))toupper);
|
2007-10-27 22:38:48 +03:00
|
|
|
std::string hlp = CGI->objh->objInstances[vv]->defInfo->name;
|
2007-08-03 16:56:36 +03:00
|
|
|
std::transform(hlp.begin(), hlp.end(), hlp.begin(), (int(*)(int))toupper);
|
|
|
|
if(town1DefNames[mm]==hlp)
|
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->subid = mm;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-27 22:38:48 +03:00
|
|
|
int lvl = atoi(CGI->objh->objInstances[j]->defInfo->name.substr(7, 8).c_str())-1;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creGenNames[nxt->subid][lvl];
|
|
|
|
if(creGenNumbers[nxt->subid][lvl]!=NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creGenNumbers[nxt->subid][lvl];
|
2007-08-03 16:56:36 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-08-03 16:56:36 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creGenNumbers[nxt->subid][lvl]==NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creGenNumbers[nxt->subid][lvl] = nxt;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else //if not as castle
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 17;
|
2007-08-03 16:56:36 +03:00
|
|
|
std::vector<int> possibleTowns;
|
|
|
|
for(int bb=0; bb<8; ++bb)
|
|
|
|
{
|
2007-08-08 22:28:56 +03:00
|
|
|
if(((CCreGenObjInfo*)CGI->objh->objInstances[j]->info)->castles[0] & (1<<bb))
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
|
|
|
possibleTowns.push_back(bb);
|
|
|
|
}
|
|
|
|
}
|
2007-08-08 22:28:56 +03:00
|
|
|
if(((CCreGenObjInfo*)CGI->objh->objInstances[j]->info)->castles[1])
|
2007-08-03 16:56:36 +03:00
|
|
|
possibleTowns.push_back(8);
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->subid = possibleTowns[rand()%possibleTowns.size()];
|
2007-10-27 22:38:48 +03:00
|
|
|
int lvl = atoi(CGI->objh->objInstances[j]->defInfo->name.substr(7, 8).c_str())-1;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creGenNames[nxt->subid][lvl];
|
|
|
|
if(creGenNumbers[nxt->subid][lvl]!=NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creGenNumbers[nxt->subid][lvl];
|
2007-08-03 16:56:36 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-08-03 16:56:36 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creGenNumbers[nxt->subid][lvl]==NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creGenNumbers[nxt->subid][lvl] = nxt;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EDefType::CREGEN2_DEF:
|
|
|
|
{
|
2007-08-08 22:28:56 +03:00
|
|
|
if(((CCreGenObjInfo*)CGI->objh->objInstances[j]->info)->asCastle)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 17;
|
2007-08-03 16:56:36 +03:00
|
|
|
for(int vv=0; vv<CGI->objh->objInstances.size(); ++vv)
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
if(getDefType(CGI->objh->objInstances[vv]->defInfo)==EDefType::TOWN_DEF)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
|
|
|
if(
|
2007-08-08 22:28:56 +03:00
|
|
|
((CCastleObjInfo*)CGI->objh->objInstances[vv]->info)->bytes[0]==((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->bytes[0]
|
|
|
|
&& ((CCastleObjInfo*)CGI->objh->objInstances[vv]->info)->bytes[1]==((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->bytes[1]
|
|
|
|
&& ((CCastleObjInfo*)CGI->objh->objInstances[vv]->info)->bytes[2]==((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->bytes[2]
|
|
|
|
&& ((CCastleObjInfo*)CGI->objh->objInstances[vv]->info)->bytes[3]==((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->bytes[3])
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
|
|
|
for(int mm=0; mm<town1DefNames.size(); ++mm)
|
|
|
|
{
|
|
|
|
std::transform(town1DefNames[mm].begin(), town1DefNames[mm].end(), town1DefNames[mm].begin(), (int(*)(int))toupper);
|
2007-10-27 22:38:48 +03:00
|
|
|
std::string hlp = CGI->objh->objInstances[vv]->defInfo->name;
|
2007-08-03 16:56:36 +03:00
|
|
|
std::transform(hlp.begin(), hlp.end(), hlp.begin(), (int(*)(int))toupper);
|
|
|
|
if(town1DefNames[mm]==hlp)
|
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->subid = mm;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-08-25 20:51:32 +03:00
|
|
|
int lvl;
|
|
|
|
if((((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->maxLevel - ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel)!=0)
|
|
|
|
lvl = rand()%(((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->maxLevel - ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel) + ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel;
|
|
|
|
else lvl = 0;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creGenNames[nxt->subid][lvl];
|
|
|
|
if(creGenNumbers[nxt->subid][lvl]!=NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creGenNumbers[nxt->subid][lvl];
|
2007-08-03 16:56:36 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-08-03 16:56:36 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creGenNumbers[nxt->subid][lvl]==NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creGenNumbers[nxt->subid][lvl] = nxt;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else //if not as castle
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 17;
|
2007-08-03 16:56:36 +03:00
|
|
|
std::vector<int> possibleTowns;
|
|
|
|
for(int bb=0; bb<8; ++bb)
|
|
|
|
{
|
2007-08-08 22:28:56 +03:00
|
|
|
if(((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->castles[0] & (1<<bb))
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
|
|
|
possibleTowns.push_back(bb);
|
|
|
|
}
|
|
|
|
}
|
2007-08-08 22:28:56 +03:00
|
|
|
if(((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->castles[1])
|
2007-08-03 16:56:36 +03:00
|
|
|
possibleTowns.push_back(8);
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->subid = possibleTowns[rand()%possibleTowns.size()];
|
2007-08-08 22:28:56 +03:00
|
|
|
int lvl = rand()%(((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->maxLevel - ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel) + ((CCreGen2ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creGenNames[nxt->subid][lvl];
|
|
|
|
if(creGenNumbers[nxt->subid][lvl]!=NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creGenNumbers[nxt->subid][lvl];
|
2007-08-03 16:56:36 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-08-03 16:56:36 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creGenNumbers[nxt->subid][lvl]==NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creGenNumbers[nxt->subid][lvl] = nxt;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case EDefType::CREGEN3_DEF:
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
CGDefInfo * nxt = curDef;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->id = 17;
|
|
|
|
nxt->subid = atoi(CGI->objh->objInstances[j]->defInfo->name.substr(7, 8).c_str());
|
2007-08-06 16:09:41 +03:00
|
|
|
int lvl = -1;
|
2007-08-08 22:28:56 +03:00
|
|
|
CCreGen3ObjInfo * ct = (CCreGen3ObjInfo*)CGI->objh->objInstances[j]->info;
|
2007-08-06 16:09:41 +03:00
|
|
|
if(ct->maxLevel>7)
|
|
|
|
ct->maxLevel = 7;
|
|
|
|
if(ct->minLevel<1)
|
|
|
|
ct->minLevel = 1;
|
2007-08-08 22:28:56 +03:00
|
|
|
if((((CCreGen3ObjInfo*)CGI->objh->objInstances[j]->info)->maxLevel - ((CCreGen3ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel)!=0)
|
|
|
|
lvl = rand()%(((CCreGen3ObjInfo*)CGI->objh->objInstances[j]->info)->maxLevel - ((CCreGen3ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel) + ((CCreGen3ObjInfo*)CGI->objh->objInstances[j]->info)->minLevel;
|
2007-08-06 16:09:41 +03:00
|
|
|
else
|
2007-08-08 22:28:56 +03:00
|
|
|
lvl = ((CCreGen3ObjInfo*)CGI->objh->objInstances[j]->info)->maxLevel;
|
2007-10-28 19:56:16 +02:00
|
|
|
nxt->name = creGenNames[nxt->subid][lvl];
|
|
|
|
if(creGenNumbers[nxt->subid][lvl]!=NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
CGI->objh->objInstances[j]->defInfo = creGenNumbers[nxt->subid][lvl];
|
2007-08-03 16:56:36 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
std::vector<DefObjInfo>::iterator pit = std::find(CGameInfo::mainObj->dobjinfo->objs.begin(), CGameInfo::mainObj->dobjinfo->objs.end(),
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->name);
|
2007-08-03 16:56:36 +03:00
|
|
|
if(pit == CGameInfo::mainObj->dobjinfo->objs.end())
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->isOnDefList = false;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-27 22:38:48 +03:00
|
|
|
nxt->printPriority = pit->priority;
|
|
|
|
nxt->isOnDefList = true;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
map.defy.push_back(nxt); // add this def to the vector
|
2007-10-27 22:38:48 +03:00
|
|
|
defsToUnpack.push_back(nxt->name);
|
|
|
|
CGI->objh->objInstances[j]->defInfo = nxt;
|
2007-10-28 19:56:16 +02:00
|
|
|
if(creGenNumbers[nxt->subid][lvl]==NULL)
|
2007-08-03 16:56:36 +03:00
|
|
|
{
|
2007-10-28 19:56:16 +02:00
|
|
|
creGenNumbers[nxt->subid][lvl] = nxt;
|
2007-08-03 16:56:36 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}//end of main switch
|
|
|
|
} //end of sencond for loop
|
2007-07-13 14:27:58 +03:00
|
|
|
}
|