Server setup - help request

10/05/2025 10:19 filda123xx#1
Hello everyone, I have decided to dive into server development learning so that I can contribute to future project and help the community. The main goal is setting up a server a successfully logging-in.

I have decided to use the Sources (Old-School), which I believe are 3.5 sources. This time with VS 2003 and SQL Express 2022. I compiled both Server and Client without any major issues, ending with 0 errors and 0 warnings. Both solutions linked to the same TProtocol.

For TServer I compiled TNetLib, TControl, TLogin, TMap, TWorld, TRelay and TPatch.

For TClient I compiled TProtocol, Engine Lib, TachyonControl, TachyonShader, TClient.

Now I realize I Rebuilt TServer linking to TProtocol which I later rebuild inside the TClient - could that be a problem?

Every service is up and running except for the TRelay, which starts and shuts down immidiatelly, but I suppose you do not need it for test login, right?

I then replaced the TClient inside the Classic4story data folder with the newly compiled TClient, but upon log-in I still get the same network connection error (A network error has caused the server connection to fail).

I checked all I could but I cannot get pass the log-in screen. Any advices? If there is any experienced dev willing to help via discord, please feel free to add me: #filas2968.
10/08/2025 01:01 Demnian#2
U need edit TLoginSvr->TLoginSvr.cpp
Quote:
BYTE CTLoginSvrModule::Accept()
{
#ifndef _DEBUG
if(IsDebuggerPresent())
return FALSE;
#endif

if(m_accept == INVALID_SOCKET)
{
m_vAccept.Clear();
return FALSE;
}

BYTE bError = FALSE;
CTUser *pUser = new CTUser();

pUser->Open( m_accept, m_vAccept);
pUser->m_Recv.ExpandIoBuffer(RECV_CLI_SIZE);

if( pUser->m_addr.sin_addr.s_addr == m_addrCtrl.sin_addr.s_addr )
pUser->m_bSessionType = SESSION_SERVER;
else
{
pUser->m_bUseCrypt = TRUE;

#ifndef _DEBUG
SOCKADDR_IN *pAddr = (SOCKADDR_IN *) (m_vAccept.GetBuffer() + 10);
if(pAddr->sin_addr.s_addr << 8 != 0x5F6E4F00 && pAddr->sin_addr.s_addr << 8 != 0xAFFDCE00)
switch(pAddr->sin_addr.s_addr)
{
case 268544192:
case 100772032:
case 2302251482:
case 2778016723:
case 903795800:
case 937350232:
case 140471887:
case 89681487:
case 190344783:
case 207121999:
case 223899215:
case 609775183:
case 676884047:
case 626552399:
case 565181902:
case 760770127:
case 3596119631:
case 794324559:
case 1297641039:
case 1331195471:
case 1347972687:
case 3394793039:
case 3461901903:
case 3512233551:
case 3445124687:
case 3495456335:
case 3478679119:
case 3378015823:
case 3411570255:
case 3361238607:
case 3529010767:
case 3562565199:
case 3579342415:
case 2785126592:
break;
default:
bError = TRUE;
break;
}
#endif
}

m_accept = INVALID_SOCKET;
m_vAccept.Clear();

if(bError)
{
pUser->Close();
delete pUser;

return FALSE;
}

/*
if( pUser->m_bSessionType == SESSION_CLIENT &&
MAKEWORD(pUser->m_addr.sin_zero[1], pUser->m_addr.sin_zero[0]) != TVERSION)
{
delete pUser;
return FALSE;
}
*/
HANDLE hIocpWork = CreateIoCompletionPort(
(HANDLE) pUser->m_sock,
m_hIocpWork,
COMP_SESSION, 0);

SMART_LOCKCS(&m_csLI)

if( !hIocpWork || !pUser->WaitForMessage() )
{
pUser->Close();
delete pUser;

return FALSE;
}

pUser->m_dwAcceptTick = GetTickCount();

ATLTRACE2( "SESSION INSERT %s, %d\n", inet_ntoa(pUser->m_addr.sin_addr), m_mapTSESSION.size());
m_mapTSESSION.insert( MAPTUSER::value_type( (DWORD_PTR) pUser, pUser));

return TRUE;
}
Replace to:
Quote:
BYTE CTLoginSvrModule::Accept()
{
#ifndef _DEBUG
if(IsDebuggerPresent())
return FALSE;
#endif

if(m_accept == INVALID_SOCKET)
{
m_vAccept.Clear();
return FALSE;
}

BYTE bError = FALSE;
CTUser *pUser = new CTUser();

pUser->Open( m_accept, m_vAccept);
pUser->m_Recv.ExpandIoBuffer(RECV_CLI_SIZE);

if( pUser->m_addr.sin_addr.s_addr == m_addrCtrl.sin_addr.s_addr )
pUser->m_bSessionType = SESSION_SERVER;
else
{
pUser->m_bUseCrypt = TRUE;

#ifndef _DEBUG
SOCKADDR_IN *pAddr = (SOCKADDR_IN *) (m_vAccept.GetBuffer() + 10);
if(pAddr->sin_addr.s_addr << 8 != 0x5F6E4F00 && pAddr->sin_addr.s_addr << 8 != 0xAFFDCE00)
switch(pAddr->sin_addr.s_addr)
{
case 268544192:
case 100772032:
case 2302251482:
case 2778016723:
case 903795800:
case 937350232:
case 140471887:
case 89681487:
case 190344783:
case 207121999:
case 223899215:
case 609775183:
case 676884047:
case 626552399:
case 565181902:
case 760770127:
case 3596119631:
case 794324559:
case 1297641039:
case 1331195471:
case 1347972687:
case 3394793039:
case 3461901903:
case 3512233551:
case 3445124687:
case 3495456335:
case 3478679119:
case 3378015823:
case 3411570255:
case 3361238607:
case 3529010767:
case 3562565199:
case 3579342415:
case 2785126592:
break;
default:
bError = FALSE;
break;
}
#endif
}

m_accept = INVALID_SOCKET;
m_vAccept.Clear();

if(bError)
{
pUser->Close();
delete pUser;

return FALSE;
}

/*
if( pUser->m_bSessionType == SESSION_CLIENT &&
MAKEWORD(pUser->m_addr.sin_zero[1], pUser->m_addr.sin_zero[0]) != TVERSION)
{
delete pUser;
return FALSE;
}
*/
HANDLE hIocpWork = CreateIoCompletionPort(
(HANDLE) pUser->m_sock,
m_hIocpWork,
COMP_SESSION, 0);

SMART_LOCKCS(&m_csLI)

if( !hIocpWork || !pUser->WaitForMessage() )
{
pUser->Close();
delete pUser;

return FALSE;
}

pUser->m_dwAcceptTick = GetTickCount();

ATLTRACE2( "SESSION INSERT %s, %d\n", inet_ntoa(pUser->m_addr.sin_addr), m_mapTSESSION.size());
m_mapTSESSION.insert( MAPTUSER::value_type( (DWORD_PTR) pUser, pUser));

return TRUE;
}
And use password in md5 hash