Merge pull request #49 from iamthesenate1/master

Some optimisations
This commit is contained in:
ptitSeb 2021-12-27 10:28:00 +01:00 committed by GitHub
commit 9179b4e2f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 4610 additions and 4664 deletions

View File

@ -29,12 +29,7 @@ void AdjustFilePath_t(CTFileName &fnm)
} }
// class constructor // class constructor
CDependInfo::CDependInfo(CTFileName fnFileName, CTFileName fnParent) CDependInfo::CDependInfo(CTFileName fnFileName, CTFileName fnParent): /*copy file name*/ di_fnFileName(fnFileName), di_fnParent(fnParent){}
{
// copy file name
di_fnFileName = fnFileName;
di_fnParent = fnParent;
}
BOOL CDependInfo::IsFileOnDiskUpdated(void) BOOL CDependInfo::IsFileOnDiskUpdated(void)
{ {

View File

@ -37,7 +37,7 @@ const char *CTFileName::convertFromWin32(const char *src)
static const char *dirsep = NULL; static const char *dirsep = NULL;
static size_t seplen = 0; static size_t seplen = 0;
static char buf[MAX_PATH]; // This is NOT thread safe, fyi. static char buf[MAX_PATH]; // This is NOT thread safe, fyi.
char *dest = buf; char *dest;
if (src == NULL) if (src == NULL)
{ {
@ -78,7 +78,7 @@ const char *CTFileName::convertToWin32(const char *src)
static const char *dirsep = NULL; static const char *dirsep = NULL;
static size_t seplen = 0; static size_t seplen = 0;
static char buf[MAX_PATH]; // This is NOT thread safe, fyi. static char buf[MAX_PATH]; // This is NOT thread safe, fyi.
char *dest = buf; char *dest;
if (src == NULL) if (src == NULL)
{ {

View File

@ -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 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 it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation the Free Software Foundation
@ -182,6 +182,7 @@ CTString ScriptEsc(const CTString &str)
#pragma inline_depth(0) #pragma inline_depth(0)
void MakeAccessViolation(void* pArgs) void MakeAccessViolation(void* pArgs)
{ {
INDEX bDont = NEXTARGUMENT(INDEX); INDEX bDont = NEXTARGUMENT(INDEX);
if( bDont) return; if( bDont) return;
@ -674,7 +675,7 @@ FLOAT CShell::GetFLOAT(const CTString &strName)
// error // error
ASSERT(FALSE); ASSERT(FALSE);
return -666.0f; return -666.0f;
} }
// get it // get it
return *(FLOAT*)pss->ss_pvValue; return *(FLOAT*)pss->ss_pvValue;
} }
@ -688,7 +689,7 @@ void CShell::SetFLOAT(const CTString &strName, FLOAT fValue)
// error // error
ASSERT(FALSE); ASSERT(FALSE);
return; return;
} }
// set it // set it
*(FLOAT*)pss->ss_pvValue = fValue; *(FLOAT*)pss->ss_pvValue = fValue;
} }
@ -703,7 +704,7 @@ INDEX CShell::GetINDEX(const CTString &strName)
// error // error
ASSERT(FALSE); ASSERT(FALSE);
return -666; return -666;
} }
// get it // get it
return *(INDEX*)pss->ss_pvValue; return *(INDEX*)pss->ss_pvValue;
} }
@ -717,7 +718,7 @@ void CShell::SetINDEX(const CTString &strName, INDEX iValue)
// error // error
ASSERT(FALSE); ASSERT(FALSE);
return; return;
} }
// set it // set it
*(INDEX*)pss->ss_pvValue = iValue; *(INDEX*)pss->ss_pvValue = iValue;
} }
@ -732,7 +733,7 @@ CTString CShell::GetString(const CTString &strName)
// error // error
ASSERT(FALSE); ASSERT(FALSE);
return "<invalid>"; return "<invalid>";
} }
// get it // get it
return *(CTString*)pss->ss_pvValue; return *(CTString*)pss->ss_pvValue;
} }
@ -746,7 +747,7 @@ void CShell::SetString(const CTString &strName, const CTString &strValue)
// error // error
ASSERT(FALSE); ASSERT(FALSE);
return; return;
} }
// set it // set it
*(CTString*)pss->ss_pvValue = strValue; *(CTString*)pss->ss_pvValue = strValue;
} }
@ -762,7 +763,7 @@ CTString CShell::GetValue(const CTString &strName)
// error // error
ASSERT(FALSE); ASSERT(FALSE);
return "<invalid>"; return "<invalid>";
} }
// get it // get it
ShellTypeType stt = _shell_ast[pss->ss_istType].st_sttType; ShellTypeType stt = _shell_ast[pss->ss_istType].st_sttType;
@ -795,7 +796,7 @@ void CShell::SetValue(const CTString &strName, const CTString &strValue)
// error // error
ASSERT(FALSE); ASSERT(FALSE);
return; return;
} }
// get it // get it
ShellTypeType stt = _shell_ast[pss->ss_istType].st_sttType; ShellTypeType stt = _shell_ast[pss->ss_istType].st_sttType;
switch(stt) { switch(stt) {

View File

@ -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)); memset(&zh_zstream, 0, sizeof(zh_zstream));
} }
void CZipHandle::Clear(void) void CZipHandle::Clear(void)

View File

