Fix gcc 9/10 & mapbase build errors

This commit is contained in:
Alexander 'z33ky' Hirsch
2020-06-14 10:39:08 +02:00
parent 4d45c32be9
commit 9d0f5197bd
33 changed files with 267 additions and 204 deletions

View File

@@ -39,7 +39,7 @@ inline void DebugMsg(const tchar *pMsg, ...)
{
if (mapedit_debug.GetBool() == true)
{
Msg(pMsg);
Msg("%s", pMsg);
}
}
@@ -544,7 +544,7 @@ public:
else
{
DebugMsg("MapEdit Debug: File not NULL, loading %s\n", pFile);
Q_snprintf(szFullName,sizeof(szFullName), pFile);
Q_strncpy(szFullName, pFile, sizeof(szFullName));
}
KeyValues *pkvFile = new KeyValues( "MapEdit" );
if ( pkvFile->LoadFromFile( filesystem, szFullName, "MOD" ) )

View File

@@ -162,9 +162,9 @@ void MapbaseGameLog_Record( const char *szContext )
continue;
if ( pPlayer->GetActiveWeapon() == pWeapon )
pKVWeapons->SetString(pWeapon->GetClassname(), CFmtStrN<32>("%i; %i (active)", pWeapon->m_iClip1, pWeapon->m_iClip2));
pKVWeapons->SetString(pWeapon->GetClassname(), CFmtStrN<32>("%i; %i (active)", pWeapon->m_iClip1.Get(), pWeapon->m_iClip2.Get()));
else
pKVWeapons->SetString(pWeapon->GetClassname(), CFmtStrN<32>("%i; %i", pWeapon->m_iClip1, pWeapon->m_iClip2));
pKVWeapons->SetString(pWeapon->GetClassname(), CFmtStrN<32>("%i; %i", pWeapon->m_iClip1.Get(), pWeapon->m_iClip2.Get()));
}
}
@@ -209,7 +209,7 @@ void MapbaseGameLog_Record( const char *szContext )
}
}
CFmtStrN<MAX_PATH> pathfmt("map_logs/%s_log_%i.txt", gpGlobals->mapname, pGameLoggerEnt->m_iSaveID);
CFmtStrN<MAX_PATH> pathfmt("map_logs/%s_log_%i.txt", STRING(gpGlobals->mapname), pGameLoggerEnt->m_iSaveID);
pGameLoggerEnt->m_flLastLogTime = gpGlobals->curtime;
pGameLoggerEnt->m_iSaveID++;
@@ -219,7 +219,7 @@ void MapbaseGameLog_Record( const char *szContext )
if (pKV->SaveToFile( g_pFullFileSystem, pathfmt, "MOD" ))
{
Msg("Saved game log file to \"%s\"\n", pathfmt);
Msg("Saved game log file to \"%s\"\n", pathfmt.Get());
}
pKV->deleteThis();

View File

