- transitioned Blood to the new main loop.

Mostly working but interpolation is not correct yet and for some strange reason the numbers on the HUD are gone.
This commit is contained in:
Christoph Oelckers 2020-09-01 23:34:04 +02:00
parent 35b14753e7
commit 8d63e735d0
22 changed files with 477 additions and 662 deletions

View file

@ -49,7 +49,6 @@ set( PCH_SOURCES
src/messages.cpp src/messages.cpp
src/mirrors.cpp src/mirrors.cpp
src/misc.cpp src/misc.cpp
src/network.cpp
src/nnexts.cpp src/nnexts.cpp
src/osdcmd.cpp src/osdcmd.cpp
src/player.cpp src/player.cpp

View file

@ -42,7 +42,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "globals.h" #include "globals.h"
#include "levels.h" #include "levels.h"
#include "loadsave.h" #include "loadsave.h"
#include "network.h"
#include "sectorfx.h" #include "sectorfx.h"
#include "seq.h" #include "seq.h"
#include "sound.h" #include "sound.h"
@ -61,26 +60,27 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "screenjob.h" #include "screenjob.h"
#include "mapinfo.h" #include "mapinfo.h"
#include "choke.h" #include "choke.h"
#include "d_net.h"
#include "v_video.h"
#include "map2d.h"
BEGIN_BLD_NS BEGIN_BLD_NS
void InitCheats(); void InitCheats();
bool bNoDemo = false; bool bNoDemo = false;
char gUserMapFilename[BMAX_PATH];
short BloodVersion = 0x115;
bool gameRestart; bool gameRestart;
int gNetPlayers; int gNetPlayers;
int gQuitRequest; int gQuitRequest;
int gChokeCounter = 0; int gChokeCounter = 0;
bool gQuitGame; bool gQuitGame;
int blood_globalflags; int blood_globalflags;
PLAYER gPlayerTemp[kMaxPlayers];
int gHealthTemp[kMaxPlayers];
vec3_t startpos;
int16_t startang, startsectnum;
MapRecord* gStartNewGame = nullptr;
void QuitGame(void) void QuitGame(void)
{ {
@ -97,13 +97,6 @@ void EndLevel(void)
seqKillAll(); seqKillAll();
} }
PLAYER gPlayerTemp[kMaxPlayers];
int gHealthTemp[kMaxPlayers];
vec3_t startpos;
int16_t startang, startsectnum;
void StartLevel(MapRecord* level) void StartLevel(MapRecord* level)
{ {
if (!level) return; if (!level) return;
@ -141,7 +134,7 @@ void StartLevel(MapRecord *level)
//drawLoadingScreen(); //drawLoadingScreen();
if (dbLoadMap(currentLevel->fileName, (int*)&startpos.x, (int*)&startpos.y, (int*)&startpos.z, &startang, &startsectnum, nullptr)) if (dbLoadMap(currentLevel->fileName, (int*)&startpos.x, (int*)&startpos.y, (int*)&startpos.z, &startang, &startsectnum, nullptr))
{ {
I_Error("Unable to load map"); I_Error("%s: Unable to load map", level->DisplayName());
} }
SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name); SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name);
STAT_NewLevel(currentLevel->fileName); STAT_NewLevel(currentLevel->fileName);
@ -176,7 +169,7 @@ void StartLevel(MapRecord *level)
} }
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
if (!gModernMap) if (!gModernMap && modernTypesErased > 0)
Printf(PRINT_NONOTIFY, "> Modern types erased: %d.\n", modernTypesErased); Printf(PRINT_NONOTIFY, "> Modern types erased: %d.\n", modernTypesErased);
#endif #endif
@ -216,8 +209,6 @@ void StartLevel(MapRecord *level)
if (numplayers == 1) if (numplayers == 1)
{ {
gProfile[i].skill = gSkill; gProfile[i].skill = gSkill;
gProfile[i].nAutoAim = cl_autoaim;
gProfile[i].nWeaponSwitch = cl_weaponswitch;
} }
playerInit(i, 0); playerInit(i, 0);
} }
@ -247,14 +238,13 @@ void StartLevel(MapRecord *level)
if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
sfxSetReverb(0); sfxSetReverb(0);
ambInit(); ambInit();
netReset(); Net_ClearFifo();
gFrameCount = 0; gFrameCount = 0;
gChokeCounter = 0; gChokeCounter = 0;
M_ClearMenus(); M_ClearMenus();
// viewSetMessage(""); // viewSetMessage("");
viewSetErrorMessage(""); viewSetErrorMessage("");
gameclock = 0; gameclock = 0;
lastTic = -1;
paused = 0; paused = 0;
levelTryPlayMusic(); levelTryPlayMusic();
gFrameClock = 0; gFrameClock = 0;
@ -264,20 +254,72 @@ void StartLevel(MapRecord *level)
bool gRestartGame = false; bool gRestartGame = false;
void ProcessFrame(void) static void commonTicker()
{
if (TestBitString(gotpic, 2342))
{
FireProcess();
ClearBitString(gotpic, 2342);
}
if (gStartNewGame)
{
auto sng = gStartNewGame;
gStartNewGame = nullptr;
gQuitGame = false;
auto completion = [=](bool = false)
{
StartLevel(sng);
gamestate = GS_LEVEL;
};
bool startedCutscene = false;
if (!(sng->flags & MI_USERMAP))
{
int episode = volfromlevelnum(sng->levelNumber);
int level = mapfromlevelnum(sng->levelNumber);
if (gEpisodeInfo[episode].cutALevel == level && gEpisodeInfo[episode].cutsceneAName[0])
{
levelPlayIntroScene(episode, completion);
startedCutscene = true;
}
}
if (!startedCutscene) completion(false);
}
else if (gRestartGame)
{
Mus_Stop();
soundEngine->StopAllChannels();
gQuitGame = 0;
gQuitRequest = 0;
gRestartGame = 0;
// Don't switch to startup if we're already outside the game.
if (gamestate == GS_LEVEL)
{
gamestate = GS_MENUSCREEN;
M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu);
}
}
}
void GameInterface::Ticker()
{ {
for (int i = connecthead; i >= 0; i = connectpoint2[i]) for (int i = connecthead; i >= 0; i = connectpoint2[i])
{ {
auto& inp = gPlayer[i].input; auto& inp = gPlayer[i].input;
auto oldactions = inp.actions; auto oldactions = inp.actions;
inp = gFifoInput[gNetFifoTail & 255][i]; inp = playercmds[i].ucmd;
inp.actions |= oldactions & ~(SB_BUTTON_MASK | SB_RUN | SB_WEAPONMASK_BITS); // should be everything non-button and non-weapon inp.actions |= oldactions & ~(SB_BUTTON_MASK | SB_RUN | SB_WEAPONMASK_BITS); // should be everything non-button and non-weapon
int newweap = inp.getNewWeapon(); int newweap = inp.getNewWeapon();
if (newweap > 0 && newweap < WeaponSel_MaxBlood) gPlayer[i].newWeapon = newweap; if (newweap > 0 && newweap < WeaponSel_MaxBlood) gPlayer[i].newWeapon = newweap;
} }
gNetFifoTail++;
// This is single player only. // This is single player only.
if (gameRestart) if (gameRestart)
@ -379,6 +421,14 @@ void ProcessFrame(void)
ShowSummaryScreen(); ShowSummaryScreen();
} }
} }
commonTicker();
}
void GameInterface::DrawBackground()
{
twod->ClearScreen();
DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
commonTicker();
} }
@ -423,8 +473,12 @@ void GameInterface::app_init()
WeaponInit(); WeaponInit();
LoadSaveSetup(); LoadSaveSetup();
Printf(PRINT_NONOTIFY, "Initializing network users\n"); myconnectindex = connecthead = 0;
netInitialize(true); gNetPlayers = numplayers = 1;
connectpoint2[0] = -1;
gGameOptions.nGameType = 0;
UpdateNetworkMenus();
Printf(PRINT_NONOTIFY, "Initializing sound system\n"); Printf(PRINT_NONOTIFY, "Initializing sound system\n");
sndInit(); sndInit();
registerosdcommands(); registerosdcommands();
@ -438,10 +492,12 @@ void GameInterface::app_init()
static void gameInit() static void gameInit()
{ {
//RESTART: //RESTART:
netReset();
gViewIndex = myconnectindex; gViewIndex = myconnectindex;
gMe = gView = &gPlayer[myconnectindex]; gMe = gView = &gPlayer[myconnectindex];
netBroadcastPlayerInfo(myconnectindex);
PROFILE* pProfile = &gProfile[myconnectindex];
strcpy(pProfile->name, playername);
pProfile->skill = gSkill;
UpdateNetworkMenus(); UpdateNetworkMenus();
gQuitGame = 0; gQuitGame = 0;
@ -453,121 +509,9 @@ static void gameInit()
} }
static void gameTicker()
{
bool gameUpdate = false;
double const gameUpdateStartTime = I_msTimeF();
while (gPredictTail < gNetFifoHead[myconnectindex] && !paused)
{
viewUpdatePrediction(&gFifoInput[gPredictTail & 255][myconnectindex]);
}
int gBufferJitter = 0; void GameInterface::Startup()
int const currentTic = I_GetTime();
gameclock = I_GetBuildTime();
gameupdatetime.Reset();
gameupdatetime.Clock();
while (currentTic - lastTic >= 1)
{ {
gNetInput = gInput;
gInput = {};
netGetInput();
lastTic = currentTic;
while (gNetFifoHead[myconnectindex] - gNetFifoTail > gBufferJitter && !gStartNewGame && !gQuitGame)
{
int i;
for (i = connecthead; i >= 0; i = connectpoint2[i])
if (gNetFifoHead[i] == gNetFifoTail)
break;
if (i >= 0)
break;
ProcessFrame();
gameUpdate = true;
}
}
gameupdatetime.Unclock();
if (gQuitRequest && gQuitGame)
videoClearScreen(0);
else
{
drawtime.Reset();
drawtime.Clock();
viewDrawScreen();
drawtime.Unclock();
}
}
static void drawBackground()
{
twod->ClearScreen();
DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
}
static void commonTicker()
{
if (TestBitString(gotpic, 2342))
{
FireProcess();
ClearBitString(gotpic, 2342);
}
if (gStartNewGame)
{
auto sng = gStartNewGame;
gStartNewGame = nullptr;
gQuitGame = false;
auto completion = [=](bool = false)
{
StartLevel(sng);
gamestate = GS_LEVEL;
};
bool startedCutscene = false;
if (!(sng->flags & MI_USERMAP))
{
int episode = volfromlevelnum(sng->levelNumber);
int level = mapfromlevelnum(sng->levelNumber);
if (gEpisodeInfo[episode].cutALevel == level && gEpisodeInfo[episode].cutsceneAName[0])
{
levelPlayIntroScene(episode, completion);
startedCutscene = true;
}
}
if (!startedCutscene) completion(false);
}
else if (gRestartGame)
{
Mus_Stop();
soundEngine->StopAllChannels();
gQuitGame = 0;
gQuitRequest = 0;
gRestartGame = 0;
// Don't switch to startup if we're already outside the game.
if (gamestate == GS_LEVEL)
{
gamestate = GS_MENUSCREEN;
M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu);
}
}
}
void GameInterface::RunGameFrame()
{
commonTicker();
ctrlGetInput();
switch (gamestate)
{
default:
case GS_STARTUP:
gameInit(); gameInit();
if (userConfig.CommandMap.IsNotEmpty()) if (userConfig.CommandMap.IsNotEmpty())
{ {
@ -582,22 +526,48 @@ void GameInterface::RunGameFrame()
M_SetMenu(NAME_Mainmenu); M_SetMenu(NAME_Mainmenu);
} }
} }
break;
case GS_MENUSCREEN:
case GS_FULLCONSOLE:
drawBackground();
break;
case GS_INTRO:
case GS_INTERMISSION:
RunScreenJobFrame(); // This handles continuation through its completion callback.
break;
case GS_LEVEL:
gameTicker();
break;
} }
static void nonsharedkeys(void)
{
static int nonsharedtimer;
int ms = screen->FrameTime;
int interval;
if (nonsharedtimer > 0 || ms < nonsharedtimer)
{
interval = ms - nonsharedtimer;
}
else
{
interval = 0;
}
nonsharedtimer = screen->FrameTime;
if (System_WantGuiCapture())
return;
if (automapMode != am_off)
{
double j = interval * (120. / 1000);
if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
gZoom += (int)fmulscale6(j, max(gZoom, 256));
if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
gZoom -= (int)fmulscale6(j, max(gZoom, 256));
gZoom = clamp(gZoom, 48, 2048);
gViewMap.nZoom = gZoom;
}
}
void GameInterface::Render()
{
nonsharedkeys();
drawtime.Reset();
drawtime.Clock();
viewDrawScreen();
drawtime.Unclock();
} }