@ -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 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 it under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation the Free Software Foundation
@ -593,7 +593,7 @@ extern void GameAgent_EnumTrigger(BOOL bInternet)
if ( _pNetwork->ga_bEnumerationChange ) { if ( _pNetwork->ga_bEnumerationChange ) {
return; return;
} }
if ( !bInternet && ga_bMSLegacy) { if ( !bInternet && ga_bMSLegacy) {
// make sure that there are no requests still stuck in buffer // make sure that there are no requests still stuck in buffer
ga_asrRequests.Clear(); ga_asrRequests.Clear();
@ -866,7 +866,7 @@ extern void GameAgent_EnumTrigger(BOOL bInternet)
_bActivated = TRUE; _bActivated = TRUE;
_bInitialized = TRUE; _bInitialized = TRUE;
_initializeWinsock(); _initializeWinsock();
} }
} }
} }
@ -1051,7 +1051,7 @@ extern void GameAgent_EnumUpdate(void)
pthread_detach(_hThread); pthread_detach(_hThread);
} }
_bActivatedLocal = FALSE; _bActivatedLocal = FALSE;
} }
#else #else
/* MSLegacy */ /* MSLegacy */
if(_bActivated) { if(_bActivated) {
@ -1152,7 +1152,7 @@ void* _MS_Thread(void *arg) {
/** do recvfrom stuff **/ /** do recvfrom stuff **/
iRet = recvfrom(_sockudp, _szBuffer, 2048, 0, (sockaddr*)&_sinClient, &_iClientLength); iRet = recvfrom(_sockudp, _szBuffer, 2048, 0, (sockaddr*)&_sinClient, &_iClientLength);
FD_CLR(_sockudp, &readfds_udp); FD_CLR(_sockudp, &readfds_udp);
if(iRet != -1 && iRet > 100 && iRet != SOCKET_ERROR) { if(iRet > 100 && iRet != SOCKET_ERROR) {
// null terminate the buffer // null terminate the buffer
_szBuffer[iRet] = 0; _szBuffer[iRet] = 0;
char *sPch = NULL; char *sPch = NULL;
@ -1360,7 +1360,7 @@ void* _LocalNet_Thread(void *arg) {
/** do recvfrom stuff **/ /** do recvfrom stuff **/
iRet = recvfrom(_sockudp, _szBuffer, 2048, 0, (sockaddr*)&_sinClient, &_iClientLength); iRet = recvfrom(_sockudp, _szBuffer, 2048, 0, (sockaddr*)&_sinClient, &_iClientLength);
FD_CLR(_sockudp, &readfds_udp); FD_CLR(_sockudp, &readfds_udp);
if(iRet != -1 && iRet > 100 && iRet != SOCKET_ERROR) { if(iRet > 100 && iRet != SOCKET_ERROR) {
// null terminate the buffer // null terminate the buffer
_szBuffer[iRet] = 0; _szBuffer[iRet] = 0;
char *sPch = NULL; char *sPch = NULL;
@ -1370,7 +1370,7 @@ void* _LocalNet_Thread(void *arg) {
if(_szIPPortBufferLocal != NULL) { if(_szIPPortBufferLocal != NULL) {
delete[] _szIPPortBufferLocal; delete[] _szIPPortBufferLocal;
} }
_szIPPortBufferLocal = NULL; _szIPPortBufferLocal = NULL;
WSACleanup(); WSACleanup();
return 0; return 0;
} else { } else {

View File

@ -2002,9 +2002,8 @@ void CLayerMixer::MixOneMipmapDynamic( CBrushShadowMap *pbsm, INDEX iMipmap)
// constructor // 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) { if( bDynamic) {
// check dynamic layers for complete blackness // check dynamic layers for complete blackness
BOOL bAllBlack = TRUE; BOOL bAllBlack = TRUE;

View File

@ -195,9 +195,7 @@ public:
// array for holding edges that proceed with testing // array for holding edges that proceed with testing
CDynamicArray<DOUBLEbspedge3D> oc_abedProceeding; CDynamicArray<DOUBLEbspedge3D> oc_abedProceeding;
CObjectCSG(void) { CObjectCSG(void): oc_bCSGIngoringEnabled(FALSE), oc_bSkipObjectB(FALSE){
oc_bCSGIngoringEnabled = FALSE;
oc_bSkipObjectB = FALSE;
} }
/* Add an entire array of BSP edges to some polygon according to action code. */ /* Add an entire array of BSP edges to some polygon according to action code. */

View File

@ -480,9 +480,6 @@ BOOL CClientInterface::UpdateInputBuffers(void)
// take this packet out of the input buffer // take this packet out of the input buffer
ci_pbInputBuffer.RemovePacket(ppaPacket->pa_ulSequence,FALSE); 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 // 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 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) { if (ppaPacket->pa_adrAddress.adr_uwID == SLASHSLASH || ppaPacket->pa_adrAddress.adr_uwID == 0) {

View File

@ -81,12 +81,7 @@ struct TickMarker {
UBYTE tm_ubAcknowledgesExpected; UBYTE tm_ubAcknowledgesExpected;
UWORD tm_uwNumMessages; UWORD tm_uwNumMessages;
TickMarker() { TickMarker(): tm_fTickTime(-1), tm_fTickTime(-1), tm_ubAcknowledgesExpected(0), tm_uwNumMessages (0){}
tm_fTickTime = -1;
tm_slTickOffset = -1;
tm_ubAcknowledgesExpected = 0;
tm_uwNumMessages = 0;
}
}; };

View File

@ -47,7 +47,7 @@ public:
CEntityPointer ehi_epEntityPointer; CEntityPointer ehi_epEntityPointer;
CClientEntry ehi_ceClientEntries[SERVER_CLIENTS]; 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 ~CEntityItem() {}; // entity poiner will destroy itself and remove the reference

View File

@ -185,9 +185,7 @@ public:
~CGatherCRC(); ~CGatherCRC();
}; };
CGatherCRC::CGatherCRC() { CGatherCRC::CGatherCRC(): bOld(CRCT_bGatherCRCs){}
bOld = CRCT_bGatherCRCs;
}
CGatherCRC::~CGatherCRC() { CGatherCRC::~CGatherCRC() {
CRCT_bGatherCRCs = bOld; CRCT_bGatherCRCs = bOld;
} }

View File

@ -165,8 +165,7 @@ void SelectVertexOnRender(CBrushVertex &bvx, const PIX2D &vpix)
// if selecting with lasso // if selecting with lasso
} else { } else {
// if the vertex is set in lasso buffer // if the vertex is set in lasso buffer
if (_pubLassoBuffer!=NULL if (_pubLassoBuffer[vpix(2)*_pixSizeI+vpix(1)]) {
&&_pubLassoBuffer[vpix(2)*_pixSizeI+vpix(1)]) {
// if alternative // if alternative
if (_bSelectAlternative) { if (_bSelectAlternative) {

View File

@ -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 the polygon is intersected by the ray, and it is the closest intersection so far
if (isIntersector.IsIntersecting() && (fHitDistance < fDistance)) { if (isIntersector.IsIntersecting() && (fHitDistance < fDistance)) {
// remember hit coordinates // remember hit coordinates
if(fHitDistance<fDistance) {
fDistance = fHitDistance; fDistance = fHitDistance;
_vHitExact = vHitPoint; _vHitExact = vHitPoint;
_plHitPlane = plTriPlane; _plHitPlane = plTriPlane;
}
} }
} }
} }

View File

@ -154,7 +154,7 @@ CTFileName CEngineGUI::CreateTexture(CTFileName fnTexFileToRecreate/*=CTString("
CDlgChooseTextureType dlgChooseTextureType; CDlgChooseTextureType dlgChooseTextureType;
int iDlgResult = dlgChooseTextureType.DoModal(); int iDlgResult = dlgChooseTextureType.DoModal();
// if user choosed a texture type // 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 result is 2 we want to create effect texture
if( iDlgResult == 2) if( iDlgResult == 2)

View File

@ -1,215 +1,208 @@
// common headers for flesh entity classes // common headers for flesh entity classes
#include <Entities/Debris.h> /* rcg10062001 need enum definition... */ #include <Entities/Debris.h> /* rcg10062001 need enum definition... */
#include <Entities/KeyItem.h> /* rcg10062001 need enum definition... */ #include <Entities/KeyItem.h> /* rcg10062001 need enum definition... */
#define SURFACE_SAND 9 #define SURFACE_SAND 9
#define SURFACE_WATER 12 #define SURFACE_WATER 12
#define SURFACE_RED_SAND 13 #define SURFACE_RED_SAND 13
// Max ammo // Max ammo
#define MAX_BULLETS INDEX(500) #define MAX_BULLETS INDEX(500)
#define MAX_SHELLS INDEX(100) #define MAX_SHELLS INDEX(100)
#define MAX_ROCKETS INDEX(50) #define MAX_ROCKETS INDEX(50)
#define MAX_GRENADES INDEX(50) #define MAX_GRENADES INDEX(50)
//#define MAX_NAPALM INDEX(250) //#define MAX_NAPALM INDEX(250)
#define MAX_ELECTRICITY INDEX(400) #define MAX_ELECTRICITY INDEX(400)
#define MAX_IRONBALLS INDEX(30) #define MAX_IRONBALLS INDEX(30)
//#define MAX_NUKEBALLS INDEX(3) //#define MAX_NUKEBALLS INDEX(3)
// Bit shifters for ammo // Bit shifters for ammo
#define AMMO_BULLETS 0 #define AMMO_BULLETS 0
#define AMMO_SHELLS 1 #define AMMO_SHELLS 1
#define AMMO_ROCKETS 2 #define AMMO_ROCKETS 2
#define AMMO_GRENADES 3 #define AMMO_GRENADES 3
//#define AMMO_NAPALM 4 //#define AMMO_NAPALM 4
#define AMMO_ELECTRICITY 5 #define AMMO_ELECTRICITY 5
//#define AMMO_NUKEBALLS 6 //#define AMMO_NUKEBALLS 6
#define AMMO_IRONBALLS 7 #define AMMO_IRONBALLS 7
// Ammo mana Value // Ammo mana Value
#define AV_SHELLS INDEX(70) #define AV_SHELLS INDEX(70)
#define AV_BULLETS INDEX(10) #define AV_BULLETS INDEX(10)
#define AV_ROCKETS INDEX(150) #define AV_ROCKETS INDEX(150)
#define AV_GRENADES INDEX(150) #define AV_GRENADES INDEX(150)
#define AV_ELECTRICITY INDEX(250) #define AV_ELECTRICITY INDEX(250)
#define AV_IRONBALLS INDEX(700) #define AV_IRONBALLS INDEX(700)
//#define AV_NUKEBALLS INDEX(1800) //#define AV_NUKEBALLS INDEX(1800)
//#define AV_NAPALM INDEX(200) //#define AV_NAPALM INDEX(200)
enum EmptyShellType { enum EmptyShellType {
ESL_BULLET = 0, ESL_BULLET = 0,
ESL_SHOTGUN = 1, ESL_SHOTGUN = 1,
ESL_BUBBLE = 2, ESL_BUBBLE = 2,
ESL_BULLET_SMOKE = 3, ESL_BULLET_SMOKE = 3,
ESL_SHOTGUN_SMOKE = 4, ESL_SHOTGUN_SMOKE = 4,
ESL_COLT_SMOKE = 5, ESL_COLT_SMOKE = 5,
}; };
// empty shell launch info // empty shell launch info
#define MAX_FLYING_SHELLS 32 #define MAX_FLYING_SHELLS 32
struct ShellLaunchData { struct ShellLaunchData {
FLOAT sld_fSize; // size multiplier FLOAT sld_fSize; // size multiplier
FLOAT3D sld_vPos; // launch position FLOAT3D sld_vPos; // launch position
FLOAT3D sld_vSpeed; // launch speed FLOAT3D sld_vSpeed; // launch speed
FLOAT3D sld_vUp; // up vector in moment of launch FLOAT3D sld_vUp; // up vector in moment of launch
FLOAT sld_tmLaunch; // time of launch FLOAT sld_tmLaunch; // time of launch
EmptyShellType sld_estType; // shell type EmptyShellType sld_estType; // shell type
}; };
#define ShellLaunchData_array m_asldData[MAX_FLYING_SHELLS] #define ShellLaunchData_array m_asldData[MAX_FLYING_SHELLS]
// world change // world change
struct WorldChange { struct WorldChange {
CTString strGroup; // group name CTString strGroup; // group name
CPlacement3D plLink; // link placement for relative change CPlacement3D plLink; // link placement for relative change
INDEX iType; // change type INDEX iType; // change type
}; };
extern struct WorldChange _SwcWorldChange; extern struct WorldChange _SwcWorldChange;
// entity info // entity info
struct EntityInfo { struct EntityInfo {
EntityInfoBodyType Eeibt; // body type EntityInfoBodyType Eeibt; // body type
FLOAT fMass; // mass (in kg) FLOAT fMass; // mass (in kg)
FLOAT vSourceCenter[3]; // body point (offset from handle) when entity look another entity 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 FLOAT vTargetCenter[3]; // body point (offset from handle) when entity is target of look
}; };
// entity info // entity info
struct EntityStats { struct EntityStats {
CTString es_strName; CTString es_strName;
INDEX es_ctCount; INDEX es_ctCount;
INDEX es_ctAmmount; INDEX es_ctAmmount;
FLOAT es_fValue; FLOAT es_fValue;
INDEX es_iScore; INDEX es_iScore;
inline void Clear() { es_strName.Clear(); } inline void Clear() { es_strName.Clear(); }
}; };
// statistics data for player stats management // statistics data for player stats management
struct DECL_DLL PlayerStats { struct DECL_DLL PlayerStats {
INDEX ps_iScore; INDEX ps_iScore;
INDEX ps_iKills; INDEX ps_iKills;
INDEX ps_iDeaths; INDEX ps_iDeaths;
INDEX ps_iSecrets; INDEX ps_iSecrets;
TIME ps_tmTime; TIME ps_tmTime;
PlayerStats(void) PlayerStats(void): ps_iScore(0), ps_iKills(0), ps_iDeaths(0), ps_iSecrets(0), ps_tmTime(0.0f){}
{ };
ps_iScore = 0;
ps_iKills = 0; // get info position for entity
ps_iDeaths = 0; DECL_DLL void GetEntityInfoPosition(CEntity *pen, FLOAT *pf, FLOAT3D &vPos);
ps_iSecrets = 0; // get source and target positions for ray cast
ps_tmTime = 0.0f; 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);
// get info position for entity // send event to target
DECL_DLL void GetEntityInfoPosition(CEntity *pen, FLOAT *pf, FLOAT3D &vPos); DECL_DLL void SendToTarget(CEntity *penSendEvent, EventEType eetEventType, CEntity *penCaused = NULL);
// get source and target positions for ray cast // send event in range
DECL_DLL void GetPositionCastRay(CEntity *penSource, CEntity *penTarget, FLOAT3D &vSource, FLOAT3D &vTarget); DECL_DLL void SendInRange(CEntity *penSource, EventEType eetEventType, const FLOATaabbox3D &boxRange);
// set bool from bool enum type // spawn reminder
DECL_DLL void SetBoolFromBoolEType(BOOL &bSet, BoolEType bet); DECL_DLL CEntityPointer SpawnReminder(CEntity *penOwner, FLOAT fWaitTime, INDEX iValue);
// send event to target // spawn flame
DECL_DLL void SendToTarget(CEntity *penSendEvent, EventEType eetEventType, CEntity *penCaused = NULL); //CEntityPointer SpawnFlame(CEntity *penOwner, CEntity *penAttach, const FLOAT3D &vSource);
// send event in range
DECL_DLL void SendInRange(CEntity *penSource, EventEType eetEventType, const FLOATaabbox3D &boxRange); // Set components
DECL_DLL void SetComponents(CEntity *pen, CModelObject &mo, ULONG ulIDModel, ULONG ulIDTexture,
// spawn reminder ULONG ulIDReflectionTexture, ULONG ulIDSpecularTexture, ULONG ulIDBumpTexture);
DECL_DLL CEntityPointer SpawnReminder(CEntity *penOwner, FLOAT fWaitTime, INDEX iValue); // Add attachment to model
// spawn flame DECL_DLL void AddAttachmentToModel(CEntity *pen, CModelObject &mo, INDEX iAttachment, ULONG ulIDModel, ULONG ulIDTexture,
//CEntityPointer SpawnFlame(CEntity *penOwner, CEntity *penAttach, const FLOAT3D &vSource); ULONG ulIDReflectionTexture, ULONG ulIDSpecularTexture, ULONG ulIDBumpTexture);
// Remove attachment from model
// Set components DECL_DLL void RemoveAttachmentFromModel(CModelObject &mo, INDEX iAttachment);
DECL_DLL void SetComponents(CEntity *pen, CModelObject &mo, ULONG ulIDModel, ULONG ulIDTexture,
ULONG ulIDReflectionTexture, ULONG ulIDSpecularTexture, ULONG ulIDBumpTexture); // Kick entity
// Add attachment to model DECL_DLL void KickEntity(CEntity *penTarget, FLOAT3D vSpeed);
DECL_DLL void AddAttachmentToModel(CEntity *pen, CModelObject &mo, INDEX iAttachment, ULONG ulIDModel, ULONG ulIDTexture,
ULONG ulIDReflectionTexture, ULONG ulIDSpecularTexture, ULONG ulIDBumpTexture);
// Remove attachment from model // lens flare variables
DECL_DLL void RemoveAttachmentFromModel(CModelObject &mo, INDEX iAttachment); extern CLensFlareType _lftStandard;
extern CLensFlareType _lftStandardReflections;
// Kick entity extern CLensFlareType _lftYellowStarRedRing;
DECL_DLL void KickEntity(CEntity *penTarget, FLOAT3D vSpeed); extern CLensFlareType _lftYellowStarRedRingFar;
extern CLensFlareType _lftWhiteGlowStarRedRing;
extern CLensFlareType _lftWhiteGlowStar;
// lens flare variables extern CLensFlareType _lftWhiteGlowStarNG;
extern CLensFlareType _lftStandard; extern CLensFlareType _lftWhiteStarRedRingStreaks;
extern CLensFlareType _lftStandardReflections; extern CLensFlareType _lftWhiteStarRedReflections;
extern CLensFlareType _lftYellowStarRedRing; extern CLensFlareType _lftBlueStarBlueReflections;
extern CLensFlareType _lftYellowStarRedRingFar; extern CLensFlareType _lftProjectileStarGlow;
extern CLensFlareType _lftWhiteGlowStarRedRing; extern CLensFlareType _lftProjectileWhiteBubbleGlow;
extern CLensFlareType _lftWhiteGlowStar; extern CLensFlareType _lftProjectileYellowBubbleGlow;
extern CLensFlareType _lftWhiteGlowStarNG; extern CLensFlareType _lftPVSpaceShipWindowFlare;
extern CLensFlareType _lftWhiteStarRedRingStreaks; extern CLensFlareType _lftCatmanFireGlow;
extern CLensFlareType _lftWhiteStarRedReflections; extern CLensFlareType _lftWhiteGlowFar;
extern CLensFlareType _lftBlueStarBlueReflections; // init lens flare effects
extern CLensFlareType _lftProjectileStarGlow; void InitLensFlares(void);
extern CLensFlareType _lftProjectileWhiteBubbleGlow; // close lens flares effects
extern CLensFlareType _lftProjectileYellowBubbleGlow; void CloseLensFlares(void);
extern CLensFlareType _lftPVSpaceShipWindowFlare;
extern CLensFlareType _lftCatmanFireGlow; DECL_DLL BOOL SetPlayerAppearance(CModelObject *mo, CPlayerCharacter *ppc, CTString &strName, BOOL bPreview);
extern CLensFlareType _lftWhiteGlowFar;
// init lens flare effects // debugging functions
void InitLensFlares(void); DECL_DLL const char *PrintConsole(void);
// close lens flares effects DECL_DLL const char *PrintStack(CEntity *pen);
void CloseLensFlares(void);
// debris spawning
DECL_DLL BOOL SetPlayerAppearance(CModelObject *mo, CPlayerCharacter *ppc, CTString &strName, BOOL bPreview); DECL_DLL void Debris_Begin(
EntityInfoBodyType Eeibt,
// debugging functions enum DebrisParticlesType dptParticles,
DECL_DLL const char *PrintConsole(void); enum BasicEffectType betStain,
DECL_DLL const char *PrintStack(CEntity *pen); FLOAT fEntitySize, // entity size in meters
const FLOAT3D &vSpeed,
// debris spawning const FLOAT3D &vSpawnerSpeed, // how fast was the entity moving
DECL_DLL void Debris_Begin( const FLOAT fConeSize, // size multiplier for debris cone
EntityInfoBodyType Eeibt, const FLOAT fSpeedUp, // size multiplier for debris catapulting up (0-no multiply)
enum DebrisParticlesType dptParticles, const COLOR colDebris=C_WHITE // multiply color
enum BasicEffectType betStain, );
FLOAT fEntitySize, // entity size in meters DECL_DLL CEntityPointer Debris_Spawn(
const FLOAT3D &vSpeed, CEntity *penSpawner,
const FLOAT3D &vSpawnerSpeed, // how fast was the entity moving CEntity *penComponents,
const FLOAT fConeSize, // size multiplier for debris cone SLONG idModelComponent,
const FLOAT fSpeedUp, // size multiplier for debris catapulting up (0-no multiply) SLONG idTextureComponent,
const COLOR colDebris=C_WHITE // multiply color SLONG idReflectionTextureComponent,
); SLONG idSpecularTextureComponent,
DECL_DLL CEntityPointer Debris_Spawn( SLONG idBumpTextureComponent,
CEntity *penSpawner, INDEX iModelAnim,
CEntity *penComponents, FLOAT fSize, // size relative to entity size (or 0 for absolute stretch of 1)
SLONG idModelComponent, const FLOAT3D &vPosRatio);
SLONG idTextureComponent,
SLONG idReflectionTextureComponent, // get default entity info for given body type
SLONG idSpecularTextureComponent, DECL_DLL EntityInfo *GetStdEntityInfo(EntityInfoBodyType eibt);
SLONG idBumpTextureComponent, // damage control functions
INDEX iModelAnim, DECL_DLL FLOAT DamageStrength(EntityInfoBodyType eibtBody, enum DamageType dtDamage);
FLOAT fSize, // size relative to entity size (or 0 for absolute stretch of 1)
const FLOAT3D &vPosRatio); // Print center screen message
DECL_DLL void PrintCenterMessage(CEntity *penThis, CEntity *penTarget,
// get default entity info for given body type const CTString &strMessage, TIME tmLength, enum MessageSound mssSound);
DECL_DLL EntityInfo *GetStdEntityInfo(EntityInfoBodyType eibt);
// damage control functions // get name of a key item
DECL_DLL FLOAT DamageStrength(EntityInfoBodyType eibtBody, enum DamageType dtDamage); DECL_DLL const char *GetKeyName(enum KeyItemType kit);
// Print center screen message // get session properties
DECL_DLL void PrintCenterMessage(CEntity *penThis, CEntity *penTarget, DECL_DLL inline const CSessionProperties *GetSP(void)
const CTString &strMessage, TIME tmLength, enum MessageSound mssSound); {
return ((const CSessionProperties *)_pNetwork->GetSessionProperties());
// get name of a key item }
DECL_DLL const char *GetKeyName(enum KeyItemType kit);
// i.e. weapon sound when fireing or exploding
// get session properties DECL_DLL void SpawnRangeSound( CEntity *penPlayer, CEntity *penPos, enum SoundType st, FLOAT fRange);
DECL_DLL inline const CSessionProperties *GetSP(void)
{ // get some player for trigger source if any is existing
return ((const CSessionProperties *)_pNetwork->GetSessionProperties()); DECL_DLL CEntity *FixupCausedToPlayer(CEntity *penThis, CEntity *penCaused, BOOL bWarning=TRUE);
}
// precisely lerp between two placement using quaternions
// i.e. weapon sound when fireing or exploding DECL_DLL CPlacement3D LerpPlacementsPrecise(const CPlacement3D &pl0, const CPlacement3D &pl1, FLOAT fRatio);
DECL_DLL void SpawnRangeSound( CEntity *penPlayer, CEntity *penPos, enum SoundType st, FLOAT fRange);
// obtain game extra damage per enemy and per player
// get some player for trigger source if any is existing DECL_DLL FLOAT GetGameDamageMultiplier(void);
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

View File

@ -1,282 +1,275 @@
#include "../StdH/StdH.h" #include "../StdH/StdH.h"
#include "Entities/Common/PathFinding.h" #include "Entities/Common/PathFinding.h"
#include "Entities/NavigationMarker.h" #include "Entities/NavigationMarker.h"
#define PRINTOUT(_dummy) #define PRINTOUT(_dummy)
//#define PRINTOUT(something) something //#define PRINTOUT(something) something
// open and closed lists of nodes // open and closed lists of nodes
static CListHead _lhOpen; static CListHead _lhOpen;
static CListHead _lhClosed; static CListHead _lhClosed;
FLOAT NodeDistance(CPathNode *ppn0, CPathNode *ppn1) FLOAT NodeDistance(CPathNode *ppn0, CPathNode *ppn1)
{ {
return ( return (
ppn0->pn_pnmMarker->GetPlacement().pl_PositionVector - ppn0->pn_pnmMarker->GetPlacement().pl_PositionVector -
ppn1->pn_pnmMarker->GetPlacement().pl_PositionVector).Length(); ppn1->pn_pnmMarker->GetPlacement().pl_PositionVector).Length();
} }
CPathNode::CPathNode(class CNavigationMarker *penMarker) CPathNode::CPathNode(class CNavigationMarker *penMarker): pn_pnmMarker(penMarker), pn_ppnParent(NULL), pn_fG(0.0f), pn_fH(0.0f), pn_fF(0.0f){}
{
pn_pnmMarker = penMarker; CPathNode::~CPathNode(void)
pn_ppnParent = NULL; {
pn_fG = 0.0f; // detach from marker when deleting
pn_fH = 0.0f; ASSERT(pn_pnmMarker!=NULL);
pn_fF = 0.0f; pn_pnmMarker->m_ppnNode = NULL;
} }
CPathNode::~CPathNode(void) // get name of this node
{ const CTString &CPathNode::GetName(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); ASSERT(this!=NULL);
static CTString strNone="<none>"; static CTString strNone="<none>";
if (pn_pnmMarker==NULL) { if (pn_pnmMarker==NULL) {
return strNone; return strNone;
} else { } else {
return pn_pnmMarker->GetName(); return pn_pnmMarker->GetName();
} }
} }
// get link with given index or null if no more (for iteration along the graph) // get link with given index or null if no more (for iteration along the graph)
CPathNode *CPathNode::GetLink(INDEX i) CPathNode *CPathNode::GetLink(INDEX i)
{ {
ASSERT(this!=NULL); ASSERT(this!=NULL);
if (pn_pnmMarker==NULL) { if (pn_pnmMarker==NULL) {
ASSERT(FALSE); ASSERT(FALSE);
return NULL; return NULL;
} }
CNavigationMarker *pnm = pn_pnmMarker->GetLink(i); CNavigationMarker *pnm = pn_pnmMarker->GetLink(i);
if (pnm==NULL) { if (pnm==NULL) {
return NULL; return NULL;
} }
return pnm->GetPathNode(); return pnm->GetPathNode();
} }
// add given node to open list, sorting best first // add given node to open list, sorting best first
static void SortIntoOpenList(CPathNode *ppnLink) static void SortIntoOpenList(CPathNode *ppnLink)
{ {
// start at head of the open list // start at head of the open list
LISTITER(CPathNode, pn_lnInOpen) itpn(_lhOpen); LISTITER(CPathNode, pn_lnInOpen) itpn(_lhOpen);
// while the given node is further than the one in list // while the given node is further than the one in list
while(ppnLink->pn_fF>itpn->pn_fF && !itpn.IsPastEnd()) { while(ppnLink->pn_fF>itpn->pn_fF && !itpn.IsPastEnd()) {
// move to next node // move to next node
itpn.MoveToNext(); itpn.MoveToNext();
} }
// if past the end of list // if past the end of list
if (itpn.IsPastEnd()) { if (itpn.IsPastEnd()) {
// add to the end of list // add to the end of list
_lhOpen.AddTail(ppnLink->pn_lnInOpen); _lhOpen.AddTail(ppnLink->pn_lnInOpen);
// if not past end of list // if not past end of list
} else { } else {
// add before current node // add before current node
itpn.InsertBeforeCurrent(ppnLink->pn_lnInOpen); itpn.InsertBeforeCurrent(ppnLink->pn_lnInOpen);
} }
} }
// find shortest path from one marker to another // find shortest path from one marker to another
static BOOL FindPath(CNavigationMarker *pnmSrc, CNavigationMarker *pnmDst) static BOOL FindPath(CNavigationMarker *pnmSrc, CNavigationMarker *pnmDst)
{ {
ASSERT(pnmSrc!=pnmDst); ASSERT(pnmSrc!=pnmDst);
CPathNode *ppnSrc = pnmSrc->GetPathNode(); CPathNode *ppnSrc = pnmSrc->GetPathNode();
CPathNode *ppnDst = pnmDst->GetPathNode(); CPathNode *ppnDst = pnmDst->GetPathNode();
PRINTOUT(CPrintF("--------------------\n")); PRINTOUT(CPrintF("--------------------\n"));
PRINTOUT(CPrintF("FindPath(%s, %s)\n", ppnSrc->GetName(), ppnDst->GetName())); PRINTOUT(CPrintF("FindPath(%s, %s)\n", ppnSrc->GetName(), ppnDst->GetName()));
// start with empty open and closed lists // start with empty open and closed lists
ASSERT(_lhOpen.IsEmpty()); ASSERT(_lhOpen.IsEmpty());
ASSERT(_lhClosed.IsEmpty()); ASSERT(_lhClosed.IsEmpty());
// add the start node to open list // add the start node to open list
ppnSrc->pn_fG = 0.0f; ppnSrc->pn_fG = 0.0f;
ppnSrc->pn_fH = NodeDistance(ppnSrc, ppnDst); ppnSrc->pn_fH = NodeDistance(ppnSrc, ppnDst);
ppnSrc->pn_fF = ppnSrc->pn_fG +ppnSrc->pn_fH; ppnSrc->pn_fF = ppnSrc->pn_fG +ppnSrc->pn_fH;
_lhOpen.AddTail(ppnSrc->pn_lnInOpen); _lhOpen.AddTail(ppnSrc->pn_lnInOpen);
PRINTOUT(CPrintF("StartState: %s\n", ppnSrc->GetName())); PRINTOUT(CPrintF("StartState: %s\n", ppnSrc->GetName()));
// while the open list is not empty // while the open list is not empty
while (!_lhOpen.IsEmpty()) { while (!_lhOpen.IsEmpty()) {
// get the first node from open list (that is, the one with lowest F) // get the first node from open list (that is, the one with lowest F)
CPathNode *ppnNode = LIST_HEAD(_lhOpen, CPathNode, pn_lnInOpen); CPathNode *ppnNode = LIST_HEAD(_lhOpen, CPathNode, pn_lnInOpen);
ppnNode->pn_lnInOpen.Remove(); ppnNode->pn_lnInOpen.Remove();
_lhClosed.AddTail(ppnNode->pn_lnInClosed); _lhClosed.AddTail(ppnNode->pn_lnInClosed);
PRINTOUT(CPrintF("Node: %s - moved from OPEN to CLOSED\n", ppnNode->GetName())); PRINTOUT(CPrintF("Node: %s - moved from OPEN to CLOSED\n", ppnNode->GetName()));
// if this is the goal // if this is the goal
if (ppnNode==ppnDst) { if (ppnNode==ppnDst) {
PRINTOUT(CPrintF("PATH FOUND!\n")); PRINTOUT(CPrintF("PATH FOUND!\n"));
// the path is found // the path is found
return TRUE; return TRUE;
} }
// for each link of current node // for each link of current node
CPathNode *ppnLink = NULL; CPathNode *ppnLink = NULL;
for(INDEX i=0; (ppnLink=ppnNode->GetLink(i))!=NULL; i++) { for(INDEX i=0; (ppnLink=ppnNode->GetLink(i))!=NULL; i++) {
PRINTOUT(CPrintF(" Link %d: %s\n", i, ppnLink->GetName())); PRINTOUT(CPrintF(" Link %d: %s\n", i, ppnLink->GetName()));
// get cost to get to this node if coming from current node // get cost to get to this node if coming from current node
FLOAT fNewG = ppnLink->pn_fG+NodeDistance(ppnNode, ppnLink); FLOAT fNewG = ppnLink->pn_fG+NodeDistance(ppnNode, ppnLink);
// if a shorter path already exists // if a shorter path already exists
if ((ppnLink->pn_lnInOpen.IsLinked() || ppnLink->pn_lnInClosed.IsLinked()) && fNewG>=ppnLink->pn_fG) { 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())); PRINTOUT(CPrintF(" shorter path exists through: %s\n", ppnLink->pn_ppnParent->GetName()));
// skip this link // skip this link
continue; continue;
} }
// remember this path // remember this path
ppnLink->pn_ppnParent = ppnNode; ppnLink->pn_ppnParent = ppnNode;
ppnLink->pn_fG = fNewG; ppnLink->pn_fG = fNewG;
ppnLink->pn_fH = NodeDistance(ppnLink, ppnDst); ppnLink->pn_fH = NodeDistance(ppnLink, ppnDst);
ppnLink->pn_fF = ppnLink->pn_fG + ppnLink->pn_fH; ppnLink->pn_fF = ppnLink->pn_fG + ppnLink->pn_fH;
// remove from closed list, if in it // remove from closed list, if in it
if (ppnLink->pn_lnInClosed.IsLinked()) { if (ppnLink->pn_lnInClosed.IsLinked()) {
ppnLink->pn_lnInClosed.Remove(); ppnLink->pn_lnInClosed.Remove();
PRINTOUT(CPrintF(" %s removed from CLOSED\n", ppnLink->GetName())); PRINTOUT(CPrintF(" %s removed from CLOSED\n", ppnLink->GetName()));
} }
// add to open if not in it // add to open if not in it
if (!ppnLink->pn_lnInOpen.IsLinked()) { if (!ppnLink->pn_lnInOpen.IsLinked()) {
SortIntoOpenList(ppnLink); SortIntoOpenList(ppnLink);
PRINTOUT(CPrintF(" %s added to OPEN\n", ppnLink->GetName())); PRINTOUT(CPrintF(" %s added to OPEN\n", ppnLink->GetName()));
} }
} }
} }
// if we get here, there is no path // if we get here, there is no path
PRINTOUT(CPrintF("PATH NOT FOUND!\n")); PRINTOUT(CPrintF("PATH NOT FOUND!\n"));
return FALSE; return FALSE;
} }
// clear all temporary structures used for path finding // clear all temporary structures used for path finding
static void ClearPath(CEntity *penThis) static void ClearPath(CEntity *penThis)
{ {
{FORDELETELIST(CPathNode, pn_lnInOpen, _lhOpen, itpn) { {FORDELETELIST(CPathNode, pn_lnInOpen, _lhOpen, itpn) {
delete &itpn.Current(); delete &itpn.Current();
}} }}
{FORDELETELIST(CPathNode, pn_lnInClosed, _lhClosed, itpn) { {FORDELETELIST(CPathNode, pn_lnInClosed, _lhClosed, itpn) {
delete &itpn.Current(); delete &itpn.Current();
}} }}
#ifndef NDEBUG #ifndef NDEBUG
// for each navigation marker in the world // for each navigation marker in the world
{FOREACHINDYNAMICCONTAINER(penThis->en_pwoWorld->wo_cenEntities, CEntity, iten) { {FOREACHINDYNAMICCONTAINER(penThis->en_pwoWorld->wo_cenEntities, CEntity, iten) {
if (!IsOfClass(iten, "NavigationMarker")) { if (!IsOfClass(iten, "NavigationMarker")) {
continue; continue;
} }
CNavigationMarker &nm = (CNavigationMarker&)*iten; CNavigationMarker &nm = (CNavigationMarker&)*iten;
ASSERT(nm.m_ppnNode==NULL); ASSERT(nm.m_ppnNode==NULL);
}} }}
#endif #endif
} }
// find marker closest to a given position // find marker closest to a given position
static void FindClosestMarker( static void FindClosestMarker(
CEntity *penThis, const FLOAT3D &vSrc, CEntity *&penMarker, FLOAT3D &vPath) CEntity *penThis, const FLOAT3D &vSrc, CEntity *&penMarker, FLOAT3D &vPath)
{ {
CNavigationMarker *pnmMin = NULL; CNavigationMarker *pnmMin = NULL;
FLOAT fMinDist = UpperLimit(0.0f); FLOAT fMinDist = UpperLimit(0.0f);
// for each sector this entity is in // for each sector this entity is in
{FOREACHSRCOFDST(penThis->en_rdSectors, CBrushSector, bsc_rsEntities, pbsc) {FOREACHSRCOFDST(penThis->en_rdSectors, CBrushSector, bsc_rsEntities, pbsc)
// for each navigation marker in that sector // for each navigation marker in that sector
{FOREACHDSTOFSRC(pbsc->bsc_rsEntities, CEntity, en_rdSectors, pen) {FOREACHDSTOFSRC(pbsc->bsc_rsEntities, CEntity, en_rdSectors, pen)
if (!IsOfClass(pen, "NavigationMarker")) { if (!IsOfClass(pen, "NavigationMarker")) {
continue; continue;
} }
CNavigationMarker &nm = (CNavigationMarker&)*pen; CNavigationMarker &nm = (CNavigationMarker&)*pen;
// get distance from source // get distance from source
FLOAT fDist = (vSrc-nm.GetPlacement().pl_PositionVector).Length(); FLOAT fDist = (vSrc-nm.GetPlacement().pl_PositionVector).Length();
// if closer than best found // if closer than best found
if(fDist<fMinDist) { if(fDist<fMinDist) {
// remember it // remember it
fMinDist = fDist; fMinDist = fDist;
pnmMin = &nm; pnmMin = &nm;
} }
ENDFOR} ENDFOR}
ENDFOR} ENDFOR}
// if none found // if none found
if (pnmMin==NULL) { if (pnmMin==NULL) {
// fail // fail
vPath = vSrc; vPath = vSrc;
penMarker = NULL; penMarker = NULL;
return; return;
} }
// return position // return position
vPath = pnmMin->GetPlacement().pl_PositionVector; vPath = pnmMin->GetPlacement().pl_PositionVector;
penMarker = pnmMin; penMarker = pnmMin;
} }
// find first marker for path navigation // find first marker for path navigation
void PATH_FindFirstMarker(CEntity *penThis, const FLOAT3D &vSrc, const FLOAT3D &vDst, CEntity *&penMarker, FLOAT3D &vPath) void PATH_FindFirstMarker(CEntity *penThis, const FLOAT3D &vSrc, const FLOAT3D &vDst, CEntity *&penMarker, FLOAT3D &vPath)
{ {
// find closest markers to source and destination positions // find closest markers to source and destination positions
CNavigationMarker *pnmSrc; CNavigationMarker *pnmSrc;
FLOAT3D vSrcPath; FLOAT3D vSrcPath;
FindClosestMarker(penThis, vSrc, (CEntity*&)pnmSrc, vSrcPath); FindClosestMarker(penThis, vSrc, (CEntity*&)pnmSrc, vSrcPath);
CNavigationMarker *pnmDst; CNavigationMarker *pnmDst;
FLOAT3D vDstPath; FLOAT3D vDstPath;
FindClosestMarker(penThis, vDst, (CEntity*&)pnmDst, vDstPath); FindClosestMarker(penThis, vDst, (CEntity*&)pnmDst, vDstPath);
// if at least one is not found, or if they are same // if at least one is not found, or if they are same
if (pnmSrc==NULL || pnmDst==NULL || pnmSrc==pnmDst) { if (pnmSrc==NULL || pnmDst==NULL || pnmSrc==pnmDst) {
// fail // fail
penMarker = NULL; penMarker = NULL;
vPath = vSrc; vPath = vSrc;
return; return;
} }
// go to the source marker position // go to the source marker position
vPath = vSrcPath; vPath = vSrcPath;
penMarker = pnmSrc; penMarker = pnmSrc;
} }
// find next marker for path navigation // find next marker for path navigation
void PATH_FindNextMarker(CEntity *penThis, const FLOAT3D &vSrc, const FLOAT3D &vDst, CEntity *&penMarker, FLOAT3D &vPath) void PATH_FindNextMarker(CEntity *penThis, const FLOAT3D &vSrc, const FLOAT3D &vDst, CEntity *&penMarker, FLOAT3D &vPath)
{ {
// find closest marker to destination position // find closest marker to destination position
CNavigationMarker *pnmDst; CNavigationMarker *pnmDst;
FLOAT3D vDstPath; FLOAT3D vDstPath;
FindClosestMarker(penThis, vDst, (CEntity*&)pnmDst, vDstPath); FindClosestMarker(penThis, vDst, (CEntity*&)pnmDst, vDstPath);
// if at not found, or if same as current // if at not found, or if same as current
if (pnmDst==NULL || penMarker==pnmDst) { if (pnmDst==NULL || penMarker==pnmDst) {
// fail // fail
penMarker = NULL; penMarker = NULL;
vPath = vSrc; vPath = vSrc;
return; return;
} }
// try to find shortest path to the destination // try to find shortest path to the destination
BOOL bFound = FindPath((CNavigationMarker*)penMarker, pnmDst); BOOL bFound = FindPath((CNavigationMarker*)penMarker, pnmDst);
// if not found // if not found
if (!bFound) { if (!bFound) {
// just clean up and fail // just clean up and fail
delete pnmDst->GetPathNode(); delete pnmDst->GetPathNode();
ClearPath(penThis); ClearPath(penThis);
penMarker = NULL; penMarker = NULL;
vPath = vSrc; vPath = vSrc;
return; return;
} }
// find the first marker position after current // find the first marker position after current
CPathNode *ppn = pnmDst->GetPathNode(); CPathNode *ppn = pnmDst->GetPathNode();
while (ppn->pn_ppnParent!=NULL && ppn->pn_ppnParent->pn_pnmMarker!=penMarker) { while (ppn->pn_ppnParent!=NULL && ppn->pn_ppnParent->pn_pnmMarker!=penMarker) {
ppn = ppn->pn_ppnParent; ppn = ppn->pn_ppnParent;
} }
penMarker = ppn->pn_pnmMarker; penMarker = ppn->pn_pnmMarker;
// go there // go there
vPath = penMarker->GetPlacement().pl_PositionVector; vPath = penMarker->GetPlacement().pl_PositionVector;
// clean up // clean up
ClearPath(penThis); ClearPath(penThis);
} }

View File

@ -156,14 +156,7 @@ struct DECL_DLL PlayerStats {
INDEX ps_iSecrets; INDEX ps_iSecrets;
TIME ps_tmTime; TIME ps_tmTime;
PlayerStats(void) PlayerStats(void): ps_iScore(0), ps_iKills(0), ps_iDeaths(0), ps_iSecrets(0), ps_tmTime(0.0f){}
{
ps_iScore = 0;
ps_iKills = 0;
ps_iDeaths = 0;
ps_iSecrets = 0;
ps_tmTime = 0.0f;
}
}; };
static inline CTStream &operator>>(CTStream &strm, PlayerStats &ps) static inline CTStream &operator>>(CTStream &strm, PlayerStats &ps)

View File

@ -1180,7 +1180,7 @@ extern void DrawHUD( const CPlayer *penPlayerCurrent, CDrawPort *pdpCurrent, BOO
if( iHealth>25) colHealth = _colHUD; if( iHealth>25) colHealth = _colHUD;
if( iArmor >25) colArmor = _colHUD; if( iArmor >25) colArmor = _colHUD;
// eventually print it out // 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 // printout location and info aren't the same for deathmatch and coop play
const FLOAT fCharWidth = (PIX)((_pfdDisplayFont->GetWidth()-2) *fTextScale); const FLOAT fCharWidth = (PIX)((_pfdDisplayFont->GetWidth()-2) *fTextScale);
if( bCooperative) { if( bCooperative) {

View File

@ -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 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 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; //ubRndS = 0;
ubRndV = 255; UBYTE ubRndV = 255;
COLOR col = HSVToColor(ubRndH, ubRndS, ubRndV)|UBYTE(255.0f*fRatio); COLOR col = HSVToColor(ubRndH, ubRndS, ubRndV)|UBYTE(255.0f*fRatio);
FLOAT fRotation = fT*400.0f*afStarsPositions[iRnd][0]; FLOAT fRotation = fT*400.0f*afStarsPositions[iRnd][0];
FLOAT fSize = fBoxSize*0.005f+0.125f+afStarsPositions[iRnd][1]*0.025f; 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: case SPT_ELECTRICITY_SPARKS:
{ {
UBYTE ubRndH = UBYTE( 180+afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][0]*16); 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 ubRndS = 0;
UBYTE ubRndV = UBYTE( 192+(afStarsPositions[ int(iSpray+tmStarted*10)%CT_MAX_PARTICLES_TABLE][2])*64); UBYTE ubRndV = 255;
ubRndS = 0;
ubRndV = 255;
col = HSVToColor(ubRndH, ubRndS, ubRndV)|ubAlpha; col = HSVToColor(ubRndH, ubRndS, ubRndV)|ubAlpha;
fSize/=32.0f; fSize/=32.0f;
fRotation = fT*200.0f; fRotation = fT*200.0f;

View File

@ -188,8 +188,7 @@ public:
~CEnableUserBreak(); ~CEnableUserBreak();
}; };
CEnableUserBreak::CEnableUserBreak() { CEnableUserBreak::CEnableUserBreak(): bOld(_bUserBreakEnabled){
bOld = _bUserBreakEnabled;
_bUserBreakEnabled = TRUE; _bUserBreakEnabled = TRUE;
} }
CEnableUserBreak::~CEnableUserBreak() { CEnableUserBreak::~CEnableUserBreak() {

View File

@ -139,10 +139,8 @@ public:
CPlayerSource *lp_pplsPlayerSource; CPlayerSource *lp_pplsPlayerSource;
UBYTE lp_ubPlayerControlsState[2048]; // current state of player controls that are local to the player UBYTE lp_ubPlayerControlsState[2048]; // current state of player controls that are local to the player
// Construction // Construction
CLocalPlayer( void) CLocalPlayer(void): lp_pplsPlayerSource(NULL), lp_bActive(FALSE)
{ {
lp_pplsPlayerSource = NULL;
lp_bActive = FALSE;
memset(lp_ubPlayerControlsState, 0, sizeof(lp_ubPlayerControlsState)) ; memset(lp_ubPlayerControlsState, 0, sizeof(lp_ubPlayerControlsState)) ;
}; };
}; };