UFO: Alien Invasion
Doxygen documentation generating
g_stats.cpp
Go to the documentation of this file.
1 
5 /*
6 Copyright (C) 2002-2023 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 
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 }
int TU
Definition: g_edict.h:88
void G_SendStats(Edict &ent)
Send stats to network buffer.
Definition: g_stats.cpp:34
int morale
Definition: g_edict.h:91
Definition: g_edict.h:45
#define G_PlayerToPM(player)
Definition: g_events.h:37
int getTeam() const
Definition: g_edict.h:269
void G_EventActorStats(const Edict &ent, playermask_t playerMask)
Definition: g_events.cpp:383
int HP
Definition: g_edict.h:89
void setStun(int stu)
Definition: g_edict.h:302
Actor * G_EdictsGetNextActor(Actor *lastEnt)
Iterate through the actor entities (even the dead!)
Definition: g_edicts.cpp:231
Local definitions for game module.
functions to handle the storage and lifecycle of all edicts in the game module.
An Edict of type Actor.
Definition: g_edict.h:348
int getStun() const
Definition: g_edict.h:308
void G_SendWoundStats(Edict *const ent)
Send wound stats to network buffer.
Definition: g_health.cpp:157
Interface for g_client.cpp.
playermask_t G_TeamToPM(int team)
Generates the player bit mask for a given team.
Definition: g_client.cpp:144
void G_SendPlayerStats(const Player &player)
Write player stats to network buffer.
Definition: g_stats.cpp:49