Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client-server desync for weapon Kind value when Kind is set in TTT2Initialize #1433

Open
nike4613 opened this issue Feb 25, 2024 · 5 comments
Labels
type/bug Something isn't working
Milestone

Comments

@nike4613
Copy link
Contributor

nike4613 commented Feb 25, 2024

Your version of TTT2 (mandatory)

v0.13.0b (both workshop and git)

Describe the bug (mandatory)

Client:

] lua_run_cl PrintTable(LocalPlayer():GetInventory())
{
    [1] = {
        [1] = Weapon [1174][weapon_zm_improvised],
    },
    [2] = { --[[ empty ]] },
    [3] = {
        [1] = Weapon [965][tfa_ins2_remington_m870],
        [2] = Weapon [1068][tfa_ins2_deagle],
    },
    [4] = {
        [1] = Weapon [1039][weapon_zm_molotov],
    },
    [5] = {
        [1] = Weapon [1173][weapon_zm_carry],
    },
    [6] = {
        [1] = Weapon [1172][weapon_ttt_unarmed],
    },
    [7] = {
        [1] = Weapon [1006][weapon_ttt_firstaid],
    },
    [8] = { --[[ empty ]] },
    [9] = { --[[ empty ]] },
}

Server:

lua_run PrintTable(Player(7).inventory)
> PrintTable(Player(7).inventory)...
{
    [1] = {
        [1] = Weapon [1174][weapon_zm_improvised],
    },
    [2] = {
        [1] = Weapon [1068][tfa_ins2_deagle],
    },
    [3] = {
        [1] = Weapon [965][tfa_ins2_remington_m870],
    },
    [4] = {
        [1] = Weapon [1039][weapon_zm_molotov],
    },
    [5] = {
        [1] = Weapon [1173][weapon_zm_carry],
    },
    [6] = {
        [1] = Weapon [1172][weapon_ttt_unarmed],
    },
    [7] = {
        [1] = Weapon [1006][weapon_ttt_firstaid],
    },
    [8] = { --[[ empty ]] },
    [9] = { --[[ empty ]] },
}

This desync causes the desync'd weapons to appear in the incorrect slot.

To reproduce

This one is difficult... The easiest is probably to do something like:

hook.Add("TTT2Initialize", "MyWeaponPatch", function()
    let tbl = weapons.GetStored("weapon_zm_mac10")
    tbl.Kind = 2
end)

My own setup is more indirect and extensible, but this is effectively what it does.
(A lot of the weapons we use are incorrectly classified, so I have to touch a lot of them to make sure that they have the correct kind. This used to work perfectly ~2 weeks ago, something changed. I'm not sure if it was a change in G-Mod or in TTT2. The especially strange thing is that some weapons don't get the desync, while others do, even though they go through exactly the same process.)

My own investigations suggest that the Weapon objects are somehow being instantiated on the client before the weapon tables are modified. I cannot for the life of me figure out why this is happening, however.

Expected behaviour

The client and server remain in-sync, and all weapons are displayed in the correct slots.

Context (please provide as much as you can)

Same details as #1411 and #1432.

@EntranceJew
Copy link
Contributor

this is probably definitely the cause for at least part of what's wrong with Weapon Slot Reassignment mentioned on #1360 (but probably not the whole story, since it existed prior to the reassignment being an option, and none of these weapons seem reassigned)

@Histalek Histalek added the type/bug Something isn't working label Feb 25, 2024
@TimGoll
Copy link
Member

TimGoll commented Feb 25, 2024

Could you try TTT2FinishedLoading as a hook as this one is hotreload safe and called after all entities are ready. Just to rule out a basic GMod entity syncing issue. Thanks!

@nike4613
Copy link
Contributor Author

Performing the changes in TTT2FinishedLoading does not appear to fix the issue. I am noticing that this basically only happens when connecting to the server after the map has already loaded and the game has begun to start, such as after a map transition. First load into an empty server and adding a bot does not cause it to happen.

My guess is that something in the game's netcode is instantiating the weapons before any of these hooks. I don't think that operating before hooks is a good idea though; I worry that it will very consistently miss some weapons.

@EntranceJew
Copy link
Contributor

Performing the changes in TTT2FinishedLoading does not appear to fix the issue. I am noticing that this basically only happens when connecting to the server after the map has already loaded and the game has begun to start, such as after a map transition. First load into an empty server and adding a bot does not cause it to happen.

This lines up with the issues in #1360 pretty concisely, a lot of data fails to make it to the client.

My guess is that something in the game's netcode is instantiating the weapons before any of these hooks. I don't think that operating before hooks is a good idea though; I worry that it will very consistently miss some weapons.

It's becoming more and more apparent that we ought to be utilizing some of the data from ClientSignOnStateChanged utilizing SIGNONSTATE so that we can actually properly process letting the server hit the client with data AFTER they're fully apart of the game -- and more specifically EXCLUDING them from receiving roles or any information until they're fully joined-in.

@TimGoll
Copy link
Member

TimGoll commented Feb 26, 2024

I think one of the next minor releases (not v.0.13.1) will put a focus on syncing for late joiners

@Histalek Histalek added this to the v0.13.xb milestone Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants