1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

* make compatible with boost 1.36.0 (there was breaking change in boost::function)

* randomizing spells in towns
* fixed reading forbidden structures
* support for heroes starting in town garrisons
* hopefully fixed problems with wrong town defs (village/fort/capitol)
* moved CSpellHandler.* to VCMI_Lib (project files must be updated)
* redone reading spell info
* added missing features to the fort screen
* minor improvements

* partially done mage guild screen
This commit is contained in:
Michał W. Urbańczyk
2008-08-20 06:57:53 +00:00
parent 65999f4429
commit 22ade5efbe
35 changed files with 453 additions and 485 deletions

View File

@@ -1,25 +1,26 @@
#include "stdafx.h" #include "stdafx.h"
#include "CCastleInterface.h"
#include "hch/CObjectHandler.h"
#include "CGameInfo.h"
#include "hch/CLodHandler.h"
#include "SDL_Extensions.h"
#include "CAdvmapInterface.h"
#include "hch/CTownHandler.h"
#include "AdventureMapButton.h" #include "AdventureMapButton.h"
#include "CAdvmapInterface.h"
#include "CCallback.h"
#include "CCastleInterface.h"
#include "CGameInfo.h"
#include "CHeroWindow.h"
#include "CMessage.h"
#include "SDL_Extensions.h"
#include "client/CCreatureAnimation.h"
#include "client/Graphics.h"
#include "hch/CBuildingHandler.h" #include "hch/CBuildingHandler.h"
#include "hch/CDefHandler.h" #include "hch/CDefHandler.h"
#include <sstream>
#include "CMessage.h"
#include "hch/CGeneralTextHandler.h" #include "hch/CGeneralTextHandler.h"
#include "CCallback.h" #include "hch/CLodHandler.h"
#include "client/Graphics.h" #include "hch/CObjectHandler.h"
#include "client/CCreatureAnimation.h" #include "hch/CSpellHandler.h"
#include "CHeroWindow.h" #include "hch/CTownHandler.h"
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <boost/assign/std/vector.hpp> #include <boost/assign/std/vector.hpp>
#include <cmath> #include <cmath>
#include <sstream>
using namespace boost::assign; using namespace boost::assign;
using namespace CSDL_Ext; using namespace CSDL_Ext;
@@ -469,6 +470,12 @@ void CCastleInterface::buildingClicked(int building)
{ {
switch(building) switch(building)
{ {
case 0: case 1: case 2: case 3: case 4:
{
deactivate();
(new CMageGuildScreen(this))->activate();
break;
}
case 7: case 8: case 9: case 7: case 8: case 9:
{ {
CFortScreen *fs = new CFortScreen(this); CFortScreen *fs = new CFortScreen(this);
@@ -944,10 +951,6 @@ CHallInterface::CHallInterface(CCastleInterface * owner)
} }
//TODO: check if capital is already built, check if there is water for shipyard //TODO: check if capital is already built, check if there is water for shipyard
break; break;
} }
} }
@@ -1205,6 +1208,8 @@ void CFortScreen::show( SDL_Surface * to)
} }
anim++; anim++;
exit->show(); exit->show();
resdatabar.show();
LOCPLINT->statusbar->show();
} }
void CFortScreen::activate() void CFortScreen::activate()
@@ -1324,12 +1329,13 @@ void CFortScreen::draw( CCastleInterface * owner, bool first)
} }
void CFortScreen::RecArea::clickLeft (tribool down) void CFortScreen::RecArea::clickLeft (tribool down)
{ {
if(!down) if(!down && pressedL)
{ {
LOCPLINT->curint->deactivate(); LOCPLINT->curint->deactivate();
CRecrutationWindow *rw = LOCPLINT->castleInt->showRecruitmentWindow(bid); CRecrutationWindow *rw = LOCPLINT->castleInt->showRecruitmentWindow(bid);
rw->buy->callback += boost::bind(&CFortScreen::draw, static_cast<CFortScreen*>(LOCPLINT->curint), LOCPLINT->castleInt, false); rw->buy->callback += boost::bind(&CFortScreen::draw, static_cast<CFortScreen*>(LOCPLINT->curint), LOCPLINT->castleInt, false);
} }
ClickableL::clickLeft(down);
} }
void CFortScreen::RecArea::activate() void CFortScreen::RecArea::activate()
{ {
@@ -1339,3 +1345,110 @@ void CFortScreen::RecArea::deactivate()
{ {
ClickableL::deactivate(); ClickableL::deactivate();
} }
CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner)
{
bg = BitmapHandler::loadBitmap("TPMAGE.bmp");
exit = new AdventureMapButton(CGI->townh->tcommands[8],"",boost::bind(&CMageGuildScreen::close,this),748,556,"TPMAGE1.DEF",false,NULL,false);
scrolls = CDefHandler::giveDefEss("SPELLSCR.DEF");
scrolls2 = CDefHandler::giveDefEss("TPMAGES.DEF");
SDL_Surface *view = BitmapHandler::loadBitmap(graphics->guildBgs[owner->town->subID]);
SDL_SetColorKey(view,SDL_SRCCOLORKEY,SDL_MapRGB(view->format,0,255,255));
positions.resize(5);
positions[0] += genRect(61,83,222,445), genRect(61,83,312,445), genRect(61,83,402,445), genRect(61,83,520,445), genRect(61,83,610,445), genRect(61,83,700,445);
positions[1] += genRect(61,83,48,53), genRect(61,83,48,147), genRect(61,83,48,241), genRect(61,83,48,335), genRect(61,83,48,429);
positions[2] += genRect(61,83,570,82), genRect(61,83,672,82), genRect(61,83,570,157), genRect(61,83,672,157);
positions[3] += genRect(61,83,183,42), genRect(61,83,183,148), genRect(61,83,183,253);
positions[4] += genRect(61,83,491,325), genRect(61,83,591,325);
blitAt(view,332,76,bg);
for(int i=0; i<owner->town->town->mageLevel; i++)
{
int sp = 5 - i; //how many spells are available at this level
if(owner->town->subID==2 && vstd::contains(owner->town->builtBuildings,22)) sp++; //magic library in tower
for(int j=0; j<sp; j++)
{
if(i < owner->town->mageGuildLevel())
{
spells.push_back(Scroll(&CGI->spellh->spells[owner->town->spells[i][j]]));
spells[spells.size()-1].pos = positions[i][j];
blitAt(scrolls->ourImages[owner->town->spells[i][j]].bitmap,positions[i][j],bg);
}
else
{
blitAt(scrolls2->ourImages[1].bitmap,positions[i][j],bg);
}
}
}
SDL_FreeSurface(view);
delete scrolls2;
}
CMageGuildScreen::~CMageGuildScreen()
{
delete exit;
delete scrolls;
SDL_FreeSurface(bg);
}
void CMageGuildScreen::close()
{
deactivate();
delete this;
LOCPLINT->castleInt->activate();
LOCPLINT->castleInt->showAll();
}
void CMageGuildScreen::show(SDL_Surface * to)
{
blitAt(bg,0,0);
resdatabar.show();
exit->show();
}
void CMageGuildScreen::activate()
{
LOCPLINT->objsToBlit += this;
LOCPLINT->castleInt->subInt = this;
exit->activate();
for(int i=0;i<spells.size();i++)
spells[i].activate();
}
void CMageGuildScreen::deactivate()
{
LOCPLINT->objsToBlit -= this;
exit->deactivate();
for(int i=0;i<spells.size();i++)
spells[i].deactivate();
}
void CMageGuildScreen::Scroll::clickLeft (tribool down)
{
}
void CMageGuildScreen::Scroll::clickRight (tribool down)
{
if(down)
{
CInfoPopup *vinya = new CInfoPopup();
vinya->free = true;
vinya->bitmap = CMessage::drawBoxTextBitmapSub
(LOCPLINT->playerID,
spell->descriptions[0],
static_cast<CMageGuildScreen*>(LOCPLINT->castleInt->subInt)->scrolls->ourImages[spell->id].bitmap,
spell->name);
vinya->pos.x = screen->w/2 - vinya->bitmap->w/2;
vinya->pos.y = screen->h/2 - vinya->bitmap->h/2;
vinya->activate();
}
}
void CMageGuildScreen::Scroll::hover(bool on)
{
}
void CMageGuildScreen::Scroll::activate()
{
ClickableL::activate();
ClickableR::activate();
Hoverable::activate();
}
void CMageGuildScreen::Scroll::deactivate()
{
ClickableL::deactivate();
ClickableR::deactivate();
Hoverable::deactivate();
}

View File

@@ -7,6 +7,7 @@ class CGTownInstance;
class CTownHandler; class CTownHandler;
class CHallInterface; class CHallInterface;
struct Structure; struct Structure;
class CSpell;
class AdventureMapButton; class AdventureMapButton;
class CBuildingRect : public Hoverable, public MotionInterested, public ClickableL, public ClickableR//, public TimeInterested class CBuildingRect : public Hoverable, public MotionInterested, public ClickableL, public ClickableR//, public TimeInterested
{ {
@@ -171,4 +172,36 @@ public:
void show(SDL_Surface * to=NULL); void show(SDL_Surface * to=NULL);
void activate(); void activate();
void deactivate(); void deactivate();
};
class CMageGuildScreen : public IShowActivable
{
public:
class Scroll : public ClickableL, public Hoverable, public ClickableR
{
public:
CSpell *spell;
Scroll(CSpell *Spell):spell(Spell){};
void clickLeft (tribool down);
void clickRight (tribool down);
void hover(bool on);
void activate();
void deactivate();
};
std::vector<std::vector<SDL_Rect> > positions;
SDL_Surface *bg;
CDefEssential *scrolls, *scrolls2;
AdventureMapButton *exit;
std::vector<Scroll> spells;
CMinorResDataBar resdatabar;
CMageGuildScreen(CCastleInterface * owner);
~CMageGuildScreen();
void close();
void show(SDL_Surface * to=NULL);
void activate();
void deactivate();
}; };

View File

@@ -34,7 +34,10 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
if (!dll) if (!dll)
{ {
std::cout << "Cannot open AI library ("<<dllname<<"). Throwing..."<<std::endl; std::cout << "Cannot open AI library ("<<dllname<<"). Throwing..."<<std::endl;
#ifdef _MSC_VER
throw new std::exception("Cannot open AI library"); throw new std::exception("Cannot open AI library");
#endif
throw new std::exception();
} }
//int len = dllname.size()+1; //int len = dllname.size()+1;
getName = (void(*)(char*))GetProcAddress(dll,"GetAiName"); getName = (void(*)(char*))GetProcAddress(dll,"GetAiName");
@@ -43,12 +46,12 @@ CGlobalAI * CAIHandler::getNewAI(CCallback * cb, std::string dllname)
; //TODO: handle AI library on Linux ; //TODO: handle AI library on Linux
#endif #endif
char * temp = new char[50]; char * temp = new char[50];
#if !defined(__amigaos4__) && !defined(__unix__) #if _WIN32
getName(temp); getName(temp);
#endif #endif
std::cout << "Loaded .dll with AI named " << temp << std::endl; std::cout << "Loaded .dll with AI named " << temp << std::endl;
delete temp; delete temp;
#if !defined(__amigaos4__) && !defined(__unix__) #if _WIN32
ret = getAI(); ret = getAI();
ret->init(cb); ret->init(cb);
#else #else

View File

@@ -54,8 +54,8 @@ public:
virtual void tileRevealed(int3 pos){}; virtual void tileRevealed(int3 pos){};
virtual void tileHidden(int3 pos){}; virtual void tileHidden(int3 pos){};
virtual void receivedResource(int type, int val){}; virtual void receivedResource(int type, int val){};
virtual void showInfoDialog(std::string &text, std::vector<Component*> &components){}; virtual void showInfoDialog(std::string &text, const std::vector<Component*> &components){};
virtual void showSelDialog(std::string &text, std::vector<Component*> &components, ui32 askID){}; virtual void showSelDialog(std::string &text, const std::vector<Component*> &components, ui32 askID){};
virtual void garrisonChanged(const CGObjectInstance * obj){}; virtual void garrisonChanged(const CGObjectInstance * obj){};
virtual void buildChanged(const CGTownInstance *town, int buildingID, int what){}; //what: 1 - built, 2 - demolished virtual void buildChanged(const CGTownInstance *town, int buildingID, int what){}; //what: 1 - built, 2 - demolished
virtual void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback)=0; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id virtual void heroGotLevel(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback)=0; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id

