38 Commits

Author SHA1 Message Date
Aaron Suen
12302342dc Backout hashed value caching
At only 50% hit ratio, it's probably
costing as much to cache as to recalc,
and this simplifies the code better.
2020-07-03 09:26:26 -04:00
Aaron Suen
f27378ca12 Optic "virtualization"
If we're running multiple optic ticks in
rapid succession, then we don't return
control to the rest of the game between
ticks, so there's no point in reading the
map more than once per pos, and no
point in updating the map until the end
when optics may have oscillated
across multiple states.

Maintain a cache and commit buffer
during each globalstep and only flush
them at the end.
2020-07-03 09:23:19 -04:00
Aaron Suen
d6426e9a9f Remove redundant dependency logic 2020-07-03 08:37:09 -04:00
Aaron Suen
32902d5554 Un-hard-code optic config parameters 2020-07-03 08:31:03 -04:00
Aaron Suen
0675d943ad Make lenses sense input immediately 2020-07-03 08:24:09 -04:00
Aaron Suen
fe1a5e38b7 Microoptimization consistency
Carry the node pre-indexing a little further to
cover the scan case as well.
2020-07-01 21:40:32 -04:00
Aaron Suen
9203734e5a Optics overhaul: eliminate node meta
Apparently as oilboi pointed out, node metadata
is kinda gross, and in this case we didn't actually
need it, since the information could actually
always have been inferred from the nodes
themselves.

Instead of storing output state in node meta,
just register a callback on the node definition to
interrogate the node itself about its power output.
2020-07-01 21:35:23 -04:00
Aaron Suen
e7bd68a24b Reduce optic tick speed to 12Hz
This is the GCF between 60Hz and 144Hz
displays, so ideally a beefy enough
machine should be able to run optics
smoothly either way.
2020-06-24 08:16:51 -04:00
Aaron Suen
ec86f0f130 Reawaken optic circuits more reliably on load 2020-06-24 08:11:44 -04:00
Aaron Suen
2ea41b27ea Allow optic ticks to "slip" under load
If the server can't handle optics, it would lead to a
runaway effect and bring the system down.  Instead
only process up to half a second worth of optics on
each tick, so that this effect is capped and the server
will at least be able to chug along.
2020-06-24 08:03:42 -04:00
Aaron Suen
7b44fb2b29 Make optic systems tick at a consistent Hz 2020-06-24 07:45:20 -04:00
Aaron Suen
9c150a2054 Fix stasis
- Late-bind ABM registration alias so stasis
  wrapper is honored.
- Make DNTs wait in a loop until stasis is
  cleared.
- Make optics honor stasis.
2020-06-21 10:46:35 -04:00
Aaron Suen
41e744b0e9 Apply ABM laundering at base level 2020-06-21 10:25:07 -04:00
Aaron Suen
3367ca1857 Fast optic path obstruction response
Optics keep track of path dependency info
used in calculating state.  When a node is
added/removed in the path via the mod API
(i.e. not schematics, vmanip, etc.) then the
nodes whose state decisions depended on
paths going through there are automatically
triggered for a recheck.

This should make things like furnace sand
auto-loaders respond snappily.

Granted, memory use with this approach is
a concern, but we will just have to monitor it
under normal usage patterns.
2020-06-19 10:01:25 -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
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
f54117718b Spread passive optic checks across multiple ticks. 2019-12-03 08:01:33 -05:00
Aaron Suen
4ee34d4b2d Fix major optics performance bug.
Optic checks were being propagated unconditionally in loops,
causing nearly every node in an optic network to be checked every
time.

This restores behavior to the original intended behavior of
propagating forward changes on next tick, but stopping at points
where state quiesces.

Unfortunately beam obstruction sensing has been working
instantaneously because of this bug, and that will revert to the
original intended behavior of having those picked up only on
random checks, which may cause regressions in some builds.
2019-12-03 07:57:22 -05:00
Aaron Suen
fd31c8dad7 Opaque nodes can block lens beams in item form. 2019-11-23 08:57:03 -05:00
Aaron Suen
39dea8a2ae MAJOR: Code quality audit using luacheck.
- Removed lots of unused variables, a few shadowed identifiers.
- Removed a few sections of dead code.
2019-08-31 09:26:53 -04:00
Aaron Suen
fe2c153f9e Clean up all lua code style.
Formatting rules based on Paul Kulchenko's perl-based formatter...
http://notebook.kulchenko.com/programming/lua-beautifier-in-55-lines-of-perl
...using a single tab for indent.

Mostly pure whitespace changes.
2019-08-27 19:14:51 -04:00
Aaron Suen
fb63ad0a82 Fix some optics unloaded-area crashes. 2019-03-24 23:15:25 -04:00
Aaron Suen
c44d9879bd Cut down on log noise from optics. 2019-03-24 19:52:14 -04:00
Aaron Suen
e08e017e04 Stop excess optic rechecks on ignores. 2019-03-24 18:24:37 -04:00
Aaron Suen
7cae0bd430 Clean up optic processing code. 2019-03-12 20:30:59 -04:00
Aaron Suen
8053bbc21c Transactional stability for optics.
- Make lens not flicker with light level dithering by using
  histerisis in threshold.
- Optical nodes always read the past world snapshot for creating
  the next snapshot, so there are no accidental fast paths
  through optical logic leading to glitches (hopefully).
2019-03-12 20:22:42 -04:00
Aaron Suen
0f0377da52 Make lens/prism light pass thru sunlight_propagates nodes.
This also prevents the lens from igniting them.

Made stick and staff at least as transarent as frames/ladders.
2019-03-09 19:46:52 -05:00
Aaron Suen
58109d30e7 Create basic crafting recipes, completing tech tree bridge.
It should now be possible to obtain the new optical stuff given
only resources in-game.  The molten glass casting process, in
particular, should be at least a little interesing.

These recipes aren't very interesting and may be subject to
refinements in the future.
2019-03-07 22:27:38 -05:00
Aaron Suen
fa4ae544ad Crank abm back up again, log unloaded area issues. 2019-03-07 01:56:27 -05:00
Aaron Suen
cb78b5a334 Got immediate triggering working. 2019-03-07 01:40:26 -05:00
Aaron Suen
94082bc86a Prism and full logic basically working.
There seems to be an issue triggering events, so a lot of work
is being done by the abm to cover over this problem...

Much like my earlier work with sz_rotary, I suspect a lot of
fine-tuning will be needed.
2019-03-07 00:58:37 -05:00
Aaron Suen
e68693c062 Optic API works, lens basically works. 2019-03-07 00:35:27 -05:00
Aaron Suen
2b9ff67ee1 Plan. 2019-03-06 00:11:11 -05:00
Aaron Suen
3bb18e195e A little refactoring... 2019-03-05 23:05:56 -05:00
Aaron Suen
b10cdfaa7d Fixed. 2019-03-04 23:52:15 -05:00
Aaron Suen
15805fee3a Typo. 2019-03-04 23:51:04 -05:00
Aaron Suen
42466f557c Oops, of course, I left debug code in. 2019-03-04 23:50:33 -05:00
Aaron Suen
0d23186747 Start getting into nitty-gritty optical transmission protocol.
This is going to be a lot like sz_rotary from sztest, and one of
the more complex things to implement.
2019-03-04 23:49:16 -05:00