|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: game.c,v 1.97 2004/09/30 21:01:10 stpohle Exp $
|
|
|
|
/* $Id: game.c,v 1.98 2004/10/06 18:16:14 stpohle Exp $
|
|
|
|
game.c - procedures for the game. */
|
|
|
|
game.c - procedures for the game. */
|
|
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <string.h>
|
|
|
@ -521,7 +521,7 @@ static void game_showresultteam () {
|
|
|
|
_team *team; // pointer to the team
|
|
|
|
_team *team; // pointer to the team
|
|
|
|
_player *pl[MAX_PLAYERS]; // players in the team (sorted)
|
|
|
|
_player *pl[MAX_PLAYERS]; // players in the team (sorted)
|
|
|
|
int cnt;
|
|
|
|
int cnt;
|
|
|
|
} tdata[MAX_TEAMS+1]; // hold some team informations (sorted)
|
|
|
|
} tdata[MAX_TEAMS]; // hold some team informations (sorted)
|
|
|
|
int t_count = 0, p_maxcount = 0, p_sumcount = 0;
|
|
|
|
int t_count = 0, p_maxcount = 0, p_sumcount = 0;
|
|
|
|
int sx, sy, p_y, p_x , dx, dy, col, x;
|
|
|
|
int sx, sy, p_y, p_x , dx, dy, col, x;
|
|
|
|
SDL_Rect dest, src;
|
|
|
|
SDL_Rect dest, src;
|
|
|
@ -552,7 +552,7 @@ static void game_showresultteam () {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* sort all players dependsing on the number of wins they have */
|
|
|
|
/* sort all players dependsing on the number of wins they have */
|
|
|
|
for (t_nr = 0; t_nr <= t_count; t_nr++) for (p_nr = 0, tdata[t_nr].cnt = 0; p_nr < MAX_PLAYERS; p_nr++) {
|
|
|
|
for (t_nr = 0; t_nr < t_count; t_nr++) for (p_nr = 0, tdata[t_nr].cnt = 0; p_nr < MAX_PLAYERS; p_nr++) {
|
|
|
|
if (t_nr < t_count) {
|
|
|
|
if (t_nr < t_count) {
|
|
|
|
if (tdata[t_nr].team->players[p_nr] != NULL && PS_IS_used (tdata[t_nr].team->players[p_nr]->state)) {
|
|
|
|
if (tdata[t_nr].team->players[p_nr] != NULL && PS_IS_used (tdata[t_nr].team->players[p_nr]->state)) {
|
|
|
|
tdata[t_nr].pl[tdata[t_nr].cnt] = tdata[t_nr].team->players[p_nr];
|
|
|
|
tdata[t_nr].pl[tdata[t_nr].cnt] = tdata[t_nr].team->players[p_nr];
|
|
|
@ -568,25 +568,10 @@ static void game_showresultteam () {
|
|
|
|
tdata[t_nr].cnt++;
|
|
|
|
tdata[t_nr].cnt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { /* sort all players also the ones which are not in a team */
|
|
|
|
|
|
|
|
if (players[p_nr].team_nr == -1 && PS_IS_used (players[p_nr].state)) {
|
|
|
|
|
|
|
|
tdata[t_nr].pl[tdata[t_nr].cnt] = &players[p_nr];
|
|
|
|
|
|
|
|
i = tdata[t_nr].cnt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (i > 0 && (tdata[t_nr].pl[i-1]->wins < players[p_nr].wins
|
|
|
|
|
|
|
|
|| (tdata[t_nr].pl[i-1]->wins == players[p_nr].wins
|
|
|
|
|
|
|
|
&& tdata[t_nr].pl[i-1]->points < players[p_nr].points))) {
|
|
|
|
|
|
|
|
tdata[t_nr].pl[i] = tdata[t_nr].pl[i-1];
|
|
|
|
|
|
|
|
i--;
|
|
|
|
|
|
|
|
tdata[t_nr].pl[i] = &players[p_nr];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tdata[t_nr].cnt++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* check the max number of players in one team and number of all players */
|
|
|
|
/* check the max number of players in one team and number of all players */
|
|
|
|
for (t_nr = 0, p_maxcount = 0; t_nr <= t_count; t_nr++) /* t_count + 1 */
|
|
|
|
for (t_nr = 0, p_maxcount = 0; t_nr < t_count; t_nr++) /* t_count + 1 */
|
|
|
|
if (p_maxcount < tdata[t_nr].cnt) p_maxcount = tdata[t_nr].cnt;
|
|
|
|
if (p_maxcount < tdata[t_nr].cnt) p_maxcount = tdata[t_nr].cnt;
|
|
|
|
|
|
|
|
|
|
|
|
for (p_sumcount = 0, p_nr = 0; p_nr < MAX_PLAYERS; p_nr++)
|
|
|
|
for (p_sumcount = 0, p_nr = 0; p_nr < MAX_PLAYERS; p_nr++)
|
|
|
@ -597,22 +582,19 @@ static void game_showresultteam () {
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
p_x++;
|
|
|
|
p_x++;
|
|
|
|
p_y = 0; // calc. again for this setting
|
|
|
|
p_y = 0; // calc. again for this setting
|
|
|
|
for (t_nr = 0; t_nr <= t_count; t_nr++) {
|
|
|
|
for (t_nr = 0; t_nr < t_count; t_nr++) {
|
|
|
|
p_y += ceil ((float)(((float) tdata[t_nr].cnt) / ((float)p_x)));
|
|
|
|
p_y += ceil ((float)(((float) tdata[t_nr].cnt) / ((float)p_x)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (p_y == 0) p_y = 1;
|
|
|
|
if (p_y == 0) p_y = 1;
|
|
|
|
dy = (gfx.res.y - 100 - (SHOWRESULT_TEAMHEAD * (t_count + 1))) / p_y;
|
|
|
|
dy = (gfx.res.y - 100 - (SHOWRESULT_TEAMHEAD * t_count)) / p_y;
|
|
|
|
} while (dy < SHOWRESULT_TEAMPLAYER);
|
|
|
|
} while (dy < SHOWRESULT_TEAMPLAYER);
|
|
|
|
|
|
|
|
|
|
|
|
if (dy > 2*SHOWRESULT_TEAMPLAYER) dy = 2*SHOWRESULT_TEAMPLAYER;
|
|
|
|
if (dy > 2*SHOWRESULT_TEAMPLAYER) dy = 2*SHOWRESULT_TEAMPLAYER;
|
|
|
|
|
|
|
|
|
|
|
|
/* draw everything */
|
|
|
|
/* draw everything */
|
|
|
|
sy = (gfx.res.y - (SHOWRESULT_TEAMHEAD * (t_count + 1) + dy * p_y)) / 2;
|
|
|
|
sy = (gfx.res.y - (SHOWRESULT_TEAMHEAD * t_count + dy * p_y)) / 2;
|
|
|
|
for (t_nr = 0; t_nr <= t_count; t_nr++) {
|
|
|
|
for (t_nr = 0; t_nr < t_count; t_nr++) {
|
|
|
|
if (t_nr < t_count) /* normal teams */
|
|
|
|
sprintf (text, "%s Victorys %d (%d)", tdata[t_nr].team->name, tdata[t_nr].team->wins, tdata[t_nr].team->points);
|
|
|
|
sprintf (text, "%s Victorys %d (%d)", tdata[t_nr].team->name, tdata[t_nr].team->wins, tdata[t_nr].team->points);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
sprintf (text, "Players without a Team");
|
|
|
|
|
|
|
|
sx = (gfx.res.y - strlen (text) * font[0].size.x) / 2;
|
|
|
|
sx = (gfx.res.y - strlen (text) * font[0].size.x) / 2;
|
|
|
|
font_drawbold (sx, sy+3, text, 0, COLOR_brown, 1);
|
|
|
|
font_drawbold (sx, sy+3, text, 0, COLOR_brown, 1);
|
|
|
|
font_draw (sx, sy+3, text, 0, COLOR_yellow);
|
|
|
|
font_draw (sx, sy+3, text, 0, COLOR_yellow);
|
|
|
|