Rename some functions and separate the player's weapon choice back out into its own packet, because we don't need to send it with player updates from the menu.

git-svn-id: https://svn.eduke32.com/eduke32@371 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-11-30 23:37:47 +00:00
parent da317ac063
commit 5dda5b1660
6 changed files with 53 additions and 25 deletions

View file

@ -351,7 +351,7 @@ extern void OnEvent(int iEventID, short sActor,short sPlayer,long lDist);
extern int isspritemakingsound(short i, int num);
extern int issoundplaying(short i, int num);
extern void stopspritesound(short num, short i);
extern void updatenames(void);
extern void updateplayer(void);
extern void sendboardname(void);
extern void sendquit(void);

View file

@ -810,9 +810,6 @@ void getpackets(void)
ud.user_name[other][i-3] = 0;
i++;
j = i; //This used to be Duke packet #9... now concatenated with Duke packet #6
for (;i-j<10;i++) ud.wchoice[other][i-j] = packbuf[i];
ps[other].aim_mode = packbuf[i++];
ps[other].auto_aim = packbuf[i++];
ps[other].weaponswitch = packbuf[i++];
@ -825,6 +822,21 @@ void getpackets(void)
hittype[ps[other].i].picnum = APLAYERTOP;
} */
break;
case 10:
//slaves in M/S mode only send to master
//Master re-transmits message to all others
if ((!networkmode) && (myconnectindex == connecthead))
for (i=connectpoint2[connecthead];i>=0;i=connectpoint2[i])
if (i != other) sendpacket(i,packbuf,packbufleng);
other = packbuf[1];
i = 2;
j = i; //This used to be Duke packet #9... now concatenated with Duke packet #6
for (;i-j<10;i++) ud.wchoice[other][i-j] = packbuf[i];
break;
case 7:
//slaves in M/S mode only send to master
@ -9355,7 +9367,28 @@ void sendscore(char *s)
genericmultifunction(-1,s,strlen(s)+1,5);
}
void syncnames(void)
void sendwchoice(void)
{
int i,l;
buf[0] = 10;
buf[1] = myconnectindex;
l = 2;
for (i=0;i<10;i++)
{
ud.wchoice[myconnectindex][i] = ud.wchoice[0][i];
buf[l++] = (char)ud.wchoice[0][i];
}
for (i=connecthead;i>=0;i=connectpoint2[i])
{
if (i != myconnectindex) sendpacket(i,&buf[0],l);
if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master
}
}
void sendplayerupdate(void)
{
int i,l;
@ -9368,12 +9401,6 @@ void syncnames(void)
for (i=0;myname[i];i++) buf[l++] = Btoupper(myname[i]);
buf[l++] = 0;
for (i=0;i<10;i++)
{
ud.wchoice[myconnectindex][i] = ud.wchoice[0][i];
buf[l++] = (char)ud.wchoice[0][i];
}
buf[l++] = ps[myconnectindex].aim_mode = ud.mouseaiming;
buf[l++] = ps[myconnectindex].auto_aim = AutoAim;
buf[l++] = ps[myconnectindex].weaponswitch = ud.weaponswitch;
@ -9419,7 +9446,8 @@ void getnames(void)
if (numplayers > 1)
{
syncnames();
sendplayerupdate();
sendwchoice();
sendboardname();
getpackets();
waitforeverybody();
@ -9429,7 +9457,7 @@ void getnames(void)
gameexit("Please put the Duke Nukem 3D Atomic Edition CD in the CD-ROM drive.");
}
void updatenames(void)
void updateplayer(void)
{
int l;
@ -9441,7 +9469,7 @@ void updatenames(void)
if (ud.multimode > 1)
{
syncnames();
sendplayerupdate();
if (sprite[ps[myconnectindex].i].picnum == APLAYER && sprite[ps[myconnectindex].i].pal != 1)
sprite[ps[myconnectindex].i].pal = ud.pcolor[myconnectindex];
}

View file

@ -725,26 +725,26 @@ void menus(void)
if (ud.color > 23)
ud.color = 0;
check_player_color((int *)&ud.color,-1);
updatenames();
updateplayer();
break;
case 2:
ud.team = 1-ud.team;
updatenames();
updateplayer();
break;
case 3:
AutoAim = (AutoAim == 2) ? 0 : AutoAim+1;
updatenames();
updateplayer();
break;
case 4:
ud.weaponswitch = (ud.weaponswitch == 3) ? 0 : ud.weaponswitch+1;
updatenames();
updateplayer();
break;
case 5:
ud.mouseaiming = !ud.mouseaiming;
updatenames();
updateplayer();
break;
case 6:
cmenu(20004);
@ -776,7 +776,7 @@ void menus(void)
KB_FlushKeyboardQueue();
current_menu = 20002;
updatenames();
updateplayer();
}
}
@ -798,7 +798,7 @@ void menus(void)
modval(0,1,(int *)&ud.mouseaiming,1,probey==5);
check_player_color((int *)&ud.color,ud_color);
if (ud_color != ud.color || aaim != AutoAim || ud_weaponswitch != ud.weaponswitch || ud_maim != ud.mouseaiming || ud_team != ud.team)
updatenames();
updateplayer();
}
menutext(40,50+16+16,MENUHIGHLIGHT(2),0,"TEAM");
menutext(40,50+16+16+16,MENUHIGHLIGHT(3),0,"AUTO AIM");

View file

@ -594,7 +594,7 @@ int osdcmd_cvar_set(const osdfuncparm_t *parm)
break;
}
if (cvar[i].type&256)
updatenames();
updateplayer();
}
}
OSD_Printf("\n");
@ -784,7 +784,7 @@ int osdcmd_name(const osdfuncparm_t *parm)
OSD_Printf("name %s\n",myname);
updatenames();
updateplayer();
return OSDCMD_OK;
}

View file

@ -2752,7 +2752,7 @@ void getinput(short snum)
momx = momy = 0;
p = &ps[snum];
if ((p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) || p->player_par < 10)
if ((p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause)) || (numplayers > 1 && totalclock < 10)) // HACK: kill getinput() for the first 10 tics of a new map in multi
{
CONTROL_GetInput(&info);
memset(&lastinfo, 0, sizeof(lastinfo));

View file

@ -1584,7 +1584,7 @@ int enterlevel(char g)
long l;
char levname[BMAX_PATH];
ready2send = 1; // HACK
ready2send = 1; // HACK: fetch any leftover p2p sync packets
KB_ClearKeysDown();
handleevents();
getpackets();