diff options
-rw-r--r-- | src/game/g_admin.c | 51 | ||||
-rw-r--r-- | src/game/g_admin.h | 2 |
2 files changed, 52 insertions, 1 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 5c4af687..adf840d1 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -923,6 +923,52 @@ qboolean G_admin_cmd_check( gentity_t *ent ) return qfalse; } +struct llist +{ + struct llist *next; +}; +static void llsort( struct llist **head, int compar( const void *, const void * ) ) +{ + struct llist *a, *b, *t, *l; + int i, c = 1, ns, as, bs; + + if( !*head ) + return; + + do + { + a = *head, l = *head = NULL; + for( ns = 0; a; ns++, a = b ) + { + b = a; + for( i = as = 0; i < c; i++ ) + { + as++; + if( !( b = b->next ) ) + break; + } + for( bs = c; ( b && bs ) || as; l = t ) + { + if( as && ( !bs || !b || compar( a, b ) < 0 ) ) + t = a, a = a->next, as--; + else + t = b, b = b->next, bs--; + if( l ) + l->next = t; + else + *head = t; + } + } + l->next = NULL; + c *= 2; + } while( ns > 1 ); +} + +static int cmplevel( const void *a, const void *b ) +{ + return ((g_admin_level_t *)b)->level - ((g_admin_level_t *)a)->level; +} + qboolean G_admin_readconfig( gentity_t *ent ) { g_admin_level_t *l = NULL; @@ -1127,6 +1173,11 @@ qboolean G_admin_readconfig( gentity_t *ent ) lc, ac, bc, cc ) ); if( lc == 0 ) admin_default_levels(); + else + { + llsort( (struct llist **)&g_admin_levels, cmplevel ); + llsort( (struct llist **)&g_admin_admins, cmplevel ); + } // restore admin mapping for( i = 0; i < level.maxclients; i++ ) diff --git a/src/game/g_admin.h b/src/game/g_admin.h index 0ff45796..3de278af 100644 --- a/src/game/g_admin.h +++ b/src/game/g_admin.h @@ -92,9 +92,9 @@ g_admin_level_t; typedef struct g_admin_admin { struct g_admin_admin *next; + int level; char guid[ 33 ]; char name[ MAX_NAME_LENGTH ]; - int level; char flags[ MAX_ADMIN_FLAGS ]; } g_admin_admin_t; |