View File

@@ -7,6 +7,7 @@
#include "hch/CDefObjInfoHandler.h" #include "hch/CDefObjInfoHandler.h"
#include "hch/CArtHandler.h" #include "hch/CArtHandler.h"
#include "hch/CTownHandler.h" #include "hch/CTownHandler.h"
#include "hch/CSpellHandler.h"
#include "hch/CHeroHandler.h" #include "hch/CHeroHandler.h"
#include "hch/CObjectHandler.h" #include "hch/CObjectHandler.h"
#include "hch/CCreatureHandler.h" #include "hch/CCreatureHandler.h"
@@ -19,6 +20,8 @@
#include <boost/thread/shared_mutex.hpp> #include <boost/thread/shared_mutex.hpp>
boost::rand48 ran; boost::rand48 ran;
CGObjectInstance * createObject(int id, int subid, int3 pos, int owner) CGObjectInstance * createObject(int id, int subid, int3 pos, int owner)
{ {
CGObjectInstance * nobj; CGObjectInstance * nobj;
@@ -1018,6 +1021,8 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
vti->town = &VLC->townh->towns[vti->subID]; vti->town = &VLC->townh->towns[vti->subID];
if (vti->name.length()==0) // if town hasn't name we draw it if (vti->name.length()==0) // if town hasn't name we draw it
vti->name=vti->town->names[ran()%vti->town->names.size()]; vti->name=vti->town->names[ran()%vti->town->names.size()];
//init buildings
if(vti->builtBuildings.find(-50)!=vti->builtBuildings.end()) //give standard set of buildings if(vti->builtBuildings.find(-50)!=vti->builtBuildings.end()) //give standard set of buildings
{ {
vti->builtBuildings.erase(-50); vti->builtBuildings.erase(-50);
@@ -1027,6 +1032,39 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
if(ran()%2) if(ran()%2)
vti->builtBuildings.insert(31); vti->builtBuildings.insert(31);
} }
//init spells
vti->spells.resize(SPELL_LEVELS);
CSpell *s;
for(int z=0; z<vti->obligatorySpells.size();z++)
{
s = &VLC->spellh->spells[vti->obligatorySpells[z]];
vti->spells[s->level-1].push_back(s->id);
vti->possibleSpells -= s->id;
}
while(vti->possibleSpells.size())
{
ui32 total=0, sel=-1;
for(int ps=0;ps<vti->possibleSpells.size();ps++)
total += VLC->spellh->spells[vti->possibleSpells[ps]].probabilities[vti->subID];
int r = (total)? ran()%total : -1;
for(int ps=0; ps<vti->possibleSpells.size();ps++)
{
r -= VLC->spellh->spells[vti->possibleSpells[ps]].probabilities[vti->subID];
if(r<0)
{
sel = ps;
break;
}
}
if(sel<0)
sel=0;
CSpell *s = &VLC->spellh->spells[vti->possibleSpells[sel]];
vti->spells[s->level-1].push_back(s->id);
vti->possibleSpells -= s->id;
}
players[vti->getOwner()].towns.push_back(vti); players[vti->getOwner()].towns.push_back(vti);
} }
@@ -1048,7 +1086,7 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
} }
} }
//init visiting heroes //init visiting and garrisoned heroes
for(int l=0; l<k->second.heroes.size();l++) for(int l=0; l<k->second.heroes.size();l++)
{ {
for(int m=0; m<k->second.towns.size();m++) for(int m=0; m<k->second.towns.size();m++)
@@ -1057,9 +1095,21 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
if(vistile == k->second.heroes[l]->pos) if(vistile == k->second.heroes[l]->pos)
{ {
k->second.towns[m]->visitingHero = k->second.heroes[l]; k->second.towns[m]->visitingHero = k->second.heroes[l];
break; k->second.heroes[l]->visitedTown = k->second.towns[m];
k->second.heroes[l]->inTownGarrison = false;
goto mainplheloop;
}
else if(k->second.heroes[l]->pos == k->second.towns[m]->pos)
{
k->second.towns[m]->garrisonHero = k->second.heroes[l];
k->second.towns[m]->army = k->second.heroes[l]->army;
k->second.heroes[l]->visitedTown = k->second.towns[m];
k->second.heroes[l]->inTownGarrison = true;
k->second.heroes[l]->pos.x -= 1;
goto mainplheloop;
} }
} }
mainplheloop:;
} }
} }
} }

View File

