2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2007-06-20 15:00:18 +03:00
|
|
|
#include "map.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CObjectHandler.h"
|
|
|
|
#include "CDefObjInfoHandler.h"
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "VCMI_Lib.h"
|
2008-07-25 20:28:28 +03:00
|
|
|
#include <zlib.h>
|
|
|
|
#include <boost/crc.hpp>
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CLodHandler.h"
|
|
|
|
#include "CArtHandler.h"
|
|
|
|
#include "CCreatureHandler.h"
|
|
|
|
#include "CSpellHandler.h"
|
2011-09-03 23:45:27 +03:00
|
|
|
#include "../lib/JsonNode.h"
|
2011-10-08 04:23:46 +03:00
|
|
|
#include "vcmi_endian.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
#include "GameConstants.h"
|
2011-12-17 21:59:59 +03:00
|
|
|
#include "CStopWatch.h"
|
2009-04-15 17:03:31 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* map.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-08-25 23:02:38 +03:00
|
|
|
static std::set<si32> convertBuildings(const std::set<si32> h3m, int castleID, bool addAuxiliary = true)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
|
|
|
std::map<int,int> mapa;
|
2008-08-01 14:21:15 +03:00
|
|
|
std::set<si32> ret;
|
2011-09-03 23:45:27 +03:00
|
|
|
|
|
|
|
// Note: this file is parsed many times.
|
2011-12-14 00:23:17 +03:00
|
|
|
const JsonNode config(GameConstants::DATA_DIR + "/config/buildings5.json");
|
2011-09-03 23:45:27 +03:00
|
|
|
|
|
|
|
BOOST_FOREACH(const JsonNode &entry, config["table"].Vector())
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-09-03 23:45:27 +03:00
|
|
|
int town = entry["town"].Float();
|
|
|
|
|
2010-07-26 01:47:59 +03:00
|
|
|
if ( town == castleID || town == -1 )
|
2011-09-03 23:45:27 +03:00
|
|
|
mapa[entry["h3"].Float()] = entry["vcmi"].Float();
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2011-09-03 23:45:27 +03:00
|
|
|
|
2008-08-01 14:21:15 +03:00
|
|
|
for(std::set<si32>::const_iterator i=h3m.begin();i!=h3m.end();i++)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
|
|
|
if(mapa[*i]>=0)
|
|
|
|
ret.insert(mapa[*i]);
|
2011-12-14 00:23:17 +03:00
|
|
|
else if(mapa[*i] >= (-GameConstants::CREATURES_PER_TOWN)) // horde buildings
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2010-01-01 20:54:31 +02:00
|
|
|
int level = (mapa[*i]);
|
|
|
|
ret.insert(level-30);//(-30)..(-36) - horde buildings (for game loading only), don't see other way to handle hordes in random towns
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-09-19 15:09:15 +03:00
|
|
|
tlog3<<"Conversion warning: unknown building "<<*i<<" in castle "<<castleID<<std::endl;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-25 23:02:38 +03:00
|
|
|
if(addAuxiliary)
|
|
|
|
{
|
|
|
|
ret.insert(10); //village hall is always present
|
|
|
|
ret.insert(-1); //houses near v.hall / eyecandies
|
|
|
|
ret.insert(-2); //terrain eyecandy, if -1 is used
|
|
|
|
}
|
2007-06-20 15:00:18 +03:00
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
if(ret.find(11)!=ret.end())
|
|
|
|
ret.insert(27);
|
|
|
|
if(ret.find(12)!=ret.end())
|
|
|
|
ret.insert(28);
|
|
|
|
if(ret.find(13)!=ret.end())
|
|
|
|
ret.insert(29);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
static ui32 intPow(ui32 a, ui32 b)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui32 ret=1;
|
|
|
|
for(ui32 i=0; i<b; ++i)
|
2008-06-21 16:27:52 +03:00
|
|
|
ret*=a;
|
|
|
|
return ret;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
static ui8 reverse(ui8 arg)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 ret = 0;
|
2008-06-21 16:27:52 +03:00
|
|
|
for (int i=0; i<8;i++)
|
|
|
|
{
|
|
|
|
if(((arg)&(1<<i))>>i)
|
|
|
|
{
|
|
|
|
ret |= (128>>i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2010-02-09 15:48:14 +02:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void readCreatureSet(CCreatureSet *out, const ui8 * bufor, int &i, int number, bool version) //version==true for >RoE maps
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2010-04-02 05:07:40 +03:00
|
|
|
const int bytesPerCre = version ? 4 : 3,
|
|
|
|
maxID = version ? 0xffff : 0xff;
|
|
|
|
|
|
|
|
for(int ir=0;ir < number; ir++)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-10-08 19:06:11 +03:00
|
|
|
int creID;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
if (version)
|
|
|
|
{
|
|
|
|
creID = read_le_u16(bufor + i+ir*bytesPerCre);
|
|
|
|
count = read_le_u16(bufor + i+ir*bytesPerCre + 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
creID = bufor[i+ir*bytesPerCre];
|
|
|
|
count = read_le_u16(bufor + i+ir*bytesPerCre + 1);
|
|
|
|
}
|
|
|
|
|
2010-04-02 05:07:40 +03:00
|
|
|
if(creID == maxID) //empty slot
|
|
|
|
continue;
|
2010-05-02 21:20:26 +03:00
|
|
|
|
2010-11-22 02:34:46 +02:00
|
|
|
CStackInstance *hlp = new CStackInstance();
|
|
|
|
hlp->count = count;
|
2010-05-02 21:20:26 +03:00
|
|
|
|
2010-04-02 05:07:40 +03:00
|
|
|
if(creID > maxID - 0xf)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2010-04-02 05:07:40 +03:00
|
|
|
creID = maxID + 1 - creID + VLC->creh->creatures.size();//this will happen when random object has random army
|
2010-11-22 02:34:46 +02:00
|
|
|
hlp->idRand = creID;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2010-04-02 05:07:40 +03:00
|
|
|
else
|
2010-11-22 02:34:46 +02:00
|
|
|
hlp->setType(creID);
|
2010-04-02 05:07:40 +03:00
|
|
|
|
2010-11-27 03:46:19 +02:00
|
|
|
out->putStack(ir, hlp);
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2010-04-02 05:07:40 +03:00
|
|
|
i+=number*bytesPerCre;
|
|
|
|
|
2010-11-22 02:34:46 +02:00
|
|
|
out->validTypes(true);
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2010-11-22 02:34:46 +02:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
CMapHeader::CMapHeader(const ui8 *map)
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
int i=0;
|
|
|
|
initFromMemory(map,i);
|
|
|
|
}
|
|
|
|
|
|
|
|
CMapHeader::CMapHeader()
|
|
|
|
{
|
|
|
|
areAnyPLayers = difficulty = levelLimit = howManyTeams = 0;
|
|
|
|
height = width = twoLevel = -1;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void CMapHeader::initFromMemory( const ui8 *bufor, int &i )
|
2009-01-06 20:42:20 +02:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
version = (Eformat)(read_le_u32(bufor + i)); i+=4; //map version
|
2010-03-01 20:22:22 +02:00
|
|
|
if(version != RoE && version != AB && version != SoD && version != WoG)
|
|
|
|
{
|
|
|
|
throw std::string("Invalid map format!");
|
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
areAnyPLayers = readChar(bufor,i); //invalid on some maps
|
2011-10-08 04:23:46 +03:00
|
|
|
height = width = (read_le_u32(bufor + i)); i+=4; // dimensions of map
|
2010-01-29 18:19:12 +02:00
|
|
|
twoLevel = readChar(bufor,i); //if there is underground
|
2009-01-06 20:42:20 +02:00
|
|
|
int pom;
|
|
|
|
name = readString(bufor,i);
|
|
|
|
description= readString(bufor,i);
|
|
|
|
difficulty = readChar(bufor,i); // reading map difficulty
|
|
|
|
if(version != RoE)
|
|
|
|
levelLimit = readChar(bufor,i); // hero level limit
|
2007-08-23 20:38:00 +03:00
|
|
|
else
|
|
|
|
levelLimit = 0;
|
2009-01-06 20:42:20 +02:00
|
|
|
loadPlayerInfo(pom, bufor, i);
|
|
|
|
loadViCLossConditions(bufor, i);
|
|
|
|
|
|
|
|
howManyTeams=bufor[i++]; //read number of teams
|
|
|
|
if(howManyTeams>0) //read team numbers
|
|
|
|
{
|
|
|
|
for(int rr=0; rr<8; ++rr)
|
|
|
|
{
|
2009-08-22 16:59:15 +03:00
|
|
|
players[rr].team = bufor[i++];
|
2009-01-06 20:42:20 +02:00
|
|
|
}
|
2007-08-23 20:38:00 +03:00
|
|
|
}
|
2009-08-27 11:04:32 +03:00
|
|
|
else//no alliances
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
for(int i=0;i<GameConstants::PLAYER_LIMIT;i++)
|
2009-08-27 11:04:32 +03:00
|
|
|
if(players[i].canComputerPlay || players[i].canHumanPlay)
|
|
|
|
players[i].team = howManyTeams++;
|
|
|
|
}
|
|
|
|
|
2009-08-17 11:50:31 +03:00
|
|
|
|
|
|
|
pom = i;
|
2011-12-14 00:23:17 +03:00
|
|
|
allowedHeroes.resize(GameConstants::HEROES_QUANTITY,false);
|
2010-11-09 13:27:58 +02:00
|
|
|
for(; i<pom+ (version == RoE ? 16 : 20) ; ++i)
|
2009-08-17 11:50:31 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 c = bufor[i];
|
2009-08-17 11:50:31 +03:00
|
|
|
for(int yy=0; yy<8; ++yy)
|
2011-12-14 00:23:17 +03:00
|
|
|
if((i-pom)*8+yy < GameConstants::HEROES_QUANTITY)
|
|
|
|
if(c == (c|((ui8)intPow(2, yy))))
|
2009-08-17 11:50:31 +03:00
|
|
|
allowedHeroes[(i-pom)*8+yy] = true;
|
|
|
|
}
|
|
|
|
if(version>RoE) //probably reserved for further heroes
|
2010-02-01 19:07:46 +02:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
int placeholdersQty = read_le_u32(bufor + i); i+=4;
|
2010-02-01 19:07:46 +02:00
|
|
|
for(int p = 0; p < placeholdersQty; p++)
|
|
|
|
placeholdedHeroes.push_back(bufor[i++]);
|
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
void CMapHeader::loadPlayerInfo( int &pom, const ui8 * bufor, int &i )
|
2009-01-06 20:42:20 +02:00
|
|
|
{
|
2009-01-11 00:08:18 +02:00
|
|
|
players.resize(8);
|
2007-06-20 15:00:18 +03:00
|
|
|
for (pom=0;pom<8;pom++)
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].canHumanPlay = bufor[i++];
|
|
|
|
players[pom].canComputerPlay = bufor[i++];
|
2010-01-29 18:19:12 +02:00
|
|
|
if ((!(players[pom].canHumanPlay || players[pom].canComputerPlay))) //if nobody can play with this player
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
switch(version)
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
case SoD: case WoG:
|
2007-08-23 20:38:00 +03:00
|
|
|
i+=13;
|
|
|
|
break;
|
2008-08-02 18:08:03 +03:00
|
|
|
case AB:
|
2007-08-23 20:38:00 +03:00
|
|
|
i+=12;
|
|
|
|
break;
|
2008-08-02 18:08:03 +03:00
|
|
|
case RoE:
|
2007-08-23 20:38:00 +03:00
|
|
|
i+=6;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-20 15:00:18 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].AITactic = bufor[i++];
|
2007-08-23 20:38:00 +03:00
|
|
|
|
2008-08-02 18:08:03 +03:00
|
|
|
if(version == SoD || version == WoG)
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].p7= bufor[i++];
|
|
|
|
else
|
|
|
|
players[pom].p7= -1;
|
2007-08-23 20:38:00 +03:00
|
|
|
|
2010-01-29 18:19:12 +02:00
|
|
|
//factions this player can choose
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].allowedFactions = 0;
|
|
|
|
players[pom].allowedFactions += bufor[i++];
|
2008-08-02 18:08:03 +03:00
|
|
|
if(version != RoE)
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].allowedFactions += (bufor[i++])*256;
|
2007-08-23 20:38:00 +03:00
|
|
|
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].isFactionRandom = bufor[i++];
|
|
|
|
players[pom].hasMainTown = bufor[i++];
|
|
|
|
if (players[pom].hasMainTown)
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2008-08-02 18:08:03 +03:00
|
|
|
if(version != RoE)
|
2007-08-23 20:38:00 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].generateHeroAtMainTown = bufor[i++];
|
|
|
|
players[pom].generateHero = bufor[i++];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-19 16:35:29 +02:00
|
|
|
players[pom].generateHeroAtMainTown = true;
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].generateHero = false;
|
2007-08-23 20:38:00 +03:00
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
|
|
|
|
players[pom].posOfMainTown.x = bufor[i++];
|
|
|
|
players[pom].posOfMainTown.y = bufor[i++];
|
|
|
|
players[pom].posOfMainTown.z = bufor[i++];
|
|
|
|
|
|
|
|
|
2007-06-20 15:00:18 +03:00
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].p8= bufor[i++];
|
|
|
|
players[pom].p9= bufor[i++];
|
2007-08-27 17:15:03 +03:00
|
|
|
if(players[pom].p9!=0xff)
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].mainHeroPortrait = bufor[i++];
|
2009-02-20 12:36:15 +02:00
|
|
|
players[pom].mainHeroName = readString(bufor,i);
|
2007-06-20 15:00:18 +03:00
|
|
|
}
|
2007-08-23 20:38:00 +03:00
|
|
|
|
2009-01-06 20:42:20 +02:00
|
|
|
if(version != RoE)
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2010-02-01 19:07:46 +02:00
|
|
|
players[pom].powerPlacehodlers = bufor[i++];//unknown byte
|
2009-01-06 20:42:20 +02:00
|
|
|
int heroCount = bufor[i++];
|
2007-06-20 15:00:18 +03:00
|
|
|
i+=3;
|
2007-08-23 20:38:00 +03:00
|
|
|
for (int pp=0;pp<heroCount;pp++)
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2007-08-23 20:38:00 +03:00
|
|
|
SheroName vv;
|
2009-01-06 20:42:20 +02:00
|
|
|
vv.heroID=bufor[i++];
|
|
|
|
int hnl = bufor[i++];
|
2007-08-23 20:38:00 +03:00
|
|
|
i+=3;
|
|
|
|
for (int zz=0;zz<hnl;zz++)
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
vv.heroName+=bufor[i++];
|
2007-08-23 20:38:00 +03:00
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
players[pom].heroesNames.push_back(vv);
|
2007-06-20 15:00:18 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void CMapHeader::loadViCLossConditions( const ui8 * bufor, int &i)
|
2009-01-06 20:42:20 +02:00
|
|
|
{
|
2010-01-29 22:52:45 +02:00
|
|
|
victoryCondition.obj = NULL;
|
2011-12-14 00:23:17 +03:00
|
|
|
victoryCondition.condition = (EVictoryConditionType::EVictoryConditionType)bufor[i++];
|
|
|
|
if (victoryCondition.condition != EVictoryConditionType::WINSTANDARD) //specific victory conditions
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
|
|
|
int nr;
|
2009-01-06 20:42:20 +02:00
|
|
|
switch (victoryCondition.condition) //read victory conditions
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
case EVictoryConditionType::ARTIFACT:
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
victoryCondition.ID = bufor[i+2];
|
2007-08-24 18:00:13 +03:00
|
|
|
nr=(version==RoE ? 1 : 2);
|
2007-06-20 15:00:18 +03:00
|
|
|
break;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
case EVictoryConditionType::GATHERTROOP:
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2010-01-29 22:52:45 +02:00
|
|
|
// int temp1 = bufor[i+2];
|
|
|
|
// int temp2 = bufor[i+3];
|
2009-01-06 20:42:20 +02:00
|
|
|
victoryCondition.ID = bufor[i+2];
|
2011-10-08 04:23:46 +03:00
|
|
|
victoryCondition.count = read_le_u32(bufor + i+(version==RoE ? 3 : 4));
|
2007-08-24 18:00:13 +03:00
|
|
|
nr=(version==RoE ? 5 : 6);
|
2007-06-20 15:00:18 +03:00
|
|
|
break;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
case EVictoryConditionType::GATHERRESOURCE:
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
victoryCondition.ID = bufor[i+2];
|
2011-10-08 04:23:46 +03:00
|
|
|
victoryCondition.count = read_le_u32(bufor + i+3);
|
2009-02-12 16:44:58 +02:00
|
|
|
nr = 5;
|
2007-06-20 15:00:18 +03:00
|
|
|
break;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
case EVictoryConditionType::BUILDCITY:
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
victoryCondition.pos.x = bufor[i+2];
|
|
|
|
victoryCondition.pos.y = bufor[i+3];
|
|
|
|
victoryCondition.pos.z = bufor[i+4];
|
|
|
|
victoryCondition.count = bufor[i+5];
|
|
|
|
victoryCondition.ID = bufor[i+6];
|
2009-02-12 16:44:58 +02:00
|
|
|
nr = 5;
|
2007-06-20 15:00:18 +03:00
|
|
|
break;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
case EVictoryConditionType::BUILDGRAIL:
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
if (bufor[i+4]>2)
|
|
|
|
victoryCondition.pos = int3(-1,-1,-1);
|
2007-06-20 15:00:18 +03:00
|
|
|
else
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
victoryCondition.pos.x = bufor[i+2];
|
|
|
|
victoryCondition.pos.y = bufor[i+3];
|
|
|
|
victoryCondition.pos.z = bufor[i+4];
|
2007-06-20 15:00:18 +03:00
|
|
|
}
|
2009-02-12 16:44:58 +02:00
|
|
|
nr = 3;
|
2007-06-20 15:00:18 +03:00
|
|
|
break;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
case EVictoryConditionType::BEATHERO:
|
|
|
|
case EVictoryConditionType::CAPTURECITY:
|
|
|
|
case EVictoryConditionType::BEATMONSTER:
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
victoryCondition.pos.x = bufor[i+2];
|
|
|
|
victoryCondition.pos.y = bufor[i+3];
|
|
|
|
victoryCondition.pos.z = bufor[i+4];
|
2009-02-12 16:44:58 +02:00
|
|
|
nr = 3;
|
2007-06-20 15:00:18 +03:00
|
|
|
break;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
case EVictoryConditionType::TAKEDWELLINGS:
|
|
|
|
case EVictoryConditionType::TAKEMINES:
|
2008-08-02 18:08:03 +03:00
|
|
|
{
|
2009-02-12 16:44:58 +02:00
|
|
|
nr = 0;
|
2007-06-20 15:00:18 +03:00
|
|
|
break;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
case EVictoryConditionType::TRANSPORTITEM:
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
victoryCondition.ID = bufor[i+2];
|
|
|
|
victoryCondition.pos.x = bufor[i+3];
|
|
|
|
victoryCondition.pos.y = bufor[i+4];
|
|
|
|
victoryCondition.pos.z = bufor[i+5];
|
2009-02-12 16:44:58 +02:00
|
|
|
nr = 4;
|
2007-06-20 15:00:18 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
victoryCondition.allowNormalVictory = bufor[i++];
|
|
|
|
victoryCondition.appliesToAI = bufor[i++];
|
2007-06-20 15:00:18 +03:00
|
|
|
i+=nr;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
lossCondition.typeOfLossCon = (ELossConditionType::ELossConditionType)bufor[i++];
|
2009-01-06 20:42:20 +02:00
|
|
|
switch (lossCondition.typeOfLossCon) //read loss conditions
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
case ELossConditionType::LOSSCASTLE:
|
|
|
|
case ELossConditionType::LOSSHERO:
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2010-01-29 22:52:45 +02:00
|
|
|
lossCondition.pos.x=bufor[i++];
|
|
|
|
lossCondition.pos.y=bufor[i++];
|
|
|
|
lossCondition.pos.z=bufor[i++];
|
2009-01-06 20:42:20 +02:00
|
|
|
break;
|
2007-06-20 15:00:18 +03:00
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
case ELossConditionType::TIMEEXPIRES:
|
2007-06-20 15:00:18 +03:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
lossCondition.timeLimit = read_le_u16(bufor + i);
|
|
|
|
i+=2;
|
2009-01-06 20:42:20 +02:00
|
|
|
break;
|
2007-06-20 15:00:18 +03:00
|
|
|
}
|
|
|
|
}
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
|
2009-08-27 11:04:32 +03:00
|
|
|
CMapHeader::~CMapHeader()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::initFromBytes(const ui8 * bufor, size_t size)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-11-27 16:14:20 +03:00
|
|
|
// Compute checksum
|
|
|
|
boost::crc_32_type result;
|
|
|
|
result.process_bytes(bufor, size);
|
|
|
|
checksum = result.checksum();
|
|
|
|
tlog0 << "\tOur map checksum: "<<result.checksum() << std::endl;
|
|
|
|
|
2009-01-06 20:42:20 +02:00
|
|
|
int i=0;
|
|
|
|
initFromMemory(bufor,i);
|
2011-12-17 21:59:59 +03:00
|
|
|
CStopWatch th;
|
2011-12-14 00:23:17 +03:00
|
|
|
th.getDiff();
|
2008-08-15 15:11:42 +03:00
|
|
|
readHeader(bufor, i);
|
2011-12-14 00:23:17 +03:00
|
|
|
tlog0<<"\tReading header: "<<th.getDiff()<<std::endl;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
if (victoryCondition.condition == EVictoryConditionType::ARTIFACT || victoryCondition.condition == EVictoryConditionType::TRANSPORTITEM)
|
2010-06-28 09:12:22 +03:00
|
|
|
{ //messy, but needed
|
|
|
|
allowedArtifact[victoryCondition.ID] = false;
|
|
|
|
}
|
|
|
|
|
2008-08-15 15:11:42 +03:00
|
|
|
readRumors(bufor, i);
|
2011-12-14 00:23:17 +03:00
|
|
|
tlog0<<"\tReading rumors: "<<th.getDiff()<<std::endl;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
|
|
|
readPredefinedHeroes(bufor, i);
|
2011-12-14 00:23:17 +03:00
|
|
|
tlog0<<"\tReading predefined heroes: "<<th.getDiff()<<std::endl;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
|
|
|
readTerrain(bufor, i);
|
2011-12-14 00:23:17 +03:00
|
|
|
tlog0<<"\tReading terrain: "<<th.getDiff()<<std::endl;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
|
|
|
readDefInfo(bufor, i);
|
2011-12-14 00:23:17 +03:00
|
|
|
tlog0<<"\tReading defs info: "<<th.getDiff()<<std::endl;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
|
|
|
readObjects(bufor, i);
|
2011-12-14 00:23:17 +03:00
|
|
|
tlog0<<"\tReading objects: "<<th.getDiff()<<std::endl;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
|
|
|
readEvents(bufor, i);
|
2011-12-14 00:23:17 +03:00
|
|
|
tlog0<<"\tReading events: "<<th.getDiff()<<std::endl;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
2009-01-11 00:08:18 +02:00
|
|
|
//map readed, bufor no longer needed
|
2011-12-14 00:23:17 +03:00
|
|
|
for(ui32 f=0; f<objects.size(); ++f) //calculationg blocked / visitable positions
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-08-15 15:11:42 +03:00
|
|
|
if(!objects[f]->defInfo)
|
|
|
|
continue;
|
|
|
|
addBlockVisTiles(objects[f]);
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
tlog0<<"\tCalculating blocked/visitable tiles: "<<th.getDiff()<<std::endl;
|
2010-01-29 22:52:45 +02:00
|
|
|
tlog0 << "\tMap initialization done!" << std::endl;
|
2011-11-27 16:14:20 +03:00
|
|
|
}
|
|
|
|
|
2009-02-14 21:12:40 +02:00
|
|
|
void Mapa::removeBlockVisTiles(CGObjectInstance * obj, bool total)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
|
|
|
for(int fx=0; fx<8; ++fx)
|
|
|
|
{
|
|
|
|
for(int fy=0; fy<6; ++fy)
|
|
|
|
{
|
|
|
|
int xVal = obj->pos.x + fx - 7;
|
|
|
|
int yVal = obj->pos.y + fy - 5;
|
|
|
|
int zVal = obj->pos.z;
|
|
|
|
if(xVal>=0 && xVal<width && yVal>=0 && yVal<height)
|
|
|
|
{
|
|
|
|
TerrainTile & curt = terrain[xVal][yVal][zVal];
|
2009-02-14 21:12:40 +02:00
|
|
|
if(total || ((obj->defInfo->visitMap[fy] >> (7 - fx)) & 1))
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
|
|
|
curt.visitableObjects -= obj;
|
|
|
|
curt.visitable = curt.visitableObjects.size();
|
|
|
|
}
|
2009-02-14 21:12:40 +02:00
|
|
|
if(total || !((obj->defInfo->blockMap[fy] >> (7 - fx)) & 1))
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
|
|
|
curt.blockingObjects -= obj;
|
2008-09-20 21:30:37 +03:00
|
|
|
curt.blocked = curt.blockingObjects.size();
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void Mapa::addBlockVisTiles(CGObjectInstance * obj)
|
|
|
|
{
|
|
|
|
for(int fx=0; fx<8; ++fx)
|
|
|
|
{
|
|
|
|
for(int fy=0; fy<6; ++fy)
|
|
|
|
{
|
|
|
|
int xVal = obj->pos.x + fx - 7;
|
|
|
|
int yVal = obj->pos.y + fy - 5;
|
|
|
|
int zVal = obj->pos.z;
|
|
|
|
if(xVal>=0 && xVal<width && yVal>=0 && yVal<height)
|
|
|
|
{
|
|
|
|
TerrainTile & curt = terrain[xVal][yVal][zVal];
|
|
|
|
if(((obj->defInfo->visitMap[fy] >> (7 - fx)) & 1))
|
|
|
|
{
|
|
|
|
curt.visitableObjects.push_back(obj);
|
|
|
|
curt.visitable = true;
|
|
|
|
}
|
|
|
|
if(!((obj->defInfo->blockMap[fy] >> (7 - fx)) & 1))
|
|
|
|
{
|
|
|
|
curt.blockingObjects.push_back(obj);
|
|
|
|
curt.blocked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Mapa::Mapa(std::string filename)
|
2010-02-12 02:53:25 +02:00
|
|
|
:grailPos(-1, -1, -1), grailRadious(0)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2009-05-24 19:33:42 +03:00
|
|
|
int mapsize = 0;
|
|
|
|
|
2008-09-19 11:16:19 +03:00
|
|
|
tlog0<<"Opening map file: "<<filename<<"\t "<<std::flush;
|
2009-05-24 19:33:42 +03:00
|
|
|
|
2010-02-09 15:48:14 +02:00
|
|
|
//load file and decompress
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 * initTable = CLodHandler::getUnpackedFile(filename, &mapsize);
|
2009-05-24 19:33:42 +03:00
|
|
|
|
2008-09-19 11:16:19 +03:00
|
|
|
tlog0<<"done."<<std::endl;
|
2009-05-24 19:33:42 +03:00
|
|
|
|
2011-11-27 16:14:20 +03:00
|
|
|
initFromBytes(initTable, mapsize);
|
2009-05-24 19:33:42 +03:00
|
|
|
|
2009-01-11 00:08:18 +02:00
|
|
|
delete [] initTable;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
|
2009-01-06 20:42:20 +02:00
|
|
|
Mapa::Mapa()
|
|
|
|
{
|
2009-01-11 00:08:18 +02:00
|
|
|
terrain = NULL;
|
2009-01-06 20:42:20 +02:00
|
|
|
|
|
|
|
}
|
2009-01-11 00:08:18 +02:00
|
|
|
Mapa::~Mapa()
|
|
|
|
{
|
2009-07-20 11:18:33 +03:00
|
|
|
//for(int i=0; i < defy.size(); i++)
|
|
|
|
// if(defy[i]->serial < 0) //def not present in the main vector in defobjinfo
|
|
|
|
// delete defy[i];
|
|
|
|
|
2009-01-11 00:08:18 +02:00
|
|
|
if(terrain)
|
|
|
|
{
|
|
|
|
for (int ii=0;ii<width;ii++)
|
|
|
|
{
|
|
|
|
for(int jj=0;jj<height;jj++)
|
|
|
|
delete [] terrain[ii][jj];
|
|
|
|
delete [] terrain[ii];
|
|
|
|
}
|
|
|
|
delete [] terrain;
|
|
|
|
}
|
2010-12-20 15:04:24 +02:00
|
|
|
for(std::list<ConstTransitivePtr<CMapEvent> >::iterator i = events.begin(); i != events.end(); i++)
|
2011-02-06 19:26:27 +02:00
|
|
|
i->dellNull();
|
2009-01-11 00:08:18 +02:00
|
|
|
}
|
|
|
|
|
2008-08-15 15:11:42 +03:00
|
|
|
CGHeroInstance * Mapa::getHero(int ID, int mode)
|
|
|
|
{
|
|
|
|
if (mode != 0)
|
|
|
|
#ifndef __GNUC__
|
|
|
|
throw new std::exception("gs->getHero: This mode is not supported!");
|
|
|
|
#else
|
|
|
|
throw new std::exception();
|
|
|
|
#endif
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
for(ui32 i=0; i<heroes.size();i++)
|
2008-08-15 15:11:42 +03:00
|
|
|
if(heroes[i]->subID == ID)
|
|
|
|
return heroes[i];
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
int Mapa::loadSeerHut( const ui8 * bufor, int i, CGObjectInstance *& nobj )
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGSeerHut *hut = new CGSeerHut();
|
|
|
|
nobj = hut;
|
|
|
|
|
2008-08-15 15:11:42 +03:00
|
|
|
if(version>RoE)
|
|
|
|
{
|
2008-12-27 03:01:59 +02:00
|
|
|
loadQuest(hut,bufor,i);
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
else //RoE
|
|
|
|
{
|
|
|
|
int artID = bufor[i]; ++i;
|
|
|
|
if(artID!=255) //not none quest
|
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
hut->m5arts.push_back(artID);
|
|
|
|
hut->missionType = 5;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-19 21:30:51 +03:00
|
|
|
hut->missionType = 0; //no mission
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
2011-10-16 22:24:05 +03:00
|
|
|
hut->isCustomFirst = hut->isCustomNext = hut->isCustomComplete = false;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
|
2010-07-19 21:30:51 +03:00
|
|
|
if(hut->missionType)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 rewardType = bufor[i]; ++i;
|
2008-12-22 19:48:41 +02:00
|
|
|
hut->rewardType = rewardType;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
|
|
|
switch(rewardType)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
hut->rVal = read_le_u32(bufor + i); i+=4;
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
hut->rVal = read_le_u32(bufor + i); i+=4;
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
hut->rVal = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4:
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
hut->rVal = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
hut->rID = bufor[i]; ++i;
|
2011-10-08 19:06:11 +03:00
|
|
|
/* Only the first 3 bytes are used. Skip the 4th. */
|
|
|
|
hut->rVal = read_le_u32(bufor + i) & 0x00ffffff;
|
|
|
|
i+=4;
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 6:
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
hut->rID = bufor[i]; ++i;
|
|
|
|
hut->rVal = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 7:
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
hut->rID = bufor[i]; ++i;
|
|
|
|
hut->rVal = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 8:
|
|
|
|
{
|
2011-10-08 19:06:11 +03:00
|
|
|
if (version == RoE)
|
|
|
|
{
|
|
|
|
hut->rID = bufor[i]; i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hut->rID = read_le_u16(bufor + i); i+=2;
|
|
|
|
}
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 9:
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
hut->rID = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 10:
|
|
|
|
{
|
|
|
|
if(version>RoE)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
hut->rID = read_le_u16(bufor + i); i+=2;
|
|
|
|
hut->rVal = read_le_u16(bufor + i); i+=2;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
hut->rID = bufor[i]; ++i;
|
2011-10-08 04:23:46 +03:00
|
|
|
hut->rVal = read_le_u16(bufor + i); i+=2;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}// end of internal switch
|
|
|
|
i+=2;
|
|
|
|
}
|
|
|
|
else //missionType==255
|
|
|
|
{
|
|
|
|
i+=3;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::loadTown( CGObjectInstance * &nobj, const ui8 * bufor, int &i, int subid)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
|
|
|
CGTownInstance * nt = new CGTownInstance();
|
2008-12-22 19:48:41 +02:00
|
|
|
//(*(static_cast<CGObjectInstance*>(nt))) = *nobj;
|
|
|
|
//delete nobj;
|
2008-08-15 15:11:42 +03:00
|
|
|
nobj = nt;
|
|
|
|
nt->identifier = 0;
|
|
|
|
if(version>RoE)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
nt->identifier = read_le_u32(bufor + i); i+=4;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
nt->tempOwner = bufor[i]; ++i;
|
|
|
|
if(readChar(bufor,i)) //has name
|
|
|
|
nt->name = readString(bufor,i);
|
|
|
|
if(readChar(bufor,i))//true if garrison isn't empty
|
2010-11-22 02:34:46 +02:00
|
|
|
readCreatureSet(nt, bufor, i, 7, version > RoE);
|
2010-05-02 21:20:26 +03:00
|
|
|
nt->formation = bufor[i]; ++i;
|
2009-06-10 22:44:09 +03:00
|
|
|
if(readChar(bufor,i)) //custom buildings info
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
|
|
|
//built buildings
|
|
|
|
for(int byte=0;byte<6;byte++)
|
|
|
|
{
|
|
|
|
for(int bit=0;bit<8;bit++)
|
|
|
|
if(bufor[i] & (1<<bit))
|
|
|
|
nt->builtBuildings.insert(byte*8+bit);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
//forbidden buildings
|
|
|
|
for(int byte=6;byte<12;byte++)
|
|
|
|
{
|
|
|
|
for(int bit=0;bit<8;bit++)
|
|
|
|
if(bufor[i] & (1<<bit))
|
2008-08-20 09:57:53 +03:00
|
|
|
nt->forbiddenBuildings.insert((byte-6)*8+bit);
|
2008-08-15 15:11:42 +03:00
|
|
|
i++;
|
|
|
|
}
|
2009-06-13 02:34:02 +03:00
|
|
|
nt->builtBuildings = convertBuildings(nt->builtBuildings,subid);
|
|
|
|
nt->forbiddenBuildings = convertBuildings(nt->forbiddenBuildings,subid);
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
else //standard buildings
|
|
|
|
{
|
|
|
|
if(readChar(bufor,i)) //has fort
|
|
|
|
nt->builtBuildings.insert(7);
|
|
|
|
nt->builtBuildings.insert(-50); //means that set of standard building should be included
|
|
|
|
}
|
|
|
|
|
|
|
|
int ist = i;
|
|
|
|
if(version>RoE)
|
|
|
|
{
|
2010-11-09 13:27:58 +02:00
|
|
|
for(; i<ist+9; ++i)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 c = bufor[i];
|
2008-08-15 15:11:42 +03:00
|
|
|
for(int yy=0; yy<8; ++yy)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if((i-ist)*8+yy < GameConstants::SPELLS_QUANTITY)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if(c == (c|((ui8)intPow(2, yy))))
|
2008-08-15 15:11:42 +03:00
|
|
|
nt->obligatorySpells.push_back((i-ist)*8+yy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ist = i;
|
2010-11-09 13:27:58 +02:00
|
|
|
for(; i<ist+9; ++i)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 c = bufor[i];
|
2008-08-15 15:11:42 +03:00
|
|
|
for(int yy=0; yy<8; ++yy)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if((i-ist)*8+yy < GameConstants::SPELLS_QUANTITY)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if(c != (c|((ui8)intPow(2, yy))))
|
2008-08-15 15:11:42 +03:00
|
|
|
nt->possibleSpells.push_back((i-ist)*8+yy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/////// reading castle events //////////////////////////////////
|
|
|
|
|
2011-10-08 04:23:46 +03:00
|
|
|
int numberOfEvent = read_le_u32(bufor + i); i+=4;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
|
|
|
for(int gh = 0; gh<numberOfEvent; ++gh)
|
|
|
|
{
|
2010-08-18 17:24:30 +03:00
|
|
|
CCastleEvent *nce = new CCastleEvent();
|
|
|
|
nce->town = nt;
|
|
|
|
nce->name = readString(bufor,i);
|
|
|
|
nce->message = readString(bufor,i);
|
2008-12-31 11:33:46 +02:00
|
|
|
for(int x=0; x < 7; x++)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
nce->resources[x] = read_le_u32(bufor + i);
|
2008-12-31 11:33:46 +02:00
|
|
|
i+=4;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
|
2010-08-18 17:24:30 +03:00
|
|
|
nce->players = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
if(version > AB)
|
|
|
|
{
|
2010-08-18 17:24:30 +03:00
|
|
|
nce->humanAffected = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
else
|
2010-08-18 17:24:30 +03:00
|
|
|
nce->humanAffected = true;
|
2008-12-31 11:33:46 +02:00
|
|
|
|
2010-08-18 17:24:30 +03:00
|
|
|
nce->computerAffected = bufor[i]; ++i;
|
2011-10-08 04:23:46 +03:00
|
|
|
nce->firstOccurence = read_le_u16(bufor + i); i+=2;
|
2010-08-18 17:24:30 +03:00
|
|
|
nce->nextOccurence = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
|
|
|
|
i+=17;
|
|
|
|
|
2010-08-18 17:24:30 +03:00
|
|
|
//new buildings
|
|
|
|
for(int byte=0;byte<6;byte++)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2010-08-18 17:24:30 +03:00
|
|
|
for(int bit=0;bit<8;bit++)
|
|
|
|
if(bufor[i] & (1<<bit))
|
|
|
|
nce->buildings.insert(byte*8+bit);
|
|
|
|
i++;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
2011-08-25 23:02:38 +03:00
|
|
|
nce->buildings = convertBuildings(nce->buildings,subid, false);
|
2010-08-18 17:24:30 +03:00
|
|
|
|
|
|
|
nce->creatures.resize(7);
|
2008-08-15 15:11:42 +03:00
|
|
|
for(int vv=0; vv<7; ++vv)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
nce->creatures[vv] = read_le_u16(bufor + i);i+=2;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
i+=4;
|
2010-08-18 17:24:30 +03:00
|
|
|
nt->events.push_back(nce);
|
2008-08-15 15:11:42 +03:00
|
|
|
}//castle events have been read
|
|
|
|
|
|
|
|
if(version > AB)
|
|
|
|
{
|
|
|
|
nt->alignment = bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
else
|
2008-08-15 15:11:42 +03:00
|
|
|
nt->alignment = 0xff;
|
|
|
|
i+=3;
|
|
|
|
|
|
|
|
nt->builded = 0;
|
|
|
|
nt->destroyed = 0;
|
|
|
|
nt->garrisonHero = NULL;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
CGObjectInstance * Mapa::loadHero(const ui8 * bufor, int &i, int idToBeGiven)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2010-12-12 01:11:26 +02:00
|
|
|
CGHeroInstance * nhi = new CGHeroInstance();
|
2008-12-22 19:48:41 +02:00
|
|
|
|
2008-10-26 22:58:34 +02:00
|
|
|
int identifier = 0;
|
2011-02-11 14:27:38 +02:00
|
|
|
if(version > RoE)
|
2008-10-26 22:58:34 +02:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
identifier = read_le_u32(bufor + i); i+=4;
|
2011-02-11 14:27:38 +02:00
|
|
|
questIdentifierToId[identifier] = idToBeGiven;
|
2008-10-26 22:58:34 +02:00
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
|
|
|
|
ui8 owner = bufor[i++];
|
2011-10-08 04:23:46 +03:00
|
|
|
nhi->subID = bufor[i++];
|
2008-10-26 22:58:34 +02:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
for(ui32 j=0; j<predefinedHeroes.size(); j++)
|
2008-10-26 22:58:34 +02:00
|
|
|
{
|
2010-12-12 01:11:26 +02:00
|
|
|
if(predefinedHeroes[j]->subID == nhi->subID)
|
2008-10-26 22:58:34 +02:00
|
|
|
{
|
2010-12-12 01:11:26 +02:00
|
|
|
tlog0 << "Hero " << nhi->subID << " will be taken from the predefined heroes list.\n";
|
|
|
|
delete nhi;
|
|
|
|
nhi = predefinedHeroes[j];
|
2008-10-26 22:58:34 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-12-12 01:11:26 +02:00
|
|
|
nhi->setOwner(owner);
|
2008-10-26 22:58:34 +02:00
|
|
|
|
|
|
|
nhi->portrait = nhi->subID;
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
for(ui32 j=0; j<disposedHeroes.size(); j++)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2008-10-26 22:58:34 +02:00
|
|
|
if(disposedHeroes[j].ID == nhi->subID)
|
|
|
|
{
|
|
|
|
nhi->name = disposedHeroes[j].name;
|
|
|
|
nhi->portrait = disposedHeroes[j].portrait;
|
|
|
|
break;
|
|
|
|
}
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
if(readChar(bufor,i))//true if hero has nonstandard name
|
|
|
|
nhi->name = readString(bufor,i);
|
|
|
|
if(version>AB)
|
|
|
|
{
|
2009-07-31 23:10:22 +03:00
|
|
|
if(readChar(bufor,i))//true if hero's experience is greater than 0
|
2011-10-08 04:23:46 +03:00
|
|
|
{ nhi->exp = read_le_u32(bufor + i); i+=4; }
|
2008-08-15 15:11:42 +03:00
|
|
|
else
|
2008-11-15 02:55:19 +02:00
|
|
|
nhi->exp = 0xffffffff;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
else
|
2009-07-31 23:10:22 +03:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
nhi->exp = read_le_u32(bufor + i); i+=4;
|
2009-07-31 23:10:22 +03:00
|
|
|
if(!nhi->exp) //0 means "not set" in <=AB maps
|
|
|
|
nhi->exp = 0xffffffff;
|
|
|
|
}
|
2008-08-15 15:11:42 +03:00
|
|
|
|
|
|
|
bool portrait=bufor[i]; ++i;
|
|
|
|
if (portrait)
|
2009-02-08 19:19:42 +02:00
|
|
|
nhi->portrait = bufor[i++];
|
2008-08-15 15:11:42 +03:00
|
|
|
if(readChar(bufor,i))//true if hero has specified abilities
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
int howMany = read_le_u32(bufor + i); i+=4;
|
2008-08-15 15:11:42 +03:00
|
|
|
nhi->secSkills.resize(howMany);
|
|
|
|
for(int yy=0; yy<howMany; ++yy)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
nhi->secSkills[yy].first = bufor[i++];
|
|
|
|
nhi->secSkills[yy].second = bufor[i++];
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(readChar(bufor,i))//true if hero has nonstandard garrison
|
2010-11-22 02:34:46 +02:00
|
|
|
readCreatureSet(nhi, bufor, i, 7, version > RoE);
|
2010-04-02 05:07:40 +03:00
|
|
|
|
2010-05-02 21:20:26 +03:00
|
|
|
nhi->formation =bufor[i]; ++i; //formation
|
2010-12-30 16:41:46 +02:00
|
|
|
loadArtifactsOfHero(bufor, i, nhi);
|
2011-10-08 04:23:46 +03:00
|
|
|
nhi->patrol.patrolRadious = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
if(nhi->patrol.patrolRadious == 0xff)
|
|
|
|
nhi->patrol.patrolling = false;
|
|
|
|
else
|
|
|
|
nhi->patrol.patrolling = true;
|
|
|
|
|
|
|
|
if(version>RoE)
|
|
|
|
{
|
|
|
|
if(readChar(bufor,i))//true if hero has nonstandard (mapmaker defined) biography
|
|
|
|
nhi->biography = readString(bufor,i);
|
2010-08-25 17:57:58 +03:00
|
|
|
nhi->sex = bufor[i]; ++i;
|
|
|
|
|
|
|
|
if (nhi->sex != 0xFF)//remove trash
|
|
|
|
nhi->sex &=1;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
2010-08-25 17:57:58 +03:00
|
|
|
else
|
|
|
|
nhi->sex = 0xFF;
|
2008-08-15 15:11:42 +03:00
|
|
|
//spells
|
|
|
|
if(version>AB)
|
|
|
|
{
|
|
|
|
bool areSpells = bufor[i]; ++i;
|
|
|
|
|
2010-07-20 17:08:13 +03:00
|
|
|
if(areSpells) //TODO: sprawdziæ //seems to be ok - tow
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2009-09-14 01:45:58 +03:00
|
|
|
nhi->spells.insert(0xffffffff); //placeholder "preset spells"
|
2008-08-15 15:11:42 +03:00
|
|
|
int ist = i;
|
2010-11-09 13:27:58 +02:00
|
|
|
for(; i<ist+9; ++i)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 c = bufor[i];
|
2008-08-15 15:11:42 +03:00
|
|
|
for(int yy=0; yy<8; ++yy)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if((i-ist)*8+yy < GameConstants::SPELLS_QUANTITY)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if(c == (c|((ui8)intPow(2, yy))))
|
2008-08-15 15:11:42 +03:00
|
|
|
nhi->spells.insert((i-ist)*8+yy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(version==AB) //we can read one spell
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 buff = bufor[i]; ++i;
|
2009-09-14 01:45:58 +03:00
|
|
|
if(buff != 254)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2009-09-14 01:45:58 +03:00
|
|
|
nhi->spells.insert(0xffffffff); //placeholder "preset spells"
|
|
|
|
if(buff < 254) //255 means no spells
|
|
|
|
nhi->spells.insert(buff);
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//spells loaded
|
|
|
|
if(version>AB)
|
|
|
|
{
|
|
|
|
if(readChar(bufor,i))//customPrimSkills
|
|
|
|
{
|
|
|
|
for(int xx=0;xx<4;xx++)
|
2010-05-02 21:20:26 +03:00
|
|
|
nhi->pushPrimSkill(xx, bufor[i++]);
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
i+=16;
|
2010-12-12 01:11:26 +02:00
|
|
|
|
|
|
|
return nhi;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::readRumors( const ui8 * bufor, int &i)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
int rumNr = read_le_u32(bufor + i);i+=4;
|
2008-08-15 15:11:42 +03:00
|
|
|
for (int it=0;it<rumNr;it++)
|
|
|
|
{
|
|
|
|
Rumor ourRumor;
|
2011-10-08 04:23:46 +03:00
|
|
|
int nameL = read_le_u32(bufor + i);i+=4; //read length of name of rumor
|
2008-08-15 15:11:42 +03:00
|
|
|
for (int zz=0; zz<nameL; zz++)
|
|
|
|
ourRumor.name+=bufor[i++];
|
2011-10-08 04:23:46 +03:00
|
|
|
nameL = read_le_u32(bufor + i);i+=4; //read length of rumor
|
2008-08-15 15:11:42 +03:00
|
|
|
for (int zz=0; zz<nameL; zz++)
|
|
|
|
ourRumor.text+=bufor[i++];
|
|
|
|
rumors.push_back(ourRumor); //add to our list
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::readHeader( const ui8 * bufor, int &i)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2008-06-21 16:27:52 +03:00
|
|
|
//reading allowed heroes (20 bytes)
|
2011-05-04 05:38:58 +03:00
|
|
|
int ist = i; //starting i for loop
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 disp = 0;
|
2011-05-04 05:38:58 +03:00
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
if(version>=SoD)
|
|
|
|
{
|
|
|
|
disp = bufor[i++];
|
|
|
|
disposedHeroes.resize(disp);
|
|
|
|
for(int g=0; g<disp; ++g)
|
|
|
|
{
|
|
|
|
disposedHeroes[g].ID = bufor[i++];
|
|
|
|
disposedHeroes[g].portrait = bufor[i++];
|
2011-10-08 04:23:46 +03:00
|
|
|
int lenbuf = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
for (int zz=0; zz<lenbuf; zz++)
|
|
|
|
disposedHeroes[g].name+=bufor[i++];
|
2008-10-26 22:58:34 +02:00
|
|
|
disposedHeroes[g].players = bufor[i++];
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
i+=31; //omitting NULLS
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
allowedArtifact.resize(GameConstants::ARTIFACTS_QUANTITY);
|
|
|
|
for (ui32 x=0; x<allowedArtifact.size(); x++)
|
2008-06-21 16:27:52 +03:00
|
|
|
allowedArtifact[x] = true;
|
|
|
|
|
|
|
|
//reading allowed artifacts: 17 or 18 bytes
|
2010-06-06 12:50:37 +03:00
|
|
|
if (version!=RoE)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
|
|
|
ist=i; //starting i for loop
|
2010-11-09 13:27:58 +02:00
|
|
|
for (; i<ist+(version==AB ? 17 : 18); ++i)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 c = bufor[i];
|
2010-06-06 12:50:37 +03:00
|
|
|
for (int yy=0; yy<8; ++yy)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if ((i-ist)*8+yy < GameConstants::ARTIFACTS_QUANTITY)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if (c == (c|((ui8)intPow(2, yy))))
|
2008-06-21 16:27:52 +03:00
|
|
|
allowedArtifact[(i-ist)*8+yy] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}//allowed artifacts have been read
|
|
|
|
}
|
2011-06-18 12:48:25 +03:00
|
|
|
if (version == RoE || version == AB) //ban combo artifacts
|
2011-06-18 08:55:39 +03:00
|
|
|
{
|
|
|
|
BOOST_FOREACH(CArtifact *artifact, VLC->arth->artifacts)
|
|
|
|
{
|
2011-06-18 13:58:46 +03:00
|
|
|
if (artifact->constituents) //combo
|
2011-06-18 08:55:39 +03:00
|
|
|
{
|
|
|
|
allowedArtifact[artifact->id] = false;
|
|
|
|
}
|
|
|
|
}
|
2011-06-24 20:50:22 +03:00
|
|
|
if (version == RoE)
|
2011-06-24 20:43:02 +03:00
|
|
|
allowedArtifact[128] = false; //Armageddon's Blade
|
2011-06-18 08:55:39 +03:00
|
|
|
}
|
2008-06-21 16:27:52 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
allowedSpell.resize(GameConstants::SPELLS_QUANTITY);
|
|
|
|
for(ui32 x=0;x<allowedSpell.size();x++)
|
2008-06-21 16:27:52 +03:00
|
|
|
allowedSpell[x] = true;
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
allowedAbilities.resize(GameConstants::SKILL_QUANTITY);
|
|
|
|
for(ui32 x=0;x<allowedAbilities.size();x++)
|
2008-06-21 16:27:52 +03:00
|
|
|
allowedAbilities[x] = true;
|
|
|
|
|
|
|
|
if(version>=SoD)
|
|
|
|
{
|
|
|
|
//reading allowed spells (9 bytes)
|
|
|
|
ist=i; //starting i for loop
|
2010-11-09 13:27:58 +02:00
|
|
|
for(; i<ist+9; ++i)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 c = bufor[i];
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int yy=0; yy<8; ++yy)
|
2011-12-14 00:23:17 +03:00
|
|
|
if((i-ist)*8+yy < GameConstants::SPELLS_QUANTITY)
|
|
|
|
if(c == (c|((ui8)intPow(2, yy))))
|
2008-06-21 16:27:52 +03:00
|
|
|
allowedSpell[(i-ist)*8+yy] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//allowed hero's abilities (4 bytes)
|
|
|
|
ist=i; //starting i for loop
|
2010-11-09 13:27:58 +02:00
|
|
|
for(; i<ist+4; ++i)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 c = bufor[i];
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int yy=0; yy<8; ++yy)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if((i-ist)*8+yy < GameConstants::SKILL_QUANTITY)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if(c == (c|((ui8)intPow(2, yy))))
|
2008-06-21 16:27:52 +03:00
|
|
|
allowedAbilities[(i-ist)*8+yy] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
2008-06-21 16:27:52 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::readPredefinedHeroes( const ui8 * bufor, int &i)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2008-06-21 16:27:52 +03:00
|
|
|
switch(version)
|
|
|
|
{
|
|
|
|
case WoG: case SoD:
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
for(int z=0;z<GameConstants::HEROES_QUANTITY;z++) //disposed heroes
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
|
|
|
int custom = bufor[i++];
|
|
|
|
if(!custom)
|
|
|
|
continue;
|
|
|
|
CGHeroInstance * cgh = new CGHeroInstance;
|
2011-12-14 00:23:17 +03:00
|
|
|
cgh->ID = GameConstants::HEROI_TYPE;
|
2008-06-21 16:27:52 +03:00
|
|
|
cgh->subID = z;
|
|
|
|
if(readChar(bufor,i))//true if hore's experience is greater than 0
|
2011-10-08 04:23:46 +03:00
|
|
|
{ cgh->exp = read_le_u32(bufor + i); i+=4; }
|
2008-06-21 16:27:52 +03:00
|
|
|
else
|
|
|
|
cgh->exp = 0;
|
|
|
|
if(readChar(bufor,i))//true if hero has specified abilities
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
int howMany = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
cgh->secSkills.resize(howMany);
|
|
|
|
for(int yy=0; yy<howMany; ++yy)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
cgh->secSkills[yy].first = bufor[i]; ++i;
|
|
|
|
cgh->secSkills[yy].second = bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
}
|
2010-12-30 16:41:46 +02:00
|
|
|
|
|
|
|
loadArtifactsOfHero(bufor, i, cgh);
|
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
if(readChar(bufor,i))//customBio
|
|
|
|
cgh->biography = readString(bufor,i);
|
2011-07-01 19:26:36 +03:00
|
|
|
cgh->sex = bufor[i++]; // 0xFF is default, 00 male, 01 female
|
2008-06-21 16:27:52 +03:00
|
|
|
if(readChar(bufor,i))//are spells
|
|
|
|
{
|
|
|
|
int ist = i;
|
2010-11-09 13:27:58 +02:00
|
|
|
for(; i<ist+9; ++i)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 c = bufor[i];
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int yy=0; yy<8; ++yy)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if((i-ist)*8+yy < GameConstants::SPELLS_QUANTITY)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if(c == (c|((ui8)intPow(2, yy))))
|
2008-06-21 16:27:52 +03:00
|
|
|
cgh->spells.insert((i-ist)*8+yy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(readChar(bufor,i))//customPrimSkills
|
|
|
|
{
|
|
|
|
for(int xx=0;xx<4;xx++)
|
2010-05-02 21:20:26 +03:00
|
|
|
cgh->pushPrimSkill(xx, bufor[i++]);
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
predefinedHeroes.push_back(cgh);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RoE:
|
|
|
|
i+=0;
|
|
|
|
break;
|
|
|
|
}
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::readTerrain( const ui8 * bufor, int &i)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2009-01-06 20:42:20 +02:00
|
|
|
terrain = new TerrainTile**[width]; // allocate memory
|
|
|
|
for (int ii=0;ii<width;ii++)
|
|
|
|
{
|
|
|
|
terrain[ii] = new TerrainTile*[height]; // allocate memory
|
|
|
|
for(int jj=0;jj<height;jj++)
|
|
|
|
terrain[ii][jj] = new TerrainTile[twoLevel+1];
|
|
|
|
}
|
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
for (int c=0; c<width; c++) // reading terrain
|
|
|
|
{
|
|
|
|
for (int z=0; z<height; z++)
|
|
|
|
{
|
2009-05-07 20:20:41 +03:00
|
|
|
terrain[z][c][0].tertype = static_cast<TerrainTile::EterrainType>(bufor[i++]);
|
2008-07-29 22:10:28 +03:00
|
|
|
terrain[z][c][0].terview = bufor[i++];
|
2009-05-07 20:20:41 +03:00
|
|
|
terrain[z][c][0].nuine = static_cast<TerrainTile::Eriver>(bufor[i++]);
|
2008-07-29 22:10:28 +03:00
|
|
|
terrain[z][c][0].rivDir = bufor[i++];
|
2009-05-07 20:20:41 +03:00
|
|
|
terrain[z][c][0].malle = static_cast<TerrainTile::Eroad>(bufor[i++]);
|
2008-07-29 22:10:28 +03:00
|
|
|
terrain[z][c][0].roadDir = bufor[i++];
|
|
|
|
terrain[z][c][0].siodmyTajemniczyBajt = bufor[i++];
|
2011-07-22 10:07:27 +03:00
|
|
|
terrain[z][c][0].blocked = (terrain[z][c][0].tertype == TerrainTile::rock ? 1 : 0); //underground tiles are always blocked
|
2008-07-29 22:10:28 +03:00
|
|
|
terrain[z][c][0].visitable = 0;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (twoLevel) // read underground terrain
|
|
|
|
{
|
|
|
|
for (int c=0; c<width; c++) // reading terrain
|
|
|
|
{
|
|
|
|
for (int z=0; z<height; z++)
|
|
|
|
{
|
2009-05-07 20:20:41 +03:00
|
|
|
terrain[z][c][1].tertype = static_cast<TerrainTile::EterrainType>(bufor[i++]);
|
2008-07-29 22:10:28 +03:00
|
|
|
terrain[z][c][1].terview = bufor[i++];
|
2009-05-07 20:20:41 +03:00
|
|
|
terrain[z][c][1].nuine = static_cast<TerrainTile::Eriver>(bufor[i++]);
|
2008-07-29 22:10:28 +03:00
|
|
|
terrain[z][c][1].rivDir = bufor[i++];
|
2009-05-07 20:20:41 +03:00
|
|
|
terrain[z][c][1].malle = static_cast<TerrainTile::Eroad>(bufor[i++]);
|
2008-07-29 22:10:28 +03:00
|
|
|
terrain[z][c][1].roadDir = bufor[i++];
|
|
|
|
terrain[z][c][1].siodmyTajemniczyBajt = bufor[i++];
|
2011-07-22 10:07:27 +03:00
|
|
|
terrain[z][c][1].blocked = (terrain[z][c][1].tertype == TerrainTile::rock ? 1 : 0); //underground tiles are always blocked
|
2008-07-29 22:10:28 +03:00
|
|
|
terrain[z][c][1].visitable = 0;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
2008-06-21 16:27:52 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::readDefInfo( const ui8 * bufor, int &i)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
int defAmount = read_le_u32(bufor + i); i+=4;
|
2010-02-21 17:03:30 +02:00
|
|
|
defy.reserve(defAmount+8);
|
2008-06-21 16:27:52 +03:00
|
|
|
for (int idd = 0 ; idd<defAmount; idd++) // reading defs
|
|
|
|
{
|
|
|
|
CGDefInfo * vinya = new CGDefInfo(); // info about new def
|
|
|
|
|
|
|
|
//reading name
|
2011-10-08 04:23:46 +03:00
|
|
|
int nameLength = read_le_u32(bufor + i);i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
vinya->name.reserve(nameLength);
|
|
|
|
for (int cd=0;cd<nameLength;cd++)
|
|
|
|
{
|
|
|
|
vinya->name += bufor[i++];
|
|
|
|
}
|
|
|
|
std::transform(vinya->name.begin(),vinya->name.end(),vinya->name.begin(),(int(*)(int))toupper);
|
|
|
|
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 bytes[12];
|
2008-06-21 16:27:52 +03:00
|
|
|
for (int v=0; v<12; v++) // read info
|
|
|
|
{
|
|
|
|
bytes[v] = bufor[i++];
|
|
|
|
}
|
2011-10-08 04:23:46 +03:00
|
|
|
vinya->terrainAllowed = read_le_u16(bufor + i);i+=2;
|
|
|
|
vinya->terrainMenu = read_le_u16(bufor + i);i+=2;
|
|
|
|
vinya->id = read_le_u32(bufor + i);i+=4;
|
|
|
|
vinya->subid = read_le_u32(bufor + i);i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
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;
|
2011-12-14 00:23:17 +03:00
|
|
|
if(vinya->id!=GameConstants::HEROI_TYPE && vinya->id!=70)
|
2009-02-08 19:19:42 +02:00
|
|
|
{
|
|
|
|
CGDefInfo *h = VLC->dobjinfo->gobjs[vinya->id][vinya->subid];
|
|
|
|
if(!h)
|
|
|
|
{
|
|
|
|
//remove fake entry
|
|
|
|
VLC->dobjinfo->gobjs[vinya->id].erase(vinya->subid);
|
|
|
|
if(VLC->dobjinfo->gobjs[vinya->id].size())
|
|
|
|
VLC->dobjinfo->gobjs.erase(vinya->id);
|
|
|
|
tlog2<<"\t\tWarning: no defobjinfo entry for object ID="<<vinya->id<<" subID=" << vinya->subid<<std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vinya->visitDir = VLC->dobjinfo->gobjs[vinya->id][vinya->subid]->visitDir;
|
|
|
|
}
|
|
|
|
}
|
2008-09-18 17:18:08 +03:00
|
|
|
else
|
2009-07-20 01:16:07 +03:00
|
|
|
{
|
2008-09-18 17:18:08 +03:00
|
|
|
vinya->visitDir = 0xff;
|
2009-07-20 01:16:07 +03:00
|
|
|
}
|
2009-04-21 01:57:07 +03:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
if(vinya->id == GameConstants::EVENTI_TYPE)
|
2009-04-21 01:57:07 +03:00
|
|
|
std::memset(vinya->blockMap,255,6);
|
|
|
|
|
2009-07-01 18:58:20 +03:00
|
|
|
//calculating coverageMap
|
2010-08-01 21:12:53 +03:00
|
|
|
vinya->fetchInfoFromMSK();
|
2009-07-01 18:58:20 +03:00
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
defy.push_back(vinya); // add this def to the vector
|
|
|
|
}
|
2010-02-21 17:03:30 +02:00
|
|
|
|
|
|
|
//add holes - they always can appear
|
|
|
|
for (int i = 0; i < 8 ; i++)
|
|
|
|
{
|
|
|
|
defy.push_back(VLC->dobjinfo->gobjs[124][i]);
|
|
|
|
}
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
2008-06-21 16:27:52 +03:00
|
|
|
|
2010-12-20 15:04:24 +02:00
|
|
|
class _HERO_SORTER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool operator()(const ConstTransitivePtr<CGHeroInstance> & a, const ConstTransitivePtr<CGHeroInstance> & b)
|
|
|
|
{
|
|
|
|
return a->subID < b->subID;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::readObjects( const ui8 * bufor, int &i)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
int howManyObjs = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int ww=0; ww<howManyObjs; ++ww) //comment this line to turn loading objects off
|
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGObjectInstance * nobj = 0;
|
2008-06-21 16:27:52 +03:00
|
|
|
|
2008-12-22 19:48:41 +02:00
|
|
|
int3 pos;
|
|
|
|
pos.x = bufor[i++];
|
|
|
|
pos.y = bufor[i++];
|
|
|
|
pos.z = bufor[i++];
|
2010-01-29 22:52:45 +02:00
|
|
|
|
2011-10-08 04:23:46 +03:00
|
|
|
int defnum = read_le_u32(bufor + i); i+=4;
|
2011-02-11 14:27:38 +02:00
|
|
|
int idToBeGiven = objects.size();
|
2008-06-21 16:27:52 +03:00
|
|
|
|
2008-12-22 19:48:41 +02:00
|
|
|
CGDefInfo * defInfo = defy[defnum];
|
2008-06-21 16:27:52 +03:00
|
|
|
i+=5;
|
2008-12-22 19:48:41 +02:00
|
|
|
|
|
|
|
switch(defInfo->id)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
case GameConstants::EVENTI_TYPE: //for event objects
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGEvent *evnt = new CGEvent();
|
|
|
|
nobj = evnt;
|
|
|
|
|
|
|
|
bool guardMess = bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
if(guardMess)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
int messLong = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
if(messLong>0)
|
|
|
|
{
|
|
|
|
for(int yy=0; yy<messLong; ++yy)
|
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
evnt->message +=bufor[i+yy];
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
i+=messLong;
|
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
if(bufor[i++])
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2010-11-22 02:34:46 +02:00
|
|
|
readCreatureSet(evnt, bufor, i, 7, version > RoE);
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
i+=4;
|
|
|
|
}
|
2011-10-08 04:23:46 +03:00
|
|
|
evnt->gainedExp = read_le_u32(bufor + i); i+=4;
|
|
|
|
evnt->manaDiff = read_le_u32(bufor + i); i+=4;
|
2011-12-14 00:23:17 +03:00
|
|
|
evnt->moraleDiff = (char)bufor[i]; ++i;
|
|
|
|
evnt->luckDiff = (char)bufor[i]; ++i;
|
2009-01-06 20:42:20 +02:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
evnt->resources.resize(GameConstants::RESOURCE_QUANTITY);
|
2009-01-06 20:42:20 +02:00
|
|
|
for(int x=0; x<7; x++)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
evnt->resources[x] = read_le_u32(bufor + i);
|
2009-01-06 20:42:20 +02:00
|
|
|
i+=4;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
evnt->primskills.resize(GameConstants::PRIMARY_SKILLS);
|
2009-01-06 20:42:20 +02:00
|
|
|
for(int x=0; x<4; x++)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
evnt->primskills[x] = bufor[i];
|
2009-01-06 20:42:20 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
int gabn; //number of gained abilities
|
2011-10-08 04:23:46 +03:00
|
|
|
gabn = bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int oo = 0; oo<gabn; ++oo)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
evnt->abilities.push_back(bufor[i]); ++i;
|
|
|
|
evnt->abilityLevels.push_back(bufor[i]); ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
|
2011-10-08 04:23:46 +03:00
|
|
|
int gart = bufor[i]; ++i; //number of gained artifacts
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int oo = 0; oo<gart; ++oo)
|
|
|
|
{
|
2011-10-08 19:06:11 +03:00
|
|
|
if (version == RoE)
|
|
|
|
{
|
|
|
|
evnt->artifacts.push_back(bufor[i]); i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evnt->artifacts.push_back(read_le_u16(bufor + i)); i+=2;
|
|
|
|
}
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
|
2011-10-08 04:23:46 +03:00
|
|
|
int gspel = bufor[i]; ++i; //number of gained spells
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int oo = 0; oo<gspel; ++oo)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
evnt->spells.push_back(bufor[i]); ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2009-01-06 20:42:20 +02:00
|
|
|
|
2011-10-08 04:23:46 +03:00
|
|
|
int gcre = bufor[i]; ++i; //number of gained creatures
|
2010-11-22 02:34:46 +02:00
|
|
|
readCreatureSet(&evnt->creatures, bufor,i,gcre,(version>RoE));
|
2009-01-06 20:42:20 +02:00
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
i+=8;
|
2011-10-08 04:23:46 +03:00
|
|
|
evnt->availableFor = bufor[i]; ++i;
|
|
|
|
evnt->computerActivate = bufor[i]; ++i;
|
|
|
|
evnt->removeAfterVisit = bufor[i]; ++i;
|
2009-04-21 01:57:07 +03:00
|
|
|
evnt->humanActivate = true;
|
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
i+=4;
|
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 34: case 70: case 62: //34 - hero; 70 - random hero; 62 - prison
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-02-11 14:27:38 +02:00
|
|
|
nobj = loadHero(bufor, i, idToBeGiven);
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2009-04-11 04:32:50 +03:00
|
|
|
case 4: //Arena
|
2008-12-27 03:01:59 +02:00
|
|
|
case 51: //Mercenary Camp
|
|
|
|
case 23: //Marletto Tower
|
|
|
|
case 61: // Star Axis
|
|
|
|
case 32: // Garden of Revelation
|
|
|
|
case 100: //Learning Stone
|
|
|
|
case 102: //Tree of Knowledge
|
2009-02-01 16:11:41 +02:00
|
|
|
case 41: //Library of Enlightenment
|
2009-04-11 04:32:50 +03:00
|
|
|
case 47: //School of Magic
|
|
|
|
case 107: //School of War
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
|
|
|
nobj = new CGVisitableOPH();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 55: //mystical garden
|
|
|
|
case 112://windmill
|
|
|
|
case 109://water wheel
|
|
|
|
{
|
|
|
|
nobj = new CGVisitableOPW();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 43: //teleport
|
|
|
|
case 44: //teleport
|
|
|
|
case 45: //teleport
|
|
|
|
case 103://subterranean gate
|
2010-06-07 16:11:08 +03:00
|
|
|
case 111://Whirlpool
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
|
|
|
nobj = new CGTeleport();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 12: //campfire
|
2009-07-19 06:10:24 +03:00
|
|
|
case 29: //Flotsam
|
|
|
|
case 82: //Sea Chest
|
|
|
|
case 86: //Shipwreck Survivor
|
|
|
|
case 101://treasure chest
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
|
|
|
nobj = new CGPickable();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 54: //Monster
|
|
|
|
case 71: case 72: case 73: case 74: case 75: // Random Monster 1 - 4
|
|
|
|
case 162: case 163: case 164: // Random Monster 5 - 7
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGCreature *cre = new CGCreature();
|
|
|
|
nobj = cre;
|
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
if(version>RoE)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
cre->identifier = read_le_u32(bufor + i); i+=4;
|
2011-02-11 14:27:38 +02:00
|
|
|
questIdentifierToId[cre->identifier] = idToBeGiven;
|
|
|
|
//monsters[cre->identifier] = cre;
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
2010-05-02 21:20:26 +03:00
|
|
|
|
2010-11-22 02:34:46 +02:00
|
|
|
CStackInstance *hlp = new CStackInstance();
|
2011-10-08 04:23:46 +03:00
|
|
|
hlp->count = read_le_u16(bufor + i); i+=2;
|
2010-05-02 21:20:26 +03:00
|
|
|
//type will be set during initialization
|
2010-12-13 01:44:16 +02:00
|
|
|
cre->putStack(0, hlp);
|
2010-05-02 21:20:26 +03:00
|
|
|
|
2008-12-22 19:48:41 +02:00
|
|
|
cre->character = bufor[i]; ++i;
|
2008-08-15 15:11:42 +03:00
|
|
|
bool isMesTre = bufor[i]; ++i; //true if there is message or treasury
|
|
|
|
if(isMesTre)
|
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
cre->message = readString(bufor,i);
|
2011-12-14 00:23:17 +03:00
|
|
|
cre->resources.resize(GameConstants::RESOURCE_QUANTITY);
|
2008-12-22 19:48:41 +02:00
|
|
|
for(int j=0; j<7; j++)
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
cre->resources[j] = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
|
2011-10-08 19:06:11 +03:00
|
|
|
int artID;
|
|
|
|
if (version == RoE)
|
|
|
|
{
|
|
|
|
artID = bufor[i]; i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
artID = read_le_u16(bufor + i); i+=2;
|
|
|
|
}
|
|
|
|
|
2008-08-15 15:11:42 +03:00
|
|
|
if(version==RoE)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-08-15 15:11:42 +03:00
|
|
|
if(artID!=0xff)
|
2008-12-22 19:48:41 +02:00
|
|
|
cre->gainedArtifact = artID;
|
2008-08-15 15:11:42 +03:00
|
|
|
else
|
2008-12-22 19:48:41 +02:00
|
|
|
cre->gainedArtifact = -1;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-15 15:11:42 +03:00
|
|
|
if(artID!=0xffff)
|
2008-12-22 19:48:41 +02:00
|
|
|
cre->gainedArtifact = artID;
|
2008-08-15 15:11:42 +03:00
|
|
|
else
|
2008-12-22 19:48:41 +02:00
|
|
|
cre->gainedArtifact = -1;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
cre->neverFlees = bufor[i]; ++i;
|
|
|
|
cre->notGrowingTeam = bufor[i]; ++i;
|
|
|
|
i+=2;;
|
2008-08-15 15:11:42 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 59: case 91: //ocean bottle and sign
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGSignBottle *sb = new CGSignBottle();
|
|
|
|
nobj = sb;
|
|
|
|
sb->message = readString(bufor,i);
|
2008-08-15 15:11:42 +03:00
|
|
|
i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 83: //seer's hut
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
|
|
|
i = loadSeerHut(bufor, i, nobj);
|
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 113: //witch hut
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGWitchHut *wh = new CGWitchHut();
|
|
|
|
nobj = wh;
|
2008-06-21 16:27:52 +03:00
|
|
|
if(version>RoE) //in reo we cannot specify it - all are allowed (I hope)
|
|
|
|
{
|
2008-08-15 15:11:42 +03:00
|
|
|
int ist=i; //starting i for loop
|
2010-11-09 13:27:58 +02:00
|
|
|
for(; i<ist+4; ++i)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
ui8 c = bufor[i];
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int yy=0; yy<8; ++yy)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if((i-ist)*8+yy < GameConstants::SKILL_QUANTITY)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if(c == (c|((ui8)intPow(2, yy))))
|
2008-12-22 19:48:41 +02:00
|
|
|
wh->allowedAbilities.push_back((i-ist)*8+yy);
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else //(RoE map)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
for(int gg=0; gg<GameConstants::SKILL_QUANTITY; ++gg)
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
wh->allowedAbilities.push_back(gg);
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 81: //scholar
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGScholar *sch = new CGScholar();
|
|
|
|
nobj = sch;
|
2009-04-08 22:55:50 +03:00
|
|
|
sch->bonusType = bufor[i++];
|
|
|
|
sch->bonusID = bufor[i++];
|
2008-06-21 16:27:52 +03:00
|
|
|
i+=6;
|
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 33: case 219: //garrison
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGGarrison *gar = new CGGarrison();
|
|
|
|
nobj = gar;
|
|
|
|
nobj->setOwner(bufor[i++]);
|
2008-06-21 16:27:52 +03:00
|
|
|
i+=3;
|
2010-11-22 02:34:46 +02:00
|
|
|
readCreatureSet(gar, bufor, i, 7, version > RoE);
|
2008-06-21 16:27:52 +03:00
|
|
|
if(version > RoE)
|
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
gar->removableUnits = bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
else
|
2008-12-22 19:48:41 +02:00
|
|
|
gar->removableUnits = true;
|
2008-06-21 16:27:52 +03:00
|
|
|
i+=8;
|
|
|
|
break;
|
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
case 5: //artifact
|
|
|
|
case 65: case 66: case 67: case 68: case 69: //random artifact
|
2008-12-22 19:48:41 +02:00
|
|
|
case 93: //spell scroll
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2011-03-12 23:55:31 +02:00
|
|
|
int artID = -1;
|
|
|
|
int spellID = -1;
|
2008-12-22 19:48:41 +02:00
|
|
|
CGArtifact *art = new CGArtifact();
|
|
|
|
nobj = art;
|
|
|
|
|
2011-03-12 23:55:31 +02:00
|
|
|
bool areSettings = bufor[i++];
|
2008-06-21 16:27:52 +03:00
|
|
|
if(areSettings)
|
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
art->message = readString(bufor,i);
|
2011-03-12 23:55:31 +02:00
|
|
|
bool areGuards = bufor[i++];
|
2008-06-21 16:27:52 +03:00
|
|
|
if(areGuards)
|
|
|
|
{
|
2010-11-22 02:34:46 +02:00
|
|
|
readCreatureSet(art, bufor, i, 7, version > RoE);
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2009-02-02 01:56:45 +02:00
|
|
|
i+=4;
|
2009-02-01 16:11:41 +02:00
|
|
|
}
|
2010-12-17 20:47:07 +02:00
|
|
|
|
2009-02-02 01:56:45 +02:00
|
|
|
if(defInfo->id==93)
|
2009-02-01 16:11:41 +02:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
spellID = read_le_u32(bufor + i); i+=4;
|
2011-03-12 23:55:31 +02:00
|
|
|
artID = 1;
|
2010-12-17 20:47:07 +02:00
|
|
|
}
|
2011-01-22 05:43:20 +02:00
|
|
|
else if(defInfo->id == 5) //specific artifact
|
2010-12-17 20:47:07 +02:00
|
|
|
{
|
2011-03-12 23:55:31 +02:00
|
|
|
artID = defInfo->subid;
|
2010-12-17 20:47:07 +02:00
|
|
|
}
|
2011-03-12 23:55:31 +02:00
|
|
|
|
|
|
|
art->storedArtifact = createArt(artID, spellID);
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
case 76: case 79: //random resource; resource
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGResource *res = new CGResource();
|
|
|
|
nobj = res;
|
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
bool isMessGuard = bufor[i]; ++i;
|
|
|
|
if(isMessGuard)
|
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
res->message = readString(bufor,i);
|
|
|
|
if(bufor[i++])
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2010-11-22 02:34:46 +02:00
|
|
|
readCreatureSet(res, bufor, i, 7, version > RoE);
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
i+=4;
|
|
|
|
}
|
2011-10-08 04:23:46 +03:00
|
|
|
res->amount = read_le_u32(bufor + i); i+=4;
|
2009-09-12 15:55:03 +03:00
|
|
|
if (defInfo->subid == 6) // Gold is multiplied by 100.
|
|
|
|
res->amount *= 100;
|
2008-06-21 16:27:52 +03:00
|
|
|
i+=4;
|
2008-12-22 19:48:41 +02:00
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
case 77: case 98: //random town; town
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2009-06-13 02:34:02 +03:00
|
|
|
loadTown(nobj, bufor, i, defInfo->subid);
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
case 53:
|
2010-07-31 03:26:34 +03:00
|
|
|
case 220://mine (?)
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
|
|
|
nobj = new CGMine();
|
|
|
|
nobj->setOwner(bufor[i++]);
|
|
|
|
i+=3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 17: case 18: case 19: case 20: //dwellings
|
2009-07-06 22:41:27 +03:00
|
|
|
{
|
|
|
|
nobj = new CGDwelling();
|
|
|
|
nobj->setOwner(bufor[i++]);
|
|
|
|
i+=3;
|
|
|
|
break;
|
|
|
|
}
|
2010-07-24 00:05:49 +03:00
|
|
|
case 78: //Refugee Camp
|
2010-05-15 11:33:32 +03:00
|
|
|
case 106: //War Machine Factory
|
|
|
|
{
|
|
|
|
nobj = new CGDwelling();
|
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 88: case 89: case 90: //spell shrine
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGShrine * shr = new CGShrine();
|
|
|
|
nobj = shr;
|
|
|
|
shr->spell = bufor[i]; i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2010-02-06 15:49:14 +02:00
|
|
|
case 6: //pandora's box
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGPandoraBox *box = new CGPandoraBox();
|
|
|
|
nobj = box;
|
2008-06-21 16:27:52 +03:00
|
|
|
bool messg = bufor[i]; ++i;
|
|
|
|
if(messg)
|
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
box->message = readString(bufor,i);
|
|
|
|
if(bufor[i++])
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2010-11-22 02:34:46 +02:00
|
|
|
readCreatureSet(box, bufor, i, 7, version > RoE);
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
i+=4;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
|
2011-10-08 04:23:46 +03:00
|
|
|
box->gainedExp = read_le_u32(bufor + i); i+=4;
|
|
|
|
box->manaDiff = read_le_u32(bufor + i); i+=4;
|
2011-10-08 19:06:11 +03:00
|
|
|
box->moraleDiff = (si8)bufor[i]; ++i;
|
|
|
|
box->luckDiff = (si8)bufor[i]; ++i;
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
box->resources.resize(GameConstants::RESOURCE_QUANTITY);
|
2009-01-06 20:42:20 +02:00
|
|
|
for(int x=0; x<7; x++)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
box->resources[x] = read_le_u32(bufor + i);
|
2009-01-06 20:42:20 +02:00
|
|
|
i+=4;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
box->primskills.resize(GameConstants::PRIMARY_SKILLS);
|
2009-01-06 20:42:20 +02:00
|
|
|
for(int x=0; x<4; x++)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
box->primskills[x] = bufor[i];
|
2009-01-06 20:42:20 +02:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
int gabn; //number of gained abilities
|
2011-10-08 04:23:46 +03:00
|
|
|
gabn = bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int oo = 0; oo<gabn; ++oo)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
box->abilities.push_back(bufor[i]); ++i;
|
|
|
|
box->abilityLevels.push_back(bufor[i]); ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2011-10-08 04:23:46 +03:00
|
|
|
int gart = bufor[i]; ++i; //number of gained artifacts
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int oo = 0; oo<gart; ++oo)
|
|
|
|
{
|
|
|
|
if(version > RoE)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
box->artifacts.push_back(read_le_u16(bufor + i)); i+=2;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
box->artifacts.push_back(bufor[i]); i+=1;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
}
|
2011-10-08 04:23:46 +03:00
|
|
|
int gspel = bufor[i]; ++i; //number of gained spells
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int oo = 0; oo<gspel; ++oo)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
box->spells.push_back(bufor[i]); ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2011-10-08 04:23:46 +03:00
|
|
|
int gcre = bufor[i]; ++i; //number of gained creatures
|
2010-11-22 02:34:46 +02:00
|
|
|
readCreatureSet(&box->creatures, bufor,i,gcre,(version>RoE));
|
2008-06-21 16:27:52 +03:00
|
|
|
i+=8;
|
|
|
|
break;
|
|
|
|
}
|
2010-02-06 15:49:14 +02:00
|
|
|
case 36: //grail
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
grailPos = pos;
|
2011-10-08 04:23:46 +03:00
|
|
|
grailRadious = read_le_u32(bufor + i); i+=4;
|
2008-12-22 19:48:41 +02:00
|
|
|
continue;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 217:
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2009-07-06 22:41:27 +03:00
|
|
|
nobj = new CGDwelling();
|
2008-06-21 16:27:52 +03:00
|
|
|
CCreGenObjInfo * spec = new CCreGenObjInfo;
|
2011-10-08 04:23:46 +03:00
|
|
|
spec->player = read_le_u32(bufor + i); i+=4;
|
|
|
|
spec->identifier = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
if(!spec->identifier)
|
|
|
|
{
|
|
|
|
spec->asCastle = false;
|
|
|
|
spec->castles[0] = bufor[i]; ++i;
|
|
|
|
spec->castles[1] = bufor[i]; ++i;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spec->asCastle = true;
|
|
|
|
}
|
|
|
|
nobj->setOwner(spec->player);
|
2010-02-21 20:07:24 +02:00
|
|
|
static_cast<CGDwelling*>(nobj)->info = spec;
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 216:
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2009-07-06 22:41:27 +03:00
|
|
|
nobj = new CGDwelling();
|
2008-06-21 16:27:52 +03:00
|
|
|
CCreGen2ObjInfo * spec = new CCreGen2ObjInfo;
|
2011-10-08 04:23:46 +03:00
|
|
|
spec->player = read_le_u32(bufor + i); i+=4;
|
|
|
|
spec->identifier = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
if(!spec->identifier)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
nobj->setOwner(spec->player);
|
2010-02-21 20:07:24 +02:00
|
|
|
static_cast<CGDwelling*>(nobj)->info = spec;
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 218:
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2009-07-06 22:41:27 +03:00
|
|
|
nobj = new CGDwelling();
|
2008-06-21 16:27:52 +03:00
|
|
|
CCreGen3ObjInfo * spec = new CCreGen3ObjInfo;
|
|
|
|
spec->player = bufor[i]; ++i;
|
|
|
|
i+=3;
|
|
|
|
spec->minLevel = bufor[i]; ++i;
|
|
|
|
spec->maxLevel = bufor[i]; ++i;
|
|
|
|
if(spec->maxLevel>7)
|
|
|
|
spec->maxLevel = 7;
|
|
|
|
if(spec->minLevel<1)
|
|
|
|
spec->minLevel = 1;
|
|
|
|
nobj->setOwner(spec->player);
|
2010-02-21 20:07:24 +02:00
|
|
|
static_cast<CGDwelling*>(nobj)->info = spec;
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 215:
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2008-12-22 19:48:41 +02:00
|
|
|
CGQuestGuard *guard = new CGQuestGuard();
|
|
|
|
nobj = guard;
|
2008-12-27 03:01:59 +02:00
|
|
|
loadQuest(guard, bufor, i);
|
2008-06-21 16:27:52 +03:00
|
|
|
break;
|
|
|
|
}
|
2009-02-04 15:40:54 +02:00
|
|
|
case 28: //faerie ring
|
|
|
|
case 14: //Swan pond
|
|
|
|
case 38: //idol of fortune
|
|
|
|
case 30: //Fountain of Fortune
|
2009-02-05 11:49:45 +02:00
|
|
|
case 64: //Rally Flag
|
|
|
|
case 56: //oasis
|
|
|
|
case 96: //temple
|
|
|
|
case 110://Watering Hole
|
|
|
|
case 31: //Fountain of Youth
|
2009-07-19 10:16:33 +03:00
|
|
|
case 11: //Buoy
|
|
|
|
case 52: //Mermaid
|
2009-08-11 10:50:29 +03:00
|
|
|
case 94: //Stables
|
2009-02-04 15:40:54 +02:00
|
|
|
{
|
|
|
|
nobj = new CGBonusingObject();
|
|
|
|
break;
|
|
|
|
}
|
2009-02-06 13:15:39 +02:00
|
|
|
case 49: //Magic Well
|
|
|
|
{
|
|
|
|
nobj = new CGMagicWell();
|
|
|
|
break;
|
|
|
|
}
|
2010-06-06 12:50:37 +03:00
|
|
|
case 15: //Cover of darkness
|
2009-03-14 13:25:25 +02:00
|
|
|
case 58: //Redwood Observatory
|
2009-04-11 04:32:50 +03:00
|
|
|
case 60: //Pillar of Fire
|
2009-03-14 13:25:25 +02:00
|
|
|
{
|
|
|
|
nobj = new CGObservatory();
|
|
|
|
break;
|
|
|
|
}
|
2009-04-16 03:28:54 +03:00
|
|
|
case 22: //Corpse
|
|
|
|
case 39: //Lean To
|
|
|
|
case 105://Wagon
|
|
|
|
case 108://Warrior's Tomb
|
|
|
|
{
|
|
|
|
nobj = new CGOnceVisitable();
|
|
|
|
break;
|
|
|
|
}
|
2009-07-19 04:00:19 +03:00
|
|
|
case 8: //Boat
|
|
|
|
{
|
|
|
|
nobj = new CGBoat();
|
|
|
|
break;
|
|
|
|
}
|
2009-07-19 10:16:33 +03:00
|
|
|
case 92: //Sirens
|
|
|
|
{
|
|
|
|
nobj = new CGSirens();
|
|
|
|
break;
|
|
|
|
}
|
2009-07-26 06:33:13 +03:00
|
|
|
case 87: //Shipyard
|
|
|
|
{
|
|
|
|
nobj = new CGShipyard();
|
2011-10-08 04:23:46 +03:00
|
|
|
nobj->setOwner(read_le_u32(bufor + i)); i+=4;
|
2009-07-26 06:33:13 +03:00
|
|
|
break;
|
|
|
|
}
|
2008-12-22 19:48:41 +02:00
|
|
|
case 214: //hero placeholder
|
2008-06-21 16:27:52 +03:00
|
|
|
{
|
2010-02-01 19:07:46 +02:00
|
|
|
CGHeroPlaceholder *hp = new CGHeroPlaceholder();;
|
|
|
|
nobj = hp;
|
|
|
|
|
2011-09-24 04:15:36 +03:00
|
|
|
int a = bufor[i++]; //unknown byte, seems to be always 0 (if not - scream!)
|
2011-07-01 19:26:36 +03:00
|
|
|
tlog2 << "Unhandled Hero Placeholder detected: "<<a<<"\n";
|
2010-02-01 19:07:46 +02:00
|
|
|
|
|
|
|
int htid = bufor[i++]; //hero type id
|
|
|
|
nobj->subID = htid;
|
|
|
|
|
|
|
|
if(htid == 0xff)
|
|
|
|
hp->power = bufor[i++];
|
|
|
|
else
|
|
|
|
hp->power = 0;
|
|
|
|
|
|
|
|
break;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2009-08-11 10:50:29 +03:00
|
|
|
case 10: //Keymaster
|
|
|
|
{
|
|
|
|
nobj = new CGKeymasterTent();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 9: //Border Guard
|
|
|
|
{
|
|
|
|
nobj = new CGBorderGuard();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 212: //Border Gate
|
|
|
|
{
|
|
|
|
nobj = new CGBorderGate();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 27: case 37: //Eye and Hut of Magi
|
|
|
|
{
|
|
|
|
nobj = new CGMagi();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 16: case 24: case 25: case 84: case 85: //treasure bank
|
|
|
|
{
|
|
|
|
nobj = new CBank();
|
|
|
|
break;
|
|
|
|
}
|
2009-09-24 20:54:02 +03:00
|
|
|
case 63: //Pyramid
|
|
|
|
{
|
|
|
|
nobj = new CGPyramid();
|
|
|
|
break;
|
|
|
|
}
|
2009-08-19 09:56:53 +03:00
|
|
|
case 13: //Cartographer
|
|
|
|
{
|
|
|
|
nobj = new CCartographer();
|
|
|
|
break;
|
|
|
|
}
|
2009-09-22 19:12:33 +03:00
|
|
|
case 48: //Magic Spring
|
|
|
|
{
|
2009-09-23 15:42:14 +03:00
|
|
|
nobj = new CGMagicSpring();
|
2009-09-22 19:12:33 +03:00
|
|
|
break;
|
|
|
|
}
|
2010-02-06 15:49:14 +02:00
|
|
|
case 97: //den of thieves
|
|
|
|
{
|
|
|
|
nobj = new CGDenOfthieves();
|
|
|
|
break;
|
|
|
|
}
|
2010-02-10 04:56:00 +02:00
|
|
|
case 57: //Obelisk
|
|
|
|
{
|
|
|
|
nobj = new CGObelisk();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 42: //Lighthouse
|
|
|
|
{
|
|
|
|
nobj = new CGLighthouse();
|
2011-10-08 04:23:46 +03:00
|
|
|
nobj->tempOwner = read_le_u32(bufor + i); i+=4;
|
2010-02-10 04:56:00 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-07-06 05:10:26 +03:00
|
|
|
case 2: //Altar of Sacrifice
|
2010-05-18 10:01:54 +03:00
|
|
|
case 99: //Trading Post
|
|
|
|
case 213: //Freelancer's Guild
|
|
|
|
case 221: //Trading Post (snow)
|
|
|
|
{
|
|
|
|
nobj = new CGMarket();
|
|
|
|
break;
|
|
|
|
}
|
2010-07-20 17:08:13 +03:00
|
|
|
case 104: //University
|
|
|
|
{
|
|
|
|
nobj = new CGUniversity();
|
|
|
|
break;
|
|
|
|
}
|
2010-06-27 19:03:01 +03:00
|
|
|
case 7: //Black Market
|
|
|
|
{
|
|
|
|
nobj = new CGBlackMarket();
|
|
|
|
break;
|
|
|
|
}
|
2010-05-18 10:01:54 +03:00
|
|
|
|
2010-02-06 15:49:14 +02:00
|
|
|
default: //any other object
|
|
|
|
{
|
|
|
|
nobj = new CGObjectInstance();
|
|
|
|
break;
|
|
|
|
}
|
2010-02-10 04:56:00 +02:00
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
} //end of main switch
|
2008-12-22 19:48:41 +02:00
|
|
|
|
|
|
|
nobj->pos = pos;
|
|
|
|
nobj->ID = defInfo->id;
|
2011-02-11 14:27:38 +02:00
|
|
|
nobj->id = idToBeGiven;
|
2011-12-14 00:23:17 +03:00
|
|
|
if(nobj->ID != GameConstants::HEROI_TYPE && nobj->ID != 214 && nobj->ID != 62)
|
2008-12-22 19:48:41 +02:00
|
|
|
nobj->subID = defInfo->subid;
|
|
|
|
nobj->defInfo = defInfo;
|
2011-02-11 14:27:38 +02:00
|
|
|
assert(idToBeGiven == objects.size());
|
2008-06-21 16:27:52 +03:00
|
|
|
objects.push_back(nobj);
|
2011-12-14 00:23:17 +03:00
|
|
|
if(nobj->ID==GameConstants::TOWNI_TYPE)
|
2008-12-22 19:48:41 +02:00
|
|
|
towns.push_back(static_cast<CGTownInstance*>(nobj));
|
2011-12-14 00:23:17 +03:00
|
|
|
if(nobj->ID==GameConstants::HEROI_TYPE)
|
2008-12-22 19:48:41 +02:00
|
|
|
heroes.push_back(static_cast<CGHeroInstance*>(nobj));
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
2009-07-27 20:55:56 +03:00
|
|
|
|
2010-12-20 15:04:24 +02:00
|
|
|
std::sort(heroes.begin(), heroes.end(), _HERO_SORTER());
|
2008-08-15 15:11:42 +03:00
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::readEvents( const ui8 * bufor, int &i )
|
2008-08-15 15:11:42 +03:00
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
int numberOfEvents = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int yyoo=0; yyoo<numberOfEvents; ++yyoo)
|
|
|
|
{
|
2009-03-09 21:40:43 +02:00
|
|
|
CMapEvent *ne = new CMapEvent();
|
|
|
|
ne->name = std::string();
|
|
|
|
ne->message = std::string();
|
2011-10-08 04:23:46 +03:00
|
|
|
int nameLen = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int qq=0; qq<nameLen; ++qq)
|
|
|
|
{
|
2009-03-09 21:40:43 +02:00
|
|
|
ne->name += bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2011-10-08 04:23:46 +03:00
|
|
|
int messLen = read_le_u32(bufor + i); i+=4;
|
2008-06-21 16:27:52 +03:00
|
|
|
for(int qq=0; qq<messLen; ++qq)
|
|
|
|
{
|
2009-03-09 21:40:43 +02:00
|
|
|
ne->message +=bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
2009-02-06 13:15:39 +02:00
|
|
|
for(int k=0; k < 7; k++)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
ne->resources[k] = read_le_u32(bufor + i); i+=4;
|
2009-02-06 13:15:39 +02:00
|
|
|
}
|
2009-03-09 21:40:43 +02:00
|
|
|
ne->players = bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
if(version>AB)
|
|
|
|
{
|
2009-03-09 21:40:43 +02:00
|
|
|
ne->humanAffected = bufor[i]; ++i;
|
2008-06-21 16:27:52 +03:00
|
|
|
}
|
|
|
|
else
|
2009-03-09 21:40:43 +02:00
|
|
|
ne->humanAffected = true;
|
|
|
|
ne->computerAffected = bufor[i]; ++i;
|
2011-10-08 04:23:46 +03:00
|
|
|
ne->firstOccurence = read_le_u16(bufor + i); i+=2;
|
2009-03-09 21:40:43 +02:00
|
|
|
ne->nextOccurence = bufor[i]; ++i;
|
2009-07-18 00:53:28 +03:00
|
|
|
|
|
|
|
char unknown[17];
|
|
|
|
memcpy(unknown, bufor+i, 17);
|
|
|
|
i+=17;
|
|
|
|
|
2008-06-21 16:27:52 +03:00
|
|
|
events.push_back(ne);
|
|
|
|
}
|
2008-08-30 00:41:32 +03:00
|
|
|
}
|
|
|
|
|
2009-08-22 16:59:15 +03:00
|
|
|
bool Mapa::isInTheMap(const int3 &pos) const
|
2008-08-30 00:41:32 +03:00
|
|
|
{
|
|
|
|
if(pos.x<0 || pos.y<0 || pos.z<0 || pos.x >= width || pos.y >= height || pos.z > twoLevel)
|
|
|
|
return false;
|
|
|
|
else return true;
|
2008-09-18 23:24:53 +03:00
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::loadQuest(CQuest * guard, const ui8 * bufor, int & i)
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
|
|
|
guard->missionType = bufor[i]; ++i;
|
2010-05-03 09:25:19 +03:00
|
|
|
//int len1, len2, len3;
|
2008-12-27 03:01:59 +02:00
|
|
|
switch(guard->missionType)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
return;
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
guard->m2stats.resize(4);
|
|
|
|
for(int x=0; x<4; x++)
|
|
|
|
{
|
|
|
|
guard->m2stats[x] = bufor[i++];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
guard->m13489val = read_le_u32(bufor + i); i+=4;
|
2008-12-27 03:01:59 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 5:
|
|
|
|
{
|
|
|
|
int artNumber = bufor[i]; ++i;
|
|
|
|
for(int yy=0; yy<artNumber; ++yy)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
int artid = read_le_u16(bufor + i); i+=2;
|
2010-07-09 08:07:56 +03:00
|
|
|
guard->m5arts.push_back(artid);
|
2011-09-24 04:15:36 +03:00
|
|
|
allowedArtifact[artid] = false; //these are unavailable for random generation
|
2008-12-27 03:01:59 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 6:
|
|
|
|
{
|
|
|
|
int typeNumber = bufor[i]; ++i;
|
2010-11-22 02:34:46 +02:00
|
|
|
guard->m6creatures.resize(typeNumber);
|
2008-12-27 03:01:59 +02:00
|
|
|
for(int hh=0; hh<typeNumber; ++hh)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
guard->m6creatures[hh].type = VLC->creh->creatures[read_le_u16(bufor + i)]; i+=2;
|
|
|
|
guard->m6creatures[hh].count = read_le_u16(bufor + i); i+=2;
|
2008-12-27 03:01:59 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 7:
|
|
|
|
{
|
|
|
|
guard->m7resources.resize(7);
|
|
|
|
for(int x=0; x<7; x++)
|
|
|
|
{
|
2011-10-08 04:23:46 +03:00
|
|
|
guard->m7resources[x] = read_le_u32(bufor + i);
|
2008-12-27 03:01:59 +02:00
|
|
|
i+=4;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
{
|
|
|
|
guard->m13489val = bufor[i]; ++i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-10-08 04:23:46 +03:00
|
|
|
int limit = read_le_u32(bufor + i); i+=4;
|
2008-12-27 03:01:59 +02:00
|
|
|
if(limit == ((int)0xffffffff))
|
|
|
|
{
|
|
|
|
guard->lastDay = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
guard->lastDay = limit;
|
|
|
|
}
|
|
|
|
guard->firstVisitText = readString(bufor,i);
|
|
|
|
guard->nextVisitText = readString(bufor,i);
|
|
|
|
guard->completedText = readString(bufor,i);
|
2011-10-16 22:24:05 +03:00
|
|
|
guard->isCustomFirst = guard->firstVisitText.size() > 0;
|
|
|
|
guard->isCustomNext = guard->nextVisitText.size() > 0;
|
|
|
|
guard->isCustomComplete = guard->completedText.size() > 0;
|
2009-01-11 00:08:18 +02:00
|
|
|
}
|
|
|
|
|
2010-08-16 16:51:31 +03:00
|
|
|
TerrainTile & Mapa::getTile( const int3 & tile )
|
2009-02-12 16:44:58 +02:00
|
|
|
{
|
|
|
|
return terrain[tile.x][tile.y][tile.z];
|
|
|
|
}
|
2009-07-26 06:33:13 +03:00
|
|
|
|
2010-08-16 16:51:31 +03:00
|
|
|
const TerrainTile & Mapa::getTile( const int3 & tile ) const
|
2009-07-26 06:33:13 +03:00
|
|
|
{
|
|
|
|
return terrain[tile.x][tile.y][tile.z];
|
|
|
|
}
|
|
|
|
|
2009-08-22 16:59:15 +03:00
|
|
|
bool Mapa::isWaterTile(const int3 &pos) const
|
2009-07-26 06:33:13 +03:00
|
|
|
{
|
|
|
|
return isInTheMap(pos) && getTile(pos).tertype == TerrainTile::water;
|
|
|
|
}
|
|
|
|
|
2011-05-30 02:49:25 +03:00
|
|
|
const CGObjectInstance *Mapa::getObjectiveObjectFrom(int3 pos, bool lookForHero)
|
2010-01-29 22:52:45 +02:00
|
|
|
{
|
2011-05-30 02:49:25 +03:00
|
|
|
const std::vector <CGObjectInstance*> &objs = getTile(pos).visitableObjects;
|
|
|
|
assert(objs.size());
|
2011-12-14 00:23:17 +03:00
|
|
|
if(objs.size() > 1 && lookForHero && objs.front()->ID != GameConstants::HEROI_TYPE)
|
2010-01-29 22:52:45 +02:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
assert(objs.back()->ID == GameConstants::HEROI_TYPE);
|
2011-05-30 02:49:25 +03:00
|
|
|
return objs.back();
|
2010-01-29 22:52:45 +02:00
|
|
|
}
|
2011-05-30 02:49:25 +03:00
|
|
|
else
|
|
|
|
return objs.front();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mapa::checkForObjectives()
|
|
|
|
{
|
|
|
|
if(isInTheMap(victoryCondition.pos))
|
2011-12-14 00:23:17 +03:00
|
|
|
victoryCondition.obj = getObjectiveObjectFrom(victoryCondition.pos, victoryCondition.condition == EVictoryConditionType::BEATHERO);
|
2010-01-29 22:52:45 +02:00
|
|
|
|
|
|
|
if(isInTheMap(lossCondition.pos))
|
2011-12-14 00:23:17 +03:00
|
|
|
lossCondition.obj = getObjectiveObjectFrom(lossCondition.pos, lossCondition.typeOfLossCon == ELossConditionType::LOSSHERO);
|
2010-01-29 22:52:45 +02:00
|
|
|
}
|
|
|
|
|
2010-12-17 20:47:07 +02:00
|
|
|
void Mapa::addNewArtifactInstance( CArtifactInstance *art )
|
|
|
|
{
|
|
|
|
art->id = artInstances.size();
|
|
|
|
artInstances.push_back(art);
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
bool Mapa::loadArtifactToSlot(CGHeroInstance *h, int slot, const ui8 * bufor, int &i)
|
2010-12-30 16:41:46 +02:00
|
|
|
{
|
|
|
|
const int artmask = version == RoE ? 0xff : 0xffff;
|
2011-10-08 19:06:11 +03:00
|
|
|
int aid;
|
|
|
|
|
|
|
|
if (version == RoE)
|
|
|
|
{
|
|
|
|
aid = bufor[i]; i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aid = read_le_u16(bufor + i); i+=2;
|
|
|
|
}
|
2010-12-30 16:41:46 +02:00
|
|
|
|
|
|
|
bool isArt = aid != artmask;
|
|
|
|
if(isArt)
|
2011-01-18 20:56:14 +02:00
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if(vstd::contains(VLC->arth->bigArtifacts, aid) && slot >= GameConstants::BACKPACK_START)
|
2011-05-30 02:49:25 +03:00
|
|
|
{
|
2011-01-18 20:56:14 +02:00
|
|
|
tlog3 << "Warning: A big artifact (war machine) in hero's backpack, ignoring...\n";
|
2011-05-30 02:49:25 +03:00
|
|
|
return false;
|
|
|
|
}
|
2011-12-14 00:23:17 +03:00
|
|
|
if(aid == 0 && slot == ArtifactPosition::MISC5)
|
2011-05-30 02:49:25 +03:00
|
|
|
{
|
|
|
|
//TODO: check how H3 handles it -> art 0 in slot 18 in AB map
|
|
|
|
tlog3 << "Spellbook to MISC5 slot? Putting it spellbook place. AB format peculiarity ? (format " << (int)version << ")\n";
|
2011-12-14 00:23:17 +03:00
|
|
|
slot = ArtifactPosition::SPELLBOOK;
|
2011-05-30 02:49:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
h->putArtifact(slot, createArt(aid));
|
2011-01-18 20:56:14 +02:00
|
|
|
}
|
2010-12-30 16:41:46 +02:00
|
|
|
return isArt;
|
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
void Mapa::loadArtifactsOfHero(const ui8 * bufor, int & i, CGHeroInstance * nhi)
|
2010-12-30 16:41:46 +02:00
|
|
|
{
|
|
|
|
bool artSet = bufor[i]; ++i; //true if artifact set is not default (hero has some artifacts)
|
|
|
|
if(artSet)
|
|
|
|
{
|
|
|
|
for(int pom=0;pom<16;pom++)
|
|
|
|
loadArtifactToSlot(nhi, pom, bufor, i);
|
|
|
|
|
|
|
|
//misc5 art //17
|
|
|
|
if(version >= SoD)
|
|
|
|
{
|
2011-12-14 00:23:17 +03:00
|
|
|
if(!loadArtifactToSlot(nhi, ArtifactPosition::MACH4, bufor, i))
|
|
|
|
nhi->putArtifact(ArtifactPosition::MACH4, createArt(GameConstants::ID_CATAPULT)); //catapult by default
|
2010-12-30 16:41:46 +02:00
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
loadArtifactToSlot(nhi, ArtifactPosition::SPELLBOOK, bufor, i);
|
2010-12-30 16:41:46 +02:00
|
|
|
|
|
|
|
//19 //???what is that? gap in file or what? - it's probably fifth slot..
|
|
|
|
if(version > RoE)
|
2011-12-14 00:23:17 +03:00
|
|
|
loadArtifactToSlot(nhi, ArtifactPosition::MISC5, bufor, i);
|
2010-12-30 16:41:46 +02:00
|
|
|
else
|
|
|
|
i+=1;
|
|
|
|
|
|
|
|
//bag artifacts //20
|
2011-10-08 04:23:46 +03:00
|
|
|
int amount = read_le_u16(bufor + i); i+=2; //number of artifacts in hero's bag
|
2010-12-30 16:41:46 +02:00
|
|
|
for(int ss = 0; ss < amount; ++ss)
|
2011-12-14 00:23:17 +03:00
|
|
|
loadArtifactToSlot(nhi, GameConstants::BACKPACK_START + nhi->artifactsInBackpack.size(), bufor, i);
|
2010-12-30 16:41:46 +02:00
|
|
|
} //artifacts
|
|
|
|
}
|
|
|
|
|
2011-03-12 23:55:31 +02:00
|
|
|
CArtifactInstance * Mapa::createArt(int aid, int spellID /*= -1*/)
|
2010-12-30 16:41:46 +02:00
|
|
|
{
|
|
|
|
CArtifactInstance *a = NULL;
|
|
|
|
if(aid >= 0)
|
2011-03-12 23:55:31 +02:00
|
|
|
{
|
|
|
|
if(spellID < 0)
|
|
|
|
a = CArtifactInstance::createNewArtifactInstance(aid);
|
|
|
|
else
|
|
|
|
a = CArtifactInstance::createScroll(VLC->spellh->spells[spellID]);
|
|
|
|
}
|
2010-12-30 16:41:46 +02:00
|
|
|
else
|
|
|
|
a = new CArtifactInstance();
|
|
|
|
|
2011-01-22 05:43:20 +02:00
|
|
|
addNewArtifactInstance(a);
|
|
|
|
if(a->artType && a->artType->constituents) //TODO make it nicer
|
|
|
|
{
|
|
|
|
CCombinedArtifactInstance *comb = dynamic_cast<CCombinedArtifactInstance*>(a);
|
|
|
|
BOOST_FOREACH(CCombinedArtifactInstance::ConstituentInfo &ci, comb->constituentsInfo)
|
|
|
|
{
|
|
|
|
addNewArtifactInstance(ci.art);
|
|
|
|
}
|
|
|
|
}
|
2010-12-30 16:41:46 +02:00
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2011-01-28 04:11:58 +02:00
|
|
|
void Mapa::eraseArtifactInstance(CArtifactInstance *art)
|
|
|
|
{
|
|
|
|
assert(artInstances[art->id] == art);
|
|
|
|
artInstances[art->id].dellNull();
|
|
|
|
}
|
|
|
|
|
2010-01-29 22:52:45 +02:00
|
|
|
LossCondition::LossCondition()
|
|
|
|
{
|
|
|
|
obj = NULL;
|
|
|
|
timeLimit = -1;
|
|
|
|
pos = int3(-1,-1,-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
CVictoryCondition::CVictoryCondition()
|
|
|
|
{
|
|
|
|
pos = int3(-1,-1,-1);
|
|
|
|
obj = NULL;
|
|
|
|
ID = allowNormalVictory = appliesToAI = count = 0;
|
2010-02-13 17:56:34 +02:00
|
|
|
}
|
2010-03-21 00:17:19 +02:00
|
|
|
|
|
|
|
bool TerrainTile::entrableTerrain(const TerrainTile *from /*= NULL*/) const
|
|
|
|
{
|
|
|
|
return entrableTerrain(from ? from->tertype != water : true, from ? from->tertype == water : true);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TerrainTile::entrableTerrain(bool allowLand, bool allowSea) const
|
|
|
|
{
|
|
|
|
return tertype != rock
|
2010-11-09 13:27:58 +02:00
|
|
|
&& ((allowSea && tertype == water) || (allowLand && tertype != water));
|
2010-03-21 00:17:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TerrainTile::isClear(const TerrainTile *from /*= NULL*/) const
|
|
|
|
{
|
|
|
|
return entrableTerrain(from) && !blocked;
|
2011-02-06 19:26:27 +02:00
|
|
|
}
|
2011-09-19 23:50:25 +03:00
|
|
|
|
|
|
|
int TerrainTile::topVisitableID() const
|
|
|
|
{
|
|
|
|
return visitableObjects.size() ? visitableObjects.back()->ID : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TerrainTile::isCoastal() const
|
|
|
|
{
|
|
|
|
return siodmyTajemniczyBajt & 64;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TerrainTile::hasFavourableWinds() const
|
|
|
|
{
|
|
|
|
return siodmyTajemniczyBajt & 128;
|
2011-09-24 04:15:36 +03:00
|
|
|
}
|
2012-01-03 04:55:26 +03:00
|
|
|
|
|
|
|
bool TerrainTile::isWater() const
|
|
|
|
{
|
|
|
|
return tertype == water;
|
|
|
|
}
|