trigger_changelevel: fix transitioning bug I introduced when I added states.

This commit is contained in:
Marco Cawthorne 2020-09-09 02:21:16 +02:00
parent 51cf0e9f15
commit d8fa002419

View file

@ -80,10 +80,16 @@ trigger_changelevel::Change(void)
if (!m_strLandmark) { if (!m_strLandmark) {
dprint(sprintf("^2trigger_changelevel::^3Change^7: Change to `%s`\n", dprint(sprintf("^2trigger_changelevel::^3Change^7: Change to `%s`\n",
m_strMap)); m_strMap));
changelevel(m_strMap); //changelevel(m_strMap);
return; return;
} }
/* if some other entity triggered us... just find the next player. */
if (!(m_activator.flags & FL_CLIENT)) {
/* we need a player if we want to use landmarks at all */
m_activator = find(world, ::classname, "player");
}
/* a trigger_transition may share the same targetname, thus we do this */ /* a trigger_transition may share the same targetname, thus we do this */
for (entity e = world; (e = find(e, ::classname, "info_landmark"));) { for (entity e = world; (e = find(e, ::classname, "info_landmark"));) {
info_landmark lm = (info_landmark)e; info_landmark lm = (info_landmark)e;
@ -91,7 +97,7 @@ trigger_changelevel::Change(void)
if (lm.targetname == m_strLandmark) { if (lm.targetname == m_strLandmark) {
dprint(sprintf("^2trigger_changelevel::^3Change^7: Found landmark for %s\n", m_strLandmark)); dprint(sprintf("^2trigger_changelevel::^3Change^7: Found landmark for %s\n", m_strLandmark));
g_landmarkpos = m_activator.origin - lm.origin; g_landmarkpos = m_activator.origin - lm.origin;
changelevel(m_strMap, m_strLandmark); //changelevel(m_strMap, m_strLandmark);
break; break;
} }
} }
@ -100,15 +106,14 @@ trigger_changelevel::Change(void)
void void
trigger_changelevel::Trigger(entity act, int unused) trigger_changelevel::Trigger(entity act, int unused)
{ {
/* this means a delayed trigger is active */ if (GetMaster() == FALSE)
if (nextthink > 0.0f)
return; return;
/* disable meself */
SetSolid(SOLID_NOT);
/* eActivator == player who triggered the damn thing */ /* eActivator == player who triggered the damn thing */
m_activator = eActivator; m_activator = act;
if (eActivator.classname != "player")
return;
if (m_flChangeDelay) { if (m_flChangeDelay) {
dprint(sprintf("^2trigger_changelevel::^3Trigger^7: Delayed change to `%s` in %d sec/s\n", m_strMap, m_flChangeDelay)); dprint(sprintf("^2trigger_changelevel::^3Trigger^7: Delayed change to `%s` in %d sec/s\n", m_strMap, m_flChangeDelay));
@ -123,6 +128,9 @@ trigger_changelevel::Trigger(entity act, int unused)
void void
trigger_changelevel::TouchTrigger(void) trigger_changelevel::TouchTrigger(void)
{ {
if (!(other.flags & FL_CLIENT))
return;
Trigger(other, TRIG_TOGGLE); Trigger(other, TRIG_TOGGLE);
} }