Merge pull request #322 from z33ky/small-mapbase-fixes

Small mapbase fixes
This commit is contained in:
Blixibon 2025-01-04 08:43:02 -06:00 committed by GitHub
commit b51c5c3f86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 33 additions and 20 deletions

View File

@ -95,18 +95,23 @@ extern PMaterialHandle g_Material_Spark;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void GetColorForSurface( trace_t *trace, Vector *color ) void GetColorForSurface( trace_t *trace, Vector *color )
{ {
Vector baseColor, diffuseColor; Vector baseColor = vec3_invalid, diffuseColor;
Vector end = trace->startpos + ( ( Vector )trace->endpos - ( Vector )trace->startpos ) * 1.1f; const char *kind;
if ( trace->DidHitWorld() ) if ( trace->DidHitWorld() )
{ {
if ( trace->hitbox == 0 ) if ( trace->hitbox == 0 )
{ {
kind = "World";
Vector end = trace->startpos + ( trace->endpos - trace->startpos ) * 1.1f;
// If we hit the world, then ask the world for the fleck color // If we hit the world, then ask the world for the fleck color
engine->TraceLineMaterialAndLighting( trace->startpos, end, diffuseColor, baseColor ); if ( !engine->TraceLineMaterialAndLighting( trace->startpos, end, diffuseColor, baseColor ) ) {
baseColor = vec3_invalid; // Make sure this wasn't modified
}
} }
else else
{ {
kind = "Static Prop";
// In this case we hit a static prop. // In this case we hit a static prop.
staticpropmgr->GetStaticPropMaterialColorAndLighting( trace, trace->hitbox - 1, diffuseColor, baseColor ); staticpropmgr->GetStaticPropMaterialColorAndLighting( trace, trace->hitbox - 1, diffuseColor, baseColor );
} }
@ -117,20 +122,24 @@ void GetColorForSurface( trace_t *trace, Vector *color )
C_BaseEntity *pEnt = trace->m_pEnt; C_BaseEntity *pEnt = trace->m_pEnt;
if ( !pEnt ) if ( !pEnt )
{ {
Msg("Couldn't find surface in GetColorForSurface()\n"); kind = "Null-Entity";
color->x = 255; } else {
color->y = 255; kind = "Entity";
color->z = 255; ICollideable *pCollide = pEnt->GetCollideable();
return; int modelIndex = pCollide->GetCollisionModelIndex();
model_t* pModel = const_cast<model_t*>(modelinfo->GetModel( modelIndex ));
// Ask the model info about what we need to know
modelinfo->GetModelMaterialColorAndLighting( pModel, pCollide->GetCollisionOrigin(),
pCollide->GetCollisionAngles(), trace, diffuseColor, baseColor );
} }
}
ICollideable *pCollide = pEnt->GetCollideable(); if ( baseColor == vec3_invalid )
int modelIndex = pCollide->GetCollisionModelIndex(); {
model_t* pModel = const_cast<model_t*>(modelinfo->GetModel( modelIndex )); Warning( "Couldn't find surface color of %s\n", kind );
baseColor = Vector( .5f, .5f, .5f );
// Ask the model info about what we need to know diffuseColor = engine->GetLightForPoint( trace->endpos, true );
modelinfo->GetModelMaterialColorAndLighting( pModel, pCollide->GetCollisionOrigin(),
pCollide->GetCollisionAngles(), trace, diffuseColor, baseColor );
} }
//Get final light value //Get final light value

View File

@ -107,7 +107,7 @@ public:
virtual void ReleaseData(const void* pData) const virtual void ReleaseData(const void* pData) const
{ {
delete pData; delete (Data*)pData;
} }
}; };

View File

@ -938,7 +938,7 @@ void CAmbientGeneric::SendSound( SoundFlags_t flags)
{ {
#ifdef MAPBASE #ifdef MAPBASE
int iFlags = flags != SND_STOP ? ((int)flags | m_iSoundFlags) : flags; int iFlags = flags != SND_STOP ? ((int)flags | m_iSoundFlags) : flags;
char *szSoundFile = (char *)STRING( m_iszSound ); const char *szSoundFile = STRING( m_iszSound );
CBaseEntity* pSoundSource = m_hSoundSource; CBaseEntity* pSoundSource = m_hSoundSource;
if ( pSoundSource ) if ( pSoundSource )
{ {

View File

@ -1001,7 +1001,11 @@ public:
if ( duration ) if ( duration )
{ {
*duration = enginesound->GetSoundDuration( pSample ); if ( Q_stristr( pSample, ".mp3" ) ) {
*duration = 0;
} else {
*duration = enginesound->GetSoundDuration( pSample );
}
} }
TraceEmitSound( "EmitAmbientSound: Raw wave emitted '%s' (ent %i)\n", TraceEmitSound( "EmitAmbientSound: Raw wave emitted '%s' (ent %i)\n",

View File

@ -2776,7 +2776,7 @@ void* SquirrelVM::GetInstanceValue(HSCRIPT hInstance, ScriptClassDesc_t* pExpect
bool SquirrelVM::GenerateUniqueKey(const char* pszRoot, char* pBuf, int nBufSize) bool SquirrelVM::GenerateUniqueKey(const char* pszRoot, char* pBuf, int nBufSize)
{ {
static int keyIdx = 0; static unsigned keyIdx = 0;
// This gets used for script scope, still confused why it needs to be inside IScriptVM // This gets used for script scope, still confused why it needs to be inside IScriptVM
// is it just to be a compatible name for CreateScope? // is it just to be a compatible name for CreateScope?
V_snprintf(pBuf, nBufSize, "%08X_%s", ++keyIdx, pszRoot); V_snprintf(pBuf, nBufSize, "%08X_%s", ++keyIdx, pszRoot);