The bits2 member of the input struct has been renamed to extbits, and a proper fix for the strange OOS issues has been implemented.

git-svn-id: https://svn.eduke32.com/eduke32@275 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-08-22 05:38:59 +00:00
parent daa3b7b7a7
commit f369ba745c
8 changed files with 55 additions and 56 deletions

View file

@ -289,7 +289,7 @@ enum USRHOOKS_Errors {
typedef struct {
signed char avel, horz;
short fvel, svel;
unsigned long bits, bits2;
unsigned long bits, extbits;
} input;
#define sync dsync // JBF 20040604: sync is a function on some platforms
@ -483,7 +483,7 @@ extern struct weaponhit hittype[MAXSPRITES];
extern input loc;
extern input recsync[RECSYNCBUFSIZ];
extern long avgfvel, avgsvel, avgavel, avghorz, avgbits, avgbits2;
extern long avgfvel, avgsvel, avgavel, avghorz, avgbits, avgextbits;
extern long numplayers, myconnectindex;
extern long connecthead, connectpoint2[MAXPLAYERS]; //Player linked list variables (indeces, not connection numbers)

View file

@ -444,7 +444,6 @@ if( !(ps[myconnectindex].gm&MODE_GAME) ) { OSD_DispatchQueued(); }
}
if (numplayers < 2) return;
Bmemset(packbuf,0,sizeof(packbuf));
while ((packbufleng = getpacket(&other,packbuf)) > 0)
{
switch(packbuf[0])
@ -615,10 +614,10 @@ if( !(ps[myconnectindex].gm&MODE_GAME) ) { OSD_DispatchQueued(); }
if (l&32) nsyn[i].bits = ((nsyn[i].bits&0xff00ffff)|((long)packbuf[j++])<<16);
if (l&64) nsyn[i].bits = ((nsyn[i].bits&0x00ffffff)|((long)packbuf[j++])<<24);
if (l&128) nsyn[i].horz = (signed char)packbuf[j++];
if (l&256) nsyn[i].bits2 = ((nsyn[i].bits2&0xffffff00)|((long)packbuf[j++]));
if (l&512) nsyn[i].bits2 = ((nsyn[i].bits2&0xffff00ff)|((long)packbuf[j++])<<8);
if (l&1024) nsyn[i].bits2 = ((nsyn[i].bits2&0xff00ffff)|((long)packbuf[j++])<<16);
if (l&2048) nsyn[i].bits2 = ((nsyn[i].bits2&0x00ffffff)|((long)packbuf[j++])<<24);
if (l&256) nsyn[i].extbits = ((nsyn[i].extbits&0xffffff00)|((long)packbuf[j++]));
if (l&512) nsyn[i].extbits = ((nsyn[i].extbits&0xffff00ff)|((long)packbuf[j++])<<8);
if (l&1024) nsyn[i].extbits = ((nsyn[i].extbits&0xff00ffff)|((long)packbuf[j++])<<16);
if (l&2048) nsyn[i].extbits = ((nsyn[i].extbits&0x00ffffff)|((long)packbuf[j++])<<24);
if (nsyn[i].bits&(1<<26)) playerquitflag[i] = 0;
movefifoend[i]++;
@ -661,10 +660,10 @@ if( !(ps[myconnectindex].gm&MODE_GAME) ) { OSD_DispatchQueued(); }
if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((long)packbuf[j++])<<16);
if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((long)packbuf[j++])<<24);
if (k&128) nsyn[other].horz = (signed char)packbuf[j++];
if (k&256) nsyn[other].bits2 = ((nsyn[other].bits2&0xffffff00)|((long)packbuf[j++]));
if (k&512) nsyn[other].bits2 = ((nsyn[other].bits2&0xffff00ff)|((long)packbuf[j++])<<8);
if (k&1024) nsyn[other].bits2 = ((nsyn[other].bits2&0xff00ffff)|((long)packbuf[j++])<<16);
if (k&2048) nsyn[other].bits2 = ((nsyn[other].bits2&0x00ffffff)|((long)packbuf[j++])<<24);
if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((long)packbuf[j++]));
if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((long)packbuf[j++])<<8);
if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((long)packbuf[j++])<<16);
if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((long)packbuf[j++])<<24);
movefifoend[other]++;
while (j != packbufleng)
@ -841,10 +840,10 @@ if( !(ps[myconnectindex].gm&MODE_GAME) ) { OSD_DispatchQueued(); }
if (k&32) nsyn[other].bits = ((nsyn[other].bits&0xff00ffff)|((long)packbuf[j++])<<16);
if (k&64) nsyn[other].bits = ((nsyn[other].bits&0x00ffffff)|((long)packbuf[j++])<<24);
if (k&128) nsyn[other].horz = (signed char)packbuf[j++];
if (k&256) nsyn[other].bits2 = ((nsyn[other].bits2&0xffffff00)|((long)packbuf[j++]));
if (k&512) nsyn[other].bits2 = ((nsyn[other].bits2&0xffff00ff)|((long)packbuf[j++])<<8);
if (k&1024) nsyn[other].bits2 = ((nsyn[other].bits2&0xff00ffff)|((long)packbuf[j++])<<16);
if (k&2048) nsyn[other].bits2 = ((nsyn[other].bits2&0x00ffffff)|((long)packbuf[j++])<<24);
if (k&256) nsyn[other].extbits = ((nsyn[other].extbits&0xffffff00)|((long)packbuf[j++]));
if (k&512) nsyn[other].extbits = ((nsyn[other].extbits&0xffff00ff)|((long)packbuf[j++])<<8);
if (k&1024) nsyn[other].extbits = ((nsyn[other].extbits&0xff00ffff)|((long)packbuf[j++])<<16);
if (k&2048) nsyn[other].extbits = ((nsyn[other].extbits&0x00ffffff)|((long)packbuf[j++])<<24);
movefifoend[other]++;
for(i=1;i<movesperpacket;i++)
@ -854,7 +853,7 @@ if( !(ps[myconnectindex].gm&MODE_GAME) ) { OSD_DispatchQueued(); }
}
if (j > packbufleng)
initprintf("INVALID GAME PACKET!!! (%ld too many bytes)\n",j-packbufleng);
initprintf("INVALID GAME PACKET!!! (packet %d, %ld too many bytes)\n",packbuf[0],j-packbufleng);
while (j != packbufleng)
{
@ -908,7 +907,7 @@ void faketimerhandler()
avgavel += loc.avel;
avghorz += loc.horz;
avgbits |= loc.bits;
avgbits2 |= loc.bits2;
avgextbits |= loc.extbits;
if (movefifoend[myconnectindex]&(movesperpacket-1))
{
copybufbyte(&inputfifo[(movefifoend[myconnectindex]-1)&(MOVEFIFOSIZ-1)][myconnectindex],
@ -922,8 +921,8 @@ void faketimerhandler()
nsyn[0].avel = avgavel/movesperpacket;
nsyn[0].horz = avghorz/movesperpacket;
nsyn[0].bits = avgbits;
nsyn[0].bits2 = avgbits2;
avgfvel = avgsvel = avgavel = avghorz = avgbits = avgbits2 = 0;
nsyn[0].extbits = avgextbits;
avgfvel = avgsvel = avgavel = avghorz = avgbits = avgextbits = 0;
movefifoend[myconnectindex]++;
if (numplayers < 2)
@ -1019,10 +1018,10 @@ void faketimerhandler()
}
k++;
packbuf[k] = 0;
if ((nsyn[0].bits2^osyn[0].bits2)&0x000000ff) packbuf[j++] = (nsyn[0].bits2&255), packbuf[k] |= 1;
if ((nsyn[0].bits2^osyn[0].bits2)&0x0000ff00) packbuf[j++] = ((nsyn[0].bits2>>8)&255), packbuf[k] |= 2;
if ((nsyn[0].bits2^osyn[0].bits2)&0x00ff0000) packbuf[j++] = ((nsyn[0].bits2>>16)&255), packbuf[k] |= 4;
if ((nsyn[0].bits2^osyn[0].bits2)&0xff000000) packbuf[j++] = ((nsyn[0].bits2>>24)&255), packbuf[k] |= 8;
if ((nsyn[0].extbits^osyn[0].extbits)&0x000000ff) packbuf[j++] = (nsyn[0].extbits&255), packbuf[k] |= 1;
if ((nsyn[0].extbits^osyn[0].extbits)&0x0000ff00) packbuf[j++] = ((nsyn[0].extbits>>8)&255), packbuf[k] |= 2;
if ((nsyn[0].extbits^osyn[0].extbits)&0x00ff0000) packbuf[j++] = ((nsyn[0].extbits>>16)&255), packbuf[k] |= 4;
if ((nsyn[0].extbits^osyn[0].extbits)&0xff000000) packbuf[j++] = ((nsyn[0].extbits>>24)&255), packbuf[k] |= 8;
while (syncvalhead[myconnectindex] != syncvaltail)
{
@ -1085,10 +1084,10 @@ void faketimerhandler()
packbuf[1] |= 128;
}
packbuf[2] = 0;
if ((nsyn[0].bits2^osyn[0].bits2)&0x000000ff) packbuf[j++] = (nsyn[0].bits2&255), packbuf[2] |= 1;
if ((nsyn[0].bits2^osyn[0].bits2)&0x0000ff00) packbuf[j++] = ((nsyn[0].bits2>>8)&255), packbuf[2] |= 2;
if ((nsyn[0].bits2^osyn[0].bits2)&0x00ff0000) packbuf[j++] = ((nsyn[0].bits2>>16)&255), packbuf[2] |= 4;
if ((nsyn[0].bits2^osyn[0].bits2)&0xff000000) packbuf[j++] = ((nsyn[0].bits2>>24)&255), packbuf[2] |= 8;
if ((nsyn[0].extbits^osyn[0].extbits)&0x000000ff) packbuf[j++] = (nsyn[0].extbits&255), packbuf[2] |= 1;
if ((nsyn[0].extbits^osyn[0].extbits)&0x0000ff00) packbuf[j++] = ((nsyn[0].extbits>>8)&255), packbuf[2] |= 2;
if ((nsyn[0].extbits^osyn[0].extbits)&0x00ff0000) packbuf[j++] = ((nsyn[0].extbits>>16)&255), packbuf[2] |= 4;
if ((nsyn[0].extbits^osyn[0].extbits)&0xff000000) packbuf[j++] = ((nsyn[0].extbits>>24)&255), packbuf[2] |= 8;
while (syncvalhead[myconnectindex] != syncvaltail)
{
@ -1168,10 +1167,10 @@ void faketimerhandler()
}
k++;
packbuf[k] = 0;
if ((nsyn[i].bits2^osyn[i].bits2)&0x000000ff) packbuf[j++] = (nsyn[i].bits2&255), packbuf[k] |= 1;
if ((nsyn[i].bits2^osyn[i].bits2)&0x0000ff00) packbuf[j++] = ((nsyn[i].bits2>>8)&255), packbuf[k] |= 2;
if ((nsyn[i].bits2^osyn[i].bits2)&0x00ff0000) packbuf[j++] = ((nsyn[i].bits2>>16)&255), packbuf[k] |= 4;
if ((nsyn[i].bits2^osyn[i].bits2)&0xff000000) packbuf[j++] = ((nsyn[i].bits2>>24)&255), packbuf[k] |= 8;
if ((nsyn[i].extbits^osyn[i].extbits)&0x000000ff) packbuf[j++] = (nsyn[i].extbits&255), packbuf[k] |= 1;
if ((nsyn[i].extbits^osyn[i].extbits)&0x0000ff00) packbuf[j++] = ((nsyn[i].extbits>>8)&255), packbuf[k] |= 2;
if ((nsyn[i].extbits^osyn[i].extbits)&0x00ff0000) packbuf[j++] = ((nsyn[i].extbits>>16)&255), packbuf[k] |= 4;
if ((nsyn[i].extbits^osyn[i].extbits)&0xff000000) packbuf[j++] = ((nsyn[i].extbits>>24)&255), packbuf[k] |= 8;
k++;
}

View file

@ -822,7 +822,7 @@ LABELS inputlabels[]= {
{ "fvel", INPUT_FVEL, 0, 0 },
{ "svel", INPUT_SVEL, 0, 0 },
{ "bits", INPUT_BITS, 0, 0 },
{ "bits2", INPUT_BITS2, 0, 0 },
{ "extbits", INPUT_EXTBITS, 0, 0 },
{ "", -1, 0, 0 } // END OF LIST
};

View file

@ -396,7 +396,7 @@ enum inputlabels {
INPUT_FVEL,
INPUT_SVEL,
INPUT_BITS,
INPUT_BITS2
INPUT_EXTBITS
};
enum projectilelabels {

View file

@ -1964,11 +1964,11 @@ void DoInput(char bSet, long lVar1, long lLabelID, long lVar2, short sActor, sho
SetGameVarID((int)lVar2, sync[iPlayer].bits, sActor, sPlayer);
break;
case INPUT_BITS2:
case INPUT_EXTBITS:
if(bSet)
sync[iPlayer].bits2=lValue;
sync[iPlayer].extbits=lValue;
else
SetGameVarID((int)lVar2, sync[iPlayer].bits2, sActor, sPlayer);
SetGameVarID((int)lVar2, sync[iPlayer].extbits, sActor, sPlayer);
break;
default:
break;

View file

@ -93,7 +93,7 @@ long syncvalhead[MAXPLAYERS], syncvaltail, syncvaltottail;
input sync[MAXPLAYERS], loc;
input recsync[RECSYNCBUFSIZ];
long avgfvel, avgsvel, avgavel, avghorz, avgbits, avgbits2;
long avgfvel, avgsvel, avgavel, avghorz, avgbits, avgextbits;
input inputfifo[MOVEFIFOSIZ][MAXPLAYERS];

View file

@ -2945,12 +2945,12 @@ void getinput(short snum)
if(horiz < -MAXHORIZ) horiz = -MAXHORIZ;
if(horiz > MAXHORIZ) horiz = MAXHORIZ;
loc.bits2 = BUTTON(gamefunc_Move_Forward);
loc.bits2 |= BUTTON(gamefunc_Move_Backward)<<1;
loc.bits2 |= BUTTON(gamefunc_Strafe_Left)<<2;
loc.bits2 |= BUTTON(gamefunc_Strafe_Right)<<3;
loc.bits2 |= BUTTON(gamefunc_Turn_Left)<<4;
loc.bits2 |= BUTTON(gamefunc_Turn_Right)<<5;
loc.extbits = BUTTON(gamefunc_Move_Forward);
loc.extbits |= BUTTON(gamefunc_Move_Backward)<<1;
loc.extbits |= BUTTON(gamefunc_Strafe_Left)<<2;
loc.extbits |= BUTTON(gamefunc_Strafe_Right)<<3;
loc.extbits |= BUTTON(gamefunc_Turn_Left)<<4;
loc.extbits |= BUTTON(gamefunc_Turn_Right)<<5;
if(ud.scrollmode && ud.overhead_on)
{
@ -4254,29 +4254,29 @@ void processinput(short snum)
doubvel <<= 1;
/*
loc.bits2 = BUTTON(gamefunc_Move_Forward);
loc.bits2 |= BUTTON(gamefunc_Move_Backward)<<1;
loc.bits2 |= BUTTON(gamefunc_Strafe_Left)<<2;
loc.bits2 |= BUTTON(gamefunc_Strafe_Right)<<3;
loc.bits2 |= BUTTON(gamefunc_Turn_Left)<<4;
loc.bits2 |= BUTTON(gamefunc_Turn_Right)<<5;
loc.extbits = BUTTON(gamefunc_Move_Forward);
loc.extbits |= BUTTON(gamefunc_Move_Backward)<<1;
loc.extbits |= BUTTON(gamefunc_Strafe_Left)<<2;
loc.extbits |= BUTTON(gamefunc_Strafe_Right)<<3;
loc.extbits |= BUTTON(gamefunc_Turn_Left)<<4;
loc.extbits |= BUTTON(gamefunc_Turn_Right)<<5;
*/
if (sync[snum].bits2&(1))
if (sync[snum].extbits&(1))
OnEvent(EVENT_MOVEFORWARD,pi,snum, -1);
if (sync[snum].bits2&(1<<1))
if (sync[snum].extbits&(1<<1))
OnEvent(EVENT_MOVEBACKWARD,pi,snum, -1);
if (sync[snum].bits2&(1<<2))
if (sync[snum].extbits&(1<<2))
OnEvent(EVENT_STRAFELEFT,pi,snum, -1);
if (sync[snum].bits2&(1<<3))
if (sync[snum].extbits&(1<<3))
OnEvent(EVENT_STRAFERIGHT,pi,snum, -1);
if (sync[snum].bits2&(1<<4) || sync[snum].avel < 0)
if (sync[snum].extbits&(1<<4) || sync[snum].avel < 0)
OnEvent(EVENT_TURNLEFT,pi,snum, -1);
if (sync[snum].bits2&(1<<5) || sync[snum].avel > 0)
if (sync[snum].extbits&(1<<5) || sync[snum].avel > 0)
OnEvent(EVENT_TURNRIGHT,pi,snum, -1);
p->posxv += ((sync[snum].fvel*doubvel)<<6);

View file

@ -1454,7 +1454,7 @@ void clearfifo(void)
mymaxlag = otherminlag = 0;
movefifoplc = movefifosendplc = fakemovefifoplc = 0;
avgfvel = avgsvel = avgavel = avghorz = avgbits = 0;
avgfvel = avgsvel = avgavel = avghorz = avgbits = avgextbits = 0;
otherminlag = mymaxlag = 0;
clearbufbyte(myminlag,MAXPLAYERS<<2,0L);