ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.67k stars 619 forks source link

[HL1/GoldSrc] Player color sliders in multiplayer dialog #1477

Closed PaHgoM closed 10 months ago

PaHgoM commented 10 years ago

Player color sliders does not change the preview picture. Screenshot attached/ 2. I think this maybe in all GoldSrc games. Sorry for bad english. Upd: Sliders don't work in software mode too

tschumann commented 8 years ago

You should post your OS etc.

PaHgoM commented 8 years ago

Windows 7 x64

SamVanheer commented 7 years ago

This happens because the dialog checks if the image has these particular color indices. The images for these models were saved with the maximum number of colors available, so the number is actually 0. The check fails and the code ignores your color changes.

Affected code here: https://github.com/SamVanheer/GoldSourceRebuild/blob/d72ddae5516c7d6a0f11bd16915a126e3c9bdb27/src/GameUI/OptionsSubMultiplayer.cpp#L672

rtxa commented 5 years ago

@mikela-valve please fix this

SamVanheer commented 5 years ago

Since my link is no longer valid i'll explain the cause of this bug in detail.

The Multiplayer dialog will only perform a remap if enough colors are available in the bitmap palette.

It does this by checking the biClrUsed field in the BITMAPINFO structure it reads from the file:

LPBITMAPINFO* lpbmi = ...;
if ( lpbmi->bmiHeader.biClrUsed > 223 )
{
  PaletteHueReplace(lpbmi->bmiColors, topcolor, 192, 223);
}
if ( lpbmi->bmiHeader.biClrUsed > 191 )
  PaletteHueReplace(lpbmi->bmiColors, bottomcolor, 160, 191);

Now here's the problem: the BITMAPINFO spec states the following:

If biClrUsed is zero, the array contains the maximum number of colors for the given bitdepth; that is, 2^biBitCount colors.

The code needs to be updated to handle the value being 0.

The original version of this code can be found in the Alien Swarm SDK: https://github.com/Nican/swarm-sdk/blob/b86cc6c4a04095488da6fcde917542329dafd746/src/game/client/swarm/gameui/optionssubmultiplayer.cpp#L2457-L2459

This also includes the code to perform remapping so if you need the code for anything, there it is.

@mikela-valve seems like a very easy fix.

shytzedaka commented 4 years ago

Looking forward to see this one fixed.

schmurtzm commented 4 years ago

May be the bug comes from the image bitmap files and not from the game interface.

This guy has done modifications on the portrait image to make it work again : https://gamebanana.com/guis/35187

This fix should be included in a next release because it is useful to choose your personal color in deathmatch.

(a little disappointed to see that this bug is not resolved in 6 years because it was working in very old versions of half-life...)

rtxa commented 4 years ago

May be the bug comes from the image bitmap files and not from the game interface.

This guy has done modifications on the portrait image to make it work again : https://gamebanana.com/guis/35187

This fix should be included in a next release because it is useful to choose your personal color in deathmatch.

(a little disappointed to see that this bug is not resolved in 6 years because it was working in very old versions of half-life...)

Well, thanks for the link with the fixed images, still it would be more easy to fix the code that handles it, because the .bmp images were never modified, Solokiller has pointed the solution.

PaHgoM commented 1 year ago

2023, still not fixed.

PaHgoM commented 10 months ago

Fixed in HL anniversary update, so I guess I can close this.