DEADSOFTWARE

fix invalid value for TRIGGER_MUSIC.action
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 13 Dec 2019 20:45:34 +0000 (23:45 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 13 Dec 2019 20:45:34 +0000 (23:45 +0300)
src/editor/f_main.pas
src/shared/MAPWRITER.pas

index 225daecbb528255b4ad1c689dcdb14b2e59d705d..1d1d2ce5da316808b4db68c1e3fb168ed1ac12f8 100644 (file)
@@ -5155,7 +5155,7 @@ begin
                 if vleObjectProperty.Values[_lc[I_PROP_TR_MUSIC_ACT]] = _lc[I_PROP_TR_MUSIC_ON] then
                   Data.MusicAction := 1
                 else
-                  Data.MusicAction := 2;
+                  Data.MusicAction := 0;
               end;
 
             TRIGGER_PUSH:
index 4c7a6379b179c4c1bbe008e28d45c10eaa45dad2..95a181d0f056596e37b7b0650173777b8fe9f502 100644 (file)
@@ -50,7 +50,7 @@ type
 implementation
 
 uses
-  BinEditor, SysUtils;
+  MAPDEF, BinEditor, SysUtils, Math;
 
 { TMapWriter }
 
@@ -268,7 +268,8 @@ end;
 
 function TMapWriter_1.AddTriggers(Triggers: TTriggersRec1Array): Boolean;
 var
-  a, size: LongWord;
+  a, i, size: LongWord;
+  tr: ^TTriggerData;
 begin
  if Triggers = nil then
  begin
@@ -276,6 +277,15 @@ begin
   Exit;
  end;
 
+ // fix broken maps
+ for i := 0 to High(Triggers) do
+ begin
+   tr := @Triggers[i].data;
+   case Triggers[i].TriggerType of
+     TRIGGER_MUSIC: tr.MusicAction := Min(Max(tr.MusicAction, 0), 1);
+   end
+ end;
+
  SetLength(FDataBlocks, Length(FDataBlocks)+1);
 
  size := SizeOf(TTriggerRec_1);