Skip to content

Commit

Permalink
Remove no longer used "lossy distribution" net code
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolfering committed Oct 11, 2024
1 parent 27f9ed4 commit 33032c3
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 484 deletions.
3 changes: 0 additions & 3 deletions Source_Files/Network/NetworkGameProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ class NetworkGameProtocol
public:
/* Distribute information to the whole net. */
virtual bool Enter(short* inNetStatePtr) = 0;
virtual void Exit1() = 0;
virtual void Exit2() = 0;
virtual void DistributeInformation(short type, void *buffer, short buffer_size, bool send_to_self, bool only_send_to_team) = 0;
virtual bool Sync(NetTopology* inTopology, int32 inSmallestGameTick, int inLocalPlayerIndex, bool isServer) = 0;
virtual bool UnSync(bool inGraceful, int32 inSmallestPostgameTick) = 0;
virtual int32 GetNetTime() = 0;
Expand Down
40 changes: 0 additions & 40 deletions Source_Files/Network/StarGameProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,6 @@ StarGameProtocol::Enter(short* inNetStatePtr)
return true;
}



void
StarGameProtocol::Exit1()
{
// return true;
}



void
StarGameProtocol::Exit2()
{
// return true;
}



void
StarGameProtocol::DistributeInformation(short type, void *buffer, short buffer_size, bool send_to_self, bool only_send_to_team)
{
const NetDistributionInfo* theInfo = NetGetDistributionInfoForType(type);
if(theInfo != NULL && theInfo->lossy)
spoke_distribute_lossy_streaming_bytes_to_everyone(type, static_cast<byte*>(buffer), buffer_size, !send_to_self, only_send_to_team);
}



void
StarGameProtocol::PacketHandler(DDPPacketBufferPtr packet)
{
Expand Down Expand Up @@ -248,18 +220,6 @@ make_player_really_net_dead(size_t inPlayerIndex)
sTopology->players[inPlayerIndex].net_dead = true;
}



void
call_distribution_response_function_if_available(byte* inBuffer, uint16 inBufferSize, int16 inDistributionType, uint8 inSendingPlayerIndex)
{
const NetDistributionInfo* theInfo = NetGetDistributionInfoForType(inDistributionType);
if(theInfo != NULL)
theInfo->distribution_proc(inBuffer, inBufferSize, inSendingPlayerIndex);
}



