UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
g_stats.cpp
Go to the documentation of this file.
1
4
5
/*
6
Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2
11
of the License, or (at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17
See the GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, 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
34
void
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
42
G_EventActorStats
(ent,
G_TeamToPM
(ent.
getTeam
()));
43
}
44
49
void
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
}
Actor
An Edict of type Actor.
Definition
g_edict.h:348
Edict
Definition
g_edict.h:45
Edict::TU
int TU
Definition
g_edict.h:88
Edict::HP
int HP
Definition
g_edict.h:89
Edict::getTeam
int getTeam() const
Definition
g_edict.h:269
Edict::setStun
void setStun(int stu)
Definition
g_edict.h:302
Edict::getStun
int getStun() const
Definition
g_edict.h:308
Edict::morale
int morale
Definition
g_edict.h:91
G_TeamToPM
playermask_t G_TeamToPM(int team)
Generates the player bit mask for a given team.
Definition
g_client.cpp:144
g_client.h
Interface for g_client.cpp.
G_EdictsGetNextActor
Actor * G_EdictsGetNextActor(Actor *lastEnt)
Iterate through the actor entities (even the dead!).
Definition
g_edicts.cpp:231
g_edicts.h
functions to handle the storage and lifecycle of all edicts in the game module.
G_EventActorStats
void G_EventActorStats(const Edict &ent, playermask_t playerMask)
Definition
g_events.cpp:383
G_PlayerToPM
#define G_PlayerToPM(player)
Definition
g_events.h:37
G_SendWoundStats
void G_SendWoundStats(Edict *const ent)
Send wound stats to network buffer.
Definition
g_health.cpp:157
g_health.h
g_local.h
Local definitions for game module.
G_SendStats
void G_SendStats(Edict &ent)
Send stats to network buffer.
Definition
g_stats.cpp:34
G_SendPlayerStats
void G_SendPlayerStats(const Player &player)
Write player stats to network buffer.
Definition
g_stats.cpp:49
src
game
g_stats.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0