diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-08-15 15:48:19 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-08-15 15:50:32 -0300 |
| commit | 8082c228c5d618e6f865f76b4d0518c2fde573ec (patch) | |
| tree | 59e61abe98c3060fb1eb3677b9dbbb744c92174a /src | |
| parent | e4b8bf807b76f6f446d9617d9a3957dc77dd6e90 (diff) | |
| download | game-8082c228c5d618e6f865f76b4d0518c2fde573ec.tar.gz game-8082c228c5d618e6f865f76b4d0518c2fde573ec.zip | |
wrapping up for a public release
Diffstat (limited to 'src')
| -rw-r--r-- | src/common.hh | 1 | ||||
| -rw-r--r-- | src/communication.cc | 2 | ||||
| -rw-r--r-- | src/cract.cc | 4 | ||||
| -rw-r--r-- | src/houses.cc | 2 | ||||
| -rw-r--r-- | src/map.cc | 10 | ||||
| -rw-r--r-- | src/moveuse.cc | 4 | ||||
| -rw-r--r-- | src/operate.cc | 12 | ||||
| -rw-r--r-- | src/query.cc | 7 |
8 files changed, 19 insertions, 23 deletions
diff --git a/src/common.hh b/src/common.hh index 971dca2..8e0cac7 100644 --- a/src/common.hh +++ b/src/common.hh @@ -245,7 +245,6 @@ struct TWriteStream { struct TWriteBuffer: TWriteStream { TWriteBuffer(uint8 *Data, int Size); - void reset(void) { this->Position = 0; } // VIRTUAL FUNCTIONS // ================= diff --git a/src/communication.cc b/src/communication.cc index b981d1e..f9a1753 100644 --- a/src/communication.cc +++ b/src/communication.cc @@ -1232,7 +1232,7 @@ void IncrementActiveConnections(void){ void DecrementActiveConnections(void){ CommunicationThreadMutex.down(); - ActiveConnections += 1; + ActiveConnections -= 1; CommunicationThreadMutex.up(); } diff --git a/src/cract.cc b/src/cract.cc index 41bbcca..35ca92a 100644 --- a/src/cract.cc +++ b/src/cract.cc @@ -1434,9 +1434,7 @@ void TCreature::NotifyGo(void){ } } - // TODO(fusion): This is probably an inlined function to get the first object - // with some specific flag on a field. - int Waypoints; + int Waypoints = 0; Object Bank = GetFirstObject(DestX, DestY, DestZ); while(Bank != NONE){ ObjectType BankType = Bank.getObjectType(); diff --git a/src/houses.cc b/src/houses.cc index a26ffbf..84c9634 100644 --- a/src/houses.cc +++ b/src/houses.cc @@ -36,7 +36,7 @@ THouse::THouse(void) : Subowner(0, 4, 5), Guest(0, 9, 10) { this->CenterY = 0; this->CenterZ = 0; this->OwnerID = 0; - this->OwnerName[30] = 0; + this->OwnerName[0] = 0; this->LastTransition = 0; this->PaidUntil = 0; this->Subowners = 0; @@ -995,7 +995,7 @@ void LoadSector(const char *FileName, int SectorX, int SectorY, int SectorZ){ AccessObject(LoadingSector->MapCon[OffsetX][OffsetY])->Attributes[3] |= 0x400; }else if(strcmp(Identifier, "content") == 0){ Script.readSymbol('='); - HelpBuffer.reset(); + HelpBuffer.Position = 0; LoadObjects(&Script, &HelpBuffer, false); TReadBuffer ReadBuffer(HelpBuffer.Data, HelpBuffer.Position); LoadObjects(&ReadBuffer, LoadingSector->MapCon[OffsetX][OffsetY]); @@ -1254,7 +1254,7 @@ void SaveSector(char *FileName, int SectorX, int SectorY, int SectorZ){ Script.writeText(", "); } Script.writeText("Content="); - HelpBuffer.reset(); + HelpBuffer.Position = 0; SaveObjects(First, &HelpBuffer, false); TReadBuffer ReadBuffer(HelpBuffer.Data, HelpBuffer.Position); SaveObjects(&ReadBuffer, &Script); @@ -1459,7 +1459,7 @@ void PatchSector(int SectorX, int SectorY, int SectorZ, bool FullSector, } }else if(strcmp(Identifier, "content") == 0){ Script->readSymbol('='); - HelpBuffer.reset(); + HelpBuffer.Position = 0; if(!House || !SaveHouses){ LoadObjects(Script, &HelpBuffer, false); TReadBuffer ReadBuffer(HelpBuffer.Data, HelpBuffer.Position); @@ -1615,7 +1615,7 @@ void PatchSector(int SectorX, int SectorY, int SectorZ, bool FullSector, } }else if(strcmp(Identifier, "content") == 0){ IN.readSymbol('='); - HelpBuffer.reset(); + HelpBuffer.Position = 0; LoadObjects(&IN, &HelpBuffer, false); if(!FieldPatched[OffsetX][OffsetY]){ if(AttrCount > 0){ @@ -1680,7 +1680,7 @@ void PatchSector(int SectorX, int SectorY, int SectorZ, bool FullSector, OUT.writeText(", "); } OUT.writeText("Content="); - HelpBuffer.reset(); + HelpBuffer.Position = 0; SaveObjects(First, &HelpBuffer, false); TReadBuffer ReadBuffer(HelpBuffer.Data, HelpBuffer.Position); SaveObjects(&ReadBuffer, &OUT); diff --git a/src/moveuse.cc b/src/moveuse.cc index e4d76db..396207d 100644 --- a/src/moveuse.cc +++ b/src/moveuse.cc @@ -2977,7 +2977,9 @@ void LoadDataBase(void){ continue; } - int EventType; + // NOTE(fusion): `TReadScriptFile::error` will always throw but the + // compiler might not be able to detect that and issue a warning. + int EventType = 0; if(strcmp(Identifier, "use") == 0){ EventType = MOVEUSE_EVENT_USE; }else if(strcmp(Identifier, "multiuse") == 0){ diff --git a/src/operate.cc b/src/operate.cc index 92ba83e..b0c81e2 100644 --- a/src/operate.cc +++ b/src/operate.cc @@ -2892,10 +2892,10 @@ void RefreshMap(void){ continue; } - bool Refreshable = false; int OffsetX = -1; int OffsetY = -1; - HelpBuffer.reset(); + bool Refreshable = false; + HelpBuffer.Position = 0; try{ TReadScriptFile Script; Script.open(FileName); @@ -2914,13 +2914,9 @@ void RefreshMap(void){ uint8 *SectorOffset = Script.getBytesequence(); OffsetX = (int)SectorOffset[0]; OffsetY = (int)SectorOffset[1]; + Refreshable = false; Script.readSymbol(':'); - continue; - } - - // TODO(fusion): We don't enforce the token to be an identifier - // here as we do when loading any sector file in `map.cc`. - if(Script.Token == IDENTIFIER){ + }else if(Script.Token == IDENTIFIER){ if(OffsetX == -1 || OffsetY == -1){ Script.error("coordinate expected"); } diff --git a/src/query.cc b/src/query.cc index c9b47aa..3b62ecd 100644 --- a/src/query.cc +++ b/src/query.cc @@ -312,7 +312,8 @@ int TQueryManagerConnection::executeQuery(int Timeout, bool AutoReconnect){ return QUERY_STATUS_FAILED; } - for(int Attempt = 0; true; Attempt += 1){ + const int MaxAttempts = 2; + for(int Attempt = 1; true; Attempt += 1){ if(!this->isConnected()){ if(!AutoReconnect){ return QUERY_STATUS_FAILED; @@ -335,7 +336,7 @@ int TQueryManagerConnection::executeQuery(int Timeout, bool AutoReconnect){ if(this->write(this->Buffer, PacketSize) != PacketSize){ this->disconnect(); - if(Attempt > 0){ + if(Attempt >= MaxAttempts){ error("TQueryManagerConnection::executeQuery: Fehler beim Abschicken der Anfrage.\n"); return QUERY_STATUS_FAILED; } @@ -346,7 +347,7 @@ int TQueryManagerConnection::executeQuery(int Timeout, bool AutoReconnect){ int BytesRead = this->read(Help, 2, Timeout); if(BytesRead != 2){ this->disconnect(); - if(BytesRead == -2 || Attempt > 0){ + if(BytesRead == -2 || Attempt >= MaxAttempts){ return QUERY_STATUS_FAILED; } continue; |
