hedgewars/uStore.pas
changeset 3513 f589230fa21b
parent 3509 d72c2219595d
child 3523 6592fbb969da
equal deleted inserted replaced
3512:6a8b5f313190 3513:f589230fa21b
   248         if flagsurf = nil then
   248         if flagsurf = nil then
   249             flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone);
   249             flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone);
   250         TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true);
   250         TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true);
   251         copyToXY(flagsurf, texsurf, 2, 2);
   251         copyToXY(flagsurf, texsurf, 2, 2);
   252         SDL_FreeSurface(flagsurf);
   252         SDL_FreeSurface(flagsurf);
       
   253         flagsurf:= nil;
   253         
   254         
   254         // restore black border pixels inside the flag
   255         // restore black border pixels inside the flag
   255         PLongwordArray(texsurf^.pixels)^[32 * 2 +  2]:= cNearBlackColor;
   256         PLongwordArray(texsurf^.pixels)^[32 * 2 +  2]:= cNearBlackColor;
   256         PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor;
   257         PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor;
   257         PLongwordArray(texsurf^.pixels)^[32 * 16 +  2]:= cNearBlackColor;
   258         PLongwordArray(texsurf^.pixels)^[32 * 16 +  2]:= cNearBlackColor;
   258         PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor;
   259         PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor;
   259 
   260 
   260         FlagTex:= Surface2Tex(texsurf, false);
   261         FlagTex:= Surface2Tex(texsurf, false);
   261         SDL_FreeSurface(texsurf);
   262         SDL_FreeSurface(texsurf);
   262         texsurf:= nil;
       
   263 
   263 
   264         dec(drY, r.h + 2);
   264         dec(drY, r.h + 2);
   265         DrawHealthY:= drY;
   265         DrawHealthY:= drY;
   266         for i:= 0 to 7 do
   266         for i:= 0 to 7 do
   267             with Hedgehogs[i] do
   267             with Hedgehogs[i] do
   272                         begin
   272                         begin
   273                         if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then
   273                         if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then
   274                             texsurf:= LoadImage(Pathz[ptHats] + '/Reserved/' + Copy(Hat,9,Length(s)-8), ifNone)
   274                             texsurf:= LoadImage(Pathz[ptHats] + '/Reserved/' + Copy(Hat,9,Length(s)-8), ifNone)
   275                         else
   275                         else
   276                             texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone);
   276                             texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone);
   277                         if texsurf <> nil then
   277                             if texsurf <> nil then
   278                             begin
   278                             begin
   279                             HatTex:= Surface2Tex(texsurf, true);
   279                                 HatTex:= Surface2Tex(texsurf, true);
   280                             SDL_FreeSurface(texsurf)
   280                                 SDL_FreeSurface(texsurf)
   281                             end
   281                             end;
       
   282                             texsurf:= nil;
   282                         end
   283                         end
   283                     end;
   284                     end;
   284         end;
   285         end;
   285     MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical);
   286     MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical);
   286     iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask);
   287     iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask);
   287     if iconsurf <> nil then
   288         if iconsurf <> nil then
   288         begin
   289         begin
   289         r.x:= 0;
   290             r.x:= 0;
   290         r.y:= 0;
   291             r.y:= 0;
   291         r.w:= 28;
   292             r.w:= 28;
   292         r.h:= 28;
   293             r.h:= 28;
   293         DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true);
   294             DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true);
   294         ropeIconTex:= Surface2Tex(iconsurf, false);
   295             ropeIconTex:= Surface2Tex(iconsurf, false);
   295         SDL_FreeSurface(iconsurf)
   296             SDL_FreeSurface(iconsurf);
       
   297             iconsurf:= nil;
   296         end;
   298         end;
   297     end;
   299     end;
   298 
   300 
   299     procedure MakeCrossHairs;
   301     procedure MakeCrossHairs;
   300     var t: LongInt;
   302     var t: LongInt;
   814 var ii: TSprite;
   816 var ii: TSprite;
   815 begin
   817 begin
   816     for ii:= Low(TSprite) to High(TSprite) do
   818     for ii:= Low(TSprite) to High(TSprite) do
   817     begin
   819     begin
   818         FreeTexture(SpritesData[ii].Texture);
   820         FreeTexture(SpritesData[ii].Texture);
       
   821         SpritesData[ii].Texture:= nil;
   819         if SpritesData[ii].Surface <> nil then
   822         if SpritesData[ii].Surface <> nil then
   820             SDL_FreeSurface(SpritesData[ii].Surface)
   823             SDL_FreeSurface(SpritesData[ii].Surface);
       
   824         SpritesData[ii].Surface:= nil;
   821     end;
   825     end;
   822     SDL_FreeSurface(MissionIcons);
   826     SDL_FreeSurface(MissionIcons);
   823     FreeTexture(ropeIconTex);
   827     FreeTexture(ropeIconTex);
   824     FreeTexture(HHTexture);
   828     FreeTexture(HHTexture);
   825 end;
   829 end;