DEADSOFTWARE

net: it is now possible to use more than one master (use "List=host:port,host:port...
[d2df-sdl.git] / src / game / g_options.pas
index a5486509c00bf029c02e98fa80e7750db0cd2f58..a80d682cc3fdfcc5764377011b4a3d9c2821afe7 100644 (file)
@@ -2,8 +2,7 @@
  *
  * 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.
+ * the Free Software Foundation, version 3 of the License ONLY.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -97,9 +96,12 @@ implementation
 
 uses
   {$INCLUDE ../nogl/noGLuses.inc}
+  {$IFDEF USE_SDL2}
+    SDL2,
+  {$ENDIF}
   e_log, e_input, g_console, g_window, g_sound, g_gfx, g_player, Math,
   g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
-  g_items, wadreader, e_graphics, g_touch, SDL2, envvars;
+  g_items, wadreader, e_graphics, g_touch, envvars;
 
   var
     machine: Integer;
@@ -116,19 +118,27 @@ uses
       Result := Copy(Result, 1, 10) + ' ' + IntToStr(n)
   end;
 
+{$IFDEF USE_SDL2}
 procedure g_Options_SetDefaultVideo;
 var
   target, closest, display: TSDL_DisplayMode;
   percentage: Integer;
 begin
   (* Display 0 = Primary display *)
-  SDL_GetDesktopDisplayMode(0, @display);
-  {$IF DEFINED(ANDROID)}
+  gScreenWidth := 640;
+  gScreenHeight := 480;
+  //gBPP := SDL_BITSPERPIXEL(dispaly.format);
+  gBPP := 32;
+  {$IFDEF ANDROID}
+    gFullScreen := True; (* rotation not allowed? *)
+  {$ELSE}
+    gFullScreen := False;
+  {$ENDIF}
+  if SDL_GetDesktopDisplayMode(0, @display) = 0 then
+  begin
+  {$IFDEF ANDROID}
     gScreenWidth := display.w;
     gScreenHeight := display.h;
-    //gBPP := SDL_BITSPERPIXEL(dispaly.format);
-    gBPP := 32;
-    gFullScreen := True; (* rotation not allowed? *)
   {$ELSE}
     (* Window must be smaller than display *)
     closest.w := display.w;
@@ -153,9 +163,12 @@ begin
     gScreenWidth := closest.w;
     gScreenHeight := closest.h;
     //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
-    gBPP := 32;
-    gFullScreen := False;
   {$ENDIF}
+  end
+  else
+  begin
+    e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError])
+  end;
   (* Must be positioned on primary display *)
   gWinRealPosX := SDL_WINDOWPOS_CENTERED;
   gWinRealPosY := SDL_WINDOWPOS_CENTERED;
@@ -166,6 +179,23 @@ begin
   e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
   g_Console_ResetBinds;
 end;
+{$ELSE}
+procedure g_Options_SetDefaultVideo;
+begin
+  gScreenWidth := 640;
+  gScreenHeight := 480;
+  gBPP := 32;
+  gFullScreen := False;
+  gWinRealPosX := 0;
+  gWinRealPosY := 0;
+  gWinMaximized := False;
+  gVSync := True;
+  gTextureFilter := True;
+  glLegacyNPOT := False;
+  e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
+  g_Console_ResetBinds;
+end;
+{$ENDIF}
 
 procedure g_Options_SetDefault();
 var
@@ -227,7 +257,6 @@ begin
   gShowMessages := True;
   gRevertPlayers := False;
   gChatBubble := 4;
-  gPlayerIndicator := True;
   gSFSDebug := False;
   gSFSFastMode := False;
   e_FastScreenshots := True;
@@ -267,7 +296,7 @@ begin
   (* section MasterServer *)
   NetSlistIP := 'mpms.doom2d.org';
   NetSlistPort := 25665;
-  g_Net_Slist_Set(NetSlistIP, NetSlistPort);
+  g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
 
   (* section Server *)
   NetServerName := 'Unnamed Server';
@@ -420,7 +449,6 @@ begin
   ReadBoolean(gShowMessages, 'Messages');
   ReadBoolean(gRevertPlayers, 'RevertPlayers');
   ReadInteger(gChatBubble, 'ChatBubble', 0, 4);
-  ReadBoolean(gPlayerIndicator, 'PlayerIndicator');
   ReadBoolean(gSFSDebug, 'SFSDebug'); wadoptDebug := gSFSDebug;
   ReadBoolean(gSFSFastMode, 'SFSFastMode'); wadoptFast := gSFSFastMode;
   ReadBoolean(e_FastScreenshots, 'FastScreenshots');
@@ -490,7 +518,8 @@ begin
   section := 'MasterServer';
   ReadString(NetSlistIP, 'IP');
   ReadInteger(NetSlistPort, 'Port', 0, 65535);
-  g_Net_Slist_Set(NetSlistIP, NetSlistPort);
+  ReadString(NetSlistList, 'List');
+  g_Net_Slist_Set(NetSlistIP, NetSlistPort, NetSlistList);
 
   section := 'Server';
   ReadString(NetServerName, 'Name');
@@ -594,7 +623,6 @@ begin
   config.WriteBool('Game', 'Messages', gShowMessages);
   config.WriteBool('Game', 'RevertPlayers', gRevertPlayers);
   config.WriteInt('Game', 'ChatBubble', gChatBubble);
-  config.WriteBool('Game', 'PlayerIndicator', gPlayerIndicator);
   config.WriteBool('Game', 'SFSDebug', gSFSDebug);
   config.WriteBool('Game', 'SFSFastMode', gSFSFastMode);
   config.WriteBool('Game', 'FastScreenshots', e_FastScreenshots);
@@ -628,6 +656,7 @@ begin
 
   config.WriteStr('MasterServer', 'IP', NetSlistIP);
   config.WriteInt('MasterServer', 'Port', NetSlistPort);
+  config.WriteStr('MasterServer', 'List', NetSlistList);
 
   config.WriteStr ('Server', 'Name', NetServerName);
   config.WriteStr ('Server', 'Password', NetPassword);