more semi-tested multiplayer changes and sound callback fix

git-svn-id: https://svn.eduke32.com/eduke32@1582 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2010-01-05 21:53:14 +00:00
parent f543a69ab8
commit 4917be2439
5 changed files with 473 additions and 465 deletions

View file

@ -25,8 +25,8 @@
// 1.5.0 BETA 2
#ifndef QLZ_COMPRESSION_LEVEL
#define QLZ_COMPRESSION_LEVEL 1
//#define QLZ_COMPRESSION_LEVEL 2
//#define QLZ_COMPRESSION_LEVEL 1
#define QLZ_COMPRESSION_LEVEL 2
//#define QLZ_COMPRESSION_LEVEL 3
#define QLZ_STREAMING_BUFFER 0

View file

@ -280,12 +280,12 @@ typedef struct {
int16_t i;
} SOUNDOWNER;
#define SOUNDMAX 8
#define MAXSOUNDINSTANCES 8
typedef struct {
int32_t length, num, soundsiz; // 12b
char *filename, *ptr, *filename1; // 12b/24b
SOUNDOWNER SoundOwner[SOUNDMAX]; // 32b
SOUNDOWNER SoundOwner[MAXSOUNDINSTANCES]; // 32b
int16_t ps,pe,vo; // 6b
char pr,m; // 2b
} sound_t;
@ -535,17 +535,6 @@ typedef struct {
int8_t velmult, filler; // 2b
} projectile_t;
// extern char gotz;
typedef struct {
/* int32_t x;
int32_t y;
int32_t z; */
int16_t ang, oldang, angdir, angdif;
} spriteinterpolate;
// spriteinterpolate sprpos[MAXSPRITES];
typedef struct {
intptr_t temp_data[10]; // 40b/80b sometimes used to hold pointers to con code

View file

@ -968,8 +968,8 @@ void Net_ParseServerPacket(ENetEvent * event)
packbuf = Bcalloc(1, packbufleng+1);
packbufleng = qlz_decompress((char *)&event->packet->data[1], (char *)(packbuf), state_decompress);
Bmemcpy(&ticrandomseed, &packbuf[j], sizeof(ticrandomseed));
j += sizeof(ticrandomseed);
ticrandomseed = *(int32_t *)&packbuf[j];
j += sizeof(int32_t);
ud.pause_on = packbuf[j++];
TRAVERSE_CONNECT(i)
@ -982,7 +982,7 @@ void Net_ParseServerPacket(ENetEvent * event)
if (i == myconnectindex && !g_player[i].ps->dead_flag)
{
j += (sizeof(input_t) - sizeof(loc.filler)) +
(sizeof(vec3_t) * 2) + // position and velocity
(sizeof(vec3_t) * 3) + // position and velocity
(sizeof(int16_t) * 3); // ang and horiz
goto process;
}
@ -996,23 +996,22 @@ void Net_ParseServerPacket(ENetEvent * event)
if (TEST_SYNC_KEY(nsyn[i].bits,SK_GAMEQUIT)) g_player[i].playerquitflag = 0;
g_player[i].movefifoend++;
Bmemcpy(&g_player[i].ps->oposx, &g_player[i].ps->posx, sizeof(vec3_t));
// Bmemcpy(&g_player[i].ps->oposx, &g_player[i].ps->posx, sizeof(vec3_t));
Bmemcpy(&g_player[i].ps->posx, &packbuf[j], sizeof(vec3_t));
Bmemcpy(&g_player[i].ps->posx, &packbuf[j], sizeof(vec3_t) * 2);
updatesectorz(g_player[i].ps->posx, g_player[i].ps->posy, g_player[i].ps->posz,
&g_player[i].ps->cursectnum);
changespritesect(g_player[i].ps->i, g_player[i].ps->cursectnum);
Bmemcpy(&sprite[g_player[i].ps->i], &packbuf[j], sizeof(vec3_t));
sprite[g_player[i].ps->i].z += PHEIGHT;
j += sizeof(vec3_t);
j += sizeof(vec3_t) * 2;
Bmemcpy(&g_player[i].ps->posxv, &packbuf[j], sizeof(vec3_t));
j += sizeof(vec3_t);
Bmemcpy(&g_player[i].ps->oang, &g_player[i].ps->ang, sizeof(int16_t));
Bmemcpy(&g_player[i].ps->ang, &packbuf[j], sizeof(int16_t));
sprite[g_player[i].ps->i].ang = *(int16_t *)&packbuf[j];
g_player[i].ps->oang = g_player[i].ps->ang;
g_player[i].ps->ang = sprite[g_player[i].ps->i].ang = *(int16_t *)&packbuf[j];
j += sizeof(int16_t);
Bmemcpy(&g_player[i].ps->ohoriz, &g_player[i].ps->horiz, sizeof(int16_t) * 2);
@ -1505,14 +1504,14 @@ void Net_ParseClientPacket(ENetEvent * event)
break;
}
Bmemcpy(&g_player[other].ps->oposx, &g_player[other].ps->posx, sizeof(vec3_t));
Bmemcpy(&g_player[other].ps->posx, &packbuf[j], sizeof(vec3_t));
// Bmemcpy(&g_player[other].ps->oposx, &g_player[other].ps->posx, sizeof(vec3_t));
Bmemcpy(&g_player[other].ps->posx, &packbuf[j], sizeof(vec3_t) * 2);
updatesectorz(g_player[other].ps->posx, g_player[other].ps->posy, g_player[other].ps->posz,
&g_player[other].ps->cursectnum);
Bmemcpy(&sprite[g_player[other].ps->i], &packbuf[j], sizeof(vec3_t));
sprite[g_player[other].ps->i].z += PHEIGHT;
changespritesect(g_player[other].ps->i, g_player[other].ps->cursectnum);
j += sizeof(vec3_t);
j += sizeof(vec3_t) * 2;
Bmemcpy(&g_player[other].ps->posxv, &packbuf[j], sizeof(vec3_t));
j += sizeof(vec3_t);
@ -1839,12 +1838,12 @@ void Net_GetPackets(void)
switch (event.type)
{
case ENET_EVENT_TYPE_RECEIVE:
/*
initprintf ("A packet of length %u was received from player %d on channel %u.\n",
event.packet -> dataLength,
event.peer -> data,
event.channelID);
*/
// channelID 1 is the map state transfer from the server
if (event.channelID == 1)
{
@ -1899,6 +1898,9 @@ void Net_GetPackets(void)
break;
case ENET_EVENT_TYPE_DISCONNECT:
g_netDisconnect = 1;
numplayers = playerswhenstarted = ud.multimode = 1;
myconnectindex = screenpeek = 0;
G_BackToMenu();
switch (event.data)
{
case DISC_BAD_PASSWORD:
@ -1921,10 +1923,321 @@ void Net_GetPackets(void)
}
}
void Net_UpdateClients(void)
{
input_t * osyn = (input_t *)&inputfifo[1][0];
input_t * nsyn = (input_t *)&inputfifo[0][0];
int16_t i, nexti, k = 0, l;
int32_t j;
if (!net_server || numplayers < 2)
{
if (net_server)
Bmemcpy(&osyn[0], &nsyn[0], sizeof(input_t));
return;
}
packbuf[0] = PACKET_MASTER_TO_SLAVE;
j = 1;
ticrandomseed = randomseed;
*(int32_t *)&packbuf[j] = ticrandomseed;
j += sizeof(int32_t);
packbuf[j++] = ud.pause_on;
TRAVERSE_CONNECT(i)
{
if (g_player[i].playerquitflag == 0) continue;
Bmemcpy(&osyn[i], &nsyn[i], sizeof(input_t));
*(int16_t *)&packbuf[j] = g_player[i].ps->dead_flag;
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &nsyn[i], sizeof(input_t)-sizeof(loc.filler));
j += sizeof(input_t)-sizeof(loc.filler);
Bmemcpy(&packbuf[j], &g_player[i].ps->posx, sizeof(vec3_t) * 2);
j += sizeof(vec3_t) * 2;
Bmemcpy(&packbuf[j], &g_player[i].ps->posxv, sizeof(vec3_t));
j += sizeof(vec3_t);
*(int16_t *)&packbuf[j] = g_player[i].ps->ang;
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &g_player[i].ps->horiz, sizeof(int16_t) * 2);
j += sizeof(int16_t) * 2;
Bmemcpy(&packbuf[j], &g_player[i].ps->gotweapon[0], sizeof(g_player[i].ps->gotweapon));
j += sizeof(g_player[i].ps->gotweapon);
Bmemcpy(&packbuf[j], &g_player[i].ps->ammo_amount[0], sizeof(g_player[i].ps->ammo_amount));
j += sizeof(g_player[i].ps->ammo_amount);
Bmemcpy(&packbuf[j], &g_player[i].ps->inv_amount[0], sizeof(g_player[i].ps->inv_amount));
j += sizeof(g_player[i].ps->inv_amount);
Bmemcpy(&packbuf[j], g_player[i].frags, sizeof(g_player[i].frags));
j += sizeof(g_player[i].frags);
*(int16_t *)&packbuf[j] = sprite[g_player[i].ps->i].extra;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = sprite[g_player[i].ps->i].cstat;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = g_player[i].ps->kickback_pic;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = ActorExtra[g_player[i].ps->i].owner;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = ActorExtra[g_player[i].ps->i].picnum;
j += sizeof(int16_t);
packbuf[j++] = (uint8_t) g_player[i].ps->curr_weapon;
packbuf[j++] = (uint8_t) g_player[i].ps->last_weapon;
packbuf[j++] = (uint8_t) g_player[i].ps->wantweaponfire;
packbuf[j++] = (uint8_t) g_player[i].ps->frag_ps;
*(int16_t *)&packbuf[j] = g_player[i].ps->frag;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = g_player[i].ps->fraggedself;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = g_player[i].ps->last_extra;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = g_player[i].ping;
j += sizeof(int16_t);
packbuf[j++] = sprite[g_player[i].ps->i].pal;
l = i;
{
int32_t jj, oa;
i = g_player[l].ps->i;
packbuf[(jj = j++)] = 0;
if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 2;
T5 -= (intptr_t)&script[0];
}
oa = T5;
Bmemcpy(&packbuf[j], &T5, sizeof(T5));
j += sizeof(T5);
if (oa != T5) T3 = T4 = 0;
if (packbuf[jj] & 2) T5 += (intptr_t)&script[0];
}
i = l;
{
int16_t ii=g_gameVarCount-1, kk = 0;
for (; ii>=0; ii--)
{
if ((aGameVars[ii].dwFlags & (GAMEVAR_PERACTOR|GAMEVAR_NOMULTI)) == GAMEVAR_PERACTOR && aGameVars[ii].val.plValues)
{
if (peractorvals[ii][i] != aGameVars[ii].val.plValues[i])
{
peractorvals[ii][i] = aGameVars[ii].val.plValues[i];
*(int16_t *)&packbuf[j] = ii;
j += sizeof(int16_t);
*(int32_t *)&packbuf[j] = aGameVars[ii].val.plValues[i];
j += sizeof(int32_t);
kk++;
}
}
if (kk > 64) break;
}
*(int16_t *)&packbuf[j] = MAXGAMEVARS;
j += sizeof(int16_t);
}
i = l;
{
int16_t ii=g_gameVarCount-1, kk = 0;
for (; ii>=0; ii--)
{
if ((aGameVars[ii].dwFlags & (GAMEVAR_PERPLAYER|GAMEVAR_NOMULTI)) == GAMEVAR_PERPLAYER && aGameVars[ii].val.plValues)
{
if (perplayervals[ii][i] != aGameVars[ii].val.plValues[i])
{
perplayervals[ii][i] = aGameVars[ii].val.plValues[i];
*(int16_t *)&packbuf[j] = ii;
j += sizeof(int16_t);
*(int32_t *)&packbuf[j] = aGameVars[ii].val.plValues[i];
j += sizeof(int32_t);
kk++;
}
}
if (kk > 64) break;
}
*(int16_t *)&packbuf[j] = MAXGAMEVARS;
j += sizeof(int16_t);
}
}
k = 0;
{
int32_t zz, zj;
packbuf[(zj = j++)] = 0;
for (zz = 0; (unsigned)zz < (sizeof(net_lists)/sizeof(net_lists[0])); zz++)
TRAVERSE_SPRITE_STAT(headspritestat[net_lists[zz]], i, nexti)
{
if (totalclock > (lastupdate[i] + TICRATE))
{
l = crc32once((uint8_t *)&sprite[i], sizeof(spritetype));
if (!lastupdate[i] || spritecrc[i] != l)
{
int32_t jj = 0;
/*initprintf("updating sprite %d (%d)\n",i,sprite[i].picnum);*/
spritecrc[i] = l;
lastupdate[i] = totalclock;
*(int16_t *)&packbuf[j] = i;
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &sprite[i], sizeof(spritetype));
j += sizeof(spritetype);
packbuf[(jj = j++)] = 0;
if (T2 >= (intptr_t)&script[0] && T2 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 1;
T2 -= (intptr_t)&script[0];
}
if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 2;
T5 -= (intptr_t)&script[0];
}
if (T6 >= (intptr_t)&script[0] && T6 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 4;
T6 -= (intptr_t)&script[0];
}
Bmemcpy(&packbuf[j], &ActorExtra[i], sizeof(NetActorData_t));
j += sizeof(NetActorData_t);
if (packbuf[jj] & 1) T2 += (intptr_t)&script[0];
if (packbuf[jj] & 2) T5 += (intptr_t)&script[0];
if (packbuf[jj] & 4) T6 += (intptr_t)&script[0];
{
int16_t ii=g_gameVarCount-1, kk = 0;
for (; ii>=0; ii--)
{
if ((aGameVars[ii].dwFlags & GAMEVAR_PERACTOR) && aGameVars[ii].val.plValues)
{
if (peractorvals[ii][i] != aGameVars[ii].val.plValues[i])
{
peractorvals[ii][i] = aGameVars[ii].val.plValues[i];
*(int16_t *)&packbuf[j] = ii;
j += sizeof(int16_t);
*(int32_t *)&packbuf[j] = aGameVars[ii].val.plValues[i];
j += sizeof(int32_t);
kk++;
}
}
if (kk > 64) break;
}
*(int16_t *)&packbuf[j] = MAXGAMEVARS;
j += sizeof(int16_t);
}
k++;
}
}
if (k > 8) break;
}
packbuf[zj] = k;
k = 0;
packbuf[(zj = j++)] = 0;
for (i = numsectors-1; i >= 0; i--)
{
if (totalclock > (lastsectupdate[i] + TICRATE))
{
l = crc32once((uint8_t *)&sector[i], sizeof(sectortype));
if (sectcrc[i] != l)
{
sectcrc[i] = l;
lastsectupdate[i] = totalclock;
*(int16_t *)&packbuf[j] = i;
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &sector[i], sizeof(sectortype));
j += sizeof(sectortype);
k++;
}
}
if (k > 6) break;
}
packbuf[zj] = k;
k = 0;
packbuf[(zj = j++)] = 0;
for (i = numwalls-1; i >= 0; i--)
{
if (totalclock > (lastwallupdate[i] + TICRATE))
{
l = crc32once((uint8_t *)&wall[i], sizeof(walltype));
if (wallcrc[i] != l)
{
wallcrc[i] = l;
lastwallupdate[i] = totalclock;
*(int16_t *)&packbuf[j] = i;
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &wall[i], sizeof(walltype));
j += sizeof(walltype);
k++;
}
}
if (k > 6) break;
}
packbuf[zj] = k;
j++;
}
{
char buf[4096];
j = qlz_compress((char *)(packbuf)+1, (char *)buf, j, state_compress);
Bmemcpy((char *)(packbuf)+1, (char *)buf, j);
j++;
}
packbuf[j++] = myconnectindex;
enet_host_broadcast(net_server, 0, enet_packet_create(packbuf, j, 0));
movefifosendplc++;
}
void faketimerhandler(void)
{
int32_t i, j;
// short who;
int32_t i;
input_t *nsyn;
if (qe == 0 && KB_KeyPressed(sc_LeftControl) && KB_KeyPressed(sc_LeftAlt) && KB_KeyPressed(sc_Delete))
@ -1970,369 +2283,6 @@ void faketimerhandler(void)
computergetinput(i,&inputfifo[0][i]);
}
}
if (net_client) //Slave
{
int32_t jj = 0;
packbuf[0] = PACKET_SLAVE_TO_MASTER;
j = 1;
nsyn = (input_t *)&inputfifo[0][myconnectindex];
Bmemcpy(&packbuf[j], &nsyn[0], sizeof(input_t));
j += sizeof(input_t)-sizeof(loc.filler);
Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->posx, sizeof(vec3_t));
j += sizeof(vec3_t);
Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->posxv, sizeof(vec3_t));
j += sizeof(vec3_t);
*(int16_t *)&packbuf[j] = g_player[myconnectindex].ps->ang;
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->horiz, sizeof(int16_t) * 2);
j += sizeof(int16_t) * 2;
i = g_player[myconnectindex].ps->i;
packbuf[(jj = j++)] = 0;
if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 2;
T5 -= (intptr_t)&script[0];
}
Bmemcpy(&packbuf[j], &T5, sizeof(T5));
j += sizeof(T5);
if (packbuf[jj] & 2) T5 += (intptr_t)&script[0];
{
char buf[1024];
j = qlz_compress((char *)(packbuf)+1, (char *)buf, j, state_compress);
Bmemcpy((char *)(packbuf)+1, (char *)buf, j);
j++;
}
packbuf[j++] = myconnectindex;
enet_peer_send(net_peer, 1, enet_packet_create(packbuf, j, 0));
movefifosendplc++;
return;
}
if (net_server)
{
input_t * osyn = (input_t *)&inputfifo[1][0];
int16_t i, nexti, k = 0, l;
//MASTER -> SLAVE packet
packbuf[0] = PACKET_MASTER_TO_SLAVE;
j = 1;
ticrandomseed = randomseed;
Bmemcpy(&packbuf[j], &ticrandomseed, sizeof(ticrandomseed));
j += sizeof(ticrandomseed);
packbuf[j++] = ud.pause_on;
nsyn = (input_t *)&inputfifo[0][0];
TRAVERSE_CONNECT(i)
{
if (g_player[i].playerquitflag == 0) continue;
Bmemcpy(&osyn[i], &nsyn[i], sizeof(input_t));
*(int16_t *)&packbuf[j] = g_player[i].ps->dead_flag;
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &nsyn[i], sizeof(input_t)-sizeof(loc.filler));
j += sizeof(input_t)-sizeof(loc.filler);
Bmemcpy(&packbuf[j], &g_player[i].ps->posx, sizeof(vec3_t));
j += sizeof(vec3_t);
Bmemcpy(&packbuf[j], &g_player[i].ps->posxv, sizeof(vec3_t));
j += sizeof(vec3_t);
*(int16_t *)&packbuf[j] = g_player[i].ps->ang;
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &g_player[i].ps->horiz, sizeof(int16_t) * 2);
j += sizeof(int16_t) * 2;
Bmemcpy(&packbuf[j], &g_player[i].ps->gotweapon[0], sizeof(g_player[i].ps->gotweapon));
j += sizeof(g_player[i].ps->gotweapon);
Bmemcpy(&packbuf[j], &g_player[i].ps->ammo_amount[0], sizeof(g_player[i].ps->ammo_amount));
j += sizeof(g_player[i].ps->ammo_amount);
Bmemcpy(&packbuf[j], &g_player[i].ps->inv_amount[0], sizeof(g_player[i].ps->inv_amount));
j += sizeof(g_player[i].ps->inv_amount);
Bmemcpy(&packbuf[j], g_player[i].frags, sizeof(g_player[i].frags));
j += sizeof(g_player[i].frags);
*(int16_t *)&packbuf[j] = sprite[g_player[i].ps->i].extra;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = sprite[g_player[i].ps->i].cstat;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = g_player[i].ps->kickback_pic;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = ActorExtra[g_player[i].ps->i].owner;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = ActorExtra[g_player[i].ps->i].picnum;
j += sizeof(int16_t);
packbuf[j++] = (uint8_t) g_player[i].ps->curr_weapon;
packbuf[j++] = (uint8_t) g_player[i].ps->last_weapon;
packbuf[j++] = (uint8_t) g_player[i].ps->wantweaponfire;
packbuf[j++] = (uint8_t) g_player[i].ps->frag_ps;
*(int16_t *)&packbuf[j] = g_player[i].ps->frag;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = g_player[i].ps->fraggedself;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = g_player[i].ps->last_extra;
j += sizeof(int16_t);
*(int16_t *)&packbuf[j] = g_player[i].ping;
j += sizeof(int16_t);
packbuf[j++] = sprite[g_player[i].ps->i].pal;
l = i;
{
int32_t jj, oa;
i = g_player[l].ps->i;
packbuf[(jj = j++)] = 0;
if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 2;
T5 -= (intptr_t)&script[0];
}
oa = T5;
Bmemcpy(&packbuf[j], &T5, sizeof(T5));
j += sizeof(T5);
if (oa != T5) T3 = T4 = 0;
if (packbuf[jj] & 2) T5 += (intptr_t)&script[0];
}
i = l;
{
int16_t ii=g_gameVarCount-1, kk = 0;
for (; ii>=0; ii--)
{
if ((aGameVars[ii].dwFlags & (GAMEVAR_PERACTOR|GAMEVAR_NOMULTI)) == GAMEVAR_PERACTOR && aGameVars[ii].val.plValues)
{
if (peractorvals[ii][i] != aGameVars[ii].val.plValues[i])
{
peractorvals[ii][i] = aGameVars[ii].val.plValues[i];
Bmemcpy(&packbuf[j], &ii, sizeof(int16_t));
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &aGameVars[ii].val.plValues[i], sizeof(int32_t));
j += sizeof(int32_t);
kk++;
}
}
if (kk > 64) break;
}
ii = MAXGAMEVARS;
Bmemcpy(&packbuf[j], &ii, sizeof(int16_t));
j += sizeof(int16_t);
}
i = l;
{
int16_t ii=g_gameVarCount-1, kk = 0;
for (; ii>=0; ii--)
{
if ((aGameVars[ii].dwFlags & (GAMEVAR_PERPLAYER|GAMEVAR_NOMULTI)) == GAMEVAR_PERPLAYER && aGameVars[ii].val.plValues)
{
if (perplayervals[ii][i] != aGameVars[ii].val.plValues[i])
{
perplayervals[ii][i] = aGameVars[ii].val.plValues[i];
Bmemcpy(&packbuf[j], &ii, sizeof(int16_t));
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &aGameVars[ii].val.plValues[i], sizeof(int32_t));
j += sizeof(int32_t);
kk++;
}
}
if (kk > 64) break;
}
ii = MAXGAMEVARS;
Bmemcpy(&packbuf[j], &ii, sizeof(int16_t));
j += sizeof(int16_t);
}
}
k = 0;
{
int32_t zz, zj;
packbuf[(zj = j++)] = 0;
for (zz = 0; (unsigned)zz < (sizeof(net_lists)/sizeof(net_lists[0])); zz++)
TRAVERSE_SPRITE_STAT(headspritestat[net_lists[zz]], i, nexti)
{
if (totalclock > (lastupdate[i] + (TICSPERFRAME * 6)))
{
l = crc32once((uint8_t *)&sprite[i], sizeof(spritetype));
if (!lastupdate[i] || spritecrc[i] != l)
{
int32_t jj = 0;
/*initprintf("updating sprite %d (%d)\n",i,sprite[i].picnum);*/
spritecrc[i] = l;
lastupdate[i] = totalclock;
Bmemcpy(&packbuf[j], &i, sizeof(int16_t));
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &sprite[i], sizeof(spritetype));
j += sizeof(spritetype);
packbuf[(jj = j++)] = 0;
if (T2 >= (intptr_t)&script[0] && T2 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 1;
T2 -= (intptr_t)&script[0];
}
if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 2;
T5 -= (intptr_t)&script[0];
}
if (T6 >= (intptr_t)&script[0] && T6 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 4;
T6 -= (intptr_t)&script[0];
}
Bmemcpy(&packbuf[j], &ActorExtra[i], sizeof(NetActorData_t));
j += sizeof(NetActorData_t);
if (packbuf[jj] & 1) T2 += (intptr_t)&script[0];
if (packbuf[jj] & 2) T5 += (intptr_t)&script[0];
if (packbuf[jj] & 4) T6 += (intptr_t)&script[0];
{
int16_t ii=g_gameVarCount-1, kk = 0;
for (; ii>=0; ii--)
{
if ((aGameVars[ii].dwFlags & GAMEVAR_PERACTOR) && aGameVars[ii].val.plValues)
{
if (peractorvals[ii][i] != aGameVars[ii].val.plValues[i])
{
peractorvals[ii][i] = aGameVars[ii].val.plValues[i];
Bmemcpy(&packbuf[j], &ii, sizeof(int16_t));
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &aGameVars[ii].val.plValues[i], sizeof(int32_t));
j += sizeof(int32_t);
kk++;
}
}
if (kk > 64) break;
}
ii = MAXGAMEVARS;
Bmemcpy(&packbuf[j], &ii, sizeof(int16_t));
j += sizeof(int16_t);
}
k++;
}
}
if (k > 4) break;
}
packbuf[zj] = k;
k = 0;
packbuf[(zj = j++)] = 0;
for (i = numsectors-1; i >= 0; i--)
{
if (totalclock > (lastsectupdate[i] + (TICSPERFRAME * 12)))
{
l = crc32once((uint8_t *)&sector[i], sizeof(sectortype));
if (sectcrc[i] != l)
{
sectcrc[i] = l;
lastsectupdate[i] = totalclock;
Bmemcpy(&packbuf[j], &i, sizeof(int16_t));
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &sector[i], sizeof(sectortype));
j += sizeof(sectortype);
k++;
}
}
if (k > 6) break;
}
packbuf[zj] = k;
k = 0;
packbuf[(zj = j++)] = 0;
for (i = numwalls-1; i >= 0; i--)
{
if (totalclock > (lastwallupdate[i] + (TICSPERFRAME * 12)))
{
l = crc32once((uint8_t *)&wall[i], sizeof(walltype));
if (wallcrc[i] != l)
{
wallcrc[i] = l;
lastwallupdate[i] = totalclock;
Bmemcpy(&packbuf[j], &i, sizeof(int16_t));
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &wall[i], sizeof(walltype));
j += sizeof(walltype);
k++;
}
}
if (k > 6) break;
}
packbuf[zj] = k;
j++;
}
{
char buf[4096];
j = qlz_compress((char *)(packbuf)+1, (char *)buf, j, state_compress);
Bmemcpy((char *)(packbuf)+1, (char *)buf, j);
j++;
}
packbuf[j++] = myconnectindex;
enet_host_broadcast(net_server, 0, enet_packet_create(packbuf, j, 0));
movefifosendplc++;
}
}
extern int32_t cacnum;
@ -12656,6 +12606,60 @@ static int32_t G_DoMoveThings(void)
{
G_AnimateWalls();
A_MoveCyclers();
Net_UpdateClients();
}
if (net_client) //Slave
{
int32_t jj = 0;
input_t *nsyn = (input_t *)&inputfifo[0][myconnectindex];
packbuf[0] = PACKET_SLAVE_TO_MASTER;
j = 1;
Bmemcpy(&packbuf[j], &nsyn[0], sizeof(input_t) - sizeof(loc.filler));
j += sizeof(input_t) - sizeof(loc.filler);
Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->posx, sizeof(vec3_t) * 2);
j += sizeof(vec3_t) * 2;
Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->posxv, sizeof(vec3_t));
j += sizeof(vec3_t);
*(int16_t *)&packbuf[j] = g_player[myconnectindex].ps->ang;
j += sizeof(int16_t);
Bmemcpy(&packbuf[j], &g_player[myconnectindex].ps->horiz, sizeof(int16_t) * 2);
j += sizeof(int16_t) * 2;
i = g_player[myconnectindex].ps->i;
packbuf[(jj = j++)] = 0;
if (T5 >= (intptr_t)&script[0] && T5 < (intptr_t)(&script[g_scriptSize]))
{
packbuf[jj] |= 2;
T5 -= (intptr_t)&script[0];
}
Bmemcpy(&packbuf[j], &T5, sizeof(T5));
j += sizeof(T5);
if (packbuf[jj] & 2) T5 += (intptr_t)&script[0];
{
char buf[1024];
j = qlz_compress((char *)(packbuf)+1, (char *)buf, j, state_compress);
Bmemcpy((char *)(packbuf)+1, (char *)buf, j);
j++;
}
packbuf[j++] = myconnectindex;
enet_peer_send(net_peer, 1, enet_packet_create(packbuf, j, 0));
movefifosendplc++;
}
return 0;

