diff --git dataobj/objlist.cc dataobj/objlist.cc index 1c2dc520b9..fc564328aa 100644 --- dataobj/objlist.cc +++ dataobj/objlist.cc @@ -376,6 +376,26 @@ void objlist_t::sort_trees(uint8 index, uint8 count) } +bool objlist_t::append(obj_t *new_obj) +{ + if(capacity==0) { + // the first one save direct + obj.one = new_obj; + top = 1; + capacity = 1; + return true; + } + + if(top>=capacity && !grow_capacity()) { + // memory exceeded + return false; + } + + intern_insert_at(new_obj, top); + return true; +} + + bool objlist_t::add(obj_t* new_obj) { if(capacity==0) { @@ -992,7 +1012,7 @@ void objlist_t::rdwr(loadsave_t *file, koord3d current_pos) } if(new_obj) { - add(new_obj); + append(new_obj); } } } diff --git dataobj/objlist.h dataobj/objlist.h index 1e7c372cda..b890dde3b2 100644 --- dataobj/objlist.h +++ dataobj/objlist.h @@ -70,12 +70,10 @@ public: // usually used only for copying by grund_t obj_t *remove_last(); - /** - * this routine will automatically obey the correct order of things during - * insert into objlist - */ - bool add(obj_t* obj); + /// This routine will automatically obey the correct order of things during insertion. + bool add(obj_t *obj); + bool append(obj_t *obj); bool remove(const obj_t* obj); bool loesche_alle(player_t *player,uint8 offset); bool ist_da(const obj_t* obj) const; diff --git vehicle/simvehicle.cc vehicle/simvehicle.cc index 6b9387c2f6..b948375cdc 100644 --- vehicle/simvehicle.cc +++ vehicle/simvehicle.cc @@ -1555,7 +1555,7 @@ DBG_MESSAGE("vehicle_t::rdwr_from_convoi()","bought at %i/%i.",(purchase_time%12 ware_t ware(file); if( (desc==NULL || ware.menge>0) && welt->is_within_limits(ware.get_zielpos()) && ware.get_desc() ) { // also add, of the desc is unknown to find matching replacement - fracht.insert(ware); + fracht.append(ware); #ifdef CACHE_TRANSIT if( file->is_version_less(112, 1) ) #endif