1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-05 23:28:14 +02:00

- fixed crash on opening spellbook during enemy turn

- fixed last known localization issue (bank configs)
- diplomacy and new weeks\month mechanics should be identical to H3
- minor fixes
This commit is contained in:
Ivan Savenko
2012-01-19 14:33:22 +00:00
parent 3fcf8b6f4b
commit dbc603b7d7
19 changed files with 355 additions and 472 deletions

View File

@@ -175,11 +175,11 @@ CCampaignScenario CCampaignHandler::readScenarioFromMemory( const ui8 *buffer, i
ret.packedMapSize = read_le_u32(buffer + outIt); outIt += 4;
if(mapVersion == 18)//unholy alliance
{
ret.preconditionRegion = read_le_u16(buffer + outIt); outIt += 2;
ret.loadPreconditionRegions(read_le_u16(buffer + outIt)); outIt += 2;
}
else
{
ret.preconditionRegion = buffer[outIt++];
ret.loadPreconditionRegions(buffer[outIt++]);
}
ret.regionColor = buffer[outIt++];
ret.difficulty = buffer[outIt++];
@@ -192,6 +192,15 @@ CCampaignScenario CCampaignHandler::readScenarioFromMemory( const ui8 *buffer, i
return ret;
}
void CCampaignScenario::loadPreconditionRegions(ui32 regions)
{
for (int i=0; i<32; i++) //for each bit in region. h3c however can only hold up to 16
{
if ( (1 << i) & regions)
preconditionRegions.insert(i);
}
}
CScenarioTravel CCampaignHandler::readScenarioTravelFromMemory( const ui8 * buffer, int & outIt , int version )
{
CScenarioTravel ret;
@@ -444,7 +453,7 @@ bool CCampaign::conquerable( int whichScenario ) const
//check preconditioned regions
for (int g=0; g<scenarios.size(); ++g)
{
if(( (1 << g) & scenarios[whichScenario].preconditionRegion ) && !scenarios[g].conquered)
if( vstd::contains(scenarios[whichScenario].preconditionRegions, g) && !scenarios[g].conquered)
return false; //prerequisite does not met
}
@@ -510,17 +519,25 @@ void CCampaignScenario::prepareCrossoverHeroes( std::vector<CGHeroInstance *> he
if (!(travelOptions.whatHeroKeeps & 16))
{
//trimming artifacts
for (int g=0; g<VLC->arth->artifacts.size(); ++g)
BOOST_FOREACH(CGHeroInstance * hero, crossoverHeroes)
{
bool takeable = travelOptions.artifsKeptByHero[g / 8] & ( 1 << (g%8) ) ;
if (!takeable)
size_t totalArts = GameConstants::BACKPACK_START + hero->artifactsInBackpack.size();
for (size_t i=0; i<totalArts; i++ )
{
//BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
{
tlog1 << "TODO TODO TODO - take artifacts from hero\n";
//TODO how was that supposed to work with worn artifacts?
//cgh->artifactsInBackpack -= VLC->arth->artifacts[g];
}
const ArtSlotInfo *info = hero->getSlot(i);
if (!info)
continue;
const CArtifactInstance *art = info->artifact;
if (!art)//FIXME: check spellbook and catapult behaviour
continue;
int id = art->artType->id;
assert( 8*18 > id );//number of arts that fits into h3m format
bool takeable = travelOptions.artifsKeptByHero[id / 8] & ( 1 << (id%8) );
if (takeable)
hero->eraseArtSlot(i);
}
}
}