From: Ketmar Dark Date: Fri, 22 Sep 2017 08:13:23 +0000 (+0300) Subject: renamed `SArray` type to `SSArray`, and moved it to "utils.pas" X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=cd1ca85acc0740e0f307782e2af54e5ba0a59507;p=d2df-sdl.git renamed `SArray` type to `SSArray`, and moved it to "utils.pas" --- diff --git a/src/game/g_basic.pas b/src/game/g_basic.pas index f6653a3..d82b285 100644 --- a/src/game/g_basic.pas +++ b/src/game/g_basic.pas @@ -19,7 +19,7 @@ unit g_basic; interface uses - wadreader, g_phys; + utils, g_phys; const GAME_VERSION = '0.667'; @@ -72,19 +72,19 @@ function Sign(A: Single): ShortInt; overload; function PointToRect(X, Y, X1, Y1: Integer; Width, Height: Word): Integer; function GetAngle(baseX, baseY, pointX, PointY: Integer): SmallInt; function GetAngle2(vx, vy: Integer): SmallInt; -function GetLines(Text: string; FontID: DWORD; MaxWidth: Word): SArray; -procedure Sort(var a: SArray); +function GetLines(Text: string; FontID: DWORD; MaxWidth: Word): SSArray; +procedure Sort(var a: SSArray); function Sscanf(const s: string; const fmt: string; const Pointers: array of Pointer): Integer; function InDWArray(a: DWORD; arr: DWArray): Boolean; function InWArray(a: Word; arr: WArray): Boolean; -function InSArray(a: string; arr: SArray): Boolean; +function InSArray(a: string; arr: SSArray): Boolean; function GetPos(UID: Word; o: PObj): Boolean; -function parse(s: string): SArray; -function parse2(s: string; delim: Char): SArray; +function parse(s: string): SSArray; +function parse2(s: string; delim: Char): SSArray; function g_GetFileTime(fileName: String): Integer; function g_SetFileTime(fileName: String; time: Integer): Boolean; -procedure SortSArray(var S: SArray); +procedure SortSArray(var S: SSArray); function b_Text_Format(S: string): string; function b_Text_Unformat(S: string): string; @@ -626,7 +626,7 @@ begin end; end; -{function GetLines(Text: string; MaxChars: Word): SArray; +{function GetLines(Text: string; MaxChars: Word): SSArray; var a: Integer; b: array of string; @@ -673,7 +673,7 @@ begin end; end;} -function GetLines(Text: string; FontID: DWORD; MaxWidth: Word): SArray; +function GetLines(Text: string; FontID: DWORD; MaxWidth: Word): SSArray; function TextLen(Text: string): Word; var @@ -741,7 +741,7 @@ begin end; end; -procedure Sort(var a: SArray); +procedure Sort(var a: SSArray); var i, j: Integer; s: string; @@ -934,7 +934,7 @@ begin end; end; -function InSArray(a: string; arr: SArray): Boolean; +function InSArray(a: string; arr: SSArray): Boolean; var b: Integer; begin @@ -983,7 +983,7 @@ begin Result := True; end; -function parse(s: String): SArray; +function parse(s: String): SSArray; var a: Integer; begin @@ -1009,7 +1009,7 @@ begin end; end; -function parse2(s: string; delim: Char): SArray; +function parse2(s: string; delim: Char): SSArray; var a: Integer; begin @@ -1064,7 +1064,7 @@ begin CloseFile(F); end; -procedure SortSArray(var S: SArray); +procedure SortSArray(var S: SSArray); var b: Boolean; i: Integer; diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 19c83b6..9e6f4d5 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -19,7 +19,7 @@ unit g_console; interface uses - wadreader; // for SArray + utils; // for SSArray procedure g_Console_Init (); procedure g_Console_Update (); @@ -36,7 +36,7 @@ procedure conwriteln (const s: AnsiString; show: Boolean=false); procedure conwritefln (const s: AnsiString; args: array of const; show: Boolean=false); // <0: no arg; 0/1: true/false -function conGetBoolArg (p: SArray; idx: Integer): Integer; +function conGetBoolArg (p: SSArray; idx: Integer): Integer; procedure g_Console_Chat_Switch (team: Boolean=false); @@ -61,14 +61,14 @@ implementation uses g_textures, g_main, e_graphics, e_input, g_game, SysUtils, g_basic, g_options, Math, - g_menu, g_language, g_net, g_netmsg, e_log, conbuf, utils; + g_menu, g_language, g_net, g_netmsg, e_log, conbuf; type PCommand = ^TCommand; - TCmdProc = procedure (p: SArray); - TCmdProcEx = procedure (me: PCommand; p: SArray); + TCmdProc = procedure (p: SSArray); + TCmdProcEx = procedure (me: PCommand; p: SSArray); TCommand = record cmd: AnsiString; @@ -83,7 +83,7 @@ type TAlias = record name: AnsiString; - commands: SArray; + commands: SSArray; end; @@ -103,9 +103,9 @@ var Cons_Shown: Boolean; // Ðèñîâàòü ëè êîíñîëü? Line: AnsiString; CPos: Word; - //ConsoleHistory: SArray; - CommandHistory: SArray; - Whitelist: SArray; + //ConsoleHistory: SSArray; + CommandHistory: SSArray; + Whitelist: SSArray; commands: Array of TCommand = nil; Aliases: Array of TAlias = nil; CmdIndex: Word; @@ -157,7 +157,7 @@ end; // ////////////////////////////////////////////////////////////////////////// // // <0: no arg; 0/1: true/false; 666: toggle -function conGetBoolArg (p: SArray; idx: Integer): Integer; +function conGetBoolArg (p: SSArray; idx: Integer): Integer; begin if (idx < 0) or (idx > High(p)) then begin result := -1; exit; end; result := 0; @@ -168,7 +168,7 @@ begin end; -procedure boolVarHandler (me: PCommand; p: SArray); +procedure boolVarHandler (me: PCommand; p: SSArray); procedure binaryFlag (var flag: Boolean; msg: AnsiString); begin if (Length(p) > 2) then @@ -220,7 +220,7 @@ type end; -procedure singleVarHandler (me: PCommand; p: SArray); +procedure singleVarHandler (me: PCommand; p: SSArray); var pv: PVarSingle; nv: Single; @@ -300,7 +300,7 @@ begin end; end; -function ParseAlias(Str: AnsiString): SArray; +function ParseAlias(Str: AnsiString): SSArray; begin Result := nil; @@ -316,7 +316,7 @@ begin end; end; -procedure ConsoleCommands(p: SArray); +procedure ConsoleCommands(p: SSArray); var cmd, s: AnsiString; a, b: Integer; @@ -563,7 +563,7 @@ begin end; -procedure segfault (p: SArray); +procedure segfault (p: SSArray); var pp: PByte = nil; begin @@ -1168,7 +1168,7 @@ begin end; end; -function ParseString(Str: AnsiString): SArray; +function ParseString(Str: AnsiString): SSArray; begin Result := nil; @@ -1319,7 +1319,7 @@ end; function g_Console_CommandBlacklisted(C: AnsiString): Boolean; var - Arr: SArray; + Arr: SSArray; i: Integer; begin Result := True; @@ -1340,7 +1340,7 @@ end; procedure g_Console_Process(L: AnsiString; quiet: Boolean = False); var - Arr: SArray; + Arr: SSArray; i: Integer; begin Arr := nil; diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 97a5959..f696acc 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -22,7 +22,7 @@ uses SysUtils, Classes, MAPDEF, g_basic, g_player, e_graphics, g_res_downloader, - g_sound, g_gui, wadreader, md5, xprofiler; + g_sound, g_gui, utils, md5, xprofiler; type TGameSettings = record @@ -123,10 +123,10 @@ procedure g_FatalError(Text: String); procedure g_SimpleError(Text: String); function g_Game_IsTestMap(): Boolean; procedure g_Game_DeleteTestMap(); -procedure GameCVars(P: SArray); -procedure GameCommands(P: SArray); -procedure GameCheats(P: SArray); -procedure DebugCommands(P: SArray); +procedure GameCVars(P: SSArray); +procedure GameCommands(P: SSArray); +procedure GameCheats(P: SSArray); +procedure DebugCommands(P: SSArray); procedure g_Game_Process_Params; procedure g_Game_SetLoadingText(Text: String; Max: Integer; reWrite: Boolean); procedure g_Game_StepLoading(); @@ -346,7 +346,7 @@ uses g_triggers, g_monsters, e_sound, CONFIG, g_language, g_net, SDL, ENet, e_msg, g_netmsg, g_netmaster, GL, GLExt, - utils, sfs, g_holmes; + sfs, wadreader, g_holmes; // ////////////////////////////////////////////////////////////////////////// // @@ -540,7 +540,7 @@ var EndingGameCounter: Byte = 0; MessageText: String; MessageTime: Word; - MapList: SArray = nil; + MapList: SSArray = nil; MapIndex: Integer = -1; MegaWAD: record info: TMegaWADInfo; @@ -563,7 +563,7 @@ var end; //InterPic: String; InterText: record - lines: SArray; + lines: SSArray; img: String; cur_line: Integer; cur_char: Integer; @@ -4603,7 +4603,7 @@ var WadName: string; { WAD: TWADFile; - MapList: SArray; + MapList: SSArray; time: Integer; } begin @@ -4656,7 +4656,7 @@ begin if gTempDelete then DeleteFile(WadName); end; -procedure GameCVars(P: SArray); +procedure GameCVars(P: SSArray); var a, b: Integer; stat: TPlayerStatArray; @@ -5203,7 +5203,7 @@ begin e_LogWriteLn ('^=======================^'); end; -procedure DebugCommands(P: SArray); +procedure DebugCommands(P: SSArray); var a, b: Integer; cmd: string; @@ -5339,7 +5339,7 @@ begin end; -procedure GameCheats(P: SArray); +procedure GameCheats(P: SSArray); var cmd: string; f, a: Integer; @@ -5554,7 +5554,7 @@ begin end; end; -procedure GameCommands(P: SArray); +procedure GameCommands(P: SSArray); var a, b: Integer; s, pw: String; diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas index 79b46ad..893bdd8 100644 --- a/src/game/g_gui.pas +++ b/src/game/g_gui.pas @@ -20,7 +20,7 @@ interface uses mempool, - e_graphics, e_input, e_log, g_playermodel, g_basic, MAPDEF, wadreader; + e_graphics, e_input, e_log, g_playermodel, g_basic, MAPDEF, utils; const MAINMENU_HEADER_COLOR: TRGB = (R:255; G:255; B:255); @@ -381,7 +381,7 @@ type TGUIListBox = class(TGUIControl) private - FItems: SArray; + FItems: SSArray; FActiveColor: TRGB; FUnActiveColor: TRGB; FFont: TFont; @@ -394,7 +394,7 @@ type FDrawScroll: Boolean; FOnChangeEvent: TOnChangeEvent; - procedure FSetItems(Items: SArray); + procedure FSetItems(Items: SSArray); procedure FSetIndex(aIndex: Integer); public @@ -411,7 +411,7 @@ type property OnChange: TOnChangeEvent read FOnChangeEvent write FOnChangeEvent; property Sort: Boolean read FSort write FSort; property ItemIndex: Integer read FIndex write FSetIndex; - property Items: SArray read FItems write FSetItems; + property Items: SSArray read FItems write FSetItems; property DrawBack: Boolean read FDrawBack write FDrawBack; property DrawScrollBar: Boolean read FDrawScroll write FDrawScroll; property ActiveColor: TRGB read FActiveColor write FActiveColor; @@ -441,7 +441,7 @@ type TGUIMemo = class(TGUIControl) private - FLines: SArray; + FLines: SSArray; FFont: TFont; FStartLine: Integer; FWidth: Word; @@ -545,16 +545,19 @@ function g_GUI_Destroy(): Boolean; procedure g_GUI_SaveMenuPos(); procedure g_GUI_LoadMenuPos(); + implementation uses GL, GLExt, g_textures, g_sound, SysUtils, g_game, Math, StrUtils, g_player, g_options, - g_map, g_weapons, xdynrec; + g_map, g_weapons, xdynrec, wadreader; + var Box: Array [0..8] of DWORD; - Saved_Windows: SArray; + Saved_Windows: SSArray; + procedure g_GUI_Init(); begin @@ -1321,7 +1324,7 @@ end; procedure TGUIMenu.AddText(fText: string; MaxWidth: Word); var a, i: Integer; - l: SArray; + l: SSArray; begin l := GetLines(fText, FFontID, MaxWidth); @@ -3057,7 +3060,7 @@ begin Result := FItems[FIndex]; end; -procedure TGUIListBox.FSetItems(Items: SArray); +procedure TGUIListBox.FSetItems(Items: SSArray); begin if FItems <> nil then FItems := nil; diff --git a/src/game/g_map.pas b/src/game/g_map.pas index b1174c8..745f261 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -22,7 +22,7 @@ interface uses SysUtils, Classes, e_graphics, g_basic, MAPDEF, g_textures, - g_phys, wadreader, g_panel, g_grid, md5, binheap, xprofiler, xparser, xdynrec; + g_phys, utils, g_panel, g_grid, md5, binheap, xprofiler, xparser, xdynrec; type TMapInfo = record @@ -59,7 +59,7 @@ type function g_Map_Load(Res: String): Boolean; function g_Map_GetMapInfo(Res: String): TMapInfo; -function g_Map_GetMapsList(WADName: String): SArray; +function g_Map_GetMapsList(WADName: String): SSArray; function g_Map_Exist(Res: String): Boolean; procedure g_Map_Free(freeTextures: Boolean=true); procedure g_Map_Update(); @@ -247,7 +247,7 @@ uses GL, GLExt, g_weapons, g_game, g_sound, e_sound, CONFIG, g_options, g_triggers, g_player, Math, g_monsters, g_saveload, g_language, g_netmsg, - utils, sfs, xstreams, hashtable, + sfs, xstreams, hashtable, wadreader, ImagingTypes, Imaging, ImagingUtility, ImagingGif, ImagingNetworkGraphics; @@ -2290,11 +2290,11 @@ begin mapReader.Free(); end; -function g_Map_GetMapsList(WADName: string): SArray; +function g_Map_GetMapsList(WADName: string): SSArray; var WAD: TWADFile; a: Integer; - ResList: SArray; + ResList: SSArray; begin Result := nil; WAD := TWADFile.Create(); @@ -2319,7 +2319,7 @@ function g_Map_Exist(Res: string): Boolean; var WAD: TWADFile; FileName, mnn: string; - ResList: SArray; + ResList: SSArray; a: Integer; begin Result := False; diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas index 05e32bf..e719b86 100644 --- a/src/game/g_menu.pas +++ b/src/game/g_menu.pas @@ -45,10 +45,10 @@ uses g_gui, g_textures, e_graphics, g_main, g_window, g_game, g_map, g_basic, g_console, g_sound, g_gfx, g_player, g_options, g_weapons, e_log, SysUtils, CONFIG, g_playermodel, DateUtils, - MAPDEF, wadreader, Math, g_saveload, + MAPDEF, Math, g_saveload, e_texture, GL, GLExt, g_language, g_net, g_netmsg, g_netmaster, g_items, e_input, - utils; + utils, wadreader; type TYNCallback = procedure (yes:Boolean); @@ -790,7 +790,7 @@ end; procedure ProcSelectWAD(Sender: TGUIControl); var wad: String; - list: SArray; + list: SSArray; begin with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do begin @@ -1698,7 +1698,7 @@ end; procedure ProcVideoOptionsRes(); var menu: TGUIMenu; - list: SArray; + list: SSArray; SR: DWORD; begin menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu')); @@ -1880,7 +1880,7 @@ var Menu: TGUIWindow; //SR: TSearchRec; a, cx, _y, i: Integer; - //list: SArray; + //list: SSArray; begin Menu := TGUIWindow.Create('MainMenu'); with TGUIMainMenu(Menu.AddChild(TGUIMainMenu.Create(gMenuFont, _lc[I_MENU_MAIN_MENU]))) do diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 14a2fdc..b4d00c9 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -987,7 +987,7 @@ end; procedure g_Bot_Add(Team, Difficult: Byte); var - m: SArray; + m: SSArray; _name, _model: String; a, tr, tb: Integer; begin @@ -1084,7 +1084,7 @@ end; procedure g_Bot_AddList(Team: Byte; lName: ShortString; num: Integer = -1); var - m: SArray; + m: SSArray; _name, _model: String; a: Integer; begin @@ -1221,7 +1221,7 @@ var s: String; a, b: Integer; config: TConfig; - sa: SArray; + sa: SSArray; begin BotNames := nil; diff --git a/src/game/g_playermodel.pas b/src/game/g_playermodel.pas index e4b485d..4465143 100644 --- a/src/game/g_playermodel.pas +++ b/src/game/g_playermodel.pas @@ -21,7 +21,7 @@ interface uses mempool, - MAPDEF, g_textures, g_basic, g_weapons, e_graphics, wadreader; + MAPDEF, g_textures, g_basic, g_weapons, e_graphics, utils; const A_STAND = 0; @@ -130,17 +130,18 @@ type procedure g_PlayerModel_LoadData(); procedure g_PlayerModel_FreeData(); function g_PlayerModel_Load(FileName: String): Boolean; -function g_PlayerModel_GetNames(): SArray; +function g_PlayerModel_GetNames(): SSArray; function g_PlayerModel_GetInfo(ModelName: String): TModelInfo; function g_PlayerModel_Get(ModelName: String): TPlayerModel; function g_PlayerModel_GetAnim(ModelName: String; Anim: Byte; var _Anim, _Mask: TAnimation): Boolean; function g_PlayerModel_GetGibs(ModelName: String; var Gibs: TGibsArray): Boolean; + implementation uses g_main, g_sound, g_console, SysUtils, g_player, CONFIG, - GL, GLExt, e_sound, g_options, g_map, Math, e_log; + GL, GLExt, e_sound, g_options, g_map, Math, e_log, wadreader; type TPlayerModelInfo = record @@ -692,7 +693,7 @@ begin end; end; -function g_PlayerModel_GetNames(): SArray; +function g_PlayerModel_GetNames(): SSArray; var i: DWORD; begin diff --git a/src/game/g_window.pas b/src/game/g_window.pas index 79fb99f..03b7dd0 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -19,7 +19,7 @@ unit g_window; interface uses - wadreader; + utils; function SDLMain(): Integer; function GetTimer(): Int64; @@ -32,7 +32,7 @@ procedure ProcessLoading (forceUpdate: Boolean=false); procedure ReDrawWindow(); procedure SwapBuffers(); procedure Sleep(ms: LongWord); -function GetDisplayModes(dBPP: DWORD; var SelRes: DWORD): SArray; +function GetDisplayModes(dBPP: DWORD; var SelRes: DWORD): SSArray; function g_Window_SetDisplay(PreserveGL: Boolean = False): Boolean; function g_Window_SetSize(W, H: Word; FScreen: Boolean): Boolean; @@ -51,7 +51,7 @@ uses SDL2, GL, GLExt, e_graphics, e_log, e_texture, g_main, g_console, e_input, g_options, g_game, g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net, - g_map, g_gfx, g_monsters, g_holmes, xprofiler, utils; + g_map, g_gfx, g_monsters, g_holmes, xprofiler; var h_Wnd: PSDL_Window; @@ -61,13 +61,9 @@ var flag: Boolean; wTitle: PChar = nil; wNeedTimeReset: Boolean = False; - //wWindowCreated: Boolean = False; - //wCursorShown: Boolean = False; wMinimized: Boolean = False; - //wNeedFree: Boolean = True; wLoadingProgress: Boolean = False; wLoadingQuit: Boolean = False; - {wWinPause: Byte = 0;} {$IFNDEF WINDOWS} ticksOverflow: Int64 = -1; lastTicks: Uint32 = 0; // to detect overflow @@ -135,7 +131,7 @@ begin // TODO: what was this for? end; -function GetDisplayModes(dBPP: DWORD; var SelRes: DWORD): SArray; +function GetDisplayModes(dBPP: DWORD; var SelRes: DWORD): SSArray; var mode: TSDL_DisplayMode; res, i, k, n, pw, ph: Integer; @@ -528,7 +524,6 @@ begin if h_GL <> nil then SDL_GL_DeleteContext(h_GL); h_Wnd := nil; h_GL := nil; - //wWindowCreated := False; end; function CreateGLWindow(Title: PChar): Boolean; @@ -554,7 +549,6 @@ begin h_Gl := SDL_GL_CreateContext(h_Wnd); if h_Gl = nil then Exit; {$ENDIF} - //wWindowCreated := True; e_ResizeWindow(gScreenWidth, gScreenHeight); e_InitGL(); @@ -623,14 +617,12 @@ var stt: UInt64; begin FillChar(ev, SizeOf(ev), 0); - //wNeedFree := False; wLoadingProgress := True; while SDL_PollEvent(@ev) > 0 do begin if (ev.type_ = SDL_QUITEV) then break; end; - //wNeedFree := True; if (ev.type_ = SDL_QUITEV) or (gExit = EXIT_QUIT) then begin @@ -706,14 +698,14 @@ begin if wNeedTimeReset then begin - Time_Delta := 28{(27777 div 1000)}; + Time_Delta := 28; wNeedTimeReset := False; end; g_Map_ProfilersBegin(); g_Mons_ProfilersBegin(); - t := Time_Delta div 28{(27777 div 1000)}; + t := Time_Delta div 28; if t > 0 then begin flag := True; @@ -748,7 +740,7 @@ begin // Âðåìÿ ïðåäûäóùåãî îáíîâëåíèÿ: if flag then begin - Time_Old := Time - (Time_Delta mod 28{(27777 div 1000)}); + Time_Old := Time-(Time_Delta mod 28); if (not wMinimized) then begin Draw(); diff --git a/src/shared/utils.pas b/src/shared/utils.pas index d0a0ac5..308293d 100644 --- a/src/shared/utils.pas +++ b/src/shared/utils.pas @@ -22,6 +22,11 @@ uses SysUtils, Classes; +// ////////////////////////////////////////////////////////////////////////// // +type + SSArray = array of ShortString; + + // ////////////////////////////////////////////////////////////////////////// // type TUtf8DecoderFast = packed record diff --git a/src/shared/wadreader.pas b/src/shared/wadreader.pas index b83102b..818e912 100644 --- a/src/shared/wadreader.pas +++ b/src/shared/wadreader.pas @@ -22,12 +22,11 @@ unit wadreader; interface uses - mempool, sfs, xstreams, Classes; + Classes, + mempool, sfs, xstreams, utils; type - SArray = array of ShortString; - TWADFile = class(TPoolObject) private fFileName: AnsiString; // empty: not opened @@ -49,7 +48,7 @@ type function GetResource (name: AnsiString; var pData: Pointer; var Len: Integer; logError: Boolean=true): Boolean; function GetMapResource (name: AnsiString; var pData: Pointer; var Len: Integer; logError: Boolean=true): Boolean; - function GetMapResources (): SArray; + function GetMapResources (): SSArray; // returns `nil` if file wasn't found function openFileStream (name: AnsiString): TStream; @@ -76,7 +75,7 @@ var implementation uses - SysUtils, e_log, utils, MAPDEF, xdynrec; + SysUtils, e_log, MAPDEF, xdynrec; function findDiskWad (fname: AnsiString): AnsiString; @@ -459,7 +458,7 @@ begin result := GetResourceEx(name, true, pData, Len, logError); end; -function TWADFile.GetMapResources (): SArray; +function TWADFile.GetMapResources (): SSArray; var f, c: Integer; fi: TSFSFileInfo;