@@ -9,14 +9,20 @@
#include "matchers.h"
#include "fmtstr.h"
// glibc (Linux) uses these tokens when including <regex>, so we must not #define them
#undef max
#undef min
#include <regex>
#undef MINMAX_H
#include "minmax.h"
ConVar mapbase_wildcards_enabled("mapbase_wildcards_enabled", "1", FCVAR_NONE, "Toggles Mapbase's '?' wildcard and true '*' features. Useful for maps that have '?' in their targetnames.");
ConVar mapbase_regex_enabled("mapbase_regex_enabled", "1", FCVAR_NONE, "Toggles Mapbase's regex matching handover.");
#ifdef CLIENT_DLL
// FIXME: There is no clientside equivalent to the RS code
bool ResponseSystemCompare(const char *criterion, const char *value) { return Matcher_NamesMatch(criterion, value); }
static bool ResponseSystemCompare(const char *criterion, const char *value) { return Matcher_NamesMatch(criterion, value); }
#else
extern bool ResponseSystemCompare(const char *criterion, const char *value);
#endif
@@ -32,21 +38,20 @@ extern bool ResponseSystemCompare(const char *criterion, const char *value);
// AppearsToBeANumber - Response System-based function which checks if the string might be a number.
//=============================================================================
inline bool Matcher_Match(const char *pszQuery, const char *szValue)
bool Matcher_Match(const char *pszQuery, const char *szValue)
{
// I wasn't kidding when I said all this did was hijack response system matching.
return ResponseSystemCompare(pszQuery, szValue);
}
inline bool Matcher_Match(const char *pszQuery, int iValue) { return Matcher_Match(pszQuery, CNumStr(iValue)); }
inline bool Matcher_Match(const char *pszQuery, float flValue) { return Matcher_Match(pszQuery, CNumStr(flValue)); }
bool Matcher_Match(const char *pszQuery, int iValue) { return Matcher_Match(pszQuery, CNumStr(iValue)); }
bool Matcher_Match(const char *pszQuery, float flValue) { return Matcher_Match(pszQuery, CNumStr(flValue)); }
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------
// The recursive part of Mapbase's modified version of Valve's NamesMatch().
// This part is no longer inlined since it's recursive.
/*FORCEINLINE*/ bool Matcher_RunCharCompare(const char *pszQuery, const char *szValue)
bool Matcher_RunCharCompare(const char *pszQuery, const char *szValue)
{
// This matching model is based off of the ASW SDK
while ( *szValue && *pszQuery )
@@ -119,7 +124,7 @@ bool Matcher_Regex(const char *pszQuery, const char *szValue)
}
// The entry point for Mapbase's modified version of Valve's NamesMatch().
FORCEINLINE bool Matcher_NamesMatch(const char *pszQuery, const char *szValue)
bool Matcher_NamesMatch(const char *pszQuery, const char *szValue)
{
if ( szValue == NULL )
return (*pszQuery == 0 || *pszQuery == '*');
@@ -142,7 +147,7 @@ FORCEINLINE bool Matcher_NamesMatch(const char *pszQuery, const char *szValue)
return Matcher_RunCharCompare( pszQuery, szValue );
}
FORCEINLINE bool Matcher_NamesMatch_Classic(const char *pszQuery, const char *szValue)
bool Matcher_NamesMatch_Classic(const char *pszQuery, const char *szValue)
{
if ( szValue == NULL )
return (!pszQuery || *pszQuery == 0 || *pszQuery == '*');
@@ -178,7 +183,7 @@ FORCEINLINE bool Matcher_NamesMatch_Classic(const char *pszQuery, const char *sz
return false;
}
FORCEINLINE bool Matcher_NamesMatch_MutualWildcard(const char *pszQuery, const char *szValue)
bool Matcher_NamesMatch_MutualWildcard(const char *pszQuery, const char *szValue)
{
if ( szValue == NULL )
return (!pszQuery || *pszQuery == 0 || *pszQuery == '*');
@@ -219,7 +224,7 @@ FORCEINLINE bool Matcher_NamesMatch_MutualWildcard(const char *pszQuery, const c
// Matcher_Compare is a deprecated alias originally used when Matcher_Match didn't support wildcards.
/*
inline bool Matcher_Compare(const char *pszQuery, const char *szValue)
bool Matcher_Compare(const char *pszQuery, const char *szValue)
{
return Matcher_Match(pszQuery, szValue);
#if 0

View File

@@ -5,39 +5,46 @@
// $NoKeywords: $
//=============================================================================
#ifndef MAPBASE_MATCHERS_H
#define MAPBASE_MATCHERS_H
#ifdef _WIN32
#pragma once
#endif
#define MAPBASE_MATCHERS 1
// Compares with != and the like. Basically hijacks the response system matching.
// This also loops back around to Matcher_NamesMatch.
// pszQuery = The value that should have the operator(s) at the beginning.
// szValue = The value tested against the criterion.
extern bool Matcher_Match( const char *pszQuery, const char *szValue );
extern bool Matcher_Match( const char *pszQuery, int iValue );
extern bool Matcher_Match( const char *pszQuery, float flValue );
bool Matcher_Match( const char *pszQuery, const char *szValue );
bool Matcher_Match( const char *pszQuery, int iValue );
bool Matcher_Match( const char *pszQuery, float flValue );
// Regular expressions based off of the std library.
// pszQuery = The regex text.
// szValue = The value that should be matched.
extern bool Matcher_Regex( const char *pszQuery, const char *szValue );
bool Matcher_Regex( const char *pszQuery, const char *szValue );
// Compares two strings with support for wildcards or regex. This code is an expanded version of baseentity.cpp's NamesMatch().
// pszQuery = The value that should have the wildcard.
// szValue = The value tested against the query.
// Use Matcher_Match if you want <, !=, etc. as well.
extern bool Matcher_NamesMatch( const char *pszQuery, const char *szValue );
bool Matcher_NamesMatch( const char *pszQuery, const char *szValue );
// Identical to baseentity.cpp's original NamesMatch().
// pszQuery = The value that should have the wildcard.
// szValue = The value tested against the query.
extern bool Matcher_NamesMatch_Classic( const char *pszQuery, const char *szValue );
bool Matcher_NamesMatch_Classic( const char *pszQuery, const char *szValue );
// Identical to Matcher_NamesMatch_Classic(), but either value could use a wildcard.
// pszQuery = The value that serves as the query. This value can use wildcards.
// szValue = The value tested against the query. This value can use wildcards as well.
extern bool Matcher_NamesMatch_MutualWildcard( const char *pszQuery, const char *szValue );
bool Matcher_NamesMatch_MutualWildcard( const char *pszQuery, const char *szValue );
// Deprecated; do not use
inline bool Matcher_Compare( const char *pszQuery, const char *szValue ) { return Matcher_Match( pszQuery, szValue ); }
static inline bool Matcher_Compare( const char *pszQuery, const char *szValue ) { return Matcher_Match( pszQuery, szValue ); }
// Taken from the Response System.
// Checks if the specified string appears to be a number of some sort.
@@ -57,3 +64,5 @@ static bool AppearsToBeANumber( char const *token )
return true;
}
#endif