game: port TRAIN_FIX_OFFSET and TRAIN_USE_ORIGIN from ReRelease

Fix platforms in `train` level.
This commit is contained in:
Denis Pauk 2024-05-02 23:41:47 +03:00
parent ded6f0c962
commit f1d9bd6f47
2 changed files with 76 additions and 8 deletions

View file

@ -57,6 +57,8 @@
#define TRAIN_START_ON 1
#define TRAIN_TOGGLE 2
#define TRAIN_BLOCK_STOPS 4
#define TRAIN_FIX_OFFSET 16
#define TRAIN_USE_ORIGIN 32
#define SECRET_ALWAYS_SHOOT 1
#define SECRET_1ST_LEFT 2
@ -3247,7 +3249,23 @@ again:
}
first = false;
if (self->spawnflags & TRAIN_USE_ORIGIN)
{
VectorCopy(ent->s.origin, self->s.origin);
}
else
{
VectorSubtract(ent->s.origin, self->mins, self->s.origin);
if (self->spawnflags & TRAIN_FIX_OFFSET)
{
vec3_t diff = {1.f, 1.f, 1.f};
VectorSubtract(self->s.origin, diff, self->s.origin);
}
}
VectorCopy(self->s.origin, self->s.old_origin);
self->s.event = EV_OTHER_TELEPORT;
gi.linkentity(self);
@ -3295,7 +3313,22 @@ again:
self->s.sound = self->moveinfo.sound_middle;
}
if (self->spawnflags & TRAIN_USE_ORIGIN)
{
VectorCopy(ent->s.origin, dest);
}
else
{
VectorSubtract(ent->s.origin, self->mins, dest);
if (self->spawnflags & TRAIN_FIX_OFFSET)
{
vec3_t diff = {1.f, 1.f, 1.f};
VectorSubtract(dest, diff, dest);
}
}
self->moveinfo.state = STATE_TOP;
VectorCopy(self->s.origin, self->moveinfo.start_origin);
VectorCopy(dest, self->moveinfo.end_origin);
@ -3339,7 +3372,22 @@ train_resume(edict_t *self)
ent = self->target_ent;
if (self->spawnflags & TRAIN_USE_ORIGIN)
{
VectorCopy(ent->s.origin, dest);
}
else
{
VectorSubtract(ent->s.origin, self->mins, dest);
if (self->spawnflags & TRAIN_FIX_OFFSET)
{
vec3_t diff = {1.f, 1.f, 1.f};
VectorSubtract(dest, diff, dest);
}
}
self->moveinfo.state = STATE_TOP;
VectorCopy(self->s.origin, self->moveinfo.start_origin);
VectorCopy(dest, self->moveinfo.end_origin);
@ -3373,7 +3421,22 @@ func_train_find(edict_t *self)
self->target = ent->target;
if (self->spawnflags & TRAIN_USE_ORIGIN)
{
VectorCopy(ent->s.origin, self->s.origin);
}
else
{
VectorSubtract(ent->s.origin, self->mins, self->s.origin);
if (self->spawnflags & TRAIN_FIX_OFFSET)
{
vec3_t diff = {1.f, 1.f, 1.f};
VectorSubtract(self->s.origin, diff, self->s.origin);
}
}
gi.linkentity(self);
/* if not triggered, start immediately */

View file

@ -1778,12 +1778,17 @@ SelectSpawnPoint(edict_t *ent, vec3_t origin, vec3_t angles)
if (!spot)
{
/* still no spawnpoint? use any */
gi.dprintf("Couldn't find spawn point '%s'\n", game.spawnpoint);
if (!game.spawnpoint[0])
{
/* there wasn't a spawnpoint without a target, so use any */
spot = G_Find(spot, FOFS(classname), "info_player_start");
}
if (!spot)
{
gi.error("Couldn't find spawn point '%s'\n", game.spawnpoint);
}
}
}
/* If we are in coop and we didn't find a coop