DEADSOFTWARE

map: prevent random values while loading ini maps
[d2df-editor.git] / src / editor / g_map.pas
index 792f258c43bb41a22a472eaf166e062391ddde1e..d6e71a0f263f97e33b7ab55f01e57b98c6cf5010 100644 (file)
@@ -1730,7 +1730,7 @@ begin
     MainForm.pbLoad.StepIt();
     Application.ProcessMessages();
 
-    s := TexturePrefix + UpperCase(map.ReadStr('Textures', 'TextureName'+IntToStr(a), ''));
+    s := TexturePrefix + UpperCase(win2utf(map.ReadStr('Textures', 'TextureName'+IntToStr(a), '')));
     if s = TexturePrefix then
       Continue;
 
@@ -1764,6 +1764,7 @@ begin
     if not map.SectionExists(section) then
       Continue;
 
+    panel := Default(TPanel);
     panel.X := map.ReadInt(section, 'X1', 0);
     panel.Y := map.ReadInt(section, 'Y1', 0);
     panel.Height := map.ReadInt(section, 'Height', 16);
@@ -1780,11 +1781,12 @@ begin
     end;
 
     panel.Alpha := map.ReadInt(section, 'Alpha', 0);
+    panel.Blending := false;
 
   // Текстура панели:
     if panel.PanelType in [PANEL_WALL, PANEL_BACK, PANEL_FORE, PANEL_STEP] then
       begin
-        s := TexturePrefix + UpperCase(map.ReadStr(section, 'TextureName', ''));
+        s := TexturePrefix + UpperCase(win2utf(map.ReadStr(section, 'TextureName', '')));
 
         if g_GetTexture(s, panel.TextureID) then
           begin
@@ -1853,6 +1855,7 @@ begin
     if not map.SectionExists(section) then
       Continue;
 
+    item := Default(TItem);
     item.X := map.ReadInt(section, 'X', 0);
     item.Y := map.ReadInt(section, 'Y', 0);
     item.ItemType := ITEMSCONVERT[map.ReadInt(section, 'Type', 0)];
@@ -1882,6 +1885,7 @@ begin
     if not map.SectionExists(section) then
       Continue;
 
+    area := Default(TArea);
     area.X := map.ReadInt(section, 'X', 0);
     area.Y := map.ReadInt(section, 'Y', 0);
     area.AreaType := map.ReadInt(section, 'Type', 0);
@@ -1895,10 +1899,11 @@ begin
   end;
 
 // Чтение параметров карты:
+  gMapInfo := Default(TMapInfo);
   with gMapInfo do
   begin
-    Name := map.ReadStr('MapOptions', 'MapName', '');
-    Description := map.ReadStr('MapOptions', 'MapDescription', '');
+    Name := win2utf(map.ReadStr('MapOptions', 'MapName', ''));
+    Description := win2utf(map.ReadStr('MapOptions', 'MapDescription', ''));
     Author := '';
     MusicName := DefaultMusRes;
     SkyName := DefaultSkyRes;
@@ -1912,6 +1917,8 @@ begin
       SetLength(Description, 256);
   end;
 
+  LoadSky(gMapInfo.SkyName);
+
   map.Free();
 
   Result := True;
@@ -1938,17 +1945,9 @@ begin
   SetLength(gTriggers, 0);
   gTriggers := nil;
 
-  with gMapInfo do
-  begin
-    Name := '';
-    Description := '';
-    Author := '';
-    MusicName := '';
-    SkyName := '';
-    FileName := '';
-    Height := 1600;
-    Width := 1600;
-  end;
+  gMapInfo := Default(TMapInfo);
+  gMapInfo.Width := 1600;
+  gMapInfo.Height := 1600;
 
   with MainForm.lbTextureList do
   begin