Skip to content

Commit

Permalink
Initial Linux build fixes
Browse files Browse the repository at this point in the history
- Moved libs/clsocket to be in the same radiant/gameconnection directory as the
  code which uses it (similar to the picomodel library). The whole
  radiant/gameconnection directory could be moved into a separate plugin at a
  later date.
- Added all of the new .cpp files to radiant/Makefile.am
- Fixed some typical Windows-to-Linux compilation issues (missing #includes,
  incorrect #include case etc).
- Use correct macro for detecting Linux in clsocket library (__linux__ instead
  of _LINUX)
- Added missing "#pragma once" to a couple of headers (not causing any problems
  but better to be safe).
  • Loading branch information
Matthew Mott committed Sep 1, 2020
1 parent 924f038 commit 83e4028
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 26 deletions.
7 changes: 7 additions & 0 deletions radiant/Makefile.am
Expand Up @@ -113,6 +113,13 @@ darkradiant_SOURCES = main.cpp \
fonts/GlyphInfo.cpp \
fonts/GlyphSet.cpp \
fonts/FontManager.cpp \
gameconnection/DiffDoom3MapWriter.cpp \
gameconnection/GameConnection.cpp \
gameconnection/MapObserver.cpp \
gameconnection/MessageTcp.cpp \
gameconnection/clsocket/ActiveSocket.cpp \
gameconnection/clsocket/PassiveSocket.cpp \
gameconnection/clsocket/SimpleSocket.cpp \
image/dds.cpp \
image/ddslib.cpp \
image/Doom3ImageLoader.cpp \
Expand Down
2 changes: 2 additions & 0 deletions radiant/gameconnection/DiffDoom3MapWriter.cpp
@@ -1,6 +1,8 @@
#include "DiffDoom3MapWriter.h"
#include "DiffStatus.h"

#include "ientity.h"

namespace map
{

Expand Down
2 changes: 2 additions & 0 deletions radiant/gameconnection/DiffDoom3MapWriter.h
@@ -1,5 +1,7 @@
#pragma once

#include <map>

#include "map/format/Doom3MapWriter.h"

namespace map
Expand Down
10 changes: 7 additions & 3 deletions radiant/gameconnection/DiffStatus.h
@@ -1,12 +1,16 @@
#pragma
#pragma once

namespace map {
#include <map>

namespace map
{

/**
* Represents the change of status of some object.
* Used mainly to write map diff for hot reload feature.
*/
class DiffStatus {
class DiffStatus
{
//change in presence:
// -1: removed
// 1: added
Expand Down
10 changes: 5 additions & 5 deletions radiant/gameconnection/GameConnection.cpp
@@ -1,16 +1,16 @@
#include "GameConnection.h"
#include "MessageTCP.h"
#include "Camera/GlobalCamera.h"
#include "MessageTcp.h"
#include "camera/GlobalCamera.h"
#include "inode.h"
#include "ientity.h"
#include "map/Map.h"
#include "selection/RadiantSelectionSystem.h"
#include "modulesystem/StaticModule.h"
#include <sigc++/signal.h>
#include <../libs/clsocket/ActiveSocket.h>
#include "clsocket/ActiveSocket.h"


namespace gameconn {
namespace gameconn
{

//this is how often this class "thinks" when idle
static const int THINK_INTERVAL = 123;
Expand Down
3 changes: 3 additions & 0 deletions radiant/gameconnection/GameConnection.h
@@ -1,8 +1,11 @@
#pragma once

#include "igameconnection.h"
#include "icommandsystem.h"
#include "iscenegraph.h"
#include "MapObserver.h"

#include <wx/timer.h>

class CameraObserver;
namespace sigc {
Expand Down
9 changes: 7 additions & 2 deletions radiant/gameconnection/MapObserver.h
@@ -1,15 +1,20 @@
#pragma once

#include "icommandsystem.h"
#include "iscenegraph.h"
#include "ientity.h"
#include "DiffStatus.h"

namespace gameconn {
namespace gameconn
{

/**
* Private for GameConnection class: do not use directly!
* Observer for "update map" / "hot reload" feature.
* It follows all changes done to the map, remembering entities to be included into diff on next map update.
*/
class MapObserver {
class MapObserver
{
public:
~MapObserver();

Expand Down
6 changes: 3 additions & 3 deletions radiant/gameconnection/MessageTcp.cpp
@@ -1,10 +1,10 @@
#include "MessageTcp.h"
#include <assert.h>
#include "itextstream.h"
#include <../libs/clsocket/ActiveSocket.h>
#include "clsocket/ActiveSocket.h"


namespace gameconn {
namespace gameconn
{

MessageTcp::~MessageTcp() {}
MessageTcp::MessageTcp() {}
Expand Down
File renamed without changes.
File renamed without changes.
Expand Up @@ -61,7 +61,7 @@ extern "C"
#define __WORDSIZE 32
#endif

#if defined(_LINUX) || defined(_DARWIN)
#if defined(__linux__) || defined(_DARWIN)
typedef unsigned char uint8;
typedef char int8;
typedef unsigned short uint16;
Expand Down Expand Up @@ -176,7 +176,7 @@ extern "C"
#define GETHOSTBYNAME(a) gethostbyname(a)
#endif

#if defined(_LINUX) || defined(_DARWIN)
#if defined(__linux__) || defined(_DARWIN)
#define ACCEPT(a,b,c) accept(a,b,c)
#define CONNECT(a,b,c) connect(a,b,c)
#define CLOSE(a) close(a)
Expand Down
File renamed without changes.
File renamed without changes.
Expand Up @@ -92,7 +92,7 @@ CSimpleSocket::CSimpleSocket(CSocketType nType) :
//----------------------------------------------------------------------
case CSimpleSocket::SocketTypeRaw:
{
#if defined(_LINUX) && !defined(_DARWIN)
#if defined(__linux__) && !defined(_DARWIN)
m_nSocketDomain = AF_PACKET;
m_nSocketType = CSimpleSocket::SocketTypeRaw;
#endif
Expand Down Expand Up @@ -947,7 +947,7 @@ int32 CSimpleSocket::SendFile(int32 nOutFd, int32 nInFd, off_t *pOffset, int32 n
//------------------------------------------------------------------------------
void CSimpleSocket::TranslateSocketError(void)
{
#if defined(_LINUX) || defined(_DARWIN)
#if defined(__linux__) || defined(_DARWIN)
switch (errno)
{
case EXIT_SUCCESS:
Expand Down
Expand Up @@ -49,15 +49,15 @@
#include <stdarg.h>
#include <errno.h>

#if defined(_LINUX) || defined (_DARWIN)
#if defined(__linux__) || defined (_DARWIN)
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <netdb.h>
#endif
#ifdef _LINUX
#ifdef __linux__
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <linux/if.h>
Expand All @@ -66,7 +66,7 @@
#ifdef _DARWIN
#include <net/if.h>
#endif
#if defined(_LINUX) || defined (_DARWIN)
#if defined(__linux__) || defined (_DARWIN)
#include <sys/time.h>
#include <sys/uio.h>
#include <unistd.h>
Expand Down
Expand Up @@ -50,7 +50,7 @@
#include <time.h>
#endif

#ifdef _LINUX
#ifdef __linux__
#include <stdio.h>
#include <sys/time.h>
#endif
Expand Down Expand Up @@ -90,19 +90,19 @@ class CStatTimer {
struct timeval GetEndTime() { return m_endTime; };
void SetEndTime() { GET_CLOCK_COUNT(&m_endTime); };

uint32 GetMilliSeconds() { return (CalcTotalUSec() / MILLISECONDS_CONVERSION); };
uint32 GetMicroSeconds() { return (CalcTotalUSec()); };
uint32 GetSeconds() { return (CalcTotalUSec() / MICROSECONDS_CONVERSION); };
uint32_t GetMilliSeconds() { return (CalcTotalUSec() / MILLISECONDS_CONVERSION); };
uint32_t GetMicroSeconds() { return (CalcTotalUSec()); };
uint32_t GetSeconds() { return (CalcTotalUSec() / MICROSECONDS_CONVERSION); };

uint32 GetCurrentTime()
uint32_t GetCurrentTime()
{
struct timeval tmpTime;
GET_CLOCK_COUNT(&tmpTime);
return ((tmpTime.tv_sec * MICROSECONDS_CONVERSION) + tmpTime.tv_usec);
};

private:
uint32 CalcTotalUSec() { return (((m_endTime.tv_sec - m_startTime.tv_sec) * MICROSECONDS_CONVERSION) +
uint32_t CalcTotalUSec() { return (((m_endTime.tv_sec - m_startTime.tv_sec) * MICROSECONDS_CONVERSION) +
(m_endTime.tv_usec - m_startTime.tv_usec)); };


Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions radiant/ui/UserInterfaceModule.cpp
Expand Up @@ -160,6 +160,8 @@ void UserInterfaceModule::registerUICommands()
GlobalCommandSystem().addCommand("EntityClassTree", EClassTree::ShowDialog);
GlobalCommandSystem().addCommand("EntityList", EntityList::toggle);

// FIXME: should not dynamic_cast, required methods should be in the
// IGameConnection interface
if (GameConnection *gameconn = dynamic_cast<GameConnection*>(GlobalGameConnection())) {
GlobalCommandSystem().addCommand("GameConnectionCameraSyncEnable",
[gameconn](const cmd::ArgumentList&) { gameconn->setCameraSyncEnabled(true); });
Expand Down

0 comments on commit 83e4028

Please sign in to comment.