1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +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:
mateuszb 2008-12-23 13:59:03 +00:00
parent ae48e73fe7
commit b114582857
19 changed files with 290 additions and 217 deletions

View File

@ -39,11 +39,12 @@ struct CMP_stack2
} }
} cmpst2 ; } 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), : printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL),
attackingInfo(NULL), myTurn(false), resWindow(NULL), showStackQueue(false), animSpeed(2), printStackRange(true), attackingInfo(NULL), myTurn(false), resWindow(NULL), showStackQueue(false), animSpeed(2), printStackRange(true),
printMouseShadow(true), spellDestSelectMode(false), spellToCast(NULL), previouslyHoveredHex(-1) printMouseShadow(true), spellDestSelectMode(false), spellToCast(NULL), previouslyHoveredHex(-1)
{ {
pos = myRect;
strongInterest = true; strongInterest = true;
givenCommand = new CondSh<BattleAction *>(NULL); givenCommand = new CondSh<BattleAction *>(NULL);
//initializing armies //initializing armies
@ -119,25 +120,25 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
} }
////blitting menu background and terrain ////blitting menu background and terrain
blitAt(background, 0, 0); blitAt(background, pos.x, pos.y);
blitAt(menu, 0, 556); blitAt(menu, pos.x, 556 + pos.y);
CSDL_Ext::update(); CSDL_Ext::update();
//preparing buttons and console //preparing buttons and console
bOptions = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bOptionsf,this), 3, 561, "icm003.def", SDLK_o); 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, 561, "icm001.def", SDLK_s); 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, 561, "icm002.def", SDLK_r); 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, 561, "icm004.def", SDLK_a); 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, 561, "icm005.def", SDLK_c); 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, 561, "icm006.def", SDLK_w); 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, 561, "icm007.def", SDLK_d); 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); bDefence->assignedKeys.insert(SDLK_SPACE);
bConsoleUp = new AdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleUpf,this), 624, 561, "ComSlide.def", SDLK_UP); 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, 580, "ComSlide.def", SDLK_DOWN); 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; bConsoleDown->bitmapOffset = 2;
console = new CBattleConsole(); console = new CBattleConsole();
console->pos.x = 211; console->pos.x = 211 + pos.x;
console->pos.y = 560; console->pos.y = 560 + pos.y;
console->pos.w = 406; console->pos.w = 406;
console->pos.h = 38; console->pos.h = 38;
@ -145,7 +146,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
if(hero1) // attacking hero 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 = 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 else
{ {
@ -154,7 +155,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C
if(hero2) // defending hero 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 = 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 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 x = 14 + ((h/BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(h%BFIELD_WIDTH);
int y = 86 + 42 * (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].accesible = true;
bfield[h].myInterface = this; bfield[h].myInterface = this;
} }
@ -346,15 +347,15 @@ void CBattleInterface::show(SDL_Surface * to)
//printing background and hexes //printing background and hexes
if(activeStack != -1 && creAnims[activeStack]->getType() != 0) //show everything with range if(activeStack != -1 && creAnims[activeStack]->getType() != 0) //show everything with range
{ {
blitAt(backgroundWithHexes, 0, 0, to); blitAt(backgroundWithHexes, pos.x, pos.y, to);
} }
else else
{ {
//showing background //showing background
blitAt(background, 0, 0, to); blitAt(background, pos.x, pos.y, to);
if(printCellBorders) if(printCellBorders)
{ {
CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, NULL, to, NULL); CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, NULL, to, &pos);
} }
} }
//printing hovered cell //printing hovered cell
@ -372,8 +373,8 @@ void CBattleInterface::show(SDL_Surface * to)
currentlyHoveredHex = b; currentlyHoveredHex = b;
} }
//print shade //print shade
int x = 14 + ((b/BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(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); int y = 86 + 42 * (b/BFIELD_WIDTH) + pos.y;
CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, to, &genRect(cellShade->h, cellShade->w, x, 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 //showing menu background and console
blitAt(menu, 0, 556, to); blitAt(menu, pos.x, 556 + pos.y, to);
console->show(to); console->show(to);
//showing buttons //showing buttons
@ -422,7 +423,7 @@ void CBattleInterface::show(SDL_Surface * to)
{ {
for(size_t v=0; v<stackDeadByHex[b].size(); ++v) 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 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(); int animType = creAnims[stackAliveByHex[b][v]]->getType();
bool incrementFrame = (animCount%(4/animSpeed)==0) && animType!=0 && animType!=5 && animType!=20 && animType!=21 && animType!=3; 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 //printing amount
if(stacks[stackAliveByHex[b][v]].amount > 0) //don't print if stack is not alive 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; 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 //blitting amount
std::stringstream ss; std::stringstream ss;
ss<<stacks[stackAliveByHex[b][v]].amount; ss<<stacks[stackAliveByHex[b][v]].amount;
CSDL_Ext::printAtMiddleWB( CSDL_Ext::printAtMiddleWB(
ss.str(), ss.str(),
creAnims[stackAliveByHex[b][v]]->pos.x + xAdd + 14, creAnims[stackAliveByHex[b][v]]->pos.x + xAdd + 14 + pos.x,
creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4, creAnims[stackAliveByHex[b][v]]->pos.y + 260 + 4 + pos.y,
GEOR13, GEOR13,
20, 20,
zwykly, zwykly,
to to
); );
} }
} }
@ -488,12 +489,13 @@ void CBattleInterface::show(SDL_Surface * to)
std::vector< std::list<SBattleEffect>::iterator > toErase; std::vector< std::list<SBattleEffect>::iterator > toErase;
for(std::list<SBattleEffect>::iterator it = battleEffects.begin(); it!=battleEffects.end(); ++it) 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); ++(it->frame);
if(it->frame == it->maxFrame) { if(it->frame == it->maxFrame)
{
toErase.push_back(it); toErase.push_back(it);
} }
} }
for(size_t b=0; b<toErase.size(); ++b) 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) void CBattleInterface::keyPressed(const SDL_KeyboardEvent & key)
{ {
if(key.keysym.sym == SDLK_q) { if(key.keysym.sym == SDLK_q)
{
showStackQueue = key.state==SDL_PRESSED; showStackQueue = key.state==SDL_PRESSED;
} }
} }
void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent) void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
{ {
@ -945,12 +948,14 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
bool break_loop = true; bool break_loop = true;
for(size_t g=0; g<attackedInfos.size(); ++g) 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; break_loop = false;
} }
if(attackingInfo && attackingInfo->IDby == attackedInfos[g].IDby) { if(attackingInfo && attackingInfo->IDby == attackedInfos[g].IDby)
{
break_loop = false; break_loop = false;
} }
} }
if(break_loop) break; if(break_loop) break;
} }
@ -1926,30 +1931,30 @@ void CBattleHero::show(SDL_Surface *to)
if(flip) if(flip)
{ {
CSDL_Ext::blit8bppAlphaTo24bpp( CSDL_Ext::blit8bppAlphaTo24bpp(
flag->ourImages[flagAnim].bitmap, flag->ourImages[flagAnim].bitmap,
NULL, NULL,
screen, screen,
&genRect( &genRect(
flag->ourImages[flagAnim].bitmap->h, flag->ourImages[flagAnim].bitmap->h,
flag->ourImages[flagAnim].bitmap->w, flag->ourImages[flagAnim].bitmap->w,
752, 62 + pos.x,
39 39 + pos.y
) )
); );
} }
else else
{ {
CSDL_Ext::blit8bppAlphaTo24bpp( CSDL_Ext::blit8bppAlphaTo24bpp(
flag->ourImages[flagAnim].bitmap, flag->ourImages[flagAnim].bitmap,
NULL, NULL,
screen, screen,
&genRect( &genRect(
flag->ourImages[flagAnim].bitmap->h, flag->ourImages[flagAnim].bitmap->h,
flag->ourImages[flagAnim].bitmap->w, flag->ourImages[flagAnim].bitmap->w,
31, 71 + pos.x,
39 39 + pos.y
) )
); );
} }
++flagAnimCount; ++flagAnimCount;
if(flagAnimCount%4==0) if(flagAnimCount%4==0)
@ -2164,11 +2169,12 @@ void CBattleHex::clickRight(boost::logic::tribool down)
pom->defenseBonus = h->getPrimSkillLevel(1); pom->defenseBonus = h->getPrimSkillLevel(1);
pom->luck = h->getCurrentLuck(); pom->luck = h->getCurrentLuck();
pom->morale = h->getCurrentMorale(); pom->morale = h->getCurrentMorale();
pom->shotsLeft = myst.shots; }
for(int vb=0; vb<myst.effects.size(); ++vb)
{ pom->shotsLeft = myst.shots;
pom->effects.insert(myst.effects[vb].id); for(int vb=0; vb<myst.effects.size(); ++vb)
} {
pom->effects.insert(myst.effects[vb].id);
} }
pom->currentHealth = myst.firstHPleft; pom->currentHealth = myst.firstHPleft;
(new CCreInfoWindow(myst.creature->idNumber,0,myst.amount,pom,boost::function<void()>(),boost::function<void()>(),NULL)) (new CCreInfoWindow(myst.creature->idNumber,0,myst.amount,pom,boost::function<void()>(),boost::function<void()>(),NULL))

