Skip to content

Commit

Permalink
Merged pull request "Sync with Q2PRO: Game changes": NVIDIA#328
Browse files Browse the repository at this point in the history
  • Loading branch information
apanteleev committed Oct 6, 2023
2 parents 1ac439c + aefb270 commit 0e4f243
Show file tree
Hide file tree
Showing 29 changed files with 408 additions and 449 deletions.
2 changes: 1 addition & 1 deletion extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (NOT CONFIG_LINUX_STEAM_RUNTIME_SUPPORT)
target_include_directories(zlibstatic PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/zlib> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/zlib>)

set_target_properties(zlib PROPERTIES FOLDER extern)
set_target_properties(zlibstatic PROPERTIES FOLDER extern)
set_target_properties(zlibstatic PROPERTIES FOLDER extern POSITION_INDEPENDENT_CODE ON)
set_target_properties(minigzip PROPERTIES FOLDER extern)
set_target_properties(example PROPERTIES FOLDER extern)
endif()
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,13 @@ if (CONFIG_LINUX_STEAM_RUNTIME_SUPPORT)
TARGET_LINK_LIBRARIES(client SDL2main SDL2-static z)
ENDIF()
TARGET_LINK_LIBRARIES(server z)
TARGET_LINK_LIBRARIES(baseq2 z)
else()
IF(TARGET client)
TARGET_LINK_LIBRARIES(client SDL2main SDL2-static zlibstatic)
ENDIF()
TARGET_LINK_LIBRARIES(server zlibstatic)
TARGET_LINK_LIBRARIES(baseq2 zlibstatic)
endif()

IF(UNIX)
Expand Down
18 changes: 0 additions & 18 deletions src/baseq2/g_ai.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,6 @@ void ai_run(edict_t *self, float dist)
}

if (enemy_vis) {
// if (self.aiflags & AI_LOST_SIGHT)
// dprint("regained sight\n");
M_MoveToGoal(self, dist);
self->monsterinfo.aiflags &= ~AI_LOST_SIGHT;
VectorCopy(self->enemy->s.origin, self->monsterinfo.last_sighting);
Expand All @@ -879,7 +877,6 @@ void ai_run(edict_t *self, float dist)
if ((self->monsterinfo.search_framenum) && (level.framenum > (self->monsterinfo.search_framenum + 20 * BASE_FRAMERATE))) {
M_MoveToGoal(self, dist);
self->monsterinfo.search_framenum = 0;
// dprint("search timeout\n");
return;
}

Expand All @@ -891,21 +888,18 @@ void ai_run(edict_t *self, float dist)

if (!(self->monsterinfo.aiflags & AI_LOST_SIGHT)) {
// just lost sight of the player, decide where to go first
// dprint("lost sight of player, last seen at "); dprint(vtos(self.last_sighting)); dprint("\n");
self->monsterinfo.aiflags |= (AI_LOST_SIGHT | AI_PURSUIT_LAST_SEEN);
self->monsterinfo.aiflags &= ~(AI_PURSUE_NEXT | AI_PURSUE_TEMP);
new = true;
}

if (self->monsterinfo.aiflags & AI_PURSUE_NEXT) {
self->monsterinfo.aiflags &= ~AI_PURSUE_NEXT;
// dprint("reached current goal: "); dprint(vtos(self.origin)); dprint(" "); dprint(vtos(self.last_sighting)); dprint(" "); dprint(ftos(vlen(self.origin - self.last_sighting))); dprint("\n");

// give ourself more time since we got this far
self->monsterinfo.search_framenum = level.framenum + 5 * BASE_FRAMERATE;

if (self->monsterinfo.aiflags & AI_PURSUE_TEMP) {
// dprint("was temp goal; retrying original\n");
self->monsterinfo.aiflags &= ~AI_PURSUE_TEMP;
marker = NULL;
VectorCopy(self->monsterinfo.saved_goal, self->monsterinfo.last_sighting);
Expand All @@ -921,9 +915,6 @@ void ai_run(edict_t *self, float dist)
VectorCopy(marker->s.origin, self->monsterinfo.last_sighting);
self->monsterinfo.trail_framenum = marker->timestamp;
self->s.angles[YAW] = self->ideal_yaw = marker->s.angles[YAW];
// dprint("heading is "); dprint(ftos(self.ideal_yaw)); dprint("\n");

// debug_drawline(self.origin, self.last_sighting, 52);
new = true;
}
}
Expand All @@ -938,8 +929,6 @@ void ai_run(edict_t *self, float dist)
VectorCopy(self->monsterinfo.last_sighting, self->goalentity->s.origin);

if (new) {
// gi.dprintf("checking for course correction\n");

tr = gi.trace(self->s.origin, self->mins, self->maxs, self->monsterinfo.last_sighting, self, MASK_PLAYERSOLID);
if (tr.fraction < 1) {
VectorSubtract(self->goalentity->s.origin, self->s.origin, v);
Expand All @@ -964,33 +953,26 @@ void ai_run(edict_t *self, float dist)
if (left < 1) {
VectorSet(v, d2 * left * 0.5f, -16, 0);
G_ProjectSource(self->s.origin, v, v_forward, v_right, left_target);
// gi.dprintf("incomplete path, go part way and adjust again\n");
}
VectorCopy(self->monsterinfo.last_sighting, self->monsterinfo.saved_goal);
self->monsterinfo.aiflags |= AI_PURSUE_TEMP;
VectorCopy(left_target, self->goalentity->s.origin);
VectorCopy(left_target, self->monsterinfo.last_sighting);
VectorSubtract(self->goalentity->s.origin, self->s.origin, v);
self->s.angles[YAW] = self->ideal_yaw = vectoyaw(v);
// gi.dprintf("adjusted left\n");
// debug_drawline(self.origin, self.last_sighting, 152);
} else if (right >= center && right > left) {
if (right < 1) {
VectorSet(v, d2 * right * 0.5f, 16, 0);
G_ProjectSource(self->s.origin, v, v_forward, v_right, right_target);
// gi.dprintf("incomplete path, go part way and adjust again\n");
}
VectorCopy(self->monsterinfo.last_sighting, self->monsterinfo.saved_goal);
self->monsterinfo.aiflags |= AI_PURSUE_TEMP;
VectorCopy(right_target, self->goalentity->s.origin);
VectorCopy(right_target, self->monsterinfo.last_sighting);
VectorSubtract(self->goalentity->s.origin, self->s.origin, v);
self->s.angles[YAW] = self->ideal_yaw = vectoyaw(v);
// gi.dprintf("adjusted right\n");
// debug_drawline(self.origin, self.last_sighting, 152);
}
}
// else gi.dprintf("course was fine\n");
}