@@ -2,7 +2,7 @@
#define CGAMESTATE_H #define CGAMESTATE_H
#include "global.h" #include "global.h"
#ifndef _MSC_VER #ifndef _MSC_VER
#include "../hch/CCreatureHandler.h" #include "hch/CCreatureHandler.h"
#include "lib/VCMI_Lib.h" #include "lib/VCMI_Lib.h"
#endif #endif
#include <set> #include <set>
@@ -152,7 +152,7 @@ private:
UpgradeInfo getUpgradeInfo(CArmedInstance *obj, int stackPos); UpgradeInfo getUpgradeInfo(CArmedInstance *obj, int stackPos);
public: public:
int getDate(int mode=0) const; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month int getDate(int mode=0) const; //mode=0 - total days in game, mode=1 - day of week, mode=2 - current week, mode=3 - current month
friend class CCallback; friend class CCallback;
friend class CPathfinder;; friend class CPathfinder;;
friend class CLuaCallback; friend class CLuaCallback;

View File

@@ -8,6 +8,7 @@
#include "SDL.h" #include "SDL.h"
#include "SDL_Extensions.h" #include "SDL_Extensions.h"
#include "CAdvmapInterface.h" #include "CAdvmapInterface.h"
#include "CCastleInterface.h"
#include "hch/CLodHandler.h" #include "hch/CLodHandler.h"
#include "AdventureMapButton.h" #include "AdventureMapButton.h"
#include "hch/CObjectHandler.h" #include "hch/CObjectHandler.h"
@@ -39,7 +40,7 @@ CHeroWindow::CHeroWindow(int playerColor):
garInt = NULL; garInt = NULL;
ourBar = new CStatusBar(72, 567, "ADROLLVR.bmp", 660); ourBar = new CStatusBar(72, 567, "ADROLLVR.bmp", 660);
quitButton = new AdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(), boost::bind(&CHeroWindow::quit,this), 674, 524, "hsbtns.def", false, NULL, false); quitButton = new AdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(), boost::function<void()>(), 674, 524, "hsbtns.def", false, NULL, false);
dismissButton = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), 519, 437, "hsbtns2.def", false, NULL, false); dismissButton = new AdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), 519, 437, "hsbtns2.def", false, NULL, false);
questlogButton = new AdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), 379, 437, "hsbtns4.def", false, NULL, false); questlogButton = new AdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), 379, 437, "hsbtns4.def", false, NULL, false);
@@ -509,24 +510,16 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
void CHeroWindow::quit() void CHeroWindow::quit()
{ {
for(int i=0; i<LOCPLINT->objsToBlit.size(); ++i) LOCPLINT->objsToBlit -= this;
{
if( dynamic_cast<CHeroWindow*>( LOCPLINT->objsToBlit[i] ) )
{
LOCPLINT->objsToBlit.erase(LOCPLINT->objsToBlit.begin()+i);
}
}
deactivate(); deactivate();
if(LOCPLINT->curint == LOCPLINT->castleInt)
LOCPLINT->castleInt->subInt = NULL;
LOCPLINT->curint->activate(); LOCPLINT->curint->activate();
SDL_FreeSurface(curBack); SDL_FreeSurface(curBack);
curBack = NULL; curBack = NULL;
/*for(int v=0; v<LOCPLINT->lclickable.size(); ++v)
{
if(dynamic_cast<CArtPlace*>(LOCPLINT->lclickable[v]))
LOCPLINT->lclickable.erase(LOCPLINT->lclickable.begin()+v);
}*/
for(int g=0; g<artWorn.size(); ++g) for(int g=0; g<artWorn.size(); ++g)
{ {
@@ -1052,8 +1045,7 @@ void LRClickableAreaWText::clickLeft(boost::logic::tribool down)
{ {
if(!down) if(!down)
{ {
std::vector<SComponent*> comp; LOCPLINT->showInfoDialog(text, std::vector<SComponent*>());
LOCPLINT->showInfoDialog(text, comp);
} }
} }
void LRClickableAreaWText::clickRight(boost::logic::tribool down) void LRClickableAreaWText::clickRight(boost::logic::tribool down)
@@ -1097,7 +1089,7 @@ void LRClickableAreaWTextComp::clickLeft(boost::logic::tribool down)
{ {
if((!down) && pressedL) if((!down) && pressedL)
{ {
std::vector<SComponent*> comp(1, new SComponent(SComponent::Etype(baseType), type, bonus)); std::vector<SComponent*> comp(1, new SComponent(SComponent::Etype(baseType), type, bonus));
LOCPLINT->showInfoDialog(text, comp); LOCPLINT->showInfoDialog(text, comp);
} }
ClickableL::clickLeft(down); ClickableL::clickLeft(down);

View File

@@ -80,7 +80,7 @@ public:
~CArtPlace(); ~CArtPlace();
}; };
class CHeroWindow: public IActivable, public IShowable, public virtual CIntObject class CHeroWindow: public IShowActivable, public virtual CIntObject
{ {
SDL_Surface * background, * curBack; SDL_Surface * background, * curBack;
const CGHeroInstance * curHero; const CGHeroInstance * curHero;

View File

@@ -101,6 +101,7 @@ int main(int argc, _TCHAR* argv[])
CGI->townh = VLC->townh; CGI->townh = VLC->townh;
CGI->heroh = VLC->heroh; CGI->heroh = VLC->heroh;
CGI->objh = VLC->objh; CGI->objh = VLC->objh;
CGI->spellh = VLC->spellh;
CGI->dobjinfo = VLC->dobjinfo; CGI->dobjinfo = VLC->dobjinfo;
CGI->buildh = VLC->buildh; CGI->buildh = VLC->buildh;
THC std::cout<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl; THC std::cout<<"Initializing VCMI_Lib: "<<tmh.getDif()<<std::endl;
@@ -139,10 +140,6 @@ int main(int argc, _TCHAR* argv[])
boost::thread servthr(boost::bind(system,SERVER_NAME " > server_log.txt")); //runs server executable; boost::thread servthr(boost::bind(system,SERVER_NAME " > server_log.txt")); //runs server executable;
//TODO: will it work on non-windows platforms? //TODO: will it work on non-windows platforms?
THC tmh.getDif();pomtime.getDif();//reset timers THC tmh.getDif();pomtime.getDif();//reset timers
CSpellHandler * spellh = new CSpellHandler;
spellh->loadSpells();
cgi->spellh = spellh;
THC std::cout<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
cgi->pathf = new CPathfinder(); cgi->pathf = new CPathfinder();
THC std::cout<<"\tPathfinder: "<<pomtime.getDif()<<std::endl; THC std::cout<<"\tPathfinder: "<<pomtime.getDif()<<std::endl;
cgi->consoleh->runConsole(); cgi->consoleh->runConsole();

View File

@@ -165,13 +165,19 @@ void CGarrisonSlot::clickLeft(tribool down)
boost::bind(&CCallback::upgradeCreature,LOCPLINT->cb,getObj(),ID,pom.newID[0]), //if upgrade is possible we'll bind proper function in callback boost::bind(&CCallback::upgradeCreature,LOCPLINT->cb,getObj(),ID,pom.newID[0]), //if upgrade is possible we'll bind proper function in callback
boost::bind(&CCallback::dismissCreature,LOCPLINT->cb,getObj(),ID),&pom)) boost::bind(&CCallback::dismissCreature,LOCPLINT->cb,getObj(),ID),&pom))
->activate(); ->activate();
LOCPLINT->curint->deactivate();
} }
else else
{ {
(new CCreInfoWindow (new CCreInfoWindow
(creature->idNumber,1,count,NULL,0, boost::bind(&CCallback::dismissCreature,LOCPLINT->cb,getObj(),ID),NULL) ) (creature->idNumber,1,count,NULL,0, boost::bind(&CCallback::dismissCreature,LOCPLINT->cb,getObj(),ID),NULL) )
->activate(); ->activate();
}
if(LOCPLINT->curint == LOCPLINT->castleInt && dynamic_cast<CHeroWindow*>(LOCPLINT->castleInt->subInt))
{
LOCPLINT->castleInt->subInt->deactivate();
}
else
{
LOCPLINT->curint->deactivate(); LOCPLINT->curint->deactivate();
} }
owner->highlighted = NULL; owner->highlighted = NULL;
@@ -479,7 +485,7 @@ void CGarrisonInt::deactivate()
deactiveteSlots(); deactiveteSlots();
} }
CInfoWindow::CInfoWindow(std::string text, int player, int charperline, std::vector<SComponent*> &comps, std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons) CInfoWindow::CInfoWindow(std::string text, int player, int charperline, const std::vector<SComponent*> &comps, std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons)
{ {
for(int i=0;i<Buttons.size();i++) for(int i=0;i<Buttons.size();i++)
{ {
@@ -1932,7 +1938,7 @@ void CPlayerInterface::receivedResource(int type, int val)
adventureInt->resdatabar.draw(); adventureInt->resdatabar.draw();
} }
void CPlayerInterface::showSelDialog(std::string &text, std::vector<Component*> &components, ui32 askID) void CPlayerInterface::showSelDialog(std::string &text, const std::vector<Component*> &components, ui32 askID)
//void CPlayerInterface::showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID) //void CPlayerInterface::showSelDialog(std::string text, std::vector<CSelectableComponent*> & components, int askID)
{ {
boost::unique_lock<boost::mutex> un(*pim); boost::unique_lock<boost::mutex> un(*pim);
@@ -1970,26 +1976,12 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
if(town->garrisonHero) if(town->garrisonHero)
{ {
CGI->mh->hideObject(town->garrisonHero); CGI->mh->hideObject(town->garrisonHero);
if(adventureInt->heroList.items.size()==1) //it was the only hero
adventureInt->townList.select(0);
else
{
for(int i=0; i<adventureInt->heroList.items.size();i++)
{
if(adventureInt->heroList.items[i].first == town->garrisonHero)
{
adventureInt->heroList.items.erase(adventureInt->heroList.items.begin()+i);
adventureInt->heroList.selected = adventureInt->heroList.items.size()-1;
break;
}
}
}
} }
if(town->visitingHero) if(town->visitingHero)
{ {
CGI->mh->printObject(town->visitingHero); CGI->mh->printObject(town->visitingHero);
adventureInt->heroList.items.push_back(std::pair<const CGHeroInstance*, CPath *>(town->visitingHero,NULL));
} }
adventureInt->heroList.updateHList();
CCastleInterface *c = dynamic_cast<CCastleInterface*>(curint); CCastleInterface *c = dynamic_cast<CCastleInterface*>(curint);
if(c) if(c)
@@ -2039,7 +2031,11 @@ void CPlayerInterface::garrisonChanged(const CGObjectInstance * obj)
SDL_FreeSurface(graphics->townWins[tt->id]); SDL_FreeSurface(graphics->townWins[tt->id]);
graphics->townWins[tt->id] = infoWin(tt); graphics->townWins[tt->id] = infoWin(tt);
} }
if(tt->visitingHero)
{
SDL_FreeSurface(graphics->heroWins[tt->visitingHero->subID]);
graphics->heroWins[tt->visitingHero->subID] = infoWin(tt->visitingHero);
}
if(LOCPLINT->castleInt) if(LOCPLINT->castleInt)
{ {
LOCPLINT->castleInt->garr->highlighted = NULL; LOCPLINT->castleInt->garr->highlighted = NULL;
@@ -2049,11 +2045,20 @@ void CPlayerInterface::garrisonChanged(const CGObjectInstance * obj)
} }
void CPlayerInterface::buildChanged(const CGTownInstance *town, int buildingID, int what) //what: 1 - built, 2 - demolished void CPlayerInterface::buildChanged(const CGTownInstance *town, int buildingID, int what) //what: 1 - built, 2 - demolished
{ {
boost::unique_lock<boost::mutex> un(*pim);
switch (buildingID)
{
case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 15:
{
SDL_FreeSurface(graphics->townWins[town->id]);
graphics->townWins[town->id] = infoWin(town);
break;
}
}
if(curint!=castleInt) if(curint!=castleInt)
return; return;
if(castleInt->town!=town) if(castleInt->town!=town)
return; return;
boost::unique_lock<boost::mutex> un(*pim);
switch(what) switch(what)
{ {
case 1: case 1:
@@ -2156,14 +2161,14 @@ void CPlayerInterface::showComp(SComponent comp)
adventureInt->infoBar.showComp(&comp,4000); adventureInt->infoBar.showComp(&comp,4000);
} }
void CPlayerInterface::showInfoDialog(std::string &text, std::vector<Component*> &components) void CPlayerInterface::showInfoDialog(std::string &text, const std::vector<Component*> &components)
{ {
std::vector<SComponent*> intComps; std::vector<SComponent*> intComps;
for(int i=0;i<components.size();i++) for(int i=0;i<components.size();i++)
intComps.push_back(new SComponent(*components[i])); intComps.push_back(new SComponent(*components[i]));
showInfoDialog(text,intComps); showInfoDialog(text,intComps);
} }
void CPlayerInterface::showInfoDialog(std::string &text, std::vector<SComponent*> & components) void CPlayerInterface::showInfoDialog(std::string &text, const std::vector<SComponent*> & components)
{ {
showingDialog->set(true); showingDialog->set(true);
curint->deactivate(); //dezaktywacja starego interfejsu curint->deactivate(); //dezaktywacja starego interfejsu
@@ -2176,7 +2181,7 @@ void CPlayerInterface::showInfoDialog(std::string &text, std::vector<SComponent*
temp->activate(); temp->activate();
LOCPLINT->objsToBlit.push_back(temp); LOCPLINT->objsToBlit.push_back(temp);
} }
void CPlayerInterface::showYesNoDialog(std::string &text, std::vector<SComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool deactivateCur, bool DelComps) void CPlayerInterface::showYesNoDialog(std::string &text, const std::vector<SComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool deactivateCur, bool DelComps)
{ {
if(deactivateCur) if(deactivateCur)
curint->deactivate(); //dezaktywacja starego interfejsu curint->deactivate(); //dezaktywacja starego interfejsu
@@ -2216,6 +2221,10 @@ void CPlayerInterface::openHeroWindow(const CGHeroInstance *hero)
adventureInt->heroWindow->setHero(hero); adventureInt->heroWindow->setHero(hero);
this->objsToBlit.push_back(adventureInt->heroWindow); this->objsToBlit.push_back(adventureInt->heroWindow);
curint->deactivate(); curint->deactivate();
if(curint == castleInt)
castleInt->subInt = adventureInt->heroWindow;
adventureInt->heroWindow->quitButton->callback.funcs.clear();
adventureInt->heroWindow->quitButton->callback += boost::bind(&CHeroWindow::quit,adventureInt->heroWindow);
adventureInt->heroWindow->activate(); adventureInt->heroWindow->activate();
} }
CStatusBar::CStatusBar(int x, int y, std::string name, int maxw) CStatusBar::CStatusBar(int x, int y, std::string name, int maxw)
@@ -2318,7 +2327,9 @@ void CHeroList::genList()
int howMany = LOCPLINT->cb->howManyHeroes(); int howMany = LOCPLINT->cb->howManyHeroes();
for (int i=0;i<howMany;i++) for (int i=0;i<howMany;i++)
{ {
items.push_back(std::pair<const CGHeroInstance *,CPath *>(LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,i,0),NULL)); const CGHeroInstance * h = LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,i,0);
if(!h->inTownGarrison)
items.push_back(std::pair<const CGHeroInstance *,CPath *>(h,NULL));
} }
} }
void CHeroList::select(int which) void CHeroList::select(int which)
@@ -2506,15 +2517,16 @@ void CHeroList::draw()
blitAt(empty,posporx,pospory+i*32); blitAt(empty,posporx,pospory+i*32);
continue; continue;
} }
int pom = (LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->movement)/100; const CGHeroInstance *cur = items[iT].first;
int pom = cur->movement / 100;
if (pom>25) pom=25; if (pom>25) pom=25;
if (pom<0) pom=0; if (pom<0) pom=0;
blitAt(mobile->ourImages[pom].bitmap,posmobx,posmoby+i*32); //move point blitAt(mobile->ourImages[pom].bitmap,posmobx,posmoby+i*32); //move point
pom = (LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->mana)/5; //bylo: .../10; pom = cur->mana / 5; //bylo: .../10;
if (pom>25) pom=25; if (pom>25) pom=25;
if (pom<0) pom=0; if (pom<0) pom=0;
blitAt(mana->ourImages[pom].bitmap,posmanx,posmany+i*32); //mana blitAt(mana->ourImages[pom].bitmap,posmanx,posmany+i*32); //mana
SDL_Surface * temp = graphics->portraitSmall[LOCPLINT->cb->getHeroInfo(LOCPLINT->playerID,iT,0)->portrait]; SDL_Surface * temp = graphics->portraitSmall[cur->portrait];
blitAt(temp,posporx,pospory+i*32); blitAt(temp,posporx,pospory+i*32);
if ((selected == iT) && (LOCPLINT->adventureInt->selection.type == HEROI_TYPE)) if ((selected == iT) && (LOCPLINT->adventureInt->selection.type == HEROI_TYPE))
{ {
@@ -2860,7 +2872,7 @@ void CRecrutationWindow::show(SDL_Surface * to)
cancel->show(); cancel->show();
slider->show(); slider->show();
char pom[15]; char pom[15];
SDL_itoa(creatures[which].amount,pom,10); //available SDL_itoa(creatures[which].amount-slider->value,pom,10); //available
printAtMiddle(pom,pos.x+205,pos.y+252,GEOR13,zwykly,screen); printAtMiddle(pom,pos.x+205,pos.y+252,GEOR13,zwykly,screen);
SDL_itoa(slider->value,pom,10); //recruit SDL_itoa(slider->value,pom,10); //recruit
printAtMiddle(pom,pos.x+279,pos.y+252,GEOR13,zwykly,screen); printAtMiddle(pom,pos.x+279,pos.y+252,GEOR13,zwykly,screen);
@@ -3228,9 +3240,18 @@ void CCreInfoWindow::close()
{ {
deactivate(); deactivate();
CCastleInterface *c = dynamic_cast<CCastleInterface*>(LOCPLINT->curint); CCastleInterface *c = dynamic_cast<CCastleInterface*>(LOCPLINT->curint);
if(c) c->showAll(); if(c && dynamic_cast<CHeroWindow*>(c->subInt))
if(type) {
LOCPLINT->curint->activate(); if(type)
c->subInt->activate();
}
else
{
if(c)
c->showAll();
if(type)
LOCPLINT->curint->activate();
}
delete this; delete this;
} }
void CCreInfoWindow::clickRight(boost::logic::tribool down) void CCreInfoWindow::clickRight(boost::logic::tribool down)

View File

@@ -24,7 +24,7 @@ class CCreatureSet;
class CGObjectInstance; class CGObjectInstance;
class CSlider; class CSlider;
struct UpgradeInfo; struct UpgradeInfo;
template <typename T> struct CondSh; template <typename T> struct CondSh;
namespace boost namespace boost
{ {
@@ -174,7 +174,7 @@ public:
virtual void show(SDL_Surface * to = NULL); virtual void show(SDL_Surface * to = NULL);
void activate(); void activate();
void deactivate(); void deactivate();
CInfoWindow(std::string text, int player, int charperline, std::vector<SComponent*> &comps, std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons); CInfoWindow(std::string text, int player, int charperline, const std::vector<SComponent*> &comps, std::vector<std::pair<std::string,CFunctionList<void()> > > &Buttons);
CInfoWindow(); CInfoWindow();
~CInfoWindow(); ~CInfoWindow();
}; };
@@ -341,8 +341,8 @@ public:
void heroCreated(const CGHeroInstance* hero); void heroCreated(const CGHeroInstance* hero);
void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val); void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, int val);
void receivedResource(int type, int val); void receivedResource(int type, int val);
void showInfoDialog(std::string &text, std::vector<Component*> &components); void showInfoDialog(std::string &text, const std::vector<Component*> &components);
void showSelDialog(std::string &text, std::vector<Component*> &components, ui32 askID); void showSelDialog(std::string &text, const std::vector<Component*> &components, ui32 askID);
void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town); void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town);
void garrisonChanged(const CGObjectInstance * obj); void garrisonChanged(const CGObjectInstance * obj);
void buildChanged(const CGTownInstance *town, int buildingID, int what); //what: 1 - built, 2 - demolished void buildChanged(const CGTownInstance *town, int buildingID, int what); //what: 1 - built, 2 - demolished
@@ -374,9 +374,9 @@ public:
void handleMouseMotion(SDL_Event *sEvent); void handleMouseMotion(SDL_Event *sEvent);
void init(ICallback * CB); void init(ICallback * CB);
int3 repairScreenPos(int3 pos); int3 repairScreenPos(int3 pos);
void removeObjToBlit(IShowable* obj); void removeObjToBlit(IShowable* obj);
void showInfoDialog(std::string &text, std::vector<SComponent*> & components); void showInfoDialog(std::string &text, const std::vector<SComponent*> & components);
void showYesNoDialog(std::string &text, std::vector<SComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool deactivateCur, bool DelComps); //deactivateCur - whether current main interface should be deactivated; delComps - if components will be deleted on window close void showYesNoDialog(std::string &text, const std::vector<SComponent*> & components, CFunctionList<void()> onYes, CFunctionList<void()> onNo, bool deactivateCur, bool DelComps); //deactivateCur - whether current main interface should be deactivated; delComps - if components will be deleted on window close
CPlayerInterface(int Player, int serial);//c-tor CPlayerInterface(int Player, int serial);//c-tor
~CPlayerInterface();//d-tor ~CPlayerInterface();//d-tor
@@ -565,7 +565,7 @@ public:
std::vector<CSelectableComponent *> comps; //skills to select std::vector<CSelectableComponent *> comps; //skills to select
AdventureMapButton *ok; AdventureMapButton *ok;
boost::function<void(ui32)> cb; boost::function<void(ui32)> cb;
void close(); void close();
CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback); CLevelWindow(const CGHeroInstance *hero, int pskill, std::vector<ui16> &skills, boost::function<void(ui32)> &callback);
~CLevelWindow(); ~CLevelWindow();
@@ -586,4 +586,4 @@ public:
extern CPlayerInterface * LOCPLINT; extern CPlayerInterface * LOCPLINT;
#endif //CPLAYERINTERFACE_H #endif //CPLAYERINTERFACE_H

