mirror of
https://github.com/UberGames/rpgxEF.git
synced 2025-04-22 08:50:48 +00:00
more fixes
This commit is contained in:
parent
696a1ad99d
commit
35fc7f2d27
3 changed files with 73 additions and 101 deletions
|
@ -633,8 +633,9 @@ and transfer to clients
|
|||
**************************/
|
||||
static qboolean G_LoadClassData( char* fileName )
|
||||
{
|
||||
char *buffer = NULL;
|
||||
char *textPtr = NULL, *token = NULL;
|
||||
char* buffer = NULL;
|
||||
char* textPtr = NULL;
|
||||
char* token = NULL;
|
||||
int fileLen;
|
||||
fileHandle_t f = 0;
|
||||
qboolean classValid=qfalse;
|
||||
|
@ -647,18 +648,18 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
|
||||
fileLen = trap_FS_FOpenFile( fileName, &f, FS_READ );
|
||||
|
||||
if ( !f ) {
|
||||
if ( f == 0 ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: File %s not found.\n", fileName );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
buffer = (char *)malloc((fileLen+1) * sizeof(char));
|
||||
|
||||
if(!buffer) {
|
||||
if(buffer == NULL) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Was unable to allocate %i bytes.\n", (fileLen+1) * sizeof(char) );
|
||||
trap_FS_FCloseFile( f );
|
||||
return qfalse;
|
||||
}
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
trap_FS_Read( buffer, fileLen, f );
|
||||
buffer[fileLen] = 0;
|
||||
|
@ -670,36 +671,32 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
if ( !token[0] ) {
|
||||
if ( token == NULL || token[0] == 0 ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: No data was found when going to parse the file!\n" );
|
||||
free(buffer);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( Q_stricmpn( token, "{", 1 ) ) {
|
||||
if ( Q_stricmpn( token, "{", 1 ) != 0 ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: File did not start with a '{' symbol!\n" );
|
||||
free(buffer);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
if ( classIndex >= MAX_CLASSES )
|
||||
while ( qtrue ) {
|
||||
if ( classIndex >= MAX_CLASSES ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "{", 1 ) )
|
||||
{
|
||||
while ( 1 )
|
||||
{
|
||||
if ( Q_stricmpn( token, "{", 1 ) == 0 ) {
|
||||
while ( qtrue ) {
|
||||
token = COM_Parse( &textPtr );
|
||||
if (!token[0]) {
|
||||
if (token == NULL || token[0] == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "consoleName", 11 ) )
|
||||
{
|
||||
if ( COM_ParseString( &textPtr, &token ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "consoleName", 11 ) == 0 ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Invalid class console name in class index: %i.\n", classIndex );
|
||||
SkipBracedSection( &textPtr );
|
||||
continue;
|
||||
|
@ -711,10 +708,8 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "formalName", 11 ) )
|
||||
{
|
||||
if ( COM_ParseString( &textPtr, &token ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "formalName", 11 ) == 0 ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Invalid class formal name in class index: %i.\n", classIndex );
|
||||
SkipBracedSection( &textPtr );
|
||||
continue;
|
||||
|
@ -726,10 +721,8 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "message", 7 ) )
|
||||
{
|
||||
if ( COM_ParseString( &textPtr, &token ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "message", 7 ) == 0 ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Invalid class message in class index: %i.\n", classIndex );
|
||||
continue;
|
||||
}
|
||||
|
@ -738,10 +731,8 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "modelSkin", 9 ) )
|
||||
{
|
||||
if ( COM_ParseString( &textPtr, &token ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "modelSkin", 9 ) == 0 ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Invalid class skin color in class index: %i.\n", classIndex );
|
||||
continue;
|
||||
}
|
||||
|
@ -750,37 +741,36 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "weapons", 7) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "weapons", 7) == 0 ) {
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
if ( Q_stricmpn( token, "{", 1 ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "{", 1 ) != 0 ) {
|
||||
G_Printf( S_COLOR_RED "No opening bracket found for weapons field in class: %i.\n", classIndex );
|
||||
SkipRestOfLine( &textPtr );
|
||||
continue;
|
||||
}
|
||||
|
||||
//sub loop
|
||||
while ( 1 )
|
||||
{
|
||||
while ( qtrue ) {
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
if ( !token[0] )
|
||||
if ( token == NULL || token[0] == 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "|", 1 ) )
|
||||
if ( Q_stricmpn( token, "|", 1 ) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "}", 1 ) )
|
||||
if ( Q_stricmpn( token, "}", 1 ) == 0 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if( !Q_stricmpn( token, "WP_", 3 ) )
|
||||
if( Q_stricmpn( token, "WP_", 3 ) == 0 )
|
||||
{
|
||||
weapon = GetIDForString( WeaponTable, token );
|
||||
|
||||
if ( weapon >= 0 )
|
||||
{
|
||||
if ( weapon >= 0 ) {
|
||||
g_classData[classIndex].weaponsFlags |= ( 1 << weapon );
|
||||
continue;
|
||||
}
|
||||
|
@ -790,10 +780,8 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "admin", 5 ) )
|
||||
{
|
||||
if ( COM_ParseInt( &textPtr, &g_classData[classIndex].isAdmin ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "admin", 5 ) == 0 ) {
|
||||
if ( COM_ParseInt( &textPtr, &g_classData[classIndex].isAdmin ) ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Class admin check for class %i was invalid.\n", classIndex );
|
||||
continue;
|
||||
}
|
||||
|
@ -801,10 +789,8 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "marine", 6 ) )
|
||||
{
|
||||
if ( COM_ParseInt( &textPtr, &g_classData[classIndex].isMarine ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "marine", 6 ) == 0 ) {
|
||||
if ( COM_ParseInt( &textPtr, &g_classData[classIndex].isMarine ) ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Class marine check for class %i was invalid.\n", classIndex );
|
||||
continue;
|
||||
}
|
||||
|
@ -812,10 +798,8 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "medical", 7 ) )
|
||||
{
|
||||
if ( COM_ParseInt( &textPtr, &g_classData[classIndex].isMedical ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "medical", 7 ) == 0) {
|
||||
if ( COM_ParseInt( &textPtr, &g_classData[classIndex].isMedical ) ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Class medic check for class %i was invalid.\n", classIndex );
|
||||
continue;
|
||||
}
|
||||
|
@ -823,20 +807,16 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
continue;
|
||||
}
|
||||
|
||||
if( !Q_stricmpn( token, "isBorg", 6 ) )
|
||||
{
|
||||
if( COM_ParseInt( &textPtr, &g_classData[classIndex].isBorg ) )
|
||||
{
|
||||
if( Q_stricmpn( token, "isBorg", 6 ) == 0 ) {
|
||||
if( COM_ParseInt( &textPtr, &g_classData[classIndex].isBorg ) ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Class borg check for class %i was invalid.\n", classIndex );
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "n00b", 4 ) )
|
||||
{
|
||||
if ( COM_ParseInt( &textPtr, &g_classData[classIndex].isn00b ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "n00b", 4 ) == 0 ) {
|
||||
if ( COM_ParseInt( &textPtr, &g_classData[classIndex].isn00b ) ) {
|
||||
G_Printf( S_COLOR_RED "ERROR: Class n00b check for class %i was invalid.\n", classIndex );
|
||||
continue;
|
||||
}
|
||||
|
@ -845,33 +825,29 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
}
|
||||
|
||||
//skip the client-side specific entries since they interfere with the parsing
|
||||
if ( !Q_stricmpn( token, "radarColor", 10 )
|
||||
|| !Q_stricmpn( token, "iconColor", 9 )
|
||||
|| !Q_stricmpn( token, "hasRanks", 8 )
|
||||
|| !Q_stricmpn( token, "noShow", 6 )
|
||||
)
|
||||
{
|
||||
if ( (Q_stricmpn( token, "radarColor", 10 ) == 0)
|
||||
|| (Q_stricmpn( token, "iconColor", 9 ) == 0)
|
||||
|| (Q_stricmpn( token, "hasRanks", 8 ) == 0)
|
||||
|| (Q_stricmpn( token, "noShow", 6 ) == 0)
|
||||
) {
|
||||
SkipRestOfLine( &textPtr );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "}", 1 ) )
|
||||
{
|
||||
if ( Q_stricmpn( token, "}", 1 ) == 0 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( classValid )
|
||||
{
|
||||
if ( classValid ) {
|
||||
classIndex++;
|
||||
classValid = qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
if (!token[0])
|
||||
{
|
||||
if (token == NULL || token[0] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -879,18 +855,14 @@ static qboolean G_LoadClassData( char* fileName )
|
|||
free(buffer);
|
||||
|
||||
//build ourselves custom CVARs for each class
|
||||
for ( i=0; g_classData[i].consoleName[0] && i < MAX_CLASSES; i++ )
|
||||
{
|
||||
for ( i=0; (g_classData[i].consoleName[0] != 0) && (i < MAX_CLASSES); i++ ) {
|
||||
trap_Cvar_Register( NULL, va("rpg_%sPass", g_classData[i].consoleName ), g_classData[i].consoleName, CVAR_ARCHIVE );
|
||||
trap_Cvar_Register( NULL, va("rpg_%sFlags", g_classData[i].consoleName ), va("%i", g_classData[i].weaponsFlags), CVAR_ARCHIVE );
|
||||
}
|
||||
|
||||
if ( classIndex > 0 )
|
||||
{
|
||||
if ( classIndex > 0 ) {
|
||||
return qtrue;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
G_Printf( S_COLOR_RED "ERROR: No valid classes were found.\n");
|
||||
return qfalse;
|
||||
}
|
||||
|
@ -1012,7 +984,7 @@ static void G_LoadHolodeckFile(void) {
|
|||
COM_BeginParseSession();
|
||||
txtPtr = buffer;
|
||||
|
||||
while(1) {
|
||||
while(qtrue) {
|
||||
token = COM_Parse(&txtPtr);
|
||||
if(token == NULL || token[0] == 0) {
|
||||
break;
|
||||
|
@ -1043,7 +1015,7 @@ static void G_LoadHolodeckFile(void) {
|
|||
// <string> - desc1
|
||||
// <string> - desc2
|
||||
// <string> - image
|
||||
while(Q_stricmpn(token, "]", 1)) {
|
||||
while(Q_stricmpn(token, "]", 1) != 0) {
|
||||
if(token == NULL || token[0] == 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ void trap_SendConsoleCommand( int exec_when, const char *text ) {
|
|||
syscall( G_SEND_CONSOLE_COMMAND, exec_when, text );
|
||||
}
|
||||
|
||||
void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ) {
|
||||
void trap_Cvar_Register( /*@null@*/ vmCvar_t *cvar, const char *var_name, const char *value, int flags ) {
|
||||
syscall( G_CVAR_REGISTER, cvar, var_name, value, flags );
|
||||
}
|
||||
|
||||
|
|
|
@ -98,25 +98,25 @@ struct list{
|
|||
int length; /*!< count of elements in the list */
|
||||
lnode_p first; /*!< first element of the list */
|
||||
lnode_p last; /*!< last element of the list */
|
||||
void (*destructor)(void*); /*!< pointer to destructor for data. Default is free. */
|
||||
list_iter_p (*iterator)(list_p list, char init); /*!< creates a new list iterator */
|
||||
void (*destructor)(/*@only@*/ /*@out@*/ /*@null@*/ void*); /*!< pointer to destructor for data. Default is free. */
|
||||
/*@shared@*/ /*@null@*/ list_iter_p (*iterator)(list_p list, char init); /*!< creates a new list iterator */
|
||||
int (*add_ptr)(list_p list, void* data, dataType_t type, char end); /*!< add a pointer to the list */
|
||||
int (*append_ptr)(list_p list, void* data, dataType_t type); /*!< append a pointer to the list */
|
||||
int (*prepend_ptr)(list_p list, void* data, dataType_t type); /*!< prepend a pointer to the list */
|
||||
int (*add)(list_p list, void* data, dataType_t type, size_t size, char end); /*!< add data to the list */
|
||||
int (*append)(list_p list, void* data, dataType_t type, size_t size); /*!< append data to the list */
|
||||
int (*prepend)(list_p list, void* data, dataType_t type, size_t size); /*!< prepend data to the list */
|
||||
container_p (*at)(list_p list, int idx); /*!< get container at given index */
|
||||
/*@shared@*/ /*@null@*/ container_p (*at)(list_p list, int idx); /*!< get container at given index */
|
||||
void (*clear)(list_p list); /*!< clear the list */
|
||||
container_p (*current)(list_iter_p iter); /*!< get the current element for the iterator */
|
||||
container_p (*cycl_next)(list_iter_p iter); /*!< get the next element for the iterator (cyclic access) */
|
||||
container_p (*cycl_prev)(list_iter_p iter); /*!< get the previous element for the iterator (cyclic acccess) */
|
||||
container_p (*front)(list_p list); /*!< get the first element of the list */
|
||||
container_p (*end)(list_p list); /*!< get the last element of the list */
|
||||
container_p (*next)(list_iter_p iter); /*!< get the next element for the iterator */
|
||||
container_p (*prev)(list_iter_p iter); /*!< get the previous element for the iterator */
|
||||
container_p (*poll)(list_p list); /*<! poll */
|
||||
container_p (*pop)(list_p list); /*<! pop */
|
||||
/*@shared@*/ /*@null@*/ container_p (*current)(list_iter_p iter); /*!< get the current element for the iterator */
|
||||
/*@shared@*/ /*@null@*/ container_p (*cycl_next)(list_iter_p iter); /*!< get the next element for the iterator (cyclic access) */
|
||||
/*@shared@*/ /*@null@*/ container_p (*cycl_prev)(list_iter_p iter); /*!< get the previous element for the iterator (cyclic acccess) */
|
||||
/*@shared@*/ /*@null@*/ container_p (*front)(list_p list); /*!< get the first element of the list */
|
||||
/*@shared@*/ /*@null@*/ container_p (*end)(list_p list); /*!< get the last element of the list */
|
||||
/*@shared@*/ /*@null@*/ container_p (*next)(list_iter_p iter); /*!< get the next element for the iterator */
|
||||
/*@shared@*/ /*@null@*/ container_p (*prev)(list_iter_p iter); /*!< get the previous element for the iterator */
|
||||
/*@shared@*/ /*@null@*/ container_p (*poll)(list_p list); /*<! poll */
|
||||
/*@shared@*/ /*@null@*/ container_p (*pop)(list_p list); /*<! pop */
|
||||
void (*remove)(list_p list, char end); /*!< remove an element from the list */
|
||||
void (*removeAt)(list_p list, int idx); /*!< remove an element at a specified index */
|
||||
};
|
||||
|
@ -136,21 +136,21 @@ struct list_iter {
|
|||
*
|
||||
* \return A new list allocated on the heap.
|
||||
*/
|
||||
list_p create_list(void);
|
||||
/*@shared@*/ /*@null@*/ list_p create_list(void);
|
||||
|
||||
/**
|
||||
* Completely free the data associated with the list.
|
||||
*
|
||||
* \param list pointer to a list
|
||||
*/
|
||||
void destroy_list(list_p list);
|
||||
void destroy_list(/*@only@*/ /*@out@*/ /*@null@*/ list_p list);
|
||||
|
||||
/**
|
||||
* Destroy a list iterator if allocated.
|
||||
*
|
||||
* \param list pointer to a iterator
|
||||
*/
|
||||
void destroy_iterator(list_iter_p iter);
|
||||
void destroy_iterator(/*@only@*/ /*@out@*/ /*@null@*/list_iter_p iter);
|
||||
|
||||
/**
|
||||
* Initialize list. For use on lists that are NOT allocated on the heap.
|
||||
|
@ -158,6 +158,6 @@ void destroy_iterator(list_iter_p iter);
|
|||
* \param l a list
|
||||
* \param destructor pointer to destructor function
|
||||
*/
|
||||
void list_init(struct list * l, void (*destructor)(void*));
|
||||
void list_init(struct list * l, /*@null@*/ void (*destructor)(void*));
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue