summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d9595ee)
raw | patch | inline | side by side (parent: d9595ee)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 22 Sep 2017 08:13:23 +0000 (11:13 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 22 Sep 2017 08:42:15 +0000 (11:42 +0300) |
diff --git a/src/game/g_basic.pas b/src/game/g_basic.pas
index f6653a3126574ff91eb115f2af3dda260595b8e1..d82b285bf9f344afc9f906bb2c017f432916d055 100644 (file)
--- a/src/game/g_basic.pas
+++ b/src/game/g_basic.pas
interface
uses
- wadreader, g_phys;
+ utils, g_phys;
const
GAME_VERSION = '0.667';
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;
end;
end;
-{function GetLines(Text: string; MaxChars: Word): SArray;
+{function GetLines(Text: string; MaxChars: Word): SSArray;
var
a: Integer;
b: array of string;
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
end;
end;
-procedure Sort(var a: SArray);
+procedure Sort(var a: SSArray);
var
i, j: Integer;
s: string;
end;
end;
-function InSArray(a: string; arr: SArray): Boolean;
+function InSArray(a: string; arr: SSArray): Boolean;
var
b: Integer;
begin
Result := True;
end;
-function parse(s: String): SArray;
+function parse(s: String): SSArray;
var
a: Integer;
begin
end;
end;
-function parse2(s: string; delim: Char): SArray;
+function parse2(s: string; delim: Char): SSArray;
var
a: Integer;
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 19c83b6f67c7c5ddc5269a838c295bc7643ff246..9e6f4d5de4776bd505e2499b4a384cfff3a6862a 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
interface
uses
- wadreader; // for SArray
+ utils; // for SSArray
procedure g_Console_Init ();
procedure g_Console_Update ();
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);
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;
TAlias = record
name: AnsiString;
- commands: SArray;
+ commands: SSArray;
end;
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;
// ////////////////////////////////////////////////////////////////////////// //
// <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;
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
end;
-procedure singleVarHandler (me: PCommand; p: SArray);
+procedure singleVarHandler (me: PCommand; p: SSArray);
var
pv: PVarSingle;
nv: Single;
end;
end;
-function ParseAlias(Str: AnsiString): SArray;
+function ParseAlias(Str: AnsiString): SSArray;
begin
Result := nil;
end;
end;
-procedure ConsoleCommands(p: SArray);
+procedure ConsoleCommands(p: SSArray);
var
cmd, s: AnsiString;
a, b: Integer;
end;
-procedure segfault (p: SArray);
+procedure segfault (p: SSArray);
var
pp: PByte = nil;
begin
end;
end;
-function ParseString(Str: AnsiString): SArray;
+function ParseString(Str: AnsiString): SSArray;
begin
Result := nil;
function g_Console_CommandBlacklisted(C: AnsiString): Boolean;
var
- Arr: SArray;
+ Arr: SSArray;
i: Integer;
begin
Result := True;
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 97a59594020df6b53b7f4a6371af572becb4e2c5..f696accdf385baf3a40b56daa97ac22f6f8e678a 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
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
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();
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;
// ////////////////////////////////////////////////////////////////////////// //
EndingGameCounter: Byte = 0;
MessageText: String;
MessageTime: Word;
- MapList: SArray = nil;
+ MapList: SSArray = nil;
MapIndex: Integer = -1;
MegaWAD: record
info: TMegaWADInfo;
end;
//InterPic: String;
InterText: record
- lines: SArray;
+ lines: SSArray;
img: String;
cur_line: Integer;
cur_char: Integer;
WadName: string;
{
WAD: TWADFile;
- MapList: SArray;
+ MapList: SSArray;
time: Integer;
}
begin
if gTempDelete then DeleteFile(WadName);
end;
-procedure GameCVars(P: SArray);
+procedure GameCVars(P: SSArray);
var
a, b: Integer;
stat: TPlayerStatArray;
e_LogWriteLn ('^=======================^');
end;
-procedure DebugCommands(P: SArray);
+procedure DebugCommands(P: SSArray);
var
a, b: Integer;
cmd: string;
end;
-procedure GameCheats(P: SArray);
+procedure GameCheats(P: SSArray);
var
cmd: string;
f, a: Integer;
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 79b46ad6692ab1f3ae0c262b85a8e04a9d574545..893bdd8e2c0c2362a99b345ca9262e966b3b1d8f 100644 (file)
--- a/src/game/g_gui.pas
+++ b/src/game/g_gui.pas
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);
TGUIListBox = class(TGUIControl)
private
- FItems: SArray;
+ FItems: SSArray;
FActiveColor: TRGB;
FUnActiveColor: TRGB;
FFont: TFont;
FDrawScroll: Boolean;
FOnChangeEvent: TOnChangeEvent;
- procedure FSetItems(Items: SArray);
+ procedure FSetItems(Items: SSArray);
procedure FSetIndex(aIndex: Integer);
public
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;
TGUIMemo = class(TGUIControl)
private
- FLines: SArray;
+ FLines: SSArray;
FFont: TFont;
FStartLine: Integer;
FWidth: Word;
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
procedure TGUIMenu.AddText(fText: string; MaxWidth: Word);
var
a, i: Integer;
- l: SArray;
+ l: SSArray;
begin
l := GetLines(fText, FFontID, MaxWidth);
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 b1174c8595ef86a1dafd7b550994b894906e0e06..745f26166a931226c604f90871e2213d1291f288 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
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
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();
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;
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();
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 05e32bf9d016ca27fca3883e4c2569a6f26d00d6..e719b86d088f0c46fce0abb11c18139ad9d6f4db 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
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);
procedure ProcSelectWAD(Sender: TGUIControl);
var
wad: String;
- list: SArray;
+ list: SSArray;
begin
with TGUIMenu(g_GUI_GetWindow('SelectMapMenu').GetControl('mSelectMapMenu')) do
begin
procedure ProcVideoOptionsRes();
var
menu: TGUIMenu;
- list: SArray;
+ list: SSArray;
SR: DWORD;
begin
menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoResMenu').GetControl('mOptionsVideoResMenu'));
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 14a2fdcd4d17d4fb9c3478ce9383303c7fe14986..b4d00c9923a6f8e4a63d15795fe00d42e9d112c5 100644 (file)
--- a/src/game/g_player.pas
+++ b/src/game/g_player.pas
procedure g_Bot_Add(Team, Difficult: Byte);
var
- m: SArray;
+ m: SSArray;
_name, _model: String;
a, tr, tb: Integer;
begin
procedure g_Bot_AddList(Team: Byte; lName: ShortString; num: Integer = -1);
var
- m: SArray;
+ m: SSArray;
_name, _model: String;
a: Integer;
begin
s: String;
a, b: Integer;
config: TConfig;
- sa: SArray;
+ sa: SSArray;
begin
BotNames := nil;
index e4b485d9eac079280c34118ec8e237be918097c3..44651438e93ec006d360c5f67598ab26e3199a67 100644 (file)
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;
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
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 79fb99fc963b7b005f38f82edc40b81f11eba6ff..03b7dd0144192d857d1a5dee7ffec5411daa5ae7 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
interface
uses
- wadreader;
+ utils;
function SDLMain(): Integer;
function GetTimer(): Int64;
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;
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;
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
// 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;
if h_GL <> nil then SDL_GL_DeleteContext(h_GL);
h_Wnd := nil;
h_GL := nil;
- //wWindowCreated := False;
end;
function CreateGLWindow(Title: PChar): Boolean;
h_Gl := SDL_GL_CreateContext(h_Wnd);
if h_Gl = nil then Exit;
{$ENDIF}
- //wWindowCreated := True;
e_ResizeWindow(gScreenWidth, gScreenHeight);
e_InitGL();
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
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;
// Âðåìÿ ïðåäûäóùåãî îáíîâëåíèÿ:
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 d0a0ac53375a5b563b46cdfe99be12a61b5eec5c..308293da64e3aed41b94449e6f71a2b3d69727ac 100644 (file)
--- a/src/shared/utils.pas
+++ b/src/shared/utils.pas
SysUtils, Classes;
+// ////////////////////////////////////////////////////////////////////////// //
+type
+ SSArray = array of ShortString;
+
+
// ////////////////////////////////////////////////////////////////////////// //
type
TUtf8DecoderFast = packed record
index b83102bf611814015126b787f8cc968608541120..818e912f7ee532a42591b2059d890d39c4b27edb 100644 (file)
--- a/src/shared/wadreader.pas
+++ b/src/shared/wadreader.pas
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
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;
implementation
uses
- SysUtils, e_log, utils, MAPDEF, xdynrec;
+ SysUtils, e_log, MAPDEF, xdynrec;
function findDiskWad (fname: AnsiString): AnsiString;
result := GetResourceEx(name, true, pData, Len, logError);
end;
-function TWADFile.GetMapResources (): SArray;
+function TWADFile.GetMapResources (): SSArray;
var
f, c: Integer;
fi: TSFSFileInfo;