View file

@ -794,6 +794,8 @@ void P_ResetStatus(int32_t snum)
p->movement_lock = 0;
p->frag_ps = snum;
P_UpdateScreenPal(p);
X_OnEvent(EVENT_RESETPLAYER, p->i, snum, -1);
}

View file

@ -416,6 +416,7 @@ int32_t S_LoadSound(uint32_t num)
allocache((intptr_t *)&g_sounds[num].ptr,l,(char *)&g_soundlocks[num]);
kread(fp, g_sounds[num].ptr , l);
kclose(fp);
return 1;
}
@ -432,7 +433,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
ud.config.FXDevice < 0 ||
((g_sounds[num].m&8) && ud.lockout) ||
ud.config.SoundToggle == 0 ||
g_sounds[num].num >= SOUNDMAX ||
g_sounds[num].num >= MAXSOUNDINSTANCES ||
FX_VoiceAvailable(g_sounds[num].pr) == 0 ||
(g_player[myconnectindex].ps->timebeforeexit > 0 && g_player[myconnectindex].ps->timebeforeexit <= GAMETICSPERSEC*3) ||
g_player[myconnectindex].ps->gm&MODE_MENU) return -1;
@ -441,10 +442,15 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
{
voice = S_PlaySound(num);
if (voice >= FX_Ok && g_sounds[num].num < SOUNDMAX && i >= 0 && i < MAXSPRITES)
if (voice >= FX_Ok && g_sounds[num].num < MAXSOUNDINSTANCES && i >= 0 && i < MAXSPRITES)
{
g_sounds[num].SoundOwner[g_sounds[num].num].i = i;
g_sounds[num].SoundOwner[g_sounds[num].num].voice = voice;
int32_t l = 0;
while (l < MAXSOUNDINSTANCES && g_sounds[num].SoundOwner[l].voice > 0)
l++;
g_sounds[num].SoundOwner[l].i = i;
g_sounds[num].SoundOwner[l].voice = voice;
g_sounds[num].num++;
}
@ -461,7 +467,7 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
else if (!(ud.config.VoiceToggle&1))
return -1;
for (j=g_maxSoundPos; j>=0; j--)
for (k=0; k<g_sounds[j].num; k++)
for (k=0; k<MAXSOUNDINSTANCES; k++)
if ((g_sounds[j].num > 0) && (g_sounds[j].m&4))
return -1;
}
@ -550,25 +556,33 @@ int32_t S_PlaySound3D(int32_t num, int32_t i, const vec3_t *pos)
if (sndist < ((255-LOUDESTVOLUME)<<6))
sndist = ((255-LOUDESTVOLUME)<<6);
if (g_sounds[num].m&1)
{
if (g_sounds[num].num > 0) return -1;
int32_t l = 0;
voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num);
}
else
{
voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,sndang>>4,sndist>>6, g_sounds[num].pr, num);
}
while (l < MAXSOUNDINSTANCES && g_sounds[num].SoundOwner[l].voice > 0)
l++;
if (voice >= FX_Ok)
{
g_sounds[num].SoundOwner[g_sounds[num].num].i = i;
g_sounds[num].SoundOwner[g_sounds[num].num].voice = voice;
g_sounds[num].num++;
if (g_sounds[num].m&1)
{
if (g_sounds[num].num > 0) return -1;
voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,(num * MAXSOUNDINSTANCES) + l);
}
else
{
voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,sndang>>4,sndist>>6, g_sounds[num].pr,
(num * MAXSOUNDINSTANCES) + l);
}
if (voice >= FX_Ok)
{
g_sounds[num].SoundOwner[l].i = i;
g_sounds[num].SoundOwner[l].voice = voice;
g_sounds[num].num++;
}
else g_soundlocks[num]--;
}
else g_soundlocks[num]--;
return (voice);
}
@ -614,11 +628,11 @@ int32_t S_PlaySound(int32_t num)
if (g_sounds[num].m&1)
{
voice = FX_PlayLoopedAuto(g_sounds[num].ptr, g_sounds[num].soundsiz, 0, -1,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].soundsiz,num);
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].soundsiz,num * MAXSOUNDINSTANCES);
}
else
{
voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
voice = FX_PlayAuto3D(g_sounds[ num ].ptr, g_sounds[num].soundsiz, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num * MAXSOUNDINSTANCES);
}
if (voice >= FX_Ok) return voice;
@ -645,11 +659,15 @@ void S_StopSound(int32_t num)
{
if (g_sounds[num].num > 0)
{
int32_t j=g_sounds[num].num-1;
int32_t j=MAXSOUNDINSTANCES-1;
for (; j>=0; j--)
{
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
if (g_sounds[num].SoundOwner[j].voice)
{
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
g_sounds[num].SoundOwner[j].voice = 0;
}
// S_TestSoundCallback(num);
}
}
@ -662,13 +680,17 @@ void S_StopEnvSound(int32_t num,int32_t i)
{
if (g_sounds[num].num > 0)
{
int32_t j=g_sounds[num].num-1;
int32_t j=MAXSOUNDINSTANCES-1;
for (; j>=0; j--)
{
if (g_sounds[num].SoundOwner[j].i == i)
{
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
if (g_sounds[num].SoundOwner[j].voice)
{
FX_StopSound(g_sounds[num].SoundOwner[j].voice);
g_sounds[num].SoundOwner[j].voice = 0;
}
// S_TestSoundCallback(num);
}
}
@ -701,13 +723,13 @@ void S_Pan3D(void)
do
{
for (k=g_sounds[j].num-1; k>=0; k--)
for (k=MAXSOUNDINSTANCES-1; k>=0; k--)
{
i = g_sounds[j].SoundOwner[k].i;
if (i < 0 || i >= MAXSPRITES)
if (i < 0 || i >= MAXSPRITES || g_sounds[j].SoundOwner[k].voice < 1)
{
OSD_Printf(OSD_ERROR "S_Pan3D(): INTERNAL ERROR: invalid id %d!\n",i);
// OSD_Printf(OSD_ERROR "S_Pan3D(): INTERNAL ERROR: invalid id %d!\n",i);
k--;
continue;
}
@ -766,47 +788,38 @@ void S_Pan3D(void)
while (j--);
}
void S_TestSoundCallback(uint32_t num)
{
int32_t tempi,tempj,tempk;
if ((int32_t) num == MUSIC_ID)
{
return;
}
if((int32_t)num < 0)
{
if(lumplockbyte[-(int32_t)num] >= 200)
lumplockbyte[-(int32_t)num]--;
return;
}
tempk = g_sounds[num].num;
if (tempk > 0)
{
if ((g_sounds[num].m&16) == 0)
for (tempj=0; tempj<tempk; tempj++)
{
tempi = g_sounds[num].SoundOwner[tempj].i;
if (sprite[tempi].picnum == MUSICANDSFX && sector[sprite[tempi].sectnum].lotag < 3 && sprite[tempi].lotag < 999)
{
ActorExtra[tempi].temp_data[0] = 0;
if ((tempj + 1) < tempk)
{
g_sounds[num].SoundOwner[tempj].voice = g_sounds[num].SoundOwner[tempk-1].voice;
g_sounds[num].SoundOwner[tempj].i = g_sounds[num].SoundOwner[tempk-1].i;
}
break;
}
}
g_sounds[num].num--;
g_sounds[num].SoundOwner[tempk-1].i = -1;
}
g_soundlocks[num]--;
void S_TestSoundCallback(uint32_t num)
{
if ((int32_t)num == MUSIC_ID)
return;
// negative index is RTS playback
if ((int32_t)num < 0)
{
if (lumplockbyte[-(int32_t)num] >= 200)
lumplockbyte[-(int32_t)num]--;
return;
}
{
int32_t j = num & (MAXSOUNDINSTANCES-1);
num = (num - j) / MAXSOUNDINSTANCES;
if (g_sounds[num].num > 0)
{
int32_t i = g_sounds[num].SoundOwner[j].i;
// OSD_Printf("removing sound %d index %d from spr %d\n",num,j,i);
if (sprite[i].picnum == MUSICANDSFX && sector[sprite[i].sectnum].lotag < 3 && sprite[i].lotag < 999)
ActorExtra[i].temp_data[0] = 0;
g_sounds[num].SoundOwner[j].i = -1;
g_sounds[num].SoundOwner[j].voice = 0;
g_sounds[num].num--;
}
}
g_soundlocks[num]--;
}
void S_ClearSoundLocks(void)
@ -831,7 +844,7 @@ int32_t A_CheckSoundPlaying(int32_t i, int32_t num)
if (g_sounds[num].num > 0)
{
for (j=g_sounds[num].num-1; j>=0; j--)
for (j=MAXSOUNDINSTANCES-1; j>=0; j--)
if (g_sounds[num].SoundOwner[j].i == i)
{
return 1;