From d359c0af4874534efa810729d47f610a29687e93 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sat, 19 Jul 2025 11:35:11 -0300 Subject: THREADING: upgrade from LinuxThreads to NPTL This was a required change to make the server run on a modern GLIBC version without resorting to shady shared libraries or compatibility tricks. It is very straightforward but we should always keep an eye out for possible bugs. There was also a problem with the Z loop on field sending functions that was causing the server to hang in an infinite loop and should now be fixed. With these changes it is now possible to login into the game for a split second before the client asserting. --- src/sending.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/sending.cc') diff --git a/src/sending.cc b/src/sending.cc index 970439f..3b22cc3 100644 --- a/src/sending.cc +++ b/src/sending.cc @@ -20,8 +20,10 @@ void SendAll(void){ while(Connection != NULL){ if(Connection->WillingToSend){ Connection->WillingToSend = false; + // NOTE(fusion): `SIGUSR2` is used to signal the connection thread + // that there is pending data in the connection's output buffer. if(Connection->Live() && Connection->NextToCommit > Connection->NextToSend){ - kill(Connection->GetPID(), SIGUSR2); + tgkill(GetGameProcessID(), Connection->GetThreadID(), SIGUSR2); } }else{ error("SendAll: Verbindung ist nicht sendewillig.\n"); @@ -274,6 +276,7 @@ void SendMapPoint(TConnection *Connection, int x, int y, int z){ while(Obj != NONE && ObjCount < MAX_OBJECTS_PER_POINT){ SendMapObject(Connection, Obj); Obj = Obj.getNextObject(); + ObjCount += 1; } } Skip += 1; @@ -445,7 +448,7 @@ void SendFullScreen(TConnection *Connection){ SendByte(Connection, (uint8)PlayerZ); Skip = -1; - for(int PointZ = StartZ; PointZ != EndZ; EndZ += StepZ){ + for(int PointZ = StartZ; PointZ != EndZ; PointZ += StepZ){ int ZOffset = (PlayerZ - PointZ); for(int PointX = MinX; PointX <= MaxX; PointX += 1) for(int PointY = MinY; PointY <= MaxY; PointY += 1){ @@ -499,7 +502,7 @@ void SendRow(TConnection *Connection, int Direction){ } Skip = -1; - for(int PointZ = StartZ; PointZ != EndZ; EndZ += StepZ){ + for(int PointZ = StartZ; PointZ != EndZ; PointZ += StepZ){ int ZOffset = (PlayerZ - PointZ); for(int PointX = MinX; PointX <= MaxX; PointX += 1) for(int PointY = MinY; PointY <= MaxY; PointY += 1){ @@ -561,7 +564,7 @@ void SendFloors(TConnection *Connection, bool Up){ int MaxY = MinY + Connection->TerminalHeight - 1; Skip = -1; - for(int PointZ = StartZ; PointZ != EndZ; EndZ += StepZ){ + for(int PointZ = StartZ; PointZ != EndZ; PointZ += StepZ){ int ZOffset = (PlayerZ - PointZ); for(int PointX = MinX; PointX <= MaxX; PointX += 1) for(int PointY = MinY; PointY <= MaxY; PointY += 1){ -- cgit v1.2.3