mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Compilation fixes for VC10.
Changes towards hot-seat support.
This commit is contained in:
parent
acbfa7a6b9
commit
e6f31b7500
@ -16,6 +16,10 @@ using namespace geniusai::BattleAI;
|
||||
using namespace boost::lambda;
|
||||
using namespace std;
|
||||
|
||||
#if _MSC_VER >= 1600
|
||||
#define bind boost::lambda::bind
|
||||
#endif
|
||||
|
||||
/*
|
||||
ui8 side; //who made this action: false - left, true - right player
|
||||
ui32 stackNumber;//stack ID, -1 left hero, -2 right hero,
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
virtual void actionStarted(const BattleAction *action){};//occurs BEFORE every action taken by any stack or by the hero
|
||||
virtual BattleAction activeStack(int stackID)=0; //called when it's turn of that stack
|
||||
virtual void battleAttack(BattleAttack *ba){}; //called when stack is performing attack
|
||||
virtual void battleStacksAttacked(std::set<BattleStackAttacked> & bsa){}; //called when stack receives damage (after battleAttack())
|
||||
virtual void battleStacksAttacked(std::vector<BattleStackAttacked> & bsa){}; //called when stack receives damage (after battleAttack())
|
||||
virtual void battleEnd(BattleResult *br){};
|
||||
virtual void battleResultsApplied(){}; //called when all effects of last battle are applied
|
||||
virtual void battleNewRound(int round){}; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
|
||||
|
@ -151,7 +151,7 @@ void AdventureMapButton::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
if(down && helpBox.size()) //there is no point to show window with nothing inside...
|
||||
if(LOCPLINT)
|
||||
LOCPLINT->adventureInt->handleRightClick(helpBox,down,this);
|
||||
adventureInt->handleRightClick(helpBox,down,this);
|
||||
else
|
||||
GH.pushInt(new CRClickPopupInt(CMessage::genWindow(helpBox, 0),true));
|
||||
}
|
||||
@ -268,6 +268,14 @@ void AdventureMapButton::setDef(const std::string & defName, bool playerColoredB
|
||||
}
|
||||
delete temp;
|
||||
}
|
||||
|
||||
void AdventureMapButton::setPlayerColor(int player)
|
||||
{
|
||||
for(int i =0; i<imgs.size();i++)
|
||||
for(int j=0;j<imgs[i].size();j++)
|
||||
graphics->blueToPlayersAdv(imgs[i][j],player);
|
||||
}
|
||||
|
||||
void CHighlightableButton::select(bool on)
|
||||
{
|
||||
selected = on;
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
|
||||
void init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key );
|
||||
void setDef(const std::string & defName, bool playerColoredButton);
|
||||
void setPlayerColor(int player);
|
||||
};
|
||||
|
||||
class CHighlightableButton
|
||||
|
@ -47,6 +47,8 @@ using namespace boost::logic;
|
||||
using namespace boost::assign;
|
||||
using namespace CSDL_Ext;
|
||||
|
||||
CAdvMapInt *adventureInt;
|
||||
|
||||
CMinimap::CMinimap(bool draw)
|
||||
{
|
||||
int3 mapSizes = LOCPLINT->cb->getMapSize();
|
||||
@ -123,7 +125,7 @@ void CMinimap::draw(SDL_Surface * to)
|
||||
{
|
||||
int3 mapSizes = LOCPLINT->cb->getMapSize();
|
||||
//draw terrain
|
||||
blitAt(map[LOCPLINT->adventureInt->position.z],0,0,temps);
|
||||
blitAt(map[adventureInt->position.z],0,0,temps);
|
||||
|
||||
//draw heroes
|
||||
std::vector <const CGHeroInstance *> hh = LOCPLINT->cb->getHeroesInfo(false);
|
||||
@ -133,7 +135,7 @@ void CMinimap::draw(SDL_Surface * to)
|
||||
for (size_t i=0; i < hh.size(); ++i)
|
||||
{
|
||||
int3 hpos = hh[i]->getPosition(false);
|
||||
if(hpos.z!=LOCPLINT->adventureInt->position.z)
|
||||
if(hpos.z!=adventureInt->position.z)
|
||||
continue;
|
||||
//float zawx = ((float)hpos.x/CGI->mh->sizes.x), zawy = ((float)hpos.y/CGI->mh->sizes.y);
|
||||
int3 maplgp ( (hpos.x*mw)/mapSizes.x, (hpos.y*mh)/mapSizes.y, hpos.z );
|
||||
@ -147,13 +149,13 @@ void CMinimap::draw(SDL_Surface * to)
|
||||
}
|
||||
}
|
||||
|
||||
blitAt(flObjs[LOCPLINT->adventureInt->position.z],0,0,temps);
|
||||
blitAt(flObjs[adventureInt->position.z],0,0,temps);
|
||||
|
||||
blitAt(FoW[LOCPLINT->adventureInt->position.z],0,0,temps);
|
||||
blitAt(FoW[adventureInt->position.z],0,0,temps);
|
||||
|
||||
//draw radar
|
||||
int bx = (((float)LOCPLINT->adventureInt->position.x)/(((float)mapSizes.x)))*pos.w,
|
||||
by = (((float)LOCPLINT->adventureInt->position.y)/(((float)mapSizes.y)))*pos.h;
|
||||
int bx = (((float)adventureInt->position.x)/(((float)mapSizes.x)))*pos.w,
|
||||
by = (((float)adventureInt->position.y)/(((float)mapSizes.y)))*pos.h;
|
||||
blitAt(radar,bx,by,temps);
|
||||
blitAt(temps,pos.x,pos.y,to);
|
||||
}
|
||||
@ -270,7 +272,7 @@ void CMinimap::updateRadar()
|
||||
|
||||
void CMinimap::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(rcText,down,this);
|
||||
adventureInt->handleRightClick(rcText,down,this);
|
||||
}
|
||||
|
||||
void CMinimap::clickLeft(tribool down, bool previousState)
|
||||
@ -292,17 +294,17 @@ void CMinimap::clickLeft(tribool down, bool previousState)
|
||||
int3 newCPos;
|
||||
newCPos.x = (CGI->mh->sizes.x*dx);
|
||||
newCPos.y = (CGI->mh->sizes.y*dy);
|
||||
newCPos.z = LOCPLINT->adventureInt->position.z;
|
||||
LOCPLINT->adventureInt->centerOn(newCPos);
|
||||
newCPos.z = adventureInt->position.z;
|
||||
adventureInt->centerOn(newCPos);
|
||||
}
|
||||
|
||||
void CMinimap::hover (bool on)
|
||||
{
|
||||
//Hoverable::hover(on);
|
||||
if (on)
|
||||
LOCPLINT->adventureInt->statusbar.print(statusbarTxt);
|
||||
else if (LOCPLINT->adventureInt->statusbar.current==statusbarTxt)
|
||||
LOCPLINT->adventureInt->statusbar.clear();
|
||||
adventureInt->statusbar.print(statusbarTxt);
|
||||
else if (adventureInt->statusbar.current==statusbarTxt)
|
||||
adventureInt->statusbar.clear();
|
||||
}
|
||||
|
||||
void CMinimap::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
@ -478,7 +480,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState)
|
||||
std::vector < const CGObjectInstance * > bobjs = LOCPLINT->cb->getBlockingObjs(mp), //blocking objects at tile
|
||||
vobjs = LOCPLINT->cb->getVisitableObjs(mp); //visitable objects
|
||||
|
||||
if (LOCPLINT->adventureInt->selection->ID != HEROI_TYPE) //hero is not selected (presumably town)
|
||||
if (adventureInt->selection->ID != HEROI_TYPE) //hero is not selected (presumably town)
|
||||
{
|
||||
if(currentPath)
|
||||
{
|
||||
@ -491,16 +493,16 @@ void CTerrainRect::clickLeft(tribool down, bool previousState)
|
||||
{
|
||||
if(bobjs[i]->ID == TOWNI_TYPE && bobjs[i]->getOwner() == LOCPLINT->playerID) //our town clicked
|
||||
{
|
||||
if(LOCPLINT->adventureInt->selection == (bobjs[i])) //selected town clicked
|
||||
if(adventureInt->selection == (bobjs[i])) //selected town clicked
|
||||
LOCPLINT->openTownWindow(static_cast<const CGTownInstance*>(bobjs[i]));
|
||||
else
|
||||
LOCPLINT->adventureInt->select(static_cast<const CArmedInstance*>(bobjs[i]));
|
||||
adventureInt->select(static_cast<const CArmedInstance*>(bobjs[i]));
|
||||
|
||||
return;
|
||||
}
|
||||
else if(bobjs[i]->ID == HEROI_TYPE && bobjs[i]->tempOwner == LOCPLINT->playerID) //hero clicked - select him
|
||||
{
|
||||
LOCPLINT->adventureInt->select(static_cast<const CArmedInstance*>(bobjs[i]));
|
||||
adventureInt->select(static_cast<const CArmedInstance*>(bobjs[i]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -509,7 +511,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState)
|
||||
else //hero is selected
|
||||
{
|
||||
bool townEntrance = false; //town entrance tile has been clicked?
|
||||
const CGHeroInstance * currentHero = static_cast<const CGHeroInstance*>(LOCPLINT->adventureInt->selection);
|
||||
const CGHeroInstance * currentHero = static_cast<const CGHeroInstance*>(adventureInt->selection);
|
||||
|
||||
for(size_t i=0; i < vobjs.size(); ++i)
|
||||
{
|
||||
@ -527,7 +529,7 @@ void CTerrainRect::clickLeft(tribool down, bool previousState)
|
||||
|| o->ID == TOWNI_TYPE) //or town
|
||||
&& o->tempOwner == LOCPLINT->playerID) //but must belong to us
|
||||
{
|
||||
LOCPLINT->adventureInt->select(static_cast<const CArmedInstance*>(o));
|
||||
adventureInt->select(static_cast<const CArmedInstance*>(o));
|
||||
return;
|
||||
}
|
||||
else if(o->ID == HEROI_TYPE //it's a hero
|
||||
@ -555,10 +557,10 @@ void CTerrainRect::clickLeft(tribool down, bool previousState)
|
||||
else if(mp.z == currentHero->pos.z) //remove old path and find a new one if we clicked on the map level on which hero is present
|
||||
{
|
||||
int3 bufpos = currentHero->getPosition(false);
|
||||
CGPath &path = LOCPLINT->adventureInt->paths[currentHero];
|
||||
CGPath &path = LOCPLINT->paths[currentHero];
|
||||
currentPath = &path;
|
||||
if(!LOCPLINT->cb->getPath2(mp, path))
|
||||
LOCPLINT->adventureInt->eraseCurrentPathOf(currentHero);
|
||||
LOCPLINT->eraseCurrentPathOf(currentHero);
|
||||
}
|
||||
} //end of hero is selected "case"
|
||||
}
|
||||
@ -675,7 +677,7 @@ void CTerrainRect::clickRight(tribool down, bool previousState)
|
||||
}
|
||||
default:
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(obj->getHoverText(),down,this);
|
||||
adventureInt->handleRightClick(obj->getHoverText(),down,this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -683,7 +685,7 @@ void CTerrainRect::clickRight(tribool down, bool previousState)
|
||||
void CTerrainRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
{
|
||||
int3 tHovered = whichTileIsIt(sEvent.x,sEvent.y);
|
||||
int3 pom = LOCPLINT->adventureInt->verifyPos(tHovered);
|
||||
int3 pom = adventureInt->verifyPos(tHovered);
|
||||
|
||||
if(tHovered != pom) //tile outside the map
|
||||
{
|
||||
@ -700,11 +702,11 @@ void CTerrainRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
if (temp.size())
|
||||
{
|
||||
boost::replace_all(temp.back(),"\n"," ");
|
||||
LOCPLINT->adventureInt->statusbar.print(temp.back());
|
||||
adventureInt->statusbar.print(temp.back());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOCPLINT->adventureInt->statusbar.clear();
|
||||
adventureInt->statusbar.clear();
|
||||
}
|
||||
|
||||
const CGPathNode *pnode = LOCPLINT->cb->getPathInfo(pom);
|
||||
@ -715,9 +717,9 @@ void CTerrainRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
int turns = pnode->turns;
|
||||
amin(turns, 3);
|
||||
|
||||
if(LOCPLINT->adventureInt->selection)
|
||||
if(adventureInt->selection)
|
||||
{
|
||||
if(LOCPLINT->adventureInt->selection->ID == TOWNI_TYPE)
|
||||
if(adventureInt->selection->ID == TOWNI_TYPE)
|
||||
{
|
||||
if(obj && obj->tempOwner == LOCPLINT->playerID)
|
||||
{
|
||||
@ -735,9 +737,9 @@ void CTerrainRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
CGI->curh->changeGraphic(0, 0);
|
||||
}
|
||||
}
|
||||
else if(LOCPLINT->adventureInt->selection->ID == HEROI_TYPE)
|
||||
else if(adventureInt->selection->ID == HEROI_TYPE)
|
||||
{
|
||||
const CGHeroInstance *h = static_cast<const CGHeroInstance *>(LOCPLINT->adventureInt->selection);
|
||||
const CGHeroInstance *h = static_cast<const CGHeroInstance *>(adventureInt->selection);
|
||||
if(obj)
|
||||
{
|
||||
if(obj->ID == HEROI_TYPE)
|
||||
@ -751,7 +753,7 @@ void CTerrainRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
}
|
||||
else //our hero
|
||||
{
|
||||
if(LOCPLINT->adventureInt->selection == obj)
|
||||
if(adventureInt->selection == obj)
|
||||
CGI->curh->changeGraphic(0, 2);
|
||||
else if(accessible)
|
||||
CGI->curh->changeGraphic(0, 8 + turns*6);
|
||||
@ -855,7 +857,7 @@ void CTerrainRect::hover(bool on)
|
||||
{
|
||||
if (!on)
|
||||
{
|
||||
LOCPLINT->adventureInt->statusbar.clear();
|
||||
adventureInt->statusbar.clear();
|
||||
CGI->curh->changeGraphic(0,0);
|
||||
}
|
||||
//Hoverable::hover(on);
|
||||
@ -867,8 +869,8 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
|
||||
int pn=-1;//number of picture
|
||||
if (i==0) //last tile
|
||||
{
|
||||
int x = 32*(currentPath->nodes[i].coord.x-LOCPLINT->adventureInt->position.x)+CGI->mh->offsetX + pos.x,
|
||||
y = 32*(currentPath->nodes[i].coord.y-LOCPLINT->adventureInt->position.y)+CGI->mh->offsetY + pos.y;
|
||||
int x = 32*(currentPath->nodes[i].coord.x-adventureInt->position.x)+CGI->mh->offsetX + pos.x,
|
||||
y = 32*(currentPath->nodes[i].coord.y-adventureInt->position.y)+CGI->mh->offsetY + pos.y;
|
||||
if (x<0 || y<0 || x>pos.w || y>pos.h)
|
||||
continue;
|
||||
pn=0;
|
||||
@ -1129,8 +1131,8 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
|
||||
pn+=25;
|
||||
if (pn>=0)
|
||||
{
|
||||
int x = 32*(currentPath->nodes[i].coord.x-LOCPLINT->adventureInt->position.x)+CGI->mh->offsetX + pos.x,
|
||||
y = 32*(currentPath->nodes[i].coord.y-LOCPLINT->adventureInt->position.y)+CGI->mh->offsetY + pos.y;
|
||||
int x = 32*(currentPath->nodes[i].coord.x-adventureInt->position.x)+CGI->mh->offsetX + pos.x,
|
||||
y = 32*(currentPath->nodes[i].coord.y-adventureInt->position.y)+CGI->mh->offsetY + pos.y;
|
||||
if (x<0 || y<0 || x>pos.w || y>pos.h)
|
||||
continue;
|
||||
int hvx = (x+arrows->ourImages[pn].bitmap->w)-(pos.x+pos.w),
|
||||
@ -1199,18 +1201,18 @@ void CTerrainRect::show(SDL_Surface * to)
|
||||
{
|
||||
if(ADVOPT.smoothMove)
|
||||
CGI->mh->terrainRect
|
||||
(LOCPLINT->adventureInt->position, LOCPLINT->adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim,
|
||||
(adventureInt->position, adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim,
|
||||
to, &pos, moveX, moveY, false);
|
||||
else
|
||||
CGI->mh->terrainRect
|
||||
(LOCPLINT->adventureInt->position, LOCPLINT->adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim,
|
||||
(adventureInt->position, adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim,
|
||||
to, &pos, 0, 0, false);
|
||||
|
||||
//SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),screen,&genRect(547,594,7,6));
|
||||
//SDL_FreeSurface(teren);
|
||||
if (currentPath && LOCPLINT->adventureInt->position.z==currentPath->startPos().z) //drawing path
|
||||
if (currentPath && adventureInt->position.z==currentPath->startPos().z) //drawing path
|
||||
{
|
||||
showPath(&pos, to);
|
||||
}
|
||||
@ -1219,9 +1221,9 @@ void CTerrainRect::show(SDL_Surface * to)
|
||||
int3 CTerrainRect::whichTileIsIt(const int & x, const int & y)
|
||||
{
|
||||
int3 ret;
|
||||
ret.x = LOCPLINT->adventureInt->position.x + ((GH.current->motion.x-CGI->mh->offsetX-pos.x)/32);
|
||||
ret.y = LOCPLINT->adventureInt->position.y + ((GH.current->motion.y-CGI->mh->offsetY-pos.y)/32);
|
||||
ret.z = LOCPLINT->adventureInt->position.z;
|
||||
ret.x = adventureInt->position.x + ((GH.current->motion.x-CGI->mh->offsetX-pos.x)/32);
|
||||
ret.y = adventureInt->position.y + ((GH.current->motion.y-CGI->mh->offsetY-pos.y)/32);
|
||||
ret.z = adventureInt->position.z;
|
||||
return ret;
|
||||
}
|
||||
int3 CTerrainRect::whichTileIsIt()
|
||||
@ -1333,10 +1335,10 @@ void CInfoBar::draw(SDL_Surface * to, const CGObjectInstance * specific)
|
||||
else if (mode==5)
|
||||
{
|
||||
mode = -1;
|
||||
draw(to,LOCPLINT->adventureInt->selection);
|
||||
draw(to,adventureInt->selection);
|
||||
}
|
||||
if (!specific)
|
||||
specific = LOCPLINT->adventureInt->selection;
|
||||
specific = adventureInt->selection;
|
||||
|
||||
if(!specific)
|
||||
return;
|
||||
@ -1483,9 +1485,8 @@ void CInfoBar::deactivate()
|
||||
deactivateTimer();
|
||||
}
|
||||
|
||||
CAdvMapInt::CAdvMapInt(int Player)
|
||||
:player(Player),
|
||||
statusbar(ADVOPT.statusbarX,ADVOPT.statusbarY,ADVOPT.statusbarG),
|
||||
CAdvMapInt::CAdvMapInt()
|
||||
:statusbar(ADVOPT.statusbarX,ADVOPT.statusbarY,ADVOPT.statusbarG),
|
||||
kingOverview(CGI->generaltexth->zelp[293].first,CGI->generaltexth->zelp[293].second,
|
||||
boost::bind(&CAdvMapInt::fshowOverview,this),&ADVOPT.kingOverview, SDLK_k),
|
||||
|
||||
@ -1519,14 +1520,14 @@ endTurn(CGI->generaltexth->zelp[302].first,CGI->generaltexth->zelp[302].second,
|
||||
heroList(ADVOPT.hlistSize),
|
||||
townList(ADVOPT.tlistSize,ADVOPT.tlistX,ADVOPT.tlistY,ADVOPT.tlistAU,ADVOPT.tlistAD)//(5,&genRect(192,48,747,196),747,196,747,372),
|
||||
{
|
||||
player = 0;
|
||||
pos.x = pos.y = 0;
|
||||
pos.w = screen->w;
|
||||
pos.h = screen->h;
|
||||
selection = NULL;
|
||||
townList.fun = boost::bind(&CAdvMapInt::selectionChanged,this);
|
||||
LOCPLINT->adventureInt=this;
|
||||
adventureInt=this;
|
||||
bg = BitmapHandler::loadBitmap(ADVOPT.mainGraphic);
|
||||
graphics->blueToPlayersAdv(bg,player);
|
||||
scrollingDir = 0;
|
||||
updateScreen = false;
|
||||
anim=0;
|
||||
@ -1593,7 +1594,7 @@ void CAdvMapInt::fmoveHero()
|
||||
return;
|
||||
|
||||
LOCPLINT->pim->unlock();
|
||||
LOCPLINT->moveHero(static_cast<const CGHeroInstance*>(LOCPLINT->adventureInt->selection),*terrain.currentPath);
|
||||
LOCPLINT->moveHero(static_cast<const CGHeroInstance*>(adventureInt->selection),*terrain.currentPath);
|
||||
LOCPLINT->pim->lock();
|
||||
}
|
||||
|
||||
@ -1603,7 +1604,7 @@ void CAdvMapInt::fshowSpellbok()
|
||||
return;
|
||||
|
||||
|
||||
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), (static_cast<const CGHeroInstance*>(LOCPLINT->adventureInt->selection)), false);
|
||||
CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (conf.cc.resx - 620)/2, (conf.cc.resy - 595)/2), (static_cast<const CGHeroInstance*>(adventureInt->selection)), false);
|
||||
GH.pushInt(spellWindow);
|
||||
}
|
||||
|
||||
@ -1637,6 +1638,7 @@ void CAdvMapInt::fnextHero()
|
||||
|
||||
void CAdvMapInt::fendTurn()
|
||||
{
|
||||
LOCPLINT->cingconsole->deactivate();
|
||||
LOCPLINT->makingTurn = false;
|
||||
LOCPLINT->cb->endTurn();
|
||||
}
|
||||
@ -1694,13 +1696,14 @@ void CAdvMapInt::deactivate()
|
||||
terrain.deactivate();
|
||||
infoBar.deactivate();
|
||||
infoBar.mode=-1;
|
||||
|
||||
LOCPLINT->cingconsole->deactivate();
|
||||
}
|
||||
void CAdvMapInt::showAll(SDL_Surface *to)
|
||||
{
|
||||
blitAt(bg,0,0,to);
|
||||
|
||||
if(state != INGAME)
|
||||
return;
|
||||
|
||||
kingOverview.show(to);
|
||||
underground.show(to);
|
||||
questlog.show(to);
|
||||
@ -1727,6 +1730,9 @@ void CAdvMapInt::showAll(SDL_Surface *to)
|
||||
}
|
||||
void CAdvMapInt::show(SDL_Surface *to)
|
||||
{
|
||||
if(state != INGAME)
|
||||
return;
|
||||
|
||||
++animValHitCount; //for animations
|
||||
if(animValHitCount == 8)
|
||||
{
|
||||
@ -1794,8 +1800,8 @@ void CAdvMapInt::centerOn(int3 on)
|
||||
|
||||
on = LOCPLINT->repairScreenPos(on);
|
||||
|
||||
LOCPLINT->adventureInt->position = on;
|
||||
LOCPLINT->adventureInt->updateScreen=true;
|
||||
adventureInt->position = on;
|
||||
adventureInt->updateScreen=true;
|
||||
updateMinimap=true;
|
||||
underground.curimg = on.z; //change underground switch button image
|
||||
if(GH.topInt() == this)
|
||||
@ -1902,7 +1908,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
|
||||
|
||||
int3 dir = directions[k];
|
||||
|
||||
CGPath &path = paths[h];
|
||||
CGPath &path = LOCPLINT->paths[h];
|
||||
terrain.currentPath = &path;
|
||||
if(!LOCPLINT->cb->getPath2(h->getPosition(false) + dir, path))
|
||||
{
|
||||
@ -1977,24 +1983,7 @@ void CAdvMapInt::select(const CArmedInstance *sel )
|
||||
heroList.fixPos();
|
||||
}
|
||||
|
||||
if(vstd::contains(paths,h)) //hero has assigned path
|
||||
{
|
||||
CGPath &path = paths[h];
|
||||
if(!path.nodes.size())
|
||||
{
|
||||
tlog3 << "Warning: empty path found...\n";
|
||||
paths.erase(h);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(h->getPosition(false) == path.startPos());
|
||||
//update the hero path in case of something has changed on map
|
||||
if(LOCPLINT->cb->getPath2(path.endPos(), path))
|
||||
terrain.currentPath = &path;
|
||||
else
|
||||
paths.erase(h);
|
||||
}
|
||||
}
|
||||
terrain.currentPath = LOCPLINT->getAndVerifyPath(h);
|
||||
}
|
||||
townList.draw(screen);
|
||||
heroList.draw(screen);
|
||||
@ -2046,13 +2035,36 @@ bool CAdvMapInt::isActive()
|
||||
return active & ~CIntObject::KEYBOARD;
|
||||
}
|
||||
|
||||
void CAdvMapInt::eraseCurrentPathOf( const CGHeroInstance * ho )
|
||||
void CAdvMapInt::startHotSeatWait(int Player)
|
||||
{
|
||||
assert(vstd::contains(paths, ho));
|
||||
assert(ho == selection);
|
||||
setPlayer(Player);
|
||||
state = WAITING;
|
||||
}
|
||||
|
||||
paths.erase(ho);
|
||||
terrain.currentPath = NULL;
|
||||
void CAdvMapInt::setPlayer(int Player)
|
||||
{
|
||||
player = Player;
|
||||
graphics->blueToPlayersAdv(bg,player);
|
||||
|
||||
kingOverview.setPlayerColor(player);
|
||||
underground.setPlayerColor(player);
|
||||
questlog.setPlayerColor(player);
|
||||
sleepWake.setPlayerColor(player);
|
||||
moveHero.setPlayerColor(player);
|
||||
spellbook.setPlayerColor(player);
|
||||
sysOptions.setPlayerColor(player);
|
||||
advOptions.setPlayerColor(player);
|
||||
nextHero.setPlayerColor(player);
|
||||
endTurn.setPlayerColor(player);
|
||||
graphics->blueToPlayersAdv(resdatabar.bg,player);
|
||||
|
||||
heroList.updateHList();
|
||||
townList.genList();
|
||||
}
|
||||
|
||||
void CAdvMapInt::startTurn()
|
||||
{
|
||||
state = INGAME;
|
||||
}
|
||||
|
||||
CAdventureOptions::CAdventureOptions()
|
||||
|
@ -133,7 +133,7 @@ public:
|
||||
class CAdvMapInt : public CIntObject //adventure map interface
|
||||
{
|
||||
public:
|
||||
CAdvMapInt(int Player);
|
||||
CAdvMapInt();
|
||||
~CAdvMapInt();
|
||||
|
||||
int3 position; //top left corner of visible map part
|
||||
@ -143,6 +143,8 @@ public:
|
||||
enum{LEFT=1, RIGHT=2, UP=4, DOWN=8};
|
||||
ui8 scrollingDir; //uses enum: LEFT RIGHT, UP, DOWN
|
||||
|
||||
enum{NA, INGAME, WAITING} state;
|
||||
|
||||
bool updateScreen, updateMinimap ;
|
||||
unsigned char anim, animValHitCount; //animation frame
|
||||
unsigned char heroAnim, heroAnimValHitCount; //animation frame
|
||||
@ -174,7 +176,6 @@ public:
|
||||
CHeroWindow * heroWindow;
|
||||
|
||||
const CArmedInstance *selection; //currently selected town/hero
|
||||
std::map<const CGHeroInstance *, CGPath> paths; //maps hero => selected path in adventure map
|
||||
|
||||
//functions bound to buttons
|
||||
void fshowOverview();
|
||||
@ -202,6 +203,12 @@ public:
|
||||
void keyPressed(const SDL_KeyboardEvent & key);
|
||||
void mouseMoved (const SDL_MouseMotionEvent & sEvent);
|
||||
bool isActive();
|
||||
void eraseCurrentPathOf( const CGHeroInstance * ho );
|
||||
|
||||
void setPlayer(int Player);
|
||||
void startHotSeatWait(int Player);
|
||||
void startTurn();
|
||||
};
|
||||
|
||||
extern CAdvMapInt *adventureInt;
|
||||
|
||||
#endif // __CADVMAPINTERFACE_H__
|
||||
|
@ -2671,7 +2671,7 @@ void CBattleInterface::spellCast(SpellCast * sc)
|
||||
|
||||
void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
|
||||
{
|
||||
for(std::set<ui32>::const_iterator ci = sse.stacks.begin(); ci!=sse.stacks.end(); ++ci)
|
||||
for(std::vector<ui32>::const_iterator ci = sse.stacks.begin(); ci!=sse.stacks.end(); ++ci)
|
||||
{
|
||||
displayEffect(CGI->spellh->spells[sse.effect.id].mainEffectAnim, curInt->cb->battleGetStackByID(*ci)->position);
|
||||
}
|
||||
|
@ -532,9 +532,9 @@ CCastleInterface::~CCastleInterface()
|
||||
void CCastleInterface::close()
|
||||
{
|
||||
if(town->visitingHero)
|
||||
LOCPLINT->adventureInt->select(town->visitingHero);
|
||||
adventureInt->select(town->visitingHero);
|
||||
else
|
||||
LOCPLINT->adventureInt->select(town);
|
||||
adventureInt->select(town);
|
||||
LOCPLINT->castleInt = NULL;
|
||||
GH.popIntTotally(this);
|
||||
CGI->musich->stopMusic(5000);
|
||||
@ -761,7 +761,7 @@ void CCastleInterface::showAll( SDL_Surface * to/*=NULL*/)
|
||||
{
|
||||
blitAt(cityBg,pos,to);
|
||||
blitAt(townInt,pos.x,pos.y+374,to);
|
||||
LOCPLINT->adventureInt->resdatabar.draw(to);
|
||||
adventureInt->resdatabar.draw(to);
|
||||
townlist->draw(to);
|
||||
statusbar->show(to);
|
||||
resdatabar->draw(to);
|
||||
@ -937,11 +937,7 @@ void CCastleInterface::recreateBuildings()
|
||||
{
|
||||
delete buildings[itpb];
|
||||
buildings.erase(buildings.begin() + itpb);
|
||||
#ifndef __GNUC__
|
||||
obecny->second = st->ID; //XXX look closer!
|
||||
#else
|
||||
*(const_cast<int*>(&(obecny->second))) = st->ID;
|
||||
#endif
|
||||
buildings.push_back(new CBuildingRect(st));
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ void CKingdomInterface::updateAllGarrisons()
|
||||
|
||||
void CKingdomInterface::showAll( SDL_Surface * to/*=NULL*/)
|
||||
{
|
||||
LOCPLINT->adventureInt->resdatabar.draw(to);
|
||||
adventureInt->resdatabar.draw(to);
|
||||
blitAt(bg,pos,to);
|
||||
resdatabar->draw(to);
|
||||
toTowns->show(to);
|
||||
|
@ -193,7 +193,6 @@ int main(int argc, char** argv)
|
||||
playIntro();
|
||||
SDL_FillRect(screen,NULL,0);
|
||||
SDL_Flip(screen);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
loading.join();
|
||||
tlog0<<"Initialization of VCMI (together): "<<total.getDif()<<std::endl;
|
||||
|
||||
@ -232,7 +231,7 @@ void processCommand(const std::string &message)
|
||||
GH.topInt()->activate();
|
||||
break;
|
||||
case 1:
|
||||
LOCPLINT->adventureInt->activate();
|
||||
adventureInt->activate();
|
||||
break;
|
||||
case 2:
|
||||
LOCPLINT->castleInt->activate();
|
||||
@ -416,6 +415,7 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen)
|
||||
SDL_EnableUNICODE(1);
|
||||
SDL_WM_SetCaption(NAME.c_str(),""); //set window title
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
|
||||
#ifdef _WIN32
|
||||
SDL_SysWMinfo wm;
|
||||
|
@ -127,7 +127,7 @@ std::vector<std::string> * CMessage::breakText(std::string text, size_t maxLineS
|
||||
unsigned int braces = 0;
|
||||
bool opened = false;
|
||||
|
||||
while((text[z] != 0) && (text[z] != 0x0a) && (z < maxLineSize+braces))
|
||||
while(z < text.length() && (text[z] != 0x0a) && (z < maxLineSize+braces))
|
||||
{
|
||||
/* We don't count braces in string length. */
|
||||
if (text[z] == '{')
|
||||
@ -144,7 +144,7 @@ std::vector<std::string> * CMessage::breakText(std::string text, size_t maxLineS
|
||||
z++;
|
||||
}
|
||||
|
||||
if ((text[z] != 0) && (text[z] != 0x0a))
|
||||
if (z < text.length() && (text[z] != 0x0a))
|
||||
{
|
||||
/* We have a long line. Try to do a nice line break, if
|
||||
* possible. We backtrack on the line until we find a
|
||||
@ -185,7 +185,7 @@ std::vector<std::string> * CMessage::breakText(std::string text, size_t maxLineS
|
||||
ret->push_back(""); //add empty string, no extra actions needed
|
||||
}
|
||||
|
||||
if (text[0] == 0x0a)
|
||||
if (text.length() && text[0] == 0x0a)
|
||||
{
|
||||
/* Braces do not carry over lines. The map author forgot
|
||||
* to close it. */
|
||||
@ -292,14 +292,14 @@ std::vector<std::vector<SDL_Surface*> > * CMessage::drawText(std::vector<std::st
|
||||
|
||||
/* Handle normal text. */
|
||||
z = 0;
|
||||
while((*brtext)[i][z]!= 0 && (*brtext)[i][z] != ('{'))
|
||||
while(z < (*brtext)[i].length() && (*brtext)[i][z] != ('{'))
|
||||
z++;
|
||||
|
||||
if (z)
|
||||
(*txtg)[i].push_back(FNT_RenderText(font, (*brtext)[i].substr(0,z), zwykly));
|
||||
(*brtext)[i].erase(0,z);
|
||||
|
||||
if ((*brtext)[i][0] == '{')
|
||||
if ((*brtext)[i].length() && (*brtext)[i][0] == '{')
|
||||
/* Remove '{' */
|
||||
(*brtext)[i].erase(0,1);
|
||||
|
||||
@ -309,14 +309,14 @@ std::vector<std::vector<SDL_Surface*> > * CMessage::drawText(std::vector<std::st
|
||||
|
||||
/* This text will be highlighted. */
|
||||
z = 0;
|
||||
while((*brtext)[i][z]!= 0 && (*brtext)[i][z] != ('}'))
|
||||
while(z < (*brtext)[i].length() && (*brtext)[i][z] != ('}'))
|
||||
z++;
|
||||
|
||||
if (z)
|
||||
(*txtg)[i].push_back(FNT_RenderText(font, (*brtext)[i].substr(0,z), tytulowy));
|
||||
(*brtext)[i].erase(0,z);
|
||||
|
||||
if ((*brtext)[i][0] == '}')
|
||||
if ((*brtext)[i].length() && (*brtext)[i][0] == '}')
|
||||
/* Remove '}' */
|
||||
(*brtext)[i].erase(0,1);
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include "../StartInfo.h"
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
@ -75,6 +76,9 @@ CBattleInterface * CPlayerInterface::battleInt;
|
||||
enum EMoveState {STOP_MOVE, WAITING_MOVE, CONTINUE_MOVE, DURING_MOVE};
|
||||
CondSh<EMoveState> stillMoveHero; //used during hero movement
|
||||
|
||||
int howManyPeople = 0;
|
||||
|
||||
|
||||
struct OCM_HLP_CGIN
|
||||
{
|
||||
bool inline operator ()(const std::pair<const CGObjectInstance*,SDL_Rect> & a, const std::pair<const CGObjectInstance*,SDL_Rect> & b) const
|
||||
@ -87,6 +91,7 @@ struct OCM_HLP_CGIN
|
||||
|
||||
CPlayerInterface::CPlayerInterface(int Player, int serial)
|
||||
{
|
||||
howManyPeople++;
|
||||
GH.defActionsDef = 0;
|
||||
LOCPLINT = this;
|
||||
curAction = NULL;
|
||||
@ -94,7 +99,6 @@ CPlayerInterface::CPlayerInterface(int Player, int serial)
|
||||
serialID=serial;
|
||||
human=true;
|
||||
castleInt = NULL;
|
||||
adventureInt = NULL;
|
||||
battleInt = NULL;
|
||||
pim = new boost::recursive_mutex;
|
||||
makingTurn = false;
|
||||
@ -112,6 +116,7 @@ CPlayerInterface::CPlayerInterface(int Player, int serial)
|
||||
}
|
||||
CPlayerInterface::~CPlayerInterface()
|
||||
{
|
||||
howManyPeople--;
|
||||
delete pim;
|
||||
delete showingDialog;
|
||||
delete mainFPSmng;
|
||||
@ -133,7 +138,9 @@ CPlayerInterface::~CPlayerInterface()
|
||||
void CPlayerInterface::init(ICallback * CB)
|
||||
{
|
||||
cb = dynamic_cast<CCallback*>(CB);
|
||||
adventureInt = new CAdvMapInt(playerID);
|
||||
if(!adventureInt)
|
||||
adventureInt = new CAdvMapInt();
|
||||
|
||||
std::vector<const CGTownInstance*> tt = cb->getTownsInfo(false);
|
||||
for(int i=0;i<tt.size();i++)
|
||||
{
|
||||
@ -144,61 +151,55 @@ void CPlayerInterface::init(ICallback * CB)
|
||||
}
|
||||
void CPlayerInterface::yourTurn()
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
boost::unique_lock<boost::mutex> lock(eventsM); //block handling events until interface is ready
|
||||
|
||||
LOCPLINT = this;
|
||||
makingTurn = true;
|
||||
|
||||
if(firstCall)
|
||||
{
|
||||
autosaveCount = getLastIndex("Autosave_");
|
||||
GH.pushInt(adventureInt);
|
||||
adventureInt->activateKeys();
|
||||
if(firstCall > 0) //new game, not laoded
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
boost::unique_lock<boost::mutex> lock(eventsM); //block handling events until interface is ready
|
||||
|
||||
LOCPLINT = this;
|
||||
makingTurn = true;
|
||||
GH.curInt = this;
|
||||
|
||||
if(firstCall)
|
||||
{
|
||||
int index = getLastIndex("Newgame_Autosave_");
|
||||
index %= SAVES_COUNT;
|
||||
cb->save("Newgame_Autosave_" + boost::lexical_cast<std::string>(index + 1));
|
||||
if(howManyPeople == 1)
|
||||
adventureInt->setPlayer(playerID);
|
||||
|
||||
autosaveCount = getLastIndex("Autosave_");
|
||||
|
||||
if(!GH.listInt.size())
|
||||
{
|
||||
GH.pushInt(adventureInt);
|
||||
adventureInt->activateKeys();
|
||||
}
|
||||
|
||||
if(firstCall > 0) //new game, not loaded
|
||||
{
|
||||
int index = getLastIndex("Newgame_Autosave_");
|
||||
index %= SAVES_COUNT;
|
||||
cb->save("Newgame_Autosave_" + boost::lexical_cast<std::string>(index + 1));
|
||||
}
|
||||
firstCall = 0;
|
||||
}
|
||||
firstCall = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOCPLINT->cb->save("Autosave_" + boost::lexical_cast<std::string>(autosaveCount++ + 1));
|
||||
autosaveCount %= 5;
|
||||
else
|
||||
{
|
||||
LOCPLINT->cb->save("Autosave_" + boost::lexical_cast<std::string>(autosaveCount++ + 1));
|
||||
autosaveCount %= 5;
|
||||
}
|
||||
|
||||
if(howManyPeople > 1) //hot seat message
|
||||
{
|
||||
adventureInt->startHotSeatWait(playerID);
|
||||
std::string msg = CGI->generaltexth->allTexts[13];
|
||||
boost::replace_first(msg, "%s", cb->getStartInfo()->playerInfos[serialID].name);
|
||||
std::vector<SComponent*> cmp;
|
||||
cmp.push_back(new SComponent(SComponent::flag, playerID, 0));
|
||||
showInfoDialog(msg, cmp);
|
||||
}
|
||||
else
|
||||
adventureInt->startTurn();
|
||||
}
|
||||
|
||||
for(std::map<int,SDL_Surface*>::iterator i=graphics->heroWins.begin(); i!=graphics->heroWins.end();i++) //redraw hero infoboxes
|
||||
SDL_FreeSurface(i->second);
|
||||
graphics->heroWins.clear();
|
||||
std::vector <const CGHeroInstance *> hh = cb->getHeroesInfo(false);
|
||||
for(int i=0;i<hh.size();i++)
|
||||
{
|
||||
SDL_Surface * pom = infoWin(hh[i]);
|
||||
graphics->heroWins.insert(std::pair<int,SDL_Surface*>(hh[i]->subID,pom));
|
||||
}
|
||||
|
||||
/* TODO: This isn't quite right. First day in game should play
|
||||
* NEWDAY. And we don't play NEWMONTH. */
|
||||
int day = cb->getDate(1);
|
||||
if (day != 1)
|
||||
CGI->soundh->playSound(soundBase::newDay);
|
||||
else
|
||||
CGI->soundh->playSound(soundBase::newWeek);
|
||||
|
||||
adventureInt->infoBar.newDay(day);
|
||||
|
||||
//select first hero if available.
|
||||
//TODO: check if hero is slept
|
||||
if(wanderingHeroes.size())
|
||||
adventureInt->select(wanderingHeroes[0]);
|
||||
else
|
||||
adventureInt->select(adventureInt->townList.items[0]);
|
||||
|
||||
adventureInt->showAll(screen);
|
||||
|
||||
GH.curInt = this;
|
||||
acceptTurn();
|
||||
}
|
||||
|
||||
inline void subRect(const int & x, const int & y, const int & z, const SDL_Rect & r, const int & hid)
|
||||
@ -224,6 +225,8 @@ inline void delObjRect(const int & x, const int & y, const int & z, const int &
|
||||
}
|
||||
void CPlayerInterface::heroMoved(const TryMoveHero & details)
|
||||
{
|
||||
if(LOCPLINT != this)
|
||||
return;
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
const CGHeroInstance * ho = cb->getHeroInfo(details.id); //object representing this hero
|
||||
int3 hp = details.start;
|
||||
@ -238,21 +241,21 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
|
||||
if(details.result == TryMoveHero::TELEPORTATION || details.start == details.end)
|
||||
{
|
||||
if(adventureInt->terrain.currentPath)
|
||||
adventureInt->eraseCurrentPathOf(ho);
|
||||
eraseCurrentPathOf(ho);
|
||||
return; //teleport - no fancy moving animation
|
||||
//TODO: smooth disappear / appear effect
|
||||
}
|
||||
|
||||
if (details.result != TryMoveHero::SUCCESS && details.result != TryMoveHero::FAILED) //hero didn't change tile but visit succeeded
|
||||
{
|
||||
adventureInt->eraseCurrentPathOf(ho);
|
||||
eraseCurrentPathOf(ho);
|
||||
}
|
||||
else if(adventureInt->terrain.currentPath && details.result == TryMoveHero::SUCCESS) //&& hero is moving
|
||||
{
|
||||
//remove one node from the path (the one we went)
|
||||
adventureInt->terrain.currentPath->nodes.erase(adventureInt->terrain.currentPath->nodes.end()-1);
|
||||
if(!adventureInt->terrain.currentPath->nodes.size()) //if it was the last one, remove entire path
|
||||
adventureInt->eraseCurrentPathOf(ho);
|
||||
eraseCurrentPathOf(ho);
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,10 +380,10 @@ int3 CPlayerInterface::repairScreenPos(int3 pos)
|
||||
pos.x = -CGI->mh->frameW;
|
||||
if(pos.y<-CGI->mh->frameH)
|
||||
pos.y = -CGI->mh->frameH;
|
||||
if(pos.x>CGI->mh->map->width - this->adventureInt->terrain.tilesw + CGI->mh->frameW)
|
||||
pos.x = CGI->mh->map->width - this->adventureInt->terrain.tilesw + CGI->mh->frameW;
|
||||
if(pos.y>CGI->mh->map->height - this->adventureInt->terrain.tilesh + CGI->mh->frameH)
|
||||
pos.y = CGI->mh->map->height - this->adventureInt->terrain.tilesh + CGI->mh->frameH;
|
||||
if(pos.x>CGI->mh->map->width - adventureInt->terrain.tilesw + CGI->mh->frameW)
|
||||
pos.x = CGI->mh->map->width - adventureInt->terrain.tilesw + CGI->mh->frameW;
|
||||
if(pos.y>CGI->mh->map->height - adventureInt->terrain.tilesh + CGI->mh->frameH)
|
||||
pos.y = CGI->mh->map->height - adventureInt->terrain.tilesh + CGI->mh->frameH;
|
||||
return pos;
|
||||
}
|
||||
void CPlayerInterface::heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val)
|
||||
@ -733,7 +736,7 @@ void CPlayerInterface::battleStacksEffectsSet(SetStackEffect & sse)
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
battleInt->battleStacksEffectsSet(sse);
|
||||
}
|
||||
void CPlayerInterface::battleStacksAttacked(std::set<BattleStackAttacked> & bsa)
|
||||
void CPlayerInterface::battleStacksAttacked(std::vector<BattleStackAttacked> & bsa)
|
||||
{
|
||||
if(LOCPLINT != this)
|
||||
{ //another local interface should do this
|
||||
@ -746,7 +749,7 @@ void CPlayerInterface::battleStacksAttacked(std::set<BattleStackAttacked> & bsa)
|
||||
|
||||
|
||||
std::vector<SStackAttackedInfo> arg;
|
||||
for(std::set<BattleStackAttacked>::iterator i = bsa.begin(); i != bsa.end(); i++)
|
||||
for(std::vector<BattleStackAttacked>::iterator i = bsa.begin(); i != bsa.end(); i++)
|
||||
{
|
||||
if(i->isEffect() && i->effect != 12) //and not armageddon
|
||||
{
|
||||
@ -788,7 +791,7 @@ void CPlayerInterface::battleAttack(BattleAttack *ba)
|
||||
|
||||
if(ba->shot())
|
||||
{
|
||||
for(std::set<BattleStackAttacked>::iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++)
|
||||
for(std::vector<BattleStackAttacked>::iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++)
|
||||
battleInt->stackIsShooting(ba->stackAttacking,cb->battleGetPos(i->stackAttacked), i->stackAttacked);
|
||||
}
|
||||
else
|
||||
@ -1169,7 +1172,7 @@ void CPlayerInterface::newObject( const CGObjectInstance * obj )
|
||||
|
||||
void CPlayerInterface::centerView (int3 pos, int focusTime)
|
||||
{
|
||||
LOCPLINT->adventureInt->centerOn (pos);
|
||||
adventureInt->centerOn (pos);
|
||||
if(focusTime)
|
||||
{
|
||||
bool activeAdv = (GH.topInt() == adventureInt && adventureInt->isActive());
|
||||
@ -1789,3 +1792,74 @@ SystemOptions::SystemOptions()
|
||||
printMouseShadow = true;
|
||||
showQueue = true;
|
||||
}
|
||||
|
||||
void CPlayerInterface::eraseCurrentPathOf( const CGHeroInstance * ho )
|
||||
{
|
||||
assert(vstd::contains(paths, ho));
|
||||
assert(ho == adventureInt->selection);
|
||||
|
||||
paths.erase(ho);
|
||||
adventureInt->terrain.currentPath = NULL;
|
||||
}
|
||||
|
||||
CGPath * CPlayerInterface::getAndVerifyPath(const CGHeroInstance * h)
|
||||
{
|
||||
if(vstd::contains(paths,h)) //hero has assigned path
|
||||
{
|
||||
CGPath &path = paths[h];
|
||||
if(!path.nodes.size())
|
||||
{
|
||||
tlog3 << "Warning: empty path found...\n";
|
||||
paths.erase(h);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(h->getPosition(false) == path.startPos());
|
||||
//update the hero path in case of something has changed on map
|
||||
if(LOCPLINT->cb->getPath2(path.endPos(), path))
|
||||
return &path;
|
||||
else
|
||||
paths.erase(h);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CPlayerInterface::acceptTurn()
|
||||
{
|
||||
waitWhileDialog();
|
||||
|
||||
if(howManyPeople > 1)
|
||||
adventureInt->startTurn();
|
||||
|
||||
boost::unique_lock<boost::recursive_mutex> un(*pim);
|
||||
for(std::map<int,SDL_Surface*>::iterator i=graphics->heroWins.begin(); i!=graphics->heroWins.end();i++) //redraw hero infoboxes
|
||||
SDL_FreeSurface(i->second);
|
||||
graphics->heroWins.clear();
|
||||
std::vector <const CGHeroInstance *> hh = cb->getHeroesInfo(false);
|
||||
for(int i=0;i<hh.size();i++)
|
||||
{
|
||||
SDL_Surface * pom = infoWin(hh[i]);
|
||||
graphics->heroWins.insert(std::pair<int,SDL_Surface*>(hh[i]->subID,pom));
|
||||
}
|
||||
|
||||
/* TODO: This isn't quite right. First day in game should play
|
||||
* NEWDAY. And we don't play NEWMONTH. */
|
||||
int day = cb->getDate(1);
|
||||
if (day != 1)
|
||||
CGI->soundh->playSound(soundBase::newDay);
|
||||
else
|
||||
CGI->soundh->playSound(soundBase::newWeek);
|
||||
|
||||
adventureInt->infoBar.newDay(day);
|
||||
|
||||
//select first hero if available.
|
||||
//TODO: check if hero is slept
|
||||
if(wanderingHeroes.size())
|
||||
adventureInt->select(wanderingHeroes[0]);
|
||||
else
|
||||
adventureInt->select(adventureInt->townList.items[0]);
|
||||
|
||||
adventureInt->showAll(screen);
|
||||
}
|
@ -121,7 +121,6 @@ public:
|
||||
|
||||
SystemOptions sysOpts;
|
||||
|
||||
CAdvMapInt * adventureInt;
|
||||
CCastleInterface * castleInt; //NULL if castle window isn't opened
|
||||
static CBattleInterface * battleInt; //NULL if no battle
|
||||
FPSmanager * mainFPSmng; //to keep const framerate
|
||||
@ -134,6 +133,7 @@ public:
|
||||
|
||||
|
||||
std::vector<const CGHeroInstance *> wanderingHeroes; //our heroes on the adventure map (not the garrisoned ones)
|
||||
std::map<const CGHeroInstance *, CGPath> paths; //maps hero => selected path in adventure map
|
||||
|
||||
void update();
|
||||
void recreateWanderingHeroes();
|
||||
@ -186,7 +186,7 @@ public:
|
||||
void battleStackMoved(int ID, int dest, int distance, bool end);
|
||||
void battleSpellCast(SpellCast *sc);
|
||||
void battleStacksEffectsSet(SetStackEffect & sse); //called when a specific effect is set to stacks
|
||||
void battleStacksAttacked(std::set<BattleStackAttacked> & bsa);
|
||||
void battleStacksAttacked(std::vector<BattleStackAttacked> & bsa);
|
||||
void battleStart(CCreatureSet *army1, CCreatureSet *army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
|
||||
void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
|
||||
void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks); //called when stacks are healed / resurrected
|
||||
@ -209,10 +209,14 @@ public:
|
||||
int3 repairScreenPos(int3 pos); //returns position closest to pos we can center screen on
|
||||
void showInfoDialog(const std::string &text, const std::vector<SComponent*> & components = std::vector<SComponent*>(), int soundID = 0);
|
||||
void showYesNoDialog(const std::string &text, const std::vector<SComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool DelComps); //deactivateCur - whether current main interface should be deactivated; delComps - if components will be deleted on window close
|
||||
|
||||
bool moveHero(const CGHeroInstance *h, CGPath path);
|
||||
void initMovement(const TryMoveHero &details, const CGHeroInstance * ho, const int3 &hp );//initializing objects and performing first step of move
|
||||
void movementPxStep( const TryMoveHero &details, int i, const int3 &hp, const CGHeroInstance * ho );//performing step of movement
|
||||
void finishMovement( const TryMoveHero &details, const int3 &hp, const CGHeroInstance * ho ); //finish movement
|
||||
void eraseCurrentPathOf( const CGHeroInstance * ho );
|
||||
CGPath *getAndVerifyPath( const CGHeroInstance * h );
|
||||
void acceptTurn(); //used during hot seat after your turn message is closed
|
||||
|
||||
CPlayerInterface(int Player, int serial);//c-tor
|
||||
~CPlayerInterface();//d-tor
|
||||
|
@ -46,6 +46,12 @@
|
||||
namespace fs = boost::filesystem;
|
||||
using boost::bind;
|
||||
using boost::ref;
|
||||
|
||||
#if _MSC_VER >= 1600
|
||||
#define bind boost::bind
|
||||
#define ref boost::ref
|
||||
#endif
|
||||
|
||||
void startGame(StartInfo * options);
|
||||
|
||||
CGPreGame * CGP;
|
||||
@ -2090,7 +2096,7 @@ CBonusSelection::CBonusSelection( const CCampaign * _ourCampaign, int _whichMap
|
||||
blitAt(panel, 456, 6, background);
|
||||
|
||||
startB = new AdventureMapButton("", "", 0 /*cb*/, 475, 536, "SCNRBEG.DEF", SDLK_RETURN);
|
||||
backB = new AdventureMapButton("", "", boost::bind(&CBonusSelection::goBack, this), 624, 536, "SCNRBACK.DEF", SDLK_ESCAPE);
|
||||
backB = new AdventureMapButton("", "", bind(&CBonusSelection::goBack, this), 624, 536, "SCNRBACK.DEF", SDLK_ESCAPE);
|
||||
|
||||
//campaign name
|
||||
if (ourCampaign->header.name.length())
|
||||
|
@ -51,7 +51,7 @@ void SpellbookInteractiveArea::clickLeft(tribool down, bool previousState)
|
||||
|
||||
void SpellbookInteractiveArea::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
myInt->adventureInt->handleRightClick(textOnRclick, down, this);
|
||||
adventureInt->handleRightClick(textOnRclick, down, this);
|
||||
}
|
||||
|
||||
void SpellbookInteractiveArea::hover(bool on)
|
||||
|
@ -91,6 +91,7 @@ public:
|
||||
|
||||
void CClient::init()
|
||||
{
|
||||
hotSeat = false;
|
||||
connectionHandler = NULL;
|
||||
pathInfo = NULL;
|
||||
applier = new CCLApplier;
|
||||
@ -196,6 +197,7 @@ void CClient::endGame()
|
||||
GH.topInt()->deactivate();
|
||||
GH.listInt.clear();
|
||||
GH.objsToBlit.clear();
|
||||
GH.statusbar = NULL;
|
||||
tlog0 << "Removed GUI." << std::endl;
|
||||
|
||||
delete CGI->mh;
|
||||
@ -301,25 +303,6 @@ void CClient::loadGame( const std::string & fname )
|
||||
CLoadFile lf(fname + ".vcgm1");
|
||||
lf >> *this;
|
||||
}
|
||||
//for (size_t i=0; i<gs->scenarioOps->playerInfos.size();++i) //initializing interfaces for players
|
||||
//{
|
||||
// ui8 color = gs->scenarioOps->playerInfos[i].color;
|
||||
// CCallback *cb = new CCallback(gs,color,this);
|
||||
// if(!gs->scenarioOps->playerInfos[i].human) {
|
||||
// playerint[color] = static_cast<CGameInterface*>(CAIHandler::getNewAI(cb,conf.cc.defaultAI));
|
||||
// }
|
||||
// else {
|
||||
// playerint[color] = new CPlayerInterface(color,i);
|
||||
// }
|
||||
// gs->currentPlayer = color;
|
||||
// playerint[color]->init(cb);
|
||||
// tlog0 <<"Setting up interface for player "<< (int)color <<": "<<tmh.getDif()<<std::endl;
|
||||
//}
|
||||
//playerint[255] = CAIHandler::getNewAI(cb,conf.cc.defaultAI);
|
||||
//playerint[255]->init(new CCallback(gs,255,this));
|
||||
//tlog0 <<"Setting up interface for neutral \"player\"" << tmh.getDif() << std::endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int CClient::getCurrentPlayer()
|
||||
@ -416,19 +399,26 @@ void CClient::newGame( CConnection *con, StartInfo *si )
|
||||
pathInfo = new CPathsInfo(int3(mapa->width, mapa->height, mapa->twoLevel+1));
|
||||
tlog0 <<"Initializing mapHandler (together): "<<tmh.getDif()<<std::endl;
|
||||
|
||||
int humanPlayers = 0;
|
||||
for (size_t i=0; i<gs->scenarioOps->playerInfos.size();++i) //initializing interfaces for players
|
||||
{
|
||||
ui8 color = gs->scenarioOps->playerInfos[i].color;
|
||||
CCallback *cb = new CCallback(gs,color,this);
|
||||
if(!gs->scenarioOps->playerInfos[i].human) {
|
||||
if(!gs->scenarioOps->playerInfos[i].human)
|
||||
{
|
||||
playerint[color] = static_cast<CGameInterface*>(CAIHandler::getNewAI(cb,conf.cc.defaultAI));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
playerint[color] = new CPlayerInterface(color,i);
|
||||
humanPlayers++;
|
||||
}
|
||||
gs->currentPlayer = color;
|
||||
playerint[color]->init(cb);
|
||||
}
|
||||
|
||||
hotSeat = (humanPlayers > 1);
|
||||
|
||||
playerint[255] = CAIHandler::getNewAI(cb,conf.cc.defaultAI);
|
||||
playerint[255]->init(new CCallback(gs,255,this));
|
||||
}
|
||||
@ -451,6 +441,7 @@ void CClient::waitForServer()
|
||||
template <typename Handler>
|
||||
void CClient::serialize( Handler &h, const int version )
|
||||
{
|
||||
h & hotSeat;
|
||||
if(h.saving)
|
||||
{
|
||||
ui8 players = playerint.size();
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
CCallback *cb;
|
||||
std::set<CCallback*> callbacks; //callbacks given to player interfaces
|
||||
std::map<ui8,CGameInterface *> playerint;
|
||||
bool hotSeat;
|
||||
CConnection *serv;
|
||||
SharedMem *shared;
|
||||
BattleAction *curbaction;
|
||||
|
@ -953,7 +953,7 @@ SDL_Surface * SComponent::getImg()
|
||||
void SComponent::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
if(description.size())
|
||||
LOCPLINT->adventureInt->handleRightClick(description,down,this);
|
||||
adventureInt->handleRightClick(description,down,this);
|
||||
}
|
||||
void SComponent::activate()
|
||||
{
|
||||
@ -1159,7 +1159,7 @@ void CStatusBar::print(const std::string & text)
|
||||
if(LOCPLINT->cingconsole->enteredText == "" || text == LOCPLINT->cingconsole->enteredText) //for appropriate support for in-game console
|
||||
{
|
||||
current=text;
|
||||
show(GH.topInt()==LOCPLINT->adventureInt ? screen : screen2); //if there are now windows opened, update statusbar on screen, else to cache surface
|
||||
show(GH.topInt()==adventureInt ? screen : screen2); //if there are now windows opened, update statusbar on screen, else to cache surface
|
||||
}
|
||||
}
|
||||
|
||||
@ -1217,7 +1217,7 @@ void CList::fixPos()
|
||||
}
|
||||
|
||||
CHeroList::CHeroList(int Size)
|
||||
:CList(Size), heroes(LOCPLINT->wanderingHeroes)
|
||||
:CList(Size)
|
||||
{
|
||||
arrup = CDefHandler::giveDef(conf.go()->ac.hlistAU);
|
||||
arrdo = CDefHandler::giveDef(conf.go()->ac.hlistAD);
|
||||
@ -1248,7 +1248,7 @@ void CHeroList::init()
|
||||
{
|
||||
int w = pos.w+1, h = pos.h+4;
|
||||
bg = CSDL_Ext::newSurface(w,h,screen);
|
||||
SDL_BlitSurface(LOCPLINT->adventureInt->bg,&genRect(w,h,pos.x,pos.y),bg,&genRect(w,h,0,0));
|
||||
SDL_BlitSurface(adventureInt->bg,&genRect(w,h,pos.x,pos.y),bg,&genRect(w,h,0,0));
|
||||
}
|
||||
|
||||
void CHeroList::genList()
|
||||
@ -1267,16 +1267,16 @@ void CHeroList::select(int which)
|
||||
if (which<0)
|
||||
{
|
||||
selected = which;
|
||||
LOCPLINT->adventureInt->selection = NULL;
|
||||
LOCPLINT->adventureInt->terrain.currentPath = NULL;
|
||||
adventureInt->selection = NULL;
|
||||
adventureInt->terrain.currentPath = NULL;
|
||||
draw(screen);
|
||||
LOCPLINT->adventureInt->infoBar.draw(screen);
|
||||
adventureInt->infoBar.draw(screen);
|
||||
}
|
||||
if (which>=heroes.size())
|
||||
if (which>=LOCPLINT->wanderingHeroes.size())
|
||||
return;
|
||||
|
||||
selected = which;
|
||||
LOCPLINT->adventureInt->select(heroes[which]);
|
||||
adventureInt->select(LOCPLINT->wanderingHeroes[which]);
|
||||
}
|
||||
|
||||
void CHeroList::clickLeft(tribool down, bool previousState)
|
||||
@ -1295,7 +1295,7 @@ void CHeroList::clickLeft(tribool down, bool previousState)
|
||||
}
|
||||
else if(isItIn(&arrdop,GH.current->motion.x,GH.current->motion.y))
|
||||
{
|
||||
if(heroes.size()-from>SIZE)
|
||||
if(LOCPLINT->wanderingHeroes.size()-from>SIZE)
|
||||
{
|
||||
blitAt(arrdo->ourImages[1].bitmap,arrdop.x,arrdop.y);
|
||||
pressed = false;
|
||||
@ -1309,8 +1309,8 @@ void CHeroList::clickLeft(tribool down, bool previousState)
|
||||
int ny = hy/32;
|
||||
if (ny>=SIZE || ny<0)
|
||||
return;
|
||||
if ( (ny+from)==selected && (LOCPLINT->adventureInt->selection->ID == HEROI_TYPE))
|
||||
LOCPLINT->openHeroWindow(heroes[selected]);//print hero screen
|
||||
if ( (ny+from)==selected && (adventureInt->selection->ID == HEROI_TYPE))
|
||||
LOCPLINT->openHeroWindow(LOCPLINT->wanderingHeroes[selected]);//print hero screen
|
||||
select(ny+from);
|
||||
}
|
||||
else
|
||||
@ -1353,17 +1353,17 @@ void CHeroList::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
if(isItIn(&arrupp,GH.current->motion.x,GH.current->motion.y))
|
||||
{
|
||||
if (from>0)
|
||||
LOCPLINT->adventureInt->statusbar.print(CGI->generaltexth->zelp[303].first);
|
||||
adventureInt->statusbar.print(CGI->generaltexth->zelp[303].first);
|
||||
else
|
||||
LOCPLINT->adventureInt->statusbar.clear();
|
||||
adventureInt->statusbar.clear();
|
||||
return;
|
||||
}
|
||||
else if(isItIn(&arrdop,GH.current->motion.x,GH.current->motion.y))
|
||||
{
|
||||
if ((heroes.size()-from) > SIZE)
|
||||
LOCPLINT->adventureInt->statusbar.print(CGI->generaltexth->zelp[304].first);
|
||||
if ((LOCPLINT->wanderingHeroes.size()-from) > SIZE)
|
||||
adventureInt->statusbar.print(CGI->generaltexth->zelp[304].first);
|
||||
else
|
||||
LOCPLINT->adventureInt->statusbar.clear();
|
||||
adventureInt->statusbar.clear();
|
||||
return;
|
||||
}
|
||||
//if not buttons then heroes
|
||||
@ -1371,15 +1371,15 @@ void CHeroList::mouseMoved (const SDL_MouseMotionEvent & sEvent)
|
||||
hx-=pos.x;
|
||||
hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
|
||||
int ny = hy/32;
|
||||
if ((ny>SIZE || ny<0) || (from+ny>=heroes.size()))
|
||||
if ((ny>SIZE || ny<0) || (from+ny>=LOCPLINT->wanderingHeroes.size()))
|
||||
{
|
||||
LOCPLINT->adventureInt->statusbar.clear();
|
||||
adventureInt->statusbar.clear();
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> temp;
|
||||
temp.push_back(heroes[from+ny]->name);
|
||||
temp.push_back(heroes[from+ny]->type->heroClass->name);
|
||||
LOCPLINT->adventureInt->statusbar.print( processStr(CGI->generaltexth->allTexts[15],temp) );
|
||||
temp.push_back(LOCPLINT->wanderingHeroes[from+ny]->name);
|
||||
temp.push_back(LOCPLINT->wanderingHeroes[from+ny]->type->heroClass->name);
|
||||
adventureInt->statusbar.print( processStr(CGI->generaltexth->allTexts[15],temp) );
|
||||
//select(ny+from);
|
||||
}
|
||||
|
||||
@ -1390,11 +1390,11 @@ void CHeroList::clickRight(tribool down, bool previousState)
|
||||
/***************************ARROWS*****************************************/
|
||||
if(isItIn(&arrupp,GH.current->motion.x,GH.current->motion.y) && from>0)
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->generaltexth->zelp[303].second,down,this);
|
||||
adventureInt->handleRightClick(CGI->generaltexth->zelp[303].second,down,this);
|
||||
}
|
||||
else if(isItIn(&arrdop,GH.current->motion.x,GH.current->motion.y) && (heroes.size()-from>5))
|
||||
else if(isItIn(&arrdop,GH.current->motion.x,GH.current->motion.y) && (LOCPLINT->wanderingHeroes.size()-from>5))
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->generaltexth->zelp[304].second,down,this);
|
||||
adventureInt->handleRightClick(CGI->generaltexth->zelp[304].second,down,this);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1403,23 +1403,23 @@ void CHeroList::clickRight(tribool down, bool previousState)
|
||||
hx-=pos.x;
|
||||
hy-=pos.y; hy-=arrup->ourImages[0].bitmap->h;
|
||||
int ny = hy/32;
|
||||
if ((ny>SIZE || ny<0) || (from+ny>=heroes.size()))
|
||||
if ((ny>SIZE || ny<0) || (from+ny>=LOCPLINT->wanderingHeroes.size()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//show popup
|
||||
CInfoPopup * ip = new CInfoPopup(graphics->heroWins[heroes[from+ny]->subID],
|
||||
GH.current->motion.x-graphics->heroWins[heroes[from+ny]->subID]->w,
|
||||
GH.current->motion.y-graphics->heroWins[heroes[from+ny]->subID]->h,
|
||||
CInfoPopup * ip = new CInfoPopup(graphics->heroWins[LOCPLINT->wanderingHeroes[from+ny]->subID],
|
||||
GH.current->motion.x-graphics->heroWins[LOCPLINT->wanderingHeroes[from+ny]->subID]->w,
|
||||
GH.current->motion.y-graphics->heroWins[LOCPLINT->wanderingHeroes[from+ny]->subID]->h,
|
||||
false);
|
||||
GH.pushInt(ip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->generaltexth->zelp[303].second,down,this);
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->generaltexth->zelp[304].second,down,this);
|
||||
adventureInt->handleRightClick(CGI->generaltexth->zelp[303].second,down,this);
|
||||
adventureInt->handleRightClick(CGI->generaltexth->zelp[304].second,down,this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1434,18 +1434,18 @@ void CHeroList::keyPressed (const SDL_KeyboardEvent & key)
|
||||
void CHeroList::updateHList(const CGHeroInstance *toRemove)
|
||||
{
|
||||
if(toRemove) //remove specific hero
|
||||
heroes -= toRemove;
|
||||
LOCPLINT->wanderingHeroes -= toRemove;
|
||||
else
|
||||
LOCPLINT->recreateWanderingHeroes();
|
||||
|
||||
|
||||
if(selected >= heroes.size())
|
||||
select(heroes.size()-1);
|
||||
if(selected >= LOCPLINT->wanderingHeroes.size())
|
||||
select(LOCPLINT->wanderingHeroes.size()-1);
|
||||
|
||||
if(toRemove)
|
||||
{
|
||||
if(heroes.size() == 0)
|
||||
LOCPLINT->adventureInt->townList.select(0);
|
||||
if(LOCPLINT->wanderingHeroes.size() == 0)
|
||||
adventureInt->townList.select(0);
|
||||
else
|
||||
select(selected);
|
||||
}
|
||||
@ -1454,8 +1454,8 @@ void CHeroList::updateHList(const CGHeroInstance *toRemove)
|
||||
void CHeroList::updateMove(const CGHeroInstance* which) //draws move points bar
|
||||
{
|
||||
int ser = -1;
|
||||
for(int i=0; i<heroes.size() && ser<0; i++)
|
||||
if(heroes[i]->subID == which->subID)
|
||||
for(int i=0; i<LOCPLINT->wanderingHeroes.size() && ser<0; i++)
|
||||
if(LOCPLINT->wanderingHeroes[i]->subID == which->subID)
|
||||
ser = i;
|
||||
ser -= from;
|
||||
if(ser<0 || ser >= SIZE) return;
|
||||
@ -1468,14 +1468,14 @@ void CHeroList::draw(SDL_Surface * to)
|
||||
for (int iT=0+from;iT<SIZE+from;iT++)
|
||||
{
|
||||
int i = iT-from;
|
||||
if (iT>=heroes.size())
|
||||
if (iT>=LOCPLINT->wanderingHeroes.size())
|
||||
{
|
||||
blitAt(mobile->ourImages[0].bitmap,posmobx,posmoby+i*32,to);
|
||||
blitAt(mana->ourImages[0].bitmap,posmanx,posmany+i*32,to);
|
||||
blitAt(empty,posporx,pospory+i*32,to);
|
||||
continue;
|
||||
}
|
||||
const CGHeroInstance *cur = heroes[iT];
|
||||
const CGHeroInstance *cur = LOCPLINT->wanderingHeroes[iT];
|
||||
int pom = cur->movement / 100;
|
||||
if (pom>25) pom=25;
|
||||
if (pom<0) pom=0;
|
||||
@ -1486,7 +1486,7 @@ void CHeroList::draw(SDL_Surface * to)
|
||||
blitAt(mana->ourImages[pom].bitmap,posmanx,posmany+i*32,to); //mana
|
||||
SDL_Surface * temp = graphics->portraitSmall[cur->portrait];
|
||||
blitAt(temp,posporx,pospory+i*32,to);
|
||||
if ((selected == iT) && (LOCPLINT->adventureInt->selection->ID == HEROI_TYPE))
|
||||
if ((selected == iT) && (adventureInt->selection->ID == HEROI_TYPE))
|
||||
{
|
||||
blitAt(selection,posporx,pospory+i*32,to);
|
||||
}
|
||||
@ -1497,7 +1497,7 @@ void CHeroList::draw(SDL_Surface * to)
|
||||
else
|
||||
blitAt(arrup->ourImages[2].bitmap,arrupp.x,arrupp.y,to);
|
||||
|
||||
if (heroes.size()-from > SIZE)
|
||||
if (LOCPLINT->wanderingHeroes.size()-from > SIZE)
|
||||
blitAt(arrdo->ourImages[0].bitmap,arrdop.x,arrdop.y,to);
|
||||
else
|
||||
blitAt(arrdo->ourImages[2].bitmap,arrdop.x,arrdop.y,to);
|
||||
@ -1505,7 +1505,7 @@ void CHeroList::draw(SDL_Surface * to)
|
||||
|
||||
int CHeroList::getPosOfHero(const CGHeroInstance* h)
|
||||
{
|
||||
return vstd::findPos(heroes, h, std::equal_to<const CGHeroInstance*>());
|
||||
return vstd::findPos(LOCPLINT->wanderingHeroes, h, std::equal_to<const CGHeroInstance*>());
|
||||
}
|
||||
|
||||
void CHeroList::show( SDL_Surface * to )
|
||||
@ -1515,7 +1515,7 @@ void CHeroList::show( SDL_Surface * to )
|
||||
|
||||
int CHeroList::size()
|
||||
{
|
||||
return heroes.size();
|
||||
return LOCPLINT->wanderingHeroes.size();
|
||||
}
|
||||
|
||||
CTownList::~CTownList()
|
||||
@ -1634,9 +1634,9 @@ void CTownList::clickLeft(tribool down, bool previousState)
|
||||
int ny = hy/32;
|
||||
if (ny>=SIZE || ny<0)
|
||||
return;
|
||||
if(GH.topInt() == LOCPLINT->adventureInt
|
||||
if(GH.topInt() == adventureInt
|
||||
&& (ny+from)==selected
|
||||
&& LOCPLINT->adventureInt->selection->ID == TOWNI_TYPE
|
||||
&& adventureInt->selection->ID == TOWNI_TYPE
|
||||
)
|
||||
LOCPLINT->openTownWindow(items[selected]);//print town screen
|
||||
else
|
||||
@ -1685,11 +1685,11 @@ void CTownList::clickRight(tribool down, bool previousState)
|
||||
/***************************ARROWS*****************************************/
|
||||
if(isItIn(&arrupp,GH.current->motion.x,GH.current->motion.y) && from>0)
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->generaltexth->zelp[306].second,down,this);
|
||||
adventureInt->handleRightClick(CGI->generaltexth->zelp[306].second,down,this);
|
||||
}
|
||||
else if(isItIn(&arrdop,GH.current->motion.x,GH.current->motion.y) && (items.size()-from>5))
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->generaltexth->zelp[307].second,down,this);
|
||||
adventureInt->handleRightClick(CGI->generaltexth->zelp[307].second,down,this);
|
||||
}
|
||||
//if not buttons then towns
|
||||
int hx = GH.current->motion.x, hy = GH.current->motion.y;
|
||||
@ -1711,8 +1711,8 @@ void CTownList::clickRight(tribool down, bool previousState)
|
||||
}
|
||||
else
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->generaltexth->zelp[306].second,down,this);
|
||||
LOCPLINT->adventureInt->handleRightClick(CGI->generaltexth->zelp[307].second,down,this);
|
||||
adventureInt->handleRightClick(CGI->generaltexth->zelp[306].second,down,this);
|
||||
adventureInt->handleRightClick(CGI->generaltexth->zelp[307].second,down,this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1737,7 +1737,7 @@ void CTownList::draw(SDL_Surface * to)
|
||||
|
||||
blitAt(graphics->getPic(items[iT]->subID,items[iT]->hasFort(),items[iT]->builded),posporx,pospory+i*32,to);
|
||||
|
||||
if ((selected == iT) && (LOCPLINT->adventureInt->selection->ID == TOWNI_TYPE))
|
||||
if ((selected == iT) && (adventureInt->selection->ID == TOWNI_TYPE))
|
||||
{
|
||||
blitAt(graphics->getPic(-2),posporx,pospory+i*32,to);
|
||||
}
|
||||
@ -3220,8 +3220,8 @@ void CTavernWindow::HeroPortrait::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
if(down)
|
||||
{
|
||||
LOCPLINT->adventureInt->heroWindow->setHero(h);
|
||||
GH.pushInt(new CRClickPopupInt(LOCPLINT->adventureInt->heroWindow,false));
|
||||
adventureInt->heroWindow->setHero(h);
|
||||
GH.pushInt(new CRClickPopupInt(adventureInt->heroWindow,false));
|
||||
}
|
||||
}
|
||||
|
||||
@ -3433,7 +3433,7 @@ void CInGameConsole::keyPressed (const SDL_KeyboardEvent & key)
|
||||
void CInGameConsole::startEnteringText()
|
||||
{
|
||||
enteredText = "_";
|
||||
if(GH.topInt() == LOCPLINT->adventureInt)
|
||||
if(GH.topInt() == adventureInt)
|
||||
{
|
||||
GH.statusbar->print(enteredText);
|
||||
}
|
||||
@ -3454,7 +3454,7 @@ void CInGameConsole::endEnteringText(bool printEnteredText)
|
||||
print(txt);
|
||||
}
|
||||
enteredText = "";
|
||||
if(GH.topInt() == LOCPLINT->adventureInt)
|
||||
if(GH.topInt() == adventureInt)
|
||||
{
|
||||
GH.statusbar->clear();
|
||||
}
|
||||
@ -3467,7 +3467,7 @@ void CInGameConsole::endEnteringText(bool printEnteredText)
|
||||
|
||||
void CInGameConsole::refreshEnteredText()
|
||||
{
|
||||
if(GH.topInt() == LOCPLINT->adventureInt)
|
||||
if(GH.topInt() == adventureInt)
|
||||
{
|
||||
GH.statusbar->print(enteredText);
|
||||
}
|
||||
@ -3558,8 +3558,8 @@ CRClickPopupInt::~CRClickPopupInt()
|
||||
{
|
||||
//workaround for hero window issue - if it's our interface, call dispose to properly reset it's state
|
||||
//TODO? it might be better to rewrite hero window so it will bee newed/deleted on opening / closing (not effort-worthy now, but on some day...?)
|
||||
if(LOCPLINT && inner == LOCPLINT->adventureInt->heroWindow)
|
||||
LOCPLINT->adventureInt->heroWindow->dispose();
|
||||
if(LOCPLINT && inner == adventureInt->heroWindow)
|
||||
adventureInt->heroWindow->dispose();
|
||||
|
||||
if(delInner)
|
||||
delete inner;
|
||||
@ -3880,7 +3880,7 @@ void LRClickableAreaWText::clickLeft(tribool down, bool previousState)
|
||||
}
|
||||
void LRClickableAreaWText::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(text, down, this);
|
||||
adventureInt->handleRightClick(text, down, this);
|
||||
}
|
||||
void LRClickableAreaWText::activate()
|
||||
{
|
||||
@ -3918,7 +3918,7 @@ void LRClickableAreaWTextComp::clickLeft(tribool down, bool previousState)
|
||||
}
|
||||
void LRClickableAreaWTextComp::clickRight(tribool down, bool previousState)
|
||||
{
|
||||
LOCPLINT->adventureInt->handleRightClick(text, down, this);
|
||||
adventureInt->handleRightClick(text, down, this);
|
||||
}
|
||||
void LRClickableAreaWTextComp::activate()
|
||||
{
|
||||
@ -4751,8 +4751,8 @@ CPuzzleWindow::CPuzzleWindow(const int3 &grailPos, float discoveredRatio)
|
||||
//printing necessary things to background
|
||||
int3 moveInt = int3(8, 9, 0);
|
||||
CGI->mh->terrainRect
|
||||
(grailPos - moveInt, LOCPLINT->adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim,
|
||||
(grailPos - moveInt, adventureInt->anim,
|
||||
&LOCPLINT->cb->getVisibilityMap(), true, adventureInt->heroAnim,
|
||||
background, &genRect(544, 591, 8, 8), 0, 0, true);
|
||||
|
||||
//printing X sign
|
||||
|
@ -358,7 +358,6 @@ public:
|
||||
CDefHandler *mobile, *mana; //mana and movement indicators
|
||||
int posmobx, posporx, posmanx, posmoby, pospory, posmany;
|
||||
|
||||
std::vector<const CGHeroInstance *> &heroes; //points to LOCPLINT->wandering heroes
|
||||
CHeroList(int Size); //c-tor
|
||||
int getPosOfHero(const CGHeroInstance* h); //hero's position on list
|
||||
void genList();
|
||||
|
@ -525,8 +525,8 @@ SDL_Surface * Graphics::getPic(int ID, bool fort, bool builded)
|
||||
|
||||
void Graphics::blueToPlayersAdv(SDL_Surface * sur, int player)
|
||||
{
|
||||
if(player==1) //it is actually blue...
|
||||
return;
|
||||
// if(player==1) //it is actually blue...
|
||||
// return;
|
||||
if(sur->format->BitsPerPixel == 8)
|
||||
{
|
||||
SDL_Color *palette = NULL;
|
||||
|
@ -469,8 +469,8 @@ void BattleStackMoved::applyFirstCl( CClient *cl )
|
||||
|
||||
void BattleStackAttacked::applyCl( CClient *cl )
|
||||
{
|
||||
std::set<BattleStackAttacked> bsa;
|
||||
bsa.insert(*this);
|
||||
std::vector<BattleStackAttacked> bsa;
|
||||
bsa.push_back(*this);
|
||||
|
||||
INTERFACE_CALL_IF_PRESENT(GS(cl)->curB->side1,battleStacksAttacked,bsa);
|
||||
INTERFACE_CALL_IF_PRESENT(GS(cl)->curB->side2,battleStacksAttacked,bsa);
|
||||
|
@ -164,7 +164,7 @@ void CArtHandler::loadArtifacts(bool onlyTxt)
|
||||
for(int j=0;j<slots.size();j++)
|
||||
{
|
||||
loadToIt(pom,buf,it,4);
|
||||
if(pom[0]=='x')
|
||||
if(pom.size() && pom[0]=='x')
|
||||
nart.possibleSlots.push_back(slots[j]);
|
||||
}
|
||||
loadToIt(pom,buf,it,4);
|
||||
|
@ -28,7 +28,7 @@ std::string readTo(const std::string &in, int &it, char end)
|
||||
|
||||
void trimQuotation(std::string &op)
|
||||
{
|
||||
if(op[0] == '\"' && op[op.size()-1] == '\"')
|
||||
if(op.length() && op[0] == '\"' && op[op.size()-1] == '\"')
|
||||
op = op.substr(1,op.size()-2);
|
||||
}
|
||||
|
||||
@ -175,8 +175,7 @@ void CGeneralTextHandler::load()
|
||||
{
|
||||
std::string &str = j->second.second;
|
||||
boost::algorithm::trim(str);
|
||||
if(str[0] == '"' && str[str.size()-1] == '"')
|
||||
str = str.substr(1,str.size()-2);
|
||||
trimQuotation(str);
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,7 +520,7 @@ void CGeneralTextHandler::load()
|
||||
do //dump comments and empty lines
|
||||
{
|
||||
loadToIt(nameBuf, buf, it, 3);
|
||||
} while (nameBuf[0] != '/');
|
||||
} while (!nameBuf.size() || nameBuf[0] != '/');
|
||||
do //actual names
|
||||
{
|
||||
loadToIt(nameBuf, buf, it, 3);
|
||||
|
@ -164,7 +164,7 @@ void CSoundHandler::initCreaturesSounds(std::vector<CCreature> &creatures)
|
||||
|
||||
str >> cname >> attack >> defend >> killed >> move >> shoot >> wince >> ext1 >> ext2;
|
||||
|
||||
if (cname[0] == '#')
|
||||
if (!line.size() || cname[0] == '#')
|
||||
// That's a comment. Discard.
|
||||
continue;
|
||||
|
||||
|
@ -189,6 +189,11 @@ std::set<ui16> CSpell::rangeInHexes(unsigned int centralHex, ui8 schoolLvl ) con
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool startsWithX(const std::string &s)
|
||||
{
|
||||
return s.size() && s[0] == 'x';
|
||||
}
|
||||
|
||||
void CSpellHandler::loadSpells()
|
||||
{
|
||||
std::string buf = bitmaph->getTextFile("SPTRAITS.TXT"), pom;
|
||||
@ -224,15 +229,14 @@ void CSpellHandler::loadSpells()
|
||||
|
||||
loadToIt(nsp.abbName,buf,i,4);
|
||||
loadToIt(nsp.level,buf,i,4);
|
||||
|
||||
loadToIt(pom,buf,i,4);
|
||||
nsp.earth = pom[0]=='x' ? true : false;
|
||||
nsp.earth = startsWithX(pom);
|
||||
loadToIt(pom,buf,i,4);
|
||||
nsp.water = pom[0]=='x' ? true : false;
|
||||
nsp.water = startsWithX(pom);
|
||||
loadToIt(pom,buf,i,4);
|
||||
nsp.fire = pom[0]=='x' ? true : false;
|
||||
nsp.fire = startsWithX(pom);
|
||||
loadToIt(pom,buf,i,4);
|
||||
nsp.air = pom[0]=='x' ? true : false;
|
||||
nsp.air = startsWithX(pom);
|
||||
|
||||
nsp.costs.resize(4);
|
||||
for (int z = 0; z < 4 ; z++)
|
||||
|
@ -930,7 +930,7 @@ struct BattleAttack : public CPackForClient//3006
|
||||
DLL_EXPORT void applyGs(CGameState *gs);
|
||||
void applyCl(CClient *cl);
|
||||
|
||||
std::set<BattleStackAttacked> bsa;
|
||||
std::vector<BattleStackAttacked> bsa;
|
||||
ui32 stackAttacking;
|
||||
ui8 flags;
|
||||
|
||||
@ -1010,7 +1010,7 @@ struct SetStackEffect : public CPackForClient //3010
|
||||
DLL_EXPORT void applyGs(CGameState *gs);
|
||||
void applyCl(CClient *cl);
|
||||
|
||||
std::set<ui32> stacks; //affected stacks (IDs)
|
||||
std::vector<ui32> stacks; //affected stacks (IDs)
|
||||
CStack::StackEffect effect; //type of effect
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
@ -1024,7 +1024,7 @@ struct StacksInjured : public CPackForClient //3011
|
||||
DLL_EXPORT void applyGs(CGameState *gs);
|
||||
void applyCl(CClient *cl);
|
||||
|
||||
std::set<BattleStackAttacked> stacks;
|
||||
std::vector<BattleStackAttacked> stacks;
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & stacks;
|
||||
|
@ -775,7 +775,7 @@ DLL_EXPORT void BattleAttack::applyGs( CGameState *gs )
|
||||
}
|
||||
}
|
||||
|
||||
for(std::set<BattleStackAttacked>::const_iterator it = bsa.begin(); it != bsa.end(); ++it)
|
||||
for(std::vector<BattleStackAttacked>::const_iterator it = bsa.begin(); it != bsa.end(); ++it)
|
||||
{
|
||||
CStack * stack = gs->curB->getStack(it->stackAttacked, false);
|
||||
|
||||
|
@ -588,13 +588,8 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
|
||||
{
|
||||
bat.bsa.clear();
|
||||
bat.stackAttacking = att->ID;
|
||||
std::set<BattleStackAttacked>::iterator i = bat.bsa.insert(BattleStackAttacked()).first;
|
||||
#ifdef __GNUC__
|
||||
BattleStackAttacked *bsa = (BattleStackAttacked *)&*i;
|
||||
#else
|
||||
BattleStackAttacked *bsa = &*i;
|
||||
#endif
|
||||
|
||||
bat.bsa.push_back(BattleStackAttacked());
|
||||
BattleStackAttacked *bsa = &bat.bsa.back();
|
||||
bsa->stackAttacked = def->ID;
|
||||
bsa->attackerID = att->ID;
|
||||
bsa->damageAmount = BattleInfo::calculateDmg(att, def, gs->battleGetOwner(att->ID), gs->battleGetOwner(def->ID), bat.shot(), distance);//counting dealt damage
|
||||
@ -3403,7 +3398,7 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
|
||||
bsa.stackAttacked = (*it)->ID;
|
||||
bsa.attackerID = -1;
|
||||
prepareAttacked(bsa,*it);
|
||||
si.stacks.insert(bsa);
|
||||
si.stacks.push_back(bsa);
|
||||
}
|
||||
if(!si.stacks.empty())
|
||||
sendAndApply(&si);
|
||||
@ -3443,7 +3438,7 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
|
||||
{
|
||||
if(vstd::contains(sc.resisted, (*it)->ID)) //this creature resisted the spell
|
||||
continue;
|
||||
sse.stacks.insert((*it)->ID);
|
||||
sse.stacks.push_back((*it)->ID);
|
||||
}
|
||||
sse.effect.id = ba.additionalInfo;
|
||||
sse.effect.level = h->getSpellSchoolLevel(s);
|
||||
|
Loading…
Reference in New Issue
Block a user