mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
* corrected indentation
* centered battle interface * battle cursor while 1024x768 is now correct * new version of settings.txt from Tow
This commit is contained in:
parent
ae48e73fe7
commit
b114582857
@ -39,11 +39,12 @@ struct CMP_stack2
|
||||
}
|
||||
} cmpst2 ;
|
||||
|
||||
CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2)
|
||||
CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2, const SDL_Rect & myRect)
|
||||
: printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL),
|
||||
attackingInfo(NULL), myTurn(false), resWindow(NULL), showStackQueue(false), animSpeed(2), printStackRange(true),
|
||||
printMouseShadow(true), spellDestSelectMode(false), spellToCast(NULL), previouslyHoveredHex(-1)
|
||||
{
|
||||
pos = myRect;
|
||||
strongInterest = true;
|
||||
givenCommand = new CondSh<BattleAction *>(NULL);
|
||||
//initializing armies
|
||||
@ -119,25 +120,25 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
}
|
||||
|
||||
////blitting menu background and terrain
|
||||
blitAt(background, 0, 0);
|
||||
blitAt(menu, 0, 556);
|
||||
blitAt(background, pos.x, pos.y);
|
||||
blitAt(menu, pos.x, 556 + pos.y);
|
||||
CSDL_Ext::update();
|
||||
|
||||
//preparing buttons and console
|
||||
bOptions = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bOptionsf,this), 3, 561, "icm003.def", SDLK_o);
|
||||
bSurrender = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bSurrenderf,this), 54, 561, "icm001.def", SDLK_s);
|
||||
bFlee = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bFleef,this), 105, 561, "icm002.def", SDLK_r);
|
||||
bAutofight = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bAutofightf,this), 157, 561, "icm004.def", SDLK_a);
|
||||
bSpell = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bSpellf,this), 645, 561, "icm005.def", SDLK_c);
|
||||
bWait = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bWaitf,this), 696, 561, "icm006.def", SDLK_w);
|
||||
bDefence = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bDefencef,this), 747, 561, "icm007.def", SDLK_d);
|
||||
bOptions = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bOptionsf,this), 3 + pos.x, 561 + pos.y, "icm003.def", SDLK_o);
|
||||
bSurrender = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bSurrenderf,this), 54 + pos.x, 561 + pos.y, "icm001.def", SDLK_s);
|
||||
bFlee = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bFleef,this), 105 + pos.x, 561 + pos.y, "icm002.def", SDLK_r);
|
||||
bAutofight = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bAutofightf,this), 157 + pos.x, 561 + pos.y, "icm004.def", SDLK_a);
|
||||
bSpell = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bSpellf,this), 645 + pos.x, 561 + pos.y, "icm005.def", SDLK_c);
|
||||
bWait = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bWaitf,this), 696 + pos.x, 561 + pos.y, "icm006.def", SDLK_w);
|
||||
bDefence = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bDefencef,this), 747 + pos.x, 561 + pos.y, "icm007.def", SDLK_d);
|
||||
bDefence->assignedKeys.insert(SDLK_SPACE);
|
||||
bConsoleUp = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleUpf,this), 624, 561, "ComSlide.def", SDLK_UP);
|
||||
bConsoleDown = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleDownf,this), 624, 580, "ComSlide.def", SDLK_DOWN);
|
||||
bConsoleUp = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleUpf,this), 624 + pos.x, 561 + pos.y, "ComSlide.def", SDLK_UP);
|
||||
bConsoleDown = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleDownf,this), 624 + pos.x, 580 + pos.y, "ComSlide.def", SDLK_DOWN);
|
||||
bConsoleDown->bitmapOffset = 2;
|
||||
console = new CBattleConsole();
|
||||
console->pos.x = 211;
|
||||
console->pos.y = 560;
|
||||
console->pos.x = 211 + pos.x;
|
||||
console->pos.y = 560 + pos.y;
|
||||
console->pos.w = 406;
|
||||
console->pos.h = 38;
|
||||
|
||||
@ -145,7 +146,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
if(hero1) // attacking hero
|
||||
{
|
||||
attackingHero = new CBattleHero(graphics->battleHeroes[hero1->type->heroType], 0, 0, false, hero1->tempOwner, hero1->tempOwner == LOCPLINT->playerID ? hero1 : NULL, this);
|
||||
attackingHero->pos = genRect(attackingHero->dh->ourImages[0].bitmap->h, attackingHero->dh->ourImages[0].bitmap->w, -40, 0);
|
||||
attackingHero->pos = genRect(attackingHero->dh->ourImages[0].bitmap->h, attackingHero->dh->ourImages[0].bitmap->w, -40 + pos.x, pos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -154,7 +155,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
if(hero2) // defending hero
|
||||
{
|
||||
defendingHero = new CBattleHero(graphics->battleHeroes[hero2->type->heroType], 0, 0, true, hero2->tempOwner, hero2->tempOwner == LOCPLINT->playerID ? hero2 : NULL, this);
|
||||
defendingHero->pos = genRect(defendingHero->dh->ourImages[0].bitmap->h, defendingHero->dh->ourImages[0].bitmap->w, 690, 0);
|
||||
defendingHero->pos = genRect(defendingHero->dh->ourImages[0].bitmap->h, defendingHero->dh->ourImages[0].bitmap->w, 690 + pos.x, pos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -172,7 +173,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
|
||||
|
||||
int x = 14 + ((h/BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(h%BFIELD_WIDTH);
|
||||
int y = 86 + 42 * (h/BFIELD_WIDTH);
|
||||
bfield[h].pos = genRect(cellShade->h, cellShade->w, x, y);
|
||||
bfield[h].pos = genRect(cellShade->h, cellShade->w, x + pos.x, y + pos.y);
|
||||
bfield[h].accesible = true;
|
||||
bfield[h].myInterface = this;
|
||||
}
|
||||
@ -346,15 +347,15 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
//printing background and hexes
|
||||
if(activeStack != -1 && creAnims[activeStack]->getType() != 0) //show everything with range
|
||||
{
|
||||
blitAt(backgroundWithHexes, 0, 0, to);
|
||||
blitAt(backgroundWithHexes, pos.x, pos.y, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
//showing background
|
||||
blitAt(background, 0, 0, to);
|
||||
blitAt(background, pos.x, pos.y, to);
|
||||
if(printCellBorders)
|
||||
{
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, NULL, to, NULL);
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, NULL, to, &pos);
|
||||
}
|
||||
}
|
||||
//printing hovered cell
|
||||
@ -372,8 +373,8 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
currentlyHoveredHex = b;
|
||||
}
|
||||
//print shade
|
||||
int x = 14 + ((b/BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(b%BFIELD_WIDTH);
|
||||
int y = 86 + 42 * (b/BFIELD_WIDTH);
|
||||
int x = 14 + ((b/BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(b%BFIELD_WIDTH) + pos.x;
|
||||
int y = 86 + 42 * (b/BFIELD_WIDTH) + pos.y;
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, to, &genRect(cellShade->h, cellShade->w, x, y));
|
||||
}
|
||||
}
|
||||
@ -381,7 +382,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
|
||||
|
||||
//showing menu background and console
|
||||
blitAt(menu, 0, 556, to);
|
||||
blitAt(menu, pos.x, 556 + pos.y, to);
|
||||
console->show(to);
|
||||
|
||||
//showing buttons
|
||||
@ -422,7 +423,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
{
|
||||
for(size_t v=0; v<stackDeadByHex[b].size(); ++v)
|
||||
{
|
||||
creAnims[stackDeadByHex[b][v]]->nextFrame(to, creAnims[stackDeadByHex[b][v]]->pos.x, creAnims[stackDeadByHex[b][v]]->pos.y, creDir[stackDeadByHex[b][v]], false, stackDeadByHex[b][v]==activeStack); //increment always when moving, never if stack died
|
||||
creAnims[stackDeadByHex[b][v]]->nextFrame(to, creAnims[stackDeadByHex[b][v]]->pos.x + pos.x, creAnims[stackDeadByHex[b][v]]->pos.y + pos.y, creDir[stackDeadByHex[b][v]], false, stackDeadByHex[b][v]==activeStack); //increment always when moving, never if stack died
|
||||
}
|
||||
}
|
||||
for(int b=0; b<BFIELD_SIZE; ++b) //showing alive stacks
|
||||
@ -431,7 +432,7 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
{
|
||||
int animType = creAnims[stackAliveByHex[b][v]]->getType();
|
||||
bool incrementFrame = (animCount%(4/animSpeed)==0) && animType!=0 && animType!=5 && animType!=20 && animType!=21 && animType!=3;
|
||||
creAnims[stackAliveByHex[b][v]]->nextFrame(to, creAnims[stackAliveByHex[b][v]]->pos.x, creAnims[stackAliveByHex[b][v]]->pos.y, creDir[stackAliveByHex[b][v]], incrementFrame, stackAliveByHex[b][v]==activeStack); //increment always when moving, never if stack died
|
||||
creAnims[stackAliveByHex[b][v]]->nextFrame(to, creAnims[stackAliveByHex[b][v]]->pos.x + pos.x, creAnims[stackAliveByHex[b][v]]->pos.y + pos.y, creDir[stackAliveByHex[b][v]], incrementFrame, stackAliveByHex[b][v]==activeStack); //increment always when moving, never if stack died
|
||||
//printing amount
|
||||
if(stacks[stackAliveByHex[b][v]].amount > 0) //don't print if stack is not alive
|
||||
{
|
||||
@ -463,18 +464,18 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
amountBG = amountEffNeutral;
|
||||
}
|
||||
}
|
||||
SDL_BlitSurface(amountBG, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackAliveByHex[b][v]]->pos.x + xAdd, creAnims[stackAliveByHex[b][v]]->pos.y + 260));
|
||||
SDL_BlitSurface(amountBG, NULL, to, &genRect(amountNormal->h, amountNormal->w, creAnims[stackAliveByHex[b][v]]->pos.x + xAdd + pos.x, creAnims[stackAliveByHex[b][v]]->pos.y + 260 + pos.y));
|
||||
//blitting amount
|
||||
std::stringstream ss;
|
||||
ss<<stacks[stackAliveByHex[b][v]].amount;
|
||||
CSDL_Ext::printAtMiddleWB(
|
||||
ss.str(),
|
||||
creAnims[stackAliveByHex[b][v]]->pos.x + xAdd + 14,
|
||||
creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4,
|
||||
GEOR13,
|
||||
20,
|
||||
zwykly,
|
||||
to
|
||||
ss.str(),
|
||||
creAnims[stackAliveByHex[b][v]]->pos.x + xAdd + 14 + pos.x,
|
||||
creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4 + pos.y,
|
||||
GEOR13,
|
||||
20,
|
||||
zwykly,
|
||||
to
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -488,12 +489,13 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
std::vector< std::list<SBattleEffect>::iterator > toErase;
|
||||
for(std::list<SBattleEffect>::iterator it = battleEffects.begin(); it!=battleEffects.end(); ++it)
|
||||
{
|
||||
blitAt(it->anim->ourImages[(it->frame)%it->anim->ourImages.size()].bitmap, it->x, it->y, to);
|
||||
blitAt(it->anim->ourImages[(it->frame)%it->anim->ourImages.size()].bitmap, it->x + pos.x, it->y + pos.y, to);
|
||||
++(it->frame);
|
||||
|
||||
if(it->frame == it->maxFrame) {
|
||||
if(it->frame == it->maxFrame)
|
||||
{
|
||||
toErase.push_back(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(size_t b=0; b<toErase.size(); ++b)
|
||||
{
|
||||
@ -560,9 +562,10 @@ void CBattleInterface::show(SDL_Surface * to)
|
||||
}
|
||||
void CBattleInterface::keyPressed(const SDL_KeyboardEvent & key)
|
||||
{
|
||||
if(key.keysym.sym == SDLK_q) {
|
||||
if(key.keysym.sym == SDLK_q)
|
||||
{
|
||||
showStackQueue = key.state==SDL_PRESSED;
|
||||
}
|
||||
}
|
||||
}
|
||||
void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
|
||||
{
|
||||
@ -945,12 +948,14 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
|
||||
bool break_loop = true;
|
||||
for(size_t g=0; g<attackedInfos.size(); ++g)
|
||||
{
|
||||
if(creAnims[attackedInfos[g].ID]->getType() != 2) {
|
||||
if(creAnims[attackedInfos[g].ID]->getType() != 2)
|
||||
{
|
||||
break_loop = false;
|
||||
}
|
||||
if(attackingInfo && attackingInfo->IDby == attackedInfos[g].IDby) {
|
||||
}
|
||||
if(attackingInfo && attackingInfo->IDby == attackedInfos[g].IDby)
|
||||
{
|
||||
break_loop = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(break_loop) break;
|
||||
}
|
||||
@ -1926,30 +1931,30 @@ void CBattleHero::show(SDL_Surface *to)
|
||||
if(flip)
|
||||
{
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
752,
|
||||
39
|
||||
)
|
||||
);
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
62 + pos.x,
|
||||
39 + pos.y
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
CSDL_Ext::blit8bppAlphaTo24bpp(
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
31,
|
||||
39
|
||||
)
|
||||
);
|
||||
flag->ourImages[flagAnim].bitmap,
|
||||
NULL,
|
||||
screen,
|
||||
&genRect(
|
||||
flag->ourImages[flagAnim].bitmap->h,
|
||||
flag->ourImages[flagAnim].bitmap->w,
|
||||
71 + pos.x,
|
||||
39 + pos.y
|
||||
)
|
||||
);
|
||||
}
|
||||
++flagAnimCount;
|
||||
if(flagAnimCount%4==0)
|
||||
@ -2164,11 +2169,12 @@ void CBattleHex::clickRight(boost::logic::tribool down)
|
||||
pom->defenseBonus = h->getPrimSkillLevel(1);
|
||||
pom->luck = h->getCurrentLuck();
|
||||
pom->morale = h->getCurrentMorale();
|
||||
pom->shotsLeft = myst.shots;
|
||||
for(int vb=0; vb<myst.effects.size(); ++vb)
|
||||
{
|
||||
pom->effects.insert(myst.effects[vb].id);
|
||||
}
|
||||
}
|
||||
|
||||
pom->shotsLeft = myst.shots;
|
||||
for(int vb=0; vb<myst.effects.size(); ++vb)
|
||||
{
|
||||
pom->effects.insert(myst.effects[vb].id);
|
||||
}
|
||||
pom->currentHealth = myst.firstHPleft;
|
||||
(new CCreInfoWindow(myst.creature->idNumber,0,myst.amount,pom,boost::function<void()>(),boost::function<void()>(),NULL))
|
||||
|
@ -187,7 +187,7 @@ private:
|
||||
};
|
||||
std::list<SBattleEffect> battleEffects; //different animations to display on the screen like spell effects
|
||||
public:
|
||||
CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2); //c-tor
|
||||
CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2, const SDL_Rect & myRect); //c-tor
|
||||
~CBattleInterface(); //d-tor
|
||||
|
||||
//std::vector<TimeInterested*> timeinterested; //animation handling
|
||||
|
@ -197,19 +197,24 @@ const CGHeroInstance * CCallback::getHeroInfo(int val, int mode) const //mode =
|
||||
//if (gs->currentPlayer!=player) //TODO: checking if we are allowed to give that info
|
||||
// return NULL;
|
||||
if (!mode) //esrial id
|
||||
if(val<gs->players[player].heroes.size()) {
|
||||
{
|
||||
if(val<gs->players[player].heroes.size())
|
||||
{
|
||||
return gs->players[player].heroes[val];
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if(mode==1) //it's hero type id
|
||||
{
|
||||
for (size_t i=0; i < gs->players[player].heroes.size(); ++i)
|
||||
{
|
||||
if (gs->players[player].heroes[i]->type->ID==val) {
|
||||
if (gs->players[player].heroes[i]->type->ID==val)
|
||||
{
|
||||
return gs->players[player].heroes[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else //object id
|
||||
|
@ -27,7 +27,7 @@ using namespace CSDL_Ext;
|
||||
|
||||
extern TTF_Font * GEOR16;
|
||||
CBuildingRect::CBuildingRect(Structure *Str)
|
||||
:moi(false), offset(0), str(Str)
|
||||
:moi(false), offset(0), str(Str)
|
||||
{
|
||||
def = CDefHandler::giveDef(Str->defName);
|
||||
max = def->ourImages.size();
|
||||
@ -49,18 +49,22 @@ CBuildingRect::CBuildingRect(Structure *Str)
|
||||
area = border = NULL;
|
||||
return;
|
||||
}
|
||||
if (border = BitmapHandler::loadBitmap(str->borderName)) {//FIXME hmmm if '=' use () else '==' fatal mistake
|
||||
if (border = BitmapHandler::loadBitmap(str->borderName)) //FIXME hmmm if '=' use () else '==' fatal mistake
|
||||
{
|
||||
SDL_SetColorKey(border,SDL_SRCCOLORKEY,SDL_MapRGB(border->format,0,255,255));
|
||||
}
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
tlog2 << "Warning: no border for "<<Str->ID<<std::endl;
|
||||
}
|
||||
if (area = BitmapHandler::loadBitmap(str->areaName)) { //FIXME look up
|
||||
}
|
||||
if (area = BitmapHandler::loadBitmap(str->areaName))//FIXME look up
|
||||
{
|
||||
;//SDL_SetColorKey(area,SDL_SRCCOLORKEY,SDL_MapRGB(area->format,0,255,255));
|
||||
}
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
tlog2 << "Warning: no area for "<<Str->ID<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CBuildingRect::~CBuildingRect()
|
||||
@ -711,9 +715,10 @@ void CCastleInterface::activate()
|
||||
LOCPLINT->statusbar = statusbar;
|
||||
exit->activate();
|
||||
split->activate();
|
||||
for(size_t i=0;i<buildings.size();i++) { //XXX pls use iterators or at() but not []
|
||||
for(size_t i=0;i<buildings.size();i++) //XXX pls use iterators or at() but not []
|
||||
{
|
||||
buildings[i]->activate();
|
||||
}
|
||||
}
|
||||
hslotdown.activate();
|
||||
hslotup.activate();
|
||||
showAll(0,true);
|
||||
@ -730,9 +735,10 @@ void CCastleInterface::deactivate()
|
||||
garr->deactivate();
|
||||
exit->deactivate();
|
||||
split->deactivate();
|
||||
for(size_t i=0;i<buildings.size();i++) { //XXX iterators
|
||||
for(size_t i=0;i<buildings.size();i++) //XXX iterators
|
||||
{
|
||||
buildings[i]->deactivate();
|
||||
}
|
||||
}
|
||||
hslotdown.deactivate();
|
||||
hslotup.deactivate();
|
||||
}
|
||||
@ -1097,9 +1103,12 @@ void CHallInterface::show(SDL_Surface * to) //TODO use me
|
||||
void CHallInterface::activate()
|
||||
{
|
||||
for(int i=0;i<5;i++)
|
||||
for(size_t j=0; j < boxes[i].size(); ++j) {
|
||||
{
|
||||
for(size_t j=0; j < boxes[i].size(); ++j)
|
||||
{
|
||||
boxes[i][j]->activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
exit->activate();
|
||||
}
|
||||
void CHallInterface::deactivate()
|
||||
@ -1245,13 +1254,15 @@ CHallInterface::CBuildWindow::CBuildWindow(int Tid, int Bid, int State, bool Mod
|
||||
CSDL_Ext::printAtMiddleWB(CGI->buildh->buildings[tid][bid]->Description(),197,168,GEOR16,40,zwykly,bitmap);
|
||||
CSDL_Ext::printAtMiddleWB(getTextForState(state),197,248,GEOR13,50,zwykly,bitmap);
|
||||
CSDL_Ext::printAtMiddle(CSDL_Ext::processStr(CGI->generaltexth->hcommands[7],pom),197,30,GEOR16,tytulowy,bitmap);
|
||||
int resamount=0;
|
||||
|
||||
for(int i=0;i<7;i++) {
|
||||
if(CGI->buildh->buildings[tid][bid]->resources[i]) {
|
||||
resamount++;
|
||||
}
|
||||
}
|
||||
int resamount=0;
|
||||
for(int i=0;i<7;i++)
|
||||
{
|
||||
if(CGI->buildh->buildings[tid][bid]->resources[i])
|
||||
{
|
||||
resamount++;
|
||||
}
|
||||
}
|
||||
int ah = (resamount>4) ? 304 : 341;
|
||||
int cn=-1, it=0;
|
||||
int row1w = std::min(resamount,4) * 32 + (std::min(resamount,4)-1) * 45,
|
||||
@ -1531,17 +1542,19 @@ void CMageGuildScreen::activate()
|
||||
LOCPLINT->objsToBlit += this;
|
||||
LOCPLINT->castleInt->subInt = this;
|
||||
exit->activate();
|
||||
for(size_t i=0;i<spells.size();i++) {
|
||||
for(size_t i=0;i<spells.size();i++)
|
||||
{
|
||||
spells[i].activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
void CMageGuildScreen::deactivate()
|
||||
{
|
||||
LOCPLINT->objsToBlit -= this;
|
||||
exit->deactivate();
|
||||
for(size_t i=0;i<spells.size();i++) {
|
||||
for(size_t i=0;i<spells.size();i++)
|
||||
{
|
||||
spells[i].deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
void CMageGuildScreen::Scroll::clickLeft (tribool down)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ void CCursorHandler::draw2()
|
||||
{
|
||||
if(!Show) return;
|
||||
int x = xpos, y = ypos;
|
||||
if(mode==1)
|
||||
if((mode==1 && number!=6) || mode == 3)
|
||||
{
|
||||
x-=16;
|
||||
y-=16;
|
||||
|
@ -131,13 +131,15 @@ CHeroWindow::~CHeroWindow()
|
||||
delete leftArtRoll;
|
||||
delete rightArtRoll;
|
||||
|
||||
for(size_t g=0; g<heroListMi.size(); ++g) {
|
||||
for(size_t g=0; g<heroListMi.size(); ++g)
|
||||
{
|
||||
delete heroListMi[g];
|
||||
}
|
||||
}
|
||||
|
||||
if(curBack) {
|
||||
if(curBack)
|
||||
{
|
||||
SDL_FreeSurface(curBack);
|
||||
}
|
||||
}
|
||||
|
||||
delete flags;
|
||||
|
||||
@ -306,12 +308,14 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
|
||||
add->pos.x = pos.x + 403 + 46*s;
|
||||
add->pos.y = pos.y + 365;
|
||||
add->pos.h = add->pos.w = 44;
|
||||
if(s<hero->artifacts.size() && hero->artifacts[s]) {
|
||||
if(s<hero->artifacts.size() && hero->artifacts[s])
|
||||
{
|
||||
add->text = hero->getArt(19+s)->Description();
|
||||
}
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
add->text = std::string();
|
||||
}
|
||||
}
|
||||
add->ourWindow = this;
|
||||
add->slotID = 19+s;
|
||||
backpack.push_back(add);
|
||||
|
30
CMessage.cpp
30
CMessage.cpp
@ -89,9 +89,10 @@ SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor) //draws box for
|
||||
SDL_Surface * ret = SDL_CreateRGBSurface(screen->flags, w, h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
|
||||
for (int i=0; i<h; i+=background->h)//background
|
||||
{
|
||||
for (int j=0; j<w; j+=background->w-1) {
|
||||
for (int j=0; j<w; j+=background->w-1)
|
||||
{
|
||||
SDL_BlitSurface(background,&genRect(background->h,background->w-1,1,0),ret,&genRect(h,w,j,i)); //FIXME taking address of temporary
|
||||
}
|
||||
}
|
||||
}
|
||||
drawBorder(playerColor, ret, w, h);
|
||||
return ret;
|
||||
@ -224,12 +225,14 @@ SDL_Surface * CMessage::blitTextOnSur(std::vector<std::vector<SDL_Surface*> > *
|
||||
SDL_Surface * CMessage::blitCompsOnSur(std::vector<SComponent*> & comps, int maxw, int inter, int & curh, SDL_Surface * ret)
|
||||
{
|
||||
std::vector<std::string> * brdtext;
|
||||
if (comps.size()) {
|
||||
if (comps.size())
|
||||
{
|
||||
brdtext = breakText(comps[0]->subtitle,12,true,true);
|
||||
}
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
brdtext = NULL;
|
||||
}
|
||||
}
|
||||
comps[0]->pos.x = (ret->w/2) - ((comps[0]->getImg()->w)/2);
|
||||
comps[0]->pos.y = curh;
|
||||
blitAt(comps[0]->getImg(),comps[0]->pos.x,comps[0]->pos.y,ret);
|
||||
@ -251,16 +254,19 @@ SDL_Surface* CMessage::blitCompsOnSur(SDL_Surface * _or, std::vector< std::vecto
|
||||
for(size_t j=0;j<(*komp)[i].size();j++)
|
||||
{
|
||||
totalw+=(*komp)[i][j]->getImg()->w;
|
||||
if(maxh<(*komp)[i][j]->getImg()->h) {
|
||||
if(maxh<(*komp)[i][j]->getImg()->h)
|
||||
{
|
||||
maxh=(*komp)[i][j]->getImg()->h;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_or) {
|
||||
if(_or)
|
||||
{
|
||||
totalw += (inter*2+_or->w) * ((*komp)[i].size() - 1);
|
||||
}
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
totalw += (inter) * ((*komp)[i].size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
curh+=maxh/2;
|
||||
int curw = (ret->w/2)-(totalw/2);
|
||||
|
@ -55,27 +55,32 @@ CPath * CPathfinder::getPath(int3 src, int3 dest, const CGHeroInstance * hero, u
|
||||
for(size_t j=0; j<graph[i].size(); ++j)
|
||||
{
|
||||
graph[i][j].accesible = !CGI->mh->ttiles[i][j][src.z].tileInfo->blocked;
|
||||
if(i==dest.x && j==dest.y && CGI->mh->ttiles[i][j][src.z].tileInfo->visitable) {
|
||||
if(i==dest.x && j==dest.y && CGI->mh->ttiles[i][j][src.z].tileInfo->visitable)
|
||||
{
|
||||
graph[i][j].accesible = true; //for allowing visiting objects
|
||||
}
|
||||
}
|
||||
graph[i][j].dist = -1;
|
||||
graph[i][j].theNodeBefore = NULL;
|
||||
graph[i][j].visited = false;
|
||||
graph[i][j].coord.x = i;
|
||||
graph[i][j].coord.y = j;
|
||||
graph[i][j].coord.z = dest.z;
|
||||
if (CGI->mh->ttiles[i][j][src.z].tileInfo->tertype==rock) {
|
||||
if (CGI->mh->ttiles[i][j][src.z].tileInfo->tertype==rock)
|
||||
{
|
||||
graph[i][j].accesible = false;
|
||||
}
|
||||
if ((blockLandSea) && (CGI->mh->ttiles[i][j][src.z].tileInfo->tertype==water)) {
|
||||
}
|
||||
if ((blockLandSea) && (CGI->mh->ttiles[i][j][src.z].tileInfo->tertype==water))
|
||||
{
|
||||
graph[i][j].accesible = false;
|
||||
}
|
||||
else if ((!blockLandSea) && (CGI->mh->ttiles[i][j][src.z].tileInfo->tertype!=water)) {
|
||||
}
|
||||
else if ((!blockLandSea) && (CGI->mh->ttiles[i][j][src.z].tileInfo->tertype!=water))
|
||||
{
|
||||
graph[i][j].accesible = false;
|
||||
}
|
||||
if(graph[i][j].accesible) {
|
||||
}
|
||||
if(graph[i][j].accesible)
|
||||
{
|
||||
graph[i][j].accesible = CGI->state->players[hero->tempOwner].fogOfWarMap[i][j][src.z];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,16 +311,18 @@ CGarrisonInt::~CGarrisonInt()
|
||||
{
|
||||
if(sup)
|
||||
{
|
||||
for(size_t i=0;i<sup->size();i++) {
|
||||
for(size_t i=0;i<sup->size();i++)
|
||||
{
|
||||
delete (*sup)[i];
|
||||
}
|
||||
}
|
||||
delete sup;
|
||||
}
|
||||
if(sdown)
|
||||
{
|
||||
for(size_t i=0;i<sdown->size();i++) {
|
||||
for(size_t i=0;i<sdown->size();i++)
|
||||
{
|
||||
delete (*sdown)[i]; //XXX what about smartpointers? boost or auto_ptr from std
|
||||
}
|
||||
}
|
||||
delete sdown;
|
||||
}
|
||||
}
|
||||
@ -330,17 +332,22 @@ void CGarrisonInt::show()
|
||||
if(sup)
|
||||
{
|
||||
for(size_t i = 0; i<sup->size(); i++)
|
||||
if((*sup)[i]) {
|
||||
{
|
||||
if((*sup)[i])
|
||||
{
|
||||
(*sup)[i]->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(sdown)
|
||||
{
|
||||
for(size_t i = 0; i<sdown->size(); i++) {
|
||||
if((*sdown)[i]){
|
||||
for(size_t i = 0; i<sdown->size(); i++)
|
||||
{
|
||||
if((*sdown)[i])
|
||||
{
|
||||
(*sdown)[i]->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void CGarrisonInt::deactiveteSlots()
|
||||
@ -924,9 +931,8 @@ ClickableL::ClickableL()
|
||||
pressedL=false;
|
||||
}
|
||||
|
||||
ClickableL::~ClickableL() {
|
||||
|
||||
}
|
||||
ClickableL::~ClickableL()
|
||||
{}
|
||||
|
||||
void ClickableL::clickLeft(tribool down)
|
||||
{
|
||||
@ -950,9 +956,8 @@ ClickableR::ClickableR()
|
||||
pressedR=false;
|
||||
}
|
||||
|
||||
ClickableR::~ClickableR() {
|
||||
|
||||
}
|
||||
ClickableR::~ClickableR()
|
||||
{}
|
||||
|
||||
void ClickableR::clickRight(tribool down)
|
||||
{
|
||||
@ -971,9 +976,8 @@ void ClickableR::deactivate()
|
||||
}
|
||||
//ClickableR
|
||||
|
||||
Hoverable::~Hoverable() {
|
||||
|
||||
}
|
||||
Hoverable::~Hoverable()
|
||||
{}
|
||||
|
||||
void Hoverable::activate()
|
||||
{
|
||||
@ -990,9 +994,8 @@ void Hoverable::hover(bool on)
|
||||
}
|
||||
//Hoverable
|
||||
|
||||
KeyInterested::~KeyInterested() {
|
||||
|
||||
}
|
||||
KeyInterested::~KeyInterested()
|
||||
{}
|
||||
|
||||
void KeyInterested::activate()
|
||||
{
|
||||
@ -2027,7 +2030,7 @@ void CPlayerInterface::battleStart(CCreatureSet *army1, CCreatureSet *army2, int
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
curint->deactivate();
|
||||
curint = battleInt = new CBattleInterface(army1,army2,hero1,hero2);
|
||||
curint = battleInt = new CBattleInterface(army1, army2, hero1, hero2, genRect(600, 800, (conf.cc.resx - 800)/2, (conf.cc.resy - 600)/2));
|
||||
curint->activate();
|
||||
LOCPLINT->objsToBlit.push_back(dynamic_cast<IShowable*>(curint));
|
||||
}
|
||||
|
@ -74,9 +74,10 @@ void CSDL_Ext::printAtMiddleWB(const std::string & text, int x, int y, TTF_Font
|
||||
std::vector<std::string> * ws = CMessage::breakText(text,charpr);
|
||||
std::vector<SDL_Surface*> wesu;
|
||||
wesu.resize(ws->size());
|
||||
for (size_t i=0; i < wesu.size(); ++i) {
|
||||
for (size_t i=0; i < wesu.size(); ++i)
|
||||
{
|
||||
wesu[i]=TTF_RenderText_Blended(font,(*ws)[i].c_str(),kolor);
|
||||
}
|
||||
}
|
||||
|
||||
int tox=0, toy=0;
|
||||
for (size_t i=0; i < wesu.size(); ++i)
|
||||
@ -404,7 +405,8 @@ Uint32 CSDL_Ext::SDL_GetPixel(SDL_Surface *surface, const int & x, const int & y
|
||||
/* Here p is the address to the pixel we want to retrieve */
|
||||
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||
|
||||
switch(bpp) {
|
||||
switch(bpp)
|
||||
{
|
||||
case 1:
|
||||
if(colorByte)
|
||||
{
|
||||
@ -544,18 +546,21 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
int srcx, srcy, w, h;
|
||||
|
||||
/* Make sure the surfaces aren't locked */
|
||||
if ( ! src || ! dst ) {
|
||||
if ( ! src || ! dst )
|
||||
{
|
||||
SDL_SetError("SDL_UpperBlit: passed a NULL surface");
|
||||
return(-1);
|
||||
}
|
||||
if ( src->locked || dst->locked ) {
|
||||
if ( src->locked || dst->locked )
|
||||
{
|
||||
SDL_SetError("Surfaces must not be locked during blit");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* If the destination rectangle is NULL, use the entire dest surface */
|
||||
if ( dstRect == NULL ) {
|
||||
fulldst.x = fulldst.y = 0;
|
||||
if ( dstRect == NULL )
|
||||
{
|
||||
fulldst.x = fulldst.y = 0;
|
||||
dstRect = &fulldst;
|
||||
}
|
||||
|
||||
@ -566,7 +571,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
|
||||
srcx = srcRect->x;
|
||||
w = srcRect->w;
|
||||
if(srcx < 0) {
|
||||
if(srcx < 0)
|
||||
{
|
||||
w += srcx;
|
||||
dstRect->x -= srcx;
|
||||
srcx = 0;
|
||||
@ -577,7 +583,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
|
||||
srcy = srcRect->y;
|
||||
h = srcRect->h;
|
||||
if(srcy < 0) {
|
||||
if(srcy < 0)
|
||||
{
|
||||
h += srcy;
|
||||
dstRect->y -= srcy;
|
||||
srcy = 0;
|
||||
@ -600,7 +607,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
int dx, dy;
|
||||
|
||||
dx = clip->x - dstRect->x;
|
||||
if(dx > 0) {
|
||||
if(dx > 0)
|
||||
{
|
||||
w -= dx;
|
||||
dstRect->x += dx;
|
||||
srcx += dx;
|
||||
@ -610,7 +618,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
|
||||
w -= dx;
|
||||
|
||||
dy = clip->y - dstRect->y;
|
||||
if(dy > 0) {
|
||||
if(dy > 0)
|
||||
{
|
||||
h -= dy;
|
||||
dstRect->y += dy;
|
||||
srcy += dy;
|
||||
|
@ -22,16 +22,18 @@ void CCreatureAnimation::setType(int type)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(curFrame != -1) {
|
||||
if(curFrame != -1)
|
||||
{
|
||||
curFrame = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(curFrame>=frames) {
|
||||
if(curFrame>=frames)
|
||||
{
|
||||
curFrame = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,7 +288,8 @@ inline void CCreatureAnimation::putPixel(
|
||||
const bool & yellowBorder
|
||||
) const {
|
||||
|
||||
if(palc!=0) {
|
||||
if(palc!=0)
|
||||
{
|
||||
Uint8 * p = (Uint8*)dest->pixels + ftcp*3;
|
||||
if(palc > 7) //normal color
|
||||
{
|
||||
|
@ -65,12 +65,10 @@ void SpellbookInteractiveArea::deactivate()
|
||||
Hoverable::deactivate();
|
||||
}
|
||||
|
||||
CSpellWindow::CSpellWindow(
|
||||
const SDL_Rect & myRect,
|
||||
const CGHeroInstance * myHero):
|
||||
battleSpellsOnly(true),
|
||||
selectedTab(4),
|
||||
spellSite(0)
|
||||
CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero):
|
||||
battleSpellsOnly(true),
|
||||
selectedTab(4),
|
||||
spellSite(0)
|
||||
{
|
||||
//XXX for testing only
|
||||
//mySpells = myHero->spells;
|
||||
@ -547,12 +545,14 @@ void CSpellWindow::computeSpellsPerArea()
|
||||
{
|
||||
for(size_t c=0; c<12; ++c)
|
||||
{
|
||||
if(c<spellsCurSite.size()) {
|
||||
if(c<spellsCurSite.size())
|
||||
{
|
||||
spellAreas[c]->mySpell = spellsCurSite[c];
|
||||
}
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
spellAreas[c]->mySpell = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -124,6 +124,7 @@ void Graphics::loadPaletteAndColors()
|
||||
}
|
||||
bback.close();
|
||||
}
|
||||
|
||||
void Graphics::initializeBattleGraphics()
|
||||
{
|
||||
std::ifstream bback("config/battleBack.txt");
|
||||
|
@ -83,16 +83,16 @@ GUISettings
|
||||
HeroList: size=10 x=832 y=201 movePoints=IMOBIL.DEF manaPoints=IMANA.DEF arrowUp=IAM012.DEF arrowDown=IAM013.DEF;
|
||||
TownList: size=10 x=970 y=201 arrowUp=IAM014.DEF arrowDown=IAM015.DEF;
|
||||
Minimap: width=144 height=144 x=854 y=26;
|
||||
Statusbar: x=8 y=856 graphic=ADROLLVR2.pcx;
|
||||
Statusbar: x=8 y=723 graphic=ADROLLVR2.pcx;
|
||||
ResDataBar: x=0 y=743 graphic=ZRESBAR2.pcx offsetX=65 offsetY=2 resSpace=109 resDateSpace=135;
|
||||
ButtonKingdomOv: x=903 y=197 graphic=IAM002.DEF playerColoured=1;
|
||||
ButtonUnderground: x=903 y=230 graphic=IAM010.DEF playerColoured=1 additionalDefs=(IAM003.DEF);
|
||||
ButtonQuestLog: x=903 y=261 graphic=IAM004.DEF playerColoured=1;
|
||||
ButtonSleepWake: x=903 y=294 graphic=IAM005.DEF playerColoured=1;
|
||||
ButtonMoveHero: x=903 y=327 graphic=IAM006.DEF playerColoured=1;
|
||||
ButtonSpellbook: x=903 y=359 graphic=IAM007.DEF playerColoured=1;
|
||||
ButtonAdvOptions: x=903 y=393 graphic=IAM008.DEF playerColoured=1;
|
||||
ButtonSysOptions: x=903 y=426 graphic=IAM009.DEF playerColoured=1;
|
||||
ButtonKingdomOv: x=903 y=197 graphic=IAM002L.DEF playerColoured=1;
|
||||
ButtonUnderground: x=903 y=230 graphic=IAM010L.DEF playerColoured=1 additionalDefs=(IAM003L.DEF);
|
||||
ButtonQuestLog: x=903 y=261 graphic=IAM004L.DEF playerColoured=1;
|
||||
ButtonSleepWake: x=903 y=294 graphic=IAM005L.DEF playerColoured=1;
|
||||
ButtonMoveHero: x=903 y=327 graphic=IAM006L.DEF playerColoured=1;
|
||||
ButtonSpellbook: x=903 y=359 graphic=IAM007L.DEF playerColoured=1;
|
||||
ButtonAdvOptions: x=903 y=393 graphic=IAM008L.DEF playerColoured=1;
|
||||
ButtonSysOptions: x=903 y=426 graphic=IAM009L.DEF playerColoured=1;
|
||||
ButtonNextHero: x=903 y=491 graphic=IAM000.DEF playerColoured=1;
|
||||
ButtonEndTurn: x=903 y=524 graphic=IAM001.DEF playerColoured=1;
|
||||
};
|
||||
|
20
global.h
20
global.h
@ -215,17 +215,21 @@ public:
|
||||
template<typename T>
|
||||
CLogger<lvl> & operator<<(const T & data)
|
||||
{
|
||||
if(lvl < CONSOLE_LOGGING_LEVEL) {
|
||||
if(console) {
|
||||
if(lvl < CONSOLE_LOGGING_LEVEL)
|
||||
{
|
||||
if(console)
|
||||
{
|
||||
console->print(data,lvl);
|
||||
}
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << data << std::flush;
|
||||
}
|
||||
}
|
||||
if((lvl < FILE_LOGGING_LEVEL) && logfile) {
|
||||
}
|
||||
}
|
||||
if((lvl < FILE_LOGGING_LEVEL) && logfile)
|
||||
{
|
||||
*logfile << data << std::flush;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
@ -52,9 +52,10 @@ void CObjectHandler::loadObjects()
|
||||
{
|
||||
std::string nobj;
|
||||
loadToIt(nobj, buf, it, 3);
|
||||
if(nobj.size() && (nobj[nobj.size()-1]==(char)10 || nobj[nobj.size()-1]==(char)13 || nobj[nobj.size()-1]==(char)9)) {
|
||||
if(nobj.size() && (nobj[nobj.size()-1]==(char)10 || nobj[nobj.size()-1]==(char)13 || nobj[nobj.size()-1]==(char)9))
|
||||
{
|
||||
nobj = nobj.substr(0, nobj.size()-1);
|
||||
}
|
||||
}
|
||||
names.push_back(nobj);
|
||||
}
|
||||
|
||||
@ -65,9 +66,10 @@ void CObjectHandler::loadObjects()
|
||||
while (it<buf.length()-1)
|
||||
{
|
||||
loadToIt(temp,buf,it,3);
|
||||
if (temp[0]=='\"') {
|
||||
if (temp[0]=='\"')
|
||||
{
|
||||
temp = temp.substr(1,temp.length()-2);
|
||||
}
|
||||
}
|
||||
boost::algorithm::replace_all(temp,"\"\"","\"");
|
||||
advobtxt.push_back(temp);
|
||||
}
|
||||
@ -112,9 +114,10 @@ void CObjectHandler::loadObjects()
|
||||
|
||||
tlog5 << "\t\tReading cregens \n";
|
||||
cregens.resize(110); //TODO: hardcoded value - change
|
||||
for(size_t i=0; i < cregens.size(); ++i) {
|
||||
for(size_t i=0; i < cregens.size(); ++i)
|
||||
{
|
||||
cregens[i]=-1;
|
||||
}
|
||||
}
|
||||
std::ifstream ifs("config/cregens.txt");
|
||||
while(!ifs.eof())
|
||||
{
|
||||
@ -362,12 +365,14 @@ int3 CGHeroInstance::convertPosition(int3 src, bool toh3m) //toh3m=true: manifes
|
||||
}
|
||||
int3 CGHeroInstance::getPosition(bool h3m) const //h3m=true - returns position of hero object; h3m=false - returns position of hero 'manifestation'
|
||||
{
|
||||
if (h3m) {
|
||||
if (h3m)
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
else {
|
||||
return convertPosition(pos,false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return convertPosition(pos,false);
|
||||
}
|
||||
}
|
||||
int CGHeroInstance::getSightDistance() const //returns sight distance of this hero
|
||||
{
|
||||
|
14
int3.h
14
int3.h
@ -14,13 +14,19 @@ public:
|
||||
si32 getSlotFor(ui32 creature, ui32 slotsAmount=7) //returns -1 if no slot available
|
||||
{
|
||||
for(std::map<si32,std::pair<ui32,si32> >::iterator i=slots.begin(); i!=slots.end(); ++i)
|
||||
if(i->second.first == creature) {
|
||||
{
|
||||
if(i->second.first == creature)
|
||||
{
|
||||
return i->first; //if there is already such creature we return its slot id
|
||||
}
|
||||
}
|
||||
}
|
||||
for(ui32 i=0; i<slotsAmount; i++)
|
||||
if(slots.find(i) == slots.end()) {
|
||||
{
|
||||
if(slots.find(i) == slots.end())
|
||||
{
|
||||
return i; //return first free slot
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1; //no slot available
|
||||
}
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
|
@ -170,7 +170,8 @@ public:
|
||||
}
|
||||
|
||||
template<class T>
|
||||
COSer & operator&(T & t){
|
||||
COSer & operator&(T & t)
|
||||
{
|
||||
return * this->This() << t;
|
||||
}
|
||||
|
||||
@ -272,7 +273,8 @@ public:
|
||||
}
|
||||
|
||||
template<class T>
|
||||
CISer & operator&(T & t){
|
||||
CISer & operator&(T & t)
|
||||
{
|
||||
return * this->This() >> t;
|
||||
}
|
||||
|
||||
|
@ -155,9 +155,10 @@ void CMapHandler::prepareFOWDefs()
|
||||
for (int j=0; j < CGI->mh->map->height; ++j)
|
||||
{
|
||||
hideBitmap[i][j].resize(CGI->mh->map->twoLevel+1);
|
||||
for(int k=0; k<CGI->mh->map->twoLevel+1; ++k) {
|
||||
for(int k=0; k<CGI->mh->map->twoLevel+1; ++k)
|
||||
{
|
||||
hideBitmap[i][j][k] = rand()%fullHide->ourImages.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user