/*
=================
PC_Rect_Parse
=================
*/
bool PC_Rect_Parse( int handle, rectDef_t *r )
{
	if ( PC_Float_Parse( handle, &r->x ) )
	{
		if ( PC_Float_Parse( handle, &r->y ) )
		{
			if ( PC_Float_Parse( handle, &r->w ) )
			{
				if ( PC_Float_Parse( handle, &r->h ) )
				{
					return true;
				}
			}
		}
	}

	return false;
}
Beispiel #2
0
static qboolean CG_RectParse(int handle, rectDef_t *r)
{
	float x = 0;

	if (PC_Float_Parse(handle, &x))
	{
		r->x = Ccg_WideX(x);
		if (PC_Float_Parse(handle, &r->y))
		{
			if (PC_Float_Parse(handle, &r->w))
			{
				if (PC_Float_Parse(handle, &r->h))
				{
					return qtrue;
				}
			}
		}
	}
	return qfalse;
}
/*
=================
PC_Color_Parse
=================
*/
bool PC_Color_Parse( int handle, Color::Color *c )
{
	int   i;
	float f;

	for ( i = 0; i < 4; i++ )
	{
		if ( !PC_Float_Parse( handle, &f ) )
		{
			return false;
		}

		c->ToArray()[ i ] = f;
	}

	return true;
}
void CG_BuildableStatusParse( const char *filename, buildStat_t *bs )
{
  pc_token_t token;
  int        handle;
  const char *s;
  int        i;
  float      f;
  vec4_t     c;

  handle = trap_Parse_LoadSource( filename );
  if( !handle )
    return;
  while( 1 )
  {
    if( !trap_Parse_ReadToken( handle, &token ) )
      break;
    if( !Q_stricmp( token.string, "frameShader" ) )
    {
      if( PC_String_Parse( handle, &s ) )
        bs->frameShader = trap_R_RegisterShader( s );
      continue;
    }
    else if( !Q_stricmp( token.string, "overlayShader" ) )
    {
      if( PC_String_Parse( handle, &s ) )
        bs->overlayShader = trap_R_RegisterShader( s );
      continue;
    }
    else if( !Q_stricmp( token.string, "noPowerShader" ) )
    {
      if( PC_String_Parse( handle, &s ) )
        bs->noPowerShader = trap_R_RegisterShader( s );
      continue;
    }
    else if( !Q_stricmp( token.string, "markedShader" ) )
    {
      if( PC_String_Parse( handle, &s ) )
        bs->markedShader = trap_R_RegisterShader( s );
      continue;
    }
    else if( !Q_stricmp( token.string, "healthSevereColor" ) )
    {
      if( PC_Color_Parse( handle, &c ) )
        Vector4Copy( c, bs->healthSevereColor );
      continue;
    }
    else if( !Q_stricmp( token.string, "healthHighColor" ) )
    {
      if( PC_Color_Parse( handle, &c ) )
        Vector4Copy( c, bs->healthHighColor );
      continue;
    }
    else if( !Q_stricmp( token.string, "healthElevatedColor" ) )
    {
      if( PC_Color_Parse( handle, &c ) )
        Vector4Copy( c, bs->healthElevatedColor );
      continue;
    }
    else if( !Q_stricmp( token.string, "healthGuardedColor" ) )
    {
      if( PC_Color_Parse( handle, &c ) )
        Vector4Copy( c, bs->healthGuardedColor );
      continue;
    }
    else if( !Q_stricmp( token.string, "healthLowColor" ) )
    {
      if( PC_Color_Parse( handle, &c ) )
        Vector4Copy( c, bs->healthLowColor );
      continue;
    }
    else if( !Q_stricmp( token.string, "foreColor" ) )
    {
      if( PC_Color_Parse( handle, &c ) )
        Vector4Copy( c, bs->foreColor );
      continue;
    }
    else if( !Q_stricmp( token.string, "backColor" ) )
    {
      if( PC_Color_Parse( handle, &c ) )
        Vector4Copy( c, bs->backColor );
      continue;
    }
    else if( !Q_stricmp( token.string, "frameHeight" ) )
    {
      if( PC_Int_Parse( handle, &i ) )
        bs->frameHeight = i;
      continue;
    }
    else if( !Q_stricmp( token.string, "frameWidth" ) )
    {
      if( PC_Int_Parse( handle, &i ) )
        bs->frameWidth = i;
      continue;
    }
    else if( !Q_stricmp( token.string, "healthPadding" ) )
    {
      if( PC_Int_Parse( handle, &i ) )
        bs->healthPadding = i;
      continue;
    }
    else if( !Q_stricmp( token.string, "overlayHeight" ) )
    {
      if( PC_Int_Parse( handle, &i ) )
        bs->overlayHeight = i;
      continue;
    }
    else if( !Q_stricmp( token.string, "overlayWidth" ) )
    {
      if( PC_Int_Parse( handle, &i ) )
        bs->overlayWidth = i;
      continue;
    }
    else if( !Q_stricmp( token.string, "verticalMargin" ) )
    {
      if( PC_Float_Parse( handle, &f ) )
        bs->verticalMargin = f;
      continue;
    }
    else if( !Q_stricmp( token.string, "horizontalMargin" ) )
    {
      if( PC_Float_Parse( handle, &f ) )
        bs->horizontalMargin = f;
      continue;
    }
    else
    {
      Com_Printf("CG_BuildableStatusParse: unknown token %s in %s\n",
        token.string, filename );
      bs->loaded = qfalse;
      return;
    }
  }
  bs->loaded = qtrue;
}
Beispiel #5
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 ============= */
Beispiel #6
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;
}