YaLTeR / OpenAG

An open-source reimplementation of Adrenaline Gamer's client library.
https://j.mp/OpenAG
Other
131 stars 39 forks source link

Fixed spectator mode VGUI panel #104

Closed chinese-soup closed 3 years ago

chinese-soup commented 3 years ago

Hello. Useless fixes galore!

This PR fixes a thing that's probably only been bugging me as I am probably the only person to ever try to use the VGUI spectator panel in AG and it always ticked me off that it doesn't work. This is the panel that appears when you press +duck while in spectator mode.

Let's get this out of the way first: spectating while on a server (and not on an HLTV server or on dem_forcehltv 1) is server-side, the client only sends the server commands when it wants to change the target to spectate / change the mode of spectating etc.

First: let's start with the easy stuff. To fix this menu:

image This change has to be made:

sprintf(cmdstring,"spec_mode %i",iNewMainMode );

As the server DLL that we are all using implements this client->server cmd as "spec_mode" instead of "specmode", see here: https://github.com/martinwebrant/agmod/blob/master/src/dlls/agclient.cpp#L126

Second: these two arrows were already working, but didn't make sense, they were flipped, i.e. the NEXT did previous player and PREV did next player, I fixed that in VGUI_SpectatorPanel.cpp**

image

Third of all: the worst offender - the player picker

image

This panel is supposed to just send the name of the player to FindPlayer(name) that sends the follow %s command to the AG server dll, but the AG server dll removed this and doesn't implement this at all, it only implements the follownext %i command (that's why clicking with the +attack & +attack2 works and also why the arrows mentioned above work) as can be seen here: https://github.com/martinwebrant/agmod/blob/master/src/dlls/agclient.cpp#L120

The workaround for this is to calculate how many times the client needs to send the follownext %i command where %i decides whether to go backwards (previous player) (1) or forwards (next player) (0).

Quirks & stuff:

All the fixes can be seen featured in this video: https://user-images.githubusercontent.com/5108747/115096852-5562a080-9f27-11eb-8357-d83127154249.mp4

Review welcome, I am a big C++ (or well, HLSDK is mostly just C with OOP but whatever) noob and this is a learning experience for me.

PS: The player picker could obviously be fixed server side by adding back the "follow" command that the AGMod author deleted. But for now, here's this.

YaLTeR commented 3 years ago

@tmp64 would you mind reviewing this too?

YaLTeR commented 3 years ago

This should be good to merge now, right?

chinese-soup commented 3 years ago

Not yet, sorry.

chinese-soup commented 3 years ago

Never mind, it is. Turns out the "follow" command isn't implemented in vanilla Half-Life server DLL either, so there's no need to check for gamemode there. This is good to go now.

YaLTeR commented 3 years ago

Alright, cool, thanks!