1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

* fixed possible freeze when applying changes in gamestate

* it's impossible to enter not owned town
* giving starting bonus
* other improvements
This commit is contained in:
Michał W. Urbańczyk 2008-08-25 21:14:00 +00:00
parent 6613955463
commit ce6a9ae374
17 changed files with 150 additions and 304 deletions

View File

@ -312,7 +312,7 @@ void CTerrainRect::clickLeft(tribool down)
LOCPLINT->pim->unlock();
mres = LOCPLINT->cb->moveHero( ((const CGHeroInstance*)LOCPLINT->adventureInt->selection.selected)->type->ID,&sended,1,0);
LOCPLINT->pim->lock();
if(!mres)
if(mres)
{
delete currentPath;
currentPath = NULL;

View File

@ -558,7 +558,8 @@ void CGameState::applyNL(IPack * pack)
}
void CGameState::apply(IPack * pack)
{
mx->lock();
while(!mx->try_lock())
boost::this_thread::sleep(boost::posix_time::milliseconds(50)); //give other threads time to finish
applyNL(pack);
mx->unlock();
}
@ -930,7 +931,6 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
(*i).second.resources.resize(RESOURCE_QUANTITY);
for (int x=0;x<RESOURCE_QUANTITY;x++)
(*i).second.resources[x] = startres[x];
}
/*************************HEROES************************************************/
@ -1032,6 +1032,49 @@ void CGameState::init(StartInfo * si, Mapa * map, int Seed)
}
}
}
//starting bonus
if(si->playerInfos[k->second.serial].bonus==brandom)
si->playerInfos[k->second.serial].bonus = ran()%3;
switch(si->playerInfos[k->second.serial].bonus)
{
case bgold:
k->second.resources[6] += 500 + (ran()%6)*100;
break;
case bresource:
{
int res = VLC->townh->towns[si->playerInfos[k->second.serial].castle].primaryRes;
if(res == 127)
{
k->second.resources[0] += 5 + ran()%6;
k->second.resources[2] += 5 + ran()%6;
}
else
{
k->second.resources[res] += 3 + ran()%4;
}
break;
}
case bartifact:
{
if(!k->second.heroes[0])
{
std::cout << "Cannot give starting artifact - no heroes!" << std::endl;
break;
}
CArtifact *toGive;
do
{
toGive = VLC->arth->minors[ran() % VLC->arth->minors.size()];
} while (!map->allowedArtifact[toGive->id]);
CGHeroInstance *hero = k->second.heroes[0];
std::vector<ui16>::iterator slot = vstd::findFirstNot(hero->artifWorn,toGive->possibleSlots);
if(slot!=toGive->possibleSlots.end())
hero->artifWorn[*slot] = toGive->id;
else
hero->artifacts.push_back(toGive->id);
}
}
}
/****************************TOWNS************************************************/
for (int i=0;i<map->towns.size();i++)

View File

