Facepunch / garrysmod-issues

Garry's Mod issue tracker
143 stars 56 forks source link

Workshop Enabled Gamemodes Create Version Conflicts #3876

Open TimGoll opened 5 years ago

TimGoll commented 5 years ago

I don't know if it is something that has to be changed, but since it was a headache for our team for months until we found the problem, I'll leave this here for further addon devs. Additionally a few thiings are outlined in this issue that seem to be bugs.

Details

Adding a workshop id to gamemode text file causes it to be force dowloaded even if you have the gamemode manually installed by dropping the folder of your addon into the addons folder. This isn't a problem for files that have to be executed by GarrysMod, but it is a problem if your addon scans through all files in a specific folder. Like ours does.

We fixed it like this: https://github.com/Alf21/TTT2/commit/07e859488114f19f7b7f0aa5c521edf499a9ece2

How we noticed it

Note: It was tested on local multiplayer with only myself connected to the game. But other players connecting to my local game encountered the same problem as well.

In the following paragraphs I'll explain how we noticed this problem. We are the devs of TTT2, an overhauled version of TTT2. In a recent update we introduced a new HUD system. This hud system scans through terrortown/gamemode/shared/hud_elements of all addons to find every HUD element added by addons. This allows addon devs to create dynamic HUD systems without a huge hassle.

After releasing this version to the WS a problem arised. We fixed it with a workaround, but a recent update broke it again. I renamed on of our HUD elements and suddenly there were two HUD elements. The old one and the new one. But this shouldn't happen, since only one element is registered (First I disabled the TTT2 addon, then I unsubscribed it). After a night full of annoyed testing (deleting the downloads folders in GM seemed to fix the problem, but only until you load the gamemode a second time), I reinstalled GM, including all addons. This fixed the problem (I do not understand why this fixed it, there might be a problem in GM).

Today I tested a few new things and this it were it gets interesting. I resubscriped to TTT2 and, like expected, I had both HUD elements, the new and the old one. Disabling the addon inside of GM itself removed the old one. But only until you reload the gamemode a second time. It reappeard. Strange! Deleting the folders seen in the following screenshot and unsubscribing from TTT2 did not help either.

image

Reloading the gamemode two time readded the old HUD element. Then I tried the command menu_cleanupgmas in order to delete the addon from my harddrive. Tried it again and it was the same thing as always. I checked the addons folder and TTT2 was still installed! This command might be bugged!

image

Then I noticed something different. After deleting the four folders and connecting to my local server, it seemed like TTT2 got downloaded. I recorded the screen and made a frame by frame analysis ans yes, it got downloaded:

image

This left me confused. Why would this be downloaded? And to where? I looked though folders and found a suspicious file. I recognized the size and unpacked it. It was TTT2. I had no idea why it was placed in this folder.

image

I don't know where this ID comes from. So I deleted the TTT2 folder in the addons folder and restarted the game again. This time the workshop file did not get downloaded. It seemed to be caused by our addon. I searched through the files and used the steam ID of our addon and found that it was only registered in the gamemode file.

So it seems like adding this line to the gamemode file causes the client to autodownload the file. This isn't a problem since our HUD manager checks if the HUD elements are registered on the server as well. But when connecting a second time, this file is also loaded on the server which causes our bug. I think this is not intended to work this way.

Additionaly a few things are strange:

I mark the other devs of the mod here so they can participate in it @Alf21 @saibotk @lebroomer

TimGoll commented 5 years ago

A small note, @lebroomer or @saibotk could tell you more about this: file.IsDir returned something different when it was executed on a path in the auto downloaded file compared to the addon installed manually by dropping the folder into the addons folder

This information seemed to help with our problem, but completely broke when executed in the normal WS version since file.IsDir seems to not work properly in gma files