UFO: Alien Invasion
Loading...
Searching...
No Matches
g_stats.cpp
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#include "g_local.h"
26#include "g_client.h"
27#include "g_edicts.h"
28#include "g_health.h"
29
34void G_SendStats (Edict& ent)
35{
36 /* extra sanity checks */
37 assert(ent.TU >= 0);
38 ent.HP = std::max(ent.HP, 0);
39 ent.setStun(std::min(ent.getStun(), 255));
40 ent.morale = std::max(ent.morale, 0);
41
43}
44
49void G_SendPlayerStats (const Player& player)
50{
51 Actor* actor = nullptr;
52
53 while ((actor = G_EdictsGetNextActor(actor)))
54 if (actor->getTeam() == player.getTeam()) {
55 G_EventActorStats(*actor, G_PlayerToPM(player));
56 G_SendWoundStats(actor);
57 }
58}
An Edict of type Actor.
Definition g_edict.h:348
int TU
Definition g_edict.h:88
int HP
Definition g_edict.h:89
int getTeam() const
Definition g_edict.h:269
void setStun(int stu)
Definition g_edict.h:302
int getStun() const
Definition g_edict.h:308
int morale
Definition g_edict.h:91
playermask_t G_TeamToPM(int team)
Generates the player bit mask for a given team.
Definition g_client.cpp:144
Interface for g_client.cpp.
Actor * G_EdictsGetNextActor(Actor *lastEnt)
Iterate through the actor entities (even the dead!).
Definition g_edicts.cpp:231
functions to handle the storage and lifecycle of all edicts in the game module.
void G_EventActorStats(const Edict &ent, playermask_t playerMask)
Definition g_events.cpp:383
#define G_PlayerToPM(player)
Definition g_events.h:37
void G_SendWoundStats(Edict *const ent)
Send wound stats to network buffer.
Definition g_health.cpp:157
Local definitions for game module.
void G_SendStats(Edict &ent)
Send stats to network buffer.
Definition g_stats.cpp:34
void G_SendPlayerStats(const Player &player)
Write player stats to network buffer.
Definition g_stats.cpp:49