Jump to content

Server-only mods will still run on the local client when hosting a server with caves


hoxi
  • Pending

When setting up a server with caves with a server-only mod enabled (or what's the closest to that, with both client_only_mod and all_clients_require_mod set to false), the mod will still load and execute on the local client.

If having those flags set to false is implicit for "server-only" (which I would assume, given that clients can't run mods like that at all on their end, even if the server has those mods enabled), then it's not working as intended. It's also kinda weird to need to put server/mastersim checks in a server-only mod, where that's already supposed to be the case.

 

 

Also, slightly related:

Both ModManager:GetServerModsNames() calls here could be changed to something that ignore ignores server-only mods (or rather, only gets all_clients_require_mod mods), as clients simply won't have those mods running on their end, nor depend on them.

    for _,modname in pairs(ModManager:GetServerModsNames()) do
        inst.actionreplica.modactioncomponents[modname] = net_smallbytearray(guid, "modactioncomponents"..modname, "modactioncomponentsdirty"..modname)
    end


    if not TheWorld.ismastersim then
        inst:ListenForEvent("actioncomponentsdirty", OnActionComponentsDirty)
        inst:ListenForEvent("inherentactionsdirty", DeserializeInherentActions)
        inst:ListenForEvent("inherentsceneactiondirty", OnInherentSceneActionDirty)
        inst:ListenForEvent("inherentscenealtactiondirty", OnInherentSceneAltActionDirty)

        for _, modname in pairs(ModManager:GetServerModsNames()) do
            inst:ListenForEvent("modactioncomponentsdirty"..modname, function(inst)
                OnModActionComponentsDirty(inst, modname)
            end)
        end
    end

Because what's the point of defining net variables only on the server that will never be defined by clients, and viceversa with the listeners for clients?

What's more, even if that gets addressed, another flag could be added for all_clients_require_mod mods that don't need these variables and listeners (set by the mod author in modinfo.lua, and have nil be the default for backwards compatibility to not affect existing mods).

Wouldn't both of those things be better than assuming that all server mods need this?

Edit: thinking about it after posting, I realized that yes, clients can get these just fine due to how they obtain server mod names, but what's the point of doing that if both server and client need to register component actions with AddComponentAction? Not sure if I'm missing something.


Steps to Reproduce
  1. Start a server with caves and a server-only mod (preferably with something to log in modmain.lua, either there in the environment, or in a prefab post init).
  2. Notice how the mod will still execute on your local client, despite supposed to be server-only.



User Feedback


There are no comments to display.



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...