2006-04-13 20:47:06 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
2016-02-07 02:38:03 +00:00
|
|
|
Copyright (C) 2016 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
|
2014-07-20 08:55:56 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2006-04-13 20:47:06 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "duke3d.h"
|
2010-08-02 08:13:51 +00:00
|
|
|
#include "anim.h"
|
|
|
|
#include "menus.h"
|
2010-08-02 08:19:28 +00:00
|
|
|
#include "demo.h"
|
2017-12-18 11:24:53 +00:00
|
|
|
#include "savegame.h"
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-06-03 15:45:59 +00:00
|
|
|
#ifdef LUNATIC
|
2012-11-10 20:59:00 +00:00
|
|
|
# include "lunatic_game.h"
|
2011-09-20 19:12:24 +00:00
|
|
|
#endif
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
static int32_t g_whichPalForPlayer = 9;
|
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
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t g_levelTextTime;
|
2008-07-22 09:05:34 +00:00
|
|
|
|
2012-11-17 19:46:37 +00:00
|
|
|
static void flag_precache(int32_t tile, int32_t type)
|
|
|
|
{
|
|
|
|
if (!(gotpic[tile>>3] & pow2char[tile&7]))
|
|
|
|
g_precacheCount++;
|
|
|
|
gotpic[tile>>3] |= pow2char[tile&7];
|
|
|
|
precachehightile[type][tile>>3] |= pow2char[tile&7];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-11-17 19:46:37 +00:00
|
|
|
int32_t i,j;
|
|
|
|
|
|
|
|
if ((picanm[tilenume].sf&PICANM_ANIMTYPE_MASK)==PICANM_ANIMTYPE_BACK)
|
2006-12-17 21:20:35 +00:00
|
|
|
{
|
2012-11-17 19:46:37 +00:00
|
|
|
i = tilenume - picanm[tilenume].num;
|
|
|
|
j = tilenume;
|
2006-12-17 21:20:35 +00:00
|
|
|
}
|
2012-11-17 19:46:37 +00:00
|
|
|
else
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2012-11-17 19:46:37 +00:00
|
|
|
i = tilenume;
|
|
|
|
j = tilenume + picanm[tilenume].num;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2012-11-17 19:46:37 +00:00
|
|
|
|
|
|
|
for (; i<=j; i++)
|
|
|
|
flag_precache(i, type);
|
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
|
|
|
|
2016-08-27 01:40:06 +00:00
|
|
|
if (ud.monsters_off && A_CheckEnemySprite(&sprite[i])) return;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
maxc = 1;
|
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
for (j = PN(i); j <= g_tile[PN(i)].cacherange; j++)
|
2014-02-02 10:50:40 +00:00
|
|
|
tloadtile(j,1);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
switch (DYNAMICTILEMAP(PN(i)))
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
for (j = PN(i); j < (PN(i)+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
|
|
|
{
|
2014-02-22 19:38:52 +00:00
|
|
|
if (g_tile[i].flags & SFLAG_PROJECTILE)
|
2006-04-13 20:47:06 +00:00
|
|
|
tloadtile(i,1);
|
2012-10-30 15:54:35 +00:00
|
|
|
|
2014-02-22 19:38:52 +00:00
|
|
|
if (A_CheckSpriteTileFlags(i, SFLAG_CACHE))
|
2012-11-15 14:28:00 +00:00
|
|
|
for (j = i; j <= g_tile[i].cacherange; 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);
|
2013-03-25 04:31:09 +00:00
|
|
|
for (i=BIGALPHANUM-11; i<BIGALPHANUM+82; i++) tloadtile(i,1);
|
|
|
|
for (i=MINIFONT; i<MINIFONT+93; 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
|
|
|
}
|
|
|
|
|
2012-07-01 22:11:33 +00:00
|
|
|
static void G_DoLoadScreen(const 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)
|
|
|
|
{
|
2017-12-02 09:24:55 +00:00
|
|
|
j = VM_OnEventWithReturn(EVENT_GETLOADTILE, g_player[screenpeek].ps->i, screenpeek, LOADSCREEN);
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2011-12-28 20:35:23 +00:00
|
|
|
//g_player[myconnectindex].ps->palette = palette;
|
2012-09-24 21:09:31 +00:00
|
|
|
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 1); // JBF 20040308
|
2011-12-28 20:35:23 +00:00
|
|
|
|
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();
|
2018-04-12 21:02:51 +00:00
|
|
|
videoClearScreen(0L);
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
|
|
|
|
2011-08-17 18:52:54 +00:00
|
|
|
if ((uint32_t)j < 2*MAXTILES)
|
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
videoClearScreen(0);
|
2012-08-16 21:48:52 +00:00
|
|
|
|
2012-02-02 17:35:05 +00:00
|
|
|
rotatesprite_fs(320<<15,200<<15,65536L,0, j > MAXTILES-1?j-MAXTILES:j,0,0,
|
2015-02-11 05:21:46 +00:00
|
|
|
2+8+64+BGSTRETCH);
|
2011-08-17 18:52:54 +00:00
|
|
|
}
|
|
|
|
else
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
videoNextPage();
|
2006-12-10 06:49:01 +00:00
|
|
|
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)
|
|
|
|
{
|
2017-06-19 23:07:18 +00:00
|
|
|
menutext_center(90,"Loading User Map");
|
2017-06-20 09:28:42 +00:00
|
|
|
gametext_center_shade_pal(90+10, boardfilename, 14, 2);
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-19 23:07:18 +00:00
|
|
|
menutext_center(90,"Loading");
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name != NULL)
|
2017-06-19 23:07:18 +00:00
|
|
|
menutext_center(90+16+8,g_mapInfo[(ud.volume_number*MAXLEVELS) + ud.level_number].name);
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
|
|
|
|
2015-02-11 05:22:55 +00:00
|
|
|
#ifndef EDUKE32_TOUCH_DEVICES
|
2017-06-20 09:28:49 +00:00
|
|
|
if (statustext) gametext_center_number(180, statustext);
|
2015-02-11 05:22:55 +00:00
|
|
|
#endif
|
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
|
|
|
|
2015-01-11 04:55:36 +00:00
|
|
|
VM_OnEventWithReturn(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, percent);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoNextPage();
|
2006-12-10 06:49:01 +00:00
|
|
|
|
|
|
|
if (!statustext)
|
|
|
|
{
|
|
|
|
KB_FlushKeyboardQueue();
|
|
|
|
ud.screen_size = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!statustext)
|
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
videoClearScreen(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
|
|
|
|
2017-12-02 09:24:55 +00:00
|
|
|
j = VM_OnEventWithReturn(EVENT_GETLOADTILE, g_player[screenpeek].ps->i, screenpeek, LOADSCREEN);
|
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,
|
2015-02-11 05:21:46 +00:00
|
|
|
2+8+64+BGSTRETCH);
|
2011-08-17 18:52:54 +00:00
|
|
|
}
|
|
|
|
else
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
2018-04-12 21:02:51 +00:00
|
|
|
videoNextPage();
|
2006-12-10 06:49:01 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-08-17 18:52:54 +00:00
|
|
|
|
2017-06-19 23:07:18 +00:00
|
|
|
menutext_center(105,"Loading...");
|
2017-06-20 09:28:49 +00:00
|
|
|
if (statustext) gametext_center_number(180, statustext);
|
2015-01-11 04:55:36 +00:00
|
|
|
VM_OnEventWithReturn(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, percent);
|
2018-04-12 21:02:51 +00:00
|
|
|
videoNextPage();
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2018-01-29 11:13:43 +00:00
|
|
|
S_TryPlaySpecialMusic(MUS_LOADING);
|
2008-03-16 06:37:47 +00:00
|
|
|
|
2015-02-14 07:26:10 +00:00
|
|
|
#if defined EDUKE32_TOUCH_DEVICES && defined USE_OPENGL
|
2015-02-11 05:22:48 +00:00
|
|
|
polymost_glreset();
|
2015-02-11 05:22:26 +00:00
|
|
|
#endif
|
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
starttime = timerGetTicks();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-02 22:00:11 +00:00
|
|
|
S_PrecacheSounds();
|
2008-11-20 14:06:36 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-02-02 10:50:40 +00:00
|
|
|
for (SPRITES_OF_SECT(i, j))
|
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
|
|
|
}
|
|
|
|
|
2006-04-16 03:42:36 +00:00
|
|
|
tc = totalclock;
|
2006-04-13 20:47:06 +00:00
|
|
|
j = 0;
|
|
|
|
|
2015-02-11 05:22:55 +00:00
|
|
|
int lpc = -1;
|
|
|
|
|
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)
|
2018-04-12 21:03:30 +00:00
|
|
|
tileLoad((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
|
2012-11-04 23:41:05 +00:00
|
|
|
if (ud.config.useprecache && bpp > 8)
|
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
|
|
|
{
|
2013-12-28 17:04:27 +00:00
|
|
|
// this is the CROSSHAIR_PAL, see comment in game.c
|
2011-09-28 20:30:24 +00:00
|
|
|
if (k == MAXPALOOKUPS-RESERVEDPALS-1)
|
|
|
|
break;
|
2013-02-07 21:01:24 +00:00
|
|
|
#ifdef POLYMER
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() != REND_POLYMER || !polymer_havehighpalookup(0, k))
|
2013-02-07 21:01:24 +00:00
|
|
|
#endif
|
2011-09-28 20:30:24 +00:00
|
|
|
polymost_precache(i,k,type);
|
|
|
|
}
|
|
|
|
|
2016-01-08 01:33:20 +00:00
|
|
|
#ifdef USE_GLEXT
|
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);
|
2015-02-11 05:22:48 +00:00
|
|
|
#endif
|
2010-06-23 04:20:46 +00:00
|
|
|
#ifdef POLYMER
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() == REND_POLYMER)
|
2010-03-11 23:35:22 +00:00
|
|
|
{
|
|
|
|
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)
|
2012-09-05 17:25:34 +00:00
|
|
|
G_HandleAsync();
|
|
|
|
|
2012-11-04 23:41:05 +00:00
|
|
|
if (bpp > 8 && totalclock - tc > TICRATE/4)
|
2006-11-15 01:16:55 +00:00
|
|
|
{
|
2009-01-19 06:41:28 +00:00
|
|
|
/*Bsprintf(tempbuf,"%d resources remaining\n",g_precacheCount-pc+1);*/
|
2015-02-11 05:22:55 +00:00
|
|
|
int percentage = min(100, tabledivide32_noinline(100 * pc, g_precacheCount));
|
|
|
|
|
|
|
|
while (percentage > lpc)
|
|
|
|
{
|
|
|
|
Bsprintf(tempbuf, "Loaded %d%% (%d/%d textures)\n", lpc, pc, g_precacheCount);
|
|
|
|
G_DoLoadScreen(tempbuf, lpc);
|
2018-04-12 21:02:51 +00:00
|
|
|
timerUpdate();
|
2015-02-11 05:22:55 +00:00
|
|
|
|
|
|
|
if (totalclock - tc >= 1)
|
|
|
|
{
|
|
|
|
tc = totalclock;
|
|
|
|
lpc++;
|
|
|
|
}
|
|
|
|
|
2015-02-17 16:23:04 +00:00
|
|
|
// OSD_Printf("percentage %d lpc %d\n", percentage, lpc);
|
2015-02-11 05:22:55 +00:00
|
|
|
}
|
|
|
|
|
2006-04-16 03:42:36 +00:00
|
|
|
tc = totalclock;
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2014-01-12 14:54:36 +00:00
|
|
|
Bmemset(gotpic, 0, sizeof(gotpic));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
endtime = timerGetTicks();
|
2006-04-16 03:42:36 +00:00
|
|
|
OSD_Printf("Cache time: %dms\n", endtime-starttime);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2018-01-26 04:34:51 +00:00
|
|
|
extern int32_t fragbarheight(void)
|
|
|
|
{
|
|
|
|
if (ud.screen_size > 0 && !(ud.statusbarflags & STATUSBAR_NOFRAGBAR)
|
|
|
|
#ifdef SPLITSCREEN_MOD_HACKS
|
|
|
|
&& !g_fakeMultiMode
|
|
|
|
#endif
|
|
|
|
&& (g_netServer || ud.multimode > 1) && GTFLAGS(GAMETYPE_FRAGBAR))
|
|
|
|
{
|
|
|
|
int32_t i, j = 0;
|
|
|
|
|
|
|
|
for (TRAVERSE_CONNECT(i))
|
|
|
|
if (i > j)
|
|
|
|
j = i;
|
|
|
|
|
|
|
|
return ((j + 3) >> 2) << 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
void G_UpdateScreenArea(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2013-05-30 09:13:32 +00:00
|
|
|
if (!in3dmode())
|
2013-01-17 21:59:11 +00:00
|
|
|
return;
|
2009-04-29 19:43:51 +00:00
|
|
|
|
2012-05-26 21:58:21 +00:00
|
|
|
ud.screen_size = clamp(ud.screen_size, 0, 64);
|
2013-01-17 21:59:11 +00:00
|
|
|
if (ud.screen_size == 0)
|
2018-04-12 21:04:00 +00:00
|
|
|
renderFlushPerms();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-01-17 21:59:11 +00:00
|
|
|
{
|
|
|
|
const int32_t ss = max(ud.screen_size-8,0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2017-11-29 07:29:44 +00:00
|
|
|
int32_t x1 = scale(ss,xdim,160);
|
2013-01-20 21:17:31 +00:00
|
|
|
int32_t x2 = xdim-x1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-01-26 04:34:51 +00:00
|
|
|
int32_t y1 = scale(ss,(200 * 100) - (tilesiz[BOTTOMSTATUSBAR].y * ud.statusbarscale),200 - tilesiz[BOTTOMSTATUSBAR].y);
|
|
|
|
int32_t y2 = 200*100-y1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-01-26 04:34:51 +00:00
|
|
|
y1 += fragbarheight()*100;
|
2013-01-17 21:59:11 +00:00
|
|
|
if (ud.screen_size >= 8 && ud.statusbarmode==0)
|
2017-11-29 07:29:44 +00:00
|
|
|
y2 -= tilesiz[BOTTOMSTATUSBAR].y*ud.statusbarscale;
|
2018-01-26 04:34:51 +00:00
|
|
|
y1 = scale(y1,ydim,200*100);
|
2017-11-29 07:29:44 +00:00
|
|
|
y2 = scale(y2,ydim,200*100);
|
|
|
|
|
|
|
|
if (VM_HaveEvent(EVENT_UPDATESCREENAREA))
|
|
|
|
{
|
2018-02-26 20:20:00 +00:00
|
|
|
ud.returnvar[0] = y1;
|
|
|
|
ud.returnvar[1] = x2;
|
|
|
|
ud.returnvar[2] = y2;
|
|
|
|
x1 = VM_OnEventWithReturn(EVENT_UPDATESCREENAREA, g_player[screenpeek].ps->i, screenpeek, x1);
|
|
|
|
y1 = ud.returnvar[0];
|
|
|
|
x2 = ud.returnvar[1];
|
|
|
|
y2 = ud.returnvar[2];
|
2017-11-29 07:29:44 +00:00
|
|
|
}
|
2013-01-20 21:17:31 +00:00
|
|
|
|
2018-04-12 21:02:51 +00:00
|
|
|
videoSetViewableArea(x1,y1,x2-1,y2-1);
|
2013-01-17 21:59:11 +00:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
void P_RandomSpawnPoint(int playerNum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
|
|
|
|
|
|
|
|
int32_t i = playerNum;
|
|
|
|
uint32_t dist;
|
|
|
|
uint32_t pdist = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if ((g_netServer || ud.multimode > 1) && !(g_gametypeFlags[ud.coop] & GAMETYPE_FIXEDRESPAWN))
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
i = krand() % g_playerSpawnCnt;
|
2016-08-27 01:40:56 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_gametypeFlags[ud.coop] & GAMETYPE_TDMSPAWN)
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t j=0; j<ud.multimode; j++)
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
if (j != playerNum && g_player[j].ps->team == pPlayer->team && sprite[g_player[j].ps->i].extra > 0)
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bssize_t k=0; k<g_playerSpawnCnt; k++)
|
2006-08-18 23:52:26 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
dist = FindDistance2D(g_player[j].ps->pos.x - g_playerSpawnPoints[k].pos.x,
|
|
|
|
g_player[j].ps->pos.y - g_playerSpawnPoints[k].pos.y);
|
|
|
|
|
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
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->pos = g_playerSpawnPoints[i].pos;
|
|
|
|
pPlayer->opos = pPlayer->pos;
|
|
|
|
pPlayer->bobpos = *(vec2_t *)&pPlayer->pos;
|
2018-03-07 04:21:18 +00:00
|
|
|
pPlayer->q16ang = fix16_from_int(g_playerSpawnPoints[i].ang);
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->cursectnum = g_playerSpawnPoints[i].sect;
|
|
|
|
|
|
|
|
sprite[pPlayer->i].cstat = 1 + 256;
|
2009-12-12 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
static inline void P_ResetTintFade(DukePlayer_t *const pPlayer)
|
2013-06-20 18:31:50 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->pals.f = 0;
|
2013-06-20 18:31:50 +00:00
|
|
|
#ifdef LUNATIC
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->palsfadeprio = 0;
|
2013-06-20 18:31:50 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
void P_ResetPlayer(int playerNum)
|
2009-12-12 11:07:59 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
|
|
|
|
spritetype *const pSprite = &sprite[pPlayer->i];
|
|
|
|
vec3_t tmpvect = pPlayer->pos;
|
|
|
|
|
|
|
|
tmpvect.z += PHEIGHT;
|
|
|
|
|
|
|
|
P_RandomSpawnPoint(playerNum);
|
|
|
|
|
|
|
|
pPlayer->opos = pPlayer->pos;
|
|
|
|
pPlayer->bobpos = *(vec2_t *)&pPlayer->pos;
|
|
|
|
actor[pPlayer->i].bpos = pPlayer->pos;
|
|
|
|
*(vec3_t *)pSprite = pPlayer->pos;
|
|
|
|
|
|
|
|
updatesector(pPlayer->pos.x, pPlayer->pos.y, &pPlayer->cursectnum);
|
|
|
|
setsprite(pPlayer->i, &tmpvect);
|
|
|
|
|
|
|
|
pSprite->cstat = 257;
|
|
|
|
pSprite->shade = -12;
|
|
|
|
pSprite->clipdist = 64;
|
|
|
|
pSprite->xrepeat = 42;
|
|
|
|
pSprite->yrepeat = 36;
|
|
|
|
pSprite->owner = pPlayer->i;
|
|
|
|
pSprite->xoffset = 0;
|
|
|
|
pSprite->pal = pPlayer->palookup;
|
|
|
|
|
|
|
|
pPlayer->last_extra = pSprite->extra = pPlayer->max_player_health;
|
|
|
|
|
|
|
|
pPlayer->wantweaponfire = -1;
|
2018-03-07 04:21:18 +00:00
|
|
|
pPlayer->q16horiz = F16(100);
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->on_crane = -1;
|
|
|
|
pPlayer->frag_ps = playerNum;
|
2018-03-07 04:21:18 +00:00
|
|
|
pPlayer->q16horizoff = 0;
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->opyoff = 0;
|
|
|
|
pPlayer->wackedbyactor = -1;
|
|
|
|
pPlayer->inv_amount[GET_SHIELD] = g_startArmorAmount;
|
|
|
|
pPlayer->dead_flag = 0;
|
|
|
|
pPlayer->footprintcount = 0;
|
|
|
|
pPlayer->weapreccnt = 0;
|
|
|
|
pPlayer->fta = 0;
|
|
|
|
pPlayer->ftq = 0;
|
|
|
|
pPlayer->vel.x = pPlayer->vel.y = 0;
|
|
|
|
pPlayer->rotscrnang = 0;
|
|
|
|
pPlayer->runspeed = g_playerFriction;
|
|
|
|
pPlayer->falling_counter = 0;
|
|
|
|
|
|
|
|
P_ResetTintFade(pPlayer);
|
|
|
|
|
|
|
|
actor[pPlayer->i].extra = -1;
|
|
|
|
actor[pPlayer->i].owner = pPlayer->i;
|
|
|
|
actor[pPlayer->i].cgg = 0;
|
|
|
|
actor[pPlayer->i].movflag = 0;
|
|
|
|
actor[pPlayer->i].tempang = 0;
|
|
|
|
actor[pPlayer->i].actorstayput = -1;
|
|
|
|
actor[pPlayer->i].dispicnum = 0;
|
|
|
|
actor[pPlayer->i].owner = pPlayer->i;
|
|
|
|
actor[pPlayer->i].t_data[4] = 0;
|
|
|
|
|
|
|
|
P_ResetInventory(playerNum);
|
|
|
|
P_ResetWeapons(playerNum);
|
|
|
|
|
|
|
|
pPlayer->reloading = 0;
|
|
|
|
pPlayer->movement_lock = 0;
|
|
|
|
|
|
|
|
VM_OnEvent(EVENT_RESETPLAYER, pPlayer->i, playerNum);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
void P_ResetStatus(int playerNum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
|
|
|
|
|
|
|
|
ud.show_help = 0;
|
|
|
|
ud.showallmap = 0;
|
|
|
|
pPlayer->dead_flag = 0;
|
|
|
|
pPlayer->wackedbyactor = -1;
|
|
|
|
pPlayer->falling_counter = 0;
|
|
|
|
pPlayer->quick_kick = 0;
|
|
|
|
pPlayer->subweapon = 0;
|
|
|
|
pPlayer->last_full_weapon = 0;
|
|
|
|
pPlayer->ftq = 0;
|
|
|
|
pPlayer->fta = 0;
|
|
|
|
pPlayer->tipincs = 0;
|
|
|
|
pPlayer->buttonpalette = 0;
|
|
|
|
pPlayer->actorsqu = -1;
|
|
|
|
pPlayer->invdisptime = 0;
|
|
|
|
pPlayer->refresh_inventory = 0;
|
|
|
|
pPlayer->last_pissed_time = 0;
|
|
|
|
pPlayer->holster_weapon = 0;
|
|
|
|
pPlayer->pycount = 0;
|
|
|
|
pPlayer->pyoff = 0;
|
|
|
|
pPlayer->opyoff = 0;
|
|
|
|
pPlayer->loogcnt = 0;
|
2018-03-07 04:21:18 +00:00
|
|
|
pPlayer->q16angvel = 0;
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->weapon_sway = 0;
|
|
|
|
pPlayer->extra_extra8 = 0;
|
|
|
|
pPlayer->show_empty_weapon = 0;
|
|
|
|
pPlayer->dummyplayersprite = -1;
|
|
|
|
pPlayer->crack_time = 0;
|
|
|
|
pPlayer->hbomb_hold_delay = 0;
|
|
|
|
pPlayer->transporter_hold = 0;
|
2017-06-23 03:58:43 +00:00
|
|
|
pPlayer->clipdist = 164;
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->wantweaponfire = -1;
|
|
|
|
pPlayer->hurt_delay = 0;
|
|
|
|
pPlayer->footprintcount = 0;
|
|
|
|
pPlayer->footprintpal = 0;
|
|
|
|
pPlayer->footprintshade = 0;
|
|
|
|
pPlayer->jumping_toggle = 0;
|
2018-03-07 04:21:18 +00:00
|
|
|
pPlayer->oq16horiz = F16(140);
|
|
|
|
pPlayer->q16horiz = F16(140);
|
|
|
|
pPlayer->q16horizoff = 0;
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->bobcounter = 0;
|
|
|
|
pPlayer->on_ground = 0;
|
|
|
|
pPlayer->player_par = 0;
|
|
|
|
pPlayer->return_to_center = 9;
|
|
|
|
pPlayer->airleft = 15 * GAMETICSPERSEC;
|
|
|
|
pPlayer->rapid_fire_hold = 0;
|
|
|
|
pPlayer->toggle_key_flag = 0;
|
|
|
|
pPlayer->access_spritenum = -1;
|
2016-08-27 01:42:01 +00:00
|
|
|
pPlayer->got_access = ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop] & GAMETYPE_ACCESSATSTART)) ? 7 : 0;
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->random_club_frame = 0;
|
|
|
|
pus = 1;
|
|
|
|
pPlayer->on_warping_sector = 0;
|
|
|
|
pPlayer->spritebridge = 0;
|
|
|
|
pPlayer->sbs = 0;
|
|
|
|
pPlayer->palette = BASEPAL;
|
|
|
|
|
|
|
|
if (pPlayer->inv_amount[GET_STEROIDS] < 400)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->inv_amount[GET_STEROIDS] = 0;
|
|
|
|
pPlayer->inven_icon = ICON_NONE;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2016-08-27 01:40:56 +00:00
|
|
|
|
|
|
|
pPlayer->heat_on = 0;
|
|
|
|
pPlayer->jetpack_on = 0;
|
|
|
|
pPlayer->holoduke_on = -1;
|
|
|
|
pPlayer->look_ang = 512 - ((ud.level_number & 1) << 10);
|
|
|
|
pPlayer->rotscrnang = 0;
|
|
|
|
pPlayer->orotscrnang = 1; // JBF 20031220
|
|
|
|
pPlayer->newowner = -1;
|
|
|
|
pPlayer->jumping_counter = 0;
|
|
|
|
pPlayer->hard_landing = 0;
|
|
|
|
pPlayer->vel.x = 0;
|
|
|
|
pPlayer->vel.y = 0;
|
|
|
|
pPlayer->vel.z = 0;
|
|
|
|
pPlayer->fric.x = 0;
|
|
|
|
pPlayer->fric.y = 0;
|
|
|
|
pPlayer->somethingonplayer = -1;
|
|
|
|
pPlayer->one_eighty_count = 0;
|
|
|
|
pPlayer->cheat_phase = 0;
|
|
|
|
pPlayer->on_crane = -1;
|
|
|
|
|
|
|
|
pPlayer->kickback_pic = ((PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == PISTOL_WEAPON)
|
|
|
|
&& (PWEAPON(playerNum, pPlayer->curr_weapon, Reload) > PWEAPON(playerNum, pPlayer->curr_weapon, TotalTime)))
|
|
|
|
? PWEAPON(playerNum, pPlayer->curr_weapon, TotalTime)
|
|
|
|
: 0;
|
|
|
|
|
|
|
|
pPlayer->weapon_pos = WEAPON_POS_START;
|
|
|
|
pPlayer->walking_snd_toggle = 0;
|
|
|
|
pPlayer->weapon_ang = 0;
|
|
|
|
pPlayer->knuckle_incs = 1;
|
|
|
|
pPlayer->fist_incs = 0;
|
|
|
|
pPlayer->knee_incs = 0;
|
|
|
|
pPlayer->jetpack_on = 0;
|
|
|
|
pPlayer->reloading = 0;
|
|
|
|
pPlayer->movement_lock = 0;
|
|
|
|
pPlayer->frag_ps = playerNum;
|
|
|
|
|
|
|
|
P_UpdateScreenPal(pPlayer);
|
|
|
|
VM_OnEvent(EVENT_RESETPLAYER, pPlayer->i, playerNum);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
void P_ResetWeapons(int playerNum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
|
|
|
|
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t weaponNum = PISTOL_WEAPON; weaponNum < MAX_WEAPONS; weaponNum++)
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->ammo_amount[weaponNum] = 0;
|
|
|
|
|
|
|
|
pPlayer->weapon_pos = WEAPON_POS_START;
|
|
|
|
pPlayer->curr_weapon = PISTOL_WEAPON;
|
|
|
|
pPlayer->kickback_pic = PWEAPON(playerNum, pPlayer->curr_weapon, TotalTime);
|
|
|
|
pPlayer->gotweapon = ((1 << PISTOL_WEAPON) | (1 << KNEE_WEAPON) | (1 << HANDREMOTE_WEAPON));
|
|
|
|
pPlayer->ammo_amount[PISTOL_WEAPON] = min(pPlayer->max_ammo_amount[PISTOL_WEAPON], 48);
|
|
|
|
pPlayer->last_weapon = -1;
|
|
|
|
pPlayer->show_empty_weapon = 0;
|
|
|
|
pPlayer->last_pissed_time = 0;
|
|
|
|
pPlayer->holster_weapon = 0;
|
2018-03-08 03:54:54 +00:00
|
|
|
pPlayer->last_used_weapon = -1;
|
2016-08-27 01:40:56 +00:00
|
|
|
|
|
|
|
VM_OnEvent(EVENT_RESETWEAPONS, pPlayer->i, playerNum);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
void P_ResetInventory(int playerNum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
|
|
|
|
|
|
|
|
Bmemset(pPlayer->inv_amount, 0, sizeof(pPlayer->inv_amount));
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->scuba_on = 0;
|
|
|
|
pPlayer->heat_on = 0;
|
|
|
|
pPlayer->jetpack_on = 0;
|
|
|
|
pPlayer->holoduke_on = -1;
|
|
|
|
pPlayer->inven_icon = ICON_NONE;
|
|
|
|
pPlayer->inv_amount[GET_SHIELD] = g_startArmorAmount;
|
2009-12-15 05:53:15 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
VM_OnEvent(EVENT_RESETINVENTORY, pPlayer->i, playerNum);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
static void resetprestat(int playerNum, int gameMode)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
DukePlayer_t *const pPlayer = g_player[playerNum].ps;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
g_spriteDeleteQueuePos = 0;
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t i = 0; i < g_deleteQueueSize; i++) SpriteDeletionQueue[i] = -1;
|
2016-08-27 01:40:56 +00:00
|
|
|
|
|
|
|
pPlayer->hbomb_on = 0;
|
|
|
|
pPlayer->cheat_phase = 0;
|
|
|
|
pPlayer->toggle_key_flag = 0;
|
|
|
|
pPlayer->secret_rooms = 0;
|
|
|
|
pPlayer->max_secret_rooms = 0;
|
|
|
|
pPlayer->actors_killed = 0;
|
|
|
|
pPlayer->max_actors_killed = 0;
|
|
|
|
pPlayer->lastrandomspot = 0;
|
|
|
|
pPlayer->weapon_pos = WEAPON_POS_START;
|
|
|
|
|
|
|
|
P_ResetTintFade(pPlayer);
|
|
|
|
|
|
|
|
pPlayer->kickback_pic = ((PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == PISTOL_WEAPON)
|
|
|
|
&& (PWEAPON(playerNum, pPlayer->curr_weapon, Reload) > PWEAPON(playerNum, pPlayer->curr_weapon, TotalTime)))
|
|
|
|
? PWEAPON(playerNum, pPlayer->curr_weapon, TotalTime)
|
|
|
|
: 0;
|
|
|
|
|
|
|
|
pPlayer->last_weapon = -1;
|
|
|
|
pPlayer->weapreccnt = 0;
|
|
|
|
pPlayer->interface_toggle_flag = 0;
|
|
|
|
pPlayer->show_empty_weapon = 0;
|
|
|
|
pPlayer->holster_weapon = 0;
|
|
|
|
pPlayer->last_pissed_time = 0;
|
|
|
|
pPlayer->one_parallax_sectnum = -1;
|
|
|
|
pPlayer->visibility = ud.const_visibility;
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
screenpeek = myconnectindex;
|
|
|
|
g_animWallCnt = 0;
|
|
|
|
g_cyclerCnt = 0;
|
|
|
|
g_animateCnt = 0;
|
|
|
|
parallaxtype = 0;
|
|
|
|
randomseed = 1996;
|
|
|
|
ud.pause_on = 0;
|
|
|
|
ud.camerasprite = -1;
|
|
|
|
ud.eog = 0;
|
|
|
|
tempwallptr = 0;
|
|
|
|
g_curViewscreen = -1;
|
|
|
|
g_earthquakeTime = 0;
|
|
|
|
g_interpolationCnt = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if (((gameMode & MODE_EOL) != MODE_EOL && numplayers < 2 && !g_netServer)
|
2016-08-27 01:42:01 +00:00
|
|
|
|| (!(g_gametypeFlags[ud.coop] & GAMETYPE_PRESERVEINVENTORYDEATH) && numplayers > 1))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
P_ResetWeapons(playerNum);
|
|
|
|
P_ResetInventory(playerNum);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2016-08-27 01:40:56 +00:00
|
|
|
else if (PWEAPON(playerNum, pPlayer->curr_weapon, WorksLike) == HANDREMOTE_WEAPON)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->ammo_amount[HANDBOMB_WEAPON]++;
|
|
|
|
pPlayer->curr_weapon = HANDBOMB_WEAPON;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->timebeforeexit = 0;
|
|
|
|
pPlayer->customexitsound = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2014-02-22 19:38:54 +00:00
|
|
|
// Tweak sprites contained in moving sectors with these SE lotags.
|
2016-08-27 01:40:56 +00:00
|
|
|
#define FIXSPR_SELOTAGP(k) ((k) == SE_0_ROTATING_SECTOR || (k) == SE_6_SUBWAY || (k) == SE_14_SUBWAY_CAR)
|
2011-06-22 19:12:47 +00:00
|
|
|
|
2012-12-28 17:17:53 +00:00
|
|
|
// Set up sprites in moving sectors that are to be fixed wrt a certain pivot
|
2011-06-22 19:12:47 +00:00
|
|
|
// position and should not diverge from it due to roundoff error in the future.
|
2012-12-28 17:17:53 +00:00
|
|
|
// Has to be after the spawning stuff.
|
|
|
|
static void G_SetupRotfixedSprites(void)
|
2011-06-22 19:12:47 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
int spriteNum, nextSpriteNum;
|
2011-06-22 19:12:47 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
for (SPRITES_OF_STAT_SAFE(STAT_EFFECTOR, spriteNum, nextSpriteNum))
|
2011-06-22 19:12:47 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
if (FIXSPR_SELOTAGP(sprite[spriteNum].lotag))
|
2011-06-22 19:12:47 +00:00
|
|
|
{
|
2011-06-29 19:57:05 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2016-08-27 01:40:56 +00:00
|
|
|
int firstrun = 1;
|
2011-06-29 19:57:05 +00:00
|
|
|
#endif
|
2016-08-27 01:40:56 +00:00
|
|
|
int sectSprite = headspritesect[sprite[spriteNum].sectnum];
|
2014-02-22 19:38:54 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
do
|
2011-06-22 19:12:47 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
const spritetype *const pSprite = &sprite[sectSprite];
|
2014-02-22 19:38:54 +00:00
|
|
|
|
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
|
2016-08-27 01:40:56 +00:00
|
|
|
if ((ROTFIXSPR_STATNUMP(pSprite->statnum) && pSprite->picnum != TRIPBOMB)
|
|
|
|
|| ((pSprite->statnum == STAT_ACTOR || pSprite->statnum == STAT_ZOMBIEACTOR)
|
|
|
|
&& A_CheckSpriteFlags(sectSprite, SFLAG_ROTFIXED)))
|
2011-06-22 19:12:47 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
int pivotSprite = spriteNum;
|
2012-12-28 17:17:53 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if (sprite[spriteNum].lotag == 0)
|
|
|
|
pivotSprite = sprite[spriteNum].owner;
|
|
|
|
|
|
|
|
if (sectSprite != spriteNum && sectSprite != pivotSprite && pivotSprite >= 0 && pivotSprite < MAXSPRITES)
|
2011-06-29 19:57:05 +00:00
|
|
|
{
|
|
|
|
// let's hope we don't step on anyone's toes here
|
2016-08-27 01:40:56 +00:00
|
|
|
actor[sectSprite].t_data[7] = ROTFIXSPR_MAGIC | pivotSprite; // 'rs' magic + pivot SE sprite index
|
|
|
|
actor[sectSprite].t_data[8] = pSprite->x - sprite[pivotSprite].x;
|
|
|
|
actor[sectSprite].t_data[9] = pSprite->y - sprite[pivotSprite].y;
|
2011-06-29 19:57:05 +00:00
|
|
|
}
|
2011-06-22 19:12:47 +00:00
|
|
|
}
|
2011-06-29 19:57:05 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
sectSprite = nextspritesect[sectSprite];
|
2011-06-29 19:57:05 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2016-08-27 01:40:56 +00:00
|
|
|
if ((sectSprite < 0 && firstrun) &&
|
|
|
|
(sprite[spriteNum].lotag == SE_6_SUBWAY || sprite[spriteNum].lotag == SE_14_SUBWAY_CAR))
|
|
|
|
{
|
|
|
|
firstrun = 0;
|
|
|
|
sectSprite = actor[spriteNum].t_data[9];
|
|
|
|
|
|
|
|
if (sectSprite >= 0)
|
|
|
|
sectSprite = headspritesect[sectSprite];
|
|
|
|
}
|
2011-06-29 19:57:05 +00:00
|
|
|
#endif
|
2016-08-27 01:40:56 +00:00
|
|
|
} while (sectSprite>=0);
|
2011-06-22 19:12:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-15 23:13:50 +00:00
|
|
|
static inline int G_CheckExitSprite(int spriteNum) { return ((uint16_t)sprite[spriteNum].lotag == UINT16_MAX && (sprite[spriteNum].cstat & 16)); }
|
2013-09-05 17:37:38 +00:00
|
|
|
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
static void prelevel(char g)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2014-05-30 00:02:19 +00:00
|
|
|
uint8_t *tagbitmap = (uint8_t *)Xcalloc(65536>>3, 1);
|
2011-08-17 18:52:54 +00:00
|
|
|
|
2012-03-25 22:01:03 +00:00
|
|
|
Bmemset(show2dsector, 0, sizeof(show2dsector));
|
2013-12-28 17:04:34 +00:00
|
|
|
#ifdef LEGACY_ROR
|
2009-07-04 09:28:21 +00:00
|
|
|
Bmemset(ror_protectedsectors, 0, MAXSECTORS);
|
2013-12-28 17:04:34 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
resetprestat(0,g);
|
2016-08-27 01:42:01 +00:00
|
|
|
g_cloudCnt = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
G_SetupGlobalPsky();
|
|
|
|
|
2015-03-27 12:29:05 +00:00
|
|
|
VM_OnEvent(EVENT_PRELEVEL, -1, -1);
|
|
|
|
|
2015-04-18 21:59:18 +00:00
|
|
|
int missedCloudSectors = 0;
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bssize_t 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
|
|
|
{
|
2012-08-26 22:16:08 +00:00
|
|
|
case ST_20_CEILING_DOOR:
|
|
|
|
case ST_22_SPLITTING_DOOR:
|
2006-11-16 03:02:42 +00:00
|
|
|
if (sector[i].floorz > sector[i].ceilingz)
|
2018-01-28 04:30:34 +00:00
|
|
|
sector[i].lotag |= 32768u;
|
2006-11-16 03:02:42 +00:00
|
|
|
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)
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bsize_t j = 0; j < 5; j++)
|
|
|
|
tloadtile(sector[i].ceilingpicnum + j, 0);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 21:59:18 +00:00
|
|
|
if (sector[i].ceilingpicnum == CLOUDYSKIES)
|
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_cloudCnt < ARRAY_SSIZE(g_cloudSect))
|
|
|
|
g_cloudSect[g_cloudCnt++] = i;
|
2015-04-18 21:59:18 +00:00
|
|
|
else
|
|
|
|
missedCloudSectors++;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2018-01-15 23:13:50 +00:00
|
|
|
if ((uint16_t)sector[i].lotag == UINT16_MAX)
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-18 21:59:18 +00:00
|
|
|
if (missedCloudSectors > 0)
|
|
|
|
OSD_Printf(OSDTEXT_RED "Map warning: have %d unhandled CLOUDYSKIES ceilings.\n", missedCloudSectors);
|
|
|
|
|
2013-09-05 17:37:38 +00:00
|
|
|
// NOTE: must be safe loop because callbacks could delete sprites.
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bssize_t nextSprite, SPRITES_OF_STAT_SAFE(STAT_DEFAULT, i, nextSprite))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2008-12-13 07:23:13 +00:00
|
|
|
A_ResetVars(i);
|
2013-10-27 21:12:22 +00:00
|
|
|
#if !defined LUNATIC
|
2008-11-20 14:06:36 +00:00
|
|
|
A_LoadActor(i);
|
2013-02-21 18:54:07 +00:00
|
|
|
#endif
|
2014-11-22 12:29:25 +00:00
|
|
|
VM_OnEvent(EVENT_LOADACTOR, i, -1);
|
2013-09-05 17:37:38 +00:00
|
|
|
if (G_CheckExitSprite(i))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
g_player[0].ps->exitx = SX(i);
|
|
|
|
g_player[0].ps->exity = SY(i);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2016-08-27 01:40:35 +00:00
|
|
|
else switch (DYNAMICTILEMAP(PN(i)))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2006-11-16 03:02:42 +00:00
|
|
|
case GPSPEED__STATIC:
|
2013-09-05 17:37:38 +00:00
|
|
|
// DELETE_AFTER_LOADACTOR. Must not change statnum.
|
2016-08-27 01:40:35 +00:00
|
|
|
sector[SECT(i)].extra = SLT(i);
|
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 CYCLER__STATIC:
|
2013-09-05 17:37:38 +00:00
|
|
|
// DELETE_AFTER_LOADACTOR. Must not change statnum.
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_cyclerCnt >= 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
|
|
|
}
|
2016-08-27 01:42:01 +00:00
|
|
|
g_cyclers[g_cyclerCnt][0] = SECT(i);
|
|
|
|
g_cyclers[g_cyclerCnt][1] = SLT(i);
|
|
|
|
g_cyclers[g_cyclerCnt][2] = SS(i);
|
|
|
|
g_cyclers[g_cyclerCnt][3] = sector[SECT(i)].floorshade;
|
|
|
|
g_cyclers[g_cyclerCnt][4] = SHT(i);
|
|
|
|
g_cyclers[g_cyclerCnt][5] = (SA(i) == 1536);
|
|
|
|
g_cyclerCnt++;
|
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 SECTOREFFECTOR__STATIC:
|
|
|
|
case ACTIVATOR__STATIC:
|
|
|
|
case TOUCHPLATE__STATIC:
|
|
|
|
case ACTIVATORLOCKED__STATIC:
|
|
|
|
case MUSICANDSFX__STATIC:
|
|
|
|
case LOCATORS__STATIC:
|
|
|
|
case MASTERSWITCH__STATIC:
|
|
|
|
case RESPAWN__STATIC:
|
2015-11-14 17:21:14 +00:00
|
|
|
sprite[i].cstat &= ~(1|16|32|256);
|
2006-11-16 03:02:42 +00:00
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-05 17:37:38 +00:00
|
|
|
// Delete some effector / effector modifier sprites AFTER the loop running
|
|
|
|
// the LOADACTOR events. DELETE_AFTER_LOADACTOR.
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bssize_t nextSprite, SPRITES_OF_STAT_SAFE(STAT_DEFAULT, i, nextSprite))
|
2013-09-05 17:37:38 +00:00
|
|
|
if (!G_CheckExitSprite(i))
|
2016-08-27 01:40:35 +00:00
|
|
|
switch (DYNAMICTILEMAP(PN(i)))
|
2013-09-05 17:37:38 +00:00
|
|
|
{
|
|
|
|
case GPSPEED__STATIC:
|
|
|
|
case CYCLER__STATIC:
|
|
|
|
A_DeleteSprite(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
for (size_t i = 0; i < MAXSPRITES; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS && (PN(i) != SECTOREFFECTOR || SLT(i) != SE_14_SUBWAY_CAR))
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
A_Spawn(-1, i);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
for (size_t i = 0; i < MAXSPRITES; i++)
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if (sprite[i].statnum < MAXSTATUS && PN(i) == SECTOREFFECTOR && SLT(i) == SE_14_SUBWAY_CAR)
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
A_Spawn(-1, i);
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-12-28 17:17:53 +00:00
|
|
|
G_SetupRotfixedSprites();
|
2011-06-22 19:12:47 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bssize_t i=headspritestat[STAT_DEFAULT]; i>=0; i=nextspritestat[i])
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
if (PN(i) <= 0) // oob safety for switch below
|
2011-12-11 13:26:39 +00:00
|
|
|
continue;
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bsize_t ii=0; ii<2; ii++)
|
|
|
|
{
|
2016-08-27 01:40:35 +00:00
|
|
|
switch (DYNAMICTILEMAP(PN(i)-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:
|
2012-09-02 14:00:58 +00:00
|
|
|
// the lower code only for the 'on' state (*)
|
2011-08-17 18:52:54 +00:00
|
|
|
if (ii==0)
|
2006-11-16 03:02:42 +00:00
|
|
|
{
|
2018-02-11 05:03:50 +00:00
|
|
|
uint16_t const tag = sprite[i].lotag;
|
2016-08-27 01:42:01 +00:00
|
|
|
tagbitmap[tag>>3] |= 1<<(tag&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
|
|
|
}
|
2016-08-27 01:42:01 +00:00
|
|
|
}
|
2011-08-17 18:52:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// initially 'on' SE 12 light (*)
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bssize_t j=headspritestat[STAT_EFFECTOR]; j>=0; j=nextspritestat[j])
|
2011-08-17 18:52:54 +00:00
|
|
|
{
|
2018-02-11 05:03:50 +00:00
|
|
|
uint16_t const tag = sprite[j].hitag;
|
2011-08-17 18:52:16 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (sprite[j].lotag == SE_12_LIGHT_SWITCH && tagbitmap[tag>>3]&(1<<(tag&7)))
|
2011-08-17 18:52:54 +00:00
|
|
|
actor[j].t_data[0] = 1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2013-03-21 10:20:37 +00:00
|
|
|
Bfree(tagbitmap);
|
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
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bssize_t i = 0; i < numwalls; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
walltype * const pWall = &wall[i];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (pWall->overpicnum == MIRROR && (pWall->cstat&32) != 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
int const nextSectnum = pWall->nextsector;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if ((nextSectnum >= 0) && sector[nextSectnum].ceilingpicnum != MIRROR)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-01-05 20:48:05 +00:00
|
|
|
if (g_mirrorCount > 63)
|
2016-08-27 01:42:01 +00:00
|
|
|
{
|
2012-01-05 20:48:05 +00:00
|
|
|
G_GameExit("\nToo many mirrors (64 max.)");
|
2016-08-27 01:42:01 +00:00
|
|
|
}
|
2012-01-05 20:48:05 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
sector[nextSectnum].ceilingpicnum = MIRROR;
|
|
|
|
sector[nextSectnum].floorpicnum = MIRROR;
|
|
|
|
g_mirrorWall[g_mirrorCount] = i;
|
|
|
|
g_mirrorSector[g_mirrorCount] = nextSectnum;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_mirrorCount++;
|
2006-04-13 20:47:06 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_animWallCnt >= 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
|
|
|
}
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
animwall[g_animWallCnt].tag = 0;
|
|
|
|
animwall[g_animWallCnt].wallnum = 0;
|
2012-09-12 09:45:14 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
int const switchPic = G_GetForcefieldPicnum(i);
|
2011-12-09 19:12:15 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (switchPic >= 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
switch (DYNAMICTILEMAP(switchPic))
|
2011-12-09 19:12:15 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
case FANSHADOW__STATIC:
|
|
|
|
case FANSPRITE__STATIC:
|
|
|
|
wall->cstat |= 65;
|
|
|
|
animwall[g_animWallCnt].wallnum = i;
|
|
|
|
g_animWallCnt++;
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
case W_FORCEFIELD__STATIC:
|
|
|
|
if (pWall->overpicnum == W_FORCEFIELD__STATIC)
|
|
|
|
for (bsize_t j = 0; j < 3; j++) tloadtile(W_FORCEFIELD + j, 0);
|
|
|
|
if (pWall->shade > 31)
|
|
|
|
pWall->cstat = 0;
|
|
|
|
else
|
|
|
|
pWall->cstat |= FORCEFIELD_CSTAT | 256;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (pWall->lotag && pWall->nextwall >= 0)
|
|
|
|
wall[pWall->nextwall].lotag = pWall->lotag;
|
2017-07-18 20:53:41 +00:00
|
|
|
fallthrough__;
|
2016-08-27 01:42:01 +00:00
|
|
|
case BIGFORCE__STATIC:
|
|
|
|
animwall[g_animWallCnt].wallnum = i;
|
|
|
|
g_animWallCnt++;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
continue;
|
2011-12-09 19:12:15 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
pWall->extra = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
switch (DYNAMICTILEMAP(pWall->picnum))
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
case WATERTILE2__STATIC:
|
|
|
|
for (bsize_t j = 0; j < 3; j++)
|
|
|
|
tloadtile(pWall->picnum + j, 0);
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
case TECHLIGHT2__STATIC:
|
|
|
|
case TECHLIGHT4__STATIC: tloadtile(pWall->picnum, 0); break;
|
|
|
|
case W_TECHWALL1__STATIC:
|
|
|
|
case W_TECHWALL2__STATIC:
|
|
|
|
case W_TECHWALL3__STATIC:
|
|
|
|
case W_TECHWALL4__STATIC:
|
|
|
|
animwall[g_animWallCnt].wallnum = i;
|
|
|
|
// animwall[g_numAnimWalls].tag = -1;
|
|
|
|
g_animWallCnt++;
|
|
|
|
break;
|
|
|
|
case SCREENBREAK6__STATIC:
|
|
|
|
case SCREENBREAK7__STATIC:
|
|
|
|
case SCREENBREAK8__STATIC:
|
|
|
|
for (bssize_t j = SCREENBREAK6; j < SCREENBREAK9; j++)
|
|
|
|
tloadtile(j, 0);
|
|
|
|
|
|
|
|
animwall[g_animWallCnt].wallnum = i;
|
|
|
|
animwall[g_animWallCnt].tag = -1;
|
|
|
|
g_animWallCnt++;
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
case FEMPIC1__STATIC:
|
|
|
|
case FEMPIC2__STATIC:
|
|
|
|
case FEMPIC3__STATIC:
|
|
|
|
pWall->extra = pWall->picnum;
|
|
|
|
animwall[g_animWallCnt].tag = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (ud.lockout)
|
|
|
|
pWall->picnum = (pWall->picnum == FEMPIC1) ? BLANKSCREEN : SCREENBREAK6;
|
|
|
|
|
|
|
|
animwall[g_animWallCnt].wallnum = i;
|
|
|
|
animwall[g_animWallCnt].tag = pWall->picnum;
|
|
|
|
g_animWallCnt++;
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
case SCREENBREAK1__STATIC:
|
|
|
|
case SCREENBREAK2__STATIC:
|
|
|
|
case SCREENBREAK3__STATIC:
|
|
|
|
case SCREENBREAK4__STATIC:
|
|
|
|
case SCREENBREAK5__STATIC:
|
2012-09-12 09:45:14 +00:00
|
|
|
//
|
2016-08-27 01:42:01 +00:00
|
|
|
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:
|
|
|
|
animwall[g_animWallCnt].wallnum = i;
|
|
|
|
animwall[g_animWallCnt].tag = pWall->picnum;
|
|
|
|
g_animWallCnt++;
|
|
|
|
break;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Invalidate textures in sector behind mirror
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bssize_t i=0; i<g_mirrorCount; i++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
int const startWall = sector[g_mirrorSector[i]].wallptr;
|
|
|
|
int const endWall = startWall + sector[g_mirrorSector[i]].wallnum;
|
|
|
|
|
|
|
|
for (bssize_t j = startWall; j < endWall; j++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
wall[j].picnum = MIRROR;
|
2006-04-13 20:47:06 +00:00
|
|
|
wall[j].overpicnum = MIRROR;
|
2016-08-27 01:42:01 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-25 23:25:38 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
void G_NewGame(int volumeNum, int levelNum, int skillNum)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
DukePlayer_t *const pPlayer = g_player[0].ps;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-09-05 17:25:34 +00:00
|
|
|
G_HandleAsync();
|
2006-12-17 21:20:35 +00:00
|
|
|
|
2015-02-11 05:22:00 +00:00
|
|
|
if (g_skillSoundVoice >= 0 && ud.config.SoundToggle)
|
2006-12-17 21:20:35 +00:00
|
|
|
{
|
2014-04-19 22:42:20 +00:00
|
|
|
while (FX_SoundActive(g_skillSoundVoice))
|
2012-09-05 17:25:34 +00:00
|
|
|
G_HandleAsync();
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2006-12-18 08:37:12 +00:00
|
|
|
|
2014-04-19 22:42:20 +00:00
|
|
|
g_skillSoundVoice = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
ready2send = 0;
|
|
|
|
|
2018-01-26 04:34:38 +00:00
|
|
|
if (ud.m_recstat != 2 && ud.last_level >= 0 &&
|
|
|
|
VM_OnEventWithReturn(EVENT_EXITGAMESCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0) == 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
|
|
|
|
2018-01-26 04:34:38 +00:00
|
|
|
g_showShareware = GAMETICSPERSEC*34;
|
|
|
|
|
|
|
|
ud.level_number = levelNum;
|
|
|
|
ud.volume_number = volumeNum;
|
|
|
|
ud.player_skill = skillNum;
|
|
|
|
ud.secretlevel = 0;
|
|
|
|
ud.from_bonus = 0;
|
|
|
|
|
|
|
|
ud.last_level = -1;
|
|
|
|
g_lastAutoSaveArbitraryID = -1;
|
|
|
|
g_lastautosave.reset();
|
|
|
|
g_lastusersave.reset();
|
|
|
|
g_quickload = nullptr;
|
|
|
|
|
2018-01-29 11:13:21 +00:00
|
|
|
int const UserMap = Menu_HaveUserMap();
|
2018-01-26 04:34:38 +00:00
|
|
|
|
|
|
|
// we don't want the intro to play after the multiplayer setup screen
|
|
|
|
if ((!g_netServer && ud.multimode < 2) && UserMap == 0 &&
|
|
|
|
VM_OnEventWithReturn(EVENT_NEWGAMESCREEN, g_player[myconnectindex].ps->i, myconnectindex, 0) == 0 &&
|
|
|
|
levelNum == 0 && volumeNum == 3 && ud.lockout == 0 && (G_GetLogoFlags() & LOGO_NOE4CUTSCENE)==0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2018-01-29 11:13:43 +00:00
|
|
|
S_PlaySpecialMusicOrNothing(MUS_BRIEFING);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-04-12 21:04:00 +00:00
|
|
|
renderFlushPerms();
|
2018-04-12 21:02:51 +00:00
|
|
|
videoSetViewableArea(0,0,xdim-1,ydim-1);
|
|
|
|
videoClearViewableArea(0L);
|
|
|
|
videoNextPage();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
int animReturn = Anim_Play("vol41a.anm");
|
2018-04-12 21:02:51 +00:00
|
|
|
videoClearViewableArea(0L);
|
|
|
|
videoNextPage();
|
2016-08-27 01:40:56 +00:00
|
|
|
if (animReturn)
|
2014-01-12 14:02:30 +00:00
|
|
|
goto end_vol4a;
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
animReturn = Anim_Play("vol42a.anm");
|
2018-04-12 21:02:51 +00:00
|
|
|
videoClearViewableArea(0L);
|
|
|
|
videoNextPage();
|
2016-08-27 01:40:56 +00:00
|
|
|
if (animReturn)
|
2014-01-12 14:02:30 +00:00
|
|
|
goto end_vol4a;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-02-07 02:38:28 +00:00
|
|
|
Anim_Play("vol43a.anm");
|
2018-04-12 21:02:51 +00:00
|
|
|
videoClearViewableArea(0L);
|
|
|
|
videoNextPage();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-01-12 14:02:30 +00:00
|
|
|
end_vol4a:
|
2006-04-13 20:47:06 +00:00
|
|
|
FX_StopAllSounds();
|
|
|
|
}
|
|
|
|
|
2014-12-27 18:36:14 +00:00
|
|
|
#ifdef EDUKE32_TOUCH_DEVICES
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->zoom = 360;
|
2014-10-29 17:07:47 +00:00
|
|
|
#else
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->zoom = 768;
|
2014-10-29 17:07:47 +00:00
|
|
|
#endif
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->gm = 0;
|
2016-11-01 01:35:32 +00:00
|
|
|
Menu_Close(0);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-01-19 18:29:00 +00:00
|
|
|
#if !defined LUNATIC
|
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();
|
2013-01-01 15:24:18 +00:00
|
|
|
#endif
|
2013-02-07 21:00:48 +00:00
|
|
|
Gv_ResetSystemDefaults();
|
|
|
|
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t i=0; i<(MAXVOLUMES*MAXLEVELS); i++)
|
2017-12-02 08:45:09 +00:00
|
|
|
G_FreeMapState(i);
|
2008-07-18 02:46:24 +00:00
|
|
|
|
2006-12-17 21:20:35 +00:00
|
|
|
if (ud.m_coop != 1)
|
|
|
|
{
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t weaponNum = 0; weaponNum < MAX_WEAPONS; weaponNum++)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
if (PWEAPON(0, weaponNum, WorksLike) == PISTOL_WEAPON)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->curr_weapon = weaponNum;
|
|
|
|
pPlayer->gotweapon |= (1 << weaponNum);
|
|
|
|
pPlayer->ammo_amount[weaponNum] = min(pPlayer->max_ammo_amount[weaponNum], 48);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2016-08-27 01:40:56 +00:00
|
|
|
else if (PWEAPON(0, weaponNum, WorksLike) == KNEE_WEAPON || PWEAPON(0, weaponNum, WorksLike) == HANDREMOTE_WEAPON)
|
|
|
|
pPlayer->gotweapon |= (1 << weaponNum);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2016-08-27 01:40:56 +00:00
|
|
|
pPlayer->last_weapon = -1;
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
2006-12-18 08:37:12 +00:00
|
|
|
|
2013-07-13 21:04:52 +00:00
|
|
|
display_mirror = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2013-07-13 21:04:53 +00:00
|
|
|
#ifdef LUNATIC
|
|
|
|
// NOTE: Lunatic state creation is relatively early. No map has yet been loaded.
|
|
|
|
// XXX: What about the cases where G_EnterLevel() is called without a preceding G_NewGame()?
|
|
|
|
El_CreateGameState();
|
|
|
|
G_PostCreateGameState();
|
|
|
|
#endif
|
2017-12-02 09:24:55 +00:00
|
|
|
VM_OnEvent(EVENT_NEWGAME, g_player[screenpeek].ps->i, screenpeek);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
static void resetpspritevars(char gameMode)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-08-16 21:48:13 +00:00
|
|
|
int16_t i, j; //circ;
|
|
|
|
|
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,
|
2018-03-07 04:21:18 +00:00
|
|
|
APLAYER,0,0,0,fix16_to_int(g_player[0].ps->q16ang),0,0,0,10);
|
2012-02-14 23:13:38 +00:00
|
|
|
}
|
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;
|
2016-08-27 01:42:01 +00:00
|
|
|
if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0)
|
2012-02-21 19:33:33 +00:00
|
|
|
{
|
|
|
|
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];
|
2016-08-27 01:42:01 +00:00
|
|
|
if ((g_netServer || ud.multimode > 1) && (g_gametypeFlags[ud.coop]&GAMETYPE_PRESERVEINVENTORYDEATH) && ud.last_level >= 0)
|
2012-02-21 19:33:33 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
g_playerSpawnCnt = 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
|
|
|
{
|
2012-08-16 21:48:13 +00:00
|
|
|
const int32_t nexti = nextspritestat[i];
|
|
|
|
spritetype *const s = &sprite[i];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_playerSpawnCnt == MAXPLAYERS)
|
2008-11-20 14:06:36 +00:00
|
|
|
G_GameExit("\nToo many player sprites (max 16.)");
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
g_playerSpawnPoints[g_playerSpawnCnt].pos.x = s->x;
|
|
|
|
g_playerSpawnPoints[g_playerSpawnCnt].pos.y = s->y;
|
|
|
|
g_playerSpawnPoints[g_playerSpawnCnt].pos.z = s->z;
|
|
|
|
g_playerSpawnPoints[g_playerSpawnCnt].ang = s->ang;
|
|
|
|
g_playerSpawnPoints[g_playerSpawnCnt].sect = s->sectnum;
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
g_playerSpawnCnt++;
|
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;
|
2012-08-13 18:25:32 +00:00
|
|
|
if (!g_fakeMultiMode)
|
|
|
|
s->cstat = j < numplayers ? 1+256 : 32768;
|
|
|
|
else
|
2012-08-16 21:48:13 +00:00
|
|
|
s->cstat = j < ud.multimode ? 1+256 : 32768;
|
2006-04-13 20:47:06 +00:00
|
|
|
s->xoffset = 0;
|
|
|
|
s->clipdist = 64;
|
|
|
|
|
2017-01-05 05:29:47 +00:00
|
|
|
// if (j < g_mostConcurrentPlayers)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
if ((gameMode&MODE_EOL) != MODE_EOL || g_player[j].ps->last_extra == 0)
|
2009-12-05 09:22:43 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (!g_player[j].pcolor && (g_netServer || ud.multimode > 1) && !(g_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
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_gametypeFlags[ud.coop] & GAMETYPE_TDM)
|
2009-12-05 09:22:43 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2012-10-29 04:29:17 +00:00
|
|
|
g_player[j].ps->autostep = (20L<<8);
|
|
|
|
g_player[j].ps->autostep_sbw = (4L<<8);
|
|
|
|
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
actor[i].bpos.x = g_player[j].ps->bobpos.x = g_player[j].ps->opos.x = g_player[j].ps->pos.x = s->x;
|
|
|
|
actor[i].bpos.y = g_player[j].ps->bobpos.y = g_player[j].ps->opos.y = g_player[j].ps->pos.y = s->y;
|
2012-12-23 14:00:08 +00:00
|
|
|
actor[i].bpos.z = g_player[j].ps->opos.z = g_player[j].ps->pos.z = s->z;
|
2018-03-07 04:21:18 +00:00
|
|
|
g_player[j].ps->oq16ang = g_player[j].ps->q16ang = fix16_from_int(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
|
|
|
}
|
2012-03-11 17:38:13 +00:00
|
|
|
else A_DeleteSprite(i);
|
2012-08-16 21:48:13 +00:00
|
|
|
|
2006-04-13 20:47:06 +00:00
|
|
|
i = nexti;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-10 21:53:33 +00:00
|
|
|
static inline void clearfrags(void)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t i = 0; i < ud.multimode; i++)
|
2007-08-27 06:46:31 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
playerdata_t *const pPlayerData = &g_player[i];
|
|
|
|
pPlayerData->ps->frag = pPlayerData->ps->fraggedself = 0;
|
|
|
|
Bmemset(pPlayerData->frags, 0, sizeof(pPlayerData->frags));
|
2007-08-27 06:46:31 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2013-07-04 19:38:46 +00:00
|
|
|
void G_ResetTimers(uint8_t keepgtics)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
totalclock = g_cloudClock = ototalclock = lockclock = 0;
|
2006-04-13 20:47:06 +00:00
|
|
|
ready2send = 1;
|
2008-11-20 14:06:36 +00:00
|
|
|
g_levelTextTime = 85;
|
2014-12-21 15:51:48 +00:00
|
|
|
|
2013-07-04 19:38:46 +00:00
|
|
|
if (!keepgtics)
|
|
|
|
g_moveThingsCount = 0;
|
2014-12-21 15:51:48 +00:00
|
|
|
|
2014-10-25 03:27:13 +00:00
|
|
|
if (g_curViewscreen >= 0)
|
|
|
|
actor[g_curViewscreen].t_data[0] = 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
|
|
|
g_emuJumpTics = 0;
|
2007-08-27 00:20:15 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
clearbufbyte(&localInput, sizeof(input_t), 0L);
|
|
|
|
clearbufbyte(&inputfifo, sizeof(input_t) * MOVEFIFOSIZ * MAXPLAYERS, 0L);
|
2008-11-20 14:06:36 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
for (bsize_t p = 0; p <= MAXPLAYERS - 1; ++p)
|
2007-08-27 06:46:31 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_player[p].inputBits != NULL)
|
|
|
|
Bmemset(g_player[p].inputBits, 0, sizeof(input_t));
|
|
|
|
g_player[p].vote = g_player[p].gotvote = 0;
|
2007-08-27 06:46:31 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
int G_FindLevelByFile(const char *fileName)
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t volumeNum = 0; volumeNum < MAXVOLUMES; volumeNum++)
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
int const volOffset = volumeNum * MAXLEVELS;
|
2016-08-27 01:40:56 +00:00
|
|
|
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t levelNum = 0; levelNum < MAXLEVELS; levelNum++)
|
2006-12-10 06:49:01 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_mapInfo[volOffset + levelNum].filename == NULL)
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
continue;
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (!Bstrcasecmp(fileName, g_mapInfo[volOffset + levelNum].filename))
|
|
|
|
return volOffset + levelNum;
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
|
|
|
}
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
|
|
|
|
return MAXLEVELS * MAXVOLUMES;
|
2006-12-10 06:49:01 +00:00
|
|
|
}
|
|
|
|
|
2017-06-17 11:41:49 +00:00
|
|
|
#if 0
|
2015-02-09 05:50:47 +00:00
|
|
|
static void G_FadeLoad(int32_t r, int32_t g, int32_t b, int32_t start, int32_t end, int32_t step, int32_t ticwait, int32_t tc)
|
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
|
|
|
|
2015-09-23 17:55:11 +00:00
|
|
|
setpalettefade(r,g,b,start);
|
2011-08-17 18:52:54 +00:00
|
|
|
flushperms();
|
2015-02-09 05:50:47 +00:00
|
|
|
G_DoLoadScreen(" ", tc);
|
2011-08-17 18:52:54 +00:00
|
|
|
}
|
2010-05-02 23:27:30 +00:00
|
|
|
}
|
2017-06-17 11:41:49 +00:00
|
|
|
#endif
|
2010-05-02 23:27:30 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
static int G_TryMapHack(const char *mhkfile)
|
2015-01-08 15:14:00 +00:00
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t failure = engineLoadMHK(mhkfile);
|
2015-01-08 15:14:00 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if (!failure)
|
2015-01-08 15:14:00 +00:00
|
|
|
initprintf("Loaded map hack file \"%s\"\n", mhkfile);
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
return failure;
|
2015-01-08 15:14:00 +00:00
|
|
|
}
|
2011-01-09 18:53:06 +00:00
|
|
|
|
|
|
|
static void G_LoadMapHack(char *outbuf, const char *filename)
|
|
|
|
{
|
|
|
|
if (filename != NULL)
|
|
|
|
Bstrcpy(outbuf, filename);
|
2011-02-25 21:50:19 +00:00
|
|
|
|
2013-05-06 19:43:38 +00:00
|
|
|
append_ext_UNSAFE(outbuf, ".mhk");
|
2011-02-25 21:50:19 +00:00
|
|
|
|
2016-09-16 21:55:39 +00:00
|
|
|
if (G_TryMapHack(outbuf) && usermaphacks != NULL)
|
2015-01-08 15:14:00 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
usermaphack_t *pMapInfo = (usermaphack_t*)bsearch(
|
2015-01-18 20:31:37 +00:00
|
|
|
&g_loadedMapHack, usermaphacks, num_usermaphacks, sizeof(usermaphack_t),
|
|
|
|
compare_usermaphacks);
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if (pMapInfo)
|
|
|
|
G_TryMapHack(pMapInfo->mhkfile);
|
2015-01-08 15:14:00 +00:00
|
|
|
}
|
2011-01-09 18:53:06 +00:00
|
|
|
}
|
|
|
|
|
2011-12-25 15:32:30 +00:00
|
|
|
// levnamebuf should have at least size BMAX_PATH
|
2016-08-27 01:40:56 +00:00
|
|
|
void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName, int levelNum)
|
2011-12-25 15:32:30 +00:00
|
|
|
{
|
2016-01-11 05:06:10 +00:00
|
|
|
char *p;
|
2016-08-27 01:40:56 +00:00
|
|
|
char const *exts[] = {
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
#ifdef HAVE_FLAC
|
2016-08-27 01:40:56 +00:00
|
|
|
"flac",
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_VORBIS
|
2016-08-27 01:40:56 +00:00
|
|
|
"ogg",
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
#endif
|
2016-08-27 01:40:56 +00:00
|
|
|
"mid"
|
|
|
|
};
|
2011-12-25 15:32:30 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
Bstrncpy(nameBuf, fileName, BMAX_PATH);
|
2011-12-25 15:32:30 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
Bcorrectfilename(nameBuf, 0);
|
2011-12-25 15:32:30 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if (NULL == (p = Bstrrchr(nameBuf, '.')))
|
2011-12-25 15:32:30 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
p = nameBuf + Bstrlen(nameBuf);
|
2011-12-25 15:32:30 +00:00
|
|
|
p[0] = '.';
|
|
|
|
}
|
|
|
|
|
2014-10-29 17:07:47 +00:00
|
|
|
for (unsigned int i = 0; i < ARRAY_SIZE(exts); i++)
|
2011-12-25 15:32:30 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
int32_t kFile;
|
2011-12-25 15:32:30 +00:00
|
|
|
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
Bmemcpy(p+1, exts[i], Bstrlen(exts[i]) + 1);
|
2011-12-25 15:32:30 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if ((kFile = kopen4loadfrommod(nameBuf, 0)) != -1)
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
kclose(kFile);
|
2016-08-27 01:42:01 +00:00
|
|
|
realloc_copy(&g_mapInfo[levelNum].musicfn, nameBuf);
|
Clean up some player code a bit... make bobposx/bobposy a vec2_t, make fricxv/fricyv a per-player vec2_t (TODO: CON access), promote angvel in input_t to int16_t and allow for player angle changes that result in odd numbered angles (we were effectively artificially limiting the angle to 1024 values before), fix some HUD model ID stuff that should help with the weapons in the HRP, clean up a bunch of random functions (P_FireWeapon(), P_DisplayTip(), P_DisplayAccess(), P_DisplayWeapon(), P_GetInput(), etc). Also clean up G_SetupFilenameBasedMusic() to loop through flac/ogg/mid when searching for usermap music replacements. Some of this really needs a BYTEVERSION bump, but these commits aren't for synthesis to build so we're not doing it yet. DONT_BUILD.
git-svn-id: https://svn.eduke32.com/eduke32@4703 1a8010ca-5511-0410-912e-c29ae57300e0
2014-10-29 17:07:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-12-25 15:32:30 +00:00
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
realloc_copy(&g_mapInfo[levelNum].musicfn, "dethtoll.mid");
|
2011-12-25 15:32:30 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
int G_EnterLevel(int gameMode)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2012-05-25 18:39:22 +00:00
|
|
|
int32_t i, mii;
|
2016-08-27 01:40:56 +00:00
|
|
|
char levelName[BMAX_PATH];
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2008-11-20 14:06:36 +00:00
|
|
|
// flushpackets();
|
|
|
|
// waitforeverybody();
|
2007-08-27 06:46:31 +00:00
|
|
|
vote_map = vote_episode = voting = -1;
|
|
|
|
|
2016-08-27 01:40:56 +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;
|
|
|
|
ud.noexits = ud.m_noexits;
|
2006-05-04 03:14:49 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if ((gameMode & MODE_DEMO) != MODE_DEMO)
|
2013-07-13 21:04:52 +00:00
|
|
|
ud.recstat = ud.m_recstat;
|
2016-08-27 01:40:56 +00:00
|
|
|
if ((gameMode & 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)
|
|
|
|
{
|
2016-11-15 21:55:09 +00:00
|
|
|
S_PauseSounds(0);
|
2011-02-25 21:50:19 +00:00
|
|
|
FX_StopAllSounds();
|
|
|
|
S_ClearSoundLocks();
|
|
|
|
FX_SetReverb(0);
|
2018-07-14 21:36:44 +00:00
|
|
|
videoSetGameMode(ud.config.ScreenMode, ud.config.ScreenWidth, ud.config.ScreenHeight, ud.config.ScreenBPP, upscalefactor);
|
2016-06-05 04:46:28 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-01-29 11:13:21 +00:00
|
|
|
if (Menu_HaveUserMap())
|
2006-12-09 23:41:43 +00:00
|
|
|
{
|
2006-12-12 07:25:01 +00:00
|
|
|
Bcorrectfilename(boardfilename,0);
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
int levelNum = G_FindLevelByFile(boardfilename);
|
2006-12-10 06:49:01 +00:00
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if (levelNum != MAXLEVELS*MAXVOLUMES)
|
2006-12-09 23:41:43 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
int volumeNum = levelNum;
|
|
|
|
|
|
|
|
levelNum &= MAXLEVELS-1;
|
|
|
|
volumeNum = (volumeNum - levelNum) / MAXLEVELS;
|
|
|
|
|
|
|
|
ud.level_number = ud.m_level_number = levelNum;
|
|
|
|
ud.volume_number = ud.m_volume_number = volumeNum;
|
2009-06-28 20:23:12 +00:00
|
|
|
|
2006-12-09 23:41:43 +00:00
|
|
|
boardfilename[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-25 18:39:22 +00:00
|
|
|
mii = (ud.volume_number*MAXLEVELS)+ud.level_number;
|
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_mapInfo[mii].name == NULL || g_mapInfo[mii].filename == NULL)
|
2006-12-04 22:22:07 +00:00
|
|
|
{
|
2018-01-29 11:13:21 +00:00
|
|
|
if (Menu_HaveUserMap())
|
2006-12-05 21:22:19 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
if (g_mapInfo[mii].filename == NULL)
|
|
|
|
g_mapInfo[mii].filename = (char *)Xcalloc(BMAX_PATH, sizeof(uint8_t));
|
|
|
|
if (g_mapInfo[mii].name == NULL)
|
|
|
|
g_mapInfo[mii].name = Xstrdup("User Map");
|
2006-12-05 21:22:19 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-25 18:39:22 +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
|
|
|
|
2018-01-29 11:13:21 +00:00
|
|
|
if (Menu_HaveUserMap())
|
2006-12-04 22:22:07 +00:00
|
|
|
{
|
2014-06-16 23:17:11 +00:00
|
|
|
if (g_gameNamePtr)
|
2017-06-09 06:41:39 +00:00
|
|
|
#ifdef EDUKE32_STANDALONE
|
2018-07-23 02:55:59 +00:00
|
|
|
Bsnprintf(apptitle, sizeof(apptitle), "%s - %s", boardfilename, g_gameNamePtr);
|
2017-06-09 06:41:39 +00:00
|
|
|
#else
|
2018-07-23 02:55:59 +00:00
|
|
|
Bsnprintf(apptitle, sizeof(apptitle), "%s - %s - " APPNAME, boardfilename, g_gameNamePtr);
|
2017-06-09 06:41:39 +00:00
|
|
|
#endif
|
2014-06-16 23:17:11 +00:00
|
|
|
else
|
2018-07-23 02:55:59 +00:00
|
|
|
Bsnprintf(apptitle, sizeof(apptitle), "%s - " APPNAME, boardfilename);
|
2014-06-16 23:17:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g_gameNamePtr)
|
2017-06-09 06:41:39 +00:00
|
|
|
#ifdef EDUKE32_STANDALONE
|
|
|
|
Bsprintf(apptitle,"%s - %s",g_mapInfo[mii].name,g_gameNamePtr);
|
|
|
|
#else
|
|
|
|
Bsprintf(apptitle, "%s - %s - " APPNAME, g_mapInfo[mii].name, g_gameNamePtr);
|
|
|
|
#endif
|
2014-06-16 23:17:11 +00:00
|
|
|
else
|
2016-08-27 01:42:01 +00:00
|
|
|
Bsprintf(apptitle,"%s - " APPNAME,g_mapInfo[mii].name);
|
2006-12-04 22:22:07 +00:00
|
|
|
}
|
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
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
DukePlayer_t *const pPlayer = g_player[0].ps;
|
2018-03-07 04:21:18 +00:00
|
|
|
int16_t lbang;
|
2013-12-24 09:44:25 +00:00
|
|
|
|
2018-01-29 11:13:21 +00:00
|
|
|
if (!VOLUMEONE && Menu_HaveUserMap())
|
2016-08-27 01:40:56 +00:00
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
if (engineLoadBoard(boardfilename, 0, &pPlayer->pos, &lbang, &pPlayer->cursectnum) < 0)
|
2006-04-13 20:47:06 +00:00
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", boardfilename);
|
2006-04-13 20:47:06 +00:00
|
|
|
return 1;
|
2006-11-15 01:16:55 +00:00
|
|
|
}
|
2016-08-27 01:40:56 +00:00
|
|
|
|
|
|
|
G_LoadMapHack(levelName, boardfilename);
|
|
|
|
G_SetupFilenameBasedMusic(levelName, boardfilename, ud.m_level_number);
|
|
|
|
}
|
2018-04-12 21:03:47 +00:00
|
|
|
else if (engineLoadBoard(g_mapInfo[mii].filename, VOLUMEONE, &pPlayer->pos, &lbang, &pPlayer->cursectnum) < 0)
|
2016-08-27 01:40:56 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", g_mapInfo[mii].filename);
|
2016-08-27 01:40:56 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
G_LoadMapHack(levelName, g_mapInfo[mii].filename);
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2018-03-07 04:21:18 +00:00
|
|
|
pPlayer->q16ang = fix16_from_int(lbang);
|
|
|
|
|
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
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
prelevel(gameMode);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-09-12 09:45:14 +00:00
|
|
|
G_AlignWarpElevators();
|
2016-08-27 01:40:56 +00:00
|
|
|
resetpspritevars(gameMode);
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2018-01-29 11:13:21 +00:00
|
|
|
ud.playerbest = CONFIG_GetMapBestTime(Menu_HaveUserMap() ? boardfilename : g_mapInfo[mii].filename, g_loadedMapHack.md4);
|
2015-02-08 08:03:30 +00:00
|
|
|
|
2017-06-17 11:41:49 +00:00
|
|
|
// G_FadeLoad(0,0,0, 252,0, -28, 4, -1);
|
2010-01-24 23:33:17 +00:00
|
|
|
G_CacheMapData();
|
2017-06-17 11:41:49 +00:00
|
|
|
// G_FadeLoad(0,0,0, 0,252, 28, 4, -2);
|
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
|
|
|
{
|
2018-01-29 11:13:43 +00:00
|
|
|
if (g_mapInfo[g_musicIndex].musicfn == NULL ||
|
|
|
|
g_mapInfo[mii].musicfn == NULL || // intentional, to pass control further while avoiding the strcmp on null
|
|
|
|
strcmp(g_mapInfo[g_musicIndex].musicfn, g_mapInfo[mii].musicfn) ||
|
|
|
|
g_musicSize == 0 ||
|
|
|
|
ud.last_level == -1)
|
|
|
|
{
|
|
|
|
S_PlayLevelMusicOrNothing(mii);
|
|
|
|
}
|
2018-01-29 11:14:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
S_ContinueLevelMusic();
|
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if (gameMode & (MODE_GAME|MODE_EOL))
|
2009-06-24 08:20:10 +00:00
|
|
|
{
|
2012-02-21 19:33:33 +00:00
|
|
|
for (TRAVERSE_CONNECT(i))
|
2014-11-29 03:43:11 +00:00
|
|
|
{
|
2012-02-21 19:33:33 +00:00
|
|
|
g_player[i].ps->gm = MODE_GAME;
|
2016-11-01 01:35:32 +00:00
|
|
|
Menu_Close(i);
|
2014-11-29 03:43:11 +00:00
|
|
|
}
|
2009-06-24 08:20:10 +00:00
|
|
|
}
|
2016-08-27 01:40:56 +00:00
|
|
|
else if (gameMode & 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
|
|
|
}
|
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
if ((ud.recstat == 1) && (gameMode&MODE_RESTART) != MODE_RESTART)
|
2008-11-20 14:06:36 +00:00
|
|
|
G_OpenDemoWrite();
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2014-12-27 18:36:14 +00:00
|
|
|
#ifndef EDUKE32_TOUCH_DEVICES
|
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);
|
2014-09-30 04:08:10 +00:00
|
|
|
#endif
|
2006-04-13 20:47:06 +00:00
|
|
|
|
2012-02-21 19:33:33 +00:00
|
|
|
for (TRAVERSE_CONNECT(i))
|
2016-08-27 01:40:56 +00:00
|
|
|
{
|
2012-02-21 19:33:33 +00:00
|
|
|
switch (DYNAMICTILEMAP(sector[sprite[g_player[i].ps->i].sectnum].floorpicnum))
|
|
|
|
{
|
2016-08-27 01:40:56 +00:00
|
|
|
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;
|
2012-02-21 19:33:33 +00:00
|
|
|
}
|
2016-08-27 01:40:56 +00:00
|
|
|
}
|
2006-04-13 20:47:06 +00:00
|
|
|
|
|
|
|
//PREMAP.C - replace near the my's at the end of the file
|
|
|
|
|
2012-12-12 02:53:13 +00:00
|
|
|
Net_NotifyNewGame();
|
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
|
2010-01-24 23:33:17 +00:00
|
|
|
P_UpdateScreenPal(g_player[myconnectindex].ps);
|
2018-04-12 21:04:00 +00:00
|
|
|
renderFlushPerms();
|
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
|
|
|
|
2016-08-27 01:42:01 +00:00
|
|
|
for (i=g_interpolationCnt-1; i>=0; i--) bakipos[i] = *curipos[i];
|
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();
|
|
|
|
|
2013-07-04 19:38:46 +00:00
|
|
|
G_ResetTimers(0); // 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
|
|
|
|
2012-05-25 18:39:22 +00:00
|
|
|
Bmemcpy(currentboardfilename, boardfilename, BMAX_PATH);
|
2015-05-25 12:57:50 +00:00
|
|
|
|
|
|
|
for (TRAVERSE_CONNECT(i))
|
|
|
|
{
|
|
|
|
const int32_t ret = VM_OnEventWithReturn(EVENT_ENTERLEVEL, g_player[i].ps->i, i, 0);
|
|
|
|
if (ret == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-01-29 11:13:37 +00:00
|
|
|
if (G_HaveUserMap())
|
|
|
|
{
|
|
|
|
OSD_Printf(OSDTEXT_YELLOW "User Map: %s\n", boardfilename);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
OSD_Printf(OSDTEXT_YELLOW "E%dL%d: %s\n", ud.volume_number+1, ud.level_number+1,
|
|
|
|
g_mapInfo[mii].name);
|
|
|
|
}
|
2011-04-07 01:16:29 +00:00
|
|
|
|
2015-12-23 04:06:13 +00:00
|
|
|
g_restorePalette = -1;
|
|
|
|
|
|
|
|
G_UpdateScreenArea();
|
2018-04-12 21:02:51 +00:00
|
|
|
videoClearViewableArea(0L);
|
2015-12-23 04:06:13 +00:00
|
|
|
G_DrawBackground();
|
|
|
|
G_DrawRooms(myconnectindex,65536);
|
|
|
|
|
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
|
|
|
|
2016-08-27 01:40:56 +00:00
|
|
|
void G_FreeMapState(int levelNum)
|
2008-07-18 02:46:24 +00:00
|
|
|
{
|
2016-08-27 01:42:01 +00:00
|
|
|
map_t *const pMapInfo = &g_mapInfo[levelNum];
|
2016-08-27 01:40:56 +00:00
|
|
|
|
|
|
|
if (pMapInfo->savedstate == NULL)
|
2013-05-19 19:29:23 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
#if !defined LUNATIC
|
2016-08-27 01:41:21 +00:00
|
|
|
for (bssize_t j=0; j<g_gameVarCount; j++)
|
2008-07-18 02:46:24 +00:00
|
|
|
{
|
2017-10-31 02:09:25 +00:00
|
|
|
if (aGameVars[j].flags & GAMEVAR_NORESET)
|
|
|
|
continue;
|
|
|
|
|
2016-08-27 01:40:35 +00:00
|
|
|
if (aGameVars[j].flags & (GAMEVAR_PERPLAYER|GAMEVAR_PERACTOR))
|
2017-10-31 02:09:25 +00:00
|
|
|
ALIGNED_FREE_AND_NULL(pMapInfo->savedstate->vars[j]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (bssize_t j=0; j<g_gameArrayCount; j++)
|
|
|
|
{
|
|
|
|
if (aGameArrays[j].flags & GAMEARRAY_RESTORE)
|
|
|
|
ALIGNED_FREE_AND_NULL(pMapInfo->savedstate->arrays[j]);
|
2008-07-18 02:46:24 +00:00
|
|
|
}
|
2013-10-27 21:12:20 +00:00
|
|
|
#else
|
2016-08-27 01:40:56 +00:00
|
|
|
Bfree(pMapInfo->savedstate->savecode);
|
2013-01-20 21:17:06 +00:00
|
|
|
#endif
|
2017-10-31 02:09:25 +00:00
|
|
|
|
|
|
|
ALIGNED_FREE_AND_NULL(pMapInfo->savedstate);
|
2008-08-09 19:59:41 +00:00
|
|
|
}
|