@ -1,28 +1,29 @@
#include "stdafx.h"
#include <cstdlib>
#include "global.h"
#include "CHeroWindow.h"
#include "AdventureMapButton.h"
#include "CAdvmapInterface.h"
#include "CCallback.h"
#include "CCastleInterface.h"
#include "CGameInfo.h"
#include "hch/CHeroHandler.h"
#include "hch/CGeneralTextHandler.h"
#include "CHeroWindow.h"
#include "CMessage.h"
#include "SDL.h"
#include "SDL_Extensions.h"
#include "CAdvmapInterface.h"
#include "CCastleInterface.h"
#include "hch/CLodHandler.h"
#include "AdventureMapButton.h"
#include "hch/CObjectHandler.h"
#include "CMessage.h"
#include "CCallback.h"
#include "hch/CArtHandler.h"
#include "hch/CAbilityHandler.h"
#include "hch/CDefHandler.h"
#include "client/CBitmapHandler.h"
#include <sstream>
#include "client/Graphics.h"
#include "global.h"
#include "hch/CAbilityHandler.h"
#include "hch/CArtHandler.h"
#include "hch/CDefHandler.h"
#include "hch/CGeneralTextHandler.h"
#include "hch/CHeroHandler.h"
#include "hch/CLodHandler.h"
#include "hch/CObjectHandler.h"
#include <boost/assign/std/vector.hpp>
#include <cstdlib>
#include <sstream>
extern SDL_Surface * screen;
extern TTF_Font * GEOR16;
using namespace boost::assign;
CHeroWindow::CHeroWindow(int playerColor):
backpackPos(0), player(playerColor)
{
@ -247,214 +248,22 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
}
backpack.clear();
artWorn[8] = new CArtPlace(hero->getArt(8));
artWorn[8]->pos.x = 515;
artWorn[8]->pos.y = 295;
artWorn[8]->pos.h = artWorn[8]->pos.w = 44;
if(hero->getArt(8))
artWorn[8]->text = hero->getArt(8)->description;
else
artWorn[8]->text = std::string();
artWorn[8]->ourWindow = this;
artWorn[8]->feet = true;
std::vector<SDL_Rect> slotPos;
artWorn[0] = new CArtPlace(hero->getArt(0));
artWorn[0]->pos.x = 509;
artWorn[0]->pos.y = 30;
artWorn[0]->pos.h = artWorn[0]->pos.w = 44;
if(hero->getArt(0))
artWorn[0]->text = hero->getArt(0)->description;
else
artWorn[0]->text = std::string();
artWorn[0]->ourWindow = this;
artWorn[0]->head = true;
slotPos += genRect(44,44,509,30), genRect(44,44,567,240), genRect(44,44,509,30), genRect(44,44,383,68),
genRect(44,44,564,183), genRect(44,44,509,130), genRect(44,44,431,68), genRect(44,44,610,183),
genRect(44,44,515,295), genRect(44,44,383,143), genRect(44,44,399,194), genRect(44,44,415,245),
genRect(44,44,431,296), genRect(44,44,564,30), genRect(44,44,610,30), genRect(44,44,610,76),
genRect(44,44,610,122), genRect(44,44,610,310), genRect(44,44,381,296);
artWorn[4] = new CArtPlace(hero->getArt(4));
artWorn[4]->pos.x = 564;
artWorn[4]->pos.y = 183;
artWorn[4]->pos.h = artWorn[4]->pos.w = 44;
if(hero->getArt(4))
artWorn[4]->text = hero->getArt(4)->description;
else
artWorn[4]->text = std::string();
artWorn[4]->ourWindow = this;
artWorn[4]->lHand = true;
artWorn[7] = new CArtPlace(hero->getArt(7));
artWorn[7]->pos.x = 610;
artWorn[7]->pos.y = 183;
artWorn[7]->pos.h = artWorn[7]->pos.w = 44;
if(hero->getArt(7))
artWorn[7]->text = hero->getArt(7)->description;
else
artWorn[7]->text = std::string();
artWorn[7]->ourWindow = this;
artWorn[7]->lRing = true;
artWorn[13] = new CArtPlace(hero->getArt(13));
artWorn[13]->pos.x = 564;
artWorn[13]->pos.y = 30;
artWorn[13]->pos.h = artWorn[13]->pos.w = 44;
if(hero->getArt(13))
artWorn[13]->text = hero->getArt(13)->description;
else
artWorn[13]->text = std::string();
artWorn[13]->ourWindow = this;
artWorn[13]->warMachine1 = true;
artWorn[14] = new CArtPlace(hero->getArt(14));
artWorn[14]->pos.x = 610;
artWorn[14]->pos.y = 30;
artWorn[14]->pos.h = artWorn[14]->pos.w = 44;
if(hero->getArt(14))
artWorn[14]->text = hero->getArt(14)->description;
else
artWorn[14]->text = std::string();
artWorn[14]->ourWindow = this;
artWorn[14]->warMachine2 = true;
artWorn[15] = new CArtPlace(hero->getArt(15));
artWorn[15]->pos.x = 610;
artWorn[15]->pos.y = 76;
artWorn[15]->pos.h = artWorn[15]->pos.w = 44;
if(hero->getArt(15))
artWorn[15]->text = hero->getArt(15)->description;
else
artWorn[15]->text = std::string();
artWorn[15]->ourWindow = this;
artWorn[15]->warMachine3 = true;
artWorn[16] = new CArtPlace(hero->getArt(16));
artWorn[16]->pos.x = 610;
artWorn[16]->pos.y = 122;
artWorn[16]->pos.h = artWorn[16]->pos.w = 44;
if(hero->getArt(16))
artWorn[16]->text = hero->getArt(16)->description;
else
artWorn[16]->text = std::string();
artWorn[16]->ourWindow = this;
artWorn[16]->warMachine4 = true;
artWorn[9] = new CArtPlace(hero->getArt(9));
artWorn[9]->pos.x = 383;
artWorn[9]->pos.y = 143;
artWorn[9]->pos.h = artWorn[9]->pos.w = 44;
if(hero->getArt(9))
artWorn[9]->text = hero->getArt(9)->description;
else
artWorn[9]->text = std::string();
artWorn[9]->ourWindow = this;
artWorn[9]->misc1 = true;
artWorn[10] = new CArtPlace(hero->getArt(10));
artWorn[10]->pos.x = 399;
artWorn[10]->pos.y = 194;
artWorn[10]->pos.h = artWorn[10]->pos.w = 44;
if(hero->getArt(10))
artWorn[10]->text = hero->getArt(10)->description;
else
artWorn[10]->text = std::string();
artWorn[10]->ourWindow = this;
artWorn[10]->misc1 = true;
artWorn[11] = new CArtPlace(hero->getArt(11));
artWorn[11]->pos.x = 415;
artWorn[11]->pos.y = 245;
artWorn[11]->pos.h = artWorn[11]->pos.w = 44;
if(hero->getArt(11))
artWorn[11]->text = hero->getArt(11)->description;
else
artWorn[11]->text = std::string();
artWorn[11]->ourWindow = this;
artWorn[11]->misc3 = true;
artWorn[12] = new CArtPlace(hero->getArt(12));
artWorn[12]->pos.x = 431;
artWorn[12]->pos.y = 296;
artWorn[12]->pos.h = artWorn[12]->pos.w = 44;
if(hero->getArt(12))
artWorn[12]->text = hero->getArt(12)->description;
else
artWorn[12]->text = std::string();
artWorn[12]->ourWindow = this;
artWorn[12]->misc4 = true;
artWorn[18] = new CArtPlace(hero->getArt(18));
artWorn[18]->pos.x = 381;
artWorn[18]->pos.y = 296;
artWorn[18]->pos.h = artWorn[18]->pos.w = 44;
if(hero->getArt(18))
artWorn[18]->text = hero->getArt(18)->description;
else
artWorn[18]->text = std::string();
artWorn[18]->ourWindow = this;
artWorn[18]->misc5 = true;
artWorn[2] = new CArtPlace(hero->getArt(2));
artWorn[2]->pos.x = 508;
artWorn[2]->pos.y = 79;
artWorn[2]->pos.h = artWorn[2]->pos.w = 44;
if(hero->getArt(2))
artWorn[2]->text = hero->getArt(2)->description;
else
artWorn[2]->text = std::string();
artWorn[2]->ourWindow = this;
artWorn[2]->neck = true;
artWorn[3] = new CArtPlace(hero->getArt(3));
artWorn[3]->pos.x = 383;
artWorn[3]->pos.y = 68;
artWorn[3]->pos.h = artWorn[3]->pos.w = 44;
if(hero->getArt(3))
artWorn[3]->text = hero->getArt(3)->description;
else
artWorn[3]->text = std::string();
artWorn[3]->ourWindow = this;
artWorn[3]->rHand = true;
artWorn[6] = new CArtPlace(hero->getArt(6));
artWorn[6]->pos.x = 431;
artWorn[6]->pos.y = 68;
artWorn[6]->pos.h = artWorn[6]->pos.w = 44;
if(hero->getArt(6))
artWorn[6]->text = hero->getArt(6)->description;
else
artWorn[6]->text = std::string();
artWorn[6]->ourWindow = this;
artWorn[6]->rRing = true;
artWorn[1] = new CArtPlace(hero->getArt(1));
artWorn[1]->pos.x = 567;
artWorn[1]->pos.y = 240;
artWorn[1]->pos.h = artWorn[1]->pos.w = 44;
if(hero->getArt(1))
artWorn[1]->text = hero->getArt(1)->description;
else
artWorn[1]->text = std::string();
artWorn[1]->ourWindow = this;
artWorn[1]->shoulders = true;
artWorn[17] = new CArtPlace(hero->getArt(17));
artWorn[17]->pos.x = 610;
artWorn[17]->pos.y = 310;
artWorn[17]->pos.h = artWorn[17]->pos.w = 44;
if(hero->getArt(17))
artWorn[17]->text = hero->getArt(17)->description;
else
artWorn[17]->text = std::string();
artWorn[17]->ourWindow = this;
artWorn[17]->spellBook = true;
artWorn[5] = new CArtPlace(hero->getArt(5));
artWorn[5]->pos.x = 509;
artWorn[5]->pos.y = 130;
artWorn[5]->pos.h = artWorn[5]->pos.w = 44;
if(hero->getArt(5))
artWorn[5]->text = hero->getArt(5)->description;
else
artWorn[5]->text = std::string();
artWorn[5]->ourWindow = this;
artWorn[5]->torso = true;
for (int g = 0; g < 19 ; g++)
{
artWorn[g] = new CArtPlace(hero->getArt(g));
artWorn[g]->pos = slotPos[g];
if(hero->getArt(g))
artWorn[g]->text = hero->getArt(g)->description;
artWorn[g]->ourWindow = this;
}
for(int g=0; g<artWorn.size(); ++g)
{
@ -480,25 +289,6 @@ void CHeroWindow::setHero(const CGHeroInstance *Hero)
else
add->text = std::string();
add->ourWindow = this;
add->spellBook = true;
add->warMachine1 = true;
add->warMachine2 = true;
add->warMachine3 = true;
add->warMachine4 = true;
add->misc1 = true;
add->misc2 = true;
add->misc3 = true;
add->misc4 = true;
add->misc5 = true;
add->feet = true;
add->lRing = true;
add->rRing = true;
add->torso = true;
add->lHand = true;
add->rHand = true;
add->neck = true;
add->shoulders = true;
add->head = true;
add->slotID = 19+s;
backpack.push_back(add);
}
@ -857,11 +647,11 @@ void CHeroWindow::redrawCurBack()
CSDL_Ext::printAt(manastr.str(), 212, 247, GEOR16, zwykly, curBack);
}
CArtPlace::CArtPlace(const CArtifact* Art): ourArt(Art), active(false), clicked(false),
CArtPlace::CArtPlace(const CArtifact* Art): ourArt(Art), active(false), clicked(false)/*,
spellBook(false), warMachine1(false), warMachine2(false), warMachine3(false),
warMachine4(false),misc1(false), misc2(false), misc3(false), misc4(false),
misc5(false), feet(false), lRing(false), rRing(false), torso(false),
lHand(false), rHand(false), neck(false), shoulders(false), head(false) {}
lHand(false), rHand(false), neck(false), shoulders(false), head(false) */{}
void CArtPlace::activate()
{
if(!active)
@ -972,19 +762,8 @@ bool CArtPlace::fitsHere(const CArtifact * art)
{
if(!art)
return true; //you can have no artifact somewhere
if( this->spellBook && art->spellBook || this->warMachine1 && art->warMachine1 ||
this->warMachine2 && art->warMachine2 || this->warMachine3 && art->warMachine3 ||
this->warMachine4 && art->warMachine4 || this->misc1 && art->misc1 ||
this->misc2 && art->misc2 || this->misc3 && art->misc3 ||
this->misc4 && art->misc4 || this->misc5 && art->misc5 ||
this->feet && art->feet || this->lRing && art->lRing ||
this->rRing && art->rRing || this->torso && art->torso ||
this->lHand && art->lHand || this->rHand && art->rHand ||
this->neck && art->neck || this->shoulders && art->shoulders ||
this->head && art->head )
{
if(slotID > 18 || vstd::contains(art->possibleSlots,slotID)) //backpack or right slot
return true;
}
return false;
}
CArtPlace::~CArtPlace()

View File

@ -61,9 +61,9 @@ class CArtPlace: public IShowable, public LRClickableAreaWTextComp
private:
bool active;
public:
bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4,
misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso,
lHand, rHand, neck, shoulders, head; //my types
//bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4,
// misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso,
// lHand, rHand, neck, shoulders, head; //my types
ui16 slotID; //0 head 1 shoulders 2 neck 3 right hand 4 left hand 5 torso 6 right ring 7 left ring 8 feet 9 misc. slot 1 10 misc. slot 2 11 misc. slot 3 12 misc. slot 4 13 ballista (war machine 1) 14 ammo cart (war machine 2) 15 first aid tent (war machine 3) 16 catapult 17 spell book 18 misc. slot 5 19+ backpack slots
bool clicked;

View File

@ -293,7 +293,7 @@ void CVisitableOPH::onNAHeroVisit(int objid, int heroID, bool alreadyVisited)
InfoWindow iw;
iw.components.push_back(Component(0,subid,val,0));
iw.text << std::pair<ui8,ui32>(11,ot);
iw.player = cb->getHeroOwner(heroID);
iw.player = cb->getOwner(heroID);
cb->showInfoDialog(&iw);
break;
}
@ -301,7 +301,7 @@ void CVisitableOPH::onNAHeroVisit(int objid, int heroID, bool alreadyVisited)
{
InfoWindow iw;
iw.components.push_back(Component(id,subid,val,0));
iw.player = cb->getHeroOwner(heroID);
iw.player = cb->getOwner(heroID);
iw.text << std::pair<ui8,ui32>(11,ot);
cb->showInfoDialog(&iw);
cb->changePrimSkill(heroID,4,val);
@ -316,7 +316,7 @@ void CVisitableOPH::onNAHeroVisit(int objid, int heroID, bool alreadyVisited)
visitors[objid].insert(heroID);
InfoWindow iw;
iw.components.push_back(Component(id,subid,1,0));
iw.player = cb->getHeroOwner(heroID);
iw.player = cb->getOwner(heroID);
iw.text << std::pair<ui8,ui32>(11,148);
cb->showInfoDialog(&iw);
cb->changePrimSkill(heroID,4,val);
@ -349,7 +349,7 @@ void CVisitableOPH::onNAHeroVisit(int objid, int heroID, bool alreadyVisited)
}
YesNoDialog sd;
sd.player = cb->getHeroOwner(heroID);
sd.player = cb->getOwner(heroID);
sd.text << std::pair<ui8,ui32>(11,ot);
sd.components.push_back(Component(id,subid,val,0));
cb->showYesNoDialog(&sd,CFunctionList<void(ui32)>(boost::bind(&CVisitableOPH::treeSelected,this,objid,heroID,res,resval,val,_1)));
@ -362,7 +362,7 @@ void CVisitableOPH::onNAHeroVisit(int objid, int heroID, bool alreadyVisited)
{
ot++;
InfoWindow iw;
iw.player = cb->getHeroOwner(heroID);
iw.player = cb->getOwner(heroID);
iw.text << std::pair<ui8,ui32>(11,ot);
cb->showInfoDialog(&iw);
}
@ -384,7 +384,7 @@ void CVisitableOPH::treeSelected( int objid, int heroID, int resType, int resVal
{
if(result==0) //player agreed to give res for exp
{
cb->giveResource(cb->getHeroOwner(heroID),resType,-resVal); //take resource
cb->giveResource(cb->getOwner(heroID),resType,-resVal); //take resource
cb->changePrimSkill(heroID,4,expVal); //give exp
visitors[objid].insert(heroID); //set state to visited
}
@ -448,7 +448,7 @@ void CVisitableOPW::onNAHeroVisit(int objid, int heroID, bool alreadyVisited)
else
val = 1000;
}
int player = cb->getHeroOwner(heroID);
int player = cb->getOwner(heroID);
cb->giveResource(player,sub,val);
InfoWindow iw;
iw.player = player;
@ -589,7 +589,7 @@ void CPickable::onHeroVisit(int objid, int heroID)
{
cb->giveHeroArtifact(os->subID,heroID,-1); //TODO: na pozycje
InfoWindow iw;
iw.player = cb->getHeroOwner(heroID);
iw.player = cb->getOwner(heroID);
iw.components.push_back(Component(4,os->subID,0,0));
iw.text << std::pair<ui8,ui32>(12,os->subID);
cb->showInfoDialog(&iw);
@ -599,7 +599,7 @@ void CPickable::onHeroVisit(int objid, int heroID)
{
int val = (rand()%3) + 4, //4 - 6
res = rand()%6,
owner = cb->getHeroOwner(heroID);
owner = cb->getOwner(heroID);
cb->giveResource(owner,res,val); //non-gold resource
cb->giveResource(owner,6,val*100);//gold
InfoWindow iw;
@ -640,10 +640,10 @@ void CPickable::onHeroVisit(int objid, int heroID)
cb->showInfoDialog(&iw);
}
cb->giveResource(cb->getHeroOwner(heroID),os->subID,val);
cb->giveResource(cb->getOwner(heroID),os->subID,val);
ShowInInfobox sii;
sii.player = cb->getHeroOwner(heroID);
sii.player = cb->getOwner(heroID);
sii.c = Component(2,os->subID,val,0);
sii.text << std::pair<ui8,ui32>(11,113);
sii.text.replacements.push_back(VLC->objh->restypes[os->subID]);
@ -680,7 +680,7 @@ void CPickable::onHeroVisit(int objid, int heroID)
}
}
SelectionDialog sd;
sd.player = cb->getHeroOwner(heroID);
sd.player = cb->getOwner(heroID);
sd.text << std::pair<ui8,ui32>(11,146);
sd.components.push_back(Component(2,6,val,0));
sd.components.push_back(Component(5,0,val-500,0));
@ -696,7 +696,7 @@ void CPickable::chosen(ui32 which, int heroid, int val)
switch(which)
{
case 0: //player pick gold
cb->giveResource(cb->getHeroOwner(heroid),6,val);
cb->giveResource(cb->getOwner(heroid),6,val);
break;
case 1: //player pick exp
cb->changePrimSkill(heroid, 4, val-500);

View File

@ -1229,7 +1229,7 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
{
boost::unique_lock<boost::mutex> un(*pim);
//initializing objects and performing first step of move
CGHeroInstance * ho = details.ho; //object representing this hero
const CGHeroInstance * ho = details.ho; //object representing this hero
int3 hp = details.src;
if (!details.successful)
{
@ -1644,8 +1644,6 @@ void CPlayerInterface::heroMoved(const HeroMoveDetails & details)
delObjRect(hp.x, hp.y-1, hp.z, ho->id);
delObjRect(hp.x, hp.y, hp.z, ho->id);
}
ho->pos = details.dst; //copy of hero's position
//ho->moveDir = 0; //move ended
ho->isStanding = true;
//move finished
adventureInt->minimap.draw();
@ -2008,6 +2006,8 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
}
void CPlayerInterface::heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town)
{
if(hero->tempOwner != town->tempOwner)
return;
boost::unique_lock<boost::mutex> un(*pim);
openTownWindow(town);
}

