HLFixes

Fixing Bugs in GoldSrc

Download

Latest Release

Requirements

Windows

Linux

Installation Guide

Windows

  1. Make sure Half-Life isn't running
  2. Download
    Windows.zip
    from here
  3. Extract it somewhere
  4. Run
    Installer.exe
  5. Click on
    Install
    or
    Reinstall
    if you're updating
  6. If all goes well the fixes should be applied

Linux

  1. Make sure Half-Life isn't running
  2. Download
    Linux.zip
    from here
  3. Extract it somewhere (
    unzip Linux.zip
    )
  4. Run
    ./installer.sh
    from a terminal
  5. Select
    Install HLFixes
    or
    Reinstall HLFixes
    if you're updating
  6. If all goes well the fixes should be applied

You can see if it's working by running

version
in console. It should say
Patched with HLFixes
at the end of the output.

Why?

Because there's still bugs in GoldSrc that have yet to be fixed, unfortunately.
Ideally, HLFixes will be made entirely obsolete by Valve but so far that hasn't happened.

How?

The installer modifies the Half-Life launcher so that it loads HLFixes instead of the engine. HLFixes then loads the engine and applies patches and hooks.

What's Been Fixed?

Quick save backup not functioning

When you make a quick save, the engine is supposed to rename the already existing

quick.sav
to
quick01.sav
before writing the new quick save.
However, this functionality was unintentionally broken in an update that fixed this issue. HLFixes restores the previous behaviour.

Technical Details

SaveGameSlot
is the function responsible for calling the save backup function. It does this by checking to see if the save is called
quick
or
autosave
and calling
Host_SaveAgeList
if it is.
However, after the update,
Host_Savegame_f
now appends
.sav
to the save name before calling
SaveGameSlot
, thus preventing
Host_SaveAgeList
from ever being called as the save is now called
quick.sav
.
HLFixes resolves this issue by hooking
SaveGameSlot
and changing the save name to
quick
if it was
quick.sav
.

GitHub issue.


Music stopping after a level transition

This is technically intentional behaviour. If the game isn't Half-Life 1, the engine stops music after a level transition.
However, the expansions and a lot of mods aren't expecting this to be the case. HLFixes removes the whitelist and makes it work in all games/mods.

Technical Details

CGameUI::ConnectToServer
checks to see if the game name is
valve
. If it isn't, it issues the
mp3 stop
command to the engine.
HLFixes resolves this issue by hooking
CGameUI::ConnectToServer
and changing the game name to
valve
.


Main menu music continuing to play while in-game

The engine never stops the main menu music after leaving the main menu. HLFixes fixes this by telling the engine to stop playing the music when going in-game.

Technical Details

HLFixes resolves this issue by hooking

CGameUI::ConnectToServer
and checking to see if the current track is
media\gamestartup.mp3
.
If it is, the game name is changed to something other than
valve
in order to take advantage of the music stopping behaviour.


Main menu music playing over top of the intro video

The engine starts playing the main menu music before the intro video starts playing. HLFixes fixes this by starting the main menu music after the videos are done playing.

Technical Details

HLFixes resolves this issue by hooking

Cmd_ExecuteStringWithPrivilegeCheck
and preventing the command that starts the main menu music from executing.
HLFixes also hooks
CVideoMode_Common::PlayStartupSequence
and issues the command to start the main menu music after the intro videos are done playing.


gl_overbright

This fix has been made mostly obsolete with the anniversary update.



The engine turns off texture sorting if it detects that your GPU supports the multitexture extension.
HLFixes turns texture sorting back on, which allows

gl_overbright
to work.

Technical Details

HLFixes resolves this issue by forcing

gl_texsort
to 1 when
gl_use_shaders
is 0.


Broken skies in Condition Zero Deleted Scenes

When the engine draws the sky, it needs to know what surfaces are supposed to have the sky drawn on them. The way it does this depends on whether texture sorting is on.
When

gl_texsort
is set to 0 (i.e. when the engine detects the multitexture extension), it simply checks to see if a given surface has the
SURF_DRAWSKY
flag.
When
gl_texsort
is set to 1, it'll check every texture the map uses to see if it starts with
sky
. When it comes time to draw the sky, it'll draw it on surfaces that use the texture it found.

The latter behaviour works well for the most part, but it assumes that there will only ever be one texture that starts with
sky
.
Condition Zero added a new texture called
skycull
that is supposed to be used on the exterior of sky brushes in order for weather effects to work properly.
If this texture comes after the real sky texture in the texture list, it will be incorrectly selected as the sky texture and thus causes the sky to break when
gl_texsort
is set to 1.

Technical Details

HLFixes resolves this by patching part of
R_NewMap
so that instead of calling
Q_strncmp
to determine if a texture starts with
sky
, it calls HLFixes.
HLFixes checks if the texture being checked is called
skycull
and prevents a match if it does. Otherwise, it calls
Q_strncmp
as normal.


Launch Options

Option Description
--no-fixes
Causes HLFixes to not apply any fixes.
--no-music-fix
Causes HLFixes to not apply music fixes.
--no-startup-music-fix
Causes HLFixes to not apply the main menu music fix.
--no-quicksave-fix
Causes HLFixes to not apply the quick save backup fix.
--no-overbright-fix
Causes HLFixes to not apply the overbright fix.
--no-sky-fix
Causes HLFixes to not apply the CZDS sky fix.
--no-startup-video-music-fix
Causes HLFixes to not apply the music playing during startup video fix.
--persist-music-in-mp
Allows music to continue playing between multiplayer level changes.
--no-multitexture
(Windows only) Prevents use of the OpenGL multitexture extension. May improve performance when using a poorly written graphics driver. Incompatible with
gl_use_shaders 1
.

Known Issues

Regarding VAC

While HLFixes is not a cheat, I would recommend disabling HLFixes before entering a VAC-secured server, just to be safe.



This can be done by putting

--no-fixes
in your launch options, or by uninstalling HLFixes through the installer.