|
|
@ -1,4 +1,4 @@
|
|
|
|
/* $Id: single.c,v 1.63 2004/05/20 16:55:30 stpohle Exp $ */
|
|
|
|
/* $Id: single.c,v 1.64 2004/06/08 22:35:26 stpohle Exp $ */
|
|
|
|
/* single player */
|
|
|
|
/* single player */
|
|
|
|
|
|
|
|
|
|
|
|
#include "basic.h"
|
|
|
|
#include "basic.h"
|
|
|
@ -7,6 +7,8 @@
|
|
|
|
#include "player.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "single.h"
|
|
|
|
#include "single.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* start a single player game and prepare everything for the game */
|
|
|
|
void
|
|
|
|
void
|
|
|
|
single_game_new ()
|
|
|
|
single_game_new ()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -577,9 +579,13 @@ single_create_ai (int num_players)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* single player game win/point screen */
|
|
|
|
/* single player game win/point screen
|
|
|
|
|
|
|
|
* 1. setup all player data
|
|
|
|
|
|
|
|
* 2. setup second local player and ai players
|
|
|
|
|
|
|
|
* 3. setup all other game related data
|
|
|
|
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
void
|
|
|
|
single_playergame ()
|
|
|
|
single_playergame (int second_player, int ai_players)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int p,
|
|
|
|
int p,
|
|
|
|
done = 0;
|
|
|
|
done = 0;
|
|
|
@ -605,13 +611,18 @@ single_playergame ()
|
|
|
|
strncpy (players[bman.p_nr].name, bman.playername, LEN_PLAYERNAME);
|
|
|
|
strncpy (players[bman.p_nr].name, bman.playername, LEN_PLAYERNAME);
|
|
|
|
gfx_load_players (32, 32);
|
|
|
|
gfx_load_players (32, 32);
|
|
|
|
playermenu_selgfx (bman.p_nr);
|
|
|
|
playermenu_selgfx (bman.p_nr);
|
|
|
|
gfx_free_players ();
|
|
|
|
|
|
|
|
if (players[bman.p_nr].gfx_nr == -1)
|
|
|
|
if (players[bman.p_nr].gfx_nr == -1)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
players[bman.p_nr].state = PSF_used + PSF_alife + PSF_playing;
|
|
|
|
players[bman.p_nr].state = PSF_used + PSF_alife + PSF_playing;
|
|
|
|
strncpy (players[bman.p_nr].name, bman.playername, LEN_PLAYERNAME);
|
|
|
|
strncpy (players[bman.p_nr].name, bman.playername, LEN_PLAYERNAME);
|
|
|
|
single_create_ai (bman.ai_players);
|
|
|
|
|
|
|
|
|
|
|
|
if (second_player) {
|
|
|
|
|
|
|
|
player2_join ();
|
|
|
|
|
|
|
|
playermenu_selgfx (bman.p2_nr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx_free_players ();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
single_create_ai (ai_players);
|
|
|
|
bman.state = GS_ready;
|
|
|
|
bman.state = GS_ready;
|
|
|
|
|
|
|
|
|
|
|
|
while (!done && bman.state != GS_quit && bman.state != GS_startup) {
|
|
|
|
while (!done && bman.state != GS_quit && bman.state != GS_startup) {
|
|
|
@ -699,13 +710,18 @@ single_loop ()
|
|
|
|
void
|
|
|
|
void
|
|
|
|
single_menu ()
|
|
|
|
single_menu ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int menuselect = 0,
|
|
|
|
int i,
|
|
|
|
i,
|
|
|
|
|
|
|
|
p,
|
|
|
|
p,
|
|
|
|
done = 0;
|
|
|
|
eventstate = 0,
|
|
|
|
|
|
|
|
done = 0,
|
|
|
|
|
|
|
|
second_playerold = 0,
|
|
|
|
|
|
|
|
second_player = 0;
|
|
|
|
_charlist nrplayerlist[MAX_PLAYERS + 1];
|
|
|
|
_charlist nrplayerlist[MAX_PLAYERS + 1];
|
|
|
|
_charlist *selnrplayer = &nrplayerlist[bman.ai_players];
|
|
|
|
_charlist *selnrplayer = &nrplayerlist[bman.ai_players];
|
|
|
|
_menu *menu;
|
|
|
|
_menu *menu;
|
|
|
|
|
|
|
|
_menuitem *pl2name = NULL;
|
|
|
|
|
|
|
|
_menuitem *aiplayer = NULL;
|
|
|
|
|
|
|
|
SDL_Event event;
|
|
|
|
|
|
|
|
|
|
|
|
/* fill in the nrplayerlist */
|
|
|
|
/* fill in the nrplayerlist */
|
|
|
|
if (debug)
|
|
|
|
if (debug)
|
|
|
@ -721,41 +737,61 @@ single_menu ()
|
|
|
|
p++;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while (!done && bman.state != GS_quit) {
|
|
|
|
menu = menu_new ("Single Game", 380,240);
|
|
|
|
menu = menu_new ("Single Player", 300, 250);
|
|
|
|
|
|
|
|
menu_create_label (menu, "Number Of AI Players", -1, 55, 0, COLOR_brown);
|
|
|
|
menu_create_text (menu, "numpl", 20, 50, 12, 2, COLOR_yellow, "Number of\nAI Players");
|
|
|
|
menu_create_list (menu, "Players", -1, 80, 70, 70, nrplayerlist, &selnrplayer, 1);
|
|
|
|
aiplayer = menu_create_list (menu, "AI Players", 40, 90, 50, 100, nrplayerlist, &selnrplayer, 3);
|
|
|
|
menu_create_button (menu, "Map Setting", -1, 180, 150, 2);
|
|
|
|
|
|
|
|
menu_create_button (menu, "OK", -1, 220, 150, 0);
|
|
|
|
menu_create_entry (menu,"Player 1:",150, 50, 230, &bman.playername, LEN_PLAYERNAME, MENU_entrytext, 4);
|
|
|
|
menuselect = menu_loop (menu);
|
|
|
|
|
|
|
|
menu_delete (menu);
|
|
|
|
menu_create_bool (menu, "Use Second Player", 160, 90, 210, &second_player, 5);
|
|
|
|
|
|
|
|
|
|
|
|
/* read the current number of AI Players */
|
|
|
|
menu_create_button (menu, "Map Options", 180, 160, 150, 6);
|
|
|
|
bman.ai_players = (selnrplayer - &nrplayerlist[0]);
|
|
|
|
|
|
|
|
if (!debug)
|
|
|
|
menu_create_button (menu, "Main Menu", 30, 220, 150, 1);
|
|
|
|
bman.ai_players++;
|
|
|
|
menu_create_button (menu, "Start", 220, 220, 150, 2);
|
|
|
|
if (bman.ai_players > MAX_PLAYERS) {
|
|
|
|
|
|
|
|
d_fatal ("single_menu: bman.ai_players selection out of range (%d)\n", bman.ai_players);
|
|
|
|
menu_focus_id (menu, 2);
|
|
|
|
bman.ai_players = 5;
|
|
|
|
menu->looprunning = 1;
|
|
|
|
|
|
|
|
menu_draw (menu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
|
|
|
/* create or destroy second playername menuentry */
|
|
|
|
|
|
|
|
if (second_player != second_playerold) {
|
|
|
|
|
|
|
|
if (pl2name != NULL && !second_player) {
|
|
|
|
|
|
|
|
menu_del_menuitem (pl2name);
|
|
|
|
|
|
|
|
pl2name = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pl2name == NULL && second_player)
|
|
|
|
|
|
|
|
pl2name = menu_create_entry (menu,"Player 2:",150,120, 230, &bman.player2name, LEN_PLAYERNAME, MENU_entrytext, 4);
|
|
|
|
|
|
|
|
|
|
|
|
switch (menuselect) {
|
|
|
|
second_playerold = second_player;
|
|
|
|
case (0): // Start Game
|
|
|
|
aiplayer->changed = 1;
|
|
|
|
single_playergame ();
|
|
|
|
menu_draw (menu);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (2): // Map Options
|
|
|
|
|
|
|
|
mapmenu ();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (-1):
|
|
|
|
|
|
|
|
done = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
draw_logo ();
|
|
|
|
|
|
|
|
SDL_Flip (gfx.screen);
|
|
|
|
gfx_blitdraw ();
|
|
|
|
|
|
|
|
eventstate = SDL_PollEvent (&event);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
done = menu_event_loop (menu, &event, eventstate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (done && menu->focus->id == 6) {
|
|
|
|
|
|
|
|
done = 0;
|
|
|
|
|
|
|
|
mapmenu ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s_calctimesync ();
|
|
|
|
|
|
|
|
} while (!done);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (menu->focus->id == 2)
|
|
|
|
|
|
|
|
single_playergame (second_player, bman.ai_players);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menu_delete (menu);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* single player selection
|
|
|
|
/* single player selection
|
|
|
|
return value the gfx of the player or -1 for escape */
|
|
|
|
return value the gfx of the player or -1 for escape */
|
|
|
|
int
|
|
|
|
int
|
|
|
|