Skip to content
Snippets Groups Projects

Substitute MT_NULL with MT_RAY in Lua

Merged Zwip-Zwap Zapony requested to merge Zwip-Zwap_Zapony/SRB2:substitute-null-with-ray into next
1 unresolved thread

As of !1973 (merged), P_SpawnMobj no longer replaces MT_NULL with MT_RAY, and instead aborts spawning MT_NULL mobj types. However, some Lua scripts, including [Silver the Hedgehog], expect MT_NULL to be spawnable.
This merge request replaces MT_NULL with MT_RAY in Lua's mobj-spawning functions, with a // TODO: 2.3: comment for making it show a Lua error instead for v2.3 (because usually, trying to spawn MT_NULL means that something has gone wrong, that you don't want to spawn anything and so don't need to call a spawning function, or that you should be using MT_RAY instead).
(SOC actions trying to spawn MT_NULL will still not spawn anything, though.)



TL;DR: Reverted Lua mobj-spawning to v2.2.13's behaviour. Not worth mentioning in v2.2.14's changelog.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
44 44 else if (hook_cmd_running)\
45 45 return luaL_error(L, "CMD building code should not call this function!");
46 46
47 #define NOSPAWNNULL if (type >= NUMMOBJTYPES)\
48 return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1);\
49 else if (type == MT_NULL)\
50 {\
51 CONS_Debug(DBG_GAMELOGIC, "Tried to spawn MT_NULL, using MT_RAY\n");\
  • Contributor

    Maybe raise a Lua warning here instead? MT_NULL really shouldn't be spawned, so it's important that we raise awareness to the Lua developer about that.

  • Is it worth it for semantics' sake only? The behaviour (automatically substituting MT_NULL with MT_RAY) is the same as in v2.2.13, and updating the script to use MT_RAY doesn't cause any in-game difference. That would cause harmless-but-annoying warnings to pop up for end users, "requiring" a mod to be updated just for semantics.

    (For reference, this CONS_Debug line is taken verbatim from pre-​!1973 (merged) P_SpawnMobj.)

  • Contributor

    It's not really semantics, though. From a comment you added right below this:

    TODO: 2.3: Use the below NOSPAWNNULL define instead. P_SpawnMobj used to say "if MT_NULL, use MT_RAY instead", so the above define maintains Lua script compatibility until v2.3

    That, to me, sounds like MT_NULL is now obsolete and shouldn't be used. We already warn in cases where scripts use P_TeleportMove in favor of P_*Origin, so why not do that here too? If we don't warn, script writers won't be able to prepare for a breaking change we've planned for in 2.3, which can lead to unexpected breakage to some script writers once 2.3 is released.

  • Contributor

    I agree. Trying to spawn an invalid object is very distinctly a script error, and it should be treated as such.

    I reported the Silver crash because Lua causing crashes is always a flaw. It ended up just being a genuine regression, but if it was due to bad Lua, then that should've also been changed to error.

  • Zwip-Zwap Zapony changed this line in version 2 of the diff

    changed this line in version 2 of the diff

  • @ Hanicef - [...] We already warn in cases where scripts use P_TeleportMove in favor of P_*Origin, so why not do that here too? [...]

    Funnily enough, I considered bringing that up in my previous comment. There's a difference between changing P_TeleportMove to P_MoveOrigin and changing it to P_SnapOrigin (i.e. it's not just semantic), and SRB2 can't automatically tell what the Lua scripter originally intended.

    I'd be happy to add a Lua warning here too, but I'd like to hear STJr's opinion first - and with LJ Sonic giving a thumbs-up and Sal commenting, I've heard their opinion now. :thumbsup:

  • Please register or sign in to reply
  • added 1 commit

    • bdeec562 - Substitute MT_NULL with MT_RAY in Lua

    Compare with previous version

  • sphere changed milestone to %2.2.14

    changed milestone to %2.2.14

  • Logan Aerl Arias added 294 commits

    added 294 commits

    Compare with previous version

  • Logan Aerl Arias mentioned in commit add091ba

    mentioned in commit add091ba

  • Please register or sign in to reply
    Loading