UFO: Alien Invasion
Loading...
Searching...
No Matches
e_event_results.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 "../../../../client.h"
27#include "e_event_results.h"
28
29int CL_ParseResultsTime (const struct eventRegister_s* self, dbuffer* msg, eventTiming_t* eventTiming)
30{
31 return eventTiming->nextTime + 1400;
32}
33
40void CL_ParseResults (const eventRegister_t* self, dbuffer* msg)
41{
42 /* get number of teams */
43 const int num = NET_ReadByte(msg);
44 if (num > MAX_TEAMS)
45 Com_Error(ERR_DROP, "Too many teams in result message");
46
47 Com_DPrintf(DEBUG_CLIENT, "Receiving results with %i teams.\n", num);
48
49 /* get winning team */
50 const int winner = NET_ReadByte(msg);
51 const bool nextmap = NET_ReadByte(msg);
52
53 if (cls.team > num)
54 Com_Error(ERR_DROP, "Team number %d too high (only %d teams)", cls.team, num);
55
56 /* get spawn and alive count */
57 int num_spawned[MAX_TEAMS];
58 int num_alive[MAX_TEAMS];
59 OBJZERO(num_spawned);
60 OBJZERO(num_alive);
61 for (int i = 0; i < num; i++) {
62 num_spawned[i] = NET_ReadByte(msg);
63 num_alive[i] = NET_ReadByte(msg);
64 }
65
66 /* get kills */
67 /* the first dimension contains the attacker team, the second the victim team */
68 int num_kills[MAX_TEAMS + 1][MAX_TEAMS];
69 OBJZERO(num_kills);
70 for (int i = 0; i <= num; i++)
71 for (int j = 0; j < num; j++)
72 num_kills[i][j] = NET_ReadByte(msg);
73
74 /* get stuns */
75 int num_stuns[MAX_TEAMS + 1][MAX_TEAMS];
76 OBJZERO(num_stuns);
77 for (int i = 0; i <= num; i++)
78 for (int j = 0; j < num; j++)
79 num_stuns[i][j] = NET_ReadByte(msg);
80
81 GAME_HandleResults(msg, winner, num_spawned, num_alive, num_kills, num_stuns, nextmap);
82}
void GAME_HandleResults(dbuffer *msg, int winner, int *numSpawned, int *numAlive, int numKilled[][MAX_TEAMS], int numStunned[][MAX_TEAMS], bool nextmap)
After a mission was finished this function is called.
Definition cl_game.cpp:1135
Shared game type headers.
client_static_t cls
Definition cl_main.cpp:83
Primary header for client.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
Definition common.cpp:440
void Com_Error(int code, const char *fmt,...)
Definition common.cpp:459
#define ERR_DROP
Definition common.h:211
#define MAX_TEAMS
Definition defines.h:98
#define DEBUG_CLIENT
Definition defines.h:59
void CL_ParseResults(const eventRegister_t *self, dbuffer *msg)
Reads mission result data from server.
int CL_ParseResultsTime(const struct eventRegister_s *self, dbuffer *msg, eventTiming_t *eventTiming)
int NET_ReadByte(dbuffer *buf)
Reads a byte from the netchannel.
Definition netpack.cpp:234
QGL_EXTERN GLint i
Definition r_gl.h:113
#define OBJZERO(obj)
Definition shared.h:178
Struct that defines one particular event with all its callbacks and data.
Definition e_main.h:42
CL_ParseEvent timers and vars.
Definition e_main.h:30
int nextTime
Definition e_main.h:31