another source cleanup struct map created and all map/fielddata put in there.

origin
stpohle 23 years ago
parent 94202c9983
commit bd54991241

23
TODO

@ -1,23 +1,32 @@
$Id: TODO,v 1.10 2003/07/15 11:43:08 stpohle Exp $
$Id: TODO,v 1.11 2003/07/16 14:41:59 stpohle Exp $
next version (0.9.10):
======================
- more specials (Kicking Bomb, Pushing Bomb Ver.2)
- maps will have more options to set and it will be displayed in the multiplayer menu
- maps will have more options to set and it will be displayed in the
multiplayer menu, this options can be saved for every map seperated
- network joining menu Add: i on a game for information about the playernames and
- Switch to enable/disable broadcasting chat messages to the bomberclone
mserv
- network joining menu Add: information about the playernames and
the point list.
- gfx, source cleanup. player will now drawn in order they stay
tileset will change we can support 64x64pixel size and 64x92pixel size tilesets
no sdl_blit* calls from game_loop for the game gfx.. working on a new engine with
sorting the tiles and update rects.
tileset will change we can support 64x64pixel size and 64x92pixel size
tilesets no sdl_blit* calls from game_loop for the game gfx.. working
on a new engine with sorting the tiles and update rects.
- keyboard/keybinput cleanup so all keyboard inputs will be read from there.
hopefully we will get so out of this menu problem that sometimes keys are ignored.
hopefully we will get so out of this menu problem that sometimes keys are
ignored.
- Sound menu to select the samplerate mono+stereo 8bit or 16bit
- add musicfiles with type of mp3, mod, xm, s3m and
mid (but i don't know how i can do this)
always change if possible:
==========================

@ -116,7 +116,8 @@ module.source.files=\
sound.c\
font.h\
map.c\
tileset.c
tileset.c\
map.h
module.pixmap.name=pixmaps
module.pixmap.type=

@ -20,6 +20,7 @@ bomberclone_SOURCES = \
udp.c\
menu.c\
map.c\
map.h\
mapmenu.c\
tileset.c\
field.c\

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.37 2003/07/15 11:43:09 stpohle Exp $ */
/* $Id: basic.h,v 1.38 2003/07/16 14:42:00 stpohle Exp $ */
/* basic types which we need everywhere */
#ifndef _BC_BASIC_H_
@ -63,7 +63,7 @@
#define LEN_PORT 6
#define LEN_GAMENAME 32
#define LEN_PATHFILENAME 512
#define LEN_FILENAME 256
#define LEN_FILENAME 64
#define LEN_TILESETNAME 32
#define DEFAULT_UDPPORT 11000

@ -1,10 +1,7 @@
/* $Id: bomb.c,v 1.33 2003/07/13 00:08:26 stpohle Exp $ */
/* $Id: bomb.c,v 1.34 2003/07/16 14:42:00 stpohle Exp $ */
/* everything what have to do with the bombs */
#include "bomberclone.h"
#include "network.h"
#include "gfx.h"
#include "sound.h"
#include <math.h>
void
@ -15,7 +12,7 @@ draw_bomb (_bomb * bomb)
int x = bomb->pos.x,
y = bomb->pos.y;
if (x < 0 || y < 0 || x>>8 >= bman.fieldsize.x || y>>8 >= bman.fieldsize.y) {
if (x < 0 || y < 0 || x>>8 >= map.size.x || y>>8 >= map.size.y) {
d_printf ("FATAL: Draw Bomb out of range [%d,%d]\n", x, y);
return;
}
@ -239,7 +236,7 @@ draw_fire (int x, int y, int d, int frame)
dest;
if (frame == -1) // no giving frame
frame = bman.field[x][y].ex[d].frame;
frame = map.field[x][y].ex[d].frame;
src.w = src.w = gfx.block.x;
dest.h = src.h = gfx.block.y;
@ -293,8 +290,8 @@ restore_explosion (_bomb * bomb)
_y = bpos.y;
for (i = 0; i < bomb->firer[d]; i++) {
if (--bman.field[_x][_y].ex[d].count == 0) // there was only one explosion so
bman.field[_x][_y].ex[d].frame = 0; // reset the framenumber
if (--map.field[_x][_y].ex[d].count == 0) // there was only one explosion so
map.field[_x][_y].ex[d].frame = 0; // reset the framenumber
if (i == 0 && d == 3)
draw_stone (_x, _y);
@ -305,19 +302,19 @@ restore_explosion (_bomb * bomb)
_y = _y + dy;
}
// delete the stone completly if there was any in the way
if (bomb->firer[d] <= bomb->r && bman.field[_x][_y].type != FT_block
&& bomb->ex_nr != bman.field[_x][_y].ex_nr) {
bman.field[_x][_y].ex_nr = bomb->ex_nr;
bman.field[_x][_y].frame = 0;
bman.field[_x][_y].frameto = 0;
if (bman.field[_x][_y].special != FT_nothing) {
bman.field[_x][_y].type = bman.field[_x][_y].special;
bman.field[_x][_y].special = FT_nothing;
d_printf ("field_explode (%d,%d) ex_nr = %d\n", _x, _y, bman.field[_x][_y].ex_nr);
if (bomb->firer[d] <= bomb->r && map.field[_x][_y].type != FT_block
&& bomb->ex_nr != map.field[_x][_y].ex_nr) {
map.field[_x][_y].ex_nr = bomb->ex_nr;
map.field[_x][_y].frame = 0;
map.field[_x][_y].frameto = 0;
if (map.field[_x][_y].special != FT_nothing) {
map.field[_x][_y].type = map.field[_x][_y].special;
map.field[_x][_y].special = FT_nothing;
d_printf ("field_explode (%d,%d) ex_nr = %d\n", _x, _y, map.field[_x][_y].ex_nr);
}
else
bman.field[_x][_y].type = FT_nothing;
map.field[_x][_y].type = FT_nothing;
draw_stone (_x, _y);
@ -333,7 +330,7 @@ restore_explosion (_bomb * bomb)
gfx.block.x * (bomb->firer[up] + bomb->firer[down] + 1));
/* delete field from the bfield map */
bman.bfield[bpos.x][bpos.y] = 0;
map.bfield[bpos.x][bpos.y] = 0;
};
@ -351,7 +348,7 @@ explosion_check_field (int x, int y, int p, int b)
_bomb *tmpbomb;
_player *tmpplayer;
if (x < 0 || x >= bman.fieldsize.x || y < 0 || y >= bman.fieldsize.y)
if (x < 0 || x >= map.size.x || y < 0 || y >= map.size.y)
return FT_block;
get_player_on (x << 8, y << 8, pl);
@ -376,17 +373,17 @@ explosion_check_field (int x, int y, int p, int b)
}
// let the stones right beside explode
if (bman.field[x][y].type != FT_nothing
&& bman.field[x][y].type != FT_block && bomb->ex_nr != bman.field[x][y].ex_nr)
if (bman.field[x][y].frame == 0) {
bman.field[x][y].frameto = ANI_STONETIMEOUT;
bman.field[x][y].frame = 1;
if (map.field[x][y].type != FT_nothing
&& map.field[x][y].type != FT_block && bomb->ex_nr != map.field[x][y].ex_nr)
if (map.field[x][y].frame == 0) {
map.field[x][y].frameto = ANI_STONETIMEOUT;
map.field[x][y].frame = 1;
draw_stone (x, y);
field_update (x, y);
}
return bman.field[x][y].type;
return map.field[x][y].type;
};
@ -432,9 +429,9 @@ draw_explosion (_bomb * bomb)
for (r = 0; r < bomb->firer[d]; r++) {
if (bomb->frameto == 0) {
bman.field[p.x][p.y].ex[d].frame++;
if (bman.field[p.x][p.y].ex[d].frame >= gfx.fire.frames)
bman.field[p.x][p.y].ex[d].frame = 0;
map.field[p.x][p.y].ex[d].frame++;
if (map.field[p.x][p.y].ex[d].frame >= gfx.fire.frames)
map.field[p.x][p.y].ex[d].frame = 0;
}
draw_fire (p.x, p.y, d, -1);
p.x += dx;
@ -483,8 +480,8 @@ do_explosion (int p, int b)
if (explosion_check_field (bpos.x + dx, bpos.y + dy, p, b) ==
BS_off && bomb->firerst[d] == -1) {
bomb->firer[d]++;
bman.field[bpos.x + dx][bpos.y + dy].ex[d].count++;
bman.field[bpos.x + dx][bpos.y + dy].ex[d].frame = bomb->firer[d];
map.field[bpos.x + dx][bpos.y + dy].ex[d].count++;
map.field[bpos.x + dx][bpos.y + dy].ex[d].frame = bomb->firer[d];
/* if we have a slow pc we can enable this and disable the drawing animation */
// draw_fire (bomb->pos.x + dx, bomb->pos.y + dy, d, gfx.fire.frames>>1);
}

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.43 2003/07/15 11:43:09 stpohle Exp $ */
/* $Id: bomberclone.h,v 1.44 2003/07/16 14:42:00 stpohle Exp $ */
/* bomberclone.h */
#ifndef _BOMBERCLONE_H_
@ -38,6 +38,8 @@
#include "config.h"
#endif
#include "basic.h"
#include "map.h"
#include "gfx.h"
#include "font.h"
#include "sound.h"
@ -113,41 +115,17 @@ struct __player {
} typedef _player;
struct __ex_field {
unsigned char count;
unsigned char frame;
} typedef _ex_field;
struct __field {
unsigned char type;
signed char mixframe; // data for the mixed frame
short int frame; // frame (frame > 0 && FS_stone)
int frameto; // frame to
unsigned char special; // to save special stones
_ex_field ex[4]; // count up every explosion there is on this field for ever direction
int ex_nr; // number to identify the explosion.
} typedef _field;
struct __serverlist {
char name[255];
} typedef _serverlist;
struct __bomberclone {
_point fieldsize; // dimension of the field
char datapath[512];
_player players[MAX_PLAYERS];
int p_nr; // Playernumber 0 if you host a game or the number of the one you are.
_field field[MAX_FIELDSIZE_X][MAX_FIELDSIZE_Y];
unsigned char bfield[MAX_FIELDSIZE_X][MAX_FIELDSIZE_Y]; // will hold informations if ther is a bomb
int random_map; // random selecting of a map
char fieldpath[512]; // path of the field file
int last_ex_nr; // number of the last explosion
int updatestatusbar; // 1 if statusbar has to be updated
unsigned char gametype;
@ -280,17 +258,6 @@ extern int ai_checkfield (int x, int y);
extern int ai_easyrunaway (_point p);
// mapmenu.c
extern void mapmenu ();
// map.c
extern void map_random ();
extern void map_genrandom ();
extern void init_map_tileset();
extern void map_new (char *filename);
extern void map_set_playerposition (int usermap);
extern void map_load (FILE * map);
// special.c
extern void special_use (int p_nr);
extern void special_pickup (int p_nr, int s_type);

@ -47,18 +47,18 @@ game_init (int argc, char **argv)
gfx.res.x = 640;
gfx.res.y = 480;
gfx.bpp = 16;
gfx.tileset[0] = 0;
gfx.random_tileset = 1;
bman.fieldsize.x = 25;
bman.fieldsize.y = 17;
map.tileset[0] = 0;
map.random_tileset = 1;
map.size.x = 25;
map.size.y = 17;
sprintf (bman.datapath, PACKAGE_DATA_DIR);
printf ("DataPath: %s\n", bman.datapath);
bman.fieldpath[0] = 0;
bman.random_map = 2;
map.map[0] = 0;
map.map_selection = 2;
bman.firewall = 0;
bman.ai_players = 1;
snd.inited = 0;
init_map_tileset();
// init_map_tileset(); why was this in here...
d_printf ("\n\n ***** Bomberclone Version %s \n\n",VERSION);
if (ReadConfig()) {
@ -159,16 +159,16 @@ ReadConfig ()
gfx.res.y = atoi (value);
}
if (!strcmp (keyword, "tileset")) {
strcpy (gfx.tileset, value);
strcpy (map.tileset, value);
}
if (!strcmp (keyword, "fieldpath")) {
if (strlen (value) > 510) {
if (!strcmp (keyword, "mapname")) {
if (strlen (value) > LEN_PATHFILENAME) {
d_printf
("*** Error - fieldpath too long (maximum size permitted is %d characters)!\n\n",
510);
LEN_PATHFILENAME);
}
value[511] = 0;
strcpy(bman.fieldpath,value);
strcpy(map.map,value);
}
if (!strcmp (keyword, "firewall")) {
bman.firewall = atoi (value);
@ -186,10 +186,10 @@ ReadConfig ()
bman.ai_players = atoi (value);
}
if (!strcmp (keyword, "fieldsizex")) {
bman.fieldsize.x = atoi (value);
map.size.x = atoi (value);
}
if (!strcmp (keyword, "fieldsizey")) {
bman.fieldsize.y = atoi (value);
map.size.y = atoi (value);
}
if (!strcmp (keyword, "fullscreen")) {
gfx.fullscreen = atoi (value);
@ -212,14 +212,11 @@ ReadConfig ()
if (!strcmp (keyword, "maxplayer")) {
bman.maxplayer = atoi (value);
}
if (!strcmp (keyword, "fieldpath")) {
strcpy (bman.fieldpath, value);
}
if (!strcmp (keyword, "randommap")) {
bman.random_map = atoi (value);
if (!strcmp (keyword, "mapselection")) {
map.map_selection = atoi (value);
}
if (!strcmp (keyword, "randomtileset")) {
gfx.random_tileset = atoi (value);
map.random_tileset = atoi (value);
}
for (i = 0; i < MAX_SERVERENTRYS; i++) {
sprintf (key2, "ip%d", i);
@ -248,13 +245,13 @@ WriteConfig ()
fprintf (config, "resolutionx=%d\n", gfx.res.x);
fprintf (config, "resolutiony=%d\n", gfx.res.y);
fprintf (config, "fullscreen=%d\n", gfx.fullscreen);
fprintf (config, "tileset=%s\n", gfx.tileset);
fprintf (config, "fieldpath=%s\n", bman.fieldpath);
fprintf (config, "tileset=%s\n", map.tileset);
fprintf (config, "mapname=%s\n", map.map);
fprintf (config, "firewall=%d\n", bman.firewall);
fprintf (config, "udpport=%s\n", bman.port);
fprintf (config, "ai_players=%d\n", bman.ai_players);
fprintf (config, "fieldsizex=%d\n", bman.fieldsize.x);
fprintf (config, "fieldsizey=%d\n", bman.fieldsize.y);
fprintf (config, "fieldsizex=%d\n", map.size.x);
fprintf (config, "fieldsizey=%d\n", map.size.y);
fprintf (config, "notify=%d\n", bman.notifygamemaster);
fprintf (config, "ai_family=%d\n", bman.net_ai_family);
fprintf (config, "masterserver=%s\n", bman.gamemaster);
@ -266,8 +263,8 @@ WriteConfig ()
fprintf (config, "askplayername=%d\n", bman.askplayername);
fprintf (config, "playername=%s\n", bman.playername);
fprintf (config, "bitsperpixel=%d\n", gfx.bpp);
fprintf (config, "randomtileset=%d\n", gfx.random_tileset);
fprintf (config, "randommap=%d\n", bman.random_map);
fprintf (config, "randomtileset=%d\n", map.random_tileset);
fprintf (config, "mapselection=%d\n", map.map_selection);
fclose (config);
return 0;
}

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.34 2003/07/15 11:43:09 stpohle Exp $ */
/* $Id: field.c,v 1.35 2003/07/16 14:42:00 stpohle Exp $ */
/* field.c - procedures which are needed to control the field */
#include <stdlib.h>
@ -12,14 +12,14 @@ static _point fieldani[MAX_FILEDANIMATION];
void
draw_stone (int x, int y)
{
_field *stone = &bman.field[x][y];
_field *stone = &map.field[x][y];
SDL_Rect dest,
src;
SDL_Surface *srcimg = NULL;
int i,
d;
if (x < 0 || y < 0 || x >= bman.fieldsize.x || y >= bman.fieldsize.y) {
if (x < 0 || y < 0 || x >= map.size.x || y >= map.size.y) {
d_fatal ("Draw Stone out of range [%d,%d]\n", x, y);
return;
}
@ -113,8 +113,8 @@ draw_field ()
int x,
y;
for (x = 0; x < bman.fieldsize.x; x++)
for (y = 0; y < bman.fieldsize.y; y++)
for (x = 0; x < map.size.x; x++)
for (y = 0; y < map.size.y; y++)
draw_stone (x, y);
};
@ -123,7 +123,7 @@ draw_field ()
void
field_clear (int x, int y)
{
bman.field[x][y].type = FT_nothing;
map.field[x][y].type = FT_nothing;
if (bman.gametype != GT_single)
net_game_send_field (x, y);
}
@ -145,10 +145,10 @@ field_animation ()
_field *stone;
for (i = 0; i < MAX_FILEDANIMATION; i++)
if (fieldani[i].x >= 0 && fieldani[i].x < bman.fieldsize.x && fieldani[i].y >= 0
&& fieldani[i].y < bman.fieldsize.y) {
if (fieldani[i].x >= 0 && fieldani[i].x < map.size.x && fieldani[i].y >= 0
&& fieldani[i].y < map.size.y) {
/* check if there is a need to animate this */
stone = &bman.field[fieldani[i].x][fieldani[i].y];
stone = &map.field[fieldani[i].x][fieldani[i].y];
if ((stone->type == FT_stone && stone->frame > 0) || (stone->type >= FT_death)) {
/* animate this stone */

@ -101,8 +101,8 @@ game_draw_info ()
}
if (debug) { /* do some debug informations on the screen */
redraw_logo (0, gfx.res.y - font[0].size.y, gfx.res.x, gfx.res.y);
for (x = 0; x < bman.fieldsize.x; x++)
draw_stone (x, bman.fieldsize.y - 1);
for (x = 0; x < map.size.x; x++)
draw_stone (x, map.size.y - 1);
if (GT_MP_PTP) {
sprintf (text, "NET_STAT: [");
for (i = 0; i < MAX_PLAYERS; i++)
@ -111,7 +111,7 @@ game_draw_info ()
text[strlen (text)] = ']';
font_draw (0, gfx.res.y - (font[0].size.y << 1), text, 0);
}
sprintf (text, "TILESET: %s Tframe: %d Tloop: %d", gfx.tileset, timediff, timediff1);
sprintf (text, "TILESET: %s Tframe: %d Tloop: %d", map.tileset, timediff, timediff1);
sprintf (text, "%s GFX_RECTS:%d", text, UpdateRects_nr);
font_draw (0, gfx.res.y - font[0].size.y, text, 0);
gfx_AddUpdateRect (0, gfx.res.y - (font[0].size.y << 1), gfx.res.x, font[0].size.y << 1);
@ -286,7 +286,7 @@ void
game_start ()
{
menu_displaytext ("Loading..", "Please Wait", 32, 128, 32);
tileset_load (gfx.tileset);
tileset_load (map.tileset);
gfx_load_players (gfx.block.x, gfx.block.y);
snd_load (gfx.tileset);
snd_load (map.tileset);
};

@ -1,4 +1,4 @@
/* $Id: gfx.h,v 1.12 2003/07/15 11:43:09 stpohle Exp $ */
/* $Id: gfx.h,v 1.13 2003/07/16 14:42:00 stpohle Exp $ */
#ifndef _GFX_H_
#define _GFX_H_
@ -48,9 +48,6 @@ struct __gfx {
_gfxani menuselect; // The Menu Select GFX (the bomb ?)
int random_tileset; // random selecting of a tileset
char tileset[LEN_TILESETNAME]; // name of the tileset
SDL_Surface *logo;
} typedef _gfx;

@ -1,8 +1,10 @@
/* $Id: map.c,v 1.1 2003/07/15 11:43:09 stpohle Exp $ */
/* $Id: map.c,v 1.2 2003/07/16 14:42:00 stpohle Exp $ */
/* map handling, like generate and load maps. */
#include "bomberclone.h"
_map map;
// put items into the field
void
map_fillitems (int fieldtype, int num)
@ -13,19 +15,19 @@ map_fillitems (int fieldtype, int num)
y;
/* this is the item factor we multiply it with this so we know
how much items we want in the game */
float fkt = ((float) (bman.fieldsize.x * bman.fieldsize.y)) / (25.0 * 17.0);
float fkt = ((float) (map.size.x * map.size.y)) / (25.0 * 17.0);
/* put the row special in the field */
for (d = 0; d < num * fkt; d++) {
x = y = 0;
while (bman.field[x][y].type != FT_stone || bman.field[x][y].special != FT_nothing) {
x = ((float) rand () / (float) RAND_MAX) * (bman.fieldsize.x - 1);
y = ((float) rand () / (float) RAND_MAX) * (bman.fieldsize.y - 1);
while (map.field[x][y].type != FT_stone || map.field[x][y].special != FT_nothing) {
x = ((float) rand () / (float) RAND_MAX) * (map.size.x - 1);
y = ((float) rand () / (float) RAND_MAX) * (map.size.y - 1);
nb_try--;
if (nb_try < 0)
break;
}
bman.field[x][y].special = fieldtype;
map.field[x][y].special = fieldtype;
}
}
@ -56,7 +58,7 @@ map_new (char *filename)
/* delete the bfield data */
for (x = 0; x < MAX_FIELDSIZE_X; x++)
for (y = 0; y < MAX_FIELDSIZE_Y; y++)
bman.bfield[x][y] = 0;
map.bfield[x][y] = 0;
/* Set the Playerinformation */
map_set_playerposition (fmap != NULL);
@ -85,33 +87,33 @@ void map_genrandom () {
int x, y, d;
/* if we can't load the map check first the fieldsize settings */
if (bman.fieldsize.x < MIN_FIELDSIZE_X)
bman.fieldsize.x = MIN_FIELDSIZE_X;
if (bman.fieldsize.x > MAX_FIELDSIZE_X)
bman.fieldsize.x = MAX_FIELDSIZE_X;
for (x = 0; x < bman.fieldsize.x; x++)
for (y = 0; y < bman.fieldsize.y; y++) {
if ((y == 0) || (y == bman.fieldsize.y - 1))
bman.field[x][y].type = FT_block;
else if ((x == 0) || (x == bman.fieldsize.x - 1))
bman.field[x][y].type = FT_block;
if (map.size.x < MIN_FIELDSIZE_X)
map.size.x = MIN_FIELDSIZE_X;
if (map.size.x > MAX_FIELDSIZE_X)
map.size.x = MAX_FIELDSIZE_X;
for (x = 0; x < map.size.x; x++)
for (y = 0; y < map.size.y; y++) {
if ((y == 0) || (y == map.size.y - 1))
map.field[x][y].type = FT_block;
else if ((x == 0) || (x == map.size.x - 1))
map.field[x][y].type = FT_block;
else if (((x & 1) == 0) && ((y & 1) == 0))
bman.field[x][y].type = FT_block;
map.field[x][y].type = FT_block;
else {
// create random field
if ((s_random (256) & 3) == 0)
bman.field[x][y].type = FT_nothing;
map.field[x][y].type = FT_nothing;
else
bman.field[x][y].type = FT_stone;
map.field[x][y].type = FT_stone;
}
for (d = 0; d < 4; d++)
bman.field[x][y].ex[d].frame = bman.field[x][y].ex[d].count = 0;
bman.field[x][y].ex_nr = -1;
bman.field[x][y].frame = 0;
bman.field[x][y].frameto = 0;
bman.field[x][y].special = FT_nothing;
map.field[x][y].ex[d].frame = map.field[x][y].ex[d].count = 0;
map.field[x][y].ex_nr = -1;
map.field[x][y].frame = 0;
map.field[x][y].frameto = 0;
map.field[x][y].special = FT_nothing;
}
}
@ -143,8 +145,8 @@ map_set_playerposition (int usermap)
int maxloop = 0;
while (maxloop < 200 && (PLX == -1 || PLY == -1)) {
maxloop++;
PLX = s_random (bman.fieldsize.x - 2) + 1;
PLY = s_random (bman.fieldsize.y - 2) + 1;
PLX = s_random (map.size.x - 2) + 1;
PLY = s_random (map.size.y - 2) + 1;
for (dx = 10, dy = 10, j = 0; (j < i && j < MAX_PLAYERS && (dx > 1 || dy > 1)); j++) { /* is ther any other player */
dx = PLX - bman.players[j].pos.x;
@ -157,8 +159,8 @@ map_set_playerposition (int usermap)
/* check if there is no block */
if ((dx > 1 || dy > 1)
&& ((bman.field[PLX][PLY].type != FT_block && maxloop > 100)
|| bman.field[PLX][PLY].type == FT_nothing)) {
&& ((map.field[PLX][PLY].type != FT_block && maxloop > 100)
|| map.field[PLX][PLY].type == FT_nothing)) {
/* get (up or down) dx and (left or right) dy */
dx = s_random (2);
if (dx == 0)
@ -168,18 +170,18 @@ map_set_playerposition (int usermap)
dy = -1;
/* first check if there is and free place for us */
if (!((bman.field[PLX + dx][PLY].type != FT_block && maxloop > 100) ||
bman.field[PLX + dx][PLY].type == FT_nothing))
if (!((map.field[PLX + dx][PLY].type != FT_block && maxloop > 100) ||
map.field[PLX + dx][PLY].type == FT_nothing))
dx = -dx;
if (!((bman.field[PLX + dx][PLY].type != FT_block && maxloop > 100) ||
bman.field[PLX + dx][PLY].type == FT_nothing))
if (!((map.field[PLX + dx][PLY].type != FT_block && maxloop > 100) ||
map.field[PLX + dx][PLY].type == FT_nothing))
PLX = -1;
if (!((bman.field[PLX][PLY + dy].type != FT_block && maxloop > 100) ||
bman.field[PLX][PLY + dy].type == FT_nothing))
if (!((map.field[PLX][PLY + dy].type != FT_block && maxloop > 100) ||
map.field[PLX][PLY + dy].type == FT_nothing))
dy = -dy;
if (!((bman.field[PLX][PLY + dy].type != FT_block && maxloop > 100) ||
bman.field[PLX][PLY + dy].type == FT_nothing))
if (!((map.field[PLX][PLY + dy].type != FT_block && maxloop > 100) ||
map.field[PLX][PLY + dy].type == FT_nothing))
PLY = -1;
}
else {
@ -189,9 +191,9 @@ map_set_playerposition (int usermap)
/* make some space */
if (PLX != -1 && PLY != -1) {
bman.field[PLX][PLY].type = FT_nothing;
bman.field[PLX + dx][PLY].type = FT_nothing;
bman.field[PLX][PLY + dy].type = FT_nothing;
map.field[PLX][PLY].type = FT_nothing;
map.field[PLX + dx][PLY].type = FT_nothing;
map.field[PLX][PLY + dy].type = FT_nothing;
}
}
}
@ -203,22 +205,22 @@ map_set_playerposition (int usermap)
}
/* now there will be some fields deleted */
PLX = 2 * (s_random ((bman.fieldsize.x - 1) / 2)) + 1;
PLY = 2 * (s_random ((bman.fieldsize.y - 1) / 2)) + 1;
PLX = 2 * (s_random ((map.size.x - 1) / 2)) + 1;
PLY = 2 * (s_random ((map.size.y - 1) / 2)) + 1;
bman.field[PLX][PLY].type = FT_nothing;
map.field[PLX][PLY].type = FT_nothing;
dx = s_random (4); // bit 1 = up/down bit 2 = left/right
/* up and down */
if (((dx & 1) == 0 && PLX > 1) || PLX >= bman.fieldsize.x - 2)
bman.field[PLX - 1][PLY].type = FT_nothing;
if (((dx & 1) == 0 && PLX > 1) || PLX >= map.size.x - 2)
map.field[PLX - 1][PLY].type = FT_nothing;
else
bman.field[PLX + 1][PLY].type = FT_nothing;
map.field[PLX + 1][PLY].type = FT_nothing;
/* left and right */
if (((dx & 2) == 0 && PLY > 1) || PLY >= bman.fieldsize.y - 2)
bman.field[PLX][PLY - 1].type = FT_nothing;
if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2)
map.field[PLX][PLY - 1].type = FT_nothing;
else
bman.field[PLX][PLY + 1].type = FT_nothing;
map.field[PLX][PLY + 1].type = FT_nothing;
}
mx = my = 100;
for (j = 0; j <= i; j++) { /* search smalest distance */
@ -273,27 +275,27 @@ void map_random () {
d_printf ("Random Map %s (%d on %d)\n", desel->name, sel, max);
if (desel != NULL)
sprintf (bman.fieldpath, "%s/maps/%s", bman.datapath, desel->name);
sprintf (map.map, "%s/maps/%s", bman.datapath, desel->name);
}
// Init the game according to options
void init_map_tileset()
{
switch (bman.random_map) {
switch (map.map_selection) {
case (0):
map_new (bman.fieldpath);
map_new (map.map);
break;
case (1):
map_random ();
map_new (bman.fieldpath);
map_new (map.map);
break;
case (2):
map_new (NULL);
break;
}
if (gfx.random_tileset)
if (map.random_tileset)
tileset_random ();
}
@ -304,7 +306,7 @@ void init_map_tileset()
an espace is nothing ' '
% are commentary at the beginning of the map */
void
map_load (FILE * map)
map_load (FILE * mapname)
{
size_t length;
char *currentline;
@ -314,7 +316,7 @@ map_load (FILE * map)
int i;
int d;
while ((currentline = fgets (tmp, MAX_FIELDSIZE_X, map))) {
while ((currentline = fgets (tmp, MAX_FIELDSIZE_X, mapname))) {
length = strlen (currentline);
if (currentline[0] == '%')
continue;
@ -323,22 +325,22 @@ map_load (FILE * map)
for (i = 0; i < length; i++) {
switch (currentline[i]) {
case '#':
bman.field[i][sizey].type = FT_block;
map.field[i][sizey].type = FT_block;
break;
case '@':
bman.field[i][sizey].type = FT_stone;
map.field[i][sizey].type = FT_stone;
break;
case ' ':
bman.field[i][sizey].type = FT_nothing;
map.field[i][sizey].type = FT_nothing;
default:
break;
}
for (d = 0; d < 4; d++)
bman.field[i][sizey].ex[d].frame = bman.field[i][sizey].ex[d].count = 0;
bman.field[i][sizey].ex_nr = -1;
bman.field[i][sizey].frame = 0;
bman.field[i][sizey].frameto = 0;
bman.field[i][sizey].special = FT_nothing;
map.field[i][sizey].ex[d].frame = map.field[i][sizey].ex[d].count = 0;
map.field[i][sizey].ex_nr = -1;
map.field[i][sizey].frame = 0;
map.field[i][sizey].frameto = 0;
map.field[i][sizey].special = FT_nothing;
}
sizey++;
if (sizex < length)
@ -346,12 +348,12 @@ map_load (FILE * map)
}
}
bman.fieldsize.x = sizex - 1;
bman.fieldsize.y = sizey;
map.size.x = sizex - 1;
map.size.y = sizey;
/* darw the border so we know everything is right */
for (i = 0; i < bman.fieldsize.x; i++)
bman.field[i][0].type = bman.field[i][bman.fieldsize.y - 1].type = FT_block;
for (i = 0; i < bman.fieldsize.y; i++)
bman.field[0][i].type = bman.field[bman.fieldsize.x - 1][i].type = FT_block;
for (i = 0; i < map.size.x; i++)
map.field[i][0].type = map.field[i][map.size.y - 1].type = FT_block;
for (i = 0; i < map.size.y; i++)
map.field[0][i].type = map.field[map.size.x - 1][i].type = FT_block;
}

@ -1,148 +1,156 @@
/* $Id: */
/* map/tileset selection menu */
#include "bomberclone.h"
#include "gfx.h"
/* launch the map options menu */
void mapmenu ()
void
mapmenu ()
{
int menuselect = 0;
char text[255], *map, pathname[LEN_PATHFILENAME], size[4];
char text[255],
*mapname,
pathname[LEN_PATHFILENAME],
size[4];
_menu menu[] = {
{1, "Random Map:"},
{1, "Selected Map:"},
{1, "Selected Map:"},
{2, " Size X:"},
{3, " Size Y:"},
{4, "Random Tileset:"},
{5, "Selected Tileset:"},
{6, "Max Players:"},
{0, ""},
{8, "Return To Previous Menu"},
{5, "Selected Tileset:"},
{6, "Max Players:"},
{7, "Bombs:"},
{8, "Fire :"},
{9, "Shoes:"},
{10, "Special Trigger:"},
{11, "Special Push :"},
{12, "Special Row :"},
{0, ""},
{14, "Return To Previous Menu"},
{-1, ""}
};
while (menuselect != -1) {
switch (map.map_selection) {
case (0):
if (map.map[0] == 0)
sprintf (menu[1].text, "Selected Map: < undefined >");
else
sprintf (menu[1].text, "Selected Map: %s", getfilename (map.map));
menu[1].index = 1;
sprintf (menu[0].text, "Random Map: OFF");
menu[2].text[0] = 0;
menu[2].index = 0;
menu[3].text[0] = 0;
menu[3].index = 0;
break;
case (1):
menu[1].text[0] = 0;
menu[1].index = 0;
sprintf (menu[0].text, "Random Map: random file");
menu[2].text[0] = 0;
menu[2].index = 0;
menu[3].text[0] = 0;
menu[3].index = 0;
break;
case (2):
menu[1].text[0] = 0;
menu[1].index = 0;
sprintf (menu[0].text, "Random Map: auto-generated");
sprintf (menu[2].text, " Size X: %d", map.size.x);
menu[2].index = 2;
sprintf (menu[3].text, " Size Y: %d", map.size.y);
menu[3].index = 3;
break;
}
switch (bman.random_map) {
case (0):
if(bman.fieldpath[0]==0)
sprintf (menu[1].text, "Selected Map: < undefined >");
else
sprintf (menu[1].text, "Selected Map: %s", getfilename(bman.fieldpath));
menu[1].index = 1;
sprintf (menu[0].text, "Random Map: OFF");
menu[2].text[0] = 0;
menu[2].index = 0;
menu[3].text[0] = 0;
menu[3].index = 0;
break;
case (1):
menu[1].text[0] = 0;
menu[1].index = 0;
sprintf (menu[0].text, "Random Map: random file");
menu[2].text[0] = 0;
menu[2].index = 0;
menu[3].text[0] = 0;
menu[3].index = 0;
break;
case (2):
menu[1].text[0] = 0;
menu[1].index = 0;
sprintf (menu[0].text, "Random Map: auto-generated");
sprintf (menu[2].text, " Size X: %d", bman.fieldsize.x);
menu[2].index = 2;
sprintf (menu[3].text, " Size Y: %d", bman.fieldsize.y);
menu[3].index = 3;
break;
}
if(gfx.random_tileset)
{
menu[5].text[0] = 0;
menu[5].index = 0;
}
else
{
if(gfx.tileset[0]==0)
sprintf (menu[5].text, "Selected Tileset: < undefined >");
else
sprintf (menu[5].text, "Selected Tileset: %s", gfx.tileset);
menu[5].index = 5;
}
if(gfx.random_tileset)
sprintf (menu[4].text, "Random Tileset: random file");
else
sprintf (menu[4].text, "Random Tileset: OFF");
sprintf(menu[6].text,"Max Players: %d/%d",bman.maxplayer,MAX_PLAYERS);
if (map.random_tileset) {
menu[5].text[0] = 0;
menu[5].index = 0;
}
else {
if (map.tileset[0] == 0)
sprintf (menu[5].text, "Selected Tileset: < undefined >");
else
sprintf (menu[5].text, "Selected Tileset: %s", map.tileset);
menu[5].index = 5;
}
if (map.random_tileset)
sprintf (menu[4].text, "Random Tileset: random file");
else
sprintf (menu[4].text, "Random Tileset: OFF");
sprintf (menu[6].text, "Max Players: %d/%d", bman.maxplayer, MAX_PLAYERS);
sprintf (menu[7].text, "Bombs:%d", map.bombs);
sprintf (menu[8].text, "Fire :%d", map.fire);
sprintf (menu[9].text, "Shoes:%d", map.shoes);
sprintf (menu[10].text, "Special Trigger:%d", map.sp_trigger);
sprintf (menu[11].text, "Special Push :%d", map.sp_push);
sprintf (menu[12].text, "Special Row :%d", map.sp_row);
menuselect = menu_loop ("Map Options", menu, menuselect);
switch (menuselect) {
case (0): // Random Map
bman.random_map = (bman.random_map+2)%3;
map.map_selection = (map.map_selection + 2) % 3;
break;
case (1): // Selected Map
sprintf (pathname , "%s/maps", bman.datapath);
map = menu_dir_select ("Select Map", pathname, DF_file);
if (map == NULL)
{
bman.fieldpath[0] = 0;
bman.random_map = 2;
}
else
sprintf (bman.fieldpath, "%s/maps/%s", bman.datapath, map);
sprintf (pathname, "%s/maps", bman.datapath);
mapname = menu_dir_select ("Select Map", pathname, DF_file);
if (mapname == NULL) {
map.map[0] = 0;
map.map_selection = 2;
}
else
sprintf (map.map, "%s/maps/%s", bman.datapath, mapname);
break;
case (2): // Size X
sprintf (text, "Field Size X (%d - %d)", MIN_FIELDSIZE_X, MAX_FIELDSIZE_X);
sprintf (size, "%d", bman.fieldsize.x);
sprintf (size, "%d", map.size.x);
menu_get_text (text, size, 3);
bman.fieldsize.x = atoi (size) | 1;
if (bman.fieldsize.x < MIN_FIELDSIZE_X)
bman.fieldsize.x = MIN_FIELDSIZE_X;
if (bman.fieldsize.x > MAX_FIELDSIZE_X)
bman.fieldsize.x = MAX_FIELDSIZE_X;
break;
map.size.x = atoi (size) | 1;
if (map.size.x < MIN_FIELDSIZE_X)
map.size.x = MIN_FIELDSIZE_X;
if (map.size.x > MAX_FIELDSIZE_X)
map.size.x = MAX_FIELDSIZE_X;
break;
case (3): // Size Y
sprintf (text, "Field Size Y (%d - %d)", MIN_FIELDSIZE_Y, MAX_FIELDSIZE_Y);
sprintf (size, "%d", bman.fieldsize.y);
sprintf (size, "%d", map.size.y);
menu_get_text (text, size, 3);
bman.fieldsize.y = atoi (size) | 1;
if (bman.fieldsize.y < MIN_FIELDSIZE_Y)
bman.fieldsize.y = MIN_FIELDSIZE_Y;
if (bman.fieldsize.y > MAX_FIELDSIZE_Y)
bman.fieldsize.y = MAX_FIELDSIZE_Y;
map.size.y = atoi (size) | 1;
if (map.size.y < MIN_FIELDSIZE_Y)
map.size.y = MIN_FIELDSIZE_Y;
if (map.size.y > MAX_FIELDSIZE_Y)
map.size.y = MAX_FIELDSIZE_Y;
break;
case (4): // Random Tileset
if (gfx.random_tileset == 1)
gfx.random_tileset = 0;
else
gfx.random_tileset = 1;
if (map.random_tileset == 1)
map.random_tileset = 0;
else
map.random_tileset = 1;
break;
case (5): // Selected Tileset
sprintf (pathname , "%s/tileset", bman.datapath);
map = menu_dir_select ("Select Tileset", pathname, DF_dir);
if (map == NULL)
{
gfx.tileset[0] = 0;
gfx.random_tileset = 1;
}
else
strcpy (gfx.tileset, map);
sprintf (pathname, "%s/tileset", bman.datapath);
mapname = menu_dir_select ("Select Tileset", pathname, DF_dir);
if (mapname == NULL) {
map.tileset[0] = 0;
map.random_tileset = 1;
}
else
strcpy (map.tileset, mapname);
break;
case (6):
case (6):
sprintf (text, "%d", bman.maxplayer);
menu_get_text ("Max Players", text, 2);
bman.maxplayer = atoi (text);
@ -152,9 +160,16 @@ void mapmenu ()
bman.maxplayer = 2;
break;
case (8): // Return to previous menu
case (14): // Return to previous menu
menuselect = -1;
break;
}
}
}
void
display_mapinfo ()
{
/* bla */
}

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.34 2003/07/08 22:18:33 stpohle Exp $ */
/* $Id: network.c,v 1.35 2003/07/16 14:42:00 stpohle Exp $ */
/*
network routines.
*/
@ -342,7 +342,7 @@ draw_netupdatestate ()
text[0] = 0;
if (bman.players[i].net.net_istep == 2)
sprintf (text, "Getting Field Data %d of %d.", bman.players[i].net.net_status,
bman.fieldsize.x);
map.size.x);
if (bman.players[i].net.net_istep == 1)
sprintf (text, "Getting Player Data %d of %d.", bman.players[i].net.net_status,
@ -447,19 +447,19 @@ net_new_gamedata ()
/* if PTPS get all data */
if (GT_MP_PTPS) {
if (net_istep == 2) {
if ((y < bman.fieldsize.y - 1 && y == bman.players[bman.p_nr].net.net_status)
if ((y < map.size.y - 1 && y == bman.players[bman.p_nr].net.net_status)
|| y == -1) {
/* send field data req */
y++;
downtimestamp = timestamp;
send_getfield (&bman.players[0].net.addr, y);
}
else if (y < bman.fieldsize.y && y != bman.players[bman.p_nr].net.net_status
else if (y < map.size.y && y != bman.players[bman.p_nr].net.net_status
&& y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
/* we have got no field data */
y--;
}
else if (y == bman.fieldsize.y - 1 && bman.players[bman.p_nr].net.net_status == y) {
else if (y == map.size.y - 1 && bman.players[bman.p_nr].net.net_status == y) {
/* we have got all field data */
y = -1;
bman.players[bman.p_nr].net.net_istep = --net_istep;
@ -604,7 +604,7 @@ net_game_send_field (int x, int y)
for (pl = 0; pl < MAX_PLAYERS; pl++)
if (PS_IS_netplayer (bman.players[pl].state) && pl != bman.p_nr && NET_CANSEND(pl))
send_field (&bman.players[pl].net.addr, x, y, &bman.field[x][y]);
send_field (&bman.players[pl].net.addr, x, y, &map.field[x][y]);
};

@ -273,10 +273,9 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
bman.lastwinner = s_mod->last_winner;
if (GT_MP_PTPS) {
bman.fieldsize.x = s_mod->fieldsize_x;
bman.fieldsize.y = s_mod->fieldsize_y;
map.size.x = s_mod->fieldsize_x;
map.size.y = s_mod->fieldsize_y;
}
strncpy (gfx.tileset, s_mod->tileset, LEN_TILESETNAME);
bman.updatestatusbar = 1;
};
@ -301,9 +300,8 @@ send_servermode (_net_addr * addr, int pl_nr)
s_mod.maxplayer = bman.maxplayer;
s_mod.pl_nr = pl_nr;
s_mod.last_winner = bman.lastwinner;
s_mod.fieldsize_x = bman.fieldsize.x;
s_mod.fieldsize_y = bman.fieldsize.y;
strncpy (s_mod.tileset, gfx.tileset, LEN_TILESETNAME);
s_mod.fieldsize_x = map.size.x;
s_mod.fieldsize_y = map.size.y;
send_pkg ((struct pkg *) &s_mod, addr);
};
@ -322,9 +320,9 @@ send_field (_net_addr * addr, int x, int y, _field * field)
f_dat.x = x;
f_dat.y = y;
if (x < 0 || x >= bman.fieldsize.x || y < 0 || y >= bman.fieldsize.y)
if (x < 0 || x >= map.size.x || y < 0 || y >= map.size.y)
return;
memcpy (&f_dat.field, &bman.field[x][y], sizeof (_field));
memcpy (&f_dat.field, &map.field[x][y], sizeof (_field));
send_pkg ((struct pkg *) &f_dat, addr);
};
@ -336,8 +334,8 @@ do_field (struct pkg_field *f_dat, _net_addr * addr)
if (addr->pl_nr == -1)
return;
if (f_dat->x < bman.fieldsize.x && f_dat->y < bman.fieldsize.y) {
memcpy (&bman.field[f_dat->x][f_dat->y], &f_dat->field, sizeof (_field));
if (f_dat->x < map.size.x && f_dat->y < map.size.y) {
memcpy (&map.field[f_dat->x][f_dat->y], &f_dat->field, sizeof (_field));
}
if (bman.state == GS_running)
draw_stone (f_dat->x, f_dat->y);
@ -607,9 +605,9 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
if ((bomb->state == BS_ticking || bomb->state == BS_trigger) && (b_dat->state == BS_ticking || b_dat->state == BS_trigger)) { // handle push & kick special
if (bomb->moves)
bman.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 0; //remove bomb at old location
map.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 0; //remove bomb at old location
else
bman.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 1; //set bomb at position
map.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 1; //set bomb at position
draw_stone (bomb->pos.x >> 8, bomb->pos.y >> 8);
field_update (bomb->pos.x >> 8, bomb->pos.y >> 8);
}
@ -625,7 +623,7 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
to make sure the timeout won't be resetted
by an old network packet */
bman.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1; // keep the bfield up to date
map.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1; // keep the bfield up to date
bomb->r = b_dat->r;
bomb->ex_nr = b_dat->ex_nr;
@ -761,13 +759,13 @@ send_fieldline (_net_addr * addr, int line)
return;
for (i = 0; i < MAX_FIELDSIZE_X; i++) {
f_dat.type[i] = bman.field[i][line].type;
f_dat.special[i] = bman.field[i][line].special;
bman.field[i][line].frame = 0;
bman.field[i][line].frameto = 0;
bman.field[i][line].ex_nr = 0;
f_dat.type[i] = map.field[i][line].type;
f_dat.special[i] = map.field[i][line].special;
map.field[i][line].frame = 0;
map.field[i][line].frameto = 0;
map.field[i][line].ex_nr = 0;
for (j = 0; j < 4; j++)
bman.field[i][line].ex[j].frame = bman.field[i][line].ex[j].count = 0;
map.field[i][line].ex[j].frame = map.field[i][line].ex[j].count = 0;
}
send_pkg ((struct pkg *) &f_dat, addr);
};
@ -798,12 +796,12 @@ do_fieldline (struct pkg_fieldline *f_dat, _net_addr * addr)
bman.players[bman.p_nr].net.net_status = f_dat->line;
for (i = 0; i < MAX_FIELDSIZE_X; i++) {
bman.field[i][f_dat->line].type = f_dat->type[i];
bman.field[i][f_dat->line].special = f_dat->special[i];
bman.field[i][f_dat->line].frameto = 0;
bman.field[i][f_dat->line].frame = 0;
map.field[i][f_dat->line].type = f_dat->type[i];
map.field[i][f_dat->line].special = f_dat->special[i];
map.field[i][f_dat->line].frameto = 0;
map.field[i][f_dat->line].frame = 0;
for (d = 0; d < 4; d++)
bman.field[i][f_dat->line].ex[d].frame = bman.field[i][f_dat->line].ex[d].count = 0;
map.field[i][f_dat->line].ex[d].frame = map.field[i][f_dat->line].ex[d].count = 0;
}
};

@ -1,6 +1,5 @@
/* network packets.. */
enum _network_data {
PKG_error = 0,
PKG_pingreq,
@ -20,6 +19,7 @@ enum _network_data {
PKG_chat,
PKG_ill,
PKG_special,
PKG_mapinfo,
PKG_bcmservchat = 90
};
@ -89,11 +89,9 @@ struct pkg_servermode {
signed char last_winner;
signed char fieldsize_x;
signed char fieldsize_y;
char tileset [LEN_TILESETNAME];
signed char pl_nr; /* if the server sends this to a client...
it will be the clients in_nr number
(-1) for not set */
};
@ -204,6 +202,30 @@ struct pkg_chat {
};
struct pkg_special {
struct pkgheader h;
signed char pl_nr;
int ex_nr;
unsigned char typ;
};
struct pkg_mapinfo {
struct pkgheader h;
char tileset[LEN_TILESETNAME];
char mapname[LEN_FILENAME];
unsigned char bombs;
unsigned char shoes;
unsigned char fire;
unsigned char death;
unsigned char sp_trigger;
unsigned char sp_push;
unsigned char sp_row;
unsigned char size_x;
unsigned char size_y;
};
struct _rscache_entry {
signed char pl_nr; // playernumber to whom this data should go
short int len; // size of the entry
@ -228,14 +250,6 @@ struct _inpkg_index {
};
struct pkg_special {
struct pkgheader h;
signed char pl_nr;
int ex_nr;
unsigned char typ;
};
extern int do_error (struct pkg_error *data, _net_addr *addr);
extern void do_playerid (struct pkg_playerid *p_id, _net_addr *addr);
extern void do_servermode (struct pkg_servermode *s_mod, _net_addr *addr);

@ -12,8 +12,8 @@ draw_player (_player * player)
dest;
int i;
if ((player->pos.x >> 8) < 0 || (player->pos.x >> 8) >= bman.fieldsize.x ||
(player->pos.y >> 8) < 0 || (player->pos.y >> 8) >= bman.fieldsize.y) {
if ((player->pos.x >> 8) < 0 || (player->pos.x >> 8) >= map.size.x ||
(player->pos.y >> 8) < 0 || (player->pos.y >> 8) >= map.size.y) {
d_printf ("FATAL: Draw Player out of range : [%d,%d]\n", (player->pos.x >> 8),
(player->pos.y >> 8));
return;
@ -88,9 +88,9 @@ restore_players_screen ()
for (i = 0; i < MAX_PLAYERS; i++)
if ((PS_IS_used (bman.players[i].state)) && bman.players[i].old.x != -1) {
if ((bman.players[i].old.x >> 8) < 0 || (bman.players[i].old.x >> 8) >= bman.fieldsize.x
if ((bman.players[i].old.x >> 8) < 0 || (bman.players[i].old.x >> 8) >= map.size.x
|| (bman.players[i].old.y >> 8) < 0
|| (bman.players[i].old.y >> 8) >= bman.fieldsize.y)
|| (bman.players[i].old.y >> 8) >= map.size.y)
d_printf ("FATAL: Restore Player out of range : playernr %d [%d,%d]\n", i,
(bman.players[i].old.x >> 8), (bman.players[i].old.y >> 8));
else {
@ -104,14 +104,14 @@ restore_players_screen ()
}
if (x < 0)
x = 0;
if (xe >= bman.fieldsize.x)
xe = bman.fieldsize.x - 1;
if (xe >= map.size.x)
xe = map.size.x - 1;
ys = (bman.players[i].old.y >> 8) - 1;
ye = (bman.players[i].old.y >> 8) + 1;
if (ys < 0)
ys = 0;
if (ye >= bman.fieldsize.y)
ye = bman.fieldsize.y - 1;
if (ye >= map.size.y)
ye = map.size.y - 1;
xs = x;
for (; x <= xe; x++)
for (y = ys; y <= ye; y++)
@ -142,7 +142,7 @@ player_check_powerup (int p_nr)
fx = fx + 1;
if (_y > 128)
fy = fy + 1;
ft = bman.field[fx][fy].type;
ft = map.field[fx][fy].type;
/* we found a mixed powerup */
if (ft == FT_mixed) {
i = s_random (6);
@ -219,7 +219,7 @@ check_field (short int x, short int y)
{
int res = 0;
if (bman.field[x][y].type != FT_stone && bman.field[x][y].type != FT_block)
if (map.field[x][y].type != FT_stone && map.field[x][y].type != FT_block)
res = 1;
return res;
@ -401,7 +401,7 @@ player_drop_bomb (int pl_nr)
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200
}
bomb->ex_nr = -1;
bman.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1;
map.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1;
if (bman.gametype != GT_single) {
net_game_send_bomb (pl_nr, i);
if (GT_MP_PTPS)
@ -523,7 +523,7 @@ player_calcstep (_player * pl)
player_animation (pl);
fx = pl->pos.x >> 8;
fy = pl->pos.y >> 8;
if (bman.field[fx][fy].type != FT_block && bman.field[fx][fy].type != FT_stone) {
if (map.field[fx][fy].type != FT_block && map.field[fx][fy].type != FT_stone) {
d.x = 0;
d.y = 0;
if (pl->d == left)

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.34 2003/07/15 11:43:09 stpohle Exp $ */
/* $Id: single.c,v 1.35 2003/07/16 14:42:00 stpohle Exp $ */
/* single player */
#include "basic.h"
@ -69,7 +69,7 @@ single_game_new ()
int
ai_checkfield (int x, int y)
{
return ((bman.field[x][y].type == FT_nothing || bman.field[x][y].type == FT_fire || bman.field[x][y].type == FT_shoe || bman.field[x][y].type == FT_bomb ) && bman.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);
}
@ -113,8 +113,8 @@ ai_easyrunaway (_point p)
for (i = 0; i < 4; i++) {
/* check if we are still in the game field */
if (pos[i].x <= 0 || pos[i].y <= 0 || pos[i].x >= bman.fieldsize.x - 1
|| pos[i].y >= bman.fieldsize.y - 1)
if (pos[i].x <= 0 || pos[i].y <= 0 || pos[i].x >= map.size.x - 1
|| pos[i].y >= map.size.y - 1)
pos[i].x = pos[i].y = -1;
if (pos[i].x != -1 && pos[i].y != -1) {
@ -212,8 +212,8 @@ ai_runawayfrom (_point p, int nearbomb, signed char norecursive)
for (i = 0; i < 4; i++) {
/* check if we are still in the game field */
if (pos[i].x <= 0 || pos[i].y <= 0 || pos[i].x >= bman.fieldsize.x - 1
|| pos[i].y >= bman.fieldsize.y - 1)
if (pos[i].x <= 0 || pos[i].y <= 0 || pos[i].x >= map.size.x - 1
|| pos[i].y >= map.size.y - 1)
pos[i].x = pos[i].y = -1;
if (pos[i].x != -1 && pos[i].y != -1) {
@ -290,7 +290,7 @@ ai_bombpoints (_point pos, int range)
_point p,
m;
if (bman.field[pos.x][pos.y].type != FT_block && bman.field[pos.x][pos.y].type != FT_stone
if (map.field[pos.x][pos.y].type != FT_block && map.field[pos.x][pos.y].type != FT_stone
&& ai_checkfield (pos.x, pos.y)) {
for (d = 0; d < 4; d++) {
switch (d) {
@ -314,15 +314,15 @@ ai_bombpoints (_point pos, int range)
p = pos;
for (r = 0; (r < range && bman.field[p.x][p.y].type == FT_nothing); r++) {
for (r = 0; (r < range && map.field[p.x][p.y].type == FT_nothing); r++) {
p.x += m.x;
p.y += m.y;
}
if (bman.field[p.x][p.y].type != FT_nothing && (bman.field[p.x][p.y].type != FT_block || bman.field[p.x][p.y].type == FT_shoe || bman.field[p.x][p.y].type == FT_bomb || bman.field[p.x][p.y].type == FT_fire))
if (map.field[p.x][p.y].type != FT_nothing && (map.field[p.x][p.y].type != FT_block || map.field[p.x][p.y].type == FT_shoe || map.field[p.x][p.y].type == FT_bomb || map.field[p.x][p.y].type == FT_fire))
points++;
if (bman.field[p.x][p.y].type == FT_shoe || bman.field[p.x][p.y].type == FT_bomb ||
bman.field[p.x][p.y].type == FT_fire)
if (map.field[p.x][p.y].type == FT_shoe || map.field[p.x][p.y].type == FT_bomb ||
map.field[p.x][p.y].type == FT_fire)
points += 2;
}
}
@ -381,8 +381,8 @@ ai_findbestbombdir (_point pos, int dir, int range)
if (d < 4) {
p[d].x += m[d].x;
p[d].y += m[d].y;
if (p[d].x > 0 && p[d].y > 0 && p[d].x < bman.fieldsize.x - 1
&& p[d].y < bman.fieldsize.y - 1) {
if (p[d].x > 0 && p[d].y > 0 && p[d].x < map.size.x - 1
&& p[d].y < map.size.y - 1) {
if (ai_checkfield (p[d].x, p[d].y)) {
/* we are opn a empty field go on with the test */
done = 0;
@ -463,13 +463,13 @@ ai_findnearbombs (_point pos)
done = 1;
/* check every direction again */
for (d = 0; d < 4; d++)
if (dist[d].x >= 0 && dist[d].x < bman.fieldsize.x &&
dist[d].y >= 0 && dist[d].y < bman.fieldsize.y) {
if (bman.bfield[dist[d].x][dist[d].y] != 0) {
if (dist[d].x >= 0 && dist[d].x < map.size.x &&
dist[d].y >= 0 && dist[d].y < map.size.y) {
if (map.bfield[dist[d].x][dist[d].y] != 0) {
res |= (1 << d); // set the bit for the direction;
dist[d].x = dist[d].y = -1; // don't check no more.
}
if (bman.field[dist[d].x][dist[d].y].type != FT_nothing)
if (map.field[dist[d].x][dist[d].y].type != FT_nothing)
dist[d].x = dist[d].y = -1; // don't check no more.
else if (dist[d].x != -1 && dist[d].y != -1) {
dist[d].x += m[d].x;
@ -479,7 +479,7 @@ ai_findnearbombs (_point pos)
}
}
if (bman.bfield[pos.x][pos.y] != 0)
if (map.bfield[pos.x][pos.y] != 0)
res |= 16; // set the 4th. bit
return res;

@ -1,4 +1,4 @@
/* $Id: special.c,v 1.22 2003/07/13 23:07:59 stpohle Exp $ */
/* $Id: special.c,v 1.23 2003/07/16 14:42:00 stpohle Exp $ */
/* special.c - procedues to control the specials */
#include "bomberclone.h"
@ -60,14 +60,14 @@ special_row (int p_nr)
}
x += dx;
y += dy;
while (bman.bfield[x][y]) {
while (map.bfield[x][y]) {
x += dx;
y += dy;
/* add one time tick to each bomb found to ensure that the explosion is infacted by the previous bomb
otherwise powerups will disappear due to explosion of previous bomb */
t++;
}
if (bman.field[x][y].type == FT_nothing) {
if (map.field[x][y].type == FT_nothing) {
for (i = 0; ((i < p->bombs_n) && (p->bombs[i].state != BS_off)); i++);
if (i < p->bombs_n) {
b = &p->bombs[i];
@ -77,7 +77,7 @@ special_row (int p_nr)
b->pos.x = x << 8;
b->pos.y = y << 8;
b->to = BOMB_TIMEOUT * TIME_FACTOR + t; // 5 Secs * 200
bman.bfield[x][y] = 1;
map.bfield[x][y] = 1;
if (bman.gametype != GT_single) {
net_game_send_bomb (p_nr, i);
if (GT_MP_PTPS)
@ -123,14 +123,14 @@ special_push (int p_nr)
y += dy;
// check that player is beside a bomb
if (!bman.bfield[x][y])
if (!map.bfield[x][y])
return;
x1 = x + dx;
y1 = y + dy;
// check the field behind the bomb
if (bman.bfield[x1][y1] || bman.field[x1][y1].type != FT_nothing)
if (map.bfield[x1][y1] || map.field[x1][y1].type != FT_nothing)
return;
get_bomb_on (x << 8, y << 8, bombs);
@ -141,8 +141,8 @@ special_push (int p_nr)
b->moveto.x = x1 << 8;
b->moveto.y = y1 << 8;
b->moves = p->speed;
bman.bfield[x][y] = 0;
bman.bfield[x1][y1] = 1;
map.bfield[x][y] = 0;
map.bfield[x1][y1] = 1;
draw_stone (x, y);
field_update (x, y);
if (bman.gametype != GT_single) {

@ -1,4 +1,4 @@
/* $Id: tileset.c,v 1.1 2003/07/15 11:43:09 stpohle Exp $ */
/* $Id: tileset.c,v 1.2 2003/07/16 14:42:00 stpohle Exp $ */
/* load and select tilesets */
#include "bomberclone.h"
@ -28,8 +28,8 @@ void tileset_random () {
d_printf ("Random Tileset %s (%d on %d)\n", desel->name, sel, max);
if (desel != NULL)
strncpy (gfx.tileset, desel->name, LEN_TILESETNAME);
gfx.tileset[LEN_TILESETNAME-1] = 0;
strncpy (map.tileset, desel->name, LEN_TILESETNAME);
map.tileset[LEN_TILESETNAME-1] = 0;
}
@ -54,8 +54,8 @@ tileset_load (char *tilesetname)
strncpy (tileset, tilesetname, LEN_TILESETNAME);
/* Calculate the Best Size of the Images */
gfx.block.x = gfx.res.x / (bman.fieldsize.x + 1);
gfx.block.y = (gfx.res.y - 80) / (bman.fieldsize.y + 1);
gfx.block.x = gfx.res.x / (map.size.x + 1);
gfx.block.y = (gfx.res.y - 80) / (map.size.y + 1);
if (gfx.block.x < gfx.block.y)
gfx.block.y = gfx.block.x;
else
@ -66,8 +66,8 @@ tileset_load (char *tilesetname)
sfkt = ((float) gfx.block.x) / ((float) GFX_IMGSIZE);
/* calculating the best offset for the field on the screen */
gfx.offset.x = (gfx.res.x - (gfx.block.x * bman.fieldsize.x)) / 2;
gfx.offset.y = gfx.res.y - (gfx.block.y * bman.fieldsize.y);
gfx.offset.x = (gfx.res.x - (gfx.block.x * map.size.x)) / 2;
gfx.offset.y = gfx.res.y - (gfx.block.y * map.size.y);
/* load the fire */
sprintf (fullname, "%s/tileset/%s/fire.bmp", bman.datapath, tileset);

Loading…
Cancel
Save