📄 g_main.pas
字号:
The timelimit or fraglimit has been exceeded
=================
*)
procedure EndDMLevel;
var
ent: edict_p;
s, t, f: PChar;
const
seps = ' ,'#10#13; // static const char *
begin
// stay on same level flag
if ({Round}Trunc(dmflags^.value) and DF_SAME_LEVEL) <> 0 then
begin
BeginIntermission(CreateTargetChangeLevel(level.mapname));
Exit;
end;
{$IFDEF CTF}
if (PChar(@level.forcemap)^ <> #0) then
begin
BeginIntermission(CreateTargetChangeLevel(level.forcemap));
Exit;
end;
{$ENDIF}
// see if it's in the map list
if (sv_maplist^.string_^ <> #0) then
begin
s := StrNew(sv_maplist^.string_);
f := nil;
t := strtok(s, seps);
while (t <> nil) do
begin
if (Q_stricmp(t, level.mapname) = 0) then
begin
// it's in the list, go to the next one
t := strtok(nil, seps);
if (t = nil) then // end of list, go to first one
begin
if (f = nil) then // there isn't a first one, same level
BeginIntermission(CreateTargetChangeLevel(level.mapname))
else
BeginIntermission(CreateTargetChangeLevel(f));
end else
BeginIntermission(CreateTargetChangeLevel(t));
StrDispose(s);
Exit;
end;
if (f = nil) then
f := t;
t := strtok(nil, seps);
end;
StrDispose(s);
end;
if (level.nextmap[0] <> #0) then // go to a specific map
BeginIntermission(CreateTargetChangeLevel(level.nextmap))
else
begin // search for a changelevel
// #define FOFS(x) (int)&(((edict_t *)0)->x)
// ent := G_Find(nil, FOFS(classname), 'target_changelevel');
ent := G_Find(nil, Integer(@edict_p(nil).classname), 'target_changelevel');
if (ent = nil) then
begin // the map designer didn't include a changelevel,
// so create a fake ent that goes back to the same level
BeginIntermission(CreateTargetChangeLevel(level.mapname));
Exit;
end;
BeginIntermission(ent);
end;
end;
{$IFNDEF CTF}
(*
=================
CheckNeedPass
=================
*)
procedure CheckNeedPass;
var
need: Integer;
begin
// if password or spectator_password has changed, update needpass
// as needed
if (password^.modified or spectator_password^.modified) then
begin
spectator_password^.modified := False;
password^.modified := spectator_password^.modified;
need := 0;
{ 2003-05-14 (SP): In case a more literal translation is required:
if (password^.string_^ <> #0) and }
if (password^.string_ <> nil) and (Q_stricmp(password^.string_, 'none') <> 0) then
need := need or 1;
{ 2003-05-14 (SP): In case a more literal translation is required:
if (spectator_password^.string_^ <> #0) and }
if (spectator_password^.string_ <> nil) and (Q_stricmp(spectator_password^.string_, 'none') <> 0) then
need := need or 2;
gi.cvar_set('needpass', va('%d', [need]));
end;
end;
{$ENDIF}
(*
=================
CheckDMRules
=================
*)
procedure CheckDMRules;
var
i: Integer;
cl: gclient_p;
begin
if (level.intermissiontime <> 0) then
Exit;
if (deathmatch^.value = 0) then
Exit;
{$IFDEF CTF}
//ZOID
if (ctf.value <> 0) and (CTFCheckRules) then
begin
EndDMLevel;
Exit;
end;
if CTFInMatch then
Exit; // no checking in match mode
//ZOID
{$ENDIF}
if (timelimit^.value <> 0) then
begin
if (level.time >= timelimit^.value * 60) then
begin
gi.bprintf(PRINT_HIGH, 'Timelimit hit.'#10, []);
EndDMLevel;
Exit;
end;
end;
if (fraglimit^.value <> 0) then
begin
for i := 0 to {Round}Trunc(maxclients^.value) - 1 do
begin
{ cl := game.clients + i; }
cl := game.clients; Inc(cl, i);
if g_edicts^[i+1].inuse then
Continue;
if (cl^.resp.score >= fraglimit^.value) then
begin
gi.bprintf(PRINT_HIGH, 'Fraglimit hit.'#10, []);
EndDMLevel;
Exit;
end;
end;
end;
end;
(*
=============
ExitLevel
=============
*)
procedure ExitLevel;
var
i: Integer;
ent: edict_p;
command: array [0..255] of Char;
begin
{$IFDEF CTF}
level.exitintermission := 0;
level.intermissiontime := 0;
if CTFNextMap then Exit;
{$ENDIF}
Com_sprintf(command, SizeOf(command), 'gamemap "%s"'#10, [level.changemap]);
gi.AddCommandString(command);
{$IFNDEF CTF}
level.changemap := nil;
level.exitintermission := 0;
level.intermissiontime := 0;
{$ENDIF}
ClientEndServerFrames;
{$IFDEF CTF}
level.changemap := nil;
{$ENDIF}
// clear some things before going to next level
for i := 0 to {Round}Trunc(maxclients^.value) - 1 do
begin
ent := @g_edicts^[1 + i];
if (not ent^.inuse) then
Continue;
if (ent^.health > ent^.client^.pers.max_health) then
ent^.health := ent^.client^.pers.max_health;
end;
end;
(*
================
G_RunFrame
Advances the world by 0.1 seconds
================
*)
procedure G_RunFrame; cdecl;
var
i: Integer;
ent: edict_p;
label
continue_;
begin
Inc(level.framenum);
level.time := level.framenum*FRAMETIME;
// choose a client for monsters to target this frame
AI_SetSightClient;
// exit intermissions
if (level.exitintermission <> 0) then
begin
ExitLevel;
Exit;
end;
//
// treat each object in turn
// even the world gets a chance to think
//
ent := @g_edicts^[0];
for i := 0 to globals.num_edicts -1 do //; i++, ent++)
begin
if (not ent^.inuse) then
goto Continue_;
level.current_entity := ent;
VectorCopy(ent^.s.origin, ent^.s.old_origin);
// if the ground entity moved, make sure we are still on it
if (ent^.groundentity <> nil) and
(ent^.groundentity^.linkcount <> ent^.groundentity_linkcount) then
begin
ent^.groundentity := nil;
if ((ent^.flags and (FL_SWIM or FL_FLY)) = 0) and
((ent^.svflags and SVF_MONSTER) <> 0) then
begin
M_CheckGround(ent);
end;
end;
if (i > 0) and (i <= maxclients^.value) then
begin
ClientBeginServerFrame(ent);
goto Continue_;
end;
G_RunEntity(ent);
{ Label to perform secondary increment }
Continue_:
Inc(ent);
end;
// see if it is time to end a deathmatch
CheckDMRules;
{$IFNDEF CTF}
// see if needpass needs updated
CheckNeedPass;
{$ENDIF}
// build the playerstate_t structures for all players
ClientEndServerFrames;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -