Teammenus again changed, now all players will be in team 1. this will be changed again. So the new player will join the weakest team or the team with the less people

origin
stpohle 21 years ago
parent 5ef32ad040
commit 7b383ec1df

@ -1,154 +0,0 @@
This file will hold some Details about the Game.
A list of files and what every file is used for:
field.c:
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
- specials
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.
forwarding packets between the players who are behind
a firewall.
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
mapmenu.c:
map option menu
map initializing
- selects random maps
- loads random tilesets
keypinput.c:
loop for keyboard text fields
sysfunc.c:
s_delay
- waiting for some milliseconds
s_random
- returns a random number
s_gethomedir
- returns the name of the homedir used for the config file
s_getdir
- list of files and directorys
s_filterdir
- filters the list

@ -1,4 +1,4 @@
/* $Id: player.h,v 1.7 2004/10/03 20:22:45 stpohle Exp $ /* $Id: player.h,v 1.8 2004/10/04 21:36:47 stpohle Exp $
* playerinclude file * playerinclude file
*/ */
@ -114,6 +114,7 @@ struct {
struct __team { struct __team {
_player *players[MAX_PLAYERS]; _player *players[MAX_PLAYERS];
char name[LEN_PLAYERNAME]; char name[LEN_PLAYERNAME];
int col; // color of the Teamname
int wins; int wins;
int points; int points;
} typedef _team; } typedef _team;
@ -151,7 +152,7 @@ extern void player2_join ();
extern void player2_add (int pl_nr); extern void player2_add (int pl_nr);
extern void team_update (); extern void team_update ();
extern void team_choose (_player *pl);
// for the playerinput handling // for the playerinput handling
extern void playerinput_loop (int pl_nr); extern void playerinput_loop (int pl_nr);
@ -164,6 +165,7 @@ extern void playermenu ();
extern int playermenu_selgfx (int pl_nr); extern int playermenu_selgfx (int pl_nr);
extern void playermenu_getflags (char *text, _player *player); extern void playermenu_getflags (char *text, _player *player);
extern int teammenu_select (_player *pl);
extern void teammenu (); extern void teammenu ();
#endif #endif

@ -1,4 +1,4 @@
/* $Id: single.h,v 1.4 2004/09/23 13:21:44 stpohle Exp $ /* $Id: single.h,v 1.5 2004/10/04 21:36:47 stpohle Exp $
* single player */ * single player */
// single.c // single.c
@ -17,3 +17,4 @@ extern int ai_bombpoints (_point pos, int range);
extern _airunaway ai_runawayfrom (_point p, int nearbomb, int range, signed char norecursive); extern _airunaway ai_runawayfrom (_point p, int nearbomb, int range, signed char norecursive);
extern int ai_checkfield (int x, int y); extern int ai_checkfield (int x, int y);
extern int ai_easyrunaway (_point p, int range); extern int ai_easyrunaway (_point p, int range);
extern void ai_team_choosegfx ();

@ -157,6 +157,7 @@ void host_multiplayer_game () {
/* prepare the server */ /* prepare the server */
strncpy (players[0].name, bman.playername, LEN_PLAYERNAME); strncpy (players[0].name, bman.playername, LEN_PLAYERNAME);
bman.p_nr = bman.p_servnr = 0; bman.p_nr = bman.p_servnr = 0;
team_choose (&players[0]);
players[0].state = PSF_used; players[0].state = PSF_used;
if (bman.notifygamemaster) if (bman.notifygamemaster)
send_ogc_update (); /* send the information that we started an server */ send_ogc_update (); /* send the information that we started an server */

@ -146,6 +146,8 @@ do_joingame (struct pkg_joingame *p_jg, _net_addr * addr)
pl->points = 0; pl->points = 0;
pl->wins = 0; pl->wins = 0;
pl->team_nr = -1; pl->team_nr = -1;
team_choose (pl);
} }
strncpy (pl->name, p_jg->name, LEN_PLAYERNAME); strncpy (pl->name, p_jg->name, LEN_PLAYERNAME);
player_set_gfx (pl, -1); player_set_gfx (pl, -1);

