oldmp wip

# Conflicts:
#	source/rr/src/net.cpp
This commit is contained in:
nukeykt 2019-07-03 04:14:37 +09:00 committed by Christoph Oelckers
parent fe80b46d54
commit c3fc897a3e
6 changed files with 1061 additions and 61 deletions

View file

@ -7798,6 +7798,10 @@ int app_main(int argc, char const * const * argv)
g_skillCnt = 4;
ud.multimode = 1;
g_movesPerPacket = 1;
bufferjitter = 1;
initsynccrc();
// This needs to happen before G_CheckCommandLine() because G_GameExit()
// accesses g_player[0].
G_MaybeAllocPlayer(0);
@ -8427,9 +8431,26 @@ MAIN_LOOP_RESTART:
GAME_STATIC GAME_INLINE int32_t G_MoveLoop()
{
int i;
if (numplayers > 1)
while (predictfifoplc < g_player[myconnectindex].movefifoend) Net_DoPrediction();
Net_GetPackets();
return G_DoMoveThings();
if (numplayers < 2) bufferjitter = 0;
while (g_player[myconnectindex].movefifoend-movefifoplc > bufferjitter)
{
for(TRAVERSE_CONNECT(i))
{
if (movefifoplc == g_player[i].movefifoend) break;
}
if (i >= 0) break;
if (G_DoMoveThings()) return 1;
}
return 0;
}
int G_DoMoveThings(void)
@ -8508,11 +8529,13 @@ int G_DoMoveThings(void)
// Moved lower so it is restored correctly by diffs:
// everyothertime++;
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;
for (bssize_t TRAVERSE_CONNECT(i))
Bmemcpy(g_player[i].inputBits, &inputfifo[(g_netServer && myconnectindex == i)][i], sizeof(input_t));
Bmemcpy(g_player[i].inputBits, &inputfifo[movefifoplc&(MOVEFIFOSIZ-1)][i], sizeof(input_t));
movefifoplc++;
G_UpdateInterpolations();
@ -8532,6 +8555,8 @@ int G_DoMoveThings(void)
}
*/
Net_GetSyncStat();
g_moveThingsCount++;
if (ud.recstat == 1) G_DemoRecord();
@ -8574,24 +8599,24 @@ int G_DoMoveThings(void)
if (ud.pause_on == 0)
G_MoveWorld();
// Net_CorrectPrediction();
Net_CorrectPrediction();
if (g_netServer)
Net_SendServerUpdates();
//if (g_netServer)
// Net_SendServerUpdates();
if ((everyothertime&1) == 0)
{
G_AnimateWalls();
A_MoveCyclers();
if (g_netServer && (everyothertime % 10) == 0)
{
Net_SendMapUpdate();
}
//if (g_netServer && (everyothertime % 10) == 0)
//{
// Net_SendMapUpdate();
//}
}
if (g_netClient) //Slave
Net_SendClientUpdate();
//if (g_netClient) //Slave
// Net_SendClientUpdate();
if (RR && ud.recstat == 0 && ud.multimode < 2 && g_torchCnt)
G_DoTorch();

View file

@ -84,7 +84,8 @@ G_EXTERN char pus,pub;
G_EXTERN char ready2send;
#define MAXPLAYERNAME 32
G_EXTERN char szPlayerName[MAXPLAYERNAME];
G_EXTERN char tempbuf[MAXSECTORS<<1],packbuf[PACKBUF_SIZE],buf[1024];
G_EXTERN char tempbuf[MAXSECTORS<<1],buf[1024];
G_EXTERN uint8_t packbuf[PACKBUF_SIZE];
#define TYPEBUFSIZE 141
G_EXTERN char typebuf[TYPEBUFSIZE];
@ -92,6 +93,28 @@ G_EXTERN char typebuf[TYPEBUFSIZE];
G_EXTERN input_t localInput;
G_EXTERN input_t recsync[RECSYNCBUFSIZ];
//G_EXTERN uint8_t syncstat, syncval[MAXPLAYERS][MOVEFIFOSIZ];
//G_EXTERN int32_t syncvalhead[MAXPLAYERS], syncvaltail, syncvaltottail;
G_EXTERN int32_t avgfvel, avgsvel, avgbits;
G_EXTERN fix16_t avgavel, avghorz;
G_EXTERN int8_t avgextbits;
G_EXTERN int32_t movefifosendplc;
G_EXTERN int32_t movefifoplc;
G_EXTERN int32_t predictfifoplc;
G_EXTERN vec3_t mypos, omypos, myvel;
G_EXTERN fix16_t myhoriz, omyhoriz, myhorizoff, omyhorizoff, myang, omyang;
G_EXTERN int16_t mycursectnum, myjumpingcounter;
G_EXTERN uint8_t myjumpingtoggle, myonground, myhardlanding, myreturntocenter;
G_EXTERN vec3_t myposbak[MOVEFIFOSIZ];
G_EXTERN fix16_t myhorizbak[MOVEFIFOSIZ], myangbak[MOVEFIFOSIZ];
G_EXTERN int32_t myminlag[MAXPLAYERS], mymaxlag, otherminlag, bufferjitter;
G_EXTERN int32_t g_networkBroadcastMode, g_movesPerPacket;
G_EXTERN int32_t g_animWallCnt;
G_EXTERN int32_t g_animateCnt;
G_EXTERN int32_t g_cloudCnt;

