10 Commits

Author SHA1 Message Date
Aaron Suen
620e7c09a4 Change dynamic light API, smoother under lag?
Instead of registering the TTL for a light and expecting
more time to be pushed in, use a fixed TTL of 0.25s and
register a callback to check if the light is still valid, i.e.
lights now pull time as necessary.

This should prevent light flickering that can happen
under heavy server lag, i.e. when the time step is
wider than the dynamic light TTL.

Lights that don't register a callback will be ephemeral,
and will disappear after 0.25 seconds, which can be
used to increase the chance that the server has had an
opportunity to move the light, as per torch destructor.
2020-05-26 07:50:57 -04:00
Aaron Suen
9c9eb4b85a Guard against dummy objects in 5.3+
Some time in the 5.3 dev stream (docs updated at
217f3a42), object refs started being invalidated
immediately on calling obj:remove(), such that
obj:get_pos() starts to return nil instead of the object's
last known position.

This can cause some crashes in NodeCore, where we
assume that our object is still valid (or usable as if it
were still valid) even though we're looping through
handlers and any one of them may have remove()d the
object before other handlers get a chance to fire.

Instead, just watch for unexpected nil returns from
functions we expect would never return nil (e.g.
get_pos or get_properties) and return if we hit one.
We can assume all other calls will be non-nil after that
one, as long as we stay in the same function flow.
2020-05-18 18:36:06 -04:00
Aaron Suen
7dbc22abe7 Centralize some sanity checks 2020-05-12 07:25:58 -04:00
Aaron Suen
3fc187f0e6 Centralize entity glow too
Thrown/falling entities containing a light_source will now cast
a dynamic light glow automatically as well.
2020-05-12 07:22:41 -04:00
Aaron Suen
3484b55cb0 Centralize wield glow logic
- Wield item glow is now handled automatically
- Player glows with same glow level as scaling nodes
2020-05-12 07:13:36 -04:00
Aaron Suen
124aa5e4f4 Dynamic light restructuring
All possible light level nodes are pre-registered at startup time
so that light levels can be determined fully dynamically at run
time, without needing to explicitly declare what light levels will
actually be needed.

Hopefully this will make using dynamic lights a little easier
and lead to some interesting content.
2020-05-12 06:55:11 -04:00
Aaron Suen
48473ea34c A little tighter "airlike" detection. 2020-03-29 20:05:11 -04:00
Aaron Suen
48e7bab366 More torch smoothing.
- Smoother entity light casting.
- Fix flicker on torch pickup.
2020-03-15 08:34:45 -04:00
Aaron Suen
82bc47642e Smoother torch light operation.
Also reduce client packets by tracking dynalight node
ttl in-memory instead of meta.  Lights might flicker out
a bit on area first loading, but some startup judder is
expected on any unloaded area anyway.

Add a "cheat" code for torch testing, and possibly for
other dev uses.
2020-03-15 08:20:56 -04:00
Aaron Suen
3200149cc4 Buff torch and scaling light sources.
- Better compat with low gamma play.
- Torch now emits some light when in inventory, even
  if not actively wielded.
- Dynamic light API for mod use.
2020-02-22 21:57:08 -05:00