View File

@@ -323,10 +323,21 @@ void CClient::process(int what)
{ {
NewStructures ns; NewStructures ns;
*serv >> ns; *serv >> ns;
std::cout << "New structure(s) in " << ns.tid << " - " << *ns.bid.begin() << std::endl; CGTownInstance *town = static_cast<CGTownInstance*>(gs->map->objects[ns.tid]);
std::cout << "New structure(s) in " << ns.tid <<" " << town->name << " - " << *ns.bid.begin() << std::endl;
gs->apply(&ns); gs->apply(&ns);
BOOST_FOREACH(si32 bid, ns.bid) BOOST_FOREACH(si32 bid, ns.bid)
playerint[gs->map->objects[ns.tid]->tempOwner]->buildChanged(static_cast<CGTownInstance*>(gs->map->objects[ns.tid]),bid,1); {
if(bid==13) //for or capitol
{
town->defInfo = gs->capitols[town->subID];
}
if(bid ==7)
{
town->defInfo = gs->forts[town->subID];
}
playerint[town->tempOwner]->buildChanged(town,bid,1);
}
break; break;
} }
case 506: case 506:

View File

@@ -1,24 +1,24 @@
#pragma once #pragma once
#include <boost/function.hpp> #include <boost/function.hpp>
template<typename Signature, typename Allocator = std::allocator<void> > template<typename Signature>
class CFunctionList class CFunctionList
{ {
public: public:
std::vector<boost::function<Signature,Allocator> > funcs; std::vector<boost::function<Signature> > funcs;
CFunctionList(int){}; CFunctionList(int){};
CFunctionList(){}; CFunctionList(){};
CFunctionList(const boost::function<Signature,Allocator> &first) CFunctionList(const boost::function<Signature> &first)
{ {
funcs.push_back(first); funcs.push_back(first);
} }
CFunctionList & operator+=(const boost::function<Signature,Allocator> &first) CFunctionList & operator+=(const boost::function<Signature> &first)
{ {
funcs.push_back(first); funcs.push_back(first);
return *this; return *this;
} }
const boost::function<Signature,Allocator> & operator=(const boost::function<Signature,Allocator> &first) const boost::function<Signature> & operator=(const boost::function<Signature> &first)
{ {
funcs.push_back(first); funcs.push_back(first);
return first; return first;
@@ -29,7 +29,7 @@ public:
} }
void operator()() const void operator()() const
{ {
std::vector<boost::function<Signature,Allocator> > funcs2 = funcs; //backup std::vector<boost::function<Signature> > funcs2 = funcs; //backup
for(int i=0;i<funcs2.size(); i++) for(int i=0;i<funcs2.size(); i++)
funcs2[i](); funcs2[i]();
} }

View File

@@ -118,6 +118,14 @@ void Graphics::loadPaletteAndColors()
playerColors[i].unused = 0; playerColors[i].unused = 0;
} }
neutralColor->r = 0x84; neutralColor->g = 0x84; neutralColor->b = 0x84; neutralColor->unused = 0x0;//gray neutralColor->r = 0x84; neutralColor->g = 0x84; neutralColor->b = 0x84; neutralColor->unused = 0x0;//gray
std::ifstream bback("config/mageBg.txt");
while(!bback.eof())
{
bback >> pals;
guildBgs.push_back(pals);
}
bback.close();
} }
void Graphics::initializeBattleGraphics() void Graphics::initializeBattleGraphics()
{ {

View File

@@ -38,6 +38,7 @@ public:
//for battles //for battles
std::vector< std::vector< std::string > > battleBacks; //battleBacks[terType] - vector of possible names for certain terrain type std::vector< std::vector< std::string > > battleBacks; //battleBacks[terType] - vector of possible names for certain terrain type
std::vector< std::string > battleHeroes; //battleHeroes[hero type] - name of def that has hero animation for battle std::vector< std::string > battleHeroes; //battleHeroes[hero type] - name of def that has hero animation for battle
std::vector<std::string> guildBgs;// name of bitmaps with imgs for mage guild screen
//functions //functions
Graphics(); Graphics();
void initializeBattleGraphics(); void initializeBattleGraphics();

View File

@@ -362,10 +362,6 @@
RelativePath="..\hch\CSndHandler.cpp" RelativePath="..\hch\CSndHandler.cpp"
> >
</File> </File>
<File
RelativePath="..\hch\CSpellHandler.cpp"
>
</File>
<File <File
RelativePath="..\CThreadHelper.cpp" RelativePath="..\CThreadHelper.cpp"
> >
@@ -512,10 +508,6 @@
RelativePath="..\hch\CSndHandler.h" RelativePath="..\hch\CSndHandler.h"
> >
</File> </File>
<File
RelativePath="..\hch\CSpellHandler.h"
>
</File>
<File <File
RelativePath="..\CThreadHelper.h" RelativePath="..\CThreadHelper.h"
> >
@@ -565,6 +557,10 @@
> >
</File> </File>
</Filter> </Filter>
<File
RelativePath=".\ClassDiagram1.cd"
>
</File>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>

9
config/mageLevel.txt Normal file
View File

@@ -0,0 +1,9 @@
4
5
5
5
5
5
3
3
5

View File

@@ -61,6 +61,7 @@ const int NEUTRAL_PLAYER=255;
const int NAMES_PER_TOWN=16; const int NAMES_PER_TOWN=16;
const int CREATURES_PER_TOWN = 7; //without upgrades const int CREATURES_PER_TOWN = 7; //without upgrades
const int MAX_BUILDING_PER_TURN = 1; const int MAX_BUILDING_PER_TURN = 1;
const int SPELL_LEVELS = 5;
#define MARK_BLOCKED_POSITIONS false #define MARK_BLOCKED_POSITIONS false
#define MARK_VISITABLE_POSITIONS false #define MARK_VISITABLE_POSITIONS false

View File

@@ -5,7 +5,6 @@
#include <boost/assign/std/vector.hpp> #include <boost/assign/std/vector.hpp>
#include <boost/assign/list_of.hpp> #include <boost/assign/list_of.hpp>
#include "../lib/VCMI_Lib.h" #include "../lib/VCMI_Lib.h"
void loadToIt(std::string &dest, std::string &src, int &iter, int mode);
extern CLodHandler *bitmaph; extern CLodHandler *bitmaph;
using namespace boost::assign; using namespace boost::assign;
CArtHandler::CArtHandler() CArtHandler::CArtHandler()

View File

@@ -271,6 +271,20 @@ int CGTownInstance::hallLevel() const // -1 - none, 0 - village, 1 - town, 2 - c
return 0; return 0;
return -1; return -1;
} }
int CGTownInstance::mageGuildLevel() const
{
if ((builtBuildings.find(4))!=builtBuildings.end())
return 5;
if ((builtBuildings.find(3))!=builtBuildings.end())
return 4;
if ((builtBuildings.find(2))!=builtBuildings.end())
return 3;
if ((builtBuildings.find(1))!=builtBuildings.end())
return 2;
if ((builtBuildings.find(0))!=builtBuildings.end())
return 1;
return 0;
}
bool CGTownInstance::creatureDwelling(const int & level, bool upgraded) const bool CGTownInstance::creatureDwelling(const int & level, bool upgraded) const
{ {
return builtBuildings.find(30+level+upgraded*7)!=builtBuildings.end(); return builtBuildings.find(30+level+upgraded*7)!=builtBuildings.end();
@@ -349,6 +363,7 @@ CGObjectInstance::~CGObjectInstance()
} }
CGHeroInstance::CGHeroInstance() CGHeroInstance::CGHeroInstance()
{ {
inTownGarrison = false;
portrait = level = exp = -1; portrait = level = exp = -1;
isStanding = true; isStanding = true;
moveDir = 4; moveDir = 4;

View File

@@ -141,7 +141,8 @@ public:
int identifier; //special identifier from h3m (only > RoE maps) int identifier; //special identifier from h3m (only > RoE maps)
int alignment; int alignment;
std::set<si32> forbiddenBuildings, builtBuildings; std::set<si32> forbiddenBuildings, builtBuildings;
std::vector<int> possibleSpells, obligatorySpells, availableSpells; std::vector<int> possibleSpells, obligatorySpells;
std::vector<std::vector<ui32> > spells; //spells[level] -> vector of spells, first will be available in guild
struct StrInfo struct StrInfo
{ {
@@ -158,6 +159,7 @@ public:
int getSightDistance() const; //returns sight distance int getSightDistance() const; //returns sight distance
int fortLevel() const; //0 - none, 1 - fort, 2 - citadel, 3 - castle int fortLevel() const; //0 - none, 1 - fort, 2 - citadel, 3 - castle
int hallLevel() const; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol int hallLevel() const; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
int mageGuildLevel() const; // -1 - none, 0 - village, 1 - town, 2 - city, 3 - capitol
bool creatureDwelling(const int & level, bool upgraded=false) const; bool creatureDwelling(const int & level, bool upgraded=false) const;
int getHordeLevel(const int & HID) const; //HID - 0 or 1; returns creature level or -1 if that horde structure is not present int getHordeLevel(const int & HID) const; //HID - 0 or 1; returns creature level or -1 if that horde structure is not present
int creatureGrowth(const int & level) const; int creatureGrowth(const int & level) const;

View File

@@ -1,359 +1,70 @@
#include "../stdafx.h" #define VCMI_DLL
#include "../stdafx.h"
#include "CSpellHandler.h" #include "CSpellHandler.h"
#include "../CGameInfo.h"
#include "CLodHandler.h" #include "CLodHandler.h"
#include "../lib/VCMI_Lib.h"
#include <boost/algorithm/string/replace.hpp>
extern CLodHandler *bitmaph;
void CSpellHandler::loadSpells() void CSpellHandler::loadSpells()
{ {
std::string buf = CGI->bitmaph->getTextFile("SPTRAITS.TXT"); std::string buf = bitmaph->getTextFile("SPTRAITS.TXT"), pom;
int andame = buf.size(); int andame = buf.size(), i=0; //buf iterator
int i=0; //buf iterator for(int z=0; z<5; ++z)
int hmcr=0; loadToIt(pom,buf,i,3);
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
++hmcr;
if(hmcr==5)
break;
}
i+=2;
bool combSpells=false; //true, if we are reading combat spells bool combSpells=false; //true, if we are reading combat spells
while(i<andame) while(i<andame)
{ {
if(spells.size()==81) if(spells.size()==81)
break; break;
CSpell nsp; //new currently being read spell CSpell nsp; //new currently being read spell
int befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.name = buf.substr(befi, i-befi);
++i;
loadToIt(nsp.name,buf,i,4);
if(nsp.name == std::string("")) if(nsp.name == std::string(""))
{ {
combSpells = true; for(int z=0; z<3; ++z)
int hmcr=0; loadToIt(pom,buf,i,3);
for(i; i<andame; ++i) loadToIt(nsp.name,buf,i,4);
{
if(buf[i]=='\r')
++hmcr;
if(hmcr==3)
break;
}
++i;
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.name = buf.substr(befi, i-befi);
++i;
} }
befi=i; loadToIt(nsp.abbName,buf,i,4);
for(i; i<andame; ++i) loadToIt(nsp.level,buf,i,4);
{
if(buf[i]=='\t')
break;
}
nsp.abbName = buf.substr(befi, i-befi);
++i;
befi=i; loadToIt(pom,buf,i,4);
for(i; i<andame; ++i) nsp.earth = pom[0]=='x' ? true : false;
{ loadToIt(pom,buf,i,4);
if(buf[i]=='\t') nsp.water = pom[0]=='x' ? true : false;
break; loadToIt(pom,buf,i,4);
} nsp.fire = pom[0]=='x' ? true : false;
nsp.level = atoi(buf.substr(befi, i-befi).c_str()); loadToIt(pom,buf,i,4);
++i; nsp.air = pom[0]=='x' ? true : false;
befi=i; nsp.costs.resize(4);
for(i; i<andame; ++i) for (int z = 0; z < 4 ; z++)
{ loadToIt(nsp.costs[z],buf,i,4);
if(buf[i]=='\t') loadToIt(nsp.power,buf,i,4);
break; nsp.powers.resize(4);
} for (int z = 0; z < 4 ; z++)
nsp.earth = buf.substr(befi, i-befi)[0]=='x' ? true : false; loadToIt(nsp.powers[z],buf,i,4);
++i;
befi=i; nsp.probabilities.resize(9);
for(i; i<andame; ++i) for (int z = 0; z < 9 ; z++)
{ loadToIt(nsp.probabilities[z],buf,i,4);
if(buf[i]=='\t')
break;
}
nsp.water = buf.substr(befi, i-befi)[0]=='x' ? true : false;
++i;
befi=i; nsp.AIVals.resize(4);
for(i; i<andame; ++i) for (int z = 0; z < 4 ; z++)
{ loadToIt(nsp.AIVals[z],buf,i,4);
if(buf[i]=='\t')
break;
}
nsp.fire = buf.substr(befi, i-befi)[0]=='x' ? true : false;
++i;
befi=i; nsp.descriptions.resize(4);
for(i; i<andame; ++i) for (int z = 0; z < 4 ; z++)
{ {
if(buf[i]=='\t') loadToIt(nsp.descriptions[z],buf,i,4);
break; boost::algorithm::replace_all(nsp.descriptions[z],"\"","");
} }
nsp.air = buf.substr(befi, i-befi)[0]=='x' ? true : false;
++i;
befi=i; loadToIt(nsp.attributes,buf,i,3);
for(i; i<andame; ++i) nsp.id = spells.size();
{
if(buf[i]=='\t')
break;
}
nsp.costNone = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.costBas = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.costAdv = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.costExp = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.power = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.powerNone = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.powerBas = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.powerAdv = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.powerExp = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.castle = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.rampart = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.tower = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.inferno = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.necropolis = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.dungeon = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.stronghold = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.fortress = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.conflux = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.none2 = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.bas2 = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.adv2 = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.exp2 = atoi(buf.substr(befi, i-befi).c_str());
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.noneTip = buf.substr(befi, i-befi).c_str();
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.basTip = buf.substr(befi, i-befi).c_str();
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.advTip = buf.substr(befi, i-befi).c_str();
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\t')
break;
}
nsp.expTip = buf.substr(befi, i-befi).c_str();
++i;
befi=i;
for(i; i<andame; ++i)
{
if(buf[i]=='\r')
break;
}
nsp.attributes = buf.substr(befi, i-befi).c_str();
++i;
++i;
nsp.combatSpell = combSpells; nsp.combatSpell = combSpells;
spells.push_back(nsp); spells.push_back(nsp);
} }
} }

View File

@@ -7,31 +7,25 @@
class CSpell class CSpell
{ {
public: public:
bool isAllowed; //true if we can use this spell (depends on map) ui32 id;
std::string name; std::string name;
std::string abbName; //abbreviated name std::string abbName; //abbreviated name
int level; si32 level;
bool earth; bool earth;
bool water; bool water;
bool fire; bool fire;
bool air; bool air;
int costNone; si32 power; //spell's power
int costBas; std::vector<si32> costs; //per skill level: 0 - none, 1 - basic, etc
int costAdv; std::vector<si32> powers; //[er skill level: 0 - none, 1 - basic, etc
int costExp; std::vector<si32> probabilities; //% chance to gain for castles
int power; //spell's power std::vector<si32> AIVals; //AI values: per skill level: 0 - none, 1 - basic, etc
int powerNone; //effect without magic ability std::vector<std::string> descriptions; //descriptions of spell for skill levels: 0 - none, 1 - basic, etc
int powerBas; //efect with basic magic ability
int powerAdv; //efect with advanced magic ability
int powerExp; //efect with expert magic ability
int castle, rampart, tower, inferno, necropolis, dungeon, stronghold, fortress, conflux; //% chance to gain
int none2, bas2, adv2, exp2; //AI values
std::string noneTip, basTip, advTip, expTip; //descriptions of spell
std::string attributes; //reference only attributes std::string attributes; //reference only attributes
bool combatSpell; //is this spell combat (true) or adventure (false) bool combatSpell; //is this spell combat (true) or adventure (false)
}; };
class CSpellHandler class DLL_EXPORT CSpellHandler
{ {
public: public:
std::vector<CSpell> spells; std::vector<CSpell> spells;

View File

@@ -248,6 +248,15 @@ void CTownHandler::loadNames()
of.close(); of.close();
of.clear(); of.clear();
itr=0;
of.open("config/mageLevel.txt");
while(!of.eof())
{
of >> towns[itr++].mageLevel;
}
of.close();
of.clear();
of.open("config/requirements.txt"); of.open("config/requirements.txt");
while(!of.eof()) while(!of.eof())
{ {

View File

@@ -14,6 +14,7 @@ public:
std::vector<int> basicCreatures; //level (from 0) -> ID std::vector<int> basicCreatures; //level (from 0) -> ID
std::vector<int> upgradedCreatures; //level (from 0) -> ID std::vector<int> upgradedCreatures; //level (from 0) -> ID
std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present) std::map<int,int> hordeLvl; //[0] - first horde building creature level; [1] - second horde building (-1 if not present)
ui32 mageLevel; //max available mage guild level
int bonus; //pic number int bonus; //pic number
int typeID; int typeID;
}; };

View File

@@ -7,6 +7,7 @@
#include <boost/type_traits/is_fundamental.hpp> #include <boost/type_traits/is_fundamental.hpp>
#include <boost/type_traits/is_enum.hpp> #include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_pointer.hpp> #include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/remove_pointer.hpp> #include <boost/type_traits/remove_pointer.hpp>
#include <boost/mpl/eval_if.hpp> #include <boost/mpl/eval_if.hpp>

View File

@@ -8,6 +8,7 @@
#include "../hch/CObjectHandler.h" #include "../hch/CObjectHandler.h"
#include "../hch/CTownHandler.h" #include "../hch/CTownHandler.h"
#include "../hch/CBuildingHandler.h" #include "../hch/CBuildingHandler.h"
#include "../hch/CSpellHandler.h"
class CLodHandler; class CLodHandler;
LibClasses * VLC = NULL; LibClasses * VLC = NULL;
CLodHandler * bitmaph=NULL; CLodHandler * bitmaph=NULL;
@@ -50,6 +51,11 @@ DLL_EXPORT void initDLL(CLodHandler *b)
VLC->buildh = new CBuildingHandler; VLC->buildh = new CBuildingHandler;
VLC->buildh->loadBuildings(); VLC->buildh->loadBuildings();
THC std::cout<<"\tBuilding handler: "<<pomtime.getDif()<<std::endl; THC std::cout<<"\tBuilding handler: "<<pomtime.getDif()<<std::endl;
CSpellHandler * spellh = new CSpellHandler;
spellh->loadSpells();
VLC->spellh = spellh;
THC std::cout<<"\tSpell handler: "<<pomtime.getDif()<<std::endl;
} }
DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode) DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode)
@@ -159,3 +165,10 @@ DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mod
} }
} }
DLL_EXPORT void loadToIt(si32 &dest, std::string &src, int &iter, int mode)
{
std::string pom;
loadToIt(pom,src,iter,mode);
dest = atol(pom.c_str());
}

