Browse Source

Fix bugs with plNetAddress.

This allows the patcher to successfully connect to both GateKeeper and
FileSrv.
Darryl Pogue 13 years ago
parent
commit
06a561fc85
  1. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp
  2. 2
      Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp
  3. 4
      Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp
  4. 4
      Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp
  5. 2
      Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp
  6. 13
      Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Addr.cpp
  7. 2
      Sources/Plasma/NucleusLib/pnUtils/pnUtAddr.h

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtSocket.cpp

@ -638,7 +638,7 @@ static SOCKET ConnectSocket (unsigned localPort, const NetAddress & addr) {
} }
} }
if (connect(s, (const sockaddr *) &addr, sizeof(addr))) { if (connect(s, (const sockaddr *) &addr.GetAddressInfo(), sizeof(AddressType))) {
if (WSAGetLastError() != WSAEWOULDBLOCK) { if (WSAGetLastError() != WSAEWOULDBLOCK) {
LogMsg(kLogError, "sockegt connect failed"); LogMsg(kLogError, "sockegt connect failed");
break; break;

2
Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp

@ -342,7 +342,7 @@ void AsyncAddressLookupAddr (
lookup->param = param; lookup->param = param;
plString str = address.GetHostString(); plString str = address.GetHostString();
lookup->name = str.toUtf16().GetData(); wcsncpy(lookup->name, (const wchar_t*)str.ToUtf16().GetData(), 127);
s_critsect.Enter(); s_critsect.Enter();
{ {

4
Sources/Plasma/NucleusLib/pnNetCli/pnNcChannel.cpp

@ -254,10 +254,10 @@ static NetMsgChannel* FindChannel_CS (uint32_t protocol, bool server) {
std::list<NetMsgChannel*>::iterator it = s_channels->begin(); std::list<NetMsgChannel*>::iterator it = s_channels->begin();
for (; it != s_channels->end(); ++it) { for (; it != s_channels->end(); ++it) {
if (((*it)->m_protocol == protocol) && ((*it)->m_server == server)) if (((*it)->m_protocol == protocol) && ((*it)->m_server == server))
break; return *it;
} }
return *it; return nil;
} }
//=========================================================================== //===========================================================================

4
Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp

@ -309,7 +309,7 @@ static void BufferedSendData (
else else
{ {
// Value arrays are passed in by ptr // Value arrays are passed in by ptr
for (int i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
if (cmd->size == sizeof(uint8_t)) { if (cmd->size == sizeof(uint8_t)) {
((uint8_t*)temp)[i] = ((uint8_t*)*msg)[i]; ((uint8_t*)temp)[i] = ((uint8_t*)*msg)[i];
} else if (cmd->size == sizeof(uint16_t)) { } else if (cmd->size == sizeof(uint16_t)) {
@ -449,7 +449,7 @@ static bool DispatchData (NetCli * cli, void * param) {
// byte-swap integers // byte-swap integers
// This is so screwed up >.< // This is so screwed up >.<
for (int i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
if (cli->recvField->size == sizeof(uint16_t)) { if (cli->recvField->size == sizeof(uint16_t)) {
((uint16_t*)data)[i] = hsToLE16(((uint16_t*)data)[i]); ((uint16_t*)data)[i] = hsToLE16(((uint16_t*)data)[i]);
} else if (cli->recvField->size == sizeof(uint32_t)) { } else if (cli->recvField->size == sizeof(uint32_t)) {

2
Sources/Plasma/NucleusLib/pnSimpleNet/pnSimpleNet.cpp

@ -286,7 +286,7 @@ static bool AsyncNotifySocketProc (
s_critsect.Lock(); s_critsect.Lock();
{ {
std::map<uint32_t, SimpleNetChannel*>::iterator it; std::map<uint32_t, SimpleNetChannel*>::iterator it;
if ((it = s_channels.find(conn->channelId)) != s_channels.end()) { if ((it = s_channels.find(connect.channelId)) != s_channels.end()) {
channel = it->second; channel = it->second;
channel->IncRef(); channel->IncRef();
} }

13
Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Addr.cpp

@ -95,13 +95,10 @@ static NetAddressNode NodeFromString (const wchar_t * string[]) {
***/ ***/
//=========================================================================== //===========================================================================
bool NetAddressFromString (NetAddress * addr, const wchar_t str[], unsigned defaultPort) { bool NetAddressFromString (NetAddress * addr, const wchar_t str[], uint16_t defaultPort) {
ASSERT(addr); ASSERT(addr);
ASSERT(str); ASSERT(str);
// NetAddress is bigger than sockaddr_in so start by zeroing the whole thing
memset(addr, 0, sizeof(*addr));
for (;;) { for (;;) {
NetAddressNode node = NodeFromString(&str); NetAddressNode node = NodeFromString(&str);
if (node == (unsigned)-1) if (node == (unsigned)-1)
@ -110,12 +107,8 @@ bool NetAddressFromString (NetAddress * addr, const wchar_t str[], unsigned defa
if (*str == L':') if (*str == L':')
defaultPort = StrToUnsigned(str + 1, nil, 10); defaultPort = StrToUnsigned(str + 1, nil, 10);
sockaddr_in * inetaddr = (sockaddr_in *) addr; addr->SetPort((uint16_t)defaultPort);
inetaddr->sin_family = AF_INET; addr->SetHostLE(node);
inetaddr->sin_port = htons((uint16_t) defaultPort);
inetaddr->sin_addr.S_un.S_addr = htonl(node);
// inetaddr->sin_zero already zeroed
return true; return true;
} }

2
Sources/Plasma/NucleusLib/pnUtils/pnUtAddr.h

@ -79,7 +79,7 @@ typedef uint32_t NetAddressNode;
bool NetAddressFromString ( bool NetAddressFromString (
NetAddress * addr, NetAddress * addr,
const wchar_t str[], const wchar_t str[],
unsigned defaultPort uint16_t defaultPort
); );
#endif #endif

Loading…
Cancel
Save