23 static std::vector<std::pair<object *, tag_t>>
friends;
39 LOG(
llevError,
"add_friendly_object: Trying to add object already on list (%s)\n", op->
name);
54 auto find = std::find_if(
friends.begin(),
friends.end(), [&] (
auto item) {
return item.first == op; });
56 if ((*find).second != op->
count) {
57 LOG(
llevError,
"remove_friendly_object, tags do no match, %s, %u != %u\n",
71 std::for_each(
friends.begin(),
friends.end(), [] (
const auto item) {
72 LOG(
llevError,
"%s (%u)\n", item.first->name, item.second);
87 || ((*item).first->count != (*item).second)) {
97 LOG(
llevDebug,
"clean_friendly_list: Removed %d bogus links\n", count);
109 return std::find_if(
friends.begin(),
friends.end(), [&] (
auto item) {
return item.first == op; }) !=
friends.end();
122 add->
id = item.second;
123 add->
ob = item.first;
147 if (current ==
nullptr) {
150 auto pos = std::find_if(
friends.begin(),
friends.end(), [&] (
const auto item) {
return item.first == current; });
155 return pos ==
friends.end() ? nullptr : (*pos).first;
object * ob
Item to link to.
objectlink * get_objectlink(void)
Allocates a new objectlink structure, initialises it, and returns a pointer to it.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
#define FLAG_FRIENDLY
Will help players.
static std::vector< std::pair< object *, tag_t > > friends
List of all friendly objects, object and its count.
void clean_friendly_list(void)
It traverses the friendly list removing objects that should not be here (ie, do not have friendly fla...
void dump_friendly_objects(void)
Dumps all friendly objects.
void remove_friendly_object(object *op)
Removes the specified object from the linked list of friendly objects.
Global type definitions and header inclusions.
int is_friendly(const object *op)
Checks if the given object is already in the friendly list or not.
tag_t id
ob's tag, in case it is removed.
#define QUERY_FLAG(xyz, p)
void clear_friendly_list(void)
Totally clear the friendly list.
objectlink * get_friends_of(const object *owner)
Get a list of friendly objects for the specified owner.
Used to link together several objects.
object * get_next_friend(object *current)
Get the next object on the friendly list.
void add_friendly_object(object *op)
Add a new friendly object to the list of friendly objects.
sstring name
The name of the object, obviously...
Only for debugging purposes.
#define CLEAR_FLAG(xyz, p)
tag_t count
Unique object number for this object.
objectlink * next
Next item to link to.
#define FLAG_FREED
Object is in the list of free objects.