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
73
74
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#include "ServerInfoMsgHandler.h"
#include "serverinfo.h"
#include "info.h"
extern void v_strncpy(char *dest, const char *src, int bufsize);
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CServerInfoMsgHandlerDetails::CServerInfoMsgHandlerDetails( CServerInfo *baseobject, HANDLERTYPE type, void *typeinfo /*= NULL*/ )
: CMsgHandler( type, typeinfo )
{
m_pServerInfo = baseobject;
}
//-----------------------------------------------------------------------------
// Purpose: Process cracked message
//-----------------------------------------------------------------------------
bool CServerInfoMsgHandlerDetails::Process( netadr_t *from, CMsgBuffer *msg )
{
// Skip the control character
msg->ReadByte();
// get response name
const char *str = msg->ReadString();
if ( !str || !str[0] )
return false;
// get infostring
str = msg->ReadString();
if ( !str || !str[0] )
return false;
char info[ 2048 ];
strncpy( info, str, 2047 );
info[2047] = 0;
char name[256], map[256], gamedir[256], desc[256];
v_strncpy(name, Info_ValueForKey(info, "hostname"), 255);
v_strncpy(map, Info_ValueForKey(info, "map"), 255);
v_strncpy(gamedir, Info_ValueForKey(info, "gamedir"), 255);
strlwr(gamedir);
v_strncpy(desc, Info_ValueForKey(info, "description"), 255);
int players = atoi(Info_ValueForKey(info, "players"));
int maxplayers = atoi(Info_ValueForKey(info, "max"));
char serverType = *Info_ValueForKey(info, "type");
bool password = atoi(Info_ValueForKey(info, "password"));
m_pServerInfo->UpdateServer(from, // index of server
(serverType == 'p'),
name,
map,
gamedir,
desc,
players,
maxplayers,
msg->GetTime(), // receive time
password
);
return true;
}
|