View File

@ -66,6 +66,7 @@
AdditionalLibraryDirectories="G:\vcmt\repa\libs"
GenerateDebugInformation="true"
TargetMachine="1"
Profile="true"
/>
<Tool
Name="VCALinkTool"
@ -142,12 +143,13 @@
Name="VCLinkerTool"
AdditionalDependencies="SDL.lib zdll.lib SDL_image.lib SDL_ttf.lib SDL_mixer.lib lua5.1.lib VCMI_lib.lib"
AdditionalLibraryDirectories="G:\vcmt\repa\libs"
GenerateDebugInformation="false"
GenerateDebugInformation="true"
Driver="0"
OptimizeReferences="2"
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="0"
TargetMachine="1"
Profile="true"
/>
<Tool
Name="VCALinkTool"
@ -230,6 +232,7 @@
EnableCOMDATFolding="2"
LinkTimeCodeGeneration="0"
TargetMachine="1"
Profile="true"
/>
<Tool
Name="VCALinkTool"
@ -557,6 +560,10 @@
>
</File>
</Filter>
<File
RelativePath="..\ChangeLog"
>
</File>
<File
RelativePath=".\ClassDiagram1.cd"
>

View File

@ -1,9 +1,14 @@
4
5
5
5
5
5
3
3
5
9
4 127
5 4
5 5
5 1
5 127
5 3
3 127
3 127
5 1
FORMAT:
#castles
mage_guild_max_level main_res (127 for wood&ore)

