From 20420dc702a3017e3009191fd783186a833ae83f Mon Sep 17 00:00:00 2001 From: nukeykt Date: Thu, 4 Jul 2019 04:04:38 +0900 Subject: [PATCH] Semiworking mp --- source/rr/src/duke3d.h | 2 +- source/rr/src/gameexec.cpp | 4 ++-- source/rr/src/menus.cpp | 2 +- source/rr/src/net.cpp | 7 ++++--- source/rr/src/player.cpp | 14 +++++++------- source/rr/src/player.h | 5 +++-- source/rr/src/premap.cpp | 2 +- source/rr/src/sector.cpp | 4 ++-- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/source/rr/src/duke3d.h b/source/rr/src/duke3d.h index b65135d79..43f51e3a4 100644 --- a/source/rr/src/duke3d.h +++ b/source/rr/src/duke3d.h @@ -60,7 +60,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define NUMPAGES 1 #define RECSYNCBUFSIZ 2520 //2520 is the (LCM of 1-8)*3 -#define MOVEFIFOSIZ 2 +#define MOVEFIFOSIZ 256 // KEEPINSYNC lunatic/con_lang.lua #define MAXVOLUMES 7 diff --git a/source/rr/src/gameexec.cpp b/source/rr/src/gameexec.cpp index 2eeef4e6e..2db76bb8e 100644 --- a/source/rr/src/gameexec.cpp +++ b/source/rr/src/gameexec.cpp @@ -2628,8 +2628,8 @@ void A_Execute(int spriteNum, int playerNum, int playerDist) } */ - if (g_netClient) // [75] The server should not overwrite its own randomseed - randomseed = ticrandomseed; + //if (g_netClient) // [75] The server should not overwrite its own randomseed + // randomseed = ticrandomseed; if (EDUKE32_PREDICT_FALSE((unsigned)vm.pSprite->sectnum >= MAXSECTORS)) { diff --git a/source/rr/src/menus.cpp b/source/rr/src/menus.cpp index ca6e54dbe..4b7afc5dd 100644 --- a/source/rr/src/menus.cpp +++ b/source/rr/src/menus.cpp @@ -3666,8 +3666,8 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry) if (g_netServer) { Net_FillNewGame(&pendingnewgame, 1); - Net_StartNewGame(); Net_SendNewGame(1, NULL); + Net_StartNewGame(); } else if (voting == -1) { diff --git a/source/rr/src/net.cpp b/source/rr/src/net.cpp index 89889148c..18439b3f9 100644 --- a/source/rr/src/net.cpp +++ b/source/rr/src/net.cpp @@ -108,7 +108,7 @@ void Net_SyncPlayer(ENetEvent *event) Net_SendPlayerIndex(i, event->peer); Net_SendClientInfo(); Net_SendUserMapName(); - Net_SendNewGame(0, event->peer); + // Net_SendNewGame(0, event->peer); } //void Net_SpawnPlayer(int32_t player) @@ -149,6 +149,7 @@ void Net_WaitForEverybody(void) { if (numplayers < 2) return; + packbuf[0] = PACKET_TYPE_PLAYER_READY; g_player[myconnectindex].playerreadyflag++; // if we're a peer or slave, not a master @@ -2561,7 +2562,7 @@ void Net_SendPacket(int dest, uint8_t *pbuf, int32_t packbufleng) uint8_t* buffer = packet->data; *buffer++ = myconnectindex; Bmemcpy(buffer, pbuf, packbufleng); - enet_peer_send(g_netPlayerPeer[dest], CHAN_GAME, packet); + enet_peer_send(g_netClientPeer, CHAN_GAME, packet); } else { @@ -2570,7 +2571,7 @@ void Net_SendPacket(int dest, uint8_t *pbuf, int32_t packbufleng) *buffer++ = dest; *buffer++ = myconnectindex; Bmemcpy(buffer, pbuf, packbufleng); - enet_peer_send(g_netPlayerPeer[dest], CHAN_REROUTE, packet); + enet_peer_send(g_netClientPeer, CHAN_REROUTE, packet); } enet_host_service(g_netClient, NULL, 0); } diff --git a/source/rr/src/player.cpp b/source/rr/src/player.cpp index 0517f52b4..9d6d7ac74 100644 --- a/source/rr/src/player.cpp +++ b/source/rr/src/player.cpp @@ -1121,8 +1121,8 @@ growspark_rr: shootAng = pSprite->ang + (krand2() & 31) - 16; } - if (numplayers > 1 && g_netClient) - return -1; + //if (numplayers > 1 && g_netClient) + // return -1; if (RRRA && projecTile == RRTILE1790) { @@ -4478,8 +4478,8 @@ void P_FragPlayer(int playerNum) DukePlayer_t *const pPlayer = g_player[playerNum].ps; spritetype *const pSprite = &sprite[pPlayer->i]; - if (g_netClient) // [75] The server should not overwrite its own randomseed - randomseed = ticrandomseed; + //if (g_netClient) // [75] The server should not overwrite its own randomseed + // randomseed = ticrandomseed; if (pSprite->pal != 1) { @@ -4880,7 +4880,7 @@ static void P_ProcessWeapon(int playerNum) if (pPlayer->ammo_amount[RPG_WEAPON]) pPlayer->ammo_amount[RPG_WEAPON]--; - if (numplayers < 2 || g_netServer) + //if (numplayers < 2 || g_netServer) { int pipeBombZvel; int pipeBombFwdVel; @@ -5443,7 +5443,7 @@ static void P_ProcessWeapon(int playerNum) { pPlayer->ammo_amount[pPlayer->curr_weapon]--; - if (numplayers < 2 || g_netServer) + //if (numplayers < 2 || g_netServer) { int pipeBombZvel; int pipeBombFwdVel; @@ -6091,7 +6091,7 @@ static void P_Dead(int const playerNum, int const sectorLotag, int const floorZ, if (ud.recstat == 1 && (!g_netServer && ud.multimode < 2)) G_CloseDemoWrite(); - if ((numplayers < 2 || g_netServer) && pPlayer->dead_flag == 0) + if (/*(numplayers < 2 || g_netServer) && */pPlayer->dead_flag == 0) P_FragPlayer(playerNum); if (sectorLotag == ST_2_UNDERWATER) diff --git a/source/rr/src/player.h b/source/rr/src/player.h index 7fa818d9a..ffe85470a 100644 --- a/source/rr/src/player.h +++ b/source/rr/src/player.h @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "inv.h" #include "namesdyn.h" #include "fix16.h" +#include "net.h" #ifdef __cplusplus extern "C" { @@ -33,7 +34,7 @@ extern "C" { extern int32_t g_mostConcurrentPlayers; -#define MOVEFIFOSIZ 2 +#define MOVEFIFOSIZ 256 #define NAM_GRENADE_LIFETIME 120 #define NAM_GRENADE_LIFETIME_VAR 30 @@ -219,7 +220,7 @@ typedef struct { char vote, gotvote, playerreadyflag, playerquitflag, connected; char user_name[32]; - char syncval[MAXPLAYERS][MOVEFIFOSIZ]; + char syncval[SYNCFIFOSIZ][MAXSYNCBYTES]; } playerdata_t; #pragma pack(pop) diff --git a/source/rr/src/premap.cpp b/source/rr/src/premap.cpp index 6e75ad8cc..b7a60acb7 100644 --- a/source/rr/src/premap.cpp +++ b/source/rr/src/premap.cpp @@ -2096,7 +2096,7 @@ static void resetpspritevars(char gameMode) s->xoffset = 0; s->clipdist = 64; -// if (j < g_mostConcurrentPlayers) + if (j < g_mostConcurrentPlayers) { if ((gameMode&MODE_EOL) != MODE_EOL || g_player[j].ps->last_extra == 0) { diff --git a/source/rr/src/sector.cpp b/source/rr/src/sector.cpp index 4c79f993b..5bb923d70 100644 --- a/source/rr/src/sector.cpp +++ b/source/rr/src/sector.cpp @@ -2380,8 +2380,8 @@ void Sect_DamageCeiling(int const sectNum) // hard coded props... :( void A_DamageObject(int spriteNum, int const dmgSrc) { - if (g_netClient) - return; + //if (g_netClient) + // return; spriteNum &= (MAXSPRITES-1);