oldmp wip

# Conflicts:
#	source/rr/src/game.cpp
#	source/rr/src/net.cpp
This commit is contained in:
nukeykt 2019-07-04 02:19:06 +09:00 committed by Christoph Oelckers
parent c3fc897a3e
commit 5e182e2962
11 changed files with 923 additions and 1188 deletions

View file

@ -527,11 +527,11 @@ void A_DeleteSprite(int spriteNum)
S_StopEnvSound(sprite[spriteNum].lotag, spriteNum);
// NetAlloc
if (Net_IsRelevantSprite(spriteNum))
{
Net_DeleteSprite(spriteNum);
return;
}
//if (Net_IsRelevantSprite(spriteNum))
//{
// Net_DeleteSprite(spriteNum);
// return;
//}
deletesprite(spriteNum);
}

View file

@ -339,13 +339,13 @@ void G_CheckCommandLine(int32_t argc, char const * const * argv)
i++;
continue;
}
if (!Bstrcasecmp(c+1, "dedicated"))
{
g_networkMode = NET_DEDICATED_SERVER;
g_noSetup = g_noLogo = TRUE;
i++;
continue;
}
//if (!Bstrcasecmp(c+1, "dedicated"))
//{
// g_networkMode = NET_DEDICATED_SERVER;
// g_noSetup = g_noLogo = TRUE;
// i++;
// continue;
//}
if (!Bstrcasecmp(c+1, "connect"))
{
if (argc > i+1)

View file

@ -184,7 +184,7 @@ void G_HandleSpecialKeys(void)
// CONTROL_ProcessBinds();
if (g_networkMode != NET_DEDICATED_SERVER && ALT_IS_PRESSED && KB_KeyPressed(sc_Enter))
if (/*g_networkMode != NET_DEDICATED_SERVER && */ALT_IS_PRESSED && KB_KeyPressed(sc_Enter))
{
if (videoSetGameMode(!ud.setup.fullscreen,ud.setup.xdim,ud.setup.ydim,ud.setup.bpp,ud.detail))
{
@ -228,11 +228,12 @@ void G_GameQuit(void)
{
g_gameQuit = 1;
g_quitDeadline = (int32_t)totalclock + 120;
g_netDisconnect = 1;
//g_netDisconnect = 1;
}
if ((totalclock > g_quitDeadline) && (g_gameQuit == 1))
G_GameExit("Timed out.");
g_netDisconnect = 1;
//G_GameExit("Timed out.");
}
@ -953,7 +954,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
int yxAspect = yxaspect;
int viewingRange = viewingrange;
if (g_networkMode == NET_DEDICATED_SERVER) return;
//if (g_networkMode == NET_DEDICATED_SERVER) return;
totalclocklock = totalclock;
@ -1618,7 +1619,7 @@ int32_t A_InsertSprite(int16_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int1
if (RR && s_ow < 0)
return 0;
int32_t i = Net_IsRelevantStat(s_ss) ? Net_InsertSprite(whatsect, s_ss) : insertsprite(whatsect, s_ss);
int32_t i = /*Net_IsRelevantStat(s_ss) ? Net_InsertSprite(whatsect, s_ss) : */insertsprite(whatsect, s_ss);
if (EDUKE32_PREDICT_FALSE((unsigned)i >= MAXSPRITES))
{
@ -7523,7 +7524,7 @@ static void G_Startup(void)
}
for (i=0; i<MAXPLAYERS; i++)
g_player[i].pingcnt = 0;
g_player[i].playerreadyflag = 0;
if (quitevent)
{
@ -7679,7 +7680,7 @@ static int G_EndOfLevel(void)
return 2;
}
Net_WaitForServer();
Net_WaitForEverybody();
return 1;
}
@ -7939,7 +7940,7 @@ int app_main(int argc, char const * const * argv)
initprintf("CON debugging activated (level %d).\n",g_scriptDebug);
#ifndef NETCODE_DISABLE
if (g_networkMode == NET_SERVER || g_networkMode == NET_DEDICATED_SERVER)
if (g_networkMode == NET_SERVER/* || g_networkMode == NET_DEDICATED_SERVER*/)
{
ENetAddress address = { ENET_HOST_ANY, g_netPort };
g_netServer = enet_host_create(&address, MAXPLAYERS, CHAN_MAX, 0, 0);
@ -8052,7 +8053,7 @@ int app_main(int argc, char const * const * argv)
OSD_SetParameters(0, 0, 0, 12, 2, 12, OSD_ERROR, OSDTEXT_RED, gamefunctions[gamefunc_Show_Console][0] == '\0' ? OSD_PROTECTED : 0);
registerosdcommands();
if (g_networkMode != NET_DEDICATED_SERVER)
//if (g_networkMode != NET_DEDICATED_SERVER)
{
if (CONTROL_Startup(controltype_keyboardandmouse, &BGetTime, TICRATE))
{
@ -8100,7 +8101,7 @@ int app_main(int argc, char const * const * argv)
system_getcvars();
if (g_networkMode != NET_DEDICATED_SERVER)
//if (g_networkMode != NET_DEDICATED_SERVER)
{
if (videoSetGameMode(ud.setup.fullscreen, ud.setup.xdim, ud.setup.ydim, ud.setup.bpp, ud.detail) < 0)
{
@ -8154,7 +8155,7 @@ int app_main(int argc, char const * const * argv)
for (bssize_t i = MINIFONT + ('a'-'!'); minitext_lowercase && i < MINIFONT + ('z'-'!') + 1; ++i)
minitext_lowercase &= (int)tileLoad(i);
if (g_networkMode != NET_DEDICATED_SERVER)
//if (g_networkMode != NET_DEDICATED_SERVER)
{
Menu_Init();
}
@ -8195,7 +8196,7 @@ MAIN_LOOP_RESTART:
Menu_Change(MENU_MAIN);
if (g_networkMode != NET_DEDICATED_SERVER)
//if (g_networkMode != NET_DEDICATED_SERVER)
{
G_GetCrosshairColor();
G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
@ -8226,12 +8227,12 @@ MAIN_LOOP_RESTART:
G_NewGame_EnterLevel();
Net_WaitForServer();
Net_WaitForEverybody();
}
else if (g_networkMode != NET_DEDICATED_SERVER)
else// if (g_networkMode != NET_DEDICATED_SERVER)
G_DisplayLogo();
if (g_networkMode != NET_DEDICATED_SERVER)
//if (g_networkMode != NET_DEDICATED_SERVER)
{
if (G_PlaybackDemo())
{
@ -8312,17 +8313,18 @@ MAIN_LOOP_RESTART:
double const gameUpdateStartTime = timerGetHiTicks();
if (((g_netClient || g_netServer) || !(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO))) && totalclock >= ototalclock+TICSPERFRAME)
{
if (g_networkMode != NET_DEDICATED_SERVER)
{
if (RRRA && g_player[myconnectindex].ps->on_motorcycle)
P_GetInputMotorcycle(myconnectindex);
else if (RRRA && g_player[myconnectindex].ps->on_boat)
P_GetInputBoat(myconnectindex);
else
P_GetInput(myconnectindex);
}
Net_GetInput();
//if (g_networkMode != NET_DEDICATED_SERVER)
//{
// if (RRRA && g_player[myconnectindex].ps->on_motorcycle)
// P_GetInputMotorcycle(myconnectindex);
// else if (RRRA && g_player[myconnectindex].ps->on_boat)
// P_GetInputBoat(myconnectindex);
// else
// P_GetInput(myconnectindex);
//}
Bmemcpy(&inputfifo[0][myconnectindex], &localInput, sizeof(input_t));
//Bmemcpy(&inputfifo[0][myconnectindex], &localInput, sizeof(input_t));
S_Update();
@ -8378,11 +8380,11 @@ MAIN_LOOP_RESTART:
}
}
if (g_networkMode == NET_DEDICATED_SERVER)
/*if (g_networkMode == NET_DEDICATED_SERVER)
{
idle();
}
else if (G_FPSLimit() || g_saveRequested)
else */if (G_FPSLimit() || g_saveRequested)
{
int const smoothRatio
= ((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && !(g_player[myconnectindex].ps->gm & MODE_MENU))

View file

@ -1093,14 +1093,14 @@ static int32_t VM_ResetPlayer(int const playerNum, int32_t vmFlags)
CAMERACLOCK = (int32_t)totalclock;
}
if (g_fakeMultiMode)
//if (g_fakeMultiMode)
P_ResetPlayer(playerNum);
#ifndef NETCODE_DISABLE
if (g_netServer)
{
P_ResetPlayer(playerNum);
Net_SpawnPlayer(playerNum);
}
//if (g_netServer)
//{
// P_ResetPlayer(playerNum);
// Net_SpawnPlayer(playerNum);
//}
#endif
}

File diff suppressed because it is too large Load diff

View file

@ -56,60 +56,67 @@ extern int16_t g_netStatnums[];
enum netchan_t
{
CHAN_MOVE, // unreliable movement packets
CHAN_REROUTE,
CHAN_GAME,
//CHAN_MOVE, // unreliable movement packets
CHAN_GAMESTATE, // gamestate changes... frags, respawns, player names, etc
CHAN_CHAT, // chat and RTS
CHAN_MISC, // whatever else
//CHAN_MISC, // whatever else
CHAN_MAX
};
enum ServicePacket_t
{
SERVICEPACKET_TYPE_SENDTOID,
};
enum DukePacket_t
{
PACKET_TYPE_MASTER_TO_SLAVE,
PACKET_TYPE_SLAVE_TO_MASTER,
PACKET_TYPE_BROADCAST,
SERVER_GENERATED_BROADCAST,
PACKET_TYPE_VERSION,
//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_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_TYPE_FRAGLIMIT_CHANGED,
//PACKET_TYPE_EOL,
//PACKET_TYPE_QUIT = 255, // should match mmulti I think
PACKET_MASTER_TO_SLAVE,
PACKET_SLAVE_TO_MASTER,
//PACKET_MASTER_TO_SLAVE,
//PACKET_SLAVE_TO_MASTER,
PACKET_NUM_PLAYERS,
PACKET_PLAYER_INDEX,
PACKET_PLAYER_DISCONNECTED,
PACKET_PLAYER_SPAWN,
PACKET_FRAG,
//PACKET_PLAYER_SPAWN,
//PACKET_FRAG,
PACKET_ACK,
PACKET_AUTH,
PACKET_PLAYER_PING,
PACKET_PLAYER_READY,
PACKET_MAP_STREAM,
//PACKET_PLAYER_PING,
//PACKET_PLAYER_READY,
//PACKET_MAP_STREAM,
// any packet with an ID higher than PACKET_BROADCAST is rebroadcast by server
// so hacked clients can't create fake server packets and get the server to
@ -132,6 +139,7 @@ enum DukePacket_t
enum netdisconnect_t
{
DISC_BAD_PASSWORD = 1,
DISC_GAME_STARTED,
DISC_VERSION_MISMATCH,
DISC_INVALID,
DISC_SERVER_QUIT,
@ -144,8 +152,8 @@ enum netmode_t
{
NET_CLIENT = 0,
NET_SERVER,
NET_DEDICATED_CLIENT, // client on dedicated server
NET_DEDICATED_SERVER
//NET_DEDICATED_CLIENT, // client on dedicated server
//NET_DEDICATED_SERVER
};
#define MAXSYNCBYTES 16
@ -164,49 +172,6 @@ extern int g_numSyncBytes;
extern int g_foundSyncError;
extern int syncvaltail, syncvaltottail;
#define NETMAXACTORS 1024
#pragma pack(push,1)
typedef struct
{
uint32_t numActors;
netactor_t actor[NETMAXACTORS];
} netmapstate_t;
typedef struct
{
uint32_t numActors;
uint32_t numToDelete;
uint32_t fromRevision;
uint32_t toRevision;
char data[MAXSPRITES *sizeof(netactor_t)];
} netmapdiff_t;
extern netmapstate_t *g_multiMapState[MAXPLAYERS];
extern netmapstate_t *g_multiMapRevisions[NET_REVISIONS];
#pragma pack(pop)
#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)
#pragma pack(push,1)
typedef struct
{
@ -241,7 +206,7 @@ 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);
void Net_GetSyncInfoFromPacket(uint8_t* packbuf, int packbufleng, int* j, int otherconnectindex);
// Connect/Disconnect
@ -251,6 +216,7 @@ void Net_ReceiveDisconnect(ENetEvent *event);
// Packet Handlers
#endif
void Net_GetInput(void);
void Net_GetPackets(void);
#ifndef NETCODE_DISABLE
void Net_SendPacket(int32_t dest, uint8_t* pbuf, int32_t packbufleng);
@ -278,25 +244,25 @@ void Net_ReceiveClientInfo(uint8_t *pbuf, int32_t packbufleng, int32_t fromse
void Net_SendUserMapName(void);
void Net_ReceiveUserMapName(uint8_t *pbuf, int32_t packbufleng);
netmapstate_t *Net_GetRevision(uint8_t revision, uint8_t cancreate);
//netmapstate_t *Net_GetRevision(uint8_t revision, uint8_t cancreate);
void Net_SendMapUpdate(void);
void Net_ReceiveMapUpdate(ENetEvent *event);
//void Net_SendMapUpdate(void);
//void Net_ReceiveMapUpdate(ENetEvent *event);
void Net_FillMapDiff(uint32_t fromRevision, uint32_t toRevision);
void Net_SaveMapState(netmapstate_t *save);
void Net_RestoreMapState();
//void Net_FillMapDiff(uint32_t fromRevision, uint32_t toRevision);
//void Net_SaveMapState(netmapstate_t *save);
//void Net_RestoreMapState();
void Net_CopyToNet(int32_t i, netactor_t *netactor);
void Net_CopyFromNet(int32_t i, netactor_t *netactor);
int32_t Net_ActorsAreDifferent(netactor_t *actor1, netactor_t *actor2);
int32_t Net_IsRelevantSprite(int32_t i);
int32_t Net_IsRelevantStat(int32_t stat);
int32_t Net_InsertSprite(int32_t sect, int32_t stat);
void Net_DeleteSprite(int32_t spritenum);
//void Net_CopyToNet(int32_t i, netactor_t *netactor);
//void Net_CopyFromNet(int32_t i, netactor_t *netactor);
//int32_t Net_ActorsAreDifferent(netactor_t *actor1, netactor_t *actor2);
//int32_t Net_IsRelevantSprite(int32_t i);
//int32_t Net_IsRelevantStat(int32_t stat);
//int32_t Net_InsertSprite(int32_t sect, int32_t stat);
//void Net_DeleteSprite(int32_t spritenum);
void Net_FillPlayerUpdate(playerupdate_t *update, int32_t player);
void Net_ExtractPlayerUpdate(playerupdate_t *update, int32_t type);
//void Net_FillPlayerUpdate(playerupdate_t *update, int32_t player);
//void Net_ExtractPlayerUpdate(playerupdate_t *update, int32_t type);
void Net_SendServerUpdates(void);
void Net_ReceiveServerUpdate(ENetEvent *event);
@ -310,7 +276,7 @@ void Net_ReceiveMessage(uint8_t *pbuf, int32_t packbufleng);
void Net_StartNewGame();
void Net_NotifyNewGame();
void Net_SendNewGame(int32_t frommenu, ENetPeer *peer);
void Net_ReceiveNewGame(ENetEvent *event);
void Net_ReceiveNewGame(ENetEvent* event);
void Net_FillNewGame(newgame_t *newgame, int32_t frommenu);
void Net_ExtractNewGame(newgame_t *newgame, int32_t menuonly);
@ -334,6 +300,7 @@ void Net_SpawnPlayer(int32_t player);
void Net_SyncPlayer(ENetEvent *event);
void Net_WaitForEverybody(void);
void Net_Update(void);
void Net_PostPacket(ENetPacket *packet);
void faketimerhandler(void);
#else

View file

@ -1038,7 +1038,9 @@ static int osdcmd_inittimer(osdcmdptr_t parm)
static int osdcmd_disconnect(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
g_netDisconnect = 1;
// NUKE-TODO:
if (g_player[myconnectindex].ps->gm&MODE_MENU)
g_netDisconnect = 1;
return OSDCMD_OK;
}

View file

@ -4495,17 +4495,17 @@ void P_FragPlayer(int playerNum)
pPlayer->dead_flag++;
#ifndef NETCODE_DISABLE
if (g_netServer)
{
packbuf[0] = PACKET_FRAG;
packbuf[1] = playerNum;
packbuf[2] = pPlayer->frag_ps;
packbuf[3] = actor[pPlayer->i].picnum;
B_BUF32(&packbuf[4], ticrandomseed);
packbuf[8] = myconnectindex;
enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(packbuf, 9, ENET_PACKET_FLAG_RELIABLE));
}
//if (g_netServer)
//{
// packbuf[0] = PACKET_FRAG;
// packbuf[1] = playerNum;
// packbuf[2] = pPlayer->frag_ps;
// packbuf[3] = actor[pPlayer->i].picnum;
// B_BUF32(&packbuf[4], ticrandomseed);
// packbuf[8] = myconnectindex;
//
// enet_host_broadcast(g_netServer, CHAN_GAMESTATE, enet_packet_create(packbuf, 9, ENET_PACKET_FLAG_RELIABLE));
//}
#endif
}

View file

@ -2340,7 +2340,7 @@ int G_EnterLevel(int gameMode)
if ((gameMode & MODE_DEMO) == 0 && ud.recstat == 2)
ud.recstat = 0;
if (g_networkMode != NET_DEDICATED_SERVER)
//if (g_networkMode != NET_DEDICATED_SERVER)
{
S_PauseSounds(false);
FX_StopAllSounds();
@ -2599,7 +2599,7 @@ int G_EnterLevel(int gameMode)
G_DrawBackground();
G_DrawRooms(myconnectindex,65536);
Net_WaitForServer();
Net_WaitForEverybody();
return 0;
}

View file

@ -363,7 +363,7 @@ int32_t G_LoadPlayer(savebrief_t & sv)
videoNextPage();
}
Net_WaitForServer();
Net_WaitForEverybody();
FX_StopAllSounds();
S_ClearSoundLocks();
@ -519,7 +519,7 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
G_SaveTimers();
Net_WaitForServer();
Net_WaitForEverybody();
ready2send = 0;
char temp[BMAX_PATH];
@ -579,7 +579,7 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
}
ready2send = 1;
Net_WaitForServer();
Net_WaitForEverybody();
G_RestoreTimers();
ototalclock = totalclock;
@ -588,7 +588,7 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
saveproblem:
ready2send = 1;
Net_WaitForServer();
Net_WaitForEverybody();
G_RestoreTimers();
ototalclock = totalclock;
@ -1993,7 +1993,7 @@ static void postloadplayer(int32_t savegamep)
{
ready2send = 1;
G_ClearFIFO();
Net_WaitForServer();
Net_WaitForEverybody();
}
//8

View file

@ -202,8 +202,8 @@ static void G_ShowScores(void)
Bsprintf(tempbuf, "%-4d", g_player[i].frags[i] + g_player[i].ps->fraggedself);
minitext(200, SCORESHEETOFFSET+90+t, tempbuf, 2, 2+8+16+ROTATESPRITE_MAX);
Bsprintf(tempbuf, "%-4d", g_player[i].ping);
minitext(235, SCORESHEETOFFSET+90+t, tempbuf, 2, 2+8+16+ROTATESPRITE_MAX);
//Bsprintf(tempbuf, "%-4d", g_player[i].ping);
//minitext(235, SCORESHEETOFFSET+90+t, tempbuf, 2, 2+8+16+ROTATESPRITE_MAX);
t += 7;
}
@ -2229,8 +2229,8 @@ void G_BonusScreen(int32_t bonusonly)
int32_t clockpad = 2;
const char *lastmapname;
if (g_networkMode == NET_DEDICATED_SERVER)
return;
//if (g_networkMode == NET_DEDICATED_SERVER)
// return;
G_UpdateAppTitle();
@ -2811,8 +2811,8 @@ void G_BonusScreenRRRA(int32_t bonusonly)
int32_t showMap = 0;
const char *lastmapname;
if (g_networkMode == NET_DEDICATED_SERVER)
return;
//if (g_networkMode == NET_DEDICATED_SERVER)
// return;
G_UpdateAppTitle();