View File

@@ -3,13 +3,11 @@
#include "../global.h" #include "../global.h"
class CLodHandler; class CLodHandler;
//class CMapHandler;
class CArtHandler; class CArtHandler;
class CHeroHandler; class CHeroHandler;
class CCreatureHandler; class CCreatureHandler;
//class CAbilityHandler; //class CAbilityHandler;
//class CSpellHandler; class CSpellHandler;
//class CAmbarCendamo;
//class CPreGameTextHandler; //class CPreGameTextHandler;
class CBuildingHandler; class CBuildingHandler;
class CObjectHandler; class CObjectHandler;
@@ -20,13 +18,7 @@ class CTownHandler;
//class CGeneralTextHandler; //class CGeneralTextHandler;
//class CConsoleHandler; //class CConsoleHandler;
//class CPathfinder; //class CPathfinder;
//class CCursorHandler;
//class CScreenHandler;
//class CGameState; //class CGameState;
//class CMapHandler;
//class CGameInterface;
//class CPreGame;
//class CDefHandler;
class LibClasses class LibClasses
{ {
@@ -36,29 +28,21 @@ public:
CHeroHandler * heroh; CHeroHandler * heroh;
CCreatureHandler * creh; CCreatureHandler * creh;
//CAbilityHandler * abilh; //CAbilityHandler * abilh;
//CSpellHandler * spellh; CSpellHandler * spellh;
//CMapHandler * mh;
//CPreGameTextHandler * preth; //CPreGameTextHandler * preth;
CBuildingHandler * buildh; CBuildingHandler * buildh;
CObjectHandler * objh; CObjectHandler * objh;
//CMusicHandler * mush;
//CSemiLodHandler * sspriteh;
CDefObjInfoHandler * dobjinfo; CDefObjInfoHandler * dobjinfo;
CTownHandler * townh; CTownHandler * townh;
//CGeneralTextHandler * generaltexth; //CGeneralTextHandler * generaltexth;
//CConsoleHandler * consoleh; //CConsoleHandler * consoleh;
//CPathfinder * pathf; //CPathfinder * pathf;
//CCursorHandler * curh;
//CScreenHandler * screenh;
//int localPlayer;
//std::vector<CGameInterface *> playerint;
//std::vector<SDL_Color> playerColors;
//SDL_Color neutralColor;
//StartInfo scenarioOps;
}; };
extern DLL_EXPORT LibClasses * VLC; extern DLL_EXPORT LibClasses * VLC;
DLL_EXPORT void loadToIt(std::string &dest, std::string &src, int &iter, int mode);
DLL_EXPORT void loadToIt(si32 &dest, std::string &src, int &iter, int mode);
DLL_EXPORT void initDLL(CLodHandler *b); DLL_EXPORT void initDLL(CLodHandler *b);

