Пример #1
0
static qboolean BG_RAG_ParseAnimFile(int handle, animModelInfo_t *animModelInfo)
{
	pc_token_t token;
#ifdef USE_MDXFILE
	qhandle_t mdxFile;
#else
	char mdxFileName[MAX_QPATH];
#endif // USE_MDXFILE

	animation_t *animation;

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

#ifdef USE_MDXFILE
	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 // USE_MDXFILE

	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 USE_MDXFILE
		if (!(animation = BG_RAG_FindFreeAnimation(mdxFile, token.string)))
		{
#else
		if (!(animation = BG_RAG_FindFreeAnimation(mdxFileName, token.string)))
		{
#endif // USE_MDXFILE
			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;
}
Пример #2
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];
		}
	}

	trap_PC_FreeSource(handle);
}
Пример #3
0
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;
}
Пример #4
0
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(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(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(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(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(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(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;
}