summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5599208)
raw | patch | inline | side by side (parent: 5599208)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 23 Aug 2017 18:22:58 +0000 (21:22 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 23 Aug 2017 18:23:56 +0000 (21:23 +0300) |
diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index 2e7105e7729190fbe6e1062c834034beaa43de47..b1b157f8d3c685b3b65d457ed5620051d2bbb4dc 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
for idx := 0 to High(mCells) do
begin
mCells[idx].bodies[0] := -1;
+ mCells[idx].bodies[GridCellBucketSize-1] := -1; // "has free room" flag
mCells[idx].next := idx+1;
end;
mCells[High(mCells)].next := -1; // last cell
var
g, f, cidx: Integer;
cc: PGridCell;
- //px: PBodyProxyRec;
begin
if (body < 0) or (body > High(mProxies)) or not assigned(cb) then exit;
for g := 0 to High(mGrid) do
while (cidx <> -1) do
begin
cc := @mCells[cidx];
- for f := 0 to High(TGridCell.bodies) do
+ for f := 0 to GridCellBucketSize-1 do
begin
if (cc.bodies[f] = -1) then break;
if (cc.bodies[f] = body) then cb((g mod mWidth)*mTileSize+mMinX, (g div mWidth)*mTileSize+mMinY);
- //px := @mProxies[cc.bodies[f]];
end;
// next cell
cidx := cc.next;
while (cidx <> -1) do
begin
cc := @mCells[cidx];
- for f := 0 to High(TGridCell.bodies) do
+ for f := 0 to GridCellBucketSize-1 do
begin
if (cc.bodies[f] = -1) then break;
if cb(mProxies[cc.bodies[f]].mObj, mProxies[cc.bodies[f]].mTag) then begin result := mProxies[cc.bodies[f]].mObj; exit; end;
for idx := mFreeCell to High(mCells) do
begin
mCells[idx].bodies[0] := -1;
- mCells[idx].bodies[High(TGridCell.bodies)] := -1; // 'has free room' flag
+ mCells[idx].bodies[GridCellBucketSize-1] := -1; // 'has free room' flag
mCells[idx].next := idx+1;
end;
mCells[High(mCells)].next := -1; // last cell
pc := @mCells[result];
mFreeCell := pc.next;
pc.next := -1;
- //pc.bodies[0] := -1;
Inc(mUsedCells);
//e_WriteLog(Format('grid: allocated new cell #%d (total: %d)', [result, mUsedCells]), MSG_NOTIFY);
end;
with mCells[idx] do
begin
bodies[0] := -1;
- bodies[High(TGridCell.bodies)] := -1; // 'has free room' flag
+ bodies[GridCellBucketSize-1] := -1; // 'has free room' flag
next := mFreeCell;
end;
mFreeCell := idx;
if (pc <> -1) then
begin
pi := @mCells[pc];
- if (pi.bodies[High(TGridCell.bodies)] = -1) then
+ // check "has room" flag
+ if (pi.bodies[GridCellBucketSize-1] = -1) then
begin
// can add here
- for f := 0 to High(TGridCell.bodies) do
+ for f := 0 to GridCellBucketSize-1 do
begin
if (pi.bodies[f] = -1) then
begin
pi.bodies[f] := bodyId;
- if (f+1 < Length(TGridCell.bodies)) then pi.bodies[f+1] := -1;
+ if (f+1 < GridCellBucketSize) then pi.bodies[f+1] := -1;
exit;
end;
end;
while (cidx <> -1) do
begin
pc := @mCells[cidx];
- for f := 0 to High(TGridCell.bodies) do
+ for f := 0 to GridCellBucketSize-1 do
begin
if (pc.bodies[f] = bodyId) then
begin
exit;
end;
// remove element from bucket
- for c := f to High(TGridCell.bodies)-1 do
+ for c := f to GridCellBucketSize-2 do
begin
pc.bodies[c] := pc.bodies[c+1];
if (pc.bodies[c] = -1) then break;
end;
- pc.bodies[High(TGridCell.bodies)] := -1; // "has free room" flag
+ pc.bodies[GridCellBucketSize-1] := -1; // "has free room" flag
exit;
end;
end;
end;
end;
-// absolutely not tested
procedure TBodyGridBase.removeInternal (body: TBodyProxyId);
var
px: PBodyProxyRec;
while (curci <> -1) do
begin
cc := @mCells[curci];
- for f := 0 to High(TGridCell.bodies) do
+ for f := 0 to GridCellBucketSize-1 do
begin
if (cc.bodies[f] = -1) then break;
px := @mProxies[cc.bodies[f]];
while (curci <> -1) do
begin
cc := @mCells[curci];
- for f := 0 to High(TGridCell.bodies) do
+ for f := 0 to GridCellBucketSize-1 do
begin
if (cc.bodies[f] = -1) then break;
px := @mProxies[cc.bodies[f]];
while (curci <> -1) do
begin
cc := @mCells[curci];
- for f := 0 to High(TGridCell.bodies) do
+ for f := 0 to GridCellBucketSize-1 do
begin
if (cc.bodies[f] = -1) then break;
px := @mProxies[cc.bodies[f]];
while (curci <> -1) do
begin
cc := @mCells[curci];
- for f := 0 to High(TGridCell.bodies) do
+ for f := 0 to GridCellBucketSize-1 do
begin
if (cc.bodies[f] = -1) then break;
px := @mProxies[cc.bodies[f]];
diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 210368deda7b60c463d95b1acc1b13fe11395527..87788a4b03b6f2ac449ecf91a5de91ae524a6ea1 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
kbS: Word = 0; // keyboard modifiers state
showMonsInfo: Boolean = false;
showMonsLOS2Plr: Boolean = false;
+ showAllMonsCells: Boolean = false;
// ////////////////////////////////////////////////////////////////////////// //
}
end;
+ function highlightAllMonsterCells (mon: TMonster): Boolean;
+ begin
+ result := false; // don't stop
+ monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
+ end;
+
var
mon: TMonster;
mx, my, mw, mh: Integer;
end;
end;
+ if showAllMonsCells then g_Mons_ForEach(highlightAllMonsterCells);
+
//e_DrawPoint(16, laserX0, laserY0, 255, 255, 255);
glPopMatrix();
showMonsLOS2Plr := not showMonsLOS2Plr;
exit;
end;
+ // M-G: toggle "show all cells occupied by monsters"
+ if (ev.scan = SDL_SCANCODE_G) and ((ev.kstate and THKeyEvent.ModAlt) <> 0) then
+ begin
+ result := true;
+ showAllMonsCells := not showAllMonsCells;
+ exit;
+ end;
end;
end;
diff --git a/src/game/g_items.pas b/src/game/g_items.pas
index 27dbc75bf19abf1ced60905a43afd6212a3ac526..995651748561cc0073261b288feea077fe1bf4d4 100644 (file)
--- a/src/game/g_items.pas
+++ b/src/game/g_items.pas
begin
if ForcedID < 0 then find_id := allocItem() else find_id := wantItemSlot(ForcedID);
- {$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
+ //{$IF DEFINED(D2F_DEBUG)}e_WriteLog(Format('allocated item #%d', [Integer(find_id)]), MSG_NOTIFY);{$ENDIF}
it := @ggItems[find_id];
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index bf4bd8a7cf90fb01805877988977279cfc6f494c..746d85c2445815028759f26eb0b08e532d4e50df 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
// "enabled" flag has meaning only for doors and walls (engine assumes it); but meh...
mapGrid.proxyEnabled[pan.proxyId] := pan.Enabled;
{$IFDEF MAP_DEBUG_ENABLED_FLAG}
+ {
if ((tag and (GridTagWall or GridTagDoor)) <> 0) then
begin
e_WriteLog(Format('INSERTED wall #%d(%d) enabled (%d)', [Integer(idx), Integer(pan.proxyId), Integer(mapGrid.proxyEnabled[pan.proxyId])]), MSG_NOTIFY);
end;
+ }
{$ENDIF}
end;
end;
index ea7222f3194fb0006e04a62ade5769fbd8f07e3e..05ec0b05e12524832d707d295b6ea4343a307e27 100644 (file)
--- a/src/game/g_monsters.pas
+++ b/src/game/g_monsters.pas
// can return null
function g_Mons_ByIdx_NC (uid: Integer): TMonster; inline;
+function g_Mons_TotalCount (): Integer; inline;
+
function g_Mons_IsAnyAliveAt (x, y: Integer; width, height: Integer): Boolean;
function g_Mons_ForEach (cb: TEachMonsterCB): Boolean;
if (result = nil) then raise Exception.Create('g_Mons_ByIdx: invalid monster id');
end;
-
// can return null
function g_Mons_ByIdx_NC (uid: Integer): TMonster; inline;
begin
result := gMonsters[uid];
end;
+function g_Mons_TotalCount (): Integer; inline;
+begin
+ result := Length(gMonsters);
+end;
+
function g_Mons_ForEach (cb: TEachMonsterCB): Boolean;
var