summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8c90efc)
raw | patch | inline | side by side (parent: 8c90efc)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 21 Sep 2017 20:00:06 +0000 (23:00 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 21 Sep 2017 20:00:31 +0000 (23:00 +0300) |
diff --git a/src/game/g_holmes.inc b/src/game/g_holmes.inc
index 3cfdd17b09580471164bfc819190b7ee85d861e6..c053b4c73e8eb7b246bf9470fc055a808b0b6434 100644 (file)
--- a/src/game/g_holmes.inc
+++ b/src/game/g_holmes.inc
end;
+// ////////////////////////////////////////////////////////////////////////// //
+type
+ TScissorSave = record
+ public
+ wassc: Boolean;
+ scxywh: packed array[0..3] of GLint;
+
+ public
+ procedure save (enableScissoring: Boolean);
+ procedure restore ();
+ end;
+
+procedure TScissorSave.save (enableScissoring: Boolean);
+begin
+ wassc := (glIsEnabled(GL_SCISSOR_TEST) <> 0);
+ if wassc then glGetIntegerv(GL_SCISSOR_BOX, @scxywh[0]) else glGetIntegerv(GL_VIEWPORT, @scxywh[0]);
+ //conwritefln('(%d,%d)-(%d,%d)', [scxywh[0], scxywh[1], scxywh[2], scxywh[3]]);
+ if enableScissoring then glEnable(GL_SCISSOR_TEST);
+end;
+
+
+procedure TScissorSave.restore ();
+begin
+ glScissor(scxywh[0], scxywh[1], scxywh[2], scxywh[3]);
+ if wassc then glEnable(GL_SCISSOR_TEST) else glDisable(GL_SCISSOR_TEST);
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
// fonts
const kgiFont6: array[0..256*8-1] of Byte = (
diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index e64c20508a3411567a8571300da18f0605b2f677..33db7d0a1a4c474d12c0a364ff892af0291408cf 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
begin
if (vpw < 2) or (vph < 2) then exit;
- glScissor(0, gScreenHeight-gPlayerScreenSize.Y, gPlayerScreenSize.X, gPlayerScreenSize.Y);
- glEnable(GL_SCISSOR_TEST);
if g_ol_rlayer_back then doWallsOld(gRenderBackgrounds, PANEL_BACK, 255, 127, 0);
if g_ol_rlayer_step then doWallsOld(gSteps, PANEL_STEP, 192, 192, 192);
if g_ol_rlayer_wall then doWallsOld(gWalls, PANEL_WALL, 255, 255, 255);
if g_ol_rlayer_acid2 then doWallsOld(gAcid2, PANEL_ACID2, 198, 198, 0);
if g_ol_rlayer_water then doWallsOld(gWater, PANEL_WATER, 0, 255, 255);
if g_ol_rlayer_fore then doWallsOld(gRenderForegrounds, PANEL_FORE, 210, 210, 210);
- glScissor(0, 0, gScreenWidth, gScreenHeight);
- glDisable(GL_SCISSOR_TEST);
end;
{$ENDIF}
end;
var
+ scisave: TScissorSave;
mon: TMonster;
mx, my, mw, mh: Integer;
//pan: TPanel;
begin
if (gPlayer1 = nil) then exit;
- glEnable(GL_SCISSOR_TEST);
- glScissor(0, gWinSizeY-gPlayerScreenSize.Y-1, vpw, vph);
-
+ scisave.save(true); // enable scissoring
glPushMatrix();
- glScalef(g_dbg_scale, g_dbg_scale, 1.0);
- glTranslatef(-vpx, -vpy, 0);
+ try
+ //glScissor(0, gWinSizeY-gPlayerScreenSize.Y-1, vpw, vph);
+ glScissor(0, gScreenHeight-gPlayerScreenSize.Y-1, gPlayerScreenSize.X, gPlayerScreenSize.Y);
- if (showGrid) then drawTileGrid();
- drawOutlines();
+ glScalef(g_dbg_scale, g_dbg_scale, 1.0);
+ glTranslatef(-vpx, -vpy, 0);
- if (laserSet) then g_Mons_AlongLine(laserX0, laserY0, laserX1, laserY1, monsCollector, true);
+ if (showGrid) then drawTileGrid();
+ drawOutlines();
- if (monMarkedUID <> -1) then
- begin
- mon := g_Monsters_ByUID(monMarkedUID);
- if (mon <> nil) then
+ if (laserSet) then g_Mons_AlongLine(laserX0, laserY0, laserX1, laserY1, monsCollector, true);
+
+ if (monMarkedUID <> -1) then
begin
- mon.getMapBox(mx, my, mw, mh);
- e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 0, 0, 30);
- drawMonsterInfo(mon);
+ mon := g_Monsters_ByUID(monMarkedUID);
+ if (mon <> nil) then
+ begin
+ mon.getMapBox(mx, my, mw, mh);
+ e_DrawQuad(mx, my, mx+mw-1, my+mh-1, 255, 0, 0, 30);
+ drawMonsterInfo(mon);
+ end;
end;
- end;
- if showAllMonsCells and showGrid then g_Mons_ForEach(highlightAllMonsterCells);
- if showTriggers then drawTriggers();
- if showGrid then drawSelectedPlatformCells();
+ if showAllMonsCells and showGrid then g_Mons_ForEach(highlightAllMonsterCells);
+ if showTriggers then drawTriggers();
+ if showGrid then drawSelectedPlatformCells();
- //drawAwakeCells();
+ //drawAwakeCells();
- if showTraceBox then drawTraceBox();
+ if showTraceBox then drawTraceBox();
- //drawGibsBoxes();
+ //drawGibsBoxes();
- //pan := g_Map_traceToNearest(16, 608, 16, 8, (GridTagObstacle or GridTagLiquid), @ex, @ey);
- (*
- {$IF DEFINED(D2F_DEBUG)}
- mapGrid.dbgRayTraceTileHitCB := hilightCell1;
- {$ENDIF}
- pan := mapGrid.traceRay(ex, ey, 16, 608, 16, 8, nil, (GridTagObstacle or GridTagLiquid));
- if (pan <> nil) then writeln('end=(', ex, ',', ey, ')');
- {$IF DEFINED(D2F_DEBUG)}
- mapGrid.dbgRayTraceTileHitCB := nil;
- {$ENDIF}
-
- pan := g_Map_PanelAtPoint(16, 608, (GridTagObstacle or GridTagLiquid));
- if (pan <> nil) then writeln('hit!');
- *)
+ //pan := g_Map_traceToNearest(16, 608, 16, 8, (GridTagObstacle or GridTagLiquid), @ex, @ey);
+ (*
+ {$IF DEFINED(D2F_DEBUG)}
+ mapGrid.dbgRayTraceTileHitCB := hilightCell1;
+ {$ENDIF}
+ pan := mapGrid.traceRay(ex, ey, 16, 608, 16, 8, nil, (GridTagObstacle or GridTagLiquid));
+ if (pan <> nil) then writeln('end=(', ex, ',', ey, ')');
+ {$IF DEFINED(D2F_DEBUG)}
+ mapGrid.dbgRayTraceTileHitCB := nil;
+ {$ENDIF}
- glPopMatrix();
+ pan := g_Map_PanelAtPoint(16, 608, (GridTagObstacle or GridTagLiquid));
+ if (pan <> nil) then writeln('hit!');
+ *)
- glDisable(GL_SCISSOR_TEST);
+ finally
+ glPopMatrix();
+ scisave.restore();
+ end;
if showMapCurPos then drawText8(4, gWinSizeY-10, Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]), 255, 255, 0);
end;
index 63b0ae55a83587d0e1118b97633e2053ed3185d2..578f86583d3d3df5ea68f8afebc94f630fa1a754 100644 (file)
// ////////////////////////////////////////////////////////////////////////// //
-function ansistrEquCB (constref a, b: AnsiString): Boolean; begin result := (a = b); end;
-function ansistrHashCB (constref a: AnsiString): LongWord; begin if (Length(a) > 0) then result := fnvHash(PChar(a)^, Length(a)) else result := 0; end;
-
function hashNewCommand (): TCmdHash;
begin
- result := TCmdHash.Create(ansistrHashCB, ansistrEquCB);
+ result := TCmdHash.Create(hashStrHash, hashStrEqu, hashStrFree);
end;
index f378cd1be611aad2b8a0b0197a64e0c50125a299..ac5a523ff296172447c9b34579bd7cddf184aab3 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.pas
xdynrec, hashtable, exoma;
type
- THashStrVariant = specialize THashBase<AnsiString, Variant>;
-
TActivator = record
UID: Word;
TimeOut: Word;
if (Length(afldname) > 4) and (afldname[1] = 'u') and (afldname[2] = 's') and
(afldname[3] = 'e') and (afldname[4] = 'r') then
begin
- if (me.userVars = nil) then me.userVars := THashStrVariant.Create(hashStrHash, hashStrEqu);
+ if (me.userVars = nil) then me.userVars := hashNewStrVariant();
me.userVars.put(afldname, aval);
exit;
end;
// update cached trigger variables
trigUpdateCacheData(ptg^, ptg.trigDataRec);
- ptg.userVars := nil; //THashStrVariant.Create(hashStrHash, hashStrEqu);
+ ptg.userVars := nil;
try
ptg.exoThink := TExprBase.parseStatList(tgclist, VarToStr(trec.user['exoma_think']));
if (uvcount < 0) or (uvcount > 1024*1024) then raise XStreamError.Create('invalid number of user vars in trigger');
if (uvcount > 0) then
begin
- gTriggers[i].userVars := THashStrVariant.Create(hashStrHash, hashStrEqu);
+ gTriggers[i].userVars := hashNewStrVariant();
vv := Unassigned;
while (uvcount > 0) do
begin
index 85133c3efbc10d47581f03f132ed6bda137d36b7..495f432c46474bc89027e779a6c404303fefbd55 100644 (file)
--- a/src/shared/hashtable.pas
+++ b/src/shared/hashtable.pas
THashStrInt = specialize THashBase<AnsiString, Integer>;
THashIntStr = specialize THashBase<Integer, AnsiString>;
THashStrStr = specialize THashBase<AnsiString, AnsiString>;
+ THashStrVariant = specialize THashBase<AnsiString, Variant>;
-function hashNewIntInt (): THashIntInt;
-function hashNewStrInt (): THashStrInt;
-function hashNewIntStr (): THashIntStr;
-function hashNewStrStr (): THashStrStr;
+function hashNewIntInt (): THashIntInt; inline;
+function hashNewStrInt (): THashStrInt; inline;
+function hashNewIntStr (): THashIntStr; inline;
+function hashNewStrStr (): THashStrStr; inline;
+function hashNewStrVariant (): THashStrVariant; inline;
function u32Hash (a: LongWord): LongWord; inline;
function hashStrEqu (constref a, b: AnsiString): Boolean;
function hashStrHash (constref k: AnsiString): LongWord;
procedure hashStrFree (var s: AnsiString);
+procedure hashVariantFree (var v: Variant);
implementation
uses
- SysUtils;
+ SysUtils, Variants;
// ////////////////////////////////////////////////////////////////////////// //
function hashIntEqu (constref a, b: Integer): Boolean; begin result := (a = b); end;
function hashStrEqu (constref a, b: AnsiString): Boolean; begin result := (a = b); end;
procedure hashStrFree (var s: AnsiString); begin s := ''; end;
+procedure hashVariantFree (var v: Variant); begin v := Unassigned; end;
{$PUSH}
{$RANGECHECKS OFF}
{$POP}
-function hashNewIntInt (): THashIntInt;
+function hashNewIntInt (): THashIntInt; inline;
begin
result := THashIntInt.Create(hashIntHash, hashIntEqu);
end;
-function hashNewStrInt (): THashStrInt;
+function hashNewStrInt (): THashStrInt; inline;
begin
result := THashStrInt.Create(hashStrHash, hashStrEqu, hashStrFree);
end;
-function hashNewIntStr (): THashIntStr;
+function hashNewIntStr (): THashIntStr; inline;
begin
result := THashIntStr.Create(hashIntHash, hashIntEqu, nil, hashStrFree);
end;
-function hashNewStrStr (): THashStrStr;
+function hashNewStrStr (): THashStrStr; inline;
begin
result := THashStrStr.Create(hashStrHash, hashStrEqu, hashStrFree, hashStrFree);
end;
+function hashNewStrVariant (): THashStrVariant; inline;
+begin
+ result := THashStrVariant.Create(hashStrHash, hashStrEqu, hashStrFree, hashVariantFree);
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
{$PUSH}
{$RANGECHECKS OFF}