diff --git a/CBattleInterface.cpp b/CBattleInterface.cpp index 2c17d36d4..a7b611440 100644 --- a/CBattleInterface.cpp +++ b/CBattleInterface.cpp @@ -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(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; vnextFrame(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; bgetType(); 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<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::iterator > toErase; for(std::list::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; bgetType() != 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; vbeffects.insert(myst.effects[vb].id); - } + } + + pom->shotsLeft = myst.shots; + for(int vb=0; vbeffects.insert(myst.effects[vb].id); } pom->currentHealth = myst.firstHPleft; (new CCreInfoWindow(myst.creature->idNumber,0,myst.amount,pom,boost::function(),boost::function(),NULL)) diff --git a/CBattleInterface.h b/CBattleInterface.h index 66ef37e4f..2dece63e2 100644 --- a/CBattleInterface.h +++ b/CBattleInterface.h @@ -187,7 +187,7 @@ private: }; std::list 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; //animation handling diff --git a/CCallback.cpp b/CCallback.cpp index 51d77105f..a3870229c 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -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(valplayers[player].heroes.size()) { + { + if(valplayers[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 diff --git a/CCastleInterface.cpp b/CCastleInterface.cpp index fdde809cf..d5f153907 100644 --- a/CCastleInterface.cpp +++ b/CCastleInterface.cpp @@ -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 "<ID<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 "<ID<statusbar = statusbar; exit->activate(); split->activate(); - for(size_t i=0;iactivate(); - } + } 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;ideactivate(); - } + } 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++; - } - } + 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;iobjsToBlit -= this; exit->deactivate(); - for(size_t i=0;ipos.x = pos.x + 403 + 46*s; add->pos.y = pos.y + 365; add->pos.h = add->pos.w = 44; - if(sartifacts.size() && hero->artifacts[s]) { + if(sartifacts.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); diff --git a/CMessage.cpp b/CMessage.cpp index 3567f7b82..56f2288ca 100644 --- a/CMessage.cpp +++ b/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; ih)//background { - for (int j=0; jw-1) { + for (int j=0; jw-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 > * SDL_Surface * CMessage::blitCompsOnSur(std::vector & comps, int maxw, int inter, int & curh, SDL_Surface * ret) { std::vector * 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); diff --git a/CPathfinder.cpp b/CPathfinder.cpp index 761cf71ac..75b90e34d 100644 --- a/CPathfinder.cpp +++ b/CPathfinder.cpp @@ -55,27 +55,32 @@ CPath * CPathfinder::getPath(int3 src, int3 dest, const CGHeroInstance * hero, u for(size_t j=0; jmh->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]; - } + } } } diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index 1db778c03..3bc7a7bd4 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -311,16 +311,18 @@ CGarrisonInt::~CGarrisonInt() { if(sup) { - for(size_t i=0;isize();i++) { + for(size_t i=0;isize();i++) + { delete (*sup)[i]; - } + } delete sup; } if(sdown) { - for(size_t i=0;isize();i++) { + for(size_t i=0;isize();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; isize(); i++) - if((*sup)[i]) { + { + if((*sup)[i]) + { (*sup)[i]->show(); - } + } + } } if(sdown) { - for(size_t i = 0; isize(); i++) { - if((*sdown)[i]){ + for(size_t i = 0; isize(); 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 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(curint)); } diff --git a/SDL_Extensions.cpp b/SDL_Extensions.cpp index 72ef8343e..431a99056 100644 --- a/SDL_Extensions.cpp +++ b/SDL_Extensions.cpp @@ -74,9 +74,10 @@ void CSDL_Ext::printAtMiddleWB(const std::string & text, int x, int y, TTF_Font std::vector * ws = CMessage::breakText(text,charpr); std::vector 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; diff --git a/client/CCreatureAnimation.cpp b/client/CCreatureAnimation.cpp index a6301712c..5b6f57a4f 100644 --- a/client/CCreatureAnimation.cpp +++ b/client/CCreatureAnimation.cpp @@ -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 { diff --git a/client/CSpellWindow.cpp b/client/CSpellWindow.cpp index a5e415fc2..1ce5c59f3 100644 --- a/client/CSpellWindow.cpp +++ b/client/CSpellWindow.cpp @@ -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(cmySpell = spellsCurSite[c]; - } - else { + } + else + { spellAreas[c]->mySpell = -1; - } + } } } else diff --git a/client/Graphics.cpp b/client/Graphics.cpp index bd1162e37..81cd1ae22 100644 --- a/client/Graphics.cpp +++ b/client/Graphics.cpp @@ -123,7 +123,8 @@ void Graphics::loadPaletteAndColors() guildBgs.push_back(pals); } bback.close(); -} +} + void Graphics::initializeBattleGraphics() { std::ifstream bback("config/battleBack.txt"); diff --git a/config/settings.txt b/config/settings.txt index e37738c5d..45ab039c6 100644 --- a/config/settings.txt +++ b/config/settings.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; }; diff --git a/global.h b/global.h index 7894e6246..69a826e5d 100644 --- a/global.h +++ b/global.h @@ -215,17 +215,21 @@ public: template CLogger & 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; } }; diff --git a/hch/CObjectHandler.cpp b/hch/CObjectHandler.cpp index 62f44d090..aed02e0bc 100644 --- a/hch/CObjectHandler.cpp +++ b/hch/CObjectHandler.cpp @@ -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 >::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 void serialize(Handler &h, const int version) diff --git a/lib/Connection.h b/lib/Connection.h index 37294527f..1d0712475 100644 --- a/lib/Connection.h +++ b/lib/Connection.h @@ -170,7 +170,8 @@ public: } template - COSer & operator&(T & t){ + COSer & operator&(T & t) + { return * this->This() << t; } @@ -272,7 +273,8 @@ public: } template - CISer & operator&(T & t){ + CISer & operator&(T & t) + { return * this->This() >> t; } diff --git a/mapHandler.cpp b/mapHandler.cpp index 75d851327..d95d8431c 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -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; kmh->map->twoLevel+1; ++k) { + for(int k=0; kmh->map->twoLevel+1; ++k) + { hideBitmap[i][j][k] = rand()%fullHide->ourImages.size(); - } + } } } }