View File

@ -187,7 +187,7 @@ private:
}; };
std::list<SBattleEffect> battleEffects; //different animations to display on the screen like spell effects std::list<SBattleEffect> battleEffects; //different animations to display on the screen like spell effects
public: 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 ~CBattleInterface(); //d-tor
//std::vector<TimeInterested*> timeinterested; //animation handling //std::vector<TimeInterested*> timeinterested; //animation handling

View File

@ -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 //if (gs->currentPlayer!=player) //TODO: checking if we are allowed to give that info
// return NULL; // return NULL;
if (!mode) //esrial id if (!mode) //esrial id
if(val<gs->players[player].heroes.size()) { {
if(val<gs->players[player].heroes.size())
{
return gs->players[player].heroes[val]; return gs->players[player].heroes[val];
} }
else { else
return NULL; {
} return NULL;
}
}
else if(mode==1) //it's hero type id else if(mode==1) //it's hero type id
{ {
for (size_t i=0; i < gs->players[player].heroes.size(); ++i) 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]; return gs->players[player].heroes[i];
} }
} }
} }
else //object id else //object id

View File

@ -27,7 +27,7 @@ using namespace CSDL_Ext;
extern TTF_Font * GEOR16; extern TTF_Font * GEOR16;
CBuildingRect::CBuildingRect(Structure *Str) CBuildingRect::CBuildingRect(Structure *Str)
:moi(false), offset(0), str(Str) :moi(false), offset(0), str(Str)
{ {
def = CDefHandler::giveDef(Str->defName); def = CDefHandler::giveDef(Str->defName);
max = def->ourImages.size(); max = def->ourImages.size();
@ -49,18 +49,22 @@ CBuildingRect::CBuildingRect(Structure *Str)
area = border = NULL; area = border = NULL;
return; 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)); SDL_SetColorKey(border,SDL_SRCCOLORKEY,SDL_MapRGB(border->format,0,255,255));
} }
else { else
{
tlog2 << "Warning: no border for "<<Str->ID<<std::endl; 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)); ;//SDL_SetColorKey(area,SDL_SRCCOLORKEY,SDL_MapRGB(area->format,0,255,255));
} }
else { else
{
tlog2 << "Warning: no area for "<<Str->ID<<std::endl; tlog2 << "Warning: no area for "<<Str->ID<<std::endl;
} }
} }
CBuildingRect::~CBuildingRect() CBuildingRect::~CBuildingRect()
@ -711,9 +715,10 @@ void CCastleInterface::activate()
LOCPLINT->statusbar = statusbar; LOCPLINT->statusbar = statusbar;
exit->activate(); exit->activate();
split->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(); buildings[i]->activate();
} }
hslotdown.activate(); hslotdown.activate();
hslotup.activate(); hslotup.activate();
showAll(0,true); showAll(0,true);
@ -730,9 +735,10 @@ void CCastleInterface::deactivate()
garr->deactivate(); garr->deactivate();
exit->deactivate(); exit->deactivate();
split->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(); buildings[i]->deactivate();
} }
hslotdown.deactivate(); hslotdown.deactivate();
hslotup.deactivate(); hslotup.deactivate();
} }
@ -1097,9 +1103,12 @@ void CHallInterface::show(SDL_Surface * to) //TODO use me
void CHallInterface::activate() void CHallInterface::activate()
{ {
for(int i=0;i<5;i++) 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(); boxes[i][j]->activate();
} }
}
exit->activate(); exit->activate();
} }
void CHallInterface::deactivate() 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(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::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); CSDL_Ext::printAtMiddle(CSDL_Ext::processStr(CGI->generaltexth->hcommands[7],pom),197,30,GEOR16,tytulowy,bitmap);
int resamount=0; int resamount=0;
for(int i=0;i<7;i++)
for(int i=0;i<7;i++) { {
if(CGI->buildh->buildings[tid][bid]->resources[i]) { if(CGI->buildh->buildings[tid][bid]->resources[i])
resamount++; {
} resamount++;
} }
}
int ah = (resamount>4) ? 304 : 341; int ah = (resamount>4) ? 304 : 341;
int cn=-1, it=0; int cn=-1, it=0;
int row1w = std::min(resamount,4) * 32 + (std::min(resamount,4)-1) * 45, int row1w = std::min(resamount,4) * 32 + (std::min(resamount,4)-1) * 45,
@ -1531,17 +1542,19 @@ void CMageGuildScreen::activate()
LOCPLINT->objsToBlit += this; LOCPLINT->objsToBlit += this;
LOCPLINT->castleInt->subInt = this; LOCPLINT->castleInt->subInt = this;
exit->activate(); exit->activate();
for(size_t i=0;i<spells.size();i++) { for(size_t i=0;i<spells.size();i++)
{
spells[i].activate(); spells[i].activate();
} }
} }
void CMageGuildScreen::deactivate() void CMageGuildScreen::deactivate()
{ {
LOCPLINT->objsToBlit -= this; LOCPLINT->objsToBlit -= this;
exit->deactivate(); exit->deactivate();
for(size_t i=0;i<spells.size();i++) { for(size_t i=0;i<spells.size();i++)
{
spells[i].deactivate(); spells[i].deactivate();
} }
} }
void CMageGuildScreen::Scroll::clickLeft (tribool down) void CMageGuildScreen::Scroll::clickLeft (tribool down)
{ {

View File

@ -50,7 +50,7 @@ void CCursorHandler::draw2()
{ {
if(!Show) return; if(!Show) return;
int x = xpos, y = ypos; int x = xpos, y = ypos;
if(mode==1) if((mode==1 && number!=6) || mode == 3)
{ {
x-=16; x-=16;
y-=16; y-=16;

View File

@ -131,13 +131,15 @@ CHeroWindow::~CHeroWindow()
delete leftArtRoll; delete leftArtRoll;
delete rightArtRoll; delete rightArtRoll;
for(size_t g=0; g<heroListMi.size(); ++g) { for(size_t g=0; g<heroListMi.size(); ++g)
{
delete heroListMi[g]; delete heroListMi[g];
} }
if(curBack) { if(curBack)
{
SDL_FreeSurface(curBack); SDL_FreeSurface(curBack);
} }
delete flags; delete flags;
@ -306,12 +308,14 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
add->pos.x = pos.x + 403 + 46*s; add->pos.x = pos.x + 403 + 46*s;
add->pos.y = pos.y + 365; add->pos.y = pos.y + 365;
add->pos.h = add->pos.w = 44; 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(); add->text = hero->getArt(19+s)->Description();
} }
else { else
{
add->text = std::string(); add->text = std::string();
} }
add->ourWindow = this; add->ourWindow = this;
add->slotID = 19+s; add->slotID = 19+s;
backpack.push_back(add); backpack.push_back(add);

View File

@ -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); 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 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 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); drawBorder(playerColor, ret, w, h);
return ret; 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) SDL_Surface * CMessage::blitCompsOnSur(std::vector<SComponent*> & comps, int maxw, int inter, int & curh, SDL_Surface * ret)
{ {
std::vector<std::string> * brdtext; std::vector<std::string> * brdtext;
if (comps.size()) { if (comps.size())
{
brdtext = breakText(comps[0]->subtitle,12,true,true); brdtext = breakText(comps[0]->subtitle,12,true,true);
} }
else { else
{
brdtext = NULL; brdtext = NULL;
} }
comps[0]->pos.x = (ret->w/2) - ((comps[0]->getImg()->w)/2); comps[0]->pos.x = (ret->w/2) - ((comps[0]->getImg()->w)/2);
comps[0]->pos.y = curh; comps[0]->pos.y = curh;
blitAt(comps[0]->getImg(),comps[0]->pos.x,comps[0]->pos.y,ret); 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++) for(size_t j=0;j<(*komp)[i].size();j++)
{ {
totalw+=(*komp)[i][j]->getImg()->w; 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; maxh=(*komp)[i][j]->getImg()->h;
} }
} }
if(_or) { if(_or)
{
totalw += (inter*2+_or->w) * ((*komp)[i].size() - 1); totalw += (inter*2+_or->w) * ((*komp)[i].size() - 1);
} }
else { else
{
totalw += (inter) * ((*komp)[i].size() - 1); totalw += (inter) * ((*komp)[i].size() - 1);
} }
curh+=maxh/2; curh+=maxh/2;
int curw = (ret->w/2)-(totalw/2); int curw = (ret->w/2)-(totalw/2);

