1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-27 12:22:45 +02:00

- fixes for several bugs: #639 #656 #135 #646 #638 #94 #629

- re-enabled console on Linux to allow disabling AI
This commit is contained in:
Ivan Savenko 2011-01-01 20:26:39 +00:00
parent 3d9dc0642d
commit b8f65697ca
14 changed files with 127 additions and 111 deletions

View File

@ -232,7 +232,5 @@ void CConsoleHandler::end()
void CConsoleHandler::start() void CConsoleHandler::start()
{ {
#ifdef _WIN32
thread = new boost::thread(boost::bind(&CConsoleHandler::run,console)); thread = new boost::thread(boost::bind(&CConsoleHandler::run,console));
#endif
} }

View File

@ -298,14 +298,16 @@ BMPPalette * CDefFile::getPalette()
CDefFile::CDefFile(std::string Name):data(NULL),colors(NULL) CDefFile::CDefFile(std::string Name):data(NULL),colors(NULL)
{ {
static SDL_Color H3Palette[8] = {{ 0, 0, 0, 255}, //First 8 colors in def palette used for transparency
{ 0, 0, 0, 192}, static SDL_Color H3Palette[8] = {
/* 5 shadow colors */ { 0, 0, 0, 128}, { 0, 0, 0, 255},// 100% - transparency
{ 0, 0, 0, 64}, { 0, 0, 0, 192},// 75% - shadow border,
{ 0, 0, 0, 32}, { 0, 0, 0, 128},// TODO: find exact value
{255, 255, 0, 255}, { 0, 0, 0, 128},// TODO: for transparency
/* 3 selection highlight color */{255, 255, 0, 255}, { 0, 0, 0, 128},// 50% - shadow body
{255, 255, 0, 255}}; { 0, 0, 0, 255},// 100% - selection highlight
{ 0, 0, 0, 128},// 50% - shadow body below selection
{ 0, 0, 0, 192}};// 75% - shadow border below selection
data = spriteh->giveFile(Name, FILE_ANIMATION, &datasize); data = spriteh->giveFile(Name, FILE_ANIMATION, &datasize);
if (!data) if (!data)

View File

@ -42,17 +42,16 @@ private:
ui32 TopMargin; ui32 TopMargin;
}; };
unsigned int type;
unsigned char * data;
int datasize;
BMPPalette * colors;
//offset[group][frame] - offset of frame data in file //offset[group][frame] - offset of frame data in file
std::vector< std::vector <size_t> > offset; std::vector< std::vector <size_t> > offset;
//sorted list of offsets used to determine size //sorted list of offsets used to determine size
std::set <size_t> offList; std::set <size_t> offList;
unsigned char * data;
BMPPalette * colors;
int datasize;
unsigned int type;
public: public:
CDefFile(std::string Name); CDefFile(std::string Name);
@ -88,33 +87,33 @@ private:
//surface for this entry //surface for this entry
SDL_Surface * surf; SDL_Surface * surf;
//bitfield, location of image data: 1 - def, 2 - file#9.*, 4 - file#9#2.* //data for CompressedAnim
unsigned char source; unsigned char * data;
//reference count, changed by loadFrame \ unloadFrame //reference count, changed by loadFrame \ unloadFrame
size_t refCount; size_t refCount;
//data for CompressedAnim
unsigned char * data;
//size of compressed data, unused for def files //size of compressed data, unused for def files
size_t dataSize; size_t dataSize;
//bitfield, location of image data: 1 - def, 2 - file#9.*, 4 - file#9#2.*
unsigned char source;
AnimEntry(); AnimEntry();
}; };
//animation file name
std::string name;
//if true all frames will be stored in compressed state
const bool compressed;
//palette from def file, used only for compressed anim //palette from def file, used only for compressed anim
BMPPalette * defPalette; BMPPalette * defPalette;
//entries[group][position], store all info regarding frames //entries[group][position], store all info regarding frames
std::vector< std::vector <AnimEntry> > entries; std::vector< std::vector <AnimEntry> > entries;
//animation file name
std::string name;
//if true all frames will be stored in compressed state
const bool compressed;
//loader, will be called by load(), require opened def file for loading from it. Returns true if image is loaded //loader, will be called by load(), require opened def file for loading from it. Returns true if image is loaded
bool loadFrame(CDefFile * file, size_t frame, size_t group); bool loadFrame(CDefFile * file, size_t frame, size_t group);

