Fixed problem with the second local player

origin
stpohle 19 years ago
parent cd3c8b8d72
commit 55ad817ba9

@ -1,6 +1,10 @@
$Id: ChangeLog,v 1.112 2006/08/19 23:07:12 stpohle Exp $
$Id: ChangeLog,v 1.113 2006/08/19 23:41:47 stpohle Exp $
Work on: Second Player Problem
- Fixed: Second Player Problem
this fix includes that if a second player was used the game got somehow
very instable, because there have been no reset of all the game data.
playerselection works now much better. There have been problems with
some keys for the second player.
- Fixed: problem on slow networks with the loop that the selected player
gfx gots selected and deselected. (infinite loop on the network)

@ -1,7 +1,4 @@
$Id: TODO,v 1.44 2006/08/19 23:07:12 stpohle Exp $
- addr from server will be overwritten if the address is a different then the known one..
do_playerid (never overwrite servers addr)
$Id: TODO,v 1.45 2006/08/19 23:41:47 stpohle Exp $
- kicking bombs.. maybe bombs will have to get floated points.. to make this better.

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.34 2005/07/06 13:11:55 stpohle Exp $ */
/* $Id: bomberclone.h,v 1.35 2006/08/19 23:41:47 stpohle Exp $ */
/* bomberclone.h */
#ifndef _BOMBERCLONE_H_
@ -127,7 +127,7 @@ extern void game_showresultnormal ();
extern void game_showresultteam ();
extern void game_menu_create ();
extern void game_menu_loop (SDL_Event *event, int eventstate);
extern void game_resetdata ();
// everything is declared in field.c
extern void draw_field ();

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.115 2006/08/15 02:15:39 stpohle Exp $
/* $Id: game.c,v 1.116 2006/08/19 23:41:47 stpohle Exp $
game.c - procedures for the game. */
#include <string.h>
@ -993,3 +993,14 @@ game_menu_loop (SDL_Event * event, int eventstate)
}
}
};
/* reset all old gamedata, this is only needed on join, host or
* new singleplayer games. */
void game_resetdata () {
int i;
for (i = 0; i < MAX_PLAYERS; i++)
memset (&players[i], 0, sizeof (_player));
bman.p2_nr = bman.p_nr = -1;
};

