mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Reimplemented ScriptVariable::entityValue
Some script events don't check if it's an actual entity, it would cause crashes. E3L3 would crash after the player got out of the AB41: the AB41 was targetting a VehiclePoint and vehicles_thinkers.scr script set the `self.collisionent` to `self.target` which caused a crash as `VehiclePoint` doesn't inherit from `Entity`
This commit is contained in:
parent
170b4b0972
commit
db01f72adc
1 changed files with 22 additions and 2 deletions
|
@ -900,10 +900,30 @@ void ScriptVariable::SetKey(const short3& key)
|
|||
|
||||
#endif
|
||||
|
||||
Entity *ScriptVariable::entityValue(void)
|
||||
Entity* ScriptVariable::entityValue(void)
|
||||
{
|
||||
#if defined(GAME_DLL)
|
||||
return (Entity *)listenerValue();
|
||||
Entity* ent;
|
||||
|
||||
switch (type) {
|
||||
case VARIABLE_CONSTSTRING:
|
||||
ent = static_cast<Entity*>(world->GetScriptTarget(Director.GetString(m_data.intValue)));
|
||||
break;
|
||||
case VARIABLE_STRING:
|
||||
ent = static_cast<Entity*>(world->GetScriptTarget(stringValue()));
|
||||
break;
|
||||
case VARIABLE_LISTENER:
|
||||
ent = static_cast<Entity*>(m_data.listenerValue->Pointer());
|
||||
break;
|
||||
default:
|
||||
throw ScriptException("Cannot cast '%s' to entity", typenames[type]);
|
||||
}
|
||||
|
||||
if (ent && !ent->isSubclassOf(Entity)) {
|
||||
ScriptError("Cannot cast '%s' to entity", ent->getClassname());
|
||||
}
|
||||
|
||||
return ent;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue