aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-09-13 00:37:10 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-09-13 00:39:31 -0300
commit465620a871e7da8d72d82a999eac8623570d13fd (patch)
treed66a0d17556630e88730488b5223823adef19b03 /src
parent16f2e00b055c8356a7e80fa3b92e7df5a5c89a4c (diff)
downloadgame-465620a871e7da8d72d82a999eac8623570d13fd.tar.gz
game-465620a871e7da8d72d82a999eac8623570d13fd.zip
add `MAX_DEPOTS` constant + enable assertions in debug mode
Diffstat (limited to 'src')
-rw-r--r--src/common.hh18
-rw-r--r--src/cr.hh4
-rw-r--r--src/crplayer.cc16
-rw-r--r--src/moveuse.cc2
-rw-r--r--src/receiving.cc2
5 files changed, 27 insertions, 15 deletions
diff --git a/src/common.hh b/src/common.hh
index daf66ad..a8f1460 100644
--- a/src/common.hh
+++ b/src/common.hh
@@ -66,7 +66,7 @@ typedef size_t usize;
#endif
#define ASSERT_ALWAYS(expr) if(!(expr)) { TRAP(); }
-#if BUILD_DEBUG
+#if ENABLE_ASSERTIONS
# define ASSERT(expr) ASSERT_ALWAYS(expr)
#else
# define ASSERT(expr) ((void)(expr))
@@ -86,6 +86,22 @@ STATIC_ASSERT(OS_LINUX);
# define sigev_notify_thread_id _sigev_un._tid
#endif
+// Constants
+// =============================================================================
+// TODO(fusion): There are many constants that are hardcoded as decompilation
+// artifacts. We should define them here and use when appropriate. It is not
+// as simple because I've been using `NARRAY` in some cases and they're used
+// essentially everywhere.
+
+//#define MAX_NAME 30 // used with most short strings (should replace MAX_IDENT_LENGTH too)
+//#define MAX_IPADDRESS 16
+//#define MAX_BUDDIES 100
+//#define MAX_SKILLS 25
+//#define MAX_SPELLS 256
+//#define MAX_QUESTS 500
+#define MAX_DEPOTS 9
+//#define MAX_OPEN_CONTAINERS 16
+
// shm.cc
// =============================================================================
void StartGame(void);
diff --git a/src/cr.hh b/src/cr.hh
index 6617c76..c4034e5 100644
--- a/src/cr.hh
+++ b/src/cr.hh
@@ -143,8 +143,8 @@ struct TPlayerData {
int MurderTimestamps[20];
uint8 *Inventory;
int InventorySize;
- uint8 *Depot[9];
- int DepotSize[9];
+ uint8 *Depot[MAX_DEPOTS];
+ int DepotSize[MAX_DEPOTS];
uint32 AccountID;
int Sex;
char Name[30];
diff --git a/src/crplayer.cc b/src/crplayer.cc
index 86c2aba..66e5ba5 100644
--- a/src/crplayer.cc
+++ b/src/crplayer.cc
@@ -1986,7 +1986,7 @@ void LoadDepot(TPlayerData *PlayerData, int DepotNr, Object Con){
throw ERROR;
}
- if(DepotNr < 0 || DepotNr >= 9){ // MAX_DEPOT ?
+ if(DepotNr < 0 || DepotNr >= MAX_DEPOTS){
error("LoadDepot: Ungültige Depotnummer %d.\n", DepotNr);
throw ERROR;
}
@@ -2022,7 +2022,7 @@ void SaveDepot(TPlayerData *PlayerData, int DepotNr, Object Con){
throw ERROR;
}
- if(DepotNr < 0 || DepotNr >= 9){ // MAX_DEPOT ?
+ if(DepotNr < 0 || DepotNr >= MAX_DEPOTS){
error("SaveDepot: Ungültige Depotnummer %d.\n", DepotNr);
throw ERROR;
}
@@ -2364,7 +2364,7 @@ bool LoadPlayerData(TPlayerData *Slot){
}
int DepotNr = Script.getNumber();
- if(DepotNr < 0 || DepotNr >= NARRAY(Slot->Depot)){
+ if(DepotNr < 0 || DepotNr >= MAX_DEPOTS){
Script.error("illegal depot number");
}
@@ -2398,9 +2398,7 @@ bool LoadPlayerData(TPlayerData *Slot){
Slot->Inventory = NULL;
Slot->InventorySize = 0;
- for(int DepotNr = 0;
- DepotNr < NARRAY(Slot->Depot);
- DepotNr += 1){
+ for(int DepotNr = 0; DepotNr < MAX_DEPOTS; DepotNr += 1){
delete[] Slot->Depot[DepotNr];
Slot->Depot[DepotNr] = NULL;
Slot->DepotSize[DepotNr] = 0;
@@ -2597,9 +2595,7 @@ void SavePlayerData(TPlayerData *Slot){
bool FirstDepot = true;
Script.writeText("Depots = {");
- for(int DepotNr = 0;
- DepotNr < NARRAY(Slot->Depot);
- DepotNr += 1){
+ for(int DepotNr = 0; DepotNr < MAX_DEPOTS; DepotNr += 1){
if(Slot->Depot[DepotNr] != NULL){
TReadBuffer Buffer(Slot->Depot[DepotNr], Slot->DepotSize[DepotNr]);
if(!FirstDepot){
@@ -2671,7 +2667,7 @@ void FreePlayerPoolSlot(TPlayerData *Slot){
}
delete[] Slot->Inventory;
- for(int DepotNr = 0; DepotNr < 9; DepotNr += 1){ // MAX_DEPOT ?
+ for(int DepotNr = 0; DepotNr < MAX_DEPOTS; DepotNr += 1){
delete[] Slot->Depot[DepotNr];
}
diff --git a/src/moveuse.cc b/src/moveuse.cc
index b1c7090..bdf6565 100644
--- a/src/moveuse.cc
+++ b/src/moveuse.cc
@@ -874,7 +874,7 @@ void SendMails(TPlayerData *PlayerData){
}
int DepotNr = Mail->DepotNumber;
- if(DepotNr < 0 || DepotNr >= 9){ // MAX_DEPOT ?
+ if(DepotNr < 0 || DepotNr >= MAX_DEPOTS){
error("SendMails: Ungültige Depotnummer %d.\n", DepotNr);
DepotNr = 0;
}
diff --git a/src/receiving.cc b/src/receiving.cc
index 7546396..3cf3f66 100644
--- a/src/receiving.cc
+++ b/src/receiving.cc
@@ -1620,7 +1620,7 @@ void CRuleViolation(TConnection *Connection, TReadBuffer *Buffer){
}
}
- PunishmentOrder(Player, Name,IPAddress, Reason, Action, Comment,
+ PunishmentOrder(Player, Name, IPAddress, Reason, Action, Comment,
NumberOfStatements, ReportedStatements, StatementID, IPBanishment);
}