@ -1,4 +1,4 @@
/* $Id: multiwait.c,v 1.58 2006/08/08 20:04:19 stpohle Exp $
/* $Id: multiwait.c,v 1.59 2006/08/19 23:41:47 stpohle Exp $
multiwait.c - this manages only the network screen where
everyone have to select it's players and where even the basic chat is inside
*/
@ -99,15 +99,15 @@ static void mw_keys_loop () {
bman.state = GS_startup;
}
if ((keyb_gamekeys.state[BCPK_drop] && !keyb_gamekeys.old[BCPK_drop])
|| ((!IS_LPLAYER2) && keyb_gamekeys.state[BCPK_max + BCPK_drop] && !keyb_gamekeys.old[BCPK_max + BCPK_drop])) {
if (((IS_LPLAYER2) && keyb_gamekeys.state[BCPK_max + BCPK_drop] && !keyb_gamekeys.old[BCPK_max + BCPK_drop])
|| ((!IS_LPLAYER2) && keyb_gamekeys.state[BCPK_drop] && !keyb_gamekeys.old[BCPK_drop])) {
/* player 1 want to select a new gfx */
playermenu_selgfx (bman.p_nr);
bman.updatestatusbar = 1;
keyb_loop (NULL); // to reload the current keys
}
if (IS_LPLAYER2 && keyb_gamekeys.state[BCPK_max + BCPK_drop] && !keyb_gamekeys.old[BCPK_max + BCPK_drop]) {
if (IS_LPLAYER2 && keyb_gamekeys.state[BCPK_max + BCPK_max + BCPK_drop] && !keyb_gamekeys.old[BCPK_max + BCPK_max + BCPK_drop]) {
/* player 2 want to select a new gfx */
playermenu_selgfx (bman.p2_nr);
bman.updatestatusbar = 1;

@ -26,6 +26,8 @@ netmenu ()
menuselect = menu_loop (menu);
menu_delete (menu);
game_resetdata ();
switch (menuselect) {
case (0): // Create a Game
bman.sock = -1;

@ -557,8 +557,8 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
/* if we just have connected the bman.p_nr is still -1, so we handle the
servermode packet still alittle diffrent */
if ((!s_mod->lplayer2 && bman.p_nr == -1) || (s_mod->lplayer2 && bman.p2_nr == -1)) {
d_printf (" Server gave us: p_nr: %d(old:%d), p_servnr: %d(old:%d)\n", s_mod->p_nr,
bman.p_nr, s_mod->p_servnr, bman.p_servnr);
d_printf (" Server gave us: p_nr/p2_nr: %d(old:%d), p_servnr: %d(old:%d), lplayer2:%d\n", s_mod->p_nr,
bman.p_nr, s_mod->p_servnr, bman.p_servnr, s_mod->lplayer2);
/* set the p_servnr to the playerslot which is the server */
if (bman.p_servnr != s_mod->p_servnr) {
@ -588,6 +588,8 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
players[bman.p2_nr].net.flags = NETF_firewall + NETF_local2;
players[bman.p2_nr].state &= (0xFF - PSF_net);
strncpy (players[s_mod->p_nr].name, bman.player2name, LEN_PLAYERNAME);
send_playerid (addr, NULL, NULL, NULL, -1, -1, -1, 0);
send_teamdata (addr, -1);
}
}

@ -1,4 +1,4 @@
/* $Id: pkgcache.c,v 1.12 2006/08/15 15:00:32 stpohle Exp $
/* $Id: pkgcache.c,v 1.13 2006/08/19 23:41:47 stpohle Exp $
* Resendcache work, We need this to resend lost packets over the network.
* we will keep every packet with the PKGF_ackreq flag as long as we haven't
* got any answer from the destination host. And resend the packet after a givin
@ -21,7 +21,7 @@ void rscache_init () {
void rscache_add (_net_addr *addr, struct pkg *packet) {
int len;
d_printf ("rscache_add: addr %p, pkg %p\n", addr, packet);
// d_printf ("rscache_add: addr %p, pkg %p\n", addr, packet);
/* check if there is still some free space left. */
if (rscache.count >= PKG_RESENDCACHE_SIZE) {
d_printf ("rscache_add no free rscache entry left.\n");
@ -46,7 +46,7 @@ void rscache_delnr (int nr) {
for (a = nr; a < rscache.count - 1; a++)
rscache.entry[nr] = rscache.entry[nr+1];
rscache.count--;
d_printf ("rscache_delnr: element %d deleted.\n", nr);
// d_printf ("rscache_delnr: element %d deleted.\n", nr);
}
else
d_printf ("rscache_delnr: number is out of range (%d)\n", nr);
@ -58,14 +58,13 @@ void rscache_delnr (int nr) {
int rscache_del (_net_addr *addr, unsigned char typ, short unsigned int id) {
int i;
d_printf ("rscache_del: addr %p (pl_nr:%d, typ:%d, id:%d\n", addr, addr->pl_nr, typ, id);
// d_printf ("rscache_del: addr %p (pl_nr:%d, typ:%d, id:%d\n", addr, addr->pl_nr, typ, id);
for (i = 0; (i < rscache.count) && (i < PKG_RESENDCACHE_SIZE); i++) {
if (rscache.entry[i].addr.pl_nr == addr->pl_nr &&
NTOH16(rscache.entry[i].packet.h.id) == id &&
rscache.entry[i].packet.h.typ == typ) { // found element
rscache_delnr (i);
d_printf ("rscache_del: element %d deleted.\n", i);
return 1;
}
}

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.85 2005/08/07 17:46:21 stpohle Exp $ */
/* $Id: single.c,v 1.86 2006/08/19 23:41:47 stpohle Exp $ */
/* single player */
#include "basic.h"
@ -724,6 +724,8 @@ single_menu ()
p++;
}
game_resetdata ();
menu = menu_new ("Single Game", 380,240);
menu_create_text (menu, "numpl", 20, 50, 12, 2, COLOR_yellow, "Number of\nAI Players");

Loading…
Cancel
Save