void
StarGameProtocol::ParsePreferencesTree(InfoTree prefs, std::string version)
{
Expand Down
3 changes: 0 additions & 3 deletions Source_Files/Network/StarGameProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class StarGameProtocol : public NetworkGameProtocol
{
public:
bool Enter(short* inNetStatePtr);
void Exit1();
void Exit2();
void DistributeInformation(short type, void *buffer, short buffer_size, bool send_to_self, bool only_send_to_team);
bool Sync(NetTopology* inTopology, int32 inSmallestGameTick, int inLocalPlayerIndex, bool isServer);
bool UnSync(bool inGraceful, int32 inSmallestPostgameTick);
int32 GetNetTime();
Expand Down
61 changes: 1 addition & 60 deletions Source_Files/Network/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@ struct ignore_lua
// ZZZ note: read this externally with the NetState() function.
static short netState= netUninitialized;

// ZZZ change: now using an STL 'map' to, well, _map_ distribution types to info records.
typedef std::map<int16, NetDistributionInfo> distribution_info_map_t;
static distribution_info_map_t distribution_info_map;

// ZZZ: are we trying to start a new game or resume a saved-game?
// This is only valid on the gatherer after NetGather() is called;
// only valid on a joiner once he receives the final topology (tagRESUME_GAME)
Expand Down Expand Up @@ -1349,9 +1345,7 @@ void NetExit(
void)
{
OSErr error = noErr;

sCurrentGameProtocol->Exit1();


// ZZZ: clean up SDL Time Manager emulation.
// true says wait for any late finishers to finish
// (but does NOT say to kill anyone not already removed.)
Expand All @@ -1362,9 +1356,6 @@ void NetExit(
if (!error) {
free(topology);
topology= NULL;

sCurrentGameProtocol->Exit2();

netState= netUninitialized;
} else {
logAnomaly("NetDDPCloseSocket returned %i", error);
Expand Down Expand Up @@ -1447,56 +1438,6 @@ NetRemovePinger()
}


/* Add a function for a distribution type. returns the type, or NONE if it can't be
* installed. It's safe to call this function multiple times for the same proc. */
// ZZZ: changed to take in the desired type, so a given machine can handle perhaps only some
// of the distribution types.
void
NetAddDistributionFunction(int16 inDataTypeID, NetDistributionProc inProc, bool inLossy) {
// We don't support lossless distribution yet.
assert(inLossy);

// Prepare a NetDistributionInfo with the desired data.
NetDistributionInfo theInfo;
theInfo.lossy = inLossy;
theInfo.distribution_proc = inProc;

// Insert or update a map entry
distribution_info_map[inDataTypeID] = theInfo;
}


/* Remove a distribution proc that has been installed. */
void
NetRemoveDistributionFunction(int16 inDataTypeID) {
distribution_info_map.erase(inDataTypeID);
}


const NetDistributionInfo*
NetGetDistributionInfoForType(int16 inType)
{
distribution_info_map_t::const_iterator theEntry = distribution_info_map.find(inType);
if(theEntry != distribution_info_map.end())
return &(theEntry->second);
else
return NULL;
}




void NetDistributeInformation(
short type,
void *buffer,
short buffer_size,
bool send_to_self,
bool only_send_to_team)
{
sCurrentGameProtocol->DistributeInformation(type, buffer, buffer_size, send_to_self, only_send_to_team);
}


short NetState(
void)
{
Expand Down
26 changes: 0 additions & 26 deletions Source_Files/Network/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ Tuesday, June 21, 1994 3:26:46 PM
// change this if you make a major change to the way the setup messages work
#define kNetworkSetupProtocolID "Aleph One WonderNAT V2"

// ZZZ: there probably should be a published max size somewhere, but this isn't used anywhere; better
// not to pretend it's real.
//#define MAX_NET_DISTRIBUTION_BUFFER_SIZE 512

enum // base network speeds
{
_appletalk_remote, // ARA
Expand Down Expand Up @@ -187,8 +183,6 @@ enum /* states */
};

/* -------- typedefs */
// player index is the index of the player that is sending the information
typedef void (*NetDistributionProc)(void *buffer, short buffer_size, short player_index);
typedef void (*CheckPlayerProcPtr)(short player_index, short num_players);

/* --------- prototypes/NETWORK.C */
Expand Down Expand Up @@ -235,19 +229,6 @@ std::weak_ptr<Pinger> NetGetPinger();
void NetCreatePinger();
void NetRemovePinger();

// ghs: these are obsolete, I'll get rid of them when I'm sure I won't want
// to refer back to them

// ZZZ addition - pre-game/(eventually) postgame chat
// Returns true if there was a pending message.
// Returns pointer to chat text.
// Returns pointer to sending player's data (does not copy player data).
// Data returned in pointers is only good until the next call to NetUpdateJoinState or NetCheckForIncomingMessages.
bool NetGetMostRecentChatMessage(player_info** outSendingPlayerData, char** outMessage);

// Gatherer should use this to send out his messages or to broadcast a message received from a joiner
OSErr NetDistributeChatMessage(short sender_identifier, const char* message);

void NetProcessMessagesInGame();

short NetGetLocalPlayerIndex(void);
Expand Down Expand Up @@ -284,13 +265,6 @@ void construct_multiplayer_starts(player_start_data* outStartArray, short* outSt
void match_starts_with_existing_players(player_start_data* ioStartArray, short* ioStartCount);
void display_net_game_stats(void);

// ZZZ change: caller specifies int16 ID for distribution type. Unknown types (when received) are
// passed along but ignored. Uses an STL 'map' so ID's need not be consecutive or in any particular
// sub-range.
void NetAddDistributionFunction(int16 type, NetDistributionProc proc, bool lossy);
void NetDistributeInformation(short type, void *buffer, short buffer_size, bool send_to_self, bool send_only_to_team = false);
void NetRemoveDistributionFunction(short type);

// disable "cheats"
bool NetAllowCrosshair();
bool NetAllowOverlayMap();
Expand Down
25 changes: 6 additions & 19 deletions Source_Files/Network/network_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ enum /* error string for user */
#define MAP_TRANSFER_TIME_OUT (MACHINE_TICKS_PER_SECOND*70) // 70 seconds to wait for map.

enum /* tag */
{ // ZZZ annotation: these (in NetPacketHeader) indicate the rest of the datagram is a NetPacket (i.e. a ring packet).
tagRING_PACKET,
tagACKNOWLEDGEMENT,
tagCHANGE_RING_PACKET, // to tell a player to change his downring address. also has action flags.
{
tagRING_PACKET, //obsolete
tagACKNOWLEDGEMENT, //obsolete
tagCHANGE_RING_PACKET, //obsolete

// ZZZ annotation: these should only be found in streaming data (in a NetTopology).
tagNEW_PLAYER,
Expand All @@ -109,8 +109,8 @@ enum /* tag */
tagCHANGED_PLAYER,

// ZZZ annotation: these (in NetPacketHeader) indicate the rest of the datagram is a NetDistributionPacket.
tagLOSSY_DISTRIBUTION, // for transfer data other than action flags
tagLOSSLESS_DISTRIBUTION, // ditto, but currently unimplemented
tagLOSSY_DISTRIBUTION, //obsolete
tagLOSSLESS_DISTRIBUTION, //obsolete

// ZZZ: more streaming data (topology) packet types
tagRESUME_GAME // ZZZ addition: trying to resume a saved-game rather than start a new netgame.
Expand Down Expand Up @@ -159,15 +159,6 @@ struct NetTopology
};
typedef struct NetTopology NetTopology, *NetTopologyPtr;

// ZZZ: same here (should be safe to alter)
struct NetDistributionInfo
{
bool lossy;
NetDistributionProc distribution_proc;
};

typedef struct NetDistributionInfo NetDistributionInfo, *NetDistributionInfoPtr;

/* ===== application specific data structures/enums */

// Altering these constants requires changes to get_network_version(). - Woody
Expand All @@ -193,12 +184,8 @@ enum {
class CommunicationsChannel;
class MessageDispatcher;
class MessageHandler;

class Message;


const NetDistributionInfo* NetGetDistributionInfoForType(int16 inType);

struct ClientChatInfo
{
std::string name;
Expand Down
8 changes: 0 additions & 8 deletions Source_Files/Network/network_star.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ enum {
kEndOfMessagesMessageType = 0x454d, // 'EM'
kTimingAdjustmentMessageType = 0x5441, // 'TA'
kPlayerNetDeadMessageType = 0x4e44, // 'ND'
kSpokeToHubLossyByteStreamMessageType = 0x534c, // 'SL'
kHubToSpokeLossyByteStreamMessageType = 0x484c, // 'HL'

kSpokeToHubIdentification = 0x4944, // 'ID'
kSpokeToHubGameDataPacketV1Magic = 0x5331, // 'S1'
Expand Down Expand Up @@ -79,13 +77,7 @@ extern void spoke_initialize(const NetAddrBlock& inHubAddress, int32 inFirstTick
extern void spoke_cleanup(bool inGraceful);
extern void spoke_received_network_packet(DDPPacketBufferPtr inPacket);
extern int32 spoke_get_net_time();
// "Distribute to everyone" helps to match the existing (legacy) interfaces etc.
extern void spoke_distribute_lossy_streaming_bytes_to_everyone(int16 inDistributionType, byte* inBytes, uint16 inLength, bool inExcludeLocalPlayer, bool onlySendToTeam);
// distribute_lossy_streaming_bytes offers a more direct interface (not yet used) to star's lossy
// distribution mechanism. (e.g., can select certain recipients, send unregistered dist types, etc.)
extern void spoke_distribute_lossy_streaming_bytes(int16 inDistributionType, uint32 inDestinationsBitmask, byte* inBytes, uint16 inLength);
extern int32 spoke_latency(); // in ms, kNetLatencyInvalid if not yet valid
extern int32 hub_latency(int player_index); // in ms, kNetLatencyInvalid if not valid, kNetLatencyDisconnected if d/c
extern TickBasedActionQueue* spoke_get_unconfirmed_flags_queue();
extern int32 spoke_get_smallest_unconfirmed_tick();
extern bool spoke_check_world_update();
Expand Down
Loading

0 comments on commit 33032c3

Please sign in to comment.