Skip to content

Commit b51c5c3

Browse files
authored
Merge pull request #322 from z33ky/small-mapbase-fixes
Small mapbase fixes
2 parents 0464bd7 + 6960362 commit b51c5c3

File tree

5 files changed

+33
-20
lines changed

5 files changed

+33
-20
lines changed

sp/src/game/client/c_impact_effects.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,23 @@ extern PMaterialHandle g_Material_Spark;
9595
//-----------------------------------------------------------------------------
9696
void GetColorForSurface( trace_t *trace, Vector *color )
9797
{
98-
Vector baseColor, diffuseColor;
99-
Vector end = trace->startpos + ( ( Vector )trace->endpos - ( Vector )trace->startpos ) * 1.1f;
100-
98+
Vector baseColor = vec3_invalid, diffuseColor;
99+
const char *kind;
100+
101101
if ( trace->DidHitWorld() )
102102
{
103103
if ( trace->hitbox == 0 )
104104
{
105+
kind = "World";
106+
Vector end = trace->startpos + ( trace->endpos - trace->startpos ) * 1.1f;
105107
// If we hit the world, then ask the world for the fleck color
106-
engine->TraceLineMaterialAndLighting( trace->startpos, end, diffuseColor, baseColor );
108+
if ( !engine->TraceLineMaterialAndLighting( trace->startpos, end, diffuseColor, baseColor ) ) {
109+
baseColor = vec3_invalid; // Make sure this wasn't modified
110+
}
107111
}
108112
else
109113
{
114+
kind = "Static Prop";
110115
// In this case we hit a static prop.
111116
staticpropmgr->GetStaticPropMaterialColorAndLighting( trace, trace->hitbox - 1, diffuseColor, baseColor );
112117
}
@@ -117,20 +122,24 @@ void GetColorForSurface( trace_t *trace, Vector *color )
117122
C_BaseEntity *pEnt = trace->m_pEnt;
118123
if ( !pEnt )
119124
{
120-
Msg("Couldn't find surface in GetColorForSurface()\n");
121-
color->x = 255;
122-
color->y = 255;
123-
color->z = 255;
124-
return;
125+
kind = "Null-Entity";
126+
} else {
127+
kind = "Entity";
128+
ICollideable *pCollide = pEnt->GetCollideable();
129+
int modelIndex = pCollide->GetCollisionModelIndex();
130+
model_t* pModel = const_cast<model_t*>(modelinfo->GetModel( modelIndex ));
131+
132+
// Ask the model info about what we need to know
133+
modelinfo->GetModelMaterialColorAndLighting( pModel, pCollide->GetCollisionOrigin(),
134+
pCollide->GetCollisionAngles(), trace, diffuseColor, baseColor );
125135
}
136+
}
126137

127-
ICollideable *pCollide = pEnt->GetCollideable();
128-
int modelIndex = pCollide->GetCollisionModelIndex();
129-
model_t* pModel = const_cast<model_t*>(modelinfo->GetModel( modelIndex ));
130-
131-
// Ask the model info about what we need to know
132-
modelinfo->GetModelMaterialColorAndLighting( pModel, pCollide->GetCollisionOrigin(),
133-
pCollide->GetCollisionAngles(), trace, diffuseColor, baseColor );
138+
if ( baseColor == vec3_invalid )
139+
{
140+
Warning( "Couldn't find surface color of %s\n", kind );
141+
baseColor = Vector( .5f, .5f, .5f );
142+
diffuseColor = engine->GetLightForPoint( trace->endpos, true );
134143
}
135144

136145
//Get final light value

sp/src/game/server/mapbase/custom_weapon_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class CDefaultCustomWeaponEntityFactory : public CCustomWeaponEntityFactoryBase<
107107

108108
virtual void ReleaseData(const void* pData) const
109109
{
110-
delete pData;
110+
delete (Data*)pData;
111111
}
112112
};
113113

sp/src/game/server/sound.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ void CAmbientGeneric::SendSound( SoundFlags_t flags)
938938
{
939939
#ifdef MAPBASE
940940
int iFlags = flags != SND_STOP ? ((int)flags | m_iSoundFlags) : flags;
941-
char *szSoundFile = (char *)STRING( m_iszSound );
941+
const char *szSoundFile = STRING( m_iszSound );
942942
CBaseEntity* pSoundSource = m_hSoundSource;
943943
if ( pSoundSource )
944944
{

sp/src/game/shared/SoundEmitterSystem.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,11 @@ class CSoundEmitterSystem : public CBaseGameSystem
10011001

10021002
if ( duration )
10031003
{
1004-
*duration = enginesound->GetSoundDuration( pSample );
1004+
if ( Q_stristr( pSample, ".mp3" ) ) {
1005+
*duration = 0;
1006+
} else {
1007+
*duration = enginesound->GetSoundDuration( pSample );
1008+
}
10051009
}
10061010

10071011
TraceEmitSound( "EmitAmbientSound: Raw wave emitted '%s' (ent %i)\n",

sp/src/vscript/vscript_squirrel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2776,7 +2776,7 @@ void* SquirrelVM::GetInstanceValue(HSCRIPT hInstance, ScriptClassDesc_t* pExpect
27762776

27772777
bool SquirrelVM::GenerateUniqueKey(const char* pszRoot, char* pBuf, int nBufSize)
27782778
{
2779-
static int keyIdx = 0;
2779+
static unsigned keyIdx = 0;
27802780
// This gets used for script scope, still confused why it needs to be inside IScriptVM
27812781
// is it just to be a compatible name for CreateScope?
27822782
V_snprintf(pBuf, nBufSize, "%08X_%s", ++keyIdx, pszRoot);

0 commit comments

Comments
 (0)