mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Drop content_sao.{cpp,h}
Move LuaEntitySAO to a new dedicated file Drop TestSAO (useless object) Drop the old static startup initialized SAO factory, which was pretty useless. This factory was using a std::map for 2 elements, now just use a simple condition owned by ServerEnvironment, which will be lightweight, that will also drop a one time useful test on each LuaEntitySAO creation. This should reduce server load on massive SAO creation
This commit is contained in:
parent
894a34aef4
commit
5146086a64
25 changed files with 126 additions and 295 deletions
|
@ -30,39 +30,6 @@ ServerActiveObject::ServerActiveObject(ServerEnvironment *env, v3f pos):
|
|||
{
|
||||
}
|
||||
|
||||
ServerActiveObject* ServerActiveObject::create(ActiveObjectType type,
|
||||
ServerEnvironment *env, u16 id, v3f pos,
|
||||
const std::string &data)
|
||||
{
|
||||
// Find factory function
|
||||
std::map<u16, Factory>::iterator n;
|
||||
n = m_types.find(type);
|
||||
if(n == m_types.end()) {
|
||||
// These are 0.3 entity types, return without error.
|
||||
if (ACTIVEOBJECT_TYPE_ITEM <= type && type <= ACTIVEOBJECT_TYPE_MOBV2) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// If factory is not found, just return.
|
||||
warningstream<<"ServerActiveObject: No factory for type="
|
||||
<<type<<std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Factory f = n->second;
|
||||
ServerActiveObject *object = (*f)(env, pos, data);
|
||||
return object;
|
||||
}
|
||||
|
||||
void ServerActiveObject::registerType(u16 type, Factory f)
|
||||
{
|
||||
std::map<u16, Factory>::iterator n;
|
||||
n = m_types.find(type);
|
||||
if(n != m_types.end())
|
||||
return;
|
||||
m_types[type] = f;
|
||||
}
|
||||
|
||||
float ServerActiveObject::getMinimumSavedMovement()
|
||||
{
|
||||
return 2.0*BS;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue