mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
function to set palyer's color on flags, small improvements in CHeroHandler (e.g. removing nodrze and initializing hero's classes)
This commit is contained in:
parent
daec9ecca4
commit
b65f1dae0f
@ -293,9 +293,9 @@ void CAmbarCendamo::deh3m()
|
|||||||
if((i-ist)*8+yy < CGameInfo::mainObj->heroh->heroes.size())
|
if((i-ist)*8+yy < CGameInfo::mainObj->heroh->heroes.size())
|
||||||
{
|
{
|
||||||
if(c == (c|((unsigned char)intPow(2, yy))))
|
if(c == (c|((unsigned char)intPow(2, yy))))
|
||||||
CGameInfo::mainObj->heroh->heroes[(i-ist)*8+yy].isAllowed = true;
|
CGameInfo::mainObj->heroh->heroes[(i-ist)*8+yy]->isAllowed = true;
|
||||||
else
|
else
|
||||||
CGameInfo::mainObj->heroh->heroes[(i-ist)*8+yy].isAllowed = false;
|
CGameInfo::mainObj->heroh->heroes[(i-ist)*8+yy]->isAllowed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ void CAmbarCendamo::deh3m()
|
|||||||
spec->bytes[2] = bufor[i]; ++i;
|
spec->bytes[2] = bufor[i]; ++i;
|
||||||
spec->bytes[3] = bufor[i]; ++i;
|
spec->bytes[3] = bufor[i]; ++i;
|
||||||
spec->player = bufor[i]; ++i;
|
spec->player = bufor[i]; ++i;
|
||||||
spec->type = &(CGameInfo::mainObj->heroh->heroes[readNormalNr(i, 1)]); ++i;
|
spec->type = CGameInfo::mainObj->heroh->heroes[readNormalNr(i, 1)]; ++i;
|
||||||
bool isName = bufor[i]; ++i; //true if hero has nonstandard name
|
bool isName = bufor[i]; ++i; //true if hero has nonstandard name
|
||||||
if(isName)
|
if(isName)
|
||||||
{
|
{
|
||||||
@ -978,7 +978,7 @@ void CAmbarCendamo::deh3m()
|
|||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
int heroType = bufor[i]; ++i;
|
int heroType = bufor[i]; ++i;
|
||||||
spec->m8hero = &(CGameInfo::mainObj->heroh->heroes[heroType]);
|
spec->m8hero = CGameInfo::mainObj->heroh->heroes[heroType];
|
||||||
int limit = readNormalNr(i); i+=4;
|
int limit = readNormalNr(i); i+=4;
|
||||||
if(limit == ((int)0xffffffff))
|
if(limit == ((int)0xffffffff))
|
||||||
{
|
{
|
||||||
@ -1629,7 +1629,7 @@ void CAmbarCendamo::deh3m()
|
|||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
int heroType = bufor[i]; ++i;
|
int heroType = bufor[i]; ++i;
|
||||||
spec->m8hero = &(CGameInfo::mainObj->heroh->heroes[heroType]);
|
spec->m8hero = CGameInfo::mainObj->heroh->heroes[heroType];
|
||||||
int limit = readNormalNr(i); i+=4;
|
int limit = readNormalNr(i); i+=4;
|
||||||
if(limit == ((int)0xffffffff))
|
if(limit == ((int)0xffffffff))
|
||||||
{
|
{
|
||||||
|
@ -14,9 +14,40 @@ void CHeroHandler::loadHeroes()
|
|||||||
inp>>dump;
|
inp>>dump;
|
||||||
}
|
}
|
||||||
inp.ignore();
|
inp.ignore();
|
||||||
|
int numberOfCurrentClassHeroes = 0;
|
||||||
|
int currentClass = 0;
|
||||||
|
int additHero = 0;
|
||||||
|
EHeroClasses addTab[12];
|
||||||
|
addTab[0] = HERO_KNIGHT;
|
||||||
|
addTab[1] = HERO_WITCH;
|
||||||
|
addTab[2] = HERO_KNIGHT;
|
||||||
|
addTab[3] = HERO_WIZARD;
|
||||||
|
addTab[4] = HERO_RANGER;
|
||||||
|
addTab[5] = HERO_BARBARIAN;
|
||||||
|
addTab[6] = HERO_DEATHKNIGHT;
|
||||||
|
addTab[7] = HERO_WARLOCK;
|
||||||
|
addTab[8] = HERO_KNIGHT;
|
||||||
|
addTab[9] = HERO_WARLOCK;
|
||||||
|
addTab[10] = HERO_BARBARIAN;
|
||||||
|
addTab[11] = HERO_DEMONIAC;
|
||||||
|
|
||||||
while(!inp.eof())
|
while(!inp.eof())
|
||||||
{
|
{
|
||||||
CHero nher;
|
CHero * nher = new CHero;
|
||||||
|
if(currentClass<18)
|
||||||
|
{
|
||||||
|
nher->heroType = (EHeroClasses)currentClass;
|
||||||
|
++numberOfCurrentClassHeroes;
|
||||||
|
if(numberOfCurrentClassHeroes==8)
|
||||||
|
{
|
||||||
|
numberOfCurrentClassHeroes = 0;
|
||||||
|
++currentClass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nher->heroType = addTab[additHero++];
|
||||||
|
}
|
||||||
std::string base;
|
std::string base;
|
||||||
char * tab = new char[500];
|
char * tab = new char[500];
|
||||||
int iit = 0;
|
int iit = 0;
|
||||||
@ -27,6 +58,7 @@ void CHeroHandler::loadHeroes()
|
|||||||
loadSpecialAbilities();
|
loadSpecialAbilities();
|
||||||
loadBiographies();
|
loadBiographies();
|
||||||
loadHeroClasses();
|
loadHeroClasses();
|
||||||
|
initHeroClasses();
|
||||||
inp.close();
|
inp.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -34,13 +66,13 @@ void CHeroHandler::loadHeroes()
|
|||||||
{
|
{
|
||||||
++iit;
|
++iit;
|
||||||
}
|
}
|
||||||
nher.name = base.substr(0, iit);
|
nher->name = base.substr(0, iit);
|
||||||
++iit;
|
++iit;
|
||||||
for(int i=iit; i<iit+100; ++i)
|
for(int i=iit; i<iit+100; ++i)
|
||||||
{
|
{
|
||||||
if(base[i]==(char)(10) || base[i]==(char)(9))
|
if(base[i]==(char)(10) || base[i]==(char)(9))
|
||||||
{
|
{
|
||||||
nher.low1stack = atoi(base.substr(iit, i).c_str());
|
nher->low1stack = atoi(base.substr(iit, i).c_str());
|
||||||
iit=i+1;
|
iit=i+1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -49,7 +81,7 @@ void CHeroHandler::loadHeroes()
|
|||||||
{
|
{
|
||||||
if(base[i]==(char)(10) || base[i]==(char)(9))
|
if(base[i]==(char)(10) || base[i]==(char)(9))
|
||||||
{
|
{
|
||||||
nher.high1stack = atoi(base.substr(iit, i).c_str());
|
nher->high1stack = atoi(base.substr(iit, i).c_str());
|
||||||
iit=i+1;
|
iit=i+1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -59,13 +91,13 @@ void CHeroHandler::loadHeroes()
|
|||||||
{
|
{
|
||||||
++ipom;
|
++ipom;
|
||||||
}
|
}
|
||||||
nher.refType1stack = base.substr(iit, ipom-iit);
|
nher->refType1stack = base.substr(iit, ipom-iit);
|
||||||
iit=ipom+1;
|
iit=ipom+1;
|
||||||
for(int i=iit; i<iit+100; ++i)
|
for(int i=iit; i<iit+100; ++i)
|
||||||
{
|
{
|
||||||
if(base[i]==(char)(10) || base[i]==(char)(9))
|
if(base[i]==(char)(10) || base[i]==(char)(9))
|
||||||
{
|
{
|
||||||
nher.low2stack = atoi(base.substr(iit, i-iit).c_str());
|
nher->low2stack = atoi(base.substr(iit, i-iit).c_str());
|
||||||
iit=i+1;
|
iit=i+1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -74,7 +106,7 @@ void CHeroHandler::loadHeroes()
|
|||||||
{
|
{
|
||||||
if(base[i]==(char)(10) || base[i]==(char)(9))
|
if(base[i]==(char)(10) || base[i]==(char)(9))
|
||||||
{
|
{
|
||||||
nher.high2stack = atoi(base.substr(iit, i-iit).c_str());
|
nher->high2stack = atoi(base.substr(iit, i-iit).c_str());
|
||||||
iit=i+1;
|
iit=i+1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -84,13 +116,13 @@ void CHeroHandler::loadHeroes()
|
|||||||
{
|
{
|
||||||
++ipom;
|
++ipom;
|
||||||
}
|
}
|
||||||
nher.refType2stack = base.substr(iit, ipom-iit);
|
nher->refType2stack = base.substr(iit, ipom-iit);
|
||||||
iit=ipom+1;
|
iit=ipom+1;
|
||||||
for(int i=iit; i<iit+100; ++i)
|
for(int i=iit; i<iit+100; ++i)
|
||||||
{
|
{
|
||||||
if(base[i]==(char)(10) || base[i]==(char)(9))
|
if(base[i]==(char)(10) || base[i]==(char)(9))
|
||||||
{
|
{
|
||||||
nher.low3stack = atoi(base.substr(iit, i-iit).c_str());
|
nher->low3stack = atoi(base.substr(iit, i-iit).c_str());
|
||||||
iit=i+1;
|
iit=i+1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -99,13 +131,13 @@ void CHeroHandler::loadHeroes()
|
|||||||
{
|
{
|
||||||
if(base[i]==(char)(10) || base[i]==(char)(9))
|
if(base[i]==(char)(10) || base[i]==(char)(9))
|
||||||
{
|
{
|
||||||
nher.high3stack = atoi(base.substr(iit, i-iit).c_str());
|
nher->high3stack = atoi(base.substr(iit, i-iit).c_str());
|
||||||
iit=i+1;
|
iit=i+1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nher.refType3stack = base.substr(iit, base.size()-iit);
|
nher->refType3stack = base.substr(iit, base.size()-iit);
|
||||||
nher.ID=ID++;
|
nher->ID=ID++;
|
||||||
heroes.push_back(nher);
|
heroes.push_back(nher);
|
||||||
delete[500] tab;
|
delete[500] tab;
|
||||||
}
|
}
|
||||||
@ -138,11 +170,11 @@ void CHeroHandler::loadSpecialAbilities()
|
|||||||
{
|
{
|
||||||
++iit;
|
++iit;
|
||||||
}
|
}
|
||||||
heroes[whHero].bonusName = base.substr(0, iit);
|
heroes[whHero]->bonusName = base.substr(0, iit);
|
||||||
++iit;
|
++iit;
|
||||||
iitBef=iit;
|
iitBef=iit;
|
||||||
|
|
||||||
if(heroes[whHero].bonusName == std::string("Ogry"))
|
if(heroes[whHero]->bonusName == std::string("Ogry"))
|
||||||
{
|
{
|
||||||
char * tab2 = new char[500];
|
char * tab2 = new char[500];
|
||||||
inp.getline(tab2, 500);
|
inp.getline(tab2, 500);
|
||||||
@ -154,7 +186,7 @@ void CHeroHandler::loadSpecialAbilities()
|
|||||||
{
|
{
|
||||||
++iit;
|
++iit;
|
||||||
}
|
}
|
||||||
heroes[whHero].shortBonus = base.substr(iitBef, iit-iitBef);
|
heroes[whHero]->shortBonus = base.substr(iitBef, iit-iitBef);
|
||||||
++iit;
|
++iit;
|
||||||
iitBef=iit;
|
iitBef=iit;
|
||||||
|
|
||||||
@ -162,7 +194,7 @@ void CHeroHandler::loadSpecialAbilities()
|
|||||||
{
|
{
|
||||||
++iit;
|
++iit;
|
||||||
}
|
}
|
||||||
heroes[whHero].longBonus = base.substr(iitBef, iit-iitBef);
|
heroes[whHero]->longBonus = base.substr(iitBef, iit-iitBef);
|
||||||
++whHero;
|
++whHero;
|
||||||
delete [500] tab;
|
delete [500] tab;
|
||||||
}
|
}
|
||||||
@ -189,7 +221,7 @@ void CHeroHandler::loadBiographies()
|
|||||||
if(buf[i]=='\r')
|
if(buf[i]=='\r')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
heroes[q].biography = buf.substr(befi, i-befi);
|
heroes[q]->biography = buf.substr(befi, i-befi);
|
||||||
i+=2;
|
i+=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +376,7 @@ void CHeroHandler::loadHeroClasses()
|
|||||||
hc->proKnowledge[1] = atoi(buf.substr(befi, i-befi).c_str());
|
hc->proKnowledge[1] = atoi(buf.substr(befi, i-befi).c_str());
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
CHero kkk = heroes[0];
|
//CHero kkk = heroes[0];
|
||||||
|
|
||||||
for(int dd=0; dd<CGameInfo::mainObj->abilh->abilities.size(); ++dd)
|
for(int dd=0; dd<CGameInfo::mainObj->abilh->abilities.size(); ++dd)
|
||||||
{
|
{
|
||||||
@ -374,3 +406,11 @@ void CHeroHandler::loadHeroClasses()
|
|||||||
heroClasses.push_back(hc);
|
heroClasses.push_back(hc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CHeroHandler::initHeroClasses()
|
||||||
|
{
|
||||||
|
for(int gg=0; gg<heroes.size(); ++gg)
|
||||||
|
{
|
||||||
|
heroes[gg]->heroClass = heroClasses[heroes[gg]->heroType];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,10 +4,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "CCreatureHandler.h"
|
#include "CCreatureHandler.h"
|
||||||
#include "nodrze.h"
|
|
||||||
|
|
||||||
class CHeroClass;
|
class CHeroClass;
|
||||||
|
|
||||||
|
enum EHeroClasses {HERO_KNIGHT, HERO_CLERIC, HERO_RANGER, HERO_DRUID, HREO_ALCHEMIST, HERO_WIZARD, HERO_DEMONIAC, HERO_HERETIC, HERO_DEATHKNIGHT, HERO_NECROMANCER, HERO_WARLOCK, HERO_OVERLORD, HERO_BARBARIAN, HERO_BATTLEMAGE, HERO_BEASTMASTER, HERO_WITCH, HERO_PLANESWALKER, HERO_ELEMENTALIST};
|
||||||
|
|
||||||
class CHero
|
class CHero
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -19,7 +20,8 @@ public:
|
|||||||
std::string biography; //biography, of course
|
std::string biography; //biography, of course
|
||||||
bool isAllowed; //true if we can play with this hero (depends on map)
|
bool isAllowed; //true if we can play with this hero (depends on map)
|
||||||
CHeroClass * heroClass;
|
CHeroClass * heroClass;
|
||||||
bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;}
|
EHeroClasses heroType; //hero class
|
||||||
|
//bool operator<(CHero& drugi){if (ID < drugi.ID) return true; else return false;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CHeroClass
|
class CHeroClass
|
||||||
@ -48,12 +50,13 @@ public:
|
|||||||
class CHeroHandler
|
class CHeroHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nodrze<CHero> heroes; //by³o nodrze
|
std::vector<CHero*> heroes; //by³o nodrze
|
||||||
std::vector<CHeroClass *> heroClasses;
|
std::vector<CHeroClass *> heroClasses;
|
||||||
void loadHeroes();
|
void loadHeroes();
|
||||||
void loadSpecialAbilities();
|
void loadSpecialAbilities();
|
||||||
void loadBiographies();
|
void loadBiographies();
|
||||||
void loadHeroClasses();
|
void loadHeroClasses();
|
||||||
|
void initHeroClasses();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -581,3 +581,13 @@ void CSDL_Ext::blueToPlayersAdv(SDL_Surface * sur, int player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSDL_Ext::setPlayerColor(SDL_Surface * sur, int player)
|
||||||
|
{
|
||||||
|
if(sur->format->BitsPerPixel==8)
|
||||||
|
{
|
||||||
|
if(player != -1)
|
||||||
|
*(sur->format->palette->colors+5) = CGameInfo::mainObj->playerColors[player];
|
||||||
|
else
|
||||||
|
*(sur->format->palette->colors+5) = CGameInfo::mainObj->neutralColor;
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,7 @@ namespace CSDL_Ext
|
|||||||
void update(SDL_Surface * what = ekran); //updates whole surface (default - main screen)
|
void update(SDL_Surface * what = ekran); //updates whole surface (default - main screen)
|
||||||
void blueToPlayers(SDL_Surface * sur, int player); //simple color substitution
|
void blueToPlayers(SDL_Surface * sur, int player); //simple color substitution
|
||||||
void blueToPlayersAdv(SDL_Surface * sur, int player); //substitute blue color by another one, makes it nicer keeping nuances
|
void blueToPlayersAdv(SDL_Surface * sur, int player); //substitute blue color by another one, makes it nicer keeping nuances
|
||||||
|
void setPlayerColor(SDL_Surface * sur, int player); //sets correct color of flags; -1 for neutral
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SDL_EXTENSIONS_H
|
#endif // SDL_EXTENSIONS_H
|
Loading…
Reference in New Issue
Block a user