-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPlayerLagManager.h
More file actions
40 lines (30 loc) · 883 Bytes
/
Copy pathPlayerLagManager.h
File metadata and controls
40 lines (30 loc) · 883 Bytes
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
#pragma once
#include <mathlib.h>
#include <eiface.h>
#include <inetchannel.h>
#include <amtl/am-hashmap.h>
#include "net_structures.h"
struct NetAdrHashPolicy_s {
static uint32_t hash(const dumb_netadr_t& value)
{
return *(uint32_t*)value.ip;
}
static bool matches(const dumb_netadr_t& value, const dumb_netadr_t& key)
{
return *(uint32_t*)(value.ip) == *(uint32_t*)(key.ip) && value.port == key.port && value.type == key.type;
}
};
class PlayerLagManager
{
private:
IVEngineServer* m_pEngine;
ke::HashMap<dumb_netadr_t, float, NetAdrHashPolicy_s> m_LagTimes;
const dumb_netadr_t& GetClientNetAdr(int client) const;
public:
PlayerLagManager(IVEngineServer* engine) : m_pEngine(engine) {
m_LagTimes.init(32);
}
void SetPlayerLag(int client, float lagTime);
float GetPlayerLag(int client) const;
float GetPlayerLag(const dumb_netadr_t& netadr) const;
};