Skip to content

Commit

Permalink
game: fix set entities properties value
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Oct 7, 2024
1 parent 5913c81 commit 34c78d4
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/game/g_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ cvar_t *log_file_header;
cvar_t *log_file_footer;
cvar_t *log_file_line_header;

void SpawnEntities(const char *mapname, char *entities, const char *spawnpoint, qboolean loadgame);
void SpawnEntities(const char *mapname, char *entities, const char *spawnpoint);
void ClientThink(edict_t *ent, usercmd_t *cmd);
qboolean ClientConnect(edict_t *ent, char *userinfo);
void ClientUserinfoChanged(edict_t *ent, char *userinfo);
Expand Down
143 changes: 120 additions & 23 deletions src/game/g_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ ED_ParseField(const char *key, const char *value, edict_t *ent)

for (f = fields; f->name; f++)
{
if (!Q_stricmp(f->name, key))
if (!(f->flags & FFL_NOSPAWN) && !Q_strcasecmp(f->name, (char *)key))
{
/* found it */
if (f->flags & FFL_SPAWNTEMP)
Expand Down Expand Up @@ -371,8 +371,10 @@ ED_ParseField(const char *key, const char *value, edict_t *ent)
((byte *)(b+f->ofs))[2] = color[2];
break;
default:
return;
break;
}

return;
}
}

Expand All @@ -398,6 +400,7 @@ ED_ParseEdict(char *data, edict_t *ent)

init = false;
memset(&st, 0, sizeof(st));
st.skyautorotate = 1;

/* go through all the dictionary pairs */
while (1)
Expand Down Expand Up @@ -452,15 +455,82 @@ ED_ParseEdict(char *data, edict_t *ent)
}

/*
================
G_FindTeams
* Chain together all entities with a matching team field.
*
* All but the first will have the FL_TEAMSLAVE flag set.
* All but the last will have the teamchain field set to the next one
*/
static void
G_FixTeams(void)
{
edict_t *e, *e2, *chain;
int i, j;
int c, c2;

Chain together all entities with a matching team field.
c = 0;
c2 = 0;

for (i = 1, e = g_edicts + i; i < globals.num_edicts; i++, e++)
{
if (!e->inuse)
{
continue;
}

if (!e->team)
{
continue;
}

if (!strcmp(e->classname, "func_train"))
{
if (e->flags & FL_TEAMSLAVE)
{
chain = e;
e->teammaster = e;
e->teamchain = NULL;
e->flags &= ~FL_TEAMSLAVE;
c++;
c2++;

for (j = 1, e2 = g_edicts + j;
j < globals.num_edicts;
j++, e2++)
{
if (e2 == e)
{
continue;
}

if (!e2->inuse)
{
continue;
}

if (!e2->team)
{
continue;
}

if (!strcmp(e->team, e2->team))
{
c2++;
chain->teamchain = e2;
e2->teammaster = e;
e2->teamchain = NULL;
chain = e2;
e2->flags |= FL_TEAMSLAVE;
e2->movetype = MOVETYPE_PUSH;
e2->speed = e->speed;
}
}
}
}
}

gi.dprintf("%i teams repaired\n", c);
}

All but the first will have the FL_TEAMSLAVE flag set.
All but the last will have the teamchain field set to the next one
================
*/
static void
G_FindTeams(void)
{
Expand Down Expand Up @@ -521,30 +591,24 @@ G_FindTeams(void)
}
}

G_FixTeams();

gi.dprintf("%i teams with %i entities.\n", c, c2);
}

/*
==============
SpawnEntities
Creates a server's entity / program execution context by
parsing textual entity definitions out of an ent file.
==============
*/
int loadingBaseEnts;

