Files
RP412/MUNGA/NETWORK.h
T
CydandClaude Fable 5 12b31187f9 Move the build to VS2022 (v143) with runtime parity against VC9
Hand-converted the four .vcproj projects to .vcxproj (Win32, v143,
Windows 11 SDK + DXSDK June 2010 for d3dx9/dxerr only). WinTesla.sln now
builds the v143 projects; the legacy solution is kept as WinTesla_vc9.sln.

Kept: /Zp1 in Munga_L4+RP_L4, Unicode, x86, /DYNAMICBASE:NO,
/FORCE:MULTIPLE (header-defined globals still duplicated across TUs).
Changed: CRT unified to /MD(d); import libs linked by the exes instead of
merged into Munga_L4.lib; WINDOWS_IGNORE_PACKING_MISMATCH and
_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS defined;
legacy_stdio_definitions.lib for the June-2010 dxerr.lib.

Source fixes, all behavior-preserving: Time gains standard (non-volatile)
copy-ctor/assignment overloads (rvalues cannot bind to volatile& in
standard C++); operator==(SOCKADDR_IN&,...) made inline; L4DINPUT's
Enum*Callback pair renamed DIEnum* (collided with L4CTRL's under LTCG);
std::ios.in -> std::ios::in in CAMMGR.cpp.

Verified: VC9 baseline rebuilt from this tree first, then the v143 build
compared against it in a sandboxed game working copy - identical logs and
behavior through RIO init (against vRIO) and mission load, including the
same pre-existing AV in d3d_OBJECT::LoadTexture (L4D3D.cpp:262) that both
toolchains hit; documented in BUILD.md 4 as the next debugging target.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 12:22:31 -05:00

282 lines
5.4 KiB
C++

#pragma once
#include "receiver.h"
#include "time.h"
#include "hostid.h"
//WinSock support :ADB 01/06/07
#include <Winsock2.h>
#include <Ws2tcpip.h>
class Mission;
class NetworkManager;
class NotationFile;
//
//---------------------------------------------------
// Support types for interest manager
//---------------------------------------------------
//
typedef Enumeration InterestZoneID;
const InterestZoneID NullInterestZoneID = 0;
//~~~~~~~~~~~~~~~~~~~~~~~~~~ NetworkAddress ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
typedef LWord NetworkAddress;
extern const NetworkAddress NullNetworkAddress;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ NetworkClient ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class NetworkPacket;
class NetworkClient:
public Receiver
{
friend class NetworkManager;
//##########################################################################
// Shared Data support
//
public:
static Derivation *GetClassDerivations();
static SharedData DefaultData;
//##########################################################################
// Construction and destruction support
//
public:
enum ClientID {
NetworkManagerClientID = 0,
EntityManagerClientID = 1,
HostManagerClientID = 2,
InterestManagerClientID = 3,
ApplicationClientID = 4,
ConsoleClientID = 5,
IcomManagerClientID = 6
};
private:
ClientID
clientID;
protected:
NetworkClient(
ClassID class_ID,
SharedData &virtual_data,
ClientID clientID
);
public:
~NetworkClient();
Logical
TestInstance() const;
//##########################################################################
// Message packet receiving
//
public:
virtual void
ReceiveNetworkPacket(
NetworkPacket *packet,
Receiver::Message *packet_message
);
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Network ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define NETWORKMANAGER_BUFFER_SIZE 1600
class NetworkManager__ReceiveEggFileMessage;
class NetworkManager:
public NetworkClient
{
//##########################################################################
// Shared Data support
//
public:
static Derivation *GetClassDerivations();
static SharedData DefaultData;
public:
typedef Enumeration GameID;
//WinSock support :ADB 01/06/07
//const NetworkAddress&
// GetAddress()
NetworkAddress* GetAddress()
{return addresses;}
NetworkManager(SharedData &shared_data);
~NetworkManager();
void
SetGameID(GameID new_id)
{gameID = new_id;}
virtual void
Send(
Message *what,
ClientID to,
HostID host_id
);
void
Broadcast(
Message *what,
ClientID to
);
virtual void
ExclusiveBroadcast(
Message *what,
ClientID to
);
Logical
RoutePacket();
virtual Logical
ExecuteBackground();
NetworkClient*
GetNetworkClientPointer(ClientID client_id);
virtual void
StartConnecting(Mission *mission);
virtual Logical
Shutdown();
virtual void
Marker(char *) {};
enum NetworkMode
{
ReliableMode,
UnreliableMode
};
virtual void
Mode(NetworkMode) {};
// protected: //GY for test only
virtual Logical
CheckBuffers(NetworkPacket*);
virtual void
RemovePacket(NetworkPacket *packet);
GameID
gameID;
//WinSock support :ADB 01/06/07
//NetworkAddress address;
NetworkAddress* addresses;
int num_addresses;
//struct addrinfo* address;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Message Support
//
public:
//
// Message IDs
//
enum
{
ReceiveEggFileMessageID = NetworkClient::NextMessageID,
NextMessageID
};
//
// Message types
//
typedef NetworkManager__ReceiveEggFileMessage
ReceiveEggFileMessage;
//
// Message table
//
static const HandlerEntry
MessageHandlerEntries[];
//static MessageHandlerSet MessageHandlers;
static MessageHandlerSet& GetMessageHandlers();
void
ReceiveEggFileMessageHandler(ReceiveEggFileMessage* EggMessage);
protected:
char
*eggTempBuffer;
NotationFile
*networkEggNotationFile;
long
eggTempNext;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~ NetworkManager messages ~~~~~~~~~~~~~~~~~~~~~~~~~
// NetworkManager__ReceiveEggFileMessage
// NOTE: this message should be setup as variable length rather than fixing the
// size at 1000, I wasn't sure how to do this and there wasn't anyone around
// to ask at the time so I did it this way temporarily.
//
class NetworkManager__ReceiveEggFileMessage:
public Receiver__Message
{
public:
NetworkManager__ReceiveEggFileMessage(
int sequence_number,
int total_file_length,
char* notation_data,
int length
):
Receiver__Message(
NetworkManager::ReceiveEggFileMessageID,
sizeof(NetworkManager__ReceiveEggFileMessage)
),
sequenceNumber(sequence_number),
notationFileLength(total_file_length),
thisMessageLength(length)
{Mem_Copy(notationData,notation_data,length,sizeof(notationData));}
int
sequenceNumber;
int
notationFileLength;
int
thisMessageLength;
char
notationData[1000];
};
//~~~~~~~~~~~~~~~~~~~~~~~~ NetworkPacketHeader ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class NetworkPacketHeader
{
public:
NetworkClient::ClientID
clientID;
NetworkManager::GameID
gameID;
HostID
fromHost;
Time
timeStamp;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ NetworkPacket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class NetworkPacket:
public NetworkPacketHeader
{
public:
Receiver::Message
messageData;
};
inline bool operator==(SOCKADDR_IN &address1, SOCKADDR_IN &address2)
{
return (address1.sin_family == address2.sin_family &&
address1.sin_addr.S_un.S_addr == address2.sin_addr.S_un.S_addr &&
address1.sin_port == address2.sin_port);
}