1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-31 00:07:39 +02:00

Fixes for handling starting spells / spellbook.

This commit is contained in:
Michał W. Urbańczyk
2009-09-13 22:45:58 +00:00
parent efb1049860
commit 670a408fab
2 changed files with 15 additions and 6 deletions

View File

@@ -660,12 +660,16 @@ void CGHeroInstance::initHero()
initHeroDefInfo(); initHeroDefInfo();
if(!type) if(!type)
type = VLC->heroh->heroes[subID]; type = VLC->heroh->heroes[subID];
artifWorn[16] = 3; if(!vstd::contains(spells, 0xffffffff) && type->startingSpell >= 0) //hero starts with a spell
if(type->startingSpell >= 0) //hero starts with a spell
{
artifWorn[17] = 0; //give him spellbook
spells.insert(type->startingSpell); spells.insert(type->startingSpell);
else //remove placeholder
spells -= 0xffffffff;
if(!vstd::contains(artifWorn, 16) && type->startingSpell >= 0) //no catapult means we haven't read pre-existant set
{
artifWorn[17] = 0; //give spellbook
} }
artifWorn[16] = 3; //everyone has a catapult
if(portrait < 0 || portrait == 255) if(portrait < 0 || portrait == 255)
portrait = subID; portrait = subID;

View File

@@ -981,6 +981,8 @@ void Mapa::loadHero( CGObjectInstance * &nobj, unsigned char * bufor, int &i )
int id = readNormalNr(bufor,i, artidlen); i+=artidlen; int id = readNormalNr(bufor,i, artidlen); i+=artidlen;
if(id!=artmask) if(id!=artmask)
nhi->artifWorn[16] = id; nhi->artifWorn[16] = id;
else
nhi->artifWorn[16] = 3; //catapult by default
} }
//spellbook //spellbook
int id = readNormalNr(bufor,i, artidlen); i+=artidlen; int id = readNormalNr(bufor,i, artidlen); i+=artidlen;
@@ -1027,6 +1029,7 @@ void Mapa::loadHero( CGObjectInstance * &nobj, unsigned char * bufor, int &i )
if(areSpells) //TODO: sprawdzi� //seems to be ok - tow if(areSpells) //TODO: sprawdzi� //seems to be ok - tow
{ {
nhi->spells.insert(0xffffffff); //placeholder "preset spells"
int ist = i; int ist = i;
for(i; i<ist+9; ++i) for(i; i<ist+9; ++i)
{ {
@@ -1045,9 +1048,11 @@ void Mapa::loadHero( CGObjectInstance * &nobj, unsigned char * bufor, int &i )
else if(version==AB) //we can read one spell else if(version==AB) //we can read one spell
{ {
unsigned char buff = bufor[i]; ++i; unsigned char buff = bufor[i]; ++i;
if(buff!=254) if(buff != 254)
{ {
nhi->spells.insert(buff); nhi->spells.insert(0xffffffff); //placeholder "preset spells"
if(buff < 254) //255 means no spells
nhi->spells.insert(buff);
} }
} }
//spells loaded //spells loaded