summaryrefslogtreecommitdiff
path: root/src/console/a2s.h
blob: c96e445f99b881cf3af4e870017df04fb310d1a6 (plain)
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
#ifndef A2S_H
#define A2S_H

#include <stdint.h>

/*
 * A2S_INFO query (Valve Source engine query protocol).
 * Retrieves server information over UDP.
 *
 * Only used for units with health.type == HEALTH_A2S.
 */

typedef struct {
    int  players;       /* current player count */
    int  max_players;   /* server player limit */
    char map[64];       /* current map name */
} A2SInfo;

/*
 * a2s_query: Send an A2S_INFO request and parse the response.
 *
 * Returns 0 on success with *out populated.
 * Returns -1 on timeout, parse error, or any network failure.
 */
int a2s_query(const char *host, uint16_t port, int timeout_ms, A2SInfo *out);

#endif /* A2S_H */