single player team mode fixed. Game stopped after a few seconds. Teams will be selected by AI and Players (at the moment)

origin
stpohle 21 years ago
parent 8c4be85baa
commit 0f63a474e4

@ -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. */
#include <string.h>
@ -521,7 +521,7 @@ static void game_showresultteam () {
_team *team; // pointer to the team
_player *pl[MAX_PLAYERS]; // players in the team (sorted)
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 sx, sy, p_y, p_x , dx, dy, col, x;
SDL_Rect dest, src;
@ -552,7 +552,7 @@ static void game_showresultteam () {
}
/* 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 (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];
@ -568,25 +568,10 @@ static void game_showresultteam () {
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 */
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;
for (p_sumcount = 0, p_nr = 0; p_nr < MAX_PLAYERS; p_nr++)
@ -597,22 +582,19 @@ static void game_showresultteam () {
do {
p_x++;
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)));
}
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);
if (dy > 2*SHOWRESULT_TEAMPLAYER) dy = 2*SHOWRESULT_TEAMPLAYER;
/* draw everything */
sy = (gfx.res.y - (SHOWRESULT_TEAMHEAD * (t_count + 1) + dy * p_y)) / 2;
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);
else
sprintf (text, "Players without a Team");
sy = (gfx.res.y - (SHOWRESULT_TEAMHEAD * t_count + dy * p_y)) / 2;
for (t_nr = 0; t_nr < t_count; t_nr++) {
sprintf (text, "%s Victorys %d (%d)", tdata[t_nr].team->name, tdata[t_nr].team->wins, tdata[t_nr].team->points);
sx = (gfx.res.y - strlen (text) * font[0].size.x) / 2;
font_drawbold (sx, sy+3, text, 0, COLOR_brown, 1);
font_draw (sx, sy+3, text, 0, COLOR_yellow);

@ -1,4 +1,4 @@
/* $Id: player.c,v 1.89 2004/10/04 21:36:47 stpohle Exp $
/* $Id: player.c,v 1.90 2004/10/06 18:16:14 stpohle Exp $
* player.c - everything what have to do with the player */
#include <SDL.h>
@ -1102,5 +1102,7 @@ void team_choose (_player *pl) {
return;
printf ("team_choose need to fix\n");
pl->team_nr = 1;
if (PS_IS_aiplayer (pl->state))
pl->team_nr = 1;
else pl->team_nr = 0;
};

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.76 2004/10/04 21:36:47 stpohle Exp $ */
/* $Id: single.c,v 1.77 2004/10/06 18:16:15 stpohle Exp $ */
/* single player */
#include "basic.h"
@ -625,11 +625,10 @@ single_create_ai (int num_players)
MW_IS_GFX_SELECT (gfx_sel, i);
try++;
} while (try < 100 && i != -1);
player_set_gfx (pl, gfx_sel);
pl->wins = 0;
pl->points = 0;
pl->team_nr = -1;
player_set_gfx (pl, gfx_sel);
team_choose (pl);
}
@ -676,6 +675,7 @@ single_playergame (int second_player, int ai_players)
for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++)
if (!(PS_IS_used (players[p].state)))
bman.p_nr = p;
players[bman.p_nr].team_nr = 0;
if (bman.p_nr >= MAX_PLAYERS) {
printf ("ERROR in function (single_game_new): couldn't find any free player\n");
@ -695,6 +695,7 @@ single_playergame (int second_player, int ai_players)
do {
done = playermenu_selgfx (bman.p2_nr);
} while (players[bman.p2_nr].gfx_nr == -1 && done != -1);
players[bman.p2_nr].team_nr = 0;
}
if (done == -1)
@ -702,8 +703,11 @@ single_playergame (int second_player, int ai_players)
single_create_ai (ai_players);
if (bman.gametype == GT_team)
if (bman.gametype == GT_team) {
playermenu ();
team_update ();
ai_team_choosegfx ();
}
bman.state = GS_ready;

Loading…
Cancel
Save