diff options
Diffstat (limited to 'src/server.cpp')
| -rw-r--r-- | src/server.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/server.cpp b/src/server.cpp index bae355e..6479b25 100644 --- a/src/server.cpp +++ b/src/server.cpp | |||
| @@ -58,6 +58,7 @@ static int g_srv_mapname = -1; | |||
| 58 | static int g_srv_armor = -1; | 58 | static int g_srv_armor = -1; |
| 59 | static int g_srv_detonate = -1; | 59 | static int g_srv_detonate = -1; |
| 60 | static int g_srv_grenade_radius = -1; | 60 | static int g_srv_grenade_radius = -1; |
| 61 | static int g_srv_juice = -1; | ||
| 61 | static int g_srv_ammo = -1; | 62 | static int g_srv_ammo = -1; |
| 62 | static int g_srv_myweapons = -1; | 63 | static int g_srv_myweapons = -1; |
| 63 | static bool g_srv_ready = false; | 64 | static bool g_srv_ready = false; |
| @@ -162,6 +163,7 @@ bool resolve_server_netvars() { | |||
| 162 | // CBaseGrenade fuse / blast radius (m_flDetonateTime is not networked). | 163 | // CBaseGrenade fuse / blast radius (m_flDetonateTime is not networked). |
| 163 | g_srv_detonate = datamap_offset("m_flDetonateTime", FIELD_TIME); | 164 | g_srv_detonate = datamap_offset("m_flDetonateTime", FIELD_TIME); |
| 164 | g_srv_grenade_radius = datamap_offset("m_DmgRadius", FIELD_FLOAT); | 165 | g_srv_grenade_radius = datamap_offset("m_DmgRadius", FIELD_FLOAT); |
| 166 | g_srv_juice = datamap_offset("m_iJuice", FIELD_INTEGER); | ||
| 165 | // CBaseCombatCharacter arrays: ammo counts and the weapon handle list. | 167 | // CBaseCombatCharacter arrays: ammo counts and the weapon handle list. |
| 166 | g_srv_ammo = datamap_offset("m_iAmmo", FIELD_INTEGER, 0x40, 0x4000); | 168 | g_srv_ammo = datamap_offset("m_iAmmo", FIELD_INTEGER, 0x40, 0x4000); |
| 167 | g_srv_myweapons = datamap_offset("m_hMyWeapons", FIELD_EHANDLE); | 169 | g_srv_myweapons = datamap_offset("m_hMyWeapons", FIELD_EHANDLE); |
| @@ -171,13 +173,13 @@ bool resolve_server_netvars() { | |||
| 171 | "modelindex=%d absvel=%d vel=%d activeweapon=%d relationship=%d " | 173 | "modelindex=%d absvel=%d vel=%d activeweapon=%d relationship=%d " |
| 172 | "followtarget=%d spawnflags=%d hacked=%d npcstate=%d " | 174 | "followtarget=%d spawnflags=%d hacked=%d npcstate=%d " |
| 173 | "takedamage=%d mapname=%d armor=%d detonate=%d dmgradius=%d " | 175 | "takedamage=%d mapname=%d armor=%d detonate=%d dmgradius=%d " |
| 174 | "ammo=%d myweapons=%d", | 176 | "ammo=%d myweapons=%d juice=%d", |
| 175 | g_server.path.c_str(), g_srv_health, g_srv_maxhealth, g_srv_lifestate, | 177 | g_server.path.c_str(), g_srv_health, g_srv_maxhealth, g_srv_lifestate, |
| 176 | g_srv_modelindex, g_srv_absvelocity, g_srv_velocity, | 178 | g_srv_modelindex, g_srv_absvelocity, g_srv_velocity, |
| 177 | g_srv_activeweapon, g_srv_relationship, g_srv_followtarget, | 179 | g_srv_activeweapon, g_srv_relationship, g_srv_followtarget, |
| 178 | g_srv_spawnflags, g_srv_hacked, g_srv_npcstate, g_srv_takedamage, | 180 | g_srv_spawnflags, g_srv_hacked, g_srv_npcstate, g_srv_takedamage, |
| 179 | g_srv_mapname, g_srv_armor, g_srv_detonate, g_srv_grenade_radius, | 181 | g_srv_mapname, g_srv_armor, g_srv_detonate, g_srv_grenade_radius, |
| 180 | g_srv_ammo, g_srv_myweapons); | 182 | g_srv_ammo, g_srv_myweapons, g_srv_juice); |
| 181 | fail_logged = false; | 183 | fail_logged = false; |
| 182 | } else if (!fail_logged) { | 184 | } else if (!fail_logged) { |
| 183 | fail_logged = true; | 185 | fail_logged = true; |
| @@ -475,6 +477,18 @@ float server_grenade_radius(int idx) { | |||
| 475 | return *(float *)((uintptr_t)base + g_srv_grenade_radius); | 477 | return *(float *)((uintptr_t)base + g_srv_grenade_radius); |
| 476 | } | 478 | } |
| 477 | 479 | ||
| 480 | // CWallHealth / CNewRecharge share the same m_iJuice layout (the fields before | ||
| 481 | // it match), so one datamap offset works for both health and suit chargers. | ||
| 482 | int server_item_juice(int idx) { | ||
| 483 | if (!g_srv_ready || g_srv_juice < 0) | ||
| 484 | return -1; | ||
| 485 | void *base = nullptr; | ||
| 486 | server_entity_health(idx, nullptr, nullptr, &base); | ||
| 487 | if (!base) | ||
| 488 | return -1; | ||
| 489 | return *(int *)((uintptr_t)base + g_srv_juice); | ||
| 490 | } | ||
| 491 | |||
| 478 | // Server-side CBaseCombatCharacter::m_iAmmo array (reserve ammo). The datamap | 492 | // Server-side CBaseCombatCharacter::m_iAmmo array (reserve ammo). The datamap |
| 479 | // offset points at the CNetworkArray length header; the elements start 4 bytes | 493 | // offset points at the CNetworkArray length header; the elements start 4 bytes |
| 480 | // later (confirmed by the shifted current/max table). | 494 | // later (confirmed by the shifted current/max table). |
