DEADSOFTWARE

can load map scripts from wads now
[d2df-sdl.git] / src / game / g_map.pas
index 7babdd636e6046470ad45153e0ad8b6436fed789..cb934b81705666abe9dcd89ace6d7ae251fa47cb 100644 (file)
@@ -1,3 +1,18 @@
+(* Copyright (C)  DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *)
 {$MODE DELPHI}
 unit g_map;
 
@@ -118,7 +133,7 @@ uses
   GL, GLExt, g_weapons, g_game, g_sound, e_sound, CONFIG,
   g_options, MAPREADER, g_triggers, g_player, MAPDEF,
   Math, g_monsters, g_saveload, g_language, g_netmsg,
-  utils, sfs,
+  utils, sfs, g_scripts,
   ImagingTypes, Imaging, ImagingUtility,
   ImagingGif, ImagingNetworkGraphics;
 
@@ -892,9 +907,10 @@ var
                            DoorPanel: Integer;
                            ShotPanel: Integer;
                           end;
-  FileName, mapResName, s, TexName: String;
-  Data: Pointer;
-  Len: Integer;
+  FileName, mapResName, s, TexName, ScrStr: String;
+  Data, ScrText: Pointer;
+  ScrEnd: PByte;
+  Len, ScrLen: Integer;
   ok, isAnim, trigRef: Boolean;
   CurTex, ntn: Integer;
 begin
@@ -925,6 +941,19 @@ begin
       WAD.Free();
       Exit;
     end;
+    
+    // try to load the map script
+    g_Scripts_Reset(RESET_MAP);
+    ScrText := nil;
+    ScrLen := 0;
+    if WAD.GetResource('SCRIPTS/'+mapResName, ScrText, ScrLen) then
+    begin
+      g_Console_Add('SCRIPT: Found script for this map. Loading...');
+      SetString(ScrStr, ScrText, ScrLen);
+      g_Scripts_Load(ScrStr);
+      FreeMem(ScrText);
+    end;
+
     WAD.Free();
 
   // Çàãðóçêà êàðòû: