diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 142e2be2a4f1933ef463ead57b5256bae6574503..c173bd00312e9686a7e4cb9df0165251e0de4ce4 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation, version 3 of the License ONLY.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
implementation
uses
implementation
uses
- {rttiobj,} typinfo, e_texture,
- SysUtils, Classes, GL, SDL2,
+ {$INCLUDE ../nogl/noGLuses.inc}
+ {rttiobj,} typinfo, e_texture, e_res,
+ SysUtils, Classes, SDL2,
MAPDEF, g_main, g_options,
utils, hashtable, xparser;
MAPDEF, g_main, g_options,
utils, hashtable, xparser;
procedure clearEdgeBmp ();
begin
procedure clearEdgeBmp ();
begin
- SetLength(edgeBmp, (gWinSizeX+4)*(gWinSizeY+4));
+ SetLength(edgeBmp, (gScreenWidth+4)*(gScreenHeight+4));
FillChar(edgeBmp[0], Length(edgeBmp)*sizeof(edgeBmp[0]), 0);
end;
FillChar(edgeBmp[0], Length(edgeBmp)*sizeof(edgeBmp[0]), 0);
end;
begin
sx := pan.X-(vpx-1);
len := pan.Width;
begin
sx := pan.X-(vpx-1);
len := pan.Width;
- if (len > gWinSizeX+4) then len := gWinSizeX+4;
+ if (len > gScreenWidth+4) then len := gScreenWidth+4;
if (sx < 0) then begin len += sx; sx := 0; end;
if (sx < 0) then begin len += sx; sx := 0; end;
- if (sx+len > gWinSizeX+4) then len := gWinSizeX+4-sx;
+ if (sx+len > gScreenWidth+4) then len := gScreenWidth+4-sx;
if (len < 1) then exit;
assert(sx >= 0);
if (len < 1) then exit;
assert(sx >= 0);
- assert(sx+len <= gWinSizeX+4);
+ assert(sx+len <= gScreenWidth+4);
y0 := pan.Y-(vpy-1);
y1 := y0+pan.Height;
if (y0 < 0) then y0 := 0;
y0 := pan.Y-(vpy-1);
y1 := y0+pan.Height;
if (y0 < 0) then y0 := 0;
- if (y1 > gWinSizeY+4) then y1 := gWinSizeY+4;
+ if (y1 > gScreenHeight+4) then y1 := gScreenHeight+4;
while (y0 < y1) do
begin
while (y0 < y1) do
begin
- FillChar(edgeBmp[y0*(gWinSizeX+4)+sx], len*sizeof(edgeBmp[0]), 1);
+ FillChar(edgeBmp[y0*(gScreenWidth+4)+sx], len*sizeof(edgeBmp[0]), 1);
Inc(y0);
end;
end
Inc(y0);
end;
end
glColor4f(r/255.0, g/255.0, b/255.0, 1.0);
for y := 1 to vph do
begin
glColor4f(r/255.0, g/255.0, b/255.0, 1.0);
for y := 1 to vph do
begin
- a := @edgeBmp[y*(gWinSizeX+4)+1];
+ a := @edgeBmp[y*(gScreenWidth+4)+1];
startLine(y);
for x := 1 to vpw do
begin
if (a[0] <> 0) then
begin
startLine(y);
for x := 1 to vpw do
begin
if (a[0] <> 0) then
begin
- if (a[-1] = 0) or (a[1] = 0) or (a[-(gWinSizeX+4)] = 0) or (a[gWinSizeX+4] = 0) or
- (a[-(gWinSizeX+4)-1] = 0) or (a[-(gWinSizeX+4)+1] = 0) or
- (a[gWinSizeX+4-1] = 0) or (a[gWinSizeX+4+1] = 0) then
+ if (a[-1] = 0) or (a[1] = 0) or (a[-(gScreenWidth+4)] = 0) or (a[gScreenWidth+4] = 0) or
+ (a[-(gScreenWidth+4)-1] = 0) or (a[-(gScreenWidth+4)+1] = 0) or
+ (a[gScreenWidth+4-1] = 0) or (a[gScreenWidth+4+1] = 0) then
begin
putPixel(x);
end;
begin
putPixel(x);
end;
glColor4f(r/255.0, g/255.0, b/255.0, 1.0);
for y := 1 to vph do
begin
glColor4f(r/255.0, g/255.0, b/255.0, 1.0);
for y := 1 to vph do
begin
- a := @edgeBmp[y*(gWinSizeX+4)+1];
+ a := @edgeBmp[y*(gScreenWidth+4)+1];
startLine(y);
for x := 1 to vpw do
begin
startLine(y);
for x := 1 to vpw do
begin
pdy := pmsCurMapY-(py+ph div 2);
hlmContext.color := TGxRGBA.Create(255, 0, 255, 200);
hlmContext.line(px+pw div 2, py+ph div 2, px+pw div 2+pdx, py+ph div 2+pdy);
pdy := pmsCurMapY-(py+ph div 2);
hlmContext.color := TGxRGBA.Create(255, 0, 255, 200);
hlmContext.line(px+pw div 2, py+ph div 2, px+pw div 2+pdx, py+ph div 2+pdy);
- pan := mapGrid.traceBox(ex, ey, px, py, pw, ph, pdx, pdy, nil, GridTagObstacle);
+ pan := mapGrid.traceBox(ex, ey, px, py, pw, ph, pdx, pdy, GridTagObstacle);
if (pan = nil) then
begin
hlmContext.color := TGxRGBA.Create(255, 255, 255, 180);
if (pan = nil) then
begin
hlmContext.color := TGxRGBA.Create(255, 255, 255, 180);
hlmContext.fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize);
end;
hlmContext.fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize);
end;
+ procedure hilightBodyCells (proxyId: Integer);
+ var
+ it: CellCoordIter;
+ pcellxy: PGridCellCoord;
+ begin
+ //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
+ it := monsGrid.forEachBodyCell(proxyId);
+ for pcellxy in it do hilightCell(pcellxy^.x, pcellxy^.y);
+ it.release();
+ end;
+
procedure hilightCell1 (cx, cy: Integer);
begin
//e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
procedure hilightCell1 (cx, cy: Integer);
begin
//e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
hlmContext.fillRect(pan.X, pan.Y, pan.Width, pan.Height);
end;
hlmContext.fillRect(pan.X, pan.Y, pan.Width, pan.Height);
end;
- function monsCollector (mon: TMonster; tag: Integer): Boolean;
+ procedure monsCollector (mon: TMonster);
var
ex, ey: Integer;
mx, my, mw, mh: Integer;
begin
var
ex, ey: Integer;
mx, my, mw, mh: Integer;
begin
- result := false;
mon.getMapBox(mx, my, mw, mh);
hlmContext.color := TGxRGBA.Create(255, 255, 0, 160);
hlmContext.rect(mx, my, mw, mh);
mon.getMapBox(mx, my, mw, mh);
hlmContext.color := TGxRGBA.Create(255, 255, 0, 160);
hlmContext.rect(mx, my, mw, mh);
mon.getMapBox(mx, my, mw, mh);
//mx += mw div 2;
mon.getMapBox(mx, my, mw, mh);
//mx += mw div 2;
- monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
+ //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
+ hilightBodyCells(mon.proxyId);
if showMonsInfo then
begin
if showMonsInfo then
begin
function highlightAllMonsterCells (mon: TMonster): Boolean;
begin
result := false; // don't stop
function highlightAllMonsterCells (mon: TMonster): Boolean;
begin
result := false; // don't stop
- monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
+ //monsGrid.forEachBodyCell(mon.proxyId, hilightCell);
+ hilightBodyCells(mon.proxyId);
end;
procedure drawSelectedPlatformCells ();
end;
procedure drawSelectedPlatformCells ();
if not showGrid then exit;
pan := g_Map_PanelByGUID(platMarkedGUID);
if (pan = nil) then exit;
if not showGrid then exit;
pan := g_Map_PanelByGUID(platMarkedGUID);
if (pan = nil) then exit;
- mapGrid.forEachBodyCell(pan.proxyId, hilightCell);
+ //mapGrid.forEachBodyCell(pan.proxyId, hilightCell);
+ hilightBodyCells(pan.proxyId);
hlmContext.color := TGxRGBA.Create(0, 200, 0, 200);
hlmContext.rect(pan.x, pan.y, pan.width, pan.height);
end;
hlmContext.color := TGxRGBA.Create(0, 200, 0, 200);
hlmContext.rect(pan.x, pan.y, pan.width, pan.height);
end;
var
mon: TMonster;
var
mon: TMonster;
+ mit: PMonster;
+ it: TMonsterGrid.Iter;
mx, my, mw, mh: Integer;
//pan: TPanel;
//ex, ey: Integer;
mx, my, mw, mh: Integer;
//pan: TPanel;
//ex, ey: Integer;
+ s: AnsiString;
+ dx, dy: Integer;
begin
if (gPlayer1 = nil) then exit;
begin
if (gPlayer1 = nil) then exit;
gxSetContext(hlmContext);
try
gxSetContext(hlmContext);
try
- //glScissor(0, gWinSizeY-gPlayerScreenSize.Y-1, vpw, vph);
+ //glScissor(0, gScreenHeight-gPlayerScreenSize.Y-1, vpw, vph);
//hlmContext.clip := TGxRect.Create(0, gScreenHeight-gPlayerScreenSize.Y-1, gPlayerScreenSize.X, gPlayerScreenSize.Y);
{
//hlmContext.clip := TGxRect.Create(0, gScreenHeight-gPlayerScreenSize.Y-1, gPlayerScreenSize.X, gPlayerScreenSize.Y);
{
if (showGrid) then drawTileGrid();
drawOutlines();
if (showGrid) then drawTileGrid();
drawOutlines();
- if (laserSet) then g_Mons_AlongLine(laserX0, laserY0, laserX1, laserY1, monsCollector, true);
+ if (laserSet) then
+ begin
+ //g_Mons_AlongLine(laserX0, laserY0, laserX1, laserY1, monsCollector, true);
+ it := monsGrid.forEachAlongLine(laserX0, laserY0, laserX1, laserY1, -1, true);
+ for mit in it do monsCollector(mit^);
+ it.release();
+ end;
if (monMarkedUID <> -1) then
begin
if (monMarkedUID <> -1) then
begin
if showMapCurPos then
begin
if showMapCurPos then
begin
+ s := Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]);
gxSetContext(hlmContext);
hlmContext.font := 'win8';
gxSetContext(hlmContext);
hlmContext.font := 'win8';
+ hlmContext.color := TGxRGBA.Create(0, 0, 0);
+ for dy := -1 to 1 do
+ begin
+ for dx := -1 to 1 do
+ begin
+ if (dx <> 0) or (dy <> 0) then hlmContext.drawText(4+dx, gScreenHeight-10+dy, s);
+ end;
+ end;
hlmContext.color := TGxRGBA.Create(255, 255, 0);
hlmContext.color := TGxRGBA.Create(255, 255, 0);
- hlmContext.drawText(4, gWinSizeY-10, Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]));
+ hlmContext.drawText(4, gScreenHeight-10, s);
gxSetContext(nil);
end;
end;
gxSetContext(nil);
end;
end;
var
plr: TPlayer;
x, y, w, h: Integer;
var
plr: TPlayer;
x, y, w, h: Integer;
- pmark: PoolMark;
- hitcount: Integer;
- pmon: PMonster;
+ mit: PMonster;
+ it: TMonsterGrid.Iter;
begin
monMarkedUID := -1;
if (Length(gPlayers) > 0) then
begin
monMarkedUID := -1;
if (Length(gPlayers) > 0) then
end;
end;
//e_WriteLog('===========================', MSG_NOTIFY);
end;
end;
//e_WriteLog('===========================', MSG_NOTIFY);
- pmark := framePool.mark();
- hitcount := monsGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY);
- pmon := PMonster(framePool.getPtr(pmark));
- while (hitcount > 0) do
- begin
- monsAtDump(pmon^);
- Inc(pmon);
- Dec(hitcount);
- end;
- framePool.release(pmark);
+ it := monsGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY);
+ for mit in it do monsAtDump(mit^);
+ it.release();
//e_WriteLog('---------------------------', MSG_NOTIFY);
end;
//e_WriteLog('---------------------------', MSG_NOTIFY);
end;
e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), TMsgType.Notify);
end;
var
e_WriteLog(Format('monster #%d (UID:%u) (proxyid:%d)', [mon.arrIdx, mon.UID, mon.proxyId]), TMsgType.Notify);
end;
var
- pmark: PoolMark;
- hitcount: Integer;
- pmon: PMonster;
+ mit: PMonster;
+ it: TMonsterGrid.Iter;
begin
begin
- pmark := framePool.mark();
- hitcount := monsGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY);
- if (hitcount > 0) then
+ it := monsGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY);
+ if (it.length > 0) then
begin
e_WriteLog('===========================', TMsgType.Notify);
begin
e_WriteLog('===========================', TMsgType.Notify);
- pmon := PMonster(framePool.getPtr(pmark));
- while (hitcount > 0) do
- begin
- monsAtDump(pmon^);
- Inc(pmon);
- Dec(hitcount);
- end;
+ for mit in it do monsAtDump(mit^);
e_WriteLog('---------------------------', TMsgType.Notify);
end;
e_WriteLog('---------------------------', TMsgType.Notify);
end;
- framePool.release(pmark);
+ it.release();
end;
procedure cbAtcurDumpWalls ();
end;
procedure cbAtcurDumpWalls ();
hasTrigs: Boolean = false;
f: Integer;
trig: PTrigger;
hasTrigs: Boolean = false;
f: Integer;
trig: PTrigger;
- pmark: PoolMark;
- hitcount: Integer;
- ppan: PPanel;
+ mwit: PPanel;
+ it: TPanelGrid.Iter;
begin
platMarkedGUID := -1;
begin
platMarkedGUID := -1;
- pmark := framePool.mark();
- hitcount := mapGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, (GridTagWall or GridTagDoor));
- if (hitcount > 0) then
+ it := mapGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, (GridTagWall or GridTagDoor));
+ if (it.length > 0) then
begin
e_WriteLog('=== TOGGLE WALL ===', TMsgType.Notify);
begin
e_WriteLog('=== TOGGLE WALL ===', TMsgType.Notify);
- ppan := PPanel(framePool.getPtr(pmark));
- while (hitcount > 0) do
- begin
- wallToggle(ppan^);
- Inc(ppan);
- Dec(hitcount);
- end;
+ for mwit in it do wallToggle(mwit^);
e_WriteLog('--- toggle wall ---', TMsgType.Notify);
end;
e_WriteLog('--- toggle wall ---', TMsgType.Notify);
end;
- framePool.release(pmark);
+ it.release();
if showTriggers then
begin
for f := 0 to High(gTriggers) do
if showTriggers then
begin
for f := 0 to High(gTriggers) do
if pan.Enabled then g_Map_DisableWallGUID(pan.guid) else g_Map_EnableWallGUID(pan.guid);
end;
var
if pan.Enabled then g_Map_DisableWallGUID(pan.guid) else g_Map_EnableWallGUID(pan.guid);
end;
var
- pmark: PoolMark;
- hitcount: Integer;
- ppan: PPanel;
+ mwit: PPanel;
+ it: TPanelGrid.Iter;
begin
//e_WriteLog('=== TOGGLE WALL ===', MSG_NOTIFY);
//e_WriteLog('--- toggle wall ---', MSG_NOTIFY);
begin
//e_WriteLog('=== TOGGLE WALL ===', MSG_NOTIFY);
//e_WriteLog('--- toggle wall ---', MSG_NOTIFY);
- pmark := framePool.mark();
- hitcount := mapGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, (GridTagWall or GridTagDoor));
- ppan := PPanel(framePool.getPtr(pmark));
- while (hitcount > 0) do
- begin
- wallToggle(ppan^);
- Inc(ppan);
- Dec(hitcount);
- end;
- framePool.release(pmark);
+ it := mapGrid.forEachAtPoint(pmsCurMapX, pmsCurMapY, (GridTagWall or GridTagDoor));
+ for mwit in it do wallToggle(mwit^);
+ it.release();
end;
end;
// load bindings from file
try
// load bindings from file
try
- st := openDiskFileRO(GameDir+'holmes.rc');
+ st := e_OpenResourceRO(ConfigDirs, 'holmes.rc');
pr := TFileTextParser.Create(st);
conwriteln('parsing "holmes.rc"...');
while (pr.tokType <> pr.TTEOF) do
pr := TFileTextParser.Create(st);
conwriteln('parsing "holmes.rc"...');
while (pr.tokType <> pr.TTEOF) do