diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index e99d47b19186dd65974751d9a2dd3e90539e3439..6cc1e90273033dbdbc925b27daad7c0bd258db4e 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
uses
SysUtils, Classes, mempool,
- e_graphics, g_basic, MAPDEF, g_textures,
+ g_base, r_graphics, g_basic, MAPDEF, g_textures,
g_phys, utils, g_panel, g_grid, md5, binheap, xprofiler, xparser, xdynrec;
type
CaptureTime: LongWord;
Animation: TAnimation;
Direction: TDirection;
+ NeedSend: Boolean;
end;
function g_Map_Load(Res: String): Boolean;
function g_Map_PanelByGUID (aguid: Integer): TPanel; inline;
-procedure g_Map_DrawPanels (PanelType: Word; hasAmbient: Boolean; constref ambColor: TDFColor); // unaccelerated
-procedure g_Map_CollectDrawPanels (x0, y0, wdt, hgt: Integer);
-
-procedure g_Map_DrawBack(dx, dy: Integer);
function g_Map_CollidePanel(X, Y: Integer; Width, Height: Word;
PanelType: Word; b1x3: Boolean=false): Boolean;
function g_Map_CollideLiquid_Texture(X, Y: Integer; Width, Height: Word): DWORD;
function g_Map_GetPoint(PointType: Byte; var RespawnPoint: TRespawnPoint): Boolean;
function g_Map_GetPointCount(PointType: Byte): Word;
+function g_Map_GetRandomPointType(): Byte;
function g_Map_HaveFlagPoints(): Boolean;
procedure g_Map_ResetFlag(Flag: Byte);
-procedure g_Map_DrawFlags();
procedure g_Map_SaveState (st: TStream);
procedure g_Map_LoadState (st: TStream);
-procedure g_Map_DrawPanelShadowVolumes(lightX: Integer; lightY: Integer; radius: Integer);
-
// returns panel or nil
// sets `ex` and `ey` to `x1` and `y1` when no hit was detected
function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil): TPanel;
implementation
uses
- {$INCLUDE ../nogl/noGLuses.inc}
- e_input, g_main, e_log, e_texture, e_res, g_items, g_gfx, g_console,
+ e_input, g_main, e_log, e_res, g_items, g_gfx, g_console,
g_weapons, g_game, g_sound, e_sound, CONFIG,
g_options, g_triggers, g_player,
Math, g_monsters, g_saveload, g_language, g_netmsg,
result := (a.arrIdx < b.arrIdx);
end;
-procedure dplClear ();
-begin
- if (gDrawPanelList = nil) then gDrawPanelList := TBinHeapPanelDraw.Create() else gDrawPanelList.clear();
-end;
-
-
var
Textures: TLevelTextureArray = nil;
TextNameHash: THashStrInt = nil; // key: texture name; value: index in `Textures`
begin
e_WriteLog(' Loading sky: ' + gMapInfo.SkyName, TMsgType.Notify);
g_Game_SetLoadingText(_lc[I_LOAD_SKY], 0, False);
- if gTextureFilter then TEXTUREFILTER := GL_LINEAR else TEXTUREFILTER := GL_NEAREST;
- try
- s := e_GetResourcePath(WadDirs, gMapInfo.SkyName, g_ExtractWadName(Res));
- if g_Texture_CreateWAD(BackID, s) then
- g_Game_SetupScreenSize
- else
- g_FatalError(Format(_lc[I_GAME_ERROR_SKY], [s]))
- finally
- TEXTUREFILTER := GL_NEAREST;
- end;
+ s := e_GetResourcePath(WadDirs, gMapInfo.SkyName, g_ExtractWadName(Res));
+ if g_Texture_CreateWAD(BackID, s, gTextureFilter) then
+ g_Game_SetupScreenSize
+ else
+ g_FatalError(Format(_lc[I_GAME_ERROR_SKY], [s]))
end;
// Çàãðóçêà ìóçûêè
begin
if gFlags[a].Animation <> nil then gFlags[a].Animation.Update();
+ Obj.oldX := Obj.X;
+ Obj.oldY := Obj.Y;
+
m := g_Obj_Move(@Obj, True, True);
+ NeedSend := NeedSend or (Obj.X <> Obj.oldX) or (Obj.Y <> Obj.oldY);
+
if gTime mod (GAME_TICK*2) <> 0 then Continue;
// Ñîïðîòèâëåíèå âîçäóõà
end;
end;
-
-// old algo
-procedure g_Map_DrawPanels (PanelType: Word; hasAmbient: Boolean; constref ambColor: TDFColor);
-
- procedure DrawPanels (constref panels: TPanelArray; drawDoors: Boolean=False);
- var
- idx: Integer;
- begin
- if (panels <> nil) then
- begin
- // alas, no visible set
- for idx := 0 to High(panels) do
- begin
- if not (drawDoors xor panels[idx].Door) then panels[idx].Draw(hasAmbient, ambColor);
- end;
- end;
- end;
-
-begin
- case PanelType of
- PANEL_WALL: DrawPanels(gWalls);
- PANEL_CLOSEDOOR: DrawPanels(gWalls, True);
- PANEL_BACK: DrawPanels(gRenderBackgrounds);
- PANEL_FORE: DrawPanels(gRenderForegrounds);
- PANEL_WATER: DrawPanels(gWater);
- PANEL_ACID1: DrawPanels(gAcid1);
- PANEL_ACID2: DrawPanels(gAcid2);
- PANEL_STEP: DrawPanels(gSteps);
- end;
-end;
-
-
-// new algo
-procedure g_Map_CollectDrawPanels (x0, y0, wdt, hgt: Integer);
-var
- mwit: PPanel;
- it: TPanelGrid.Iter;
-begin
- dplClear();
- it := mapGrid.forEachInAABB(x0, y0, wdt, hgt, GridDrawableMask);
- for mwit in it do if (((mwit^.tag and GridTagDoor) <> 0) = mwit^.Door) then gDrawPanelList.insert(mwit^);
- it.release();
- // list will be rendered in `g_game.DrawPlayer()`
-end;
-
-
-procedure g_Map_DrawPanelShadowVolumes (lightX: Integer; lightY: Integer; radius: Integer);
-var
- mwit: PPanel;
- it: TPanelGrid.Iter;
-begin
- it := mapGrid.forEachInAABB(lightX-radius, lightY-radius, radius*2, radius*2, (GridTagWall or GridTagDoor));
- for mwit in it do mwit^.DrawShadowVolume(lightX, lightY, radius);
- it.release();
-end;
-
-
-procedure g_Map_DrawBack(dx, dy: Integer);
-begin
- if gDrawBackGround and (BackID <> DWORD(-1)) then
- e_DrawSize(BackID, dx, dy, 0, False, False, gBackSize.X, gBackSize.Y)
- else
- e_Clear(GL_COLOR_BUFFER_BIT, 0, 0, 0);
-end;
-
function g_Map_CollidePanelOld(X, Y: Integer; Width, Height: Word;
PanelType: Word; b1x3: Boolean=false): Boolean;
var
Result := Result + 1;
end;
+function g_Map_GetRandomPointType(): Byte;
+begin
+ if RespawnPoints = nil then
+ Result := 255
+ else
+ Result := RespawnPoints[Random(Length(RespawnPoints))].PointType;
+end;
+
function g_Map_HaveFlagPoints(): Boolean;
begin
Result := (FlagPoints[FLAG_RED] <> nil) and (FlagPoints[FLAG_BLUE] <> nil);
Direction := FlagPoints[Flag]^.Direction;
State := FLAG_STATE_NORMAL;
end;
+ Obj.oldX := Obj.X;
+ Obj.oldY := Obj.Y;
+ NeedSend := False; // the event will take care of this
Count := -1;
end;
end;
-procedure g_Map_DrawFlags();
-var
- i, dx: Integer;
- Mirror: TMirrorType;
-begin
- if gGameSettings.GameMode <> GM_CTF then
- Exit;
-
- for i := FLAG_RED to FLAG_BLUE do
- with gFlags[i] do
- if State <> FLAG_STATE_CAPTURED then
- begin
- if State = FLAG_STATE_NONE then
- continue;
-
- if Direction = TDirection.D_LEFT then
- begin
- Mirror := TMirrorType.Horizontal;
- dx := -1;
- end
- else
- begin
- Mirror := TMirrorType.None;
- dx := 1;
- end;
-
- Animation.Draw(Obj.X+dx, Obj.Y+1, Mirror);
-
- if g_debug_Frames then
- begin
- e_DrawQuad(Obj.X+Obj.Rect.X,
- Obj.Y+Obj.Rect.Y,
- Obj.X+Obj.Rect.X+Obj.Rect.Width-1,
- Obj.Y+Obj.Rect.Y+Obj.Rect.Height-1,
- 0, 255, 0);
- end;
- end;
-end;
-
-
procedure g_Map_SaveState (st: TStream);
var
str: String;
if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
begin
// Î÷êè Êðàñíîé êîìàíäû
- utils.writeInt(st, SmallInt(gTeamStat[TEAM_RED].Goals));
+ utils.writeInt(st, SmallInt(gTeamStat[TEAM_RED].Score));
// Î÷êè Ñèíåé êîìàíäû
- utils.writeInt(st, SmallInt(gTeamStat[TEAM_BLUE].Goals));
+ utils.writeInt(st, SmallInt(gTeamStat[TEAM_BLUE].Score));
end;
///// /////
end;
if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
begin
// Î÷êè Êðàñíîé êîìàíäû
- gTeamStat[TEAM_RED].Goals := utils.readSmallInt(st);
+ gTeamStat[TEAM_RED].Score := utils.readSmallInt(st);
// Î÷êè Ñèíåé êîìàíäû
- gTeamStat[TEAM_BLUE].Goals := utils.readSmallInt(st);
+ gTeamStat[TEAM_BLUE].Score := utils.readSmallInt(st);
end;
///// /////
end;