View file

@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "db.h" #include "db.h"
#include "mapinfo.h" #include "mapinfo.h"
#include "gamestruct.h" #include "gamestruct.h"
#include "mapinfo.h"
BEGIN_BLD_NS BEGIN_BLD_NS
@ -45,8 +46,8 @@ struct INICHAIN {
extern INICHAIN *pINIChain; extern INICHAIN *pINIChain;
extern MapRecord* gStartNewGame;
extern short BloodVersion;
extern int gNetPlayers; extern int gNetPlayers;
extern bool gRestartGame; extern bool gRestartGame;
extern int blood_globalflags; extern int blood_globalflags;
@ -77,7 +78,6 @@ struct GameInterface : ::GameInterface
{ {
const char* Name() override { return "Blood"; } const char* Name() override { return "Blood"; }
void app_init() override; void app_init() override;
void RunGameFrame() override;
bool GenerateSavePic() override; bool GenerateSavePic() override;
void FreeGameData() override; void FreeGameData() override;
FSavegameInfo GetSaveSig() override; FSavegameInfo GetSaveSig() override;
@ -94,6 +94,11 @@ struct GameInterface : ::GameInterface
FString GetCoordString() override; FString GetCoordString() override;
ReservedSpace GetReservedScreenSpace(int viewsize) override; ReservedSpace GetReservedScreenSpace(int viewsize) override;
void UpdateSounds() override; void UpdateSounds() override;
void GetInput(InputPacket* gInput) override;
void Ticker() override;
void DrawBackground() override;
void Startup() override;
void Render() override;
GameStats getStats() override; GameStats getStats() override;
}; };

View file

@ -26,7 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "common.h" #include "common.h"
#include "pragmas.h" #include "pragmas.h"
#include "misc.h" #include "misc.h"
#include "network.h"
#include "printf.h" #include "printf.h"
#include "v_text.h" #include "v_text.h"

View file

@ -39,7 +39,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
InputPacket gInput, gNetInput; InputPacket gInput;
bool bSilentAim = false; bool bSilentAim = false;
int iTurnCount = 0; int iTurnCount = 0;
@ -51,7 +51,7 @@ float gViewAngleAdjust;
float gViewLookAdjust; float gViewLookAdjust;
int gViewLookRecenter; int gViewLookRecenter;
void ctrlGetInput(void) void GetInputInternal(InputPacket &inputParm)
{ {
int prevPauseState = paused; int prevPauseState = paused;
ControlInfo info; ControlInfo info;
@ -64,60 +64,26 @@ void ctrlGetInput(void)
auto scaleAdjustmentToInterval = [=](double x) { return x * kTicsPerSec / (1000.0 / elapsedInputTicks); }; auto scaleAdjustmentToInterval = [=](double x) { return x * kTicsPerSec / (1000.0 / elapsedInputTicks); };
if (gamestate != GS_LEVEL || System_WantGuiCapture())
{
gInput = {};
CONTROL_GetInput(&info);
return;
}
if (paused)
return;
InputPacket input = {}; InputPacket input = {};
if (numplayers == 1)
{
gProfile[myconnectindex].nAutoAim = cl_autoaim;
gProfile[myconnectindex].nWeaponSwitch = cl_weaponswitch;
}
CONTROL_GetInput(&info); CONTROL_GetInput(&info);
ApplyGlobalInput(gInput, &info); ApplyGlobalInput(inputParm, &info);
bool mouseaim = !(gInput.actions & SB_AIMMODE); bool mouseaim = !(inputParm.actions & SB_AIMMODE);
if (!mouseaim) gInput.actions |= SB_CENTERVIEW; if (!mouseaim) inputParm.actions |= SB_CENTERVIEW;
if (buttonMap.ButtonDown(gamefunc_Shrink_Screen))
{
if (automapMode != am_off)
{
gZoom = ClipLow(gZoom - (gZoom >> 4), 64);
gViewMap.nZoom = gZoom;
}
}
if (buttonMap.ButtonDown(gamefunc_Enlarge_Screen))
{
if (automapMode != am_off)
{
gZoom = ClipHigh(gZoom + (gZoom >> 4), 4096);
gViewMap.nZoom = gZoom;
}
}
if (gPlayer[myconnectindex].nextWeapon == 0) if (gPlayer[myconnectindex].nextWeapon == 0)
{ {
} }
if (gInput.actions & (SB_LOOK_UP|SB_LOOK_DOWN)) if (inputParm.actions & (SB_LOOK_UP|SB_LOOK_DOWN))
gInput.actions |= SB_CENTERVIEW; inputParm.actions |= SB_CENTERVIEW;
int const run = !!(gInput.actions & SB_RUN); int const run = !!(inputParm.actions & SB_RUN);
int const keyMove = (1 + run) << 10; int const keyMove = (1 + run) << 10;
if (gInput.fvel < keyMove && gInput.fvel > -keyMove) if (inputParm.fvel < keyMove && inputParm.fvel > -keyMove)
{ {
if (buttonMap.ButtonDown(gamefunc_Move_Forward)) if (buttonMap.ButtonDown(gamefunc_Move_Forward))
input.fvel += keyMove; input.fvel += keyMove;
@ -126,7 +92,7 @@ void ctrlGetInput(void)
input.fvel -= keyMove; input.fvel -= keyMove;
} }
if (gInput.svel < keyMove && gInput.svel > -keyMove) if (inputParm.svel < keyMove && inputParm.svel > -keyMove)
{ {
if (buttonMap.ButtonDown(gamefunc_Strafe_Left)) if (buttonMap.ButtonDown(gamefunc_Strafe_Left))
input.svel += keyMove; input.svel += keyMove;
@ -139,7 +105,7 @@ void ctrlGetInput(void)
if (buttonMap.ButtonDown(gamefunc_Strafe)) if (buttonMap.ButtonDown(gamefunc_Strafe))
{ {
if (gInput.svel < keyMove && gInput.svel > -keyMove) if (inputParm.svel < keyMove && inputParm.svel > -keyMove)
{ {
if (buttonMap.ButtonDown(gamefunc_Turn_Left)) if (buttonMap.ButtonDown(gamefunc_Turn_Left))
input.svel += keyMove; input.svel += keyMove;
@ -210,11 +176,11 @@ void ctrlGetInput(void)
input.fvel = 0; input.fvel = 0;
input.svel = 0; input.svel = 0;
} }
gInput.fvel = clamp(gInput.fvel + input.fvel, -2048, 2048); inputParm.fvel = clamp(inputParm.fvel + input.fvel, -2048, 2048);
gInput.svel = clamp(gInput.svel + input.svel, -2048, 2048); inputParm.svel = clamp(inputParm.svel + input.svel, -2048, 2048);
gInput.q16avel += input.q16avel; inputParm.q16avel += input.q16avel;
gInput.q16horz = clamp(gInput.q16horz + input.q16horz, IntToFixed(-127)>>2, IntToFixed(127)>>2); inputParm.q16horz = clamp(inputParm.q16horz + input.q16horz, IntToFixed(-127)>>2, IntToFixed(127)>>2);
if (gMe && gMe->pXSprite->health != 0 && !paused) if (gMe && gMe->pXSprite && gMe->pXSprite->health != 0 && !paused)
{ {
int upAngle = 289; int upAngle = 289;
int downAngle = -347; int downAngle = -347;
@ -236,4 +202,14 @@ void ctrlGetInput(void)
} }
} }
void GameInterface::GetInput(InputPacket* packet)
{
GetInputInternal(gInput);
if (packet)
{
*packet = gInput;
gInput = {};
}
}
END_BLD_NS END_BLD_NS

View file

@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
extern InputPacket gInput, gNetInput; extern InputPacket gInput;
extern bool bSilentAim; extern bool bSilentAim;
extern fixed_t gViewLook, gViewAngle; extern fixed_t gViewLook, gViewAngle;

View file

@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "globals.h" #include "globals.h"
#include "levels.h" #include "levels.h"
#include "loadsave.h" #include "loadsave.h"
#include "network.h"
#include "player.h" #include "player.h"
#include "sound.h" #include "sound.h"
#include "view.h" #include "view.h"

View file

@ -34,7 +34,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "levels.h" #include "levels.h"
#include "loadsave.h" #include "loadsave.h"
#include "messages.h" #include "messages.h"
#include "network.h"
#include "seq.h" #include "seq.h"
#include "sound.h" #include "sound.h"
#include "view.h" #include "view.h"

View file

@ -32,7 +32,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "globals.h" #include "globals.h"
#include "db.h" #include "db.h"
#include "messages.h" #include "messages.h"
#include "network.h"
#include "loadsave.h" #include "loadsave.h"
#include "sectorfx.h" #include "sectorfx.h"
#include "seq.h" #include "seq.h"
@ -44,6 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "raze_music.h" #include "raze_music.h"
#include "mapinfo.h" #include "mapinfo.h"
#include "gamestate.h" #include "gamestate.h"
#include "d_net.h"
#include "aistate.h" #include "aistate.h"
#include "aiunicult.h" #include "aiunicult.h"
@ -501,15 +501,11 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
sfxSetReverb(0); sfxSetReverb(0);
ambInit(); ambInit();
gNetFifoTail = 0;
memset(gNetFifoHead, 0, sizeof(gNetFifoHead));
gPredictTail = 0;
memset(gFifoInput, 0, sizeof(gFifoInput));
for (int i = 0; i < gNetPlayers; i++) for (int i = 0; i < gNetPlayers; i++)
playerSetRace(&gPlayer[i], gPlayer[i].lifeMode); playerSetRace(&gPlayer[i], gPlayer[i].lifeMode);
viewSetErrorMessage(""); viewSetErrorMessage("");
gFrameCount = 0; gFrameCount = 0;
lastTic = -1; Net_ClearFifo();
paused = 0; paused = 0;
gamestate = GS_LEVEL; gamestate = GS_LEVEL;
bVanilla = false; bVanilla = false;
@ -535,7 +531,9 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
Mus_ResumeSaved(); Mus_ResumeSaved();
netBroadcastPlayerInfo(myconnectindex); PROFILE* pProfile = &gProfile[myconnectindex];
strcpy(pProfile->name, playername);
pProfile->skill = gSkill;
return true; return true;
} }

View file

@ -189,8 +189,8 @@ void CViewMap::sub_25C74(void)
} }
// only clear the actual window. // only clear the actual window.
twod->AddColorOnlyQuad(windowxy1.x, windowxy1.y, (windowxy2.x + 1) - windowxy1.x, (windowxy2.y + 1) - windowxy1.y, 0xff000000); twod->AddColorOnlyQuad(windowxy1.x, windowxy1.y, (windowxy2.x + 1) - windowxy1.x, (windowxy2.y + 1) - windowxy1.y, 0xff000000);
renderDrawMapView(x,y,nZoom>>2,angle); renderDrawMapView(x,y,nZoom>>1,angle);
sub_2541C(x,y,nZoom>>2,angle); sub_2541C(x,y,nZoom>>1,angle);
if (tm) if (tm)
setViewport(hud_size); setViewport(hud_size);
} }