View File

@ -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) for(size_t j=0; j<graph[i].size(); ++j)
{ {
graph[i][j].accesible = !CGI->mh->ttiles[i][j][src.z].tileInfo->blocked; 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].accesible = true; //for allowing visiting objects
} }
graph[i][j].dist = -1; graph[i][j].dist = -1;
graph[i][j].theNodeBefore = NULL; graph[i][j].theNodeBefore = NULL;
graph[i][j].visited = false; graph[i][j].visited = false;
graph[i][j].coord.x = i; graph[i][j].coord.x = i;
graph[i][j].coord.y = j; graph[i][j].coord.y = j;
graph[i][j].coord.z = dest.z; 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; 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; 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; 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]; graph[i][j].accesible = CGI->state->players[hero->tempOwner].fogOfWarMap[i][j][src.z];
} }
} }
} }

View File

@ -311,16 +311,18 @@ CGarrisonInt::~CGarrisonInt()
{ {
if(sup) 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)[i];
} }
delete sup; delete sup;
} }
if(sdown) 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)[i]; //XXX what about smartpointers? boost or auto_ptr from std
} }
delete sdown; delete sdown;
} }
} }
@ -330,17 +332,22 @@ void CGarrisonInt::show()
if(sup) if(sup)
{ {
for(size_t i = 0; i<sup->size(); i++) for(size_t i = 0; i<sup->size(); i++)
if((*sup)[i]) { {
if((*sup)[i])
{
(*sup)[i]->show(); (*sup)[i]->show();
} }
}
} }
if(sdown) if(sdown)
{ {
for(size_t i = 0; i<sdown->size(); i++) { for(size_t i = 0; i<sdown->size(); i++)
if((*sdown)[i]){ {
if((*sdown)[i])
{
(*sdown)[i]->show(); (*sdown)[i]->show();
} }
} }
} }
} }
void CGarrisonInt::deactiveteSlots() void CGarrisonInt::deactiveteSlots()
@ -924,9 +931,8 @@ ClickableL::ClickableL()
pressedL=false; pressedL=false;
} }
ClickableL::~ClickableL() { ClickableL::~ClickableL()
{}
}
void ClickableL::clickLeft(tribool down) void ClickableL::clickLeft(tribool down)
{ {
@ -950,9 +956,8 @@ ClickableR::ClickableR()
pressedR=false; pressedR=false;
} }
ClickableR::~ClickableR() { ClickableR::~ClickableR()
{}
}
void ClickableR::clickRight(tribool down) void ClickableR::clickRight(tribool down)
{ {
@ -971,9 +976,8 @@ void ClickableR::deactivate()
} }
//ClickableR //ClickableR
Hoverable::~Hoverable() { Hoverable::~Hoverable()
{}
}
void Hoverable::activate() void Hoverable::activate()
{ {
@ -990,9 +994,8 @@ void Hoverable::hover(bool on)
} }
//Hoverable //Hoverable
KeyInterested::~KeyInterested() { KeyInterested::~KeyInterested()
{}
}
void KeyInterested::activate() void KeyInterested::activate()
{ {
@ -2027,7 +2030,7 @@ void CPlayerInterface::battleStart(CCreatureSet *army1, CCreatureSet *army2, int
{ {
boost::unique_lock<boost::recursive_mutex> un(*pim); boost::unique_lock<boost::recursive_mutex> un(*pim);
curint->deactivate(); 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(); curint->activate();
LOCPLINT->objsToBlit.push_back(dynamic_cast<IShowable*>(curint)); LOCPLINT->objsToBlit.push_back(dynamic_cast<IShowable*>(curint));
} }

View File

@ -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<std::string> * ws = CMessage::breakText(text,charpr);
std::vector<SDL_Surface*> wesu; std::vector<SDL_Surface*> wesu;
wesu.resize(ws->size()); 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); wesu[i]=TTF_RenderText_Blended(font,(*ws)[i].c_str(),kolor);
} }
int tox=0, toy=0; int tox=0, toy=0;
for (size_t i=0; i < wesu.size(); ++i) 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 */ /* Here p is the address to the pixel we want to retrieve */
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
switch(bpp) { switch(bpp)
{
case 1: case 1:
if(colorByte) if(colorByte)
{ {
@ -544,18 +546,21 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
int srcx, srcy, w, h; int srcx, srcy, w, h;
/* Make sure the surfaces aren't locked */ /* Make sure the surfaces aren't locked */
if ( ! src || ! dst ) { if ( ! src || ! dst )
{
SDL_SetError("SDL_UpperBlit: passed a NULL surface"); SDL_SetError("SDL_UpperBlit: passed a NULL surface");
return(-1); return(-1);
} }
if ( src->locked || dst->locked ) { if ( src->locked || dst->locked )
{
SDL_SetError("Surfaces must not be locked during blit"); SDL_SetError("Surfaces must not be locked during blit");
return(-1); return(-1);
} }
/* If the destination rectangle is NULL, use the entire dest surface */ /* If the destination rectangle is NULL, use the entire dest surface */
if ( dstRect == NULL ) { if ( dstRect == NULL )
fulldst.x = fulldst.y = 0; {
fulldst.x = fulldst.y = 0;
dstRect = &fulldst; dstRect = &fulldst;
} }
@ -566,7 +571,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
srcx = srcRect->x; srcx = srcRect->x;
w = srcRect->w; w = srcRect->w;
if(srcx < 0) { if(srcx < 0)
{
w += srcx; w += srcx;
dstRect->x -= srcx; dstRect->x -= srcx;
srcx = 0; srcx = 0;
@ -577,7 +583,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
srcy = srcRect->y; srcy = srcRect->y;
h = srcRect->h; h = srcRect->h;
if(srcy < 0) { if(srcy < 0)
{
h += srcy; h += srcy;
dstRect->y -= srcy; dstRect->y -= srcy;
srcy = 0; srcy = 0;
@ -600,7 +607,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
int dx, dy; int dx, dy;
dx = clip->x - dstRect->x; dx = clip->x - dstRect->x;
if(dx > 0) { if(dx > 0)
{
w -= dx; w -= dx;
dstRect->x += dx; dstRect->x += dx;
srcx += dx; srcx += dx;
@ -610,7 +618,8 @@ int CSDL_Ext::blit8bppAlphaTo24bpp(SDL_Surface * src, SDL_Rect * srcRect, SDL_Su
w -= dx; w -= dx;
dy = clip->y - dstRect->y; dy = clip->y - dstRect->y;
if(dy > 0) { if(dy > 0)
{
h -= dy; h -= dy;
dstRect->y += dy; dstRect->y += dy;
srcy += dy; srcy += dy;

View File

@ -22,16 +22,18 @@ void CCreatureAnimation::setType(int type)
break; break;
} }
} }
if(curFrame != -1) { if(curFrame != -1)
{
curFrame = j; curFrame = j;
} }
} }
} }
else else
{ {
if(curFrame>=frames) { if(curFrame>=frames)
{
curFrame = 0; curFrame = 0;
} }
} }
} }
@ -286,7 +288,8 @@ inline void CCreatureAnimation::putPixel(
const bool & yellowBorder const bool & yellowBorder
) const { ) const {
if(palc!=0) { if(palc!=0)
{
Uint8 * p = (Uint8*)dest->pixels + ftcp*3; Uint8 * p = (Uint8*)dest->pixels + ftcp*3;
if(palc > 7) //normal color if(palc > 7) //normal color
{ {

View File

@ -65,12 +65,10 @@ void SpellbookInteractiveArea::deactivate()
Hoverable::deactivate(); Hoverable::deactivate();
} }
CSpellWindow::CSpellWindow( CSpellWindow::CSpellWindow(const SDL_Rect & myRect, const CGHeroInstance * myHero):
const SDL_Rect & myRect, battleSpellsOnly(true),
const CGHeroInstance * myHero): selectedTab(4),
battleSpellsOnly(true), spellSite(0)
selectedTab(4),
spellSite(0)
{ {
//XXX for testing only //XXX for testing only
//mySpells = myHero->spells; //mySpells = myHero->spells;
@ -547,12 +545,14 @@ void CSpellWindow::computeSpellsPerArea()
{ {
for(size_t c=0; c<12; ++c) for(size_t c=0; c<12; ++c)
{ {
if(c<spellsCurSite.size()) { if(c<spellsCurSite.size())
{
spellAreas[c]->mySpell = spellsCurSite[c]; spellAreas[c]->mySpell = spellsCurSite[c];
} }
else { else
{
spellAreas[c]->mySpell = -1; spellAreas[c]->mySpell = -1;
} }
} }
} }
else else

View File

@ -123,7 +123,8 @@ void Graphics::loadPaletteAndColors()
guildBgs.push_back(pals); guildBgs.push_back(pals);
} }
bback.close(); bback.close();
} }
void Graphics::initializeBattleGraphics() void Graphics::initializeBattleGraphics()
{ {
std::ifstream bback("config/battleBack.txt"); std::ifstream bback("config/battleBack.txt");

View File

@ -83,16 +83,16 @@ GUISettings
HeroList: size=10 x=832 y=201 movePoints=IMOBIL.DEF manaPoints=IMANA.DEF arrowUp=IAM012.DEF arrowDown=IAM013.DEF; 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; TownList: size=10 x=970 y=201 arrowUp=IAM014.DEF arrowDown=IAM015.DEF;
Minimap: width=144 height=144 x=854 y=26; 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; 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; ButtonKingdomOv: x=903 y=197 graphic=IAM002L.DEF playerColoured=1;
ButtonUnderground: x=903 y=230 graphic=IAM010.DEF playerColoured=1 additionalDefs=(IAM003.DEF); ButtonUnderground: x=903 y=230 graphic=IAM010L.DEF playerColoured=1 additionalDefs=(IAM003L.DEF);
ButtonQuestLog: x=903 y=261 graphic=IAM004.DEF playerColoured=1; ButtonQuestLog: x=903 y=261 graphic=IAM004L.DEF playerColoured=1;
ButtonSleepWake: x=903 y=294 graphic=IAM005.DEF playerColoured=1; ButtonSleepWake: x=903 y=294 graphic=IAM005L.DEF playerColoured=1;
ButtonMoveHero: x=903 y=327 graphic=IAM006.DEF playerColoured=1; ButtonMoveHero: x=903 y=327 graphic=IAM006L.DEF playerColoured=1;
ButtonSpellbook: x=903 y=359 graphic=IAM007.DEF playerColoured=1; ButtonSpellbook: x=903 y=359 graphic=IAM007L.DEF playerColoured=1;
ButtonAdvOptions: x=903 y=393 graphic=IAM008.DEF playerColoured=1; ButtonAdvOptions: x=903 y=393 graphic=IAM008L.DEF playerColoured=1;
ButtonSysOptions: x=903 y=426 graphic=IAM009.DEF playerColoured=1; ButtonSysOptions: x=903 y=426 graphic=IAM009L.DEF playerColoured=1;
ButtonNextHero: x=903 y=491 graphic=IAM000.DEF playerColoured=1; ButtonNextHero: x=903 y=491 graphic=IAM000.DEF playerColoured=1;
ButtonEndTurn: x=903 y=524 graphic=IAM001.DEF playerColoured=1; ButtonEndTurn: x=903 y=524 graphic=IAM001.DEF playerColoured=1;
}; };

View File

@ -215,17 +215,21 @@ public:
template<typename T> template<typename T>
CLogger<lvl> & operator<<(const T & data) CLogger<lvl> & operator<<(const T & data)
{ {
if(lvl < CONSOLE_LOGGING_LEVEL) { if(lvl < CONSOLE_LOGGING_LEVEL)
if(console) { {
if(console)
{
console->print(data,lvl); console->print(data,lvl);
} }
else { else
{
std::cout << data << std::flush; std::cout << data << std::flush;
} }
} }
if((lvl < FILE_LOGGING_LEVEL) && logfile) { if((lvl < FILE_LOGGING_LEVEL) && logfile)
{
*logfile << data << std::flush; *logfile << data << std::flush;
} }
return *this; return *this;
} }
}; };

View File

@ -52,9 +52,10 @@ void CObjectHandler::loadObjects()
{ {
std::string nobj; std::string nobj;
loadToIt(nobj, buf, it, 3); 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); nobj = nobj.substr(0, nobj.size()-1);
} }
names.push_back(nobj); names.push_back(nobj);
} }
@ -65,9 +66,10 @@ void CObjectHandler::loadObjects()
while (it<buf.length()-1) while (it<buf.length()-1)
{ {
loadToIt(temp,buf,it,3); loadToIt(temp,buf,it,3);
if (temp[0]=='\"') { if (temp[0]=='\"')
{
temp = temp.substr(1,temp.length()-2); temp = temp.substr(1,temp.length()-2);
} }
boost::algorithm::replace_all(temp,"\"\"","\""); boost::algorithm::replace_all(temp,"\"\"","\"");
advobtxt.push_back(temp); advobtxt.push_back(temp);
} }
@ -112,9 +114,10 @@ void CObjectHandler::loadObjects()
tlog5 << "\t\tReading cregens \n"; tlog5 << "\t\tReading cregens \n";
cregens.resize(110); //TODO: hardcoded value - change 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; cregens[i]=-1;
} }
std::ifstream ifs("config/cregens.txt"); std::ifstream ifs("config/cregens.txt");
while(!ifs.eof()) 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' 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; return pos;
} }
else { else
return convertPosition(pos,false); {
} return convertPosition(pos,false);
}
} }
int CGHeroInstance::getSightDistance() const //returns sight distance of this hero int CGHeroInstance::getSightDistance() const //returns sight distance of this hero
{ {

14
int3.h
View File

@ -14,13 +14,19 @@ public:
si32 getSlotFor(ui32 creature, ui32 slotsAmount=7) //returns -1 if no slot available 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) 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 return i->first; //if there is already such creature we return its slot id
} }
}
for(ui32 i=0; i<slotsAmount; i++) 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 i; //return first free slot
} }
}
return -1; //no slot available return -1; //no slot available
} }
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)

View File

@ -170,7 +170,8 @@ public:
} }
template<class T> template<class T>
COSer & operator&(T & t){ COSer & operator&(T & t)
{
return * this->This() << t; return * this->This() << t;
} }
@ -272,7 +273,8 @@ public:
} }
template<class T> template<class T>
CISer & operator&(T & t){ CISer & operator&(T & t)
{
return * this->This() >> t; return * this->This() >> t;
} }

View File

@ -155,9 +155,10 @@ void CMapHandler::prepareFOWDefs()
for (int j=0; j < CGI->mh->map->height; ++j) for (int j=0; j < CGI->mh->map->height; ++j)
{ {
hideBitmap[i][j].resize(CGI->mh->map->twoLevel+1); 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(); hideBitmap[i][j][k] = rand()%fullHide->ourImages.size();
} }
} }
} }
} }