single player first wort to a full single player game

origin
stpohle 23 years ago
parent 26062e089d
commit c4eedcf3c6

@ -1,15 +1,26 @@
$Id: ChangeLog,v 1.29 2003/07/23 23:45:51 stpohle Exp $ $Id: ChangeLog,v 1.30 2003/07/24 01:47:48 stpohle Exp $
Version 0.9.10 Version 0.9.10
============== ==============
- TekKRat made two new players, the first two
tilesets with the pseudo 3D effect
(64x96 pixel tileset) and another tileset.
(cemetery, sheep, hell and farm)
- caccola made another Tileset (supermario)
- Added: Switch to enable/disable broadcasted chats.
So the confusing will stop why there are unknown people
talking. You can enable it in the Network Options.
- fixed: chat_findfreeline, there was a bug in the - fixed: chat_findfreeline, there was a bug in the
source and destination of copying the chatlines. source and destination of copying the chatlines.
Thats why the chat got mixed up after 255 lines. Thats why the chat got mixed up after 255 lines.
- maps have more options to set and it will be displayed - Added: maps have more options to set and it will be
in the multiplayer menu, this options can be saved for displayed in the multiplayer menu, this options can be
every map seperated saved for every map seperated.
- gfx, source cleanup. player will now drawn in order they - gfx, source cleanup. player will now drawn in order they
stay tileset will change we can support 64x64pixel size stay tileset will change we can support 64x64pixel size

