Some optimisations

This commit is contained in:
iamthesenate1 2021-12-26 13:17:09 +02:00
parent 0ab04baf9a
commit 3609bf4df8
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

@ -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;

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

@ -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;

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,14 +186,12 @@ 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;
} }
} }
} }
}
return fDistance; return fDistance;
} }

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

@ -92,14 +92,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;
}
}; };
// get info position for entity // get info position for entity

View File

@ -870,7 +870,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

@ -1476,9 +1476,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;
@ -2301,8 +2300,7 @@ void Particles_EmptyShells( CEntity *pen, ShellLaunchData *asldData)
{ {
fColorFactor = -fT+fLife; fColorFactor = -fT+fLife;
} }
UBYTE ubAlpha = UBYTE(CT_OPAQUE*fColorFactor); UBYTE ubAlpha = CT_OPAQUE;
ubAlpha = CT_OPAQUE;
FLOAT3D vSpeedPower = sld.sld_vSpeed/(1.0f+fT*fT); FLOAT3D vSpeedPower = sld.sld_vSpeed/(1.0f+fT*fT);
FLOAT3D vPos = sld.sld_vPos + FLOAT3D vPos = sld.sld_vPos +
@ -2779,10 +2777,8 @@ void Particles_BloodSpray(enum SprayParticlesType sptType, CEntity *penSpray, FL
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

@ -16,14 +16,7 @@ FLOAT NodeDistance(CPathNode *ppn0, CPathNode *ppn1)
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;
pn_ppnParent = NULL;
pn_fG = 0.0f;
pn_fH = 0.0f;
pn_fF = 0.0f;
}
CPathNode::~CPathNode(void) CPathNode::~CPathNode(void)
{ {

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)) ;
}; };
}; };