-
Notifications
You must be signed in to change notification settings - Fork 5
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
gcc/Linux fixes #71
gcc/Linux fixes #71
Conversation
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.
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.
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.
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 👍 |
@@ -23,13 +23,13 @@ namespace vgui | |||
} | |||
|
|||
#define DECLARE_HINTITEMFACTORY( className ) \ | |||
CHintItemBase *Create_##className##( vgui::Panel *parent, const char *panelName ) \ |
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.
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.
@@ -472,7 +472,8 @@ void CBaseTFFourWheelVehicle::PlayerControlInit( CBasePlayer *pPlayer ) | |||
pPlayer->SetViewOffset( vec3_origin ); | |||
|
|||
m_playerOn.FireOutput( pPlayer, this, 0 ); | |||
InputTurnOn( inputdata_t() ); | |||
inputdata_t inputdata; |
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.
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.
mp/src/game/server/props.cpp
Outdated
@@ -1611,6 +1618,7 @@ void CBreakableProp::Break( CBaseEntity *pBreaker, const CTakeDamageInfo &info ) | |||
{ | |||
bSmashed = true; | |||
} | |||
#ifndef TF_DLL | |||
else if ( pBreaker && dynamic_cast< CPropVehicleDriveable * >( pBreaker ) ) |
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.
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.
mp/src/game/server/props.cpp
Outdated
@@ -40,7 +40,13 @@ | |||
#include "doors.h" | |||
#include "physics_collisionevent.h" | |||
#include "gamestats.h" | |||
#define TF_DLL //FIXME |
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.
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.
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.
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.
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 may be interesting to merge other forks, like Mapbase (if it gets an MP port, mapbase-source#77).
@@ -374,8 +374,9 @@ class TableVector | |||
class ALIGN16 VectorAligned : public Vector | |||
{ | |||
public: | |||
inline VectorAligned(void) {}; | |||
inline VectorAligned(void):w(0) {}; |
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.
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.
@@ -109,6 +109,95 @@ template<class T> class CStridedConstPtr | |||
} | |||
}; | |||
|
|||
class CFltx4StridedPtr |
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.
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.
6cf5449
to
eddfeaa
Compare
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/"). 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. |
If you do, can you rename the OFL in the same directory to use the same name as the font? Basically
Both the team selection and class menus should work, so I'm not sure what's going on there. |
Yeah sure.
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. |
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.
eddfeaa
to
c860df4
Compare
@@ -695,12 +695,12 @@ void Button::SetMouseClickEnabled(MouseCode code,bool state) | |||
if(state) | |||
{ | |||
//set bit to 1 | |||
_mouseClickMask|=1<<((int)(code+1)); |
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.
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.
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.
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.
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.