M_MoveToGoal(self, dist);
Expand Down
71 changes: 37 additions & 34 deletions src/baseq2/g_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,22 +723,53 @@ void Cmd_Wave_f(edict_t *ent)
}
}

static bool FloodProtect(edict_t *ent)
{
int i, msgs = flood_msgs->value;
gclient_t *cl = ent->client;

if (msgs < 1)
return false;

if (level.time < cl->flood_locktill) {
gi.cprintf(ent, PRINT_HIGH, "You can't talk for %d more seconds\n",
(int)(cl->flood_locktill - level.time));
return true;
}

i = cl->flood_whenhead - min(msgs, FLOOD_MSGS) + 1;
if (i < 0)
i += FLOOD_MSGS;
if (cl->flood_when[i] &&
level.time - cl->flood_when[i] < flood_persecond->value) {
cl->flood_locktill = level.time + flood_waitdelay->value;
gi.cprintf(ent, PRINT_CHAT, "Flood protection: You can't talk for %d seconds.\n",
(int)flood_waitdelay->value);
return true;
}

cl->flood_whenhead = (cl->flood_whenhead + 1) % FLOOD_MSGS;
cl->flood_when[cl->flood_whenhead] = level.time;
return false;
}

/*
==================
Cmd_Say_f
==================
*/
void Cmd_Say_f(edict_t *ent, bool team, bool arg0)
{
int i, j;
int j;
edict_t *other;
char *p;
char text[2048];
gclient_t *cl;

if (gi.argc() < 2 && !arg0)
return;

if (FloodProtect(ent))
return;

if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
team = false;

Expand All @@ -752,13 +783,7 @@ void Cmd_Say_f(edict_t *ent, bool team, bool arg0)
strcat(text, " ");
strcat(text, gi.args());
} else {
p = gi.args();

if (*p == '"') {
p++;
p[strlen(p) - 1] = 0;
}
strcat(text, p);
Q_strlcat(text, COM_StripQuotes(gi.args()), sizeof(text));
}

// don't let text be too long for malicious reasons
Expand All @@ -767,29 +792,6 @@ void Cmd_Say_f(edict_t *ent, bool team, bool arg0)