@ -1,4 +1,4 @@
/* $Id: player.c,v 1.88 2004/09/26 22:06:58 stpohle Exp $ /* $Id: player.c,v 1.89 2004/10/04 21:36:47 stpohle Exp $
* player.c - everything what have to do with the player */ * player.c - everything what have to do with the player */
#include <SDL.h> #include <SDL.h>
@ -1071,13 +1071,16 @@ void player2_add (int pl_nr) {
/* /*
* set the teams[] witht he current player data * set the teams[] with the current player data
*/ */
void team_update () { void team_update () {
int cnt[MAX_TEAMS] = { 0,0,0,0 }; int cnt[MAX_TEAMS] = { 0,0,0,0 };
int pl; int pl;
for (pl = 0; pl < MAX_PLAYERS; pl++) { for (pl = 0; pl < MAX_PLAYERS; pl++) {
if (PS_IS_used (players[pl].state) && players[pl].team_nr < 0 && players[pl].team_nr >= MAX_TEAMS)
players[pl].team_nr = 0;
if (PS_IS_used (players[pl].state) && players[pl].team_nr >= 0) { if (PS_IS_used (players[pl].state) && players[pl].team_nr >= 0) {
teams[players[pl].team_nr].players[cnt[players[pl].team_nr]] = &players[pl]; teams[players[pl].team_nr].players[cnt[players[pl].team_nr]] = &players[pl];
cnt[players[pl].team_nr]++; cnt[players[pl].team_nr]++;
@ -1088,3 +1091,16 @@ void team_update () {
// d_teamdetail ("Teaminformation"); // d_teamdetail ("Teaminformation");
} }
/*
* if the team number is -1 then join this player into the losing team
*/
void team_choose (_player *pl) {
if (pl->team_nr >= 0 && pl->team_nr < MAX_TEAMS)
return;
printf ("team_choose need to fix\n");
pl->team_nr = 1;
};

@ -1,5 +1,4 @@
/* $Id: playermenu.c,v 1.9 2004/10/03 20:22:46 stpohle Exp $ /* $Id: playermenu.c,v 1.10 2004/10/04 21:36:47 stpohle Exp $
*
*/ */
#include "bomberclone.h" #include "bomberclone.h"
@ -17,28 +16,10 @@
*/ */
// static int playermenu_gfxaviable (int gfx); // static int playermenu_gfxaviable (int gfx);
static void playermenu_selgfx_drawplayer (int selgfx, _menu *menu); static void playermenu_selgfx_drawplayer (int selgfx, _menu *menu);
static void teammenu_ai_choosegfx ();
#define PLAYERMENU_GFXSEL_Y 130 #define PLAYERMENU_GFXSEL_Y 130
/*
* check if the gfx is still aviable
*
static int playermenu_gfxaviable (int gfx) {
int i;
for (i = 0; i < MAX_PLAYERS && gfx != players[i].gfx_nr; i++);
if (i == MAX_PLAYERS)
return 1;
return 0;
};
*
* **** DO WE NEED THIS?
*/
/* /*
* show the basis menu * show the basis menu
*/ */
@ -338,6 +319,13 @@ void playermenu () {
done = 0; done = 0;
} }
if (done == 1 && menu->focus->id == list_PlayerList->id) { /* team selection */
done = 0;
players[sel_pl_nr].team_nr = teammenu_select (&players[sel_pl_nr]);
bman.updatestatusbar = 1;
team_update ();
}
if (done == 1 && menu->focus->id == 4) { /* kick player */ if (done == 1 && menu->focus->id == 4) { /* kick player */
if (sel_pl_nr >= 0 && sel_pl_nr < MAX_PLAYERS && sel_pl_nr != bman.p_servnr) if (sel_pl_nr >= 0 && sel_pl_nr < MAX_PLAYERS && sel_pl_nr != bman.p_servnr)
player_delete (sel_pl_nr); player_delete (sel_pl_nr);
@ -371,293 +359,77 @@ void playermenu_getflags (char *text, _player *player) {
/* /*
* teammenu: Teamplay menuselection * teammenu: Returns a Teamnumber for this player.
* Show and edit all teams and the players.
*/ */
struct __teammenu { int teammenu_select (_player *pl) {
struct {
_charlist names[MAX_PLAYERS];
_charlist *select;
_menuitem *item;
_menuitem *label;
} teamp, freep;
_menuitem *teamlist;
_charlist teamnames[MAX_TEAMS];
_charlist *teamsel;
};
static void teammenu_update (_menu *menu, struct __teammenu *tm);
static int inline teammenu_get_selteam (_menu *menu, struct __teammenu *tm);
static void teammenu_set_selteam (_menu *menu, struct __teammenu *tm, int teamnr);
static void teammenu_player2team (_menu *menu, struct __teammenu *tm);
static void teammenu_team2player (_menu *menu, struct __teammenu *tm);
void teammenu () {
_menu *menu; _menu *menu;
struct __teammenu tm; int i;
_charlist teamlist[MAX_TEAMS];
int done, eventstate, menu_id = 0, last_id = 0, last_selteam = -1; _charlist *teamlistsel=NULL;
SDL_Event event;
menu = menu_new ("Team Details", 400, 350);
menu_create_text (menu, "help1", 10, 70, (250/font[0].size.x), 5, COLOR_gray, "Move the players from one team into the other by selecting them with ENTER.");
menu_create_button (menu, "Close", -1, 325, 150, 0);
/* reset all teamlist data and create element */
tm.teamsel = NULL;
tm.teamnames[0].text[0] = 0;
tm.teamnames[0].next = NULL;
tm.teamlist = menu_create_list (menu, "Teamlist", 250, 70, 150, 80, tm.teamnames, &tm.teamsel, ++menu_id);
/* reset all player data and create element*/ if (pl == NULL) return -1;
tm.teamp.names[0].text[0] = 0;
tm.teamp.names[0].next = NULL;
tm.teamp.select = &tm.teamp.names[0];;
tm.freep.names[0].text[0] = 0;
tm.freep.names[0].next = NULL;
tm.freep.select = &tm.freep.names[0];;
tm.freep.label = menu_create_label (menu, "Free Players", 40, 160, 0, COLOR_yellow); /* create the list of teams */
tm.freep.item = menu_create_list (menu, "freeplayer", 30, 180, 150, 120, tm.freep.names, &tm.freep.select, ++menu_id); for (i = 0; i < MAX_TEAMS; i++)
tm.teamp.label = menu_create_label (menu, teams[0].name, 250, 160, 0, COLOR_yellow); strncpy (teamlist[i].text, teams[i].name, LEN_PLAYERNAME);
tm.teamp.item = menu_create_list (menu, "teamplayer", 240, 180, 150, 120, tm.teamp.names, &tm.teamp.select, ++menu_id); charlist_fillarraypointer (teamlist, MAX_TEAMS);
teamlistsel = &teamlist[pl->team_nr];
/* prepare everything for the menu_loop */ menu = menu_new ("Teamselection", 250, 250);
menu_create_text (menu, "text", -1, 50, 200/font[0].size.x, 5, COLOR_yellow,
"Please select the team where you want to put in Player '%s'.", pl->name);
menu_create_list (menu, "teams", -1, 120, 200, 100, teamlist, &teamlistsel, 1);
menu_focus_id (menu, 1); menu_focus_id (menu, 1);
menu->looprunning = 1; menu_loop (menu);
menu_draw (menu);
teammenu_set_selteam (menu, &tm, 0);
teammenu_update (menu, &tm);
/* the menu loop */
do {
gfx_blitdraw ();
eventstate = SDL_PollEvent (&event);
if (bman.sock != -1)
network_loop ();
menu_draw (menu);
done = menu_event_loop (menu, &event, eventstate);
/*
* check if one of the buttons was pressed
*/
if (last_id != menu->focus->id || last_selteam != teammenu_get_selteam(menu, &tm)) {
teammenu_update (menu, &tm);
}
if (done == 1 && menu->focus->id == tm.freep.item->id) { // freeplayer selected
teammenu_player2team (menu, &tm);
teammenu_update (menu, &tm);
done = 0;
}
if (done == 1 && menu->focus->id == tm.teamp.item->id) { // teamplayer selected
teammenu_team2player (menu, &tm);
teammenu_update (menu, &tm);
done = 0;
}
if (done == 1 && menu->focus->id == tm.teamlist->id) {
menu_focus_id (menu, tm.freep.item->id);
teammenu_update (menu, &tm);
done = 0;
}
s_calctimesync ();
last_id = menu->focus->id;
} while ((done == 0 || menu->focus->id != 0) && done != -1);
menu_delete (menu); menu_delete (menu);
teammenu_ai_choosegfx (); i = (teamlistsel - teamlist);
}
d_printf ("teammenu_select: Player %s is in Team %s (%d)\n", pl->name, teams[i].name);
/* return i;
* add the current selected playxer to the free players
*/
static void teammenu_team2player (_menu *menu, struct __teammenu *tm) {
int sel_team = teammenu_get_selteam (menu,tm);
int sel_teampl = tm->teamp.select - tm->teamp.names;
if (sel_team < 0 || sel_team >= MAX_TEAMS || sel_teampl < 0 || sel_teampl >= MAX_PLAYERS)
return;
if (teams[sel_team].players[sel_teampl] == NULL)
return;
teams[sel_team].players[sel_teampl]->team_nr = -1;
team_update ();
}; };
/* /*
* add the current selected player to the current team * with the team menu you can select your own teamnames
*/ */
static void teammenu_player2team (_menu *menu, struct __teammenu *tm) { void teammenu () {
int sel_player = tm->freep.select - tm->freep.names; _menu *menu;
int sel_team = teammenu_get_selteam (menu,tm);
int pl;
// d_printf ("teammenu_player2team: sel_player=%d, sel_team=%d\n", sel_player, sel_team);
if (sel_team < 0 || sel_team >= MAX_TEAMS || sel_player < 0 || sel_player >= MAX_PLAYERS) int i, col, y;
return; struct _s_team {
_charlist collist[COLOR_max];
_charlist *collistsel;
} tdata[MAX_TEAMS];
/* get the player */ menu = menu_new ("Teamsettings", 360, 100 + (MAX_TEAMS * 30));
pl = 0;
while (pl < MAX_PLAYERS && (sel_player > 0 || players[pl].team_nr != -1)) {
if (players[pl].team_nr == -1) sel_player--;
pl++;
}
// d_printf ("teammenu_player2team: sel_player=%d, sel_team=%d, pl=\n", sel_player, sel_team, pl);
if (pl < MAX_PLAYERS && sel_player == 0 && players[pl].team_nr == -1) y = 60;
players[pl].team_nr = sel_team;
team_update (); for (i = 0; i < MAX_TEAMS; i++) {
} for (col = 0; col < COLOR_max; col++)
sprintf (tdata[i].collist[col].text, "%d", col);
charlist_fillarraypointer (tdata[i].collist, COLOR_max);
tdata[i].collistsel = tdata[i].collist + i;
menu_create_entry (menu, "Name :", 25, y, 200, teams[i].name, LEN_PLAYERNAME, MENU_entrytext, 2*i + 1);
menu_create_label (menu, "Color:", 250, y, 0, COLOR_yellow);
menu_create_list (menu, "Liste", 320, y, 30, 20, tdata[i].collist, &tdata[i].collistsel, 2*i + 2);
/* y += 30;
* update all elements on the screen
* clean the player lists for the team and free players
*/
static void teammenu_update (_menu *menu, struct __teammenu *tm) {
int pl, cnt_team, cnt_free;
// d_printf ("teammenu_update\n");
/*
* teamnames
*/
tm->teamnames[0].text[0] = 0;
tm->teamnames[0].next = NULL;
for (pl = 0; pl < MAX_TEAMS; pl++) {
if (pl > 0)
tm->teamnames[pl-1].next = &tm->teamnames[pl];
tm->teamnames[pl].next = NULL;
strncpy (tm->teamnames[pl].text, teams[pl].name, LEN_CHARENTRY);
} }
strncpy (tm->teamp.label->label, tm->teamsel->text, MENU_TITLELEN); menu_create_button (menu, "Close", -1, y + 10, 150, 2*i+1);
/* menu_loop (menu);
* playernames menu_delete (menu);
*/
tm->freep.names[0].next = NULL;
tm->freep.names[0].text[0] = 0;
tm->teamp.names[0].next = NULL;
tm->teamp.names[0].text[0] = 0;
for (pl = 0, cnt_team = 0, cnt_free = 0; pl < MAX_PLAYERS; pl++) {
if (PS_IS_used (players[pl].state) && (players[pl].team_nr == -1 || players[pl].team_nr == teammenu_get_selteam (menu, tm))) {
_charlist *cl;
int *cnt;
/* select the right list with the right counter */
if (players[pl].team_nr == -1) {
cl = tm->freep.names;
cnt = &cnt_free;
}
else {
cl = tm->teamp.names;
cnt = &cnt_team;
}
/* set the data */
if (*cnt > 0)
cl[(*cnt)-1].next = &cl[*cnt];
strncpy (cl[*cnt].text, players[pl].name, LEN_CHARENTRY);
cl[*cnt].next = NULL;
(*cnt)++;
}
}
/* send update */ return;
tm->freep.item->changed = 1;
tm->freep.label->changed = 1;
menu_draw_menuitem (tm->freep.item);
menu_draw_menuitem (tm->freep.label);
tm->teamp.item->changed = 1;
tm->teamp.label->changed = 1;
menu_draw_menuitem (tm->teamp.item);
menu_draw_menuitem (tm->teamp.label);
tm->teamlist->changed = 1;
menu_draw_menuitem (tm->teamlist);
} }
/*
* get the current teamnumber
*/
static inline int teammenu_get_selteam (_menu *menu, struct __teammenu *tm) {
return (tm->teamsel - tm->teamnames);
};
/*
* set the current teamnumber
*/
static void teammenu_set_selteam (_menu *menu, struct __teammenu *tm, int teamnr) {
if (teamnr < 0 ) teamnr = 0;
else if (teamnr >= MAX_TEAMS) teamnr = MAX_TEAMS-1;
tm->teamsel = &tm->teamnames[teamnr];
tm->teamlist->changed = 1;
menu_draw_menuitem (tm->teamlist);
};
/*
* the ai player will choose diffrent gfx for every
* team another gfx, but not one which is selected by
* human player.
*/
static void teammenu_ai_choosegfx () {
struct _team_tmpdata_ {
// int ai_player;
// int hu_player;
int ai_gfx;
} teamdat[MAX_TEAMS];
int tm_nr;
int pl_nr;
int i, used;
_player *pl;
/* find a ai player gfx for every team */
for (i = 0, tm_nr = 0; (i < gfx.player_gfx_count && tm_nr < MAX_TEAMS); i++) {
used = 0;
for (pl_nr = 0; pl_nr < MAX_PLAYERS; pl_nr++) {
if ((!PS_IS_aiplayer(players[pl_nr].state))
&& (PS_IS_used (players[pl_nr].state))
&& i == players[pl_nr].gfx_nr)
used = 1;
}
if (!used && tm_nr < MAX_TEAMS) {
teamdat[tm_nr].ai_gfx = i;
tm_nr++;
}
}
/*
* give all ai players in the teams the right gfx
*/
for (tm_nr = 0; tm_nr < MAX_TEAMS; tm_nr++) for (pl_nr = 0; pl_nr < MAX_PLAYERS; pl_nr++) {
pl = teams[tm_nr].players[pl_nr];
if (pl) {
if (PS_IS_used(pl->state) && PS_IS_aiplayer(pl->state))
player_set_gfx (pl, teamdat[tm_nr].ai_gfx);
}
}
};
/* /*
* create a menu where we can change the playernames * create a menu where we can change the playernames
*/ */

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.75 2004/10/03 20:22:46 stpohle Exp $ */ /* $Id: single.c,v 1.76 2004/10/04 21:36:47 stpohle Exp $ */
/* single player */ /* single player */
#include "basic.h" #include "basic.h"
@ -37,6 +37,51 @@ single_game_new ()
}; };
/*
* the ai player will choose diffrent gfx for every
* team another gfx, but not one which is selected by
* human player.
*/
void ai_team_choosegfx () {
struct _team_tmpdata_ {
int ai_gfx;
} teamdat[MAX_TEAMS];
int tm_nr;
int pl_nr;
int i, used;
_player *pl;
/* find a ai player gfx for every team */
for (i = 0, tm_nr = 0; (i < gfx.player_gfx_count && tm_nr < MAX_TEAMS); i++) {
used = 0;
for (pl_nr = 0; pl_nr < MAX_PLAYERS; pl_nr++) {
if ((!PS_IS_aiplayer(players[pl_nr].state))
&& (PS_IS_used (players[pl_nr].state))
&& i == players[pl_nr].gfx_nr)
used = 1;
}
if (!used && tm_nr < MAX_TEAMS) {
teamdat[tm_nr].ai_gfx = i;
tm_nr++;
}
}
/*
* give all ai players in the teams the right gfx
*/
for (tm_nr = 0; tm_nr < MAX_TEAMS; tm_nr++) for (pl_nr = 0; pl_nr < MAX_PLAYERS; pl_nr++) {
pl = teams[tm_nr].players[pl_nr];
if (pl) {
if (PS_IS_used(pl->state) && PS_IS_aiplayer(pl->state))
player_set_gfx (pl, teamdat[tm_nr].ai_gfx);
}
}
};
inline int inline int
ai_checkfield (int x, int y) ai_checkfield (int x, int y)
{ {
@ -584,6 +629,8 @@ single_create_ai (int num_players)
pl->wins = 0; pl->wins = 0;
pl->points = 0; pl->points = 0;
pl->team_nr = -1; pl->team_nr = -1;
team_choose (pl);
} }
if (pl == NULL) if (pl == NULL)
@ -656,7 +703,7 @@ single_playergame (int second_player, int ai_players)
single_create_ai (ai_players); single_create_ai (ai_players);
if (bman.gametype == GT_team) if (bman.gametype == GT_team)
teammenu (); playermenu ();
bman.state = GS_ready; bman.state = GS_ready;

Loading…
Cancel
Save