Sphereserver / Source

http://spherecommunity.net
Apache License 2.0
108 stars 58 forks source link

CClientLog.cpp #255

Closed Skul83 closed 4 years ago

Skul83 commented 4 years ago

Missing brackets for the IF statement in CClientLog.cpp

BYTE CClient::Login_ServerList(LPCTSTR pszAccount, LPCTSTR pszPassword) { ADDTOCALLSTACK("CClient::Login_ServerList"); // PACKET_ServersReq // Initial login (Login on "loginserver", new format)

CGString sMsg;
BYTE bResult = LogIn(pszAccount, pszPassword, sMsg);
if (bResult != PacketLoginError::Success)
{               // <--- missing a bracket here
    return bResult;
}               // <--- and missing a bracket here
m_Targ_Mode = CLIMODE_SETUP_SERVERS;
new PacketServerList(this);
return PacketLoginError::Success;

}

coruja747 commented 4 years ago
if (bResult != PacketLoginError::Success)
    return bResult;

is already the same as

if (bResult != PacketLoginError::Success)
{
    return bResult;
}

On C++ the { } bracket is not really needed when the if/else/etc operation just have a single line, so removing the { } bracket is a best practice to make the code clean

Skul83 commented 4 years ago

Ah ok, I was not totally sure if this was an issue. I'm having connection problems when it comes to Local and Network connections, External connections work fine. If I try to connect to my server via 127.0.0.1 or 192.168.1.9 (network ip), I get hung at the server selection screen. Players connecting with their External IP addresses have no problems entering the server.

Skul83 commented 4 years ago

I tested running 56b on port 2594 and I was able to connect normally. I tried running 56d on port 2594 and I can not connect locally or by the local network. External connection have no problems.

Khaldor48 commented 4 years ago

This is common network problem, you need to a new server at the end of sphere.ini

[SERVERS]
My Server - External
127.0.0.1
2593
My Server - Internal
192.168.1.9
2593

Players coming from external IPs click first server on selection, player which are coming from internal must select the second one (Internal)

Skul83 commented 4 years ago

Ok, new error but same problem. I'm getting this error:

17:28:2:Client connected [Total:1] ('192.168.1.9' 1/1) 17:28:2:Login 'Skul' 17:28:DEBUG: thread (12692) | # | function | ticks passed from previous function start 17:28:DEBUG:>> 12692 | 0 | NetworkManager::processAllInput | +0 17:28:DEBUG:>> 12692 | 1 | NetworkInput::processInput | +0 17:28:DEBUG:>> 12692 | 2 | NetworkInput::processData | +0 17:28:DEBUG:>> 12692 | 3 | NetworkInput::processData | +0 17:28:DEBUG:>> 12692 | 4 | NetworkInput::processUnknownClientData | +0 <-- exception catch point (below is guessed and could be incorrect!) 17:28:DEBUG:>> 12692 | 5 | CClient::xProcessClientSetup | +0 17:28:DEBUG:>> 12692 | 6 | CClient::Login_ServerList | +0 17:28:DEBUG:>> 12692 | 7 | PacketServerList::PacketServerList | +0 17:28:DEBUG:>> 12692 | 8 | PacketServerList::writeServerEntry | +0 17:28:CRITICAL:"Access Violation" (0x60f801c4), in NetworkInput::ProcessNewClient() #1 "messages - setup" 17:28:2:Client disconnected [Total:0] ('192.168.1.9', acct='Skul')

This happens before getting to the server selection screen. My sphere.ini options:

[SERVERS] Marchadium (Local) 192.168.1.9 2594

Marchadium 127.0.0.1 2594

coruja747 commented 4 years ago

What build/client are you using?

I'm testing here on latest build 1046 with latest client 7.0.85.15 using this .ini setting:

[SERVERS]
MyShard (local)
192.168.0.1
2594

MyShard
127.0.0.1
2594

and everything seems to be working fine

Skul83 commented 4 years ago

April 20th Build of 56d, win32. Client 6.0.11.0

Appears to happen only when I use my external IP in the [SERVERS] list, example:

[SERVERS] Marchadium shard.marchadium.ca 2594

Marchadium (Local) 127.0.0.1 2594

Could it be a windows settings? I'm operating sphere on Windows 10, 32bit.

coruja747 commented 4 years ago

Nah, I think you found the problem lol

Try replace "shard.marchadium.ca" with your numeric IP address, because the text you write there will be parsed to send on client packet, and the parser expect a numeric IP and will throw an error if it's not numeric

Anyway, if you're trying to set an DDNS as SERVIP, you must set it on sphere_serv_triggers.scp

[FUNCTION f_onserver_start]
// This function is called on server startup.

//SERV.ServIP=xxx.xxx.xxx.xxx   //Add your public IP here (not domain) if you are behind a router

But since you're using an updated 56d build, instead set SERV.SERVIP manually you can use RestAPIPublicIP on sphere.ini to set it automatically on server startup

Skul83 commented 4 years ago

Well after some testing I tried these values:

[SPHERE] // Name of your Sphere shard ServName=Marchadium // The IP of your server, this will be 127.0.0.1 almost always ServIP=* // The port of your server, this is 2593 by default ServPort=2594

[SERVERS] Marchadium * 2594

The astericks symbol (*) works great for SERVIP except I noticed the server does not monitor IP 127.0.0.1, although it does monitor my network IP 192.168.1.9 and my external IP 174.92.131.92

Below shows what sphere monitors using an astericks symbol:

Server started on hostname 'Kevin-SERVER' Monitoring local IP 192.168.1.9:2594 (TCP) - Main server Monitoring local IP 174.92.131.92:2594 (TCP) - Main server

As you can see 127.0.0.1 is not monitored and I still get hung trying to connect to my server. Other clients can connect.

Skul83 commented 4 years ago

Also noticed RestAPIPublicIP does not work, tried *, 127.0.0.1, 192.168.1.9, 174.92.131.92 and www.marchadium.ca

ERROR:Failed to get server public IP: REST API 'http://127.0.0.1' returned a non-IP value. Please check RestAPIPublicIP setting on sphere.ini

http://127.0.0.1 brings me to my webpage (local).