From 34c78d45e5a18d51debd3a93710653724544bcf6 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Tue, 8 Oct 2024 00:15:28 +0300 Subject: [PATCH] game: fix set entities properties value --- src/game/g_main.c | 2 +- src/game/g_spawn.c | 143 ++++++++++++++++++++++++----- src/game/header/game.h | 2 +- src/game/monster/elflord/elflord.c | 5 +- src/server/sv_init.c | 2 +- 5 files changed, 124 insertions(+), 30 deletions(-) diff --git a/src/game/g_main.c b/src/game/g_main.c index ad07c8703..d11846f2f 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -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); diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index cf4123de8..4cac0f1d9 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -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) @@ -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; } } @@ -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) @@ -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) { @@ -521,21 +591,17 @@ 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; @@ -543,8 +609,6 @@ SpawnEntities(const char *mapname, char *entities, const char *spawnpoint, qbool int i; float skill_level; - loadingBaseEnts = loadgame; - if (!mapname || !entities || !spawnpoint) { return; @@ -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) @@ -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); diff --git a/src/game/header/game.h b/src/game/header/game.h index 4eed177e8..be0659618 100644 --- a/src/game/header/game.h +++ b/src/game/header/game.h @@ -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. diff --git a/src/game/monster/elflord/elflord.c b/src/game/monster/elflord/elflord.c index 3782f8136..a3105feb5 100644 --- a/src/game/monster/elflord/elflord.c +++ b/src/game/monster/elflord/elflord.c @@ -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 { @@ -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 diff --git a/src/server/sv_init.c b/src/server/sv_init.c index 6e5c23530..c5e19b200 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -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 */