diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-06-05 12:12:39 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-06-05 12:12:39 -0300 |
| commit | f080f1e4bc9475500c0b5ef3c559c0e105290137 (patch) | |
| tree | 461f6a7fef0014900f5f36423a92bde964a4ae94 | |
| parent | ebfa80ab573b1a0ef9aec65a45fd0ae751196207 (diff) | |
| download | game-f080f1e4bc9475500c0b5ef3c559c0e105290137.tar.gz game-f080f1e4bc9475500c0b5ef3c559c0e105290137.zip | |
reduce clutter with struct dividing comments
| -rw-r--r-- | src/common.hh | 20 | ||||
| -rw-r--r-- | src/containers.hh | 32 | ||||
| -rw-r--r-- | src/cr.hh | 26 | ||||
| -rw-r--r-- | src/map.hh | 4 | ||||
| -rw-r--r-- | src/objects.hh | 4 | ||||
| -rw-r--r-- | src/script.hh | 20 | ||||
| -rw-r--r-- | src/thread.hh | 4 |
7 files changed, 31 insertions, 79 deletions
diff --git a/src/common.hh b/src/common.hh index 8bf7fca..ded9079 100644 --- a/src/common.hh +++ b/src/common.hh @@ -187,7 +187,7 @@ void RandomShuffle(T *Buffer, int Size){ struct TReadStream { // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= virtual bool readFlag(void); // VTABLE[0] virtual uint8 readByte(void) = 0; // VTABLE[1] virtual uint16 readWord(void); // VTABLE[2] @@ -199,12 +199,10 @@ struct TReadStream { }; struct TReadBuffer: TReadStream { - // REGULAR FUNCTIONS - // ========================================================================= TReadBuffer(const uint8 *Data, int Size); // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= uint8 readByte(void) override; uint16 readWord(void) override; uint32 readQuad(void) override; @@ -213,7 +211,7 @@ struct TReadBuffer: TReadStream { void skip(int Count) override; // DATA - // ========================================================================= + // ================= const uint8 *Data; int Size; int Position; @@ -221,7 +219,7 @@ struct TReadBuffer: TReadStream { struct TWriteStream { // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= virtual void writeFlag(bool Flag); // VTABLE[0] virtual void writeByte(uint8 Byte) = 0; // VTABLE[1] virtual void writeWord(uint16 Word); // VTABLE[2] @@ -231,33 +229,29 @@ struct TWriteStream { }; struct TWriteBuffer: TWriteStream { - // REGULAR FUNCTIONS - // ========================================================================= TWriteBuffer(uint8 *Data, int Size); void reset(void) { this->Position = 0; } // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= void writeByte(uint8 Byte) override; void writeWord(uint16 Word) override; void writeQuad(uint32 Quad) override; void writeBytes(const uint8 *Buffer, int Count) override; // DATA - // ========================================================================= + // ================= uint8 *Data; int Size; int Position; }; struct TDynamicWriteBuffer: TWriteBuffer { - // REGULAR FUNCTIONS - // ========================================================================= TDynamicWriteBuffer(int InitialSize); void resizeBuffer(void); // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= void writeByte(uint8 Byte) override; void writeWord(uint16 Word) override; void writeQuad(uint32 Quad) override; diff --git a/src/containers.hh b/src/containers.hh index 9cab94e..2533445 100644 --- a/src/containers.hh +++ b/src/containers.hh @@ -8,8 +8,6 @@ // index is valid, even for negative indices. template<typename T> struct vector{ - // REGULAR FUNCTIONS - // ========================================================================= vector(int min, int max, int block){ int space = (max - min) + 1; if(space < 1){ @@ -111,7 +109,7 @@ struct vector{ } // DATA - // ========================================================================= + // ================= int min; int max; int start; @@ -130,8 +128,6 @@ struct priority_queue_entry{ template<typename K, typename T> struct priority_queue{ - // REGULAR FUNCTIONS - // ========================================================================= priority_queue(int capacity, int increment){ Entry = new vector<priority_queue_entry<K, T>>(1, capacity, increment); Entries = 0; @@ -202,19 +198,13 @@ struct priority_queue{ } // DATA - // ========================================================================= + // ================= vector<priority_queue_entry<K, T>> *Entry; int Entries; }; -// TODO(fusion): We only use this structure two global queues: -// priority_queue<uint32, uint32> ToDoQueue(5000, 1000); -// priority_queue<uint32, TAttackWave*> AttackWaveQueue(100, 100); - template<typename T> struct matrix{ - // REGULAR FUNCTIONS - // ========================================================================= matrix(int xmin, int xmax, int ymin, int ymax){ int dx = (xmax - xmin) + 1; int dy = (ymax - ymin) + 1; @@ -262,7 +252,7 @@ struct matrix{ } // DATA - // ========================================================================= + // ================= int xmin; int ymin; int dx; @@ -272,8 +262,6 @@ struct matrix{ template<typename T> struct matrix3d{ - // REGULAR FUNCTIONS - // ========================================================================= matrix3d(int xmin, int xmax, int ymin, int ymax, int zmin, int zmax){ int dx = (xmax - xmin) + 1; int dy = (ymax - ymin) + 1; @@ -333,7 +321,7 @@ struct matrix3d{ } // DATA - // ========================================================================= + // ================= int xmin; int ymin; int zmin; @@ -352,8 +340,6 @@ struct listnode{ template<typename T> struct list{ - // REGULAR FUNCTIONS - // ========================================================================= list(void){ firstNode = NULL; lastNode = NULL; @@ -405,15 +391,13 @@ struct list{ } // DATA - // ========================================================================= + // ================= listnode<T> *firstNode; listnode<T> *lastNode; }; template<typename T> struct fifo{ - // REGULAR FUNCTIONS - // ========================================================================= fifo(int InitialSize){ ASSERT(InitialSize > 0); this->Entry = new T[InitialSize]; @@ -468,7 +452,7 @@ struct fifo{ // functions were inlined so I'm not sure it is needed. // DATA - // ========================================================================= + // ================= T *Entry; int Size; int Head; @@ -495,8 +479,6 @@ struct storeunit{ // It is also known as a slab allocator. template<typename T, usize N> struct store{ - // REGULAR FUNCTIONS - // ========================================================================= store(void){ this->Units = new list<storeunit<T, N>>; this->firstFreeItem = NULL; @@ -529,7 +511,7 @@ struct store{ } // DATA - // ========================================================================= + // ================= list<storeunit<T, N>> *Units; storeitem<T> *firstFreeItem; }; @@ -93,8 +93,6 @@ struct TRaceData { // TSkillBase // ============================================================================= struct TSkill{ - // REGULAR FUNCTIONS - // ========================================================================= TSkill(int SkNr, TCreature *Master); int Get(void); int GetProgress(void); @@ -109,7 +107,7 @@ struct TSkill{ int *Exp, int *FactorPercent, int *NextLevel, int *Delta); // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= virtual ~TSkill(void); // VTABLE[ 0] // Duplicate destructor that also calls operator delete. // VTABLE[ 1] virtual void Set(int Value); // VTABLE[ 2] @@ -129,7 +127,7 @@ struct TSkill{ virtual void Reset(void); // VTABLE[16] // DATA - // ========================================================================= + // ================= //void *VTABLE; // IMPLICIT int DAct; // Delta Value - Probably from equipment. int MDAct; // Delta Magic Value - Probably from spells. @@ -240,8 +238,6 @@ struct TSkillEnergy: TSkill { }; struct TSkillBase{ - // REGULAR FUNCTIONS - // ========================================================================= TSkillBase(void); ~TSkillBase(void); bool NewSkill(uint16 SkillNo, TCreature *Creature); @@ -251,7 +247,7 @@ struct TSkillBase{ void DelTimer(uint16 SkNr); // DATA - // ========================================================================= + // ================= TSkill *Skills[25]; TSkill *TimerList[25]; uint16 FirstFreeTimer; @@ -266,8 +262,6 @@ struct TCombatEntry{ }; struct TCombat{ - // REGULAR FUNCTIONS - // ========================================================================= TCombat(void); void GetWeapon(void); void GetAmmo(void); @@ -297,7 +291,7 @@ struct TCombat{ // DATA - // ========================================================================= + // ================= TCreature *Master; uint32 EarliestAttackTime; uint32 EarliestDefendTime; @@ -378,8 +372,6 @@ struct TToDoEntry { }; struct TCreature: TSkillBase { - // REGULAR FUNCTIONS - // ========================================================================= TCreature(void); void Attack(void); int Damage(TCreature *Attacker, int Damage, int DamageType); @@ -388,7 +380,7 @@ struct TCreature: TSkillBase { void ToDoGo(int DestX, int DestY, int DestZ, bool Dest, int MaxSteps); // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= virtual ~TCreature(void); // VTABLE[ 0] // Duplicate destructor that also calls operator delete. // VTABLE[ 1] virtual void Death(void); // VTABLE[ 2] @@ -402,7 +394,7 @@ struct TCreature: TSkillBase { virtual void AttackStimulus(uint32 AttackerID); // VTABLE[10] // DATA - // ========================================================================= + // ================= //void *VTABLE; // IMPLICIT //TSkillBase super_TSkillBase; // IMPLICIT TCombat Combat; @@ -533,8 +525,6 @@ struct TPlayerData { }; struct TPlayer: TCreature { - // REGULAR FUNCTIONS - // ========================================================================= uint8 GetRealProfession(void); uint8 GetEffectiveProfession(void); uint8 GetActiveProfession(void); @@ -556,11 +546,11 @@ struct TPlayer: TCreature { void CheckState(void); // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= // TODO // DATA - // ========================================================================= + // ================= //TCreature super_TCreature; // IMPLICIT uint32 AccountID; char Guild[31]; @@ -30,8 +30,6 @@ enum : int { }; struct Object { - // REGULAR FUNCTIONS - // ========================================================================= constexpr Object(void) : ObjectID(0) {} constexpr Object(uint32 ObjectID): ObjectID(ObjectID) {} @@ -55,7 +53,7 @@ struct Object { } // DATA - // ========================================================================= + // ================= uint32 ObjectID; }; diff --git a/src/objects.hh b/src/objects.hh index 84801e3..39fa8aa 100644 --- a/src/objects.hh +++ b/src/objects.hh @@ -20,8 +20,6 @@ enum : int{ }; struct ObjectType { - // REGULAR FUNCTIONS - // ========================================================================= ObjectType(void) { this->setTypeID(0); } ObjectType(int TypeID) { this->setTypeID(TypeID); } void setTypeID(int TypeID); @@ -61,7 +59,7 @@ struct ObjectType { } // DATA - // ========================================================================= + // ================= int TypeID; }; diff --git a/src/script.hh b/src/script.hh index 0361190..f6b3354 100644 --- a/src/script.hh +++ b/src/script.hh @@ -7,8 +7,6 @@ #define MAX_IDENT_LENGTH 30 struct TReadScriptFile { - // REGULAR FUNCTIONS - // ========================================================================= TReadScriptFile(void); ~TReadScriptFile(void); void open(const char *FileName); @@ -66,7 +64,7 @@ struct TReadScriptFile { } // DATA - // ========================================================================= + // ================= TOKEN Token; FILE *File[3]; char Filename[3][4096]; @@ -82,8 +80,6 @@ struct TReadScriptFile { }; struct TWriteScriptFile { - // REGULAR FUNCTIONS - // ========================================================================= TWriteScriptFile(void); ~TWriteScriptFile(void); void open(const char *FileName); @@ -97,15 +93,13 @@ struct TWriteScriptFile { void writeBytesequence(const uint8 *Sequence, int Length); // DATA - // ========================================================================= + // ================= FILE *File; char Filename[4096]; int Line; }; struct TReadBinaryFile: TReadStream { - // REGULAR FUNCTIONS - // ========================================================================= TReadBinaryFile(void); void open(const char *FileName); void close(void); @@ -115,7 +109,7 @@ struct TReadBinaryFile: TReadStream { void seek(int Offset); // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= uint8 readByte(void) override; void readBytes(uint8 *Buffer, int Count) override; bool eof(void) override; @@ -128,22 +122,20 @@ struct TReadBinaryFile: TReadStream { // Duplicate destructor that also calls operator delete. // VTABLE[9] // DATA - // ========================================================================= + // ================= FILE *File; char Filename[4096]; int FileSize; }; struct TWriteBinaryFile: TWriteStream { - // REGULAR FUNCTIONS - // ========================================================================= TWriteBinaryFile(void); void open(const char *FileName); void close(void); void error(const char *Text); // VIRTUAL FUNCTIONS - // ========================================================================= + // ================= void writeByte(uint8 Byte) override; void writeBytes(const uint8 *Buffer, int Count) override; @@ -153,7 +145,7 @@ struct TWriteBinaryFile: TWriteStream { virtual ~TWriteBinaryFile(void); // DATA - // ========================================================================= + // ================= FILE *File; char Filename[4096]; }; diff --git a/src/thread.hh b/src/thread.hh index 20cfa0b..cd8a881 100644 --- a/src/thread.hh +++ b/src/thread.hh @@ -16,15 +16,13 @@ int JoinThread(ThreadHandle Handle); void DelayThread(int Seconds, int MicroSeconds); struct Semaphore { - // REGULAR FUNCTIONS - // ========================================================================= Semaphore(int Value); ~Semaphore(void); void up(void); void down(void); // DATA - // ========================================================================= + // ================= int value; pthread_mutex_t mutex; pthread_cond_t condition; |
