transhumandesign / kag-base

King Arthur's Gold base folder.
258 stars 119 forks source link

Allow dismissing script errors without rebuild/ignoring specific script errors #1358

Open asumagic opened 2 years ago

asumagic commented 2 years ago

Current in-game behaviour.

If a script error occurs, you may need to /rcon rebuild in order to fix it, which can accidentally flag your server as modded when it is not.

Proposed Change

We could introduce a command like /rcon /clearerrors.

Another option, which may be useful for robustness in some scenarios: we could introduce function metadata on functions that would look like:

[ignoreScriptErrors]
string KidSafeText(const string &in textIn)
{

If any ignoreScriptErrors tagged functions appear in the call stack at the time an exception occurs, then the script would not be forced into a failed state.

Exception info would still be printed, perhaps along with an indication:

`ignoreScriptErrors` metadata applied to `string KidSafeText(const string &in)`, script will continue running
Vam-Jam commented 2 years ago

Metadata attributes would be good, but I feel like it should be reversed into [abortScriptError] or [freezeScriptError]

Generally, most errors hit are accidental 'did not check x/y/z was null here', and its safe to ignore/continue on with our day as it wont happen again for another match or so. The only time completely freezing a script/blob is suitable is when:

I feel like [ignoreScriptErrors] would just end up being overused everywhere, where as something like 'this is unrecoverable, abort execution' would be more suitable for critical scripts (game rules?)

asumagic commented 2 years ago

Maybe, I'm not sure how to deal with log spam and determining what "continuously failed" means though.

I was thinking of [ignoreScriptErrors] as a rare measure for things where edge cases tend to be unavoidable with bad code, e.g. NoSwears.as but that might be too niche..?