Flayra/NS2-Scripts — pull request #10 by matso (2011-10-11 17:50:55+00:00)
Title: Fix problems with dynamic loading of powerpoints

The problem:

The lights controlled by a PowerPoint is visible at a far longer range than the powerpoint itself.

This means that a PowerPoint affects the client at a longer range than the standard max Snapshot inclusion range.

In summit, there are two places where this is clearly visible:
- the top of the corridor leading between Data and Reactor Core
- the top of the corridor leading from Flight Control to Heliport

To replicate, go cheats 1, damage 100, j2, skulk and kill the Rector Core node, run up into Data core, come back and see that the lights inside the Reactor Core entrance are not updating. You need to get quite close before they commence the emergency lightning cycle.

This can look quite ugly. For example, the first time you as a marine walks down from Data Core towards Reactor Core, you think the PowerPoint is just fine, because the lights in Reactor core shows full power. When you get into range so the PowerPoint is loaded, it suddenly switches to emergency lightning.

The fix:

Always load PowerPoints.

Unfortunately, on summit it costs upto 4-5 ms per game tick (ie 10-15% cpu) to run all the lights (worst case, 30 ticks, all lights running emergency lightning). Normally, you have like 1-2 powerpoints loaded and the cost is about 1ms per tick (3% cpu).

Adding an updateRange to the powerpoints and setting it to 60m allows summit to run at about 2ms/tick or 6% cpu, which seems a good compromise.

Allowing the mapper to set the range at which each powerpoint should be running its update should perhaps be added to the map editor, and a note about how to setup the lights to avoid them being visible for players at long range from the powerpoint might be a good idea.