summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4d64aec)
raw | patch | inline | side by side (parent: 4d64aec)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 30 Aug 2017 11:59:43 +0000 (14:59 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 30 Aug 2017 11:59:50 +0000 (14:59 +0300) |
src/game/g_grid.pas | patch | blob | history | |
src/shared/hashtable.pas | patch | blob | history | |
src/shared/utils.pas | patch | blob | history |
diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index 475cb68d7ec3b961c324f504bcf802230ae2bbfc..06790755698dfce7e15d73241fdabd65b4cbe689 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
y := yptr^+miny;
//prevx := x;
//prevy := y;
- {$IF DEFINED(D2F_DEBUG)}
- if hopt then
- begin
- if (y <> ay0) then raise Exception.Create('htrace fatal internal error');
- end
- else
- begin
- if (x <> ax0) then raise Exception.Create('vtrace fatal internal error');
- end;
- {$ENDIF}
while (wklen > 0) do
begin
{$IF DEFINED(D2F_DEBUG)}
if dbgShowTraceLog then e_LogWritefln('optimized htrace; wklen=%d', [wklen]);
{$ENDIF}
ga := (yptr^ div tsize)*gw+(xptr^ div tsize);
- {$IF DEFINED(D2F_DEBUG)}
- if hopt then
- begin
- if (yptr^ <> ay0) then raise Exception.Create('htrace fatal internal error');
- end
- else
- begin
- if (xptr^ <> ax0) then raise Exception.Create('vtrace fatal internal error');
- end;
- {$ENDIF}
while (wklen > 0) do
begin
{$IF DEFINED(D2F_DEBUG)}
index 190d4e62b57cb9c9b9941bc78dec401239aaf0d2..9f72e3ab2f5fb547da371473cc30e87e8b47887b 100644 (file)
--- a/src/shared/hashtable.pas
+++ b/src/shared/hashtable.pas
mEntries: TEntryArray;
mFirstEntry, mLastEntry, cur: Integer;
public
- constructor Create (aents: TEntryArray; afirst, alast: Integer);
+ constructor Create (const aents: TEntryArray; afirst, alast: Integer);
function MoveNext (): Boolean; inline;
function getCurrent (): ValueT; inline;
property Current: ValueT read getCurrent;
mEntries: TEntryArray;
mFirstEntry, mLastEntry, cur: Integer;
public
- constructor Create (aents: TEntryArray; afirst, alast: Integer);
+ constructor Create (const aents: TEntryArray; afirst, alast: Integer);
function MoveNext (): Boolean; inline;
function getCurrent (): KeyT; inline;
property Current: KeyT read getCurrent;
mEntries: TEntryArray;
mFirstEntry, mLastEntry, cur: Integer;
public
- constructor Create (aents: TEntryArray; afirst, alast: Integer);
+ constructor Create (const aents: TEntryArray; afirst, alast: Integer);
function MoveNext (): Boolean; inline;
function getCurrent (): PEntry; inline;
property Current: PEntry read getCurrent;
// ////////////////////////////////////////////////////////////////////////// //
-constructor THashBase.TValEnumerator.Create (aents: TEntryArray; afirst, alast: Integer);
+constructor THashBase.TValEnumerator.Create (const aents: TEntryArray; afirst, alast: Integer);
begin
mEntries := aents;
mFirstEntry := afirst;
// ////////////////////////////////////////////////////////////////////////// //
-constructor THashBase.TKeyEnumerator.Create (aents: TEntryArray; afirst, alast: Integer);
+constructor THashBase.TKeyEnumerator.Create (const aents: TEntryArray; afirst, alast: Integer);
begin
mEntries := aents;
mFirstEntry := afirst;
// ////////////////////////////////////////////////////////////////////////// //
-constructor THashBase.TKeyValEnumerator.Create (aents: TEntryArray; afirst, alast: Integer);
+constructor THashBase.TKeyValEnumerator.Create (const aents: TEntryArray; afirst, alast: Integer);
begin
mEntries := aents;
mFirstEntry := afirst;
diff --git a/src/shared/utils.pas b/src/shared/utils.pas
index 9e136495bc8792dc661c3e4fa254ee58d24974a6..fd57312b5481e117c5ea21ea1da89a4bbe9710d2 100644 (file)
--- a/src/shared/utils.pas
+++ b/src/shared/utils.pas
generic TSimpleList<ItemT> = class
private
type PItemT = ^ItemT;
+ type TItemArr = array of ItemT;
public
type
TEnumerator = record
private
- mItems: PItemT;
+ mItems: TItemArr;
mCount: Integer;
mCurrent: Integer;
public
- constructor Create (aitems: PItemT; acount: Integer);
+ constructor Create (const aitems: TItemArr; acount: Integer);
function MoveNext: Boolean;
function getCurrent (): ItemT;
property Current: ItemT read getCurrent;
end;
private
- mItems: array of ItemT;
+ mItems: TItemArr;
mCount: Integer; // can be less than `mItems` size
private
// ////////////////////////////////////////////////////////////////////////// //
-constructor TSimpleList.TEnumerator.Create (aitems: PItemT; acount: Integer);
+constructor TSimpleList.TEnumerator.Create (const aitems: TItemArr; acount: Integer);
begin
mItems := aitems;
- mCount := acount;
mCurrent := -1;
+ mCount := acount;
end;
function TSimpleList.TEnumerator.MoveNext: Boolean;
function TSimpleList.GetEnumerator (): TEnumerator;
begin
- if (Length(mItems) > 0) then result := TEnumerator.Create(@mItems[0], mCount)
+ if (Length(mItems) > 0) then result := TEnumerator.Create(mItems, mCount)
else result := TEnumerator.Create(nil, -1);
end;