Half-Life: MMod was released just few hours ago.
Of course, I wouldn't be myself if I wasn't tried to run this mod under Xash. Moreover, mod author released a Linux port, so I don't even need to reboot to Windows or play with Wine.
First run was... almost fine if there wasn't a RED RECTANGLE OVER MY WHOLE SCREEN. I know that this can happen because of invalid HUD sprites drawing. My beloved GDB showed me a NULL pointer instead of sprite model pointer due to invalid HUD sprite index.
So I checked hud.txt, it was fine. I checked how mod runs under GoldSrc, it was fine. I ran GoldSrc under GDB and invalid index was there as well.
So I fired up Ghidra, found a function that's used to set HUD sprite model, and found out that it checks for valid index before sprite model pointer is set. I implemented similar check in Xash and BIG RED RECTANGLE was gone.
=================
But the red rectangle wasn't the only bug I fixed this night. This mod loves to showcase custom animations and cool particle effects and dlights. One of such features: our character legs in first person, was just gone.
I switched back to Ghidra and GoldSrc I left under GDB, traced all "hl1mmod_visuals_drawlegs" variable checks and after quick GDB session I found it's unusual technique to draw these legs: it's third person mode! But not actually.
The engine, before adding our player to the render list, checks if we're in third person mode. So mod author added a temporary variable, that's set to true at the beginning of each frame, and depending on its value in CL_IsThirdPerson it "lies" to the engine that we're in third person mode so our player model should be drawn but in the AddEntity call, it checks if engine was tricked and sets the variable to zero, so further Is Third Person checks are actually false.
In Xash the order of calling AddEntity and IsThirdPerson was swapped. I swapped it back and removed an additional check in the renderer, and was able to see the legs.
Thus, the current "master" version of Xash3D FWGS now runs this mod almost perfectly.
Of course, I wouldn't be myself if I wasn't tried to run this mod under Xash. Moreover, mod author released a Linux port, so I don't even need to reboot to Windows or play with Wine.
First run was... almost fine if there wasn't a RED RECTANGLE OVER MY WHOLE SCREEN. I know that this can happen because of invalid HUD sprites drawing. My beloved GDB showed me a NULL pointer instead of sprite model pointer due to invalid HUD sprite index.
So I checked hud.txt, it was fine. I checked how mod runs under GoldSrc, it was fine. I ran GoldSrc under GDB and invalid index was there as well.
So I fired up Ghidra, found a function that's used to set HUD sprite model, and found out that it checks for valid index before sprite model pointer is set. I implemented similar check in Xash and BIG RED RECTANGLE was gone.
=================
But the red rectangle wasn't the only bug I fixed this night. This mod loves to showcase custom animations and cool particle effects and dlights. One of such features: our character legs in first person, was just gone.
I switched back to Ghidra and GoldSrc I left under GDB, traced all "hl1mmod_visuals_drawlegs" variable checks and after quick GDB session I found it's unusual technique to draw these legs: it's third person mode! But not actually.
The engine, before adding our player to the render list, checks if we're in third person mode. So mod author added a temporary variable, that's set to true at the beginning of each frame, and depending on its value in CL_IsThirdPerson it "lies" to the engine that we're in third person mode so our player model should be drawn but in the AddEntity call, it checks if engine was tricked and sets the variable to zero, so further Is Third Person checks are actually false.
In Xash the order of calling AddEntity and IsThirdPerson was swapped. I swapped it back and removed an additional check in the renderer, and was able to see the legs.
Thus, the current "master" version of Xash3D FWGS now runs this mod almost perfectly.