From aad61c8ac8392befe00df4d6992c0fea00c31599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20W=2E=20Urba=C5=84czyk?= Date: Mon, 27 Jul 2009 12:29:10 +0000 Subject: [PATCH] Fixed exchanging artifacts between heroes. Fixed def visibility issues. Refactored alphaTransform. --- client/SDL_Extensions.cpp | 54 ++++----------------------------------- mapHandler.cpp | 8 +++--- server/CGameHandler.cpp | 2 +- 3 files changed, 10 insertions(+), 54 deletions(-) diff --git a/client/SDL_Extensions.cpp b/client/SDL_Extensions.cpp index 4b8a8fd80..31dad733e 100644 --- a/client/SDL_Extensions.cpp +++ b/client/SDL_Extensions.cpp @@ -403,56 +403,12 @@ Uint32 CSDL_Ext::SDL_GetPixel(SDL_Surface *surface, const int & x, const int & y void CSDL_Ext::alphaTransform(SDL_Surface *src) { - Uint32 trans = SDL_MapRGBA(src->format, 0, 255, 255, 255); - SDL_SetColorKey(src, 0, trans); - src->flags|=SDL_SRCALPHA; + assert(src->format->BitsPerPixel == 8); + SDL_Color colors[] = {{0,0,0,255}, {0,0,0,214}, {0,0,0,164}, {0,0,0,82}, {0,0,0,128}, + {255,0,0,0}, {255,0,0,0}, {255,0,0,0}, {0,0,0,192}, {0,0,0,192}}; - SDL_Color transp; - transp.b = transp.g = transp.r = 0; - transp.unused = 255; - - if(src->format->BitsPerPixel == 8) - { - for(int yy=0; yyformat->palette->ncolors; ++yy) - { - SDL_Color cur = *(src->format->palette->colors+yy); - //if(cur.r == 255 && cur.b == 255) - if(yy==1 || yy==2 || yy==3 || yy==4 || yy==8 || yy==9) - { - SDL_Color shadow; - shadow.b = shadow.g = shadow.r = 0; - switch(cur.g) //change this values; make diffrerent for objects and shadows (?) - { - case 0: - shadow.unused = 128; - break; - case 50: - shadow.unused = 50+32; - break; - case 100: - shadow.unused = 100+64; - break; - case 125: - shadow.unused = 125+64; - break; - case 128: - shadow.unused = 128+64; - break; - case 150: - shadow.unused = 150+64; - break; - default: - shadow.unused = 255; - break; - } - SDL_SetColors(src, &shadow, yy, 1); - } - if(yy==0 || (cur.r == 255 && cur.g == 0 && cur.b == 0)) - { - SDL_SetColors(src, &transp, yy, 1); - } - } - } + SDL_SetColors(src, colors, 0, ARRAY_COUNT(colors)); + SDL_SetColorKey(src, SDL_SRCCOLORKEY, SDL_MapRGBA(src->format, 0, 0, 0, 255)); } // <=> diff --git a/mapHandler.cpp b/mapHandler.cpp index c08d41139..1bbbb116c 100644 --- a/mapHandler.cpp +++ b/mapHandler.cpp @@ -422,9 +422,9 @@ static void processDef (CGDefInfo* def) } void CMapHandler::initHeroDef(CGHeroInstance * h) { - //h->defInfo->handler = graphics->flags1[0]; - //h->defInfo->width = h->defInfo->handler->ourImages[0].bitmap->w/32; - //h->defInfo->height = h->defInfo->handler->ourImages[0].bitmap->h/32; + h->defInfo->handler = graphics->flags1[0]; + h->defInfo->width = h->defInfo->handler->ourImages[0].bitmap->w/32; + h->defInfo->height = h->defInfo->handler->ourImages[0].bitmap->h/32; } void CMapHandler::init() { @@ -723,7 +723,7 @@ void CMapHandler::terrainRect(int3 top_tile, unsigned char anim, std::vector< st const CGObjectInstance *obj = objects[h].first; ui8 color = obj->tempOwner; //checking if object has non-empty graphic on this tile - if(!obj->coveringAt(obj->pos.x - (top_tile.x + bx), top_tile.y + by - obj->pos.y + 5)) + if(obj->ID != HEROI_TYPE && !obj->coveringAt(obj->pos.x - (top_tile.x + bx), top_tile.y + by - obj->pos.y + 5)) continue; SDL_Rect sr; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index be80c7cad..1c34ae43a 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -2121,7 +2121,7 @@ bool CGameHandler::swapArtifacts( si32 hid1, si32 hid2, ui16 slot1, ui16 slot2 ) sha.hid = hid2; sha.artifacts = h2->artifacts; sha.artifWorn = h2->artifWorn; - sha.setArtAtPos(slot2,h1->getArtAtPos(slot1)); + sha.setArtAtPos(slot2, a1 ? a1->id : -1); sendAndApply(&sha); }