Handle players quitting from the menu gracefully. I'm not sure that this is right.

git-svn-id: https://svn.eduke32.com/eduke32@77 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-04-20 22:18:56 +00:00
parent 5d97323553
commit cf079dd918
4 changed files with 87 additions and 49 deletions

View file

@ -353,5 +353,6 @@ extern int issoundplaying(int num);
extern void stopspritesound(short num, short i);
extern void updatenames(void);
extern void sendboardname(void);
extern void sendquit(void);
#endif // __funct_h__

View file

@ -325,6 +325,47 @@ void getpackets(void)
{
switch(packbuf[0])
{
case 254:
//slaves in M/S mode only send to master
if (myconnectindex == connecthead)
{
//Master re-transmits message to all others
for(i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
if (i != other)
sendpacket(i,packbuf,packbufleng);
}
j = packbuf[1];
playerquitflag[j] = 0;
Bsprintf(buf,"%s is history!",ud.user_name[j]);
adduserquote(buf);
if(j == connecthead && networkmode == 0 )
gameexit( " \nThe 'MASTER/First player' just quit the game. All\nplayers are returned from the game.");
for(i=connecthead;i>=0;i=connectpoint2[i])
{
if (playerquitflag[i] != 0)
continue;
if (i == connecthead)
connecthead = connectpoint2[connecthead];
else
{
for(j=connecthead;j>=0;j=connectpoint2[j]) {
if(connectpoint2[j] == i)
connectpoint2[j] = connectpoint2[i];
}
}
}
numplayers--;
ud.multimode--;
if (numplayers < 2)
sound(GENERIC_AMBIENCE17);
break;
case 9:
//slaves in M/S mode only send to master
if (myconnectindex == connecthead)
@ -661,7 +702,7 @@ void getpackets(void)
playerreadyflag[other]++;
break;
case 255:
gameexit(" ");
sendquit();
break;
}
}
@ -2068,10 +2109,9 @@ void gameexit(char *t)
if(ud.recstat == 1) closedemowrite();
else if(ud.recstat == 2) { if (frecfilep) fclose(frecfilep); } // JBF: fixes crash on demo playback
if(qe || cp)
goto GOTOHERE;
if(playerswhenstarted > 1 && (gametype_flags[ud.coop] & GAMETYPE_FLAG_SCORESHEET) && *t == ' ')
if(!qe && !cp)
{
if(playerswhenstarted > 1 && ps[myconnectindex].gm&MODE_GAME && (gametype_flags[ud.coop] & GAMETYPE_FLAG_SCORESHEET) && *t == ' ')
{
dobonus(1);
setgamemode(ScreenMode,ScreenWidth,ScreenHeight,ScreenBPP);
@ -2079,8 +2119,7 @@ else if(ud.recstat == 2) { if (frecfilep) fclose(frecfilep); } // JBF: fixes cr
if( *t != 0 && *(t+1) != 'V' && *(t+1) != 'Y')
showtwoscreens();
GOTOHERE:
}
if (qsetmode == 200)
Shutdown();
@ -9657,7 +9696,7 @@ char domovethings(void)
adduserquote(buf);
if(j < 0 && networkmode == 0 )
gameexit( " \nThe 'MASTER/First player' just quit the game. All\nplayers are returned from the game. This only happens in 5-8\nplayer mode as a different network scheme is used.");
gameexit( " \nThe 'MASTER/First player' just quit the game. All\nplayers are returned from the game.");
}
if ((numplayers >= 2) && ((movefifoplc&7) == 7))

View file

@ -438,7 +438,7 @@ static void modval(int min, int max,int *p,short dainc,char damodify)
}
}
#define MENUHIGHLIGHT(x) probey==x?(sintable[(totalclock<<4)&2047]>>12):10
#define MENUHIGHLIGHT(x) probey==x?2-(sintable[(totalclock<<4)&2047]>>12):10
#define SHX(X) 0
// ((x==X)*(-sh))
#define PHX(X) 0
@ -512,6 +512,37 @@ void check_player_color(int *color,int prev_color)
}
}
void sendquit(void)
{
int i;
if( gamequit == 0 && ( numplayers > 1 ) )
{
if(ps[myconnectindex].gm&MODE_GAME)
{
gamequit = 1;
quittimer = totalclock+120;
}
else
{
tempbuf[0] = 254;
tempbuf[1] = myconnectindex;
for(i=connecthead;i >= 0;i=connectpoint2[i])
{
if (i != myconnectindex) sendpacket(i,tempbuf,2);
if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master
}
gameexit(" ");
}
}
else if( numplayers < 2 )
gameexit(" ");
if( ( totalclock > quittimer ) && ( gamequit == 1) )
gameexit("Timed out.");
}
void menus(void)
{
CACHE1D_FIND_REC *dir;
@ -3798,24 +3829,7 @@ VOLUME_ALL_40x:
{
KB_FlushKeyboardQueue();
if( gamequit == 0 && ( numplayers > 1 ) )
{
if(ps[myconnectindex].gm&MODE_GAME)
{
gamequit = 1;
quittimer = totalclock+120;
}
else
{
sendlogoff();
gameexit(" ");
}
}
else if( numplayers < 2 )
gameexit(" ");
if( ( totalclock > quittimer ) && ( gamequit == 1) )
gameexit("Timed out.");
sendquit();
}
x = probe(186,124,0,0);

View file

@ -30,23 +30,7 @@ struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat;
int osdcmd_quit(const osdfuncparm_t *parm)
{
extern long quittimer;
if( gamequit == 0 && ( numplayers > 1 ) )
{
if(ps[myconnectindex].gm&MODE_GAME)
{
gamequit = 1;
quittimer = totalclock+120;
}
else
{
sendlogoff();
gameexit(" ");
}
}
else if( numplayers < 2 )
gameexit(" ");
sendquit();
return OSDCMD_OK;
}