* Creates a server's entity / program execution context by
* parsing textual entity definitions out of an ent file.
*/
void
SpawnEntities(const char *mapname, char *entities, const char *spawnpoint, qboolean loadgame)
SpawnEntities(const char *mapname, char *entities, const char *spawnpoint)
{
edict_t *ent;
int inhibit;
const char *com_token;
int i;
float skill_level;

loadingBaseEnts = loadgame;

if (!mapname || !entities || !spawnpoint)
{
return;
Expand Down Expand Up @@ -619,6 +683,36 @@ SpawnEntities(const char *mapname, char *entities, const char *spawnpoint, qbool

entities = ED_ParseEdict(entities, ent);

/* yet another map hack */
if (!Q_stricmp(level.mapname, "command") &&
!Q_stricmp(ent->classname, "trigger_once") &&
!Q_stricmp(ent->model, "*27"))
{
ent->spawnflags &= ~SPAWNFLAG_NOT_HARD;
}

/* ahh, the joys of map hacks .. */
if (!Q_stricmp(level.mapname, "rhangar2") &&
!Q_stricmp(ent->classname, "func_door_rotating") &&
ent->targetname && !Q_stricmp(ent->targetname, "t265"))
{
ent->spawnflags &= ~SPAWNFLAG_NOT_COOP;
}

if (!Q_stricmp(level.mapname, "rhangar2") &&
!Q_stricmp(ent->classname, "trigger_always") &&
ent->target && !Q_stricmp(ent->target, "t265"))
{
ent->spawnflags |= SPAWNFLAG_NOT_COOP;
}

if (!Q_stricmp(level.mapname, "rhangar2") &&
!Q_stricmp(ent->classname, "func_wall") &&
!Q_stricmp(ent->model, "*15"))
{
ent->spawnflags |= SPAWNFLAG_NOT_COOP;
}

/* remove things (except the world) from
different skill levels or deathmatch */
if (ent != g_edicts)
Expand Down Expand Up @@ -651,12 +745,15 @@ SpawnEntities(const char *mapname, char *entities, const char *spawnpoint, qbool
{
gi.dprintf("monster '%s' not spawned.\n", ent->classname);

G_FreeEdict (ent);
G_FreeEdict(ent);
inhibit++;
continue;
}

ent->spawnflags &= ~(SPAWNFLAG_NOT_EASY|SPAWNFLAG_NOT_MEDIUM|SPAWNFLAG_NOT_HARD|SPAWNFLAG_NOT_COOP|SPAWNFLAG_NOT_DEATHMATCH);
ent->spawnflags &=
~(SPAWNFLAG_NOT_EASY | SPAWNFLAG_NOT_MEDIUM |
SPAWNFLAG_NOT_HARD |
SPAWNFLAG_NOT_COOP | SPAWNFLAG_NOT_DEATHMATCH);
}

ED_CallSpawn(ent);
Expand Down
2 changes: 1 addition & 1 deletion src/game/header/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ typedef struct
void (*Shutdown)(void);

/* each new level entered will cause a call to SpawnEntities */
void (*SpawnEntities)(const char *mapname, char *entstring, const char *spawnpoint, qboolean loadgame);
void (*SpawnEntities)(const char *mapname, char *entstring, const char *spawnpoint);

/* Read/Write Game is for storing persistant cross level information
about the world state and the clients.
Expand Down
5 changes: 1 addition & 4 deletions src/game/monster/elflord/elflord.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include "../stats/stats.h"
#include "../../header/g_hitlocation.h"

/*QUAKED monster_elflord (1 .5 0) (-16 -16 -0) (16 16 32)
*/

//Mirrored on client side
enum cwatcher_elflord_effect_id_s
{
Expand Down Expand Up @@ -790,7 +787,7 @@ void ElflordStaticsInit()
classStatics[CID_ELFLORD].resInfo = &resInfo;
}

/*QUAKED SP_monster_elflord (0.5 0.5 1) (-24 -24 -64) (24 24 16)
/*QUAKED monster_elflord (0.5 0.5 1) (-24 -24 -64) (24 24 16)
Celestial Watcher
Expand Down
2 changes: 1 addition & 1 deletion src/server/sv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ SV_SpawnServer(char *server, char *spawnpoint, server_state_t serverstate,
}
entity[entitysize] = 0; /* jit entity bug - null terminate the entity string! */
/* load and spawn all other entities */
ge->SpawnEntities(sv.name, entity, spawnpoint, loadgame);
ge->SpawnEntities(sv.name, entity, spawnpoint);
free(entity);

/* all precaches are complete */
Expand Down

0 comments on commit 34c78d4

Please sign in to comment.