View File

@ -801,6 +801,8 @@ void CCastleInterface::townChange()
{ {
const CGTownInstance * nt = LOCPLINT->towns[townlist->selected]; const CGTownInstance * nt = LOCPLINT->towns[townlist->selected];
int tpos = townlist->selected - townlist->from; int tpos = townlist->selected - townlist->from;
if ( nt == town )
return;
GH.popIntTotally(this); GH.popIntTotally(this);
GH.pushInt(new CCastleInterface(nt, tpos)); GH.pushInt(new CCastleInterface(nt, tpos));
} }

View File

@ -315,47 +315,26 @@ inline void CCreatureAnimation::putPixel(
{ {
ColorPutter<bpp, 0>::PutColor(p, color.R, color.G, color.B); ColorPutter<bpp, 0>::PutColor(p, color.R, color.G, color.B);
} }
else if((yellowBorder || blueBorder) && (palc == 6 || palc == 7)) //dark yellow border else if((yellowBorder || blueBorder) && (palc == 6 || palc == 7)) //selection highlight
{ {
if(blueBorder) if(blueBorder)
ColorPutter<bpp, 0>::PutColor(p, 0, 0x0f + animCount, 0x0f + animCount); ColorPutter<bpp, 0>::PutColor(p, 0, 0x0f + animCount, 0x0f + animCount);
else else
ColorPutter<bpp, 0>::PutColor(p, 0x0f + animCount, 0x0f + animCount, 0); ColorPutter<bpp, 0>::PutColor(p, 0x0f + animCount, 0x0f + animCount, 0);
} }
else if((yellowBorder || blueBorder) && (palc == 5)) //yellow border else if (palc == 5) //selection highlight or transparent
{ {
if(blueBorder) if(blueBorder)
ColorPutter<bpp, 0>::PutColor(p, color.B, color.G - 0xf0 + animCount, color.R - 0xf0 + animCount); //shouldnt it be reversed? its bgr instead of rgb ColorPutter<bpp, 0>::PutColor(p, color.B, color.G - 0xf0 + animCount, color.R - 0xf0 + animCount); //shouldnt it be reversed? its bgr instead of rgb
else else if (yellowBorder)
ColorPutter<bpp, 0>::PutColor(p, color.R - 0xf0 + animCount, color.G - 0xf0 + animCount, color.B); ColorPutter<bpp, 0>::PutColor(p, color.R - 0xf0 + animCount, color.G - 0xf0 + animCount, color.B);
} }
else if(palc < 5) //shadow else //shadow
{ {
//determining transparency value, 255 or 0 should be already filtered
Uint16 alpha; Uint16 alpha;
switch(color.G) static Uint16 colToAlpha[8] = {255,192,128,128,128,255,128,192};
{ alpha = colToAlpha[palc];
case 0:
alpha = 128;
break;
case 50:
alpha = 50+32;
break;
case 100:
alpha = 100+64;
break;
case 125:
alpha = 125+64;
break;
case 128:
alpha = 128+64;
break;
case 150:
alpha = 150+64;
break;
default:
alpha = 255;
break;
}
if(bpp != 3 && bpp != 4) if(bpp != 3 && bpp != 4)
{ {

View File

@ -740,7 +740,7 @@ CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
secondarySkills[i]->pos = genRect(32, 32, pos.x+410+i*37, pos.y+5); secondarySkills[i]->pos = genRect(32, 32, pos.x+410+i*37, pos.y+5);
secondarySkills[i]->baseType = 1; secondarySkills[i]->baseType = 1;
}; };
/*
for (int i=0; i<18;i++) for (int i=0; i<18;i++)
{ {
artifacts.push_back(new CArtPlace(this)); artifacts.push_back(new CArtPlace(this));
@ -753,7 +753,7 @@ CKingdomInterface::CHeroItem::CHeroItem(int num, CKingdomInterface * Owner)
backpack.push_back(new CArtPlace(this)); backpack.push_back(new CArtPlace(this));
backpack[i]->pos = genRect(44, 44, pos.x+293+(i%9)*48, pos.y+66); backpack[i]->pos = genRect(44, 44, pos.x+293+(i%9)*48, pos.y+66);
backpack[i]->baseType = SComponent::artifact; backpack[i]->baseType = SComponent::artifact;
}; };*/
} }
@ -911,21 +911,21 @@ void CKingdomInterface::CHeroItem::showAll(SDL_Surface * to)
{//arts {//arts
case 1:iter = 9;//misc. arts, spellbook, war machines case 1:iter = 9;//misc. arts, spellbook, war machines
case 0://equipped arts case 0://equipped arts
for (int i = iter ; i<iter+9;i++) /*for (int i = iter ; i<iter+9;i++)
{ {
int artID = hero->getArtAtPos(i)->id; int artID = hero->getArtAtPos(i)->id;
if (artID>=0) if (artID>=0)
blitAt(graphics->artDefs->ourImages[artID].bitmap,pos.x+268+48*(i%9),pos.y+66,to); blitAt(graphics->artDefs->ourImages[artID].bitmap,pos.x+268+48*(i%9),pos.y+66,to);
} }*/
break; break;
case 2: case 2:
artLeft->show(to); artLeft->show(to);
artRight->show(to); artRight->show(to);
int max = hero->artifacts.size(); int max = hero->artifacts.size();
iter = std::min(8, max); iter = std::min(8, max);
for (size_t it = 0 ; it<iter;it++) /*for (size_t it = 0 ; it<iter;it++)
blitAt(graphics->artDefs->ourImages[hero->artifacts[(it+backpackPos)%max]->id].bitmap,pos.x+293+48*it,pos.y+66,to); blitAt(graphics->artDefs->ourImages[hero->artifacts[(it+backpackPos)%max]->id].bitmap,pos.x+293+48*it,pos.y+66,to);
break; */break;
} }
show(to); show(to);
} }
@ -946,7 +946,7 @@ void CKingdomInterface::CHeroItem::activate()
if (!hero) if (!hero)
return; return;
artButtons->activate(); artButtons->activate();
garr->activate(); garr->activate();/*
if ( artGroup == 2 ) if ( artGroup == 2 )
{ {
artLeft->activate(); artLeft->activate();
@ -958,7 +958,7 @@ void CKingdomInterface::CHeroItem::activate()
{ {
for (size_t i=artGroup*9; i<9+artGroup*9;i++) for (size_t i=artGroup*9; i<9+artGroup*9;i++)
artifacts[i]->activate(); artifacts[i]->activate();
} }*/
portrait->activate(); portrait->activate();
experience->activate(); experience->activate();
morale->activate(); morale->activate();
@ -978,7 +978,7 @@ void CKingdomInterface::CHeroItem::deactivate()
if (!hero) if (!hero)
return; return;
artButtons->deactivate(); artButtons->deactivate();
garr->deactivate(); garr->deactivate();/*
if ( artGroup == 2 ) if ( artGroup == 2 )
{ {
artLeft->deactivate(); artLeft->deactivate();
@ -990,7 +990,7 @@ void CKingdomInterface::CHeroItem::deactivate()
{ {
for (size_t i=artGroup*9; i<9+artGroup*9;i++) for (size_t i=artGroup*9; i<9+artGroup*9;i++)
artifacts[i]->deactivate(); artifacts[i]->deactivate();
} }*/
portrait->deactivate(); portrait->deactivate();
experience->deactivate(); experience->deactivate();

