Exemple #1
0
void Pointfile_Parse(CPointfile& pointfile)
{
	int		size;
	char	*data;
  char  *text;
  int   line = 1;

  const char* mapname = Map_Name(g_map);
  StringOutputStream name(256);
  name << StringRange(mapname, path_get_filename_base_end(mapname)) << ".lin";

	size = LoadFile (name.c_str(), (void**)&data);
  if (size == -1)
  {
    globalErrorStream() << "Pointfile " << name.c_str() << " not found\n";
		return;
  }

  // store a pointer
  text = data;

	globalOutputStream() << "Reading pointfile " << name.c_str() << "\n";

  pointfile.Init();

	while (*data)
	{
	  Vector3 v;
    if (sscanf(data,"%f %f %f", &v[0], &v[1], &v[2]) != 3)
    {
      globalOutputStream() << "Corrupt point file, line " << line << "\n";
			break;
    }

  	while (*data && *data != '\n')
    {
      if (*(data-1) == ' ' && *(data) == '-' && *(data+1) == ' ')
        break;
		  data++;
    }
    // deal with zhlt style point files.
    if (*data == '-')
    {
      if (sscanf(data,"- %f %f %f", &v[0], &v[1], &v[2]) != 3)
      {
        globalOutputStream() << "Corrupt point file, line " << line << "\n";
        break;
      }

      while (*data && *data != '\n')
		    data++;

    }
    while (*data == '\n')
    {
      data++; // skip the \n
      line++;
    }
		pointfile.PushPoint (v);
	}

  g_free(text);
}
Exemple #2
0
void WINAPI Pointfile_Check( void ) {
    char name[1024];
    int size;
    char    *data;
    char  *text;
    int line = 1;
    vec3_t v;

    strcpy( name, currentmap );
    StripExtension( name );
    strcat( name, ".lin" );

    size = vfsLoadFullPathFile( name, (void**)&data );
    if ( size <= 0 ) {
        Sys_FPrintf( SYS_ERR, "Pointfile %s not found\n", name );
        return;
    }

    // store a pointer
    text = data;

    Sys_Printf( "Reading pointfile %s\n", name );

    g_pointfile.Init();

    while ( *data )
    {
        if ( sscanf( data,"%f %f %f", &v[0], &v[1], &v[2] ) != 3 ) {
            Sys_Printf( "Corrupt point file, line %d\n",line );
            break;
        }

        while ( *data && *data != '\n' )
        {
            if ( *( data - 1 ) == ' ' && *( data ) == '-' && *( data + 1 ) == ' ' ) {
                break;
            }
            data++;
        }
        // deal with zhlt style point files.
        if ( *data == '-' ) {
            if ( sscanf( data,"- %f %f %f", &v[0], &v[1], &v[2] ) != 3 ) {
                Sys_Printf( "Corrupt point file, line %d\n",line );
                break;
            }

            while ( *data && *data != '\n' )
                data++;

        }
        while ( *data == '\n' )
        {
            data++; // skip the \n
            line++;
        }
        g_pointfile.PushPoint( v );
    }

    g_free( text );

    g_pointfile.GenerateDisplayList();

    Sys_UpdateWindows( W_ALL );
}