Changes

Jump to navigation Jump to search
1,609 bytes added ,  00:21, 1 July 2017
Added basic data types
Line 1: Line 1:  
This page details the technical '''inner workings of ManiaPlanet''' (and the original TrackMania). It describes the game's classes, data structures and functions, and is as such geared towards reverse engineers and programmers.
 
This page details the technical '''inner workings of ManiaPlanet''' (and the original TrackMania). It describes the game's classes, data structures and functions, and is as such geared towards reverse engineers and programmers.
 +
 +
== Basic data types ==
 +
Nadeo uses its own primitive data types in its game engine. Since they can't be reversed, they are not used on this page and are listed here only for the sake of completeness.
 +
 +
typedef int Integer;
 +
typedef unsigned int Bool;
 +
typedef unsigned char Nat8;
 +
typedef unsigned short Nat16;
 +
typedef unsigned int Natural, Nat32;
 +
typedef unsigned __int64 Nat64;
 +
typedef float Real, Real32;
    
== Basic data structures ==
 
== Basic data structures ==
Line 679: Line 690:  
  class CSystemFid : public CMwNod          // Base class for files
 
  class CSystemFid : public CMwNod          // Base class for files
 
  {
 
  {
 +
public:
 +
    int ArchiveHeaderUserData(CClassicArchive *);        // Reads or writes header user data
 +
    void BuildHeaderUserData(CSystemArchiveNod const &);  // Prepares the header chunk data for writing
 +
 +
private:
 +
    int HeaderUserDataCreateFromArchive(CClassicArchive *, unsigned long size);  // Reads the header chunk data
 +
 
  private:
 
  private:
 
     int unknown0;
 
     int unknown0;
Line 761: Line 779:  
     virtual CFastStringInt const * GetFileName(void);
 
     virtual CFastStringInt const * GetFileName(void);
 
   
 
   
     int ReadAll(void *, unsigned long);
+
     int ReadAll(void * data, unsigned long size);       // Reads the specified number of bytes
     int WriteAll(void const *, unsigned long);
+
     int WriteAll(void const * data, unsigned long size); // Writes the specified number of bytes
 
   
 
   
 
     CClassicBufferMemory * CreateUncompressedBlock(void);
 
     CClassicBufferMemory * CreateUncompressedBlock(void);
Line 923: Line 941:  
   
 
   
 
     void ReadData(void *, unsigned long);
 
     void ReadData(void *, unsigned long);
     void ReadBool(int *, unsigned long);
+
     void ReadBool(bool *, unsigned long);
 
     void ReadMask(unsigned long *, unsigned long);
 
     void ReadMask(unsigned long *, unsigned long);
 
     void ReadNat8(unsigned char *, unsigned long, int);
 
     void ReadNat8(unsigned char *, unsigned long, int);
Line 936: Line 954:  
   
 
   
 
     void WriteData(void const *, unsigned long);
 
     void WriteData(void const *, unsigned long);
     void WriteBool(int const *, unsigned long);
+
     void WriteBool(bool const *, unsigned long);
 
     void WriteMask(unsigned long const *, unsigned long);
 
     void WriteMask(unsigned long const *, unsigned long);
 
     void WriteNat8(unsigned char const *, unsigned long, int);
 
     void WriteNat8(unsigned char const *, unsigned long, int);
Line 948: Line 966:  
     void WriteString(CFastStringInt const *, unsigned long);
 
     void WriteString(CFastStringInt const *, unsigned long);
 
   
 
   
     void DoMarker(char const *); // Reads or writes markup, like <Thumbnail.jpg> or </Thumbnail.jpg>
+
     void DoMarker(char const *); // Reads or writes markup, like <Thumbnail.jpg> or </Thumbnail.jpg>
     void DoData(void *, unsigned long count); // Reads or writes the specified number of bytes
+
     void DoData(void *, unsigned long count); // Reads or writes the specified number of bytes
     void DoBool(int *, unsigned long count); // Reads or writes a truth value
+
     void DoBool(bool *, unsigned long count); // Reads or writes a truth value
     void DoMask(unsigned long *, unsigned long count); // Reads or writes a hex value (typically a class ID)
+
     void DoMask(unsigned long *, unsigned long count); // Reads or writes a hex value (typically a class ID)
 
     void DoNat8(unsigned char *, unsigned long count, int isHex);
 
     void DoNat8(unsigned char *, unsigned long count, int isHex);
 
     void DoNat16(unsigned short *, unsigned long count, int isHex);
 
     void DoNat16(unsigned short *, unsigned long count, int isHex);
Line 964: Line 982:  
     void DoStringI18nComment(CFastStringInt *, char const *);
 
     void DoStringI18nComment(CFastStringInt *, char const *);
 
   
 
   
     void SkipData(unsigned long);
+
     void SkipData(unsigned long); // Writes the specified number of zeros, or calls CClassicBuffer::Skip() while reading
 
   
 
   
 
     static void (__cdecl* s_ThrowCorruptedArchive)(void);
 
     static void (__cdecl* s_ThrowCorruptedArchive)(void);
Line 970: Line 988:  
   
 
   
 
  protected:
 
  protected:
     int ReadLine(void);
+
     int ReadLine(void);   // Reads data from a .gbx file in text format
     void WriteLine(void);
+
     void WriteLine(void); // Writes data to a .gbx file in text format
 
   
 
   
 
     static void (__cdecl* s_DeleteMwIdUserDataCallBack)(CClassicArchive *);
 
     static void (__cdecl* s_DeleteMwIdUserDataCallBack)(CClassicArchive *);
Line 1,003: Line 1,021:  
     int InsertExternalLocations(CSystemFids *, CFastBuffer<CSystemFids *> *);
 
     int InsertExternalLocations(CSystemFids *, CFastBuffer<CSystemFids *> *);
 
     int ExtractExternalLocations(CFastBuffer<CSystemFids *> * &, CSystemFidsDrive *);
 
     int ExtractExternalLocations(CFastBuffer<CSystemFids *> * &, CSystemFidsDrive *);
     int LoadCurrentHeader(enum EVersion);
+
     int LoadCurrentHeader(enum EVersion); // Reads the file header of a .gbx file
     int DoLoadHeader(void);
+
     int DoLoadHeader(void);     // Reads the magic 'GBX' and version of a .gbx file, and then calls LoadCurrentHeader()
     int DoSaveHeader(void);
+
     int DoSaveHeader(void);     // Writes the header of a .gbx file
     int DoLoadRef(void);
+
     int DoLoadRef(void);         // Reads the reference table of a .gbx file
     int DoSaveRef(void);
+
     int DoSaveRef(void);         // Writes the reference table of a .gbx file
     int DoLoadAllRef(void);
+
     int DoLoadAllRef(void);     // Reads the header and the reference table of a .gbx file
     int DoLoadBody(CMwNod * &);
+
     int DoLoadBody(CMwNod * &); // Reads the body of a .gbx file
     int DoSaveBody(void);
+
     int DoSaveBody(void);       // Writes the body of a .gbx file
 +
    int DoLoadAll(CMwNod * &);  // Reads the header, the reference table and the body of a .gbx file
 +
    int DoSaveAll(void);        // Writes the header, the reference table and the body of a .gbx file
 
     int DoSaveBodyMemory(CMwNod *);
 
     int DoSaveBodyMemory(CMwNod *);
    int DoLoadAll(CMwNod * &);
  −
    int DoSaveAll(void);
   
     int DoSave(CMwNod *, unsigned long, enum EArchive, int);
 
     int DoSave(CMwNod *, unsigned long, enum EArchive, int);
 
     int DoLoadResource(unsigned long, CMwNod * &);
 
     int DoLoadResource(unsigned long, CMwNod * &);
Line 1,049: Line 1,067:  
  private:
 
  private:
 
     void ParametrizedFinalization(CMwNod *);
 
     void ParametrizedFinalization(CMwNod *);
     void ParametrizedFindOrAddFid(CSystemFid *, CMwNod *);
+
     void ParametrizedFindOrAddFid(CSystemFid *, CMwNod *);
 
   
 
   
 
  private:
 
  private:

Navigation menu