2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "build.h"
|
|
|
|
#include "mmulti.h"
|
|
|
|
#include "compat.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "common_game.h"
|
2020-08-16 07:46:37 +00:00
|
|
|
#include "g_input.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
#include "db.h"
|
|
|
|
#include "blood.h"
|
|
|
|
#include "choke.h"
|
|
|
|
#include "controls.h"
|
|
|
|
#include "dude.h"
|
|
|
|
#include "endgame.h"
|
|
|
|
#include "eventq.h"
|
|
|
|
#include "fx.h"
|
2020-01-02 11:01:18 +00:00
|
|
|
#include "gib.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
#include "globals.h"
|
|
|
|
#include "levels.h"
|
|
|
|
#include "loadsave.h"
|
|
|
|
#include "sectorfx.h"
|
|
|
|
#include "seq.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "triggers.h"
|
|
|
|
#include "view.h"
|
2020-07-25 22:07:59 +00:00
|
|
|
#include "misc.h"
|
2019-10-26 18:47:37 +00:00
|
|
|
#include "gameconfigfile.h"
|
2019-11-01 18:25:42 +00:00
|
|
|
#include "gamecontrol.h"
|
|
|
|
#include "m_argv.h"
|
2019-11-12 21:59:51 +00:00
|
|
|
#include "statistics.h"
|
2020-06-14 16:57:55 +00:00
|
|
|
#include "menu.h"
|
2020-04-12 06:09:38 +00:00
|
|
|
#include "raze_sound.h"
|
2020-02-07 19:47:43 +00:00
|
|
|
#include "nnexts.h"
|
2020-07-25 22:07:59 +00:00
|
|
|
#include "secrets.h"
|
2020-07-29 21:18:08 +00:00
|
|
|
#include "gamestate.h"
|
|
|
|
#include "screenjob.h"
|
2020-08-16 11:26:57 +00:00
|
|
|
#include "mapinfo.h"
|
2020-09-01 18:08:37 +00:00
|
|
|
#include "choke.h"
|
2020-09-01 21:34:04 +00:00
|
|
|
#include "d_net.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "map2d.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2020-08-03 18:51:31 +00:00
|
|
|
void InitCheats();
|
2019-09-22 06:39:22 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
bool bNoDemo = false;
|
2020-08-28 20:51:05 +00:00
|
|
|
bool gameRestart;
|
2019-09-19 22:42:45 +00:00
|
|
|
int gNetPlayers;
|
2020-08-27 22:03:35 +00:00
|
|
|
int gQuitRequest;
|
2019-09-19 22:42:45 +00:00
|
|
|
int gChokeCounter = 0;
|
2019-06-27 04:33:22 +00:00
|
|
|
bool gQuitGame;
|
2019-09-19 22:42:45 +00:00
|
|
|
int blood_globalflags;
|
2020-09-01 21:34:04 +00:00
|
|
|
PLAYER gPlayerTemp[kMaxPlayers];
|
|
|
|
int gHealthTemp[kMaxPlayers];
|
|
|
|
vec3_t startpos;
|
|
|
|
int16_t startang, startsectnum;
|
|
|
|
MapRecord* gStartNewGame = nullptr;
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
void QuitGame(void)
|
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
throw CExitEvent(0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EndLevel(void)
|
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
gViewPos = VIEWPOS_0;
|
|
|
|
sndKillAllSounds();
|
|
|
|
sfxKillAllSounds();
|
|
|
|
ambKillAll();
|
|
|
|
seqKillAll();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 21:34:04 +00:00
|
|
|
void StartLevel(MapRecord* level)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
if (!level) return;
|
2019-11-12 21:59:51 +00:00
|
|
|
STAT_Update(0);
|
2020-09-01 21:34:04 +00:00
|
|
|
EndLevel();
|
|
|
|
gInput = {};
|
|
|
|
gStartNewGame = nullptr;
|
|
|
|
currentLevel = level;
|
|
|
|
|
|
|
|
if (gGameOptions.nGameType == 0)
|
|
|
|
{
|
|
|
|
///////
|
|
|
|
gGameOptions.weaponsV10x = gWeaponsV10x;
|
|
|
|
///////
|
|
|
|
}
|
2020-08-16 11:26:57 +00:00
|
|
|
#if 0
|
2020-09-01 21:34:04 +00:00
|
|
|
else if (gGameOptions.nGameType > 0 && !(gGameOptions.uGameFlags & 1))
|
|
|
|
{
|
|
|
|
// todo
|
|
|
|
gBlueFlagDropped = false;
|
|
|
|
gRedFlagDropped = false;
|
|
|
|
}
|
2020-08-16 11:26:57 +00:00
|
|
|
#endif
|
2020-09-01 21:34:04 +00:00
|
|
|
if (gGameOptions.uGameFlags & 1)
|
|
|
|
{
|
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
|
|
|
memcpy(&gPlayerTemp[i], &gPlayer[i], sizeof(PLAYER));
|
|
|
|
gHealthTemp[i] = xsprite[gPlayer[i].pSprite->extra].health;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bVanilla = false;
|
|
|
|
memset(xsprite, 0, sizeof(xsprite));
|
|
|
|
memset(sprite, 0, kMaxSprites * sizeof(spritetype));
|
|
|
|
//drawLoadingScreen();
|
|
|
|
if (dbLoadMap(currentLevel->fileName, (int*)&startpos.x, (int*)&startpos.y, (int*)&startpos.z, &startang, &startsectnum, nullptr))
|
|
|
|
{
|
|
|
|
I_Error("%s: Unable to load map", level->DisplayName());
|
|
|
|
}
|
|
|
|
SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name);
|
2020-04-01 20:34:49 +00:00
|
|
|
STAT_NewLevel(currentLevel->fileName);
|
2020-09-01 21:34:04 +00:00
|
|
|
G_LoadMapHack(currentLevel->fileName);
|
|
|
|
wsrand(dbReadMapCRC(currentLevel->LabelName()));
|
|
|
|
gKillMgr.Clear();
|
|
|
|
gSecretMgr.Clear();
|
|
|
|
gLevelTime = 0;
|
|
|
|
automapping = 1;
|
|
|
|
|
|
|
|
int modernTypesErased = 0;
|
|
|
|
for (int i = 0; i < kMaxSprites; i++)
|
|
|
|
{
|
|
|
|
spritetype* pSprite = &sprite[i];
|
|
|
|
if (pSprite->statnum < kMaxStatus && pSprite->extra > 0) {
|
|
|
|
|
|
|
|
XSPRITE* pXSprite = &xsprite[pSprite->extra];
|
|
|
|
if ((pXSprite->lSkill & (1 << gGameOptions.nDifficulty)) || (pXSprite->lS && gGameOptions.nGameType == 0)
|
|
|
|
|| (pXSprite->lB && gGameOptions.nGameType == 2) || (pXSprite->lT && gGameOptions.nGameType == 3)
|
|
|
|
|| (pXSprite->lC && gGameOptions.nGameType == 1)) {
|
|
|
|
|
|
|
|
DeleteSprite(i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
if (!gModernMap && nnExtEraseModernStuff(pSprite, pXSprite))
|
|
|
|
modernTypesErased++;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
if (!gModernMap && modernTypesErased > 0)
|
|
|
|
Printf(PRINT_NONOTIFY, "> Modern types erased: %d.\n", modernTypesErased);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
startpos.z = getflorzofslope(startsectnum, startpos.x, startpos.y);
|
|
|
|
for (int i = 0; i < kMaxPlayers; i++) {
|
|
|
|
gStartZone[i].x = startpos.x;
|
|
|
|
gStartZone[i].y = startpos.y;
|
|
|
|
gStartZone[i].z = startpos.z;
|
|
|
|
gStartZone[i].sectnum = startsectnum;
|
|
|
|
gStartZone[i].ang = startang;
|
|
|
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
// Create spawn zones for players in teams mode.
|
|
|
|
if (gModernMap && i <= kMaxPlayers / 2) {
|
|
|
|
gStartZoneTeam1[i].x = startpos.x;
|
|
|
|
gStartZoneTeam1[i].y = startpos.y;
|
|
|
|
gStartZoneTeam1[i].z = startpos.z;
|
|
|
|
gStartZoneTeam1[i].sectnum = startsectnum;
|
|
|
|
gStartZoneTeam1[i].ang = startang;
|
|
|
|
|
|
|
|
gStartZoneTeam2[i].x = startpos.x;
|
|
|
|
gStartZoneTeam2[i].y = startpos.y;
|
|
|
|
gStartZoneTeam2[i].z = startpos.z;
|
|
|
|
gStartZoneTeam2[i].sectnum = startsectnum;
|
|
|
|
gStartZoneTeam2[i].ang = startang;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
InitSectorFX();
|
|
|
|
warpInit();
|
|
|
|
actInit(false);
|
|
|
|
evInit();
|
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
|
|
|
if (!(gGameOptions.uGameFlags & 1))
|
|
|
|
{
|
|
|
|
if (numplayers == 1)
|
|
|
|
{
|
|
|
|
gProfile[i].skill = gSkill;
|
|
|
|
}
|
|
|
|
playerInit(i, 0);
|
|
|
|
}
|
|
|
|
playerStart(i, 1);
|
|
|
|
}
|
|
|
|
if (gGameOptions.uGameFlags & 1)
|
|
|
|
{
|
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
|
|
|
PLAYER* pPlayer = &gPlayer[i];
|
|
|
|
pPlayer->pXSprite->health &= 0xf000;
|
|
|
|
pPlayer->pXSprite->health |= gHealthTemp[i];
|
|
|
|
pPlayer->weaponQav = gPlayerTemp[i].weaponQav;
|
|
|
|
pPlayer->curWeapon = gPlayerTemp[i].curWeapon;
|
|
|
|
pPlayer->weaponState = gPlayerTemp[i].weaponState;
|
|
|
|
pPlayer->weaponAmmo = gPlayerTemp[i].weaponAmmo;
|
|
|
|
pPlayer->qavCallback = gPlayerTemp[i].qavCallback;
|
|
|
|
pPlayer->qavLoop = gPlayerTemp[i].qavLoop;
|
|
|
|
pPlayer->weaponTimer = gPlayerTemp[i].weaponTimer;
|
|
|
|
pPlayer->nextWeapon = gPlayerTemp[i].nextWeapon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gGameOptions.uGameFlags &= ~3;
|
|
|
|
PreloadCache();
|
|
|
|
InitMirrors();
|
|
|
|
trInit();
|
|
|
|
if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
|
|
|
|
sfxSetReverb(0);
|
|
|
|
ambInit();
|
|
|
|
Net_ClearFifo();
|
|
|
|
gFrameCount = 0;
|
|
|
|
gChokeCounter = 0;
|
2020-07-27 22:01:16 +00:00
|
|
|
M_ClearMenus();
|
2020-09-01 21:34:04 +00:00
|
|
|
// viewSetMessage("");
|
|
|
|
viewSetErrorMessage("");
|
|
|
|
gameclock = 0;
|
|
|
|
paused = 0;
|
|
|
|
levelTryPlayMusic();
|
2020-09-01 18:08:37 +00:00
|
|
|
gFrameClock = 0;
|
|
|
|
gChoke.reset();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-09-24 02:14:59 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
bool gRestartGame = false;
|
|
|
|
|
2020-09-01 21:34:04 +00:00
|
|
|
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()
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
|
|
|
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();
|
2020-01-02 13:37:15 +00:00
|
|
|
#ifdef POLYMER
|
2020-09-01 21:34:04 +00:00
|
|
|
G_RefreshLights();
|
2020-01-02 13:37:15 +00:00
|
|
|
#endif
|
2020-09-01 21:34:04 +00:00
|
|
|
viewCorrectPrediction();
|
|
|
|
ambProcess();
|
|
|
|
viewUpdateDelirium();
|
|
|
|
viewUpdateShake();
|
|
|
|
gi->UpdateSounds();
|
|
|
|
if (gMe->hand == 1)
|
|
|
|
{
|
|
|
|
const int CHOKERATE = 8;
|
|
|
|
const int COUNTRATE = 30;
|
|
|
|
gChokeCounter += CHOKERATE;
|
|
|
|
while (gChokeCounter >= COUNTRATE)
|
|
|
|
{
|
|
|
|
gChoke.at1c(gMe);
|
|
|
|
gChokeCounter -= COUNTRATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
thinktime.Unclock();
|
|
|
|
|
|
|
|
gLevelTime++;
|
|
|
|
gFrameCount++;
|
|
|
|
gFrameClock += 4;
|
|
|
|
|
|
|
|
for (int i = 0; i < 8; i++)
|
2020-09-01 18:14:15 +00:00
|
|
|
{
|
|
|
|
dword_21EFD0[i] = dword_21EFD0[i] -= 4;
|
|
|
|
if (dword_21EFD0[i] < 0)
|
|
|
|
dword_21EFD0[i] = 0;
|
|
|
|
}
|
|
|
|
|
2020-09-01 21:34:04 +00:00
|
|
|
if ((gGameOptions.uGameFlags & 1) != 0 && !gStartNewGame)
|
|
|
|
{
|
|
|
|
seqKillAll();
|
|
|
|
if (gGameOptions.uGameFlags & 2)
|
|
|
|
{
|
|
|
|
STAT_Update(true);
|
|
|
|
if (gGameOptions.nGameType == 0)
|
|
|
|
{
|
|
|
|
auto completion = [](bool) {
|
2020-08-10 22:46:27 +00:00
|
|
|
gamestate = GS_MENUSCREEN;
|
2020-07-29 21:18:08 +00:00
|
|
|
M_StartControlPanel(false);
|
2020-09-01 21:34:04 +00:00
|
|
|
M_SetMenu(NAME_Mainmenu);
|
|
|
|
M_SetMenu(NAME_CreditsMenu);
|
2020-07-29 21:18:08 +00:00
|
|
|
gGameOptions.uGameFlags &= ~3;
|
|
|
|
gQuitGame = 1;
|
2020-09-01 21:34:04 +00:00
|
|
|
gRestartGame = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (gGameOptions.uGameFlags & 8)
|
2020-07-29 21:18:08 +00:00
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
levelPlayEndScene(volfromlevelnum(currentLevel->levelNumber), completion);
|
2020-07-29 21:18:08 +00:00
|
|
|
}
|
|
|
|
else completion(false);
|
2020-09-01 21:34:04 +00:00
|
|
|
}
|
2020-07-29 21:18:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gGameOptions.uGameFlags &= ~3;
|
|
|
|
gRestartGame = 1;
|
|
|
|
gQuitGame = 1;
|
|
|
|
}
|
2020-09-01 21:34:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ShowSummaryScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
commonTicker();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameInterface::DrawBackground()
|
|
|
|
{
|
|
|
|
twod->ClearScreen();
|
|
|
|
DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
|
|
|
|
commonTicker();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-10-28 21:19:50 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-01-22 20:09:45 +00:00
|
|
|
void ReadAllRFS();
|
|
|
|
|
2020-08-23 15:47:05 +00:00
|
|
|
void GameInterface::app_init()
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
InitCheats();
|
|
|
|
memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
|
|
|
|
gGameOptions.nMonsterSettings = !userConfig.nomonsters;
|
|
|
|
ReadAllRFS();
|
|
|
|
|
|
|
|
HookReplaceFunctions();
|
|
|
|
|
|
|
|
Printf(PRINT_NONOTIFY, "Initializing Build 3D engine\n");
|
|
|
|
engineInit();
|
|
|
|
|
|
|
|
Printf(PRINT_NONOTIFY, "Loading tiles\n");
|
|
|
|
if (!tileInit(0, NULL))
|
|
|
|
I_FatalError("TILES###.ART files not found");
|
|
|
|
|
|
|
|
levelLoadDefaults();
|
|
|
|
|
|
|
|
loaddefinitionsfile(BLOODWIDESCREENDEF);
|
|
|
|
|
|
|
|
const char* defsfile = G_DefFile();
|
|
|
|
uint32_t stime = I_msTime();
|
|
|
|
if (!loaddefinitionsfile(defsfile))
|
|
|
|
{
|
|
|
|
uint32_t etime = I_msTime();
|
|
|
|
Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %d ms.\n", defsfile, etime - stime);
|
|
|
|
}
|
2020-09-01 22:36:49 +00:00
|
|
|
TileFiles.SetBackup();
|
2020-09-01 21:34:04 +00:00
|
|
|
powerupInit();
|
|
|
|
Printf(PRINT_NONOTIFY, "Loading cosine table\n");
|
|
|
|
trigInit();
|
|
|
|
Printf(PRINT_NONOTIFY, "Initializing view subsystem\n");
|
|
|
|
viewInit();
|
|
|
|
Printf(PRINT_NONOTIFY, "Initializing dynamic fire\n");
|
|
|
|
FireInit();
|
|
|
|
Printf(PRINT_NONOTIFY, "Initializing weapon animations\n");
|
|
|
|
WeaponInit();
|
|
|
|
LoadSaveSetup();
|
|
|
|
|
|
|
|
myconnectindex = connecthead = 0;
|
|
|
|
gNetPlayers = numplayers = 1;
|
|
|
|
connectpoint2[0] = -1;
|
|
|
|
gGameOptions.nGameType = 0;
|
|
|
|
UpdateNetworkMenus();
|
|
|
|
|
|
|
|
Printf(PRINT_NONOTIFY, "Initializing sound system\n");
|
|
|
|
sndInit();
|
|
|
|
registerosdcommands();
|
|
|
|
|
|
|
|
gChoke.init(518, sub_84230);
|
|
|
|
UpdateDacs(0, true);
|
|
|
|
|
|
|
|
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;//bVanilla;
|
2020-07-29 21:18:08 +00:00
|
|
|
}
|
2020-01-23 10:50:12 +00:00
|
|
|
|
2020-07-29 21:18:08 +00:00
|
|
|
static void gameInit()
|
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
//RESTART:
|
|
|
|
gViewIndex = myconnectindex;
|
|
|
|
gMe = gView = &gPlayer[myconnectindex];
|
|
|
|
|
|
|
|
PROFILE* pProfile = &gProfile[myconnectindex];
|
|
|
|
strcpy(pProfile->name, playername);
|
|
|
|
pProfile->skill = gSkill;
|
2020-09-01 17:49:05 +00:00
|
|
|
|
2020-07-29 21:18:08 +00:00
|
|
|
UpdateNetworkMenus();
|
2020-09-01 21:34:04 +00:00
|
|
|
gQuitGame = 0;
|
|
|
|
gRestartGame = 0;
|
|
|
|
if (gGameOptions.nGameType > 0)
|
|
|
|
{
|
|
|
|
inputState.ClearAllInput();
|
|
|
|
}
|
2020-07-29 21:18:08 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-01-29 13:19:05 +00:00
|
|
|
|
2020-09-01 21:34:04 +00:00
|
|
|
void GameInterface::Startup()
|
2020-07-29 21:18:08 +00:00
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
gameInit();
|
|
|
|
if (userConfig.CommandMap.IsNotEmpty())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!userConfig.nologo && gGameOptions.nGameType == 0) playlogos();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gamestate = GS_MENUSCREEN;
|
|
|
|
M_StartControlPanel(false);
|
|
|
|
M_SetMenu(NAME_Mainmenu);
|
|
|
|
}
|
|
|
|
}
|
2020-07-29 21:18:08 +00:00
|
|
|
}
|
2020-01-30 13:05:34 +00:00
|
|
|
|
2020-09-01 21:34:04 +00:00
|
|
|
|
|
|
|
static void nonsharedkeys(void)
|
2020-07-29 21:18:08 +00:00
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
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;
|
|
|
|
}
|
2020-07-29 21:18:08 +00:00
|
|
|
}
|
|
|
|
|
2020-09-01 21:34:04 +00:00
|
|
|
void GameInterface::Render()
|
2020-07-29 21:18:08 +00:00
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
nonsharedkeys();
|
|
|
|
drawtime.Reset();
|
|
|
|
drawtime.Clock();
|
|
|
|
viewDrawScreen();
|
|
|
|
drawtime.Unclock();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-06-28 12:45:39 +00:00
|
|
|
|
|
|
|
void sndPlaySpecialMusicOrNothing(int nMusic)
|
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
if (!Mus_Play(nullptr, quoteMgr.GetQuote(nMusic), true))
|
|
|
|
{
|
|
|
|
Mus_Stop();
|
|
|
|
}
|
2019-06-28 12:45:39 +00:00
|
|
|
}
|
2019-09-21 20:53:00 +00:00
|
|
|
|
2019-12-24 18:47:34 +00:00
|
|
|
extern IniFile* BloodINI;
|
|
|
|
void GameInterface::FreeGameData()
|
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
if (BloodINI) delete BloodINI;
|
2019-12-24 18:47:34 +00:00
|
|
|
}
|
|
|
|
|
2020-08-16 00:55:50 +00:00
|
|
|
ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize)
|
2020-01-01 08:49:06 +00:00
|
|
|
{
|
2020-09-01 21:34:04 +00:00
|
|
|
int top = 0;
|
|
|
|
if (gGameOptions.nGameType > 0 && gGameOptions.nGameType <= 3)
|
|
|
|
{
|
|
|
|
top = (tilesiz[2229].y * ((gNetPlayers + 3) / 4));
|
|
|
|
}
|
|
|
|
return { top, 25 };
|
2020-01-01 08:49:06 +00:00
|
|
|
}
|
|
|
|
|
2019-11-03 11:32:58 +00:00
|
|
|
::GameInterface* CreateInterface()
|
|
|
|
{
|
|
|
|
return new GameInterface;
|
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
END_BLD_NS
|