View File

@@ -294,6 +294,10 @@
RelativePath=".\Connection.cpp" RelativePath=".\Connection.cpp"
> >
</File> </File>
<File
RelativePath="..\hch\CSpellHandler.cpp"
>
</File>
<File <File
RelativePath="..\hch\CTownHandler.cpp" RelativePath="..\hch\CTownHandler.cpp"
> >
@@ -360,6 +364,10 @@
RelativePath=".\Connection.h" RelativePath=".\Connection.h"
> >
</File> </File>
<File
RelativePath="..\hch\CSpellHandler.h"
>
</File>
<File <File
RelativePath="..\hch\CTownHandler.h" RelativePath="..\hch\CTownHandler.h"
> >

View File

@@ -900,7 +900,7 @@ void Mapa::loadTown( CGObjectInstance * &nobj, unsigned char * bufor, int &i )
{ {
for(int bit=0;bit<8;bit++) for(int bit=0;bit<8;bit++)
if(bufor[i] & (1<<bit)) if(bufor[i] & (1<<bit))
nt->forbiddenBuildings.insert(byte*8+bit); nt->forbiddenBuildings.insert((byte-6)*8+bit);
i++; i++;
} }
nt->builtBuildings = convertBuildings(nt->builtBuildings,nt->subID); nt->builtBuildings = convertBuildings(nt->builtBuildings,nt->subID);

