Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
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( 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;
}
Ejemplo n.º 3
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 ============= */
Ejemplo n.º 4
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 );
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 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;
}