Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# ==============================================================================
# Minimalist Clang-Format Configuration (Baseline)
# ==============================================================================
# ==============================================================================
# CUSTOM CLANG-FORMAT OFF FLAGS
# When disabling clang-format, please use one of the following standard flags
# to explain why, making it easier to search and maintain the codebase:
#
# Usage: // clang-format off: [FLAG_NAME] - optional details
#
# Available Flags:
# [LEGACY_VC6] - For strict C++03 / VC6 compiler compatibility.
# [MACRO_COMPACT] - To prevent concise macros from multi-line wrapping.
# [MACRO_INDENT] - When the formatter messes up a macro's internal indentation.
# [TABLE_ALIGN] - For matrices, lookup tables, and 2D arrays alignment.
# [MATH_ALIGN] - For preserving manual spaces in complex math/logic formulas.
# [X_MACRO] - For structured X-Macro lists.
# [INLINE_ASM] - For preserving inline assembly instruction formatting.
# [BITFIELD_ALIGN] - For aligning bitfield sizes (:) in structs / hardware maps.
# [BITMASK_ALIGN] - For visual alignment of bitwise operations and bit flags.
# ==============================================================================
Language: Cpp
Standard: c++20
Comment thread
DevGeniusCode marked this conversation as resolved.

# 1. Non-Destructive Core Setting
# ------------------------------------------------------------------------------
# Completely disable automatic line wrapping to preserve manual formatting.
ColumnLimit: 0
Comment thread
greptile-apps[bot] marked this conversation as resolved.

# 2. Indentation & Tabs
# ------------------------------------------------------------------------------
UseTab: AlignWithSpaces
IndentWidth: 2
TabWidth: 2
ContinuationIndentWidth: 2
AccessModifierOffset: -2
IndentCaseLabels: true
AlignTrailingComments: false
SpacesBeforeTrailingComments: 4

# 3. Braces Style: Allman
# ------------------------------------------------------------------------------
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
AllowShortEnumsOnASingleLine: false

# 4. Pointers & Spaces
# ------------------------------------------------------------------------------
PointerAlignment: Left
SpacesInParentheses: false
BreakConstructorInitializers: BeforeComma

# 5. Legacy & Compatibility (VC6 / Custom Macros)
# ------------------------------------------------------------------------------
# Prevent expanding/collapsing short blocks and functions to minimize diffs
AllowShortFunctionsOnASingleLine: All
AllowShortBlocksOnASingleLine: Always
Comment thread
DevGeniusCode marked this conversation as resolved.
AlignEscapedNewlines: Left

# Handle custom legacy macros so the parser doesn't break
Macros:
- CPP_11(x)=x

IndentPPDirectives: BeforeHash
ConstructorInitializerIndentWidth: 2

# 6. Includes
# ------------------------------------------------------------------------------
SortIncludes: false
2 changes: 1 addition & 1 deletion Core/GameEngine/Include/Common/AddonCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ namespace addon
{
extern Bool HasFullviewportDat();

} // namespace addon
} // namespace addon
40 changes: 20 additions & 20 deletions Core/GameEngine/Include/Common/ArchiveFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
class File;

/**
* An archive file is itself a collection of sub files. Each file inside the archive file
* has a unique name by which it can be accessed. The ArchiveFile object class is the
* runtime interface to the mix file and the sub files. Each file inside the mix
* file can be accessed by the openFile().
*
* ArchiveFile interfaces can be created by the TheArchiveFileSystem object.
*/
* An archive file is itself a collection of sub files. Each file inside the archive file
* has a unique name by which it can be accessed. The ArchiveFile object class is the
* runtime interface to the mix file and the sub files. Each file inside the mix
* file can be accessed by the openFile().
*
* ArchiveFile interfaces can be created by the TheArchiveFileSystem object.
*/
//===============================

class ArchiveFile
Expand All @@ -50,23 +50,23 @@ class ArchiveFile
ArchiveFile();
virtual ~ArchiveFile();

