1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-31 22:05:10 +02:00

* CPU usage decreased

* it's impossible to select empty artifact slot in hero window
This commit is contained in:
mateuszb 2008-02-12 17:40:01 +00:00
parent 4a655a0ad1
commit d5a4dcc6cd
4 changed files with 25 additions and 14 deletions

View File

@ -546,10 +546,11 @@ void CTerrainRect::show()
SDL_Surface * teren = CGI->mh->terrainRect SDL_Surface * teren = CGI->mh->terrainRect
(LOCPLINT->adventureInt->position.x,LOCPLINT->adventureInt->position.y, (LOCPLINT->adventureInt->position.x,LOCPLINT->adventureInt->position.y,
tilesw,tilesh,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim, tilesw,tilesh,LOCPLINT->adventureInt->position.z,LOCPLINT->adventureInt->anim,
LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim LOCPLINT->cb->getVisibilityMap(), true, LOCPLINT->adventureInt->heroAnim,
ekran,&genRect(547,594,7,6)
); );
SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),ekran,&genRect(547,594,7,6)); //SDL_BlitSurface(teren,&genRect(pos.h,pos.w,0,0),ekran,&genRect(547,594,7,6));
SDL_FreeSurface(teren); //SDL_FreeSurface(teren);
if (currentPath && LOCPLINT->adventureInt->position.z==currentPath->startPos().z) //drawing path if (currentPath && LOCPLINT->adventureInt->position.z==currentPath->startPos().z) //drawing path
{ {
showPath(); showPath();

View File

@ -890,8 +890,11 @@ void CArtPlace::clickLeft(boost::logic::tribool down)
{ {
if(!ourWindow->activeArtPlace) //nothing has benn clicked if(!ourWindow->activeArtPlace) //nothing has benn clicked
{ {
clicked = true; if(ourArt) //to prevent selecting empty slots (bugfix to what GrayFace reported)
ourWindow->activeArtPlace = this; {
clicked = true;
ourWindow->activeArtPlace = this;
}
} }
else //perform artifact substitution else //perform artifact substitution
{ {

View File

@ -438,7 +438,7 @@ SDL_Surface * CSDL_Ext::alphaTransform(SDL_Surface *src)
{ {
SDL_Color cur = *(src->format->palette->colors+yy); SDL_Color cur = *(src->format->palette->colors+yy);
//if(cur.r == 255 && cur.b == 255) //if(cur.r == 255 && cur.b == 255)
if(yy==1 || yy==2 || yy==3 || yy==4 || yy==8) if(yy==1 || yy==2 || yy==3 || yy==4 || yy==8 || yy==9)
{ {
SDL_Color shadow; SDL_Color shadow;
shadow.b = shadow.g = shadow.r = 0; shadow.b = shadow.g = shadow.r = 0;

View File

@ -841,7 +841,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
sr.x=bx*32; sr.x=bx*32;
sr.h=sr.w=32; sr.h=sr.w=32;
validateRectTerr(&sr, extRect); validateRectTerr(&sr, extRect);
SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap[anim%ttiles[x+bx][y+by][level].terbitmap.size()],NULL,su,&sr); SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap[anim%ttiles[x+bx][y+by][level].terbitmap.size()],&genRect(sr.h, sr.w, 0, 0),su,&sr);
} }
} }
////terrain printed ////terrain printed
@ -857,7 +857,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
validateRectTerr(&sr, extRect); validateRectTerr(&sr, extRect);
if(ttiles[x+bx][y+by][level].rivbitmap.size()) if(ttiles[x+bx][y+by][level].rivbitmap.size())
{ {
CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].rivbitmap[anim%ttiles[x+bx][y+by][level].rivbitmap.size()],NULL,su,&sr); CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].rivbitmap[anim%ttiles[x+bx][y+by][level].rivbitmap.size()],&genRect(sr.h, sr.w, 0, 0),su,&sr);
} }
} }
} }
@ -876,7 +876,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
validateRectTerr(&sr, extRect); validateRectTerr(&sr, extRect);
if(ttiles[x+bx][y+by][level].roadbitmap.size()) if(ttiles[x+bx][y+by][level].roadbitmap.size())
{ {
CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].roadbitmap[anim%ttiles[x+bx][y+by][level].roadbitmap.size()],NULL,su,&sr); CSDL_Ext::blit8bppAlphaTo24bpp(ttiles[x+bx][y+by][level].roadbitmap[anim%ttiles[x+bx][y+by][level].roadbitmap.size()], &genRect(sr.h, sr.w, 0, (by==-1 ? 16 : 0)),su,&sr);
} }
} }
} }
@ -897,6 +897,8 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
validateRectTerr(&sr, extRect); validateRectTerr(&sr, extRect);
SDL_Rect pp = ttiles[x+bx][y+by][level].objects[h].second; SDL_Rect pp = ttiles[x+bx][y+by][level].objects[h].second;
pp.h = sr.h;
pp.w = sr.w;
CGHeroInstance * themp = (dynamic_cast<CGHeroInstance*>(ttiles[x+bx][y+by][level].objects[h].first)); CGHeroInstance * themp = (dynamic_cast<CGHeroInstance*>(ttiles[x+bx][y+by][level].objects[h].first));
if(themp && themp->moveDir && !themp->isStanding && themp->ID!=62) //last condition - this is not prison if(themp && themp->moveDir && !themp->isStanding && themp->ID!=62) //last condition - this is not prison
@ -978,7 +980,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
if(bx+x>=0 && by+y>=0 && bx+x<CGI->mh->reader->map.width && by+y<CGI->mh->reader->map.height && !visibilityMap[bx+x][by+y][level]) if(bx+x>=0 && by+y>=0 && bx+x<CGI->mh->reader->map.width && by+y<CGI->mh->reader->map.height && !visibilityMap[bx+x][by+y][level])
{ {
SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibilityMap, level); SDL_Surface * hide = getVisBitmap(bx+x, by+y, visibilityMap, level);
CSDL_Ext::blit8bppAlphaTo24bpp(hide, NULL, su, &sr); CSDL_Ext::blit8bppAlphaTo24bpp(hide, &genRect(sr.h, sr.w, 0, 0), su, &sr);
} }
} }
} }
@ -996,7 +998,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
sr.h=sr.w=32; sr.h=sr.w=32;
validateRectTerr(&sr, extRect); validateRectTerr(&sr, extRect);
SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap[anim%ttiles[x+bx][y+by][level].terbitmap.size()],NULL,su,&sr); SDL_BlitSurface(ttiles[x+bx][y+by][level].terbitmap[anim%ttiles[x+bx][y+by][level].terbitmap.size()],&genRect(sr.h, sr.w, 0, 0),su,&sr);
} }
else else
{ {
@ -1014,7 +1016,7 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
*((unsigned char*)(ns->pixels) + f) = 128; *((unsigned char*)(ns->pixels) + f) = 128;
} }
SDL_BlitSurface(ns,NULL,su,&sr); SDL_BlitSurface(ns,&genRect(sr.h, sr.w, 0, 0),su,&sr);
SDL_FreeSurface(ns); SDL_FreeSurface(ns);
} }
@ -1032,14 +1034,13 @@ SDL_Surface * CMapHandler::terrainRect(int x, int y, int dx, int dy, int level,
*((unsigned char*)(ns->pixels) + f) = 128; *((unsigned char*)(ns->pixels) + f) = 128;
} }
SDL_BlitSurface(ns,NULL,su,&sr); SDL_BlitSurface(ns,&genRect(sr.h, sr.w, 0, 0),su,&sr);
SDL_FreeSurface(ns); SDL_FreeSurface(ns);
} }
} }
} }
} }
CSDL_Ext::update(su);
//borders printed //borders printed
return su; return su;
} }
@ -1635,5 +1636,11 @@ void CMapHandler::validateRectTerr(SDL_Rect * val, const SDL_Rect * ext)
{ {
val->h = ext->y+ext->h-val->y; val->h = ext->y+ext->h-val->y;
} }
//for sign problems
if(val->h > 20000 || val->w > 20000)
{
val->h = val->w = 0;
}
} }
} }