mirror of
https://github.com/UberGames/RPG-X2.git
synced 2024-11-24 05:11:19 +00:00
Critical bugfixes ...
- Fixed errors preventing any map from beeing loaded - Fix for func_stasis_door ... so they don't crash the game anymore when loading maps containing them.
This commit is contained in:
parent
c9624b4ff5
commit
046c6a4e8e
8 changed files with 17 additions and 1933 deletions
|
@ -1263,7 +1263,6 @@ static char *CG_ParseFontParms(char *buffer,int propArray[CHARMAX][3])
|
|||
CG_LoadFonts
|
||||
=================
|
||||
*/
|
||||
#ifdef QVM
|
||||
void CG_LoadFonts(void)
|
||||
{
|
||||
char buffer[FONT_BUFF_LENGTH];
|
||||
|
@ -1300,52 +1299,6 @@ void CG_LoadFonts(void)
|
|||
holdBuf = CG_ParseFontParms( holdBuf,propMapBig);
|
||||
|
||||
}
|
||||
#else
|
||||
void CG_LoadFonts(void)
|
||||
{
|
||||
char *buffer;
|
||||
int len;
|
||||
fileHandle_t f;
|
||||
char *holdBuf;
|
||||
|
||||
buffer = (char *)malloc(sizeof(char)*FONT_BUFF_LENGTH);
|
||||
if(!buffer) {
|
||||
CG_Printf("CG_LoadFonts: could not allocate %u byte\n", sizeof(char)*FONT_BUFF_LENGTH);
|
||||
return;
|
||||
}
|
||||
|
||||
len = trap_FS_FOpenFile( "ext_data/fonts.dat", &f, FS_READ );
|
||||
|
||||
if ( !f )
|
||||
{
|
||||
trap_Print( va( S_COLOR_RED "CG_LoadFonts : FONTS.DAT file not found!\n"));
|
||||
free(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (len > FONT_BUFF_LENGTH)
|
||||
{
|
||||
trap_Print( va( S_COLOR_RED "CG_LoadFonts : FONTS.DAT file bigger than %d!\n",FONT_BUFF_LENGTH));
|
||||
free(buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
// initialise the data area
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
|
||||
trap_FS_Read( buffer, len, f );
|
||||
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
COM_BeginParseSession();
|
||||
|
||||
holdBuf = (char *) buffer;
|
||||
holdBuf = CG_ParseFontParms( holdBuf,propMapTiny);
|
||||
holdBuf = CG_ParseFontParms( holdBuf,propMap);
|
||||
holdBuf = CG_ParseFontParms( holdBuf,propMapBig);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -1510,7 +1463,6 @@ CG_LoadRanks
|
|||
By TiM
|
||||
=================
|
||||
*/
|
||||
#ifdef QVM
|
||||
qboolean CG_LoadRanks( void ) {
|
||||
fileHandle_t file;
|
||||
int file_len;
|
||||
|
@ -1758,272 +1710,6 @@ qboolean CG_LoadRanks( void ) {
|
|||
}
|
||||
return qtrue;
|
||||
}
|
||||
#else
|
||||
qboolean CG_LoadRanks( void ) {
|
||||
fileHandle_t file;
|
||||
int file_len;
|
||||
char *charText;
|
||||
char *textPtr, *prevValue;
|
||||
char fileName[MAX_QPATH];
|
||||
int i;
|
||||
int rankCount=0;
|
||||
char *token;
|
||||
|
||||
qboolean DefaultRankLoaded = qfalse;
|
||||
|
||||
charText = (char *)malloc(sizeof(char)*32000);
|
||||
if(!charText) {
|
||||
CG_Printf("CG_LoadRanks: could not allocate %u byte\n", sizeof(char)*32000);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( cgs.rankSet ) {
|
||||
Com_sprintf( fileName, sizeof( fileName ), "ext_data/ranksets/%s.ranks", cgs.rankSet );
|
||||
}
|
||||
else {
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
file_len = trap_FS_FOpenFile( fileName, &file, FS_READ );
|
||||
|
||||
if ( file_len <= 0 ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( file_len >= sizeof( charText ) - 1 ) {
|
||||
Com_Printf( S_COLOR_RED "Size of rankset file %s is too large.\n", fileName );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
memset( &charText, 0, sizeof( charText ) );
|
||||
memset( &cgs.defaultRankData, 0, sizeof( cgs.defaultRankData ) );
|
||||
memset( &cgs.ranksData, 0, sizeof( cgs.ranksData ) );
|
||||
|
||||
trap_FS_Read( charText, file_len, file );
|
||||
|
||||
charText[file_len] = 0;
|
||||
|
||||
trap_FS_FCloseFile( file );
|
||||
|
||||
COM_BeginParseSession();
|
||||
|
||||
textPtr = charText;
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
if ( !token[0] ) {
|
||||
Com_Printf( S_COLOR_RED "No data found in rankset: %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( Q_stricmp( token, "{" ) ) {
|
||||
Com_Printf( S_COLOR_RED "Missing starting { in rankset file: %s\n", fileName);
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//Parse the first one only... the first one should be the DEFAULT RANK!!!
|
||||
//DEFAULT I SAY! IT'S SPECIAL!
|
||||
//WE NEED A DEFAULT FOR ERRORS! NO DEFAULT NO RANK FOR YOU!
|
||||
while ( 1 ) {
|
||||
prevValue = textPtr;
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "MenuTextureDef", 14 ) ) {
|
||||
if ( CG_ParseRankData( &textPtr, &cgs.defaultRankData.rankMenuData ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DefaultRankLoaded = qtrue;
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "BoltModel", 9 ) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Q_strncpyz( cgs.defaultRankData.rankModelData.boltModelPath, token,
|
||||
sizeof( cgs.defaultRankData.rankModelData.boltModelPath ) );
|
||||
|
||||
/*if ( !cgs.defaultRankData.boltModel ) {
|
||||
Com_Printf(S_COLOR_RED "Unable to load model file: %s\n", token );
|
||||
}*/
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "boltShader", 8 ) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Q_strncpyz( cgs.defaultRankData.rankModelData.boltShaderPath, token,
|
||||
sizeof( cgs.defaultRankData.rankModelData.boltShaderPath ) );
|
||||
|
||||
/*cgs.defaultRankData.boltShader = trap_R_RegisterSkin( token );
|
||||
if ( !cgs.defaultRankData.boltShader ) {
|
||||
Com_Printf(S_COLOR_RED "Unable to load skin file: %s\n", token );
|
||||
}*/
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "AdmiralRank", 11 ) ) {
|
||||
if ( COM_ParseInt( &textPtr, &i ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cgs.defaultRankData.rankModelData.admiralRank = i;
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmp( token, "}" ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//if we succeeded in loading a default value (^_^!), then begin parsing the main ranks
|
||||
if ( !DefaultRankLoaded ) {
|
||||
Com_Printf( S_COLOR_RED "No default rank located in %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
else {
|
||||
//Parse.Rank.Data? :) *sigh* if only rofl
|
||||
while (1) {
|
||||
prevValue = textPtr;
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( rankCount >= MAX_RANKS ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "{", 1 ) ) {
|
||||
|
||||
while ( 1 ) {
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "ConsoleName", 11 ) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
Com_Printf( S_COLOR_RED "Could not parse console rank name for rank number: %i\n", rankCount );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
Q_strncpyz( cgs.ranksData[rankCount].consoleName, token, sizeof( cgs.ranksData[rankCount].consoleName ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "FormalName", 10 ) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
Com_Printf( S_COLOR_RED "Could not parse formal rank name for rank number: %i\n", rankCount );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
Q_strncpyz( cgs.ranksData[rankCount].formalName, token, sizeof( cgs.ranksData[rankCount].formalName ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "MenuTextureRed", 14 ) ) {
|
||||
if ( CG_ParseRankData( &textPtr, &cgs.ranksData[rankCount].rankMenuData[CLR_RED] ) ) {
|
||||
Com_Printf( S_COLOR_RED "Could not parse red rank color for rank number: %i\n", rankCount );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "MenuTextureTeal", 15 ) ) {
|
||||
if ( CG_ParseRankData( &textPtr, &cgs.ranksData[rankCount].rankMenuData[CLR_TEAL] ) ) {
|
||||
Com_Printf( S_COLOR_RED "Could not parse teal rank color for rank number: %i\n", rankCount );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "MenuTextureGold", 15 ) ) {
|
||||
if ( CG_ParseRankData( &textPtr, &cgs.ranksData[rankCount].rankMenuData[CLR_GOLD] ) ) {
|
||||
Com_Printf( S_COLOR_RED "Could not parse teal rank color for rank number: %i\n", rankCount );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "MenuTextureGreen", 16 ) ) {
|
||||
if ( CG_ParseRankData( &textPtr, &cgs.ranksData[rankCount].rankMenuData[CLR_GREEN] ) ) {
|
||||
Com_Printf( S_COLOR_RED "Could not parse green rank color for rank number: %i\n", rankCount );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "BoltModel", 9 ) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//cgs.ranksData[rankCount].boltModel = trap_R_RegisterModel( token );
|
||||
|
||||
Q_strncpyz( cgs.ranksData[rankCount].rankModelData.boltModelPath,
|
||||
token,
|
||||
sizeof( cgs.ranksData[rankCount].rankModelData.boltModelPath) );
|
||||
|
||||
/*if ( !cgs.ranksData[rankCount].boltModel ) {
|
||||
Com_Printf( S_COLOR_RED, "Could not load bolt model: %s\n", token );
|
||||
}*/
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "boltShader", 8 ) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Q_strncpyz( cgs.ranksData[rankCount].rankModelData.boltShaderPath,
|
||||
token,
|
||||
sizeof( cgs.ranksData[rankCount].rankModelData.boltShaderPath) );
|
||||
|
||||
|
||||
/*if ( !cgs.ranksData[rankCount].boltShader ) {
|
||||
Com_Printf( S_COLOR_RED, "Could not load bolt skin: %s\n", token );
|
||||
}*/
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "AdmiralRank", 11 ) ) {
|
||||
if ( COM_ParseInt( &textPtr, &i ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cgs.ranksData[rankCount].rankModelData.admiralRank = i;
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "}", 1 ) ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
rankCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(charText);
|
||||
return qtrue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -2035,7 +1721,6 @@ and display multiple
|
|||
crosshairs.
|
||||
=================
|
||||
*/
|
||||
#ifdef QVM
|
||||
qboolean CG_LoadCrosshairs(void) {
|
||||
fileHandle_t f;
|
||||
int file_len;
|
||||
|
@ -2191,180 +1876,3 @@ qboolean CG_LoadCrosshairs(void) {
|
|||
}
|
||||
return qtrue;
|
||||
}
|
||||
#else
|
||||
qboolean CG_LoadCrosshairs(void) {
|
||||
fileHandle_t f;
|
||||
int file_len;
|
||||
char *charText;
|
||||
char *token, *textPtr;
|
||||
char *fileName = "ext_data/crosshairs.dat";
|
||||
int cHairCount = 0;
|
||||
//int i;
|
||||
|
||||
charText = (char *)malloc(sizeof(char)*20000);
|
||||
if(!charText) {
|
||||
CG_Printf("CG_LoadCrosshairs: could not allocate %u byte\n", sizeof(char)*20000);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//load file and get file length
|
||||
file_len = trap_FS_FOpenFile( fileName, &f, FS_READ );
|
||||
|
||||
memset( &charText, 0, sizeof( charText ) );
|
||||
memset( &cgs.crosshairsData, 0, sizeof( &cgs.crosshairsData ) );
|
||||
|
||||
//check to see if we got anything
|
||||
if ( file_len <= 0 ) {
|
||||
Com_Printf( S_COLOR_RED "Could not find file: %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//check to see if we got too much
|
||||
if ( file_len > sizeof( charText) - 1 ) {
|
||||
Com_Printf( S_COLOR_RED "File %s waaaaay too big.\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//read the data into the array
|
||||
trap_FS_Read( charText, file_len, f );
|
||||
|
||||
//EOF?
|
||||
charText[file_len] = 0;
|
||||
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
COM_BeginParseSession();
|
||||
|
||||
textPtr = charText;
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
//wtf? Nothing here??
|
||||
if ( !token[0] ) {
|
||||
Com_Printf( S_COLOR_RED "File: %s terminated rather unexpectantly\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( Q_stricmp( token, "{" ) ) {
|
||||
Com_Printf( S_COLOR_RED "File: %s had no starting {\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//now for the natural hard-core loop parsing bit
|
||||
while ( 1 ) {
|
||||
|
||||
if ( cHairCount >= MAX_CROSSHAIRS ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "{", 1 ) ) {
|
||||
//Make color default to white
|
||||
VectorCopy( colorTable[CT_WHITE], cgs.crosshairsData[cHairCount].color );
|
||||
cgs.crosshairsData[cHairCount].color[3] = 1.0f;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
token = COM_Parse( &textPtr );
|
||||
if (!token[0]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "noDraw", 6 ) ) {
|
||||
cgs.crosshairsData[cHairCount].noDraw = qtrue;
|
||||
break;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "CrosshairColor", 14 ) ) {
|
||||
if ( COM_ParseVec4( &textPtr, cgs.crosshairsData[cHairCount].color ) ) {
|
||||
Com_Printf( S_COLOR_RED "Invalid Color Value in %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
VectorScale( cgs.crosshairsData[cHairCount].color, 1.0f/255.0f, cgs.crosshairsData[cHairCount].color );
|
||||
cgs.crosshairsData[cHairCount].color[3] *= 1.0f/255.0f;
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "BitmapCoords", 12 ) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
Com_Printf( S_COLOR_RED "No bitmap co-ords found in %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( Q_stricmpn( token, "{", 1 ) ) {
|
||||
Com_Printf( S_COLOR_RED "No { found in bitmap co-ords in %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//parse s1 value
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
Com_Printf( S_COLOR_RED "Bit co-ord value ended prematurely: %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
cgs.crosshairsData[cHairCount].s1 = atoi( token );
|
||||
|
||||
//parse t1 value
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
Com_Printf( S_COLOR_RED "Bit co-ord value ended prematurely: %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
cgs.crosshairsData[cHairCount].t1 = atoi( token );
|
||||
|
||||
//parse s2 value
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
Com_Printf( S_COLOR_RED "Bit co-ord value ended prematurely: %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
cgs.crosshairsData[cHairCount].s2 = atoi( token );
|
||||
|
||||
//parse t2 value
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
Com_Printf( S_COLOR_RED "Bit co-ord value ended prematurely: %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
cgs.crosshairsData[cHairCount].t2 = atoi( token );
|
||||
|
||||
//make sure we have } at the end FFS
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
Com_Printf( S_COLOR_RED "Bit co-ord value ended prematurely: %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//This is needed or else we can't tell between this and the main closing }
|
||||
if ( Q_stricmpn( token, "}", 1 ) ) {
|
||||
Com_Printf( S_COLOR_RED "No terminating } in bitmap co-ord: %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
}
|
||||
else if ( !Q_stricmpn ( token, "}", 1 ) ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
cHairCount++;
|
||||
}
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
if (!token[0]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(charText);
|
||||
return qtrue;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef struct {
|
|||
char luaFunc[MAX_QPATH];
|
||||
} cfx_t;
|
||||
|
||||
#ifdef QVM
|
||||
#ifdef Q3_VM
|
||||
#define MAX_CFX_CNT 32
|
||||
|
||||
typedef struct {
|
||||
|
|
407
cgame/cg_main.c
407
cgame/cg_main.c
|
@ -1970,7 +1970,6 @@ void CG_LoadIngameText(void)
|
|||
CG_LoadObjectivesForMap
|
||||
=================
|
||||
*/
|
||||
#ifdef QVM
|
||||
void CG_LoadObjectivesForMap(void)
|
||||
{
|
||||
int len, objnum = 0;
|
||||
|
@ -2036,83 +2035,8 @@ void CG_LoadObjectivesForMap(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void CG_LoadObjectivesForMap(void)
|
||||
{
|
||||
int len, objnum = 0;
|
||||
char *token;
|
||||
char *buf;
|
||||
fileHandle_t f;
|
||||
char fileName[MAX_QPATH];
|
||||
char fullFileName[MAX_QPATH];
|
||||
char *objtext;
|
||||
|
||||
objtext = (char *)malloc(sizeof(char)*MAX_OBJ_TEXT_LENGTH);
|
||||
if(!objtext) {
|
||||
CG_Printf("CG_LoadObjectivesForMap: couldn't allocate %u byte\n", sizeof(char)*MAX_OBJ_TEXT_LENGTH);
|
||||
return;
|
||||
}
|
||||
|
||||
COM_StripExtension( cgs.mapname, fileName );
|
||||
CG_LanguageFilename( fileName, "efo", fullFileName);
|
||||
|
||||
len = trap_FS_FOpenFile( fullFileName, &f, FS_READ );
|
||||
|
||||
if ( len > MAX_OBJ_TEXT_LENGTH )
|
||||
{
|
||||
Com_Printf( S_COLOR_RED "CG_LoadObjectivesForMap : %s file bigger than %d!\n", fileName, MAX_OBJ_TEXT_LENGTH );
|
||||
free(objtext);
|
||||
return;
|
||||
}
|
||||
|
||||
trap_FS_Read( objtext, len, f );
|
||||
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
buf = objtext;
|
||||
//Now parse out each objective
|
||||
while ( 1 )
|
||||
{
|
||||
token = COM_ParseExt( &buf, qtrue );
|
||||
if ( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Normal objective text
|
||||
if ( !Q_strncmp( token, "obj", 3 ) )
|
||||
{
|
||||
objnum = atoi( &token[3] );
|
||||
|
||||
if ( objnum < 1 || objnum == MAX_OBJECTIVES ) {
|
||||
Com_Printf( "Invalid objective number (%d), valid range is 1 to %d\n", objnum, MAX_OBJECTIVES );
|
||||
break;
|
||||
}
|
||||
|
||||
//Now read the objective text into the current objective
|
||||
token = COM_ParseExt( &buf, qfalse );
|
||||
Q_strncpyz( cgs.objectives[objnum-1].text, token, sizeof(cgs.objectives[objnum-1].text) );
|
||||
}
|
||||
|
||||
else if ( !Q_strncmp( token, "abridged_obj", 12 ) )
|
||||
{
|
||||
objnum = atoi( &token[12] );
|
||||
|
||||
if ( objnum < 1 || objnum == MAX_OBJECTIVES )
|
||||
{
|
||||
Com_Printf( "Invalid objective number (%d), valid range is 1 to %d\n", objnum, MAX_OBJECTIVES );
|
||||
break;
|
||||
}
|
||||
|
||||
//Now read the objective text into the current objective
|
||||
token = COM_ParseExt( &buf, qfalse );
|
||||
Q_strncpyz( cgs.objectives[objnum-1].abridgedText, token, sizeof(cgs.objectives[objnum-1].abridgedText) );
|
||||
}
|
||||
}
|
||||
free(objtext);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef QVM
|
||||
qboolean CG_LoadClasses( void )
|
||||
{
|
||||
fileHandle_t f;
|
||||
|
@ -2321,229 +2245,8 @@ qboolean CG_LoadClasses( void )
|
|||
return qfalse;
|
||||
}
|
||||
}
|
||||
#else
|
||||
qboolean CG_LoadClasses( void )
|
||||
{
|
||||
fileHandle_t f;
|
||||
int file_len;
|
||||
char *buffer;
|
||||
char *token, *textPtr;
|
||||
char filePath[MAX_QPATH];
|
||||
int numClasses=0;
|
||||
int i;
|
||||
|
||||
buffer = (char *)malloc(sizeof(char)*32000);
|
||||
if(!buffer) {
|
||||
CG_Printf("CG_LoadClasses: could not allocate %u byte\n", sizeof(char)*32000);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
Com_sprintf( filePath, sizeof( filePath ), "ext_data/classes/%s.classes", cgs.classSet );
|
||||
|
||||
memset( &cgs.classData, 0, sizeof( cg_classData_t ) );
|
||||
|
||||
file_len = trap_FS_FOpenFile( filePath, &f, FS_READ );
|
||||
|
||||
if ( !file_len )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "Couldn't find class file: %s\n", filePath );
|
||||
free(buffer);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( file_len > sizeof( buffer ) )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "File %s was way too big to be loaded.\n", filePath );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
trap_FS_Read( buffer, file_len, f );
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
buffer[file_len] = '\0';
|
||||
|
||||
COM_BeginParseSession();
|
||||
|
||||
textPtr = buffer;
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
if ( !token[0] ) {
|
||||
CG_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 ) ) {
|
||||
CG_Printf( S_COLOR_RED "ERROR: File did not start with a '{' symbol!\n" );
|
||||
free(buffer);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
if ( numClasses >= MAX_CLASSES )
|
||||
break;
|
||||
|
||||
|
||||
if ( !Q_strncmp( token, "{", 1 ) )
|
||||
{
|
||||
while ( 1 )
|
||||
{
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
if (!token[0]) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "formalName", 10 ) )
|
||||
{
|
||||
if ( COM_ParseString( &textPtr, &token ) )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: Invalid class formal name in class index: %i.\n", numClasses );
|
||||
continue;
|
||||
}
|
||||
|
||||
Q_strncpyz( cgs.classData[numClasses].formalName, token, sizeof( cgs.classData[numClasses].formalName ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "radarColor", 5 ) )
|
||||
{
|
||||
vec3_t temp;
|
||||
|
||||
if ( COM_ParseVec3( &textPtr, temp ) )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: Invalid color values in class index: %i.\n", numClasses );
|
||||
continue;
|
||||
}
|
||||
|
||||
for ( i = 0; i < 3; i++ )
|
||||
{
|
||||
cgs.classData[numClasses].radarColor[i] = (int)Com_Clamp( 0, 255, (int)temp[i] );
|
||||
//G_Printf( S_COLOR_RED "g_classData[numClasses].color[%i] = %i\n", i, g_classData[numClasses].color[i] );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "iconColor", 9 ) )
|
||||
{
|
||||
if ( COM_ParseString( &textPtr, &token ) )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: Invalid class icon color in class index: %i.\n", numClasses );
|
||||
continue;
|
||||
}
|
||||
|
||||
//Eh... there are enum values for these,
|
||||
//but they're currently out of scope ;P
|
||||
if ( !Q_stricmp( token, "red" ) )
|
||||
{
|
||||
cgs.classData[numClasses].iconColor = 1; //CLR_RED
|
||||
}
|
||||
else if ( !Q_stricmp( token, "gold" ) )
|
||||
{
|
||||
cgs.classData[numClasses].iconColor = 2; //CLR_GOLD
|
||||
}
|
||||
else if ( !Q_stricmp( token, "teal" ) )
|
||||
{
|
||||
cgs.classData[numClasses].iconColor = 3; //CLR_TEAL
|
||||
}
|
||||
else if ( !Q_stricmp( token, "green" ) )
|
||||
{
|
||||
cgs.classData[numClasses].iconColor = 4; //CLR_GREEN
|
||||
}
|
||||
else
|
||||
{
|
||||
cgs.classData[numClasses].iconColor = 0; //0
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "medical", 7 ) )
|
||||
{
|
||||
if ( COM_ParseInt( &textPtr, (int *)&cgs.classData[numClasses].isMedic ) )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: Class medic check for class %i was invalid.\n", numClasses );
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !Q_stricmpn( token, "isBorg", 6 ) )
|
||||
{
|
||||
if( COM_ParseInt( &textPtr, (int *)&cgs.classData[numClasses].isBorg ) )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: Class borg check for class %i was invalid.\n", numClasses );
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "hasRanks", 8 ) )
|
||||
{
|
||||
if ( COM_ParseInt( &textPtr, (int *)&cgs.classData[numClasses].showRanks ) )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: Class Ranks check for class %i was invalid.\n", numClasses );
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//I'm a n00b lol. I made a class called 'medical' and a parameter called 'medical'.
|
||||
//I have to double check both parms or else it confuses the parser
|
||||
//better check all of them. I'm still getting errors
|
||||
if ( !Q_stricmpn( token, "consoleName", 10 )
|
||||
|| !Q_stricmpn( token, "modelSkin", 9 )
|
||||
|| !Q_stricmpn( token, "message", 7 )
|
||||
|| !Q_stricmpn( token, "admin", 5 )
|
||||
|| !Q_stricmpn( token, "marine", 6 )
|
||||
|| !Q_stricmpn( token, "noShow", 6 )
|
||||
)
|
||||
{
|
||||
SkipRestOfLine(&textPtr);
|
||||
continue;
|
||||
}
|
||||
|
||||
//this one is a pain since it can potentially have multiple lines
|
||||
if ( !Q_stricmpn( token, "weapons", 7 ) )
|
||||
{
|
||||
SkipBracedSection( &textPtr );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "}", 1 ) )
|
||||
{
|
||||
numClasses++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
if (!token[0])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( numClasses > 0 ) {
|
||||
free(buffer);
|
||||
return qtrue;
|
||||
} else
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: No classes were found in the class file!\n" );
|
||||
free(buffer);
|
||||
return qfalse;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef QVM
|
||||
qboolean CG_LoadUsablesStrings( void )
|
||||
{
|
||||
char fileRoute[MAX_QPATH];
|
||||
|
@ -2643,113 +2346,3 @@ qboolean CG_LoadUsablesStrings( void )
|
|||
|
||||
return qtrue;
|
||||
}
|
||||
#else
|
||||
qboolean CG_LoadUsablesStrings( void )
|
||||
{
|
||||
char fileRoute[MAX_QPATH];
|
||||
char mapRoute[MAX_QPATH];
|
||||
char *buffer;
|
||||
int file_len;
|
||||
char *textPtr, *token;
|
||||
fileHandle_t f;
|
||||
int i;
|
||||
int strLen;
|
||||
|
||||
buffer = (char *)malloc(sizeof(char)*20000);
|
||||
if(!buffer) {
|
||||
CG_Printf("CG_LoadUsablesStrings: could not allocate %u byte\n", sizeof(char)*20000);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//setup the file route
|
||||
Com_sprintf( mapRoute, sizeof( mapRoute ), "%s", cgs.mapname );
|
||||
|
||||
strLen = strlen( mapRoute );
|
||||
|
||||
//*sigh* remove the bsp bit
|
||||
if ( strLen > 4 && !Q_stricmp( mapRoute + strLen-4, ".bsp" ) )
|
||||
mapRoute[strLen-4] = '\0';
|
||||
|
||||
//check for language
|
||||
CG_LanguageFilename( mapRoute, "usables", fileRoute );
|
||||
|
||||
file_len = trap_FS_FOpenFile( fileRoute, &f, FS_READ );
|
||||
|
||||
//It's assumed most maps won't have this feature, so just exit 'gracefully'
|
||||
if ( file_len<=1 )
|
||||
{
|
||||
//CG_Printf( S_COLOR_YELLOW "WARNING: No file named %s was found. If the server \n", fileRoute );
|
||||
trap_FS_FCloseFile( f );
|
||||
free(buffer);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//fill the buffer with the file data
|
||||
memset( &buffer, 0, sizeof( buffer ) );
|
||||
trap_FS_Read( buffer, file_len, f );
|
||||
buffer[file_len] = '0';
|
||||
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
if ( !buffer[0] )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: Attempted to load %s, but no data was inside!\n", fileRoute );
|
||||
free(buffer);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
COM_BeginParseSession();
|
||||
textPtr = buffer;
|
||||
|
||||
i = 0; //used for the main arrays indices
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( !token[0] )
|
||||
break;
|
||||
|
||||
if ( !Q_strncmp( token, "UsableDescriptions", 18 ) )
|
||||
{
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( Q_strncmp( token, "{", 1 ) != 0 )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: UsableDescriptions had no opening brace ( { )!\n", fileRoute );
|
||||
continue;
|
||||
}
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
//expected format is 'id' <space> 'string'
|
||||
while ( Q_strncmp( token, "}", 1 ) )
|
||||
{
|
||||
if ( !token[0] )
|
||||
break;
|
||||
|
||||
if ( !Q_strncmp( token, "UsableEntities", 14 ) )
|
||||
{
|
||||
SkipBracedSection( &textPtr );
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
//parse past the ID num
|
||||
token = COM_ParseExt( &textPtr, qfalse );
|
||||
|
||||
//copy the line of text
|
||||
if( token[0] )
|
||||
{
|
||||
Q_strncpyz( cgs.scannableStrings[i], token, sizeof( cgs.scannableStrings[i] ) );
|
||||
i++;
|
||||
}
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
return qtrue;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -307,7 +307,6 @@ This file's presence is not required
|
|||
|
||||
======================
|
||||
*/
|
||||
#ifdef QVM
|
||||
static int CG_ParseAnimationSndFile( const char *filename, int animFileIndex )
|
||||
{
|
||||
char *text_p;
|
||||
|
@ -397,107 +396,6 @@ static int CG_ParseAnimationSndFile( const char *filename, int animFileIndex )
|
|||
|
||||
return i;
|
||||
}
|
||||
#else
|
||||
static int CG_ParseAnimationSndFile( const char *filename, int animFileIndex )
|
||||
{
|
||||
char *text_p;
|
||||
int len;
|
||||
char *token;
|
||||
char *text;
|
||||
fileHandle_t f;
|
||||
int i, j, upper_i, lower_i;
|
||||
animsounds_t *lowerAnimSounds;
|
||||
animsounds_t *upperAnimSounds;
|
||||
animation_t *animations;
|
||||
|
||||
text = (char *)malloc(sizeof(char)*20000);
|
||||
if(!text) {
|
||||
Com_Error(ERR_FATAL, "CG_ParseAnimationSndFile: couldn't alloce cate %u byte\n", sizeof(char)*20000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*if ( knownAnimFileSets[animFileIndex].soundsCached )
|
||||
{//already cached this one
|
||||
return;
|
||||
}*/
|
||||
|
||||
for ( i = 0; i < cg_numSndAnims; i++ ) {
|
||||
if ( !Q_stricmp( filename, cg_animsSndList[i].animSndFileRoute ) ) {
|
||||
free(text);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
//Mark this anim set so that we know we tried to load he sounds, don't care if the load failed
|
||||
//knownAnimFileSets[animFileIndex].soundsCached = qtrue;
|
||||
|
||||
animations = cg_animsList[animFileIndex].animations;
|
||||
lowerAnimSounds = cg_animsSndList[cg_numSndAnims].lowerAnimSounds;
|
||||
upperAnimSounds = cg_animsSndList[cg_numSndAnims].upperAnimSounds;
|
||||
|
||||
//initialize anim sound array
|
||||
for(i = 0; i < MAX_ANIM_SOUNDS; i++)
|
||||
{
|
||||
upperAnimSounds[i].numRandomAnimSounds = 0;
|
||||
lowerAnimSounds[i].numRandomAnimSounds = 0;
|
||||
for(j = 0; j < MAX_RANDOM_ANIMSOUNDS; j++)
|
||||
{
|
||||
upperAnimSounds[i].soundIndex[j] = -1;
|
||||
lowerAnimSounds[i].soundIndex[j] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// load the file
|
||||
len = trap_FS_FOpenFile( filename, &f, FS_READ );
|
||||
if ( len <= 0 )
|
||||
{//no file
|
||||
free(text);
|
||||
return -1;
|
||||
}
|
||||
if ( len >= sizeof( text ) - 1 )
|
||||
{
|
||||
CG_Printf( "File %s too long\n", filename );
|
||||
free(text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
trap_FS_Read( text, len, f );
|
||||
text[len] = 0;
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
// parse the text
|
||||
text_p = text;
|
||||
upper_i =0;
|
||||
lower_i =0;
|
||||
|
||||
// read information for batches of sounds (UPPER or LOWER)
|
||||
while ( 1 )
|
||||
{
|
||||
// Get base frame of sequence
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token || !token[0] )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp(token,"UPPERSOUNDS") ) // A batch of upper sounds
|
||||
{
|
||||
ParseAnimationSndBlock( filename, upperAnimSounds, animations, &upper_i, &text_p );
|
||||
}
|
||||
|
||||
else if ( !Q_stricmp(token,"LOWERSOUNDS") ) // A batch of lower sounds
|
||||
{
|
||||
ParseAnimationSndBlock( filename, lowerAnimSounds, animations, &lower_i, &text_p );
|
||||
}
|
||||
}
|
||||
|
||||
i = cg_numSndAnims;
|
||||
cg_numSndAnims++;
|
||||
|
||||
free(text);
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
@ -525,7 +423,6 @@ A lot more efficient considering how many freakin more animations we introduced
|
|||
*/
|
||||
//
|
||||
//static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) {
|
||||
#ifdef QVM
|
||||
static int CG_ParseAnimationFile( const char* filename/*, clientInfo_t *ci*/ ) {
|
||||
char *text_p, *prev;
|
||||
int len;
|
||||
|
@ -715,208 +612,6 @@ static int CG_ParseAnimationFile( const char* filename/*, clientInfo_t *ci*/ ) {
|
|||
return i;
|
||||
//return qtrue;
|
||||
}
|
||||
#else
|
||||
static int CG_ParseAnimationFile( const char* filename/*, clientInfo_t *ci*/ ) {
|
||||
char *text_p, *prev;
|
||||
int len;
|
||||
int i;
|
||||
char *token;
|
||||
float fps;
|
||||
int skip;
|
||||
char *text;
|
||||
fileHandle_t f;
|
||||
animation_t *animations;
|
||||
|
||||
//CG_Printf( "Anim is %s\n", filename );
|
||||
|
||||
text = (char *)malloc(sizeof(char)*20000);
|
||||
if(!text) {
|
||||
CG_Printf("CG_ParseAnimationFile: couldn't allocate %u bytes\n", sizeof(char)*20000);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( cg_numAnims > 0 ) {
|
||||
for ( i = 0; i <= cg_numAnims; i++ ) {
|
||||
if ( !Q_stricmpn( cg_animsList[i].animFileRoute, filename, (int)strlen( filename ) ) ) { //We found a matching anim set
|
||||
//Com_Printf( S_COLOR_RED "Using index: %i\n", i );
|
||||
free(text);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// load the file
|
||||
len = trap_FS_FOpenFile( filename, &f, FS_READ );
|
||||
if ( len <= 0 ) {
|
||||
CG_Printf( S_COLOR_RED "File %s not found\n", filename );
|
||||
free(text);
|
||||
return -1; //qfalse
|
||||
}
|
||||
if ( len >= sizeof( text ) - 1 ) {
|
||||
CG_Printf( S_COLOR_RED "File %s too long\n", filename );
|
||||
free(text);
|
||||
return -1; //qfalse
|
||||
}
|
||||
trap_FS_Read( text, len, f );
|
||||
text[len] = 0;
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
|
||||
//animations = ci->animations;
|
||||
animations = cg_animsList[cg_numAnims].animations;
|
||||
|
||||
//copy the file name to the gloabl anims array. It doesn't matter
|
||||
//if it returns false, since the same cell will be flushed on the next call then.
|
||||
memset( cg_animsList[cg_numAnims].animFileRoute, 0, MAX_QPATH );
|
||||
Q_strncpyz( cg_animsList[cg_numAnims].animFileRoute, filename, MAX_QPATH );
|
||||
|
||||
//flush the anims
|
||||
memset( animations, 0, sizeof( animations ) );
|
||||
|
||||
// parse the text
|
||||
text_p = text;
|
||||
skip = 0; // quite the compiler warning
|
||||
|
||||
/*
|
||||
ci->footsteps = FOOTSTEP_NORMAL;
|
||||
VectorClear( ci->headOffset );
|
||||
ci->gender = GENDER_MALE;
|
||||
|
||||
Q_strncpyz(ci->soundPath, ci->modelName, sizeof(ci->soundPath));*/
|
||||
|
||||
// read optional parameters
|
||||
while ( 1 ) {
|
||||
prev = text_p; // so we can unget
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
/*if ( !Q_stricmp( token, "footsteps" ) ) {
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
if ( !Q_stricmp( token, "default" ) || !Q_stricmp( token, "normal" ) ) {
|
||||
ci->footsteps = FOOTSTEP_NORMAL;
|
||||
} else if ( !Q_stricmp( token, "borg" ) ) {
|
||||
ci->footsteps = FOOTSTEP_BORG;
|
||||
} else if ( !Q_stricmp( token, "reaver" ) ) {
|
||||
ci->footsteps = FOOTSTEP_REAVER;
|
||||
} else if ( !Q_stricmp( token, "species" ) ) {
|
||||
ci->footsteps = FOOTSTEP_SPECIES;
|
||||
} else if ( !Q_stricmp( token, "warbot" ) ) {
|
||||
ci->footsteps = FOOTSTEP_WARBOT;
|
||||
} else if ( !Q_stricmp( token, "boot" ) ) {
|
||||
ci->footsteps = FOOTSTEP_BOOT;
|
||||
} else if ( !Q_stricmp( token, "flesh" ) ) { // Old Q3 defaults, for compatibility. -PJL
|
||||
ci->footsteps = FOOTSTEP_SPECIES;
|
||||
} else if ( !Q_stricmp( token, "mech" ) ) { // Ditto
|
||||
ci->footsteps = FOOTSTEP_BORG;
|
||||
} else if ( !Q_stricmp( token, "energy" ) ) { // Ditto
|
||||
ci->footsteps = FOOTSTEP_BORG;
|
||||
} else {
|
||||
CG_Printf( "Bad footsteps parm in %s: %s\n", filename, token );
|
||||
}
|
||||
continue;
|
||||
} else if ( !Q_stricmp( token, "headoffset" ) ) {
|
||||
for ( i = 0 ; i < 3 ; i++ ) {
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
ci->headOffset[i] = atof( token );
|
||||
}
|
||||
continue;
|
||||
} else if ( !Q_stricmp( token, "sex" ) ) {
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
if ( token[0] == 'f' || token[0] == 'F' ) {
|
||||
ci->gender = GENDER_FEMALE;
|
||||
} else if ( token[0] == 'n' || token[0] == 'N' ) {
|
||||
ci->gender = GENDER_NEUTER;
|
||||
} else {
|
||||
ci->gender = GENDER_MALE;
|
||||
}
|
||||
continue;
|
||||
} else if ( !Q_stricmp( token, "soundpath" ) ) {
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
Q_strncpyz(ci->soundPath,token,sizeof (ci->soundPath) );
|
||||
continue;
|
||||
} */
|
||||
|
||||
// if it is a number, start parsing animations
|
||||
if ( token[0] >= '0' && token[0] <= '9' ) {
|
||||
text_p = prev; // unget the token
|
||||
break;
|
||||
}
|
||||
Com_Printf( "unknown token '%s' is %s\n", token, filename );
|
||||
}
|
||||
|
||||
// read information for each frame
|
||||
for ( i = 0 ; i < MAX_ANIMATIONS ; i++ ) {
|
||||
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
animations[i].firstFrame = atoi( token );
|
||||
// leg only frames are adjusted to not count the upper body only frames
|
||||
if ( i == LEGS_KNEEL1 ) { //LEGS_WALKCR
|
||||
skip = animations[LEGS_KNEEL1].firstFrame - animations[TORSO_ACTIVATEMEDKIT1].firstFrame; //TORSO_GESTURE
|
||||
}
|
||||
if ( i >= LEGS_KNEEL1 ) {
|
||||
animations[i].firstFrame -= skip;
|
||||
}
|
||||
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
animations[i].numFrames = atoi( token );
|
||||
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
animations[i].loopFrames = atoi( token );
|
||||
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
fps = atof( token );
|
||||
if ( fps == 0 ) {
|
||||
fps = 1;
|
||||
}
|
||||
animations[i].frameLerp = 1000 / fps;
|
||||
animations[i].initialLerp = 1000 / fps;
|
||||
}
|
||||
|
||||
if ( i != MAX_ANIMATIONS ) {
|
||||
CG_Printf( S_COLOR_RED "Error parsing animation file: %s", filename );
|
||||
//return qfalse;
|
||||
free(text);
|
||||
return -1;
|
||||
}
|
||||
|
||||
//CG_Printf( S_COLOR_RED "Cached File: %s\n", cgs.animsList[cgs.numAnims].animFileRoute );
|
||||
//return ++cg_numAnims;
|
||||
|
||||
i = cg_numAnims;
|
||||
if ( cg_numAnims < MAX_CLIENTS ) {
|
||||
cg_numAnims++; //offset for the next time :)
|
||||
}
|
||||
|
||||
free(text);
|
||||
return i;
|
||||
//return qtrue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
======================
|
||||
|
@ -1252,7 +947,6 @@ needed to put together
|
|||
a character model.
|
||||
======================
|
||||
*/
|
||||
#ifdef QVM
|
||||
static qboolean CG_ParseModelDataFile( clientInfo_t *ci, const char *charName,
|
||||
const char *modelName, const char *skinName ) {
|
||||
fileHandle_t file;
|
||||
|
@ -1684,458 +1378,6 @@ static qboolean CG_ParseModelDataFile( clientInfo_t *ci, const char *charName,
|
|||
//model! OWNED!
|
||||
return qtrue;
|
||||
}
|
||||
#else
|
||||
static qboolean CG_ParseModelDataFile( clientInfo_t *ci, const char *charName,
|
||||
const char *modelName, const char *skinName ) {
|
||||
fileHandle_t file;
|
||||
int file_len;
|
||||
char *charText;
|
||||
char *textPtr, *prevValue;
|
||||
char fileName[MAX_QPATH];
|
||||
//char animPath[MAX_QPATH];
|
||||
int i, n;
|
||||
char *token;
|
||||
char legsFileRoute[MAX_QPATH];
|
||||
char animSndFileRoute[MAX_QPATH];
|
||||
qboolean skinSetFound=qfalse;
|
||||
//size_t strLen;
|
||||
|
||||
charText = (char *)malloc(sizeof(char)*20000);
|
||||
if(!charText) {
|
||||
CG_Printf("CG_ParseModelDataFile: couldn't allocate %u byte\n", sizeof(char)*20000);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//create the file route
|
||||
Com_sprintf( fileName, sizeof(fileName), "models/players_rpgx/%s/%s.model", charName, modelName);
|
||||
|
||||
//Okay... gotta get the hang of ANSI C text parsing >.<
|
||||
//first... I guess load the file
|
||||
file_len = trap_FS_FOpenFile( fileName, &file, FS_READ );
|
||||
//Error handle
|
||||
//if length was 0, ie file not found or was empty
|
||||
if (file_len <= 0 ) {
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
//Another error... if text is WAY bigger than our available buffer O_O
|
||||
if ( file_len >= sizeof( charText ) - 1 ) {
|
||||
Com_Printf( S_COLOR_RED "Model Data File %s too long... WAY too long\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//initialize the buffer
|
||||
memset( charText, 0, sizeof( charText ) );
|
||||
|
||||
//read data into char array
|
||||
//i guess we use a char array so we can actually specify size/width.
|
||||
trap_FS_Read( charText, file_len, file );
|
||||
//I guess this is needed to mark the EOF.
|
||||
charText[file_len] = 0;
|
||||
//Free memory. Close Files
|
||||
trap_FS_FCloseFile( file );
|
||||
|
||||
//default values if needed
|
||||
CG_InitModelData( ci );
|
||||
|
||||
//Used to just clear any previous parse temp data
|
||||
COM_BeginParseSession();
|
||||
|
||||
//transfer our data from a char array to a char ptr.
|
||||
//needed for the parsing func methinks
|
||||
textPtr = charText;
|
||||
|
||||
token = COM_Parse( &textPtr ); //COM_Parse seems to work by splitting up each line of text by the spaces,
|
||||
//and then removes that chunk from the original
|
||||
//Okay, we should have the beginning variable first... which should be a '{'
|
||||
|
||||
//from the looks of this, I think we have to do this after
|
||||
//every parse call. O_O
|
||||
if ( !token[0] ) {
|
||||
Com_Printf( S_COLOR_RED "No data found in model data buffer!\n");
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( Q_stricmp(token, "{" ) ) {
|
||||
Com_Printf(S_COLOR_RED "Missing { in %s\n", fileName);
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
while ( 1 ) {
|
||||
prevValue = textPtr; //set a backup
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
if (!token[0] || !token ) { //we've hit the end of the file. w00t! exit!
|
||||
break;
|
||||
}
|
||||
|
||||
//if we randomly find a brace in here (ie a sub-struct that may have no header)
|
||||
//just skip it. :P
|
||||
if ( !Q_stricmpn( token, "{", 1 ) ) {
|
||||
SkipBracedSection ( &textPtr );
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "animsConfig", 11 ) ) {
|
||||
if( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ci->animIndex = CG_ParseAnimationFile( token );
|
||||
|
||||
//no valid anim file found. Don't give up hope though.
|
||||
//We have a backup resort at the end if need be. :)
|
||||
if ( ci->animIndex == -1 ) {
|
||||
Com_Printf( S_COLOR_RED "WARNING: Was unable to load file %s.\n", token );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//anim sounds config file
|
||||
else if ( !Q_stricmpn( token, "animSoundsConfig", 16 ) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//check to see if we have a valid animlist we can sync these
|
||||
//sounds to. if not, we'll put the file route asside, and
|
||||
//try again at the end.
|
||||
if ( ci->animIndex >= 0 ) {
|
||||
ci->animSndIndex = CG_ParseAnimationSndFile( token, ci->animIndex );
|
||||
|
||||
if ( ci->animSndIndex == -1 ) {
|
||||
Com_Printf( S_COLOR_RED "WARNING: Unable to load file: %s\n", token );
|
||||
}
|
||||
}
|
||||
else {
|
||||
Q_strncpyz( animSndFileRoute, token, sizeof( animSndFileRoute ) );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//character's legs model
|
||||
else if ( !Q_stricmpn( token, "legsModel", 9 ) ) {
|
||||
|
||||
if( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ci->legsModel = trap_R_RegisterModel( token );
|
||||
if (!ci->legsModel) {
|
||||
Com_Printf( S_COLOR_RED "ERROR: Unable to load legs model: %s\n", token);
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//if loaded no anims yet, copy the legs route to this variable,
|
||||
//and we'll try again at the end of the function
|
||||
//if ( ci->animIndex == -1 ) {
|
||||
Q_strncpyz( legsFileRoute, token, sizeof( legsFileRoute ) );
|
||||
//} Actually. just copy it regardless. Just in case
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//character's torso model
|
||||
else if ( !Q_stricmpn( token, "torsoModel", 10 ) ) {
|
||||
if( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
ci->torsoModel = trap_R_RegisterModel( token );
|
||||
//Com_Printf("Torsomodel passed as %s, %i\n", token, (int)ci->torsoModel);
|
||||
|
||||
if (!ci->torsoModel) {
|
||||
Com_Printf( S_COLOR_RED "ERROR: Unable to load torso model: %s\n", token);
|
||||
return qfalse;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//character's headmodel
|
||||
else if ( !Q_stricmpn( token, "headModel", 9 ) ) {
|
||||
|
||||
//return true = no extra text found on this line - bad! O_O!
|
||||
if( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ci->headModel = trap_R_RegisterModel( token );
|
||||
if (!ci->headModel) {
|
||||
Com_Printf( S_COLOR_RED "ERROR: Unable to load head model: %s\n", token);
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//holster model (basically just a null md3 with 2 tags: one for phaser, other for tric)
|
||||
else if ( !Q_stricmpn( token, "holsterModel", 12 ) ) {
|
||||
|
||||
if( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ci->holsterModel = trap_R_RegisterModel( token );
|
||||
|
||||
//You'd hope like hell this will never happen. :P
|
||||
if (!ci->holsterModel) {
|
||||
Com_Printf( S_COLOR_RED "ERROR: Unable to load holster model: %s\n", token);
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Custom bolton models... oi O_o
|
||||
else if ( !Q_stricmpn( token, "boltonModels", 12 ) ) {
|
||||
//needed coz '{' could also be on next line
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( !token[0] ) { //if that was it
|
||||
break;
|
||||
} else { //else, if next character is '{'
|
||||
if ( !Q_stricmpn( token, "{", 1 ) ) {
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
//loop till we hit the end of the brackets
|
||||
i = 0;
|
||||
|
||||
while ( Q_stricmp( token, "}" ) ) {
|
||||
if ( !Q_stricmpn( token, "BOLTON_", 7 ) ) {
|
||||
|
||||
ci->boltonTags[i].modelBase = GetIDForString( BoltonTable, token );
|
||||
|
||||
if( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Q_stricmpn( token, "tag_", 4 ) ) {
|
||||
Q_strncpyz(ci->boltonTags[i].tagName, token, sizeof (ci->boltonTags[i].tagName) );
|
||||
|
||||
if( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
ci->boltonTags[i].tagModel = trap_R_RegisterModel( token );
|
||||
|
||||
if (!ci->boltonTags[i].tagModel) {
|
||||
Com_Printf( S_COLOR_RED "WARNING: Unable to load bolton model: %s\n", token);
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
if (i > MAX_BOLTONS -1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Com_Printf("Index: %i, Name: %s, Handle: %i\n", ci->boltonTags[ci->numBoltOns].modelBase, ci->boltonTags[ci->numBoltOns].tagName, ci->boltonTags[ci->numBoltOns].tagModel );
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//whether char is allowed to wear ranks
|
||||
else if ( !Q_stricmpn( token, "hasRanks", 8 ) ) {
|
||||
if (COM_ParseInt(&textPtr, &n ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( n > 0 )
|
||||
ci->hasRanks = qtrue;
|
||||
else
|
||||
ci->hasRanks = qfalse;
|
||||
continue;
|
||||
}
|
||||
|
||||
//player footsteps.
|
||||
//FIXME: Is it possible to make these things dynamic, so we can
|
||||
//put in our own footstep sounds?
|
||||
/*else if ( !Q_stricmp( token, "footsteps" ) ) {
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
if ( !Q_stricmp( token, "default" ) || !Q_stricmp( token, "normal" ) ) {
|
||||
ci->footsteps = FOOTSTEP_NORMAL;
|
||||
} else if ( !Q_stricmp( token, "borg" ) ) {
|
||||
ci->footsteps = FOOTSTEP_BORG;
|
||||
} else if ( !Q_stricmp( token, "reaver" ) ) {
|
||||
ci->footsteps = FOOTSTEP_REAVER;
|
||||
} else if ( !Q_stricmp( token, "species" ) ) {
|
||||
ci->footsteps = FOOTSTEP_SPECIES;
|
||||
} else if ( !Q_stricmp( token, "warbot" ) ) {
|
||||
ci->footsteps = FOOTSTEP_WARBOT;
|
||||
} else if ( !Q_stricmp( token, "boot" ) ) {
|
||||
ci->footsteps = FOOTSTEP_BOOT;
|
||||
} else if ( !Q_stricmp( token, "flesh" ) ) { // Old Q3 defaults, for compatibility. -PJL
|
||||
ci->footsteps = FOOTSTEP_SPECIES;
|
||||
} else if ( !Q_stricmp( token, "mech" ) ) { // Ditto
|
||||
ci->footsteps = FOOTSTEP_BORG;
|
||||
} else if ( !Q_stricmp( token, "energy" ) ) { // Ditto
|
||||
ci->footsteps = FOOTSTEP_BORG;
|
||||
} else {
|
||||
CG_Printf( "Bad footsteps parm in %s: %s\n", fileName, token );
|
||||
}
|
||||
continue;
|
||||
} */
|
||||
|
||||
//offset for player head in the scoreboard or whatever
|
||||
else if ( !Q_stricmp( token, "headoffset" ) ) {
|
||||
for ( i = 0 ; i < 3 ; i++ ) {
|
||||
token = COM_Parse( &textPtr );
|
||||
if ( !token ) {
|
||||
break;
|
||||
}
|
||||
ci->headOffset[i] = atof( token );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//what gender the character is
|
||||
else if ( !Q_stricmpn( token, "sex", 3 ) ) {
|
||||
if (COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( token[0] == 'f' || token[0] == 'F' ) {
|
||||
ci->gender = GENDER_FEMALE;
|
||||
} else if ( token[0] == 'n' || token[0] == 'N' ) {
|
||||
ci->gender = GENDER_NEUTER;
|
||||
} else {
|
||||
ci->gender = GENDER_MALE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//file path to model sound files
|
||||
else if ( !Q_stricmpn( token, "soundPath", 9 ) ) {
|
||||
if (COM_ParseString( &textPtr, &token ) ){
|
||||
continue;
|
||||
}
|
||||
|
||||
Q_strncpyz( ci->soundPath, token, sizeof(ci->soundPath) );
|
||||
continue;
|
||||
}
|
||||
|
||||
//TiM - The skinset is defined
|
||||
else if ( !Q_stricmpn( token, "skinSet", 7 ) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( CG_ParseSkinSetDataFile( ci, token, charName, skinName ) )
|
||||
{
|
||||
skinSetFound = qtrue;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//if any of the models or skins were left blank, then output false. Coz we need them. :P
|
||||
if (!ci->headModel || !ci->torsoModel || !ci->legsModel ) {
|
||||
Com_Printf( S_COLOR_RED "One or more necessary model files weren't loaded from %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( !skinSetFound )
|
||||
{
|
||||
if ( !CG_ParseSkinSetDataFile( ci, va("%s_*", modelName, skinName ), charName, skinName ) )
|
||||
{
|
||||
CG_Printf( S_COLOR_RED "ERROR: Tried loading default skin set, however it failed.\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!ci->headSkin || !ci->torsoSkin || !ci->legsSkin ) {
|
||||
|
||||
Com_Printf( S_COLOR_RED "One or more necessary skin files weren't loaded from %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//if modder specified no animations file route, or they did, and it sucked (ie -1 ),
|
||||
//Then try looking for one in the same directory as the lower.mdr file
|
||||
|
||||
//k... the goal of this is to take a string like
|
||||
//models/players_rpgx/crewman_male/lower.mdr
|
||||
//and turn it into
|
||||
//models/players_rpgx/crewman_male/animation.cfg
|
||||
|
||||
if ( ci->animIndex == -1 && strlen( legsFileRoute ) > 0 ) {
|
||||
//get length of file route
|
||||
i = (int)strlen(legsFileRoute);
|
||||
|
||||
while( 1 ) {
|
||||
//if we looped all the way to the end.... ie BAD
|
||||
if (i <= 0) {
|
||||
//we obviously have no animation directory :(
|
||||
Com_Printf(S_COLOR_RED "ERROR: Was unable to calculate location of animation.cfg for %s\n", fileName);
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
//if this is the first '/' we come across from going from the end to the start
|
||||
if (legsFileRoute[i] == '/' ) {
|
||||
//copy i bytes of data from token to animpath (effectively giving us the route, with no file)
|
||||
Q_strncpyz(legsFileRoute, legsFileRoute, (i = i + 2 )); //+2 for the null char these things auto assign at the end... i think
|
||||
break; //won't work without it anyway :P
|
||||
}
|
||||
i--;
|
||||
}
|
||||
|
||||
//add animation.cfg to the end of the string
|
||||
Q_strcat(legsFileRoute, sizeof(legsFileRoute), "animation.cfg");
|
||||
|
||||
//Com_Printf( S_COLOR_RED "WARNING: Failed to load animation file specified in model config, attempting to load %s\n", legsFileRoute );
|
||||
|
||||
//parse it ^_^
|
||||
ci->animIndex = CG_ParseAnimationFile( legsFileRoute );
|
||||
|
||||
if ( ci->animIndex < 0 ) {
|
||||
Com_Printf( "Tried loading anim data from location %s, however nothing was valid.\n", legsFileRoute );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( !legsFileRoute[0] ) {
|
||||
Com_Printf( S_COLOR_RED "Couldn't load/locate any player animation data for player: %s.\n", charName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
}
|
||||
|
||||
//We'll check again if we can load a sound config file after everything else
|
||||
if ( ci->animSndIndex == -1 && animSndFileRoute[0] )
|
||||
{
|
||||
ci->animSndIndex = CG_ParseAnimationSndFile( animSndFileRoute, ci->animIndex );
|
||||
|
||||
if ( ci->animSndIndex == -1 ) {
|
||||
Com_Printf( S_COLOR_RED "ERROR: Unable to load sound config file: %s.\n", animSndFileRoute );
|
||||
}
|
||||
}
|
||||
|
||||
ci->animsFlushed = qfalse;
|
||||
|
||||
//TiM: Cheap hack - let us specifically check for hazard models
|
||||
if ( !Q_stricmp( modelName, "hazard" ) )
|
||||
ci->isHazardModel = qtrue;
|
||||
|
||||
//holy fudgenuggets. after all that checking, we actually made it to the end and have a valid freaking
|
||||
//model! OWNED!
|
||||
free(charText);
|
||||
return qtrue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
|
190
game/bg_misc.c
190
game/bg_misc.c
|
@ -1557,7 +1557,6 @@ void BG_LoadItemNames(void)
|
|||
* Read a configuration file to get the sex
|
||||
* models/players_rpgx/munro/animation.cfg
|
||||
*/
|
||||
#ifdef Q3_VM
|
||||
static gender_t G_ParseAnimationFileSex( const char *filename) {
|
||||
char *text_p;
|
||||
int len;
|
||||
|
@ -1610,72 +1609,6 @@ static gender_t G_ParseAnimationFileSex( const char *filename) {
|
|||
}
|
||||
return GENDER_MALE;
|
||||
}
|
||||
#else
|
||||
static gender_t G_ParseAnimationFileSex( const char *filename) {
|
||||
char *text_p;
|
||||
int len;
|
||||
char *token;
|
||||
char *text;
|
||||
fileHandle_t f;
|
||||
char animfile[MAX_QPATH];
|
||||
|
||||
/* strcpy(animfile, filename); */
|
||||
Q_strncpyz(animfile, filename, sizeof(animfile));
|
||||
len = strlen(animfile);
|
||||
strcpy(&animfile[len-strlen("groups.cfg")], "animation.cfg");
|
||||
|
||||
/* load the file */
|
||||
len = trap_FS_FOpenFile( animfile, &f, FS_READ );
|
||||
if ( len <= 0 ) {
|
||||
return GENDER_NEUTER;
|
||||
}
|
||||
|
||||
text = (char *)malloc(20000 * sizeof(char));
|
||||
if(!text) {
|
||||
trap_FS_FCloseFile(f);
|
||||
Com_Printf( "Was unable to allocate %i bytes.\n", 20000 * sizeof(char) );
|
||||
return GENDER_NEUTER;
|
||||
}
|
||||
|
||||
if ( len >= 20000 - 1 ) {
|
||||
Com_Printf( "File %s too long\n", animfile );
|
||||
trap_FS_FCloseFile( f );
|
||||
return GENDER_NEUTER;
|
||||
}
|
||||
trap_FS_Read( text, len, f );
|
||||
text[len] = 0;
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
/* parse the text */
|
||||
text_p = text;
|
||||
|
||||
/* read optional parameters */
|
||||
while ( 1 ) {
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
if ( !Q_stricmp( token, "sex" ) ) {
|
||||
token = COM_Parse( &text_p );
|
||||
if ( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
if ( token[0] == 'f' || token[0] == 'F' ) {
|
||||
free(text);
|
||||
return GENDER_FEMALE;
|
||||
} else if ( token[0] == 'n' || token[0] == 'N' ) {
|
||||
free(text);
|
||||
return GENDER_NEUTER;
|
||||
} else {
|
||||
free(text);
|
||||
return GENDER_MALE;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(text);
|
||||
return GENDER_MALE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Registers an item.
|
||||
|
@ -1767,7 +1700,6 @@ char* BG_RegisterRace( const char *name ) {
|
|||
/**
|
||||
* Parses the rank names.
|
||||
*/
|
||||
#ifdef Q3_VM
|
||||
qboolean BG_ParseRankNames( char* fileName, rankNames_t rankNames[] ) {
|
||||
fileHandle_t f;
|
||||
int file_len;
|
||||
|
@ -1877,128 +1809,6 @@ qboolean BG_ParseRankNames( char* fileName, rankNames_t rankNames[] ) {
|
|||
}
|
||||
return qtrue;
|
||||
}
|
||||
#else
|
||||
qboolean BG_ParseRankNames( char* fileName, rankNames_t rankNames[] ) {
|
||||
fileHandle_t f;
|
||||
int file_len;
|
||||
char *charText;
|
||||
char* textPtr;
|
||||
char* token;
|
||||
int i = 0;
|
||||
|
||||
file_len = trap_FS_FOpenFile( fileName, &f, FS_READ );
|
||||
|
||||
if ( file_len<= 0 ) {
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
charText = (char *)malloc(20000 * sizeof(char));
|
||||
if(!charText) {
|
||||
Com_Printf( S_COLOR_RED "Was unable to allocate %i bytes.\n", 20000 * sizeof(char) );
|
||||
trap_FS_FCloseFile(f);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( file_len >= ( 20000 - 1) ) {
|
||||
Com_Printf( S_COLOR_RED "File length of %s is too long.\n", fileName );
|
||||
trap_FS_FCloseFile(f);
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
memset( rankNames, 0, sizeof( rankNames ) );
|
||||
|
||||
trap_FS_Read( charText, file_len, f );
|
||||
|
||||
charText[file_len] = 0;
|
||||
|
||||
trap_FS_FCloseFile( f );
|
||||
|
||||
COM_BeginParseSession();
|
||||
|
||||
textPtr = charText;
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
|
||||
if ( !token[0] ) {
|
||||
Com_Printf( S_COLOR_RED "No data found in buffer: %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
if ( Q_stricmpn( token, "{", 1 ) ) {
|
||||
Com_Printf( S_COLOR_RED "No beginning { found in %s\n", fileName );
|
||||
free(charText);
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
/* Parse out the default cell. Default has no names anyway,
|
||||
but in case a n00bie modder put names in anyway. */
|
||||
SkipBracedSection( &textPtr );
|
||||
|
||||
while( 1 ) {
|
||||
//lastPtr = textPtr;
|
||||
token = COM_Parse( &textPtr );
|
||||
if( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i >= MAX_RANKS ) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we hit an open brace (ie, assuming we hit the start of a new rank cell) */
|
||||
if ( !Q_stricmpn( token, "{", 1 ) ) {
|
||||
while ( 1 ) {
|
||||
token = COM_Parse( &textPtr );
|
||||
if( !token[0] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* We hit a MenuTexture entry, since this uses { symbols, we'll skip these to stop errors. */
|
||||
if ( !Q_stricmpn( token, "MenuTexture", 11 ) ) {
|
||||
SkipRestOfLine( &textPtr );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmpn( token, "ConsoleName", 11) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Q_strncpyz( rankNames[i].consoleName, token, sizeof( rankNames[i].consoleName ) );
|
||||
|
||||
continue;
|
||||
}
|
||||
else if ( !Q_stricmpn( token, "FormalName", 10) ) {
|
||||
if ( COM_ParseString( &textPtr, &token ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Q_strncpyz( rankNames[i].formalName, token, sizeof( rankNames[i].formalName ) );
|
||||
|
||||
continue;
|
||||
}
|
||||
/* We hit the end of the cell. */
|
||||
else if ( !Q_stricmpn( token, "}", 1 ) ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Error check. If we didn't get both a formal and console name, pwn the caller. ;P */
|
||||
if ( !rankNames[i].consoleName[0] || !rankNames[i].formalName[0] ) {
|
||||
Com_Printf( S_COLOR_RED "One or more rank names were not found in rank#: %i\n", i );
|
||||
return qfalse;
|
||||
}
|
||||
else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(charText);
|
||||
return qtrue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
===========
|
||||
|
|
|
@ -3633,6 +3633,9 @@ void spawn_trigger_stasis_door( gentity_t *ent ) {
|
|||
|
||||
if (ent->wait == -1) return;
|
||||
|
||||
// prevent me from thinking again
|
||||
ent->nextthink = -1;
|
||||
|
||||
// find the bounds of everything on the team
|
||||
VectorCopy (ent->r.absmin, mins);
|
||||
VectorCopy (ent->r.absmax, maxs);
|
||||
|
@ -3659,7 +3662,6 @@ void spawn_trigger_stasis_door( gentity_t *ent ) {
|
|||
other->parent = ent;
|
||||
other->r.contents = CONTENTS_TRIGGER;
|
||||
other->touch = touch_stasis_door;
|
||||
ent->nextthink = -1;
|
||||
|
||||
trap_LinkEntity (other);
|
||||
G_Printf( "^1Spawnage complete\n", 0 );
|
||||
|
@ -3687,7 +3689,7 @@ void SP_func_stasis_door( gentity_t *ent )
|
|||
|
||||
// Stasis doors have a model2, so precache me now
|
||||
G_ModelIndex( "models/mapobjects/stasis/door2.md3" );
|
||||
ent->model2 = "models/mapobjects/stasis/door.md3";
|
||||
ent->model2 = G_NewString("models/mapobjects/stasis/door.md3");
|
||||
InitMover( ent );
|
||||
|
||||
// Now that we have the model precached, clear this out so it doesn't draw the model
|
||||
|
@ -3704,6 +3706,9 @@ void SP_func_stasis_door( gentity_t *ent )
|
|||
|
||||
// Auto create a door trigger so the designers don't have to
|
||||
ent->think = spawn_trigger_stasis_door;
|
||||
|
||||
InitMover(ent);
|
||||
|
||||
ent->nextthink = level.time + 50 * 5; // give the target a chance to spawn in
|
||||
//ent->trigger_formation = qfalse;
|
||||
|
||||
|
|
|
@ -905,7 +905,7 @@ char *Q_CleanStr( char *string ) {
|
|||
return string;
|
||||
}
|
||||
|
||||
#ifdef QVM
|
||||
#ifdef Q3_VM
|
||||
void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
|
||||
int len;
|
||||
va_list argptr;
|
||||
|
@ -928,21 +928,23 @@ void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
|
|||
void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
|
||||
int len;
|
||||
va_list argptr;
|
||||
char *bigbuffer = NULL;
|
||||
char *bigbuffer;
|
||||
|
||||
bigbuffer = (char *)malloc(sizeof(char)*64000);
|
||||
bigbuffer = (char *)malloc(sizeof(char)*(size+1));
|
||||
if(!bigbuffer) {
|
||||
Com_Printf("Com_sprintf: could not allocate %u bytes for BigBuffer\n", sizeof(char)*64000);
|
||||
Com_Printf("Com_sprintf: could not allocate %u bytes for BigBuffer\n", sizeof(char)*(size+1));
|
||||
return;
|
||||
}
|
||||
memset(bigbuffer, 0, sizeof(bigbuffer));
|
||||
|
||||
sprintf(bigbuffer, " ");
|
||||
|
||||
va_start (argptr,fmt);
|
||||
len = vsprintf (bigbuffer,fmt,argptr);
|
||||
va_end (argptr);
|
||||
if ( len >= sizeof( bigbuffer ) ) {
|
||||
if ( len >= size + 1 ) {
|
||||
free(bigbuffer);
|
||||
Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" );
|
||||
return;
|
||||
}
|
||||
if (len >= size) {
|
||||
Com_Printf ("Com_sprintf: overflow of %i in %i\n", len, size);
|
||||
|
@ -1150,7 +1152,7 @@ void Info_RemoveKey( char *s, const char *key ) {
|
|||
Info_RemoveKey_Big
|
||||
===================
|
||||
*/
|
||||
#ifdef QVM
|
||||
void Info_RemoveKey_Big( char *s, const char *key ) {
|
||||
char *start;
|
||||
char pkey[BIG_INFO_KEY];
|
||||
char value[BIG_INFO_VALUE];
|
||||
|
@ -1199,82 +1201,6 @@ Info_RemoveKey_Big
|
|||
}
|
||||
|
||||
}
|
||||
#else
|
||||
void Info_RemoveKey_Big( char *s, const char *key ) {
|
||||
char *start;
|
||||
char *pkey;
|
||||
char *value;
|
||||
char *o;
|
||||
|
||||
if ( strlen( s ) >= BIG_INFO_STRING ) {
|
||||
Com_Error( ERR_DROP, "Info_RemoveKey_Big: oversize infostring" );
|
||||
}
|
||||
|
||||
pkey = (char *)malloc(sizeof(char)*BIG_INFO_KEY);
|
||||
if(!pkey) {
|
||||
Com_Printf("Info_RemoveKey_Big: could not allocate %u byte\n", sizeof(char)*BIG_INFO_KEY);
|
||||
return;
|
||||
}
|
||||
value = (char *)malloc(sizeof(char)*BIG_INFO_VALUE);
|
||||
if(!value) {
|
||||
Com_Printf("Info_RemoveKey_Big: could not allocate %u byte\n", sizeof(char)*BIG_INFO_VALUE);
|
||||
free(value);
|
||||
return;
|
||||
}
|
||||
if (strchr (key, '\\')) {
|
||||
free(pkey);
|
||||
free(value);
|
||||
return;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
start = s;
|
||||
if (*s == '\\')
|
||||
s++;
|
||||
o = pkey;
|
||||
while (*s != '\\')
|
||||
{
|
||||
if (!*s) {
|
||||
free(value);
|
||||
free(pkey);
|
||||
return;
|
||||
}
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
s++;
|
||||
|
||||
o = value;
|
||||
while (*s != '\\' && *s)
|
||||
{
|
||||
if (!*s) {
|
||||
free(pkey);
|
||||
free(value);
|
||||
return;
|
||||
}
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
|
||||
if (!strcmp (key, pkey) )
|
||||
{
|
||||
strcpy (start, s); /* remove this part */
|
||||
free(value);
|
||||
free(pkey);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!*s) {
|
||||
free(pkey);
|
||||
free(value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
free(value);
|
||||
free(pkey);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
BIN
stefgame.suo
BIN
stefgame.suo
Binary file not shown.
Loading…
Reference in a new issue