File diff suppressed because it is too large Load diff

View file

@ -65,6 +65,38 @@ enum netchan_t
enum DukePacket_t
{
PACKET_TYPE_MASTER_TO_SLAVE,
PACKET_TYPE_SLAVE_TO_MASTER,
PACKET_TYPE_BROADCAST,
SERVER_GENERATED_BROADCAST,
PACKET_TYPE_VERSION,
/* don't change anything above this line */
PACKET_TYPE_MESSAGE,
PACKET_TYPE_NEW_GAME,
PACKET_TYPE_RTS,
PACKET_TYPE_MENU_LEVEL_QUIT,
PACKET_TYPE_WEAPON_CHOICE,
PACKET_TYPE_PLAYER_OPTIONS,
PACKET_TYPE_PLAYER_NAME,
PACKET_TYPE_INIT_SETTINGS,
PACKET_TYPE_USER_MAP,
PACKET_TYPE_MAP_VOTE,
PACKET_TYPE_MAP_VOTE_INITIATE,
PACKET_TYPE_MAP_VOTE_CANCEL,
PACKET_TYPE_LOAD_GAME,
PACKET_TYPE_NULL_PACKET,
PACKET_TYPE_PLAYER_READY,
PACKET_TYPE_FRAGLIMIT_CHANGED,
PACKET_TYPE_EOL,
PACKET_TYPE_QUIT = 255, // should match mmulti I think
PACKET_MASTER_TO_SLAVE,
PACKET_SLAVE_TO_MASTER,
@ -116,6 +148,23 @@ enum netmode_t
NET_DEDICATED_SERVER
};
#define MAXSYNCBYTES 16
#define SYNCFIFOSIZ 1024
// TENSW: on really bad network connections, the sync FIFO queue can overflow if it is the
// same size as the move fifo.
#if MOVEFIFOSIZ >= SYNCFIFOSIZ
#error "MOVEFIFOSIZ is greater than or equal to SYNCFIFOSIZ!"
#endif
extern char syncstat[MAXSYNCBYTES];
extern char g_szfirstSyncMsg[MAXSYNCBYTES][60];
extern int g_numSyncBytes;
extern int g_foundSyncError;
extern int syncvaltail, syncvaltottail;
#define NETMAXACTORS 1024
#pragma pack(push,1)
@ -181,6 +230,20 @@ extern newgame_t pendingnewgame;
#ifndef NETCODE_DISABLE
// Sync
void initsynccrc(void);
char Net_PlayerSync(void);
char Net_PlayerSync2(void);
char Net_ActorSync(void);
char Net_WeaponSync(void);
char Net_MapSync(void);
char Net_RandomSync(void);
void Net_GetSyncStat(void);
void Net_DisplaySyncMsg(void);
void Net_AddSyncInfoToPacket(int* j);
void Net_GetSyncInfoFromPacket(char* packbuf, int packbufleng, int* j, int otherconnectindex);
// Connect/Disconnect
void Net_Connect(const char *srvaddr);
void Net_Disconnect(void);
@ -190,6 +253,7 @@ void Net_ReceiveDisconnect(ENetEvent *event);
#endif
void Net_GetPackets(void);
#ifndef NETCODE_DISABLE
void Net_SendPacket(int32_t dest, uint8_t* pbuf, int32_t packbufleng);
void Net_HandleServerPackets(void);
void Net_HandleClientPackets(void);
void Net_ParseClientPacket(ENetEvent *event);
@ -264,9 +328,12 @@ void Net_ReceiveMapVoteCancel(uint8_t *pbuf);
//////////
void Net_ResetPrediction(void);
void Net_DoPrediction(void);
void Net_CorrectPrediction(void);
void Net_SpawnPlayer(int32_t player);
void Net_SyncPlayer(ENetEvent *event);
void Net_WaitForServer(void);
void Net_WaitForEverybody(void);
void Net_Update(void);
void faketimerhandler(void);
#else
@ -341,6 +408,8 @@ void faketimerhandler(void);
//////////
#define Net_ResetPrediction(...) ((void)0)
#define Net_DoPrediction(...) ((void)0)
#define Net_CorrectPrediction(...) ((void)0)
#define Net_RestoreMapState(...) ((void)0)
#define Net_SyncPlayer(...) ((void)0)
#define Net_WaitForServer(...) ((void)0)

View file

@ -212,15 +212,14 @@ typedef struct {
DukePlayer_t *ps;
input_t *inputBits;
int32_t netsynctime;
int16_t ping, filler;
int32_t movefifoend, syncvalhead, myminlag;
int32_t pcolor, pteam;
// NOTE: wchoice[HANDREMOTE_WEAPON .. MAX_WEAPONS-1] unused
uint8_t frags[MAXPLAYERS], wchoice[MAX_WEAPONS];
char vote, gotvote, pingcnt, playerquitflag, ready;
char vote, gotvote, playerreadyflag, playerquitflag, connected;
char user_name[32];
uint32_t revision;
char syncval[MAXPLAYERS][MOVEFIFOSIZ];
} playerdata_t;
#pragma pack(pop)

View file

@ -1316,6 +1316,8 @@ void G_DisplayRest(int32_t smoothratio)
if (g_Debug)
G_ShowCacheLocks();
Net_DisplaySyncMsg();
#ifndef EDUKE32_TOUCH_DEVICES
if (VOLUMEONE)
{