aboutsummaryrefslogtreecommitdiff
path: root/reference/game.c
diff options
context:
space:
mode:
Diffstat (limited to 'reference/game.c')
-rw-r--r--reference/game.c507
1 files changed, 0 insertions, 507 deletions
diff --git a/reference/game.c b/reference/game.c
index 71343d6..c954698 100644
--- a/reference/game.c
+++ b/reference/game.c
@@ -37401,513 +37401,6 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority
return;
}
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void IncrementActiveConnections(void)
-
-{
- Semaphore::down(&CommunicationThreadMutex);
- ActiveConnections = ActiveConnections + 1;
- Semaphore::up(&CommunicationThreadMutex);
- return;
-}
-
-
-
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void DecrementActiveConnections(void)
-
-{
- Semaphore::down(&CommunicationThreadMutex);
- ActiveConnections = ActiveConnections + -1;
- Semaphore::up(&CommunicationThreadMutex);
- return;
-}
-
-
-
-void CommunicationThread(int Socket)
-
-{
- CONNECTIONSTATE CVar1;
- bool bVar2;
- TConnection *this;
- __pid_t _Var3;
- int iVar4;
- int *piVar5;
- TConnection *Connection;
- char *Text;
- int local_a0;
- int Signal;
- sigset_t SignalSet;
-
- this = AssignFreeConnection();
- if (this == (TConnection *)0x0) {
- print();
- iVar4 = close(Socket);
- if (-1 < iVar4) {
- return;
- }
- piVar5 = __errno_location();
- error(&DAT_0810cf20,*piVar5);
- return;
- }
- TConnection::Connect(this,Socket);
- this->WaitingForACK = false;
- _Var3 = getpid();
- iVar4 = fcntl(Socket,8,_Var3);
- if (iVar4 < 0) {
- error(&DAT_0810cea0,Socket);
- iVar4 = close(Socket);
- if (-1 < iVar4) goto LAB_080de426;
- piVar5 = __errno_location();
- iVar4 = *piVar5;
- Text = &DAT_0810cee0;
- }
- else {
- iVar4 = fcntl(Socket,4,0x2800);
- if (-1 < iVar4) {
- sigfillset((sigset_t *)&Signal);
- sigprocmask(2,(sigset_t *)&Signal,(sigset_t *)0x0);
- alarm(5);
- bVar2 = ReceiveCommand(this);
- if (!bVar2) {
- TConnection::Close(this,true);
- }
- this->SigIOPending = false;
-switchD_080de377_caseD_0:
- bVar2 = GameRunning();
- if ((!bVar2) || (this->ConnectionIsOk == false)) goto LAB_080de403;
- sigwait((sigset_t *)&Signal,&local_a0);
- switch(local_a0) {
- default:
- goto switchD_080de377_caseD_0;
- case 1:
- case 0xd:
- break;
- case 10:
- if (this->SigIOPending != false) goto switchD_080de377_caseD_1d;
- goto switchD_080de377_caseD_0;
- case 0xc:
- bVar2 = SendData(this);
- if (bVar2) goto switchD_080de377_caseD_0;
- break;
- case 0xe:
- if (this->State != CONNECTION_CONNECTED) goto switchD_080de377_caseD_0;
- print();
- break;
- case 0x1d:
-switchD_080de377_caseD_1d:
- if (this->WaitingForACK == false) {
- this->SigIOPending = false;
- bVar2 = ReceiveCommand(this);
- if (!bVar2) {
- bVar2 = true;
- goto LAB_080de3ab;
- }
- }
- else {
- this->SigIOPending = true;
- }
- goto switchD_080de377_caseD_0;
- }
- bVar2 = false;
-LAB_080de3ab:
- TConnection::Close(this,bVar2);
- goto switchD_080de377_caseD_0;
- }
- error(&DAT_0810ce20,Socket);
- iVar4 = close(Socket);
- if (-1 < iVar4) goto LAB_080de426;
- piVar5 = __errno_location();
- iVar4 = *piVar5;
- Text = &DAT_0810ce60;
- }
-LAB_080de44b:
- error(Text,iVar4);
-LAB_080de426:
- TConnection::Free(this);
- return;
-LAB_080de403:
- CVar1 = this->State;
- while (CVar1 - CONNECTION_LOGIN < 4) {
- DelayThread(1,0);
- CVar1 = this->State;
- }
- if (this->ClosingIsDelayed != false) {
- DelayThread(2,0);
- }
- iVar4 = close(Socket);
- if (-1 < iVar4) goto LAB_080de426;
- piVar5 = __errno_location();
- iVar4 = *piVar5;
- Text = &DAT_0810cde0;
- goto LAB_080de44b;
-}
-
-
-
-int HandleConnection(void *Data)
-
-{
- __pid_t _Var1;
- int Socket;
- int iVar2;
- void *pvVar3;
-
- pvVar3 = Data;
- if ((void *)0x7fffffff < Data) {
- pvVar3 = (void *)((int)Data + 0xffff);
- }
- iVar2 = (int)pvVar3 >> 0x10;
- if (UseOwnStacks) {
- _Var1 = getpid();
- LastUsingCommunicationThread[iVar2] = _Var1;
- }
- // try { // try from 080de581 to 080de585 has its CatchHandler @ 080de5f0
- CommunicationThread((int)((int)Data + iVar2 * -0x10000));
- Semaphore::down(&CommunicationThreadMutex);
- ActiveConnections = ActiveConnections + -1;
- Semaphore::up(&CommunicationThreadMutex);
- if (UseOwnStacks != false) {
- Semaphore::down(&CommunicationThreadMutex);
- FreeCommunicationThreadStacks[NumberOfFreeCommunicationThreadStacks] = iVar2;
- NumberOfFreeCommunicationThreadStacks = NumberOfFreeCommunicationThreadStacks + 1;
- Semaphore::up(&CommunicationThreadMutex);
- }
- return 0;
-}
-
-
-
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-bool OpenSocket(void)
-
-{
- ushort __x;
- int iVar1;
- int *piVar2;
- char *pcVar3;
- undefined4 uVar4;
- undefined4 uVar5;
- undefined4 *__optval;
- undefined4 local_2c;
- linger l;
- undefined1 local_1c [4];
- sockaddr_in ServerAddress;
-
- print();
- getpid();
- __optval = (undefined4 *)GamePort;
- print();
- uVar5 = 0;
- uVar4 = 1;
- TCPSocket = socket(2,1,0);
- if (TCPSocket < 0) {
- pcVar3 = &DAT_0810d1c0;
- }
- else {
- local_2c = 0;
- __optval = &local_2c;
- l.l_onoff = 0;
- uVar5 = 0xd;
- uVar4 = 1;
- iVar1 = setsockopt(TCPSocket,1,0xd,__optval,8);
- if (-1 < iVar1) {
- local_1c._0_2_ = 0;
- local_1c[2] = '\0';
- local_1c[3] = '\0';
- ServerAddress.sin_family = 0;
- ServerAddress.sin_port = 0;
- ServerAddress.sin_addr.s_addr = 0;
- ServerAddress.sin_zero[0] = '\0';
- ServerAddress.sin_zero[1] = '\0';
- ServerAddress.sin_zero[2] = '\0';
- ServerAddress.sin_zero[3] = '\0';
- ServerAddress._0_4_ = inet_addr(GameAddress);
- local_1c._2_2_ = (ushort)GamePort >> 8 | (ushort)GamePort << 8;
- local_1c._0_2_ = 2;
- iVar1 = setsockopt(TCPSocket,1,2,(sockaddr *)local_1c,0x10);
- if (iVar1 == 0) {
- iVar1 = bind(TCPSocket,(sockaddr *)local_1c,0x10);
- if (iVar1 < 0) {
- piVar2 = __errno_location();
- error("LaunchServer: Fehler %d bei bind.\n",*piVar2);
- print();
- while (iVar1 = bind(TCPSocket,(sockaddr *)local_1c,0x10), iVar1 < 0) {
- sleep(1);
- }
- }
- piVar2 = __errno_location();
- *piVar2 = 0;
- iVar1 = listen(TCPSocket,0x200);
- if (-1 < iVar1) {
- return true;
- }
- iVar1 = *piVar2;
- pcVar3 = "LaunchServer: Fehler %d bei listen.\n";
- }
- else {
- piVar2 = __errno_location();
- iVar1 = *piVar2;
- pcVar3 = "LaunchServer: Fehler %d bei setsockopt.\n";
- }
- error(pcVar3,iVar1);
- return false;
- }
- pcVar3 = "LaunchServer: Socket wurde nicht auf LINGER=0 gesetzt.\n";
- }
- error(pcVar3,uVar4,uVar5,__optval);
- return false;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: cli_addr
-
-int AcceptorThreadLoop(void *param_1)
-
-{
- bool bVar1;
- RESULT r;
- int *piVar2;
- void *Argument;
- Thread TVar3;
- int iVar4;
- int NewSocket;
- char *Text;
- int local_28;
- int StackNumber;
- void *Stack;
- socklen_t clilen;
- sockaddr_in cli_addr;
-
- AcceptorThreadPID = getpid();
- print();
-LAB_080de8d6:
- do {
- while( true ) {
- bVar1 = GameRunning();
- if (!bVar1) {
- AcceptorThreadPID = 0;
- if (0 < ActiveConnections) {
- print();
- while (0 < ActiveConnections) {
- sleep(1);
- }
- }
- return 0;
- }
- Stack = (void *)0x10;
- piVar2 = __errno_location();
- *piVar2 = 0;
- Argument = (void *)accept(TCPSocket,(sockaddr *)&clilen,(socklen_t *)&Stack);
- if ((int)Argument < 0) goto LAB_080deb36;
- if (UseOwnStacks != false) break;
- if (ActiveConnections < 0x44c) {
- // try { // try from 080de940 to 080deb3a has its CatchHandler @ 080deba5
- Semaphore::down(&CommunicationThreadMutex);
- ActiveConnections = ActiveConnections + 1;
- Semaphore::up(&CommunicationThreadMutex);
- TVar3 = StartThread(HandleConnection,Argument,0x10000,true);
- if (TVar3 == 0) {
- print();
- iVar4 = close((int)Argument);
- if (iVar4 < 0) {
- error(&DAT_0810d240,*piVar2);
- }
- Semaphore::down(&CommunicationThreadMutex);
- ActiveConnections = ActiveConnections + -1;
-LAB_080de9b1:
- Semaphore::up(&CommunicationThreadMutex);
- }
- }
- else {
- print();
- iVar4 = close((int)Argument);
- if (iVar4 < 0) {
- iVar4 = *piVar2;
- Text = &DAT_0810d280;
- goto LAB_080dea07;
- }
- }
- }
- GetCommunicationThreadStack(&local_28,(void **)&StackNumber);
- if (StackNumber != 0) {
- Semaphore::down(&CommunicationThreadMutex);
- ActiveConnections = ActiveConnections + 1;
- Semaphore::up(&CommunicationThreadMutex);
- TVar3 = StartThread(HandleConnection,(void *)(local_28 * 0x10000 + (int)Argument),
- (void *)StackNumber,0x10000,true);
- if (TVar3 == 0) {
- print();
- iVar4 = close((int)Argument);
- if (iVar4 < 0) {
- error(&DAT_0810d2c0,*piVar2);
- }
- Semaphore::down(&CommunicationThreadMutex);
- ActiveConnections = ActiveConnections + -1;
- Semaphore::up(&CommunicationThreadMutex);
- iVar4 = local_28;
- Semaphore::down(&CommunicationThreadMutex);
- FreeCommunicationThreadStacks[NumberOfFreeCommunicationThreadStacks] = iVar4;
- NumberOfFreeCommunicationThreadStacks = NumberOfFreeCommunicationThreadStacks + 1;
- goto LAB_080de9b1;
- }
- goto LAB_080de8d6;
- }
- print();
- iVar4 = close((int)Argument);
- if (iVar4 < 0) {
- iVar4 = *piVar2;
- Text = &DAT_0810d320;
- goto LAB_080dea07;
- }
- } while( true );
-LAB_080deb36:
- bVar1 = GameRunning();
- if (bVar1) {
- iVar4 = *piVar2;
- Text = "AcceptorThreadLoop: Fehler %d beim Accept.\n";
-LAB_080dea07:
- error(Text,iVar4);
- }
- goto LAB_080de8d6;
-}
-
-
-
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void CheckThreadlibVersion(void)
-
-{
- bool bVar1;
-
- bVar1 = FileExists("/etc/image-release");
- UseOwnStacks = !bVar1;
- print();
- return;
-}
-
-
-
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void InitCommunication(void)
-
-{
- bool bVar1;
- int i;
- int iVar2;
- undefined4 *puVar3;
- char *ctx;
-
- // try { // try from 080dec6d to 080ded9e has its CatchHandler @ 080dee0e
- bVar1 = FileExists("/etc/image-release");
- UseOwnStacks = !bVar1;
- if (UseOwnStacks) {
- ctx = "Verwende eigene Stacks.\n";
- }
- else {
- ctx = "Verwende verkleinerte Bibliotheks-Stacks.\n";
- }
- print();
- if (UseOwnStacks != false) {
- ctx = (char *)0xaa;
- memset(CommunicationThreadStacks,0xaa,0x44c0000);
- iVar2 = 0;
- do {
- LastUsingCommunicationThread[iVar2] = 0;
- FreeCommunicationThreadStacks[iVar2] = iVar2;
- iVar2 = iVar2 + 1;
- } while (iVar2 < 0x44c);
- NumberOfFreeCommunicationThreadStacks = 0x44c;
- }
- TQueryManagerConnectionPool::init(&QueryManagerConnectionPool,(EVP_PKEY_CTX *)ctx);
- ActiveConnections = 0;
- TCPSocket = -1;
- OpenSocket();
- if (TCPSocket == -1) {
- puVar3 = (undefined4 *)__cxa_allocate_exception(4);
- *puVar3 = "cannot open socket";
- }
- else {
- iVar2 = 0;
- do {
- LoadHistory[iVar2] = 0;
- iVar2 = iVar2 + 1;
- } while (iVar2 < 0x168);
- LoadHistoryPointer = 0;
- TotalSend = 0;
- TotalRecv = 0;
- TotalLoad = 0;
- LagEnd = 0;
- EarliestFreeAccountAdmissionRound = 0;
- InitLog("netload");
- WaitinglistHead = (TWaitinglistEntry *)0x0;
- TRSAPrivateKey::init
- (&PrivateKey,
- (EVP_PKEY_CTX *)
- "12017580013707233233987537782574702577133548287527131234152948150506251412291888866940292054989907714155267326586216043845592229084368540020196135619327879"
- );
- AcceptorThread = StartThread(AcceptorThreadLoop,(void *)0x0,false);
- if (AcceptorThread != 0) {
- return;
- }
- puVar3 = (undefined4 *)__cxa_allocate_exception(4);
- *puVar3 = "cannot start acceptor thread";
- }
- // WARNING: Subroutine does not return
- __cxa_throw(puVar3,char_const*::typeinfo,0);
-}
-
-
-
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void ExitCommunication(void)
-
-{
- TConnection *Connection;
- TConnection *this;
- pid_t __pid;
- int iVar1;
- int *piVar2;
- char *__status;
-
- print();
- this = GetFirstConnection();
- while (this != (TConnection *)0x0) {
- __pid = TConnection::GetPID(this);
- kill(__pid,1);
- this = GetNextConnection();
- }
- ProcessConnections();
- __status = "Alle Verbindungen beendet.\n";
- print();
- if ((TCPSocket != -1) && (iVar1 = close(TCPSocket), iVar1 < 0)) {
- piVar2 = __errno_location();
- __status = (char *)*piVar2;
- error(&DAT_0810d500);
- }
- if (AcceptorThread != 0) {
- if (AcceptorThreadPID != 0) {
- __status = (char *)0x1;
- kill(AcceptorThreadPID,1);
- }
- JoinThread(AcceptorThread);
- AcceptorThread = 0;
- }
- TQueryManagerConnectionPool::exit(&QueryManagerConnectionPool,(int)__status);
- ExitCommunicationThreadStacks();
- return;
-}
-
-
-
void __tcf_0(void *param_1)
{