2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** p_terrain.h
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __P_TERRAIN_H__
|
|
|
|
#define __P_TERRAIN_H__
|
|
|
|
|
2008-06-15 02:25:09 +00:00
|
|
|
#include "s_sound.h"
|
2008-06-15 18:36:26 +00:00
|
|
|
#include "textures/textures.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-09-17 01:36:14 +00:00
|
|
|
class PClass;
|
2008-09-15 00:47:31 +00:00
|
|
|
|
2009-10-16 16:04:19 +00:00
|
|
|
extern WORD DefaultTerrainType;
|
|
|
|
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
class FTerrainTypeArray
|
|
|
|
{
|
|
|
|
public:
|
2009-10-16 16:04:19 +00:00
|
|
|
TArray<WORD> Types;
|
2008-06-15 18:36:26 +00:00
|
|
|
|
2009-10-16 16:04:19 +00:00
|
|
|
WORD operator [](FTextureID tex) const
|
2008-06-15 18:36:26 +00:00
|
|
|
{
|
2014-12-25 19:43:40 +00:00
|
|
|
if ((unsigned)tex.GetIndex() >= Types.Size()) return DefaultTerrainType;
|
2009-10-16 16:04:19 +00:00
|
|
|
WORD type = Types[tex.GetIndex()];
|
|
|
|
return type == 0xffff? DefaultTerrainType : type;
|
2008-06-15 18:36:26 +00:00
|
|
|
}
|
2009-10-16 16:04:19 +00:00
|
|
|
WORD operator [](int texnum) const
|
2008-06-15 18:36:26 +00:00
|
|
|
{
|
2014-12-25 19:43:40 +00:00
|
|
|
if ((unsigned)texnum >= Types.Size()) return DefaultTerrainType;
|
2009-10-16 16:04:19 +00:00
|
|
|
WORD type = Types[texnum];
|
|
|
|
return type == 0xffff? DefaultTerrainType : type;
|
2008-06-15 18:36:26 +00:00
|
|
|
}
|
|
|
|
void Resize(unsigned newsize)
|
|
|
|
{
|
|
|
|
Types.Resize(newsize);
|
|
|
|
}
|
2009-10-16 16:04:19 +00:00
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
memset (&Types[0], 0xff, Types.Size()*sizeof(WORD));
|
|
|
|
}
|
|
|
|
void Set(int index, int value)
|
|
|
|
{
|
2015-04-11 16:09:18 +00:00
|
|
|
if ((unsigned)index >= Types.Size())
|
|
|
|
{
|
|
|
|
int oldsize = Types.Size();
|
|
|
|
Resize(index + 1);
|
|
|
|
memset(&Types[oldsize], 0xff, (index + 1 - oldsize)*sizeof(WORD));
|
|
|
|
}
|
2009-10-16 16:04:19 +00:00
|
|
|
Types[index] = value;
|
|
|
|
}
|
2008-06-15 18:36:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern FTerrainTypeArray TerrainTypes;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// at game start
|
|
|
|
void P_InitTerrainTypes ();
|
|
|
|
|
|
|
|
struct FSplashDef
|
|
|
|
{
|
2006-05-09 15:07:45 +00:00
|
|
|
FName Name;
|
2008-06-15 02:25:09 +00:00
|
|
|
FSoundID SmallSplashSound;
|
|
|
|
FSoundID NormalSplashSound;
|
2010-04-03 04:07:17 +00:00
|
|
|
PClassActor *SmallSplash;
|
|
|
|
PClassActor *SplashBase;
|
|
|
|
PClassActor *SplashChunk;
|
2006-09-14 00:02:31 +00:00
|
|
|
BYTE ChunkXVelShift;
|
|
|
|
BYTE ChunkYVelShift;
|
|
|
|
BYTE ChunkZVelShift;
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t ChunkBaseZVel;
|
|
|
|
fixed_t SmallSplashClip;
|
|
|
|
bool NoAlert;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FTerrainDef
|
|
|
|
{
|
2006-05-09 15:07:45 +00:00
|
|
|
FName Name;
|
2006-02-24 04:48:15 +00:00
|
|
|
int Splash;
|
|
|
|
int DamageAmount;
|
2006-10-31 14:53:21 +00:00
|
|
|
FName DamageMOD;
|
2006-02-24 04:48:15 +00:00
|
|
|
int DamageTimeMask;
|
|
|
|
fixed_t FootClip;
|
|
|
|
float StepVolume;
|
|
|
|
int WalkStepTics;
|
|
|
|
int RunStepTics;
|
2008-06-15 02:25:09 +00:00
|
|
|
FSoundID LeftStepSound;
|
|
|
|
FSoundID RightStepSound;
|
2006-02-24 04:48:15 +00:00
|
|
|
bool IsLiquid;
|
2008-03-22 17:20:54 +00:00
|
|
|
bool AllowProtection;
|
2006-02-24 04:48:15 +00:00
|
|
|
fixed_t Friction;
|
|
|
|
fixed_t MoveFactor;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern TArray<FSplashDef> Splashes;
|
|
|
|
extern TArray<FTerrainDef> Terrains;
|
|
|
|
|
2016-01-09 11:28:42 +00:00
|
|
|
class FArchive;
|
2016-01-09 11:10:36 +00:00
|
|
|
int P_FindTerrain(FName name);
|
2016-01-09 11:28:42 +00:00
|
|
|
void P_SerializeTerrain(FArchive &arc, int &terrainnum);
|
2016-01-09 11:10:36 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
#endif //__P_TERRAIN_H__
|