virtual Bool getFileInfo( const AsciiString& filename, FileInfo *fileInfo) const = 0; ///< fill in the fileInfo struct with info about the file requested.
virtual File* openFile( const Char *filename, Int access = 0) = 0; ///< Open the specified file within the archive file
virtual void closeAllFiles() = 0; ///< Close all file opened in this archive file
virtual AsciiString getName() = 0; ///< Returns the name of the archive file
virtual AsciiString getPath() = 0; ///< Returns full path and name of archive file
virtual void setSearchPriority( Int new_priority ) = 0; ///< Set this archive file's search priority
virtual void close() = 0; ///< Close this archive file
void attachFile(File *file);
virtual Bool getFileInfo(const AsciiString& filename, FileInfo* fileInfo) const = 0; ///< fill in the fileInfo struct with info about the file requested.
virtual File* openFile(const Char* filename, Int access = 0) = 0; ///< Open the specified file within the archive file
virtual void closeAllFiles() = 0; ///< Close all file opened in this archive file
virtual AsciiString getName() = 0; ///< Returns the name of the archive file
virtual AsciiString getPath() = 0; ///< Returns full path and name of archive file
virtual void setSearchPriority(Int new_priority) = 0; ///< Set this archive file's search priority
virtual void close() = 0; ///< Close this archive file
void attachFile(File* file);

void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const;
void getFileListInDirectory(const DetailedArchivedDirectoryInfo *dirInfo, const AsciiString& currentDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const;
void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList& filenameList, Bool searchSubdirectories) const;
void getFileListInDirectory(const DetailedArchivedDirectoryInfo* dirInfo, const AsciiString& currentDirectory, const AsciiString& searchName, FilenameList& filenameList, Bool searchSubdirectories) const;

void addFile(const AsciiString& path, const ArchivedFileInfo *fileInfo); ///< add this file to our directory tree.
void addFile(const AsciiString& path, const ArchivedFileInfo* fileInfo); ///< add this file to our directory tree.

protected:
const ArchivedFileInfo * getArchivedFileInfo(const AsciiString& filename) const; ///< return the ArchivedFileInfo from the directory tree.
const ArchivedFileInfo* getArchivedFileInfo(const AsciiString& filename) const; ///< return the ArchivedFileInfo from the directory tree.

File *m_file; ///< file pointer to the archive file on disk. Kept open so we don't have to continuously open and close the file all the time.
File* m_file; ///< file pointer to the archive file on disk. Kept open so we don't have to continuously open and close the file all the time.
DetailedArchivedDirectoryInfo m_rootDirectory;
};
69 changes: 34 additions & 35 deletions Core/GameEngine/Include/Common/ArchiveFileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

#include "Common/SubsystemInterface.h"
#include "Common/AsciiString.h"
#include "Common/FileSystem.h" // for typedefs, etc.
#include "Common/FileSystem.h" // for typedefs, etc.
#include "Common/STLTypedefs.h"

//----------------------------------------------------------------------------
Expand All @@ -65,43 +65,42 @@ class ArchiveFile;
// Type Defines
//----------------------------------------------------------------------------


//===============================
// ArchiveFileSystem
//===============================
/**
* Creates and manages ArchiveFile interfaces. ArchiveFiles can be accessed
* by calling the openArchiveFile() member. ArchiveFiles can be accessed by
* name or by File interface.
*
* openFile() member searches all Archive files for the specified sub file.
*/
* Creates and manages ArchiveFile interfaces. ArchiveFiles can be accessed
* by calling the openArchiveFile() member. ArchiveFiles can be accessed by
* name or by File interface.
*
* openFile() member searches all Archive files for the specified sub file.
*/
//===============================
class ArchivedDirectoryInfo;
class DetailedArchivedDirectoryInfo;
class ArchivedFileInfo;

typedef std::map<AsciiString, DetailedArchivedDirectoryInfo> DetailedArchivedDirectoryInfoMap; // Archived directory name to detailed archived directory info
typedef std::map<AsciiString, ArchivedDirectoryInfo> ArchivedDirectoryInfoMap; // Archived directory name to archived directory info
typedef std::map<AsciiString, ArchivedFileInfo> ArchivedFileInfoMap; // Archived file name to archived file info
typedef std::map<AsciiString, ArchiveFile *> ArchiveFileMap; // Archive file name to archive data
typedef std::multimap<AsciiString, ArchiveFile *> ArchivedFileLocationMap; // Archived file name to archive data
typedef std::map<AsciiString, DetailedArchivedDirectoryInfo> DetailedArchivedDirectoryInfoMap; // Archived directory name to detailed archived directory info
typedef std::map<AsciiString, ArchivedDirectoryInfo> ArchivedDirectoryInfoMap; // Archived directory name to archived directory info
typedef std::map<AsciiString, ArchivedFileInfo> ArchivedFileInfoMap; // Archived file name to archived file info
typedef std::map<AsciiString, ArchiveFile*> ArchiveFileMap; // Archive file name to archive data
typedef std::multimap<AsciiString, ArchiveFile*> ArchivedFileLocationMap; // Archived file name to archive data

