Skip to content

Commit

Permalink
Cleanup: Removed LegacyNetwork
Browse files Browse the repository at this point in the history
LegacyNetwork was a transitional component designed to help migrate
the network code off SDL_net. Now that both the client and the server
directly use libdeng2 Sockets to communicate, there is no need for
LegacyNetwork any more.
  • Loading branch information
skyjake committed Feb 21, 2013
1 parent 4efac5c commit 85e146c
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 591 deletions.
27 changes: 0 additions & 27 deletions doomsday/client/include/network/protocol.h
Expand Up @@ -189,33 +189,6 @@ extern "C" {
/// Largest message sendable using the protocol.
#define PROTOCOL_MAX_DATAGRAM_SIZE (1 << 22) // 4 MB

#ifdef __CLIENT__ // used with LegacyNetwork

/**
* Send the data buffer over a TCP connection.
* The data may be compressed with zlib.
*/
void Protocol_Send(void *data, size_t size, nodeid_t destination);

/**
* Read a packet from the TCP connection and put it in the incoming
* packet queue. This function blocks until the entire packet has
* been read, so large packets should be avoided during normal
* gameplay.
*
* @return @c true, if a packet was successfully received.
*/
boolean Protocol_Receive(nodeid_t from);

/**
* Free a message buffer.
*
* @param handle Message buffer received with Protocol_Receive().
*/
void Protocol_FreeBuffer(void *handle);

#endif // __CLIENT__

#ifdef __cplusplus
} // extern "C"
#endif
Expand Down
36 changes: 0 additions & 36 deletions doomsday/client/src/network/sys_network.cpp
Expand Up @@ -111,42 +111,6 @@ int N_GetHostCount(void)
return svLink.foundServerCount();
}

/*
int N_GetNodeSocket(nodeid_t id)
{
if(id) return 0;
return 1; // There is only the one socket.
}
boolean N_HasNodeJoined(nodeid_t id)
{
if(id >= MAX_NODES) return 0;
return netNodes[id].hasJoined;
}
*/

/*
void N_ClientListen(void)
{
if(!joinedSockSet) return;
// Clientside listening. On clientside, the socket set only
// includes the server's socket.
while(LegacyNetwork_SocketSet_Activity(joinedSockSet))
{
if(!Protocol_Receive(0))
{
netevent_t nev;
nev.id = 0;
nev.type = NE_END_CONNECTION;
N_NEPost(&nev);
// No point in continuing with the listener.
break;
}
}
}*/

/**
* Called from "net info" (client-side).
*/
Expand Down
1 change: 0 additions & 1 deletion doomsday/libdeng2/include/de/LegacyNetwork

This file was deleted.

24 changes: 0 additions & 24 deletions doomsday/libdeng2/include/de/c_wrapper.h
Expand Up @@ -106,30 +106,6 @@ DENG2_PUBLIC void LogBuffer_EnableStandardOutput(int enable);
DENG2_PUBLIC void LogBuffer_Flush(void);
DENG2_PUBLIC void LogBuffer_Clear(void);

/*
* LegacyNetwork
*/
DENG2_OPAQUE(LegacyNetwork)

DENG2_PUBLIC int LegacyNetwork_OpenServerSocket(unsigned short port);
DENG2_PUBLIC int LegacyNetwork_Accept(int serverSocket);
DENG2_PUBLIC int LegacyNetwork_Open(char const *ipAddress, unsigned short port);
DENG2_PUBLIC void LegacyNetwork_GetPeerAddress(int socket, char *host, int hostMaxSize, unsigned short *port);
DENG2_PUBLIC int LegacyNetwork_IsDisconnected(int socket);
DENG2_PUBLIC int LegacyNetwork_IsLocal(int socket);
DENG2_PUBLIC void LegacyNetwork_Close(int socket);

DENG2_PUBLIC int LegacyNetwork_Send(int socket, void const *data, int size);
DENG2_PUBLIC unsigned char *LegacyNetwork_Receive(int socket, int *size);
DENG2_PUBLIC void LegacyNetwork_FreeBuffer(unsigned char *buffer);
DENG2_PUBLIC int LegacyNetwork_BytesReady(int socket);

DENG2_PUBLIC int LegacyNetwork_NewSocketSet();
DENG2_PUBLIC void LegacyNetwork_DeleteSocketSet(int set);
DENG2_PUBLIC void LegacyNetwork_SocketSet_Add(int set, int socket);
DENG2_PUBLIC void LegacyNetwork_SocketSet_Remove(int set, int socket);
DENG2_PUBLIC int LegacyNetwork_SocketSet_Activity(int set);

/*
* Info
*/
Expand Down
7 changes: 0 additions & 7 deletions doomsday/libdeng2/include/de/legacy/legacycore.h
Expand Up @@ -25,8 +25,6 @@

