-
Notifications
You must be signed in to change notification settings - Fork 148
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
Have clients select weapons by ID, rather than by name #212
Conversation
Also, the original method of selecting weapons is still available, so it won't break existing configs that use them. |
player->SelectItem(pcmd); | ||
auto weapon = player->GetNamedPlayerItem(pcmd); | ||
|
||
if (weapon != nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to have a SelectItem
overload that takes a classname and do what the original method did, then you don't need these changes here. People who merge changes into their projects won't have to make extra changes as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. If I update my branch, would you recommend amending the existing commit or creating a new one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amend the commit. No need to add multiple commits to a pull request.
Have you tested this in a multiplayer environment with |
I just did a quick comparison between the two with I should also mention that I discovered this because of it's use in Deathmatch: Classic. My thought process is that, even if they're functionally identical, less data being sent over the wire is a win. And that because it's officially implemented in a multiplayer GoldSrc game, it's likely a stable feature. |
This method is also used in Source: So they probably planned on doing it during HL1's development, got around to it when making DMC and then used it in Source games from that point onward. |
Sorry, i merged this by accident. Looks like i can't reopen it, can you create a new PR with the changes? |
The
usercmd_t
struct has aweaponselect
field, used in the weapon prediction code, to select weapons by ID. Being a part of the client's command struct, it can also be sent over the net. Using this instead of sending a"weapon_"
command every time a client wants to change weapons should substantially reduce the number of string comparisons that the server has to handle in multiplayer. Innetwork/delta.lst
, I set it to be sent as 6 bits, as weapon IDs only go up to 64.(I also removed the
SelectItem
definition on the client, as it seems to be dead code.)