View file

@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "levels.h" #include "levels.h"
#include "loadsave.h" #include "loadsave.h"
#include "messages.h" #include "messages.h"
#include "network.h"
#include "player.h" #include "player.h"
#include "view.h" #include "view.h"
#include "gstrings.h" #include "gstrings.h"

View file

@ -1,90 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
This file is part of NBlood.
NBlood is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#include "ns.h" // Must come before everything else!
#include "build.h"
#include "mmulti.h"
#include "pragmas.h"
#include "compat.h"
#include "controls.h"
#include "globals.h"
#include "network.h"
#include "player.h"
#include "seq.h"
#include "sound.h"
#include "view.h"
#include "menu.h"
#include "gamestate.h"
BEGIN_BLD_NS
MapRecord *gStartNewGame = 0;
int gNetFifoTail = 0;
int gNetFifoHead[8];
int gPredictTail = 0;
InputPacket gFifoInput[256][8];
void netResetToSinglePlayer(void)
{
myconnectindex = connecthead = 0;
gNetPlayers = numplayers = 1;
connectpoint2[0] = -1;
gGameOptions.nGameType = 0;
UpdateNetworkMenus();
}
void netReset(void)
{
lastTic = -1;
gPredictTail = 0;
gNetFifoTail = 0;
memset(gNetFifoHead, 0, sizeof(gNetFifoHead));
}
void netBroadcastPlayerInfo(int nPlayer)
{
PROFILE *pProfile = &gProfile[nPlayer];
strcpy(pProfile->name, playername);
pProfile->skill = gSkill;
pProfile->nAutoAim = cl_autoaim;
pProfile->nWeaponSwitch = cl_weaponswitch;
}
void netGetInput(void)
{
for (int p = connecthead; p >= 0; p = connectpoint2[p])
if (gNetFifoHead[myconnectindex]-200 > gNetFifoHead[p])
return;
InputPacket &input = gFifoInput[gNetFifoHead[myconnectindex]&255][myconnectindex];
input = gNetInput;
gNetFifoHead[myconnectindex]++;
}
void netInitialize(bool bConsole)
{
netReset();
netResetToSinglePlayer();
}
END_BLD_NS

