2010-08-02 08:13:51 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010 EDuke32 developers and contributors
|
|
|
|
|
|
|
|
This file is part of EDuke32.
|
|
|
|
|
|
|
|
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.
|
2010-08-02 08:13:51 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef sector_h_
|
|
|
|
#define sector_h_
|
2010-08-02 08:13:51 +00:00
|
|
|
|
2012-02-09 22:44:45 +00:00
|
|
|
#include "actors.h" // actor_t
|
2018-11-18 18:09:48 +00:00
|
|
|
#include "gamevars.h"
|
|
|
|
#include "macros.h"
|
2013-12-26 19:45:14 +00:00
|
|
|
#include "namesdyn.h" // for G_GetForcefieldPicnum()
|
2018-11-18 18:09:48 +00:00
|
|
|
#include "player.h" // playerspawn_t
|
2010-08-02 08:13:51 +00:00
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-02-25 21:50:19 +00:00
|
|
|
#define MAXCYCLERS 1024
|
2016-01-21 19:34:56 +00:00
|
|
|
#define MAXANIMATES 1024
|
2011-02-25 21:50:19 +00:00
|
|
|
#define MAXANIMWALLS 512
|
2016-01-21 19:35:30 +00:00
|
|
|
#define MAXANIMPOINTS 2048
|
2010-08-02 08:13:51 +00:00
|
|
|
|
2014-12-21 15:51:48 +00:00
|
|
|
#define VIEWSCREEN_ACTIVE_DISTANCE 8192
|
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
typedef struct {
|
|
|
|
int16_t wallnum, tag;
|
|
|
|
} animwalltype;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
// this needs to have a copy of everything related to the map/actor state
|
|
|
|
// see savegame.c
|
2016-08-27 01:42:01 +00:00
|
|
|
int32_t g_animateGoal[MAXANIMATES], g_animateVel[MAXANIMATES], g_animateCnt;
|
|
|
|
intptr_t g_animatePtr[MAXANIMATES];
|
2010-08-02 08:13:51 +00:00
|
|
|
int32_t lockclock;
|
2016-01-21 19:35:30 +00:00
|
|
|
vec2_t origins[MAXANIMPOINTS];
|
2010-08-02 08:13:51 +00:00
|
|
|
int32_t randomseed, g_globalRandom;
|
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
|
|
|
int32_t pskyidx;
|
2010-08-02 08:13:51 +00:00
|
|
|
|
|
|
|
int16_t SpriteDeletionQueue[1024],g_spriteDeleteQueuePos;
|
2016-08-27 01:42:01 +00:00
|
|
|
int16_t g_animateSect[MAXANIMATES];
|
|
|
|
int16_t g_cyclers[MAXCYCLERS][6];
|
2010-08-02 08:13:51 +00:00
|
|
|
int16_t g_mirrorWall[64], g_mirrorSector[64], g_mirrorCount;
|
2016-08-27 01:42:01 +00:00
|
|
|
int16_t g_animWallCnt;
|
|
|
|
int16_t g_cloudCnt,g_cloudSect[256],g_cloudX,g_cloudY;
|
|
|
|
int16_t g_cyclerCnt;
|
2012-03-14 22:31:49 +00:00
|
|
|
|
|
|
|
int32_t numsprites;
|
2012-03-13 20:07:17 +00:00
|
|
|
int16_t tailspritefree;
|
2010-08-02 08:13:51 +00:00
|
|
|
int16_t headspritesect[MAXSECTORS+1];
|
|
|
|
int16_t headspritestat[MAXSTATUS+1];
|
|
|
|
int16_t nextspritesect[MAXSPRITES];
|
|
|
|
int16_t nextspritestat[MAXSPRITES];
|
|
|
|
int16_t numsectors;
|
|
|
|
int16_t numwalls;
|
|
|
|
int16_t prevspritesect[MAXSPRITES];
|
|
|
|
int16_t prevspritestat[MAXSPRITES];
|
|
|
|
|
2013-02-11 17:16:50 +00:00
|
|
|
uint16_t g_earthquakeTime;
|
2016-08-27 01:42:01 +00:00
|
|
|
int8_t g_playerSpawnCnt;
|
2012-03-11 17:37:50 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
uint8_t show2dsector[(MAXSECTORS+7)>>3];
|
|
|
|
|
|
|
|
actor_t actor[MAXSPRITES];
|
|
|
|
playerspawn_t g_playerSpawnPoints[MAXPLAYERS];
|
|
|
|
animwalltype animwall[MAXANIMWALLS];
|
2016-06-21 00:33:58 +00:00
|
|
|
usectortype sector[MAXSECTORS];
|
2010-08-02 08:13:51 +00:00
|
|
|
spriteext_t spriteext[MAXSPRITES];
|
2016-06-21 00:33:58 +00:00
|
|
|
uspritetype sprite[MAXSPRITES];
|
|
|
|
uwalltype wall[MAXWALLS];
|
2017-06-25 11:23:53 +00:00
|
|
|
#ifndef NEW_MAP_FORMAT
|
|
|
|
wallext_t wallext[MAXWALLS];
|
|
|
|
#endif
|
2013-10-27 21:12:20 +00:00
|
|
|
#if !defined LUNATIC
|
2012-05-17 23:54:43 +00:00
|
|
|
intptr_t *vars[MAXGAMEVARS];
|
2016-02-13 21:05:57 +00:00
|
|
|
intptr_t *arrays[MAXGAMEARRAYS];
|
2017-10-31 02:09:25 +00:00
|
|
|
int32_t arraysiz[MAXGAMEARRAYS];
|
2013-10-27 21:12:20 +00:00
|
|
|
#else
|
|
|
|
char *savecode;
|
|
|
|
#endif
|
2012-03-11 17:37:08 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
int32_t numyaxbunches;
|
2013-04-09 17:35:11 +00:00
|
|
|
# if !defined NEW_MAP_FORMAT
|
2012-03-11 17:37:08 +00:00
|
|
|
int16_t yax_bunchnum[MAXSECTORS][2];
|
|
|
|
int16_t yax_nextwall[MAXWALLS][2];
|
2013-04-09 17:35:11 +00:00
|
|
|
# endif
|
2012-03-11 17:37:08 +00:00
|
|
|
#endif
|
2010-08-02 08:13:51 +00:00
|
|
|
} mapstate_t;
|
|
|
|
|
2013-05-19 19:29:26 +00:00
|
|
|
extern void G_SaveMapState();
|
|
|
|
extern void G_RestoreMapState();
|
2010-08-02 08:13:51 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int32_t partime, designertime;
|
2015-01-25 12:17:59 +00:00
|
|
|
char *name, *filename, *musicfn;
|
2010-08-02 08:13:51 +00:00
|
|
|
mapstate_t *savedstate;
|
|
|
|
} map_t;
|
|
|
|
|
2017-01-05 05:29:33 +00:00
|
|
|
//extern map_t g_mapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music
|
2010-08-02 08:13:51 +00:00
|
|
|
|
2018-10-16 06:08:58 +00:00
|
|
|
void G_ActivateBySector(int sect,int spriteNum);
|
2017-01-01 13:23:29 +00:00
|
|
|
int S_FindMusicSFX(int sectNum, int *sndptr);
|
2016-08-27 01:42:01 +00:00
|
|
|
int A_CallSound(int sectNum,int spriteNum);
|
|
|
|
int A_CheckHitSprite(int spriteNum,int16_t *hitSprite);
|
2018-10-16 06:08:58 +00:00
|
|
|
void A_DamageObject_Internal(int spriteNum, int dmgSrc);
|
|
|
|
void A_DamageObject(int spriteNum,int dmgSrc);
|
|
|
|
void A_DamageWall_Internal(int spr, int dawallnum, const vec3_t *pos, int weaponNum);
|
|
|
|
void A_DamageWall(int spr,int dawallnum,const vec3_t *pos,int weaponNum);
|
2016-08-27 01:42:01 +00:00
|
|
|
int __fastcall A_FindPlayer(const spritetype *pSprite,int32_t *dist);
|
2012-09-12 09:45:14 +00:00
|
|
|
void G_AlignWarpElevators(void);
|
2016-08-27 01:42:01 +00:00
|
|
|
int CheckDoorTile(int tileNum);
|
|
|
|
void G_AnimateCamSprite(int smoothRatio);
|
2010-08-02 08:13:51 +00:00
|
|
|
void G_AnimateWalls(void);
|
2018-10-16 06:08:58 +00:00
|
|
|
int G_ActivateWarpElevators(int s,int warpDir);
|
2016-08-27 01:42:01 +00:00
|
|
|
int G_CheckActivatorMotion(int lotag);
|
2010-08-02 08:13:51 +00:00
|
|
|
void G_DoSectorAnimations(void);
|
2018-10-16 06:08:58 +00:00
|
|
|
void G_OperateActivators(int lotag, int playerNum);
|
2016-08-27 01:41:46 +00:00
|
|
|
void G_OperateForceFields(int spriteNum,int wallTag);
|
2018-10-16 06:08:58 +00:00
|
|
|
void G_OperateMasterSwitches(int lotag);
|
2016-08-27 01:42:01 +00:00
|
|
|
void G_OperateRespawns(int lotag);
|
|
|
|
void G_OperateSectors(int sectNum,int spriteNum);
|
|
|
|
void P_HandleSharedKeys(int playerNum);
|
|
|
|
int GetAnimationGoal(const int32_t *animPtr);
|
|
|
|
int isanearoperator(int lotag);
|
|
|
|
int isanunderoperator(int lotag);
|
2018-10-16 06:08:58 +00:00
|
|
|
int P_ActivateSwitch(int playerNum, int wallOrSprite, int nSwitchType);
|
|
|
|
void P_CheckSectors(int playerNum);
|
|
|
|
void Sect_DamageFloor_Internal(int spriteNum, int sectNum);
|
|
|
|
void Sect_DamageFloor(int spriteNum, int sectNum);
|
|
|
|
void Sect_DamageCeiling_Internal(int spriteNum, int sectNum);
|
|
|
|
void Sect_DamageCeiling(int spriteNum, int sectNum);
|
2016-08-27 01:42:01 +00:00
|
|
|
int SetAnimation(int sectNum,int32_t *animPtr,int goalVal,int animVel);
|
2010-08-02 08:13:51 +00:00
|
|
|
|
2013-12-26 19:45:14 +00:00
|
|
|
#define FORCEFIELD_CSTAT (64+16+4+1)
|
|
|
|
|
|
|
|
// Returns W_FORCEFIELD if wall has a forcefield overpicnum, its overpicnum else.
|
2016-08-27 01:41:46 +00:00
|
|
|
static inline int G_GetForcefieldPicnum(int wallNum)
|
2013-12-26 19:45:14 +00:00
|
|
|
{
|
2016-08-27 01:41:46 +00:00
|
|
|
int tileNum = wall[wallNum].overpicnum;
|
|
|
|
if (tileNum == W_FORCEFIELD + 1)
|
|
|
|
tileNum = W_FORCEFIELD;
|
|
|
|
return tileNum;
|
2013-12-26 19:45:14 +00:00
|
|
|
}
|
|
|
|
|
2014-12-27 17:17:52 +00:00
|
|
|
// Returns the interpolated position of the camera that the player is looking
|
|
|
|
// through (using a viewscreen). <i> should be the player's ->newowner member.
|
|
|
|
static inline vec3_t G_GetCameraPosition(int32_t i, int32_t smoothratio)
|
|
|
|
{
|
|
|
|
const spritetype *const cs = &sprite[i];
|
|
|
|
const actor_t *const ca = &actor[i];
|
|
|
|
|
|
|
|
vec3_t cam = { ca->bpos.x + mulscale16(cs->x - ca->bpos.x, smoothratio),
|
|
|
|
ca->bpos.y + mulscale16(cs->y - ca->bpos.y, smoothratio),
|
|
|
|
ca->bpos.z + mulscale16(cs->z - ca->bpos.z, smoothratio)
|
|
|
|
};
|
|
|
|
return cam;
|
|
|
|
}
|
|
|
|
|
2016-01-08 01:33:35 +00:00
|
|
|
EXTERN_INLINE_HEADER int32_t G_CheckPlayerInSector(int32_t sect);
|
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-01-08 01:33:35 +00:00
|
|
|
#if defined sector_c_ || !defined DISABLE_INLINING
|
|
|
|
|
|
|
|
EXTERN_INLINE int32_t G_CheckPlayerInSector(int32_t sect)
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
for (TRAVERSE_CONNECT(i))
|
|
|
|
if ((unsigned)g_player[i].ps->i < MAXSPRITES && sprite[g_player[i].ps->i].sectnum == sect)
|
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2012-11-05 02:49:08 +00:00
|
|
|
|
2010-08-02 08:13:51 +00:00
|
|
|
#endif
|