This commit is contained in:
Blixibon
2020-06-21 10:13:29 -05:00
69 changed files with 1548 additions and 866 deletions
+2 -2
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" ) )
@@ -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();
+13 -5
View File
@@ -83,8 +83,6 @@ static const char *g_pszRPCNames[] = {
// There can be only one...for each RPC.
static EHANDLE g_Metadata[NUM_RPCS];
#define CMapbaseMetadata C_MapbaseMetadata
// Don't update constantly
#define RPC_UPDATE_COOLDOWN 5.0f
@@ -92,6 +90,10 @@ static EHANDLE g_Metadata[NUM_RPCS];
#define RPC_UPDATE_WAIT 0.25f
#endif
#ifdef CLIENT_DLL
#define CMapbaseMetadata C_MapbaseMetadata
#endif
class CMapbaseMetadata : public CBaseEntity
{
public:
@@ -101,6 +103,7 @@ public:
DECLARE_NETWORKCLASS();
DECLARE_CLASS( CMapbaseMetadata, CBaseEntity );
#ifdef MAPBASE_RPC
#ifdef CLIENT_DLL
~C_MapbaseMetadata()
{
@@ -174,15 +177,18 @@ public:
return SetTransmitState( FL_EDICT_ALWAYS );
}
#endif
#endif
#ifdef CLIENT_DLL
// Built-in update spam limiter
float m_flRPCUpdateTimer = RPC_UPDATE_COOLDOWN;
char m_iszRPCState[128];
char m_iszRPCDetails[128];
#ifdef MAPBASE_RPC
// Built-in update spam limiter
float m_flRPCUpdateTimer = RPC_UPDATE_COOLDOWN;
int m_spawnflags;
#endif
#else
CNetworkVar( string_t, m_iszRPCState );
CNetworkVar( string_t, m_iszRPCDetails );
@@ -198,6 +204,7 @@ IMPLEMENT_NETWORKCLASS_ALIASED(MapbaseMetadata, DT_MapbaseMetadata)
BEGIN_NETWORK_TABLE_NOBASE(CMapbaseMetadata, DT_MapbaseMetadata)
#ifdef MAPBASE_RPC
#ifdef CLIENT_DLL
RecvPropString(RECVINFO(m_iszRPCState)),
RecvPropString(RECVINFO(m_iszRPCDetails)),
@@ -207,6 +214,7 @@ BEGIN_NETWORK_TABLE_NOBASE(CMapbaseMetadata, DT_MapbaseMetadata)
SendPropStringT(SENDINFO(m_iszRPCDetails) ),
SendPropInt( SENDINFO(m_spawnflags), 8, SPROP_UNSIGNED ),
#endif
#endif
END_NETWORK_TABLE()
+15 -10
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
+17 -8
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