Barotrauma icon indicating copy to clipboard operation
Barotrauma copied to clipboard

Money command (And possibly others) in debug-built clients only trigger on the local client

Open NilanthAnimosus opened this issue 3 years ago • 6 comments

Disclaimers

  • [X] I have searched the issue tracker to check if the issue has already been reported.
  • [ ] My issue happened while using mods.

What happened?

Using the debug branch of the game, I quickly went to use the command "Money" to add funds for testing purposes, however the console states I do not have permission to use the command but it will do so anyways as it is a debug build. However this actually adds funds to the client side only, and somehow not on the server side resulting in a number of small money related syncing issues. Deducting money also does not set the new current value but instead changes it by the set amount so it does not re-sync.

I only feel this is worth mention if other commands exhibit strange behavior due to this as well, as I think a few commands have this occur while running a debug copy such as give affliction that I've been noticing (Or they just don't function correctly as a client).

It maybe likely due to servers default command permissions not including most of these commands yet debug will trigger their effects as if they do have permission to, resulting in unknown consequences from command to command.

Reproduction steps

Join a local host dedicated server with a client in debug mode without enabling cheats and use the "money" command on the clients side. Only that client will have its funds increased and not other clients or the servers half.

Bug prevalence

Happens every time I play

Version

Other

-

0.18.13.0

Which operating system did you encounter this bug on?

Windows

Relevant error messages and crash reports

No response

NilanthAnimosus avatar Jul 05 '22 10:07 NilanthAnimosus

I wouldn't actually consider this a bug: we've intentionally allowed the clients to execute commands they don't have the permissions to execute in debug builds for easier debugging. It can ofc lead to weird results and desync with some commands, including this one. Something we might need to look into though is the money not getting back in sync when you buy/sell something: how did that happen specifically; what did you try to do with the money?

Regalis11 avatar Jul 05 '22 11:07 Regalis11

I was attempting to test crew wallets and buy using vending machines, though it didn't go back into sync no matter what method for I think, it looked like the client was told the subtraction instead of the new value. if thats my imagination just try a vending machine followed by buying from a store.

NilanthAnimosus avatar Jul 05 '22 14:07 NilanthAnimosus

I couldn't reproduce the issue. Tested by doing the following:

  1. Make the server give the client 100 mk
  2. Make the client give themselves 200 mk without the appropriate permissions
  3. There should now be 100 mk in the wallet server-side, and 300 mk client-side
  4. Buy an energy drink (40 mk) from a vending machine
  5. The client's balance gets corrected to 60 mk as expected

Regalis11 avatar Jul 12 '22 08:07 Regalis11

Ok so I quickly re-tested this, noting at the time of testing I had zero idea the money command was capable of targetting specific characters and the client likely had 0 marks.

I re-tested quickly on the branch I had active at the time (Which is mostly 0.18.12.0) and found If I add 500 marks to the wallet (and the server has 0) there is no update to the amount and it remains 500 client side.

It appears my original description was from buying from a store when the server has 0 in the wallet and the client has wallet money, the amount gets deducted from the wallet (IE 500 -> 400 when the server-side is 0 after adding 500 without the correct permissions).

Essentially, the client in some cases reduces the money on its own side then updates from the server. though if the server has a zero it sends no update (Which makes sense) so I observed it going down client-side instead of going to 0.

NilanthAnimosus avatar Jul 12 '22 09:07 NilanthAnimosus

Should be fixed in https://github.com/Regalis11/Barotrauma-development/commit/9f06f30566c586a3f1879fec781a1840ea48662a

Regalis11 avatar Jul 12 '22 10:07 Regalis11

Tested in 0.19.0.0

Money now correctly syncs (if out of sync somehow) when using a store and the money is in the crew wallet. it does not correctly re-sync if the bank has out of sync money however.

NilanthAnimosus avatar Jul 26 '22 17:07 NilanthAnimosus

Fixed in https://github.com/Regalis11/Barotrauma-development/commit/e8f36baa327e7ade1542184b6a87562b9b984fb1

Regalis11 avatar Aug 17 '22 07:08 Regalis11

Tested against dev commit https://github.com/Regalis11/Barotrauma-development/commit/f82a333e436d97a8051448f960194e41892e9be5

Money syncing appears to be generally fixed now in all my tests, however I have noticed minor UI/client side issues after it is synced (If it is to the action).

If the money is desynced and you purchased a submarine upgrade, the client will actually purchase it on their side (IE. the UI will show 1/5), however the server will state "Tried to purchase an upgrade with insufficient funds, the transaction has not been completed." and it appears to not actually go through.

As a note, the client in question has been given all permissions (but not command permissions) and thus has access to the bank and such.

The client however (even if funds are gained and it is all resynced) will no longer be able to purchase submarine upgrades at all. they can still attempt to swap a weapon to breaking it similarly as it works client side but not server side, both of these though also breaks the UI in a few odd ways such as no longer showing the bank funds.

Note the funds available (and is correctly synced this time), lack of submarine money listed and inability to buy upgrades: image

Client also seems to believe a failed purchase of a chaingun swap (from coilgun) went through correctly.

When changing turret from the failed purchase of a chaingun (that was shown as pending) to the coilgun (which it already was) with the correct funds available, the client instantly purchased the battery upgrade.

fixing the submarine with desynced money does re-sync it correctly as well as the upgrades resyncing money correctly, but there is zero feedback if it fails to do the repair or the upgrade is the main point here in the event it ever is desynced before it corrects itself. the stores have less of a problem here as attempting to add a product instantly re-syncs it.

Vending machines attempt to craft and instantly stop, they do not resync the money on the failure of the action however but that doesn't surprise me as I think vending machines are essentially fabricators?

As usual, to desync money just use the money command for wallet or bank as a client running a debug build that does not have permission to use the command.

NilanthAnimosus avatar Aug 23 '22 09:08 NilanthAnimosus

Not worth addressing imo, considering how unlikely this is to happen unless you deliberately try to desync it

Regalis11 avatar Aug 23 '22 12:08 Regalis11