Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small mapbase fixes #322

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions sp/src/game/client/c_impact_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sp/src/game/server/mapbase/custom_weapon_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class CDefaultCustomWeaponEntityFactory : public CCustomWeaponEntityFactoryBase<

virtual void ReleaseData(const void* pData) const
{
delete pData;
delete (Data*)pData;
}
};

Expand Down
2 changes: 1 addition & 1 deletion sp/src/game/server/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
6 changes: 5 additions & 1 deletion sp/src/game/shared/SoundEmitterSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,11 @@ class CSoundEmitterSystem : public CBaseGameSystem

if ( duration )
{
*duration = enginesound->GetSoundDuration( pSample );
if ( Q_stristr( pSample, ".mp3" ) ) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the commit message states, this crashes on Linux. I guess it doesn't on Windows, but doesn't return reliable values, taking the following comment from https://www.moddb.com/mods/sourceworld (scripts/vscript/music_manager.nut):

// The price for not using WAV format for looped music, ladies and gents. Manually writing all durations because the engine can't read duration of mp3s correctly.
::SW_MUS<-{}
::SW_MUS.DurTable<-{
	hordeslayer_01=5.6411
	hordeslayer_02=5.6411
	hl2_song1=60
	...
}

*duration = 0;
} else {
*duration = enginesound->GetSoundDuration( pSample );
}
}

TraceEmitSound( "EmitAmbientSound: Raw wave emitted '%s' (ent %i)\n",
Expand Down
2 changes: 1 addition & 1 deletion sp/src/vscript/vscript_squirrel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading