Skip to content

Commit

Permalink
Move CHostLookup to separate compilation unit
Browse files Browse the repository at this point in the history
The host lookup job and the engine interface are independent so they are moved to separate files.

The include of `engine.h` in `client.h` is therefore unnecessary and other includes also had to be adjusted because of this.

The variable `m_VersionServeraddr` is unused and therefore removed. The host lookup job is currently not used on the client side.
  • Loading branch information
Robyt3 committed Oct 22, 2023
1 parent 09978f3 commit b618418
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,8 @@ set_src(ENGINE_SHARED GLOB_RECURSE src/engine/shared
filecollection.cpp
filecollection.h
global_uuid_manager.cpp
host_lookup.cpp
host_lookup.h
http.cpp
http.h
huffman.cpp
Expand Down
5 changes: 3 additions & 2 deletions src/engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
#include <memory>

#include <base/hash.h>
#include <base/logger.h>

#include <engine/client.h>
#include <engine/client/checksum.h>
#include <engine/client/friends.h>
#include <engine/client/ghost.h>
#include <engine/client/serverbrowser.h>
#include <engine/client/updater.h>
#include <engine/editor.h>
#include <engine/engine.h>
#include <engine/graphics.h>
#include <engine/shared/config.h>
#include <engine/shared/demo.h>
Expand All @@ -32,6 +33,7 @@ class CMsgPacker;
class CUnpacker;
class IConfigManager;
class IDiscord;
class IEngine;
class IEngineInput;
class IEngineMap;
class IEngineSound;
Expand Down Expand Up @@ -221,7 +223,6 @@ class CClient : public IClient, public CDemoPlayer::IListener
};

int m_State;
class CHostLookup m_VersionServeraddr;
} m_VersionInfo;

std::vector<SWarning> m_vWarnings;
Expand Down
15 changes: 0 additions & 15 deletions src/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@
class CFutureLogger;
class ILogger;

class CHostLookup : public IJob
{
private:
void Run() override;

public:
CHostLookup();
CHostLookup(const char *pHostname, int Nettype);

int m_Result;
char m_aHostname[128];
int m_Nettype;
NETADDR m_Addr;
};

class IEngine : public IInterface
{
MACRO_INTERFACE("engine", 0)
Expand Down
1 change: 1 addition & 0 deletions src/engine/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <engine/shared/econ.h>
#include <engine/shared/fifo.h>
#include <engine/shared/filecollection.h>
#include <engine/shared/host_lookup.h>
#include <engine/shared/http.h>
#include <engine/shared/json.h>
#include <engine/shared/masterserver.h>
Expand Down
13 changes: 0 additions & 13 deletions src/engine/shared/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@
#include <engine/shared/network.h>
#include <engine/storage.h>

CHostLookup::CHostLookup() = default;

CHostLookup::CHostLookup(const char *pHostname, int Nettype)
{
str_copy(m_aHostname, pHostname);
m_Nettype = Nettype;
}

void CHostLookup::Run()
{
m_Result = net_host_lookup(m_aHostname, &m_Addr, m_Nettype);
}

class CEngine : public IEngine
{
public:
Expand Down
19 changes: 19 additions & 0 deletions src/engine/shared/host_lookup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */

#include "host_lookup.h"

#include <base/system.h>

CHostLookup::CHostLookup() = default;

CHostLookup::CHostLookup(const char *pHostname, int Nettype)
{
str_copy(m_aHostname, pHostname);
m_Nettype = Nettype;
}

void CHostLookup::Run()
{
m_Result = net_host_lookup(m_aHostname, &m_Addr, m_Nettype);
}
25 changes: 25 additions & 0 deletions src/engine/shared/host_lookup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#ifndef ENGINE_SHARED_HOST_LOOKUP_H
#define ENGINE_SHARED_HOST_LOOKUP_H

#include <base/system.h>

#include <engine/shared/jobs.h>

class CHostLookup : public IJob
{
private:
void Run() override;

public:
CHostLookup();
CHostLookup(const char *pHostname, int Nettype);

int m_Result;
char m_aHostname[128];
int m_Nettype;
NETADDR m_Addr;
};

#endif
1 change: 1 addition & 0 deletions src/game/client/components/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <game/generated/client_data.h>

#include <engine/console.h>
#include <engine/engine.h>
#include <engine/graphics.h>
#include <engine/keys.h>
#include <engine/shared/config.h>
Expand Down

0 comments on commit b618418

Please sign in to comment.