mirror of
https://github.com/ptitSeb/Serious-Engine
synced 2024-11-21 18:10:26 +01:00
commit
9179b4e2f0
|
@ -29,12 +29,7 @@ void AdjustFilePath_t(CTFileName &fnm)
|
|||
}
|
||||
|
||||
// class constructor
|
||||
CDependInfo::CDependInfo(CTFileName fnFileName, CTFileName fnParent)
|
||||
{
|
||||
// copy file name
|
||||
di_fnFileName = fnFileName;
|
||||
di_fnParent = fnParent;
|
||||
}
|
||||
CDependInfo::CDependInfo(CTFileName fnFileName, CTFileName fnParent): /*copy file name*/ di_fnFileName(fnFileName), di_fnParent(fnParent){}
|
||||
|
||||
BOOL CDependInfo::IsFileOnDiskUpdated(void)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ const char *CTFileName::convertFromWin32(const char *src)
|
|||
static const char *dirsep = NULL;
|
||||
static size_t seplen = 0;
|
||||
static char buf[MAX_PATH]; // This is NOT thread safe, fyi.
|
||||
char *dest = buf;
|
||||
char *dest;
|
||||
|
||||
if (src == NULL)
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ const char *CTFileName::convertToWin32(const char *src)
|
|||
static const char *dirsep = NULL;
|
||||
static size_t seplen = 0;
|
||||
static char buf[MAX_PATH]; // This is NOT thread safe, fyi.
|
||||
char *dest = buf;
|
||||
char *dest;
|
||||
|
||||
if (src == NULL)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2002-2012 Croteam Ltd.
|
||||
/* Copyright (c) 2002-2012 Croteam Ltd.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of version 2 of the GNU General Public License as published by
|
||||
the Free Software Foundation
|
||||
|
@ -182,6 +182,7 @@ CTString ScriptEsc(const CTString &str)
|
|||
|
||||
#pragma inline_depth(0)
|
||||
void MakeAccessViolation(void* pArgs)
|
||||
|
||||
{
|
||||
INDEX bDont = NEXTARGUMENT(INDEX);
|
||||
if( bDont) return;
|
||||
|
@ -674,7 +675,7 @@ FLOAT CShell::GetFLOAT(const CTString &strName)
|
|||
// error
|
||||
ASSERT(FALSE);
|
||||
return -666.0f;
|
||||
}
|
||||
}
|
||||
// get it
|
||||
return *(FLOAT*)pss->ss_pvValue;
|
||||
}
|
||||
|
@ -688,7 +689,7 @@ void CShell::SetFLOAT(const CTString &strName, FLOAT fValue)
|
|||
// error
|
||||
ASSERT(FALSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// set it
|
||||
*(FLOAT*)pss->ss_pvValue = fValue;
|
||||
}
|
||||
|
@ -703,7 +704,7 @@ INDEX CShell::GetINDEX(const CTString &strName)
|
|||
// error
|
||||
ASSERT(FALSE);
|
||||
return -666;
|
||||
}
|
||||
}
|
||||
// get it
|
||||
return *(INDEX*)pss->ss_pvValue;
|
||||
}
|
||||
|
@ -717,7 +718,7 @@ void CShell::SetINDEX(const CTString &strName, INDEX iValue)
|
|||
// error
|
||||
ASSERT(FALSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// set it
|
||||
*(INDEX*)pss->ss_pvValue = iValue;
|
||||
}
|
||||
|
@ -732,7 +733,7 @@ CTString CShell::GetString(const CTString &strName)
|
|||
// error
|
||||
ASSERT(FALSE);
|
||||
return "<invalid>";
|
||||
}
|
||||
}
|
||||
// get it
|
||||
return *(CTString*)pss->ss_pvValue;
|
||||
}
|
||||
|
@ -746,7 +747,7 @@ void CShell::SetString(const CTString &strName, const CTString &strValue)
|
|||
// error
|
||||
ASSERT(FALSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// set it
|
||||
*(CTString*)pss->ss_pvValue = strValue;
|
||||
}
|
||||
|
@ -762,7 +763,7 @@ CTString CShell::GetValue(const CTString &strName)
|
|||
// error
|
||||
ASSERT(FALSE);
|
||||
return "<invalid>";
|
||||
}
|
||||
}
|
||||
|
||||
// get it
|
||||
ShellTypeType stt = _shell_ast[pss->ss_istType].st_sttType;
|
||||
|
@ -795,7 +796,7 @@ void CShell::SetValue(const CTString &strName, const CTString &strValue)
|
|||
// error
|
||||
ASSERT(FALSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// get it
|
||||
ShellTypeType stt = _shell_ast[pss->ss_istType].st_sttType;
|
||||
switch(stt) {
|
||||
|
|
|
@ -166,11 +166,8 @@ CTString GetZlibError(int ierr)
|
|||
}
|
||||
}
|
||||
|
||||
CZipHandle::CZipHandle(void)
|
||||
CZipHandle::CZipHandle(void): zh_bOpen(FALSE), zh_fFile(NULL), zh_pubBufIn(NULL)
|
||||
{
|
||||
zh_bOpen = FALSE;
|
||||
zh_fFile = NULL;
|
||||
zh_pubBufIn = NULL;
|
||||
memset(&zh_zstream, 0, sizeof(zh_zstream));
|
||||
}
|
||||
void CZipHandle::Clear(void)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2002-2012 Croteam Ltd.
|
||||
/* Copyright (c) 2002-2012 Croteam Ltd.
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of version 2 of the GNU General Public License as published by
|
||||
the Free Software Foundation
|
||||
|
@ -593,7 +593,7 @@ extern void GameAgent_EnumTrigger(BOOL bInternet)
|
|||
if ( _pNetwork->ga_bEnumerationChange ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( !bInternet && ga_bMSLegacy) {
|
||||
// make sure that there are no requests still stuck in buffer
|
||||
ga_asrRequests.Clear();
|
||||
|
@ -866,7 +866,7 @@ extern void GameAgent_EnumTrigger(BOOL bInternet)
|
|||
_bActivated = TRUE;
|
||||
_bInitialized = TRUE;
|
||||
_initializeWinsock();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1051,7 +1051,7 @@ extern void GameAgent_EnumUpdate(void)
|
|||
pthread_detach(_hThread);
|
||||
}
|
||||
_bActivatedLocal = FALSE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* MSLegacy */
|
||||
if(_bActivated) {
|
||||
|
@ -1152,7 +1152,7 @@ void* _MS_Thread(void *arg) {
|
|||
/** do recvfrom stuff **/
|
||||
iRet = recvfrom(_sockudp, _szBuffer, 2048, 0, (sockaddr*)&_sinClient, &_iClientLength);
|
||||
FD_CLR(_sockudp, &readfds_udp);
|
||||
if(iRet != -1 && iRet > 100 && iRet != SOCKET_ERROR) {
|
||||
if(iRet > 100 && iRet != SOCKET_ERROR) {
|
||||
// null terminate the buffer
|
||||
_szBuffer[iRet] = 0;
|
||||
char *sPch = NULL;
|
||||
|
@ -1360,7 +1360,7 @@ void* _LocalNet_Thread(void *arg) {
|
|||
/** do recvfrom stuff **/
|
||||
iRet = recvfrom(_sockudp, _szBuffer, 2048, 0, (sockaddr*)&_sinClient, &_iClientLength);
|
||||
FD_CLR(_sockudp, &readfds_udp);
|
||||
if(iRet != -1 && iRet > 100 && iRet != SOCKET_ERROR) {
|
||||
if(iRet > 100 && iRet != SOCKET_ERROR) {
|
||||
// null terminate the buffer
|
||||
_szBuffer[iRet] = 0;
|
||||
char *sPch = NULL;
|
||||
|
@ -1370,7 +1370,7 @@ void* _LocalNet_Thread(void *arg) {
|
|||
if(_szIPPortBufferLocal != NULL) {
|
||||
delete[] _szIPPortBufferLocal;
|
||||
}
|
||||
_szIPPortBufferLocal = NULL;
|
||||
_szIPPortBufferLocal = NULL;
|
||||
WSACleanup();
|
||||
return 0;
|
||||
} else {
|
||||
|
|
|
@ -2002,9 +2002,8 @@ void CLayerMixer::MixOneMipmapDynamic( CBrushShadowMap *pbsm, INDEX iMipmap)
|
|||
|
||||
|
||||
// constructor
|
||||
CLayerMixer::CLayerMixer( CBrushShadowMap *pbsm, INDEX iFirstMip, INDEX iLastMip, BOOL bDynamic)
|
||||
CLayerMixer::CLayerMixer( CBrushShadowMap *pbsm, INDEX iFirstMip, INDEX iLastMip, BOOL bDynamic): lm_bDynamic(bDynamic)
|
||||
{
|
||||
lm_bDynamic = bDynamic;
|
||||
if( bDynamic) {
|
||||
// check dynamic layers for complete blackness
|
||||
BOOL bAllBlack = TRUE;
|
||||
|
|
|
@ -195,9 +195,7 @@ public:
|
|||
// array for holding edges that proceed with testing
|
||||
CDynamicArray<DOUBLEbspedge3D> oc_abedProceeding;
|
||||
|
||||
CObjectCSG(void) {
|
||||
oc_bCSGIngoringEnabled = FALSE;
|
||||
oc_bSkipObjectB = FALSE;
|
||||
CObjectCSG(void): oc_bCSGIngoringEnabled(FALSE), oc_bSkipObjectB(FALSE){
|
||||
}
|
||||
|
||||
/* Add an entire array of BSP edges to some polygon according to action code. */
|
||||
|
|
|
@ -480,9 +480,6 @@ BOOL CClientInterface::UpdateInputBuffers(void)
|
|||
// take this packet out of the input buffer
|
||||
ci_pbInputBuffer.RemovePacket(ppaPacket->pa_ulSequence,FALSE);
|
||||
|
||||
if (ppaPacket->pa_ulSequence == 8) {
|
||||
ppaPacket->pa_ulSequence = 8;
|
||||
}
|
||||
// a packet can be accepted from the broadcast ID only if it is an acknowledge packet or
|
||||
// if it is a connection confirmation response packet and the client isn't already connected
|
||||
if (ppaPacket->pa_adrAddress.adr_uwID == SLASHSLASH || ppaPacket->pa_adrAddress.adr_uwID == 0) {
|
||||
|
|
|
@ -81,12 +81,7 @@ struct TickMarker {
|
|||
UBYTE tm_ubAcknowledgesExpected;
|
||||
UWORD tm_uwNumMessages;
|
||||
|
||||
TickMarker() {
|
||||
tm_fTickTime = -1;
|
||||
tm_slTickOffset = -1;
|
||||
tm_ubAcknowledgesExpected = 0;
|
||||
tm_uwNumMessages = 0;
|
||||
}
|
||||
TickMarker(): tm_fTickTime(-1), tm_fTickTime(-1), tm_ubAcknowledgesExpected(0), tm_uwNumMessages (0){}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
CEntityPointer ehi_epEntityPointer;
|
||||
CClientEntry ehi_ceClientEntries[SERVER_CLIENTS];
|
||||
|
||||
CEntityHashItem() {ehi_ulEntityID = -1;} // entity pointer will initialize itself to NULL
|
||||
CEntityHashItem(): ehi_ulEntityID(-1){} // entity pointer will initialize itself to NULL
|
||||
|
||||
~CEntityItem() {}; // entity poiner will destroy itself and remove the reference
|
||||
|
||||
|
|
|
@ -185,9 +185,7 @@ public:
|
|||
~CGatherCRC();
|
||||
};
|
||||
|
||||
CGatherCRC::CGatherCRC() {
|
||||
bOld = CRCT_bGatherCRCs;
|
||||
}
|
||||
CGatherCRC::CGatherCRC(): bOld(CRCT_bGatherCRCs){}
|
||||
CGatherCRC::~CGatherCRC() {
|
||||
CRCT_bGatherCRCs = bOld;
|
||||
}
|
||||
|
|
|
@ -165,8 +165,7 @@ void SelectVertexOnRender(CBrushVertex &bvx, const PIX2D &vpix)
|
|||
// if selecting with lasso
|
||||
} else {
|
||||
// if the vertex is set in lasso buffer
|
||||
if (_pubLassoBuffer!=NULL
|
||||
&&_pubLassoBuffer[vpix(2)*_pixSizeI+vpix(1)]) {
|
||||
if (_pubLassoBuffer[vpix(2)*_pixSizeI+vpix(1)]) {
|
||||
|
||||
// if alternative
|
||||
if (_bSelectAlternative) {
|
||||
|
|
|
@ -186,11 +186,9 @@ static FLOAT HitCheckQuad(const PIX ix, const PIX iz)
|
|||
// if the polygon is intersected by the ray, and it is the closest intersection so far
|
||||
if (isIntersector.IsIntersecting() && (fHitDistance < fDistance)) {
|
||||
// remember hit coordinates
|
||||
if(fHitDistance<fDistance) {
|
||||
fDistance = fHitDistance;
|
||||
_vHitExact = vHitPoint;
|
||||
_plHitPlane = plTriPlane;
|
||||
}
|
||||
_plHitPlane = plTriPlane;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ CTFileName CEngineGUI::CreateTexture(CTFileName fnTexFileToRecreate/*=CTString("
|
|||
CDlgChooseTextureType dlgChooseTextureType;
|
||||
int iDlgResult = dlgChooseTextureType.DoModal();
|
||||
// if user choosed a texture type
|
||||
if( (iDlgResult != -1) && (iDlgResult >= 0) && (iDlgResult <= 2) )
|
||||
if( (iDlgResult >= 0) && (iDlgResult <= 2) )
|
||||
{
|
||||
// if result is 2 we want to create effect texture
|
||||
if( iDlgResult == 2)
|
||||
|
|
|
@ -1,215 +1,208 @@
|
|||
// common headers for flesh entity classes
|
||||
|
||||
#include <Entities/Debris.h> /* rcg10062001 need enum definition... */
|
||||
#include <Entities/KeyItem.h> /* rcg10062001 need enum definition... */
|
||||
|
||||
#define SURFACE_SAND 9
|
||||
#define SURFACE_WATER 12
|
||||
#define SURFACE_RED_SAND 13
|
||||
|
||||
// Max ammo
|
||||
#define MAX_BULLETS INDEX(500)
|
||||
#define MAX_SHELLS INDEX(100)
|
||||
#define MAX_ROCKETS INDEX(50)
|
||||
#define MAX_GRENADES INDEX(50)
|
||||
//#define MAX_NAPALM INDEX(250)
|
||||
#define MAX_ELECTRICITY INDEX(400)
|
||||
#define MAX_IRONBALLS INDEX(30)
|
||||
//#define MAX_NUKEBALLS INDEX(3)
|
||||
|
||||
// Bit shifters for ammo
|
||||
#define AMMO_BULLETS 0
|
||||
#define AMMO_SHELLS 1
|
||||
#define AMMO_ROCKETS 2
|
||||
#define AMMO_GRENADES 3
|
||||
//#define AMMO_NAPALM 4
|
||||
#define AMMO_ELECTRICITY 5
|
||||
//#define AMMO_NUKEBALLS 6
|
||||
#define AMMO_IRONBALLS 7
|
||||
|
||||
|
||||
// Ammo mana Value
|
||||
#define AV_SHELLS INDEX(70)
|
||||
#define AV_BULLETS INDEX(10)
|
||||
#define AV_ROCKETS INDEX(150)
|
||||
#define AV_GRENADES INDEX(150)
|
||||
#define AV_ELECTRICITY INDEX(250)
|
||||
#define AV_IRONBALLS INDEX(700)
|
||||
//#define AV_NUKEBALLS INDEX(1800)
|
||||
//#define AV_NAPALM INDEX(200)
|
||||
|
||||
enum EmptyShellType {
|
||||
ESL_BULLET = 0,
|
||||
ESL_SHOTGUN = 1,
|
||||
ESL_BUBBLE = 2,
|
||||
ESL_BULLET_SMOKE = 3,
|
||||
ESL_SHOTGUN_SMOKE = 4,
|
||||
ESL_COLT_SMOKE = 5,
|
||||
};
|
||||
// empty shell launch info
|
||||
#define MAX_FLYING_SHELLS 32
|
||||
struct ShellLaunchData {
|
||||
FLOAT sld_fSize; // size multiplier
|
||||
FLOAT3D sld_vPos; // launch position
|
||||
FLOAT3D sld_vSpeed; // launch speed
|
||||
FLOAT3D sld_vUp; // up vector in moment of launch
|
||||
FLOAT sld_tmLaunch; // time of launch
|
||||
EmptyShellType sld_estType; // shell type
|
||||
};
|
||||
#define ShellLaunchData_array m_asldData[MAX_FLYING_SHELLS]
|
||||
|
||||
// world change
|
||||
struct WorldChange {
|
||||
CTString strGroup; // group name
|
||||
CPlacement3D plLink; // link placement for relative change
|
||||
INDEX iType; // change type
|
||||
};
|
||||
extern struct WorldChange _SwcWorldChange;
|
||||
|
||||
// entity info
|
||||
struct EntityInfo {
|
||||
EntityInfoBodyType Eeibt; // body type
|
||||
FLOAT fMass; // mass (in kg)
|
||||
FLOAT vSourceCenter[3]; // body point (offset from handle) when entity look another entity
|
||||
FLOAT vTargetCenter[3]; // body point (offset from handle) when entity is target of look
|
||||
};
|
||||
|
||||
// entity info
|
||||
struct EntityStats {
|
||||
CTString es_strName;
|
||||
INDEX es_ctCount;
|
||||
INDEX es_ctAmmount;
|
||||
FLOAT es_fValue;
|
||||
INDEX es_iScore;
|
||||
inline void Clear() { es_strName.Clear(); }
|
||||
};
|
||||
|
||||
// statistics data for player stats management
|
||||
struct DECL_DLL PlayerStats {
|
||||
INDEX ps_iScore;
|
||||
INDEX ps_iKills;
|
||||
INDEX ps_iDeaths;
|
||||
INDEX ps_iSecrets;
|
||||
TIME ps_tmTime;
|
||||
|
||||
PlayerStats(void)
|
||||
{
|
||||
ps_iScore = 0;
|
||||
ps_iKills = 0;
|
||||
ps_iDeaths = 0;
|
||||
ps_iSecrets = 0;
|
||||
ps_tmTime = 0.0f;
|
||||
}
|
||||
};
|
||||
|
||||
// get info position for entity
|
||||
DECL_DLL void GetEntityInfoPosition(CEntity *pen, FLOAT *pf, FLOAT3D &vPos);
|
||||
// get source and target positions for ray cast
|
||||
DECL_DLL void GetPositionCastRay(CEntity *penSource, CEntity *penTarget, FLOAT3D &vSource, FLOAT3D &vTarget);
|
||||
|
||||
// set bool from bool enum type
|
||||
DECL_DLL void SetBoolFromBoolEType(BOOL &bSet, BoolEType bet);
|
||||
// send event to target
|
||||
DECL_DLL void SendToTarget(CEntity *penSendEvent, EventEType eetEventType, CEntity *penCaused = NULL);
|
||||
// send event in range
|
||||
DECL_DLL void SendInRange(CEntity *penSource, EventEType eetEventType, const FLOATaabbox3D &boxRange);
|
||||
|
||||
// spawn reminder
|
||||
DECL_DLL CEntityPointer SpawnReminder(CEntity *penOwner, FLOAT fWaitTime, INDEX iValue);
|
||||
// spawn flame
|
||||
//CEntityPointer SpawnFlame(CEntity *penOwner, CEntity *penAttach, const FLOAT3D &vSource);
|
||||
|
||||
// Set components
|
||||
DECL_DLL void SetComponents(CEntity *pen, CModelObject &mo, ULONG ulIDModel, ULONG ulIDTexture,
|
||||
ULONG ulIDReflectionTexture, ULONG ulIDSpecularTexture, ULONG ulIDBumpTexture);
|
||||
// Add attachment to model
|
||||
DECL_DLL void AddAttachmentToModel(CEntity *pen, CModelObject &mo, INDEX iAttachment, ULONG ulIDModel, ULONG ulIDTexture,
|
||||
ULONG ulIDReflectionTexture, ULONG ulIDSpecularTexture, ULONG ulIDBumpTexture);
|
||||
// Remove attachment from model
|
||||
DECL_DLL void RemoveAttachmentFromModel(CModelObject &mo, INDEX iAttachment);
|
||||
|
||||
// Kick entity
|
||||
DECL_DLL void KickEntity(CEntity *penTarget, FLOAT3D vSpeed);
|
||||
|
||||
|
||||
// lens flare variables
|
||||
extern CLensFlareType _lftStandard;
|
||||
extern CLensFlareType _lftStandardReflections;
|
||||
extern CLensFlareType _lftYellowStarRedRing;
|
||||
extern CLensFlareType _lftYellowStarRedRingFar;
|
||||
extern CLensFlareType _lftWhiteGlowStarRedRing;
|
||||
extern CLensFlareType _lftWhiteGlowStar;
|
||||
extern CLensFlareType _lftWhiteGlowStarNG;
|
||||
extern CLensFlareType _lftWhiteStarRedRingStreaks;
|
||||
extern CLensFlareType _lftWhiteStarRedReflections;
|
||||
extern CLensFlareType _lftBlueStarBlueReflections;
|
||||
extern CLensFlareType _lftProjectileStarGlow;
|
||||
extern CLensFlareType _lftProjectileWhiteBubbleGlow;
|
||||
extern CLensFlareType _lftProjectileYellowBubbleGlow;
|
||||
extern CLensFlareType _lftPVSpaceShipWindowFlare;
|
||||
extern CLensFlareType _lftCatmanFireGlow;
|
||||
extern CLensFlareType _lftWhiteGlowFar;
|
||||
// init lens flare effects
|
||||
void InitLensFlares(void);
|
||||
// close lens flares effects
|
||||
void CloseLensFlares(void);
|
||||
|
||||
DECL_DLL BOOL SetPlayerAppearance(CModelObject *mo, CPlayerCharacter *ppc, CTString &strName, BOOL bPreview);
|
||||
|
||||
// debugging functions
|
||||
DECL_DLL const char *PrintConsole(void);
|
||||
DECL_DLL const char *PrintStack(CEntity *pen);
|
||||
|
||||
// debris spawning
|
||||
DECL_DLL void Debris_Begin(
|
||||
EntityInfoBodyType Eeibt,
|
||||
enum DebrisParticlesType dptParticles,
|
||||
enum BasicEffectType betStain,
|
||||
FLOAT fEntitySize, // entity size in meters
|
||||
const FLOAT3D &vSpeed,
|
||||
const FLOAT3D &vSpawnerSpeed, // how fast was the entity moving
|
||||
const FLOAT fConeSize, // size multiplier for debris cone
|
||||
const FLOAT fSpeedUp, // size multiplier for debris catapulting up (0-no multiply)
|
||||
const COLOR colDebris=C_WHITE // multiply color
|
||||
);
|
||||
DECL_DLL CEntityPointer Debris_Spawn(
|
||||
CEntity *penSpawner,
|
||||
CEntity *penComponents,
|
||||
SLONG idModelComponent,
|
||||
SLONG idTextureComponent,
|
||||
SLONG idReflectionTextureComponent,
|
||||
SLONG idSpecularTextureComponent,
|
||||
SLONG idBumpTextureComponent,
|
||||
INDEX iModelAnim,
|
||||
FLOAT fSize, // size relative to entity size (or 0 for absolute stretch of 1)
|
||||
const FLOAT3D &vPosRatio);
|
||||
|
||||
// get default entity info for given body type
|
||||
DECL_DLL EntityInfo *GetStdEntityInfo(EntityInfoBodyType eibt);
|
||||
// damage control functions
|
||||
DECL_DLL FLOAT DamageStrength(EntityInfoBodyType eibtBody, enum DamageType dtDamage);
|
||||
|
||||
// Print center screen message
|
||||
DECL_DLL void PrintCenterMessage(CEntity *penThis, CEntity *penTarget,
|
||||
const CTString &strMessage, TIME tmLength, enum MessageSound mssSound);
|
||||
|
||||
// get name of a key item
|
||||
DECL_DLL const char *GetKeyName(enum KeyItemType kit);
|
||||
|
||||
// get session properties
|
||||
DECL_DLL inline const CSessionProperties *GetSP(void)
|
||||
{
|
||||
return ((const CSessionProperties *)_pNetwork->GetSessionProperties());
|
||||
}
|
||||
|
||||
// i.e. weapon sound when fireing or exploding
|
||||
DECL_DLL void SpawnRangeSound( CEntity *penPlayer, CEntity *penPos, enum SoundType st, FLOAT fRange);
|
||||
|
||||
// get some player for trigger source if any is existing
|
||||
DECL_DLL CEntity *FixupCausedToPlayer(CEntity *penThis, CEntity *penCaused, BOOL bWarning=TRUE);
|
||||
|
||||
// precisely lerp between two placement using quaternions
|
||||
DECL_DLL CPlacement3D LerpPlacementsPrecise(const CPlacement3D &pl0, const CPlacement3D &pl1, FLOAT fRatio);
|
||||
|
||||
// obtain game extra damage per enemy and per player
|
||||
DECL_DLL FLOAT GetGameDamageMultiplier(void);
|
||||
// common headers for flesh entity classes
|
||||
|
||||
#include <Entities/Debris.h> /* rcg10062001 need enum definition... */
|
||||
#include <Entities/KeyItem.h> /* rcg10062001 need enum definition... */
|
||||
|
||||
#define SURFACE_SAND 9
|
||||
#define SURFACE_WATER 12
|
||||
#define SURFACE_RED_SAND 13
|
||||
|
||||
// Max ammo
|
||||
#define MAX_BULLETS INDEX(500)
|
||||
#define MAX_SHELLS INDEX(100)
|
||||
#define MAX_ROCKETS INDEX(50)
|
||||
#define MAX_GRENADES INDEX(50)
|
||||
//#define MAX_NAPALM INDEX(250)
|
||||
#define MAX_ELECTRICITY INDEX(400)
|
||||
#define MAX_IRONBALLS INDEX(30)
|
||||
//#define MAX_NUKEBALLS INDEX(3)
|
||||
|
||||
// Bit shifters for ammo
|
||||
#define AMMO_BULLETS 0
|
||||
#define AMMO_SHELLS 1
|
||||
#define AMMO_ROCKETS 2
|
||||
#define AMMO_GRENADES 3
|
||||
//#define AMMO_NAPALM 4
|
||||
#define AMMO_ELECTRICITY 5
|
||||
//#define AMMO_NUKEBALLS 6
|
||||
#define AMMO_IRONBALLS 7
|
||||
|
||||
|
||||
// Ammo mana Value
|
||||
#define AV_SHELLS INDEX(70)
|
||||
#define AV_BULLETS INDEX(10)
|
||||
#define AV_ROCKETS INDEX(150)
|
||||
#define AV_GRENADES INDEX(150)
|
||||
#define AV_ELECTRICITY INDEX(250)
|
||||
#define AV_IRONBALLS INDEX(700)
|
||||
//#define AV_NUKEBALLS INDEX(1800)
|
||||
//#define AV_NAPALM INDEX(200)
|
||||
|
||||
enum EmptyShellType {
|
||||
ESL_BULLET = 0,
|
||||
ESL_SHOTGUN = 1,
|
||||
ESL_BUBBLE = 2,
|
||||
ESL_BULLET_SMOKE = 3,
|
||||
ESL_SHOTGUN_SMOKE = 4,
|
||||
ESL_COLT_SMOKE = 5,
|
||||
};
|
||||
// empty shell launch info
|
||||
#define MAX_FLYING_SHELLS 32
|
||||
struct ShellLaunchData {
|
||||
FLOAT sld_fSize; // size multiplier
|
||||
FLOAT3D sld_vPos; // launch position
|
||||
FLOAT3D sld_vSpeed; // launch speed
|
||||
FLOAT3D sld_vUp; // up vector in moment of launch
|
||||
FLOAT sld_tmLaunch; // time of launch
|
||||
EmptyShellType sld_estType; // shell type
|
||||
};
|
||||
#define ShellLaunchData_array m_asldData[MAX_FLYING_SHELLS]
|
||||
|
||||
// world change
|
||||
struct WorldChange {
|
||||
CTString strGroup; // group name
|
||||
CPlacement3D plLink; // link placement for relative change
|
||||
INDEX iType; // change type
|
||||
};
|
||||
extern struct WorldChange _SwcWorldChange;
|
||||
|
||||
// entity info
|
||||
struct EntityInfo {
|
||||
EntityInfoBodyType Eeibt; // body type
|
||||
FLOAT fMass; // mass (in kg)
|
||||
FLOAT vSourceCenter[3]; // body point (offset from handle) when entity look another entity
|
||||
FLOAT vTargetCenter[3]; // body point (offset from handle) when entity is target of look
|
||||
};
|
||||
|
||||
// entity info
|
||||
struct EntityStats {
|
||||
CTString es_strName;
|
||||
INDEX es_ctCount;
|
||||
INDEX es_ctAmmount;
|
||||
FLOAT es_fValue;
|
||||
INDEX es_iScore;
|
||||
inline void Clear() { es_strName.Clear(); }
|
||||
};
|
||||
|
||||
// statistics data for player stats management
|
||||
struct DECL_DLL PlayerStats {
|
||||
INDEX ps_iScore;
|
||||
INDEX ps_iKills;
|
||||
INDEX ps_iDeaths;
|
||||
INDEX ps_iSecrets;
|
||||
TIME ps_tmTime;
|
||||
|
||||
PlayerStats(void): ps_iScore(0), ps_iKills(0), ps_iDeaths(0), ps_iSecrets(0), ps_tmTime(0.0f){}
|
||||
};
|
||||
|
||||
// get info position for entity
|
||||
DECL_DLL void GetEntityInfoPosition(CEntity *pen, FLOAT *pf, FLOAT3D &vPos);
|
||||
// get source and target positions for ray cast
|
||||
DECL_DLL void GetPositionCastRay(CEntity *penSource, CEntity *penTarget, FLOAT3D &vSource, FLOAT3D &vTarget);
|
||||
|
||||
// set bool from bool enum type
|
||||
DECL_DLL void SetBoolFromBoolEType(BOOL &bSet, BoolEType bet);
|
||||
// send event to target
|
||||
DECL_DLL void SendToTarget(CEntity *penSendEvent, EventEType eetEventType, CEntity *penCaused = NULL);
|
||||
// send event in range
|
||||
DECL_DLL void SendInRange(CEntity *penSource, EventEType eetEventType, const FLOATaabbox3D &boxRange);
|
||||
|
||||
// spawn reminder
|
||||
DECL_DLL CEntityPointer SpawnReminder(CEntity *penOwner, FLOAT fWaitTime, INDEX iValue);
|
||||
// spawn flame
|
||||
//CEntityPointer SpawnFlame(CEntity *penOwner, CEntity *penAttach, const FLOAT3D &vSource);
|
||||
|
||||
// Set components
|
||||
DECL_DLL void SetComponents(CEntity *pen, CModelObject &mo, ULONG ulIDModel, ULONG ulIDTexture,
|
||||
ULONG ulIDReflectionTexture, ULONG ulIDSpecularTexture, ULONG ulIDBumpTexture);
|
||||
// Add attachment to model
|
||||
DECL_DLL void AddAttachmentToModel(CEntity *pen, CModelObject &mo, INDEX iAttachment, ULONG ulIDModel, ULONG ulIDTexture,
|
||||
ULONG ulIDReflectionTexture, ULONG ulIDSpecularTexture, ULONG ulIDBumpTexture);
|
||||
// Remove attachment from model
|
||||
DECL_DLL void RemoveAttachmentFromModel(CModelObject &mo, INDEX iAttachment);
|
||||
|
||||
// Kick entity
|
||||
DECL_DLL void KickEntity(CEntity *penTarget, FLOAT3D vSpeed);
|
||||
|
||||
|
||||
// lens flare variables
|
||||
extern CLensFlareType _lftStandard;
|
||||
extern CLensFlareType _lftStandardReflections;
|
||||
extern CLensFlareType _lftYellowStarRedRing;
|
||||
extern CLensFlareType _lftYellowStarRedRingFar;
|
||||
extern CLensFlareType _lftWhiteGlowStarRedRing;
|
||||
extern CLensFlareType _lftWhiteGlowStar;
|
||||
extern CLensFlareType _lftWhiteGlowStarNG;
|
||||
extern CLensFlareType _lftWhiteStarRedRingStreaks;
|
||||
extern CLensFlareType _lftWhiteStarRedReflections;
|
||||
extern CLensFlareType _lftBlueStarBlueReflections;
|
||||
extern CLensFlareType _lftProjectileStarGlow;
|
||||
extern CLensFlareType _lftProjectileWhiteBubbleGlow;
|
||||
extern CLensFlareType _lftProjectileYellowBubbleGlow;
|
||||
extern CLensFlareType _lftPVSpaceShipWindowFlare;
|
||||
extern CLensFlareType _lftCatmanFireGlow;
|
||||
extern CLensFlareType _lftWhiteGlowFar;
|
||||
// init lens flare effects
|
||||
void InitLensFlares(void);
|
||||
// close lens flares effects
|
||||
void CloseLensFlares(void);
|
||||
|
||||
DECL_DLL BOOL SetPlayerAppearance(CModelObject *mo, CPlayerCharacter *ppc, CTString &strName, BOOL bPreview);
|
||||
|
||||
// debugging functions
|
||||
DECL_DLL const char *PrintConsole(void);
|
||||
DECL_DLL const char *PrintStack(CEntity *pen);
|
||||
|
||||
// debris spawning
|
||||
DECL_DLL void Debris_Begin(
|
||||
EntityInfoBodyType Eeibt,
|
||||
enum DebrisParticlesType dptParticles,
|
||||
enum BasicEffectType betStain,
|
||||
FLOAT fEntitySize, // entity size in meters
|
||||
const FLOAT3D &vSpeed,
|
||||
const FLOAT3D &vSpawnerSpeed, // how fast was the entity moving
|
||||
const FLOAT fConeSize, // size multiplier for debris cone
|
||||
const FLOAT fSpeedUp, // size multiplier for debris catapulting up (0-no multiply)
|
||||
const COLOR colDebris=C_WHITE // multiply color
|
||||
);
|
||||
DECL_DLL CEntityPointer Debris_Spawn(
|
||||
CEntity *penSpawner,
|
||||
CEntity *penComponents,
|
||||
SLONG idModelComponent,
|
||||
SLONG idTextureComponent,
|
||||
SLONG idReflectionTextureComponent,
|
||||
SLONG idSpecularTextureComponent,
|
||||
SLONG idBumpTextureComponent,
|
||||
INDEX iModelAnim,
|
||||
FLOAT fSize, // size relative to entity size (or 0 for absolute stretch of 1)
|
||||
const FLOAT3D &vPosRatio);
|
||||
|
||||
// get default entity info for given body type
|
||||
DECL_DLL EntityInfo *GetStdEntityInfo(EntityInfoBodyType eibt);
|
||||
// damage control functions
|
||||
DECL_DLL FLOAT DamageStrength(EntityInfoBodyType eibtBody, enum DamageType dtDamage);
|
||||
|
||||
// Print center screen message
|
||||
DECL_DLL void PrintCenterMessage(CEntity *penThis, CEntity *penTarget,
|
||||
const CTString &strMessage, TIME tmLength, enum MessageSound mssSound);
|
||||
|
||||
// get name of a key item
|
||||
DECL_DLL const char *GetKeyName(enum KeyItemType kit);
|
||||
|
||||
// get session properties
|
||||
DECL_DLL inline const CSessionProperties *GetSP(void)
|
||||
{
|
||||
return ((const CSessionProperties *)_pNetwork->GetSessionProperties());
|
||||
}
|
||||
|
||||
// i.e. weapon sound when fireing or exploding
|
||||
DECL_DLL void SpawnRangeSound( CEntity *penPlayer, CEntity *penPos, enum SoundType st, FLOAT fRange);
|
||||
|
||||
// get some player for trigger source if any is existing
|
||||
DECL_DLL CEntity *FixupCausedToPlayer(CEntity *penThis, CEntity *penCaused, BOOL bWarning=TRUE);
|
||||
|
||||
// precisely lerp between two placement using quaternions
|
||||
DECL_DLL CPlacement3D LerpPlacementsPrecise(const CPlacement3D &pl0, const CPlacement3D &pl1, FLOAT fRatio);
|
||||
|
||||
// obtain game extra damage per enemy and per player
|
||||
DECL_DLL FLOAT GetGameDamageMultiplier(void);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,282 +1,275 @@
|
|||
#include "../StdH/StdH.h"
|
||||
#include "Entities/Common/PathFinding.h"
|
||||
#include "Entities/NavigationMarker.h"
|
||||
|
||||
#define PRINTOUT(_dummy)
|
||||
//#define PRINTOUT(something) something
|
||||
|
||||
// open and closed lists of nodes
|
||||
static CListHead _lhOpen;
|
||||
static CListHead _lhClosed;
|
||||
|
||||
FLOAT NodeDistance(CPathNode *ppn0, CPathNode *ppn1)
|
||||
{
|
||||
return (
|
||||
ppn0->pn_pnmMarker->GetPlacement().pl_PositionVector -
|
||||
ppn1->pn_pnmMarker->GetPlacement().pl_PositionVector).Length();
|
||||
}
|
||||
|
||||
CPathNode::CPathNode(class CNavigationMarker *penMarker)
|
||||
{
|
||||
pn_pnmMarker = penMarker;
|
||||
pn_ppnParent = NULL;
|
||||
pn_fG = 0.0f;
|
||||
pn_fH = 0.0f;
|
||||
pn_fF = 0.0f;
|
||||
}
|
||||
|
||||
CPathNode::~CPathNode(void)
|
||||
{
|
||||
// detach from marker when deleting
|
||||
ASSERT(pn_pnmMarker!=NULL);
|
||||
pn_pnmMarker->m_ppnNode = NULL;
|
||||
}
|
||||
|
||||
// get name of this node
|
||||
const CTString &CPathNode::GetName(void)
|
||||
{
|
||||
#include "../StdH/StdH.h"
|
||||
#include "Entities/Common/PathFinding.h"
|
||||
#include "Entities/NavigationMarker.h"
|
||||
|
||||
#define PRINTOUT(_dummy)
|
||||
//#define PRINTOUT(something) something
|
||||
|
||||
// open and closed lists of nodes
|
||||
static CListHead _lhOpen;
|
||||
static CListHead _lhClosed;
|
||||
|
||||
FLOAT NodeDistance(CPathNode *ppn0, CPathNode *ppn1)
|
||||
{
|
||||
return (
|
||||
ppn0->pn_pnmMarker->GetPlacement().pl_PositionVector -
|
||||
ppn1->pn_pnmMarker->GetPlacement().pl_PositionVector).Length();
|
||||
}
|
||||
|
||||
CPathNode::CPathNode(class CNavigationMarker *penMarker): pn_pnmMarker(penMarker), pn_ppnParent(NULL), pn_fG(0.0f), pn_fH(0.0f), pn_fF(0.0f){}
|
||||
|
||||
CPathNode::~CPathNode(void)
|
||||
{
|
||||
// detach from marker when deleting
|
||||
ASSERT(pn_pnmMarker!=NULL);
|
||||
pn_pnmMarker->m_ppnNode = NULL;
|
||||
}
|
||||
|
||||
// get name of this node
|
||||
const CTString &CPathNode::GetName(void)
|
||||
{
|
||||
ASSERT(this!=NULL);
|
||||
static CTString strNone="<none>";
|
||||
if (pn_pnmMarker==NULL) {
|
||||
return strNone;
|
||||
} else {
|
||||
return pn_pnmMarker->GetName();
|
||||
}
|
||||
}
|
||||
|
||||
// get link with given index or null if no more (for iteration along the graph)
|
||||
CPathNode *CPathNode::GetLink(INDEX i)
|
||||
{
|
||||
ASSERT(this!=NULL);
|
||||
if (pn_pnmMarker==NULL) {
|
||||
ASSERT(FALSE);
|
||||
return NULL;
|
||||
}
|
||||
CNavigationMarker *pnm = pn_pnmMarker->GetLink(i);
|
||||
if (pnm==NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return pnm->GetPathNode();
|
||||
}
|
||||
|
||||
// add given node to open list, sorting best first
|
||||
static void SortIntoOpenList(CPathNode *ppnLink)
|
||||
{
|
||||
// start at head of the open list
|
||||
LISTITER(CPathNode, pn_lnInOpen) itpn(_lhOpen);
|
||||
// while the given node is further than the one in list
|
||||
while(ppnLink->pn_fF>itpn->pn_fF && !itpn.IsPastEnd()) {
|
||||
// move to next node
|
||||
itpn.MoveToNext();
|
||||
}
|
||||
|
||||
// if past the end of list
|
||||
if (itpn.IsPastEnd()) {
|
||||
// add to the end of list
|
||||
_lhOpen.AddTail(ppnLink->pn_lnInOpen);
|
||||
// if not past end of list
|
||||
} else {
|
||||
// add before current node
|
||||
itpn.InsertBeforeCurrent(ppnLink->pn_lnInOpen);
|
||||
}
|
||||
}
|
||||
|
||||
// find shortest path from one marker to another
|
||||
static BOOL FindPath(CNavigationMarker *pnmSrc, CNavigationMarker *pnmDst)
|
||||
{
|
||||
|
||||
ASSERT(pnmSrc!=pnmDst);
|
||||
CPathNode *ppnSrc = pnmSrc->GetPathNode();
|
||||
CPathNode *ppnDst = pnmDst->GetPathNode();
|
||||
|
||||
PRINTOUT(CPrintF("--------------------\n"));
|
||||
PRINTOUT(CPrintF("FindPath(%s, %s)\n", ppnSrc->GetName(), ppnDst->GetName()));
|
||||
|
||||
// start with empty open and closed lists
|
||||
ASSERT(_lhOpen.IsEmpty());
|
||||
ASSERT(_lhClosed.IsEmpty());
|
||||
|
||||
// add the start node to open list
|
||||
ppnSrc->pn_fG = 0.0f;
|
||||
ppnSrc->pn_fH = NodeDistance(ppnSrc, ppnDst);
|
||||
ppnSrc->pn_fF = ppnSrc->pn_fG +ppnSrc->pn_fH;
|
||||
_lhOpen.AddTail(ppnSrc->pn_lnInOpen);
|
||||
PRINTOUT(CPrintF("StartState: %s\n", ppnSrc->GetName()));
|
||||
|
||||
// while the open list is not empty
|
||||
while (!_lhOpen.IsEmpty()) {
|
||||
// get the first node from open list (that is, the one with lowest F)
|
||||
CPathNode *ppnNode = LIST_HEAD(_lhOpen, CPathNode, pn_lnInOpen);
|
||||
ppnNode->pn_lnInOpen.Remove();
|
||||
_lhClosed.AddTail(ppnNode->pn_lnInClosed);
|
||||
PRINTOUT(CPrintF("Node: %s - moved from OPEN to CLOSED\n", ppnNode->GetName()));
|
||||
|
||||
// if this is the goal
|
||||
if (ppnNode==ppnDst) {
|
||||
PRINTOUT(CPrintF("PATH FOUND!\n"));
|
||||
// the path is found
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// for each link of current node
|
||||
CPathNode *ppnLink = NULL;
|
||||
for(INDEX i=0; (ppnLink=ppnNode->GetLink(i))!=NULL; i++) {
|
||||
PRINTOUT(CPrintF(" Link %d: %s\n", i, ppnLink->GetName()));
|
||||
// get cost to get to this node if coming from current node
|
||||
FLOAT fNewG = ppnLink->pn_fG+NodeDistance(ppnNode, ppnLink);
|
||||
// if a shorter path already exists
|
||||
if ((ppnLink->pn_lnInOpen.IsLinked() || ppnLink->pn_lnInClosed.IsLinked()) && fNewG>=ppnLink->pn_fG) {
|
||||
PRINTOUT(CPrintF(" shorter path exists through: %s\n", ppnLink->pn_ppnParent->GetName()));
|
||||
// skip this link
|
||||
continue;
|
||||
}
|
||||
// remember this path
|
||||
ppnLink->pn_ppnParent = ppnNode;
|
||||
ppnLink->pn_fG = fNewG;
|
||||
ppnLink->pn_fH = NodeDistance(ppnLink, ppnDst);
|
||||
ppnLink->pn_fF = ppnLink->pn_fG + ppnLink->pn_fH;
|
||||
// remove from closed list, if in it
|
||||
if (ppnLink->pn_lnInClosed.IsLinked()) {
|
||||
ppnLink->pn_lnInClosed.Remove();
|
||||
PRINTOUT(CPrintF(" %s removed from CLOSED\n", ppnLink->GetName()));
|
||||
}
|
||||
// add to open if not in it
|
||||
if (!ppnLink->pn_lnInOpen.IsLinked()) {
|
||||
SortIntoOpenList(ppnLink);
|
||||
PRINTOUT(CPrintF(" %s added to OPEN\n", ppnLink->GetName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we get here, there is no path
|
||||
PRINTOUT(CPrintF("PATH NOT FOUND!\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// clear all temporary structures used for path finding
|
||||
static void ClearPath(CEntity *penThis)
|
||||
{
|
||||
{FORDELETELIST(CPathNode, pn_lnInOpen, _lhOpen, itpn) {
|
||||
delete &itpn.Current();
|
||||
}}
|
||||
{FORDELETELIST(CPathNode, pn_lnInClosed, _lhClosed, itpn) {
|
||||
delete &itpn.Current();
|
||||
}}
|
||||
|
||||
#ifndef NDEBUG
|
||||
// for each navigation marker in the world
|
||||
{FOREACHINDYNAMICCONTAINER(penThis->en_pwoWorld->wo_cenEntities, CEntity, iten) {
|
||||
if (!IsOfClass(iten, "NavigationMarker")) {
|
||||
continue;
|
||||
}
|
||||
CNavigationMarker &nm = (CNavigationMarker&)*iten;
|
||||
ASSERT(nm.m_ppnNode==NULL);
|
||||
}}
|
||||
#endif
|
||||
}
|
||||
|
||||
// find marker closest to a given position
|
||||
static void FindClosestMarker(
|
||||
CEntity *penThis, const FLOAT3D &vSrc, CEntity *&penMarker, FLOAT3D &vPath)
|
||||
{
|
||||
CNavigationMarker *pnmMin = NULL;
|
||||
FLOAT fMinDist = UpperLimit(0.0f);
|
||||
// for each sector this entity is in
|
||||
{FOREACHSRCOFDST(penThis->en_rdSectors, CBrushSector, bsc_rsEntities, pbsc)
|
||||
// for each navigation marker in that sector
|
||||
{FOREACHDSTOFSRC(pbsc->bsc_rsEntities, CEntity, en_rdSectors, pen)
|
||||
if (!IsOfClass(pen, "NavigationMarker")) {
|
||||
continue;
|
||||
}
|
||||
CNavigationMarker &nm = (CNavigationMarker&)*pen;
|
||||
|
||||
// get distance from source
|
||||
FLOAT fDist = (vSrc-nm.GetPlacement().pl_PositionVector).Length();
|
||||
// if closer than best found
|
||||
if(fDist<fMinDist) {
|
||||
// remember it
|
||||
fMinDist = fDist;
|
||||
pnmMin = &nm;
|
||||
}
|
||||
ENDFOR}
|
||||
ENDFOR}
|
||||
|
||||
// if none found
|
||||
if (pnmMin==NULL) {
|
||||
// fail
|
||||
vPath = vSrc;
|
||||
penMarker = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
// return position
|
||||
vPath = pnmMin->GetPlacement().pl_PositionVector;
|
||||
penMarker = pnmMin;
|
||||
}
|
||||
|
||||
// find first marker for path navigation
|
||||
void PATH_FindFirstMarker(CEntity *penThis, const FLOAT3D &vSrc, const FLOAT3D &vDst, CEntity *&penMarker, FLOAT3D &vPath)
|
||||
{
|
||||
// find closest markers to source and destination positions
|
||||
CNavigationMarker *pnmSrc;
|
||||
FLOAT3D vSrcPath;
|
||||
FindClosestMarker(penThis, vSrc, (CEntity*&)pnmSrc, vSrcPath);
|
||||
CNavigationMarker *pnmDst;
|
||||
FLOAT3D vDstPath;
|
||||
FindClosestMarker(penThis, vDst, (CEntity*&)pnmDst, vDstPath);
|
||||
|
||||
// if at least one is not found, or if they are same
|
||||
if (pnmSrc==NULL || pnmDst==NULL || pnmSrc==pnmDst) {
|
||||
// fail
|
||||
penMarker = NULL;
|
||||
vPath = vSrc;
|
||||
return;
|
||||
}
|
||||
|
||||
// go to the source marker position
|
||||
vPath = vSrcPath;
|
||||
penMarker = pnmSrc;
|
||||
}
|
||||
|
||||
// find next marker for path navigation
|
||||
void PATH_FindNextMarker(CEntity *penThis, const FLOAT3D &vSrc, const FLOAT3D &vDst, CEntity *&penMarker, FLOAT3D &vPath)
|
||||
{
|
||||
// find closest marker to destination position
|
||||
CNavigationMarker *pnmDst;
|
||||
FLOAT3D vDstPath;
|
||||
FindClosestMarker(penThis, vDst, (CEntity*&)pnmDst, vDstPath);
|
||||
|
||||
// if at not found, or if same as current
|
||||
if (pnmDst==NULL || penMarker==pnmDst) {
|
||||
// fail
|
||||
penMarker = NULL;
|
||||
vPath = vSrc;
|
||||
return;
|
||||
}
|
||||
|
||||
// try to find shortest path to the destination
|
||||
BOOL bFound = FindPath((CNavigationMarker*)penMarker, pnmDst);
|
||||
|
||||
// if not found
|
||||
if (!bFound) {
|
||||
// just clean up and fail
|
||||
delete pnmDst->GetPathNode();
|
||||
ClearPath(penThis);
|
||||
penMarker = NULL;
|
||||
vPath = vSrc;
|
||||
return;
|
||||
}
|
||||
|
||||
// find the first marker position after current
|
||||
CPathNode *ppn = pnmDst->GetPathNode();
|
||||
while (ppn->pn_ppnParent!=NULL && ppn->pn_ppnParent->pn_pnmMarker!=penMarker) {
|
||||
ppn = ppn->pn_ppnParent;
|
||||
}
|
||||
penMarker = ppn->pn_pnmMarker;
|
||||
|
||||
// go there
|
||||
vPath = penMarker->GetPlacement().pl_PositionVector;
|
||||
|
||||
// clean up
|
||||
ClearPath(penThis);
|
||||
}
|
||||
static CTString strNone="<none>";
|
||||
if (pn_pnmMarker==NULL) {
|
||||
return strNone;
|
||||
} else {
|
||||
return pn_pnmMarker->GetName();
|
||||
}
|
||||
}
|
||||
|
||||
// get link with given index or null if no more (for iteration along the graph)
|
||||
CPathNode *CPathNode::GetLink(INDEX i)
|
||||
{
|
||||
ASSERT(this!=NULL);
|
||||
if (pn_pnmMarker==NULL) {
|
||||
ASSERT(FALSE);
|
||||
return NULL;
|
||||
}
|
||||
CNavigationMarker *pnm = pn_pnmMarker->GetLink(i);
|
||||
if (pnm==NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return pnm->GetPathNode();
|
||||
}
|
||||
|
||||
// add given node to open list, sorting best first
|
||||
static void SortIntoOpenList(CPathNode *ppnLink)
|
||||
{
|
||||
// start at head of the open list
|
||||
LISTITER(CPathNode, pn_lnInOpen) itpn(_lhOpen);
|
||||
// while the given node is further than the one in list
|
||||
while(ppnLink->pn_fF>itpn->pn_fF && !itpn.IsPastEnd()) {
|
||||
// move to next node
|
||||
itpn.MoveToNext();
|
||||
}
|
||||
|
||||
// if past the end of list
|
||||
if (itpn.IsPastEnd()) {
|
||||
// add to the end of list
|
||||
_lhOpen.AddTail(ppnLink->pn_lnInOpen);
|
||||
// if not past end of list
|
||||
} else {
|
||||
// add before current node
|
||||
itpn.InsertBeforeCurrent(ppnLink->pn_lnInOpen);
|
||||
}
|
||||
}
|
||||
|
||||
// find shortest path from one marker to another
|
||||
static BOOL FindPath(CNavigationMarker *pnmSrc, CNavigationMarker *pnmDst)
|
||||
{
|
||||
|
||||
ASSERT(pnmSrc!=pnmDst);
|
||||
CPathNode *ppnSrc = pnmSrc->GetPathNode();
|
||||
CPathNode *ppnDst = pnmDst->GetPathNode();
|
||||
|
||||
PRINTOUT(CPrintF("--------------------\n"));
|
||||
PRINTOUT(CPrintF("FindPath(%s, %s)\n", ppnSrc->GetName(), ppnDst->GetName()));
|
||||
|
||||
// start with empty open and closed lists
|
||||
ASSERT(_lhOpen.IsEmpty());
|
||||
ASSERT(_lhClosed.IsEmpty());
|
||||
|
||||
// add the start node to open list
|
||||
ppnSrc->pn_fG = 0.0f;
|
||||
ppnSrc->pn_fH = NodeDistance(ppnSrc, ppnDst);
|
||||
ppnSrc->pn_fF = ppnSrc->pn_fG +ppnSrc->pn_fH;
|
||||
_lhOpen.AddTail(ppnSrc->pn_lnInOpen);
|
||||
PRINTOUT(CPrintF("StartState: %s\n", ppnSrc->GetName()));
|
||||
|
||||
// while the open list is not empty
|
||||
while (!_lhOpen.IsEmpty()) {
|
||||
// get the first node from open list (that is, the one with lowest F)
|
||||
CPathNode *ppnNode = LIST_HEAD(_lhOpen, CPathNode, pn_lnInOpen);
|
||||
ppnNode->pn_lnInOpen.Remove();
|
||||
_lhClosed.AddTail(ppnNode->pn_lnInClosed);
|
||||
PRINTOUT(CPrintF("Node: %s - moved from OPEN to CLOSED\n", ppnNode->GetName()));
|
||||
|
||||
// if this is the goal
|
||||
if (ppnNode==ppnDst) {
|
||||
PRINTOUT(CPrintF("PATH FOUND!\n"));
|
||||
// the path is found
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// for each link of current node
|
||||
CPathNode *ppnLink = NULL;
|
||||
for(INDEX i=0; (ppnLink=ppnNode->GetLink(i))!=NULL; i++) {
|
||||
PRINTOUT(CPrintF(" Link %d: %s\n", i, ppnLink->GetName()));
|
||||
// get cost to get to this node if coming from current node
|
||||
FLOAT fNewG = ppnLink->pn_fG+NodeDistance(ppnNode, ppnLink);
|
||||
// if a shorter path already exists
|
||||
if ((ppnLink->pn_lnInOpen.IsLinked() || ppnLink->pn_lnInClosed.IsLinked()) && fNewG>=ppnLink->pn_fG) {
|
||||
PRINTOUT(CPrintF(" shorter path exists through: %s\n", ppnLink->pn_ppnParent->GetName()));
|
||||
// skip this link
|
||||
continue;
|
||||
}
|
||||
// remember this path
|
||||
ppnLink->pn_ppnParent = ppnNode;
|
||||
ppnLink->pn_fG = fNewG;
|
||||
ppnLink->pn_fH = NodeDistance(ppnLink, ppnDst);
|
||||
ppnLink->pn_fF = ppnLink->pn_fG + ppnLink->pn_fH;
|
||||
// remove from closed list, if in it
|
||||
if (ppnLink->pn_lnInClosed.IsLinked()) {
|
||||
ppnLink->pn_lnInClosed.Remove();
|
||||
PRINTOUT(CPrintF(" %s removed from CLOSED\n", ppnLink->GetName()));
|
||||
}
|
||||
// add to open if not in it
|
||||
if (!ppnLink->pn_lnInOpen.IsLinked()) {
|
||||
SortIntoOpenList(ppnLink);
|
||||
PRINTOUT(CPrintF(" %s added to OPEN\n", ppnLink->GetName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we get here, there is no path
|
||||
PRINTOUT(CPrintF("PATH NOT FOUND!\n"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// clear all temporary structures used for path finding
|
||||
static void ClearPath(CEntity *penThis)
|
||||
{
|
||||
{FORDELETELIST(CPathNode, pn_lnInOpen, _lhOpen, itpn) {
|
||||
delete &itpn.Current();
|
||||
}}
|
||||
{FORDELETELIST(CPathNode, pn_lnInClosed, _lhClosed, itpn) {
|
||||
delete &itpn.Current();
|
||||
}}
|
||||
|
||||
#ifndef NDEBUG
|
||||
// for each navigation marker in the world
|
||||
{FOREACHINDYNAMICCONTAINER(penThis->en_pwoWorld->wo_cenEntities, CEntity, iten) {
|
||||
if (!IsOfClass(iten, "NavigationMarker")) {
|
||||
continue;
|
||||
}
|
||||
CNavigationMarker &nm = (CNavigationMarker&)*iten;
|
||||
ASSERT(nm.m_ppnNode==NULL);
|
||||
}}
|
||||
#endif
|
||||
}
|
||||
|
||||
// find marker closest to a given position
|
||||
static void FindClosestMarker(
|
||||
CEntity *penThis, const FLOAT3D &vSrc, CEntity *&penMarker, FLOAT3D &vPath)
|
||||
{
|
||||
CNavigationMarker *pnmMin = NULL;
|
||||
FLOAT fMinDist = UpperLimit(0.0f);
|
||||
// for each sector this entity is in
|
||||
{FOREACHSRCOFDST(penThis->en_rdSectors, CBrushSector, bsc_rsEntities, pbsc)
|
||||
// for each navigation marker in that sector
|
||||
{FOREACHDSTOFSRC(pbsc->bsc_rsEntities, CEntity, en_rdSectors, pen)
|
||||
if (!IsOfClass(pen, "NavigationMarker")) {
|
||||
continue;
|
||||
}
|
||||
CNavigationMarker &nm = (CNavigationMarker&)*pen;
|
||||
|
||||
// get distance from source
|
||||
FLOAT fDist = (vSrc-nm.GetPlacement().pl_PositionVector).Length();
|
||||
// if closer than best found
|
||||
if(fDist<fMinDist) {
|
||||
// remember it
|
||||
fMinDist = fDist;
|
||||
pnmMin = &nm;
|
||||
}
|
||||
ENDFOR}
|
||||
ENDFOR}
|
||||
|
||||
// if none found
|
||||
if (pnmMin==NULL) {
|
||||
// fail
|
||||
vPath = vSrc;
|
||||
penMarker = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
// return position
|
||||
vPath = pnmMin->GetPlacement().pl_PositionVector;
|
||||
penMarker = pnmMin;
|
||||
}
|
||||
|
||||
// find first marker for path navigation
|
||||
void PATH_FindFirstMarker(CEntity *penThis, const FLOAT3D &vSrc, const FLOAT3D &vDst, CEntity *&penMarker, FLOAT3D &vPath)
|
||||
{
|
||||
// find closest markers to source and destination positions
|
||||
CNavigationMarker *pnmSrc;
|
||||
FLOAT3D vSrcPath;
|
||||
FindClosestMarker(penThis, vSrc, (CEntity*&)pnmSrc, vSrcPath);
|
||||
CNavigationMarker *pnmDst;
|
||||
FLOAT3D vDstPath;
|
||||
FindClosestMarker(penThis, vDst, (CEntity*&)pnmDst, vDstPath);
|
||||
|
||||
// if at least one is not found, or if they are same
|
||||
if (pnmSrc==NULL || pnmDst==NULL || pnmSrc==pnmDst) {
|
||||
// fail
|
||||
penMarker = NULL;
|
||||
vPath = vSrc;
|
||||
return;
|
||||
}
|
||||
|
||||
// go to the source marker position
|
||||
vPath = vSrcPath;
|
||||
penMarker = pnmSrc;
|
||||
}
|
||||
|
||||
// find next marker for path navigation
|
||||
void PATH_FindNextMarker(CEntity *penThis, const FLOAT3D &vSrc, const FLOAT3D &vDst, CEntity *&penMarker, FLOAT3D &vPath)
|
||||
{
|
||||
// find closest marker to destination position
|
||||
CNavigationMarker *pnmDst;
|
||||
FLOAT3D vDstPath;
|
||||
FindClosestMarker(penThis, vDst, (CEntity*&)pnmDst, vDstPath);
|
||||
|
||||
// if at not found, or if same as current
|
||||
if (pnmDst==NULL || penMarker==pnmDst) {
|
||||
// fail
|
||||
penMarker = NULL;
|
||||
vPath = vSrc;
|
||||
return;
|
||||
}
|
||||
|
||||
// try to find shortest path to the destination
|
||||
BOOL bFound = FindPath((CNavigationMarker*)penMarker, pnmDst);
|
||||
|
||||
// if not found
|
||||
if (!bFound) {
|
||||
// just clean up and fail
|
||||
delete pnmDst->GetPathNode();
|
||||
ClearPath(penThis);
|
||||
penMarker = NULL;
|
||||
vPath = vSrc;
|
||||
return;
|
||||
}
|
||||
|
||||
// find the first marker position after current
|
||||
CPathNode *ppn = pnmDst->GetPathNode();
|
||||
while (ppn->pn_ppnParent!=NULL && ppn->pn_ppnParent->pn_pnmMarker!=penMarker) {
|
||||
ppn = ppn->pn_ppnParent;
|
||||
}
|
||||
penMarker = ppn->pn_pnmMarker;
|
||||
|
||||
// go there
|
||||
vPath = penMarker->GetPlacement().pl_PositionVector;
|
||||
|
||||
// clean up
|
||||
ClearPath(penThis);
|
||||
}
|
||||
|
|
|
@ -156,14 +156,7 @@ struct DECL_DLL PlayerStats {
|
|||
INDEX ps_iSecrets;
|
||||
TIME ps_tmTime;
|
||||
|
||||
PlayerStats(void)
|
||||
{
|
||||
ps_iScore = 0;
|
||||
ps_iKills = 0;
|
||||
ps_iDeaths = 0;
|
||||
ps_iSecrets = 0;
|
||||
ps_tmTime = 0.0f;
|
||||
}
|
||||
PlayerStats(void): ps_iScore(0), ps_iKills(0), ps_iDeaths(0), ps_iSecrets(0), ps_tmTime(0.0f){}
|
||||
};
|
||||
|
||||
static inline CTStream &operator>>(CTStream &strm, PlayerStats &ps)
|
||||
|
|
|
@ -1180,7 +1180,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO
|
|||
if( iHealth>25) colHealth = _colHUD;
|
||||
if( iArmor >25) colArmor = _colHUD;
|
||||
// eventually print it out
|
||||
if( hud_iShowPlayers==1 || (hud_iShowPlayers==-1 && !bSinglePlay)) {
|
||||
if( hud_iShowPlayers==1 || hud_iShowPlayers==-1) {
|
||||
// printout location and info aren't the same for deathmatch and coop play
|
||||
const FLOAT fCharWidth = (PIX)((_pfdDisplayFont->GetWidth()-2) *fTextScale);
|
||||
if( bCooperative) {
|
||||
|
|
|
@ -2284,9 +2284,8 @@ void Particles_MetalParts( CEntity *pen, FLOAT tmStarted, FLOATaabbox3D boxOwner
|
|||
|
||||
UBYTE ubRndH = UBYTE( 180+afStarsPositions[ int(iPart+tmStarted*10)%CT_MAX_PARTICLES_TABLE][0]*16);
|
||||
UBYTE ubRndS = UBYTE( 12+(afStarsPositions[ int(iPart+tmStarted*10)%CT_MAX_PARTICLES_TABLE][1])*8);
|
||||
UBYTE ubRndV = UBYTE( 192+(afStarsPositions[ int(iPart+tmStarted*10)%CT_MAX_PARTICLES_TABLE][2])*64);
|
||||
//ubRndS = 0;
|
||||
ubRndV = 255;
|
||||
UBYTE ubRndV = 255;
|
||||
COLOR col = HSVToColor(ubRndH, ubRndS, ubRndV)|UBYTE(255.0f*fRatio);
|
||||
FLOAT fRotation = fT*400.0f*afStarsPositions[iRnd][0];
|
||||
FLOAT fSize = fBoxSize*0.005f+0.125f+afStarsPositions[iRnd][1]*0.025f;
|
||||
|
@ -4502,10 +4501,8 @@ void Particles_BloodSpray(enum SprayParticlesType sptType, FLOAT3D vSource, FLOA
|
|||
case SPT_ELECTRICITY_SPARKS:
|
||||
{
|
||||
UBYTE ubRndH = UBYTE( 180+afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][0]*16);
|
||||
UBYTE ubRndS = UBYTE( 32+(afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][1]+0.5)*16);
|
||||
UBYTE ubRndV = UBYTE( 192+(afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][2])*64);
|
||||
ubRndS = 0;
|
||||
ubRndV = 255;
|
||||
UBYTE ubRndS = 0;
|
||||
UBYTE ubRndV = 255;
|
||||
col = HSVToColor(ubRndH, ubRndS, ubRndV)|ubAlpha;
|
||||
fSize/=32.0f;
|
||||
fRotation = fT*200.0f;
|
||||
|
|
|
@ -188,8 +188,7 @@ public:
|
|||
~CEnableUserBreak();
|
||||
};
|
||||
|
||||
CEnableUserBreak::CEnableUserBreak() {
|
||||
bOld = _bUserBreakEnabled;
|
||||
CEnableUserBreak::CEnableUserBreak(): bOld(_bUserBreakEnabled){
|
||||
_bUserBreakEnabled = TRUE;
|
||||
}
|
||||
CEnableUserBreak::~CEnableUserBreak() {
|
||||
|
|
|
@ -139,10 +139,8 @@ public:
|
|||
CPlayerSource *lp_pplsPlayerSource;
|
||||
UBYTE lp_ubPlayerControlsState[2048]; // current state of player controls that are local to the player
|
||||
// Construction
|
||||
CLocalPlayer( void)
|
||||
CLocalPlayer(void): lp_pplsPlayerSource(NULL), lp_bActive(FALSE)
|
||||
{
|
||||
lp_pplsPlayerSource = NULL;
|
||||
lp_bActive = FALSE;
|
||||
memset(lp_ubPlayerControlsState, 0, sizeof(lp_ubPlayerControlsState)) ;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user