2006-04-13 20:47:06 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
2010-05-25 10:56:00 +00:00
|
|
|
Copyright (C) 2010 EDuke32 developers and contributors
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-25 10:56:00 +00:00
|
|
|
This file is part of EDuke32.
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
EDuke32 is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "duke3d.h"
|
2012-01-27 15:03:55 +00:00
|
|
|
#include "game.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
#include "osd.h"
|
2009-12-12 11:07:59 +00:00
|
|
|
#include "gamedef.h"
|
2010-08-02 08:13:51 +00:00
|
|
|
#include "premap.h"
|
|
|
|
#include "sounds.h"
|
|
|
|
#include "gameexec.h"
|
|
|
|
#include "anim.h"
|
|
|
|
#include "menus.h"
|
2010-08-02 08:19:28 +00:00
|
|
|
#include "demo.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-03-04 19:52:57 +00:00
|
|
|
#ifdef RENDERTYPEWIN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2011-09-20 19:12:24 +00:00
|
|
|
#ifdef LUNATIC_ENABLE
|
|
|
|
# include "lunatic.h"
|
|
|
|
extern El_State g_ElState;
|
|
|
|
#endif
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
extern char pow2char[];
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t g_whichPalForPlayer = 9;
|
|
|
|
int32_t g_numRealPalettes;
|
|
|
|
int16_t SpriteCacheList[MAXTILES][3];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 09:39:19 +00:00
|
|
|
static uint8_t precachehightile[2][MAXTILES>>3];
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t g_precacheCount;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-01-16 23:08:17 +00:00
|
|
|
extern char *g_gameNamePtr;
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t g_levelTextTime;
|
2008-07-22 09:05:34 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static void tloadtile(int32_t tilenume, int32_t type)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-12-17 21:20:35 +00:00
|
|
|
if ((picanm[tilenume]&63) < 1)
|
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (!(gotpic[tilenume>>3] & pow2char[tilenume&7])) g_precacheCount++;
|
2006-12-17 21:20:35 +00:00
|
|
|
gotpic[tilenume>>3] |= pow2char[tilenume&7];
|
2009-01-09 09:29:17 +00:00
|
|
|
precachehightile[(uint8_t)type][tilenume>>3] |= pow2char[tilenume&7];
|
2006-12-17 21:20:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i,j;
|
2006-04-16 03:42:36 +00:00
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if ((picanm[tilenume]&192)==192)
|
|
|
|
{
|
2006-04-16 03:42:36 +00:00
|
|
|
i = tilenume - (picanm[tilenume]&63);
|
|
|
|
j = tilenume;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-16 03:42:36 +00:00
|
|
|
i = tilenume;
|
|
|
|
j = tilenume + (picanm[tilenume]&63);
|
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
for (; i<=j; i++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (!(gotpic[i>>3] & pow2char[i&7])) g_precacheCount++;
|
2006-04-16 03:42:36 +00:00
|
|
|
gotpic[i>>3] |= pow2char[i&7];
|
2009-01-09 09:29:17 +00:00
|
|
|
precachehightile[(uint8_t)type][i>>3] |= pow2char[i&7];
|
2006-04-16 03:42:36 +00:00
|
|
|
}
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static void G_CacheSpriteNum(int32_t i)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
char maxc;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t j;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
if (ud.monsters_off && A_CheckEnemySprite(&sprite[i])) return;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
maxc = 1;
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
if (SpriteCacheList[PN][0] == PN)
|
|
|
|
for (j = PN; j <= SpriteCacheList[PN][1]; j++)
|
2006-04-13 20:47:06 +00:00
|
|
|
tloadtile(j,1);
|
|
|
|
|
2012-01-28 14:38:23 +00:00
|
|
|
switch (DYNAMICTILEMAP(PN))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case HYDRENT__STATIC:
|
|
|
|
tloadtile(BROKEFIREHYDRENT,1);
|
|
|
|
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case TOILET__STATIC:
|
|
|
|
tloadtile(TOILETBROKE,1);
|
|
|
|
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case STALL__STATIC:
|
|
|
|
tloadtile(STALLBROKE,1);
|
|
|
|
for (j = TOILETWATER; j < (TOILETWATER+4); j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case RUBBERCAN__STATIC:
|
|
|
|
maxc = 2;
|
|
|
|
break;
|
|
|
|
case TOILETWATER__STATIC:
|
|
|
|
maxc = 4;
|
|
|
|
break;
|
|
|
|
case FEMPIC1__STATIC:
|
|
|
|
maxc = 44;
|
|
|
|
break;
|
|
|
|
case LIZTROOP__STATIC:
|
|
|
|
case LIZTROOPRUNNING__STATIC:
|
|
|
|
case LIZTROOPSHOOT__STATIC:
|
|
|
|
case LIZTROOPJETPACK__STATIC:
|
|
|
|
case LIZTROOPONTOILET__STATIC:
|
|
|
|
case LIZTROOPDUCKING__STATIC:
|
|
|
|
for (j = LIZTROOP; j < (LIZTROOP+72); j++) tloadtile(j,1);
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=HEADJIB1; j<LEGJIB1+3; j++) tloadtile(j,1);
|
2006-11-16 03:02:42 +00:00
|
|
|
maxc = 0;
|
|
|
|
break;
|
|
|
|
case WOODENHORSE__STATIC:
|
|
|
|
maxc = 5;
|
|
|
|
for (j = HORSEONSIDE; j < (HORSEONSIDE+4); j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case NEWBEAST__STATIC:
|
|
|
|
case NEWBEASTSTAYPUT__STATIC:
|
|
|
|
maxc = 90;
|
|
|
|
break;
|
|
|
|
case BOSS1__STATIC:
|
|
|
|
case BOSS2__STATIC:
|
|
|
|
case BOSS3__STATIC:
|
|
|
|
maxc = 30;
|
|
|
|
break;
|
|
|
|
case OCTABRAIN__STATIC:
|
|
|
|
case OCTABRAINSTAYPUT__STATIC:
|
|
|
|
case COMMANDER__STATIC:
|
|
|
|
case COMMANDERSTAYPUT__STATIC:
|
|
|
|
maxc = 38;
|
|
|
|
break;
|
|
|
|
case RECON__STATIC:
|
|
|
|
maxc = 13;
|
|
|
|
break;
|
|
|
|
case PIGCOP__STATIC:
|
|
|
|
case PIGCOPDIVE__STATIC:
|
|
|
|
maxc = 61;
|
|
|
|
break;
|
|
|
|
case SHARK__STATIC:
|
|
|
|
maxc = 30;
|
|
|
|
break;
|
|
|
|
case LIZMAN__STATIC:
|
|
|
|
case LIZMANSPITTING__STATIC:
|
|
|
|
case LIZMANFEEDING__STATIC:
|
|
|
|
case LIZMANJUMP__STATIC:
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=LIZMANHEAD1; j<LIZMANLEG1+3; j++) tloadtile(j,1);
|
2006-11-16 03:02:42 +00:00
|
|
|
maxc = 80;
|
|
|
|
break;
|
|
|
|
case APLAYER__STATIC:
|
|
|
|
maxc = 0;
|
2010-01-16 23:08:17 +00:00
|
|
|
if ((g_netServer || ud.multimode > 1))
|
2006-11-16 03:02:42 +00:00
|
|
|
{
|
2006-11-15 01:16:55 +00:00
|
|
|
maxc = 5;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j = 1420; j < 1420+106; j++) tloadtile(j,1);
|
2006-11-16 03:02:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ATOMICHEALTH__STATIC:
|
|
|
|
maxc = 14;
|
|
|
|
break;
|
|
|
|
case DRONE__STATIC:
|
|
|
|
maxc = 10;
|
|
|
|
break;
|
|
|
|
case EXPLODINGBARREL__STATIC:
|
|
|
|
case SEENINE__STATIC:
|
|
|
|
case OOZFILTER__STATIC:
|
|
|
|
maxc = 3;
|
|
|
|
break;
|
|
|
|
case NUKEBARREL__STATIC:
|
|
|
|
case CAMERA1__STATIC:
|
|
|
|
maxc = 5;
|
|
|
|
break;
|
|
|
|
// caching of HUD sprites for weapons that may be in the level
|
|
|
|
case CHAINGUNSPRITE__STATIC:
|
|
|
|
for (j=CHAINGUN; j<=CHAINGUN+7; j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case RPGSPRITE__STATIC:
|
|
|
|
for (j=RPGGUN; j<=RPGGUN+2; j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case FREEZESPRITE__STATIC:
|
|
|
|
for (j=FREEZE; j<=FREEZE+5; j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case GROWSPRITEICON__STATIC:
|
|
|
|
case SHRINKERSPRITE__STATIC:
|
|
|
|
for (j=SHRINKER-2; j<=SHRINKER+5; j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case HBOMBAMMO__STATIC:
|
|
|
|
case HEAVYHBOMB__STATIC:
|
|
|
|
for (j=HANDREMOTE; j<=HANDREMOTE+5; j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case TRIPBOMBSPRITE__STATIC:
|
|
|
|
for (j=HANDHOLDINGLASER; j<=HANDHOLDINGLASER+4; j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case SHOTGUNSPRITE__STATIC:
|
|
|
|
tloadtile(SHOTGUNSHELL,1);
|
|
|
|
for (j=SHOTGUN; j<=SHOTGUN+6; j++) tloadtile(j,1);
|
|
|
|
break;
|
|
|
|
case DEVISTATORSPRITE__STATIC:
|
|
|
|
for (j=DEVISTATOR; j<=DEVISTATOR+1; j++) tloadtile(j,1);
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
for (j = PN; j < (PN+maxc); j++) tloadtile(j,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
static void G_PrecacheSprites(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i,j;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXTILES; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (SpriteFlags[i] & SPRITE_PROJECTILE)
|
2006-04-13 20:47:06 +00:00
|
|
|
tloadtile(i,1);
|
2008-11-20 14:06:36 +00:00
|
|
|
if (SpriteCacheList[i][0] == i && SpriteCacheList[i][2])
|
|
|
|
for (j = i; j <= SpriteCacheList[i][1]; j++)
|
2006-04-13 20:47:06 +00:00
|
|
|
tloadtile(j,1);
|
|
|
|
}
|
|
|
|
tloadtile(BOTTOMSTATUSBAR,1);
|
2010-01-16 23:08:17 +00:00
|
|
|
if ((g_netServer || ud.multimode > 1))
|
2006-04-13 20:47:06 +00:00
|
|
|
tloadtile(FRAGBAR,1);
|
|
|
|
|
|
|
|
tloadtile(VIEWSCREEN,1);
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=STARTALPHANUM; i<ENDALPHANUM+1; i++) tloadtile(i,1);
|
2006-11-13 23:12:47 +00:00
|
|
|
for (i=BIGALPHANUM; i<BIGALPHANUM+82; i++) tloadtile(i,1);
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=MINIFONT; i<MINIFONT+63; i++) tloadtile(i,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=FOOTPRINTS; i<FOOTPRINTS+3; i++) tloadtile(i,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
for (i = BURNING; i < BURNING+14; i++) tloadtile(i,1);
|
|
|
|
for (i = BURNING2; i < BURNING2+14; i++) tloadtile(i,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
for (i = CRACKKNUCKLES; i < CRACKKNUCKLES+4; i++) tloadtile(i,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
for (i = FIRSTGUN; i < FIRSTGUN+3 ; i++) tloadtile(i,1);
|
|
|
|
for (i = FIRSTGUNRELOAD; i < FIRSTGUNRELOAD+8 ; i++) tloadtile(i,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
for (i = EXPLOSION2; i < EXPLOSION2+21 ; i++) tloadtile(i,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-03-01 00:50:59 +00:00
|
|
|
for (i = COOLEXPLOSION1; i < COOLEXPLOSION1+21 ; i++) tloadtile(i,1);
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
tloadtile(BULLETHOLE,1);
|
2007-03-01 00:50:59 +00:00
|
|
|
tloadtile(BLOODPOOL,1);
|
|
|
|
for (i = TRANSPORTERBEAM; i < (TRANSPORTERBEAM+6); i++) tloadtile(i,1);
|
2007-03-11 00:47:32 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
for (i = SMALLSMOKE; i < (SMALLSMOKE+4); i++) tloadtile(i,1);
|
2008-04-25 01:46:19 +00:00
|
|
|
for (i = SHOTSPARK1; i < (SHOTSPARK1+4); i++) tloadtile(i,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-03-01 00:50:59 +00:00
|
|
|
for (i = BLOOD; i < (BLOOD+4); i++) tloadtile(i,1);
|
2006-11-14 21:35:50 +00:00
|
|
|
for (i = JIBS1; i < (JIBS5+5); i++) tloadtile(i,1);
|
2008-04-25 01:46:19 +00:00
|
|
|
for (i = JIBS6; i < (JIBS6+8); i++) tloadtile(i,1);
|
|
|
|
|
2007-03-01 00:50:59 +00:00
|
|
|
for (i = SCRAP1; i < (SCRAP1+29); i++) tloadtile(i,1);
|
|
|
|
|
|
|
|
tloadtile(FIRELASER,1);
|
2011-01-09 18:53:06 +00:00
|
|
|
for (i=TRANSPORTERSTAR; i<TRANSPORTERSTAR+6; i++) tloadtile(i,1);
|
2007-03-01 00:50:59 +00:00
|
|
|
for (i=FORCERIPPLE; i<(FORCERIPPLE+9); i++) tloadtile(i,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-03-01 00:50:59 +00:00
|
|
|
for (i=MENUSCREEN; i<DUKECAR; i++) tloadtile(i,1);
|
2007-03-11 00:47:32 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
for (i=RPG; i<RPG+7; i++) tloadtile(i,1);
|
|
|
|
for (i=FREEZEBLAST; i<FREEZEBLAST+3; i++) tloadtile(i,1);
|
|
|
|
for (i=SHRINKSPARK; i<SHRINKSPARK+4; i++) tloadtile(i,1);
|
|
|
|
for (i=GROWSPARK; i<GROWSPARK+4; i++) tloadtile(i,1);
|
|
|
|
for (i=SHRINKEREXPLOSION; i<SHRINKEREXPLOSION+4; i++) tloadtile(i,1);
|
2010-03-11 23:35:22 +00:00
|
|
|
for (i=MORTER; i<MORTER+4; i++) tloadtile(i,1);
|
2008-08-23 23:37:01 +00:00
|
|
|
for (i=0; i<=60; i++) tloadtile(i,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
// FIXME: this function is a piece of shit, needs specific sounds listed
|
2009-02-19 16:47:54 +00:00
|
|
|
static int32_t G_CacheSound(uint32_t num)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t fp = -1;
|
|
|
|
int32_t l;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-10-24 06:48:13 +00:00
|
|
|
if (num >= MAXSOUNDS || ud.config.SoundToggle == 0) return 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.FXDevice < 0) return 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-16 00:48:02 +00:00
|
|
|
if (!g_sounds[num].filename && !g_sounds[num].filename1) return 0;
|
2008-11-20 14:06:36 +00:00
|
|
|
if (g_sounds[num].filename1) fp = kopen4loadfrommod(g_sounds[num].filename1,g_loadFromGroupOnly);
|
|
|
|
if (fp == -1) fp = kopen4loadfrommod(g_sounds[num].filename,g_loadFromGroupOnly);
|
2008-08-23 15:37:30 +00:00
|
|
|
if (fp == -1)
|
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
// OSD_Printf(OSDTEXT_RED "Sound %s(#%d) not found!\n",g_sounds[num].filename,num);
|
2008-08-23 15:37:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
l = kfilelength(fp);
|
2007-09-11 05:26:38 +00:00
|
|
|
g_sounds[num].soundsiz = l;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if ((ud.level_number == 0 && ud.volume_number == 0 && (num == 189 || num == 232 || num == 99 || num == 233 || num == 17)) ||
|
|
|
|
(l < 12288))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-07-12 01:55:34 +00:00
|
|
|
g_soundlocks[num] = 199;
|
|
|
|
allocache((intptr_t *)&g_sounds[num].ptr,l,(char *)&g_soundlocks[num]);
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[num].ptr != NULL)
|
|
|
|
kread(fp, g_sounds[num].ptr , l);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-11-14 21:35:50 +00:00
|
|
|
kclose(fp);
|
2006-04-13 20:47:06 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
static void G_PrecacheSounds(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.FXDevice < 0) return;
|
2006-04-13 20:47:06 +00:00
|
|
|
j = 0;
|
|
|
|
|
2010-06-07 09:03:16 +00:00
|
|
|
for (i=MAXSOUNDS-1; i>=0; i--)
|
2007-09-11 05:26:38 +00:00
|
|
|
if (g_sounds[i].ptr == 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
j++;
|
2006-11-14 21:35:50 +00:00
|
|
|
if ((j&7) == 0)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
|
|
|
handleevents();
|
2009-01-09 09:29:17 +00:00
|
|
|
Net_GetPackets();
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
G_CacheSound(i);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static void G_DoLoadScreen(char *statustext, int32_t percent)
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i=0,j;
|
2006-12-10 06:49:01 +00:00
|
|
|
|
|
|
|
if (ud.recstat != 2)
|
|
|
|
{
|
2010-08-02 08:13:51 +00:00
|
|
|
/*Gv_SetVar(g_iReturnVarID,LOADSCREEN, -1, -1);*/
|
2010-05-02 23:27:30 +00:00
|
|
|
aGameVars[g_iReturnVarID].val.lValue = LOADSCREEN;
|
|
|
|
VM_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1);
|
|
|
|
j = aGameVars[g_iReturnVarID].val.lValue;
|
|
|
|
|
2011-12-28 20:35:23 +00:00
|
|
|
//g_player[myconnectindex].ps->palette = palette;
|
|
|
|
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0 /*1*/); // JBF 20040308
|
|
|
|
|
2006-12-10 06:49:01 +00:00
|
|
|
if (!statustext)
|
|
|
|
{
|
|
|
|
i = ud.screen_size;
|
|
|
|
ud.screen_size = 0;
|
2008-11-20 14:06:36 +00:00
|
|
|
G_UpdateScreenArea();
|
2006-12-10 06:49:01 +00:00
|
|
|
clearview(0L);
|
|
|
|
}
|
|
|
|
|
2011-08-17 18:52:54 +00:00
|
|
|
if ((uint32_t)j < 2*MAXTILES)
|
|
|
|
{
|
2012-02-02 17:35:05 +00:00
|
|
|
rotatesprite_fs(320<<15,200<<15,65536L,0, j > MAXTILES-1?j-MAXTILES:j,0,0,
|
|
|
|
2+8+64+(ud.bgstretch?1024:0));
|
2011-08-17 18:52:54 +00:00
|
|
|
}
|
|
|
|
else
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
|
|
|
nextpage();
|
|
|
|
return;
|
|
|
|
}
|
2011-08-17 18:52:54 +00:00
|
|
|
|
2006-12-10 06:49:01 +00:00
|
|
|
if (boardfilename[0] != 0 && ud.level_number == 7 && ud.volume_number == 0)
|
|
|
|
{
|
2008-09-15 02:47:02 +00:00
|
|
|
menutext(160,90,0,0,"LOADING USER MAP");
|
2006-12-10 06:49:01 +00:00
|
|
|
gametextpal(160,90+10,boardfilename,14,2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-09-15 02:47:02 +00:00
|
|
|
menutext(160,90,0,0,"LOADING");
|
2008-11-20 14:06:36 +00:00
|
|
|
if (MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL)
|
|
|
|
menutext(160,90+16+8,0,0,MapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name);
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (statustext) gametext(160,180,statustext,0,2+8+16);
|
2010-05-02 23:27:30 +00:00
|
|
|
|
|
|
|
if (percent != -1)
|
2008-12-17 01:59:36 +00:00
|
|
|
{
|
2009-04-15 05:58:38 +00:00
|
|
|
int32_t ii = scale(scale(xdim-1,288,320),percent,100);
|
|
|
|
rotatesprite(31<<16,145<<16,65536,0,929,15,0,2+8+16,0,0,ii,ydim-1);
|
|
|
|
rotatesprite(159<<16,145<<16,65536,0,929,15,0,2+8+16,0,0,ii,ydim-1);
|
|
|
|
rotatesprite(30<<16,144<<16,65536,0,929,0,0,2+8+16,0,0,ii,ydim-1);
|
|
|
|
rotatesprite(158<<16,144<<16,65536,0,929,0,0,2+8+16,0,0,ii,ydim-1);
|
2008-12-17 01:59:36 +00:00
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
|
|
|
|
VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1);
|
2006-12-10 06:49:01 +00:00
|
|
|
nextpage();
|
|
|
|
|
|
|
|
if (!statustext)
|
|
|
|
{
|
|
|
|
KB_FlushKeyboardQueue();
|
|
|
|
ud.screen_size = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!statustext)
|
|
|
|
{
|
|
|
|
clearview(0L);
|
2007-08-27 06:46:31 +00:00
|
|
|
//g_player[myconnectindex].ps->palette = palette;
|
2008-11-20 14:06:36 +00:00
|
|
|
//G_FadePalette(0,0,0,0);
|
2011-01-17 03:49:34 +00:00
|
|
|
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); // JBF 20040308
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
2009-01-18 07:32:35 +00:00
|
|
|
/*Gv_SetVar(g_iReturnVarID,LOADSCREEN, -1, -1);*/
|
2011-08-17 18:52:54 +00:00
|
|
|
|
2009-01-18 07:32:35 +00:00
|
|
|
aGameVars[g_iReturnVarID].val.lValue = LOADSCREEN;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_GETLOADTILE, -1, myconnectindex, -1);
|
2009-01-18 07:32:35 +00:00
|
|
|
j = aGameVars[g_iReturnVarID].val.lValue;
|
2011-08-17 18:52:54 +00:00
|
|
|
|
|
|
|
if ((uint32_t)j < 2*MAXTILES)
|
|
|
|
{
|
2012-02-02 17:35:05 +00:00
|
|
|
rotatesprite_fs(320<<15,200<<15,65536L, 0,j > MAXTILES-1?j-MAXTILES:j,0,0,
|
|
|
|
2+8+64+(ud.bgstretch?1024:0));
|
2011-08-17 18:52:54 +00:00
|
|
|
}
|
|
|
|
else
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
|
|
|
nextpage();
|
|
|
|
return;
|
|
|
|
}
|
2011-08-17 18:52:54 +00:00
|
|
|
|
2006-12-10 06:49:01 +00:00
|
|
|
menutext(160,105,0,0,"LOADING...");
|
|
|
|
if (statustext) gametext(160,180,statustext,0,2+8+16);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1);
|
2006-12-10 06:49:01 +00:00
|
|
|
nextpage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b);
|
2008-11-20 14:06:36 +00:00
|
|
|
extern palette_t CrosshairColors;
|
2008-08-07 13:23:08 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void G_CacheMapData(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i,j,pc=0;
|
|
|
|
int32_t tc;
|
|
|
|
uint32_t starttime, endtime;
|
2006-04-16 03:42:36 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (ud.recstat == 2)
|
2006-04-16 03:42:36 +00:00
|
|
|
return;
|
|
|
|
|
2009-07-27 05:33:12 +00:00
|
|
|
S_PauseMusic(1);
|
2009-07-28 08:28:58 +00:00
|
|
|
if (MapInfo[MAXVOLUMES*MAXLEVELS+2].alt_musicfn)
|
2008-04-05 04:18:48 +00:00
|
|
|
{
|
2009-07-27 05:33:12 +00:00
|
|
|
S_StopMusic();
|
2008-11-20 14:06:36 +00:00
|
|
|
S_PlayMusic(&EnvMusicFilename[2][0],MAXVOLUMES*MAXLEVELS+2); // loadmus
|
2008-04-05 04:18:48 +00:00
|
|
|
}
|
2008-03-16 06:37:47 +00:00
|
|
|
|
2006-04-16 03:42:36 +00:00
|
|
|
starttime = getticks();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
G_PrecacheSounds();
|
|
|
|
G_PrecacheSprites();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numwalls; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
tloadtile(wall[i].picnum, 0);
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (wall[i].overpicnum >= 0)
|
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
tloadtile(wall[i].overpicnum, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-14 21:35:50 +00:00
|
|
|
tloadtile(sector[i].floorpicnum, 0);
|
|
|
|
tloadtile(sector[i].ceilingpicnum, 0);
|
2009-11-14 02:30:47 +00:00
|
|
|
if (sector[i].ceilingpicnum == LA) // JBF 20040509: if( waloff[sector[i].ceilingpicnum] == LA) WTF?!?!?!?
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
tloadtile(LA+1, 0);
|
|
|
|
tloadtile(LA+2, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
j = headspritesect[i];
|
2006-11-13 23:12:47 +00:00
|
|
|
while (j >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sprite[j].xrepeat != 0 && sprite[j].yrepeat != 0 && (sprite[j].cstat&32768) == 0)
|
2008-11-20 14:06:36 +00:00
|
|
|
G_CacheSpriteNum(j);
|
2006-04-13 20:47:06 +00:00
|
|
|
j = nextspritesect[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-16 03:42:36 +00:00
|
|
|
tc = totalclock;
|
2006-04-13 20:47:06 +00:00
|
|
|
j = 0;
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAXTILES; i++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
|
|
|
if (!(i&7) && !gotpic[i>>3])
|
|
|
|
{
|
2006-04-16 03:42:36 +00:00
|
|
|
i+=7;
|
|
|
|
continue;
|
|
|
|
}
|
2006-11-15 01:16:55 +00:00
|
|
|
if (gotpic[i>>3] & pow2char[i&7])
|
|
|
|
{
|
2006-04-16 03:42:36 +00:00
|
|
|
if (waloff[i] == 0)
|
2009-01-09 09:29:17 +00:00
|
|
|
loadtile((int16_t)i);
|
2006-04-16 03:42:36 +00:00
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2011-01-09 18:53:06 +00:00
|
|
|
// PRECACHE
|
2007-08-27 00:20:15 +00:00
|
|
|
if (ud.config.useprecache)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2010-03-11 23:35:22 +00:00
|
|
|
int32_t k,type;
|
|
|
|
|
|
|
|
for (type=0; type<=1; type++)
|
|
|
|
if (precachehightile[type][i>>3] & pow2char[i&7])
|
|
|
|
{
|
2011-09-28 20:30:24 +00:00
|
|
|
k = 0;
|
2010-03-11 23:35:22 +00:00
|
|
|
for (k=0; k<MAXPALOOKUPS-RESERVEDPALS && !KB_KeyPressed(sc_Space); k++)
|
2011-09-28 20:30:24 +00:00
|
|
|
{
|
|
|
|
// this is the CROSSHAIR_COLOR, see comment in game.c
|
|
|
|
if (k == MAXPALOOKUPS-RESERVEDPALS-1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (rendmode!=4 || !polymer_havehighpalookup(0, k))
|
|
|
|
polymost_precache(i,k,type);
|
|
|
|
}
|
|
|
|
|
2010-03-11 23:35:22 +00:00
|
|
|
if (r_detailmapping && !KB_KeyPressed(sc_Space))
|
|
|
|
polymost_precache(i,DETAILPAL,type);
|
|
|
|
if (r_glowmapping && !KB_KeyPressed(sc_Space))
|
|
|
|
polymost_precache(i,GLOWPAL,type);
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2010-03-11 23:35:22 +00:00
|
|
|
if (rendmode==4)
|
|
|
|
{
|
|
|
|
if (pr_specularmapping && !KB_KeyPressed(sc_Space))
|
|
|
|
polymost_precache(i,SPECULARPAL,type);
|
|
|
|
if (pr_normalmapping && !KB_KeyPressed(sc_Space))
|
|
|
|
polymost_precache(i,NORMALPAL,type);
|
|
|
|
}
|
2010-06-23 04:20:46 +00:00
|
|
|
#endif
|
2010-03-11 23:35:22 +00:00
|
|
|
}
|
2006-04-16 03:42:36 +00:00
|
|
|
}
|
2006-08-07 19:57:53 +00:00
|
|
|
#endif
|
2006-04-16 03:42:36 +00:00
|
|
|
j++;
|
|
|
|
pc++;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
else continue;
|
2006-04-16 03:42:36 +00:00
|
|
|
|
2009-07-28 06:32:58 +00:00
|
|
|
MUSIC_Update();
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if ((j&7) == 0)
|
|
|
|
{
|
|
|
|
handleevents();
|
2009-01-09 09:29:17 +00:00
|
|
|
Net_GetPackets();
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
if (totalclock - tc > TICRATE/4)
|
|
|
|
{
|
2009-01-19 06:41:28 +00:00
|
|
|
/*Bsprintf(tempbuf,"%d resources remaining\n",g_precacheCount-pc+1);*/
|
|
|
|
tc = min(100,100*pc/g_precacheCount);
|
|
|
|
Bsprintf(tempbuf,"Loaded %d%% (%d/%d textures)\n",tc,pc,g_precacheCount);
|
|
|
|
G_DoLoadScreen(tempbuf, tc);
|
2006-04-16 03:42:36 +00:00
|
|
|
tc = totalclock;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
clearbufbyte(gotpic,sizeof(gotpic),0L);
|
|
|
|
|
2006-04-16 03:42:36 +00:00
|
|
|
endtime = getticks();
|
|
|
|
OSD_Printf("Cache time: %dms\n", endtime-starttime);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 21:50:19 +00:00
|
|
|
void G_SetupCamTile(int32_t i,int32_t wn)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
//if (waloff[wn] == 0) loadtile(wn);
|
|
|
|
setviewtotile(wn,tilesizy[wn],tilesizx[wn]);
|
|
|
|
|
2011-09-15 17:03:08 +00:00
|
|
|
yax_preparedrawrooms();
|
2006-04-13 20:47:06 +00:00
|
|
|
drawrooms(SX,SY,SZ,SA,100+sprite[i].shade,SECT);
|
2011-09-15 17:03:08 +00:00
|
|
|
// g_yax_smoothratio?
|
|
|
|
yax_drawrooms(G_AnalyzeSprites, 100+sprite[i].shade, SECT);
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
display_mirror = 1;
|
2008-11-20 14:06:36 +00:00
|
|
|
G_DoSpriteAnimations(SX,SY,SA,65536L);
|
2006-11-15 01:16:55 +00:00
|
|
|
display_mirror = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
drawmasks();
|
|
|
|
|
|
|
|
setviewback();
|
|
|
|
squarerotatetile(wn);
|
|
|
|
invalidatetile(wn,-1,255);
|
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void G_UpdateScreenArea(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i, j, ss, x1, x2, y1, y2;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-04-29 19:43:51 +00:00
|
|
|
if (qsetmode != 200) return;
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (ud.screen_size < 0) ud.screen_size = 0;
|
2006-12-17 21:20:35 +00:00
|
|
|
if (ud.screen_size > 64) ud.screen_size = 64;
|
2006-11-13 23:12:47 +00:00
|
|
|
if (ud.screen_size == 0) flushperms();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
ss = max(ud.screen_size-8,0);
|
|
|
|
|
|
|
|
x1 = scale(ss,xdim,160);
|
|
|
|
x2 = xdim-x1;
|
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
y1 = ss;
|
|
|
|
y2 = 200;
|
2010-01-16 23:08:17 +00:00
|
|
|
if (ud.screen_size > 0 && (GametypeFlags[ud.coop]&GAMETYPE_FRAGBAR) && (g_netServer || ud.multimode > 1))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
j = 0;
|
2012-02-21 19:33:33 +00:00
|
|
|
for (TRAVERSE_CONNECT(i))
|
|
|
|
if (i > j) j = i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
if (j >= 1) y1 += 8;
|
|
|
|
if (j >= 4) y1 += 8;
|
|
|
|
if (j >= 8) y1 += 8;
|
|
|
|
if (j >= 12) y1 += 8;
|
|
|
|
}
|
|
|
|
|
2008-07-24 11:16:20 +00:00
|
|
|
if (ud.screen_size >= 8 && !(getrendermode() >= 3 && ud.screen_size == 8 && ud.statusbarmode))
|
2006-12-17 21:20:35 +00:00
|
|
|
y2 -= (ss+scale(tilesizy[BOTTOMSTATUSBAR],ud.statusbarscale,100));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
y1 = scale(y1,ydim,200);
|
|
|
|
y2 = scale(y2,ydim,200);
|
|
|
|
|
2010-05-10 03:11:15 +00:00
|
|
|
setview(x1,y1,x2-1,y2-(getrendermode() < 3));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
G_GetCrosshairColor();
|
|
|
|
G_SetCrosshairColor(CrosshairColors.r, CrosshairColors.g, CrosshairColors.b);
|
2008-08-08 00:32:16 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
pub = NUMPAGES;
|
|
|
|
pus = NUMPAGES;
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void P_RandomSpawnPoint(int32_t snum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
DukePlayer_t *p = g_player[snum].ps;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i=snum,j,k;
|
|
|
|
uint32_t dist,pdist = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-01-16 23:08:17 +00:00
|
|
|
if ((g_netServer || ud.multimode > 1) && !(GametypeFlags[ud.coop] & GAMETYPE_FIXEDRESPAWN))
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
i = krand()%g_numPlayerSprites;
|
|
|
|
if (GametypeFlags[ud.coop] & GAMETYPE_TDMSPAWN)
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<ud.multimode; j++)
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2008-08-11 23:22:29 +00:00
|
|
|
if (j != snum && g_player[j].ps->team == p->team && sprite[g_player[j].ps->i].extra > 0)
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (k=0; k<g_numPlayerSprites; k++)
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2010-05-02 23:27:30 +00:00
|
|
|
dist = FindDistance2D(g_player[j].ps->pos.x-g_playerSpawnPoints[k].ox,g_player[j].ps->pos.y-g_playerSpawnPoints[k].oy);
|
2006-11-13 23:12:47 +00:00
|
|
|
if (dist < pdist)
|
2006-08-18 23:52:26 +00:00
|
|
|
i = k, pdist = dist;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2006-08-18 23:52:26 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
p->bobposx = p->opos.x = p->pos.x = g_playerSpawnPoints[i].ox;
|
|
|
|
p->bobposy = p->opos.y = p->pos.y = g_playerSpawnPoints[i].oy;
|
|
|
|
p->opos.z = p->pos.z = g_playerSpawnPoints[i].oz;
|
2008-11-20 14:06:36 +00:00
|
|
|
p->ang = g_playerSpawnPoints[i].oa;
|
|
|
|
p->cursectnum = g_playerSpawnPoints[i].os;
|
2009-12-12 11:07:59 +00:00
|
|
|
sprite[p->i].cstat = 1+256;
|
|
|
|
}
|
|
|
|
|
|
|
|
void P_ResetPlayer(int32_t snum)
|
|
|
|
{
|
|
|
|
vec3_t tmpvect;
|
|
|
|
spritetype *sp = &sprite[g_player[snum].ps->i];
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
tmpvect.x = g_player[snum].ps->pos.x;
|
|
|
|
tmpvect.y = g_player[snum].ps->pos.y;
|
|
|
|
tmpvect.z = g_player[snum].ps->pos.z+PHEIGHT;
|
2009-12-12 11:07:59 +00:00
|
|
|
P_RandomSpawnPoint(snum);
|
2010-05-02 23:27:30 +00:00
|
|
|
sp->x = actor[g_player[snum].ps->i].bposx = g_player[snum].ps->bobposx = g_player[snum].ps->opos.x = g_player[snum].ps->pos.x;
|
|
|
|
sp->y = actor[g_player[snum].ps->i].bposy = g_player[snum].ps->bobposy = g_player[snum].ps->opos.y =g_player[snum].ps->pos.y;
|
|
|
|
sp->z = actor[g_player[snum].ps->i].bposy = g_player[snum].ps->opos.z =g_player[snum].ps->pos.z;
|
|
|
|
updatesector(g_player[snum].ps->pos.x,g_player[snum].ps->pos.y,&g_player[snum].ps->cursectnum);
|
2009-12-12 11:07:59 +00:00
|
|
|
setsprite(g_player[snum].ps->i,&tmpvect);
|
|
|
|
sp->cstat = 257;
|
|
|
|
|
|
|
|
sp->shade = -12;
|
|
|
|
sp->clipdist = 64;
|
|
|
|
sp->xrepeat = 42;
|
|
|
|
sp->yrepeat = 36;
|
|
|
|
sp->owner = g_player[snum].ps->i;
|
|
|
|
sp->xoffset = 0;
|
|
|
|
sp->pal = g_player[snum].ps->palookup;
|
|
|
|
|
|
|
|
g_player[snum].ps->last_extra = sp->extra = g_player[snum].ps->max_player_health;
|
|
|
|
g_player[snum].ps->wantweaponfire = -1;
|
|
|
|
g_player[snum].ps->horiz = 100;
|
|
|
|
g_player[snum].ps->on_crane = -1;
|
|
|
|
g_player[snum].ps->frag_ps = snum;
|
|
|
|
g_player[snum].ps->horizoff = 0;
|
|
|
|
g_player[snum].ps->opyoff = 0;
|
|
|
|
g_player[snum].ps->wackedbyactor = -1;
|
2009-12-15 05:53:15 +00:00
|
|
|
g_player[snum].ps->inv_amount[GET_SHIELD] = g_startArmorAmount;
|
2009-12-12 11:07:59 +00:00
|
|
|
g_player[snum].ps->dead_flag = 0;
|
2010-05-02 23:27:30 +00:00
|
|
|
g_player[snum].ps->pals.f = 0;
|
2009-12-12 11:07:59 +00:00
|
|
|
g_player[snum].ps->footprintcount = 0;
|
|
|
|
g_player[snum].ps->weapreccnt = 0;
|
|
|
|
g_player[snum].ps->fta = 0;
|
|
|
|
g_player[snum].ps->ftq = 0;
|
2011-02-25 21:50:19 +00:00
|
|
|
g_player[snum].ps->vel.x = g_player[snum].ps->vel.y = 0;
|
2009-12-12 11:07:59 +00:00
|
|
|
g_player[snum].ps->rotscrnang = 0;
|
|
|
|
g_player[snum].ps->runspeed = g_playerFriction;
|
|
|
|
g_player[snum].ps->falling_counter = 0;
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
actor[g_player[snum].ps->i].extra = -1;
|
|
|
|
actor[g_player[snum].ps->i].owner = g_player[snum].ps->i;
|
2009-12-12 11:07:59 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
actor[g_player[snum].ps->i].cgg = 0;
|
|
|
|
actor[g_player[snum].ps->i].movflag = 0;
|
|
|
|
actor[g_player[snum].ps->i].tempang = 0;
|
|
|
|
actor[g_player[snum].ps->i].actorstayput = -1;
|
|
|
|
actor[g_player[snum].ps->i].dispicnum = 0;
|
|
|
|
actor[g_player[snum].ps->i].owner = g_player[snum].ps->i;
|
2009-12-12 11:07:59 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
actor[g_player[snum].ps->i].t_data[4] = 0;
|
2009-12-12 11:07:59 +00:00
|
|
|
|
|
|
|
P_ResetInventory(snum);
|
|
|
|
P_ResetWeapons(snum);
|
|
|
|
|
|
|
|
g_player[snum].ps->reloading = 0;
|
|
|
|
|
|
|
|
g_player[snum].ps->movement_lock = 0;
|
|
|
|
|
|
|
|
if (apScriptGameEvent[EVENT_RESETPLAYER])
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_RESETPLAYER, g_player[snum].ps->i, snum, -1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-12-05 09:22:43 +00:00
|
|
|
void P_ResetStatus(int32_t snum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
DukePlayer_t *p = g_player[snum].ps;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
ud.show_help = 0;
|
|
|
|
ud.showallmap = 0;
|
|
|
|
p->dead_flag = 0;
|
|
|
|
p->wackedbyactor = -1;
|
|
|
|
p->falling_counter = 0;
|
|
|
|
p->quick_kick = 0;
|
|
|
|
p->subweapon = 0;
|
|
|
|
p->last_full_weapon = 0;
|
|
|
|
p->ftq = 0;
|
|
|
|
p->fta = 0;
|
|
|
|
p->tipincs = 0;
|
|
|
|
p->buttonpalette = 0;
|
|
|
|
p->actorsqu =-1;
|
|
|
|
p->invdisptime = 0;
|
|
|
|
p->refresh_inventory= 0;
|
|
|
|
p->last_pissed_time = 0;
|
|
|
|
p->holster_weapon = 0;
|
|
|
|
p->pycount = 0;
|
|
|
|
p->pyoff = 0;
|
|
|
|
p->opyoff = 0;
|
|
|
|
p->loogcnt = 0;
|
|
|
|
p->angvel = 0;
|
|
|
|
p->weapon_sway = 0;
|
|
|
|
// p->select_dir = 0;
|
|
|
|
p->extra_extra8 = 0;
|
|
|
|
p->show_empty_weapon= 0;
|
|
|
|
p->dummyplayersprite=-1;
|
|
|
|
p->crack_time = 0;
|
|
|
|
p->hbomb_hold_delay = 0;
|
|
|
|
p->transporter_hold = 0;
|
|
|
|
p->wantweaponfire = -1;
|
|
|
|
p->hurt_delay = 0;
|
|
|
|
p->footprintcount = 0;
|
|
|
|
p->footprintpal = 0;
|
|
|
|
p->footprintshade = 0;
|
|
|
|
p->jumping_toggle = 0;
|
|
|
|
p->ohoriz = p->horiz= 140;
|
|
|
|
p->horizoff = 0;
|
|
|
|
p->bobcounter = 0;
|
|
|
|
p->on_ground = 0;
|
|
|
|
p->player_par = 0;
|
|
|
|
p->return_to_center = 9;
|
2009-04-26 05:57:42 +00:00
|
|
|
p->airleft = 15*GAMETICSPERSEC;
|
2006-04-13 20:47:06 +00:00
|
|
|
p->rapid_fire_hold = 0;
|
|
|
|
p->toggle_key_flag = 0;
|
|
|
|
p->access_spritenum = -1;
|
2010-01-16 23:08:17 +00:00
|
|
|
if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop] & GAMETYPE_ACCESSATSTART))
|
2006-04-13 20:47:06 +00:00
|
|
|
p->got_access = 7;
|
|
|
|
else p->got_access = 0;
|
|
|
|
p->random_club_frame= 0;
|
|
|
|
pus = 1;
|
|
|
|
p->on_warping_sector = 0;
|
|
|
|
p->spritebridge = 0;
|
|
|
|
p->sbs = 0;
|
2011-01-17 03:49:34 +00:00
|
|
|
p->palette = BASEPAL;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-12-15 05:53:15 +00:00
|
|
|
if (p->inv_amount[GET_STEROIDS] < 400)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-12-15 05:53:15 +00:00
|
|
|
p->inv_amount[GET_STEROIDS] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
p->inven_icon = 0;
|
|
|
|
}
|
|
|
|
p->heat_on = 0;
|
|
|
|
p->jetpack_on = 0;
|
|
|
|
p->holoduke_on = -1;
|
|
|
|
|
|
|
|
p->look_ang = 512 - ((ud.level_number&1)<<10);
|
|
|
|
|
|
|
|
p->rotscrnang = 0;
|
|
|
|
p->orotscrnang = 1; // JBF 20031220
|
|
|
|
p->newowner =-1;
|
|
|
|
p->jumping_counter = 0;
|
|
|
|
p->hard_landing = 0;
|
2011-02-25 21:50:19 +00:00
|
|
|
p->vel.x = 0;
|
|
|
|
p->vel.y = 0;
|
|
|
|
p->vel.z = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
fricxv = 0;
|
|
|
|
fricyv = 0;
|
|
|
|
p->somethingonplayer =-1;
|
|
|
|
p->one_eighty_count = 0;
|
|
|
|
p->cheat_phase = 0;
|
|
|
|
|
|
|
|
p->on_crane = -1;
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if ((aplWeaponWorksLike[p->curr_weapon][snum] == PISTOL_WEAPON) &&
|
|
|
|
(aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]))
|
2010-05-16 22:53:08 +00:00
|
|
|
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum];
|
2006-04-13 20:47:06 +00:00
|
|
|
else p->kickback_pic = 0;
|
|
|
|
|
|
|
|
p->weapon_pos = 6;
|
|
|
|
p->walking_snd_toggle= 0;
|
|
|
|
p->weapon_ang = 0;
|
|
|
|
|
|
|
|
p->knuckle_incs = 1;
|
|
|
|
p->fist_incs = 0;
|
|
|
|
p->knee_incs = 0;
|
|
|
|
p->jetpack_on = 0;
|
|
|
|
p->reloading = 0;
|
|
|
|
|
2006-05-20 14:31:24 +00:00
|
|
|
p->movement_lock = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-01-05 21:53:14 +00:00
|
|
|
p->frag_ps = snum;
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
P_UpdateScreenPal(p);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_RESETPLAYER, p->i, snum, -1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void P_ResetWeapons(int32_t snum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t weapon;
|
2008-11-20 14:06:36 +00:00
|
|
|
DukePlayer_t *p = g_player[snum].ps;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
for (weapon = PISTOL_WEAPON; weapon < MAX_WEAPONS; weapon++)
|
2006-04-13 20:47:06 +00:00
|
|
|
p->ammo_amount[weapon] = 0;
|
|
|
|
|
|
|
|
p->weapon_pos = 6;
|
|
|
|
p->curr_weapon = PISTOL_WEAPON;
|
2010-05-16 22:53:08 +00:00
|
|
|
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum];
|
2010-05-02 23:27:30 +00:00
|
|
|
p->gotweapon = ((1<<PISTOL_WEAPON) | (1<<KNEE_WEAPON) | (1<<HANDREMOTE_WEAPON));
|
2009-06-28 20:23:12 +00:00
|
|
|
p->ammo_amount[PISTOL_WEAPON] = min(p->max_ammo_amount[PISTOL_WEAPON], 48);
|
2006-04-13 20:47:06 +00:00
|
|
|
p->last_weapon = -1;
|
|
|
|
|
|
|
|
p->show_empty_weapon= 0;
|
|
|
|
p->last_pissed_time = 0;
|
|
|
|
p->holster_weapon = 0;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_RESETWEAPONS, p->i, snum, -1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void P_ResetInventory(int32_t snum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
DukePlayer_t *p = g_player[snum].ps;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-12-15 05:53:15 +00:00
|
|
|
Bmemset(p->inv_amount, 0, sizeof(p->inv_amount));
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
p->inven_icon = 0;
|
2006-11-15 01:16:55 +00:00
|
|
|
p->scuba_on = 0;
|
|
|
|
p->heat_on = 0;
|
|
|
|
p->jetpack_on = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
p->holoduke_on = -1;
|
2009-12-15 05:53:15 +00:00
|
|
|
|
|
|
|
p->inv_amount[GET_SHIELD] = g_startArmorAmount;
|
2006-04-13 20:47:06 +00:00
|
|
|
p->inven_icon = 0;
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_RESETINVENTORY, p->i, snum, -1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static void resetprestat(int32_t snum,int32_t g)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
DukePlayer_t *p = g_player[snum].ps;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_spriteDeleteQueuePos = 0;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<g_spriteDeleteQueueSize; i++) SpriteDeletionQueue[i] = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
p->hbomb_on = 0;
|
|
|
|
p->cheat_phase = 0;
|
2010-05-02 23:27:30 +00:00
|
|
|
p->pals.f = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
p->toggle_key_flag = 0;
|
|
|
|
p->secret_rooms = 0;
|
|
|
|
p->max_secret_rooms = 0;
|
|
|
|
p->actors_killed = 0;
|
|
|
|
p->max_actors_killed = 0;
|
|
|
|
p->lastrandomspot = 0;
|
|
|
|
p->weapon_pos = 6;
|
2010-05-16 22:53:08 +00:00
|
|
|
|
|
|
|
if ((aplWeaponWorksLike[p->curr_weapon][snum] == PISTOL_WEAPON) &&
|
2010-08-02 08:13:51 +00:00
|
|
|
(aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]))
|
2010-05-16 22:53:08 +00:00
|
|
|
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum];
|
|
|
|
else p->kickback_pic = 0;
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
p->last_weapon = -1;
|
|
|
|
p->weapreccnt = 0;
|
|
|
|
p->interface_toggle_flag = 0;
|
|
|
|
p->show_empty_weapon= 0;
|
|
|
|
p->holster_weapon = 0;
|
|
|
|
p->last_pissed_time = 0;
|
|
|
|
|
|
|
|
p->one_parallax_sectnum = -1;
|
|
|
|
p->visibility = ud.const_visibility;
|
|
|
|
|
|
|
|
screenpeek = myconnectindex;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_numAnimWalls = 0;
|
|
|
|
g_numCyclers = 0;
|
|
|
|
g_animateCount = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
parallaxtype = 0;
|
2008-11-20 14:06:36 +00:00
|
|
|
randomseed = 1996;
|
2006-04-13 20:47:06 +00:00
|
|
|
ud.pause_on = 0;
|
|
|
|
ud.camerasprite =-1;
|
|
|
|
ud.eog = 0;
|
|
|
|
tempwallptr = 0;
|
|
|
|
camsprite =-1;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_earthquakeTime = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_numInterpolations = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
startofdynamicinterpolations = 0;
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
if (((g&MODE_EOL) != MODE_EOL && numplayers < 2 && !g_netServer) ||
|
2010-08-02 08:13:51 +00:00
|
|
|
(!(GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && numplayers > 1))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
P_ResetWeapons(snum);
|
|
|
|
P_ResetInventory(snum);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-11-13 23:12:47 +00:00
|
|
|
else if (p->curr_weapon == HANDREMOTE_WEAPON)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
p->ammo_amount[HANDBOMB_WEAPON]++;
|
|
|
|
p->curr_weapon = HANDBOMB_WEAPON;
|
|
|
|
}
|
|
|
|
|
|
|
|
p->timebeforeexit = 0;
|
|
|
|
p->customexitsound = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-05-12 23:35:29 +00:00
|
|
|
static void G_MultiPskyInit(void)
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
|
|
|
|
// new-style multi-psky handling
|
|
|
|
pskymultilist[0] = MOONSKY1;
|
|
|
|
pskymultilist[1] = BIGORBIT1;
|
|
|
|
pskymultilist[2] = LA;
|
2011-05-15 22:37:24 +00:00
|
|
|
|
|
|
|
pskymultiyscale[0] = 32768;
|
|
|
|
pskymultiyscale[1] = 32768;
|
|
|
|
pskymultiyscale[2] = 16384+1024;
|
|
|
|
|
2011-05-12 23:35:29 +00:00
|
|
|
for (i=0; i<3; i++)
|
|
|
|
{
|
|
|
|
pskymultibits[i] = 3;
|
|
|
|
Bmemset(pskymultioff[i], 0, sizeof(pskymultioff[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
// MOONSKY1
|
|
|
|
// earth mountian mountain sun
|
|
|
|
pskymultioff[0][6]=1;
|
|
|
|
pskymultioff[0][1]=2;
|
|
|
|
pskymultioff[0][4]=2;
|
|
|
|
pskymultioff[0][2]=3;
|
|
|
|
|
|
|
|
// BIGORBIT1 // orbit
|
|
|
|
// earth1 2 3 moon/sun
|
|
|
|
pskymultioff[1][5]=1;
|
|
|
|
pskymultioff[1][6]=2;
|
|
|
|
pskymultioff[1][7]=3;
|
|
|
|
pskymultioff[1][2]=4;
|
|
|
|
|
|
|
|
// LA // la city
|
|
|
|
// earth1 2 3 moon/sun
|
|
|
|
pskymultioff[2][0]=1;
|
|
|
|
pskymultioff[2][1]=2;
|
|
|
|
pskymultioff[2][2]=1;
|
|
|
|
pskymultioff[2][3]=3;
|
|
|
|
pskymultioff[2][4]=4;
|
|
|
|
pskymultioff[2][5]=0;
|
|
|
|
pskymultioff[2][6]=2;
|
|
|
|
pskymultioff[2][7]=3;
|
|
|
|
|
|
|
|
pskynummultis = 3;
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
static inline void G_SetupBackdrop(int16_t sky)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-05-15 22:37:24 +00:00
|
|
|
static int32_t multiskiesinited=0;
|
|
|
|
|
|
|
|
if (!multiskiesinited)
|
|
|
|
{
|
|
|
|
multiskiesinited = 1;
|
|
|
|
G_MultiPskyInit();
|
|
|
|
}
|
2011-05-12 23:35:29 +00:00
|
|
|
|
2012-01-10 23:45:34 +00:00
|
|
|
Bmemset(pskyoff, 0, sizeof(pskyoff));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-05-12 23:35:29 +00:00
|
|
|
if (parallaxyscale != 65536)
|
2006-04-13 20:47:06 +00:00
|
|
|
parallaxyscale = 32768;
|
|
|
|
|
2012-01-28 14:38:23 +00:00
|
|
|
switch (DYNAMICTILEMAP(sky))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case CLOUDYOCEAN__STATIC:
|
|
|
|
parallaxyscale = 65536L;
|
|
|
|
break;
|
|
|
|
case MOONSKY1__STATIC :
|
|
|
|
pskyoff[6]=1;
|
|
|
|
pskyoff[1]=2;
|
|
|
|
pskyoff[4]=2;
|
|
|
|
pskyoff[2]=3;
|
|
|
|
break;
|
|
|
|
case BIGORBIT1__STATIC: // orbit
|
|
|
|
pskyoff[5]=1;
|
|
|
|
pskyoff[6]=2;
|
|
|
|
pskyoff[7]=3;
|
|
|
|
pskyoff[2]=4;
|
|
|
|
break;
|
|
|
|
case LA__STATIC:
|
|
|
|
parallaxyscale = 16384+1024;
|
|
|
|
pskyoff[0]=1;
|
|
|
|
pskyoff[1]=2;
|
|
|
|
pskyoff[2]=1;
|
|
|
|
pskyoff[3]=3;
|
|
|
|
pskyoff[4]=4;
|
|
|
|
pskyoff[5]=0;
|
|
|
|
pskyoff[6]=2;
|
|
|
|
pskyoff[7]=3;
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pskybits=3;
|
|
|
|
}
|
|
|
|
|
2011-07-20 22:08:05 +00:00
|
|
|
// tweak moving sectors with these SE lotags
|
2011-06-22 19:12:47 +00:00
|
|
|
#define FIXSPR_SELOTAGP(k) ((k==0) || (k==6) || (k==14))
|
|
|
|
|
|
|
|
// setup sprites in moving sectors that are to be fixed wrt a certain pivot
|
|
|
|
// position and should not diverge from it due to roundoff error in the future.
|
|
|
|
// has to be after the spawning stuff.
|
|
|
|
static void premap_setup_fixed_sprites(void)
|
|
|
|
{
|
|
|
|
int32_t i, j, pivot;
|
|
|
|
|
|
|
|
for (i=headspritestat[STAT_EFFECTOR]; i>=0; i=nextspritestat[i])
|
|
|
|
{
|
|
|
|
if (FIXSPR_SELOTAGP(sprite[i].lotag))
|
|
|
|
{
|
2011-06-29 19:57:05 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int32_t firstrun = 1;
|
|
|
|
#endif
|
|
|
|
j = headspritesect[sprite[i].sectnum];
|
|
|
|
while (j>=0)
|
2011-06-22 19:12:47 +00:00
|
|
|
{
|
|
|
|
// TRIPBOMB uses t_data[7] for its own purposes. Wouldn't be
|
|
|
|
// too useful with moving sectors anyway
|
|
|
|
if ((FIXSPR_STATNUMP(sprite[j].statnum) && sprite[j].picnum!=TRIPBOMB) ||
|
2011-07-20 22:08:05 +00:00
|
|
|
(sprite[j].picnum==SECTOREFFECTOR && (sprite[j].lotag==49||sprite[j].lotag==50)) ||
|
|
|
|
((sprite[j].statnum==1 || sprite[j].statnum==2) && (ActorType[sprite[j].picnum]&4)))
|
2011-06-22 19:12:47 +00:00
|
|
|
{
|
|
|
|
pivot = i;
|
|
|
|
if (sprite[i].lotag==0)
|
|
|
|
pivot = sprite[i].owner;
|
2011-06-29 19:57:05 +00:00
|
|
|
if (j!=i && j!=pivot && pivot>=0 && pivot<MAXSPRITES)
|
|
|
|
{
|
|
|
|
// let's hope we don't step on anyone's toes here
|
|
|
|
actor[j].t_data[7] = 0x18190000 | pivot; // 'rs' magic + pivot SE sprite index
|
|
|
|
actor[j].t_data[8] = sprite[j].x - sprite[pivot].x;
|
|
|
|
actor[j].t_data[9] = sprite[j].y - sprite[pivot].y;
|
|
|
|
}
|
2011-06-22 19:12:47 +00:00
|
|
|
}
|
2011-06-29 19:57:05 +00:00
|
|
|
|
|
|
|
j = nextspritesect[j];
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
if (j<0 && firstrun)
|
|
|
|
if (sprite[i].lotag==6 || sprite[i].lotag==14)
|
|
|
|
{
|
|
|
|
firstrun = 0;
|
|
|
|
j = actor[i].t_data[9];
|
|
|
|
if (j >= 0)
|
|
|
|
j = headspritesect[j];
|
|
|
|
}
|
|
|
|
#endif
|
2011-06-22 19:12:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
static inline void prelevel(char g)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-08-17 18:52:54 +00:00
|
|
|
int32_t i, nexti, j, startwall, endwall;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t switchpicnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-08-17 18:52:54 +00:00
|
|
|
uint8_t tagbitmap[65536>>3];
|
|
|
|
Bmemset(tagbitmap, 0, sizeof(tagbitmap));
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
clearbufbyte(show2dsector,sizeof(show2dsector),0L);
|
|
|
|
clearbufbyte(show2dwall,sizeof(show2dwall),0L);
|
|
|
|
clearbufbyte(show2dsprite,sizeof(show2dsprite),0L);
|
|
|
|
|
2009-07-04 09:28:21 +00:00
|
|
|
Bmemset(ror_protectedsectors, 0, MAXSECTORS);
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
resetprestat(0,g);
|
2008-11-20 14:06:36 +00:00
|
|
|
g_numClouds = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<numsectors; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
sector[i].extra = 256;
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
switch (sector[i].lotag)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case 20:
|
|
|
|
case 22:
|
|
|
|
if (sector[i].floorz > sector[i].ceilingz)
|
|
|
|
sector[i].lotag |= 32768;
|
|
|
|
continue;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sector[i].ceilingstat&1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (waloff[sector[i].ceilingpicnum] == 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sector[i].ceilingpicnum == LA)
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<5; j++)
|
2006-04-13 20:47:06 +00:00
|
|
|
tloadtile(sector[i].ceilingpicnum+j, 0);
|
|
|
|
}
|
2009-02-19 16:47:54 +00:00
|
|
|
G_SetupBackdrop(sector[i].ceilingpicnum);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
if (sector[i].ceilingpicnum == CLOUDYSKIES && g_numClouds < 127)
|
|
|
|
clouds[g_numClouds++] = i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 06:46:31 +00:00
|
|
|
if (g_player[0].ps->one_parallax_sectnum == -1)
|
|
|
|
g_player[0].ps->one_parallax_sectnum = i;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sector[i].lotag == 32767) //Found a secret room
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-08-27 06:46:31 +00:00
|
|
|
g_player[0].ps->max_secret_rooms++;
|
2006-04-13 20:47:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sector[i].lotag == -1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-08-27 06:46:31 +00:00
|
|
|
g_player[0].ps->exitx = wall[sector[i].wallptr].x;
|
|
|
|
g_player[0].ps->exity = wall[sector[i].wallptr].y;
|
2006-04-13 20:47:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
i = headspritestat[STAT_DEFAULT];
|
2006-11-13 23:12:47 +00:00
|
|
|
while (i >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
nexti = nextspritestat[i];
|
2008-12-13 07:23:13 +00:00
|
|
|
A_ResetVars(i);
|
2008-11-20 14:06:36 +00:00
|
|
|
A_LoadActor(i);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_LOADACTOR, i, -1, -1);
|
2006-11-14 21:35:50 +00:00
|
|
|
if (sprite[i].lotag == -1 && (sprite[i].cstat&16))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2007-08-27 06:46:31 +00:00
|
|
|
g_player[0].ps->exitx = SX;
|
|
|
|
g_player[0].ps->exity = SY;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2012-01-28 14:38:23 +00:00
|
|
|
else switch (DYNAMICTILEMAP(PN))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case GPSPEED__STATIC:
|
|
|
|
sector[SECT].extra = SLT;
|
|
|
|
deletesprite(i);
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case CYCLER__STATIC:
|
2008-11-20 14:06:36 +00:00
|
|
|
if (g_numCyclers >= MAXCYCLERS)
|
2006-11-16 03:02:42 +00:00
|
|
|
{
|
|
|
|
Bsprintf(tempbuf,"\nToo many cycling sectors (%d max).",MAXCYCLERS);
|
2008-11-20 14:06:36 +00:00
|
|
|
G_GameExit(tempbuf);
|
2006-11-16 03:02:42 +00:00
|
|
|
}
|
2008-11-20 14:06:36 +00:00
|
|
|
cyclers[g_numCyclers][0] = SECT;
|
|
|
|
cyclers[g_numCyclers][1] = SLT;
|
|
|
|
cyclers[g_numCyclers][2] = SS;
|
|
|
|
cyclers[g_numCyclers][3] = sector[SECT].floorshade;
|
|
|
|
cyclers[g_numCyclers][4] = SHT;
|
|
|
|
cyclers[g_numCyclers][5] = (SA == 1536);
|
|
|
|
g_numCyclers++;
|
2006-11-16 03:02:42 +00:00
|
|
|
deletesprite(i);
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case SECTOREFFECTOR__STATIC:
|
|
|
|
case ACTIVATOR__STATIC:
|
|
|
|
case TOUCHPLATE__STATIC:
|
|
|
|
case ACTIVATORLOCKED__STATIC:
|
|
|
|
case MUSICANDSFX__STATIC:
|
|
|
|
case LOCATORS__STATIC:
|
|
|
|
case MASTERSWITCH__STATIC:
|
|
|
|
case RESPAWN__STATIC:
|
2009-04-28 05:31:32 +00:00
|
|
|
sprite[i].cstat &= ~(1|256);
|
2006-11-16 03:02:42 +00:00
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
i = nexti;
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i < MAXSPRITES; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (PN == SECTOREFFECTOR && SLT == 14)
|
2006-04-13 20:47:06 +00:00
|
|
|
continue;
|
2008-11-20 14:06:36 +00:00
|
|
|
A_Spawn(-1,i);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i < MAXSPRITES; i++)
|
2006-11-13 23:12:47 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-14 21:35:50 +00:00
|
|
|
if (PN == SECTOREFFECTOR && SLT == 14)
|
2008-11-20 14:06:36 +00:00
|
|
|
A_Spawn(-1,i);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-06-22 19:12:47 +00:00
|
|
|
premap_setup_fixed_sprites();
|
|
|
|
|
2011-08-17 18:52:54 +00:00
|
|
|
for (i=headspritestat[STAT_DEFAULT]; i>=0; i=nextspritestat[i])
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-08-20 11:53:52 +00:00
|
|
|
int32_t ii;
|
|
|
|
#if 0
|
|
|
|
int32_t dx, dy;
|
2011-08-17 18:52:16 +00:00
|
|
|
int16_t sprsec;
|
2011-08-20 11:53:52 +00:00
|
|
|
#endif
|
2011-12-11 13:26:39 +00:00
|
|
|
if (PN <= 0) // oob safety for switch below
|
|
|
|
continue;
|
|
|
|
|
2011-08-17 18:52:16 +00:00
|
|
|
for (ii=0; ii<2; ii++)
|
2012-01-28 14:38:23 +00:00
|
|
|
switch (DYNAMICTILEMAP(PN-1+ii))
|
2006-11-16 03:02:42 +00:00
|
|
|
{
|
2011-08-17 18:52:16 +00:00
|
|
|
case DIPSWITCH__STATIC:
|
|
|
|
case DIPSWITCH2__STATIC:
|
|
|
|
case PULLSWITCH__STATIC:
|
|
|
|
case HANDSWITCH__STATIC:
|
|
|
|
case SLOTDOOR__STATIC:
|
|
|
|
case LIGHTSWITCH__STATIC:
|
|
|
|
case SPACELIGHTSWITCH__STATIC:
|
|
|
|
case SPACEDOORSWITCH__STATIC:
|
|
|
|
case FRANKENSTINESWITCH__STATIC:
|
|
|
|
case LIGHTSWITCH2__STATIC:
|
|
|
|
case POWERSWITCH1__STATIC:
|
|
|
|
case LOCKSWITCH1__STATIC:
|
|
|
|
case POWERSWITCH2__STATIC:
|
2011-08-20 11:53:52 +00:00
|
|
|
#if 0
|
2011-08-17 18:52:16 +00:00
|
|
|
dx = sintable[(sprite[i].ang+512)&2047]>>9;
|
|
|
|
dy = sintable[(sprite[i].ang)&2047]>>9;
|
|
|
|
|
|
|
|
sprsec = sprite[i].sectnum;
|
|
|
|
|
|
|
|
// check if in 'air' (and not inside something 'solid' like
|
|
|
|
// sprite #624 in E4L1):
|
|
|
|
updatesectorz(sprite[i].x, sprite[i].y, sprite[i].z, &sprsec);
|
|
|
|
|
|
|
|
// check 2 (slightly different from 'would generate light?'):
|
|
|
|
if (sprsec >= 0)
|
|
|
|
updatesectorz(sprite[i].x+dx, sprite[i].y+dy, sprite[i].z, &sprsec);
|
|
|
|
if (sprsec < 0)
|
|
|
|
{
|
|
|
|
// dynamic re-check occurs in G_MoveWorld():
|
|
|
|
spriteext[i].flags |= SPREXT_TEMPINVISIBLE;
|
|
|
|
sprite[i].cstat |= 32768;
|
|
|
|
}
|
2011-08-20 11:53:52 +00:00
|
|
|
#endif
|
2011-08-17 18:52:54 +00:00
|
|
|
// invisi-make for both switch states, but the lower code only
|
|
|
|
// for the 'on' state (*)
|
|
|
|
if (ii==0)
|
2006-11-16 03:02:42 +00:00
|
|
|
{
|
2011-08-17 18:52:54 +00:00
|
|
|
j = sprite[i].lotag+32768;
|
|
|
|
tagbitmap[j>>3] |= 1<<(j&7);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2011-08-17 18:52:54 +00:00
|
|
|
|
2011-08-17 18:52:16 +00:00
|
|
|
break;
|
2006-11-16 03:02:42 +00:00
|
|
|
}
|
2011-08-17 18:52:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// initially 'on' SE 12 light (*)
|
|
|
|
for (j=headspritestat[STAT_EFFECTOR]; j>=0; j=nextspritestat[j])
|
|
|
|
{
|
|
|
|
int32_t t = sprite[j].hitag+32768;
|
2011-08-17 18:52:16 +00:00
|
|
|
|
2011-08-17 18:52:54 +00:00
|
|
|
if (sprite[j].lotag == 12 && tagbitmap[t>>3]&(1<<(t&7)))
|
|
|
|
actor[j].t_data[0] = 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-08-17 18:52:54 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_mirrorCount = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
for (i = 0; i < numwalls; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
walltype *wal;
|
|
|
|
wal = &wall[i];
|
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (wal->overpicnum == MIRROR && (wal->cstat&32) != 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
j = wal->nextsector;
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if ((j >= 0) && sector[j].ceilingpicnum != MIRROR)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-01-05 20:48:05 +00:00
|
|
|
if (g_mirrorCount > 63)
|
|
|
|
G_GameExit("\nToo many mirrors (64 max.)");
|
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
sector[j].ceilingpicnum = MIRROR;
|
|
|
|
sector[j].floorpicnum = MIRROR;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_mirrorWall[g_mirrorCount] = i;
|
|
|
|
g_mirrorSector[g_mirrorCount] = j;
|
|
|
|
g_mirrorCount++;
|
2006-04-13 20:47:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
if (g_numAnimWalls >= MAXANIMWALLS)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
Bsprintf(tempbuf,"\nToo many 'anim' walls (%d max).",MAXANIMWALLS);
|
2008-11-20 14:06:36 +00:00
|
|
|
G_GameExit(tempbuf);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
animwall[g_numAnimWalls].tag = 0;
|
|
|
|
animwall[g_numAnimWalls].wallnum = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
switchpicnum = wal->overpicnum;
|
2006-11-15 01:16:55 +00:00
|
|
|
if ((wal->overpicnum > W_FORCEFIELD)&&(wal->overpicnum <= W_FORCEFIELD+2))
|
|
|
|
{
|
2006-04-13 20:47:06 +00:00
|
|
|
switchpicnum = W_FORCEFIELD;
|
|
|
|
}
|
2011-12-09 19:12:15 +00:00
|
|
|
|
|
|
|
if (switchpicnum >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-01-28 14:38:23 +00:00
|
|
|
switch (DYNAMICTILEMAP(switchpicnum))
|
2011-12-09 19:12:15 +00:00
|
|
|
{
|
|
|
|
case FANSHADOW__STATIC:
|
|
|
|
case FANSPRITE__STATIC:
|
|
|
|
wall->cstat |= 65;
|
|
|
|
animwall[g_numAnimWalls].wallnum = i;
|
|
|
|
g_numAnimWalls++;
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-12-09 19:12:15 +00:00
|
|
|
case W_FORCEFIELD__STATIC:
|
|
|
|
if (wal->overpicnum==W_FORCEFIELD__STATIC)
|
|
|
|
for (j=0; j<3; j++)
|
|
|
|
tloadtile(W_FORCEFIELD+j, 0);
|
|
|
|
if (wal->shade > 31)
|
|
|
|
wal->cstat = 0;
|
|
|
|
else wal->cstat |= 85+256;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
|
2011-12-09 19:12:15 +00:00
|
|
|
if (wal->lotag && wal->nextwall >= 0)
|
|
|
|
wall[wal->nextwall].lotag =
|
|
|
|
wal->lotag;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-12-09 19:12:15 +00:00
|
|
|
case BIGFORCE__STATIC:
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-12-09 19:12:15 +00:00
|
|
|
animwall[g_numAnimWalls].wallnum = i;
|
|
|
|
g_numAnimWalls++;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-12-09 19:12:15 +00:00
|
|
|
continue;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wal->extra = -1;
|
|
|
|
|
2012-01-28 14:38:23 +00:00
|
|
|
switch (DYNAMICTILEMAP(wal->picnum))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case WATERTILE2__STATIC:
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<3; j++)
|
2006-11-16 03:02:42 +00:00
|
|
|
tloadtile(wal->picnum+j, 0);
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case TECHLIGHT2__STATIC:
|
|
|
|
case TECHLIGHT4__STATIC:
|
|
|
|
tloadtile(wal->picnum, 0);
|
|
|
|
break;
|
|
|
|
case W_TECHWALL1__STATIC:
|
|
|
|
case W_TECHWALL2__STATIC:
|
|
|
|
case W_TECHWALL3__STATIC:
|
|
|
|
case W_TECHWALL4__STATIC:
|
2008-11-20 14:06:36 +00:00
|
|
|
animwall[g_numAnimWalls].wallnum = i;
|
|
|
|
// animwall[g_numAnimWalls].tag = -1;
|
|
|
|
g_numAnimWalls++;
|
2006-11-16 03:02:42 +00:00
|
|
|
break;
|
|
|
|
case SCREENBREAK6__STATIC:
|
|
|
|
case SCREENBREAK7__STATIC:
|
|
|
|
case SCREENBREAK8__STATIC:
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=SCREENBREAK6; j<SCREENBREAK9; j++)
|
2006-11-16 03:02:42 +00:00
|
|
|
tloadtile(j, 0);
|
2008-11-20 14:06:36 +00:00
|
|
|
animwall[g_numAnimWalls].wallnum = i;
|
|
|
|
animwall[g_numAnimWalls].tag = -1;
|
|
|
|
g_numAnimWalls++;
|
2006-11-16 03:02:42 +00:00
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case FEMPIC1__STATIC:
|
|
|
|
case FEMPIC2__STATIC:
|
|
|
|
case FEMPIC3__STATIC:
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
wal->extra = wal->picnum;
|
2008-11-20 14:06:36 +00:00
|
|
|
animwall[g_numAnimWalls].tag = -1;
|
2006-11-16 03:02:42 +00:00
|
|
|
if (ud.lockout)
|
|
|
|
{
|
|
|
|
if (wal->picnum == FEMPIC1)
|
|
|
|
wal->picnum = BLANKSCREEN;
|
|
|
|
else wal->picnum = SCREENBREAK6;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
animwall[g_numAnimWalls].wallnum = i;
|
|
|
|
animwall[g_numAnimWalls].tag = wal->picnum;
|
|
|
|
g_numAnimWalls++;
|
2006-11-16 03:02:42 +00:00
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-16 03:02:42 +00:00
|
|
|
case SCREENBREAK1__STATIC:
|
|
|
|
case SCREENBREAK2__STATIC:
|
|
|
|
case SCREENBREAK3__STATIC:
|
|
|
|
case SCREENBREAK4__STATIC:
|
|
|
|
case SCREENBREAK5__STATIC:
|
|
|
|
|
|
|
|
case SCREENBREAK9__STATIC:
|
|
|
|
case SCREENBREAK10__STATIC:
|
|
|
|
case SCREENBREAK11__STATIC:
|
|
|
|
case SCREENBREAK12__STATIC:
|
|
|
|
case SCREENBREAK13__STATIC:
|
|
|
|
case SCREENBREAK14__STATIC:
|
|
|
|
case SCREENBREAK15__STATIC:
|
|
|
|
case SCREENBREAK16__STATIC:
|
|
|
|
case SCREENBREAK17__STATIC:
|
|
|
|
case SCREENBREAK18__STATIC:
|
|
|
|
case SCREENBREAK19__STATIC:
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
animwall[g_numAnimWalls].wallnum = i;
|
|
|
|
animwall[g_numAnimWalls].tag = wal->picnum;
|
|
|
|
g_numAnimWalls++;
|
2006-11-16 03:02:42 +00:00
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Invalidate textures in sector behind mirror
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<g_mirrorCount; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
startwall = sector[g_mirrorSector[i]].wallptr;
|
|
|
|
endwall = startwall + sector[g_mirrorSector[i]].wallnum;
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=startwall; j<endwall; j++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
wall[j].picnum = MIRROR;
|
|
|
|
wall[j].overpicnum = MIRROR;
|
2008-11-20 14:06:36 +00:00
|
|
|
if (wall[g_mirrorWall[i]].pal == 4)
|
2008-10-11 11:50:02 +00:00
|
|
|
wall[j].pal = 4;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-20 19:12:24 +00:00
|
|
|
|
|
|
|
#ifdef LUNATIC_ENABLE
|
|
|
|
if (El_IsInitialized(&g_ElState))
|
|
|
|
{
|
|
|
|
i = El_RunOnce(&g_ElState, "test.elua");
|
|
|
|
if (i)
|
|
|
|
OSD_Printf("Error running the test ELua script (code %d)\n", i);
|
|
|
|
else
|
|
|
|
initprintf("ELua test script run ok!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
initprintf("ELua test script: not inited!\n");
|
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2009-10-25 23:25:38 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void G_NewGame(int32_t vn,int32_t ln,int32_t sk)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
DukePlayer_t *p = g_player[0].ps;
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-12-17 21:20:35 +00:00
|
|
|
handleevents();
|
2009-01-09 09:29:17 +00:00
|
|
|
Net_GetPackets();
|
2006-12-17 21:20:35 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
if (g_skillSoundID >= 0 && ud.config.FXDevice >= 0 && ud.config.SoundToggle)
|
2006-12-17 21:20:35 +00:00
|
|
|
{
|
2010-03-02 22:49:26 +00:00
|
|
|
while (S_CheckSoundPlaying(-1, g_skillSoundID))
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
|
|
|
handleevents();
|
2009-01-09 09:29:17 +00:00
|
|
|
Net_GetPackets();
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
}
|
2006-12-18 08:37:12 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_skillSoundID = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
ready2send = 0;
|
|
|
|
|
2010-01-16 23:08:17 +00:00
|
|
|
if (ud.m_recstat != 2 && ud.last_level >= 0 && (g_netServer || ud.multimode > 1) && (ud.coop&GAMETYPE_SCORESHEET))
|
2008-11-20 14:06:36 +00:00
|
|
|
G_BonusScreen(1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-01-16 23:08:17 +00:00
|
|
|
if (ln == 0 && vn == 3 && (!g_netServer && ud.multimode < 2) && ud.lockout == 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
S_PlayMusic(&EnvMusicFilename[1][0],MAXVOLUMES*MAXLEVELS+1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
flushperms();
|
|
|
|
setview(0,0,xdim-1,ydim-1);
|
|
|
|
clearview(0L);
|
|
|
|
nextpage();
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
G_PlayAnim("vol41a.anm",6);
|
2006-04-13 20:47:06 +00:00
|
|
|
clearview(0L);
|
|
|
|
nextpage();
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
G_PlayAnim("vol42a.anm",7);
|
|
|
|
G_PlayAnim("vol43a.anm",9);
|
2006-04-13 20:47:06 +00:00
|
|
|
clearview(0L);
|
|
|
|
nextpage();
|
|
|
|
|
|
|
|
FX_StopAllSounds();
|
|
|
|
}
|
|
|
|
|
2009-04-26 05:57:42 +00:00
|
|
|
g_showShareware = GAMETICSPERSEC*34;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
ud.level_number = ln;
|
|
|
|
ud.volume_number = vn;
|
|
|
|
ud.player_skill = sk;
|
|
|
|
ud.secretlevel = 0;
|
|
|
|
ud.from_bonus = 0;
|
|
|
|
parallaxyscale = 0;
|
|
|
|
|
|
|
|
ud.last_level = -1;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_lastSaveSlot = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
p->zoom = 768;
|
|
|
|
p->gm = 0;
|
|
|
|
|
2006-12-17 21:20:35 +00:00
|
|
|
//AddLog("Newgame");
|
2008-12-13 07:23:13 +00:00
|
|
|
Gv_ResetVars();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
Gv_InitWeaponPointers();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-01-03 19:55:38 +00:00
|
|
|
// PK: Gv_ResetVars() might trip up the system (pointer) gamevars,
|
|
|
|
// e.g. if some earlier-version CON code had been loaded before
|
|
|
|
Gv_RefreshPointers();
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
Gv_ResetSystemDefaults();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<(MAXVOLUMES*MAXLEVELS); i++)
|
2008-11-20 14:06:36 +00:00
|
|
|
if (MapInfo[i].savedstate)
|
2008-07-18 02:46:24 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
Bfree(MapInfo[i].savedstate);
|
|
|
|
MapInfo[i].savedstate = NULL;
|
2008-07-18 02:46:24 +00:00
|
|
|
}
|
|
|
|
|
2006-12-17 21:20:35 +00:00
|
|
|
if (ud.m_coop != 1)
|
|
|
|
{
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=0; i<MAX_WEAPONS; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-12-17 21:20:35 +00:00
|
|
|
if (aplWeaponWorksLike[i][0]==PISTOL_WEAPON)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-12-17 21:20:35 +00:00
|
|
|
p->curr_weapon = i;
|
2010-05-02 23:27:30 +00:00
|
|
|
p->gotweapon |= (1<<i);
|
2009-06-28 20:23:12 +00:00
|
|
|
p->ammo_amount[i] = min(p->max_ammo_amount[i], 48);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-12-17 21:20:35 +00:00
|
|
|
else if (aplWeaponWorksLike[i][0]==KNEE_WEAPON)
|
2010-05-02 23:27:30 +00:00
|
|
|
p->gotweapon |= (1<<i);
|
2006-12-17 21:20:35 +00:00
|
|
|
else if (aplWeaponWorksLike[i][0]==HANDREMOTE_WEAPON)
|
2010-05-02 23:27:30 +00:00
|
|
|
p->gotweapon |= (1<<i);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-12-17 21:20:35 +00:00
|
|
|
p->last_weapon = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-12-18 08:37:12 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
display_mirror = 0;
|
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_NEWGAME, g_player[screenpeek].ps->i, screenpeek, -1);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-12-10 03:15:56 +00:00
|
|
|
static void resetpspritevars(char g)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-10-17 18:42:10 +00:00
|
|
|
int16_t i, j, nexti; //circ;
|
2009-01-09 09:29:17 +00:00
|
|
|
// int32_t firstx,firsty;
|
2006-04-13 20:47:06 +00:00
|
|
|
spritetype *s;
|
2009-07-12 01:55:34 +00:00
|
|
|
uint8_t aimmode[MAXPLAYERS],autoaim[MAXPLAYERS],weaponswitch[MAXPLAYERS];
|
|
|
|
DukeStatus_t tsbar[MAXPLAYERS];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-02-14 23:13:38 +00:00
|
|
|
if (g_player[0].ps->cursectnum >= 0) // < 0 may happen if we start a map in void space (e.g. testing it)
|
|
|
|
{
|
|
|
|
A_InsertSprite(g_player[0].ps->cursectnum,g_player[0].ps->pos.x,g_player[0].ps->pos.y,g_player[0].ps->pos.z,
|
|
|
|
APLAYER,0,0,0,g_player[0].ps->ang,0,0,0,10);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-07-12 01:55:34 +00:00
|
|
|
if (ud.recstat != 2)
|
2012-02-21 19:33:33 +00:00
|
|
|
for (TRAVERSE_CONNECT(i))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-02-21 19:33:33 +00:00
|
|
|
aimmode[i] = g_player[i].ps->aim_mode;
|
|
|
|
autoaim[i] = g_player[i].ps->auto_aim;
|
|
|
|
weaponswitch[i] = g_player[i].ps->weaponswitch;
|
|
|
|
if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0)
|
|
|
|
{
|
|
|
|
for (j=0; j<MAX_WEAPONS; j++)
|
|
|
|
tsbar[i].ammo_amount[j] = g_player[i].ps->ammo_amount[j];
|
2010-01-23 22:12:02 +00:00
|
|
|
|
2012-02-21 19:33:33 +00:00
|
|
|
tsbar[i].gotweapon = g_player[i].ps->gotweapon;
|
|
|
|
Bmemcpy(tsbar[i].inv_amount, g_player[i].ps->inv_amount, sizeof(tsbar[i].inv_amount));
|
|
|
|
tsbar[i].curr_weapon = g_player[i].ps->curr_weapon;
|
|
|
|
tsbar[i].inven_icon = g_player[i].ps->inven_icon;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
P_ResetStatus(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-02-21 19:33:33 +00:00
|
|
|
for (TRAVERSE_CONNECT(i))
|
|
|
|
if (i) Bmemcpy(g_player[i].ps,g_player[0].ps,sizeof(DukePlayer_t));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-03-04 19:52:57 +00:00
|
|
|
if (ud.recstat != 2)
|
2012-02-21 19:33:33 +00:00
|
|
|
for (TRAVERSE_CONNECT(i))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-02-21 19:33:33 +00:00
|
|
|
g_player[i].ps->aim_mode = aimmode[i];
|
|
|
|
g_player[i].ps->auto_aim = autoaim[i];
|
|
|
|
g_player[i].ps->weaponswitch = weaponswitch[i];
|
|
|
|
if ((g_netServer || ud.multimode > 1) && (GametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0)
|
|
|
|
{
|
|
|
|
for (j=0; j<MAX_WEAPONS; j++)
|
|
|
|
g_player[i].ps->ammo_amount[j] = tsbar[i].ammo_amount[j];
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2012-02-21 19:33:33 +00:00
|
|
|
g_player[i].ps->gotweapon = tsbar[i].gotweapon;
|
|
|
|
g_player[i].ps->curr_weapon = tsbar[i].curr_weapon;
|
|
|
|
g_player[i].ps->inven_icon = tsbar[i].inven_icon;
|
|
|
|
Bmemcpy(g_player[i].ps->inv_amount, tsbar[i].inv_amount, sizeof(tsbar[i].inv_amount));
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_numPlayerSprites = 0;
|
2011-10-17 18:42:10 +00:00
|
|
|
// circ = 2048/ud.multimode;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_whichPalForPlayer = 9;
|
2009-12-05 09:22:43 +00:00
|
|
|
j = 0;
|
2008-11-20 14:06:36 +00:00
|
|
|
i = headspritestat[STAT_PLAYER];
|
2006-11-13 23:12:47 +00:00
|
|
|
while (i >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
nexti = nextspritestat[i];
|
|
|
|
s = &sprite[i];
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
if (g_numPlayerSprites == MAXPLAYERS)
|
|
|
|
G_GameExit("\nToo many player sprites (max 16.)");
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].ox = s->x;
|
|
|
|
g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].oy = s->y;
|
|
|
|
g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].oz = s->z;
|
|
|
|
g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].oa = s->ang;
|
|
|
|
g_playerSpawnPoints[(uint8_t)g_numPlayerSprites].os = s->sectnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_numPlayerSprites++;
|
2009-12-05 09:22:43 +00:00
|
|
|
|
|
|
|
if (j < MAXPLAYERS)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
s->owner = i;
|
|
|
|
s->shade = 0;
|
|
|
|
s->xrepeat = 42;
|
|
|
|
s->yrepeat = 36;
|
2009-12-05 09:22:43 +00:00
|
|
|
s->cstat = j < numplayers ? 1+256 : 32768;
|
2006-04-13 20:47:06 +00:00
|
|
|
s->xoffset = 0;
|
|
|
|
s->clipdist = 64;
|
|
|
|
|
2009-12-05 09:22:43 +00:00
|
|
|
// if (j < playerswhenstarted)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-12-05 09:22:43 +00:00
|
|
|
if ((g&MODE_EOL) != MODE_EOL || g_player[j].ps->last_extra == 0)
|
|
|
|
{
|
|
|
|
g_player[j].ps->last_extra = g_player[j].ps->max_player_health;
|
|
|
|
s->extra = g_player[j].ps->max_player_health;
|
|
|
|
g_player[j].ps->runspeed = g_playerFriction;
|
|
|
|
}
|
|
|
|
else s->extra = g_player[j].ps->last_extra;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-12-05 09:22:43 +00:00
|
|
|
s->yvel = j;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-01-16 23:08:17 +00:00
|
|
|
if (!g_player[j].pcolor && (g_netServer || ud.multimode > 1) && !(GametypeFlags[ud.coop] & GAMETYPE_TDM))
|
2006-04-18 06:01:16 +00:00
|
|
|
{
|
2009-12-05 09:22:43 +00:00
|
|
|
if (s->pal == 0)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2009-12-05 09:22:43 +00:00
|
|
|
int32_t k = 0;
|
|
|
|
|
|
|
|
for (; k<ud.multimode; k++)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2009-12-05 09:22:43 +00:00
|
|
|
if (g_whichPalForPlayer == g_player[k].ps->palookup)
|
|
|
|
{
|
|
|
|
g_whichPalForPlayer++;
|
|
|
|
if (g_whichPalForPlayer >= 17)
|
|
|
|
g_whichPalForPlayer = 9;
|
|
|
|
k=0;
|
|
|
|
}
|
2006-04-18 16:30:15 +00:00
|
|
|
}
|
2009-12-05 09:22:43 +00:00
|
|
|
g_player[j].pcolor = s->pal = g_player[j].ps->palookup = g_whichPalForPlayer++;
|
|
|
|
if (g_whichPalForPlayer >= 17)
|
|
|
|
g_whichPalForPlayer = 9;
|
2006-04-18 16:30:15 +00:00
|
|
|
}
|
2009-12-05 09:22:43 +00:00
|
|
|
else g_player[j].pcolor = g_player[j].ps->palookup = s->pal;
|
2006-04-18 06:01:16 +00:00
|
|
|
}
|
2009-12-05 09:22:43 +00:00
|
|
|
else
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2009-12-05 09:22:43 +00:00
|
|
|
int32_t k = g_player[j].pcolor;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-12-05 09:22:43 +00:00
|
|
|
if (GametypeFlags[ud.coop] & GAMETYPE_TDM)
|
|
|
|
{
|
|
|
|
k = G_GetTeamPalette(g_player[j].pteam);
|
|
|
|
g_player[j].ps->team = g_player[j].pteam;
|
|
|
|
}
|
|
|
|
s->pal = g_player[j].ps->palookup = k;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-12-05 09:22:43 +00:00
|
|
|
g_player[j].ps->i = i;
|
|
|
|
g_player[j].ps->frag_ps = j;
|
2010-05-02 23:27:30 +00:00
|
|
|
actor[i].owner = i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
actor[i].bposx = g_player[j].ps->bobposx = g_player[j].ps->opos.x = g_player[j].ps->pos.x = s->x;
|
|
|
|
actor[i].bposy = g_player[j].ps->bobposy = g_player[j].ps->opos.y = g_player[j].ps->pos.y = s->y;
|
|
|
|
actor[i].bposz = g_player[j].ps->opos.z = g_player[j].ps->pos.z = s->z;
|
2009-12-05 09:22:43 +00:00
|
|
|
g_player[j].ps->oang = g_player[j].ps->ang = s->ang;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-12-05 09:22:43 +00:00
|
|
|
updatesector(s->x,s->y,&g_player[j].ps->cursectnum);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-12-05 09:22:43 +00:00
|
|
|
j++;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
else deletesprite(i);
|
|
|
|
i = nexti;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-10 21:53:33 +00:00
|
|
|
static inline void clearfrags(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-12-25 15:32:14 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-12-25 15:32:14 +00:00
|
|
|
for (i=0; i<ud.multimode; i++)
|
2007-08-27 06:46:31 +00:00
|
|
|
{
|
2011-12-25 15:32:14 +00:00
|
|
|
playerdata_t *p = &g_player[i];
|
|
|
|
|
|
|
|
p->ps->frag = p->ps->fraggedself = 0;
|
|
|
|
|
2011-12-25 15:33:37 +00:00
|
|
|
if (i == 0)
|
|
|
|
continue;
|
2011-12-25 15:32:14 +00:00
|
|
|
|
|
|
|
Bmemset(p->frags, 0, sizeof(g_player[i].frags));
|
|
|
|
Bmemset(p->wchoice, 0, sizeof(g_player[i].wchoice));
|
|
|
|
p->vote = p->gotvote = p->pingcnt = p->playerquitflag = 0;
|
2007-08-27 06:46:31 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void G_ResetTimers(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
|
|
|
vel = svel = angvel = horiz = 0;
|
|
|
|
|
2011-12-25 15:32:14 +00:00
|
|
|
totalclock = 0;
|
|
|
|
cloudtotalclock = 0;
|
|
|
|
ototalclock = 0;
|
|
|
|
lockclock = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
ready2send = 1;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_levelTextTime = 85;
|
|
|
|
g_moveThingsCount = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 21:50:19 +00:00
|
|
|
void G_ClearFIFO(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2011-02-25 21:50:19 +00:00
|
|
|
int32_t i = MAXPLAYERS-1;
|
|
|
|
|
|
|
|
g_emuJumpTics = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
|
2011-02-25 21:50:19 +00:00
|
|
|
Bmemset(&avg, 0, sizeof(input_t));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-08-06 11:50:34 +00:00
|
|
|
clearbufbyte(&loc,sizeof(input_t),0L);
|
|
|
|
clearbufbyte(&inputfifo,sizeof(input_t)*MOVEFIFOSIZ*MAXPLAYERS,0L);
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2011-02-25 21:50:19 +00:00
|
|
|
for (; i >= 0; i--)
|
2007-08-27 06:46:31 +00:00
|
|
|
{
|
|
|
|
if (g_player[i].sync != NULL)
|
2011-02-25 21:50:19 +00:00
|
|
|
Bmemset(g_player[i].sync, 0, sizeof(input_t));
|
|
|
|
g_player[i].vote = g_player[i].gotvote = 0;
|
2007-08-27 06:46:31 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2011-02-25 21:50:19 +00:00
|
|
|
int32_t G_FindLevelByFile(const char *fn)
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
2009-06-28 20:23:12 +00:00
|
|
|
int32_t volume, level;
|
|
|
|
|
|
|
|
for (volume=0; volume<MAXVOLUMES; volume++)
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
2009-06-28 20:23:12 +00:00
|
|
|
for (level=0; level<MAXLEVELS; level++)
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
2009-06-28 20:23:12 +00:00
|
|
|
if (MapInfo[(volume*MAXLEVELS)+level].filename != NULL)
|
|
|
|
if (!Bstrcasecmp(fn, MapInfo[(volume*MAXLEVELS)+level].filename))
|
|
|
|
return ((volume * MAXLEVELS) + level);
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-28 06:32:58 +00:00
|
|
|
return MAXLEVELS*MAXVOLUMES;
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
|
|
|
|
2011-08-17 18:52:54 +00:00
|
|
|
void G_FadeLoad(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_t step, int32_t ticwait)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
2011-08-17 18:52:54 +00:00
|
|
|
int32_t m = (step < 0) ? -1 : 1;
|
|
|
|
|
|
|
|
int32_t nexttic = totalclock;
|
|
|
|
|
|
|
|
for (; m*start <= m*end; start += step)
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
2011-08-17 18:52:54 +00:00
|
|
|
while (totalclock < nexttic)
|
|
|
|
sampletimer();
|
|
|
|
nexttic += ticwait;
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2011-08-17 18:52:54 +00:00
|
|
|
if (KB_KeyPressed(sc_Space))
|
2010-05-02 23:27:30 +00:00
|
|
|
{
|
2011-08-17 18:52:54 +00:00
|
|
|
KB_ClearKeyDown(sc_Space);
|
|
|
|
return;
|
2010-05-02 23:27:30 +00:00
|
|
|
}
|
2011-08-17 18:52:54 +00:00
|
|
|
|
|
|
|
G_FadePalette(r,g,b,start|128);
|
|
|
|
flushperms();
|
|
|
|
G_DoLoadScreen(" ", -1);
|
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
}
|
|
|
|
|
2011-01-09 18:53:06 +00:00
|
|
|
|
|
|
|
static void G_LoadMapHack(char *outbuf, const char *filename)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if (filename != NULL)
|
|
|
|
Bstrcpy(outbuf, filename);
|
2011-02-25 21:50:19 +00:00
|
|
|
|
2011-01-09 18:53:06 +00:00
|
|
|
p = Bstrrchr(outbuf,'.');
|
2011-02-25 21:50:19 +00:00
|
|
|
if (!p)
|
|
|
|
Bstrcat(outbuf,".mhk");
|
2011-01-09 18:53:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
p[1]='m';
|
|
|
|
p[2]='h';
|
|
|
|
p[3]='k';
|
|
|
|
p[4]=0;
|
|
|
|
}
|
2011-02-25 21:50:19 +00:00
|
|
|
|
|
|
|
if (!loadmaphack(outbuf))
|
|
|
|
initprintf("Loaded map hack file '%s'\n",outbuf);
|
2011-01-09 18:53:06 +00:00
|
|
|
}
|
|
|
|
|
2011-12-25 15:32:30 +00:00
|
|
|
static void realloc_and_copy_musicfn(int32_t level_number, const char *levnamebuf, int32_t altp)
|
|
|
|
{
|
|
|
|
char **musicfn = altp ? &MapInfo[level_number].alt_musicfn : &MapInfo[level_number].musicfn;
|
|
|
|
int32_t dastrlen = Bstrlen(levnamebuf);
|
|
|
|
|
|
|
|
*musicfn = Brealloc(*musicfn, dastrlen+1);
|
|
|
|
Bstrcpy(*musicfn, levnamebuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
// levnamebuf should have at least size BMAX_PATH
|
|
|
|
void G_SetupFilenameBasedMusic(char *levnamebuf, const char *boardfilename, int32_t level_number)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
int32_t fil;
|
|
|
|
|
|
|
|
Bstrcpy(levnamebuf, boardfilename);
|
|
|
|
|
|
|
|
// usermap music based on map filename
|
|
|
|
Bcorrectfilename(levnamebuf,0);
|
|
|
|
|
|
|
|
p = Bstrrchr(levnamebuf,'.');
|
|
|
|
if (!p)
|
|
|
|
{
|
|
|
|
p = levnamebuf + Bstrlen(levnamebuf);
|
|
|
|
p[0] = '.';
|
|
|
|
}
|
|
|
|
|
|
|
|
Bmemcpy(p+1, "ogg", 4);
|
|
|
|
fil = kopen4loadfrommod(levnamebuf,0);
|
|
|
|
|
|
|
|
if (fil > -1)
|
|
|
|
{
|
|
|
|
kclose(fil);
|
|
|
|
|
|
|
|
realloc_and_copy_musicfn(level_number, levnamebuf, 1);
|
|
|
|
}
|
|
|
|
else if (MapInfo[level_number].alt_musicfn != NULL)
|
|
|
|
{
|
|
|
|
Bfree(MapInfo[level_number].alt_musicfn);
|
|
|
|
MapInfo[level_number].alt_musicfn = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bmemcpy(p+1, "mid", 4);
|
|
|
|
fil = kopen4loadfrommod(levnamebuf,0);
|
|
|
|
|
|
|
|
if (fil == -1)
|
|
|
|
Bstrcpy(levnamebuf, "dethtoll.mid");
|
|
|
|
else kclose(fil);
|
|
|
|
|
|
|
|
realloc_and_copy_musicfn(level_number, levnamebuf, 0);
|
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t G_EnterLevel(int32_t g)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t i;
|
2006-04-13 20:47:06 +00:00
|
|
|
char levname[BMAX_PATH];
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
// flushpackets();
|
|
|
|
// waitforeverybody();
|
2007-08-27 06:46:31 +00:00
|
|
|
vote_map = vote_episode = voting = -1;
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if ((g&MODE_DEMO) != MODE_DEMO) ud.recstat = ud.m_recstat;
|
2006-04-13 20:47:06 +00:00
|
|
|
ud.respawn_monsters = ud.m_respawn_monsters;
|
|
|
|
ud.respawn_items = ud.m_respawn_items;
|
|
|
|
ud.respawn_inventory = ud.m_respawn_inventory;
|
|
|
|
ud.monsters_off = ud.m_monsters_off;
|
|
|
|
ud.coop = ud.m_coop;
|
|
|
|
ud.marker = ud.m_marker;
|
|
|
|
ud.ffire = ud.m_ffire;
|
2006-05-04 03:14:49 +00:00
|
|
|
ud.noexits = ud.m_noexits;
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if ((g&MODE_DEMO) == 0 && ud.recstat == 2)
|
2006-04-13 20:47:06 +00:00
|
|
|
ud.recstat = 0;
|
|
|
|
|
2011-02-25 21:50:19 +00:00
|
|
|
if (g_networkMode != NET_DEDICATED_SERVER)
|
|
|
|
{
|
|
|
|
FX_StopAllSounds();
|
|
|
|
S_ClearSoundLocks();
|
|
|
|
FX_SetReverb(0);
|
|
|
|
setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-12-09 23:41:43 +00:00
|
|
|
if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0)
|
|
|
|
{
|
2009-06-28 20:23:12 +00:00
|
|
|
int32_t volume, level;
|
2006-12-10 06:49:01 +00:00
|
|
|
|
2006-12-12 07:25:01 +00:00
|
|
|
Bcorrectfilename(boardfilename,0);
|
|
|
|
|
2011-02-25 21:50:19 +00:00
|
|
|
volume = level = G_FindLevelByFile(boardfilename);
|
2006-12-10 06:49:01 +00:00
|
|
|
|
2009-07-28 06:32:58 +00:00
|
|
|
if (level != MAXLEVELS*MAXVOLUMES)
|
2006-12-09 23:41:43 +00:00
|
|
|
{
|
2009-06-28 20:23:12 +00:00
|
|
|
level &= MAXLEVELS-1;
|
|
|
|
volume = (volume - level) / MAXLEVELS;
|
|
|
|
|
2006-12-09 23:41:43 +00:00
|
|
|
ud.level_number = ud.m_level_number = level;
|
|
|
|
ud.volume_number = ud.m_volume_number = volume;
|
|
|
|
boardfilename[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
if (MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].name == NULL || MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename == NULL)
|
2006-12-04 22:22:07 +00:00
|
|
|
{
|
2006-12-05 21:22:19 +00:00
|
|
|
if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0)
|
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename == NULL)
|
2009-01-09 09:29:17 +00:00
|
|
|
MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename = Bcalloc(BMAX_PATH,sizeof(uint8_t));
|
2008-11-20 14:06:36 +00:00
|
|
|
if (MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].name == NULL)
|
2006-12-05 21:22:19 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].name = Bcalloc(16,sizeof(uint8_t));
|
2008-11-20 14:06:36 +00:00
|
|
|
Bsprintf(MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].name,"USER MAP");
|
2006-12-05 21:22:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-07-18 13:18:12 +00:00
|
|
|
OSD_Printf(OSDTEXT_RED "Map E%dL%d not defined!\n",ud.volume_number+1,ud.level_number+1);
|
2006-12-05 21:22:19 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2006-12-04 22:22:07 +00:00
|
|
|
}
|
|
|
|
|
2010-01-24 23:33:17 +00:00
|
|
|
i = ud.screen_size;
|
|
|
|
ud.screen_size = 0;
|
2009-10-25 23:25:38 +00:00
|
|
|
|
2011-01-09 18:53:06 +00:00
|
|
|
G_DoLoadScreen("Loading map . . .", -1);
|
2010-01-24 23:33:17 +00:00
|
|
|
G_UpdateScreenArea();
|
2011-01-09 18:53:06 +00:00
|
|
|
|
2010-01-24 23:33:17 +00:00
|
|
|
ud.screen_size = i;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-12-04 22:22:07 +00:00
|
|
|
if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0)
|
|
|
|
{
|
|
|
|
Bstrcpy(levname, boardfilename);
|
2010-01-16 23:08:17 +00:00
|
|
|
Bsprintf(apptitle,"%s - %s - " APPNAME,levname,g_gameNamePtr);
|
2006-12-04 22:22:07 +00:00
|
|
|
}
|
2010-01-16 23:08:17 +00:00
|
|
|
else Bsprintf(apptitle,"%s - %s - " APPNAME,MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].name,g_gameNamePtr);
|
2006-12-05 21:22:19 +00:00
|
|
|
|
2008-07-22 09:05:34 +00:00
|
|
|
Bstrcpy(tempbuf,apptitle);
|
2006-12-05 21:22:19 +00:00
|
|
|
wm_setapptitle(tempbuf);
|
2011-01-09 18:53:06 +00:00
|
|
|
|
2006-11-15 01:16:55 +00:00
|
|
|
if (!VOLUMEONE)
|
|
|
|
{
|
2006-11-14 21:35:50 +00:00
|
|
|
if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2010-05-02 23:27:30 +00:00
|
|
|
if (loadboard(boardfilename,0,&g_player[0].ps->pos.x, &g_player[0].ps->pos.y,
|
2010-08-02 08:13:51 +00:00
|
|
|
&g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-07-27 01:22:17 +00:00
|
|
|
OSD_Printf(OSD_ERROR "Map '%s' not found!\n",boardfilename);
|
2008-11-20 14:06:36 +00:00
|
|
|
//G_GameExit(tempbuf);
|
2006-04-13 20:47:06 +00:00
|
|
|
return 1;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2006-12-17 21:20:35 +00:00
|
|
|
|
2011-12-25 15:32:30 +00:00
|
|
|
G_LoadMapHack(levname, boardfilename);
|
2008-10-31 10:08:51 +00:00
|
|
|
|
2011-12-25 15:32:30 +00:00
|
|
|
G_SetupFilenameBasedMusic(levname, boardfilename, ud.m_level_number);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
else if (loadboard(MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename,0,&g_player[0].ps->pos.x,
|
2010-08-02 08:13:51 +00:00
|
|
|
&g_player[0].ps->pos.y, &g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
OSD_Printf(OSD_ERROR "Map %s not found!\n",MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename);
|
|
|
|
//G_GameExit(tempbuf);
|
2006-04-13 20:47:06 +00:00
|
|
|
return 1;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-09 18:53:06 +00:00
|
|
|
G_LoadMapHack(levname, MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-17 18:52:54 +00:00
|
|
|
i = Bstrlen(MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename);
|
|
|
|
Bmemcpy(levname, MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename, i);
|
|
|
|
levname[i] = 255; // leads to flags=1 for kopen4load
|
2007-02-11 00:49:03 +00:00
|
|
|
levname[i+1] = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
if (loadboard(levname,1,&g_player[0].ps->pos.x, &g_player[0].ps->pos.y,
|
2010-08-02 08:13:51 +00:00
|
|
|
&g_player[0].ps->pos.z, &g_player[0].ps->ang,&g_player[0].ps->cursectnum) == -1)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
OSD_Printf(OSD_ERROR "Map '%s' not found!\n",MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].filename);
|
|
|
|
//G_GameExit(tempbuf);
|
2006-04-13 20:47:06 +00:00
|
|
|
return 1;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-09 18:53:06 +00:00
|
|
|
G_LoadMapHack(levname, NULL);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-24 23:33:17 +00:00
|
|
|
g_precacheCount = 0;
|
2011-08-17 18:52:54 +00:00
|
|
|
Bmemset(gotpic, 0, sizeof(gotpic));
|
|
|
|
Bmemset(precachehightile, 0, sizeof(precachehightile));
|
2010-01-24 23:33:17 +00:00
|
|
|
|
2010-05-02 23:27:30 +00:00
|
|
|
//clearbufbyte(Actor,sizeof(Actor),0l); // JBF 20040531: yes? no?
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
prelevel(g);
|
|
|
|
|
|
|
|
allignwarpelevators();
|
|
|
|
resetpspritevars(g);
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
// automapping = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2011-08-17 18:52:54 +00:00
|
|
|
G_FadeLoad(0,0,0, 63,0, -7, 4);
|
2010-01-24 23:33:17 +00:00
|
|
|
G_CacheMapData();
|
2011-08-17 18:52:54 +00:00
|
|
|
G_FadeLoad(0,0,0, 0,63, 7, 4);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2006-11-13 23:12:47 +00:00
|
|
|
if (ud.recstat != 2)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
g_musicIndex = (ud.volume_number*MAXLEVELS) + ud.level_number;
|
2009-01-09 09:29:17 +00:00
|
|
|
if (MapInfo[(uint8_t)g_musicIndex].musicfn != NULL)
|
|
|
|
S_PlayMusic(&MapInfo[(uint8_t)g_musicIndex].musicfn[0],g_musicIndex);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2010-07-22 20:29:09 +00:00
|
|
|
if (g & (MODE_GAME|MODE_EOL))
|
2009-06-24 08:20:10 +00:00
|
|
|
{
|
2012-02-21 19:33:33 +00:00
|
|
|
for (TRAVERSE_CONNECT(i))
|
|
|
|
g_player[i].ps->gm = MODE_GAME;
|
2009-06-24 08:20:10 +00:00
|
|
|
}
|
2010-07-22 20:29:09 +00:00
|
|
|
else if (g & MODE_RESTART)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-13 23:12:47 +00:00
|
|
|
if (ud.recstat == 2)
|
2007-08-27 06:46:31 +00:00
|
|
|
g_player[myconnectindex].ps->gm = MODE_DEMO;
|
|
|
|
else g_player[myconnectindex].ps->gm = MODE_GAME;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2006-11-14 21:35:50 +00:00
|
|
|
if ((ud.recstat == 1) && (g&MODE_RESTART) != MODE_RESTART)
|
2008-11-20 14:06:36 +00:00
|
|
|
G_OpenDemoWrite();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-07-22 20:29:09 +00:00
|
|
|
if (VOLUMEONE && ud.level_number == 0 && ud.recstat != 2)
|
2011-02-25 21:50:19 +00:00
|
|
|
P_DoQuote(QUOTE_F1HELP,g_player[myconnectindex].ps);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-02-21 19:33:33 +00:00
|
|
|
for (TRAVERSE_CONNECT(i))
|
|
|
|
switch (DYNAMICTILEMAP(sector[sprite[g_player[i].ps->i].sectnum].floorpicnum))
|
|
|
|
{
|
|
|
|
case HURTRAIL__STATIC:
|
|
|
|
case FLOORSLIME__STATIC:
|
|
|
|
case FLOORPLASMA__STATIC:
|
|
|
|
P_ResetWeapons(i);
|
|
|
|
P_ResetInventory(i);
|
|
|
|
g_player[i].ps->gotweapon &= ~(1<<PISTOL_WEAPON);
|
|
|
|
g_player[i].ps->ammo_amount[PISTOL_WEAPON] = 0;
|
|
|
|
g_player[i].ps->curr_weapon = KNEE_WEAPON;
|
|
|
|
g_player[i].ps->kickback_pic = 0;
|
|
|
|
break;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
//PREMAP.C - replace near the my's at the end of the file
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
Net_ResetPrediction();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 06:46:31 +00:00
|
|
|
//g_player[myconnectindex].ps->palette = palette;
|
2008-11-20 14:06:36 +00:00
|
|
|
//G_FadePalette(0,0,0,0);
|
2011-01-17 03:49:34 +00:00
|
|
|
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0); // JBF 20040308
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-01-24 23:33:17 +00:00
|
|
|
P_UpdateScreenPal(g_player[myconnectindex].ps);
|
|
|
|
flushperms();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
everyothertime = 0;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_globalRandom = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
ud.last_level = ud.level_number+1;
|
|
|
|
|
2011-02-25 21:50:19 +00:00
|
|
|
G_ClearFIFO();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (i=g_numInterpolations-1; i>=0; i--) bakipos[i] = *curipos[i];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-02-02 17:34:16 +00:00
|
|
|
g_restorePalette = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2009-12-05 09:22:43 +00:00
|
|
|
// mmulti_flushpackets();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2010-01-24 23:33:17 +00:00
|
|
|
G_FadePalette(0,0,0,0);
|
|
|
|
G_UpdateScreenArea();
|
|
|
|
clearview(0L);
|
|
|
|
G_DrawBackground();
|
|
|
|
G_DrawRooms(myconnectindex,65536);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2007-08-27 06:46:31 +00:00
|
|
|
g_player[myconnectindex].ps->over_shoulder_on = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
clearfrags();
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
G_ResetTimers(); // Here we go
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
//Bsprintf(g_szBuf,"G_EnterLevel L=%d V=%d",ud.level_number, ud.volume_number);
|
2006-04-13 20:47:06 +00:00
|
|
|
//AddLog(g_szBuf);
|
|
|
|
// variables are set by pointer...
|
2006-10-19 00:45:36 +00:00
|
|
|
|
2008-09-15 02:47:02 +00:00
|
|
|
Bmemcpy(¤tboardfilename[0],&boardfilename[0],BMAX_PATH);
|
2010-05-02 23:27:30 +00:00
|
|
|
VM_OnEvent(EVENT_ENTERLEVEL, -1, -1, -1);
|
|
|
|
OSD_Printf(OSDTEXT_YELLOW "E%dL%d: %s\n",ud.volume_number+1,ud.level_number+1,
|
2010-08-02 08:13:51 +00:00
|
|
|
MapInfo[(ud.volume_number*MAXLEVELS)+ud.level_number].name);
|
2011-04-07 01:16:29 +00:00
|
|
|
|
|
|
|
Net_WaitForServer();
|
2006-04-13 20:47:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2008-07-18 02:46:24 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void G_FreeMapState(int32_t mapnum)
|
2008-07-18 02:46:24 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t j;
|
2008-07-18 02:46:24 +00:00
|
|
|
|
2009-02-19 16:47:54 +00:00
|
|
|
for (j=0; j<g_gameVarCount; j++)
|
2008-07-18 02:46:24 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (aGameVars[j].dwFlags & GAMEVAR_NORESET) continue;
|
|
|
|
if (aGameVars[j].dwFlags & GAMEVAR_PERPLAYER)
|
2008-07-18 02:46:24 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (MapInfo[mapnum].savedstate->vars[j])
|
|
|
|
Bfree(MapInfo[mapnum].savedstate->vars[j]);
|
2008-07-18 02:46:24 +00:00
|
|
|
}
|
2008-11-20 14:06:36 +00:00
|
|
|
else if (aGameVars[j].dwFlags & GAMEVAR_PERACTOR)
|
2008-07-18 02:46:24 +00:00
|
|
|
{
|
2008-11-20 14:06:36 +00:00
|
|
|
if (MapInfo[mapnum].savedstate->vars[j])
|
|
|
|
Bfree(MapInfo[mapnum].savedstate->vars[j]);
|
2008-07-18 02:46:24 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-20 14:06:36 +00:00
|
|
|
Bfree(MapInfo[mapnum].savedstate);
|
|
|
|
MapInfo[mapnum].savedstate = NULL;
|
2008-08-09 19:59:41 +00:00
|
|
|
}
|