1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* (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 <base/system.h>
#include <engine/engine.h>
#include <engine/shared/config.h>
#include <engine/shared/network.h>
#include <engine/console.h>
static int HostLookupThread(void *pUser)
{
CHostLookup *pLookup = (CHostLookup *)pUser;
net_host_lookup(pLookup->m_aHostname, &pLookup->m_Addr, NETTYPE_IPV4);
return 0;
}
class CEngine : public IEngine
{
public:
/*
static void con_dbg_dumpmem(IConsole::IResult *result, void *user_data)
{
mem_debug_dump();
}
static void con_dbg_lognetwork(IConsole::IResult *result, void *user_data)
{
CNetBase::OpenLog("network_sent.dat", "network_recv.dat");
}*/
CEngine(const char *pAppname)
{
dbg_logger_stdout();
dbg_logger_debugger();
//
dbg_msg("engine", "running on %s-%s-%s", CONF_FAMILY_STRING, CONF_PLATFORM_STRING, CONF_ARCH_STRING);
#ifdef CONF_ARCH_ENDIAN_LITTLE
dbg_msg("engine", "arch is little endian");
#elif defined(CONF_ARCH_ENDIAN_BIG)
dbg_msg("engine", "arch is big endian");
#else
dbg_msg("engine", "unknown endian");
#endif
// init the network
net_init();
CNetBase::Init();
m_HostLookupPool.Init(1);
//MACRO_REGISTER_COMMAND("dbg_dumpmem", "", CFGFLAG_SERVER|CFGFLAG_CLIENT, con_dbg_dumpmem, 0x0, "Dump the memory");
//MACRO_REGISTER_COMMAND("dbg_lognetwork", "", CFGFLAG_SERVER|CFGFLAG_CLIENT, con_dbg_lognetwork, 0x0, "Log the network");
}
void InitLogfile()
{
// open logfile if needed
if(g_Config.m_Logfile[0])
dbg_logger_file(g_Config.m_Logfile);
}
void HostLookup(CHostLookup *pLookup, const char *pHostname)
{
str_copy(pLookup->m_aHostname, pHostname, sizeof(pLookup->m_aHostname));
m_HostLookupPool.Add(&pLookup->m_Job, HostLookupThread, pLookup);
}
};
IEngine *CreateEngine(const char *pAppname) { return new CEngine(pAppname); }
|