mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
WIP networking updates from Jasper Foreman
git-svn-id: https://svn.eduke32.com/eduke32@3095 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
067baf626a
commit
a3fe057c0a
8 changed files with 1773 additions and 1553 deletions
|
@ -532,7 +532,7 @@ void A_DeleteSprite(int32_t s)
|
|||
|
||||
void A_AddToDeleteQueue(int32_t i)
|
||||
{
|
||||
if (g_netClientPeer || g_spriteDeleteQueueSize == 0)
|
||||
if (g_spriteDeleteQueueSize == 0)
|
||||
{
|
||||
A_DeleteSprite(i);
|
||||
return;
|
||||
|
|
|
@ -926,7 +926,7 @@ nextdemo_nomenu:
|
|||
}
|
||||
else if (g_player[myconnectindex].ps->gm&MODE_TYPE)
|
||||
{
|
||||
Net_EnterMessage();
|
||||
Net_SendMessage();
|
||||
|
||||
if ((g_player[myconnectindex].ps->gm&MODE_TYPE) != MODE_TYPE)
|
||||
g_player[myconnectindex].ps->gm = MODE_MENU;
|
||||
|
|
|
@ -3026,7 +3026,7 @@ void G_DisplayRest(int32_t smoothratio)
|
|||
if (!Demo_IsProfiling())
|
||||
{
|
||||
if (g_player[myconnectindex].ps->gm&MODE_TYPE)
|
||||
Net_EnterMessage();
|
||||
Net_SendMessage();
|
||||
else
|
||||
M_DisplayMenus();
|
||||
}
|
||||
|
@ -7299,9 +7299,9 @@ FOUNDCHEAT:
|
|||
i = Bstrlen(CheatStrings[k])-1;
|
||||
ud.m_player_skill = ud.player_skill = cheatbuf[i] - '1';
|
||||
}
|
||||
if (numplayers > 1 && g_netServer)
|
||||
/*if (numplayers > 1 && g_netServer)
|
||||
Net_NewGame(ud.m_volume_number,ud.m_level_number);
|
||||
else g_player[myconnectindex].ps->gm |= MODE_RESTART;
|
||||
else*/ g_player[myconnectindex].ps->gm |= MODE_RESTART;
|
||||
|
||||
end_cheat();
|
||||
return;
|
||||
|
@ -7480,22 +7480,10 @@ void G_HandleLocalKeys(void)
|
|||
{
|
||||
if (KB_UnBoundKeyPressed(sc_F1) || KB_UnBoundKeyPressed(sc_F2) || ud.autovote)
|
||||
{
|
||||
tempbuf[0] = PACKET_MAP_VOTE;
|
||||
tempbuf[1] = myconnectindex;
|
||||
tempbuf[2] = (KB_UnBoundKeyPressed(sc_F1) || ud.autovote ? ud.autovote-1 : 0);
|
||||
tempbuf[3] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
|
||||
G_AddUserQuote("Vote Cast");
|
||||
g_player[myconnectindex].gotvote = 1;
|
||||
Net_SendMapVote(KB_UnBoundKeyPressed(sc_F1) || ud.autovote ? ud.autovote-1 : 0);
|
||||
KB_ClearKeyDown(sc_F1);
|
||||
KB_ClearKeyDown(sc_F2);
|
||||
voting = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10875,19 +10863,20 @@ int32_t G_DoMoveThings(void)
|
|||
// Net_CorrectPrediction();
|
||||
|
||||
if (g_netServer)
|
||||
Net_UpdateClients();
|
||||
Net_SendServerUpdates();
|
||||
|
||||
if ((everyothertime&1) == 0)
|
||||
{
|
||||
G_AnimateWalls();
|
||||
A_MoveCyclers();
|
||||
|
||||
if (g_netServer)
|
||||
Net_StreamLevel();
|
||||
// Map updates are disabled for now
|
||||
// if (g_netServer && (everyothertime % 10) == 0)
|
||||
// Net_SendMapUpdate();
|
||||
}
|
||||
|
||||
if (g_netClient) //Slave
|
||||
Net_ClientMove();
|
||||
Net_SendClientUpdate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1969,9 +1969,9 @@ nullquote:
|
|||
|
||||
ud.m_volume_number = ud.volume_number = volnume;
|
||||
ud.m_level_number = ud.level_number = levnume;
|
||||
if (numplayers > 1 && g_netServer)
|
||||
Net_NewGame(volnume,levnume);
|
||||
else
|
||||
//if (numplayers > 1 && g_netServer)
|
||||
// Net_NewGame(volnume,levnume);
|
||||
//else
|
||||
{
|
||||
g_player[myconnectindex].ps->gm |= MODE_EOL;
|
||||
ud.display_bonus_screen = 0;
|
||||
|
|
|
@ -804,22 +804,6 @@ void M_DisplayMenus(void)
|
|||
|
||||
Net_GetPackets();
|
||||
|
||||
if (g_netSync)
|
||||
{
|
||||
P_SetGamePalette(g_player[myconnectindex].ps, TITLEPAL, 8+2+1);
|
||||
rotatesprite_fs(0,0,65536L,0,BETASCREEN,0,0,2+8+16+64);
|
||||
|
||||
rotatesprite_fs(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8);
|
||||
rotatesprite_fs(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8);
|
||||
if (PLUTOPAK) // JBF 20030804
|
||||
rotatesprite_fs(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8);
|
||||
|
||||
gametext(160,190,"Transferring gamestate",14,2);
|
||||
nextpage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
if (buttonstat != 0 && !onbar)
|
||||
{
|
||||
|
@ -5227,100 +5211,23 @@ VOLUME_ALL_40x:
|
|||
|
||||
case 603:
|
||||
{
|
||||
int32_t plrvotes = 0, j = 0;
|
||||
|
||||
x = M_Probe(186,124,0,0);
|
||||
|
||||
if (voting != myconnectindex)
|
||||
{
|
||||
g_player[myconnectindex].ps->gm &= ~MODE_MENU;
|
||||
|
||||
if (x == -1)
|
||||
{
|
||||
if (voting == myconnectindex)
|
||||
{
|
||||
for (i=0; i<MAXPLAYERS; i++)
|
||||
{
|
||||
g_player[i].vote = 0;
|
||||
g_player[i].gotvote = 0;
|
||||
}
|
||||
|
||||
tempbuf[0] = PACKET_MAP_VOTE_CANCEL;
|
||||
tempbuf[1] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 2, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
voting = -1;
|
||||
}
|
||||
}
|
||||
else if (x == -1)
|
||||
{
|
||||
Net_SendMapVoteCancel(0);
|
||||
M_ChangeMenu(MENU_MAIN);
|
||||
}
|
||||
|
||||
for (i=0; i<MAXPLAYERS; i++)
|
||||
{
|
||||
plrvotes += g_player[i].vote;
|
||||
j += g_player[i].gotvote;
|
||||
}
|
||||
if (j == numplayers || !g_player[myconnectindex].ps->i || (plrvotes > (numplayers>>1)) || (g_netServer))
|
||||
{
|
||||
if (plrvotes > (numplayers>>1) || !g_player[myconnectindex].ps->i || (g_netServer))
|
||||
{
|
||||
if (ud.m_player_skill == 3) ud.m_respawn_monsters = 1;
|
||||
else ud.m_respawn_monsters = 0;
|
||||
|
||||
if ((GametypeFlags[ud.m_coop] & GAMETYPE_ITEMRESPAWN)) ud.m_respawn_items = 1;
|
||||
else ud.m_respawn_items = 0;
|
||||
|
||||
ud.m_respawn_inventory = 1;
|
||||
|
||||
for (TRAVERSE_CONNECT(margin))
|
||||
{
|
||||
P_ResetWeapons(margin);
|
||||
P_ResetInventory(margin);
|
||||
|
||||
}
|
||||
|
||||
Net_NewGame(ud.m_volume_number,ud.m_level_number);
|
||||
|
||||
if (voting == myconnectindex && !(g_netServer))
|
||||
G_AddUserQuote("Vote Succeeded");
|
||||
|
||||
G_NewGame(ud.m_volume_number,ud.m_level_number,ud.m_player_skill+1);
|
||||
if (G_EnterLevel(MODE_GAME)) G_BackToMenu();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (j == numplayers)
|
||||
{
|
||||
for (i=0; i<MAXPLAYERS; i++)
|
||||
{
|
||||
g_player[i].vote = 0;
|
||||
g_player[i].gotvote = 0;
|
||||
}
|
||||
|
||||
voting = -1;
|
||||
|
||||
tempbuf[0] = PACKET_MAP_VOTE_CANCEL;
|
||||
tempbuf[1] = myconnectindex;
|
||||
tempbuf[2] = 1;
|
||||
tempbuf[3] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 4, ENET_PACKET_FLAG_RELIABLE));
|
||||
|
||||
Bsprintf(ScriptQuotes[QUOTE_RESERVED2],"Vote Failed");
|
||||
P_DoQuote(QUOTE_RESERVED2,g_player[myconnectindex].ps);
|
||||
g_player[myconnectindex].ps->gm &= ~MODE_MENU;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
mgametext(160,90,"Waiting for votes",0,2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 600:
|
||||
margin = (320>>1) - 120;
|
||||
|
@ -5436,35 +5343,14 @@ VOLUME_ALL_40x:
|
|||
// master does whatever it wants
|
||||
if (g_netServer)
|
||||
{
|
||||
M_ChangeMenu(603);
|
||||
Net_FillNewGame(&pendingnewgame, 1);
|
||||
Net_StartNewGame();
|
||||
Net_SendNewGame(1, NULL);
|
||||
break;
|
||||
}
|
||||
if (voting == -1)
|
||||
{
|
||||
if (g_player[myconnectindex].ps->i)
|
||||
{
|
||||
for (i=0; i<MAXPLAYERS; i++)
|
||||
{
|
||||
g_player[i].vote = 0;
|
||||
g_player[i].gotvote = 0;
|
||||
}
|
||||
g_player[myconnectindex].vote = g_player[myconnectindex].gotvote = 1;
|
||||
voting = myconnectindex;
|
||||
|
||||
tempbuf[0] = PACKET_MAP_VOTE_INITIATE;
|
||||
tempbuf[1] = myconnectindex;
|
||||
tempbuf[2] = ud.m_volume_number;
|
||||
tempbuf[3] = ud.m_level_number;
|
||||
tempbuf[4] = myconnectindex;
|
||||
|
||||
if (g_netClient)
|
||||
enet_peer_send(g_netClientPeer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 5, ENET_PACKET_FLAG_RELIABLE));
|
||||
else if (g_netServer)
|
||||
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(tempbuf, 5, ENET_PACKET_FLAG_RELIABLE));
|
||||
}
|
||||
if ((GametypeFlags[ud.m_coop] & GAMETYPE_PLAYERSFRIENDLY) && !(GametypeFlags[ud.m_coop] & GAMETYPE_TDM))
|
||||
ud.m_noexits = 0;
|
||||
|
||||
Net_SendMapVoteInitiate();
|
||||
M_ChangeMenu(603);
|
||||
}
|
||||
break;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -92,7 +92,6 @@ typedef struct {
|
|||
uint32_t revision;
|
||||
int32_t animategoal[MAXANIMATES], animatevel[MAXANIMATES], g_animateCount;
|
||||
int32_t animateptr[MAXANIMATES];
|
||||
// int32_t lockclock;
|
||||
int32_t msx[2048], msy[2048];
|
||||
int32_t randomseed, g_globalRandom;
|
||||
|
||||
|
@ -138,30 +137,118 @@ extern int32_t g_netDisconnect;
|
|||
extern int32_t g_netPlayersWaiting;
|
||||
extern int32_t g_netPort;
|
||||
extern int32_t g_networkMode;
|
||||
extern int32_t g_netSync;
|
||||
extern int32_t lastsectupdate[MAXSECTORS];
|
||||
extern int32_t lastupdate[MAXSPRITES];
|
||||
extern int32_t lastwallupdate[MAXWALLS];
|
||||
extern int16_t g_netStatnums[10];
|
||||
|
||||
#pragma pack(push,1)
|
||||
typedef struct {
|
||||
vec3_t pos;
|
||||
vec3_t opos;
|
||||
vec3_t vel;
|
||||
int16_t ang;
|
||||
int16_t horiz;
|
||||
int16_t horizoff;
|
||||
int16_t ping;
|
||||
int16_t playerindex;
|
||||
int16_t deadflag;
|
||||
int16_t playerquitflag;
|
||||
} playerupdate_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
int32_t Net_PackSprite(int32_t i,uint8_t *pbuf);
|
||||
int32_t Net_UnpackSprite(int32_t i,uint8_t *pbuf);
|
||||
void Net_ClientMove(void);
|
||||
#pragma pack(push,1)
|
||||
typedef struct {
|
||||
int8_t header;
|
||||
int8_t connection;
|
||||
int8_t level_number;
|
||||
int8_t volume_number;
|
||||
int8_t player_skill;
|
||||
int8_t monsters_off;
|
||||
int8_t respawn_monsters;
|
||||
int8_t respawn_items;
|
||||
int8_t respawn_inventory;
|
||||
int8_t marker;
|
||||
int8_t ffire;
|
||||
int8_t noexits;
|
||||
int8_t coop;
|
||||
} newgame_t;
|
||||
#pragma pack(pop)
|
||||
|
||||
newgame_t pendingnewgame;
|
||||
|
||||
// Connect/Disconnect
|
||||
void Net_Connect(const char *srvaddr);
|
||||
void Net_Disconnect(void);
|
||||
void Net_EnterMessage(void);
|
||||
void Net_ReceiveDisconnect(ENetEvent *event);
|
||||
|
||||
// Packet Handlers
|
||||
void Net_GetPackets(void);
|
||||
void Net_NewGame(int32_t volume,int32_t level);
|
||||
void Net_HandleServerPackets(void);
|
||||
void Net_HandleClientPackets(void);
|
||||
void Net_ParseClientPacket(ENetEvent *event);
|
||||
void Net_ParseServerPacket(ENetEvent *event);
|
||||
void Net_ParsePacketCommon(uint8_t *pbuf, int32_t packbufleng, int32_t serverpacketp);
|
||||
|
||||
void Net_SendVersion(ENetPeer *client);
|
||||
void Net_RecieveVersion(uint8_t *pbuf, int32_t packbufleng);
|
||||
|
||||
void Net_SendChallenge();
|
||||
void Net_RecieveChallenge(uint8_t *pbuf, int32_t packbufleng, ENetEvent *event);
|
||||
|
||||
void Net_SendNewPlayer(int32_t newplayerindex);
|
||||
void Net_RecieveNewPlayer(uint8_t *pbuf, int32_t packbufleng);
|
||||
|
||||
void Net_SendPlayerIndex(int32_t index, ENetPeer *peer);
|
||||
void Net_RecievePlayerIndex(uint8_t *pbuf, int32_t packbufleng);
|
||||
|
||||
void Net_SendClientInfo(void);
|
||||
void Net_ReceiveClientInfo(uint8_t *pbuf, int32_t packbufleng, int32_t fromserver);
|
||||
|
||||
void Net_SendUserMapName(void);
|
||||
void Net_ReceiveUserMapName(uint8_t *pbuf, int32_t packbufleng);
|
||||
|
||||
void Net_SendClientSync(ENetEvent *event, int32_t player);
|
||||
void Net_ReceiveClientSync(ENetEvent *event);
|
||||
|
||||
void Net_SendMapUpdate(void);
|
||||
void Net_ReceiveMapUpdate(uint8_t *pbuf, int32_t packbufleng);
|
||||
|
||||
void Net_FillPlayerUpdate(playerupdate_t *update, int32_t player);
|
||||
void Net_ExtractPlayerUpdate(playerupdate_t *update);
|
||||
|
||||
void Net_SendServerUpdates(void);
|
||||
void Net_ReceiveServerUpdate(ENetEvent *event);
|
||||
|
||||
void Net_SendClientUpdate(void);
|
||||
void Net_ReceiveClientUpdate(ENetEvent *event);
|
||||
|
||||
void Net_SendMessage(void);
|
||||
void Net_ReceiveMessage(uint8_t *pbuf, int32_t packbufleng);
|
||||
|
||||
void Net_StartNewGame();
|
||||
void Net_SendNewGame(int32_t frommenu, ENetPeer *peer);
|
||||
void Net_ReceiveNewGame(ENetEvent *event);
|
||||
|
||||
void Net_FillNewGame(newgame_t* newgame, int32_t frommenu);
|
||||
void Net_ExtractNewGame(newgame_t* newgame, int32_t menuonly);
|
||||
|
||||
void Net_SendMapVoteInitiate(void);
|
||||
void Net_RecieveMapVoteInitiate(uint8_t *pbuf);
|
||||
|
||||
void Net_SendMapVote(int32_t votefor);
|
||||
void Net_RecieveMapVote(uint8_t *pbuf);
|
||||
void Net_CheckForEnoughVotes();
|
||||
|
||||
void Net_SendMapVoteCancel(int32_t failed);
|
||||
void Net_RecieveMapVoteCancel(uint8_t *pbuf);
|
||||
|
||||
//////////
|
||||
|
||||
void Net_ResetPrediction(void);
|
||||
void Net_RestoreMapState(netmapstate_t *save);
|
||||
void Net_SendClientInfo(void);
|
||||
void Net_SendUserMapName(void);
|
||||
void Net_StreamLevel(void);
|
||||
void Net_SyncPlayer(ENetEvent *event);
|
||||
void Net_UpdateClients(void);
|
||||
void Net_WaitForServer(void);
|
||||
void faketimerhandler(void);
|
||||
#endif
|
||||
|
||||
#endif // __netplay_h__
|
||||
|
|
|
@ -98,6 +98,7 @@ static int32_t osdcmd_changelevel(const osdfuncparm_t *parm)
|
|||
|
||||
if (numplayers > 1)
|
||||
{
|
||||
/*
|
||||
if (g_netServer)
|
||||
Net_NewGame(volume,level);
|
||||
else if (voting == -1)
|
||||
|
@ -132,6 +133,7 @@ static int32_t osdcmd_changelevel(const osdfuncparm_t *parm)
|
|||
g_player[myconnectindex].ps->gm |= MODE_MENU;
|
||||
M_ChangeMenu(603);
|
||||
}
|
||||
*/
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
if (g_player[myconnectindex].ps->gm & MODE_GAME)
|
||||
|
@ -227,6 +229,7 @@ static int32_t osdcmd_map(const osdfuncparm_t *parm)
|
|||
|
||||
if (numplayers > 1)
|
||||
{
|
||||
/*
|
||||
if (g_netServer)
|
||||
{
|
||||
Net_SendUserMapName();
|
||||
|
@ -267,6 +270,7 @@ static int32_t osdcmd_map(const osdfuncparm_t *parm)
|
|||
g_player[myconnectindex].ps->gm |= MODE_MENU;
|
||||
M_ChangeMenu(603);
|
||||
}
|
||||
*/
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue