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
|
|
|
#include "build.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 "jsector.h"
|
|
|
|
#include "menus.h"
|
|
|
|
#include "pal.h"
|
2019-12-24 12:21:36 +00:00
|
|
|
|
2019-11-20 21:01:44 +00:00
|
|
|
#include "keydef.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-25 22:32:49 +00:00
|
|
|
#include "gamecontrol.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
#include "gamedefs.h"
|
2019-03-21 02:24:19 +00:00
|
|
|
#include "network.h"
|
2019-11-26 23:41:26 +00:00
|
|
|
#include "version.h"
|
2019-12-02 20:05:19 +00:00
|
|
|
#include "network.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2020-08-05 15:07:19 +00:00
|
|
|
#include "misc.h"
|
2020-04-12 05:51:11 +00:00
|
|
|
#include "palettecontainer.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
|
|
|
|
2015-05-19 21:54:34 +00:00
|
|
|
//#define PLOCK_VERSION TRUE
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
extern SWBOOL ExitLevel, NewGame;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
2019-12-02 20:05:19 +00:00
|
|
|
short TimeLimitTable[9] = {0,3,5,10,15,20,30,45,60};
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-02 20:05:19 +00:00
|
|
|
SWBOOL
|
|
|
|
MNU_StartNetGame(void)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2020-08-15 20:31:44 +00:00
|
|
|
extern SWBOOL ExitLevel, ShortGameMode, FirstTimeIntoGame;
|
2019-12-13 19:43:23 +00:00
|
|
|
extern short Level, Skill;
|
|
|
|
// CTW REMOVED
|
|
|
|
//extern int gTenActivated;
|
|
|
|
// CTW REMOVED END
|
|
|
|
int pnum;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
// always assumed that a demo is playing
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
ready2send = 0;
|
|
|
|
// Skill can go negative here
|
2019-12-02 20:05:19 +00:00
|
|
|
Skill = gs.NetMonsters - 1;
|
2019-12-13 19:43:23 +00:00
|
|
|
Level = gs.NetLevel + 1;
|
|
|
|
ExitLevel = TRUE;
|
|
|
|
NewGame = TRUE;
|
|
|
|
// restart demo for multi-play mode
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
// TENSW: return if a joiner
|
|
|
|
if (/* CTW REMOVED gTenActivated && */ !AutoNet && FirstTimeIntoGame)
|
|
|
|
return TRUE;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
// need to set gNet vars for self
|
|
|
|
// everone else gets a packet to set them
|
|
|
|
gNet.AutoAim = cl_autoaim;
|
|
|
|
gNet.SpawnMarkers = gs.NetSpawnMarkers;
|
|
|
|
gNet.HurtTeammate = gs.NetHurtTeammate;
|
|
|
|
gNet.Nuke = gs.NetNuke;
|
2019-12-02 20:05:19 +00:00
|
|
|
gNet.KillLimit = gs.NetKillLimit * 10;
|
|
|
|
gNet.TimeLimit = TimeLimitTable[gs.NetTimeLimit] * 60 * 120;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
if (ShortGameMode)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-13 19:43:23 +00:00
|
|
|
gNet.KillLimit /= 10;
|
|
|
|
gNet.TimeLimit /= 2;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
gNet.TimeLimitClock = gNet.TimeLimit;
|
|
|
|
gNet.TeamPlay = gs.NetTeamPlay;
|
2019-12-02 20:05:19 +00:00
|
|
|
gNet.MultiGameType = gs.NetGameType + 1;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
if (gNet.MultiGameType == MULTI_GAME_COMMBAT_NO_RESPAWN)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-13 19:43:23 +00:00
|
|
|
gNet.MultiGameType = MULTI_GAME_COMMBAT;
|
|
|
|
gNet.NoRespawn = TRUE;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-13 19:43:23 +00:00
|
|
|
gNet.NoRespawn = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
if (CommEnabled)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-13 19:43:23 +00:00
|
|
|
PACKET_NEW_GAME p;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
p.PacketType = PACKET_TYPE_NEW_GAME;
|
|
|
|
p.Level = Level;
|
|
|
|
p.Skill = Skill;
|
|
|
|
p.GameType = gs.NetGameType;
|
|
|
|
p.AutoAim = cl_autoaim;
|
|
|
|
p.HurtTeammate = gs.NetHurtTeammate;
|
|
|
|
p.TeamPlay = gs.NetTeamPlay;
|
|
|
|
p.SpawnMarkers = gs.NetSpawnMarkers;
|
|
|
|
p.KillLimit = gs.NetKillLimit;
|
|
|
|
p.TimeLimit = gs.NetTimeLimit;
|
|
|
|
p.Nuke = gs.NetNuke;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
netbroadcastpacket((uint8_t*)(&p), sizeof(p)); // TENSW
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-13 19:43:23 +00:00
|
|
|
return TRUE;
|
2019-12-02 20:05:19 +00:00
|
|
|
}
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
#define FADE_DAMAGE_FACTOR 3 // 100 health / 32 shade cycles = 3.125
|
|
|
|
|
|
|
|
// Fades from 100% to 62.5% somewhat quickly,
|
|
|
|
// then from 62.5% to 37.5% slowly,
|
|
|
|
// then from 37.5% to 0% quickly.
|
|
|
|
// This seems to capture the pain caused by enemy shots, plus the extreme
|
|
|
|
// fade caused by being blinded or intense pain.
|
|
|
|
// Perhaps the next step would be to apply a gentle smoothing to the
|
|
|
|
// intersections of these lines.
|
|
|
|
static int faderamp[32] =
|
|
|
|
{
|
2015-09-23 17:55:11 +00:00
|
|
|
// y=64-4x
|
|
|
|
252,240,224,208,192,176,
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-09-23 17:55:11 +00:00
|
|
|
// y=44.8-(16/20)x
|
|
|
|
160,156,152,152,148,
|
|
|
|
144,140,136,136,132,
|
|
|
|
128,124,120,120,116,
|
|
|
|
112,108,104,104,100,
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2015-09-23 17:55:11 +00:00
|
|
|
// y=128-4x
|
|
|
|
96,80,64,48,32,16
|
2015-05-19 21:54:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-12-02 20:05:19 +00:00
|
|
|
typedef struct RGB_color_typ
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-02 20:05:19 +00:00
|
|
|
unsigned char red;
|
|
|
|
unsigned char green;
|
|
|
|
unsigned char blue;
|
|
|
|
} RGB_color, * RGB_color_ptr;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
// Set the amount of redness for damage
|
|
|
|
// the player just took
|
|
|
|
//////////////////////////////////////////
|
2019-11-17 17:02:17 +00:00
|
|
|
void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-02 20:05:19 +00:00
|
|
|
short fadedamage = 0;
|
2015-05-19 21:54:34 +00:00
|
|
|
RGB_color color;
|
|
|
|
|
2020-04-11 21:45:45 +00:00
|
|
|
//Printf("SetAmt: fadeamt = %d, startcolor = %d, pp = %d",pp->FadeAmt,startcolor,pp->StartColor);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
if (abs(pp->FadeAmt) > 0 && startcolor == pp->StartColor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Don't ever over ride flash bomb
|
|
|
|
if (pp->StartColor == 1 && abs(pp->FadeAmt) > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Reset the palette
|
|
|
|
if (pp == Player + screenpeek)
|
|
|
|
{
|
2019-12-02 20:05:19 +00:00
|
|
|
videoFadePalette(0, 0, 0, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (damage < -150 && damage > -1000) fadedamage = 150;
|
|
|
|
else if (damage < -1000) // Underwater
|
2019-12-02 20:05:19 +00:00
|
|
|
fadedamage = abs(damage + 1000);
|
2015-05-19 21:54:34 +00:00
|
|
|
else
|
|
|
|
fadedamage = abs(damage);
|
|
|
|
|
|
|
|
if (damage >= -5 && damage < 0)
|
|
|
|
fadedamage += 10;
|
|
|
|
|
|
|
|
// Don't let red to TOO red
|
|
|
|
if (startcolor == COLOR_PAIN && fadedamage > 100) fadedamage = 100;
|
|
|
|
|
|
|
|
pp->FadeAmt = fadedamage / FADE_DAMAGE_FACTOR;
|
|
|
|
|
|
|
|
if (pp->FadeAmt <= 0)
|
|
|
|
{
|
|
|
|
pp->FadeAmt = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's a health item, just do a preset flash amount
|
|
|
|
if (damage > 0)
|
|
|
|
pp->FadeAmt = 3;
|
|
|
|
|
|
|
|
pp->StartColor = startcolor;
|
|
|
|
|
|
|
|
pp->FadeTics = 0;
|
|
|
|
|
2020-04-12 05:51:11 +00:00
|
|
|
color.red = GPalette.BaseColors[pp->StartColor].r;
|
|
|
|
color.green = GPalette.BaseColors[pp->StartColor].g;
|
|
|
|
color.blue = GPalette.BaseColors[pp->StartColor].b;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// Do initial palette set
|
|
|
|
if (pp == Player + screenpeek)
|
|
|
|
{
|
2020-04-12 05:44:55 +00:00
|
|
|
videoFadePalette(color.red, color.green, color.blue, faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))]);
|
2015-05-19 21:54:34 +00:00
|
|
|
if (damage < -1000)
|
|
|
|
pp->FadeAmt = 1000; // Don't call DoPaletteFlash for underwater stuff
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
|
|
// Do the screen reddness based on damage
|
|
|
|
//////////////////////////////////////////
|
|
|
|
#define MAXFADETICS 5
|
2019-11-17 17:02:17 +00:00
|
|
|
void DoPaletteFlash(PLAYERp pp)
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
|
|
|
if (pp->FadeAmt <= 1)
|
|
|
|
{
|
|
|
|
pp->FadeAmt = 0;
|
|
|
|
pp->StartColor = 0;
|
|
|
|
if (pp == Player + screenpeek)
|
|
|
|
{
|
2019-12-02 20:05:19 +00:00
|
|
|
videoFadePalette(0, 0, 0, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
DoPlayerDivePalette(pp); // Check Dive again
|
|
|
|
DoPlayerNightVisionPalette(pp); // Check Night Vision again
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pp->FadeTics += synctics; // Add this frame's tic amount to
|
|
|
|
// counter
|
|
|
|
|
|
|
|
if (pp->FadeTics >= MAXFADETICS)
|
|
|
|
{
|
|
|
|
while (pp->FadeTics >= MAXFADETICS)
|
|
|
|
{
|
|
|
|
pp->FadeTics -= MAXFADETICS;
|
|
|
|
|
|
|
|
pp->FadeAmt--; // Decrement FadeAmt till it gets to
|
|
|
|
// 0 again.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return; // Return if they were not >
|
|
|
|
// MAXFADETICS
|
|
|
|
|
|
|
|
if (pp->FadeAmt > 32)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pp->FadeAmt <= 1)
|
|
|
|
{
|
|
|
|
pp->FadeAmt = 0;
|
|
|
|
pp->StartColor = 0;
|
|
|
|
if (pp == Player + screenpeek)
|
|
|
|
{
|
2019-12-02 20:05:19 +00:00
|
|
|
videoFadePalette(0, 0, 0, 0);
|
2015-05-19 21:54:34 +00:00
|
|
|
DoPlayerDivePalette(pp); // Check Dive again
|
|
|
|
DoPlayerNightVisionPalette(pp); // Check Night Vision again
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Only hard set the palette if this is currently the player's view
|
|
|
|
if (pp == Player + screenpeek)
|
|
|
|
{
|
2020-04-12 05:44:55 +00:00
|
|
|
videoFadePalette(
|
2020-04-12 05:51:11 +00:00
|
|
|
GPalette.BaseColors[pp->StartColor].r,
|
|
|
|
GPalette.BaseColors[pp->StartColor].g,
|
|
|
|
GPalette.BaseColors[pp->StartColor].b,
|
|
|
|
faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))]
|
2020-04-12 05:44:55 +00:00
|
|
|
);
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-02 23:01:04 +00:00
|
|
|
SWBOOL MNU_ShareWareMessage()
|
2015-05-19 21:54:34 +00:00
|
|
|
{
|
2019-12-02 23:01:04 +00:00
|
|
|
const char* extra_text;
|
|
|
|
short w, h;
|
|
|
|
|
|
|
|
if (SW_SHAREWARE)
|
|
|
|
{
|
|
|
|
extra_text = "Be sure to call 800-3DREALMS today";
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawString(160, 110, extra_text, 1, 16, 0);
|
2019-12-02 23:01:04 +00:00
|
|
|
extra_text = "and order the game.";
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawString(160, 120, extra_text, 1, 16, 0);
|
2019-12-02 23:01:04 +00:00
|
|
|
extra_text = "You are only playing the first ";
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawString(160, 130, extra_text, 1, 16, 0);
|
2019-12-02 23:01:04 +00:00
|
|
|
extra_text = "four levels, and are missing most";
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawString(160, 140, extra_text, 1, 16, 0);
|
2019-12-02 23:01:04 +00:00
|
|
|
extra_text = "of the game, weapons and monsters.";
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawString(160, 150, extra_text, 1, 16, 0);
|
2019-12-02 23:01:04 +00:00
|
|
|
extra_text = "See the ordering information.";
|
2020-08-15 18:29:13 +00:00
|
|
|
MNU_DrawString(160, 160, extra_text, 1, 16, 0);
|
2019-12-02 23:01:04 +00:00
|
|
|
//SET(item->flags, mf_disabled);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|