Skip to content
This repository was archived by the owner on May 10, 2026. It is now read-only.

gcc/Linux fixes - #71

Merged
hogsy merged 11 commits into
hogsy:masterfrom
z33ky:Invasion/gcc-linux
Feb 17, 2021
Merged

hogsy merged 11 commits into
hogsy:masterfrom
z33ky:Invasion/gcc-linux

Conversation

@z33ky

@z33ky z33ky commented Jan 30, 2021

Copy link
Copy Markdown

Hi,

I got this thing to compile and run on Linux. Mostly it's just fixing file paths, since in Linux that's usually case-sensitive.
There were a couple of compiler errors, mostly easy to fix, and I squashed a few warnings as well.

z33ky added 6 commits January 27, 2021 23:07
This crashes on Linux as pKeyValuesData is NULL when deleteThis() is
invoked. This likely is caused by another issue, but fixing this here
seems good regardless.
This is important for case-sensitive filesystems/operating systems (i.e.
Linux).
Print them using "%s" instead, so their contents are not accidentally
interpreted as format specifiers.

@z33ky z33ky left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of notes about changes that may look funny.
Feel free to ask if there are further changes that look questionable or something is still unclear.

@hogsy

hogsy commented Jan 30, 2021

Copy link
Copy Markdown
Owner

Thanks, I did a quick glance through the changes and everything looks pretty reasonable. I appreciate you took the time to clean up some other bits in there too from the looks of it.

I'll try to test this as soon as I can and will look to get it merged soon 👍

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A note to the changes here: The ## operator is for creating a singular token. In this instance, for example, pasting Create_ with className with ( will never create a valid singular token. Here two tokens are to be created: Create_##className (.
gcc is more strict than MSVC here in that it rejects the operation if pasting fails.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing a temporary via reference is only allowed for const&. gcc disallows doing that if the reference is not specified as const.
In most cases I simply changed the function parameters to include const, however since InputTurn{On,Off}() is used in multiple places I was a bit lazy to check if that's a reasonable change and opted to put the temporary in a variable instead.

Comment thread mp/src/game/server/props.cpp Outdated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CPropVehicleDriveable is not defined for this project, hence there is no type-info available to do the dynamic_cast with. I don't know what MSVC compiles this to, with gcc this results in a linker error due to missing symbol.
My best guess to implement this using CBaseTFVehicle is just below.

Comment thread mp/src/game/server/props.cpp Outdated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no macro specific to this project. I assume that other code has been changed with the assumption, that no other variant(/game) is compiled from this fork.
To cleanly separate mod-specific changes it may be a good idea to add such a macro though. TF_DLL is already taken, MOD_INVASION perhaps?
If you don't think this approach I can just #if 0 [old code] #else [new code] #endif, or flat out remove the irrelevant code.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I've not been concerned about seperating the mod-specific changes as I'm not expecting Valve to ever update the SDK at this stage - I'd prefer just to remove the irrelevant code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be interesting to merge other forks, like Mapbase (if it gets an MP port, mapbase-source#77).

Comment thread mp/src/public/mathlib/vector.h Outdated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving w uninitialized is problematic when the VectorAligned is copied, since uninitialized data would be read, which means undefined behavior occurs.
Perhaps w could just be removed, it seems totally unused. Maybe it's required for ALIGN16 to work right? It seemed safest to just initialize it with some dummy value.

Comment thread mp/src/public/tier1/utlsoacontainer.h Outdated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manual instantiation is unfortunate, but according to a gcc warning the __vector-specifier would get lost in the templated-code, meaning that (slow) unaligned access to the floats was used. By manually expanding CStridedPtr the compiler can emit the proper vectorized access instructions.
I don't know if MSVC actually just does carry over the specifiers or like the old gcc silently throws it away.

@z33ky
z33ky force-pushed the Invasion/gcc-linux branch from 6cf5449 to eddfeaa Compare January 30, 2021 17:20
@z33ky

z33ky commented Jan 30, 2021

Copy link
Copy Markdown
Author

I have a minor issue with font loading. For some reason the engine is unable to find the fonts ("Couldn't find custom font file") if they're three directories deep (e.g. "resource/fonts/Squada_One/").
It does work if I just copy the fonts in e.g. "resource/fonts". Would that be an acceptable change?

The class-selection menu is bugged for me; clicking the buttons does not work. Pressing "enter" will close it, without selecting a class. Afterwards I managed to change classes using the "changeclass" console command. I'm wondering, is this also broken on Windows? I'll probably take a look at what's going on there.

@hogsy

hogsy commented Jan 30, 2021

Copy link
Copy Markdown
Owner

I have a minor issue with font loading. For some reason the engine is unable to find the fonts ("Couldn't find custom font file") if they're three directories deep (e.g. "resource/fonts/Squada_One/").
It does work if I just copy the fonts in e.g. "resource/fonts". Would that be an acceptable change?

If you do, can you rename the OFL in the same directory to use the same name as the font? Basically squadaone-regular.txt rather than OFL.txt - just to keep it clear what license that particular font is under.

The class-selection menu is bugged for me; clicking the buttons does not work. Pressing "enter" will close it, without selecting a class. Afterwards I managed to change classes using the "changeclass" console command. I'm wondering, is this also broken on Windows? I'll probably take a look at what's going on there.

Both the team selection and class menus should work, so I'm not sure what's going on there.

@z33ky

z33ky commented Jan 31, 2021

Copy link
Copy Markdown
Author

If you do, can you rename the OFL in the same directory to use the same name as the font? Basically squadaone-regular.txt rather than OFL.txt - just to keep it clear what license that particular font is under.

Yeah sure.

Both the team selection and class menus should work, so I'm not sure what's going on there.

I figured out it's some undefined behavior in the VGUI code - also present in the upstream Source SDK. That bug just became apparent by using a newer compiler, probably some optimization which killed the intent.
I'm writing up a fix.

z33ky added 5 commits January 31, 2021 15:55
We don't use CPropVehicleDriveable. Instead we've got CBaseTFVehicle, so
check for that.
The HL2(MP) assets weren't being loaded correctly on Linux. I copied the
settings from the original Source SDK 2013 file, which fixed it.
This works around an engine bug that seems to exist for Linux, where
fonts are not found if three directories deep:
	Couldn't find custom font file 'resource/fonts/Squada_One/SquadaOne-Regular.ttf'
The button mask is created by shifting a bit according to the
MouseCode, which is just a renamed ButtonCode_t.
Mouse buttons start at 107, which is way out of range for our ints.

To fix this, introduce MouseButtonBit(), which checks if a button code
corresponds to a mouse button at all and returns a usable bitmask
for the corresponding mouse button code.
This is then used for the button mask.
@z33ky
z33ky force-pushed the Invasion/gcc-linux branch from eddfeaa to c860df4 Compare January 31, 2021 14:56
if(state)
{
//set bit to 1
_mouseClickMask|=1<<((int)(code+1));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why they did that +1 here. In MouseButtonBit() I use bit #0, which they may have wanted to avoid for some reason.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who knows, VGUI is a horrible poorly documented mess. If that resolves it I'm happy but should probably double check for regressions elsewhere before merge.

@hogsy
hogsy merged commit c860df4 into hogsy:master Feb 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants