1
0

cLuaState: Update Push for entities. (#4128)

Fixes #4127

Some classes were exported but were only pushed as a cEntity
meaning exported functions were inaccessible.
This brings cLuaState::Push(cEntity *) up to date with all exported entities.
This commit is contained in:
peterbell10 2018-01-03 11:38:00 +00:00 committed by GitHub
parent 00da9006b7
commit 177273006e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -959,55 +959,43 @@ void cLuaState::Push(cEntity * a_Entity)
lua_pushnil(m_LuaState); lua_pushnil(m_LuaState);
} }
else else
{
const char * ClassName = [&]
{ {
switch (a_Entity->GetEntityType()) switch (a_Entity->GetEntityType())
{ {
case cEntity::etBoat: return "cBoat";
case cEntity::etExpOrb: return "cExpOrb";
case cEntity::etFallingBlock: return "cFallingBlock";
case cEntity::etFloater: return "cFloater";
case cEntity::etItemFrame: return "cItemFrame";
case cEntity::etLeashKnot: return "cLeashKnot";
case cEntity::etPainting: return "cPainting";
case cEntity::etPickup: return "cPickup";
case cEntity::etPlayer: return "cPlayer";
case cEntity::etTNT: return "cTNTEntity";
case cEntity::etMonster: case cEntity::etMonster:
{ {
// Don't push specific mob types, as those are not exported in the API: // Don't push specific mob types, as those are not exported in the API:
tolua_pushusertype(m_LuaState, a_Entity, "cMonster"); return "cMonster";
break;
}
case cEntity::etPlayer:
{
tolua_pushusertype(m_LuaState, a_Entity, "cPlayer");
break;
}
case cEntity::etPickup:
{
tolua_pushusertype(m_LuaState, a_Entity, "cPickup");
break;
}
case cEntity::etTNT:
{
tolua_pushusertype(m_LuaState, a_Entity, "cTNTEntity");
break;
} }
case cEntity::etProjectile: case cEntity::etProjectile:
{ {
tolua_pushusertype(m_LuaState, a_Entity, a_Entity->GetClass()); // Push the specific projectile type:
break; return a_Entity->GetClass();
}
case cEntity::etFloater:
{
tolua_pushusertype(m_LuaState, a_Entity, "cFloater");
break;
} }
case cEntity::etEntity: case cEntity::etEntity:
case cEntity::etEnderCrystal: case cEntity::etEnderCrystal:
case cEntity::etFallingBlock:
case cEntity::etMinecart: case cEntity::etMinecart:
case cEntity::etBoat:
case cEntity::etExpOrb:
case cEntity::etItemFrame:
case cEntity::etPainting:
case cEntity::etLeashKnot:
{ {
// Push the generic entity class type: // Push the generic entity class type:
tolua_pushusertype(m_LuaState, a_Entity, "cEntity"); return "cEntity";
} }
} // switch (EntityType) } // switch (EntityType)
}();
tolua_pushusertype(m_LuaState, a_Entity, ClassName);
} }
} }