Skip to content

Commit a2dc7b9

Browse files
committed
repo: some cleanup
1 parent 163be06 commit a2dc7b9

File tree

3 files changed

+9
-128
lines changed

3 files changed

+9
-128
lines changed

source/modules/entitylist.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ LUA_FUNCTION_STATIC(GetGlobalEntityList)
242242
void CEntListModule::OnEntityDeleted(CBaseEntity* pEntity)
243243
{
244244
if (g_pEntListModule.InDebug())
245-
Msg("Deleted Entity: %p (%i)\n", pEntity, pEntityLists.size());
245+
Msg("Deleted Entity: %p (%i)\n", pEntity, (int)pEntityLists.size());
246246

247247
for (EntityList* pList : pEntityLists)
248248
{
@@ -261,7 +261,7 @@ void CEntListModule::OnEntityCreated(CBaseEntity* pEntity)
261261
g_pGlobalEntityList.AddEntity(pEntity);
262262

263263
if (g_pEntListModule.InDebug())
264-
Msg("Created Entity %p (%p, %i)\n", pEntity, &g_pGlobalEntityList, pEntityLists.size());
264+
Msg("Created Entity %p (%p, %i)\n", pEntity, &g_pGlobalEntityList, (int)pEntityLists.size());
265265
}
266266

267267
void CEntListModule::LuaInit(bool bServerInit)

source/modules/filesystem.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ static void DumpSearchCacheCmd(const CCommand& args)
525525
{
526526
for (auto& [key, val] : g_pAbsoluteSearchCache)
527527
{
528-
Msg("Key: %s (%i)\nValue: %s (%i)\n", key.data(), key.length(), val.data(), val.length());
528+
Msg("Key: %s (%i)\nValue: %s (%i)\n", key.data(), (int)key.length(), val.data(), (int)val.length());
529529
}
530530
}
531531
static ConCommand dumpabsolutesearchcache("holylib_filesystem_dumpabsolutesearchcache", DumpSearchCacheCmd, "Dumps the absolute search cache", 0);
@@ -1647,6 +1647,12 @@ void CFileSystemModule::Init(CreateInterfaceFn* appfn, CreateInterfaceFn* gamefn
16471647
static CUtlSymbolTableMT* g_pPathIDTable;
16481648
inline const char* CPathIDInfo::GetPathIDString() const
16491649
{
1650+
/*
1651+
* Why don't we return m_pDebugPathID to not rely on g_pPathIDTable?
1652+
* Because then in RARE cases it can happen that m_pDebugPathID contains a INVALID value causing random and difficult to debug crashes.
1653+
* This had happen in https://github.com/RaphaelIT7/gmod-holylib/issues/23 where it would result in crashes inside strlen calls on the string.
1654+
*/
1655+
16501656
return g_pPathIDTable->String( m_PathID );
16511657
}
16521658

@@ -1664,24 +1670,6 @@ inline const char* CSearchPath::GetPathString() const
16641670
return func_CBaseFileSystem_CSearchPath_GetDebugString((void*)this); // Look into this to possibly remove the GetDebugString function.
16651671
}
16661672

1667-
inline const char* CBaseFileSystem::CPathIDInfo::GetPathIDString() const
1668-
{
1669-
return m_pDebugPathID; // This should remove the requirement for g_pPathIDTable.
1670-
}
1671-
1672-
inline const char* CBaseFileSystem::CSearchPath::GetPathIDString() const // Remove this duplicate later :<
1673-
{
1674-
if (m_pPathIDInfo)
1675-
return m_pPathIDInfo->GetPathIDString(); // When can we nuke it :>
1676-
1677-
return NULL;
1678-
}
1679-
1680-
inline const char* CBaseFileSystem::CSearchPath::GetPathString() const
1681-
{
1682-
return func_CBaseFileSystem_CSearchPath_GetDebugString((void*)this); // Look into this to possibly remove the GetDebugString function.
1683-
}
1684-
16851673
void CFileSystemModule::InitDetour(bool bPreServer)
16861674
{
16871675
if (!bPreServer)

source/sourcesdk/filesystem_things.h

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -700,117 +700,10 @@ abstract_class CBaseFileSystem : public CTier1AppSystem< IFileSystem >
700700
// Unregister a CMemoryFileBacking; must balance with RegisterMemoryFile.
701701
virtual void UnregisterMemoryFile( CMemoryFileBacking *pFile );
702702

703-
//------------------------------------
704-
// Synchronous path for file operations
705-
//------------------------------------
706-
class CPathIDInfo
707-
{
708-
public:
709-
CPathIDInfo() : m_bByRequestOnly(), m_pDebugPathID() {}
710-
const CUtlSymbol& GetPathID() const;
711-
const char* GetPathIDString() const;
712-
void SetPathID( CUtlSymbol id );
713-
714-
public:
715-
// See MarkPathIDByRequestOnly.
716-
bool m_bByRequestOnly;
717-
718-
public:
719-
CUtlSymbol m_PathID;
720-
const char *m_pDebugPathID;
721-
};
722-
723703
////////////////////////////////////////////////
724704
// IMPLEMENTATION DETAILS FOR CBaseFileSystem //
725705
////////////////////////////////////////////////
726706

727-
class CSearchPath
728-
{
729-
public:
730-
CSearchPath( void );
731-
~CSearchPath( void );
732-
733-
const char* GetPathString() const;
734-
const char* GetDebugString() const;
735-
736-
// Path ID ("game", "mod", "gamebin") accessors.
737-
const CUtlSymbol& GetPathID() const;
738-
const char* GetPathIDString() const;
739-
740-
// Search path (c:\hl2\hl2) accessors.
741-
void SetPath( CUtlSymbol id );
742-
const CUtlSymbol& GetPath() const;
743-
744-
void SetPackFile(CPackFile *pPackFile) { m_pPackFile = pPackFile; }
745-
CPackFile *GetPackFile() const { return m_pPackFile; }
746-
747-
#ifdef SUPPORT_PACKED_STORE
748-
void SetPackedStore( CPackedStoreRefCount *pPackedStore ) { /*m_pPackedStore = pPackedStore;*/ }
749-
#endif
750-
CPackedStoreRefCount *GetPackedStore() const { return m_pPackedStore; }
751-
752-
bool IsMapPath() const;
753-
754-
int m_storeId;
755-
756-
// Used to track if its search
757-
CPathIDInfo *m_pPathIDInfo;
758-
759-
bool m_bIsRemotePath;
760-
761-
bool m_bIsTrustedForPureServer;
762-
763-
private:
764-
CUtlSymbol m_Path;
765-
const char *m_pDebugPath;
766-
CPackFile *m_pPackFile;
767-
CPackedStoreRefCount *m_pPackedStore;
768-
};
769-
770-
class CSearchPathsVisits
771-
{
772-
public:
773-
void Reset()
774-
{
775-
m_Visits.RemoveAll();
776-
}
777-
778-
bool MarkVisit( const CSearchPath &searchPath )
779-
{
780-
if ( m_Visits.Find( searchPath.m_storeId ) == m_Visits.InvalidIndex() )
781-
{
782-
MEM_ALLOC_CREDIT();
783-
m_Visits.AddToTail( searchPath.m_storeId );
784-
return false;
785-
}
786-
return true;
787-
}
788-
789-
private:
790-
CUtlVector<int> m_Visits; // This is a copy of IDs for the search paths we've visited, so
791-
};
792-
793-
class CSearchPathsIterator
794-
{
795-
public:
796-
CSearchPath *GetFirst();
797-
CSearchPath *GetNext();
798-
799-
private:
800-
CSearchPathsIterator( const CSearchPathsIterator & );
801-
void operator=(const CSearchPathsIterator &);
802-
void CopySearchPaths( const CUtlVector<CSearchPath> &searchPaths );
803-
804-
int m_iCurrent;
805-
CUtlSymbol m_pathID;
806-
CUtlVector<CSearchPath> m_SearchPaths;
807-
CSearchPathsVisits m_visits;
808-
CSearchPath m_EmptySearchPath;
809-
CPathIDInfo m_EmptyPathIDInfo;
810-
PathTypeFilter_t m_PathTypeFilter;
811-
char m_Filename[MAX_PATH]; // set for relative names only
812-
};
813-
814707
friend class CSearchPathsIterator;
815708

816709
struct FindData_t

0 commit comments

Comments
 (0)