forked from oerkki/voxelands
various cleanups and optimisations
This commit is contained in:
parent
1aac87bf61
commit
4ce27a2dc5
|
@ -1439,17 +1439,20 @@ bool isFreeServerActiveObjectId(u16 id,
|
|||
u16 getFreeServerActiveObjectId(
|
||||
core::map<u16, ServerActiveObject*> &objects)
|
||||
{
|
||||
u16 new_id = 1;
|
||||
for(;;)
|
||||
{
|
||||
if(isFreeServerActiveObjectId(new_id, objects))
|
||||
return new_id;
|
||||
//try to reuse id's as late as possible
|
||||
static u16 last_used_id = 0;
|
||||
u16 startid = last_used_id;
|
||||
|
||||
if(new_id == 65535)
|
||||
for (;;) {
|
||||
last_used_id++;
|
||||
if (isFreeServerActiveObjectId(last_used_id, objects))
|
||||
return last_used_id;
|
||||
|
||||
if (last_used_id == startid)
|
||||
return 0;
|
||||
|
||||
new_id++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16 ServerEnvironment::addActiveObject(ServerActiveObject *object)
|
||||
|
@ -2342,17 +2345,19 @@ bool isFreeClientActiveObjectId(u16 id,
|
|||
u16 getFreeClientActiveObjectId(
|
||||
core::map<u16, ClientActiveObject*> &objects)
|
||||
{
|
||||
u16 new_id = 1;
|
||||
for(;;)
|
||||
{
|
||||
if(isFreeClientActiveObjectId(new_id, objects))
|
||||
return new_id;
|
||||
//try to reuse id's as late as possible
|
||||
static u16 last_used_id = 0;
|
||||
u16 startid = last_used_id;
|
||||
|
||||
if(new_id == 65535)
|
||||
for (;;) {
|
||||
last_used_id ++;
|
||||
if (isFreeClientActiveObjectId(last_used_id, objects))
|
||||
return last_used_id;
|
||||
|
||||
if(last_used_id == startid)
|
||||
return 0;
|
||||
|
||||
new_id++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16 ClientEnvironment::addActiveObject(ClientActiveObject *object)
|
||||
|
|
|
@ -712,8 +712,7 @@ const InventoryList * Inventory::getList(const std::string &name) const
|
|||
|
||||
const s32 Inventory::getListIndex(const std::string &name) const
|
||||
{
|
||||
for(u32 i=0; i<m_lists.size(); i++)
|
||||
{
|
||||
for(u32 i=0; i<m_lists.size(); i++) {
|
||||
if (m_lists[i]->getName() == name)
|
||||
return i;
|
||||
}
|
||||
|
@ -729,23 +728,20 @@ InventoryAction * InventoryAction::deSerialize(std::istream &is)
|
|||
std::string type;
|
||||
std::getline(is, type, ' ');
|
||||
|
||||
InventoryAction *a = NULL;
|
||||
|
||||
if(type == "Move")
|
||||
{
|
||||
a = new IMoveAction(is);
|
||||
}
|
||||
return new IMoveAction(is);
|
||||
|
||||
return a;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static std::string describeC(const struct InventoryContext *c)
|
||||
{
|
||||
if(c->current_player == NULL)
|
||||
if(c->current_player == NULL) {
|
||||
return "current_player=NULL";
|
||||
else
|
||||
}else{
|
||||
return std::string("current_player=") + c->current_player->getName();
|
||||
}
|
||||
}
|
||||
|
||||
void IMoveAction::apply(InventoryContext *c, InventoryManager *mgr)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue