Added TechDoc.txt file with some informations and some other little fixes

origin
stpohle 23 years ago
parent 9acbe961a0
commit 3c8c605b3c

@ -0,0 +1,133 @@
This file will hold some Details about the Game.
A list of files and what every file is used for:
field.c:
selecting a tileset
loading maps
generating maps
drawing the field
bomb.c:
drawing bombs
drawing explosions
calculating and checking the explosions
player.c:
drawing the player
moving the player
*calculating the new position of the players
checking for powerups
chat.c:
drawing chatbox
game.c:
the whole gameloop (multi and singleplayer)
single.c:
creating a single game
*generating ai players
*moving the ai players
font.c:
drawing text on the screen
network.c:
network loop
- keeping ther network alife, like sending ping, checking for
timeouts.
- doing the dynamic change of the send_pkg option
- this function will take care about all incomming network packets.
network init
network shutdown
update the clients for a new game
send to all players
- playerdata
- playermoves
- bombdata
- fielddata
- playerlist
- chat messages
- playerillness
delete a network player from a game
fills in the sockaddr from all the players
clean everything for a new network game
netmenu.c:
network menu
join a game
host a game
network options
packets.c:
everything what have to do with the network packet,
all send_* and all do_* function are defined in here.
send_packetname, do_packetname
do_pkg
------
will check the packet for wrong data network type
illegal packets, will delete the packet if we have got it already
do automatic pingreply or send the pkgack packet back.
send_pkg
--------
if the PKGF_ACKREQ flag is set it will cache the packet and check it if
it's reched the other side and if we have got the ACKPKG back.
holds an incoming index table of the last 256 (PKG_IN_INDEX_NUM) packets
so if one reches double in a certain time it will be ignored.
pkgcache.c:
gives a pointer to a outgoing packet
add a outgoing packet
- function is only called from send_pkg
- only packet with PKGF_ackreq flag will cached
deletes a packet
len of an outgoing packet
resend cache loop
- function only called from network_loop
will resend after a timeout time a packet.
to make sure the packet got reched on the other side.
configuration.c:
configuratio/option menu
read config
write config
change resolution menu
read program arguments
game startup init
- only called from the main function to set some variables at
programstart
gfx.c:
draw shadowed boxes
shading parts on the screen
draw background logo
draw shaded background logos
updates a list of parts from the screen
- gfx_UpdateRects (updates all rects)
- gfx_AddUpdateRects(add a rect of the screen)
gets the color of an pixel on a surface
scaling of images
load/free playergraphics
load/free game data (fonts and background)
load/free tilesets
init/shutdown game graphics
- this function will calculate the best scaling size on the screen
gamesrv.c:
communiaction with the game master server
adds a game to the master server
deletes a game from the masterserver
sends chat information to the master server
server selection menu
udp.c:
send messages
get messages
dns names
start/stop udp server

@ -45,6 +45,7 @@
#define LEN_GAMENAME 32
#define LEN_PATHFILENAME 512
#define LEN_FILENAME 256
#define LEN_TILESETNAME 32
#define DEFAULT_UDPPORT 11000
#define DEFAULT_GMUDPPORT "11100"

@ -44,7 +44,8 @@ game_init ()
gfx.res.x = 640;
gfx.res.y = 480;
gfx.bpp = 16;
sprintf (gfx.tileset,"default");
tileset[0] = 0;
random_tileset = 1;
bman.fieldsize.x = 25;
bman.fieldsize.y = 17;
sprintf (bman.datapath, "data");