View File

@ -81,8 +81,8 @@ class CKingdomInterface : public CGarrisonHolder
LRClickableAreaWText * speciality; LRClickableAreaWText * speciality;
std::vector<LRClickableAreaWTextComp *> primarySkills; std::vector<LRClickableAreaWTextComp *> primarySkills;
std::vector<LRClickableAreaWTextComp *> secondarySkills; std::vector<LRClickableAreaWTextComp *> secondarySkills;
std::vector<LRClickableAreaWTextComp *> artifacts; std::vector<CArtPlace *> artifacts;
std::vector<LRClickableAreaWTextComp *> backpack; std::vector<CArtPlace *> backpack;
CHighlightableButtonsGroup * artButtons; CHighlightableButtonsGroup * artButtons;
void setHero(const CGHeroInstance * newHero);//change hero and update info void setHero(const CGHeroInstance * newHero);//change hero and update info
void scrollArts(int move);//moving backpack, receiving distance void scrollArts(int move);//moving backpack, receiving distance

View File

@ -102,11 +102,13 @@ SDL_Surface * CMessage::drawBox1(int w, int h, int playerColor) //draws box for
{ {
//prepare surface //prepare surface
SDL_Surface * ret = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask); SDL_Surface * ret = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
for (int i=0; i<h; i+=background->h)//background for (int i=0; i<w; i+=background->w)//background
{ {
for (int j=0; j<w; j+=background->w) for (int j=0; j<h; j+=background->h)
{ {
CSDL_Ext::blitSurface(background,&genRect(background->h,background->w,0,0),ret,&genRect(h,w,j,i)); //FIXME taking address of temporary Rect srcR(0,0,background->w, background->h);
Rect dstR(i,j,w,h);
CSDL_Ext::blitSurface(background, &srcR, ret, &dstR);
} }
} }
drawBorder(playerColor, ret, w, h); drawBorder(playerColor, ret, w, h);
@ -486,31 +488,41 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, int player)
void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int x, int y) void CMessage::drawBorder(int playerColor, SDL_Surface * ret, int w, int h, int x, int y)
{ {
std::vector<SDL_Surface *> &box = piecesOfBox[playerColor];
//obwodka I-szego rzedu pozioma //border of 1st series, horizontal //obwodka I-szego rzedu pozioma //border of 1st series, horizontal
for (int i=0; i<w-piecesOfBox[playerColor][6]->w; i+=piecesOfBox[playerColor][6]->w) for (int i=0; i<w-box[6]->w; i+=box[6]->w)
{ {
CSDL_Ext::blitSurface Rect dstR(x+i, y, box[6]->w, box[6]->h);
(piecesOfBox[playerColor][6],NULL,ret,&genRect(piecesOfBox[playerColor][6]->h,piecesOfBox[playerColor][6]->w,x+i,y+0)); CSDL_Ext::blitSurface(box[6], NULL, ret, &dstR);
CSDL_Ext::blitSurface
(piecesOfBox[playerColor][7],NULL,ret,&genRect(piecesOfBox[playerColor][7]->h,piecesOfBox[playerColor][7]->w,x+i,y+h-piecesOfBox[playerColor][7]->h+1)); int currY = y+h-box[7]->h+1;
dstR=Rect(x+i, currY, box[7]->w, box[7]->h);
CSDL_Ext::blitSurface(box[7], NULL, ret, &dstR);
} }
//obwodka I-szego rzedu pionowa //border of 1st series, vertical //obwodka I-szego rzedu pionowa //border of 1st series, vertical
for (int i=0; i<h-piecesOfBox[playerColor][4]->h; i+=piecesOfBox[playerColor][4]->h) for (int i=0; i<h-box[4]->h; i+=box[4]->h)
{ {
CSDL_Ext::blitSurface Rect dstR(x, y+i, box[4]->w, box[4]->h);
(piecesOfBox[playerColor][4],NULL,ret,&genRect(piecesOfBox[playerColor][4]->h,piecesOfBox[playerColor][4]->w,x+0,y+i)); CSDL_Ext::blitSurface(box[4], NULL, ret, &dstR);
CSDL_Ext::blitSurface
(piecesOfBox[playerColor][5],NULL,ret,&genRect(piecesOfBox[playerColor][5]->h,piecesOfBox[playerColor][5]->w,x+w-piecesOfBox[playerColor][5]->w,y+i)); int currX = x+w-box[5]->w;
dstR=Rect(currX, y+i, box[5]->w, box[5]->h);
CSDL_Ext::blitSurface(box[5], NULL, ret, &dstR);
} }
//corners //corners
CSDL_Ext::blitSurface Rect dstR(x, y, box[0]->w, box[0]->h);
(piecesOfBox[playerColor][0],NULL,ret,&genRect(piecesOfBox[playerColor][0]->h,piecesOfBox[playerColor][0]->w,x+0,y+0)); CSDL_Ext::blitSurface(box[0], NULL, ret, &dstR);
CSDL_Ext::blitSurface
(piecesOfBox[playerColor][1],NULL,ret,&genRect(piecesOfBox[playerColor][1]->h,piecesOfBox[playerColor][1]->w,x+w-piecesOfBox[playerColor][1]->w,y+0)); dstR=Rect(x+w-box[1]->w, y, box[1]->w, box[1]->h);
CSDL_Ext::blitSurface CSDL_Ext::blitSurface(box[1], NULL, ret, &dstR);
(piecesOfBox[playerColor][2],NULL,ret,&genRect(piecesOfBox[playerColor][2]->h,piecesOfBox[playerColor][2]->w,x+0,y+h-piecesOfBox[playerColor][2]->h+1));
CSDL_Ext::blitSurface dstR=Rect(x, y+h-box[2]->h+1, box[2]->w, box[2]->h);
(piecesOfBox[playerColor][3],NULL,ret,&genRect(piecesOfBox[playerColor][3]->h,piecesOfBox[playerColor][3]->w,x+w-piecesOfBox[playerColor][3]->w,y+h-piecesOfBox[playerColor][3]->h+1)); CSDL_Ext::blitSurface(box[2], NULL, ret, &dstR);
dstR=Rect(x+w-box[3]->w, y+h-box[3]->h+1, box[3]->w, box[3]->h);
CSDL_Ext::blitSurface(box[3], NULL, ret, &dstR);
} }
ComponentResolved::ComponentResolved() ComponentResolved::ComponentResolved()
@ -526,7 +538,7 @@ ComponentResolved::ComponentResolved( SComponent *Comp )
comp = Comp; comp = Comp;
img = comp->getImg(); img = comp->getImg();
std::vector<std::string> brtext = CMessage::breakText(comp->subtitle,13); //text std::vector<std::string> brtext = CMessage::breakText(comp->subtitle,13); //text
txt = CMessage::drawText(&brtext,txtFontHeight,FONT_MEDIUM); txt = CMessage::drawText(&brtext,txtFontHeight,FONT_SMALL);
//calculate dimensions //calculate dimensions
std::pair<int,int> textSize = CMessage::getMaxSizes(txt, txtFontHeight); std::pair<int,int> textSize = CMessage::getMaxSizes(txt, txtFontHeight);
@ -611,25 +623,24 @@ void ComponentsToBlit::blitCompsOnSur( SDL_Surface * _or, int inter, int &curh,
totalw += (inter) * ((comps)[i].size() - 1); totalw += (inter) * ((comps)[i].size() - 1);
} }
curh+=maxh/2; int middleh = curh + maxh/2;//axis for image aligment
int compX, compY;
int curw = (ret->w/2)-(totalw/2); int curw = (ret->w/2)-(totalw/2);
for(size_t j=0;j<(comps)[i].size();j++) for(size_t j=0;j<(comps)[i].size();j++)
{ {
ComponentResolved *cur = (comps)[i][j]; ComponentResolved *cur = (comps)[i][j];
//blit img //blit img
compX = curw + ( cur->comp->pos.w - cur->comp->getImg()->w ) / 2; int imgX = curw + ( cur->comp->pos.w - cur->comp->getImg()->w ) / 2;
compY = curh - cur->comp->getImg()->h / 2; int imgY = middleh - cur->comp->getImg()->h / 2;
blitAt(cur->img, compX, compY, ret); blitAt(cur->img, imgX, imgY, ret);
cur->comp->pos.x = compX; cur->comp->pos.x = imgX;
cur->comp->pos.y = compY; cur->comp->pos.y = imgY;
//blit subtitle //blit subtitle
compX += cur->comp->getImg()->w/2; int textX = imgX + cur->comp->getImg()->w/2;
compY = curh + maxh / 2 + COMPONENT_TO_SUBTITLE; int textY = middleh + cur->comp->getImg()->h /2 + COMPONENT_TO_SUBTITLE;
CMessage::blitTextOnSur(cur->txt, cur->txtFontHeight, compY, ret, compX ); CMessage::blitTextOnSur(cur->txt, cur->txtFontHeight, textY, ret, textX );
//if there is subsequent component blit "or" //if there is subsequent component blit "or"
curw += cur->comp->pos.w; curw += cur->comp->pos.w;
@ -638,12 +649,13 @@ void ComponentsToBlit::blitCompsOnSur( SDL_Surface * _or, int inter, int &curh,
if(_or) if(_or)
{ {
curw+=inter; curw+=inter;
blitAt(_or,curw,curh-(_or->h/2),ret); blitAt(_or,curw,middleh-(_or->h/2),ret);
curw+=_or->w; curw+=_or->w;
} }
curw+=inter; curw+=inter;
} }
amax(curh, textY);
} }
curh = compY+BETWEEN_COMPS_ROWS; curh += BETWEEN_COMPS_ROWS;
} }
} }