@ -1,4 +1,4 @@
$Id: TODO,v 1.15 2003/07/23 23:43:34 stpohle Exp $ $Id: TODO,v 1.16 2003/07/24 01:47:48 stpohle Exp $
next version (0.9.10): next version (0.9.10):
====================== ======================
@ -7,11 +7,6 @@ next version (0.9.10):
- more specials (Kicking Bomb, Pushing Bomb Ver.2) - more specials (Kicking Bomb, Pushing Bomb Ver.2)
- Switch to enable/disable broadcasting chat messages to the bomberclone
mserv
- chat screen
- network joining menu Add: information about the playernames and - network joining menu Add: information about the playernames and
the point list. the point list.

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.39 2003/07/22 18:29:08 stpohle Exp $ */ /* $Id: basic.h,v 1.40 2003/07/24 01:47:48 stpohle Exp $ */
/* basic types which we need everywhere */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -78,6 +78,9 @@
#define MENU_BG_SHADE_DARK -64 #define MENU_BG_SHADE_DARK -64
#define MENU_BG_SHADE_BRIGHT 64 #define MENU_BG_SHADE_BRIGHT 64
#define MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (bman.players[__result].gfx_nr != __gfx_nr) && (__result >= 0); __result--);
enum _networkflags { enum _networkflags {
NETF_firewall = 1 NETF_firewall = 1
}; };

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.45 2003/07/22 18:29:08 stpohle Exp $ */ /* $Id: bomberclone.h,v 1.46 2003/07/24 01:47:48 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -147,6 +147,7 @@ struct __bomberclone {
char gamemaster[LEN_SERVERNAME + LEN_PORT + 2]; // ** CONFIG ... GameMaster Address char gamemaster[LEN_SERVERNAME + LEN_PORT + 2]; // ** CONFIG ... GameMaster Address
unsigned char firewall; unsigned char firewall;
unsigned char notifygamemaster; unsigned char notifygamemaster;
unsigned char broadcasted_chat; // 1 if the chat should be send to the bc server
unsigned char askplayername; // ask player for name at startup unsigned char askplayername; // ask player for name at startup
unsigned char ai_players; // number of ai players unsigned char ai_players; // number of ai players
@ -250,9 +251,10 @@ extern void single_create_ai (int players);
extern void single_loop(); extern void single_loop();
extern void single_playergame (); extern void single_playergame ();
extern void single_menu (); extern void single_menu ();
extern int single_select_player ();
extern int ai_choosedir (int dir, int nearbomb, int oldpos); extern int ai_choosedir (int dir, int nearbomb, int oldpos);
extern int ai_invertdir (int dir); extern inline int ai_invertdir (int dir);
extern int ai_checkpos (_player * pl, _point * pos); extern inline int ai_checkpos (_player * pl, _point * pos);
extern int ai_findnearbombs (_point pos); extern int ai_findnearbombs (_point pos);
extern int ai_findbestbombdir (_point pos, int dir, int range); extern int ai_findbestbombdir (_point pos, int dir, int range);
extern int ai_bombpoints (_point pos, int range); extern int ai_bombpoints (_point pos, int range);

@ -57,6 +57,7 @@ game_init (int argc, char **argv)
map.map[0] = 0; map.map[0] = 0;
map.map_selection = 2; map.map_selection = 2;
bman.firewall = 0; bman.firewall = 0;
bman.broadcasted_chat = 0;
bman.ai_players = 1; bman.ai_players = 1;
snd.inited = 0; snd.inited = 0;
map.bombs = GAME_SPECIAL_ITEMBOMB; map.bombs = GAME_SPECIAL_ITEMBOMB;
@ -181,6 +182,9 @@ ReadConfig ()
if (!strcmp (keyword, "firewall")) { if (!strcmp (keyword, "firewall")) {
bman.firewall = atoi (value); bman.firewall = atoi (value);
} }
if (!strcmp (keyword, "broadcasted_chat")) {
bman.broadcasted_chat = atoi (value);
}
if (!strcmp (keyword, "udpport")) { if (!strcmp (keyword, "udpport")) {
if (strlen (value) > LEN_PORT) { if (strlen (value) > LEN_PORT) {
d_printf d_printf
@ -256,6 +260,7 @@ WriteConfig ()
fprintf (config, "tileset=%s\n", map.tileset); fprintf (config, "tileset=%s\n", map.tileset);
fprintf (config, "mapname=%s\n", map.map); fprintf (config, "mapname=%s\n", map.map);
fprintf (config, "firewall=%d\n", bman.firewall); fprintf (config, "firewall=%d\n", bman.firewall);
fprintf (config, "broadcasted_chat=%d\n", bman.broadcasted_chat);
fprintf (config, "udpport=%s\n", bman.port); fprintf (config, "udpport=%s\n", bman.port);
fprintf (config, "ai_players=%d\n", bman.ai_players); fprintf (config, "ai_players=%d\n", bman.ai_players);
fprintf (config, "fieldsizex=%d\n", map.size.x); fprintf (config, "fieldsizex=%d\n", map.size.x);

@ -9,7 +9,8 @@
#include "packets.h" #include "packets.h"
#include "chat.h" #include "chat.h"
extern int blitdb_nr, blitrects_nr; extern int blitdb_nr,
blitrects_nr;
static Uint32 timediff, static Uint32 timediff,
timediff1; timediff1;
@ -35,7 +36,6 @@ game_draw_info ()
bman.players_nr = 0; bman.players_nr = 0;
if (GT_MP_PTP) {
/* In Multiplayer mode draw Player names and /* In Multiplayer mode draw Player names and
count the players who are still alife. */ count the players who are still alife. */
for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++) for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++)
@ -73,12 +73,6 @@ game_draw_info ()
j = j + font[0].size.x; j = j + font[0].size.x;
} }
} }
}
else
/* in single mode count the player's who are still alife */
for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_alife (bman.players[i].state))
bman.players_nr++;
font_setcolor (255, 255, 255, 0); font_setcolor (255, 255, 255, 0);
x = gfx.res.x - 120; x = gfx.res.x - 120;
@ -94,7 +88,8 @@ game_draw_info ()
dest.w = gfx.smal_special[bman.players[bman.p_nr].special.type - 1]->w; dest.w = gfx.smal_special[bman.players[bman.p_nr].special.type - 1]->w;
dest.h = gfx.smal_special[bman.players[bman.p_nr].special.type - 1]->h; dest.h = gfx.smal_special[bman.players[bman.p_nr].special.type - 1]->h;
SDL_BlitSurface (gfx.smal_special[bman.players[bman.p_nr].special.type - 1], NULL, gfx.screen, &dest); SDL_BlitSurface (gfx.smal_special[bman.players[bman.p_nr].special.type - 1], NULL,
gfx.screen, &dest);
} }
if (bman.state == GS_ready && GT_MP_PTPM) if (bman.state == GS_ready && GT_MP_PTPM)
@ -208,7 +203,9 @@ game_loop ()
/* check if there is only one player left and the game is in multiplayer mode /* check if there is only one player left and the game is in multiplayer mode
and if there the last dieing animation is done */ and if there the last dieing animation is done */
if ((bman.players_nr < 2 && (GT_MP_PTP || (bman.gametype == GT_single && bman.ai_players > 0))) || (bman.gametype == GT_single && bman.ai_players == 0 && bman.players_nr < 1)) if ((bman.players_nr < 2
&& (GT_MP_PTP || (bman.gametype == GT_single && bman.ai_players > 0)))
|| (bman.gametype == GT_single && bman.ai_players == 0 && bman.players_nr < 1))
gameovertimeout--; gameovertimeout--;
if (gameovertimeout <= 0) { if (gameovertimeout <= 0) {

@ -10,8 +10,6 @@
#include "gfx.h" #include "gfx.h"
#include "chat.h" #include "chat.h"
#define MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (bman.players[__result].gfx_nr != __gfx_nr) && (__result >= 0); __result--);
extern int UpdateRects_nr; extern int UpdateRects_nr;
static int mw_player = 0, static int mw_player = 0,

@ -78,10 +78,11 @@ networkmenu_options ()
{1, "Max Players:"}, {1, "Max Players:"},
{2, "Network"}, {2, "Network"},
{3, "UDP Port"}, {3, "UDP Port"},
{4, "Notify Masterserver"}, {4, "Behind a Firewall"},
{5, "Masterserver"}, {5, "Notify Masterserver"},
{6, "Behind a Firewall"}, {6, "Masterserver"},
{7, "Return To Multiplayer Menu"}, {7, "Broadcastes Chat"},
{8, "Return To Multiplayer Menu"},
{-1, ""} {-1, ""}
}; };
#ifdef _WIN32 #ifdef _WIN32
@ -99,17 +100,33 @@ networkmenu_options ()
sprintf (menu[3].text, "UDP Port: %s", bman.port); sprintf (menu[3].text, "UDP Port: %s", bman.port);
if (bman.firewall)
sprintf (menu[4].text, "Firewall: ON");
else
sprintf (menu[4].text, "Firewall: OFF");
if (bman.notifygamemaster) if (bman.notifygamemaster)
sprintf (menu[4].text, "Notify MasterServer: Yes"); sprintf (menu[5].text, "Notify MasterServer: Yes");
else else
sprintf (menu[4].text, "Notify MasterServer: No"); sprintf (menu[5].text, "Notify MasterServer: No");
sprintf (menu[5].text, "MasterServer %s", bman.gamemaster); if (bman.notifygamemaster) {
sprintf (menu[6].text, "MasterServer %s", bman.gamemaster);
menu[6].index = 6;
}
else
menu[6].text[0] = menu[6].index = 0;
if (bman.firewall) if (bman.broadcasted_chat && bman.notifygamemaster) {
sprintf (menu[6].text, "Firewall: ON"); sprintf (menu[7].text, "Broadcasted Chat: ON");
menu[7].index = 7;
}
else if (bman.notifygamemaster) {
sprintf (menu[7].text, "Broadcasted Chat: OFF");
menu[7].index = 7;
}
else else
sprintf (menu[6].text, "Firewall: OFF"); menu[7].index = menu[7].text[0] = 0;
menuselect = menu_loop ("Multiplayer Options", menu, menuselect); menuselect = menu_loop ("Multiplayer Options", menu, menuselect);
@ -143,26 +160,24 @@ networkmenu_options ()
LEN_PORT + 1); LEN_PORT + 1);
break; break;
case (4): // Change the Notification case (4): // Firewall Option
if (bman.notifygamemaster) bman.firewall = 1 - bman.firewall ;
bman.notifygamemaster = 0; break;
else
bman.notifygamemaster = 1; case (5): // Change the Notification
bman.notifygamemaster = 1 - bman.notifygamemaster;
break; break;
case (5): // Masterserver Address case (6): // Masterserver Address
menu_get_text ("Address of the MasterServer", bman.gamemaster, menu_get_text ("Address of the MasterServer", bman.gamemaster,
LEN_SERVERNAME + LEN_PORT + 2); LEN_SERVERNAME + LEN_PORT + 2);
break; break;
case (6): // Firewall Option case (7):
if (bman.firewall) bman.broadcasted_chat = 1 - bman.broadcasted_chat;
bman.firewall = 0;
else
bman.firewall = 1;
break; break;
case (7): case (8):
menuselect = -1; menuselect = -1;
break; break;
} }

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.36 2003/07/22 18:29:08 stpohle Exp $ */ /* $Id: network.c,v 1.37 2003/07/24 01:47:48 stpohle Exp $ */
/* /*
network routines. network routines.
*/ */
@ -711,7 +711,7 @@ net_send_chat (char *text, signed char notigamesrv)
if (PS_IS_netplayer (bman.players[i].state) && i != bman.p_nr && NET_CANSEND(i)) if (PS_IS_netplayer (bman.players[i].state) && i != bman.p_nr && NET_CANSEND(i))
send_chat (&bman.players[i].net.addr, text); send_chat (&bman.players[i].net.addr, text);
if (GT_MP_PTPM && bman.notifygamemaster && notigamesrv == 1) /* send notification the the gamemaster */ if (GT_MP_PTPM && bman.notifygamemaster && notigamesrv == 1 && bman.broadcasted_chat) /* send notification the the gamemaster */
gamesrv_sendchat (text); gamesrv_sendchat (text);
}; };