View file

@ -1,43 +0,0 @@
//-------------------------------------------------------------------------
/*
Copyright (C) 2010-2019 EDuke32 developers and contributors
Copyright (C) 2019 Nuke.YKT
This file is part of NBlood.
NBlood is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//-------------------------------------------------------------------------
#pragma once
#include "compat.h"
#include "build.h"
#include "controls.h"
#include "mapinfo.h"
BEGIN_BLD_NS
extern MapRecord *gStartNewGame;
extern int gNetFifoTail;
extern int gNetFifoHead[8];
extern int gPredictTail;
extern InputPacket gFifoInput[256][8];
void netReset(void);
void netResetToSinglePlayer(void);
void netInitialize(bool bConsole);
void netBroadcastPlayerInfo(int nPlayer);
void netGetInput(void);
END_BLD_NS

View file

@ -31,7 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "globals.h" #include "globals.h"
#include "levels.h" #include "levels.h"
#include "messages.h" #include "messages.h"
#include "network.h"
#include "sound.h" #include "sound.h"
#include "view.h" #include "view.h"
#include "mapinfo.h" #include "mapinfo.h"

View file

@ -38,7 +38,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "levels.h" #include "levels.h"
#include "loadsave.h" #include "loadsave.h"
#include "map2d.h" #include "map2d.h"
#include "network.h"
#include "player.h" #include "player.h"
#include "seq.h" #include "seq.h"
#include "sound.h" #include "sound.h"

View file

@ -190,8 +190,6 @@ struct PLAYER
struct PROFILE struct PROFILE
{ {
int nAutoAim;
int nWeaponSwitch;
int skill; int skill;
char name[MAXPLAYERNAME]; char name[MAXPLAYERNAME];
}; };

View file

@ -109,8 +109,8 @@ void viewUpdatePrediction(InputPacket *pInput)
fakePlayerProcess(gMe, pInput); fakePlayerProcess(gMe, pInput);
fakeActProcessSprites(); fakeActProcessSprites();
gMe->pSprite->cstat = bakCstat; gMe->pSprite->cstat = bakCstat;
predictFifo[gPredictTail&255] = predict; //predictFifo[gPredictTail&255] = predict;
gPredictTail++; //gPredictTail++;
if (numplayers != 1) if (numplayers != 1)
{ {
gViewAngle = predict.at30; gViewAngle = predict.at30;
@ -706,6 +706,7 @@ void fakeActProcessSprites(void)
void viewCorrectPrediction(void) void viewCorrectPrediction(void)
{ {
#if 0
if (numplayers == 1) if (numplayers == 1)
{ {
gViewLook = gMe->q16look; gViewLook = gMe->q16look;
@ -724,6 +725,7 @@ void viewCorrectPrediction(void)
viewUpdatePrediction(&gFifoInput[gPredictTail&255][myconnectindex]); viewUpdatePrediction(&gFifoInput[gPredictTail&255][myconnectindex]);
} }
} }
#endif
} }
END_BLD_NS END_BLD_NS

View file

@ -125,15 +125,23 @@ void GameInterface::UpdateSounds()
{ {
SoundListener listener; SoundListener listener;
if (gMe->pSprite)
{
listener.angle = -(float)gMe->pSprite->ang * pi::pi() / 1024; // Build uses a period of 2048. listener.angle = -(float)gMe->pSprite->ang * pi::pi() / 1024; // Build uses a period of 2048.
listener.velocity.Zero(); listener.velocity.Zero();
listener.position = GetSoundPos(&gMe->pSprite->pos); listener.position = GetSoundPos(&gMe->pSprite->pos);
listener.valid = true;
}
else
{
listener.position.Zero();
listener.valid = false;
}
listener.underwater = false; listener.underwater = false;
// This should probably use a real environment instead of the pitch hacking in S_PlaySound3D. // This should probably use a real environment instead of the pitch hacking in S_PlaySound3D.
// listenactor->waterlevel == 3; // listenactor->waterlevel == 3;
//assert(primaryLevel->Zones.Size() > listenactor->Sector->ZoneNumber); //assert(primaryLevel->Zones.Size() > listenactor->Sector->ZoneNumber);
listener.Environment = 0;// primaryLevel->Zones[listenactor->Sector->ZoneNumber].Environment; listener.Environment = 0;// primaryLevel->Zones[listenactor->Sector->ZoneNumber].Environment;
listener.valid = true;
listener.ListenerObject = gMe->pSprite; listener.ListenerObject = gMe->pSprite;
soundEngine->SetListener(listener); soundEngine->SetListener(listener);

View file

@ -321,7 +321,7 @@ void UpdateAimVector(PLAYER * pPlayer)
WEAPONTRACK *pWeaponTrack = &gWeaponTrack[pPlayer->curWeapon]; WEAPONTRACK *pWeaponTrack = &gWeaponTrack[pPlayer->curWeapon];
int nTarget = -1; int nTarget = -1;
pPlayer->aimTargetsCount = 0; pPlayer->aimTargetsCount = 0;
if (gProfile[pPlayer->nPlayer].nAutoAim == 1 || (gProfile[pPlayer->nPlayer].nAutoAim == 2 && !pWeaponTrack->bIsProjectile) || pPlayer->curWeapon == 10 || pPlayer->curWeapon == 9) if (cl_autoaim == 1 || (cl_autoaim == 2 && !pWeaponTrack->bIsProjectile) || pPlayer->curWeapon == 10 || pPlayer->curWeapon == 9)
{ {
int nClosest = 0x7fffffff; int nClosest = 0x7fffffff;
for (nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite]) for (nSprite = headspritestat[kStatDude]; nSprite >= 0; nSprite = nextspritestat[nSprite])
@ -1679,7 +1679,7 @@ char gWeaponUpgrade[][13] = {
char WeaponUpgrade(PLAYER *pPlayer, char newWeapon) char WeaponUpgrade(PLAYER *pPlayer, char newWeapon)
{ {
char weapon = pPlayer->curWeapon; char weapon = pPlayer->curWeapon;
if (!sub_4B1A4(pPlayer) && (gProfile[pPlayer->nPlayer].nWeaponSwitch&1) && (gWeaponUpgrade[pPlayer->curWeapon][newWeapon] || (gProfile[pPlayer->nPlayer].nWeaponSwitch&2))) if (!sub_4B1A4(pPlayer) && (cl_weaponswitch&1) && (gWeaponUpgrade[pPlayer->curWeapon][newWeapon] || (cl_weaponswitch&2)))
weapon = newWeapon; weapon = newWeapon;
return weapon; return weapon;
} }

View file

@ -866,7 +866,7 @@ int RunGame()
videoInit(); videoInit();
// Duke has transitioned to the new main loop, the other games haven't yet. // Duke has transitioned to the new main loop, the other games haven't yet.
if (g_gameType & (GAMEFLAG_DUKE | GAMEFLAG_RRALL | GAMEFLAG_NAM | GAMEFLAG_NAPALM | GAMEFLAG_WW2GI)) if (!(g_gameType & (GAMEFLAG_SW | GAMEFLAG_PSEXHUMED)))
{ {
D_CheckNetGame(); D_CheckNetGame();
MainLoop(); MainLoop();

View file

@ -29,7 +29,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
#include "game.h" #include "game.h"
#include "sounds.h" #include "sounds.h"
#include "v_draw.h" #include "v_draw.h"
#include "network.h"
#include "menus.h" #include "menus.h"
#include "gamecontrol.h" #include "gamecontrol.h"
#include "mapinfo.h" #include "mapinfo.h"

View file

@ -37,7 +37,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "keydef.h" #include "keydef.h"
#include "gamecontrol.h" #include "gamecontrol.h"
#include "network.h"
#include "misc.h" #include "misc.h"
#include "version.h" #include "version.h"
#include "network.h" #include "network.h"