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"
|
2019-12-29 16:04:38 +00:00
|
|
|
#include "baselayer.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
#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 "network.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"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2020-08-03 17:08:49 +00:00
|
|
|
void LocalKeys(void);
|
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;
|
|
|
|
|
|
|
|
char gUserMapFilename[BMAX_PATH];
|
|
|
|
|
|
|
|
short BloodVersion = 0x115;
|
|
|
|
|
|
|
|
int gNetPlayers;
|
2020-08-27 22:03:35 +00:00
|
|
|
int gQuitRequest;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
int gChokeCounter = 0;
|
|
|
|
|
|
|
|
double g_gameUpdateTime, g_gameUpdateAndDrawTime;
|
|
|
|
double g_gameUpdateAvgTime = 0.001;
|
|
|
|
|
2019-06-27 04:33:22 +00:00
|
|
|
bool gQuitGame;
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
enum gametokens
|
|
|
|
{
|
|
|
|
T_INCLUDE = 0,
|
|
|
|
T_INTERFACE = 0,
|
|
|
|
T_LOADGRP = 1,
|
|
|
|
T_MODE = 1,
|
|
|
|
T_CACHESIZE = 2,
|
|
|
|
T_ALLOW = 2,
|
|
|
|
T_NOAUTOLOAD,
|
|
|
|
T_INCLUDEDEFAULT,
|
|
|
|
T_SOUND,
|
|
|
|
T_FILE,
|
|
|
|
//T_CUTSCENE,
|
|
|
|
//T_ANIMSOUNDS,
|
|
|
|
//T_NOFLOORPALRANGE,
|
|
|
|
T_ID,
|
|
|
|
T_MINPITCH,
|
|
|
|
T_MAXPITCH,
|
|
|
|
T_PRIORITY,
|
|
|
|
T_TYPE,
|
|
|
|
T_DISTANCE,
|
|
|
|
T_VOLUME,
|
|
|
|
T_DELAY,
|
|
|
|
T_RENAMEFILE,
|
|
|
|
T_GLOBALGAMEFLAGS,
|
|
|
|
T_ASPECT,
|
|
|
|
T_FORCEFILTER,
|
|
|
|
T_FORCENOFILTER,
|
|
|
|
T_TEXTUREFILTER,
|
|
|
|
T_RFFDEFINEID,
|
2019-08-09 13:33:45 +00:00
|
|
|
T_TILEFROMTEXTURE,
|
2019-12-29 19:20:58 +00:00
|
|
|
T_IFCRC, T_IFMATCH, T_CRC32,
|
|
|
|
T_SIZE,
|
2019-08-09 13:33:45 +00:00
|
|
|
T_SURFACE,
|
|
|
|
T_VOXEL,
|
|
|
|
T_VIEW,
|
|
|
|
T_SHADE,
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int blood_globalflags;
|
|
|
|
|
|
|
|
void QuitGame(void)
|
|
|
|
{
|
2020-07-29 21:18:08 +00:00
|
|
|
throw CExitEvent(0);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PrecacheDude(spritetype *pSprite)
|
|
|
|
{
|
2020-02-05 21:17:05 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+5);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+1);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+2);
|
|
|
|
switch (pSprite->type)
|
|
|
|
{
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeCultistTommy:
|
|
|
|
case kDudeCultistShotgun:
|
|
|
|
case kDudeCultistTesla:
|
|
|
|
case kDudeCultistTNT:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+9);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+13);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+14);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+15);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeZombieButcher:
|
|
|
|
case kDudeGillBeast:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+9);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+10);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+11);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeGargoyleStatueFlesh:
|
|
|
|
case kDudeGargoyleStatueStone:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
fallthrough__;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeGargoyleFlesh:
|
|
|
|
case kDudeGargoyleStone:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+9);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudePhantasm:
|
|
|
|
case kDudeHellHound:
|
|
|
|
case kDudeSpiderBrown:
|
|
|
|
case kDudeSpiderRed:
|
|
|
|
case kDudeSpiderBlack:
|
|
|
|
case kDudeSpiderMother:
|
|
|
|
case kDudeTchernobog:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeCerberusTwoHead:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7);
|
|
|
|
fallthrough__;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeHand:
|
|
|
|
case kDudeBoneEel:
|
|
|
|
case kDudeBat:
|
|
|
|
case kDudeRat:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeCultistBeast:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
break;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeZombieAxeBuried:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+12);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+9);
|
|
|
|
fallthrough__;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeZombieAxeLaying:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+10);
|
|
|
|
fallthrough__;
|
2019-10-11 21:59:39 +00:00
|
|
|
case kDudeZombieAxeNormal:
|
2019-09-19 22:42:45 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+11);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+13);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+14);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-11 21:59:39 +00:00
|
|
|
void PrecacheThing(spritetype *pSprite) {
|
|
|
|
switch (pSprite->type) {
|
|
|
|
case kThingGlassWindow: // worthless...
|
|
|
|
case kThingFluorescent:
|
|
|
|
seqPrecacheId(12);
|
|
|
|
break;
|
|
|
|
case kThingSpiderWeb:
|
|
|
|
seqPrecacheId(15);
|
|
|
|
break;
|
|
|
|
case kThingMetalGrate:
|
|
|
|
seqPrecacheId(21);
|
|
|
|
break;
|
|
|
|
case kThingFlammableTree:
|
|
|
|
seqPrecacheId(25);
|
|
|
|
seqPrecacheId(26);
|
|
|
|
break;
|
|
|
|
case kTrapMachinegun:
|
|
|
|
seqPrecacheId(38);
|
|
|
|
seqPrecacheId(40);
|
|
|
|
seqPrecacheId(28);
|
|
|
|
break;
|
|
|
|
case kThingObjectGib:
|
|
|
|
//case kThingObjectExplode: weird that only gib object is precached and this one is not
|
|
|
|
break;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-02 11:01:18 +00:00
|
|
|
tilePrecacheTile(pSprite->picnum);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreloadTiles(void)
|
|
|
|
{
|
2020-04-11 07:12:23 +00:00
|
|
|
nPrecacheCount = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
int skyTile = -1;
|
|
|
|
memset(gotpic,0,sizeof(gotpic));
|
2020-01-02 09:45:31 +00:00
|
|
|
// Fonts
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int i = 0; i < numsectors; i++)
|
|
|
|
{
|
|
|
|
tilePrecacheTile(sector[i].floorpicnum, 0);
|
|
|
|
tilePrecacheTile(sector[i].ceilingpicnum, 0);
|
|
|
|
if ((sector[i].ceilingstat&1) != 0 && skyTile == -1)
|
|
|
|
skyTile = sector[i].ceilingpicnum;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < numwalls; i++)
|
|
|
|
{
|
|
|
|
tilePrecacheTile(wall[i].picnum, 0);
|
|
|
|
if (wall[i].overpicnum >= 0)
|
|
|
|
tilePrecacheTile(wall[i].overpicnum, 0);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < kMaxSprites; i++)
|
|
|
|
{
|
|
|
|
if (sprite[i].statnum < kMaxStatus)
|
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[i];
|
|
|
|
switch (pSprite->statnum)
|
|
|
|
{
|
2019-10-07 19:29:52 +00:00
|
|
|
case kStatDude:
|
2019-09-19 22:42:45 +00:00
|
|
|
PrecacheDude(pSprite);
|
|
|
|
break;
|
2019-10-07 19:29:52 +00:00
|
|
|
case kStatThing:
|
2019-09-19 22:42:45 +00:00
|
|
|
PrecacheThing(pSprite);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tilePrecacheTile(pSprite->picnum);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-02 11:01:18 +00:00
|
|
|
|
|
|
|
// Precache common SEQs
|
|
|
|
for (int i = 0; i < 100; i++)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-01-02 11:01:18 +00:00
|
|
|
seqPrecacheId(i);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-01-02 11:01:18 +00:00
|
|
|
|
|
|
|
tilePrecacheTile(1147); // water drip
|
|
|
|
tilePrecacheTile(1160); // blood drip
|
|
|
|
|
|
|
|
// Player SEQs
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+6);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+7);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+8);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+9);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+10);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+14);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+15);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+12);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+16);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+17);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+18);
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
if (skyTile > -1 && skyTile < kMaxTiles)
|
|
|
|
{
|
|
|
|
for (int i = 1; i < gSkyCount; i++)
|
|
|
|
tilePrecacheTile(skyTile+i, 0);
|
|
|
|
}
|
2020-01-02 11:01:18 +00:00
|
|
|
|
|
|
|
WeaponPrecache();
|
|
|
|
viewPrecacheTiles();
|
|
|
|
fxPrecache();
|
|
|
|
gibPrecache();
|
|
|
|
|
2020-08-16 07:46:37 +00:00
|
|
|
I_GetEvent();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PreloadCache(void)
|
|
|
|
{
|
|
|
|
PreloadTiles();
|
|
|
|
int cnt = 0;
|
|
|
|
int percentDisplayed = -1;
|
|
|
|
|
2020-08-24 18:34:18 +00:00
|
|
|
for (int i = 0; i < kMaxTiles; i++)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
if (TestBitString(gotpic, i))
|
|
|
|
{
|
2020-08-16 07:46:37 +00:00
|
|
|
// For the hardware renderer precaching the raw pixel data is pointless.
|
|
|
|
if (videoGetRenderMode() < REND_POLYMOST)
|
|
|
|
tileLoad(i);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-10-23 12:39:33 +00:00
|
|
|
if (r_precache) PrecacheHardwareTextures(i);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
if ((++cnt & 7) == 0)
|
2020-08-16 07:46:37 +00:00
|
|
|
I_GetEvent();
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
memset(gotpic,0,sizeof(gotpic));
|
|
|
|
}
|
|
|
|
|
|
|
|
void EndLevel(void)
|
|
|
|
{
|
|
|
|
gViewPos = VIEWPOS_0;
|
|
|
|
sndKillAllSounds();
|
|
|
|
sfxKillAllSounds();
|
|
|
|
ambKillAll();
|
|
|
|
seqKillAll();
|
|
|
|
}
|
|
|
|
|
2020-01-02 13:37:15 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
PLAYER gPlayerTemp[kMaxPlayers];
|
|
|
|
int gHealthTemp[kMaxPlayers];
|
|
|
|
|
|
|
|
vec3_t startpos;
|
|
|
|
int16_t startang, startsectnum;
|
|
|
|
|
2020-08-16 11:26:57 +00:00
|
|
|
void StartLevel(MapRecord *level)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-08-16 11:26:57 +00:00
|
|
|
if (!level) return;
|
2019-11-12 21:59:51 +00:00
|
|
|
STAT_Update(0);
|
2019-09-19 22:42:45 +00:00
|
|
|
EndLevel();
|
2020-01-30 13:05:34 +00:00
|
|
|
gInput = {};
|
2020-08-16 11:26:57 +00:00
|
|
|
gStartNewGame = nullptr;
|
2019-09-19 22:42:45 +00:00
|
|
|
ready2send = 0;
|
|
|
|
netWaitForEveryone(0);
|
2020-08-16 11:26:57 +00:00
|
|
|
currentLevel = level;
|
2020-08-03 18:11:30 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
if (gGameOptions.nGameType == 0)
|
|
|
|
{
|
2019-09-21 11:02:17 +00:00
|
|
|
///////
|
|
|
|
gGameOptions.weaponsV10x = gWeaponsV10x;
|
|
|
|
///////
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-08-16 11:26:57 +00:00
|
|
|
#if 0
|
2019-09-19 22:42:45 +00:00
|
|
|
else if (gGameOptions.nGameType > 0 && !(gGameOptions.uGameFlags&1))
|
|
|
|
{
|
2020-08-16 11:26:57 +00:00
|
|
|
// todo
|
2019-09-15 11:59:27 +00:00
|
|
|
gBlueFlagDropped = false;
|
|
|
|
gRedFlagDropped = false;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-08-16 11:26:57 +00:00
|
|
|
#endif
|
|
|
|
if (gGameOptions.uGameFlags&1)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
|
|
|
memcpy(&gPlayerTemp[i],&gPlayer[i],sizeof(PLAYER));
|
|
|
|
gHealthTemp[i] = xsprite[gPlayer[i].pSprite->extra].health;
|
|
|
|
}
|
|
|
|
}
|
2020-07-27 22:01:16 +00:00
|
|
|
bVanilla = false;
|
2019-09-22 19:26:07 +00:00
|
|
|
enginecompatibility_mode = ENGINECOMPATIBILITY_19960925;//bVanilla;
|
2019-09-19 22:42:45 +00:00
|
|
|
memset(xsprite,0,sizeof(xsprite));
|
|
|
|
memset(sprite,0,kMaxSprites*sizeof(spritetype));
|
2020-07-29 21:18:08 +00:00
|
|
|
//drawLoadingScreen();
|
2020-08-16 09:58:42 +00:00
|
|
|
if (dbLoadMap(currentLevel->fileName,(int*)&startpos.x,(int*)&startpos.y,(int*)&startpos.z,&startang,&startsectnum,nullptr))
|
2019-06-28 16:03:47 +00:00
|
|
|
{
|
2020-07-29 21:18:08 +00:00
|
|
|
I_Error("Unable to load map");
|
2019-06-28 16:03:47 +00:00
|
|
|
}
|
2020-02-22 07:56:36 +00:00
|
|
|
SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name);
|
2020-04-01 20:34:49 +00:00
|
|
|
STAT_NewLevel(currentLevel->fileName);
|
2020-08-03 18:11:30 +00:00
|
|
|
G_LoadMapHack(currentLevel->fileName);
|
2020-08-16 09:58:42 +00:00
|
|
|
wsrand(dbReadMapCRC(currentLevel->LabelName()));
|
2019-09-19 22:42:45 +00:00
|
|
|
gKillMgr.Clear();
|
|
|
|
gSecretMgr.Clear();
|
|
|
|
gLevelTime = 0;
|
|
|
|
automapping = 1;
|
2019-09-21 11:02:17 +00:00
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
int modernTypesErased = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int i = 0; i < kMaxSprites; i++)
|
|
|
|
{
|
|
|
|
spritetype *pSprite = &sprite[i];
|
2019-10-11 21:59:39 +00:00
|
|
|
if (pSprite->statnum < kMaxStatus && pSprite->extra > 0) {
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
XSPRITE *pXSprite = &xsprite[pSprite->extra];
|
2020-08-16 11:26:57 +00:00
|
|
|
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)) {
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
DeleteSprite(i);
|
|
|
|
continue;
|
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
2020-02-07 19:47:43 +00:00
|
|
|
if (!gModernMap && nnExtEraseModernStuff(pSprite, pXSprite))
|
|
|
|
modernTypesErased++;
|
|
|
|
#endif
|
2019-10-11 21:59:39 +00:00
|
|
|
}
|
2019-10-25 20:53:41 +00:00
|
|
|
}
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2020-02-07 19:47:43 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
if (!gModernMap)
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "> Modern types erased: %d.\n", modernTypesErased);
|
2020-02-07 19:47:43 +00:00
|
|
|
#endif
|
2019-10-11 21:59:39 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
startpos.z = getflorzofslope(startsectnum,startpos.x,startpos.y);
|
2019-10-11 21:59:39 +00:00
|
|
|
for (int i = 0; i < kMaxPlayers; i++) {
|
2019-09-19 22:42:45 +00:00
|
|
|
gStartZone[i].x = startpos.x;
|
|
|
|
gStartZone[i].y = startpos.y;
|
|
|
|
gStartZone[i].z = startpos.z;
|
|
|
|
gStartZone[i].sectnum = startsectnum;
|
|
|
|
gStartZone[i].ang = startang;
|
|
|
|
|
2020-01-26 11:19:01 +00:00
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
// Create spawn zones for players in teams mode.
|
2019-10-11 21:59:39 +00:00
|
|
|
if (gModernMap && i <= kMaxPlayers / 2) {
|
2019-09-19 22:42:45 +00:00
|
|
|
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;
|
|
|
|
}
|
2020-01-26 11:19:01 +00:00
|
|
|
#endif
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
InitSectorFX();
|
|
|
|
warpInit();
|
2019-09-21 11:02:17 +00:00
|
|
|
actInit(false);
|
2019-09-19 22:42:45 +00:00
|
|
|
evInit();
|
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
2020-08-16 11:26:57 +00:00
|
|
|
if (!(gGameOptions.uGameFlags&1))
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
if (numplayers == 1)
|
|
|
|
{
|
|
|
|
gProfile[i].skill = gSkill;
|
2019-10-21 22:05:21 +00:00
|
|
|
gProfile[i].nAutoAim = cl_autoaim;
|
2019-10-22 00:31:14 +00:00
|
|
|
gProfile[i].nWeaponSwitch = cl_weaponswitch;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
playerInit(i,0);
|
|
|
|
}
|
2020-02-10 05:23:49 +00:00
|
|
|
playerStart(i, 1);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-08-16 11:26:57 +00:00
|
|
|
if (gGameOptions.uGameFlags&1)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
|
|
|
PLAYER *pPlayer = &gPlayer[i];
|
|
|
|
pPlayer->pXSprite->health &= 0xf000;
|
|
|
|
pPlayer->pXSprite->health |= gHealthTemp[i];
|
2019-10-21 19:46:41 +00:00
|
|
|
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;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-16 11:26:57 +00:00
|
|
|
gGameOptions.uGameFlags &= ~3;
|
2019-09-19 22:42:45 +00:00
|
|
|
PreloadCache();
|
|
|
|
InitMirrors();
|
|
|
|
gFrameClock = 0;
|
|
|
|
trInit();
|
2019-10-21 19:46:41 +00:00
|
|
|
if (!bVanilla && !gMe->packSlots[1].isActive) // if diving suit is not active, turn off reverb sound effect
|
2019-09-19 22:42:45 +00:00
|
|
|
sfxSetReverb(0);
|
|
|
|
ambInit();
|
2020-08-03 18:01:08 +00:00
|
|
|
netReset();
|
2020-08-26 10:55:46 +00:00
|
|
|
gFrameCount = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
gChokeCounter = 0;
|
2020-07-27 22:01:16 +00:00
|
|
|
M_ClearMenus();
|
2019-09-19 22:42:45 +00:00
|
|
|
// viewSetMessage("");
|
|
|
|
viewSetErrorMessage("");
|
|
|
|
netWaitForEveryone(0);
|
2020-08-25 23:10:14 +00:00
|
|
|
gameclock = 0;
|
|
|
|
lastTic = -1;
|
2020-05-29 01:20:40 +00:00
|
|
|
paused = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
ready2send = 1;
|
2020-08-16 11:26:57 +00:00
|
|
|
levelTryPlayMusic();
|
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;
|
|
|
|
|
|
|
|
void ProcessFrame(void)
|
|
|
|
{
|
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
2020-08-26 22:53:35 +00:00
|
|
|
auto& inp = gPlayer[i].input;
|
|
|
|
auto oldactions = inp.actions;
|
|
|
|
auto oldflags = inp.syncFlags.value;
|
|
|
|
|
|
|
|
inp = gFifoInput[gNetFifoTail & 255][i];
|
|
|
|
inp.actions |= oldactions & SB_INTERFACE_MASK; // should be everything non-button and non-weapon
|
|
|
|
inp.syncFlags.value |= oldflags & ~flag_buttonmask;
|
|
|
|
|
|
|
|
int newweap = inp.getNewWeapon();
|
|
|
|
if (newweap > 0 && newweap < WeaponSel_MaxBlood) gPlayer[i].newWeapon = newweap;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
gNetFifoTail++;
|
2020-08-25 21:04:08 +00:00
|
|
|
|
2020-08-27 22:03:35 +00:00
|
|
|
#if 0
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
2020-08-26 14:48:33 +00:00
|
|
|
if (gPlayer[i].input.syncFlags.quit)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-08-26 14:48:33 +00:00
|
|
|
gPlayer[i].input.syncFlags.quit = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
netBroadcastPlayerLogoff(i);
|
|
|
|
if (i == myconnectindex)
|
|
|
|
{
|
|
|
|
// netBroadcastMyLogoff(gQuitRequest == 2);
|
|
|
|
gQuitGame = true;
|
|
|
|
gRestartGame = gQuitRequest == 2;
|
|
|
|
netDeinitialize();
|
|
|
|
netResetToSinglePlayer();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-08-26 14:48:33 +00:00
|
|
|
if (gPlayer[i].input.syncFlags.restart)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-08-26 14:48:33 +00:00
|
|
|
gPlayer[i].input.syncFlags.restart = 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
levelRestart();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-08-27 22:03:35 +00:00
|
|
|
#endif
|
2019-09-19 22:42:45 +00:00
|
|
|
viewClearInterpolations();
|
|
|
|
{
|
2020-05-29 01:20:40 +00:00
|
|
|
if (paused || gEndGameMgr.at0 || (gGameOptions.nGameType == 0 && M_Active()))
|
2019-09-19 22:42:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
{
|
|
|
|
viewBackupView(i);
|
|
|
|
playerProcess(&gPlayer[i]);
|
|
|
|
}
|
|
|
|
trProcessBusy();
|
2020-08-26 10:55:46 +00:00
|
|
|
evProcess(gFrameClock);
|
2019-09-19 22:42:45 +00:00
|
|
|
seqProcess(4);
|
|
|
|
DoSectorPanning();
|
|
|
|
actProcessSprites();
|
|
|
|
actPostProcess();
|
2020-01-02 13:37:15 +00:00
|
|
|
#ifdef POLYMER
|
|
|
|
G_RefreshLights();
|
|
|
|
#endif
|
2019-09-19 22:42:45 +00:00
|
|
|
viewCorrectPrediction();
|
|
|
|
ambProcess();
|
|
|
|
viewUpdateDelirium();
|
|
|
|
viewUpdateShake();
|
|
|
|
sfxUpdate3DSounds();
|
2019-10-21 19:46:41 +00:00
|
|
|
if (gMe->hand == 1)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-08-16 07:46:37 +00:00
|
|
|
const int CHOKERATE = 8;
|
|
|
|
const int COUNTRATE = 30;
|
2019-09-19 22:42:45 +00:00
|
|
|
gChokeCounter += CHOKERATE;
|
2020-08-16 07:46:37 +00:00
|
|
|
while (gChokeCounter >= COUNTRATE)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
gChoke.at1c(gMe);
|
2020-08-16 07:46:37 +00:00
|
|
|
gChokeCounter -= COUNTRATE;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
gLevelTime++;
|
2020-08-26 10:55:46 +00:00
|
|
|
gFrameCount++;
|
2019-09-19 22:42:45 +00:00
|
|
|
gFrameClock += 4;
|
|
|
|
if ((gGameOptions.uGameFlags&1) != 0 && !gStartNewGame)
|
|
|
|
{
|
|
|
|
ready2send = 0;
|
2020-08-16 07:46:37 +00:00
|
|
|
#if 0
|
2019-09-19 22:42:45 +00:00
|
|
|
if (gNetPlayers > 1 && gNetMode == NETWORK_SERVER && gPacketMode == PACKETMODE_1 && myconnectindex == connecthead)
|
|
|
|
{
|
|
|
|
while (gNetFifoMasterTail < gNetFifoTail)
|
|
|
|
{
|
2020-08-16 07:46:37 +00:00
|
|
|
netGetPackets();
|
|
|
|
h andleevents();
|
2019-09-19 22:42:45 +00:00
|
|
|
netMasterUpdate();
|
|
|
|
}
|
|
|
|
}
|
2020-08-16 07:46:37 +00:00
|
|
|
#endif
|
2019-09-19 22:42:45 +00:00
|
|
|
seqKillAll();
|
|
|
|
if (gGameOptions.uGameFlags&2)
|
|
|
|
{
|
2020-01-25 15:47:06 +00:00
|
|
|
STAT_Update(true);
|
2019-09-19 22:42:45 +00:00
|
|
|
if (gGameOptions.nGameType == 0)
|
|
|
|
{
|
2020-07-29 21:18:08 +00:00
|
|
|
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-08-11 18:26:50 +00:00
|
|
|
M_SetMenu(NAME_Mainmenu);
|
|
|
|
M_SetMenu(NAME_CreditsMenu);
|
2020-07-29 21:18:08 +00:00
|
|
|
gGameOptions.uGameFlags &= ~3;
|
|
|
|
gQuitGame = 1;
|
2020-08-18 18:56:18 +00:00
|
|
|
gRestartGame = true;
|
|
|
|
};
|
2020-07-29 21:18:08 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
if (gGameOptions.uGameFlags&8)
|
2020-07-29 21:18:08 +00:00
|
|
|
{
|
2020-08-16 11:26:57 +00:00
|
|
|
levelPlayEndScene(volfromlevelnum(currentLevel->levelNumber), completion);
|
2020-07-29 21:18:08 +00:00
|
|
|
}
|
|
|
|
else completion(false);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-07-29 21:18:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gGameOptions.uGameFlags &= ~3;
|
|
|
|
gRestartGame = 1;
|
|
|
|
gQuitGame = 1;
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gEndGameMgr.Setup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-28 21:19:50 +00:00
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
void ParseOptions(void)
|
|
|
|
{
|
2020-07-27 22:01:16 +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-08-03 18:51:31 +00:00
|
|
|
InitCheats();
|
2019-09-19 22:42:45 +00:00
|
|
|
memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
|
2020-07-29 21:18:08 +00:00
|
|
|
gGameOptions.nMonsterSettings = !userConfig.nomonsters;
|
2020-01-22 20:09:45 +00:00
|
|
|
ReadAllRFS();
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-06-28 16:03:47 +00:00
|
|
|
HookReplaceFunctions();
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Initializing Build 3D engine\n");
|
2020-07-27 22:05:56 +00:00
|
|
|
engineInit();
|
2019-09-21 11:02:17 +00:00
|
|
|
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Loading tiles\n");
|
2020-07-29 21:18:08 +00:00
|
|
|
if (!tileInit(0, NULL))
|
|
|
|
I_FatalError("TILES###.ART files not found");
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
|
|
levelLoadDefaults();
|
2019-08-09 18:25:44 +00:00
|
|
|
|
|
|
|
loaddefinitionsfile(BLOODWIDESCREENDEF);
|
|
|
|
|
2020-07-29 21:18:08 +00:00
|
|
|
const char* defsfile = G_DefFile();
|
2020-08-25 23:30:27 +00:00
|
|
|
uint32_t stime = I_msTime();
|
2019-09-19 22:42:45 +00:00
|
|
|
if (!loaddefinitionsfile(defsfile))
|
|
|
|
{
|
2020-08-25 23:30:27 +00:00
|
|
|
uint32_t etime = I_msTime();
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Definitions file \"%s\" loaded in %d ms.\n", defsfile, etime - stime);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
powerupInit();
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Loading cosine table\n");
|
2020-04-11 21:54:33 +00:00
|
|
|
trigInit();
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Initializing view subsystem\n");
|
2019-09-19 22:42:45 +00:00
|
|
|
viewInit();
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Initializing dynamic fire\n");
|
2019-09-19 22:42:45 +00:00
|
|
|
FireInit();
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Initializing weapon animations\n");
|
2019-09-19 22:42:45 +00:00
|
|
|
WeaponInit();
|
|
|
|
LoadSaveSetup();
|
|
|
|
LoadSavedInfo();
|
|
|
|
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Initializing network users\n");
|
2019-09-19 22:42:45 +00:00
|
|
|
netInitialize(true);
|
2020-07-29 21:18:08 +00:00
|
|
|
videoInit();
|
2020-08-25 18:21:18 +00:00
|
|
|
Printf(PRINT_NONOTIFY, "Initializing sound system\n");
|
2019-09-19 22:42:45 +00:00
|
|
|
sndInit();
|
2020-07-27 17:45:34 +00:00
|
|
|
registerosdcommands();
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
gChoke.sub_83ff0(518, sub_84230);
|
2020-07-27 21:29:10 +00:00
|
|
|
UpdateDacs(0, true);
|
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()
|
|
|
|
{
|
|
|
|
//RESTART:
|
2020-08-03 18:01:08 +00:00
|
|
|
netReset();
|
2019-09-19 22:42:45 +00:00
|
|
|
gViewIndex = myconnectindex;
|
|
|
|
gMe = gView = &gPlayer[myconnectindex];
|
|
|
|
netBroadcastPlayerInfo(myconnectindex);
|
2020-07-29 21:18:08 +00:00
|
|
|
#if 0
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Waiting for network players!\n");
|
2019-09-19 22:42:45 +00:00
|
|
|
netWaitForEveryone(0);
|
|
|
|
if (gRestartGame)
|
|
|
|
{
|
|
|
|
// Network error
|
|
|
|
gQuitGame = false;
|
|
|
|
gRestartGame = false;
|
|
|
|
netDeinitialize();
|
|
|
|
netResetToSinglePlayer();
|
|
|
|
goto RESTART;
|
|
|
|
}
|
2020-07-29 21:18:08 +00:00
|
|
|
#endif
|
|
|
|
UpdateNetworkMenus();
|
2019-09-19 22:42:45 +00:00
|
|
|
gQuitGame = 0;
|
|
|
|
gRestartGame = 0;
|
|
|
|
if (gGameOptions.nGameType > 0)
|
|
|
|
{
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-07-29 21:18:08 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gameTicker()
|
|
|
|
{
|
|
|
|
bool gameUpdate = false;
|
2020-08-25 23:27:09 +00:00
|
|
|
double const gameUpdateStartTime = I_msTimeF();
|
2020-07-29 21:18:08 +00:00
|
|
|
while (gPredictTail < gNetFifoHead[myconnectindex] && !paused)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-07-29 21:18:08 +00:00
|
|
|
viewUpdatePrediction(&gFifoInput[gPredictTail & 255][myconnectindex]);
|
|
|
|
}
|
|
|
|
if (numplayers == 1)
|
|
|
|
gBufferJitter = 0;
|
2020-08-25 23:10:14 +00:00
|
|
|
|
|
|
|
int const currentTic = I_GetTime();
|
|
|
|
gameclock = I_GetBuildTime();
|
|
|
|
|
|
|
|
while (currentTic - lastTic >= 1 && ready2send)
|
2020-07-29 21:18:08 +00:00
|
|
|
{
|
|
|
|
gNetInput = gInput;
|
|
|
|
gInput = {};
|
|
|
|
netGetInput();
|
2020-08-25 23:10:14 +00:00
|
|
|
lastTic = currentTic;
|
2020-07-29 21:18:08 +00:00
|
|
|
while (gNetFifoHead[myconnectindex] - gNetFifoTail > gBufferJitter && !gStartNewGame && !gQuitGame)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2020-07-29 21:18:08 +00:00
|
|
|
int i;
|
|
|
|
for (i = connecthead; i >= 0; i = connectpoint2[i])
|
|
|
|
if (gNetFifoHead[i] == gNetFifoTail)
|
|
|
|
break;
|
|
|
|
if (i >= 0)
|
2020-01-29 13:19:05 +00:00
|
|
|
break;
|
2020-07-29 21:18:08 +00:00
|
|
|
ProcessFrame();
|
|
|
|
gameUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gameUpdate)
|
|
|
|
{
|
2020-08-25 23:27:09 +00:00
|
|
|
g_gameUpdateTime = I_msTimeF() - gameUpdateStartTime;
|
2020-07-29 21:18:08 +00:00
|
|
|
if (g_gameUpdateAvgTime < 0.f)
|
|
|
|
g_gameUpdateAvgTime = g_gameUpdateTime;
|
|
|
|
g_gameUpdateAvgTime = ((GAMEUPDATEAVGTIMENUMSAMPLES - 1.f) * g_gameUpdateAvgTime + g_gameUpdateTime) / ((float)GAMEUPDATEAVGTIMENUMSAMPLES);
|
|
|
|
}
|
|
|
|
if (gQuitRequest && gQuitGame)
|
|
|
|
videoClearScreen(0);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
netCheckSync();
|
|
|
|
viewDrawScreen();
|
2020-08-25 23:27:09 +00:00
|
|
|
g_gameUpdateAndDrawTime = g_beforeSwapTime/* I_msTimeF()*/ - gameUpdateStartTime;
|
2020-07-29 21:18:08 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-29 13:19:05 +00:00
|
|
|
|
2020-07-29 21:18:08 +00:00
|
|
|
static void drawBackground()
|
|
|
|
{
|
|
|
|
twod->ClearScreen();
|
2020-08-14 19:01:27 +00:00
|
|
|
DrawTexture(twod, tileGetTexture(2518, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, TAG_DONE);
|
2020-08-27 22:03:35 +00:00
|
|
|
#if 0
|
2020-07-29 21:18:08 +00:00
|
|
|
if (gQuitRequest && !gQuitGame)
|
|
|
|
netBroadcastMyLogoff(gQuitRequest == 2);
|
2020-08-27 22:03:35 +00:00
|
|
|
#endif
|
2020-07-29 21:18:08 +00:00
|
|
|
}
|
2020-01-30 13:05:34 +00:00
|
|
|
|
2020-08-23 15:47:05 +00:00
|
|
|
static void commonTicker()
|
2020-07-29 21:18:08 +00:00
|
|
|
{
|
|
|
|
if (TestBitString(gotpic, 2342))
|
|
|
|
{
|
|
|
|
FireProcess();
|
|
|
|
ClearBitString(gotpic, 2342);
|
|
|
|
}
|
|
|
|
if (gStartNewGame)
|
|
|
|
{
|
2020-08-16 11:26:57 +00:00
|
|
|
auto sng = gStartNewGame;
|
|
|
|
gStartNewGame = nullptr;
|
2020-08-12 17:11:16 +00:00
|
|
|
gQuitGame = false;
|
2020-08-16 11:26:57 +00:00
|
|
|
auto completion = [=](bool = false)
|
2020-08-11 21:21:08 +00:00
|
|
|
{
|
2020-08-16 11:26:57 +00:00
|
|
|
StartLevel(sng);
|
2020-08-26 10:55:46 +00:00
|
|
|
gFrameClock = gameclock;
|
2020-08-10 20:22:27 +00:00
|
|
|
gamestate = GS_LEVEL;
|
2020-08-11 21:21:08 +00:00
|
|
|
};
|
|
|
|
|
2020-08-16 11:26:57 +00:00
|
|
|
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;
|
|
|
|
}
|
2020-07-29 21:18:08 +00:00
|
|
|
|
2020-08-16 11:26:57 +00:00
|
|
|
}
|
|
|
|
if (!startedCutscene) completion(false);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-08-16 11:26:57 +00:00
|
|
|
else if (gRestartGame)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
2019-12-07 17:28:30 +00:00
|
|
|
Mus_Stop();
|
2019-12-18 21:24:50 +00:00
|
|
|
soundEngine->StopAllChannels();
|
2019-09-19 22:42:45 +00:00
|
|
|
gQuitGame = 0;
|
|
|
|
gQuitRequest = 0;
|
|
|
|
gRestartGame = 0;
|
2020-07-29 21:18:08 +00:00
|
|
|
|
2020-08-18 18:56:18 +00:00
|
|
|
// Don't switch to startup if we're already outside the game.
|
2020-08-25 16:06:16 +00:00
|
|
|
if (gamestate == GS_LEVEL)
|
|
|
|
{
|
|
|
|
gamestate = GS_MENUSCREEN;
|
|
|
|
M_StartControlPanel(false);
|
|
|
|
M_SetMenu(NAME_Mainmenu);
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
2020-07-29 21:18:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-23 15:47:05 +00:00
|
|
|
void GameInterface::RunGameFrame()
|
2020-07-29 21:18:08 +00:00
|
|
|
{
|
2020-08-23 15:47:05 +00:00
|
|
|
commonTicker();
|
|
|
|
netGetPackets();
|
|
|
|
ctrlGetInput();
|
2020-07-29 21:18:08 +00:00
|
|
|
|
2020-08-23 15:47:05 +00:00
|
|
|
switch (gamestate)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case GS_STARTUP:
|
2020-08-26 14:47:30 +00:00
|
|
|
gameInit();
|
2020-08-23 15:47:05 +00:00
|
|
|
if (userConfig.CommandMap.IsNotEmpty())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!userConfig.nologo && gGameOptions.nGameType == 0) playlogos();
|
|
|
|
else
|
2020-08-16 18:04:27 +00:00
|
|
|
{
|
2020-08-23 15:47:05 +00:00
|
|
|
gamestate = GS_MENUSCREEN;
|
|
|
|
M_StartControlPanel(false);
|
|
|
|
M_SetMenu(NAME_Mainmenu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2020-07-29 21:18:08 +00:00
|
|
|
|
2020-08-23 15:47:05 +00:00
|
|
|
case GS_MENUSCREEN:
|
|
|
|
case GS_FULLCONSOLE:
|
|
|
|
drawBackground();
|
|
|
|
break;
|
2020-07-29 21:18:08 +00:00
|
|
|
|
2020-08-23 15:47:05 +00:00
|
|
|
case GS_INTRO:
|
|
|
|
case GS_INTERMISSION:
|
|
|
|
RunScreenJobFrame(); // This handles continuation through its completion callback.
|
|
|
|
break;
|
2020-07-29 21:18:08 +00:00
|
|
|
|
2020-08-23 15:47:05 +00:00
|
|
|
case GS_LEVEL:
|
|
|
|
gameTicker();
|
|
|
|
LocalKeys();
|
|
|
|
break;
|
2020-07-29 21:18:08 +00:00
|
|
|
|
2020-08-23 15:47:05 +00:00
|
|
|
case GS_FINALE:
|
|
|
|
gEndGameMgr.ProcessKeys();
|
|
|
|
gEndGameMgr.Draw();
|
|
|
|
break;
|
2020-07-29 21:18:08 +00:00
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DemoRecordStatus(void) {
|
2020-07-27 22:01:16 +00:00
|
|
|
return false;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool VanillaMode() {
|
2020-07-27 22:01:16 +00:00
|
|
|
return false;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-06-28 12:45:39 +00:00
|
|
|
int sndTryPlaySpecialMusic(int nMusic)
|
|
|
|
{
|
2019-12-10 23:57:53 +00:00
|
|
|
if (Mus_Play(nullptr, quoteMgr.GetQuote(nMusic), true))
|
2019-06-28 12:45:39 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sndPlaySpecialMusicOrNothing(int nMusic)
|
|
|
|
{
|
|
|
|
if (sndTryPlaySpecialMusic(nMusic))
|
|
|
|
{
|
2019-12-07 17:28:30 +00:00
|
|
|
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()
|
|
|
|
{
|
|
|
|
if (BloodINI) delete BloodINI;
|
2020-07-29 21:18:08 +00:00
|
|
|
netDeinitialize();
|
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-08-16 00:55:50 +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
|