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
|
|
|
// CTW NOTE
|
|
|
|
/*
|
|
|
|
Known remaining issues:
|
|
|
|
- Audio stuttering.
|
|
|
|
- CD Audio not looping properly (currently hard coded to restart about every 200 seconds.
|
|
|
|
- Hitting F5 to change resolution causes a crash (currently disabled).
|
|
|
|
- Multiplayer untested.
|
|
|
|
|
|
|
|
Things required to make savegames work:
|
|
|
|
- Load makesym.wpj and build it.
|
|
|
|
- In a DOS prompt, run "makesym sw.map swdata.map swcode.map"
|
|
|
|
- Copy swcode.map to swcode.sym and swdata.map to swdata.sym
|
|
|
|
*/
|
|
|
|
// CTW NOTE END
|
|
|
|
|
|
|
|
#define MAIN
|
|
|
|
#define QUIET
|
|
|
|
#include "build.h"
|
|
|
|
#include "baselayer.h"
|
2019-12-17 22:25:07 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "osd.h"
|
2019-12-29 16:04:38 +00:00
|
|
|
#include "baselayer.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
#include "keys.h"
|
|
|
|
#include "names2.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#include "game.h"
|
|
|
|
#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 "config.h"
|
|
|
|
|
|
|
|
#include "menus.h"
|
|
|
|
|
2019-10-25 22:32:49 +00:00
|
|
|
#include "gamecontrol.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "gamedefs.h"
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "demo.h"
|
|
|
|
#include "cache.h"
|
|
|
|
//#include "exports.h"
|
|
|
|
|
|
|
|
#include "anim.h"
|
|
|
|
|
|
|
|
#include "colormap.h"
|
|
|
|
#include "break.h"
|
|
|
|
#include "ninja.h"
|
|
|
|
#include "light.h"
|
|
|
|
#include "track.h"
|
|
|
|
#include "jsector.h"
|
|
|
|
#include "text.h"
|
|
|
|
|
2015-05-19 22:07:18 +00:00
|
|
|
#include "common.h"
|
2015-05-19 22:05:20 +00:00
|
|
|
#include "common_game.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"
|
2019-12-02 20:05:19 +00:00
|
|
|
#include "menu/menu.h"
|
2019-12-07 18:57:19 +00:00
|
|
|
#include "z_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"
|
2019-12-23 18:37:40 +00:00
|
|
|
#include "rendering/v_video.h"
|
2019-12-18 18:17:37 +00:00
|
|
|
#include "sound/s_soundinternal.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"
|
|
|
|
|
2019-10-09 17:58:09 +00:00
|
|
|
//#include "crc32.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2019-10-09 17:58:09 +00:00
|
|
|
void pClearSpriteList(PLAYERp pp);
|
|
|
|
signed char MNU_InputSmallString(char*, short);
|
|
|
|
signed char MNU_InputString(char*, short);
|
2019-11-17 17:02:17 +00:00
|
|
|
SWBOOL IsCommand(const char* str);
|
2019-10-09 17:58:09 +00:00
|
|
|
SWBOOL MNU_StartNetGame(void);
|
2020-03-01 15:33:06 +00:00
|
|
|
extern SWBOOL mapcheat;
|
2019-10-09 17:58:09 +00:00
|
|
|
|
2019-12-02 20:05:19 +00:00
|
|
|
extern SWBOOL MultiPlayQuitFlag;
|
|
|
|
|
2020-02-02 07:53:10 +00:00
|
|
|
extern int sw_snd_scratch;
|
|
|
|
|
2019-04-08 06:28:54 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#if DEBUG
|
|
|
|
#define BETA 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define STAT_SCREEN_PIC 5114
|
|
|
|
#define TITLE_PIC 2324
|
|
|
|
#define THREED_REALMS_PIC 2325
|
|
|
|
#define TITLE_ROT_FLAGS (ROTATE_SPRITE_CORNER|ROTATE_SPRITE_SCREEN_CLIP|ROTATE_SPRITE_NON_MASK)
|
|
|
|
#define PAL_SIZE (256*3)
|
|
|
|
|
|
|
|
char DemoName[15][16];
|
|
|
|
|
|
|
|
// Stupid WallMart version!
|
|
|
|
//#define PLOCK_VERSION TRUE
|
|
|
|
|
|
|
|
#if PLOCK_VERSION
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL Global_PLock = TRUE;
|
2015-05-19 21:54:34 +00:00
|
|
|
#else
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL Global_PLock = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
#endif
|
|
|
|
|
2019-12-22 10:21:05 +00:00
|
|
|
// 12 was original source release. For future releases increment by two.
|
|
|
|
int GameVersion = 15;
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
char DemoText[3][64];
|
|
|
|
int DemoTextYstart = 0;
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL DoubleInitAWE32 = FALSE;
|
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;
|
2015-05-19 21:54:34 +00:00
|
|
|
short IntroAnimCount = 0;
|
|
|
|
short PlayingLevel = -1;
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL GraphicsMode = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
char CacheLastLevel[32] = "";
|
|
|
|
char PlayerNameArg[32] = "";
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL CleanExit = FALSE;
|
|
|
|
SWBOOL DemoModeMenuInit = FALSE;
|
|
|
|
SWBOOL FinishAnim = 0;
|
|
|
|
SWBOOL ShortGameMode = FALSE;
|
|
|
|
SWBOOL ReloadPrompt = FALSE;
|
|
|
|
SWBOOL ReloadPromptMode = FALSE;
|
|
|
|
SWBOOL NewGame = TRUE;
|
|
|
|
SWBOOL InMenuLevel = FALSE;
|
|
|
|
SWBOOL LoadGameOutsideMoveLoop = FALSE;
|
|
|
|
SWBOOL LoadGameFromDemo = FALSE;
|
|
|
|
SWBOOL ArgCheat = FALSE;
|
|
|
|
extern SWBOOL NetBroadcastMode, NetModeOverride;
|
|
|
|
SWBOOL MultiPlayQuitFlag = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
//Miscellaneous variables
|
|
|
|
char MessageInputString[256];
|
|
|
|
char MessageOutputString[256];
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL MessageInputMode = FALSE;
|
|
|
|
SWBOOL ConInputMode = FALSE;
|
|
|
|
SWBOOL ConPanel = FALSE;
|
|
|
|
SWBOOL FinishedLevel = FALSE;
|
|
|
|
SWBOOL HelpInputMode = FALSE;
|
|
|
|
SWBOOL PanelUpdateMode = TRUE;
|
2015-05-19 21:54:34 +00:00
|
|
|
short HelpPage = 0;
|
|
|
|
short HelpPagePic[] = { 5115, 5116, 5117 };
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL InputMode = FALSE;
|
|
|
|
SWBOOL MessageInput = FALSE;
|
|
|
|
extern SWBOOL GamePaused;
|
2015-05-19 21:54:34 +00:00
|
|
|
short screenpeek = 0;
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL NoDemoStartup = FALSE;
|
|
|
|
SWBOOL FirstTimeIntoGame;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-07 20:39:17 +00:00
|
|
|
SWBOOL BorderAdjust = FALSE;
|
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 21:54:34 +00:00
|
|
|
int DispFrameRate = FALSE;
|
|
|
|
int DispMono = TRUE;
|
|
|
|
int Fog = FALSE;
|
|
|
|
int FogColor;
|
2015-05-19 22:10:03 +00:00
|
|
|
SWBOOL PreCaching = TRUE;
|
2015-05-19 21:54:34 +00:00
|
|
|
int GodMode = FALSE;
|
2015-05-19 22:10:03 +00:00
|
|
|
SWBOOL BotMode = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
short Skill = 2;
|
|
|
|
short BetaVersion = 900;
|
|
|
|
short TotalKillable;
|
|
|
|
|
|
|
|
AUTO_NET Auto;
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL AutoNet = FALSE;
|
|
|
|
SWBOOL HasAutoColor = FALSE;
|
|
|
|
uint8_t AutoColor;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
const GAME_SET gs_defaults =
|
|
|
|
{
|
|
|
|
2, // border
|
|
|
|
0, // border tile
|
|
|
|
|
|
|
|
// Network game settings
|
|
|
|
0, // GameType
|
|
|
|
0, // Level
|
|
|
|
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 PauseMode = FALSE;
|
|
|
|
SWBOOL PauseKeySet = 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 DebugSO = FALSE;
|
|
|
|
SWBOOL DebugPanel = FALSE;
|
|
|
|
SWBOOL DebugSector = FALSE;
|
|
|
|
SWBOOL DebugActor = FALSE;
|
|
|
|
SWBOOL DebugAnim = FALSE;
|
|
|
|
SWBOOL DebugOperate = FALSE;
|
|
|
|
SWBOOL DebugActorFreeze = 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;
|
|
|
|
int turn_scale = 256;
|
|
|
|
int move_scale = 256;
|
|
|
|
|
|
|
|
short Level = 0;
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL ExitLevel = FALSE;
|
|
|
|
int16_t OrigCommPlayers=0;
|
|
|
|
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
|
|
|
|
|
|
|
char UserMapName[80]="", buffer[80], ch;
|
|
|
|
char LevelName[20];
|
|
|
|
|
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 BotPlayerInsert(PLAYERp pp);
|
|
|
|
void SybexScreen(void);
|
2019-10-30 05:51:53 +00:00
|
|
|
void PlayTheme(void);
|
2015-05-19 21:58:29 +00:00
|
|
|
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;
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DebugWriteString(char *string)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
#if BETA || !DEBUG
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!debug_fout)
|
|
|
|
{
|
|
|
|
if ((debug_fout = fopen("dbg.foo", "ab+")) == NULL)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(debug_fout, "%s\n", string);
|
|
|
|
|
|
|
|
//fclose(debug_fout);
|
|
|
|
//debug_fout = NULL;
|
|
|
|
|
|
|
|
fflush(debug_fout);
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DebugWriteLoc(char *fname, int line)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
#if BETA || !DEBUG
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!debug_fout)
|
|
|
|
{
|
|
|
|
if ((debug_fout = fopen("dbg.foo", "ab+")) == NULL)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(debug_fout, "%s, %d\n", fname, line);
|
|
|
|
|
|
|
|
//fclose(debug_fout);
|
|
|
|
//debug_fout = NULL;
|
|
|
|
|
|
|
|
fflush(debug_fout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mono_Print(char *str)
|
|
|
|
{
|
|
|
|
MONO_PRINT(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
extern SWBOOL DrawScreen;
|
2015-05-19 21:54:34 +00:00
|
|
|
#if RANDOM_DEBUG
|
|
|
|
FILE *fout_err;
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL RandomPrint;
|
2015-05-19 21:54:34 +00:00
|
|
|
int krand1(char *file, unsigned line)
|
|
|
|
{
|
|
|
|
ASSERT(!DrawScreen);
|
|
|
|
if (RandomPrint && !Prediction)
|
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
extern uint32_t MoveThingsCount;
|
2015-05-19 21:54:34 +00:00
|
|
|
sprintf(ds,"mtc %d, %s, line %d, %d",MoveThingsCount,file,line,randomseed);
|
|
|
|
DebugWriteString(ds);
|
|
|
|
}
|
|
|
|
randomseed = ((randomseed * 21 + 1) & 65535);
|
|
|
|
return randomseed;
|
|
|
|
}
|
|
|
|
|
|
|
|
int krand2()
|
|
|
|
{
|
|
|
|
ASSERT(!DrawScreen);
|
|
|
|
randomseed = ((randomseed * 21 + 1) & 65535);
|
|
|
|
return randomseed;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
int krand1(void)
|
|
|
|
{
|
|
|
|
ASSERT(!DrawScreen);
|
|
|
|
krandcount++;
|
|
|
|
randomseed = ((randomseed * 21 + 1) & 65535);
|
|
|
|
return randomseed;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if DEBUG
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL
|
|
|
|
ValidPtr(void *ptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
MEM_HDRp mhp;
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* check;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ASSERT(ptr != NULL);
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (mhp->size == 0 || mhp->checksum == 0)
|
|
|
|
{
|
|
|
|
printf("ValidPtr(): Size or Checksum == 0!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
check = (uint8_t*) & mhp->size;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (mhp->checksum == check[0] + check[1] + check[2] + check[3])
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
printf("ValidPtr(): Checksum bad!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
|
|
|
PtrCheckSum(void *ptr, unsigned int *stored, unsigned int *actual)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
MEM_HDRp mhp;
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* check;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ASSERT(ptr != NULL);
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
check = (uint8_t*) & mhp->size;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
*stored = mhp->checksum;
|
|
|
|
*actual = check[0] + check[1] + check[2] + check[3];
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void *
|
2015-05-19 21:54:34 +00:00
|
|
|
AllocMem(int size)
|
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* bp;
|
2015-05-19 21:54:34 +00:00
|
|
|
MEM_HDRp mhp;
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* check;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ASSERT(size != 0);
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
bp = (uint8_t*) malloc(size + sizeof(MEM_HDR));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Used for debugging, we can remove this at ship time
|
|
|
|
if (bp == NULL)
|
|
|
|
{
|
2019-12-25 10:26:19 +00:00
|
|
|
I_FatalError("Memory could NOT be allocated in AllocMem: size = %d\n",size);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(bp != NULL);
|
|
|
|
|
|
|
|
mhp = (MEM_HDRp) bp;
|
|
|
|
|
|
|
|
mhp->size = size;
|
2015-05-19 21:58:29 +00:00
|
|
|
check = (uint8_t*) & mhp->size;
|
2015-05-19 21:54:34 +00:00
|
|
|
mhp->checksum = check[0] + check[1] + check[2] + check[3];
|
|
|
|
|
|
|
|
bp += sizeof(MEM_HDR);
|
|
|
|
|
|
|
|
return bp;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void *
|
|
|
|
ReAllocMem(void *ptr, int size)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-26 06:27:29 +00:00
|
|
|
if (ptr == nullptr)
|
|
|
|
return AllocMem(size);
|
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
{
|
|
|
|
FreeMem(ptr);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* bp;
|
2015-05-19 21:54:34 +00:00
|
|
|
MEM_HDRp mhp;
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* check;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ASSERT(ValidPtr(ptr));
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
bp = (uint8_t*) realloc(mhp, size + sizeof(MEM_HDR));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ASSERT(bp != NULL);
|
|
|
|
|
|
|
|
mhp = (MEM_HDRp) bp;
|
|
|
|
|
|
|
|
mhp->size = size;
|
2015-05-19 21:58:29 +00:00
|
|
|
check = (uint8_t*) & mhp->size;
|
2015-05-19 21:54:34 +00:00
|
|
|
mhp->checksum = check[0] + check[1] + check[2] + check[3];
|
|
|
|
|
|
|
|
bp += sizeof(MEM_HDR);
|
|
|
|
|
|
|
|
ASSERT(ValidPtr(bp));
|
|
|
|
|
|
|
|
return bp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void *
|
2015-05-19 21:54:34 +00:00
|
|
|
CallocMem(int size, int num)
|
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* bp;
|
2015-05-19 21:54:34 +00:00
|
|
|
MEM_HDRp mhp;
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* check;
|
2015-05-19 21:54:34 +00:00
|
|
|
int num_bytes;
|
|
|
|
|
|
|
|
ASSERT(size != 0 && num != 0);
|
|
|
|
|
|
|
|
num_bytes = (size * num) + sizeof(MEM_HDR);
|
2015-05-19 21:58:29 +00:00
|
|
|
bp = (uint8_t*) calloc(num_bytes, 1);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Used for debugging, we can remove this at ship time
|
|
|
|
if (bp == NULL)
|
|
|
|
{
|
2019-12-25 10:26:19 +00:00
|
|
|
I_FatalError("Memory could NOT be allocated in CallocMem: size = %d, num = %d\n",size,num);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(bp != NULL);
|
|
|
|
|
|
|
|
mhp = (MEM_HDRp) bp;
|
|
|
|
|
|
|
|
mhp->size = size;
|
2015-05-19 21:58:29 +00:00
|
|
|
check = (uint8_t*) & mhp->size;
|
2015-05-19 21:54:34 +00:00
|
|
|
mhp->checksum = check[0] + check[1] + check[2] + check[3];
|
|
|
|
|
|
|
|
bp += sizeof(MEM_HDR);
|
|
|
|
|
|
|
|
return bp;
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
|
|
|
FreeMem(void *ptr)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-26 06:27:29 +00:00
|
|
|
if (ptr == nullptr)
|
|
|
|
return;
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
MEM_HDRp mhp;
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* check;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ASSERT(ValidPtr(ptr));
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
|
|
|
check = (uint8_t*)&mhp->size;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
memset(mhp, 0xCC, mhp->size + sizeof(MEM_HDR));
|
|
|
|
|
|
|
|
free(mhp);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
|
|
|
setup2dscreen(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// qsetmode640350();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void TerminateGame(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
DemoTerm();
|
|
|
|
|
|
|
|
ErrorCorrectionQuit();
|
|
|
|
|
2019-10-09 17:58:09 +00:00
|
|
|
// uninitmultiplayers();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (CleanExit)
|
|
|
|
{
|
|
|
|
SybexScreen();
|
|
|
|
//TenScreen();
|
|
|
|
}
|
2020-04-11 21:50:43 +00:00
|
|
|
throw CExitEvent(3);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-12-08 23:55:30 +00:00
|
|
|
bool LoadLevel(const char *filename)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-04-03 22:40:01 +00:00
|
|
|
int16_t ang;
|
|
|
|
if (engineLoadBoard(filename, SW_SHAREWARE ? 1 : 0, (vec3_t *)&Player[0], &ang, &Player[0].cursectnum) == -1)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-08 23:55:30 +00:00
|
|
|
Printf("Level not found: %s", filename);
|
|
|
|
return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2019-12-11 01:30:34 +00:00
|
|
|
currentLevel = &mapList[Level];
|
2020-02-22 07:56:36 +00:00
|
|
|
SECRET_SetMapName(currentLevel->DisplayName(), currentLevel->name);
|
|
|
|
STAT_NewLevel(currentLevel->labelName);
|
2019-12-08 23:55:30 +00:00
|
|
|
return true;
|
2020-04-03 22:40:01 +00:00
|
|
|
Player[0].q16ang = fix16_from_int(ang);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoadDemoRun(void)
|
|
|
|
{
|
|
|
|
short i;
|
|
|
|
FILE *fin;
|
|
|
|
|
|
|
|
fin = fopen("demos.run","r");
|
|
|
|
if (fin)
|
|
|
|
{
|
|
|
|
memset(DemoName,'\0',sizeof(DemoName));
|
2020-04-04 19:41:58 +00:00
|
|
|
for (i = 0; i < ARRAY_SSIZE(DemoName); i++)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (fscanf(fin, "%s", DemoName[i]) == EOF)
|
|
|
|
break;
|
|
|
|
}
|
2020-04-04 19:41:58 +00:00
|
|
|
if (i == ARRAY_SSIZE(DemoName))
|
|
|
|
initputs("WARNING: demos.run is too long, ignoring remaining files\n");
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
fclose(fin);
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(DemoText,'\0',sizeof(DemoText));
|
|
|
|
fin = fopen("demotxt.run","r");
|
|
|
|
if (fin)
|
|
|
|
{
|
|
|
|
fgets(ds, 6, fin);
|
|
|
|
sscanf(ds,"%d",&DemoTextYstart);
|
2020-04-04 19:41:58 +00:00
|
|
|
for (i = 0; i < ARRAY_SSIZE(DemoText); i++)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (fgets(DemoText[i], SIZ(DemoText[0])-1, fin) == NULL)
|
|
|
|
break;
|
|
|
|
}
|
2020-04-04 19:41:58 +00:00
|
|
|
if (i == ARRAY_SSIZE(DemoText))
|
|
|
|
initputs("WARNING: demotxt.run is too long, trimming the text\n");
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
fclose(fin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisplayDemoText(void)
|
|
|
|
{
|
|
|
|
short w,h;
|
|
|
|
short i;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
MNU_MeasureString(DemoText[i], &w, &h);
|
|
|
|
PutStringTimer(Player, TEXT_TEST_COL(w), DemoTextYstart+(i*12), DemoText[i], 999);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void InitAutoNet(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (!AutoNet)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gs.NetGameType = Auto.Rules;
|
|
|
|
gs.NetLevel = Auto.Level;
|
|
|
|
gs.NetMonsters = Auto.Enemy;
|
|
|
|
gs.NetSpawnMarkers = Auto.Markers;
|
|
|
|
gs.NetTeamPlay = Auto.Team;
|
|
|
|
gs.NetHurtTeammate = Auto.HurtTeam;
|
|
|
|
gs.NetKillLimit = Auto.Kill;
|
|
|
|
gs.NetTimeLimit = Auto.Time;
|
|
|
|
gs.NetColor = Auto.Color;
|
|
|
|
gs.NetNuke = Auto.Nuke;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AnimateCacheCursor(void)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
struct rccoord old_pos;
|
|
|
|
static short cursor_num = 0;
|
|
|
|
static char cache_cursor[] = {'|','/','-','\\'};
|
|
|
|
|
|
|
|
if (GraphicsMode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cursor_num++;
|
|
|
|
if (cursor_num > 3)
|
|
|
|
cursor_num = 0;
|
|
|
|
|
|
|
|
//old_pos = _gettextposition();
|
|
|
|
//_settextposition( old_pos.row, old_pos.col );
|
|
|
|
//_settextposition( 24, 25);
|
|
|
|
_settextposition(25, 0);
|
|
|
|
sprintf(ds,"Loading sound and graphics %c", cache_cursor[cursor_num]);
|
|
|
|
_outtext(ds);
|
|
|
|
//_settextposition( old_pos.row, old_pos.col );
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int firstnet = 0; // JBF
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
DSPRINTF(ds,"InitGame...");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
2020-02-01 22:05:43 +00:00
|
|
|
engineInit();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
InitAutoNet();
|
|
|
|
|
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-10-09 17:58:09 +00:00
|
|
|
#if 0
|
2015-05-19 21:54:34 +00:00
|
|
|
if (!firstnet)
|
|
|
|
initmultiplayers(0, NULL, 0, 0, 0);
|
2015-05-19 22:03:04 +00:00
|
|
|
else if (initmultiplayersparms(argc - firstnet, &argv[firstnet]))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
Printf("Waiting for players...\n");
|
2015-05-19 21:54:34 +00:00
|
|
|
while (initmultiplayerscycle())
|
|
|
|
{
|
|
|
|
handleevents();
|
|
|
|
}
|
|
|
|
}
|
2019-11-19 21:35:52 +00:00
|
|
|
#else
|
|
|
|
numplayers = 1; myconnectindex = 0;
|
|
|
|
connecthead = 0; connectpoint2[0] = -1;
|
2019-10-09 17:58:09 +00:00
|
|
|
#endif
|
2015-05-19 21:54:34 +00:00
|
|
|
initsynccrc();
|
|
|
|
|
|
|
|
// code to duplicate packets
|
|
|
|
if (numplayers > 4 && MovesPerPacket == 1)
|
|
|
|
{
|
|
|
|
MovesPerPacket = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
MultiSharewareCheck();
|
|
|
|
|
|
|
|
if (numplayers > 1)
|
|
|
|
{
|
|
|
|
CommPlayers = numplayers;
|
|
|
|
OrigCommPlayers = CommPlayers;
|
|
|
|
CommEnabled = TRUE;
|
|
|
|
if (!BotMode)
|
|
|
|
gNet.MultiGameType = MULTI_GAME_COMMBAT;
|
|
|
|
else
|
|
|
|
gNet.MultiGameType = MULTI_GAME_AI_BOTS;
|
|
|
|
|
|
|
|
#if 0 //def NET_MODE_MASTER_SLAVE
|
|
|
|
if (!NetModeOverride)
|
|
|
|
{
|
|
|
|
if (numplayers <= 4)
|
|
|
|
NetBroadcastMode = TRUE;
|
|
|
|
else
|
|
|
|
NetBroadcastMode = FALSE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
LoadDemoRun();
|
|
|
|
// Save off total heap for later calculations
|
|
|
|
//TotalMemory = Z_AvailHeap();
|
|
|
|
//DSPRINTF(ds,"Available Heap before LoadImages = %d", TotalMemory);
|
|
|
|
//MONO_PRINT(ds);
|
|
|
|
// Reserve 1.5 megs for normal program use
|
|
|
|
// Generally, SW is consuming about a total of 11 megs including
|
|
|
|
// all the cached in graphics, etc. per level, so even on a 16 meg
|
|
|
|
// system, reserving 1.5 megs is fine.
|
|
|
|
// Note that on a 16 meg machine, Ken was leaving us about
|
|
|
|
// 24k for use outside the cache! This was causing out of mem problems
|
|
|
|
// when songs, etc., greater than the remaining heap were being loaded.
|
|
|
|
// Even if you pre-cache songs, etc. to help, reserving some heap is
|
|
|
|
// a very smart idea since the game uses malloc throughout execution.
|
|
|
|
//ReserveMem = AllocMem(1L<<20);
|
|
|
|
//if(ReserveMem == 0) MONO_PRINT("Could not allocate 1.5 meg reserve!");
|
|
|
|
|
|
|
|
// LoadImages will now proceed to steal all the remaining heap space
|
|
|
|
//_outtext("\n\n\n\n\n\n\n\n");
|
|
|
|
//AnimateCacheCursor();
|
2019-10-30 19:13:43 +00:00
|
|
|
TileFiles.LoadArtSet("tiles%03d.art");
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Now free it up for later use
|
|
|
|
/*
|
|
|
|
if(ReserveMem)
|
|
|
|
{
|
|
|
|
// Recalc TotalMemory for later reference
|
|
|
|
ActualHeap = Z_AvailHeap() + 1536000L;
|
|
|
|
FreeMem(ReserveMem);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
Connect();
|
|
|
|
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
|
|
|
|
2019-12-22 10:20:13 +00:00
|
|
|
palettePostLoadLookups();
|
2020-01-29 18:06:26 +00:00
|
|
|
V_Init2();
|
2019-12-22 10:20:13 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
DemoModeMenuInit = TRUE;
|
|
|
|
// precache as much stuff as you can
|
|
|
|
if (UserMapName[0] == '\0')
|
|
|
|
{
|
|
|
|
AnimateCacheCursor();
|
2019-12-09 16:17:15 +00:00
|
|
|
if (!LoadLevel("$dozer.map")) return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
AnimateCacheCursor();
|
|
|
|
SetupPreCache();
|
|
|
|
DoTheCache();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AnimateCacheCursor();
|
2019-12-08 23:55:30 +00:00
|
|
|
if (!LoadLevel(UserMapName)) return false;
|
2015-05-19 21:54:34 +00:00
|
|
|
AnimateCacheCursor();
|
|
|
|
SetupPreCache();
|
|
|
|
DoTheCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
GraphicsMode = TRUE;
|
|
|
|
SetupAspectRatio();
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Directory of C:\DEV\SW\MIDI
|
|
|
|
EXECUT11 MID
|
|
|
|
HROSHMA6 MID
|
|
|
|
HOSHIA02 MID
|
|
|
|
INTRO131 MID
|
|
|
|
KOTEC2 MID
|
|
|
|
KOTOKI12 MID
|
|
|
|
NIPPON34 MID
|
|
|
|
NOKI41 MID
|
|
|
|
SANAI MID
|
|
|
|
SIANRA23 MID
|
|
|
|
TKYO2007 MID
|
|
|
|
TYTAIK16 MID
|
|
|
|
YOKOHA03 MID
|
|
|
|
*/
|
|
|
|
|
|
|
|
short SongLevelNum;
|
2019-11-17 17:02:17 +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));
|
|
|
|
}
|
|
|
|
|
|
|
|
void FindLevelInfo(char *map_name, short *level)
|
|
|
|
{
|
2020-03-06 15:49:49 +00:00
|
|
|
short j;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (j = 1; j <= MAX_LEVELS; j++)
|
|
|
|
{
|
2019-12-11 01:01:11 +00:00
|
|
|
if (Bstrcasecmp(map_name, mapList[j].fileName.GetChars()) == 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
*level = j;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*level = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
gNet.TimeLimitClock = gNet.TimeLimit;
|
|
|
|
|
|
|
|
serpwasseen = FALSE;
|
|
|
|
sumowasseen = FALSE;
|
|
|
|
zillawasseen = FALSE;
|
|
|
|
memset(BossSpriteNum,-1,sizeof(BossSpriteNum));
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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-02-01 09:50:40 +00:00
|
|
|
if (!DemoMode)
|
|
|
|
Mus_Stop();
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
InitLevelGlobals2();
|
|
|
|
if (DemoMode)
|
|
|
|
{
|
|
|
|
Level = 0;
|
|
|
|
NewGame = TRUE;
|
|
|
|
DemoInitOnce = FALSE;
|
|
|
|
strcpy(DemoFileName, DemoName[DemoNumber]);
|
|
|
|
DemoNumber++;
|
|
|
|
if (!DemoName[DemoNumber][0])
|
|
|
|
DemoNumber = 0;
|
|
|
|
|
|
|
|
// read header and such
|
|
|
|
DemoPlaySetup();
|
|
|
|
|
|
|
|
strcpy(LevelName, DemoLevelName);
|
|
|
|
|
|
|
|
FindLevelInfo(LevelName, &Level);
|
|
|
|
if (Level > 0)
|
|
|
|
{
|
2019-12-11 01:01:11 +00:00
|
|
|
strcpy(LevelName, mapList[Level].fileName);
|
2015-05-19 21:54:34 +00:00
|
|
|
UserMapName[0] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(UserMapName, DemoLevelName);
|
|
|
|
Level = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Level < 0)
|
|
|
|
Level = 0;
|
|
|
|
|
|
|
|
if (Level > MAX_LEVELS)
|
|
|
|
Level = 1;
|
|
|
|
|
|
|
|
// extra code in case something is resetting these values
|
|
|
|
if (NewGame)
|
|
|
|
{
|
|
|
|
//Level = 1;
|
|
|
|
//DemoPlaying = FALSE;
|
|
|
|
DemoMode = FALSE;
|
|
|
|
//DemoRecording = FALSE;
|
|
|
|
//DemoEdit = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (UserMapName[0])
|
|
|
|
{
|
|
|
|
strcpy(LevelName, UserMapName);
|
|
|
|
|
|
|
|
Level = 0;
|
|
|
|
FindLevelInfo(UserMapName, &Level);
|
|
|
|
|
|
|
|
if (Level > 0)
|
|
|
|
{
|
|
|
|
// user map is part of game - treat it as such
|
2019-12-11 01:01:11 +00:00
|
|
|
strcpy(LevelName, mapList[Level].fileName);
|
2015-05-19 21:54:34 +00:00
|
|
|
UserMapName[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-11 01:01:11 +00:00
|
|
|
strcpy(LevelName, mapList[Level].fileName);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayingLevel = Level;
|
|
|
|
|
|
|
|
if (NewGame)
|
|
|
|
InitNewGame();
|
|
|
|
|
2020-03-07 13:51:49 +00:00
|
|
|
LoadingLevelScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
MONO_PRINT("LoadintLevelScreen");
|
|
|
|
if (!DemoMode && !DemoInitOnce)
|
|
|
|
DemoPlaySetup();
|
|
|
|
|
2019-12-08 23:55:30 +00:00
|
|
|
if (!LoadLevel(LevelName))
|
|
|
|
{
|
|
|
|
NewGame = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
STAT_NewLevel(LevelName);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (Bstrcasecmp(CacheLastLevel, LevelName) != 0)
|
|
|
|
// clears gotpic and does some bit setting
|
|
|
|
SetupPreCache();
|
|
|
|
else
|
|
|
|
memset(gotpic,0,sizeof(gotpic));
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
// fake Multi-player game setup
|
|
|
|
if (FakeMultiNumPlayers && !BotMode)
|
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t i;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// insert all needed players except the first one - its already tere
|
|
|
|
for (i = 0; i < FakeMultiNumPlayers - 1; i++)
|
|
|
|
{
|
|
|
|
ManualPlayerInsert(Player);
|
|
|
|
// reset control back to 1st player
|
|
|
|
myconnectindex = 0;
|
|
|
|
screenpeek = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Put in the BOTS if called for
|
|
|
|
if (FakeMultiNumPlayers && BotMode)
|
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t i;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// insert all needed players except the first one - its already tere
|
|
|
|
for (i = 0; i < FakeMultiNumPlayers; i++)
|
|
|
|
{
|
|
|
|
BotPlayerInsert(Player);
|
|
|
|
// reset control back to 1st player
|
|
|
|
myconnectindex = 0;
|
|
|
|
screenpeek = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
SongLevelNum = Level;
|
|
|
|
|
|
|
|
if (DemoMode)
|
|
|
|
{
|
|
|
|
DisplayDemoText();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ArgCheat)
|
|
|
|
{
|
2019-12-04 22:07:02 +00:00
|
|
|
int bak = hud_messages;
|
|
|
|
hud_messages = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
EveryCheatToggle(&Player[0],NULL);
|
2019-10-27 15:53:00 +00:00
|
|
|
hud_messages = bak;
|
2015-05-19 21:54:34 +00:00
|
|
|
GodMode = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// reset NewGame
|
|
|
|
NewGame = FALSE;
|
|
|
|
|
|
|
|
DSPRINTF(ds,"End of InitLevel...");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#if DEBUG
|
|
|
|
if (!cansee(43594, -92986, 0x3fffffff, 290,
|
|
|
|
43180, -91707, 0x3fffffff, 290))
|
|
|
|
{
|
|
|
|
DSPRINTF(ds,"cansee failed");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
|
|
|
TerminateLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i, nexti, stat, pnum, ndx;
|
|
|
|
SECT_USERp *sectu;
|
|
|
|
|
|
|
|
//HEAP_CHECK();
|
|
|
|
|
|
|
|
DemoTerm();
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
|
|
|
////DSPRINTF(ds,"Sect User Free %d",sectu-SectUser);
|
|
|
|
//MONO_PRINT(ds);
|
|
|
|
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->InventorySprite, 0, sizeof(pp->InventorySprite));
|
|
|
|
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
|
|
|
{
|
|
|
|
if (DemoPlaying)
|
|
|
|
{
|
|
|
|
InitLevel();
|
|
|
|
InitRunLevel();
|
|
|
|
|
|
|
|
DemoInitOnce = FALSE;
|
|
|
|
if (DemoMode)
|
|
|
|
{
|
|
|
|
if (DemoModeMenuInit)
|
|
|
|
{
|
|
|
|
DemoModeMenuInit = FALSE;
|
2019-10-28 05:47:49 +00:00
|
|
|
inputState.ClearKeyStatus(sc_Escape);
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DemoPlayBack();
|
|
|
|
|
|
|
|
if (DemoRecording && DemoEdit)
|
|
|
|
{
|
|
|
|
RunLevel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-02-01 09:50:40 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
InitLevel();
|
|
|
|
RunLevel();
|
|
|
|
}
|
|
|
|
while (LoadGameOutsideMoveLoop);
|
2019-12-08 23:55:30 +00:00
|
|
|
STAT_Update(false);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!QuitFlag)
|
|
|
|
{
|
|
|
|
// for good measure do this
|
|
|
|
ready2send = 0;
|
|
|
|
waitforeverybody();
|
|
|
|
}
|
|
|
|
|
|
|
|
StatScreen(&Player[myconnectindex]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LoadGameFromDemo)
|
|
|
|
LoadGameFromDemo = FALSE;
|
|
|
|
else
|
|
|
|
TerminateLevel();
|
|
|
|
|
|
|
|
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
|
|
|
FinishAnim = 0;
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
|
|
|
|
uint8_t* KeyPressedRange(uint8_t* kb, uint8_t* ke)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* k;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (k = kb; k <= ke; k++)
|
|
|
|
{
|
|
|
|
if (*k)
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void ResetKeyRange(uint8_t* kb, uint8_t* ke)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t* k;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (k = kb; k <= ke; k++)
|
|
|
|
{
|
|
|
|
*k = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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]);
|
2019-10-30 05:51:53 +00:00
|
|
|
|
|
|
|
DSPRINTF(ds,"After music stuff...");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void LogoLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int fin;
|
|
|
|
|
2020-02-02 19:44:57 +00:00
|
|
|
if (userConfig.nologo) return;
|
2015-05-19 21:54:34 +00:00
|
|
|
DSPRINTF(ds,"LogoLevel...");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
2019-12-07 09:31:27 +00:00
|
|
|
auto pal = fileSystem.LoadFile("3drealms.pal", 0);
|
2019-10-20 18:08:17 +00:00
|
|
|
if (pal.Size() >= 768)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-10-30 05:51:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
for (auto & c : pal)
|
|
|
|
c <<= 2;
|
|
|
|
|
2019-10-30 18:26:55 +00:00
|
|
|
paletteSetColorTable(DREALMSPAL, pal.Data());
|
2020-01-26 09:58:00 +00:00
|
|
|
videoSetPalette(0, DREALMSPAL, Pal_Fullscreen);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
DSPRINTF(ds,"Just read in 3drealms.pal...");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
|
|
|
//FadeOut(0, 0);
|
|
|
|
ready2send = 0;
|
|
|
|
totalclock = 0;
|
|
|
|
ototalclock = 0;
|
|
|
|
|
|
|
|
DSPRINTF(ds,"About to display 3drealms pic...");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
|
|
|
//FadeIn(0, 3);
|
|
|
|
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
while (TRUE)
|
|
|
|
{
|
2020-02-11 06:35:21 +00:00
|
|
|
twod->ClearScreen();
|
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, THREED_REALMS_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
videoNextPage();
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
handleevents();
|
|
|
|
|
|
|
|
// taken from top of faketimerhandler
|
|
|
|
// limits checks to max of 40 times a second
|
|
|
|
if (totalclock >= ototalclock + synctics)
|
|
|
|
{
|
|
|
|
ototalclock += synctics;
|
|
|
|
}
|
|
|
|
|
2019-12-24 11:59:26 +00:00
|
|
|
if (totalclock > 5*120 || inputState.CheckAllInput())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-24 11:59:26 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2020-01-26 09:58:00 +00:00
|
|
|
videoSetPalette(0, BASEPAL, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// put up a blank screen while loading
|
|
|
|
|
|
|
|
DSPRINTF(ds,"End of LogoLevel...");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void CreditsLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int curpic;
|
|
|
|
int handle;
|
2015-05-19 21:58:29 +00:00
|
|
|
uint32_t timer = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
int zero=0;
|
|
|
|
short save;
|
|
|
|
#define CREDITS1_PIC 5111
|
|
|
|
#define CREDITS2_PIC 5118
|
|
|
|
|
|
|
|
// put up a blank screen while loading
|
|
|
|
|
|
|
|
// get rid of all PERM sprites!
|
2019-04-08 06:26:36 +00:00
|
|
|
renderFlushPerms();
|
2015-05-19 21:54:34 +00:00
|
|
|
save = gs.BorderNum;
|
|
|
|
gs.BorderNum = save;
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2020-01-24 20:41:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Lo Wang feel like singing!
|
2020-02-16 19:08:04 +00:00
|
|
|
PlaySound(DIGI_JG95012, v3df_none, CHAN_VOICE, CHANF_UI);
|
2019-12-18 18:17:37 +00:00
|
|
|
while (soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE))
|
|
|
|
{
|
|
|
|
DoUpdateSounds();
|
|
|
|
handleevents();
|
2020-01-24 20:41:47 +00:00
|
|
|
if (inputState.CheckAllInput())
|
|
|
|
break;
|
|
|
|
videoNextPage();
|
2019-12-18 18:17:37 +00:00
|
|
|
}
|
2020-01-24 20:41:47 +00:00
|
|
|
StopSound();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// try 14 then 2 then quit
|
2019-12-09 19:12:54 +00:00
|
|
|
if (!PlaySong(nullptr, ThemeSongs[5], ThemeTrack[5], true))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-01-24 20:41:47 +00:00
|
|
|
PlaySong(nullptr, nullptr, 2, true);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ready2send = 0;
|
|
|
|
totalclock = 0;
|
|
|
|
ototalclock = 0;
|
|
|
|
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
curpic = CREDITS1_PIC;
|
|
|
|
|
2020-01-27 16:11:21 +00:00
|
|
|
while (!inputState.CheckAllInput())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-02-11 06:35:24 +00:00
|
|
|
handleevents();
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
// taken from top of faketimerhandler
|
|
|
|
// limits checks to max of 40 times a second
|
|
|
|
if (totalclock >= ototalclock + synctics)
|
|
|
|
{
|
|
|
|
ototalclock += synctics;
|
|
|
|
timer += synctics;
|
|
|
|
}
|
|
|
|
|
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, curpic, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (timer > 8*120)
|
|
|
|
{
|
|
|
|
curpic = CREDITS2_PIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (timer > 16*120)
|
|
|
|
{
|
|
|
|
timer = 0;
|
|
|
|
curpic = CREDITS1_PIC;
|
|
|
|
}
|
2020-01-27 16:11:21 +00:00
|
|
|
handleevents();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// put up a blank screen while loading
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2019-12-07 18:57:19 +00:00
|
|
|
Mus_Stop();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void SybexScreen(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (!SW_SHAREWARE) return;
|
|
|
|
|
|
|
|
if (CommEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, 5261, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2019-12-24 11:59:26 +00:00
|
|
|
while (!inputState.CheckAllInput()) handleevents();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CTW REMOVED END
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void
|
|
|
|
TitleLevel(void)
|
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
|
|
|
|
2019-11-01 21:17:15 +00:00
|
|
|
ready2send = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
totalclock = 0;
|
|
|
|
ototalclock = 0;
|
|
|
|
|
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, TITLE_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
//FadeIn(0, 3);
|
|
|
|
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
handleevents();
|
|
|
|
OSD_DispatchQueued();
|
|
|
|
|
|
|
|
// taken from top of faketimerhandler
|
|
|
|
// limits checks to max of 40 times a second
|
|
|
|
if (totalclock >= ototalclock + synctics)
|
|
|
|
{
|
|
|
|
//void MNU_CheckForMenusAnyKey( void );
|
|
|
|
|
|
|
|
ototalclock += synctics;
|
|
|
|
//MNU_CheckForMenusAnyKey();
|
|
|
|
}
|
|
|
|
|
2019-12-02 20:05:19 +00:00
|
|
|
//if (M_Active())
|
2015-05-19 21:54:34 +00:00
|
|
|
// MNU_DrawMenu();
|
|
|
|
|
|
|
|
//drawscreen as fast as you can
|
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, TITLE_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-24 11:59:26 +00:00
|
|
|
if (totalclock > 5*120 || inputState.CheckAllInput())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
DemoMode = TRUE;
|
|
|
|
DemoPlaying = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// clearview(0);
|
|
|
|
// nextpage();
|
|
|
|
//SetPaletteToVESA(backup_pal);
|
|
|
|
|
|
|
|
// put up a blank screen while loading
|
|
|
|
// clearview(0);
|
|
|
|
// nextpage();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DrawMenuLevelScreen(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, TITLE_PIC, 20, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DrawStatScreen(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, STAT_SCREEN_PIC, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DrawLoadLevelScreen(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, TITLE_PIC, 20, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
short PlayerQuitMenuLevel = -1;
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void IntroAnimLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-02-02 19:44:57 +00:00
|
|
|
if (userConfig.nologo) return;
|
2015-05-19 21:54:34 +00:00
|
|
|
DSPRINTF(ds,"IntroAnimLevel");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
playanm(0);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// do demos only if not playing multi play
|
|
|
|
if (!CommEnabled && numplayers <= 1 && !FinishAnim && !NoDemoStartup)
|
|
|
|
{
|
|
|
|
// demos exist - do demo instead
|
|
|
|
if (DemoName[0][0] != '\0')
|
|
|
|
{
|
|
|
|
DemoMode = TRUE;
|
|
|
|
DemoPlaying = TRUE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DemoMode = FALSE;
|
|
|
|
DemoPlaying = 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
|
|
|
|
|
|
|
//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...");
|
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 170, ds, 1, 16);
|
|
|
|
|
|
|
|
sprintf(ds,"They are afraid!");
|
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 180, ds, 1, 16);
|
|
|
|
}
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
//FadeIn(0, 3);
|
|
|
|
|
|
|
|
waitforeverybody();
|
|
|
|
|
|
|
|
// don't allow BorderAdjusting in these menus
|
|
|
|
BorderAdjust = FALSE;
|
|
|
|
|
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();
|
|
|
|
OSD_DispatchQueued();
|
|
|
|
|
|
|
|
// taken from top of faketimerhandler
|
|
|
|
// limits checks to max of 40 times a second
|
|
|
|
if (totalclock >= ototalclock + synctics)
|
|
|
|
{
|
|
|
|
ototalclock += synctics;
|
|
|
|
if (CommEnabled)
|
|
|
|
getpackets();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CommEnabled)
|
|
|
|
{
|
|
|
|
if (MultiPlayQuitFlag)
|
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
uint8_t pbuf[1];
|
2015-05-19 21:54:34 +00:00
|
|
|
QuitFlag = TRUE;
|
|
|
|
pbuf[0] = PACKET_TYPE_MENU_LEVEL_QUIT;
|
|
|
|
netbroadcastpacket(pbuf, 1); // TENSW
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (PlayerQuitMenuLevel >= 0)
|
|
|
|
{
|
|
|
|
MenuCommPlayerQuit(PlayerQuitMenuLevel);
|
|
|
|
PlayerQuitMenuLevel = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ExitLevel)
|
|
|
|
{
|
|
|
|
// Quiting Level
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
BorderAdjust = TRUE;
|
|
|
|
//LoadGameOutsideMoveLoop = FALSE;
|
2020-01-01 10:35:47 +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-11-17 17:02:17 +00:00
|
|
|
void SceneLevel(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL dp_bak;
|
|
|
|
SWBOOL dm_bak;
|
2015-05-19 21:54:34 +00:00
|
|
|
FILE *fin;
|
|
|
|
#define CINEMATIC_DEMO_FILE "$scene.dmo"
|
|
|
|
|
|
|
|
// make sure it exists
|
|
|
|
if ((fin = fopen(CINEMATIC_DEMO_FILE,"rb")) == NULL)
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
fclose(fin);
|
|
|
|
|
|
|
|
strcpy(DemoFileName,CINEMATIC_DEMO_FILE);
|
|
|
|
|
|
|
|
dp_bak = DemoPlaying;
|
|
|
|
dm_bak = DemoMode;
|
|
|
|
|
|
|
|
DemoMode = TRUE;
|
|
|
|
DemoPlaying = TRUE;
|
|
|
|
DemoOverride = TRUE;
|
|
|
|
InitLevel();
|
|
|
|
DemoOverride = FALSE;
|
|
|
|
|
|
|
|
ScenePlayBack();
|
|
|
|
TerminateLevel();
|
|
|
|
DemoMode = dm_bak;
|
|
|
|
DemoPlaying = dp_bak;
|
|
|
|
}
|
|
|
|
|
2020-03-07 13:51:49 +00:00
|
|
|
void
|
|
|
|
LoadingLevelScreen(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short w,h;
|
2015-05-19 21:58:29 +00:00
|
|
|
extern SWBOOL DemoMode;
|
2015-05-19 21:54:34 +00:00
|
|
|
DrawLoadLevelScreen();
|
|
|
|
|
|
|
|
if (DemoMode)
|
|
|
|
sprintf(ds,"DEMO");
|
|
|
|
else
|
|
|
|
sprintf(ds,"ENTERING");
|
|
|
|
|
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 170, ds,1,16);
|
|
|
|
|
2019-12-11 01:01:11 +00:00
|
|
|
auto ds = currentLevel->DisplayName();
|
2015-05-19 21:54:34 +00:00
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 180, ds,1,16);
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void gNextState(STATEp *State)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// Transition to the next state
|
|
|
|
*State = (*State)->NextState;
|
|
|
|
|
|
|
|
if (TEST((*State)->Tics, SF_QUICK_CALL))
|
|
|
|
{
|
|
|
|
(*(*State)->Animator)(0);
|
|
|
|
*State = (*State)->NextState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generic state control
|
2019-11-17 17:02:17 +00:00
|
|
|
void gStateControl(STATEp *State, int *tics)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
*tics += synctics;
|
|
|
|
|
|
|
|
// Skip states if too much time has passed
|
|
|
|
while (*tics >= (*State)->Tics)
|
|
|
|
{
|
|
|
|
// Set Tics
|
|
|
|
*tics -= (*State)->Tics;
|
|
|
|
gNextState(State);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Call the correct animator
|
|
|
|
if ((*State)->Animator)
|
|
|
|
(*(*State)->Animator)(0);
|
|
|
|
}
|
|
|
|
|
2020-03-07 13:51:53 +00:00
|
|
|
int BonusPunchSound(short UNUSED(SpriteNum))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
PLAYERp pp = Player + myconnectindex;
|
2019-12-18 10:09:01 +00:00
|
|
|
PlaySound(DIGI_PLAYERYELL3, pp, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-07 13:51:53 +00:00
|
|
|
int BonusKickSound(short UNUSED(SpriteNum))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
PLAYERp pp = Player + myconnectindex;
|
2019-12-18 10:09:01 +00:00
|
|
|
PlaySound(DIGI_PLAYERYELL2, pp, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-07 13:51:53 +00:00
|
|
|
int BonusGrabSound(short UNUSED(SpriteNum))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
PLAYERp pp = Player + myconnectindex;
|
2019-12-18 10:09:01 +00:00
|
|
|
PlaySound(DIGI_BONUS_GRAB, pp, v3df_none);
|
2015-05-19 21:54:34 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-08 23:55:30 +00:00
|
|
|
extern SWBOOL FinishedLevel;
|
|
|
|
extern int PlayClock;
|
|
|
|
extern short LevelSecrets;
|
|
|
|
extern short TotalKillable;
|
|
|
|
|
2020-03-07 13:51:49 +00:00
|
|
|
void BonusScreen()
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int minutes,seconds,second_tics;
|
2019-12-08 23:55:30 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
short w,h;
|
2020-03-06 15:49:49 +00:00
|
|
|
short limit;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define BONUS_SCREEN_PIC 5120
|
|
|
|
#define BONUS_ANIM 5121
|
|
|
|
#define BONUS_ANIM_FRAMES (5159-5121)
|
|
|
|
|
|
|
|
#define BREAK_LIGHT_RATE 18
|
|
|
|
|
|
|
|
#define BONUS_PUNCH 5121
|
|
|
|
#define BONUS_KICK 5136
|
|
|
|
#define BONUS_GRAB 5151
|
|
|
|
#define BONUS_REST 5121
|
|
|
|
|
|
|
|
#define BONUS_TICS 8
|
|
|
|
#define BONUS_GRAB_TICS 20
|
|
|
|
#define BONUS_REST_TICS 50
|
|
|
|
|
|
|
|
static STATE s_BonusPunch[] =
|
|
|
|
{
|
|
|
|
{BONUS_PUNCH + 0, BONUS_TICS, NULL, &s_BonusPunch[1]},
|
|
|
|
{BONUS_PUNCH + 1, BONUS_TICS, NULL, &s_BonusPunch[2]},
|
|
|
|
{BONUS_PUNCH + 2, BONUS_TICS, NULL, &s_BonusPunch[3]},
|
|
|
|
{BONUS_PUNCH + 2, 0|SF_QUICK_CALL, BonusPunchSound, &s_BonusPunch[4]},
|
|
|
|
{BONUS_PUNCH + 3, BONUS_TICS, NULL, &s_BonusPunch[5]},
|
|
|
|
{BONUS_PUNCH + 4, BONUS_TICS, NULL, &s_BonusPunch[6]},
|
|
|
|
{BONUS_PUNCH + 5, BONUS_TICS, NULL, &s_BonusPunch[7]},
|
|
|
|
{BONUS_PUNCH + 6, BONUS_TICS, NULL, &s_BonusPunch[8]},
|
|
|
|
{BONUS_PUNCH + 7, BONUS_TICS, NULL, &s_BonusPunch[9]},
|
|
|
|
{BONUS_PUNCH + 8, BONUS_TICS, NULL, &s_BonusPunch[10]},
|
|
|
|
{BONUS_PUNCH + 9, BONUS_TICS, NULL, &s_BonusPunch[11]},
|
|
|
|
{BONUS_PUNCH + 10, BONUS_TICS, NULL, &s_BonusPunch[12]},
|
|
|
|
{BONUS_PUNCH + 11, BONUS_TICS, NULL, &s_BonusPunch[13]},
|
|
|
|
{BONUS_PUNCH + 12, BONUS_TICS, NULL, &s_BonusPunch[14]},
|
|
|
|
{BONUS_PUNCH + 14, 90, NULL, &s_BonusPunch[15]},
|
|
|
|
{BONUS_PUNCH + 14, BONUS_TICS, NULL, &s_BonusPunch[15]},
|
|
|
|
};
|
|
|
|
|
|
|
|
static STATE s_BonusKick[] =
|
|
|
|
{
|
|
|
|
{BONUS_KICK + 0, BONUS_TICS, NULL, &s_BonusKick[1]},
|
|
|
|
{BONUS_KICK + 1, BONUS_TICS, NULL, &s_BonusKick[2]},
|
|
|
|
{BONUS_KICK + 2, BONUS_TICS, NULL, &s_BonusKick[3]},
|
|
|
|
{BONUS_KICK + 2, 0|SF_QUICK_CALL, BonusKickSound, &s_BonusKick[4]},
|
|
|
|
{BONUS_KICK + 3, BONUS_TICS, NULL, &s_BonusKick[5]},
|
|
|
|
{BONUS_KICK + 4, BONUS_TICS, NULL, &s_BonusKick[6]},
|
|
|
|
{BONUS_KICK + 5, BONUS_TICS, NULL, &s_BonusKick[7]},
|
|
|
|
{BONUS_KICK + 6, BONUS_TICS, NULL, &s_BonusKick[8]},
|
|
|
|
{BONUS_KICK + 7, BONUS_TICS, NULL, &s_BonusKick[9]},
|
|
|
|
{BONUS_KICK + 8, BONUS_TICS, NULL, &s_BonusKick[10]},
|
|
|
|
{BONUS_KICK + 9, BONUS_TICS, NULL, &s_BonusKick[11]},
|
|
|
|
{BONUS_KICK + 10, BONUS_TICS, NULL, &s_BonusKick[12]},
|
|
|
|
{BONUS_KICK + 11, BONUS_TICS, NULL, &s_BonusKick[13]},
|
|
|
|
{BONUS_KICK + 12, BONUS_TICS, NULL, &s_BonusKick[14]},
|
|
|
|
{BONUS_KICK + 14, 90, NULL, &s_BonusKick[15]},
|
|
|
|
{BONUS_KICK + 14, BONUS_TICS, NULL, &s_BonusKick[15]},
|
|
|
|
};
|
|
|
|
|
|
|
|
static STATE s_BonusGrab[] =
|
|
|
|
{
|
|
|
|
{BONUS_GRAB + 0, BONUS_GRAB_TICS, NULL, &s_BonusGrab[1]},
|
|
|
|
{BONUS_GRAB + 1, BONUS_GRAB_TICS, NULL, &s_BonusGrab[2]},
|
|
|
|
{BONUS_GRAB + 2, BONUS_GRAB_TICS, NULL, &s_BonusGrab[3]},
|
|
|
|
{BONUS_GRAB + 2, 0|SF_QUICK_CALL, BonusGrabSound, &s_BonusGrab[4]},
|
|
|
|
{BONUS_GRAB + 3, BONUS_GRAB_TICS, NULL, &s_BonusGrab[5]},
|
|
|
|
{BONUS_GRAB + 4, BONUS_GRAB_TICS, NULL, &s_BonusGrab[6]},
|
|
|
|
{BONUS_GRAB + 5, BONUS_GRAB_TICS, NULL, &s_BonusGrab[7]},
|
|
|
|
{BONUS_GRAB + 6, BONUS_GRAB_TICS, NULL, &s_BonusGrab[8]},
|
|
|
|
{BONUS_GRAB + 7, BONUS_GRAB_TICS, NULL, &s_BonusGrab[9]},
|
|
|
|
{BONUS_GRAB + 8, BONUS_GRAB_TICS, NULL, &s_BonusGrab[10]},
|
|
|
|
{BONUS_GRAB + 9, 90, NULL, &s_BonusGrab[11]},
|
|
|
|
{BONUS_GRAB + 9, BONUS_GRAB_TICS, NULL, &s_BonusGrab[11]},
|
|
|
|
};
|
|
|
|
|
|
|
|
#if 1 // Turned off the standing animate because he looks like a FAG!
|
|
|
|
static STATE s_BonusRest[] =
|
|
|
|
{
|
|
|
|
{BONUS_REST + 0, BONUS_REST_TICS, NULL, &s_BonusRest[1]},
|
|
|
|
{BONUS_REST + 1, BONUS_REST_TICS, NULL, &s_BonusRest[2]},
|
|
|
|
{BONUS_REST + 2, BONUS_REST_TICS, NULL, &s_BonusRest[3]},
|
|
|
|
{BONUS_REST + 1, BONUS_REST_TICS, NULL, &s_BonusRest[0]},
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
static STATE s_BonusRest[] =
|
|
|
|
{
|
|
|
|
{BONUS_REST + 0, BONUS_REST_TICS, NULL, &s_BonusRest[1]},
|
|
|
|
{BONUS_REST + 0, BONUS_REST_TICS, NULL, &s_BonusRest[0]},
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static STATEp s_BonusAnim[] =
|
|
|
|
{
|
|
|
|
s_BonusPunch,
|
|
|
|
s_BonusKick,
|
|
|
|
s_BonusGrab
|
|
|
|
};
|
|
|
|
|
|
|
|
STATEp State = s_BonusRest;
|
|
|
|
|
|
|
|
int Tics = 0;
|
|
|
|
int line = 0;
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL BonusDone;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (Level < 0) Level = 0;
|
|
|
|
|
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
|
|
|
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
totalclock = ototalclock = 0;
|
|
|
|
limit = synctics;
|
|
|
|
|
2019-12-09 19:12:54 +00:00
|
|
|
PlaySong(nullptr, ThemeSongs[1], ThemeTrack[1]);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// special case code because I don't care any more!
|
|
|
|
if (FinishAnim)
|
|
|
|
{
|
2019-04-08 06:26:36 +00:00
|
|
|
renderFlushPerms();
|
2015-05-19 21:54:34 +00:00
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, 5120, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
rotatesprite(158<<16, 86<<16, RS_SCALE, 0, State->Pic, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2019-12-02 20:05:19 +00:00
|
|
|
//FadeIn(0,0);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BonusDone = FALSE;
|
|
|
|
while (!BonusDone)
|
|
|
|
{
|
|
|
|
handleevents();
|
|
|
|
|
|
|
|
// taken from top of faketimerhandler
|
|
|
|
if (totalclock < ototalclock + limit)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ototalclock += limit;
|
|
|
|
|
2019-12-24 11:59:26 +00:00
|
|
|
if (inputState.CheckAllInput())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (State >= s_BonusRest && State < &s_BonusRest[SIZ(s_BonusRest)])
|
|
|
|
{
|
|
|
|
State = s_BonusAnim[STD_RANDOM_RANGE(SIZ(s_BonusAnim))];
|
|
|
|
Tics = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gStateControl(&State, &Tics);
|
2019-11-26 08:25:03 +00:00
|
|
|
|
2020-01-05 09:48:44 +00:00
|
|
|
twod->ClearScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
rotatesprite(0, 0, RS_SCALE, 0, 5120, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
|
|
|
|
if (UserMapName[0])
|
|
|
|
{
|
|
|
|
sprintf(ds,"%s",UserMapName);
|
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 20, ds,1,19);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (PlayingLevel <= 1)
|
|
|
|
PlayingLevel = 1;
|
2019-12-11 01:01:11 +00:00
|
|
|
auto ds = currentLevel->DisplayName();
|
2015-05-19 21:54:34 +00:00
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 20, ds,1,19);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(ds,"Completed");
|
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 30, ds,1,19);
|
|
|
|
|
|
|
|
rotatesprite(158<<16, 86<<16, RS_SCALE, 0, State->Pic, 0, 0, TITLE_ROT_FLAGS, 0, 0, xdim - 1, ydim - 1);
|
|
|
|
|
|
|
|
#define BONUS_LINE(i) (50 + ((i)*20))
|
|
|
|
|
|
|
|
line = 0;
|
|
|
|
second_tics = (PlayClock/120);
|
|
|
|
minutes = (second_tics/60);
|
|
|
|
seconds = (second_tics%60);
|
|
|
|
sprintf(ds,"Your Time: %2d : %02d", minutes, seconds);
|
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(60, BONUS_LINE(line), ds,1,16);
|
|
|
|
|
|
|
|
if (!UserMapName[0])
|
|
|
|
{
|
|
|
|
line++;
|
2019-12-11 01:01:11 +00:00
|
|
|
sprintf(ds,"3D Realms Best Time: %d:%02d", currentLevel->designerTime/60, currentLevel->designerTime%60);
|
2015-05-19 21:54:34 +00:00
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(40, BONUS_LINE(line), ds,1,16);
|
|
|
|
|
|
|
|
line++;
|
2019-12-11 01:01:11 +00:00
|
|
|
sprintf(ds,"Par Time: %d:%02d", currentLevel->parTime/ 60, currentLevel->parTime%60);
|
2015-05-19 21:54:34 +00:00
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(40, BONUS_LINE(line), ds,1,16);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// always read secrets and kills from the first player
|
|
|
|
line++;
|
|
|
|
sprintf(ds,"Secrets: %d / %d", Player->SecretsFound, LevelSecrets);
|
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(60, BONUS_LINE(line), ds,1,16);
|
|
|
|
|
|
|
|
line++;
|
|
|
|
sprintf(ds,"Kills: %d / %d", Player->Kills, TotalKillable);
|
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(60, BONUS_LINE(line), ds,1,16);
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(ds,"Press SPACE to continue");
|
|
|
|
MNU_MeasureString(ds, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 185, ds,1,19);
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (State == State->NextState)
|
|
|
|
BonusDone = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
StopSound();
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void EndGameSequence(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL anim_ok = TRUE;
|
2019-12-02 20:05:19 +00:00
|
|
|
//FadeOut(0, 5);
|
2020-02-13 23:52:57 +00:00
|
|
|
StopSound();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-27 12:40:24 +00:00
|
|
|
if ((adult_lockout || Global_PLock) && FinishAnim == ANIM_SUMO)
|
2015-05-19 21:54:34 +00:00
|
|
|
anim_ok = FALSE;
|
|
|
|
|
|
|
|
if (anim_ok)
|
|
|
|
playanm(FinishAnim);
|
|
|
|
|
2020-03-07 13:51:49 +00:00
|
|
|
BonusScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
ExitLevel = FALSE;
|
|
|
|
QuitFlag = FALSE;
|
|
|
|
AutoNet = FALSE;
|
|
|
|
|
|
|
|
if (FinishAnim == ANIM_ZILLA)
|
|
|
|
CreditsLevel();
|
|
|
|
|
|
|
|
ExitLevel = FALSE;
|
|
|
|
QuitFlag = FALSE;
|
|
|
|
AutoNet = FALSE;
|
|
|
|
|
|
|
|
if (SW_SHAREWARE)
|
|
|
|
{
|
|
|
|
Level = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Level == 4 || Level == 20)
|
|
|
|
{
|
|
|
|
Level=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Level++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 death_total[MAX_SW_PLAYERS_REG];
|
|
|
|
short kills[MAX_SW_PLAYERS_REG];
|
|
|
|
short pal;
|
|
|
|
|
|
|
|
#define STAT_START_X 20
|
|
|
|
#define STAT_START_Y 85
|
|
|
|
#define STAT_OFF_Y 9
|
|
|
|
#define STAT_HEADER_Y 14
|
|
|
|
|
|
|
|
#define SM_SIZ(num) ((num)*4)
|
|
|
|
|
|
|
|
#define STAT_TABLE_X (STAT_START_X + SM_SIZ(15))
|
|
|
|
#define STAT_TABLE_XOFF SM_SIZ(6)
|
|
|
|
|
|
|
|
// No stats in bot games
|
|
|
|
//if (BotMode) return;
|
|
|
|
|
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-03-07 13:51:49 +00:00
|
|
|
BonusScreen();
|
2015-05-19 21:54:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
renderFlushPerms();
|
2015-05-19 21:54:34 +00:00
|
|
|
DrawStatScreen();
|
|
|
|
|
|
|
|
memset(death_total,0,sizeof(death_total));
|
|
|
|
memset(kills,0,sizeof(kills));
|
|
|
|
|
2019-12-09 20:19:05 +00:00
|
|
|
auto c = GStrings("MULTIPLAYER TOTALS");
|
|
|
|
MNU_MeasureString(c, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 68, c, 0, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-09 20:19:05 +00:00
|
|
|
c = GStrings("TXTS_PRESSSPACE");
|
|
|
|
MNU_MeasureString(c, &w, &h);
|
|
|
|
MNU_DrawString(TEXT_TEST_COL(w), 189, c, 0, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
x = STAT_START_X;
|
|
|
|
y = STAT_START_Y;
|
|
|
|
|
2019-12-09 20:19:05 +00:00
|
|
|
// Hm.... how to translate this without messing up the formatting?
|
2015-05-19 21:54:34 +00:00
|
|
|
sprintf(ds," NAME 1 2 3 4 5 6 7 8 KILLS");
|
|
|
|
DisplayMiniBarSmString(mpp, x, y, 0, ds);
|
|
|
|
rows = OrigCommPlayers;
|
|
|
|
cols = OrigCommPlayers;
|
|
|
|
mpp = Player + myconnectindex;
|
|
|
|
|
|
|
|
y += STAT_HEADER_Y;
|
|
|
|
|
|
|
|
for (i = 0; i < rows; i++)
|
|
|
|
{
|
|
|
|
x = STAT_START_X;
|
|
|
|
pp = Player + i;
|
|
|
|
|
|
|
|
sprintf(ds,"%d", i+1);
|
|
|
|
DisplayMiniBarSmString(mpp, x, y, 0, ds);
|
|
|
|
|
|
|
|
sprintf(ds," %-13s", pp->PlayerName);
|
|
|
|
DisplayMiniBarSmString(mpp, x, y, User[pp->PlayerSprite]->spal, ds);
|
|
|
|
|
|
|
|
x = STAT_TABLE_X;
|
|
|
|
for (j = 0; j < cols; j++)
|
|
|
|
{
|
|
|
|
pal = 0;
|
|
|
|
death_total[j] += pp->KilledPlayer[j];
|
|
|
|
|
|
|
|
if (i == j)
|
|
|
|
{
|
|
|
|
// don't add kill for self or team player
|
|
|
|
pal = PALETTE_PLAYER0 + 4;
|
|
|
|
kills[i] -= pp->KilledPlayer[j]; // subtract self kills
|
|
|
|
}
|
|
|
|
else if (gNet.TeamPlay)
|
|
|
|
{
|
|
|
|
if (User[pp->PlayerSprite]->spal == User[Player[j].PlayerSprite]->spal)
|
|
|
|
{
|
|
|
|
// don't add kill for self or team player
|
|
|
|
pal = PALETTE_PLAYER0 + 4;
|
|
|
|
kills[i] -= pp->KilledPlayer[j]; // subtract self kills
|
|
|
|
}
|
|
|
|
else
|
|
|
|
kills[i] += pp->KilledPlayer[j]; // kills added here
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
kills[i] += pp->KilledPlayer[j]; // kills added here
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(ds,"%d", pp->KilledPlayer[j]);
|
|
|
|
DisplayMiniBarSmString(mpp, x, y, pal, ds);
|
|
|
|
x += STAT_TABLE_XOFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
y += STAT_OFF_Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Deaths
|
|
|
|
|
|
|
|
x = STAT_START_X;
|
|
|
|
y += STAT_OFF_Y;
|
|
|
|
|
2019-12-09 20:19:05 +00:00
|
|
|
sprintf(ds," %s", GStrings("DEATHS"));
|
2015-05-19 21:54:34 +00:00
|
|
|
DisplayMiniBarSmString(mpp, x, y, 0, ds);
|
|
|
|
x = STAT_TABLE_X;
|
|
|
|
|
|
|
|
for (j = 0; j < cols; j++)
|
|
|
|
{
|
|
|
|
sprintf(ds,"%d",death_total[j]);
|
|
|
|
DisplayMiniBarSmString(mpp, x, y, 0, ds);
|
|
|
|
x += STAT_TABLE_XOFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
x = STAT_START_X;
|
|
|
|
y += STAT_OFF_Y;
|
|
|
|
|
|
|
|
// Kills
|
|
|
|
x = STAT_TABLE_X + SM_SIZ(50);
|
|
|
|
y = STAT_START_Y + STAT_HEADER_Y;
|
|
|
|
|
|
|
|
for (i = 0; i < rows; i++)
|
|
|
|
{
|
|
|
|
pp = Player + i;
|
|
|
|
|
|
|
|
sprintf(ds,"%d", kills[i]); //pp->Kills);
|
|
|
|
DisplayMiniBarSmString(mpp, x, y, 0, ds);
|
|
|
|
|
|
|
|
y += STAT_OFF_Y;
|
|
|
|
}
|
|
|
|
|
2019-04-08 06:26:36 +00:00
|
|
|
videoNextPage();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-24 11:59:26 +00:00
|
|
|
inputState.ClearAllInput();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-09 19:12:54 +00:00
|
|
|
PlaySong(nullptr, ThemeSongs[1], ThemeTrack[1]);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-11-03 23:53:55 +00:00
|
|
|
while (!inputState.GetKeyStatus(KEYSC_SPACE) && !inputState.GetKeyStatus(KEYSC_ENTER))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
handleevents();
|
|
|
|
}
|
|
|
|
|
|
|
|
StopSound();
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void GameIntro(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
DSPRINTF(ds,"GameIntro...");
|
|
|
|
MONO_PRINT(ds);
|
|
|
|
|
|
|
|
if (DemoPlaying)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// this could probably be taken out and you could select skill level
|
|
|
|
// from menu to start the game
|
|
|
|
if (!CommEnabled && UserMapName[0])
|
|
|
|
return;
|
|
|
|
|
|
|
|
Level = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-30 05:51:53 +00:00
|
|
|
PlayTheme();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!AutoNet)
|
|
|
|
{
|
|
|
|
LogoLevel();
|
|
|
|
//CreditsLevel();
|
|
|
|
//SceneLevel();
|
|
|
|
//TitleLevel();
|
|
|
|
IntroAnimLevel();
|
|
|
|
IntroAnimCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
MONO_PRINT("InitGame done");
|
2019-12-02 20:05:19 +00:00
|
|
|
//MNU_InitMenus();
|
2015-05-19 21:54:34 +00:00
|
|
|
InGame = TRUE;
|
|
|
|
GameIntro();
|
|
|
|
|
|
|
|
while (!QuitFlag)
|
|
|
|
{
|
|
|
|
handleevents();
|
|
|
|
OSD_DispatchQueued();
|
|
|
|
|
|
|
|
NewLevel();
|
|
|
|
}
|
|
|
|
|
|
|
|
CleanExit = TRUE;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void dsprintf(char *str, const char *format, ...)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
va_list arglist;
|
|
|
|
|
|
|
|
va_start(arglist, format);
|
|
|
|
vsprintf(str, format, arglist);
|
|
|
|
va_end(arglist);
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void dsprintf_null(char *str, const char *format, ...)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
va_list arglist;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
getpackets();
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
//if (DemoSyncRecord)
|
|
|
|
// demosync_record();
|
|
|
|
#endif
|
|
|
|
}
|
2020-04-11 07:17:59 +00:00
|
|
|
|
|
|
|
// Get input again to update q16ang/q16horiz.
|
|
|
|
if (!PEDANTIC_MODE)
|
|
|
|
getinput(&loc, TRUE);
|
2020-05-19 11:44:52 +00:00
|
|
|
}
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
void InitPlayerGameSettings(void)
|
|
|
|
{
|
|
|
|
int pnum;
|
|
|
|
|
|
|
|
// don't jack with auto aim settings if DemoMode is going
|
|
|
|
// what the hell did I do this for?????????
|
|
|
|
//if (DemoMode)
|
|
|
|
// return;
|
|
|
|
|
|
|
|
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 (DemoEdit)
|
|
|
|
return;
|
|
|
|
|
|
|
|
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();
|
|
|
|
SetCrosshair();
|
|
|
|
SetRedrawScreen(Player + myconnectindex);
|
|
|
|
// crappy little hack to prevent play clock from being overwritten
|
|
|
|
// for load games
|
|
|
|
SavePlayClock = PlayClock;
|
|
|
|
InitTimingVars();
|
|
|
|
PlayClock = SavePlayClock;
|
|
|
|
MONO_PRINT("Done with InitRunLevel");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// ensure we are through the initialization code before sending the game
|
|
|
|
// version. Otherwise, it is possible to send this too early and have it
|
|
|
|
// blown away on the other side.
|
|
|
|
waitforeverybody();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SendVersion(GameVersion);
|
|
|
|
|
|
|
|
waitforeverybody();
|
|
|
|
|
2019-12-07 18:57:19 +00:00
|
|
|
Mus_Stop();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (Bstrcasecmp(CacheLastLevel, LevelName) != 0)
|
|
|
|
DoTheCache();
|
|
|
|
|
|
|
|
// auto aim / auto run / etc
|
|
|
|
InitPlayerGameSettings();
|
|
|
|
|
|
|
|
// send packets with player info
|
|
|
|
InitNetPlayerOptions();
|
|
|
|
|
|
|
|
// Initialize Game part of network code (When ready2send != 0)
|
|
|
|
InitNetVars();
|
|
|
|
|
|
|
|
{
|
|
|
|
if (Level == 0)
|
|
|
|
{
|
2019-12-11 01:01:11 +00:00
|
|
|
PlaySong(nullptr, currentLevel->music, 1 + RANDOM_RANGE(10));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-11 01:01:11 +00:00
|
|
|
PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InitPrediction(&Player[myconnectindex]);
|
|
|
|
|
|
|
|
if (!DemoInitOnce)
|
|
|
|
DemoRecordSetup();
|
|
|
|
|
|
|
|
// everything has been inited at least once for RECORD
|
|
|
|
DemoInitOnce = TRUE;
|
|
|
|
|
|
|
|
//DebugWriteLoc(__FILE__, __LINE__);
|
|
|
|
waitforeverybody();
|
|
|
|
|
|
|
|
CheckVersion(GameVersion);
|
|
|
|
|
|
|
|
// IMPORTANT - MUST be right before game loop AFTER waitforeverybody
|
|
|
|
InitTimingVars();
|
|
|
|
|
|
|
|
SetRedrawScreen(Player + myconnectindex);
|
2019-10-22 00:01:05 +00:00
|
|
|
|
|
|
|
if (snd_ambience)
|
2015-05-19 21:54:34 +00:00
|
|
|
StartAmbientSound();
|
|
|
|
}
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
void faketimerhandler();
|
|
|
|
|
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();
|
|
|
|
OSD_DispatchQueued();
|
2019-11-20 21:01:44 +00:00
|
|
|
D_ProcessEvents();
|
2020-05-19 11:44:52 +00:00
|
|
|
faketimerhandler();
|
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-19 11:44:52 +00:00
|
|
|
if (M_Active())
|
2020-01-05 17:49:19 +00:00
|
|
|
{
|
2020-05-19 11:44:52 +00:00
|
|
|
ototalclock = (int)totalclock;
|
2020-01-05 17:49:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-19 11:44:52 +00:00
|
|
|
MoveLoop();
|
2020-05-19 10:03:52 +00:00
|
|
|
}
|
2019-11-20 21:01:44 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
drawscreen(Player + screenpeek);
|
|
|
|
|
|
|
|
if (QuitFlag)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (ExitLevel)
|
|
|
|
{
|
|
|
|
ExitLevel = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ready2send = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char notshareware;
|
2019-04-08 06:25:22 +00:00
|
|
|
const char *arg_switch;
|
2015-05-19 21:54:34 +00:00
|
|
|
short arg_match_len;
|
2019-04-08 06:25:22 +00:00
|
|
|
const char *arg_fmt;
|
|
|
|
const char *arg_descr;
|
2015-05-19 21:54:34 +00:00
|
|
|
} CLI_ARG;
|
|
|
|
|
2019-12-17 22:25:07 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
CLI_ARG cli_arg[] =
|
|
|
|
{
|
|
|
|
{0, "/?", 2, "-?", "This help message" },
|
|
|
|
//#ifndef SW_SHAREWARE
|
|
|
|
//{"/l", 2, "-l#", "Level (1-11)" },
|
|
|
|
//{"/v", 2, "-v#", "Volume (1-3)" },
|
|
|
|
{1, "/map", 4, "-map [mapname]", "Load a map" },
|
|
|
|
{1, "/nocdaudio", 5, "-nocd<audio>", "No CD Red Book Audio" },
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
{0, "/name", 5, "-name [playername]", "Player Name" },
|
|
|
|
{0, "/s", 2, "-s#", "Skill (1-4)" },
|
|
|
|
{0, "/f#", 3, "-f#", "Packet Duplication - 2, 4, 8" },
|
|
|
|
{0, "/nopredict", 7, "-nopred<ict>", "Disable Net Prediction Method" },
|
|
|
|
{0, "/level#", 5, "-level#", "Start at level# (Shareware: 1-4, full version 1-28)" },
|
|
|
|
{0, "/dr", 3, "-dr[filename.dmo]", "Demo record. NOTE: Must use -level# with this option." },
|
|
|
|
{0, "/dp", 3, "-dp[filename.dmo]", "Demo playback. NOTE: Must use -level# with this option." },
|
|
|
|
{0, "/m", 6, "-monst<ers>", "No Monsters" },
|
|
|
|
{0, "/nodemo", 6, "-nodemo", "No demos on game startup" },
|
|
|
|
{0, "/nometers", 9, "-nometers", "Don't show air or boss meter bars in game"},
|
|
|
|
{0, "/movescale #", 9, "-movescale", "Adjust movement scale: 256 = 1 unit"},
|
|
|
|
{0, "/turnscale #", 9, "-turnscale", "Adjust turning scale: 256 = 1 unit"},
|
|
|
|
{0, "/extcompat", 9, "-extcompat", "Controller compatibility mode (with Duke 3D)"},
|
|
|
|
{1, "/g#", 2, "-g[filename.grp]", "Load an extra GRP or ZIP file"},
|
|
|
|
{1, "/h#", 2, "-h[filename.def]", "Use filename.def instead of SW.DEF"},
|
|
|
|
{0, "/setup", 5, "-setup", "Displays the configuration dialogue box"},
|
|
|
|
#if DEBUG
|
|
|
|
{0, "/coop", 5, "-coop#", "Single Player Cooperative Mode" },
|
|
|
|
{0, "/commbat", 8, "-commbat#", "Single Player Commbat Mode" },
|
|
|
|
{0, "/debug", 6, "-debug", "Debug Help Options" },
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0 //def NET_MODE_MASTER_SLAVE
|
|
|
|
{0, "/broadcast", 6, "-broad<cast>", "Broadcast network method (default)" },
|
|
|
|
{0, "/masterslave", 7, "-master<slave>", "Master/Slave network method" },
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#if 0
|
2019-11-17 17:02:17 +00:00
|
|
|
Map -> User Map Name
|
|
|
|
Auto -> Auto Start Game
|
|
|
|
Rules -> 0=WangBang 1=WangBang (No Respawn) 2=CoOperative
|
|
|
|
Level -> 0 to 24(?)
|
|
|
|
Enemy -> 0=None 1=Easy 2=Norm 3=Hard 4=Insane
|
|
|
|
Markers -> 0=Off 1=On
|
|
|
|
Team -> 0=Off 1=On
|
|
|
|
HurtTeam -> 0=Off 1=On
|
|
|
|
KillLimit -> 0=Infinite 1=10 2=20 3=30 4=40 5=50 6=60 7=70 8=80 9=90 10=100
|
|
|
|
TimeLimit -> 0=Infinite 1=3 2=5 3=10 4=20 5=30 6=45 7=60
|
|
|
|
Color -> 0=Brown 1=Purple 2=Red 3=Yellow 4=Olive 5=Green
|
|
|
|
Nuke -> 0=Off 1=On
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
Example Command Line :
|
|
|
|
sw -map testmap.map -autonet 0,0,1,1,1,0,3,2,1,1 -f4 -name 1234567890 -net 12345678
|
|
|
|
commit -map grenade -autonet 0,0,1,1,1,0,3,2,1,1 -name frank
|
|
|
|
#endif
|
|
|
|
|
2019-11-30 06:10:33 +00:00
|
|
|
char isShareware = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
int DetectShareware(void)
|
|
|
|
{
|
2019-12-07 09:31:27 +00:00
|
|
|
return (isShareware = !!(g_gameType & GAMEFLAG_SHAREWARE));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-12 10:30:56 +00:00
|
|
|
void CommandLineHelp(char const * const * argv)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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",
|
|
|
|
"Weapon_1",
|
|
|
|
"Weapon_2",
|
|
|
|
"Weapon_3",
|
|
|
|
"Weapon_4",
|
|
|
|
"Weapon_5",
|
|
|
|
"Weapon_6",
|
|
|
|
"Weapon_7",
|
|
|
|
"Weapon_8",
|
|
|
|
"Weapon_9",
|
|
|
|
"Weapon_10",
|
|
|
|
"Inventory",
|
|
|
|
"Inventory_Left",
|
|
|
|
"Inventory_Right",
|
|
|
|
"NightVision",
|
|
|
|
"MedKit",
|
|
|
|
"TurnAround",
|
|
|
|
"SendMessage",
|
|
|
|
"Map",
|
|
|
|
"Shrink_Screen",
|
|
|
|
"Enlarge_Screen",
|
|
|
|
"Center_View",
|
|
|
|
"Holster_Weapon",
|
|
|
|
"Show_Opponents_Weapon",
|
|
|
|
"Map_Follow_Mode",
|
|
|
|
"See_Coop_View",
|
|
|
|
"Mouse_Aiming",
|
|
|
|
"Toggle_Crosshair",
|
|
|
|
"Next_Weapon",
|
|
|
|
"Previous_Weapon",
|
|
|
|
"Dpad_Select",
|
|
|
|
"Dpad_Aiming",
|
|
|
|
"Last_Weapon",
|
|
|
|
"Alt_Weapon",
|
|
|
|
"Third_Person_View",
|
|
|
|
"Toggle_Crouch", // This is the last one used by EDuke32"",
|
|
|
|
"Smoke_Bomb",
|
|
|
|
"Gas_Bomb",
|
|
|
|
"Flash_Bomb",
|
|
|
|
"Caltrops",
|
|
|
|
|
|
|
|
};
|
|
|
|
|
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-04-11 22:10:39 +00:00
|
|
|
buttonMap.SetButtons(actions, NUM_ACTIONS);
|
2019-12-31 21:05:23 +00:00
|
|
|
automapping = 1;
|
2019-12-07 20:39:17 +00:00
|
|
|
BorderAdjust = true;
|
2019-10-30 05:51:44 +00:00
|
|
|
SW_ExtInit();
|
|
|
|
|
2019-11-01 08:30:28 +00:00
|
|
|
CONFIG_ReadSetup();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-19 08:31:39 +00:00
|
|
|
hud_size.Callback();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!DetectShareware())
|
|
|
|
{
|
2020-04-11 21:45:45 +00:00
|
|
|
if (SW_SHAREWARE) Printf("Detected shareware GRP\n");
|
|
|
|
else Printf("Detected registered GRP\n");
|
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
|
|
|
|
|
|
|
UserMapName[0] = '\0';
|
|
|
|
|
2020-01-23 10:50:12 +00:00
|
|
|
registerosdcommands();
|
|
|
|
|
2019-10-31 23:32:56 +00:00
|
|
|
Control();
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void ManualPlayerInsert(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
PLAYERp npp = Player + numplayers;
|
|
|
|
|
|
|
|
if (numplayers < MAX_SW_PLAYERS)
|
|
|
|
{
|
|
|
|
connectpoint2[numplayers - 1] = numplayers;
|
|
|
|
connectpoint2[numplayers] = -1;
|
|
|
|
|
|
|
|
npp->posx = pp->posx;
|
|
|
|
npp->posy = pp->posy;
|
|
|
|
npp->posz = pp->posz;
|
2020-05-19 11:44:52 +00:00
|
|
|
npp->pang = pp->pang;
|
2015-05-19 21:54:34 +00:00
|
|
|
npp->cursectnum = pp->cursectnum;
|
|
|
|
|
|
|
|
myconnectindex = numplayers;
|
|
|
|
screenpeek = numplayers;
|
|
|
|
|
|
|
|
sprintf(Player[myconnectindex].PlayerName,"PLAYER %d",myconnectindex+1);
|
|
|
|
|
|
|
|
Player[numplayers].movefifoend = Player[0].movefifoend;
|
|
|
|
|
|
|
|
// If IsAI = TRUE, new player will be a bot
|
|
|
|
Player[myconnectindex].IsAI = FALSE;
|
|
|
|
|
|
|
|
numplayers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-11-17 17:02:17 +00:00
|
|
|
void BotPlayerInsert(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
PLAYERp npp = Player + numplayers;
|
|
|
|
|
|
|
|
if (numplayers < MAX_SW_PLAYERS)
|
|
|
|
{
|
|
|
|
connectpoint2[numplayers - 1] = numplayers;
|
|
|
|
connectpoint2[numplayers] = -1;
|
|
|
|
|
|
|
|
npp->posx = pp->posx;
|
|
|
|
npp->posy = pp->posy;
|
|
|
|
npp->posz = pp->posz-Z(100);
|
2020-05-19 11:44:52 +00:00
|
|
|
npp->pang = pp->pang;
|
2015-05-19 21:54:34 +00:00
|
|
|
npp->cursectnum = pp->cursectnum;
|
|
|
|
|
|
|
|
//myconnectindex = numplayers;
|
|
|
|
//screenpeek = numplayers;
|
|
|
|
|
|
|
|
sprintf(Player[numplayers].PlayerName,"BOT %d",numplayers+1);
|
|
|
|
|
|
|
|
Player[numplayers].movefifoend = Player[0].movefifoend;
|
|
|
|
|
|
|
|
// If IsAI = TRUE, new player will be a bot
|
|
|
|
Player[numplayers].IsAI = TRUE;
|
|
|
|
|
|
|
|
numplayers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetFragBar(pp);
|
|
|
|
}
|
|
|
|
|
2020-03-07 13:51:49 +00:00
|
|
|
void
|
|
|
|
ManualPlayerDelete(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
short i, nexti;
|
|
|
|
USERp u;
|
|
|
|
PLAYERp pp;
|
|
|
|
|
|
|
|
if (numplayers > 1)
|
|
|
|
{
|
|
|
|
numplayers--;
|
|
|
|
connectpoint2[numplayers - 1] = -1;
|
|
|
|
|
|
|
|
pp = Player + numplayers;
|
|
|
|
|
|
|
|
KillSprite(pp->PlayerSprite);
|
|
|
|
pp->PlayerSprite = -1;
|
|
|
|
|
|
|
|
// Make sure enemys "forget" about deleted player
|
|
|
|
TRAVERSE_SPRITE_STAT(headspritestat[STAT_ENEMY], i, nexti)
|
|
|
|
{
|
|
|
|
u = User[i];
|
|
|
|
if (u->tgt_sp == pp->SpriteP)
|
|
|
|
u->tgt_sp = Player[0].SpriteP;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (myconnectindex >= numplayers)
|
|
|
|
myconnectindex = 0;
|
|
|
|
|
|
|
|
if (screenpeek >= numplayers)
|
|
|
|
screenpeek = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-30 06:10:26 +00:00
|
|
|
char WangBangMacro[10][64];
|
|
|
|
|
|
|
|
void
|
|
|
|
FunctionKeys(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
static int rts_delay = 0;
|
|
|
|
int fn_key = 0;
|
|
|
|
|
|
|
|
rts_delay++;
|
|
|
|
|
2019-11-03 23:53:55 +00:00
|
|
|
if (inputState.GetKeyStatus(sc_F1)) { fn_key = 1; }
|
|
|
|
if (inputState.GetKeyStatus(sc_F2)) { fn_key = 2; }
|
|
|
|
if (inputState.GetKeyStatus(sc_F3)) { fn_key = 3; }
|
|
|
|
if (inputState.GetKeyStatus(sc_F4)) { fn_key = 4; }
|
|
|
|
if (inputState.GetKeyStatus(sc_F5)) { fn_key = 5; }
|
|
|
|
if (inputState.GetKeyStatus(sc_F6)) { fn_key = 6; }
|
|
|
|
if (inputState.GetKeyStatus(sc_F7)) { fn_key = 7; }
|
|
|
|
if (inputState.GetKeyStatus(sc_F8)) { fn_key = 8; }
|
|
|
|
if (inputState.GetKeyStatus(sc_F9)) { fn_key = 9; }
|
|
|
|
if (inputState.GetKeyStatus(sc_F10)) { fn_key = 10; }
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-28 06:02:42 +00:00
|
|
|
if (inputState.AltPressed())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-10-27 12:40:24 +00:00
|
|
|
if (rts_delay > 16 && fn_key && CommEnabled && !adult_lockout && !Global_PLock)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-10-28 05:47:49 +00:00
|
|
|
inputState.ClearKeyStatus(sc_F1 + fn_key - 1);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
rts_delay = 0;
|
|
|
|
|
|
|
|
PlaySoundRTS(fn_key);
|
|
|
|
|
|
|
|
if (CommEnabled)
|
|
|
|
{
|
|
|
|
PACKET_RTS p;
|
|
|
|
|
|
|
|
p.PacketType = PACKET_TYPE_RTS;
|
|
|
|
p.RTSnum = fn_key;
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
netbroadcastpacket((uint8_t*)(&p), sizeof(p)); // TENSW
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-28 06:02:42 +00:00
|
|
|
if (inputState.ShiftPressed())
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (fn_key && CommEnabled)
|
|
|
|
{
|
2019-10-28 05:47:49 +00:00
|
|
|
inputState.ClearKeyStatus(sc_Escape);
|
|
|
|
inputState.ClearKeyStatus(sc_F1 + fn_key - 1);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (CommEnabled)
|
|
|
|
{
|
|
|
|
short pnum;
|
|
|
|
|
2019-10-27 07:14:58 +00:00
|
|
|
sprintf(ds,"SENT: %s",**CombatMacros[fn_key-1]);
|
2015-05-19 21:54:34 +00:00
|
|
|
adduserquote(ds);
|
|
|
|
|
|
|
|
TRAVERSE_CONNECT(pnum)
|
|
|
|
{
|
|
|
|
if (pnum != myconnectindex)
|
|
|
|
{
|
2019-10-27 07:14:58 +00:00
|
|
|
sprintf(ds,"%s: %s",pp->PlayerName, **CombatMacros[fn_key - 1]);
|
2015-05-19 21:59:39 +00:00
|
|
|
SW_SendMessage(pnum, ds);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// F7 VIEW control
|
2019-12-02 20:05:19 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Third_Person_View))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-02 20:05:19 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Third_Person_View);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-11-03 23:53:55 +00:00
|
|
|
if (inputState.GetKeyStatus(KEYSC_LSHIFT) || inputState.GetKeyStatus(KEYSC_RSHIFT))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
|
|
|
|
pp->view_outside_dang = NORM_ANGLE(pp->view_outside_dang + 256);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (TEST(pp->Flags, PF_VIEW_FROM_OUTSIDE))
|
|
|
|
{
|
|
|
|
RESET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SET(pp->Flags, PF_VIEW_FROM_OUTSIDE);
|
|
|
|
pp->camera_dist = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void PauseKey(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2015-05-19 21:58:29 +00:00
|
|
|
extern SWBOOL GamePaused,CheatInputMode;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-02 20:05:19 +00:00
|
|
|
if (inputState.GetKeyStatus(sc_Pause) && !CommEnabled && !InputMode && !M_Active() && !CheatInputMode && !ConPanel)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-10-28 05:47:49 +00:00
|
|
|
inputState.ClearKeyStatus(sc_Pause);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
PauseKeySet ^= 1;
|
|
|
|
|
|
|
|
if (PauseKeySet)
|
|
|
|
GamePaused = TRUE;
|
|
|
|
else
|
|
|
|
GamePaused = FALSE;
|
|
|
|
|
|
|
|
if (GamePaused)
|
|
|
|
{
|
|
|
|
short w,h;
|
|
|
|
#define MSG_GAME_PAUSED "Game Paused"
|
|
|
|
MNU_MeasureString(MSG_GAME_PAUSED, &w, &h);
|
|
|
|
PutStringTimer(pp, TEXT_TEST_COL(w), 100, MSG_GAME_PAUSED, 999);
|
2019-12-07 18:57:19 +00:00
|
|
|
Mus_SetPaused(true);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pClearTextLine(pp, 100);
|
2019-12-07 18:57:19 +00:00
|
|
|
Mus_SetPaused(false);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!CommEnabled && TEST(pp->Flags, PF_DEAD))
|
|
|
|
{
|
|
|
|
if (ReloadPrompt)
|
|
|
|
{
|
|
|
|
ReloadPrompt = FALSE;
|
2019-11-30 18:23:54 +00:00
|
|
|
/*
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-28 05:47:49 +00:00
|
|
|
inputState.SetKeyStatus(sc_Escape);
|
|
|
|
ControlPanelType = ct_quickloadmenu;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2019-11-30 18:23:54 +00:00
|
|
|
*/
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
short MirrorDelay;
|
|
|
|
|
2020-04-10 22:07:41 +00:00
|
|
|
double elapsedInputTicks;
|
|
|
|
double scaleAdjustmentToInterval(double x) { return x * (120 / synctics) / (1000.0 / elapsedInputTicks); }
|
|
|
|
|
|
|
|
void
|
2020-04-11 07:17:59 +00:00
|
|
|
getinput(SW_PACKET *loc, SWBOOL tied)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
int i;
|
2020-05-19 11:44:52 +00:00
|
|
|
PLAYERp pp = Player + myconnectindex;
|
|
|
|
PLAYERp newpp = Player + myconnectindex;
|
2015-05-19 21:54:34 +00:00
|
|
|
int inv_hotkey = 0;
|
|
|
|
|
|
|
|
#define TURBOTURNTIME (120/8)
|
|
|
|
#define NORMALTURN (12+6)
|
|
|
|
#define RUNTURN (28)
|
|
|
|
#define PREAMBLETURN 3
|
|
|
|
#define NORMALKEYMOVE 35
|
|
|
|
#define MAXVEL ((NORMALKEYMOVE*2)+10)
|
|
|
|
#define MAXSVEL ((NORMALKEYMOVE*2)+10)
|
2020-05-19 11:44:52 +00:00
|
|
|
#define MAXANGVEL 100
|
2020-03-28 11:31:02 +00:00
|
|
|
#define MAXHORIZVEL 128
|
2020-05-19 11:44:52 +00:00
|
|
|
#define SET_LOC_KEY(loc, sync_num, key_test) SET(loc, ((!!(key_test)) << (sync_num)))
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
static int32_t turnheldtime;
|
2020-05-19 11:44:52 +00:00
|
|
|
int32_t momx, momy;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
extern SWBOOL MenuButtonAutoRun;
|
2015-05-19 21:58:29 +00:00
|
|
|
extern SWBOOL MenuButtonAutoAim;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (Prediction && CommEnabled)
|
|
|
|
{
|
2020-05-19 11:44:52 +00:00
|
|
|
newpp = ppp;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2020-04-11 07:17:59 +00:00
|
|
|
static double lastInputTicks;
|
|
|
|
|
|
|
|
auto const currentHiTicks = timerGetHiTicks();
|
|
|
|
elapsedInputTicks = currentHiTicks - lastInputTicks;
|
|
|
|
|
|
|
|
lastInputTicks = currentHiTicks;
|
2020-05-19 11:44:52 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
// MAKE SURE THIS WILL GET SET
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_QUIT_GAME, MultiPlayQuitFlag);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-05 00:08:35 +00:00
|
|
|
bool mouseaim = in_mousemode || buttonMap.ButtonDown(gamefunc_Mouse_Aiming);
|
2019-10-27 15:53:00 +00:00
|
|
|
|
2019-12-05 00:08:35 +00:00
|
|
|
if (!CommEnabled)
|
2019-10-27 15:53:00 +00:00
|
|
|
{
|
2019-12-05 00:08:35 +00:00
|
|
|
// Go back to the source to set this - the old code here was catastrophically bad.
|
|
|
|
// this needs to be fixed properly - as it is this can never be compatible with demo playback.
|
|
|
|
|
|
|
|
if (mouseaim)
|
2020-05-19 11:44:52 +00:00
|
|
|
SET(Player[myconnectindex].Flags, PF_MOUSE_AIMING_ON);
|
2019-10-27 15:53:00 +00:00
|
|
|
else
|
2020-05-19 11:44:52 +00:00
|
|
|
RESET(Player[myconnectindex].Flags, PF_MOUSE_AIMING_ON);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-05 00:08:35 +00:00
|
|
|
if (cl_autoaim)
|
2020-05-19 11:44:52 +00:00
|
|
|
SET(Player[myconnectindex].Flags, PF_AUTO_AIM);
|
|
|
|
else
|
|
|
|
RESET(Player[myconnectindex].Flags, PF_AUTO_AIM);
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-11-26 08:24:19 +00:00
|
|
|
ControlInfo info;
|
2015-05-19 21:54:34 +00:00
|
|
|
CONTROL_GetInput(&info);
|
|
|
|
|
2020-04-01 10:30:54 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
//info.dz = (info.dz * move_scale)>>8;
|
|
|
|
//info.dyaw = (info.dyaw * turn_scale)>>8;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
PauseKey(pp);
|
|
|
|
|
|
|
|
if (PauseKeySet)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// MAP KEY
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Map))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Map);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Init follow coords
|
2020-05-19 11:44:52 +00:00
|
|
|
Follow_posx = pp->posx;
|
|
|
|
Follow_posy = pp->posy;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (dimensionmode == 3)
|
|
|
|
dimensionmode = 5;
|
|
|
|
else if (dimensionmode == 5)
|
|
|
|
dimensionmode = 6;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MirrorDelay = 1;
|
|
|
|
dimensionmode = 3;
|
|
|
|
SetFragBar(pp);
|
2020-05-19 11:44:52 +00:00
|
|
|
ScrollMode2D = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
SetRedrawScreen(pp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Toggle follow map mode on/off
|
|
|
|
if (dimensionmode == 5 || dimensionmode == 6)
|
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Map_Follow_Mode))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Map_Follow_Mode);
|
2020-05-19 11:44:52 +00:00
|
|
|
ScrollMode2D = !ScrollMode2D;
|
|
|
|
Follow_posx = pp->posx;
|
|
|
|
Follow_posy = pp->posy;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
// If in 2D follow mode, scroll around using glob vars
|
|
|
|
// Tried calling this in domovethings, but key response it too poor, skips key presses
|
|
|
|
// Note: ScrollMode2D = Follow mode, so this get called only during follow mode
|
2020-04-11 07:17:59 +00:00
|
|
|
if (!tied && ScrollMode2D && pp == Player + myconnectindex && !Prediction)
|
2020-05-19 11:44:52 +00:00
|
|
|
MoveScrollMode2D(Player + myconnectindex);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
// !JIM! Added M_Active() so that you don't move at all while using menus
|
|
|
|
if (M_Active() || ScrollMode2D || InputMode)
|
|
|
|
return;
|
2020-04-01 10:30:54 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_SPACE_BAR, ((!!inputState.GetKeyStatus(KEYSC_SPACE)) | buttonMap.ButtonDown(gamefunc_Open)));
|
2020-04-01 10:30:54 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
int const running = G_CheckAutorun(buttonMap.ButtonDown(gamefunc_Run));
|
|
|
|
int32_t turnamount;
|
|
|
|
int32_t keymove;
|
|
|
|
constexpr int const analogExtent = 32767; // KEEPINSYNC sdlayer.cpp
|
2020-04-01 10:30:54 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
if (running)
|
|
|
|
{
|
|
|
|
if (pp->sop_control)
|
|
|
|
turnamount = RUNTURN * 3;
|
|
|
|
else
|
|
|
|
turnamount = RUNTURN;
|
2020-04-01 10:30:54 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
keymove = NORMALKEYMOVE << 1;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2020-05-19 11:44:52 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pp->sop_control)
|
|
|
|
turnamount = NORMALTURN * 3;
|
|
|
|
else
|
|
|
|
turnamount = NORMALTURN;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
keymove = NORMALKEYMOVE;
|
|
|
|
}
|
2020-04-01 10:30:54 +00:00
|
|
|
|
2020-04-11 07:17:59 +00:00
|
|
|
if (tied)
|
|
|
|
keymove = 0;
|
|
|
|
|
2019-11-26 08:24:19 +00:00
|
|
|
info.dz = (info.dz * move_scale)>>8;
|
|
|
|
info.dyaw = (info.dyaw * turn_scale)>>8;
|
|
|
|
|
2020-03-29 08:03:00 +00:00
|
|
|
int32_t svel = 0, vel = 0;
|
2020-04-12 20:28:32 +00:00
|
|
|
fix16_t q16aimvel = 0, q16angvel = 0;
|
2020-05-19 11:44:52 +00:00
|
|
|
|
2019-11-26 08:24:19 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
|
|
|
|
{
|
2020-05-19 11:44:52 +00:00
|
|
|
svel = -info.mousex;
|
|
|
|
svel -= info.dyaw * keymove / analogExtent;
|
2019-11-26 08:24:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-12 20:28:32 +00:00
|
|
|
q16angvel = fix16_div(fix16_from_int(info.mousex), fix16_from_int(32));
|
|
|
|
q16angvel += fix16_from_int(info.dyaw) / analogExtent * (turnamount << 1);
|
2019-11-26 08:24:19 +00:00
|
|
|
}
|
|
|
|
|
2019-12-05 00:08:35 +00:00
|
|
|
if (mouseaim)
|
2020-04-12 20:28:32 +00:00
|
|
|
q16aimvel = -fix16_div(fix16_from_int(info.mousey), fix16_from_int(64));
|
2019-11-26 08:24:19 +00:00
|
|
|
else
|
2020-05-19 11:44:52 +00:00
|
|
|
vel = -(info.mousey >> 6);
|
2019-11-26 08:24:19 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
if (in_mouseflip)
|
2020-04-12 20:28:32 +00:00
|
|
|
q16aimvel = -q16aimvel;
|
2019-11-26 08:24:19 +00:00
|
|
|
|
2020-04-12 20:28:32 +00:00
|
|
|
q16aimvel -= fix16_from_int(info.dpitch) * turnamount / analogExtent;
|
2020-05-19 11:44:52 +00:00
|
|
|
svel -= info.dx * keymove / analogExtent;
|
|
|
|
vel -= info.dz * keymove / analogExtent;
|
2019-11-26 08:24:19 +00:00
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Strafe) && !pp->sop)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-05-19 11:44:52 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
|
|
|
svel -= -keymove;
|
|
|
|
if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
|
|
|
svel -= keymove;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Turn_Left))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
turnheldtime += synctics;
|
2020-04-11 07:17:59 +00:00
|
|
|
if (PEDANTIC_MODE)
|
|
|
|
{
|
|
|
|
if (turnheldtime >= TURBOTURNTIME)
|
2020-04-12 20:28:32 +00:00
|
|
|
q16angvel -= fix16_from_int(turnamount);
|
2020-04-11 07:17:59 +00:00
|
|
|
else
|
2020-04-12 20:28:32 +00:00
|
|
|
q16angvel -= fix16_from_int(PREAMBLETURN);
|
2020-04-11 07:17:59 +00:00
|
|
|
}
|
2020-05-19 11:44:52 +00:00
|
|
|
else
|
2020-04-12 20:28:32 +00:00
|
|
|
q16angvel = fix16_ssub(q16angvel, fix16_from_float(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN)));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2019-11-04 22:01:50 +00:00
|
|
|
else if (buttonMap.ButtonDown(gamefunc_Turn_Right))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
turnheldtime += synctics;
|
2020-04-11 07:17:59 +00:00
|
|
|
if (PEDANTIC_MODE)
|
|
|
|
{
|
|
|
|
if (turnheldtime >= TURBOTURNTIME)
|
2020-04-12 20:28:32 +00:00
|
|
|
q16angvel += fix16_from_int(turnamount);
|
2020-04-11 07:17:59 +00:00
|
|
|
else
|
2020-04-12 20:28:32 +00:00
|
|
|
q16angvel += fix16_from_int(PREAMBLETURN);
|
2020-04-11 07:17:59 +00:00
|
|
|
}
|
2020-05-19 11:44:52 +00:00
|
|
|
else
|
2020-04-12 20:28:32 +00:00
|
|
|
q16angvel = fix16_sadd(q16angvel, fix16_from_float(scaleAdjustmentToInterval((turnheldtime >= TURBOTURNTIME) ? turnamount : PREAMBLETURN)));
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
turnheldtime = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !pp->sop)
|
|
|
|
svel += keymove;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !pp->sop)
|
|
|
|
svel += -keymove;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Move_Forward))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-05-19 11:44:52 +00:00
|
|
|
vel += keymove;
|
|
|
|
//DSPRINTF(ds,"vel key %d",vel);
|
|
|
|
//DebugWriteString(ds);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2020-05-19 11:44:52 +00:00
|
|
|
else
|
2020-04-05 11:37:34 +00:00
|
|
|
{
|
2020-05-19 11:44:52 +00:00
|
|
|
//DSPRINTF(ds,"vel %d",vel);
|
|
|
|
//DebugWriteString(ds);
|
|
|
|
}
|
2020-04-05 11:37:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Move_Backward))
|
|
|
|
vel += -keymove;
|
2020-03-29 11:01:11 +00:00
|
|
|
|
2020-04-12 20:28:32 +00:00
|
|
|
q16angvel = fix16_clamp(q16angvel, -fix16_from_int(MAXANGVEL), fix16_from_int(MAXANGVEL));
|
|
|
|
q16aimvel = fix16_clamp(q16aimvel, -fix16_from_int(MAXHORIZVEL), fix16_from_int(MAXHORIZVEL));
|
2020-04-11 07:17:59 +00:00
|
|
|
|
2020-04-03 20:26:38 +00:00
|
|
|
if (PEDANTIC_MODE)
|
|
|
|
{
|
2020-04-12 20:28:32 +00:00
|
|
|
q16angvel = fix16_floor(q16angvel);
|
|
|
|
q16aimvel = fix16_floor(q16aimvel);
|
2020-04-03 20:26:38 +00:00
|
|
|
}
|
2020-04-11 08:19:06 +00:00
|
|
|
else if (!TEST(pp->Flags, PF_DEAD))
|
2020-04-11 07:17:59 +00:00
|
|
|
{
|
2020-04-12 20:28:32 +00:00
|
|
|
void DoPlayerTurn(PLAYERp pp, fix16_t *pq16ang, fix16_t q16angvel);
|
|
|
|
void DoPlayerHorizon(PLAYERp pp, fix16_t *pq16horiz, fix16_t q16aimvel);
|
2020-04-11 08:19:06 +00:00
|
|
|
if (!TEST(pp->Flags, PF_CLIMBING))
|
2020-04-12 20:28:32 +00:00
|
|
|
DoPlayerTurn(pp, &pp->camq16ang, q16angvel);
|
|
|
|
DoPlayerHorizon(pp, &pp->camq16horiz, q16aimvel);
|
2020-04-11 07:17:59 +00:00
|
|
|
}
|
2020-04-05 11:37:34 +00:00
|
|
|
|
2020-04-11 07:17:59 +00:00
|
|
|
loc->vel += vel;
|
|
|
|
loc->svel += svel;
|
2020-04-05 11:37:34 +00:00
|
|
|
|
2020-04-11 07:17:59 +00:00
|
|
|
if (!tied)
|
|
|
|
{
|
|
|
|
vel = clamp(loc->vel, -MAXVEL, MAXVEL);
|
|
|
|
svel = clamp(loc->svel, -MAXSVEL, MAXSVEL);
|
|
|
|
|
|
|
|
momx = mulscale9(vel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 512)]);
|
|
|
|
momy = mulscale9(vel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang))]);
|
|
|
|
|
|
|
|
momx += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang))]);
|
|
|
|
momy += mulscale9(svel, sintable[NORM_ANGLE(fix16_to_int(newpp->q16ang) + 1536)]);
|
|
|
|
|
|
|
|
loc->vel = momx;
|
|
|
|
loc->svel = momy;
|
|
|
|
}
|
2020-04-05 11:37:34 +00:00
|
|
|
|
2020-04-12 20:28:32 +00:00
|
|
|
loc->q16angvel += q16angvel;
|
|
|
|
loc->q16aimvel += q16aimvel;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (!CommEnabled)
|
|
|
|
{
|
2019-12-02 20:05:19 +00:00
|
|
|
// What a mess...:?
|
|
|
|
#if 0
|
2015-05-19 21:54:34 +00:00
|
|
|
if (MenuButtonAutoAim)
|
|
|
|
{
|
|
|
|
MenuButtonAutoAim = FALSE;
|
2019-10-21 22:05:21 +00:00
|
|
|
if ((!!TEST(pp->Flags, PF_AUTO_AIM)) != !!cl_autoaim)
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_AUTO_AIM, TRUE);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2019-12-02 20:05:19 +00:00
|
|
|
#endif
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
2019-11-03 23:53:55 +00:00
|
|
|
else if (inputState.GetKeyStatus(sc_Pause))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_PAUSE, inputState.GetKeyStatus(sc_Pause));
|
2019-10-28 05:47:49 +00:00
|
|
|
inputState.ClearKeyStatus(sc_Pause);
|
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_CENTER_VIEW, buttonMap.ButtonDown(gamefunc_Center_View));
|
|
|
|
|
|
|
|
SET_LOC_KEY(loc->bits, SK_RUN, buttonMap.ButtonDown(gamefunc_Run));
|
|
|
|
SET_LOC_KEY(loc->bits, SK_SHOOT, buttonMap.ButtonDown(gamefunc_Fire));
|
|
|
|
|
|
|
|
// actually snap
|
|
|
|
SET_LOC_KEY(loc->bits, SK_SNAP_UP, buttonMap.ButtonDown(gamefunc_Aim_Up));
|
|
|
|
SET_LOC_KEY(loc->bits, SK_SNAP_DOWN, buttonMap.ButtonDown(gamefunc_Aim_Down));
|
|
|
|
|
|
|
|
// actually just look
|
|
|
|
SET_LOC_KEY(loc->bits, SK_LOOK_UP, buttonMap.ButtonDown(gamefunc_Look_Up));
|
|
|
|
SET_LOC_KEY(loc->bits, SK_LOOK_DOWN, buttonMap.ButtonDown(gamefunc_Look_Down));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_WEAPONS_KEYS; i++)
|
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Weapon_1 + i))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-05-19 11:44:52 +00:00
|
|
|
SET(loc->bits, i + 1);
|
2015-05-19 21:54:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Next_Weapon))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
USERp u = User[pp->PlayerSprite];
|
|
|
|
short next_weapon = u->WeaponNum + 1;
|
|
|
|
short start_weapon;
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Next_Weapon);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
start_weapon = u->WeaponNum + 1;
|
|
|
|
|
|
|
|
if (u->WeaponNum == WPN_SWORD)
|
|
|
|
start_weapon = WPN_STAR;
|
|
|
|
|
|
|
|
if (u->WeaponNum == WPN_FIST)
|
|
|
|
{
|
|
|
|
next_weapon = 14;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
next_weapon = -1;
|
|
|
|
for (i = start_weapon; TRUE; i++)
|
|
|
|
{
|
|
|
|
if (i >= MAX_WEAPONS_KEYS)
|
|
|
|
{
|
|
|
|
next_weapon = 13;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEST(pp->WpnFlags, BIT(i)) && pp->WpnAmmo[i])
|
|
|
|
{
|
|
|
|
next_weapon = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
SET(loc->bits, next_weapon + 1);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Previous_Weapon))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
USERp u = User[pp->PlayerSprite];
|
|
|
|
short prev_weapon = u->WeaponNum - 1;
|
|
|
|
short start_weapon;
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Previous_Weapon);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
start_weapon = u->WeaponNum - 1;
|
|
|
|
|
|
|
|
if (u->WeaponNum == WPN_SWORD)
|
|
|
|
{
|
|
|
|
prev_weapon = 13;
|
|
|
|
}
|
|
|
|
else if (u->WeaponNum == WPN_STAR)
|
|
|
|
{
|
|
|
|
prev_weapon = 14;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prev_weapon = -1;
|
|
|
|
for (i = start_weapon; TRUE; i--)
|
|
|
|
{
|
|
|
|
if (i <= -1)
|
|
|
|
i = WPN_HEART;
|
|
|
|
|
|
|
|
if (TEST(pp->WpnFlags, BIT(i)) && pp->WpnAmmo[i])
|
|
|
|
{
|
|
|
|
prev_weapon = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
SET(loc->bits, prev_weapon + 1);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-11-30 09:07:25 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Alt_Weapon))
|
2019-11-30 06:10:54 +00:00
|
|
|
{
|
2019-11-30 09:07:25 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Alt_Weapon);
|
2019-11-30 06:10:54 +00:00
|
|
|
USERp u = User[pp->PlayerSprite];
|
|
|
|
short const which_weapon = u->WeaponNum + 1;
|
2020-05-19 11:44:52 +00:00
|
|
|
SET(loc->bits, which_weapon);
|
2019-12-13 20:01:14 +00:00
|
|
|
}
|
2019-12-13 19:43:23 +00:00
|
|
|
|
2019-11-30 06:10:54 +00:00
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
inv_hotkey = 0;
|
2020-04-11 22:10:39 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_MedKit))
|
2015-05-19 21:54:34 +00:00
|
|
|
inv_hotkey = INVENTORY_MEDKIT+1;
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Smoke_Bomb))
|
2015-05-19 21:54:34 +00:00
|
|
|
inv_hotkey = INVENTORY_CLOAK+1;
|
2020-04-11 22:10:39 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_NightVision))
|
2015-05-19 21:54:34 +00:00
|
|
|
inv_hotkey = INVENTORY_NIGHT_VISION+1;
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Gas_Bomb))
|
2015-05-19 21:54:34 +00:00
|
|
|
inv_hotkey = INVENTORY_CHEMBOMB+1;
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Flash_Bomb) && dimensionmode == 3)
|
2015-05-19 21:54:34 +00:00
|
|
|
inv_hotkey = INVENTORY_FLASHBOMB+1;
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Caltrops))
|
2015-05-19 21:54:34 +00:00
|
|
|
inv_hotkey = INVENTORY_CALTROPS+1;
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
SET(loc->bits, inv_hotkey<<SK_INV_HOTKEY_BIT0);
|
|
|
|
|
|
|
|
SET_LOC_KEY(loc->bits, SK_INV_USE, buttonMap.ButtonDown(gamefunc_Inventory));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_OPERATE, buttonMap.ButtonDown(gamefunc_Open));
|
|
|
|
SET_LOC_KEY(loc->bits, SK_JUMP, buttonMap.ButtonDown(gamefunc_Jump));
|
|
|
|
SET_LOC_KEY(loc->bits, SK_CRAWL, buttonMap.ButtonDown(gamefunc_Crouch));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_TURN_180, buttonMap.ButtonDown(gamefunc_TurnAround));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_INV_LEFT, buttonMap.ButtonDown(gamefunc_Inventory_Left));
|
|
|
|
SET_LOC_KEY(loc->bits, SK_INV_RIGHT, buttonMap.ButtonDown(gamefunc_Inventory_Right));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_HIDE_WEAPON, buttonMap.ButtonDown(gamefunc_Holster_Weapon));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// need BUTTON
|
2020-05-19 11:44:52 +00:00
|
|
|
SET_LOC_KEY(loc->bits, SK_CRAWL_LOCK, inputState.GetKeyStatus(KEYSC_NUM));
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE)
|
|
|
|
{
|
2020-04-11 22:10:39 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_See_Coop_View))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-04-11 22:10:39 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_See_Coop_View);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
screenpeek = connectpoint2[screenpeek];
|
|
|
|
|
|
|
|
if (screenpeek < 0)
|
|
|
|
screenpeek = connecthead;
|
|
|
|
|
2020-05-19 11:44:52 +00:00
|
|
|
if (dimensionmode != 2 && screenpeek == myconnectindex)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
// JBF: figure out what's going on here
|
|
|
|
DoPlayerDivePalette(pp); // Check Dive again
|
|
|
|
DoPlayerNightVisionPalette(pp); // Check Night Vision again
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PLAYERp tp = Player+screenpeek;
|
|
|
|
DoPlayerDivePalette(tp);
|
|
|
|
DoPlayerNightVisionPalette(tp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
DebugKeys(pp);
|
|
|
|
|
|
|
|
if (!CommEnabled) // Single player only keys
|
|
|
|
SinglePlayInput(pp);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FunctionKeys(pp);
|
|
|
|
|
2019-11-04 22:01:50 +00:00
|
|
|
if (buttonMap.ButtonDown(gamefunc_Toggle_Crosshair))
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-11-04 22:01:50 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Toggle_Crosshair);
|
2020-03-07 13:51:49 +00:00
|
|
|
pToggleCrosshair();
|
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
|
|
|
|
if (gs.BorderNum <= BORDER_BAR-1)
|
|
|
|
{
|
|
|
|
txt_x = 7;
|
|
|
|
txt_y = 168;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
txt_x = 7;
|
|
|
|
txt_y = 147;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ScrollMode2D)
|
|
|
|
{
|
2020-03-07 13:51:49 +00:00
|
|
|
minigametext(txt_x,txt_y-7,"Follow Mode",2+8);
|
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-03-07 13:51:49 +00:00
|
|
|
minigametext(txt_x,txt_y,ds,2+8);
|
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;
|
|
|
|
|
|
|
|
if (sprisplayer)
|
|
|
|
{
|
|
|
|
if (gNet.MultiGameType != MULTI_GAME_COMMBAT || j == Player[screenpeek].PlayerSprite)
|
2017-06-24 09:20:21 +00:00
|
|
|
rotatesprite((x1 << 4) + (xdim << 15), (y1 << 4) + (ydim << 15), mulscale16(czoom * (spr->yrepeat), yxaspect), daang, 1196+pspr_ndx[myconnectindex], spr->shade, spr->pal, (spr->cstat & 2) >> 1, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
2017-06-24 09:20:21 +00:00
|
|
|
rotatesprite((x1 << 4) + (xdim << 15), (y1 << 4) + (ydim << 15), mulscale16(czoom * (spr->yrepeat), yxaspect), daang, spr->picnum, spr->shade, spr->pal, (spr->cstat & 2) >> 1, windowxy1.x, windowxy1.y, windowxy2.x, windowxy2.y);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 16: // Rotated sprite
|
|
|
|
x1 = sprx;
|
|
|
|
y1 = spry;
|
|
|
|
tilenum = spr->picnum;
|
2015-05-19 22:01:44 +00:00
|
|
|
xoff = (int)picanm[tilenum].xofs + (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;
|
2015-05-19 22:01:44 +00:00
|
|
|
xoff = (int)picanm[tilenum].xofs + (int)spr->xoffset;
|
|
|
|
yoff = (int)picanm[tilenum].yofs + (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;
|
|
|
|
|
2015-05-19 22:02:25 +00:00
|
|
|
if (tilesiz[wal->picnum].x == 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
2015-05-19 22:02:25 +00:00
|
|
|
if (tilesiz[wal->picnum].y == 0)
|
2015-05-19 21:54:34 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if RANDOM_DEBUG
|
2019-11-17 17:02:17 +00:00
|
|
|
int RandomRange(int range, char *file, unsigned line)
|
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
|
|
|
extern FILE *fout_err;
|
2015-05-19 21:58:29 +00:00
|
|
|
extern uint32_t MoveThingsCount;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (RandomPrint && !Prediction)
|
|
|
|
{
|
|
|
|
sprintf(ds,"mtc %d, %s, line %d, %d",MoveThingsCount,file,line,randomseed);
|
|
|
|
DebugWriteString(ds);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (range <= 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
rand_num = krand2();
|
|
|
|
|
|
|
|
if (rand_num == 65535U)
|
|
|
|
rand_num--;
|
|
|
|
|
|
|
|
// shift values to give more precision
|
|
|
|
value = (rand_num << 14) / ((65535UL << 14) / range);
|
|
|
|
|
|
|
|
if (value >= range)
|
|
|
|
value = range - 1;
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
#else
|
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;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-04-08 06:27:15 +00:00
|
|
|
// [JM] Probably will need some doing over. !CHECKME!
|
|
|
|
void G_Polymer_UnInit(void) { }
|
|
|
|
|
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
#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-01-22 14:21:07 +00:00
|
|
|
void GameInterface::set_hud_layout(int requested_size)
|
2019-12-07 20:39:17 +00:00
|
|
|
{
|
|
|
|
gs.BorderNum = 9 - requested_size;
|
|
|
|
SetBorder(Player + myconnectindex, gs.BorderNum);
|
|
|
|
SetRedrawScreen(Player + myconnectindex);
|
|
|
|
}
|
2020-01-22 14:21:07 +00:00
|
|
|
/*extern*/ void GameInterface::set_hud_scale(int requested_size) { }
|
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();
|
|
|
|
}
|
|
|
|
|
2020-01-01 08:49:06 +00:00
|
|
|
void GameInterface::UpdateScreenSize()
|
|
|
|
{
|
|
|
|
SetupAspectRatio();
|
|
|
|
}
|
2019-12-25 10:26:19 +00:00
|
|
|
|
|
|
|
|
2019-12-24 12:21:36 +00:00
|
|
|
#if 0 // the message input needs to be moved out of the game code!
|
|
|
|
void GetMessageInput(PLAYERp pp)
|
|
|
|
{
|
|
|
|
int pnum = myconnectindex;
|
|
|
|
short w, h;
|
|
|
|
static SWBOOL cur_show;
|
|
|
|
static SWBOOL TeamSendAll, TeamSendTeam;
|
|
|
|
#define TEAM_MENU "A - Send to ALL, T - Send to TEAM"
|
|
|
|
static char HoldMessageInputString[256];
|
|
|
|
int i;
|
2019-12-08 23:55:30 +00:00
|
|
|
|
2019-12-24 12:21:36 +00:00
|
|
|
if (!MessageInputMode && !ConInputMode)
|
|
|
|
{
|
|
|
|
if (buttonMap.ButtonDown(gamefunc_SendMessage))
|
|
|
|
{
|
|
|
|
buttonMap.ClearButton(gamefunc_SendMessage);
|
|
|
|
inputState.keyFlushChars();
|
|
|
|
MessageInputMode = TRUE;
|
|
|
|
InputMode = TRUE;
|
|
|
|
TeamSendTeam = FALSE;
|
|
|
|
TeamSendAll = FALSE;
|
|
|
|
|
|
|
|
if (MessageInputMode)
|
|
|
|
{
|
|
|
|
memset(MessageInputString, '\0', sizeof(MessageInputString));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (MessageInputMode && !ConInputMode)
|
|
|
|
{
|
|
|
|
if (gs.BorderNum > BORDER_BAR + 1)
|
|
|
|
SetRedrawScreen(pp);
|
2019-10-09 18:14:04 +00:00
|
|
|
|
2019-12-24 12:21:36 +00:00
|
|
|
// get input
|
|
|
|
switch (MNU_InputSmallString(MessageInputString, 320 - 20))
|
|
|
|
{
|
|
|
|
case -1: // Cancel Input (pressed ESC) or Err
|
|
|
|
MessageInputMode = FALSE;
|
|
|
|
InputMode = FALSE;
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2019-12-24 12:21:36 +00:00
|
|
|
break;
|
|
|
|
case FALSE: // Input finished (RETURN)
|
|
|
|
if (MessageInputString[0] == '\0')
|
|
|
|
{
|
|
|
|
// no input
|
|
|
|
MessageInputMode = FALSE;
|
|
|
|
InputMode = FALSE;
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2019-12-24 12:21:36 +00:00
|
|
|
buttonMap.ClearButton(gamefunc_Inventory);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gNet.TeamPlay)
|
|
|
|
{
|
|
|
|
if (memcmp(MessageInputString, TEAM_MENU, sizeof(TEAM_MENU)) != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
strcpy(HoldMessageInputString, MessageInputString);
|
|
|
|
strcpy(MessageInputString, TEAM_MENU);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (memcmp(MessageInputString, TEAM_MENU, sizeof(TEAM_MENU)) == 0)
|
|
|
|
{
|
|
|
|
strcpy(MessageInputString, HoldMessageInputString);
|
|
|
|
TeamSendAll = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SEND_MESSAGE:
|
|
|
|
|
|
|
|
// broadcast message
|
|
|
|
MessageInputMode = FALSE;
|
|
|
|
InputMode = FALSE;
|
2020-01-01 10:35:47 +00:00
|
|
|
inputState.ClearAllInput();
|
2019-12-24 12:21:36 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUMGAMEFUNCTIONS; i++)
|
|
|
|
buttonMap.ClearButton(i);
|
|
|
|
|
|
|
|
// Put who sent this
|
|
|
|
sprintf(ds, "%s: %s", pp->PlayerName, MessageInputString);
|
|
|
|
|
|
|
|
if (gNet.TeamPlay)
|
|
|
|
{
|
|
|
|
TRAVERSE_CONNECT(pnum)
|
|
|
|
{
|
|
|
|
if (pnum != myconnectindex)
|
|
|
|
{
|
|
|
|
if (TeamSendAll)
|
|
|
|
SW_SendMessage(pnum, ds);
|
|
|
|
else if (User[pp->PlayerSprite]->spal == User[Player[pnum].PlayerSprite]->spal)
|
|
|
|
SW_SendMessage(pnum, ds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TRAVERSE_CONNECT(pnum)
|
|
|
|
{
|
|
|
|
if (pnum != myconnectindex)
|
|
|
|
{
|
|
|
|
SW_SendMessage(pnum, ds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
adduserquote(MessageInputString);
|
|
|
|
quotebot += 8;
|
|
|
|
quotebotgoal = quotebot;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRUE: // Got input
|
|
|
|
|
|
|
|
if (gNet.TeamPlay)
|
|
|
|
{
|
|
|
|
if (memcmp(MessageInputString, TEAM_MENU "a", sizeof(TEAM_MENU) + 1) == 0)
|
|
|
|
{
|
|
|
|
strcpy(MessageInputString, HoldMessageInputString);
|
|
|
|
TeamSendAll = TRUE;
|
|
|
|
goto SEND_MESSAGE;
|
|
|
|
}
|
|
|
|
else if (memcmp(MessageInputString, TEAM_MENU "t", sizeof(TEAM_MENU) + 1) == 0)
|
|
|
|
{
|
|
|
|
strcpy(MessageInputString, HoldMessageInputString);
|
|
|
|
TeamSendTeam = TRUE;
|
|
|
|
goto SEND_MESSAGE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// reset the string if anything else is typed
|
|
|
|
if (strlen(MessageInputString) + 1 > sizeof(TEAM_MENU))
|
|
|
|
{
|
|
|
|
strcpy(MessageInputString, TEAM_MENU);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2019-12-08 23:55:30 +00:00
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|