Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Winsock header only where it's actually used #1472

Merged
merged 3 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Sources/Plasma/CoreLib/hsWindows.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
/** \file hsWindows.h
* \brief Pulls in Windows core headers
*
* This file pulls in the core Windows headers and Winsock2. It is separate from
* HeadSpin.h to improve build times and to facillitate adding precompiled headers.
* This file pulls in the core Windows headers. It is separate from HeadSpin.h
* to improve build times and to facilitate adding precompiled headers.
* You should avoid including this header from other headers!
*/

Expand All @@ -75,7 +75,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com

# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <ws2tcpip.h> // Pulls in WinSock 2 for us

// This needs to be after #include <windows.h>, since it also includes windows.h
# ifdef USE_VLD
Expand Down
6 changes: 1 addition & 5 deletions Sources/Plasma/NucleusLib/pnNetCommon/plNetAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetAddress.h"
#include "pnNetCommon.h"

#ifndef AF_INET
# define AF_INET 2
#endif

ST::string plNetAddress::GetHostString() const
{
return pnNetCommon::GetTextAddr(fHost);
Expand Down Expand Up @@ -105,5 +101,5 @@ void plNetAddress::Write(hsStream * s)
s->WriteLE16(fPort);

// Family is always AF_INET
s->WriteLE16((uint16_t)AF_INET);
s->WriteLE16(static_cast<uint16_t>(2));
dgelessus marked this conversation as resolved.
Show resolved Hide resolved
}
8 changes: 5 additions & 3 deletions Sources/Plasma/NucleusLib/pnNetCommon/pnNetCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include <string>
#include "pnNetCommon.h"
#include "hsWindows.h"

#if HS_BUILD_FOR_UNIX
#if defined(HS_BUILD_FOR_UNIX)
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# include <netdb.h>
#elif !defined(HS_BUILD_FOR_WIN32)
#elif defined(HS_BUILD_FOR_WIN32)
#include "hsWindows.h"
#include <ws2tcpip.h>
#else
#error "Not implemented for this platform"
#endif

Expand Down