View File

@ -3487,7 +3487,7 @@ CAltarWindow::CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero /*=
{ {
BLOCK_CAPTURING; BLOCK_CAPTURING;
arts = new CArtifactsOfHero(Point(-267,-10)); arts = new CArtifactsOfHero(Point(pos.x-363, pos.y-12));
arts->commonInfo = new CArtifactsOfHero::SCommonPart; arts->commonInfo = new CArtifactsOfHero::SCommonPart;
arts->commonInfo->participants.insert(arts); arts->commonInfo->participants.insert(arts);
arts->setHero(Hero); arts->setHero(Hero);
@ -5858,7 +5858,10 @@ void CUniversityWindow::CItem::showAll(SDL_Surface * to)
break; break;
case 2: bar = parent->green; case 2: bar = parent->green;
break; break;
default:bar = NULL;
break;
} }
assert(bar);
blitAtLoc(bar->bg, -28, -22, to); blitAtLoc(bar->bg, -28, -22, to);
blitAtLoc(bar->bg, -28, 48, to); blitAtLoc(bar->bg, -28, 48, to);

View File

@ -73,7 +73,7 @@
71 1 SP01_.DEF 71 1 SP01_.DEF
72 1 SP04_.DEF 72 1 SP04_.DEF
73 1 SP03_.DEF 73 1 SP03_.DEF
74 1 SP06_.DEF 74 1 SP12_.DEF
75 1 SP07_A.DEF 75 1 SP07_A.DEF
76 1 SP07_B.DEF 76 1 SP07_B.DEF
77 1 SP08_.DEF 77 1 SP08_.DEF

View File

@ -116,8 +116,8 @@
2 43 TBTWUP_6.def 75 91 2 43 TBTWUP_6.def 75 91
2 8 TBTWCAS2.def 301 0 2 8 TBTWCAS2.def 301 0
3 16 TBINBLAK.def 684 253 3 16 TBINBLAK.def 684 253
3 9 TBINCAS3.def 223 18 3 9 TBINCAS3.def 222 18
3 7 TBINCSTL.def 223 44 3 7 TBINCSTL.def 222 44
3 30 TBINDW_0.def 614 256 3 30 TBINDW_0.def 614 256
3 31 TBINDW_1.def 187 248 3 31 TBINDW_1.def 187 248
3 32 TBINDW_2.def 9 325 3 32 TBINDW_2.def 9 325

View File

@ -555,6 +555,13 @@ bool CVideoPlayer::playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey)
#else #else
//Workaround for compile error in ffmpeg (UINT_64C was not declared)
#define __STDC_CONSTANT_MACROS
#ifdef _STDINT_H
#undef _STDINT_H
#endif
#include <stdint.h>
#include <../client/SDL_framerate.h> #include <../client/SDL_framerate.h>
extern "C" { extern "C" {

View File

@ -212,6 +212,10 @@ public:
{ {
return firstOccurence < b.firstOccurence; return firstOccurence < b.firstOccurence;
} }
bool operator<=(const CMapEvent &b) const
{
return firstOccurence <= b.firstOccurence;
}
}; };
class DLL_EXPORT CCastleEvent: public CMapEvent class DLL_EXPORT CCastleEvent: public CMapEvent

View File

@ -4554,8 +4554,13 @@ void CGameHandler::handleTimeEvents()
if(ev->nextOccurence) if(ev->nextOccurence)
{ {
gs->map->events.pop_front();
ev->firstOccurence += ev->nextOccurence; ev->firstOccurence += ev->nextOccurence;
gs->map->events.sort(evntCmp); std::list<CMapEvent*>::iterator it = gs->map->events.begin();
while ( it !=gs->map->events.end() && **it <= *ev )
it++;
gs->map->events.insert(it, ev);
} }
else else
{ {
@ -4616,8 +4621,13 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n, std::map<
if(ev->nextOccurence) if(ev->nextOccurence)
{ {
town->events.pop_front();
ev->firstOccurence += ev->nextOccurence; ev->firstOccurence += ev->nextOccurence;
town->events.sort(evntCmp); std::list<CCastleEvent*>::iterator it = town->events.begin();
while ( it !=town->events.end() && **it <= *ev )
it++;
town->events.insert(it, ev);
} }
else else
{ {