View File

@ -116,6 +116,17 @@ namespace vstd
{
return c.find(i)!=c.end();
}
template <typename Container1, typename Container2>
typename Container2::iterator findFirstNot(Container1 &c1, Container2 &c2)//returns first element of c2 not present in c1
{
typename Container2::iterator itr = c2.begin();
while(itr != c2.end())
if(!contains(c1,*itr))
return itr;
else
++itr;
return c2.end();
}
template <typename Container, typename Item>
typename Container::iterator find(const Container & c, const Item &i)
{

View File

@ -13,11 +13,8 @@ CArtHandler::CArtHandler()
}
void CArtHandler::loadArtifacts()
{
std::vector<bool CArtifact::*> slots;
slots += &CArtifact::spellBook, &CArtifact::warMachine4, &CArtifact::warMachine3, &CArtifact::warMachine2,
&CArtifact::warMachine1, &CArtifact::misc5, &CArtifact::misc4, &CArtifact::misc3, &CArtifact::misc2,
&CArtifact::misc1, &CArtifact::feet, &CArtifact::lRing, &CArtifact::rRing, &CArtifact::torso,
&CArtifact::lHand, &CArtifact::rHand, &CArtifact::neck, &CArtifact::shoulders, &CArtifact::head;
std::vector<ui16> slots;
slots += 17, 16, 15,14,13, 18, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0;
std::map<char,EartClass> classes =
map_list_of('S',SartClass)('T',TartClass)('N',NartClass)('J',JartClass)('R',RartClass);
std::string buf = bitmaph->getTextFile("ARTRAITS.TXT"), dump, pom;
@ -35,7 +32,8 @@ void CArtHandler::loadArtifacts()
for(int j=0;j<slots.size();j++)
{
loadToIt(pom,buf,it,4);
nart.*slots[j] = (pom[0]=='x');
if(pom[0]=='x')
nart.possibleSlots.push_back(slots[j]);
}
loadToIt(pom,buf,it,4);
nart.aClass = classes[pom[0]];

View File

@ -15,9 +15,12 @@ public:
std::string description;
//std::string desc2;
unsigned int price;
bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4, misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso, lHand, rHand, neck, shoulders, head;
std::vector<ui16> possibleSlots; //ids of slots where artifact can be placed
//bool spellBook, warMachine1, warMachine2, warMachine3, warMachine4, misc1, misc2, misc3, misc4, misc5, feet, lRing, rRing, torso, lHand, rHand, neck, shoulders, head;
EartClass aClass;
int id;
};
class DLL_EXPORT CArtHandler //handles artifacts

