DEADSOFTWARE

cheats are active in single/coop now ('cause Wyoming Knotts, you know)
[d2df-sdl.git] / src / game / g_main.pas
index 0d84cf24a1bb27ef60c9e0456f76f4e8b0c9abda..feb59808af5870cd802b22a8c1bbad0ac3e525af 100644 (file)
@@ -13,7 +13,7 @@
  * 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}
+{$INCLUDE ../shared/a_modes.inc}
 unit g_main;
 
 interface
@@ -40,7 +40,8 @@ uses
   e_graphics, e_input, g_game, g_console, g_gui,
   e_sound, g_options, g_sound, g_player,
   g_weapons, SysUtils, g_triggers, MAPDEF, g_map,
-  MAPSTRUCT, g_menu, g_language, g_net, utils;
+  g_menu, g_language, g_net,
+  utils, conbuf, envvars;
 
 var
   charbuff: Array [0..15] of Char;
@@ -75,7 +76,13 @@ begin
   g_Language_Set(gLanguage);
 
 {$IFDEF HEADLESS}
+ {$IFDEF USE_SDLMIXER}
+  sdlflags := SDL_INIT_TIMER or SDL_INIT_AUDIO or $00004000;
+  // HACK: shit this into env and hope for the best
+  SetEnvVar('SDL_AUDIODRIVER', 'dummy');
+ {$ELSE}
   sdlflags := SDL_INIT_TIMER or $00004000;
+ {$ENDIF}
 {$ELSE}
  {$IFDEF USE_SDLMIXER}
   sdlflags := SDL_INIT_EVERYTHING;
@@ -107,9 +114,20 @@ end;
 procedure Init();
 var
   a: Integer;
+  NoSound: Boolean;
 begin
   Randomize;
 
+{$IFDEF HEADLESS}
+ {$IFDEF USE_SDLMIXER}
+  NoSound := False; // hope env has set SDL_AUDIODRIVER to dummy
+ {$ELSE}
+  NoSound := True; // FMOD backend will sort it out
+ {$ENDIF}
+{$ELSE}
+  NoSound := False;
+{$ENDIF}
+
   e_WriteLog('Init Input', MSG_NOTIFY);
   e_InitInput();
 
@@ -121,7 +139,7 @@ begin
   if (not gNoSound) then
   begin
     e_WriteLog('Initializing sound system', MSG_NOTIFY);
-    e_InitSoundSystem({$IFDEF HEADLESS}True{$ELSE}False{$ENDIF});
+    e_InitSoundSystem(NoSound);
   end;
 
   e_WriteLog('Init game', MSG_NOTIFY);
@@ -232,12 +250,16 @@ label
   Cheated;
 var
   s, s2: string;
-  c: Char16;
+  c: ShortString;
   a: Integer;
 begin
+  {
   if (not gGameOn) or (not gCheats) or ((gGameSettings.GameType <> GT_SINGLE) and
     (gGameSettings.GameMode <> GM_COOP) and (not gDebugMode))
     or g_Game_IsNet then Exit;
+  }
+  if not gGameOn then exit;
+  if not conIsCheatsEnabled then exit;
 
   s := 'SOUND_GAME_RADIO';
 
@@ -284,7 +306,8 @@ begin
         if gTriggers[a].TriggerType = TRIGGER_EXIT then
         begin
           gExitByTrigger := True;
-          g_Game_ExitLevel(gTriggers[a].Data.MapName);
+          //g_Game_ExitLevel(gTriggers[a].Data.MapName);
+          g_Game_ExitLevel(gTriggers[a].tgcMap);
           Break;
         end;
     goto Cheated;