View File

@@ -413,9 +413,8 @@ void CMapHandler::initObjectRects()
//initializing objects / rects //initializing objects / rects
for(int f=0; f<map->objects.size(); ++f) for(int f=0; f<map->objects.size(); ++f)
{ {
/*map->objects[f]->pos.x+=1; if((map->objects[f]->ID==34 && static_cast<CGHeroInstance*>(map->objects[f])->inTownGarrison)
map->objects[f]->pos.y+=1;*/ || !map->objects[f]->defInfo)
if(!map->objects[f]->defInfo)
{ {
continue; continue;
} }
@@ -489,7 +488,7 @@ void processDef (CGDefInfo* def)
def->width = def->handler->ourImages[0].bitmap->w/32; def->width = def->handler->ourImages[0].bitmap->w/32;
def->height = def->handler->ourImages[0].bitmap->h/32; def->height = def->handler->ourImages[0].bitmap->h/32;
CGDefInfo* pom = CGI->dobjinfo->gobjs[def->id][def->subid]; CGDefInfo* pom = CGI->dobjinfo->gobjs[def->id][def->subid];
if(pom) if(pom && def->id!=98)
{ {
pom->handler = def->handler; pom->handler = def->handler;
pom->width = pom->handler->ourImages[0].bitmap->w/32; pom->width = pom->handler->ourImages[0].bitmap->w/32;
@@ -566,8 +565,6 @@ void CMapHandler::init()
std::cout<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDif()<<std::endl; std::cout<<"\tPreparing FoW, roads, rivers,borders: "<<th.getDif()<<std::endl;
initObjectRects(); initObjectRects();
std::cout<<"\tMaking object rects: "<<th.getDif()<<std::endl; std::cout<<"\tMaking object rects: "<<th.getDif()<<std::endl;
calculateBlockedPos();
std::cout<<"\tCalculating blockmap: "<<th.getDif()<<std::endl;
} }
SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, unsigned char anim, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, SDL_Rect * extRect) SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level, unsigned char anim, std::vector< std::vector< std::vector<unsigned char> > > * visibilityMap, bool otherHeroAnim, unsigned char heroAnim, SDL_Surface * extSurf, SDL_Rect * extRect)

