From 8fd75f88d2c9fc3be927c620cf57bd47bb8984ef Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Thu, 11 Jan 2024 04:40:31 -0600 Subject: add launch command --- src/user.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/user.c') diff --git a/src/user.c b/src/user.c index fd1acd5..eaaadf6 100644 --- a/src/user.c +++ b/src/user.c @@ -591,6 +591,32 @@ void l2_user_delete(struct l2_user *user) } } +struct l2_user *l2_user_search(const char *searchstr) +{ + uuid_t uuid; + bool have_uuid = false; + + if (l2_uuid_from_string(&uuid, searchstr) == 0) { + have_uuid = true; + } else { + if (l2_uuid_from_string_short(&uuid, searchstr) == 0) { + have_uuid = true; + } + } + + for (struct l2_user *cur = l2_state.users_head; cur; cur = cur->next) { + if (have_uuid && !l2_uuid_compare(&cur->profile.uuid, &uuid)) { + return cur; + } else if (cur->nickname && !strcmp(searchstr, cur->nickname)) { + return cur; + } else if (!strcmp(searchstr, cur->profile.name)) { + return cur; + } + } + + return NULL; +} + void l2_user_init(struct l2_user *user) { /* using calloc works as well, so that's what we do in this file (elsewhere should use this function though) */ -- cgit v1.2.3-70-g09d2