class ArchivedDirectoryInfo
{
public:
AsciiString m_path; // The full path to this directory
AsciiString m_directoryName; // The current directory
ArchivedDirectoryInfoMap m_directories; // Contained leaf directories
ArchivedFileLocationMap m_files; // Contained files
AsciiString m_path; // The full path to this directory
AsciiString m_directoryName; // The current directory
ArchivedDirectoryInfoMap m_directories; // Contained leaf directories
ArchivedFileLocationMap m_files; // Contained files
};

class DetailedArchivedDirectoryInfo
{
public:
AsciiString m_directoryName;
DetailedArchivedDirectoryInfoMap m_directories;
ArchivedFileInfoMap m_files;
AsciiString m_directoryName;
DetailedArchivedDirectoryInfoMap m_directories;
ArchivedFileInfoMap m_files;
};

class ArchivedFileInfo
Expand All @@ -119,7 +118,6 @@ class ArchivedFileInfo
}
};


class ArchiveFileSystem : public SubsystemInterface
{
public:
Expand All @@ -132,19 +130,19 @@ class ArchiveFileSystem : public SubsystemInterface
virtual void postProcessLoad() = 0;

// ArchiveFile operations
virtual ArchiveFile* openArchiveFile( const Char *filename ) = 0; ///< Create new or return existing Archive file from file name
virtual void closeArchiveFile( const Char *filename ) = 0; ///< Close the one specified big file.
virtual void closeAllArchiveFiles() = 0; ///< Close all Archive files currently open
virtual ArchiveFile* openArchiveFile(const Char* filename) = 0; ///< Create new or return existing Archive file from file name
virtual void closeArchiveFile(const Char* filename) = 0; ///< Close the one specified big file.
virtual void closeAllArchiveFiles() = 0; ///< Close all Archive files currently open

// File operations
virtual File* openFile( const Char *filename, Int access = 0, FileInstance instance = 0); ///< Search Archive files for specified file name and open it if found
virtual void closeAllFiles() = 0; ///< Close all files associated with Archive files
virtual Bool doesFileExist(const Char *filename, FileInstance instance = 0) const; ///< return true if that file exists in an archive file somewhere.
virtual File* openFile(const Char* filename, Int access = 0, FileInstance instance = 0); ///< Search Archive files for specified file name and open it if found
virtual void closeAllFiles() = 0; ///< Close all files associated with Archive files
virtual Bool doesFileExist(const Char* filename, FileInstance instance = 0) const; ///< return true if that file exists in an archive file somewhere.

void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. Scans each Archive file.
Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo, FileInstance instance = 0) const; ///< see FileSystem.h
void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList& filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. Scans each Archive file.
Bool getFileInfo(const AsciiString& filename, FileInfo* fileInfo, FileInstance instance = 0) const; ///< see FileSystem.h

virtual Bool loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite = FALSE) = 0;
virtual Bool loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite = FALSE) = 0;

// Unprotected this for copy-protection routines
ArchiveFile* getArchiveFile(const AsciiString& filename, FileInstance instance = 0) const;
Expand All @@ -156,23 +154,24 @@ class ArchiveFileSystem : public SubsystemInterface
protected:
struct ArchivedDirectoryInfoResult
{
ArchivedDirectoryInfoResult() : dirInfo(nullptr) {}
ArchivedDirectoryInfoResult()
: dirInfo(nullptr)
{}
Bool valid() const { return dirInfo != nullptr; }

ArchivedDirectoryInfo* dirInfo;
AsciiString lastToken; ///< Synonymous for file name if the search directory was a file path
AsciiString lastToken; ///< Synonymous for file name if the search directory was a file path
};

ArchivedDirectoryInfoResult getArchivedDirectoryInfo(const Char* directory);

virtual void loadIntoDirectoryTree(ArchiveFile *archiveFile, Bool overwrite = FALSE); ///< load the archive file's header information and apply it to the global archive directory tree.
virtual void loadIntoDirectoryTree(ArchiveFile* archiveFile, Bool overwrite = FALSE); ///< load the archive file's header information and apply it to the global archive directory tree.

ArchiveFileMap m_archiveFileMap;
ArchivedDirectoryInfo m_rootDirectory;
};


extern ArchiveFileSystem *TheArchiveFileSystem;
extern ArchiveFileSystem* TheArchiveFileSystem;

//----------------------------------------------------------------------------
// Inlining
Expand Down
Loading
Loading