View File

@@ -189,7 +189,7 @@ template <typename T> void nodrze<T>::wypiszObficie(std::ostream & strum)
template <typename T, class X> T* operator%(nodrze<T> & drzewko, X co) template <typename T, class X> T* operator%(nodrze<T> & drzewko, X co)
{ {
CLOG ("Szukam " <<co <<std::endl); CLOG ("Szukam " <<co <<std::endl);
#if !defined(__amigaos4__) && !defined(__unix__) #ifdef _MSC_VER
drzewko.wypiszObficie(*C->gl->loguj); drzewko.wypiszObficie(*C->gl->loguj);
#endif #endif
wezel<T> * w = drzewko.korzen; wezel<T> * w = drzewko.korzen;

View File

@@ -168,7 +168,6 @@ void CGameHandler::changeSecSkill(int ID, ui16 which, int val, bool abs)
sps.val = val; sps.val = val;
sendAndApply(&sps); sendAndApply(&sps);
} }
void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs) void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs)
{ {
SetPrimSkill sps; SetPrimSkill sps;
@@ -677,7 +676,7 @@ upgend:
CCreatureSet csn = town->visitingHero->army, cso = town->army; CCreatureSet csn = town->visitingHero->army, cso = town->army;
while(!cso.slots.empty())//while there are unmoved creatures while(!cso.slots.empty())//while there are unmoved creatures
{ {
int pos = csn.getSlotFor(cso.slots.begin()->first); int pos = csn.getSlotFor(cso.slots.begin()->second.first);
if(pos<0) if(pos<0)
goto handleConEnd; goto handleConEnd;
if(csn.slots.find(pos)!=csn.slots.end()) //add creatures to the existing stack if(csn.slots.find(pos)!=csn.slots.end()) //add creatures to the existing stack

View File

@@ -73,7 +73,7 @@ void CScriptCallback::showInfoDialog(InfoWindow *iw)
gh->sendToAllClients(iw); gh->sendToAllClients(iw);
} }
void CScriptCallback::showSelectionDialog(SelectionDialog *iw, boost::function<void(ui32),std::allocator<void> > &callback) void CScriptCallback::showSelectionDialog(SelectionDialog *iw, boost::function<void(ui32)> &callback)
{ {
gh->ask(iw,iw->player,callback); gh->ask(iw,iw->player,callback);
} }

View File

@@ -41,7 +41,7 @@ public:
void setHoverName(int objid, MetaString * name); void setHoverName(int objid, MetaString * name);
void changePrimSkill(int ID, int which, int val, bool abs=false); void changePrimSkill(int ID, int which, int val, bool abs=false);
void showInfoDialog(InfoWindow *iw); void showInfoDialog(InfoWindow *iw);
void showSelectionDialog(SelectionDialog *iw, boost::function<void(ui32),std::allocator<void> > &callback); //returns question id void showSelectionDialog(SelectionDialog *iw, boost::function<void(ui32)> &callback); //returns question id
void giveResource(int player, int which, int val); void giveResource(int player, int which, int val);
void showCompInfo(ShowInInfobox * comp); void showCompInfo(ShowInInfobox * comp);
void heroVisitCastle(int obj, int heroID); void heroVisitCastle(int obj, int heroID);