namespace de {

class LegacyNetwork;

/**
* Transitional kernel for supporting legacy Doomsday C code in accessing
* libdeng2 functionality. The legacy engine needs to construct one of these
Expand Down Expand Up @@ -138,11 +136,6 @@ class DENG2_PUBLIC LegacyCore : public QObject
*/
static LegacyCore &instance();

/**
* Returns the legacy network subsystem interface.
*/
LegacyNetwork &network();

public slots:
void callback();

Expand Down
87 changes: 0 additions & 87 deletions doomsday/libdeng2/include/de/legacy/legacynetwork.h

This file was deleted.

7 changes: 2 additions & 5 deletions doomsday/libdeng2/legacy.pri
Expand Up @@ -2,10 +2,7 @@

HEADERS += \
include/de/LegacyCore \
include/de/LegacyNetwork \
include/de/legacy/legacycore.h \
include/de/legacy/legacynetwork.h
include/de/legacy/legacycore.h

SOURCES += \
src/legacy/legacycore.cpp \
src/legacy/legacynetwork.cpp
src/legacy/legacycore.cpp
112 changes: 0 additions & 112 deletions doomsday/libdeng2/src/c_wrapper.cpp
Expand Up @@ -21,7 +21,6 @@
#include "de/Error"
#include "de/App"
#include "de/LegacyCore"
#include "de/LegacyNetwork"
#include "de/Address"
#include "de/ByteRefArray"
#include "de/Block"
Expand Down Expand Up @@ -238,117 +237,6 @@ void LogBuffer_EnableStandardOutput(int enable)
de::LogBuffer::appBuffer().enableStandardOutput(enable != 0);
}

int LegacyNetwork_OpenServerSocket(unsigned short port)
{
try
{
return DENG2_LEGACYNETWORK().openServerSocket(port);
}
catch(de::Error const &er)
{
LOG_AS("LegacyNetwork_OpenServerSocket");
LOG_WARNING(er.asText());
return 0;
}
}

int LegacyNetwork_Accept(int serverSocket)
{
return DENG2_LEGACYNETWORK().accept(serverSocket);
}

int LegacyNetwork_Open(char const *ipAddress, unsigned short port)
{
return DENG2_LEGACYNETWORK().open(de::Address(ipAddress, port));
}

void LegacyNetwork_GetPeerAddress(int socket, char *host, int hostMaxSize, unsigned short *port)
{
de::Address peer = DENG2_LEGACYNETWORK().peerAddress(socket);
std::memset(host, 0, hostMaxSize);
std::strncpy(host, peer.host().toString().toAscii().constData(), hostMaxSize - 1);
if(port) *port = peer.port();
}

void LegacyNetwork_Close(int socket)
{
DENG2_LEGACYNETWORK().close(socket);
}

int LegacyNetwork_Send(int socket, void const *data, int size)
{
return DENG2_LEGACYNETWORK().sendBytes(
socket, de::ByteRefArray(reinterpret_cast<de::IByteArray::Byte const *>(data), size));
}

unsigned char *LegacyNetwork_Receive(int socket, int *size)
{
de::Block data;
if(DENG2_LEGACYNETWORK().receiveBlock(socket, data))
{
// Successfully got a block of data. Return a copy of it.
unsigned char *buffer = new unsigned char[data.size()];
std::memcpy(buffer, data.constData(), data.size());
*size = data.size();
return buffer;
}
else
{
// We did not receive anything.
*size = 0;
return 0;
}
}

void LegacyNetwork_FreeBuffer(unsigned char *buffer)
{
delete [] buffer;
}

int LegacyNetwork_IsDisconnected(int socket)
{
if(!socket) return 0;
return !DENG2_LEGACYNETWORK().isOpen(socket);
}

int LegacyNetwork_IsLocal(int socket)
{
if(!socket) return 0;
return DENG2_LEGACYNETWORK().isLocal(socket);
}

int LegacyNetwork_BytesReady(int socket)
{
if(!socket) return 0;
return DENG2_LEGACYNETWORK().incomingForSocket(socket);
}

int LegacyNetwork_NewSocketSet()
{
return DENG2_LEGACYNETWORK().newSocketSet();
}

void LegacyNetwork_DeleteSocketSet(int set)
{
DENG2_LEGACYNETWORK().deleteSocketSet(set);
}

void LegacyNetwork_SocketSet_Add(int set, int socket)
{
DENG2_LEGACYNETWORK().addToSet(set, socket);
}

void LegacyNetwork_SocketSet_Remove(int set, int socket)
{
DENG2_LEGACYNETWORK().removeFromSet(set, socket);
}

int LegacyNetwork_SocketSet_Activity(int set)
{
if(!set) return 0;
return DENG2_LEGACYNETWORK().checkSetForActivity(set);
}

Info *Info_NewFromString(char const *utf8text)
{
try
Expand Down
7 changes: 0 additions & 7 deletions doomsday/libdeng2/src/legacy/legacycore.cpp
Expand Up @@ -18,7 +18,6 @@
*/

#include "de/LegacyCore"
#include "de/LegacyNetwork"
#include "de/LogBuffer"
#include "de/App"

Expand Down Expand Up @@ -46,7 +45,6 @@ struct LegacyCore::Instance

App *app;
QTimer *loopTimer;
LegacyNetwork network;
Loop loop;

/// Pointer returned to callers, see LegacyCore::logFileName().
Expand Down Expand Up @@ -87,11 +85,6 @@ LegacyCore &LegacyCore::instance()
return *_appCore;
}

LegacyNetwork &LegacyCore::network()
{
return instance().d->network;
}

void LegacyCore::setLoopFunc(void (*func)(void))
{
LOG_DEBUG("Loop function changed from %p set to %p.") << dintptr(d->loop.func) << dintptr(func);
Expand Down

0 comments on commit 85e146c

Please sign in to comment.