예제 #1
0
void EClass_InitForFileList( GSList *pFiles, _EClassTable *pTable ){
	GSList *pFile = pFiles;
	while ( pFile )
	{
		// for a given name, we grab the first .def in the vfs
		// this allows to override baseq3/scripts/entities.def for instance
		char relPath[PATH_MAX];
		strcpy( relPath, "scripts/" );
		strcat( relPath, (char*)pFile->data );
		if ( !vfsGetFullPath( relPath, 0, 0 ) ) {
			Sys_FPrintf( SYS_ERR, "Failed to find the full path for '%s' in the VFS\n", relPath );
		}
		else{
			pTable->m_pfnScanFile( vfsGetFullPath( relPath, 0, 0 ) );
		}
		pFile = pFile->next;
	}
}
예제 #2
0
void Eclass_Init(){
	GSList *pFiles;

	// start by creating the default unknown eclass
	eclass_bad = EClass_Create( "UNKNOWN_CLASS", 0, 0.5, 0,NULL,NULL,NULL );

	// now scan the definitions
	_EClassTable *pTable = &g_EClassDefTable;
	while ( pTable )
	{
		// read in all scripts/*.<extension>
		pFiles = vfsGetFileList( "scripts", pTable->m_pfnGetExtension() );
		if ( pFiles ) {
			GSList *pFile = pFiles;
			while ( pFile )
			{
				/*!
				   \todo the MP/SP filtering rules need to be CLEANED UP and SANITIZED
				 */
				// HACK
				// JKII SP/MP mapping mode
				if ( g_pGameDescription->mGameFile == "jk2.game" || g_pGameDescription->mGameFile == "ja.game" ) {
					if ( !strcmp( ValueForKey( g_qeglobals.d_project_entity, "gamemode" ), "sp" ) ) {
						// SP mapping, ignore mp_*.def
						char *name = (char *)pFile->data;
						if ( name[0] == 'm' && name[1] == 'p' && name[2] == '_' ) {
							Sys_Printf( "Single Player mapping mode. Ignoring '%s'\n", name );
							pFile = pFile->next;
							continue;
						}
					}
					else
					{
						// MP mapping, ignore sp_*.def
						char *name = (char *)pFile->data;
						if ( name[0] == 's' && name[1] == 'p' && name[2] == '_' ) {
							Sys_Printf( "Multiplayer mapping mode. Ignoring '%s'\n", name );
							pFile = pFile->next;
							continue;
						}
					}
				}
				// RIANT
				// STVEF SP/MP mapping mode
				else if ( g_pGameDescription->mGameFile == "stvef.game" ) {
					if ( !strcmp( ValueForKey( g_qeglobals.d_project_entity, "gamemode" ), "sp" ) ) {
						// SP mapping, ignore mp_*.def
						char *name = (char *)pFile->data;
						if ( name[0] == 'm' && name[1] == 'p' && name[2] == '_' 
							|| name[0] == 'h' && name[1] == 'm' && name[2] == '_' ) {
							Sys_Printf( "Single Player mapping mode. Ignoring '%s'\n", name );
							pFile = pFile->next;
							continue;
						}
					}
					else
					{
						// HM mapping, ignore sp_*.def
						char *name = (char *)pFile->data;
						if ( name[0] == 's' && name[1] == 'p' && name[2] == '_' ) {
							Sys_Printf( "HoloMatch mapping mode. Ignoring '%s'\n", name );
							pFile = pFile->next;
							continue;
						}
					}
				}
				// for a given name, we grab the first .def in the vfs
				// this allows to override baseq3/scripts/entities.def for instance
				char relPath[PATH_MAX];
				strcpy( relPath, "scripts/" );
				strcat( relPath, (char*)pFile->data );
				char *fullpath = vfsGetFullPath( relPath, 0, 0 );
				if ( !fullpath ) {
					Sys_FPrintf( SYS_ERR, "Failed to find the full path for \"%s\" in the VFS\n", relPath );
				}
				else{
					pTable->m_pfnScanFile( fullpath );
				}
				if ( g_pGameDescription->mEClassSingleLoad ) {
					break;
				}
				pFile = pFile->next;
			}
			vfsClearFileDirList( &pFiles );
			pFiles = NULL;
		}
		else{
			Sys_FPrintf( SYS_ERR, "Didn't find any scripts/*.%s files to load EClass information\n", pTable->m_pfnGetExtension() );
		}

		// we deal with two formats max, if the other table exists, loop again
		if ( g_bHaveEClassExt && pTable == &g_EClassDefTable ) {
			pTable = &g_EClassExtTable;
		}
		else{
			pTable = NULL; // done, exit
		}
	}
	Eclass_CreateSpriteModelPaths();
}
예제 #3
0
void UpdateWadKeyPair( void )
{
  int i,nb;

  char wads[2048]; // change to CString usage ?
  wads[0] = 0;
  char *p1,*p2;
  entity_t *pEntity;
  epair_t *pEpair;
  GSList *wadlist = NULL;
  face_t  *f;
  brush_t *b;
  char cleanwadname[QER_MAX_NAMELEN];
  const char *actualwad;


  pEntity = (entity_t *)g_FuncTable.m_pfnGetEntityHandle(0); // get the worldspawn ent

  Sys_Printf("Searching for in-use wad files...\n");
  for(pEpair = pEntity->epairs; pEpair != NULL; pEpair = pEpair->next)
  {
    if (stricmp(pEpair->key,"wad") == 0)
    {
      strcpy(wads,pEpair->value);
      ConvertDOSToUnixName(wads,wads);

      // ok, we got the list of ; delimited wads, now split it into a GSList that contains
      // just the wad names themselves.

      p1 = wads;

      do
      {
        p2 = strchr(p1,';');
        if (p2)
          *p2 = 0; // swap the ; with a null terminator

        if (strchr(p1,'/') || strchr(p1,'\\'))
        {
          ExtractFileName(p1,cleanwadname);
          wadlist = AddToWadList (wadlist, NULL, cleanwadname);
        }
        else
        {
          wadlist = AddToWadList (wadlist, NULL, p1);
        }
        if (p2)
          p1 = p2+1; // point back to the remainder of the string
        else
          p1 = NULL; // make it so we exit the loop.

      } while (p1);

      // ok, now we have a list of wads in GSList.
      // now we need to add any new wadfiles (with their paths) to this list
      // so scan all brushes and see what wads are in use
      // FIXME: scan brushes only in the region ?

      break; // we don't need to process any more key/pairs.
    }
  }

  nb = g_FuncTable.m_pfnAllocateActiveBrushHandles();
  for( i = 0; i < nb; i++ )
	{
    b = (brush_t *)g_FuncTable.m_pfnGetActiveBrushHandle(i);
    if (b->patchBrush) // patches in halflife ?
    {
      wadlist = AddToWadList(wadlist, b->pPatch->pShader->getName(),NULL);
    } else
    {
      for (f=b->brush_faces ; f ; f=f->next)
      {
        wadlist = AddToWadList(wadlist, f->pShader->getName(),NULL);
      }
    }
  }
  g_FuncTable.m_pfnReleaseActiveBrushHandles();

  nb = g_FuncTable.m_pfnAllocateSelectedBrushHandles();
  for( i = 0; i < nb; i++ )
	{
    b = (brush_t *)g_FuncTable.m_pfnGetSelectedBrushHandle(i);
    if (b->patchBrush) // patches in halflife ?
    {
      wadlist = AddToWadList(wadlist, b->pPatch->pShader->getName(),NULL);
    } else
    {
      for (f=b->brush_faces ; f ; f=f->next)
      {
        wadlist = AddToWadList(wadlist, f->pShader->getName(),NULL);
      }
    }
  }
  g_FuncTable.m_pfnReleaseSelectedBrushHandles();

  // Now we have a complete list of wadnames (without paths) so we just have to turn this
  // back to a ; delimited list.

  wads[0] = 0;
  while (wadlist)
  {
    if (stricmp((char *)wadlist->data,"common-hydra.wad") == 0)
    {
      Sys_Printf("Skipping radiant-supplied wad file %s\n",(char *)wadlist->data);
    }
    else
    {
      if (wads[0])
        strcat(wads,";");

      actualwad = vfsGetFullPath((char *)wadlist->data);

      if (actualwad)
      {
        strcat(wads, actualwad);
      }
      else
      {
        Sys_Printf("WARNING: could not locate wad file %s\n",(char *)wadlist->data);
        strcat(wads, (char *)wadlist->data);
      }
    }

    free (wadlist->data);
    wadlist = g_slist_remove (wadlist, wadlist->data);
  }

  // store the wad list back in the worldspawn.
  if (wads[0])
  {
    //free(pEpair->value);
    //pEpair->value = strdup(wads);
    SetKeyValue(pEntity, "wad", wads);
  }

}
예제 #4
0
void Face_Parse( face_t *face, bool bAlternateTexdef = false ){
	int i, j;
	char *str;
	bool bworldcraft = false;

	char *token = Token();

	// parse planepts
	str = NULL;
	for ( i = 0; i < 3; i++ )
	{
		GetToken( true ); //(
		for ( j = 0; j < 3; j++ )
		{
			GetToken( false );
			face->planepts[i][j] = atof( token );
		}
		GetToken( false ); //)
	}

	if ( bAlternateTexdef ) {
		// parse alternate texdef
		GetToken( false ); // (
		GetToken( false ); // (
		for ( i = 0; i < 3; i++ )
		{
			GetToken( false );
			face->brushprimit_texdef.coords[0][i] = atof( token );
		}
		GetToken( false ); // )
		GetToken( false ); // (
		for ( i = 0; i < 3; i++ )
		{
			GetToken( false );
			face->brushprimit_texdef.coords[1][i] = atof( token );
		}
		GetToken( false ); // )
		GetToken( false ); // )
	}


	// parse shader name
	GetToken( false ); // shader

	// if we're loading a halflife map then we don't have a relative texture name
	// we just get <texturename>.  So we need to convert this to a relative name
	// like this: "textures/<wadname>/shader", so we use vfsFileFile to get the filename.

	// *** IMPORTANT ***
	// For Halflife we need to see if the texture is in wads listed in the
	// map's worldspawn "wad" e-pair.  If we don't then the image used will be the
	// first image with this texture name that is found in any of the wads on the
	// user's system.  this is not a huge problem, because the map compiler obeys
	// the "wad" epair when compiling the map, but the user might end up looking at
	// the wrong texture in the editor. (more of a problem if the texture we use
	// here has a different size from the one in the wad the map compiler uses...)

	// Hydra: - TTimo: I looked all over for other places to put this, but really it
	// is an issue with map loading (because of a limitation of halflife/q2 map format)
	// so it's gone in here, it also stops incorrect shader/texdef names getting used
	// in the radiant core and it's modules which we'd only have to change later on.
	// (either in map_importentities() or the shader module).  so it's actually cleaner
	// in the long run, even if a little odd.  And it keeps more game specific stuff
	// OUT of the core, which is a good thing.

	if ( g_MapVersion == MAPVERSION_HL ) {
		qboolean done = false;

		// FIXME: This bit is halflife specific.
		// look in the list of wads supplied in the worldspawn "wad" key/pair for the
		// texture first, if it's not in any then we carry on searching the vfs for it
		// as usual.

		// each time we find a texture, we add it to the a cache
		// so we don't have to hunt the vfs for it each time.
		// See SearchWadsForTextureName() and AddToCache() above for cache stuff

		char *wadname;
		wadname = SearchWadsForTextureName( token );

		if ( wadname ) {
			face->texdef.SetName( wadname );
			done = true;
		}
		else
		{
			// using the cache below means that this message is only ever printed out once!
			Sys_Printf( "WARNING: could not find \"%s\" in any listed wad files, searching all wad files instead!\n",token );
		}
		// end of half-life specific bit.

		// check the cache!
		if ( !done ) {
			str = CheckCacheForTextureName( token );
			if ( str ) {
				face->texdef.SetName( str );
				done = true;
			}
		}

		if ( !done ) {
			char *fullpath;

			str = new char[strlen( token ) + 4 + 1];

			// FIXME: halflife specific file extension, we'll have to support Q2/Q1 formats
			// and maybe tga texture format for HL here too..
			sprintf( str,"%s.hlw",token );
			fullpath = vfsGetFullPath( str,0,VFS_SEARCH_PAK | VFS_SEARCH_DIR );

			// MIP support for quake
			if ( !fullpath ) {
				sprintf( str,"%s.mip",token );
				fullpath = vfsGetFullPath( str, 0, 0 );
			}

			// TGA support in halflife ?
			/*
			   if (!fullpath)
			   {
			   sprintf(str,"%s.tga",token);
			   fullpath = vfsGetFullPath(str);
			   }
			 */
			delete [] str;

			if ( fullpath ) {
				// strip the extension.
				int len = strlen( fullpath );
				if ( fullpath[len - 4] == '.' ) {
					fullpath[len - 4] = '\0';
				}

				// and set the correct name!
				face->texdef.SetName( fullpath );
				AddToCache( token,fullpath );
			}
			else
			{
				Sys_Printf( "WARNING: could not find \"%s\" in the vfs search path\n",token );
				str = new char[strlen( token ) + 10];
				strcpy( str, "textures/" );
				strcpy( str + 9, token );
				face->texdef.SetName( str );
				AddToCache( token,str );
				delete [] str;
			}
		}
	}
	else // !MAPVERSION_HL
	{
		str = new char[strlen( token ) + 10];
		strcpy( str, "textures/" );
		strcpy( str + 9, token );
		face->texdef.SetName( str );
		delete [] str;
	}

	if ( !bAlternateTexdef ) {
		if ( g_MapVersion == MAPVERSION_HL ) { // Q1 as well ?
			GetToken( false );
			if ( token[0] == '[' && token[1] == '\0' ) {
				bworldcraft = true;

				GetToken( false ); // UAxis[0]
				GetToken( false ); // UAxis[1]
				GetToken( false ); // UAxis[2]

				GetToken( false ); // shift
				face->texdef.shift[0] = atof( token );

				GetToken( false ); // ]

				GetToken( false ); // [
				GetToken( false ); // VAxis[0]
				GetToken( false ); // VAxis[1]
				GetToken( false ); // VAxis[2]

				GetToken( false ); // shift
				face->texdef.shift[1] = atof( token );

				GetToken( false ); // ]

				// rotation is derived from the U and V axes.
				// ZHLT ignores this setting even if present in a .map file.
				GetToken( false );
				face->texdef.rotate = atof( token );

				// Scales
				GetToken( false );
				face->texdef.scale[0] = atof( token );
				GetToken( false );
				face->texdef.scale[1] = atof( token );
			}
			else
			{
				UnGetToken();
			}
		}

		if ( !bworldcraft ) { // !MAPVERSION_HL
			// parse texdef
			GetToken( false );
			face->texdef.shift[0] = atof( token );
			GetToken( false );
			face->texdef.shift[1] = atof( token );
			GetToken( false );
			face->texdef.rotate = atof( token );
			GetToken( false );
			face->texdef.scale[0] = atof( token );
			GetToken( false );
			face->texdef.scale[1] = atof( token );
		}
	}
	// parse the optional contents/flags/value
	if ( !bworldcraft && TokenAvailable() ) {
		GetToken( true );
		if ( isdigit( token[0] ) ) {
			face->texdef.contents = atoi( token );
			GetToken( false );
			face->texdef.flags = atoi( token );
			GetToken( false );
			face->texdef.value = atoi( token );
		}
		else
		{
			UnGetToken();
		}
	}
}