@ -981,8 +981,11 @@ do_bcmservchat (struct pkg_bcmservchat *packet, _net_addr * addr)
packet->data[127] = 0; packet->data[127] = 0;
if (strstr (packet->data, "BC:BC:") == packet->data) if (strstr (packet->data, "BC:BC:") == packet->data)
return; // ignore packet return; // ignore packet
if (bman.notifygamemaster && bman.broadcasted_chat) {
chat_addline (packet->data); chat_addline (packet->data);
net_send_chat (packet->data, 0); net_send_chat (packet->data, 0);
}
}; };

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.36 2003/07/23 18:14:04 stpohle Exp $ */ /* $Id: single.c,v 1.37 2003/07/24 01:47:48 stpohle Exp $ */
/* single player */ /* single player */
#include "basic.h" #include "basic.h"
@ -46,17 +46,8 @@ single_game_new ()
bman.players[p].d = 0; bman.players[p].d = 0;
} }
for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++)
if (!(PS_IS_used (bman.players[p].state)))
bman.p_nr = p;
if (bman.p_nr >= MAX_PLAYERS) {
printf ("ERROR in function (single_game_new): couldn't find any free player\n");
exit (1);
}
bman.players[bman.p_nr].state = PSFM_alife; bman.players[bman.p_nr].state = PSFM_alife;
player_set_gfx (&bman.players[bman.p_nr], 7); player_set_gfx (&bman.players[bman.p_nr], bman.players[bman.p_nr].gfx_nr);
bman.last_ex_nr = 1; bman.last_ex_nr = 1;
init_map_tileset (); init_map_tileset ();
@ -66,7 +57,7 @@ single_game_new ()
}; };
int inline int
ai_checkfield (int x, int y) ai_checkfield (int x, int y)
{ {
return ((map.field[x][y].type == FT_nothing || map.field[x][y].type == FT_fire || map.field[x][y].type == FT_shoe || map.field[x][y].type == FT_bomb ) && map.bfield[x][y] == 0); return ((map.field[x][y].type == FT_nothing || map.field[x][y].type == FT_fire || map.field[x][y].type == FT_shoe || map.field[x][y].type == FT_bomb ) && map.bfield[x][y] == 0);
@ -200,12 +191,6 @@ ai_runawayfrom (_point p, int nearbomb, signed char norecursive)
res.dir |= (1 << i); res.dir |= (1 << i);
} }
/* if (!norecursive) {
printf ("%d,%d NB:", p.x, p.y);
d_bitprint (nearbomb, 5);
d_bitprint (res.dir, 4);
}
*/
/* test the possible ways */ /* test the possible ways */
while (!done) { while (!done) {
done = 1; done = 1;
@ -234,11 +219,9 @@ ai_runawayfrom (_point p, int nearbomb, signed char norecursive)
tdir = ai_runawayfrom (tpos, nbomb, 1).dir; tdir = ai_runawayfrom (tpos, nbomb, 1).dir;
_i = ai_invertdir (i); _i = ai_invertdir (i);
if (tdir != (1 << _i)) { // usefull direction if (tdir != (1 << _i)) { // usefull direction
// printf ("B%d ", i);
res.dir |= (1 << i); // add this one res.dir |= (1 << i); // add this one
} }
else { else {
// printf ("-%d ", i);
c = -1; c = -1;
} }
} }
@ -246,7 +229,6 @@ ai_runawayfrom (_point p, int nearbomb, signed char norecursive)
res.dir |= (1 << i); res.dir |= (1 << i);
/* check for the best direction */ /* check for the best direction */
// if (!norecursive) printf ("pts:%d|%d ", bdirpoints, res.bestdir);
if (c != -1 && !norecursive) { if (c != -1 && !norecursive) {
if (c < bdirpoints) { if (c < bdirpoints) {
bdirpoints = c; bdirpoints = c;
@ -264,17 +246,6 @@ ai_runawayfrom (_point p, int nearbomb, signed char norecursive)
} }
} }
} }
/* if (!norecursive) {
d_bitprint (res.dir, 4);
printf ("%d ] ", res.bestdir);
} else {
printf ("(%d,%d NB ", p.x, p.y);
d_bitprint (nearbomb, 5);
d_bitprint (res.dir, 4);
printf (")");
}
*/
return res; return res;
}; };
@ -412,9 +383,6 @@ ai_findbestbombdir (_point pos, int dir, int range)
if (dir != -1 && (bestd & (0xFF -(1 << ai_invertdir(dir))))) if (dir != -1 && (bestd & (0xFF -(1 << ai_invertdir(dir)))))
bestd &= (0xFF - (1 << ai_invertdir(dir))); bestd &= (0xFF - (1 << ai_invertdir(dir)));
// d_printf ("ai_bestbombdir (%d,%d) [%d, %d, %d, %d, %d]\n", pos.x, pos.y, points[0],
// points[1], points[2], points[3], points[4]);
return bestd; return bestd;
} }
@ -488,7 +456,7 @@ ai_findnearbombs (_point pos)
/* check if we are still running and fill out the position /* check if we are still running and fill out the position
return == 0 we're still walking ... else we have reached a point */ return == 0 we're still walking ... else we have reached a point */
int inline int
ai_checkpos (_player * pl, _point * pos) ai_checkpos (_player * pl, _point * pos)
{ {
_point _p; _point _p;
@ -547,7 +515,7 @@ ai_choosedir (int dir, int nearbomb, int oldpos)
}; };
int inline int
ai_invertdir (int dir) ai_invertdir (int dir)
{ {
int idir; int idir;
@ -569,7 +537,7 @@ ai_invertdir (int dir)
}; };
int inline int
ai_checknewpos (_point pos, int d) ai_checknewpos (_point pos, int d)
{ {
_point m; _point m;
@ -600,8 +568,7 @@ ai_checknewpos (_point pos, int d)
void void
single_create_ai (int players) single_create_ai (int players)
{ {
int p; int p, count, gfx_sel, i = 0;
int count;
_player *pl; _player *pl;
for (count = 0; count < players; count++) { for (count = 0; count < players; count++) {
@ -609,8 +576,13 @@ single_create_ai (int players)
for (pl = NULL, p = 0; (pl == NULL && p < MAX_PLAYERS); p++) for (pl = NULL, p = 0; (pl == NULL && p < MAX_PLAYERS); p++)
if (!(PS_IS_used (bman.players[p].state))) { if (!(PS_IS_used (bman.players[p].state))) {
pl = &bman.players[p]; pl = &bman.players[p];
sprintf (pl->name, "AI %d", count+1);
pl->state |= PSF_used + PSF_alife + PSF_playing; pl->state |= PSF_used + PSF_alife + PSF_playing;
player_set_gfx (pl, s_random (MAX_PLAYERS)); do {
gfx_sel = s_random (MAX_PLAYERS);
MW_IS_GFX_SELECT (gfx_sel, i);
} while (i != -1);
player_set_gfx (pl, gfx_sel);
} }
if (pl == NULL) if (pl == NULL)
@ -619,25 +591,46 @@ single_create_ai (int players)
}; };
/* single player game win/point screen */
void void
single_playergame () single_playergame ()
{ {
int p; int p, done = 0;
/* delete player from the game */ /* delete player from the game */
for (p = 0; p < MAX_PLAYERS; p++) for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].points = 0;
bman.players[p].wins = 0;
bman.players[p].state = 0; bman.players[p].state = 0;
}
for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++)
if (!(PS_IS_used (bman.players[p].state)))
bman.p_nr = p;
if (bman.p_nr >= MAX_PLAYERS) {
printf ("ERROR in function (single_game_new): couldn't find any free player\n");
exit (1);
}
if ((bman.players[bman.p_nr].gfx_nr = single_select_player ()) == -1)
return;
bman.players[bman.p_nr].state = PSF_used + PSF_alife + PSF_playing;
strncpy (bman.players[bman.p_nr].name, bman.playername, LEN_PLAYERNAME);
single_create_ai (bman.ai_players); single_create_ai (bman.ai_players);
bman.state = GS_ready;
while (!done && bman.state != GS_quit && bman.state != GS_startup) {
single_game_new (); single_game_new ();
game_start (); game_start ();
game_loop (); game_loop ();
game_end (); game_end ();
}
}; };
/* single player loop for calculating the ai players */
void void
single_loop () single_loop ()
{ {
@ -679,7 +672,6 @@ single_loop ()
} }
else { else {
// bombs in the near found // bombs in the near found
// printf ("P%d,%d ", plpos.x, plpos.y);
rawdir = ai_runawayfrom (plpos, nearbomb, 0); rawdir = ai_runawayfrom (plpos, nearbomb, 0);
if (rawdir.dir != 0 && rawdir.bestdir == -1) { if (rawdir.dir != 0 && rawdir.bestdir == -1) {
pl->d = ai_choosedir (rawdir.dir, nearbomb, pl->d); // we have to make a choice.. do it pl->d = ai_choosedir (rawdir.dir, nearbomb, pl->d); // we have to make a choice.. do it
@ -689,7 +681,6 @@ single_loop ()
pl->d = rawdir.bestdir; pl->d = rawdir.bestdir;
pl->m = 1; pl->m = 1;
} }
// printf (" d:%d m:%d\n", pl->d, pl->m);
} }
} }
player_ilness_loop (p); player_ilness_loop (p);
@ -734,3 +725,10 @@ void single_menu () {
} }
} }
}; };
/* single player selection
return value the gfx of the player or -1 for escape */
int single_select_player () {
return 0;
};

Loading…
Cancel
Save