Load flakes information from theme.cfg when playing painted map
authorunc0rr
Tue, 22 Jul 2008 18:31:34 +0000
changeset 1085 0b82870073b5
parent 1084 61b753296c40
child 1086 5805deec7504
Load flakes information from theme.cfg when playing painted map
hedgewars/uLand.pas
hedgewars/uLandObjects.pas
hedgewars/uStore.pas
--- a/hedgewars/uLand.pas	Tue Jul 22 18:22:24 2008 +0000
+++ b/hedgewars/uLand.pas	Tue Jul 22 18:31:34 2008 +0000
@@ -599,6 +599,8 @@
 
 procedure GenMap;
 begin
+LoadThemeConfig;
+
 if (GameFlags and gfForts) = 0 then
    if Pathz[ptMapCurrent] <> '' then LoadMap
                                 else GenLandSurface
--- a/hedgewars/uLandObjects.pas	Tue Jul 22 18:22:24 2008 +0000
+++ b/hedgewars/uLandObjects.pas	Tue Jul 22 18:31:34 2008 +0000
@@ -22,10 +22,11 @@
 {$include options.inc}
 
 procedure AddObjects(InSurface, Surface: PSDL_Surface);
+procedure LoadThemeConfig;
 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image, Surface: PSDL_Surface);
 
 implementation
-uses uLand, uStore, uConsts, uMisc, uConsole, uRandom, uVisualGears, uFloat;
+uses uLand, uStore, uConsts, uMisc, uConsole, uRandom, uVisualGears, uFloat, GL;
 const MaxRects = 256;
       MAXOBJECTRECTS = 16;
       MAXTHEMEOBJECTS = 32;
@@ -56,6 +57,9 @@
 
 var Rects: PRectArray;
     RectCount: Longword;
+    ThemeObjects: TThemeObjects;
+    SprayObjects: TSprayObjects;
+
 
 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image, Surface: PSDL_Surface);
 var p: PByteArray;
@@ -354,14 +358,21 @@
     f: textfile;
     i, ii: LongInt;
     vobcount: Longword;
+    c1, c2: TSDL_Color;
 begin
 s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
 WriteLnToConsole('Reading objects info...');
 Assign(f, s);
 {$I-}
 Reset(f);
-Readln(f, s); // skip sky color
-Readln(f, s); // skip border color
+
+// read sky and explosion border colors
+Readln(f, c1.r, c1.g, c1. b);
+Readln(f, c2.r, c2.g, c2. b);
+
+glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99); // sky color
+cExplosionBorderColor:= c2.value or $FF000000;
+
 Readln(f, ThemeObjects.Count);
 for i:= 0 to Pred(ThemeObjects.Count) do
     begin
@@ -447,8 +458,6 @@
 end;
 
 procedure AddObjects(InSurface, Surface: PSDL_Surface);
-var ThemeObjects: TThemeObjects;
-    SprayObjects: TSprayObjects;
 begin
 InitRects;
 AddGirder(256, Surface);
@@ -458,7 +467,6 @@
 AddGirder(1280, Surface);
 AddGirder(1536, Surface);
 AddGirder(1792, Surface);
-ReadThemeInfo(ThemeObjects, SprayObjects);
 AddThemeObjects(Surface, ThemeObjects, 8);
 AddProgress;
 SDL_UpperBlit(InSurface, nil, Surface, nil);
@@ -466,4 +474,9 @@
 FreeRects
 end;
 
+procedure LoadThemeConfig;
+begin
+ReadThemeInfo(ThemeObjects, SprayObjects)
+end;
+
 end.
--- a/hedgewars/uStore.pas	Tue Jul 22 18:22:24 2008 +0000
+++ b/hedgewars/uStore.pas	Tue Jul 22 18:31:34 2008 +0000
@@ -224,27 +224,6 @@
           end
     end;
 
-    procedure GetExplosionBorderColor;
-    var f: textfile;
-        c1, c2: TSDL_Color;
-    begin
-    s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
-    WriteToConsole(msgLoading + s + ' ');
-    Assign(f, s);
-    {$I-}
-    Reset(f);
-    Readln(f, c1.r, c1.g, c1. b);
-    Readln(f, c2.r, c2.g, c2. b);
-    Close(f);
-    {$I+}
-    TryDo(IOResult = 0, msgFailed, true);
-    WriteLnToConsole(msgOK);
-
-    glClearColor(c1.r / 255, c1.g / 255, c1.b / 255, 0.99); // sky color
-    cExplosionBorderColor:= c2.value or
-                            $FF000000
-    end;
-
 var ii: TSprite;
     fi: THWFont;
     ai: TAmmoType;
@@ -263,8 +242,6 @@
          end;
 AddProgress;
 
-GetExplosionBorderColor;
-
 AddProgress;
 WriteNames(fnt16);
 MakeCrossHairs;