X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_main.pas;h=4e10356760d4b2e00a0e23d08083328120139343;hb=ae58c60b09a12df74e69717546235c3e5bf3c992;hp=97b005d30b2e6a8f264437a245028d5b17ac83b7;hpb=b529f458b42bebe709d4e10f42f8bcc71f33b093;p=d2df-sdl.git diff --git a/src/game/g_main.pas b/src/game/g_main.pas index 97b005d..4e10356 100644 --- a/src/game/g_main.pas +++ b/src/game/g_main.pas @@ -1,3 +1,19 @@ +(* 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 . + *) +{$INCLUDE ../shared/a_modes.inc} unit g_main; interface @@ -20,77 +36,113 @@ var implementation uses - SDL2, GL, GLExt, WADEDITOR, e_log, g_window, + SDL2, GL, GLExt, wadreader, e_log, g_window, 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, sfs; + g_menu, g_language, g_net, + utils, conbuf, envvars; var charbuff: Array [0..15] of Char; procedure Main(); +var + sdlflags: LongWord; begin + e_InitWritelnDriver(); + GetDir(0, GameDir); MapsDir := GameDir + '/maps/'; DataDir := GameDir + '/data/'; ModelsDir := DataDir + 'models/'; GameWAD := DataDir + 'Game.wad'; - e_InitLog(GameDir + '/' + LOG_FILENAME, WM_NEWFILE); + e_InitLog(GameDir + '/' + LOG_FILENAME, TWriteMode.WM_NEWFILE); - e_WriteLog('Read config file', MSG_NOTIFY); + e_WriteLog('Read config file', TMsgType.Notify); g_Options_Read(GameDir + '/' + CONFIG_FILENAME); +{$IFDEF HEADLESS} + conbufDumpToStdOut := true; +{$ENDIF} + e_WriteToStdOut := False; //{$IFDEF HEADLESS}True;{$ELSE}False;{$ENDIF} + //GetSystemDefaultLCID() //e_WriteLog('Read language file', MSG_NOTIFY); //g_Language_Load(DataDir + gLanguage + '.txt'); - e_WriteLog(gLanguage, MSG_NOTIFY); + e_WriteLog(gLanguage, TMsgType.Notify); g_Language_Set(gLanguage); -{$IFDEF USE_SDLMIXER} - if SDL_Init({SDL_INIT_JOYSTICK or SDL_INIT_TIMER or SDL_INIT_VIDEO or SDL_INIT_AUDIO}SDL_INIT_EVERYTHING) < 0 then +{$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} - if SDL_Init(SDL_INIT_JOYSTICK or SDL_INIT_TIMER or SDL_INIT_VIDEO) < 0 then + {$IFDEF USE_SDLMIXER} + sdlflags := SDL_INIT_EVERYTHING; + {$ELSE} + sdlflags := SDL_INIT_JOYSTICK or SDL_INIT_TIMER or SDL_INIT_VIDEO; + {$ENDIF} {$ENDIF} + if SDL_Init(sdlflags) < 0 then raise Exception.Create('SDL: Init failed: ' + SDL_GetError()); +{$IFDEF HEADLESS} SDL_StartTextInput(); +{$ENDIF} - e_WriteLog('Entering SDLMain', MSG_NOTIFY); + e_WriteLog('Entering SDLMain', TMsgType.Notify); - {$WARNINGS OFF} +{$WARNINGS OFF} SDLMain(); - {$WARNINGS ON} +{$WARNINGS ON} +{$IFDEF HEADLESS} SDL_StopTextInput(); +{$ENDIF} - e_WriteLog('Releasing SDL', MSG_NOTIFY); + e_WriteLog('Releasing SDL', TMsgType.Notify); SDL_Quit(); end; procedure Init(); var a: Integer; + NoSound: Boolean; begin Randomize; - e_WriteLog('Init Input', MSG_NOTIFY); +{$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', TMsgType.Notify); e_InitInput(); if (e_JoysticksAvailable > 0) then - e_WriteLog('Input: Joysticks available.', MSG_NOTIFY) + e_WriteLog('Input: Joysticks available.', TMsgType.Notify) else - e_WriteLog('Input: No Joysticks.', MSG_NOTIFY); + e_WriteLog('Input: No Joysticks.', TMsgType.Notify); - if not gNoSound then + if (not gNoSound) then begin - e_WriteLog('Initializing sound system', MSG_NOTIFY); - e_InitSoundSystem(); + e_WriteLog('Initializing sound system', TMsgType.Notify); + e_InitSoundSystem(NoSound); end; - e_WriteLog('Init game', MSG_NOTIFY); + e_WriteLog('Init game', TMsgType.Notify); g_Game_Init(); for a := 0 to 15 do charbuff[a] := ' '; @@ -98,15 +150,15 @@ end; procedure Release(); begin - e_WriteLog('Releasing engine', MSG_NOTIFY); + e_WriteLog('Releasing engine', TMsgType.Notify); e_ReleaseEngine(); - e_WriteLog('Releasing Input', MSG_NOTIFY); + e_WriteLog('Releasing Input', TMsgType.Notify); e_ReleaseInput(); if not gNoSound then begin - e_WriteLog('Releasing FMOD', MSG_NOTIFY); + e_WriteLog('Releasing FMOD', TMsgType.Notify); e_ReleaseSoundSystem(); end; end; @@ -138,8 +190,8 @@ begin 'Ø': Result[i] := 'I'; 'Ù': Result[i] := 'O'; 'Ç': Result[i] := 'P'; - 'Õ': Result[i] := Chr(219); - 'Ú': Result[i] := Chr(221); + 'Õ': Result[i] := '['; //Chr(219); + 'Ú': Result[i] := ']'; //Chr(221); 'Ô': Result[i] := 'A'; 'Û': Result[i] := 'S'; 'Â': Result[i] := 'D'; @@ -149,8 +201,8 @@ begin 'Î': Result[i] := 'J'; 'Ë': Result[i] := 'K'; 'Ä': Result[i] := 'L'; - 'Æ': Result[i] := Chr(186); - 'Ý': Result[i] := Chr(222); + 'Æ': Result[i] := ';'; //Chr(186); + 'Ý': Result[i] := #39; //Chr(222); 'ß': Result[i] := 'Z'; '×': Result[i] := 'X'; 'Ñ': Result[i] := 'C'; @@ -158,8 +210,8 @@ begin 'È': Result[i] := 'B'; 'Ò': Result[i] := 'N'; 'Ü': Result[i] := 'M'; - 'Á': Result[i] := Chr(188); - 'Þ': Result[i] := Chr(190); + 'Á': Result[i] := ','; //Chr(188); + 'Þ': Result[i] := '.'; //Chr(190); end; end; @@ -174,8 +226,20 @@ begin if length(ls2) = 0 then ls2 := '~'; result := (Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1)) = ls1) or + (Translit(Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1))) = ls1) or (Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2)) = ls2) or (Translit(Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2))) = ls2); + { + if ct = I_GAME_CHEAT_JETPACK then + begin + e_WriteLog('ls1: ['+ls1+']', MSG_NOTIFY); + e_WriteLog('ls2: ['+ls2+']', MSG_NOTIFY); + e_WriteLog('bf0: ['+Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1))+']', MSG_NOTIFY); + e_WriteLog('bf1: ['+Translit(Copy(charbuff, 17-Length(ls1)-eofs, Length(ls1)))+']', MSG_NOTIFY); + e_WriteLog('bf2: ['+Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2))+']', MSG_NOTIFY); + e_WriteLog('bf3: ['+Translit(Copy(charbuff, 17-Length(ls2)-eofs, Length(ls2)))+']', MSG_NOTIFY); + end; + } end; @@ -186,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'; @@ -238,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; @@ -469,7 +538,7 @@ begin else begin for a := 0 to 14 do charbuff[a] := charbuff[a+1]; - charbuff[15] := SFSUpCase(C); + charbuff[15] := UpCase1251(C); Cheat(); end; end;