6 n__user_8h
gullradriel edited this page 2026-10-09 00:55:18 +02:00

include/nilorea/n_user.h

USERS handling for tiny game apps. More...

Structures

Name
struct N_USERLIST
USER list.
struct N_USER
USER management cell.

Detailed Description

USERS handling for tiny game apps.

Author: Castagnier Mickael

Version: 1.0

Date: 20/02/2006

Windows headers order include.

Source code

/*
 * Nilorea Library
 * Copyright (C) 2005-2026 Castagnier Mickael
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * SPDX-License-Identifier: Apache-2.0
 */


#ifndef N_USER_MANAGEMENT

#define N_USER_MANAGEMENT

#ifdef __cplusplus
extern "C" {
#endif

#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_str.h"
#include "nilorea/n_network.h"
#include "nilorea/n_3d.h"


#define USERLIST_ALL 0
#define USERLIST_ALL_EXCEPT 1
#define USERLIST_ONE 2

typedef struct N_USER {
    char name[1024];

    NETWORK* netw;

    int state,
        nb_rec_pos,
        only_last_pos,
        id;

    VECTOR3D* last_positions;
    VECTOR3D position;

    LIST* netw_waitlist;

} N_USER;

typedef struct N_USERLIST {
    N_USER* list;

    int max,
        highter;

    pthread_rwlock_t user_rwbolt;

} N_USERLIST;

N_USERLIST* userlist_new(int max);
int userlist_set_position_behavior(N_USERLIST* ulist, int id, int nb_rec_pos, int only_last_pos);
int userlist_add_user(N_USERLIST* ulist, NETWORK* netw);
int userlist_del_user(N_USERLIST* ulist, int id);
int userlist_add_msg_to_ex(N_USERLIST* ulist, N_STR* msg, int mode, int id);
int userlist_add_msg_to(N_USERLIST* ulist, N_STR* msg, int id);
int userlist_add_msg_to_all(N_USERLIST* ulist, N_STR* msg);
int userlist_add_msg_to_all_except(N_USERLIST* ulist, N_STR* msg, int id);
int userlist_destroy(N_USERLIST** ulist);
int userlist_user_add_waiting_msg(N_USERLIST* ulist, int id, N_STR* netmsg);
int userlist_user_send_waiting_msgs(N_USERLIST* ulist, int id);
int userlist_send_waiting_msgs(N_USERLIST* ulist);


#ifdef __cplusplus
}
#endif

#endif  // header guard