26 Commits

Author SHA1 Message Date
Aaron Suen
2d78f30c11 Add just one more paranoia check 2020-09-11 22:58:34 -04:00
Aaron Suen
4f3f6066c2 Prevent hot potato item moving exploit
Certain items, e.g. heated lode, were meant not to
be carryable so that players would need to plan
certain constructions properly.  The "hot potato"
feature was added to achieve this, and I had
assumed that players would eventually find it
sufficiently frustrating that they would stop and try
to figure out how to do things properly.  This has
not worked out, and players working at a forge
spend a lot of their time fiddling with hot things
trying to randomly throw it into the right spot.

This change should make it more difficult for
players to manipulate the "hot potato" item
physics to move items that shouldn't be movable
by hand once heated.  Problems involving heated
item placement need to be solved through proper
furnace design, not workarounds.  As a bonus, it's
now also harder to accidentally hot-potato your
items into places it's hard to get them out of.

At some point in the future, we will probably be
adding tongs to provide a proper way to move
these items, once players have reached the
proper tech level.
2020-09-11 22:57:33 -04:00
Aaron Suen
61880b262a Allow visinvs to quiesce to zero
- Track visinv ents in a separate list instead
  of minetest.luaentities, so we can skip the
  removed and non-visinv ents all in one pass
- If no visinv updates were scheduled for any
  given tick then don't run any pass at all
2020-06-21 10:11:13 -04:00
Aaron Suen
7e5f70da9b Move visinv efficiency reforms
- Push early activation externally.
- Fix bug with ents fooling visinv checker into
  thinking pos is handled even when marked
  for removal
- Eliminate a redundant stack_get call
2020-06-21 09:38:54 -04:00
Aaron Suen
500ef347e1 Fully passivize visinvs
Now use an LBM to load ents, and skip the
ABM entirely.  I think we've finally found all
the "leakage" points.
2020-06-21 03:52:09 -04:00
Aaron Suen
53508ee327 Eliminate visinv on_step
We actually have good enough coverage to
push in events when the ents need to update
appearance, so the only thing the patrol
on step was doing was clearing old ents that
the ABM wouldn't catch, which would just be
cleared eventually anyway due to unloading
or something.

This cuts out a major performance cost item
entirely.
2020-06-17 21:53:07 -04:00
Aaron Suen
984e87e155 Consistent ABM labeling
- Make sure every ABM has a label
- Use consistent case
- More concise names / consistent voice
2020-06-17 07:09:20 -04:00
Aaron Suen
1ac9ed3f07 Even more wield/visinv microoptimizations
- Bake in on_step so we aren't doing metatable fallback each tick.
- Localize and tail-call some functions.
- Reduce redundant data lookups.
2020-06-16 06:43:08 -04:00
Aaron Suen
f9acdc48cf Optimize visinv globalstep
Apparently avoiding rounding and hashing a
thousand vectors each globalstep makes a big
difference...
2020-06-15 22:15:38 -04:00
Aaron Suen
e4337b698c Optimize visinv ent item checks
When items are just chillin' in place and not
changing stacks, don't recalculate and reapply
entity properties.
2020-06-15 22:05:26 -04:00
Aaron Suen
e0156b4742 Add profiler instrumentation metadata everywhere
N.B. the MT built-in profiler doesn't yet actually support reading
labels from bare-function registrations, so a builtin hack is
needed.
2020-06-15 07:21:39 -04:00
Aaron Suen
4a784aeb8f Trigger visinv checks more smoothly
- Check item on same tick as creation.
- Stagger rechecks across ticks.
2020-05-31 10:36:11 -04:00
Aaron Suen
b21b7c2da2 Fix pathological visinv scalabilty
Defer and coalesce visinv entity creation/removal
checks until the next tick, so we can process them more
efficiently in a batch.

The spawn area of the Community MP server was
lagging to something like 6x the dedicated step size,
due to the huge number of dropped items.  This code,
on the same machine, seems to appear the same to the
player, but produces almost no measurable lag.
2020-05-30 22:33:13 -04:00
Aaron Suen
b1584290a8 Fix light overlap, torch fading in lode crate 2020-05-26 19:26:08 -04:00
Aaron Suen
2c85ee9a81 Unreorder a small calc 2020-05-26 19:07:28 -04:00
Aaron Suen
9865abd2ba Visinvs can cast dynamic light too, given space 2020-05-26 19:06:20 -04:00
Aaron Suen
11438a1625 Deprecate ent_prop_set() method 2020-05-25 11:43:51 -04:00
Aaron Suen
b4bf537513 Skip visinv checks for empty stacks 2020-05-24 23:18:33 -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
afa36f1236 Standardize obj property setting.
This should more reliably minimize network traffic
incurred by excess property setting.

We could probably standardize a few more things,
like set attach, anim, yaw, pos...
2020-03-25 09:20:37 -04:00
Aaron Suen
10e65388b9 Try not to send unnecessary visinv updates. 2020-03-14 18:50:29 -04:00
Aaron Suen
266de04987 API for getting objects inside one node. 2020-02-09 10:11:13 -05:00
Aaron Suen
d0e6dcc410 Add "stasis" option and command.
This freezes many things that normally happen automatically
in the world, including most ABMs and AISMs, and a few other
custom step logic items like the player "hot potato" logic.

This can be used for "creative mode" purposes to setup a complex
build without it running itself away from you, and for texture
pack authors, to have time to see things that are normally
transient or difficult to observe because of the effects they have
on nearby things or players.
2020-01-10 06:26:07 -05:00
Aaron Suen
4d47ab2e75 NC API dependency simplification.
Treat all API mods as a "layer", and use the new
nc_api_all registration to indicate that a mod depends
on the NC API (which ALL NC mods assume they do).
This means that each non-API mod does not need to
worry about which API mods it really needs and which
it does not, nor will they need to be updated for any
internal API restructures.

This is a game, not a modpack, so all mods will be
loaded anyway, and we only care about order.  That
means that we don't really need to worry about
having excess dependencies because any mod we
don't actually need will be needed by something that's
loaded anyway.  If somebody wants to reuse a
component elsewhere, they're likely to need to do
some work to untangle it anyway, because of the
amount that NodeCore mechanics interact and
interdepend.
2020-01-05 12:59:12 -05:00
Aaron Suen
dcfc80b367 Remove explicit names in mod.confs. 2020-01-05 12:38:45 -05:00
Aaron Suen
89020e8340 Major rebuild of item_entity.
This created a ton of dependency inversions, which
necessitated moving a number of API functions up into
higher layers, and restructuring dependency lists for
a number of mods.

BOLO: non-deterministic load errors due to missed
dependencies.
2020-01-05 11:42:22 -05:00