#include "stdafx.h" #include "CAmbarCendamo.h" #include "CSemiDefHandler.h" #include 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 delete is; } CAmbarCendamo::~CAmbarCendamo () {// free memory for (int ii=0;iiArtifactID = bufor[i+2]; nr=2; break; } case gatherTroop: { map.vicConDetails = new VicCon1(); int temp1 = bufor[i+2]; int temp2 = bufor[i+3]; ((VicCon1*)map.vicConDetails)->monsterID = bufor[i+2]; ((VicCon1*)map.vicConDetails)->neededQuantity=readNormalNr(i+4); nr=6; 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(); nr=3; break; } case takeMines: { map.vicConDetails = new CspecificVictoryConidtions(); nr=3; 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++]; } case lossHero: { map.lossCondition.heroPos.x=bufor[i++]; map.lossCondition.heroPos.y=bufor[i++]; map.lossCondition.heroPos.z=bufor[i++]; } case timeExpires: { map.lossCondition.timeLimit = readNormalNr(i++,2); i++; } } 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++]; } } i+=87; THC std::cout<<"Wczytywanie naglowka: "< loadedTypes; for (int i=0; iopenDef(("H3sprite.lod\\"+sdh->nameFromType(map.terrain[i][j].tertype)).c_str()); loadedTypes.insert(map.terrain[i][j].tertype); defs.push_back(sdh); } if (loadedTypes.find(map.undergroungTerrain[i][j].tertype)==loadedTypes.end()) { CSemiDefHandler *sdh = new CSemiDefHandler(); sdh->openDef(("H3sprite.lod\\"+sdh->nameFromType(map.undergroungTerrain[i][j].tertype)).c_str()); loadedTypes.insert(map.undergroungTerrain[i][j].tertype); defs.push_back(sdh); } } } };