Exemple #1
0
qboolean BG_R_RegisterAnimationGroup(const char *filename, animModelInfo_t *animModelInfo)
{
    pc_token_t token;
    int        handle;

    animModelInfo->numAnimations = 0;
    animModelInfo->footsteps     = FOOTSTEP_NORMAL;
    animModelInfo->gender        = GENDER_MALE;
    animModelInfo->isSkeletal    = qtrue;
    animModelInfo->version       = 3;
    animModelInfo->numHeadAnims  = 0;

    handle = trap_PC_LoadSource(filename);

    if (!handle)
    {
        return qfalse;
    }

    if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "animgroup"))
    {
        return BG_RAG_ParseError(handle, "expected 'animgroup'");
    }

    if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "{"))
    {
        return BG_RAG_ParseError(handle, "expected '{'");
    }

    while (1)
    {
        if (!trap_PC_ReadToken(handle, &token))
        {
            break;
        }

        if (token.string[0] == '}')
        {
            break;
        }

        if (!Q_stricmp(token.string, "animfile"))
        {
            if (!BG_RAG_ParseAnimFile(handle, animModelInfo))
            {
                return qfalse;
            }
        }
        else
        {
            return BG_RAG_ParseError(handle, "unknown token '%s'", token.string);
        }
    }

    trap_PC_FreeSource(handle);

    return qtrue;
}
qboolean BG_LoadSpeakerScript(const char *filename)
{
	pc_token_t token;
	int        handle;

	handle = trap_PC_LoadSource(filename);

	if (!handle)
	{
		return qfalse;
	}

	if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "speakerScript"))
	{
		return BG_SS_ParseError(handle, "expected 'soundScript'");
	}

	if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "{"))
	{
		return BG_SS_ParseError(handle, "expected '{'");
	}

	while (1)
	{
		if (!trap_PC_ReadToken(handle, &token))
		{
			break;
		}

		if (token.string[0] == '}')
		{
			break;
		}

		if (!Q_stricmp(token.string, "speakerDef"))
		{
			if (!BG_SS_ParseSpeaker(handle))
			{
				return qfalse;
			}
		}
		else
		{
			return BG_SS_ParseError(handle, "unknown token '%s'", token.string);
		}
	}

	trap_PC_FreeSource(handle);

	return qtrue;
}
Exemple #3
0
static qboolean CG_ReadHudFile(const char *filename)
{
	pc_token_t token;
	int        handle;

	handle = trap_PC_LoadSource(filename);

	if (!handle)
	{
		return qfalse;
	}

	if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "hudDef"))
	{
		return CG_HUD_ParseError(handle, "expected 'hudDef'");
	}

	if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "{"))
	{
		return CG_HUD_ParseError(handle, "expected '{'");
	}

	while (1)
	{
		if (!trap_PC_ReadToken(handle, &token))
		{
			break;
		}

		if (token.string[0] == '}')
		{
			break;
		}

		if (!Q_stricmp(token.string, "hud"))
		{
			if (!CG_ParseHUD(handle))
			{
				return qfalse;
			}
		}
		else
		{
			return CG_HUD_ParseError(handle, "unknown token '%s'", token.string);
		}
	}

	trap_PC_FreeSource(handle);

	return qtrue;
}
Exemple #4
0
static qboolean BG_SS_ParseError(int handle, char *format, ...) {
	int         line;
	char        filename[128];
	va_list     argptr;
	static char string[4096];

	va_start(argptr, format);
	Q_vsnprintf(string, sizeof (string), format, argptr);
	va_end(argptr);

	filename[0] = '\0';
	line        = 0;
	trap_PC_SourceFileAndLine(handle, filename, &line);

	Com_Printf(S_COLOR_RED "ERROR: %s, line %d: %s\n", filename, line, string);

	trap_PC_FreeSource(handle);

	return qfalse;
}
Exemple #5
0
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
weightconfig_t *ReadWeightConfig(char *filename)
{
	int newindent, avail = 0, n;
	pc_token_t token;
	int source;
	fuzzyseperator_t *fs;
	weightconfig_t *config = NULL;
	int starttime;

	starttime = trap_Milliseconds();

	if (!bot_reloadcharacters.integer)
	{
		avail = -1;
		for( n = 0; n < MAX_WEIGHT_FILES; n++ )
		{
			config = weightFileList[n];
			if( !config )
			{
				if( avail == -1 )
				{
					avail = n;
				} //end if
				continue;
			} //end if
			if( strcmp( filename, config->filename ) == 0 )
			{
				//BotAI_Print( PRT_MESSAGE, "retained %s\n", filename );
				return config;
			} //end if
		} //end for

		if( avail == -1 )
		{
			BotAI_Print( PRT_ERROR, "weightFileList was full trying to load %s\n", filename );
			return NULL;
		} //end if
	} //end if

	source = trap_PC_LoadSource(filename, BOTFILESBASEFOLDER);
	if (!source)
	{
		BotAI_Print(PRT_ERROR, "counldn't load %s\n", filename);
		return NULL;
	} //end if
	//
	config = (weightconfig_t *) trap_HeapMalloc(sizeof(weightconfig_t));
	config->numweights = 0;
	Q_strncpyz( config->filename, filename, sizeof(config->filename) );
	//parse the item config file
	while(trap_PC_ReadToken(source, &token))
	{
		if (!strcmp(token.string, "weight"))
		{
			if (config->numweights >= MAX_WEIGHTS)
			{
				PC_SourceWarning(source, "too many fuzzy weights");
				break;
			} //end if
			if (!PC_ExpectTokenType(source, TT_STRING, 0, &token))
			{
				FreeWeightConfig(config);
				trap_PC_FreeSource(source);
				return NULL;
			} //end if
			config->weights[config->numweights].name = (char *) trap_HeapMalloc(strlen(token.string) + 1);
			strcpy(config->weights[config->numweights].name, token.string);
			if (!PC_ExpectAnyToken(source, &token))
			{
				FreeWeightConfig(config);
				trap_PC_FreeSource(source);
				return NULL;
			} //end if
			newindent = qfalse;
			if (!strcmp(token.string, "{"))
			{
				newindent = qtrue;
				if (!PC_ExpectAnyToken(source, &token))
				{
					FreeWeightConfig(config);
					trap_PC_FreeSource(source);
					return NULL;
				} //end if
			} //end if
			if (!strcmp(token.string, "switch"))
			{
				fs = ReadFuzzySeperators_r(source);
				if (!fs)
				{
					FreeWeightConfig(config);
					trap_PC_FreeSource(source);
					return NULL;
				} //end if
				config->weights[config->numweights].firstseperator = fs;
			} //end if
			else if (!strcmp(token.string, "return"))
			{
				fs = (fuzzyseperator_t *) trap_HeapMalloc(sizeof(fuzzyseperator_t));
				fs->index = 0;
				fs->value = MAX_INVENTORYVALUE;
				fs->next = NULL;
				fs->child = NULL;
				if (!ReadFuzzyWeight(source, fs))
				{
					trap_HeapFree(fs);
					FreeWeightConfig(config);
					trap_PC_FreeSource(source);
					return NULL;
				} //end if
				config->weights[config->numweights].firstseperator = fs;
			} //end else if
			else
			{
				PC_SourceError(source, "invalid name %s", token.string);
				FreeWeightConfig(config);
				trap_PC_FreeSource(source);
				return NULL;
			} //end else
			if (newindent)
			{
				if (!PC_ExpectTokenString(source, "}"))
				{
					FreeWeightConfig(config);
					trap_PC_FreeSource(source);
					return NULL;
				} //end if
			} //end if
			config->numweights++;
		} //end if
		else
		{
			PC_SourceError(source, "invalid name %s", token.string);
			FreeWeightConfig(config);
			trap_PC_FreeSource(source);
			return NULL;
		} //end else
	} //end while
	//free the source at the end of a pass
	trap_PC_FreeSource(source);
	//if the file was located in a pak file
	BotAI_Print(PRT_DEVELOPER, "loaded %s\n", filename);
	BotAI_Print(PRT_DEVELOPER, "weights loaded in %d msec\n", trap_Milliseconds() - starttime);
	//
	if (!bot_reloadcharacters.integer)
	{
		weightFileList[avail] = config;
	} //end if
	//
	return config;
} //end of the function ReadWeightConfig
static qboolean G_LoadCampaignsFromFile( const char *filename ) {
	int handle;
	pc_token_t token;
	const char *s;
	qboolean mapFound = qfalse;

	handle = trap_PC_LoadSource( filename );

	if ( !handle ) {
		G_Printf( va( S_COLOR_RED "file not found: %s\n", filename ) );
		return qfalse;
	}

	if ( !trap_PC_ReadToken( handle, &token ) ) {
		trap_PC_FreeSource( handle );
		return qfalse;
	}
	if ( *token.string != '{' ) {
		trap_PC_FreeSource( handle );
		return qfalse;
	}

	while ( trap_PC_ReadToken( handle, &token ) ) {
		if ( *token.string == '}' ) {
			level.campaignCount++;

			// zinx - can't handle any more.
			if ( level.campaignCount >= MAX_CAMPAIGNS ) {
				break;
			}

			if ( !trap_PC_ReadToken( handle, &token ) ) {
				// eof
				trap_PC_FreeSource( handle );
				break;
			}

			if ( *token.string != '{' ) {
				G_Printf( va( S_COLOR_RED "unexpected token '%s' inside: %s\n", token.string, filename ) );
				trap_PC_FreeSource( handle );
				return qfalse;
			}
		} else if ( !Q_stricmp( token.string, "name" ) ||
					!Q_stricmp( token.string, "description" ) ||
					!Q_stricmp( token.string, "image" ) ) {
			if ( ( s = PC_String_Parse( handle ) ) == NULL ) {
				G_Printf( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
				trap_PC_FreeSource( handle );
				return qfalse;
			}
		} else if ( !Q_stricmp( token.string, "shortname" ) ) {
			if ( ( s = PC_String_Parse( handle ) ) == NULL ) {
				G_Printf( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
				trap_PC_FreeSource( handle );
				return qfalse;
			} else {
				Q_strncpyz( g_campaigns[level.campaignCount].shortname, s, sizeof( g_campaigns[level.campaignCount].shortname ) );
			}
		} else if ( !Q_stricmp( token.string, "next" ) ) {
			if ( ( s = PC_String_Parse( handle ) ) == NULL ) {
				G_Printf( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
				trap_PC_FreeSource( handle );
				return qfalse;
			} else {
				Q_strncpyz( g_campaigns[level.campaignCount].shortname, s, sizeof( g_campaigns[level.campaignCount].next ) );
			}
		} else if ( !Q_stricmp( token.string, "type" ) ) {
			if ( !trap_PC_ReadToken( handle, &token ) ) {
				G_Printf( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
				trap_PC_FreeSource( handle );
				return qfalse;
			}

			if ( strstr( token.string, "wolfsp" ) ) {
				g_campaigns[level.campaignCount].typeBits |= ( 1 << GT_SINGLE_PLAYER );
			}
			if ( strstr( token.string, "wolfcoop" ) ) {
				g_campaigns[level.campaignCount].typeBits |= ( 1 << GT_COOP );
			}
			if ( strstr( token.string, "wolfmp" ) ) {
				g_campaigns[level.campaignCount].typeBits |= ( 1 << GT_WOLF );
			}
			if ( strstr( token.string, "wolfsw" ) ) {
				g_campaigns[level.campaignCount].typeBits |= ( 1 << GT_WOLF_STOPWATCH );
			}
			if ( strstr( token.string, "wolflms" ) ) {
				g_campaigns[level.campaignCount].typeBits |= ( 1 << GT_WOLF_LMS );
			}
		} else if ( !Q_stricmp( token.string, "maps" ) ) {
			char *ptr, mapname[128], *mapnamePtr;

			if ( !trap_PC_ReadToken( handle, &token ) ) {
				G_Printf( S_COLOR_RED "unexpected end of file inside: %s\n", filename );
				trap_PC_FreeSource( handle );
				return qfalse;
			}

			ptr = token.string;
			while ( *ptr ) {
				mapnamePtr = mapname;
				while ( *ptr && *ptr != ';' ) {
					*mapnamePtr++ = *ptr++;
				}
				if ( *ptr ) {
					ptr++;
				}
				*mapnamePtr = '\0';

				if ( g_gametype.integer == GT_WOLF_CAMPAIGN ) {
					if ( !mapFound &&
						 !Q_stricmp( g_campaigns[level.campaignCount].shortname, g_currentCampaign.string ) &&
						 !Q_stricmp( mapname, level.rawmapname ) ) {

						if ( g_currentCampaignMap.integer == 0 ) {
							level.newCampaign = qtrue;
						} else {
							level.newCampaign = qfalse;
						}

						if ( g_campaigns[level.campaignCount].mapCount == g_currentCampaignMap.integer ) {
							g_campaigns[level.campaignCount].current = g_campaigns[level.campaignCount].mapCount;
							mapFound = qtrue;
							//trap_Cvar_Set( "g_currentCampaignMap", va( "%i", g_campaigns[level.campaignCount].mapCount ) );
						}

						level.currentCampaign = level.campaignCount;
					}
				}
				// rain - don't stomp out of bounds
				if ( g_campaigns[level.campaignCount].mapCount < MAX_MAPS_PER_CAMPAIGN ) {
					Q_strncpyz( g_campaigns[level.campaignCount].mapnames[g_campaigns[level.campaignCount].mapCount], mapname, MAX_QPATH );
					g_campaigns[level.campaignCount].mapCount++;
				} else {
					// rain - yell if there are too many maps in this campaign,
					// and then skip it

					G_Printf( "^1Error: Campaign %s (%s) has too many maps\n", g_campaigns[level.campaignCount].shortname, filename );
					// rain - hack - end of campaign will increment this
					// again, so this one will be overwritten
					// rain - clear out this campaign so that everything's
					// okay when when we add the next
					memset( &g_campaigns[level.campaignCount], 0, sizeof( g_campaigns[0] ) );
					level.campaignCount--;

					break;
				}
			}
		}
	}

	return mapFound;
}
Exemple #7
0
/*
===============
UI_LoadArenasFromFile
===============
*/
static void UI_LoadArenasFromFile( char *filename ) {
    /*	int				len;
    	fileHandle_t	f;
    	char			buf[MAX_ARENAS_TEXT];

    	len = trap_FS_FOpenFile( filename, &f, FS_READ );
    	if ( !f ) {
    		trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
    		return;
    	}
    	if ( len >= MAX_ARENAS_TEXT ) {
    		trap_Print( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_ARENAS_TEXT ) );
    		trap_FS_FCloseFile( f );
    		return;
    	}

    	trap_FS_Read( buf, len, f );
    	buf[len] = 0;
    	trap_FS_FCloseFile( f );

    	ui_numArenas += UI_ParseInfos( buf, MAX_ARENAS - ui_numArenas, &ui_arenaInfos[ui_numArenas], MAX_ARENAS );*/

    int handle;
    pc_token_t token;

    handle = trap_PC_LoadSource( filename );

    if( !handle ) {
        trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
        return;
    }

    if( !trap_PC_ReadToken( handle, &token ) ) {
        trap_PC_FreeSource( handle );
        return;
    }

    if( *token.string != '{' ) {
        trap_PC_FreeSource( handle );
        return;
    }

    uiInfo.mapList[uiInfo.mapCount].cinematic = -1;
    uiInfo.mapList[uiInfo.mapCount].levelShot = -1;
    uiInfo.mapList[uiInfo.mapCount].typeBits = 0;

    while( trap_PC_ReadToken( handle, &token ) ) {
        if( *token.string == '}' ) {

            if( !uiInfo.mapList[uiInfo.mapCount].typeBits ) {
                uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF);
            }

            uiInfo.mapCount++;
            if( uiInfo.mapCount >= MAX_MAPS ) {
                break;
            }

            if( !trap_PC_ReadToken( handle, &token ) ) {
                // eof
                trap_PC_FreeSource( handle );
                return;
            }

            if( *token.string != '{' ) {
                trap_Print( va( S_COLOR_RED "unexpected token '%s' inside: %s\n", token.string, filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "map" ) ) {
            if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mapLoadName ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "longname" ) ) {
            if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mapName ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "briefing" ) ) {
            if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].briefing ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "lmsbriefing" ) ) {
            if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].lmsbriefing ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
            /*} else if( !Q_stricmp( token.string, "objectives" ) ) {
            	if( !PC_String_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].objectives ) ) {
            		trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
            		trap_PC_FreeSource( handle );
            		return;
            	}*/
        } else if( !Q_stricmp( token.string, "timelimit" ) ) {
            if( !PC_Int_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].Timelimit ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "axisrespawntime" ) ) {
            if( !PC_Int_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].AxisRespawnTime ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "alliedrespawntime" ) ) {
            if( !PC_Int_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].AlliedRespawnTime ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "type" ) ) {
            if( !trap_PC_ReadToken( handle, &token ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            } else {
                if( strstr( token.string, "wolfsp" ) ) {
                    uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_SINGLE_PLAYER);
                }
                if( strstr( token.string, "wolflms" ) ) {
                    uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_LMS);
                }
                if( strstr( token.string, "wolfmp" ) ) {
                    uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF);
                }
                if( strstr( token.string, "wolfsw" ) ) {
                    uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_STOPWATCH);
                }
            }
        } else if( !Q_stricmp( token.string, "mapposition_x" ) ) {
            if( !PC_Float_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mappos[0] ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "mapposition_y" ) ) {
            if( !PC_Float_Parse( handle, &uiInfo.mapList[uiInfo.mapCount].mappos[1] ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        }
    }

    trap_PC_FreeSource( handle );
    return;
}/* ============= UI_SortArenas CHRUKER: b090 - Sorting the map list ============= */
Exemple #8
0
static void UI_LoadCampaignsFromFile( const char *filename ) {
    int handle, i;
    pc_token_t token;

    handle = trap_PC_LoadSource( filename );

    if( !handle ) {
        trap_Print( va( S_COLOR_RED "file not found: %s\n", filename ) );
        return;
    }

    if( !trap_PC_ReadToken( handle, &token ) ) {
        trap_PC_FreeSource( handle );
        return;
    }
    if( *token.string != '{' ) {
        trap_PC_FreeSource( handle );
        return;
    }

    while ( trap_PC_ReadToken( handle, &token ) ) {
        if( *token.string == '}' ) {
            if( uiInfo.campaignList[uiInfo.campaignCount].initial ) {
                if( uiInfo.campaignList[uiInfo.campaignCount].typeBits & (1<<GT_SINGLE_PLAYER) )
                    uiInfo.campaignList[uiInfo.campaignCount].unlocked = qtrue;
                // Always unlock the initial SP campaign
            }

            uiInfo.campaignList[uiInfo.campaignCount].campaignCinematic = -1;
            uiInfo.campaignList[uiInfo.campaignCount].campaignShot = -1;

            uiInfo.campaignCount++;

            if( !trap_PC_ReadToken( handle, &token ) ) {
                // eof
                trap_PC_FreeSource( handle );
                return;
            }

            if( *token.string != '{' ) {
                //uiInfo.campaignList[uiInfo.campaignCount].order = -1;

                trap_Print( va( S_COLOR_RED "unexpected token '%s' inside: %s\n", token.string, filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "shortname" ) ) {
            if( !PC_String_Parse( handle, &uiInfo.campaignList[uiInfo.campaignCount].campaignShortName ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "name" ) ) {
            if( !PC_String_Parse( handle, &uiInfo.campaignList[uiInfo.campaignCount].campaignName ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "description" ) ) {
            if( !PC_String_Parse( handle, &uiInfo.campaignList[uiInfo.campaignCount].campaignDescription ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "image" ) ) {
            if( !PC_String_Parse( handle, &uiInfo.campaignList[uiInfo.campaignCount].campaignShotName ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            } else {
                uiInfo.campaignList[uiInfo.campaignCount].campaignShot = -1;
            }
        } else if( !Q_stricmp( token.string, "initial" ) ) {
            uiInfo.campaignList[uiInfo.campaignCount].initial = qtrue;
        } else if( !Q_stricmp( token.string, "next" ) ) {
            if( !PC_String_Parse( handle, &uiInfo.campaignList[uiInfo.campaignCount].nextCampaignShortName ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }
        } else if( !Q_stricmp( token.string, "type" ) ) {
            if( !trap_PC_ReadToken( handle, &token ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }

            if( strstr( token.string, "wolfsp" ) ) {
                uiInfo.campaignList[uiInfo.campaignCount].typeBits |= (1 << GT_SINGLE_PLAYER);
            }
            if( strstr( token.string, "wolfmp" ) ) {
                uiInfo.campaignList[uiInfo.campaignCount].typeBits |= (1 << GT_WOLF);
            }
            if( strstr( token.string, "wolfsw" ) ) {
                uiInfo.campaignList[uiInfo.campaignCount].typeBits |= (1 << GT_WOLF_STOPWATCH);
            }
            if( strstr( token.string, "wolflms" ) ) {
                uiInfo.campaignList[uiInfo.campaignCount].typeBits |= (1 << GT_WOLF_LMS);
            }
        } else if( !Q_stricmp( token.string, "maps" ) ) {
            char *ptr, mapname[128], *mapnameptr;

            if( !trap_PC_ReadToken( handle, &token ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }

            // find the mapInfo's that match our mapnames
            uiInfo.campaignList[uiInfo.campaignCount].mapCount = 0;

            ptr = token.string;
            while( *ptr ) {
                mapnameptr = mapname;
                while( *ptr && *ptr != ';' ) {
                    *mapnameptr++ = *ptr++;
                }
                if( *ptr )
                    ptr++;
                *mapnameptr = '\0';
                for( i = 0; i < uiInfo.mapCount; i++ ) {
                    if( !Q_stricmp( uiInfo.mapList[i].mapLoadName, mapname ) ) {
                        uiInfo.campaignList[uiInfo.campaignCount].mapInfos[uiInfo.campaignList[uiInfo.campaignCount].mapCount++] = &uiInfo.mapList[i];
                        break;
                    }
                }
            }
        } else if( !Q_stricmp( token.string, "maptc" ) ) {
            if( !trap_PC_ReadToken( handle, &token ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }

            uiInfo.campaignList[uiInfo.campaignCount].mapTC[0][0] = token.floatvalue;

            if( !trap_PC_ReadToken( handle, &token ) ) {
                trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
                trap_PC_FreeSource( handle );
                return;
            }

            uiInfo.campaignList[uiInfo.campaignCount].mapTC[0][1] = token.floatvalue;

            uiInfo.campaignList[uiInfo.campaignCount].mapTC[1][0] = 650 + uiInfo.campaignList[uiInfo.campaignCount].mapTC[0][0];
            uiInfo.campaignList[uiInfo.campaignCount].mapTC[1][1] = 650 + uiInfo.campaignList[uiInfo.campaignCount].mapTC[0][1];
            /*if( !trap_PC_ReadToken( handle, &token ) ) {
            	trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
            	trap_PC_FreeSource( handle );
            	return;
            }

            uiInfo.campaignList[uiInfo.campaignCount].mapTC[1][0] = token.floatvalue + uiInfo.campaignList[uiInfo.campaignCount].mapTC[0][0];

            if( !trap_PC_ReadToken( handle, &token ) ) {
            	trap_Print( va( S_COLOR_RED "unexpected end of file inside: %s\n", filename ) );
            	trap_PC_FreeSource( handle );
            	return;
            }

            uiInfo.campaignList[uiInfo.campaignCount].mapTC[1][1] = token.floatvalue + uiInfo.campaignList[uiInfo.campaignCount].mapTC[0][1];*/
        }
    }

    trap_PC_FreeSource( handle );
}
Exemple #9
0
qboolean CG_FindCampaignInFile(char *filename, char *campaignShortName, cg_campaignInfo_t *info)
{
	int             handle;
	pc_token_t      token;

//  char* dummy;
	qboolean        campaignFound = qfalse;

	info->mapCount = 0;

	handle = trap_PC_LoadSource(filename);

	if (!handle)
	{
		trap_Print(va(S_COLOR_RED "file not found: %s\n", filename));
		return qfalse;
	}

	if (!trap_PC_ReadToken(handle, &token))
	{
		trap_PC_FreeSource(handle);
		return qfalse;
	}

	if (*token.string != '{')
	{
		trap_PC_FreeSource(handle);
		return qfalse;
	}

	while (trap_PC_ReadToken(handle, &token))
	{
		if (*token.string == '}')
		{
			if (campaignFound)
			{
				trap_PC_FreeSource(handle);
				return qtrue;
			}

			if (!trap_PC_ReadToken(handle, &token))
			{
				// eof
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			if (*token.string != '{')
			{
				trap_Print(va(S_COLOR_RED "unexpected token '%s' inside: %s\n", token.string, filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			info->mapCount = 0;
		}
		else if (!Q_stricmp(token.string, "shortname"))
		{
			if (!trap_PC_ReadToken(handle, &token))
			{
				// don't do a stringparse due to memory constraints
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			if (!Q_stricmp(token.string, campaignShortName))
			{
				campaignFound = qtrue;
			}
		}
		else if (!Q_stricmp(token.string, "next") || !Q_stricmp(token.string, "image"))
		{
			//if( !PC_String_Parse( handle, &dummy ) ) {
			if (!trap_PC_ReadToken(handle, &token))
			{
				// don't do a stringparse due to memory constraints
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
		}
		else if (!Q_stricmp(token.string, "description"))
		{
			if (!trap_PC_ReadToken(handle, &token))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			Q_strncpyz(info->campaignDescription, token.string, sizeof(info->campaignDescription));
		}
		else if (!Q_stricmp(token.string, "name"))
		{
			if (!trap_PC_ReadToken(handle, &token))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			Q_strncpyz(info->campaignName, token.string, sizeof(info->campaignName));
		}
		else if (!Q_stricmp(token.string, "maps"))
		{
			char           *ptr, mapname[128], *mapnameptr;

			if (!trap_PC_ReadToken(handle, &token))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			ptr = token.string;

			while (*ptr)
			{
				mapnameptr = mapname;

				while (*ptr && *ptr != ';')
				{
					*mapnameptr++ = *ptr++;
				}

				if (*ptr)
				{
					ptr++;
				}

				*mapnameptr = '\0';

				if (info->mapCount >= MAX_MAPS_PER_CAMPAIGN)
				{
					trap_Print(va(S_COLOR_RED "too many maps for a campaign inside: %s\n", filename));
					trap_PC_FreeSource(handle);
					break;
				}

				Q_strncpyz(info->mapnames[info->mapCount++], mapname, MAX_QPATH);
			}
		}
		else if (!Q_stricmp(token.string, "maptc"))
		{
			if (!trap_PC_ReadToken(handle, &token))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			info->mapTC[0][0] = token.floatvalue;

			if (!trap_PC_ReadToken(handle, &token))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			info->mapTC[0][1] = token.floatvalue;

			info->mapTC[1][0] = 650 + info->mapTC[0][0];
			info->mapTC[1][1] = 650 + info->mapTC[0][1];
		}
	}

	trap_PC_FreeSource(handle);
	return qfalse;
}
Exemple #10
0
qboolean CG_FindArenaInfo(char *filename, char *mapname, arenaInfo_t *info)
{
	int             handle;
	pc_token_t      token;
	const char     *dummy;
	qboolean        found = qfalse;

	handle = trap_PC_LoadSource(filename);

	if (!handle)
	{
		trap_Print(va(S_COLOR_RED "file not found: %s\n", filename));
		return qfalse;
	}

	if (!trap_PC_ReadToken(handle, &token))
	{
		trap_PC_FreeSource(handle);
		return qfalse;
	}

	if (*token.string != '{')
	{
		trap_PC_FreeSource(handle);
		return qfalse;
	}

	while (trap_PC_ReadToken(handle, &token))
	{
		if (*token.string == '}')
		{
			if (found)
			{
//              info->image = trap_R_RegisterShaderNoMip(va("levelshots/%s", mapname));
				trap_PC_FreeSource(handle);
				return qtrue;
			}

			found = qfalse;

			if (!trap_PC_ReadToken(handle, &token))
			{
				// eof
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			if (*token.string != '{')
			{
				trap_Print(va(S_COLOR_RED "unexpected token '%s' inside: %s\n", token.string, filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
		}
		else if (!Q_stricmp(token.string, "objectives") || !Q_stricmp(token.string, "description") ||
		         !Q_stricmp(token.string, "type"))
		{
			if (!PC_String_Parse(handle, &dummy))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
		}
		else if (!Q_stricmp(token.string, "longname"))
		{
			if (!PC_String_Parse(handle, &dummy))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
			else
			{
				//char* p = info->longname;

				Q_strncpyz(info->longname, dummy, 128);
				// Gordon: removing cuz, er, no-one knows why it's here!...
				/*				while(*p) {
									*p = toupper(*p);
									p++;
								}*/
			}
		}
		else if (!Q_stricmp(token.string, "map"))
		{
			if (!PC_String_Parse(handle, &dummy))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
			else
			{
				if (!Q_stricmp(dummy, mapname))
				{
					found = qtrue;
				}
			}
		}
		else if (!Q_stricmp(token.string, "Timelimit") || !Q_stricmp(token.string, "AxisRespawnTime") ||
		         !Q_stricmp(token.string, "AlliedRespawnTime"))
		{
			if (!PC_Int_Parse(handle, (int *)&dummy))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
		}
		else if (!Q_stricmp(token.string, "lmsbriefing"))
		{
			if (!PC_String_Parse(handle, &dummy))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
			else
			{
				Q_strncpyz(info->lmsdescription, dummy, sizeof(info->lmsdescription));
			}
		}
		else if (!Q_stricmp(token.string, "briefing"))
		{
			if (!PC_String_Parse(handle, &dummy))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
			else
			{
				Q_strncpyz(info->description, dummy, sizeof(info->description));
			}
		}
		else if (!Q_stricmp(token.string, "alliedwintext"))
		{
			if (!PC_String_Parse(handle, &dummy))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
			else
			{
				Q_strncpyz(info->alliedwintext, dummy, sizeof(info->description));
			}
		}
		else if (!Q_stricmp(token.string, "axiswintext"))
		{
			if (!PC_String_Parse(handle, &dummy))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}
			else
			{
				Q_strncpyz(info->axiswintext, dummy, sizeof(info->description));
			}
		}
		else if (!Q_stricmp(token.string, "mapposition_x"))
		{
			vec_t           x;

			if (!trap_PC_ReadToken(handle, &token))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			x = token.floatvalue;

			info->mappos[0] = x;
		}
		else if (!Q_stricmp(token.string, "mapposition_y"))
		{
			vec_t           y;

			if (!trap_PC_ReadToken(handle, &token))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return qfalse;
			}

			y = token.floatvalue;

			info->mappos[1] = y;
		}
	}

	trap_PC_FreeSource(handle);
	return qfalse;
}
Exemple #11
0
qboolean BG_ParseCharacterFile(const char *filename, bg_characterDef_t *characterDef)
{
	pc_token_t token;
	int        handle;

	handle = trap_PC_LoadSource(filename);

	if (!handle)
	{
		return qfalse;
	}

	if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "characterDef"))
	{
		return BG_PCF_ParseError(handle, "expected 'characterDef'");
	}

	if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "{"))
	{
		return BG_PCF_ParseError(handle, "expected '{'");
	}

	while (1)
	{
		if (!trap_PC_ReadToken(handle, &token))
		{
			break;
		}

		if (token.string[0] == '}')
		{
			break;
		}

		if (!Q_stricmp(token.string, "mesh"))
		{
			if (!PC_String_ParseNoAlloc(handle, characterDef->mesh, sizeof(characterDef->mesh)))
			{
				return BG_PCF_ParseError(handle, "expected mesh filename");
			}
		}
		else if (!Q_stricmp(token.string, "animationGroup"))
		{
			if (!PC_String_ParseNoAlloc(handle, characterDef->animationGroup, sizeof(characterDef->animationGroup)))
			{
				return BG_PCF_ParseError(handle, "expected animationGroup filename");
			}
		}
		else if (!Q_stricmp(token.string, "animationScript"))
		{
			if (!PC_String_ParseNoAlloc(handle, characterDef->animationScript, sizeof(characterDef->animationScript)))
			{
				return BG_PCF_ParseError(handle, "expected animationScript filename");
			}
		}
		else if (!Q_stricmp(token.string, "skin"))
		{
			if (!PC_String_ParseNoAlloc(handle, characterDef->skin, sizeof(characterDef->skin)))
			{
				return BG_PCF_ParseError(handle, "expected skin filename");
			}
		}
		else if (!Q_stricmp(token.string, "undressedCorpseModel"))
		{
			if (!PC_String_ParseNoAlloc(handle, characterDef->undressedCorpseModel, sizeof(characterDef->undressedCorpseModel)))
			{
				return BG_PCF_ParseError(handle, "expected undressedCorpseModel filename");
			}
		}
		else if (!Q_stricmp(token.string, "undressedCorpseSkin"))
		{
			if (!PC_String_ParseNoAlloc(handle, characterDef->undressedCorpseSkin, sizeof(characterDef->undressedCorpseSkin)))
			{
				return BG_PCF_ParseError(handle, "expected undressedCorpseSkin filename");
			}
		}
		else if (!Q_stricmp(token.string, "hudhead"))
		{
			if (!PC_String_ParseNoAlloc(handle, characterDef->hudhead, sizeof(characterDef->hudhead)))
			{
				return BG_PCF_ParseError(handle, "expected hudhead filename");
			}
		}
		else if (!Q_stricmp(token.string, "hudheadskin"))
		{
			if (!PC_String_ParseNoAlloc(handle, characterDef->hudheadskin, sizeof(characterDef->hudheadskin)))
			{
				return BG_PCF_ParseError(handle, "expected hudhead filename");
			}
		}
		else if (!Q_stricmp(token.string, "hudheadanims"))
		{
			if (!PC_String_ParseNoAlloc(handle, characterDef->hudheadanims, sizeof(characterDef->hudheadanims)))
			{
				return BG_PCF_ParseError(handle, "expected hudheadanims filename");
			}
		}
		else
		{
			return BG_PCF_ParseError(handle, "unknown token '%s'", token.string);
		}
	}

	trap_PC_FreeSource(handle);

	return qtrue;
}
Exemple #12
0
void G_configLoadAndSet(const char *name)
{
	pc_token_t token;
	int        handle;
	config_t   *config;
	qboolean   parseOK = qtrue;

	handle = trap_PC_LoadSource(va("configs/%s.config", name));

	if (!handle)
	{
		Com_Printf(S_COLOR_RED "ERROR: File not found: %s\n", name);
		return;
	}

	memset(&level.config, 0, sizeof(config_t));

	G_wipeCvars();

	config = &level.config;

	config->publicConfig = qfalse;

	while (1)
	{
		if (!trap_PC_ReadToken(handle, &token))
		{
			break;
		}

		if (!Q_stricmp(token.string, "configname"))
		{
			if (!PC_String_ParseNoAlloc(handle, config->name, sizeof(config->name)))
			{
				G_Printf("expected config name\n");
				parseOK = qfalse;
				break;
			}
			G_Printf("Config name is: %s\n", config->name);
		}
		else if (!Q_stricmp(token.string, "version"))
		{
			if (!PC_String_ParseNoAlloc(handle, config->version, sizeof(config->name)))
			{
				G_Printf("expected config version\n");
				parseOK = qfalse;
				break;
			}
		}
		else if (!Q_stricmp(token.string, "init"))
		{
			if (!G_ParseSettings(handle, qtrue, config))
			{
				G_Printf("Reading settings failed\n");
				parseOK = qfalse;
				break;
			}
		}
		else if (!Q_stricmp(token.string, "map"))
		{
			if (!G_ParseMapSettings(handle, config))
			{
				G_Printf("Reading map settings failed\n");
				parseOK = qfalse;
				break;
			}
		}
		else if (!Q_stricmp(token.string, "signature"))
		{
			if (!PC_String_ParseNoAlloc(handle, config->signature, sizeof(config->signature)))
			{
				G_Printf("expected config signature\n");
				parseOK = qfalse;
				break;
			}
		}
		else if (!Q_stricmp(token.string, "public"))
		{
			config->publicConfig = qtrue;
		}
		else
		{
			G_Printf("unknown token %s\n", token.string);
			parseOK = qfalse;
			break;
		}
	}
	trap_PC_FreeSource(handle);

	if (parseOK)
	{
		trap_SetConfigstring(CS_CONFIGNAME, config->name);

		if (level.config.version[0] && level.config.name[0])
		{
			trap_SendServerCommand(-1, va("cp \"^7Config '%s^7' version '%s'^7 loaded\"", level.config.name, level.config.version));
		}
		else if (level.config.name[0])
		{
			trap_SendServerCommand(-1, va("cp \"^7Config '%s^7' loaded\"", level.config.name));
		}
	}
	else
	{
		trap_SetConfigstring(CS_CONFIGNAME, "");
		trap_SendServerCommand(-1, va("cp \"^7Config '%s^7' ^1FAILED ^7to load\"", name));
	}

	G_UpdateCvars();
}
Exemple #13
0
static animation_t * BG_RAG_FindFreeAnimation(const char *mdxFileName, const char *name)
#endif // CGAMEDLL
{
	int i;

	for (i = 0; i < MAX_ANIMPOOL_SIZE; i++)
	{
#ifdef CGAMEDLL
		if (animationPool[i].mdxFile == mdxFile && !Q_stricmp(animationPool[i].name, name))
		{
#else
		if (*animationPool[i].mdxFileName && !Q_stricmp(animationPool[i].mdxFileName, mdxFileName) && !Q_stricmp(animationPool[i].name, name))
		{
#endif // CGAMEDLL
			return(&animationPool[i]);
		}
	}

	for (i = 0; i < MAX_ANIMPOOL_SIZE; i++)
	{
#ifdef CGAMEDLL
		if (!animationPool[i].mdxFile)
		{
			animationPool[i].mdxFile = mdxFile;
#else
		if (!animationPool[i].mdxFileName[0])
		{
			Q_strncpyz(animationPool[i].mdxFileName, mdxFileName, sizeof(animationPool[i].mdxFileName));
#endif // CGAMEDLL
			Q_strncpyz(animationPool[i].name, name, sizeof(animationPool[i].name));
			return(&animationPool[i]);
		}
	}

	return NULL;
}

static qboolean BG_RAG_ParseError(int handle, char *format, ...)
{
	int         line;
	char        filename[128];
	va_list     argptr;
	static char string[4096];

	va_start(argptr, format);
	Q_vsnprintf(string, sizeof(string), format, argptr);
	va_end(argptr);

	filename[0] = '\0';
	line        = 0;
	trap_PC_SourceFileAndLine(handle, filename, &line);

	Com_Printf(S_COLOR_RED "ERROR: %s, line %d: %s\n", filename, line, string);

	trap_PC_FreeSource(handle);

	return qfalse;
}

static qboolean BG_RAG_ParseAnimation(int handle, animation_t *animation)
{
	int i;

	animation->flags = 0;

	if (!PC_Int_Parse(handle, &animation->firstFrame))
	{
		return BG_RAG_ParseError(handle, "expected first frame integer");
	}

	if (!PC_Int_Parse(handle, &animation->numFrames))
	{
		return BG_RAG_ParseError(handle, "expected length integer");
	}

	if (!PC_Int_Parse(handle, &animation->loopFrames))
	{
		return BG_RAG_ParseError(handle, "expected looping integer");
	}

	if (!PC_Int_Parse(handle, &i))
	{
		return BG_RAG_ParseError(handle, "expected fps integer");
	}

	if (i == 0)
	{
		i = 1;
	}

	animation->frameLerp   = 1000 / (float)i;
	animation->initialLerp = 1000 / (float)i;

	if (!PC_Int_Parse(handle, &animation->moveSpeed))
	{
		return BG_RAG_ParseError(handle, "expected move speed integer");
	}

	if (!PC_Int_Parse(handle, &animation->animBlend))
	{
		return BG_RAG_ParseError(handle, "expected transition integer");
	}

	if (!PC_Int_Parse(handle, &i))
	{
		return BG_RAG_ParseError(handle, "expected reversed integer");
	}

	if (i == 1)
	{
		animation->flags |= ANIMFL_REVERSED;
	}

	// calculate the duration
	animation->duration = animation->initialLerp
	                      + animation->frameLerp * animation->numFrames
	                      + animation->animBlend;

	// get the nameHash
	animation->nameHash = BG_StringHashValue(animation->name);

	// hacky-ish stuff
	if (!Q_strncmp(animation->name, "climb", 5))
	{
		animation->flags |= ANIMFL_LADDERANIM;
	}

	if (strstr(animation->name, "firing"))
	{
		animation->flags      |= ANIMFL_FIRINGANIM;
		animation->initialLerp = 40;
	}

	return qtrue;
}
Exemple #14
0
static qboolean BG_RAG_ParseAnimFile(int handle, animModelInfo_t *animModelInfo)
{
	pc_token_t token;
#ifdef CGAMEDLL
	qhandle_t mdxFile;
#else
	char mdxFileName[MAX_QPATH];
#endif // CGAMEDLL

	animation_t *animation;

	if (!trap_PC_ReadToken(handle, &token))
	{
		return BG_RAG_ParseError(handle, "expected mdx filename");
	}

#ifdef CGAMEDLL
	if (!(mdxFile = trap_R_RegisterModel(token.string)))
	{
		return BG_RAG_ParseError(handle, "failed to load %s", token.string);
	}
#else
	Q_strncpyz(mdxFileName, token.string, sizeof(mdxFileName));
#endif // CGAMEDLL

	if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "{"))
	{
		return BG_RAG_ParseError(handle, "expected '{'");
	}

	while (1)
	{
		if (!trap_PC_ReadToken(handle, &token))
		{
			return BG_RAG_ParseError(handle, "unexpected EOF");
		}

		if (token.string[0] == '}')
		{
			break;
		}

#ifdef CGAMEDLL
		if (!(animation = BG_RAG_FindFreeAnimation(mdxFile, token.string)))
		{
#else
		if (!(animation = BG_RAG_FindFreeAnimation(mdxFileName, token.string)))
		{
#endif // CGAMEDLL
			return BG_RAG_ParseError(handle, "out of animation storage space");
		}

		Q_strncpyz(animation->name, token.string, sizeof(animation->name));
		Q_strlwr(animation->name);

		if (!BG_RAG_ParseAnimation(handle, animation))
		{
			return qfalse;
		}

		animModelInfo->animations[animModelInfo->numAnimations] = animation;
		animModelInfo->numAnimations++;
	}

	return qtrue;
}

qboolean BG_R_RegisterAnimationGroup(const char *filename, animModelInfo_t *animModelInfo)
{
	pc_token_t token;
	int        handle;

	animModelInfo->numAnimations = 0;
	animModelInfo->footsteps     = FOOTSTEP_NORMAL;
	animModelInfo->gender        = GENDER_MALE;
	animModelInfo->isSkeletal    = qtrue;
	animModelInfo->version       = 3;
	animModelInfo->numHeadAnims  = 0;

	handle = trap_PC_LoadSource(filename);

	if (!handle)
	{
		return qfalse;
	}

	if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "animgroup"))
	{
		return BG_RAG_ParseError(handle, "expected 'animgroup'");
	}

	if (!trap_PC_ReadToken(handle, &token) || Q_stricmp(token.string, "{"))
	{
		return BG_RAG_ParseError(handle, "expected '{'");
	}

	while (1)
	{
		if (!trap_PC_ReadToken(handle, &token))
		{
			break;
		}

		if (token.string[0] == '}')
		{
			break;
		}

		if (!Q_stricmp(token.string, "animfile"))
		{
			if (!BG_RAG_ParseAnimFile(handle, animModelInfo))
			{
				return qfalse;
			}
		}
		else
		{
			return BG_RAG_ParseError(handle, "unknown token '%s'", token.string);
		}
	}

	trap_PC_FreeSource(handle);

	return qtrue;
}
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
qboolean BotLoadCharacterFromFile(char *charfile, int skill, bot_character_t *ch)
{
	int indent, index, foundcharacter;
	int	source;
	pc_token_t token;

	foundcharacter = qfalse;
	//a bot character is parsed in two phases
	source = trap_PC_LoadSource(charfile, BOTFILESBASEFOLDER);
	if (!source)
	{
		BotAI_Print(PRT_ERROR, "counldn't load %s\n", charfile);
		return qfalse;
	} //end if
	strcpy(ch->filename, charfile);
	while(trap_PC_ReadToken(source, &token))
	{
		if (!strcmp(token.string, "skill"))
		{
			if (!PC_ExpectTokenType(source, TT_NUMBER, 0, &token))
			{
				trap_PC_FreeSource(source);
				BotFreeCharacterStrings(ch);
				return qfalse;
			} //end if
			if (!PC_ExpectTokenString(source, "{"))
			{
				trap_PC_FreeSource(source);
				BotFreeCharacterStrings(ch);
				return qfalse;
			} //end if
			//if it's the correct skill
			if (skill < 0 || token.intvalue == skill)
			{
				foundcharacter = qtrue;
				ch->skill = token.intvalue;
				while(PC_ExpectAnyToken(source, &token))
				{
					if (!strcmp(token.string, "}")) break;
					if (token.type != TT_NUMBER || !(token.subtype & TT_INTEGER))
					{
						PC_SourceError(source, "expected integer index, found %s", token.string);
						trap_PC_FreeSource(source);
						BotFreeCharacterStrings(ch);
						return qfalse;
					} //end if
					index = token.intvalue;
					if (index < 0 || index > MAX_CHARACTERISTICS)
					{
						PC_SourceError(source, "characteristic index out of range [0, %d]", MAX_CHARACTERISTICS);
						trap_PC_FreeSource(source);
						BotFreeCharacterStrings(ch);
						return qfalse;
					} //end if
					if (ch->c[index].type)
					{
						PC_SourceError(source, "characteristic %d already initialized", index);
						trap_PC_FreeSource(source);
						BotFreeCharacterStrings(ch);
						return qfalse;
					} //end if
					if (!PC_ExpectAnyToken(source, &token))
					{
						trap_PC_FreeSource(source);
						BotFreeCharacterStrings(ch);
						return qfalse;
					} //end if
					if (token.type == TT_NUMBER)
					{
						if (token.subtype & TT_FLOAT)
						{
							ch->c[index].value._float = token.floatvalue;
							ch->c[index].type = CT_FLOAT;
						} //end if
						else
						{
							ch->c[index].value.integer = token.intvalue;
							ch->c[index].type = CT_INTEGER;
						} //end else
					} //end if
					else if (token.type == TT_STRING)
					{
						// ZTM: FIXME: ### I think I made this be done in the engine
						//StripDoubleQuotes(token.string);
						ch->c[index].value.string = trap_Alloc(strlen(token.string)+1, NULL);
						strcpy(ch->c[index].value.string, token.string);
						ch->c[index].type = CT_STRING;
					} //end else if
					else
					{
						PC_SourceError(source, "expected integer, float or string, found %s", token.string);
						trap_PC_FreeSource(source);
						BotFreeCharacterStrings(ch);
						return qfalse;
					} //end else
				} //end if
				break;
			} //end if
			else
			{
				indent = 1;
				while(indent)
				{
					if (!PC_ExpectAnyToken(source, &token))
					{
						trap_PC_FreeSource(source);
						BotFreeCharacterStrings(ch);
						return qfalse;
					} //end if
					if (!strcmp(token.string, "{")) indent++;
					else if (!strcmp(token.string, "}")) indent--;
				} //end while
			} //end else
		} //end if
		else
		{
			PC_SourceError(source, "unknown definition %s", token.string);
			trap_PC_FreeSource(source);
			BotFreeCharacterStrings(ch);
			return qfalse;
		} //end else
	} //end while
	trap_PC_FreeSource(source);
	//
	if (!foundcharacter)
	{
		BotFreeCharacterStrings(ch);
		return qfalse;
	} //end if
	return qtrue;
} //end of the function BotLoadCharacterFromFile
static void UI_LoadArenasFromFile(char *filename)
{
	int        handle;
	pc_token_t token;

	handle = trap_PC_LoadSource(filename);

	if (!handle)
	{
		trap_Print(va(S_COLOR_RED "file not found: %s\n", filename));
		return;
	}

	if (!trap_PC_ReadToken(handle, &token))
	{
		trap_PC_FreeSource(handle);
		return;
	}

	if (*token.string != '{')
	{
		trap_PC_FreeSource(handle);
		return;
	}

	uiInfo.mapList[uiInfo.mapCount].cinematic = -1;
	uiInfo.mapList[uiInfo.mapCount].levelShot = -1;
	uiInfo.mapList[uiInfo.mapCount].typeBits  = 0;

	while (trap_PC_ReadToken(handle, &token))
	{
		if (*token.string == '}')
		{

			if (!uiInfo.mapList[uiInfo.mapCount].typeBits)
			{
				uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF);
			}

			uiInfo.mapCount++;
			if (uiInfo.mapCount >= MAX_MAPS)
			{
				break;
			}

			if (!trap_PC_ReadToken(handle, &token))
			{
				// eof
				trap_PC_FreeSource(handle);
				return;
			}

			if (*token.string != '{')
			{
				trap_Print(va(S_COLOR_RED "unexpected token '%s' inside: %s\n", token.string, filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
		else if (!Q_stricmp(token.string, "map"))
		{
			if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].mapLoadName))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
		else if (!Q_stricmp(token.string, "longname"))
		{
			if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].mapName))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
		else if (!Q_stricmp(token.string, "briefing"))
		{
			if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].briefing))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
		else if (!Q_stricmp(token.string, "lmsbriefing"))
		{
			if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].lmsbriefing))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
		/*
		else if (!Q_stricmp(token.string, "objectives"))
		{
		    if (!PC_String_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].objectives))
		    {
		        trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
		        trap_PC_FreeSource(handle);
		        return;
		    }
		}
		*/
		else if (!Q_stricmp(token.string, "timelimit"))
		{
			if (!PC_Int_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].Timelimit))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
		else if (!Q_stricmp(token.string, "axisrespawntime"))
		{
			if (!PC_Int_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].AxisRespawnTime))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
		else if (!Q_stricmp(token.string, "alliedrespawntime"))
		{
			if (!PC_Int_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].AlliedRespawnTime))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
		else if (!Q_stricmp(token.string, "type"))
		{
			if (!trap_PC_ReadToken(handle, &token))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
			else
			{
				if (strstr(token.string, "wolfsp"))
				{
					uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_SINGLE_PLAYER);
				}
				if (strstr(token.string, "wolflms"))
				{
					uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_LMS);
				}
				if (strstr(token.string, "wolfmp"))
				{
					uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF);
				}
				if (strstr(token.string, "wolfsw"))
				{
					uiInfo.mapList[uiInfo.mapCount].typeBits |= (1 << GT_WOLF_STOPWATCH);
				}
			}
		}
		else if (!Q_stricmp(token.string, "mapposition_x"))
		{
			if (!PC_Float_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].mappos[0]))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
		else if (!Q_stricmp(token.string, "mapposition_y"))
		{
			if (!PC_Float_Parse(handle, &uiInfo.mapList[uiInfo.mapCount].mappos[1]))
			{
				trap_Print(va(S_COLOR_RED "unexpected end of file inside: %s\n", filename));
				trap_PC_FreeSource(handle);
				return;
			}
		}
	}

	trap_PC_FreeSource(handle);
	return;
}