aboutsummaryrefslogtreecommitdiff
path: root/src/sending.cc
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-07-19 11:35:11 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-07-19 11:35:11 -0300
commitd359c0af4874534efa810729d47f610a29687e93 (patch)
tree9a89b06444819e7e5cef84aa826682b3b01bfd03 /src/sending.cc
parent638244fd078fe91971e57b1d06e4499268d99c42 (diff)
downloadgame-d359c0af4874534efa810729d47f610a29687e93.tar.gz
game-d359c0af4874534efa810729d47f610a29687e93.zip
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.
Diffstat (limited to 'src/sending.cc')
-rw-r--r--src/sending.cc11
1 files changed, 7 insertions, 4 deletions
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){