@ -83,14 +83,16 @@ game_draw_info ()
draw_stone (x, bman.fieldsize.y-1);
if (debug) { /* do some debug informations on the screen */
sprintf (text, "Net Option: [");
sprintf (text, "NET_STAT: [");
for (i = 0 ; i < MAX_PLAYERS; i++)
sprintf (text, "%s%3d ", text, bman.players[i].net.pkgopt.send_set);
text[strlen(text)+1] = 0;
text[strlen(text)] = ']';
sprintf (text, "%s gfx_Rects:%d", text, UpdateRects_nr);
draw_text (0, gfx.res.y - gfx.font.size.y, text, 1);
gfx_AddUpdateRect (0, gfx.res.y - gfx.font.size.y, gfx.res.x, gfx.font.size.y);
sprintf (text, "%s GFX_RECTS:%d", text, UpdateRects_nr);
draw_text (0, gfx.res.y - (gfx.font.size.y << 1), text, 1);
sprintf (text, "TILESET: %s", gfx.tileset);
gfx_AddUpdateRect (0, gfx.res.y - (gfx.font.size.y << 1), gfx.res.x, gfx.font.size.y << 1);
}
if (chat.visible == 0) {

@ -650,17 +650,18 @@ SDL_Surface *gfx_copyscreen (SDL_Rect *wnd) {
};
void gfx_load_tileset (char *tileset) {
void gfx_load_tileset (char *tilesetname) {
int i,
r,
g,
b;
char filename[255];
char filename[LEN_PATHFILENAME];
char tileset[LEN_TILESETNAME];
SDL_Surface *tmpimage, *tmpimage1;
float sfkt;
d_printf ("Loading Tileset\n");
d_printf ("Loading Tileset: %s\n", tileset);
/* Calculate the Best Size of the Images */
gfx.block.x = gfx.res.x / (bman.fieldsize.x+1);
@ -673,7 +674,6 @@ void gfx_load_tileset (char *tileset) {
/* create Table of points */
scale (gfx.postab, gfx.block.x, 256);
sfkt = ((float) gfx.block.x) / ((float) GFX_IMGSIZE);
/* calculating the best offset for the field on the screen */
@ -684,8 +684,20 @@ void gfx_load_tileset (char *tileset) {
sprintf (filename, "%s/tileset/%s/fire.bmp", bman.datapath,tileset);
tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) {
printf ("Can't load image: %s\n", SDL_GetError ());
exit (1);
/* file could not be load, so load teh default tileset */
printf ("Can't load tileset: %s\n", SDL_GetError ());
if (strcmp (tileset, "default") != 0) {
strcpy (tileset, "default");
sprintf (filename, "%s/tileset/%s/fire.bmp", bman.datapath,tileset);
tmpimage = SDL_LoadBMP (filename);
if (tmpimage == NULL) {
printf ("default tileset could not be loaded.\n");
exit (1);
}
else
printf ("switching to default tileset.\n");
}
else exit (1);
}
gfx.fire.frames = tmpimage->h / GFX_IMGSIZE;
tmpimage1 = scale_image (tmpimage, (tmpimage->w / GFX_IMGSIZE) * gfx.block.x, gfx.fire.frames * gfx.block.y);
@ -694,7 +706,6 @@ void gfx_load_tileset (char *tileset) {
gfx.fire.image = SDL_DisplayFormat (tmpimage1);
SDL_FreeSurface (tmpimage);
SDL_FreeSurface (tmpimage1);
/* load the bomb */
sprintf (filename, "%s/tileset/%s/bomb.bmp", bman.datapath, tileset);

@ -52,7 +52,8 @@ struct __gfx {
_gfxani menuselect; // The Menu Select GFX (the bomb ?)
char tileset[255]; // pathname to the tileset
int random_tileset; // random selecting of a tileset
char tileset[LEN_TILESETNAME]; // name of the tileset
SDL_Surface *logo;
} typedef _gfx;

@ -13,7 +13,9 @@ void
networkmenu_joingame ()
{
int i;
gamesrv_getserver ();
for (i = 0; bman.servername[i] != 0; i++)
if (bman.servername[i] == ' ')
bman.servername[i] = ':';

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.13 2003/05/06 12:25:30 stpohle Exp $ */
/* $Id: network.c,v 1.14 2003/05/06 17:47:13 stpohle Exp $ */
/*
network routines.
*/
@ -723,8 +723,8 @@ net_game_send_ill (int p_nr)
/*
this routine is only for the server.
after this the data should be transfered to the other clients.
this routine will set up some things for the network game
after this the data should be transfered to the other clients.
*/
void
net_new_game ()

@ -267,6 +267,7 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
bman.fieldsize.x = s_mod->fieldsize_x;
bman.fieldsize.y = s_mod->fieldsize_y;
}
strncpy (gfx.tileset, s_mod.tileset, LEN_TILESETNAME);
};
@ -288,6 +289,7 @@ send_servermode (_net_addr * addr, int 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);
send_pkg ((struct pkg *) &s_mod, addr);
};
@ -978,6 +980,10 @@ do_pkg (struct pkg *packet, _net_addr * addr)
return 0;
}
/* check if the incoming packet have the right size */
if (packet->h.tye == PKG_servermode && packet->h.len != sizeof (pkg_servermode))
send_error (addr, "pkg_servermode: packetsize incorrect.");
switch (packet->h.typ) {
case (PKG_error):
if (do_error ((struct pkg_error *) packet, addr) < 0)

@ -88,9 +88,11 @@ 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 */
};

Loading…
Cancel
Save