fuzzball-muck / fuzzball

Ongoing development of the Fuzzball MUCK server software and associated functionality.
Other
46 stars 26 forks source link

Error prim fixes, GAUSSIAN simplification, and style improvements #714

Closed wyld-sw closed 8 months ago

wyld-sw commented 8 months ago

Non-cached GAUSSIAN

The current GAUSSIAN caches one of the generated random numbers for a potential next call, as does the traditional algorithm. A comment suggested we may not need to do this, and I would tentatively agree based on my limited testing. Caching does certainly have an impact, but I believe a program would exhaust the instruction limit before that impact is noticeable (even with a much larger instruction limit).

My limited testing included using the undocumented {timing} function to loop through several thousand calls (100.0 5000.0 GAUSSIAN), with both implementations (with and without caching). Without caching, I hit the instruction limit in less than 0.1 seconds. Now that was just my single-player test server, so I may be jumping to conclusions.

This is mostly the reason to review this PR, but please point out any problems with the other parts too!

Errors within errors

CLEAR_ERROR , ERROR_STR, IS_SET?, and SET_ERROR now function as expected (again) when used with a string argument. I made a commit years ago that inadvertently broke this.

Some of these primitives have been rewritten to use less code.

Style, scope, and sanity

One-line if-blocks now use braces.

Many variables have been moved closer to their access points, including globals. Except for oper1-oper4 because they're special (for now).

Redundant and ill-placed sanity checks that were missed in a recent PR for p_misc.c have been combined.