JACoders / OpenJK

Community effort to maintain and improve Jedi Academy (SP & MP) + Jedi Outcast (SP only) released by Raven Software
GNU General Public License v2.0
2.03k stars 615 forks source link

Enabling lightsaber only and disable force in multiplayer doesn't work #1215

Closed Jon-guy30 closed 8 months ago

Jon-guy30 commented 8 months ago

Reporting a bug? Please make sure you've given the following information - thanks!

Operating system and version:

Windows 11 23H2 build 22631.3155 x64

Is this for single player or multiplayer?

Multiplayer

Description of the bug (and if possible, steps to reproduce the bug):

Enabling lightsaber only and disable force in a multiplayer solo match doesn't work, the game still starts with force and weapons enabled. Open a multiplayer game, enable Lightsaber only: Yes and Disable Force: Yes Watch as bots spawn with weapons and force! This feature works in retail, in openJK it's somehow broken.

What did you expect to happen instead?

The game starts without weapons and force with the feature tuned off! In retail it works as expected.

EDIT: Better title and edited post.

Razish commented 8 months ago

I have taken a look at this. I don't see how it ever functioned in retail JKA, but I also don't have a retail install+engine+mod to test with.

If you look at the .menu file (ui/jamp/quickgame2.menu) you can see the buttons are of type ITEM_TYPE_YESNO and linked up to the cvars directly. This means the only possible values of g_weaponDisable and g_forcePowerDisable are 0 and 1, when they are actually meant to be bitfields of which weapons/forcepowers to disable.

In order for this to work right now, you would need to modify the .menu file as such:

diff --git a/base/ui/jamp/quickgame2.menu b/OpenJK/ui/jamp/quickgame2.menu
index 5cb39a5..8c7c5ee 100644
--- a/base/ui/jamp/quickgame2.menu
+++ b/OpenJK/ui/jamp/quickgame2.menu
@@ -156,10 +156,15 @@
        {
            name                options
            group               grpOptions
-           type                ITEM_TYPE_YESNO
+           type                ITEM_TYPE_MULTI
            text                @MENUS_LIGHTSABER_ONLY
            descText            @MENUS_SABER_ONLY_INFO
            cvar                "g_weaponDisable"   
+           cvarFloatList 
+           { 
+               "No" 0 
+               "Only Saber" 524278
+           }
            rect                5 130 240 20 
            textalign           ITEM_ALIGN_RIGHT
            textalignx          165
@@ -233,10 +238,15 @@
        {
            name                options
            group               grpOptions
-           type                ITEM_TYPE_YESNO
+           type                ITEM_TYPE_MULTI
            text                @MENUS_DISABLE_FORCE
            descText            @MENUS_DISABLE_FORCE_INFO
            cvar                "g_forcePowerDisable"
+           cvarFloatList 
+           { 
+               "No" 0 
+               "Only Jump + Saber" 163837
+           }
            cvarTest            "ui_netGameType"
            hideCvar
            { 

If it really did work on the retail game, perhaps we did change the behaviour of those cvars :thinking:

ensiform commented 8 months ago

I still cannot find where in the original code that the server side actually checks for 1/0

Razish commented 8 months ago

Found and fixed the issue, thanks for the report!

The reason the original menu files work is because they fire some uiScript commands that interpret the aforementioned cvars and translate them to the correct bit-values. At some point (before OpenJK was OpenJK) I had disabled that block of code for unknown reasons. Bringing it back fixes those buttons when creating a server.