e_event_results.c

Go to the documentation of this file.
00001 
00005 /*
00006 Copyright (C) 2002-2010 UFO: Alien Invasion.
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016 
00017 See the GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00023 */
00024 
00025 #include "../../../../client.h"
00026 #include "../../../../cl_game.h"
00027 #include "e_event_results.h"
00028 
00035 void CL_ParseResults (const eventRegister_t *self, struct dbuffer *msg)
00036 {
00037     int winner;
00038     int i, j, num;
00039     int num_spawned[MAX_TEAMS];
00040     int num_alive[MAX_TEAMS];
00041     /* the first dimension contains the attacker team, the second the victim team */
00042     int num_kills[MAX_TEAMS][MAX_TEAMS];
00043     int num_stuns[MAX_TEAMS][MAX_TEAMS];
00044 
00045     memset(num_spawned, 0, sizeof(num_spawned));
00046     memset(num_alive, 0, sizeof(num_alive));
00047     memset(num_kills, 0, sizeof(num_kills));
00048     memset(num_stuns, 0, sizeof(num_stuns));
00049 
00050     /* get number of teams */
00051     num = NET_ReadByte(msg);
00052     if (num > MAX_TEAMS)
00053         Com_Error(ERR_DROP, "Too many teams in result message");
00054 
00055     Com_DPrintf(DEBUG_CLIENT, "Receiving results with %i teams.\n", num);
00056 
00057     /* get winning team */
00058     winner = NET_ReadByte(msg);
00059 
00060     if (cls.team > num)
00061         Com_Error(ERR_DROP, "Team number %d too high (only %d teams)", cls.team, num);
00062 
00063     /* get spawn and alive count */
00064     for (i = 0; i < num; i++) {
00065         num_spawned[i] = NET_ReadByte(msg);
00066         num_alive[i] = NET_ReadByte(msg);
00067     }
00068 
00069     /* get kills */
00070     for (i = 0; i < num; i++)
00071         for (j = 0; j < num; j++)
00072             num_kills[i][j] = NET_ReadByte(msg);
00073 
00074     /* get stuns */
00075     for (i = 0; i < num; i++)
00076         for (j = 0; j < num; j++)
00077             num_stuns[i][j] = NET_ReadByte(msg);
00078 
00079     GAME_HandleResults(msg, winner, num_spawned, num_alive, num_kills, num_stuns);
00080 }

Generated by  doxygen 1.6.2