2015-05-19 21:54:34 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Shadow Warrior version 1.2
|
|
|
|
|
|
|
|
Shadow Warrior is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
|
|
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
#include "ns.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#define MAIN
|
|
|
|
#define QUIET
|
|
|
|
#include "build.h"
|
|
|
|
#include "baselayer.h"
|
2019-12-17 22:25:07 +00:00
|
|
|
|
2019-12-29 16:04:38 +00:00
|
|
|
#include "baselayer.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "names2.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#include "game.h"
|
2020-04-13 21:13:38 +00:00
|
|
|
#include "interp.h"
|
2020-05-01 11:29:12 +00:00
|
|
|
#include "interpso.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "tags.h"
|
|
|
|
#include "sector.h"
|
|
|
|
#include "sprite.h"
|
|
|
|
#include "weapon.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "lists.h"
|
2019-03-21 02:24:19 +00:00
|
|
|
#include "network.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "pal.h"
|
2019-12-24 12:21:36 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "mytypes.h"
|
|
|
|
|
|
|
|
#include "menus.h"
|
|
|
|
|
2019-10-25 22:32:49 +00:00
|
|
|
#include "gamecontrol.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-05 15:07:19 +00:00
|
|
|
#include "misc.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-05 15:07:19 +00:00
|
|
|
#include "misc.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "break.h"
|
|
|
|
#include "ninja.h"
|
|
|
|
#include "light.h"
|
2020-08-05 22:18:45 +00:00
|
|
|
#include "misc.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "jsector.h"
|
|
|
|
|
2015-05-19 22:07:18 +00:00
|
|
|
#include "common.h"
|
2019-10-27 15:53:00 +00:00
|
|
|
#include "gameconfigfile.h"
|
2019-11-01 07:24:10 +00:00
|
|
|
#include "printf.h"
|
2019-11-01 18:25:42 +00:00
|
|
|
#include "m_argv.h"
|
2019-11-30 09:07:25 +00:00
|
|
|
#include "debugbreak.h"
|
2020-06-14 16:57:55 +00:00
|
|
|
#include "menu.h"
|
2020-04-12 06:07:48 +00:00
|
|
|
#include "raze_music.h"
|
2019-12-08 23:55:30 +00:00
|
|
|
#include "statistics.h"
|
2019-12-09 20:19:05 +00:00
|
|
|
#include "gstrings.h"
|
2019-12-11 01:01:11 +00:00
|
|
|
#include "mapinfo.h"
|
2020-04-28 21:11:33 +00:00
|
|
|
#include "v_video.h"
|
2020-04-12 06:09:38 +00:00
|
|
|
#include "raze_sound.h"
|
2020-02-22 07:56:36 +00:00
|
|
|
#include "secrets.h"
|
2015-05-19 22:05:20 +00:00
|
|
|
|
2020-01-23 10:50:12 +00:00
|
|
|
#include "osdcmds.h"
|
2020-08-15 08:55:21 +00:00
|
|
|
#include "screenjob.h"
|
|
|
|
#include "inputstate.h"
|
|
|
|
#include "gamestate.h"
|
2020-01-23 10:50:12 +00:00
|
|
|
|
2019-10-09 17:58:09 +00:00
|
|
|
//#include "crc32.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-05 15:07:19 +00:00
|
|
|
CVAR(Bool, sw_ninjahack, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
|
|
|
CVAR(Bool, sw_darts, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2019-10-09 17:58:09 +00:00
|
|
|
void pClearSpriteList(PLAYERp pp);
|
2020-03-01 15:33:06 +00:00
|
|
|
extern SWBOOL mapcheat;
|
2019-10-09 17:58:09 +00:00
|
|
|
|
2020-02-02 07:53:10 +00:00
|
|
|
extern int sw_snd_scratch;
|
|
|
|
|
2020-07-13 20:20:14 +00:00
|
|
|
int GameVersion = 20;
|
2019-12-22 10:21:05 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
int Follow_posx=0,Follow_posy=0;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL NoMeters = FALSE;
|
|
|
|
SWBOOL FinishAnim = 0;
|
|
|
|
SWBOOL ReloadPrompt = FALSE;
|
|
|
|
SWBOOL NewGame = TRUE;
|
|
|
|
SWBOOL InMenuLevel = FALSE;
|
|
|
|
SWBOOL LoadGameOutsideMoveLoop = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
//Miscellaneous variables
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL FinishedLevel = FALSE;
|
|
|
|
SWBOOL PanelUpdateMode = TRUE;
|
2015-05-19 21:54:34 +00:00
|
|
|
short screenpeek = 0;
|
|
|
|
|
2020-04-14 15:57:09 +00:00
|
|
|
SWBOOL PedanticMode;
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL LocationInfo = 0;
|
2020-05-19 11:44:52 +00:00
|
|
|
void drawoverheadmap(int cposx, int cposy, int czoom, short cang);
|
2015-05-19 22:10:03 +00:00
|
|
|
SWBOOL PreCaching = TRUE;
|
2015-05-19 21:54:34 +00:00
|
|
|
int GodMode = FALSE;
|
|
|
|
short Skill = 2;
|
|
|
|
short TotalKillable;
|
|
|
|
|
|
|
|
const GAME_SET gs_defaults =
|
|
|
|
{
|
|
|
|
// Network game settings
|
|
|
|
0, // GameType
|
|
|
|
0, // Monsters
|
|
|
|
FALSE, // HurtTeammate
|
|
|
|
TRUE, // SpawnMarkers Markers
|
|
|
|
FALSE, // TeamPlay
|
|
|
|
0, // Kill Limit
|
|
|
|
0, // Time Limit
|
|
|
|
0, // Color
|
|
|
|
TRUE, // nuke
|
|
|
|
};
|
|
|
|
GAME_SET gs;
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL PlayerTrackingMode = FALSE;
|
|
|
|
SWBOOL SlowMode = FALSE;
|
|
|
|
SWBOOL FrameAdvanceTics = 3;
|
2020-05-19 11:44:52 +00:00
|
|
|
SWBOOL ScrollMode2D = FALSE;
|
2015-05-19 21:58:29 +00:00
|
|
|
|
|
|
|
SWBOOL DebugOperate = FALSE;
|
2020-03-07 13:51:49 +00:00
|
|
|
void LoadingLevelScreen(void);
|
2015-05-19 21:58:29 +00:00
|
|
|
|
|
|
|
uint8_t FakeMultiNumPlayers;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
int totalsynctics;
|
|
|
|
|
2020-08-16 12:39:18 +00:00
|
|
|
MapRecord* NextLevel = nullptr;
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL ExitLevel = FALSE;
|
2020-08-15 13:29:47 +00:00
|
|
|
int OrigCommPlayers=0;
|
2015-05-19 21:58:29 +00:00
|
|
|
extern uint8_t CommPlayers;
|
|
|
|
extern SWBOOL CommEnabled;
|
2015-05-19 21:54:34 +00:00
|
|
|
extern int bufferjitter;
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL CameraTestMode = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
char ds[645]; // debug string
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
extern short NormalVisibility;
|
|
|
|
|
|
|
|
extern int quotebot, quotebotgoal; // Multiplayer typing buffer
|
|
|
|
char recbuf[80]; // Used as a temp buffer to hold typing text
|
|
|
|
|
|
|
|
#define ACT_STATUE 0
|
|
|
|
|
|
|
|
int score;
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL QuitFlag = FALSE;
|
|
|
|
SWBOOL InGame = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL CommandSetup = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-16 09:42:13 +00:00
|
|
|
char buffer[80], ch;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t DebugPrintColor = 255;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
int krandcount;
|
|
|
|
|
|
|
|
/// L O C A L P R O T O T Y P E S /////////////////////////////////////////////////////////
|
|
|
|
void BOT_DeleteAllBots(void);
|
2015-05-19 21:58:29 +00:00
|
|
|
void SybexScreen(void);
|
|
|
|
void MenuLevel(void);
|
|
|
|
void StatScreen(PLAYERp mpp);
|
|
|
|
void InitRunLevel(void);
|
|
|
|
void RunLevel(void);
|
2015-05-19 21:54:34 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static FILE *debug_fout = NULL;
|
|
|
|
|
2020-08-15 08:55:21 +00:00
|
|
|
|
|
|
|
// Transitioning helper.
|
2020-08-15 11:04:15 +00:00
|
|
|
void Logo(const CompletionFunc& completion);
|
|
|
|
|
|
|
|
int SyncScreenJob()
|
2020-08-15 08:55:21 +00:00
|
|
|
{
|
2020-08-15 11:04:15 +00:00
|
|
|
while (gamestate == GS_INTERMISSION || gamestate == GS_INTRO)
|
2020-08-15 08:55:21 +00:00
|
|
|
{
|
2020-08-15 14:41:08 +00:00
|
|
|
DoUpdateSounds();
|
2020-08-15 08:55:21 +00:00
|
|
|
handleevents();
|
|
|
|
updatePauseStatus();
|
|
|
|
D_ProcessEvents();
|
|
|
|
ControlInfo info;
|
|
|
|
CONTROL_GetInput(&info);
|
|
|
|
C_RunDelayedCommands();
|
|
|
|
|
|
|
|
RunScreenJobFrame(); // This handles continuation through its completion callback.
|
|
|
|
videoNextPage();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
extern SWBOOL DrawScreen;
|
2015-05-19 21:54:34 +00:00
|
|
|
int krand1(void)
|
|
|
|
{
|
|
|
|
ASSERT(!DrawScreen);
|
|
|
|
krandcount++;
|
|
|
|
randomseed = ((randomseed * 21 + 1) & 65535);
|
|
|
|
return randomseed;
|
|
|
|
}
|
|
|
|
|
|
|
|
int PointOnLine(int x, int y, int x1, int y1, int x2, int y2)
|
|
|
|
{
|
|
|
|
// the closer to 0 the closer to the line the point is
|
|
|
|
return ((x2 - x1) * (y - y1)) - ((y2 - y1) * (x - x1));
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Distance(int x1, int y1, int x2, int y2)
|
|
|
|
{
|
|
|
|
int min;
|
|
|
|
|
|
|
|
if ((x2 = x2 - x1) < 0)
|
|
|
|
x2 = -x2;
|
|
|
|
|
|
|
|
if ((y2 = y2 - y1) < 0)
|
|
|
|
y2 = -y2;
|
|
|
|
|
|
|
|
if (x2 > y2)
|
|
|
|
min = y2;
|
|
|
|
else
|
|
|
|
min = x2;
|
|
|
|
|
|
|
|
return x2 + y2 - DIV2(min);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-16 12:39:18 +00:00
|
|
|
bool LoadLevel(MapRecord *maprec)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-04-03 22:40:01 +00:00
|
|
|
int16_t ang;
|
2020-08-16 12:39:18 +00:00
|
|
|
if (engineLoadBoard(maprec->fileName, SW_SHAREWARE ? 1 : 0, (vec3_t *)&Player[0], &ang, &Player[0].cursectnum) == -1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-16 12:39:18 +00:00
|
|
|
Printf("Map not found: %s", maprec->fileName.GetChars());
|
2020-05-20 10:44:04 +00:00
|
|
|
return false;
|
2020-08-16 12:39:18 +00:00
|
|
|
}
|
|
|
|
currentLevel = maprec;
|
2020-02-22 07:56:36 +00:00
|
|
|
SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name);
|
2020-08-16 12:39:18 +00:00
|
|
|
STAT_NewLevel(currentLevel->fileName);
|
2020-05-20 10:44:04 +00:00
|
|
|
Player[0].q16ang = fix16_from_int(ang);
|
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MultiSharewareCheck(void)
|
|
|
|
{
|
|
|
|
if (!SW_SHAREWARE) return;
|
|
|
|
if (numplayers > 4)
|
|
|
|
{
|
2019-12-24 18:59:14 +00:00
|
|
|
I_FatalError("To play a Network game with more than 4 players you must purchase "
|
2015-05-19 21:54:34 +00:00
|
|
|
"the full version. Read the Ordering Info screens for details.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Some mem crap for Jim
|
|
|
|
// I reserve 1 meg of heap space for our use out side the cache
|
|
|
|
int TotalMemory = 0;
|
|
|
|
int ActualHeap = 0;
|
|
|
|
|
|
|
|
static int firstnet = 0; // JBF
|
|
|
|
|
2020-08-12 21:43:21 +00:00
|
|
|
void SW_InitMultiPsky(void)
|
|
|
|
{
|
|
|
|
// default
|
|
|
|
psky_t* const defaultsky = tileSetupSky(DEFAULTPSKY);
|
|
|
|
defaultsky->lognumtiles = 1;
|
|
|
|
defaultsky->horizfrac = 8192;
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-08 23:55:30 +00:00
|
|
|
bool InitGame()
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
extern int MovesPerPacket;
|
|
|
|
//void *ReserveMem=NULL;
|
|
|
|
int i;
|
|
|
|
|
2020-02-01 22:05:43 +00:00
|
|
|
engineInit();
|
2020-04-12 05:50:24 +00:00
|
|
|
{
|
|
|
|
auto pal = fileSystem.LoadFile("3drealms.pal", 0);
|
|
|
|
if (pal.Size() >= 768)
|
|
|
|
{
|
|
|
|
for (auto& c : pal)
|
|
|
|
c <<= 2;
|
|
|
|
|
2020-05-23 12:40:54 +00:00
|
|
|
paletteSetColorTable(DREALMSPAL, pal.Data(), true, true);
|
2020-04-12 05:50:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
timerInit(120);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
InitPalette();
|
|
|
|
// sets numplayers, connecthead, connectpoint2, myconnectindex
|
|
|
|
|
2019-11-19 21:35:52 +00:00
|
|
|
numplayers = 1; myconnectindex = 0;
|
|
|
|
connecthead = 0; connectpoint2[0] = -1;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// code to duplicate packets
|
|
|
|
if (numplayers > 4 && MovesPerPacket == 1)
|
|
|
|
{
|
|
|
|
MovesPerPacket = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
MultiSharewareCheck();
|
|
|
|
|
|
|
|
if (numplayers > 1)
|
|
|
|
{
|
|
|
|
CommPlayers = numplayers;
|
|
|
|
OrigCommPlayers = CommPlayers;
|
|
|
|
CommEnabled = TRUE;
|
2020-08-12 22:45:50 +00:00
|
|
|
gNet.MultiGameType = MULTI_GAME_COMMBAT;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 14:41:08 +00:00
|
|
|
TileFiles.LoadArtSet("tiles%03d.art");
|
2020-08-15 18:29:13 +00:00
|
|
|
InitFonts();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-16 08:40:20 +00:00
|
|
|
//Connect();
|
2015-05-19 21:54:34 +00:00
|
|
|
SortBreakInfo();
|
|
|
|
parallaxtype = 1;
|
2015-05-19 22:05:20 +00:00
|
|
|
SW_InitMultiPsky();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
memset(Track, 0, sizeof(Track));
|
|
|
|
|
|
|
|
memset(Player, 0, sizeof(Player));
|
|
|
|
for (i = 0; i < MAX_SW_PLAYERS; i++)
|
|
|
|
INITLIST(&Player[i].PanelSpriteList);
|
|
|
|
|
|
|
|
LoadKVXFromScript("swvoxfil.txt"); // Load voxels from script file
|
|
|
|
LoadPLockFromScript("swplock.txt"); // Get Parental Lock setup info
|
2019-12-08 23:33:14 +00:00
|
|
|
|
2019-12-26 13:04:53 +00:00
|
|
|
LoadCustomInfoFromScript("engine/swcustom.txt"); // load the internal definitions. These also apply to the shareware version.
|
2015-05-19 21:54:34 +00:00
|
|
|
if (!SW_SHAREWARE)
|
2019-12-08 23:33:14 +00:00
|
|
|
{
|
2015-05-19 21:54:34 +00:00
|
|
|
LoadCustomInfoFromScript("swcustom.txt"); // Load user customisation information
|
2019-12-08 23:33:14 +00:00
|
|
|
}
|
|
|
|
|
2020-04-11 21:45:45 +00:00
|
|
|
if (!loaddefinitionsfile(G_DefFile())) Printf("Definitions file loaded.\n");
|
2015-05-19 22:07:18 +00:00
|
|
|
|
2019-11-01 18:25:42 +00:00
|
|
|
userConfig.AddDefs.reset();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-02-01 22:05:43 +00:00
|
|
|
enginePostInit();
|
2015-09-23 17:54:42 +00:00
|
|
|
|
2020-04-28 20:55:37 +00:00
|
|
|
videoInit();
|
2019-12-22 10:20:13 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
InitFX(); // JBF: do it down here so we get a hold of the window handle
|
2019-12-08 23:55:30 +00:00
|
|
|
return true;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-09 19:12:54 +00:00
|
|
|
FString ThemeSongs[6];
|
|
|
|
int ThemeTrack[6];
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void InitNewGame(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i, ready_bak;
|
|
|
|
int ver_bak;
|
|
|
|
|
|
|
|
//waitforeverybody(); // since ready flag resets after this point, need to carefully sync
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_SW_PLAYERS; i++)
|
|
|
|
{
|
|
|
|
// don't jack with the playerreadyflag
|
|
|
|
ready_bak = Player[i].playerreadyflag;
|
|
|
|
ver_bak = Player[i].PlayerVersion;
|
|
|
|
memset(&Player[i], 0, sizeof(Player[i]));
|
|
|
|
Player[i].playerreadyflag = ready_bak;
|
|
|
|
Player[i].PlayerVersion = ver_bak;
|
|
|
|
INITLIST(&Player[i].PanelSpriteList);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(puser, 0, sizeof(puser));
|
|
|
|
}
|
|
|
|
|
|
|
|
int ChopTics;
|
2015-05-19 21:58:29 +00:00
|
|
|
void InitLevelGlobals(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
extern char PlayerGravity;
|
|
|
|
extern short wait_active_check_offset;
|
|
|
|
//extern short Zombies;
|
|
|
|
extern int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
|
2015-05-19 21:58:29 +00:00
|
|
|
extern SWBOOL left_foot;
|
|
|
|
extern SWBOOL serpwasseen;
|
|
|
|
extern SWBOOL sumowasseen;
|
|
|
|
extern SWBOOL zillawasseen;
|
2015-05-19 21:54:34 +00:00
|
|
|
extern short BossSpriteNum[3];
|
|
|
|
|
|
|
|
ChopTics = 0;
|
|
|
|
dimensionmode = 3;
|
|
|
|
zoom = 768;
|
|
|
|
PlayerGravity = 24;
|
|
|
|
wait_active_check_offset = 0;
|
|
|
|
PlaxCeilGlobZadjust = PlaxFloorGlobZadjust = Z(500);
|
|
|
|
FinishedLevel = FALSE;
|
|
|
|
AnimCnt = 0;
|
|
|
|
left_foot = FALSE;
|
|
|
|
screenpeek = myconnectindex;
|
2020-04-13 21:13:38 +00:00
|
|
|
numinterpolations = short_numinterpolations = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
gNet.TimeLimitClock = gNet.TimeLimit;
|
|
|
|
|
|
|
|
serpwasseen = FALSE;
|
|
|
|
sumowasseen = FALSE;
|
|
|
|
zillawasseen = FALSE;
|
|
|
|
memset(BossSpriteNum,-1,sizeof(BossSpriteNum));
|
2020-04-14 15:57:09 +00:00
|
|
|
|
2020-08-15 20:31:44 +00:00
|
|
|
PedanticMode = false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void InitLevelGlobals2(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
extern short Bunny_Count;
|
|
|
|
// GLOBAL RESETS NOT DONE for LOAD GAME
|
|
|
|
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
InitTimingVars();
|
|
|
|
TotalKillable = 0;
|
|
|
|
Bunny_Count = 0;
|
2020-07-13 20:20:14 +00:00
|
|
|
FinishAnim = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
|
|
|
InitLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-02-29 11:33:35 +00:00
|
|
|
if (LoadGameOutsideMoveLoop)
|
|
|
|
{
|
|
|
|
InitLevelGlobals();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
static int DemoNumber = 0;
|
|
|
|
|
|
|
|
Terminate3DSounds();
|
|
|
|
|
|
|
|
// A few IMPORTANT GLOBAL RESETS
|
|
|
|
InitLevelGlobals();
|
|
|
|
|
2020-08-15 20:31:44 +00:00
|
|
|
Mus_Stop();
|
2020-02-01 09:50:40 +00:00
|
|
|
|
2020-08-16 12:39:18 +00:00
|
|
|
auto maprec = NextLevel;
|
|
|
|
NextLevel = nullptr;
|
|
|
|
if (!maprec)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-16 12:39:18 +00:00
|
|
|
NewGame = false;
|
|
|
|
return;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2020-08-16 12:39:18 +00:00
|
|
|
InitLevelGlobals2();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (NewGame)
|
|
|
|
InitNewGame();
|
|
|
|
|
2020-08-16 12:39:18 +00:00
|
|
|
if (!LoadLevel(maprec))
|
2019-12-08 23:55:30 +00:00
|
|
|
{
|
|
|
|
NewGame = false;
|
|
|
|
return;
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-16 12:39:18 +00:00
|
|
|
SetupPreCache();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sector[0].extra != -1)
|
|
|
|
{
|
2015-05-19 22:03:30 +00:00
|
|
|
NormalVisibility = g_visibility = sector[0].extra;
|
2015-05-19 21:54:34 +00:00
|
|
|
sector[0].extra = 0;
|
|
|
|
}
|
|
|
|
else
|
2015-05-19 22:03:30 +00:00
|
|
|
NormalVisibility = g_visibility;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Do Player stuff first
|
|
|
|
//
|
|
|
|
|
|
|
|
InitAllPlayers();
|
|
|
|
|
|
|
|
QueueReset();
|
|
|
|
PreMapCombineFloors();
|
|
|
|
InitMultiPlayerInfo();
|
|
|
|
InitAllPlayerSprites();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Do setup for sprite, track, panel, sector, etc
|
|
|
|
//
|
|
|
|
|
|
|
|
// Set levels up
|
|
|
|
InitTimingVars();
|
|
|
|
|
|
|
|
SpriteSetup();
|
|
|
|
SpriteSetupPost(); // post processing - already gone once through the loop
|
|
|
|
InitLighting();
|
|
|
|
|
|
|
|
TrackSetup();
|
|
|
|
|
|
|
|
PlayerPanelSetup();
|
|
|
|
SectorSetup();
|
|
|
|
JS_InitMirrors();
|
|
|
|
JS_InitLockouts(); // Setup the lockout linked lists
|
|
|
|
JS_ToggleLockouts(); // Init lockouts on/off
|
|
|
|
|
|
|
|
PlaceSectorObjectsOnTracks();
|
|
|
|
PlaceActorsOnTracks();
|
|
|
|
PostSetupSectorObject();
|
|
|
|
SetupMirrorTiles();
|
|
|
|
initlava();
|
2020-08-12 20:24:51 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
// reset NewGame
|
|
|
|
NewGame = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
|
|
|
TerminateLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-16 14:00:40 +00:00
|
|
|
if (!currentLevel) return;
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
int i, nexti, stat, pnum, ndx;
|
|
|
|
SECT_USERp *sectu;
|
|
|
|
|
|
|
|
// Free any track points
|
|
|
|
for (ndx = 0; ndx < MAX_TRACKS; ndx++)
|
|
|
|
{
|
|
|
|
if (Track[ndx].TrackPoint)
|
|
|
|
{
|
|
|
|
FreeMem(Track[ndx].TrackPoint);
|
|
|
|
// !JIM! I added null assigner
|
|
|
|
Track[ndx].TrackPoint = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear the tracks
|
|
|
|
memset(Track, 0, sizeof(Track));
|
|
|
|
|
2020-02-11 06:35:28 +00:00
|
|
|
StopFX();
|
2019-12-17 22:25:07 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
// Clear all anims and any memory associated with them
|
|
|
|
// Clear before killing sprites - save a little time
|
|
|
|
//AnimClear();
|
|
|
|
|
|
|
|
for (stat = STAT_PLAYER0; stat < STAT_PLAYER0 + numplayers; stat++)
|
|
|
|
{
|
|
|
|
|
|
|
|
pnum = stat - STAT_PLAYER0;
|
|
|
|
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[stat], i, nexti)
|
|
|
|
{
|
|
|
|
if (User[i])
|
|
|
|
memcpy(&puser[pnum], User[i], sizeof(USER));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Kill User memory and delete sprites
|
|
|
|
// for (stat = 0; stat < STAT_ALL; stat++)
|
|
|
|
for (stat = 0; stat < MAXSTATUS; stat++)
|
|
|
|
{
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[stat], i, nexti)
|
|
|
|
{
|
|
|
|
KillSprite(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Free SectUser memory
|
|
|
|
for (sectu = &SectUser[0];
|
|
|
|
sectu < &SectUser[MAXSECTORS];
|
|
|
|
sectu++)
|
|
|
|
{
|
|
|
|
if (*sectu)
|
|
|
|
{
|
|
|
|
FreeMem(*sectu);
|
|
|
|
*sectu = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//memset(&User[0], 0, sizeof(User));
|
|
|
|
memset(&SectUser[0], 0, sizeof(SectUser));
|
|
|
|
|
|
|
|
TRAVERSE_CONNECT(pnum)
|
|
|
|
{
|
|
|
|
PLAYERp pp = Player + pnum;
|
|
|
|
|
|
|
|
// Free panel sprites for players
|
|
|
|
pClearSpriteList(pp);
|
|
|
|
|
|
|
|
pp->DoPlayerAction = NULL;
|
|
|
|
|
|
|
|
pp->SpriteP = NULL;
|
|
|
|
pp->PlayerSprite = -1;
|
|
|
|
|
|
|
|
pp->UnderSpriteP = NULL;
|
|
|
|
pp->PlayerUnderSprite = -1;
|
|
|
|
|
|
|
|
memset(pp->HasKey, 0, sizeof(pp->HasKey));
|
|
|
|
|
|
|
|
//pp->WpnFlags = 0;
|
|
|
|
pp->CurWpn = NULL;
|
|
|
|
|
|
|
|
memset(pp->Wpn, 0, sizeof(pp->Wpn));
|
|
|
|
memset(pp->InventoryTics, 0, sizeof(pp->InventoryTics));
|
|
|
|
|
|
|
|
pp->Killer = -1;
|
|
|
|
|
|
|
|
INITLIST(&pp->PanelSpriteList);
|
|
|
|
}
|
|
|
|
|
|
|
|
JS_UnInitLockouts();
|
|
|
|
|
|
|
|
//HEAP_CHECK();
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void NewLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 20:31:44 +00:00
|
|
|
do
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
InitLevel();
|
2020-08-15 20:31:44 +00:00
|
|
|
RunLevel();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2020-08-15 20:31:44 +00:00
|
|
|
while (LoadGameOutsideMoveLoop);
|
|
|
|
STAT_Update(false);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-15 20:31:44 +00:00
|
|
|
if (!QuitFlag)
|
|
|
|
{
|
|
|
|
// for good measure do this
|
|
|
|
ready2send = 0;
|
|
|
|
waitforeverybody();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-08-15 20:31:44 +00:00
|
|
|
StatScreen(&Player[myconnectindex]);
|
|
|
|
|
2020-08-16 14:57:42 +00:00
|
|
|
TerminateLevel();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
InGame = FALSE;
|
|
|
|
|
|
|
|
if (SW_SHAREWARE)
|
|
|
|
{
|
|
|
|
if (FinishAnim)
|
2019-10-30 05:51:53 +00:00
|
|
|
{
|
|
|
|
PlayTheme();
|
2015-05-19 21:54:34 +00:00
|
|
|
MenuLevel();
|
2019-12-08 23:55:30 +00:00
|
|
|
STAT_Update(true);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2019-10-30 05:51:53 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FinishAnim == ANIM_ZILLA || FinishAnim == ANIM_SERP)
|
2019-10-30 05:51:53 +00:00
|
|
|
{
|
|
|
|
PlayTheme();
|
2015-05-19 21:54:34 +00:00
|
|
|
MenuLevel();
|
2019-12-08 23:55:30 +00:00
|
|
|
STAT_Update(true);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2019-10-30 05:51:53 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
|
2019-10-30 05:51:53 +00:00
|
|
|
void PlayTheme()
|
|
|
|
{
|
|
|
|
// start music at logo
|
2019-12-09 19:12:54 +00:00
|
|
|
PlaySong(nullptr, ThemeSongs[0], ThemeTrack[0]);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CTW REMOVED END
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DrawMenuLevelScreen(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 14:41:08 +00:00
|
|
|
const int TITLE_PIC = 2324;
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2020-08-15 20:04:37 +00:00
|
|
|
DrawTexture(twod, tileGetTexture(TITLE_PIC), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal,
|
|
|
|
DTA_Color, shadeToLight(20), TAG_DONE);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
short PlayerQuitMenuLevel = -1;
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void MenuLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short w,h;
|
|
|
|
|
2019-12-07 11:42:25 +00:00
|
|
|
M_StartControlPanel(false);
|
2020-04-11 22:02:48 +00:00
|
|
|
M_SetMenu(NAME_Mainmenu);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
//FadeOut(0, 0);
|
|
|
|
ready2send = 0;
|
|
|
|
totalclock = 0;
|
|
|
|
ototalclock = 0;
|
|
|
|
ExitLevel = FALSE;
|
|
|
|
InMenuLevel = TRUE;
|
|
|
|
|
|
|
|
DrawMenuLevelScreen();
|
|
|
|
|
|
|
|
if (CommEnabled)
|
|
|
|
{
|
|
|
|
sprintf(ds,"Lo Wang is waiting for other players...");
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawString(160, 170, ds, 1, 16, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
sprintf(ds,"They are afraid!");
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawString(160, 180, ds, 1, 16, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
//FadeIn(0, 3);
|
|
|
|
|
|
|
|
waitforeverybody();
|
|
|
|
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (SW_SHAREWARE)
|
|
|
|
{
|
|
|
|
// go to ordering menu only if shareware
|
|
|
|
if (FinishAnim)
|
|
|
|
{
|
2019-10-28 05:47:49 +00:00
|
|
|
inputState.ClearKeyStatus(sc_Escape);
|
2019-12-02 20:05:19 +00:00
|
|
|
M_StartControlPanel(false);
|
|
|
|
M_SetMenu(NAME_CreditsMenu);
|
2015-05-19 21:54:34 +00:00
|
|
|
FinishAnim = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FinishAnim = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
handleevents();
|
2020-07-31 06:26:16 +00:00
|
|
|
D_ProcessEvents();
|
2020-07-14 12:00:27 +00:00
|
|
|
C_RunDelayedCommands();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// limits checks to max of 40 times a second
|
|
|
|
if (totalclock >= ototalclock + synctics)
|
|
|
|
{
|
|
|
|
ototalclock += synctics;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ExitLevel)
|
|
|
|
{
|
|
|
|
ExitLevel = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QuitFlag)
|
|
|
|
{
|
|
|
|
// Quiting Game
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// must lock the clock for drawing so animations will happen
|
|
|
|
totalclocklock = totalclock;
|
|
|
|
|
|
|
|
//drawscreen as fast as you can
|
|
|
|
DrawMenuLevelScreen();
|
2019-12-19 08:31:39 +00:00
|
|
|
DoUpdateSounds();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-08-13 22:56:34 +00:00
|
|
|
inputState.ClearAllInput();
|
2019-12-02 20:05:19 +00:00
|
|
|
M_ClearMenus();
|
2015-05-19 21:54:34 +00:00
|
|
|
InMenuLevel = FALSE;
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-08 23:55:30 +00:00
|
|
|
extern SWBOOL FinishedLevel;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void EndGameSequence(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-02-13 23:52:57 +00:00
|
|
|
StopSound();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-15 14:41:08 +00:00
|
|
|
//playanm(FinishAnim);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-15 13:29:47 +00:00
|
|
|
//BonusScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ExitLevel = FALSE;
|
|
|
|
QuitFlag = FALSE;
|
|
|
|
|
2020-08-15 14:41:08 +00:00
|
|
|
//if (FinishAnim == ANIM_ZILLA)
|
|
|
|
// CreditsLevel();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ExitLevel = FALSE;
|
|
|
|
QuitFlag = FALSE;
|
|
|
|
|
2020-08-16 12:39:18 +00:00
|
|
|
if (currentLevel->levelNumber != 4 && currentLevel->levelNumber != 20)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-16 12:39:18 +00:00
|
|
|
NextLevel = FindMapByLevelNum(currentLevel->levelNumber + 1);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void StatScreen(PLAYERp mpp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
extern SWBOOL FinishedLevel;
|
2015-05-19 21:54:34 +00:00
|
|
|
short w,h;
|
|
|
|
|
|
|
|
short rows,cols,i,j;
|
|
|
|
PLAYERp pp = NULL;
|
|
|
|
int x,y;
|
|
|
|
short pal;
|
|
|
|
|
2019-12-02 20:05:19 +00:00
|
|
|
//ResetPalette(mpp);
|
2015-05-19 21:54:34 +00:00
|
|
|
COVER_SetReverb(0); // Reset reverb
|
2020-02-05 19:25:18 +00:00
|
|
|
mpp->Reverb = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
StopSound();
|
2020-02-05 19:25:18 +00:00
|
|
|
soundEngine->UpdateSounds((int)totalclock);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (FinishAnim)
|
|
|
|
{
|
|
|
|
EndGameSequence();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gNet.MultiGameType != MULTI_GAME_COMMBAT)
|
|
|
|
{
|
|
|
|
if (!FinishedLevel)
|
|
|
|
return;
|
2020-08-15 13:29:47 +00:00
|
|
|
//BonusScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-08-15 13:29:47 +00:00
|
|
|
//MPBonusScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void GameIntro(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 11:04:15 +00:00
|
|
|
Logo([](bool) { gamestate = GS_LEVEL; });
|
|
|
|
SyncScreenJob();
|
2015-05-19 21:54:34 +00:00
|
|
|
MenuLevel();
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void Control()
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-10-31 23:32:56 +00:00
|
|
|
InitGame();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
InGame = TRUE;
|
|
|
|
GameIntro();
|
|
|
|
|
|
|
|
while (!QuitFlag)
|
|
|
|
{
|
|
|
|
handleevents();
|
2020-07-14 12:00:27 +00:00
|
|
|
C_RunDelayedCommands();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
NewLevel();
|
|
|
|
}
|
|
|
|
|
2020-08-16 15:09:59 +00:00
|
|
|
//SybexScreen();
|
2020-04-11 21:50:43 +00:00
|
|
|
throw CExitEvent(0);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void _Assert(const char *expr, const char *strFile, unsigned uLine)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-24 18:59:14 +00:00
|
|
|
I_FatalError("Assertion failed: %s %s, line %u", expr, strFile, uLine);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-11 07:17:59 +00:00
|
|
|
void getinput(SW_PACKET *, SWBOOL);
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
void MoveLoop(void)
|
|
|
|
{
|
|
|
|
int pnum;
|
|
|
|
|
2020-08-16 08:40:20 +00:00
|
|
|
//getpackets();
|
2020-05-19 11:44:52 +00:00
|
|
|
|
|
|
|
if (PredictionOn && CommEnabled)
|
|
|
|
{
|
|
|
|
while (predictmovefifoplc < Player[myconnectindex].movefifoend)
|
|
|
|
{
|
|
|
|
DoPrediction(ppp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//While you have new input packets to process...
|
|
|
|
if (!CommEnabled)
|
|
|
|
bufferjitter = 0;
|
|
|
|
|
|
|
|
while (Player[myconnectindex].movefifoend - movefifoplc > bufferjitter)
|
|
|
|
{
|
|
|
|
//Make sure you have at least 1 packet from everyone else
|
|
|
|
for (pnum=connecthead; pnum>=0; pnum=connectpoint2[pnum])
|
|
|
|
{
|
|
|
|
if (movefifoplc == Player[pnum].movefifoend)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Pnum is >= 0 only if last loop was broken, meaning a player wasn't caught up
|
|
|
|
if (pnum >= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
domovethings();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
void InitPlayerGameSettings(void)
|
|
|
|
{
|
|
|
|
int pnum;
|
|
|
|
|
|
|
|
if (CommEnabled)
|
|
|
|
{
|
|
|
|
// everyone gets the same Auto Aim
|
|
|
|
TRAVERSE_CONNECT(pnum)
|
|
|
|
{
|
|
|
|
if (gNet.AutoAim)
|
|
|
|
SET(Player[pnum].Flags, PF_AUTO_AIM);
|
|
|
|
else
|
|
|
|
RESET(Player[pnum].Flags, PF_AUTO_AIM);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-21 22:05:21 +00:00
|
|
|
if (cl_autoaim)
|
2015-05-19 21:54:34 +00:00
|
|
|
SET(Player[myconnectindex].Flags, PF_AUTO_AIM);
|
|
|
|
else
|
|
|
|
RESET(Player[myconnectindex].Flags, PF_AUTO_AIM);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void InitRunLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (LoadGameOutsideMoveLoop)
|
|
|
|
{
|
|
|
|
int SavePlayClock;
|
|
|
|
extern int PlayClock;
|
|
|
|
LoadGameOutsideMoveLoop = FALSE;
|
|
|
|
// contains what is needed from calls below
|
2019-10-22 00:01:05 +00:00
|
|
|
if (snd_ambience)
|
2015-05-19 21:54:34 +00:00
|
|
|
StartAmbientSound();
|
|
|
|
// crappy little hack to prevent play clock from being overwritten
|
|
|
|
// for load games
|
|
|
|
SavePlayClock = PlayClock;
|
|
|
|
InitTimingVars();
|
|
|
|
PlayClock = SavePlayClock;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-16 08:40:20 +00:00
|
|
|
//SendVersion(GameVersion);
|
|
|
|
//waitforeverybody();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-07 18:57:19 +00:00
|
|
|
Mus_Stop();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-16 12:39:18 +00:00
|
|
|
DoTheCache();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// auto aim / auto run / etc
|
|
|
|
InitPlayerGameSettings();
|
|
|
|
|
|
|
|
// send packets with player info
|
|
|
|
InitNetPlayerOptions();
|
|
|
|
|
|
|
|
// Initialize Game part of network code (When ready2send != 0)
|
|
|
|
InitNetVars();
|
|
|
|
|
2020-08-16 12:39:18 +00:00
|
|
|
if (currentLevel)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-16 12:39:18 +00:00
|
|
|
PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
InitPrediction(&Player[myconnectindex]);
|
|
|
|
|
|
|
|
waitforeverybody();
|
|
|
|
|
2020-08-16 08:40:20 +00:00
|
|
|
//CheckVersion(GameVersion);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// IMPORTANT - MUST be right before game loop AFTER waitforeverybody
|
|
|
|
InitTimingVars();
|
|
|
|
|
2019-10-22 00:01:05 +00:00
|
|
|
if (snd_ambience)
|
2015-05-19 21:54:34 +00:00
|
|
|
StartAmbientSound();
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void RunLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
InitRunLevel();
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
waitforeverybody();
|
|
|
|
#endif
|
|
|
|
ready2send = 1;
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
handleevents();
|
2020-07-14 12:00:27 +00:00
|
|
|
C_RunDelayedCommands();
|
2019-11-20 21:01:44 +00:00
|
|
|
D_ProcessEvents();
|
2020-02-01 09:50:40 +00:00
|
|
|
if (LoadGameOutsideMoveLoop)
|
|
|
|
{
|
2020-02-01 12:07:58 +00:00
|
|
|
return; // Stop the game loop if a savegame was loaded from the menu.
|
2020-02-01 09:50:40 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-29 00:32:53 +00:00
|
|
|
updatePauseStatus();
|
|
|
|
|
|
|
|
if (paused)
|
2020-01-05 17:49:19 +00:00
|
|
|
{
|
2020-05-20 10:44:04 +00:00
|
|
|
ototalclock = (int)totalclock - (120 / synctics);
|
|
|
|
buttonMap.ResetButtonStates();
|
2020-01-05 17:49:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-29 00:32:53 +00:00
|
|
|
while (ready2send && (totalclock >= ototalclock + synctics))
|
|
|
|
{
|
|
|
|
UpdateInputs();
|
|
|
|
MoveLoop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get input again to update q16ang/q16horiz.
|
|
|
|
if (!PedanticMode)
|
|
|
|
getinput(&loc, TRUE);
|
2020-05-19 10:03:52 +00:00
|
|
|
}
|
2019-11-20 21:01:44 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
drawscreen(Player + screenpeek);
|
|
|
|
|
|
|
|
if (QuitFlag)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (ExitLevel)
|
|
|
|
{
|
|
|
|
ExitLevel = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ready2send = 0;
|
|
|
|
}
|
|
|
|
|
2020-04-11 22:10:39 +00:00
|
|
|
static const char* actions[] = {
|
|
|
|
"Move_Forward",
|
|
|
|
"Move_Backward",
|
|
|
|
"Turn_Left",
|
|
|
|
"Turn_Right",
|
|
|
|
"Strafe",
|
|
|
|
"Fire",
|
|
|
|
"Open",
|
|
|
|
"Run",
|
|
|
|
"Alt_Fire", // Duke3D", Blood
|
|
|
|
"Jump",
|
|
|
|
"Crouch",
|
|
|
|
"Look_Up",
|
|
|
|
"Look_Down",
|
|
|
|
"Look_Left",
|
|
|
|
"Look_Right",
|
|
|
|
"Strafe_Left",
|
|
|
|
"Strafe_Right",
|
|
|
|
"Aim_Up",
|
|
|
|
"Aim_Down",
|
|
|
|
"SendMessage",
|
|
|
|
"Map",
|
|
|
|
"Shrink_Screen",
|
|
|
|
"Enlarge_Screen",
|
|
|
|
"Show_Opponents_Weapon",
|
|
|
|
"Map_Follow_Mode",
|
|
|
|
"See_Coop_View",
|
|
|
|
"Mouse_Aiming",
|
|
|
|
"Dpad_Select",
|
|
|
|
"Dpad_Aiming",
|
|
|
|
"Last_Weapon",
|
|
|
|
"Alt_Weapon",
|
|
|
|
"Third_Person_View",
|
|
|
|
"Toggle_Crouch", // This is the last one used by EDuke32"",
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-11-03 11:32:58 +00:00
|
|
|
int32_t GameInterface::app_main()
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
extern int MovesPerPacket;
|
2015-05-19 21:58:29 +00:00
|
|
|
void DoSector(void);
|
|
|
|
void gameinput(void);
|
2015-05-19 21:54:34 +00:00
|
|
|
int cnt = 0;
|
|
|
|
|
2020-08-12 20:24:51 +00:00
|
|
|
InitCheats();
|
2020-04-11 22:10:39 +00:00
|
|
|
buttonMap.SetButtons(actions, NUM_ACTIONS);
|
2019-12-31 21:05:23 +00:00
|
|
|
automapping = 1;
|
2020-08-13 22:56:34 +00:00
|
|
|
|
2020-08-12 22:04:55 +00:00
|
|
|
gs = gs_defaults;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_SW_PLAYERS; i++)
|
|
|
|
INITLIST(&Player[i].PanelSpriteList);
|
|
|
|
|
|
|
|
DebugOperate = TRUE;
|
2020-02-10 21:38:17 +00:00
|
|
|
enginecompatibility_mode = ENGINECOMPATIBILITY_19961112;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-11-29 07:53:31 +00:00
|
|
|
if (SW_SHAREWARE)
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("SHADOW WARRIOR(tm) Version 1.2 (Shareware Version)\n");
|
2019-11-29 07:53:31 +00:00
|
|
|
else
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("SHADOW WARRIOR(tm) Version 1.2\n");
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-02-02 07:53:10 +00:00
|
|
|
if (sw_snd_scratch == 0) // This is always 0 at this point - this check is only here to prevent whole program optimization from eliminating the variable.
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Copyright (c) 1997 3D Realms Entertainment\n");
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-01-23 10:50:12 +00:00
|
|
|
registerosdcommands();
|
2020-08-16 14:00:40 +00:00
|
|
|
registerinputcommands();
|
2020-01-23 10:50:12 +00:00
|
|
|
|
2019-10-31 23:32:56 +00:00
|
|
|
Control();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-30 06:10:26 +00:00
|
|
|
char WangBangMacro[10][64];
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#define MAP_WHITE_SECTOR (LT_GREY + 2)
|
|
|
|
#define MAP_RED_SECTOR (RED + 6)
|
|
|
|
#define MAP_FLOOR_SPRITE (RED + 8)
|
|
|
|
#define MAP_ENEMY (RED + 10)
|
|
|
|
#define MAP_SPRITE (FIRE + 8)
|
|
|
|
#define MAP_PLAYER (GREEN + 6)
|
|
|
|
|
|
|
|
#define MAP_BLOCK_SPRITE (DK_BLUE + 6)
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
void drawoverheadmap(int cposx, int cposy, int czoom, short cang)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i, j, k, l, x1, y1, x2, y2, x3, y3, x4, y4, ox, oy, xoff, yoff;
|
|
|
|
int dax, day, cosang, sinang, xspan, yspan, sprx, spry;
|
|
|
|
int xrepeat, yrepeat, z1, z2, startwall, endwall, tilenum, daang;
|
|
|
|
int xvect, yvect, xvect2, yvect2;
|
|
|
|
char col;
|
|
|
|
walltype *wal, *wal2;
|
|
|
|
spritetype *spr;
|
|
|
|
short p;
|
|
|
|
static int pspr_ndx[8]= {0,0,0,0,0,0,0,0};
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL sprisplayer = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
short txt_x, txt_y;
|
|
|
|
|
2019-12-31 21:11:04 +00:00
|
|
|
int32_t tmpydim = (xdim * 5) / 8;
|
|
|
|
renderSetAspect(65536, divscale16(tmpydim * 320, xdim * 200));
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
// draw location text
|
2020-08-16 00:55:50 +00:00
|
|
|
if (hud_size == Hud_Nothing)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
txt_x = 7;
|
|
|
|
txt_y = 168;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
txt_x = 7;
|
|
|
|
txt_y = 147;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ScrollMode2D)
|
|
|
|
{
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawSmallString(txt_x, txt_y - 7, "Follow Mode", 0, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-12-11 01:01:11 +00:00
|
|
|
sprintf(ds,"%s",currentLevel->DisplayName());
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawSmallString(txt_x,txt_y,ds,0, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
//////////////////////////////////
|
|
|
|
|
|
|
|
xvect = sintable[(2048 - cang) & 2047] * czoom;
|
|
|
|
yvect = sintable[(1536 - cang) & 2047] * czoom;
|
2017-06-24 09:20:21 +00:00
|
|
|
xvect2 = mulscale16(xvect, yxaspect);
|
|
|
|
yvect2 = mulscale16(yvect, yxaspect);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Draw red lines
|
|
|
|
for (i = 0; i < numsectors; i++)
|
|
|
|
{
|
|
|
|
startwall = sector[i].wallptr;
|
|
|
|
endwall = sector[i].wallptr + sector[i].wallnum - 1;
|
|
|
|
|
|
|
|
z1 = sector[i].ceilingz;
|
|
|
|
z2 = sector[i].floorz;
|
|
|
|
|
|
|
|
for (j = startwall, wal = &wall[startwall]; j <= endwall; j++, wal++)
|
|
|
|
{
|
|
|
|
k = wal->nextwall;
|
2019-11-27 07:33:34 +00:00
|
|
|
if ((unsigned)k >= MAXWALLS)
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
2020-03-01 15:33:06 +00:00
|
|
|
if (!mapcheat)
|
|
|
|
{
|
|
|
|
if ((show2dwall[j >> 3] & (1 << (j & 7))) == 0)
|
|
|
|
continue;
|
|
|
|
if ((k > j) && ((show2dwall[k >> 3] & (1 << (k & 7))) > 0))
|
|
|
|
continue;
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (sector[wal->nextsector].ceilingz == z1)
|
|
|
|
if (sector[wal->nextsector].floorz == z2)
|
|
|
|
if (((wal->cstat | wall[wal->nextwall].cstat) & (16 + 32)) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
col = 152;
|
|
|
|
|
|
|
|
//if (dimensionmode == 2)
|
|
|
|
if (dimensionmode == 6)
|
|
|
|
{
|
|
|
|
if (sector[i].floorz != sector[i].ceilingz)
|
|
|
|
if (sector[wal->nextsector].floorz != sector[wal->nextsector].ceilingz)
|
|
|
|
if (((wal->cstat | wall[wal->nextwall].cstat) & (16 + 32)) == 0)
|
|
|
|
if (sector[i].floorz == sector[wal->nextsector].floorz)
|
|
|
|
continue;
|
|
|
|
if (sector[i].floorpicnum != sector[wal->nextsector].floorpicnum)
|
|
|
|
continue;
|
|
|
|
if (sector[i].floorshade != sector[wal->nextsector].floorshade)
|
|
|
|
continue;
|
2019-11-17 17:02:17 +00:00
|
|
|
col = 12; // 1=white / 31=black / 44=green / 56=pink / 128=yellow / 210=blue / 248=orange / 255=purple
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ox = wal->x - cposx;
|
|
|
|
oy = wal->y - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
wal2 = &wall[wal->point2];
|
|
|
|
ox = wal2->x - cposx;
|
|
|
|
oy = wal2->y - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x2 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y2 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
renderDrawLine(x1 + (xdim << 11), y1 + (ydim << 11), x2 + (xdim << 11), y2 + (ydim << 11), col);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw sprites
|
|
|
|
k = Player[screenpeek].PlayerSprite;
|
|
|
|
for (i = 0; i < numsectors; i++)
|
|
|
|
for (j = headspritesect[i]; j >= 0; j = nextspritesect[j])
|
|
|
|
{
|
|
|
|
for (p=connecthead; p >= 0; p=connectpoint2[p])
|
|
|
|
{
|
|
|
|
if (Player[p].PlayerSprite == j)
|
|
|
|
{
|
|
|
|
if (sprite[Player[p].PlayerSprite].xvel > 16)
|
2019-08-27 13:39:54 +00:00
|
|
|
pspr_ndx[myconnectindex] = (((int32_t) totalclock>>4)&3);
|
2015-05-19 21:54:34 +00:00
|
|
|
sprisplayer = TRUE;
|
|
|
|
|
|
|
|
goto SHOWSPRITE;
|
|
|
|
}
|
|
|
|
}
|
2020-03-01 15:33:06 +00:00
|
|
|
if (mapcheat || (show2dsprite[j >> 3] & (1 << (j & 7))) > 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
SHOWSPRITE:
|
|
|
|
spr = &sprite[j];
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
col = 56; // 1=white / 31=black / 44=green / 56=pink / 128=yellow / 210=blue / 248=orange / 255=purple
|
2015-05-19 21:54:34 +00:00
|
|
|
if ((spr->cstat & 1) > 0)
|
|
|
|
col = 248;
|
|
|
|
if (j == k)
|
|
|
|
col = 31;
|
|
|
|
|
|
|
|
sprx = spr->x;
|
|
|
|
spry = spr->y;
|
|
|
|
|
|
|
|
k = spr->statnum;
|
|
|
|
if ((k >= 1) && (k <= 8) && (k != 2)) // Interpolate moving
|
|
|
|
{
|
|
|
|
sprx = sprite[j].x;
|
|
|
|
spry = sprite[j].y;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (spr->cstat & 48)
|
|
|
|
{
|
|
|
|
case 0: // Regular sprite
|
|
|
|
if (Player[p].PlayerSprite == j)
|
|
|
|
{
|
|
|
|
ox = sprx - cposx;
|
|
|
|
oy = spry - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (dimensionmode == 5 && (gNet.MultiGameType != MULTI_GAME_COMMBAT || j == Player[screenpeek].PlayerSprite))
|
|
|
|
{
|
|
|
|
ox = (sintable[(spr->ang + 512) & 2047] >> 7);
|
|
|
|
oy = (sintable[(spr->ang) & 2047] >> 7);
|
2017-06-24 09:20:21 +00:00
|
|
|
x2 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y2 = mulscale16(oy, xvect) + mulscale16(ox, yvect);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (j == Player[screenpeek].PlayerSprite)
|
|
|
|
{
|
|
|
|
x2 = 0L;
|
|
|
|
y2 = -(czoom << 5);
|
|
|
|
}
|
|
|
|
|
2017-06-24 09:20:21 +00:00
|
|
|
x3 = mulscale16(x2, yxaspect);
|
|
|
|
y3 = mulscale16(y2, yxaspect);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
renderDrawLine(x1 - x2 + (xdim << 11), y1 - y3 + (ydim << 11),
|
|
|
|
x1 + x2 + (xdim << 11), y1 + y3 + (ydim << 11), col);
|
|
|
|
renderDrawLine(x1 - y2 + (xdim << 11), y1 + x3 + (ydim << 11),
|
|
|
|
x1 + x2 + (xdim << 11), y1 + y3 + (ydim << 11), col);
|
|
|
|
renderDrawLine(x1 + y2 + (xdim << 11), y1 - x3 + (ydim << 11),
|
|
|
|
x1 + x2 + (xdim << 11), y1 + y3 + (ydim << 11), col);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (((gotsector[i >> 3] & (1 << (i & 7))) > 0) && (czoom > 192))
|
|
|
|
{
|
|
|
|
daang = (spr->ang - cang) & 2047;
|
|
|
|
if (j == Player[screenpeek].PlayerSprite)
|
|
|
|
{
|
|
|
|
x1 = 0;
|
|
|
|
//y1 = (yxaspect << 2);
|
|
|
|
y1 = 0;
|
|
|
|
daang = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special case tiles
|
|
|
|
if (spr->picnum == 3123) break;
|
|
|
|
|
2020-08-15 20:04:37 +00:00
|
|
|
int spnum = -1;
|
2015-05-19 21:54:34 +00:00
|
|
|
if (sprisplayer)
|
|
|
|
{
|
|
|
|
if (gNet.MultiGameType != MULTI_GAME_COMMBAT || j == Player[screenpeek].PlayerSprite)
|
2020-08-15 20:04:37 +00:00
|
|
|
spnum = 1196 + pspr_ndx[myconnectindex];
|
|
|
|
}
|
|
|
|
else spnum = spr->picnum;
|
|
|
|
|
|
|
|
double xd = ((x1 << 4) + (xdim << 15)) / 65536.;
|
|
|
|
double yd = ((y1 << 4) + (ydim << 15)) / 65536.;
|
|
|
|
double sc = mulscale16(czoom * (spr->yrepeat), yxaspect) / 65536.;
|
|
|
|
if (spnum >= 0)
|
|
|
|
{
|
|
|
|
DrawTexture(twod, tileGetTexture(5407, true), xd, yd, DTA_FullscreenScale, FSMode_ScaleToFit43, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200,
|
|
|
|
DTA_CenterOffsetRel, true, DTA_TranslationIndex, TRANSLATION(Translation_Remap, spr->pal), DTA_Color, shadeToLight(spr->shade),
|
|
|
|
DTA_Alpha, (spr->cstat & 2) ? 0.33 : 1., TAG_DONE);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16: // Rotated sprite
|
|
|
|
x1 = sprx;
|
|
|
|
y1 = spry;
|
|
|
|
tilenum = spr->picnum;
|
2020-05-24 10:31:38 +00:00
|
|
|
xoff = (int)tileLeftOffset(tilenum) + (int)spr->xoffset;
|
2015-05-19 21:54:34 +00:00
|
|
|
if ((spr->cstat & 4) > 0)
|
|
|
|
xoff = -xoff;
|
|
|
|
k = spr->ang;
|
|
|
|
l = spr->xrepeat;
|
|
|
|
dax = sintable[k & 2047] * l;
|
|
|
|
day = sintable[(k + 1536) & 2047] * l;
|
2015-05-19 22:02:25 +00:00
|
|
|
l = tilesiz[tilenum].x;
|
2015-05-19 21:54:34 +00:00
|
|
|
k = (l >> 1) + xoff;
|
2017-06-24 09:20:21 +00:00
|
|
|
x1 -= mulscale16(dax, k);
|
|
|
|
x2 = x1 + mulscale16(dax, l);
|
|
|
|
y1 -= mulscale16(day, k);
|
|
|
|
y2 = y1 + mulscale16(day, l);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ox = x1 - cposx;
|
|
|
|
oy = y1 - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ox = x2 - cposx;
|
|
|
|
oy = y2 - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x2 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y2 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
renderDrawLine(x1 + (xdim << 11), y1 + (ydim << 11),
|
|
|
|
x2 + (xdim << 11), y2 + (ydim << 11), col);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
case 32: // Floor sprite
|
|
|
|
if (dimensionmode == 5)
|
|
|
|
{
|
|
|
|
tilenum = spr->picnum;
|
2020-05-24 10:31:38 +00:00
|
|
|
xoff = (int)tileLeftOffset(tilenum) + (int)spr->xoffset;
|
|
|
|
yoff = (int)tileTopOffset(tilenum) + (int)spr->yoffset;
|
2015-05-19 21:54:34 +00:00
|
|
|
if ((spr->cstat & 4) > 0)
|
|
|
|
xoff = -xoff;
|
|
|
|
if ((spr->cstat & 8) > 0)
|
|
|
|
yoff = -yoff;
|
|
|
|
|
|
|
|
k = spr->ang;
|
|
|
|
cosang = sintable[(k + 512) & 2047];
|
|
|
|
sinang = sintable[k];
|
2015-05-19 22:02:25 +00:00
|
|
|
xspan = tilesiz[tilenum].x;
|
2015-05-19 21:54:34 +00:00
|
|
|
xrepeat = spr->xrepeat;
|
2015-05-19 22:02:25 +00:00
|
|
|
yspan = tilesiz[tilenum].y;
|
2015-05-19 21:54:34 +00:00
|
|
|
yrepeat = spr->yrepeat;
|
|
|
|
|
|
|
|
dax = ((xspan >> 1) + xoff) * xrepeat;
|
|
|
|
day = ((yspan >> 1) + yoff) * yrepeat;
|
2017-06-24 09:20:21 +00:00
|
|
|
x1 = sprx + mulscale16(sinang, dax) + mulscale16(cosang, day);
|
|
|
|
y1 = spry + mulscale16(sinang, day) - mulscale16(cosang, dax);
|
2015-05-19 21:54:34 +00:00
|
|
|
l = xspan * xrepeat;
|
2017-06-24 09:20:21 +00:00
|
|
|
x2 = x1 - mulscale16(sinang, l);
|
|
|
|
y2 = y1 + mulscale16(cosang, l);
|
2015-05-19 21:54:34 +00:00
|
|
|
l = yspan * yrepeat;
|
2017-06-24 09:20:21 +00:00
|
|
|
k = -mulscale16(cosang, l);
|
2015-05-19 21:54:34 +00:00
|
|
|
x3 = x2 + k;
|
|
|
|
x4 = x1 + k;
|
2017-06-24 09:20:21 +00:00
|
|
|
k = -mulscale16(sinang, l);
|
2015-05-19 21:54:34 +00:00
|
|
|
y3 = y2 + k;
|
|
|
|
y4 = y1 + k;
|
|
|
|
|
|
|
|
ox = x1 - cposx;
|
|
|
|
oy = y1 - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ox = x2 - cposx;
|
|
|
|
oy = y2 - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x2 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y2 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ox = x3 - cposx;
|
|
|
|
oy = y3 - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x3 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y3 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ox = x4 - cposx;
|
|
|
|
oy = y4 - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x4 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y4 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
renderDrawLine(x1 + (xdim << 11), y1 + (ydim << 11),
|
|
|
|
x2 + (xdim << 11), y2 + (ydim << 11), col);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
renderDrawLine(x2 + (xdim << 11), y2 + (ydim << 11),
|
|
|
|
x3 + (xdim << 11), y3 + (ydim << 11), col);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
renderDrawLine(x3 + (xdim << 11), y3 + (ydim << 11),
|
|
|
|
x4 + (xdim << 11), y4 + (ydim << 11), col);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
renderDrawLine(x4 + (xdim << 11), y4 + (ydim << 11),
|
|
|
|
x1 + (xdim << 11), y1 + (ydim << 11), col);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Draw white lines
|
|
|
|
for (i = 0; i < numsectors; i++)
|
|
|
|
{
|
|
|
|
startwall = sector[i].wallptr;
|
|
|
|
endwall = sector[i].wallptr + sector[i].wallnum - 1;
|
|
|
|
|
|
|
|
for (j = startwall, wal = &wall[startwall]; j <= endwall; j++, wal++)
|
|
|
|
{
|
2019-11-27 07:33:34 +00:00
|
|
|
if ((uint16_t)wal->nextwall < MAXWALLS)
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
2020-03-01 15:33:06 +00:00
|
|
|
if (!mapcheat && (show2dwall[j >> 3] & (1 << (j & 7))) == 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
2020-06-15 19:57:59 +00:00
|
|
|
if (!tileGetTexture(wal->picnum)->isValid()) continue;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ox = wal->x - cposx;
|
|
|
|
oy = wal->y - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x1 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y1 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
wal2 = &wall[wal->point2];
|
|
|
|
ox = wal2->x - cposx;
|
|
|
|
oy = wal2->y - cposy;
|
2017-06-24 09:20:21 +00:00
|
|
|
x2 = mulscale16(ox, xvect) - mulscale16(oy, yvect);
|
|
|
|
y2 = mulscale16(oy, xvect2) + mulscale16(ox, yvect2);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
renderDrawLine(x1 + (xdim << 11), y1 + (ydim << 11), x2 + (xdim << 11), y2 + (ydim << 11), 24);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-31 21:11:04 +00:00
|
|
|
videoSetCorrectedAspect();
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
int RandomRange(int range)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
uint32_t rand_num;
|
|
|
|
uint32_t value;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (range <= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rand_num = RANDOM();
|
|
|
|
|
|
|
|
if (rand_num == 65535U)
|
|
|
|
rand_num--;
|
|
|
|
|
|
|
|
// shift values to give more precision
|
|
|
|
value = (rand_num << 14) / ((65535UL << 14) / range);
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
if (value >= (uint32_t)range)
|
2015-05-19 21:54:34 +00:00
|
|
|
value = range - 1;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
int StdRandomRange(int range)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
uint32_t rand_num;
|
|
|
|
uint32_t value;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (range <= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rand_num = STD_RANDOM();
|
|
|
|
|
|
|
|
if (rand_num == RAND_MAX)
|
|
|
|
rand_num--;
|
|
|
|
|
|
|
|
// shift values to give more precision
|
|
|
|
#if (RAND_MAX > 0x7fff)
|
|
|
|
value = rand_num / (((int)RAND_MAX) / range);
|
|
|
|
#else
|
|
|
|
value = (rand_num << 14) / ((((int)RAND_MAX) << 14) / range);
|
|
|
|
#endif
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
if (value >= (uint32_t)range)
|
2015-05-19 21:54:34 +00:00
|
|
|
value = range - 1;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "saveable.h"
|
|
|
|
|
2019-11-28 23:22:01 +00:00
|
|
|
saveable_module saveable_build{};
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-11-28 23:22:01 +00:00
|
|
|
void Saveable_Init_Dynamic()
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-11-28 23:22:01 +00:00
|
|
|
static saveable_data saveable_build_data[] =
|
|
|
|
{
|
|
|
|
{sector, MAXSECTORS*sizeof(sectortype)},
|
|
|
|
{sprite, MAXSPRITES*sizeof(spritetype)},
|
|
|
|
{wall, MAXWALLS*sizeof(walltype)},
|
|
|
|
};
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-11-28 23:22:01 +00:00
|
|
|
saveable_build.data = saveable_build_data;
|
|
|
|
saveable_build.numdata = NUM_SAVEABLE_ITEMS(saveable_build_data);
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-16 00:55:50 +00:00
|
|
|
ReservedSpace GameInterface::GetReservedScreenSpace(int viewsize)
|
2019-12-07 20:39:17 +00:00
|
|
|
{
|
2020-08-16 00:55:50 +00:00
|
|
|
return { 0, 48 };
|
2019-12-07 20:39:17 +00:00
|
|
|
}
|
2020-08-13 16:19:44 +00:00
|
|
|
|
2020-08-16 00:55:50 +00:00
|
|
|
|
2019-11-03 11:32:58 +00:00
|
|
|
::GameInterface* CreateInterface()
|
2019-11-06 18:22:14 +00:00
|
|
|
{
|
2019-11-03 11:32:58 +00:00
|
|
|
return new GameInterface;
|
2019-11-06 18:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-08 23:55:30 +00:00
|
|
|
GameStats GameInterface::getStats()
|
2019-11-03 11:32:58 +00:00
|
|
|
{
|
2019-12-08 23:55:30 +00:00
|
|
|
PLAYERp pp = Player + myconnectindex;
|
|
|
|
return { pp->Kills, TotalKillable, pp->SecretsFound, LevelSecrets, PlayClock / 120, 0 };
|
2019-11-03 11:32:58 +00:00
|
|
|
}
|
|
|
|
|
2019-12-25 10:26:19 +00:00
|
|
|
void GameInterface::FreeGameData()
|
|
|
|
{
|
|
|
|
TerminateLevel();
|
|
|
|
}
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|