- 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,202 +60,193 @@ 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)
{ {
throw CExitEvent(0); throw CExitEvent(0);
} }
void EndLevel(void) void EndLevel(void)
{ {
gViewPos = VIEWPOS_0; gViewPos = VIEWPOS_0;
sndKillAllSounds(); sndKillAllSounds();
sfxKillAllSounds(); sfxKillAllSounds();
ambKillAll(); ambKillAll();
seqKillAll(); seqKillAll();
} }
void StartLevel(MapRecord* level)
PLAYER gPlayerTemp[kMaxPlayers];
int gHealthTemp[kMaxPlayers];
vec3_t startpos;
int16_t startang, startsectnum;
void StartLevel(MapRecord *level)
{ {
if (!level) return; if (!level) return;
STAT_Update(0); STAT_Update(0);
EndLevel(); EndLevel();
gInput = {}; gInput = {};
gStartNewGame = nullptr; gStartNewGame = nullptr;
currentLevel = level; currentLevel = level;
if (gGameOptions.nGameType == 0) if (gGameOptions.nGameType == 0)
{ {
/////// ///////
gGameOptions.weaponsV10x = gWeaponsV10x; gGameOptions.weaponsV10x = gWeaponsV10x;
/////// ///////
} }
#if 0 #if 0
else if (gGameOptions.nGameType > 0 && !(gGameOptions.uGameFlags&1)) else if (gGameOptions.nGameType > 0 && !(gGameOptions.uGameFlags & 1))
{ {
// todo // todo
gBlueFlagDropped = false; gBlueFlagDropped = false;
gRedFlagDropped = false; gRedFlagDropped = false;
} }
#endif #endif
if (gGameOptions.uGameFlags&1) if (gGameOptions.uGameFlags & 1)
{ {
for (int i = connecthead; i >= 0; i = connectpoint2[i]) for (int i = connecthead; i >= 0; i = connectpoint2[i])
{ {
memcpy(&gPlayerTemp[i],&gPlayer[i],sizeof(PLAYER)); memcpy(&gPlayerTemp[i], &gPlayer[i], sizeof(PLAYER));
gHealthTemp[i] = xsprite[gPlayer[i].pSprite->extra].health; gHealthTemp[i] = xsprite[gPlayer[i].pSprite->extra].health;
} }
} }
bVanilla = false; bVanilla = false;
memset(xsprite,0,sizeof(xsprite)); memset(xsprite, 0, sizeof(xsprite));
memset(sprite,0,kMaxSprites*sizeof(spritetype)); memset(sprite, 0, kMaxSprites * sizeof(spritetype));
//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);
G_LoadMapHack(currentLevel->fileName); G_LoadMapHack(currentLevel->fileName);
wsrand(dbReadMapCRC(currentLevel->LabelName())); wsrand(dbReadMapCRC(currentLevel->LabelName()));
gKillMgr.Clear(); gKillMgr.Clear();
gSecretMgr.Clear(); gSecretMgr.Clear();
gLevelTime = 0; gLevelTime = 0;
automapping = 1; automapping = 1;
int modernTypesErased = 0; int modernTypesErased = 0;
for (int i = 0; i < kMaxSprites; i++) for (int i = 0; i < kMaxSprites; i++)
{ {
spritetype *pSprite = &sprite[i]; spritetype* pSprite = &sprite[i];
if (pSprite->statnum < kMaxStatus && pSprite->extra > 0) { if (pSprite->statnum < kMaxStatus && pSprite->extra > 0) {
XSPRITE *pXSprite = &xsprite[pSprite->extra]; XSPRITE* pXSprite = &xsprite[pSprite->extra];
if ((pXSprite->lSkill & (1 << gGameOptions.nDifficulty)) || (pXSprite->lS && gGameOptions.nGameType == 0) if ((pXSprite->lSkill & (1 << gGameOptions.nDifficulty)) || (pXSprite->lS && gGameOptions.nGameType == 0)
|| (pXSprite->lB && gGameOptions.nGameType == 2) || (pXSprite->lT && gGameOptions.nGameType == 3) || (pXSprite->lB && gGameOptions.nGameType == 2) || (pXSprite->lT && gGameOptions.nGameType == 3)
|| (pXSprite->lC && gGameOptions.nGameType == 1)) { || (pXSprite->lC && gGameOptions.nGameType == 1)) {
DeleteSprite(i); DeleteSprite(i);
continue; continue;
} }
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
if (!gModernMap && nnExtEraseModernStuff(pSprite, pXSprite)) if (!gModernMap && nnExtEraseModernStuff(pSprite, pXSprite))
modernTypesErased++; modernTypesErased++;
#endif #endif
} }
} }
#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
startpos.z = getflorzofslope(startsectnum,startpos.x,startpos.y); startpos.z = getflorzofslope(startsectnum, startpos.x, startpos.y);
for (int i = 0; i < kMaxPlayers; i++) { for (int i = 0; i < kMaxPlayers; i++) {
gStartZone[i].x = startpos.x; gStartZone[i].x = startpos.x;
gStartZone[i].y = startpos.y; gStartZone[i].y = startpos.y;
gStartZone[i].z = startpos.z; gStartZone[i].z = startpos.z;
gStartZone[i].sectnum = startsectnum; gStartZone[i].sectnum = startsectnum;
gStartZone[i].ang = startang; gStartZone[i].ang = startang;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
// Create spawn zones for players in teams mode. // Create spawn zones for players in teams mode.
if (gModernMap && i <= kMaxPlayers / 2) { if (gModernMap && i <= kMaxPlayers / 2) {
gStartZoneTeam1[i].x = startpos.x; gStartZoneTeam1[i].x = startpos.x;
gStartZoneTeam1[i].y = startpos.y; gStartZoneTeam1[i].y = startpos.y;
gStartZoneTeam1[i].z = startpos.z; gStartZoneTeam1[i].z = startpos.z;
gStartZoneTeam1[i].sectnum = startsectnum; gStartZoneTeam1[i].sectnum = startsectnum;
gStartZoneTeam1[i].ang = startang; gStartZoneTeam1[i].ang = startang;
gStartZoneTeam2[i].x = startpos.x; gStartZoneTeam2[i].x = startpos.x;
gStartZoneTeam2[i].y = startpos.y; gStartZoneTeam2[i].y = startpos.y;
gStartZoneTeam2[i].z = startpos.z; gStartZoneTeam2[i].z = startpos.z;
gStartZoneTeam2[i].sectnum = startsectnum; gStartZoneTeam2[i].sectnum = startsectnum;
gStartZoneTeam2[i].ang = startang; gStartZoneTeam2[i].ang = startang;
} }
#endif #endif
} }
InitSectorFX(); InitSectorFX();
warpInit(); warpInit();
actInit(false); actInit(false);
evInit(); evInit();
for (int i = connecthead; i >= 0; i = connectpoint2[i]) for (int i = connecthead; i >= 0; i = connectpoint2[i])
{ {
if (!(gGameOptions.uGameFlags&1)) if (!(gGameOptions.uGameFlags & 1))
{ {
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); playerStart(i, 1);
} }
playerStart(i, 1); if (gGameOptions.uGameFlags & 1)
} {
if (gGameOptions.uGameFlags&1) for (int i = connecthead; i >= 0; i = connectpoint2[i])
{ {
for (int i = connecthead; i >= 0; i = connectpoint2[i]) PLAYER* pPlayer = &gPlayer[i];
{ pPlayer->pXSprite->health &= 0xf000;
PLAYER *pPlayer = &gPlayer[i]; pPlayer->pXSprite->health |= gHealthTemp[i];
pPlayer->pXSprite->health &= 0xf000; pPlayer->weaponQav = gPlayerTemp[i].weaponQav;
pPlayer->pXSprite->health |= gHealthTemp[i]; pPlayer->curWeapon = gPlayerTemp[i].curWeapon;
pPlayer->weaponQav = gPlayerTemp[i].weaponQav; pPlayer->weaponState = gPlayerTemp[i].weaponState;
pPlayer->curWeapon = gPlayerTemp[i].curWeapon; pPlayer->weaponAmmo = gPlayerTemp[i].weaponAmmo;
pPlayer->weaponState = gPlayerTemp[i].weaponState; pPlayer->qavCallback = gPlayerTemp[i].qavCallback;
pPlayer->weaponAmmo = gPlayerTemp[i].weaponAmmo; pPlayer->qavLoop = gPlayerTemp[i].qavLoop;
pPlayer->qavCallback = gPlayerTemp[i].qavCallback; pPlayer->weaponTimer = gPlayerTemp[i].weaponTimer;
pPlayer->qavLoop = gPlayerTemp[i].qavLoop; pPlayer->nextWeapon = gPlayerTemp[i].nextWeapon;
pPlayer->weaponTimer = gPlayerTemp[i].weaponTimer; }
pPlayer->nextWeapon = gPlayerTemp[i].nextWeapon; }
} gGameOptions.uGameFlags &= ~3;
} PreloadCache();
gGameOptions.uGameFlags &= ~3; InitMirrors();
PreloadCache(); trInit();
InitMirrors(); if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
trInit(); sfxSetReverb(0);
if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect ambInit();
sfxSetReverb(0); Net_ClearFifo();
ambInit(); gFrameCount = 0;
netReset(); gChokeCounter = 0;
gFrameCount = 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;
gChoke.reset(); gChoke.reset();
} }
@ -264,121 +254,181 @@ void StartLevel(MapRecord *level)
bool gRestartGame = false; bool gRestartGame = false;
void ProcessFrame(void) static void commonTicker()
{ {
for (int i = connecthead; i >= 0; i = connectpoint2[i]) if (TestBitString(gotpic, 2342))
{ {
auto& inp = gPlayer[i].input; FireProcess();
auto oldactions = inp.actions; ClearBitString(gotpic, 2342);
}
if (gStartNewGame)
{
auto sng = gStartNewGame;
gStartNewGame = nullptr;
gQuitGame = false;
auto completion = [=](bool = false)
{
StartLevel(sng);
inp = gFifoInput[gNetFifoTail & 255][i]; gamestate = GS_LEVEL;
inp.actions |= oldactions & ~(SB_BUTTON_MASK|SB_RUN|SB_WEAPONMASK_BITS); // should be everything non-button and non-weapon };
int newweap = inp.getNewWeapon(); bool startedCutscene = false;
if (newweap > 0 && newweap < WeaponSel_MaxBlood) gPlayer[i].newWeapon = newweap; if (!(sng->flags & MI_USERMAP))
} {
gNetFifoTail++; int episode = volfromlevelnum(sng->levelNumber);
int level = mapfromlevelnum(sng->levelNumber);
if (gEpisodeInfo[episode].cutALevel == level && gEpisodeInfo[episode].cutsceneAName[0])
{
levelPlayIntroScene(episode, completion);
startedCutscene = true;
}
// This is single player only. }
if (gameRestart) if (!startedCutscene) completion(false);
{ }
gameRestart = false; else if (gRestartGame)
levelRestart(); {
return; Mus_Stop();
} soundEngine->StopAllChannels();
viewClearInterpolations(); gQuitGame = 0;
{ gQuitRequest = 0;
if (paused || (gGameOptions.nGameType == 0 && M_Active())) gRestartGame = 0;
return;
}
thinktime.Reset(); // Don't switch to startup if we're already outside the game.
thinktime.Clock(); if (gamestate == GS_LEVEL)
{
gamestate = GS_MENUSCREEN;
M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu);
}
}
}
actortime.Reset();
actortime.Clock();
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
viewBackupView(i);
playerProcess(&gPlayer[i]);
}
actortime.Unclock();
trProcessBusy();
evProcess(gFrameClock); void GameInterface::Ticker()
seqProcess(4); {
DoSectorPanning(); for (int i = connecthead; i >= 0; i = connectpoint2[i])
actProcessSprites(); {
actPostProcess(); auto& inp = gPlayer[i].input;
auto oldactions = inp.actions;
inp = playercmds[i].ucmd;
inp.actions |= oldactions & ~(SB_BUTTON_MASK | SB_RUN | SB_WEAPONMASK_BITS); // should be everything non-button and non-weapon
int newweap = inp.getNewWeapon();
if (newweap > 0 && newweap < WeaponSel_MaxBlood) gPlayer[i].newWeapon = newweap;
}
// This is single player only.
if (gameRestart)
{
gameRestart = false;
levelRestart();
return;
}
viewClearInterpolations();
{
if (paused || (gGameOptions.nGameType == 0 && M_Active()))
return;
}
thinktime.Reset();
thinktime.Clock();
actortime.Reset();
actortime.Clock();
for (int i = connecthead; i >= 0; i = connectpoint2[i])
{
viewBackupView(i);
playerProcess(&gPlayer[i]);
}
actortime.Unclock();
trProcessBusy();
evProcess(gFrameClock);
seqProcess(4);
DoSectorPanning();
actProcessSprites();
actPostProcess();
#ifdef POLYMER #ifdef POLYMER
G_RefreshLights(); G_RefreshLights();
#endif #endif
viewCorrectPrediction(); viewCorrectPrediction();
ambProcess(); ambProcess();
viewUpdateDelirium(); viewUpdateDelirium();
viewUpdateShake(); viewUpdateShake();
gi->UpdateSounds(); gi->UpdateSounds();
if (gMe->hand == 1) if (gMe->hand == 1)
{ {
const int CHOKERATE = 8; const int CHOKERATE = 8;
const int COUNTRATE = 30; const int COUNTRATE = 30;
gChokeCounter += CHOKERATE; gChokeCounter += CHOKERATE;
while (gChokeCounter >= COUNTRATE) while (gChokeCounter >= COUNTRATE)
{ {
gChoke.at1c(gMe); gChoke.at1c(gMe);
gChokeCounter -= COUNTRATE; gChokeCounter -= COUNTRATE;
} }
} }
thinktime.Unclock(); thinktime.Unclock();
gLevelTime++; gLevelTime++;
gFrameCount++; gFrameCount++;
gFrameClock += 4; gFrameClock += 4;
for(int i=0;i<8;i++) for (int i = 0; i < 8; i++)
{ {
dword_21EFD0[i] = dword_21EFD0[i] -= 4; dword_21EFD0[i] = dword_21EFD0[i] -= 4;
if (dword_21EFD0[i] < 0) if (dword_21EFD0[i] < 0)
dword_21EFD0[i] = 0; dword_21EFD0[i] = 0;
} }
if ((gGameOptions.uGameFlags&1) != 0 && !gStartNewGame) if ((gGameOptions.uGameFlags & 1) != 0 && !gStartNewGame)
{ {
seqKillAll(); seqKillAll();
if (gGameOptions.uGameFlags&2) if (gGameOptions.uGameFlags & 2)
{ {
STAT_Update(true); STAT_Update(true);
if (gGameOptions.nGameType == 0) if (gGameOptions.nGameType == 0)
{ {
auto completion = [] (bool) { auto completion = [](bool) {
gamestate = GS_MENUSCREEN; gamestate = GS_MENUSCREEN;
M_StartControlPanel(false); M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu); M_SetMenu(NAME_Mainmenu);
M_SetMenu(NAME_CreditsMenu); M_SetMenu(NAME_CreditsMenu);
gGameOptions.uGameFlags &= ~3; gGameOptions.uGameFlags &= ~3;
gQuitGame = 1; gQuitGame = 1;
gRestartGame = true; gRestartGame = true;
}; };
if (gGameOptions.uGameFlags&8) if (gGameOptions.uGameFlags & 8)
{ {
levelPlayEndScene(volfromlevelnum(currentLevel->levelNumber), completion); levelPlayEndScene(volfromlevelnum(currentLevel->levelNumber), completion);
} }
else completion(false); else completion(false);
} }
else else
{ {
gGameOptions.uGameFlags &= ~3; gGameOptions.uGameFlags &= ~3;
gRestartGame = 1; gRestartGame = 1;
gQuitGame = 1; gQuitGame = 1;
} }
} }
else else
{ {
ShowSummaryScreen(); ShowSummaryScreen();
} }
} }
commonTicker();
}
void GameInterface::DrawBackground()
{
twod->ClearScreen();
DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
commonTicker();
} }
@ -387,242 +437,162 @@ void ReadAllRFS();
void GameInterface::app_init() void GameInterface::app_init()
{ {
InitCheats(); InitCheats();
memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS)); memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
gGameOptions.nMonsterSettings = !userConfig.nomonsters; gGameOptions.nMonsterSettings = !userConfig.nomonsters;
ReadAllRFS(); ReadAllRFS();
HookReplaceFunctions(); HookReplaceFunctions();
Printf(PRINT_NONOTIFY, "Initializing Build 3D engine\n"); Printf(PRINT_NONOTIFY, "Initializing Build 3D engine\n");
engineInit(); engineInit();
Printf(PRINT_NONOTIFY, "Loading tiles\n"); Printf(PRINT_NONOTIFY, "Loading tiles\n");
if (!tileInit(0, NULL)) if (!tileInit(0, NULL))
I_FatalError("TILES###.ART files not found"); I_FatalError("TILES###.ART files not found");
levelLoadDefaults(); levelLoadDefaults();
loaddefinitionsfile(BLOODWIDESCREENDEF); loaddefinitionsfile(BLOODWIDESCREENDEF);
const char* defsfile = G_DefFile(); const char* defsfile = G_DefFile();
uint32_t stime = I_msTime(); uint32_t stime = I_msTime();
if (!loaddefinitionsfile(defsfile)) if (!loaddefinitionsfile(defsfile))
{ {
uint32_t etime = I_msTime(); uint32_t etime = I_msTime();
Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %d ms.\n", defsfile, etime - stime); Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %d ms.\n", defsfile, etime - stime);
} }
powerupInit(); powerupInit();
Printf(PRINT_NONOTIFY, "Loading cosine table\n"); Printf(PRINT_NONOTIFY, "Loading cosine table\n");
trigInit(); trigInit();
Printf(PRINT_NONOTIFY, "Initializing view subsystem\n"); Printf(PRINT_NONOTIFY, "Initializing view subsystem\n");
viewInit(); viewInit();
Printf(PRINT_NONOTIFY, "Initializing dynamic fire\n"); Printf(PRINT_NONOTIFY, "Initializing dynamic fire\n");
FireInit(); FireInit();
Printf(PRINT_NONOTIFY, "Initializing weapon animations\n"); Printf(PRINT_NONOTIFY, "Initializing weapon animations\n");
WeaponInit(); WeaponInit();
LoadSaveSetup(); LoadSaveSetup();
Printf(PRINT_NONOTIFY, "Initializing network users\n"); myconnectindex = connecthead = 0;
netInitialize(true); gNetPlayers = numplayers = 1;
Printf(PRINT_NONOTIFY, "Initializing sound system\n"); connectpoint2[0] = -1;
sndInit(); gGameOptions.nGameType = 0;
registerosdcommands(); UpdateNetworkMenus();
gChoke.init(518, sub_84230); Printf(PRINT_NONOTIFY, "Initializing sound system\n");
UpdateDacs(0, true); sndInit();
registerosdcommands();
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;//bVanilla; gChoke.init(518, sub_84230);
UpdateDacs(0, true);
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;//bVanilla;
} }
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;
gRestartGame = 0; gRestartGame = 0;
if (gGameOptions.nGameType > 0) if (gGameOptions.nGameType > 0)
{ {
inputState.ClearAllInput(); inputState.ClearAllInput();
} }
} }
static void gameTicker()
void GameInterface::Startup()
{ {
bool gameUpdate = false; gameInit();
double const gameUpdateStartTime = I_msTimeF(); if (userConfig.CommandMap.IsNotEmpty())
while (gPredictTail < gNetFifoHead[myconnectindex] && !paused) {
{ }
viewUpdatePrediction(&gFifoInput[gPredictTail & 255][myconnectindex]); else
} {
if (!userConfig.nologo && gGameOptions.nGameType == 0) playlogos();
int gBufferJitter = 0; else
{
int const currentTic = I_GetTime(); gamestate = GS_MENUSCREEN;
gameclock = I_GetBuildTime(); M_StartControlPanel(false);
M_SetMenu(NAME_Mainmenu);
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()
static void nonsharedkeys(void)
{ {
twod->ClearScreen(); static int nonsharedtimer;
DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE); 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;
}
} }
static void commonTicker() void GameInterface::Render()
{ {
if (TestBitString(gotpic, 2342)) nonsharedkeys();
{ drawtime.Reset();
FireProcess(); drawtime.Clock();
ClearBitString(gotpic, 2342); viewDrawScreen();
} drawtime.Unclock();
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();
if (userConfig.CommandMap.IsNotEmpty())
{
}
else
{
if (!userConfig.nologo && gGameOptions.nGameType == 0) playlogos();
else
{
gamestate = GS_MENUSCREEN;
M_StartControlPanel(false);
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;
}
} }
void sndPlaySpecialMusicOrNothing(int nMusic) void sndPlaySpecialMusicOrNothing(int nMusic)
{ {
if (!Mus_Play(nullptr, quoteMgr.GetQuote(nMusic), true)) if (!Mus_Play(nullptr, quoteMgr.GetQuote(nMusic), true))
{ {
Mus_Stop(); Mus_Stop();
} }
} }
extern IniFile* BloodINI; extern IniFile* BloodINI;
void GameInterface::FreeGameData() void GameInterface::FreeGameData()
{ {
if (BloodINI) delete BloodINI; if (BloodINI) delete BloodINI;
} }
ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize) ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize)
{ {
int top = 0; int top = 0;
if (gGameOptions.nGameType > 0 && gGameOptions.nGameType <= 3) if (gGameOptions.nGameType > 0 && gGameOptions.nGameType <= 3)
{ {
top = (tilesiz[2229].y * ((gNetPlayers + 3) / 4)); top = (tilesiz[2229].y * ((gNetPlayers + 3) / 4));
} }
return { top, 25 }; return { top, 25 };
} }
::GameInterface* CreateInterface() ::GameInterface* CreateInterface()

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,8 +531,10 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
Mus_ResumeSaved(); Mus_ResumeSaved();
netBroadcastPlayerInfo(myconnectindex); PROFILE* pProfile = &gProfile[myconnectindex];
return true; strcpy(pProfile->name, playername);
pProfile->skill = gSkill;
return true;
} }
bool GameInterface::SaveGame(FSaveGameNode* node) bool GameInterface::SaveGame(FSaveGameNode* node)

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;
listener.angle = -(float)gMe->pSprite->ang * pi::pi() / 1024; // Build uses a period of 2048. if (gMe->pSprite)
listener.velocity.Zero(); {
listener.position = GetSoundPos(&gMe->pSprite->pos); listener.angle = -(float)gMe->pSprite->ang * pi::pi() / 1024; // Build uses a period of 2048.
listener.velocity.Zero();
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"