strcat(text, "\n");

if (flood_msgs->value) {
cl = ent->client;

if (level.time < cl->flood_locktill) {
gi.cprintf(ent, PRINT_HIGH, "You can't talk for %d more seconds\n",
(int)(cl->flood_locktill - level.time));
return;
}
i = cl->flood_whenhead - flood_msgs->value + 1;
if (i < 0)
i = (sizeof(cl->flood_when) / sizeof(cl->flood_when[0])) + i;
if (cl->flood_when[i] &&
level.time - cl->flood_when[i] < flood_persecond->value) {
cl->flood_locktill = level.time + flood_waitdelay->value;
gi.cprintf(ent, PRINT_CHAT, "Flood protection: You can't talk for %d seconds.\n",
(int)flood_waitdelay->value);
return;
}
cl->flood_whenhead = (cl->flood_whenhead + 1) %
(sizeof(cl->flood_when) / sizeof(cl->flood_when[0]));
cl->flood_when[cl->flood_whenhead] = level.time;
}

if (dedicated->value)
gi.cprintf(NULL, PRINT_CHAT, "%s", text);

Expand Down Expand Up @@ -828,7 +830,8 @@ void Cmd_PlayerList_f(edict_t *ent)
e2->client->pers.netname,
e2->client->resp.spectator ? " (spectator)" : "");
if (strlen(text) + strlen(st) > sizeof(text) - 50) {
sprintf(text + strlen(text), "And more...\n");
if (strlen(text) < sizeof(text) - 12)
strcat(text, "And more...\n");
gi.cprintf(ent, PRINT_HIGH, "%s", text);
return;
}
Expand Down
27 changes: 12 additions & 15 deletions src/baseq2/g_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ void Weapon_Railgun(edict_t *ent);
void Weapon_BFG(edict_t *ent);
void Weapon_FlareGun(edict_t *ent);

gitem_armor_t jacketarmor_info = { 25, 50, .30, .00, ARMOR_JACKET};
gitem_armor_t combatarmor_info = { 50, 100, .60, .30, ARMOR_COMBAT};
gitem_armor_t bodyarmor_info = {100, 200, .80, .60, ARMOR_BODY};
gitem_armor_t jacketarmor_info = { 25, 50, .30f, .00f, ARMOR_JACKET};
gitem_armor_t combatarmor_info = { 50, 100, .60f, .30f, ARMOR_COMBAT};
gitem_armor_t bodyarmor_info = {100, 200, .80f, .60f, ARMOR_BODY};

static int jacket_armor_index;
static int combat_armor_index;
Expand Down Expand Up @@ -868,12 +868,9 @@ void droptofloor(edict_t *ent)
{
trace_t tr;
vec3_t dest;
float *v;

v = tv(-15, -15, -15);
VectorCopy(v, ent->mins);
v = tv(15, 15, 15);
VectorCopy(v, ent->maxs);
VectorSet(ent->mins, -15, -15, -15);
VectorSet(ent->maxs, 15, 15, 15);

if (ent->model)
gi.setmodel(ent, ent->model);
Expand All @@ -883,8 +880,8 @@ void droptofloor(edict_t *ent)
ent->movetype = MOVETYPE_TOSS;
ent->touch = Touch_Item;

v = tv(0, 0, -128);
VectorAdd(ent->s.origin, v, dest);
VectorCopy(ent->s.origin, dest);
dest[2] -= 128;

tr = gi.trace(ent->s.origin, ent->mins, ent->maxs, dest, ent, MASK_SOLID);
if (tr.startsolid) {
Expand Down Expand Up @@ -985,7 +982,7 @@ void PrecacheItem(gitem_t *it)
gi.modelindex(data);
else if (!strcmp(data + len - 3, "wav"))
gi.soundindex(data);
if (!strcmp(data + len - 3, "pcx"))
else if (!strcmp(data + len - 3, "pcx"))
gi.imageindex(data);
}
}
Expand Down Expand Up @@ -1234,7 +1231,7 @@ gitem_t itemlist[] = {
WEAP_BLASTER,
NULL,
0,
/* precache */ "weapons/blastf1a.wav misc/lasfly.wav"
/* precache */ "models/objects/laser/tris.md2 weapons/blastf1a.wav misc/lasfly.wav"
},

