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) {
LogMsg(kLogError, "sockegt connect failed");
break;

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

@ -342,7 +342,7 @@ void AsyncAddressLookupAddr (
lookup->param = param;
plString str = address.GetHostString();
lookup->name = str.toUtf16().GetData();
wcsncpy(lookup->name, (const wchar_t*)str.ToUtf16().GetData(), 127);
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();
for (; it != s_channels->end(); ++it) {
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
{
// 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)) {
((uint8_t*)temp)[i] = ((uint8_t*)*msg)[i];
} else if (cmd->size == sizeof(uint16_t)) {
@ -449,7 +449,7 @@ static bool DispatchData (NetCli * cli, void * param) {
// byte-swap integers
// 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)) {
((uint16_t*)data)[i] = hsToLE16(((uint16_t*)data)[i]);
} 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();
{
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->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(str);
// NetAddress is bigger than sockaddr_in so start by zeroing the whole thing
memset(addr, 0, sizeof(*addr));
for (;;) {
NetAddressNode node = NodeFromString(&str);
if (node == (unsigned)-1)
@ -110,12 +107,8 @@ bool NetAddressFromString (NetAddress * addr, const wchar_t str[], unsigned defa
if (*str == L':')
defaultPort = StrToUnsigned(str + 1, nil, 10);
sockaddr_in * inetaddr = (sockaddr_in *) addr;
inetaddr->sin_family = AF_INET;
inetaddr->sin_port = htons((uint16_t) defaultPort);
inetaddr->sin_addr.S_un.S_addr = htonl(node);
// inetaddr->sin_zero already zeroed
addr->SetPort((uint16_t)defaultPort);
addr->SetHostLE(node);
return true;
}

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

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

Loading…
Cancel
Save