View File

@ -79,10 +79,10 @@ public:
class DLL_EXPORT CGHeroInstance : public CArmedInstance
{
public:
int moveDir; //format: 123
mutable int moveDir; //format: 123
// 8 4
// 765
bool isStanding;
mutable bool isStanding;
CHero * type;
ui32 exp; //experience point
int level; //current level of hero

View File

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

View File

@ -16,7 +16,8 @@ public:
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 typeID;
ui16 primaryRes;
ui8 typeID;
};
struct DLL_EXPORT Structure

View File

@ -241,7 +241,6 @@ void CGameHandler::changePrimSkill(int ID, int which, int val, bool abs)
void CGameHandler::startBattle(CCreatureSet army1, CCreatureSet army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2)
{
BattleInfo *curB = new BattleInfo;
setupBattle(curB, tile, army1, army2, hero1, hero2); //battle start
NEW_ROUND;

View File

@ -64,7 +64,7 @@ void CScriptCallback::changePrimSkill(int ID, int which, int val, bool abs)
gh->changePrimSkill(ID, which, val, abs);
}
int CScriptCallback::getHeroOwner(int heroID)
int CScriptCallback::getOwner(int heroID)
{
return gh->gs->map->objects[heroID]->tempOwner;
}

View File

@ -28,7 +28,7 @@ public:
//get info
static int3 getPos(CGObjectInstance * ob);
int getHeroOwner(int heroID);
int getOwner(int heroID);
int getResource(int player, int which);
int getSelectedHero();
int getDate(int mode=0);