Non-spinning fortress zone does not trigger OnVanish()

What do you want to see in Armagetron soon? Any new feature ideas? Let's ponder these ground breaking ideas...
Post Reply
User avatar
vov
Match Winner
Posts: 568
Joined: Thu Feb 17, 2011 8:40 pm

Non-spinning fortress zone does not trigger OnVanish()

Post by vov »

I've had this fixed a while ago with Pathetique (he didn't submit/commit it :< ). Sorry for bothering but I don't really know how to update this myself without messing something up or if I'd even be allowed to in the main branch.

Affects: All versions. Not tested with sty+ct-console-spawned zones but the code itself is the same.
Description: It's related to fortress_collapse_speed; if you set it to a number smaller than 0.4 then that zone does not trigger OnVanish() (for killing players etc.). The border case of 0.4 works. Bigger values work as expected.
To reproduce: Set fortress_collapse_speed to a number smaller than 0.4; and fortress_conquered_kill_ratio to 1.
Expected: Enemies get killed on conquering the zone.
What happens: They don't.
Why it happens: Apparently a fort zone that does not rotate anymore does not trigger OnVanish(). I remember that we had that determined as a cause.
Why it'd be nice to have it fixed: I've had the idea of a fortress variant where the team that just lost its zone has some time to retaliate. Because of this bug it doesn't work.

To fix: edit gWinZone.cpp -> gBaseZoneHack::Timestep -> following part: Current:

Code: Select all

        SetExpansionSpeed( -GetRadius()*sg_collapseSpeed );
        SetRotationAcceleration( -GetRotationSpeed()*.4 );
        RequestSync();

        currentState_ = State_Conquered;
    }
    else if ( currentState_ == State_Conquered && GetRotationSpeed() < 0 )
The constant .4 here is what causes zones to stand still 2.5 seconds after being conquered (1/0.4=2.5).
Changing it like this will change the rotation "stop" from a constant "2.5 seconds after conquest" to "when it collapses anyways" but fix this bug. I don't know of any server or other feature that depends on the constant delay. Fixed this way:

Code: Select all

        SetExpansionSpeed( -GetRadius()*sg_collapseSpeed );
        SetRotationAcceleration( -GetRotationSpeed()*sg_collapseSpeed );
        RequestSync();

        currentState_ = State_Conquered;
    }
    else if ( currentState_ == State_Conquered && GetRotationSpeed() < 0 )
Alternatively this might have worked, can't remember or find the fixed file though; it wouldn't break the 2.5 seconds constant if it is desired. We had it fixed like this or similar to this but i lost the fixed file :(:

Code: Select all

        SetExpansionSpeed( -GetRadius()*sg_collapseSpeed );
        SetRotationAcceleration( -GetRotationSpeed()*.4 );
        RequestSync();

        currentState_ = State_Conquered;
    }
    else if ( currentState_ == State_Conquered && GetRotationSpeed() <= 0 )
I'd appreciate if someone could upload/commit this. Thanks!
User avatar
Z-Man
God & Project Admin
Posts: 11585
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: Non-spinning fortress zone does not trigger OnVanish()

Post by Z-Man »

Hmm. I could not reproduce the error on the current 0.2.8 branch, and I see nothing that would prevent OnVanish from getting called based on the rotation speed. It's called from the base gZone::Timestep whenever the zone shriks below zero, a rotation speed of zero does not stop the collapse, and gZone::Timestep is always called from gBaseZoneHack::Timestep. I believe the current trunk code for clasic fortress zones is unchanged.

What does happen, of course, is that if you set the collapse speed too low, the round may end before the collapse completes. But a collapse speed of .3 worked just fine when I tested it (basic fortress settings plus that plus kill the entire team on vanish). The proposed change does not fix that, of course.

So... I guess I need precise settings that make this bug manifest itself. It's very possible that something else I haven't seen removes the zone from the game before OnVanish can get called.

<more testing and wrestling with annoying gdb/emacs changes later>
Ah. The default trunk code for fortress zones, the one using zonesv2, is borked. There, the base class does not call OnVanish itself. Should be fixed now.
User avatar
vov
Match Winner
Posts: 568
Joined: Thu Feb 17, 2011 8:40 pm

Re: Non-spinning fortress zone does not trigger OnVanish()

Post by vov »

Ah thanks. Sorry, couldn't exactly remember what we did to fix it (the bug was there, I wanted to do stuff with the command that didn't work). I'm fairly sure we messed around with it on v0.4; and I did find this week (local game, v0.4, testing around with settings) that it was still broken; I had a quick glance and the other versions' code looked about the same. Maybe I looked at the wrong parts and maybe the rotation thing was a coincidence; but I distinctly remember that changing the rotation or a check somewhere had fixed it back then.

settings that produce(d) it:

Code: Select all

# Fortress settings base
include examples/cvs_test/fortress_complete.cfg

# Win only by being the last team alive, not by conquering the fort itself...
fortress_survive_win 0
fortress_conquered_win 0

# ...but be the last team alive because the others' zone has collapsed and they got killed for it...
fortress_conquered_kill_ratio 1

# ...and this happens 10 seconds after conquest. Any value below 0.4 -> more than 2.5 seconds delay; does not kill the team on collapse. Values >=0.4 work. The killing off is done in onVanish and it didn't get called.
fortress_collapse_speed 0.1
Edit: yes i did look at the wrong code above, my bad. Was in tron/zones/zFortress.cpp which applies only to v0.4.
Edit2: Ah nice you got that one. Awesome!
Post Reply