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 )
{
Vector baseColor, diffuseColor;
Vector end = trace->startpos + ( ( Vector )trace->endpos - ( Vector )trace->startpos ) * 1.1f;
Vector baseColor = vec3_invalid, diffuseColor;
const char *kind;
if ( trace->DidHitWorld() )
{
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
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
{
kind = "Static Prop";
// In this case we hit a static prop.
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;
if ( !pEnt )
{
Msg("Couldn't find surface in GetColorForSurface()\n");
color->x = 255;
color->y = 255;
color->z = 255;
return;
kind = "Null-Entity";
} else {
kind = "Entity";
ICollideable *pCollide = pEnt->GetCollideable();
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();
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 );
if ( baseColor == vec3_invalid )
{
Warning( "Couldn't find surface color of %s\n", kind );
baseColor = Vector( .5f, .5f, .5f );
diffuseColor = engine->GetLightForPoint( trace->endpos, true );
}
//Get final light value

View File

@ -107,7 +107,7 @@ public:
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
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;
if ( pSoundSource )
{

View File

@ -1001,7 +1001,11 @@ public:
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",

View File

@ -2776,7 +2776,7 @@ void* SquirrelVM::GetInstanceValue(HSCRIPT hInstance, ScriptClassDesc_t* pExpect
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
// is it just to be a compatible name for CreateScope?
V_snprintf(pBuf, nBufSize, "%08X_%s", ++keyIdx, pszRoot);