/*QUAKED weapon_shotgun (.3 .3 1) (-16 -16 -16) (16 16 16)
Expand Down Expand Up @@ -1326,7 +1323,7 @@ gitem_t itemlist[] = {
WEAP_CHAINGUN,
NULL,
0,
/* precache */ "weapons/chngnu1a.wav weapons/chngnl1a.wav weapons/machgf3b.wav` weapons/chngnd1a.wav"
/* precache */ "weapons/chngnu1a.wav weapons/chngnl1a.wav weapons/machgf3b.wav weapons/chngnd1a.wav"
},

/*QUAKED ammo_grenades (.3 .3 1) (-16 -16 -16) (16 16 16)
Expand All @@ -1349,7 +1346,7 @@ gitem_t itemlist[] = {
WEAP_GRENADES,
NULL,
AMMO_GRENADES,
/* precache */ "weapons/hgrent1a.wav weapons/hgrena1b.wav weapons/hgrenc1b.wav weapons/hgrenb1a.wav weapons/hgrenb2a.wav "
/* precache */ "models/objects/grenade2/tris.md2 weapons/hgrent1a.wav weapons/hgrena1b.wav weapons/hgrenc1b.wav weapons/hgrenb1a.wav weapons/hgrenb2a.wav"
},

/*QUAKED weapon_grenadelauncher (.3 .3 1) (-16 -16 -16) (16 16 16)
Expand Down Expand Up @@ -1418,7 +1415,7 @@ gitem_t itemlist[] = {
WEAP_HYPERBLASTER,
NULL,
0,
/* precache */ "weapons/hyprbu1a.wav weapons/hyprbl1a.wav weapons/hyprbf1a.wav weapons/hyprbd1a.wav misc/lasfly.wav"
/* precache */ "models/objects/laser/tris.md2 weapons/hyprbu1a.wav weapons/hyprbl1a.wav weapons/hyprbf1a.wav weapons/hyprbd1a.wav misc/lasfly.wav"
},

/*QUAKED weapon_railgun (.3 .3 1) (-16 -16 -16) (16 16 16)
Expand Down
10 changes: 5 additions & 5 deletions src/baseq2/g_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,6 @@ void G_TouchSolids(edict_t *ent);

char *G_CopyString(char *in);

float *tv(float x, float y, float z);

float vectoyaw(vec3_t vec);
void vectoangles(vec3_t vec, vec3_t angles);

Expand Down Expand Up @@ -944,9 +942,11 @@ struct gclient_s {

int pickup_msg_framenum;

float flood_locktill; // locked from talking
float flood_when[10]; // when messages were said
int flood_whenhead; // head pointer for when said
#define FLOOD_MSGS 10

float flood_locktill; // locked from talking
float flood_when[FLOOD_MSGS]; // when messages were said
int flood_whenhead; // head pointer for when said

int respawn_framenum; // can respawn when time > this

Expand Down
14 changes: 10 additions & 4 deletions src/baseq2/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ edict_t *CreateTargetChangeLevel(char *map)

ent = G_Spawn();
ent->classname = "target_changelevel";
Q_snprintf(level.nextmap, sizeof(level.nextmap), "%s", map);
if (map != level.nextmap)
Q_strlcpy(level.nextmap, map, sizeof(level.nextmap));
ent->map = level.nextmap;
return ent;
}
Expand Down Expand Up @@ -456,7 +457,6 @@ void ExitLevel(void)
level.changemap = NULL;
level.exitintermission = 0;
level.intermission_framenum = 0;
ClientEndServerFrames();

// clear some things before going to next level
for (i = 0 ; i < maxclients->value ; i++) {
Expand Down Expand Up @@ -488,7 +488,6 @@ void G_RunFrame(void)
AI_SetSightClient();

// exit intermissions

if (level.exitintermission) {
ExitLevel();
return;
Expand All @@ -505,7 +504,8 @@ void G_RunFrame(void)

level.current_entity = ent;

VectorCopy(ent->s.origin, ent->s.old_origin);
if (!(ent->s.renderfx & RF_BEAM))
VectorCopy(ent->s.origin, ent->s.old_origin);

// if the ground entity moved, make sure we are still on it
if ((ent->groundentity) && (ent->groundentity->linkcount != ent->groundentity_linkcount)) {
Expand All @@ -523,6 +523,12 @@ void G_RunFrame(void)
G_RunEntity(ent);
}

// exit intermission right now to avoid annoying fov change
if (level.exitintermission) {
ExitLevel();
return;
}

// see if it is time to end a deathmatch
CheckDMRules();

Expand Down
Loading

0 comments on commit 0e4f243

Please sign in to comment.