summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 243b29c)
raw | patch | inline | side by side (parent: 243b29c)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 19 Aug 2017 13:22:00 +0000 (16:22 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sat, 19 Aug 2017 13:28:00 +0000 (16:28 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/g_grid.pas | patch | blob | history | |
src/game/g_map.pas | patch | blob | history | |
src/game/z_aabbtree.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 369f5ac58f4adb8068bed26d2afe20260d85981b..d4af70f7fbf8376458c98d9a69a220ede0ced087 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
gDefaultMegawadStart := s;
end;
- s := LowerCase(Find_Param_Value(pars, '-dbg-mainwad-restore'));
- if (s <> '') then
+ if (Find_Param_Value(pars, '--dbg-mainwad-restore') <> '') or
+ (Find_Param_Value(pars, '--dbg-mainwad-default') <> '') then
begin
gDefaultMegawadStart := DF_Default_Megawad_Start;
end;
diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index 5b2f8b135d27583c5a849aaec6ab3e46f5d4ef7e..81974570c4e201bd52d550e2b556fed261e8ffd6 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
GridCellBucketSize = 8; // WARNING! can't be less than 2!
type
- TGridQueryCB = function (obj: TObject; objx, objy, objw, objh: Integer; tag: Integer): Boolean is nested; // return `true` to stop
+ TGridQueryCB = function (obj: TObject; tag: Integer): Boolean is nested; // return `true` to stop
type
TBodyGrid = class;
next: Integer; // in this cell; index in mCells
end;
- GridInternalCB = function (grida: Integer): Boolean is nested; // return `true` to stop
+ TGridInternalCB = function (grida: Integer): Boolean is nested; // return `true` to stop
TBodyGrid = class(TObject)
private
procedure insert (body: TBodyProxy);
procedure remove (body: TBodyProxy);
- function forGridRect (x, y, w, h: Integer; cb: GridInternalCB): Boolean;
+ function forGridRect (x, y, w, h: Integer; cb: TGridInternalCB): Boolean;
public
constructor Create (aMinPixX, aMinPixY, aPixWidth, aPixHeight: Integer; aTileSize: Integer=GridDefaultTileSize);
end;
-function TBodyGrid.forGridRect (x, y, w, h: Integer; cb: GridInternalCB): Boolean;
+function TBodyGrid.forGridRect (x, y, w, h: Integer; cb: TGridInternalCB): Boolean;
var
gx, gy: Integer;
begin
@@ -474,7 +474,7 @@ function TBodyGrid.forEachInAABB (x, y, w, h: Integer; cb: TGridQueryCB; tagmask
begin
//e_WriteLog(Format(' query #%d body hit: (%d,%d)-(%dx%d) tag:%d', [mLastQuery, mCells[idx].body.mX, mCells[idx].body.mY, mCells[idx].body.mWidth, mCells[idx].body.mHeight, mCells[idx].body.mTag]), MSG_NOTIFY);
px.mQueryMark := mLastQuery;
- if (cb(px.mObj, px.mX, px.mY, px.mWidth, px.mHeight, px.mTag)) then begin result := true; exit; end;
+ if (cb(px.mObj, px.mTag)) then begin result := true; exit; end;
end;
end;
idx := pi.next;
@@ -486,7 +486,7 @@ function TBodyGrid.forEachInAABB (x, y, w, h: Integer; cb: TGridQueryCB; tagmask
begin
//e_WriteLog(Format(' query #%d body hit: (%d,%d)-(%dx%d) tag:%d', [mLastQuery, mCells[idx].body.mX, mCells[idx].body.mY, mCells[idx].body.mWidth, mCells[idx].body.mHeight, mCells[idx].body.mTag]), MSG_NOTIFY);
px.mQueryMark := mLastQuery;
- if (cb(px.mObj, px.mX, px.mY, px.mWidth, px.mHeight, px.mTag)) then begin result := true; exit; end;
+ if (cb(px.mObj, px.mTag)) then begin result := true; exit; end;
end;
end;
idx := mCells[idx].next;
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 23fd6cbd7a038b8237a4ce5a00e3bd23e14a887c..2f1e856f7ae6a5be6a91ee40023915197504fef2 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
// new algo
procedure g_Map_CollectDrawPanels (x0, y0, wdt, hgt: Integer);
- function checker (obj: TObject; objx, objy, objw, objh: Integer; tag: Integer): Boolean;
+ function checker (obj: TObject; tag: Integer): Boolean;
var
pan: TPanel;
begin
procedure g_Map_DrawPanelShadowVolumes(lightX: Integer; lightY: Integer; radius: Integer);
- function checker (obj: TObject; objx, objy, objw, objh: Integer; tag: Integer): Boolean;
+ function checker (obj: TObject; tag: Integer): Boolean;
var
pan: TPanel;
begin
function g_Map_CollidePanel(X, Y: Integer; Width, Height: Word; PanelType: Word; b1x3: Boolean): Boolean;
-
- function checker (obj: TObject; objx, objy, objwidth, objheight: Integer; tag: Integer): Boolean;
+ function checker (obj: TObject; tag: Integer): Boolean;
var
pan: TPanel;
begin
result := false; // don't stop, ever
+ pan := TPanel(obj);
+
+ if ((tag and (GridTagWall or GridTagDoor)) <> 0) then
+ begin
+ if not pan.Enabled then exit;
+ end;
if ((tag and GridTagLift) <> 0) then
begin
- pan := TPanel(obj);
- if ((WordBool(PanelType and (PANEL_LIFTUP)) and (pan.LiftType = 0)) or
- (WordBool(PanelType and (PANEL_LIFTDOWN)) and (pan.LiftType = 1)) or
- (WordBool(PanelType and (PANEL_LIFTLEFT)) and (pan.LiftType = 2)) or
- (WordBool(PanelType and (PANEL_LIFTRIGHT)) and (pan.LiftType = 3))) and
- g_Collide(X, Y, Width, Height, objx, objy, objwidth, objheight) then
- begin
- result := true;
- exit;
- end;
+ result :=
+ ((WordBool(PanelType and PANEL_LIFTUP) and (pan.LiftType = 0)) or
+ (WordBool(PanelType and PANEL_LIFTDOWN) and (pan.LiftType = 1)) or
+ (WordBool(PanelType and PANEL_LIFTLEFT) and (pan.LiftType = 2)) or
+ (WordBool(PanelType and PANEL_LIFTRIGHT) and (pan.LiftType = 3))) and
+ g_Collide(X, Y, Width, Height, pan.X, pan.Y, pan.Width, pan.Height);
+ exit;
end;
if ((tag and GridTagBlockMon) <> 0) then
begin
- if ((not b1x3) or (objwidth+objheight >= 64)) and g_Collide(X, Y, Width, Height, objx, objy, objwidth, objheight) then
- begin
- result := True;
- exit;
- end;
+ result := ((not b1x3) or (pan.Width+pan.Height >= 64)) and g_Collide(X, Y, Width, Height, pan.X, pan.Y, pan.Width, pan.Height);
+ exit;
end;
// other shit
- result := g_Collide(X, Y, Width, Height, objx, objy, objwidth, objheight);
+ result := g_Collide(X, Y, Width, Height, pan.X, pan.Y, pan.Width, pan.Height);
end;
var
tagmask: Integer = 0;
begin
- //TODO: detailed profile
if WordBool(PanelType and PANEL_WALL) then tagmask := tagmask or GridTagWall or GridTagDoor;
if WordBool(PanelType and PANEL_WATER) then tagmask := tagmask or GridTagWater;
if WordBool(PanelType and PANEL_ACID1) then tagmask := tagmask or GridTagAcid1;
function g_Map_CollideLiquid_Texture(X, Y: Integer; Width, Height: Word): DWORD;
var
- cctype: Integer = 3; // priority: 0: water, 1: acid1, 2: acid2; 3: others (nothing)
+ cctype: Integer = 3; // priority: 0: water was hit, 1: acid1 was hit, 2: acid2 was hit; 3: nothing was hit
texid: DWORD;
// slightly different from the old code, but meh...
- function checker (obj: TObject; objx, objy, objwidth, objheight: Integer; tag: Integer): Boolean;
- //var pan: TPanel;
+ function checker (obj: TObject; tag: Integer): Boolean;
+ var
+ pan: TPanel;
begin
result := false; // don't stop, ever
- if ((tag and (GridTagWater or GridTagAcid1 or GridTagAcid2)) = 0) then exit;
+ //if ((tag and (GridTagWater or GridTagAcid1 or GridTagAcid2)) = 0) then exit;
// check priorities
case cctype of
- 0: if ((tag and GridTagWater) = 0) then exit; // only water
- 1: if ((tag and (GridTagWater or GridTagAcid1)) = 0) then exit; // water, acid1
- //2: if ((tag and (GridTagWater or GridTagAcid1 or GridTagAcid2) = 0) then exit; // water, acid1, acid2
+ 0: if ((tag and GridTagWater) = 0) then exit; // allowed: water
+ 1: if ((tag and (GridTagWater or GridTagAcid1)) = 0) then exit; // allowed: water, acid1
+ //2: if ((tag and (GridTagWater or GridTagAcid1 or GridTagAcid2) = 0) then exit; // allowed: water, acid1, acid2
end;
// collision?
- if not g_Collide(X, Y, Width, Height, objx, objy, objwidth, objheight) then exit;
+ pan := (obj as TPanel);
+ if not g_Collide(X, Y, Width, Height, pan.X, pan.Y, pan.Width, pan.Height) then exit;
// yeah
- //pan := (obj as TPanel);
texid := TPanel(obj).GetTextureID();
// water? water has the highest priority, so stop right here
if ((tag and GridTagWater) <> 0) then begin cctype := 0; result := true; exit; end;
- // acid2
+ // acid2?
if ((tag and GridTagAcid2) <> 0) then cctype := 2;
- // acid1
+ // acid1?
if ((tag and GridTagAcid1) <> 0) then cctype := 1;
end;
begin
- //TODO: detailed profile?
if (profMapCollision <> nil) then profMapCollision.sectionBeginAccum('liquids');
if gdbg_map_use_accel_coldet then
begin
index 31b6dd41969aff815aa266d296d7142154251dc2..5b3fa623d9b13dd14d4f8a6c695d5242f1b4ce50 100644 (file)
--- a/src/game/z_aabbtree.pas
+++ b/src/game/z_aabbtree.pas
public
// called when a overlapping node has been found during the call to forEachAABBOverlap()
// return `true` to stop
- type TQueryOverlapCB = function (abody: TTreeFlesh; objx, objy, objw, objh: Integer; atag: Integer): Boolean is nested;
+ type TQueryOverlapCB = function (abody: TTreeFlesh; atag: Integer): Boolean is nested;
type TSegQueryCallback = function (abody: TTreeFlesh; ax, ay, bx, by: Single): Single is nested; // return dist from (ax,ay) to abody
TSegmentQueryResult = record
{$IFDEF aabbtree_query_count}Inc(mNodesDeepVisited);{$ENDIF}
if ((node.tag and tagmask) <> 0) then
begin
- if (visitor(node.flesh, node.aabb.minX, node.aabb.minY, node.aabb.maxX, node.aabb.maxY, node.tag)) then begin result := nodeId; bigstack := nil; exit; end;
+ if (visitor(node.flesh, node.tag)) then begin result := nodeId; bigstack := nil; exit; end;
end;
end
else
@@ -1458,7 +1458,7 @@ function TDynAABBTree.pointQuery (ax, ay: TreeNumber; cb: TQueryOverlapCB): TTre
begin
result := node.aabb.contains(ax, ay);
end;
- function dummycb (abody: TTreeFlesh; objx, objy, objw, objh: Integer; atag: Integer): Boolean; begin result := false; end;
+ function dummycb (abody: TTreeFlesh; atag: Integer): Boolean; begin result := false; end;
var
nid: Integer;
caabb: AABB2D;
result := node.aabb.intersects(curax, curay, curbx, curby);
end;
- function visitor (flesh: TTreeFlesh; objx, objy, objw, objh: Integer; tag: Integer): Boolean;
+ function visitor (flesh: TTreeFlesh; tag: Integer): Boolean;
var
hitFraction: Single;
begin