Exemple #1
0
void P_LoadStrifeConversations (MapData *map, const char *mapname)
{
	P_FreeStrifeConversations ();
	if (map->Size(ML_CONVERSATION) > 0)
	{
		map->Seek(ML_CONVERSATION);
		LoadScriptFile (map->lumpnum, map->file, map->Size(ML_CONVERSATION), false, 0);
	}
	else
	{
		if (strnicmp (mapname, "MAP", 3) != 0)
		{
			return;
		}
		char scriptname_b[9] = { 'S','C','R','I','P','T',mapname[3],mapname[4],0 };
		char scriptname_t[9] = { 'D','I','A','L','O','G',mapname[3],mapname[4],0 };

		if (!LoadScriptFile(scriptname_t, false, 2))
		{
			if (!LoadScriptFile (scriptname_b, false, 1))
			{
				LoadScriptFile ("SCRIPT00", false, 1);
			}
		}
	}
}
void P_LoadStrifeConversations (const char *mapname)
{
	if (strnicmp (mapname, "MAP", 3) != 0)
	{
		return;
	}
	char scriptname[9] = { 'S','C','R','I','P','T',mapname[3],mapname[4],0 };

	LoadScriptFile ("SCRIPT00");
	LoadScriptFile (scriptname);
}
Exemple #3
0
void LoadKVXFromScript( char *filename )
{
	long lTile=0;			// lTile is the editart tile being replaced.
	char *sName;			// KVS file being loaded in.

	sName = (char *)malloc(256);	// Up to 256 bytes for path
	ASSERT(sName != NULL);

	// Load the file
	if (!LoadScriptFile(filename)) return;

	do {
		GetToken (TRUE);	// Crossing a line boundary on the end of line to first token
							// of a new line is permitted (and expected)
		if (endofscript)
			break;

		lTile = atol(token);

		GetToken(FALSE);
		// ignore lNumber

		GetToken(FALSE);
		strcpy(sName,token);			// Copy the whole token as a file name and path

		// Load the voxel file into memory
		if (!qloadkvx(nextvoxid,sName)) {
			tiletovox[lTile] = nextvoxid++;
		}

	} while (script_p < scriptend_p && nextvoxid < MAXVOXELS);

	free(scriptbuffer); 
	script_p = NULL;
}
CChoreoScene* HammerLoadScene( const char *pFilename )
{
	if ( g_pFullFileSystem->FileExists( pFilename ) )
	{
		LoadScriptFile( (char*)pFilename );
		CChoreoScene *scene = ChoreoLoadScene( pFilename, NULL, &g_TokenProcessor, Msg );
		return scene;
	}

	return NULL;
}
Exemple #5
0
	bool Parse(int lumpnum, FileReader *lump, int lumplen)
	{
		char *buffer = new char[lumplen];
		lump->Read(buffer, lumplen);
		sc.OpenMem(Wads.GetLumpFullName(lumpnum), buffer, lumplen);
		delete [] buffer;
		sc.SetCMode(true);
		// Namespace must be the first field because everything else depends on it.
		if (sc.CheckString("namespace"))
		{
			sc.MustGetToken('=');
			sc.MustGetToken(TK_StringConst);
			namespc = sc.String;
			switch(namespc)
			{
			case NAME_ZDoom:
				namespace_bits = Zd;
				break;
			case NAME_Strife:
				namespace_bits = St;
				break;
			default:
				sc.ScriptMessage("Unknown namespace %s. Ignoring dialogue lump.\n", sc.String);
				return false;
			}
			sc.MustGetToken(';');
		}
		else
		{
			sc.ScriptMessage("Map does not define a namespace.\n");
			return false;
		}

		while (sc.GetString())
		{
			if (sc.Compare("conversation"))
			{
				sc.MustGetToken('{');
				if (!ParseConversation()) return false;
			}
			else if (sc.Compare("include"))
			{
				sc.MustGetToken('=');
				sc.MustGetToken(TK_StringConst);
				LoadScriptFile(sc.String, true);
				sc.MustGetToken(';');
			}
			else
			{
				Skip();
			}
		}
		return true;
	}
bool VJSGlobalContext::EvaluateScript( VFile *inFile, VValueSingle **outResult, bool inJSONresult ) const
{
	VString script;
	bool ok = LoadScriptFile( inFile, script);
	if (ok)
	{
		VURL url( inFile->GetPath());
		ok = EvaluateScript( script, &url, outResult, inJSONresult );
	}

	return ok;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *filename - 
// Output : CChoreoScene
//-----------------------------------------------------------------------------
CChoreoScene *CVCDFile::LoadScene( char const *filename )
{
	if ( SceneManager_FullpathFileExists( va( "%s/%s", SceneManager_GetGameDirectory(), (char *)filename ) ) )
	{
		LoadScriptFile( va( "%s/%s", SceneManager_GetGameDirectory(), (char *)filename ) );

		CChoreoScene *scene = ChoreoLoadScene( this, &g_TokenProcessor, Con_Printf );
		return scene;
	}

	return NULL;
}
bool VJSContext::EvaluateScript( VFile *inFile, VJSValue *outResult, JS4D::ExceptionRef *outException, VJSObject* inThisObject) const
{
	VString script;
	bool ok = LoadScriptFile( inFile, script);
	
	if (ok)
	{
		VURL url( inFile->GetPath());
		ok = EvaluateScript( script, &url, outResult, outException, inThisObject);
	}

	return ok;
}
Exemple #9
0
void CPigEngine::ReloadScriptFile(const WIN32_FIND_DATA* pffd,
  CPigEngine::XScriptMapIt& it)
{
  // Get the name and object pointer
  tstring strFileName = it->first;
  CPigBehaviorScriptType* pScript = it->second;  

  // Remove the script's invoke commands
  RemoveInvokeCommands(pScript);

  // Reload the script file
  LoadScriptFile(pScript, pffd, strFileName);
}
void QFile_ReadMaterialTypes(char* filename)
{
	int		i;
	FILE	*f;

	if (materialtypes != defaultmaterialtypes)
	{
		if (materialtypes)
			free(materialtypes);
		materialtypes = (materialtype_t*)malloc(256 * sizeof(materialtype_t));
	}
	
	f = fopen (filename, "rb");
	if (!f)
	{
		materialtypes = defaultmaterialtypes;
		return;
	}
	fclose (f);

	LoadScriptFile(filename);
	i = 0;
	
	do	
	{
		GetScriptToken (true);
		if (endofscript)
		{
			break;
		}
		if (strcmp(sof_token, "material") != 0)
		{
			while (ScriptTokenAvailable())
			{
				GetScriptToken(false);
			}
		}
		else
		{
			GetScriptToken(false);
			materialtypes[i].name = (char*)malloc(strlen(sof_token) + 1);
			strcpy(materialtypes[i].name, sof_token);
			GetScriptToken (false);
			materialtypes[i].value = atoi(sof_token);
		}
	}
	while (i++ < 255);

	materialtypes[i].name = NULL;
	materialtypes[i].value = 0;
}
//----------------------------------------------------------------------------
//  RunModule
HRESULT CMagpieActiveScript::RunModule(
  CMagpieModule* pModule)
{
  CComPtr<IDispatch> pModuleRequireOb(pModule->GetRequire());
  if (!pModuleRequireOb)
  {
    return E_UNEXPECTED;
  }

  CString sFilename, sModuleID;
  pModule->GetID(sModuleID);
  pModule->GetFilename(sFilename);

  m_ScriptEngine->SetScriptState(SCRIPTSTATE_DISCONNECTED);

  // add namespace for module
  IF_FAILED_RET(m_ScriptEngine->AddNamedItem(sModuleID, SCRIPTITEM_CODEONLY));

  // dispatch for module's namespace
  CIDispatchHelper script;
  IF_FAILED_RET(m_ScriptEngine->GetScriptDispatch(sModuleID, &script));

  // create exports object
  CIDispatchHelper scriptGlobal;
  IF_FAILED_RET(m_ScriptEngine->GetScriptDispatch(NULL, &scriptGlobal));
  CComPtr<IDispatch> pModuleExportsOb;
  IF_FAILED_RET(scriptGlobal.CreateObject(L"Object", &pModuleExportsOb));

  // inject CommonJS objects
  script.SetPropertyByRef(L"require", CComVariant(pModuleRequireOb));
  script.SetPropertyByRef(L"module", CComVariant(pModule));
  script.SetPropertyByRef(L"exports", CComVariant(pModuleExportsOb));

  CComVariant vtSalsita;
  HRESULT hr = GetSalsitaObject(&vtSalsita);
  if (SUCCEEDED(hr))
  {
    script.SetPropertyByRef(L"salsita", vtSalsita);
  }

  // now run the module
  m_Application.EnterModule(sModuleID);
  hr = LoadScriptFile(sFilename, sModuleID);
  if (SUCCEEDED(hr))
  {
    m_ScriptEngine->SetScriptState(SCRIPTSTATE_CONNECTED);
  }
  m_Application.ExitModule();

  return S_OK;
}
Exemple #12
0
/*
================
LoadMapFile
================
*/
void Q2_LoadMapFile(char *filename)
{
	int      i;
	script_t *script;

	Log_Print("-- Q2_LoadMapFile --\n");
#ifdef ME
	//loaded map type
	loadedmaptype = MAPTYPE_QUAKE2;
	//reset the map loading
	ResetMapLoading();
#endif //ME

	script = LoadScriptFile(filename);
	if (!script)
	{
		Log_Print("couldn't open %s\n", filename);
		return;
	} //end if
	  //white spaces and escape characters inside a string are not allowed
	SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES |
	               SCFL_NOSTRINGESCAPECHARS |
	               SCFL_PRIMITIVE);

	nummapbrushsides = 0;
	num_entities     = 0;

	while (Q2_ParseMapEntity(script))
	{
	}

	ClearBounds(map_mins, map_maxs);
	for (i = 0 ; i < entities[0].numbrushes ; i++)
	{
		if (mapbrushes[i].mins[0] > 4096)
		{
			continue;   // no valid points
		}
		AddPointToBounds(mapbrushes[i].mins, map_mins, map_maxs);
		AddPointToBounds(mapbrushes[i].maxs, map_mins, map_maxs);
	} //end for

	PrintMapInfo();

	//free the script
	FreeScript(script);
//	TestExpandBrushes ();
	//
	Q2_CreateMapTexinfo();
} //end of the function Q2_LoadMapFile
Exemple #13
0
/*
 * @brief
 */
void LoadMapFile(const char *file_name) {
	int32_t subdivide;
	int32_t i;

	Com_Verbose("--- LoadMapFile ---\n");

	LoadScriptFile(file_name);

	memset(map_brushes, 0, sizeof(map_brush_t) * MAX_BSP_BRUSHES);
	num_map_brushes = 0;

	memset(map_brush_sides, 0, sizeof(side_t) * MAX_BSP_SIDES);
	num_map_brush_sides = 0;

	memset(map_brush_textures, 0, sizeof(map_brush_texture_t) * MAX_BSP_SIDES);

	memset(map_planes, 0, sizeof(map_plane_t) * MAX_BSP_PLANES);
	num_map_planes = 0;

	num_entities = 0;
	while (ParseMapEntity()) {
	}

	subdivide = atoi(ValueForKey(&entities[0], "subdivide"));

	if (subdivide >= 256 && subdivide <= 2048) {
		Com_Verbose("Using subdivide %d from worldspawn.\n", subdivide);
		subdivide_size = subdivide;
	}

	ClearBounds(map_mins, map_maxs);
	for (i = 0; i < entities[0].num_brushes; i++) {
		if (map_brushes[i].mins[0] > MAX_WORLD_COORD)
			continue; // no valid points
		AddPointToBounds(map_brushes[i].mins, map_mins, map_maxs);
		AddPointToBounds(map_brushes[i].maxs, map_mins, map_maxs);
	}

	Com_Verbose("%5i brushes\n", num_map_brushes);
	Com_Verbose("%5i clip brushes\n", c_clip_brushes);
	Com_Verbose("%5i total sides\n", num_map_brush_sides);
	Com_Verbose("%5i box bevels\n", c_box_bevels);
	Com_Verbose("%5i edge bevels\n", c_edge_bevels);
	Com_Verbose("%5i entities\n", num_entities);
	Com_Verbose("%5i planes\n", num_map_planes);
	Com_Verbose("%5i area portals\n", c_area_portals);
	Com_Verbose("size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\n", map_mins[0], map_mins[1],
			map_mins[2], map_maxs[0], map_maxs[1], map_maxs[2]);
}
Exemple #14
0
bool LoadScriptFile (const char *name, bool include, int type)
{
	int lumpnum = Wads.CheckNumForName (name);
	FileReader *lump;

	if (lumpnum < 0)
	{
		return false;
	}
	lump = Wads.ReopenLumpNum (lumpnum);

	bool res = LoadScriptFile(lumpnum, lump, Wads.LumpLength(lumpnum), include, type);
	delete lump;
	return res;
}
Exemple #15
0
/*
=================
ScrewUpFile
=================
*/
void ScrewUpFile (char *oldfile, char *newfile)
{
	FILE *fp;
	script_t *script;
	token_t token;
	replacefunc_t *f;
	char *ptr;

	printf( "screwing up file %s\n", oldfile );
	script = LoadScriptFile( oldfile );
	if ( !script ) {
		Error( "error opening %s\n", oldfile );
	}
	fp = fopen( newfile, "wb" );
	if ( !fp ) {
		Error( "error opening %s\n", newfile );
	}
	//
	while ( PS_ReadToken( script, &token ) )
	{
		WriteWhiteSpace( fp, script );
		if ( token.type == TT_NAME )
		{
			f = FindFunctionName( token.string );
			if ( f ) {
				ptr = f->newname;
			} else { ptr = token.string;}
			while ( *ptr )
			{
				fputc( *ptr, fp );
				ptr++;
			} //end while
		} //end if
		else
		{
			WriteString( fp, script );
		} //end else
	} //end while
	WriteWhiteSpace( fp, script );
	FreeMemory( script );
	fclose( fp );
} //end of the function ScrewUpFile
Exemple #16
0
void CPigEngine::AddScriptFile(const WIN32_FIND_DATA* pffd,
  tstring strFileName)
{
  // Create a new CPigBehaviorScriptType object
  CComObject<CPigBehaviorScriptType>* pScript = NULL;
  HRESULT hr = pScript->CreateInstance(&pScript);
  ZSucceeded(hr);
  if (SUCCEEDED(hr))
  {
    // AddRef the new object
    pScript->AddRef();

    // Initialize the new object
    LoadScriptFile(pScript, pffd, strFileName);

    // Add the new object to the map of scripts
    XLock lock(this);
    m_mapScripts.insert(std::make_pair(strFileName, pScript));
  }
}
Exemple #17
0
/*
=================
ProcessLumpyScript

Loads a script file, then grabs everything from it
=================
*/
void ProcessLumpyScript (char *basename)
{
	char            script[256];

	printf ("qlumpy script: %s\n",basename);
	
//
// create default destination directory
//
	strcpy (destfile, ExpandPath(basename));
	StripExtension (destfile);
	strcat (destfile,".wad");		// unless the script overrides, save in cwd

//
// save in a wadfile by default
//
	savesingle = false;
	grabbed = 0;
	outputcreated = false;
	
	
//
// read in the script file
//
	strcpy (script, basename);
	DefaultExtension (script, ".ls");
	LoadScriptFile (script);
	
	strcpy (basepath, basename);
	
	ParseScript ();				// execute load / grab commands
	
	if (!savesingle)
	{
		WriteWad (do16bit);				// write out the wad directory
		printf ("%i lumps grabbed in a wad file\n",grabbed);
	}
	else
		printf ("%i lumps written seperately\n",grabbed);
}
Exemple #18
0
/*
================
LoadMapFile
================
*/
void LoadMapFile (char *filename)
{		
	int		i;

	qprintf ("--- LoadMapFile ---\n");

	LoadScriptFile (filename);

	nummapbrushsides = 0;
	num_entities = 0;
	
	while (ParseMapEntity ())
	{
	}

	ClearBounds (map_mins, map_maxs);
	for (i=0 ; i<entities[0].numbrushes ; i++)
	{
		if (mapbrushes[i].mins[0] > 4096)
			continue;	// no valid points
		AddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs);
		AddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs);
	}

	qprintf ("%5i brushes\n", nummapbrushes);
	qprintf ("%5i clipbrushes\n", c_clipbrushes);
	qprintf ("%5i total sides\n", nummapbrushsides);
	qprintf ("%5i boxbevels\n", c_boxbevels);
	qprintf ("%5i edgebevels\n", c_edgebevels);
	qprintf ("%5i entities\n", num_entities);
	qprintf ("%5i planes\n", nummapplanes);
	qprintf ("%5i areaportals\n", c_areaportals);
	qprintf ("size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\n", map_mins[0],map_mins[1],map_mins[2],
		map_maxs[0],map_maxs[1],map_maxs[2]);

//	TestExpandBrushes ();
}
Exemple #19
0
/*
==============
main
==============
*/
int main (int argc, char **argv)
{
	static	int		i;		// VC4.2 compiler bug if auto...
	char	path[1024];

  // using GtkRadiant's versioning next to Id's versioning
  printf ("Q3Data      - (c) 1999 Id Software Inc.\n");
  printf ("GtkRadiant  - v" RADIANT_VERSION " " __DATE__ "\n");

	ExpandWildcards (&argc, &argv);

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i], "-archive"))
		{
			archive = qtrue;
			strcpy (archivedir, argv[i+1]);
			printf ("Archiving source to: %s\n", archivedir);
			i++;
		}
		else if (!strcmp(argv[i], "-release"))
		{
			g_release = qtrue;
			strcpy (g_releasedir, argv[i+1]);
			printf ("Copy output to: %s\n", g_releasedir);
			i++;
		}
		else if ( !strcmp( argv[i], "-nostrips" ) )
		{
			g_stripify = qfalse;
			printf( "Not optimizing for strips\n" );
		}
		else if ( !strcmp( argv[i], "-writedir" ) )
		{
			strcpy( writedir, argv[i+1] );
			printf( "Write output to: %s\n", writedir );
			i++;
		}
		else if ( !strcmp( argv[i], "-verbose" ) )
		{
			g_verbose = qtrue;
		}
		else if ( !strcmp( argv[i], "-dump" ) )
		{
			printf( "Dumping contents of: '%s'\n", argv[i+1] );
			if ( strstr( argv[i+1], ".md3" ) )
			{
				MD3_Dump( argv[i+1] );
			}
			else
			{
				Error( "Do not know how to dump the contents of '%s'\n", argv[i+1] );
			}
			i++;
		}
		else if ( !strcmp( argv[i], "-3dsconvert" ) )
		{
      // NOTE TTimo this is broken, tried on a sample .3ds
      // what happens .. it calls the Convert3DStoMD3,
      // which calls the scriptlib function in non initialized state .. and crashes
			printf( "Converting %s.3DS to %s.MD3\n", argv[i+1], argv[i+1] );
			SetQdirFromPath( argv[i+1] );
      vfsInitDirectory( gamedir );
			Convert3DStoMD3( argv[i+1] );
			i++;
		}
		else if (!strcmp(argv[i], "-only"))
		{
			strcpy (g_only, argv[i+1]);
			printf ("Only grabbing %s\n", g_only);
			i++;
		}
		else if (!strcmp(argv[i], "-gamedir"))
		{
			strcpy(gamedir, argv[i+1]);
			i++;
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i == argc)
		Error ("usage: q3data [-archive <directory>] [-dump <file.md3>] [-release <directory>] [-only <model>] [-3dsconvert <file.3ds>] [-verbose] [file.qdt]");

	for ( ; i<argc ; i++)
	{
		printf ("--------------- %s ---------------\n", argv[i]);
		// load the script
		strcpy (path, argv[i]);
		DefaultExtension (path, ".qdt");
		if(!gamedir[0])
			SetQdirFromPath (path);
    // NOTE TTimo
    // q3data went through a partial conversion to use the vfs
    // it was never actually tested before 1.1.1
    // the code is still mostly using direct file access calls
    vfsInitDirectory( gamedir );
		LoadScriptFile (ExpandArg(path), -1);
		
		//
		// parse it
		//
		ParseScript ();

		// write out the last model
		FinishModel ( TYPE_UNKNOWN );
	}

	return 0;
}
Exemple #20
0
/*
==============
main
==============
*/
int main (int argc, char **argv)
{
	static	int		i;		// VC4.2 compiler bug if auto...
	char	path[1024];

	ExpandWildcards (&argc, &argv);

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i], "-archive"))
		{
			// -archive f:/quake2/release/dump_11_30
			archive = true;
			strcpy (archivedir, argv[i+1]);
			printf ("Archiving source to: %s\n", archivedir);
			i++;
		}
		else if (!strcmp(argv[i], "-release"))
		{
			g_release = true;
			strcpy (g_releasedir, argv[i+1]);
			printf ("Copy output to: %s\n", g_releasedir);
			i++;
		}
		else if (!strcmp(argv[i], "-compress"))
		{
			g_compress_pak = true;
			printf ("Compressing pakfile\n");
		}
		else if (!strcmp(argv[i], "-pak"))
		{
			g_release = true;
			g_pak = true;
			printf ("Building pakfile: %s\n", argv[i+1]);
			BeginPak (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i], "-only"))
		{
			strcpy (g_only, argv[i+1]);
			printf ("Only grabbing %s\n", g_only);
			i++;
		}
		else if (!strcmp(argv[i], "-3ds"))
		{
			do3ds = true;
			printf ("loading .3ds files\n");
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i >= argc)
		Error ("usage: qgrab [-archive <directory>] [-release <directory>] [-only <model>] [-3ds] file.qgr");

	if (do3ds)
		trifileext = ext_3ds;
	else
		trifileext = ext_tri;

	for ( ; i<argc ; i++)
	{
		printf ("--------------- %s ---------------\n", argv[i]);
		// load the script
		strcpy (path, argv[i]);
		DefaultExtension (path, ".qdt");
		SetQdirFromPath (path);
		LoadScriptFile (ExpandArg(path));
		
		//
		// parse it
		//
		ParseScript ();

		// write out the last model
		FinishModel ();
		FinishSprite ();
	}

	if (g_pak)
		FinishPak ();

	return 0;
}
Exemple #21
0
/*
==============
main
==============
*/
int main (int argc, char **argv)
{
	int			i;
	char		path[1024];
	char		*basedir;
	double		starttime, endtime;

	printf ("Qdata Plus : "__TIME__" "__DATE__"\n");

	starttime = I_FloatTime();
	basedir = NULL;

	TK_Init();
	ExpandWildcards (&argc, &argv);

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i], "-archive"))
		{
			// -archive f:/quake2/release/dump_11_30
			archive = true;
			strcpy (archivedir, argv[i+1]);
			printf ("Archiving source to: %s\n", archivedir);
			i++;
		}
		else if (!strcmp(argv[i], "-release"))
		{
			g_release = true;
			strcpy (g_releasedir, argv[i+1]);
			printf ("Copy output to: %s\n", g_releasedir);
			i++;
		}
		else if (!strcmp(argv[i], "-base"))
		{
			i++;
			basedir = argv[i];
		}
		else if (!strcmp(argv[i], "-compress"))
		{
			g_compress_pak = true;
			printf ("Compressing pakfile\n");
		}
		else if (!strcmp(argv[i], "-pak"))
		{
			g_release = true;
			g_pak = true;
			printf ("Building pakfile: %s\n", argv[i+1]);
			BeginPak (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i], "-only"))
		{
			strcpy (g_only, argv[i+1]);
			printf ("Only grabbing %s\n", g_only);
			i++;
		}
		else if (!strcmpi(argv[i], "-keypress"))
		{
			g_dokeypress = true;
		}
		else if (!strcmp(argv[i], "-3ds"))
		{
			do3ds = true;
			printf ("loading .3ds files\n");
		}
		else if (!strcmp(argv[i], "-materialfile"))
		{
			strcpy(g_materialFile, argv[i+1]);
			printf("Setting material file to %s\n", g_materialFile);
			i++;
		}
/*		else if (!strcmpi(argv[i], "-newgen"))
		{
			if (i < argc-4)
			{
				printf("run new triangle grouping routine here\n");
				NewGen(argv[i+1],argv[i+2],atoi(argv[i+3]),atoi(argv[i+4]));
			}
			else
			{
				printf("qdata -newskin <base.hrc> <skin.pcx> width height\n");
			}
			return 0;
		}
*/		else if (!strcmpi(argv[i], "-genskin"))
		{
			i++;
			if (i < argc-3)
			{
				GenSkin(argv[i],argv[i+1],atol(argv[i+2]),atol(argv[i+3]));
			}
			else
			{
				printf("qdata -genskin <base.hrc> <skin.pcx> <desired width> <desired height>\n");
			}
			return 0;
			
		}
		else if (!strcmpi(argv[i], "-noopts"))
		{
			g_no_opimizations = true;
			printf("not performing optimizations\n");
		}
		else if (!strcmpi(argv[i], "-md2"))
		{
			g_forcemodel = MODEL_MD2;
		}
		else if (!strcmpi(argv[i], "-fm"))
		{
			g_forcemodel = MODEL_FM;
		}
		else if (!strcmpi(argv[i], "-verbose"))
		{
			g_verbose = true;
		}
		else if (!strcmpi(argv[i], "-oldskin"))
		{
			g_allow_newskin = false;
		}
		else if (!strcmpi(argv[i], "-ignoreUV"))
		{
			g_ignoreTriUV = true;
		}
		else if (!strcmpi(argv[i], "-publish"))
		{
			g_publishOutput = true;
		}
		else if (!strcmpi(argv[i], "-nomkdir"))
		{
			g_nomkdir = true;
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i >= argc)
	{
		Error ("usage: qdata [-archive <directory>]\n"
			"             [-release <directory>]\n"
			"             [-base <directory>]\n"
			"             [-compress]\n"
			"             [-pak <file>]\n"
			"             [-only <model>]\n"
			"             [-keypress]\n"
			"             [-3ds]\n"
			"             [-materialfile <file>]\n"
			"             [-noopts]\n"
			"             [-md2]\n"
			"             [-fm]\n"
			"             [-verbose]\n"
			"             [-ignoreUV]\n"
			"             [-oldskin]\n"
			"             [-publish]\n"
			"             [-nomkdir]\n"
			"             file.qdt\n"
			"or\n"
			"       qdata -genskin <base.hrc> <skin.pcx> <desired width> <desired height>");
	}

	if (do3ds)
		trifileext = ext_3ds;
	else
		trifileext = ext_tri;

	for ( ; i<argc ; i++)
	{
		printf ("--------------- %s ---------------\n", argv[i]);
		// load the script
		strcpy (path, argv[i]);
		DefaultExtension (path, ".qdt");
		DefaultExtension(g_materialFile, ".mat");
		SetQdirFromPath (path);

		printf("workingdir='%s'\n", gamedir);
		if (basedir)
		{
			qdir[0] = 0;
			g_outputDir = basedir;
		}

		printf("outputdir='%s'\n", g_outputDir);

		QFile_ReadMaterialTypes(g_materialFile);
		LoadScriptFile (ExpandArg(path));
		
		//
		// parse it
		//
		ParseScript ();

		// write out the last model
		FinishModel ();
		FMFinishModel ();
		FinishSprite ();
	}

	if (total_textures)
	{
		printf("\n");
		printf("Total textures processed: %d\n",total_textures);
		printf("Average size: %d x %d\n",total_x / total_textures, total_y / total_textures);
	}

	if (g_pak)
		FinishPak ();

	endtime = I_FloatTime();
	printf("Time elapsed:  %f\n", endtime-starttime);
	
	if (g_dokeypress)
	{
		printf("Success! ... Hit a key: ");
		getchar();
	}

	return 0;
}
Exemple #22
0
static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool include, int type)
{
	int i;
	DWORD prevSpeakerType;
	FStrifeDialogueNode *node;
	char buffer[4];

	lump->Read(buffer, 4);
	lump->Seek(-4, SEEK_CUR);

	// The binary format is so primitive that this check is enough to detect it.
	bool isbinary = (buffer[0] == 0 || buffer[1] == 0 || buffer[2] == 0 || buffer[3] == 0);

	if ((type == 1 && !isbinary) || (type == 2 && isbinary))
	{
		DPrintf("Incorrect data format for %s.", Wads.GetLumpFullName(lumpnum));
		return false;
	}

	if (!isbinary)
	{
		P_ParseUSDF(lumpnum, lump, numnodes);
	}
	else 
	{
		if (!include)
		{
			LoadScriptFile("SCRIPT00", true, 1);
		}
		if (!(gameinfo.flags & GI_SHAREWARE))
		{
			// Strife scripts are always a multiple of 1516 bytes because each entry
			// is exactly 1516 bytes long.
			if (numnodes % 1516 != 0)
			{
				DPrintf("Incorrect data format for %s.", Wads.GetLumpFullName(lumpnum));
				return false;
			}
			numnodes /= 1516;
		}
		else
		{
			// And the teaser version has 1488-byte entries.
			if (numnodes % 1488 != 0)
			{
				DPrintf("Incorrect data format for %s.", Wads.GetLumpFullName(lumpnum));
				return false;
			}
			numnodes /= 1488;
		}

		prevSpeakerType = 0;

		for (i = 0; i < numnodes; ++i)
		{
			if (!(gameinfo.flags & GI_SHAREWARE))
			{
				node = ReadRetailNode (lump, prevSpeakerType);
			}
			else
			{
				node = ReadTeaserNode (lump, prevSpeakerType);
			}
			node->ThisNodeNum = StrifeDialogues.Push(node);
		}
	}
	return true;
}
Exemple #23
0
void ScrSys_ChangeLocation(uint8_t w, uint8_t r,uint8_t v1, uint8_t v2, int32_t X, bool force_all) // world / room / view
{
    //reversed from 0x004246C7

    Locate temp;
    temp.World = w;
    temp.Room  = r;
    temp.Node  = v1;
    temp.View  = v2;
    temp.X     = X;

    if (GetgVarInt(SLOT_WORLD)!= SystemWorld ||
        GetgVarInt(SLOT_ROOM) != SystemRoom  )
    {
        if (temp.World == SystemWorld &&
            temp.Room  == SystemRoom)
        {
            SetDirectgVarInt(SLOT_MENU_LASTWORLD    , GetgVarInt(SLOT_WORLD));
            SetDirectgVarInt(SLOT_MENU_LASTROOM     , GetgVarInt(SLOT_ROOM));
            SetDirectgVarInt(SLOT_MENU_LASTNODE     , GetgVarInt(SLOT_NODE));
            SetDirectgVarInt(SLOT_MENU_LASTVIEW     , GetgVarInt(SLOT_VIEW));
            SetDirectgVarInt(SLOT_MENU_LASTVIEW_POS , GetgVarInt(SLOT_VIEW_POS));
        }
        else
        {
            SetDirectgVarInt(SLOT_LASTWORLD    , GetgVarInt(SLOT_WORLD));
            SetDirectgVarInt(SLOT_LASTROOM     , GetgVarInt(SLOT_ROOM));
            SetDirectgVarInt(SLOT_LASTNODE     , GetgVarInt(SLOT_NODE));
            SetDirectgVarInt(SLOT_LASTVIEW     , GetgVarInt(SLOT_VIEW));
            SetDirectgVarInt(SLOT_LASTVIEW_POS , GetgVarInt(SLOT_VIEW_POS));
        }
    }


    ScrSys_ClearStateBox();

    if (temp.World == SaveWorld && temp.Room  == SaveRoom  &&
        temp.Node  == SaveNode  && temp.View  == SaveView)
    {
        //Save all to buffer
        ScrSys_PrepareSaveBuffer();
    }

    char buf[32];
    char tm[5];


    if (temp.View  != GetgVarInt(SLOT_VIEW)  ||
        temp.Node  != GetgVarInt(SLOT_NODE)  ||
        temp.Room  != GetgVarInt(SLOT_ROOM)  ||
        temp.World != GetgVarInt(SLOT_WORLD) ||
        force_all  || view == NULL)
    {

        ScrSys_FlushResourcesByOwner(view);

        FlushPuzzleList(view);
        FlushControlList(ctrl);

        tm[0]=temp.World;
        tm[1]=temp.Room;
        tm[2]=temp.Node;
        tm[3]=temp.View;
        tm[4]=0;
        sprintf(buf,"%s.scr",tm);
        FManNode *fil = FindInBinTree(buf);
        if (fil != NULL)
            LoadScriptFile(view,fil,true,ctrl);

    }

    if (temp.Room  != GetgVarInt(SLOT_ROOM)   ||
        temp.World != GetgVarInt(SLOT_WORLD)  ||
        force_all  || room == NULL)
    {
        ScrSys_FlushResourcesByOwner(room);

        FlushPuzzleList(room);

        tm[0]=temp.World;
        tm[1]=temp.Room;
        tm[2]=0;
        sprintf(buf,"%s.scr",tm);

        FManNode *fil = FindInBinTree(buf);
        if (fil != NULL)
            LoadScriptFile(room,fil,false,NULL);
    }


    if (temp.World != GetgVarInt(SLOT_WORLD) ||
        force_all  || world == NULL)
    {
        ScrSys_FlushResourcesByOwner(world);

        FlushPuzzleList(world);

        tm[0]=temp.World;
        tm[1]=0;
        sprintf(buf,"%s.scr",tm);

        FManNode *fil = FindInBinTree(buf);
        if (fil != NULL)
            LoadScriptFile(world,fil,false,NULL);

        Mouse_ShowCursor();
    }

    FillStateBoxFromList(uni);
    FillStateBoxFromList(view);
    FillStateBoxFromList(room);
    FillStateBoxFromList(world);

    SetgVarInt(SLOT_WORLD    , w);
    SetgVarInt(SLOT_ROOM     , r);
    SetgVarInt(SLOT_NODE     , v1);
    SetgVarInt(SLOT_VIEW     , v2);
    SetgVarInt(SLOT_VIEW_POS , X);

    menu_SetMenuBarVal(0xFFFF);

    BreakExecute = false;
}
Exemple #24
0
/**
 * @sa WriteMapFile
 * @sa ParseMapEntity
 */
void LoadMapFile (const char* filename)
{
	Verb_Printf(VERB_EXTRA, "--- LoadMapFile ---\n");

	LoadScriptFile(filename);

	OBJZERO(mapbrushes);
	nummapbrushes = 0;

	OBJZERO(brushsides);
	nummapbrushsides = 0;

	OBJZERO(side_brushtextures);

	OBJZERO(mapplanes);

	num_entities = 0;
	/* Create this shortcut to mapTiles[0] */
	curTile = &mapTiles.mapTiles[0];
	/* Set the number of tiles to 1. This is fix for ufo2map right now. */
	mapTiles.numTiles = 1;

	char entityString[MAX_TOKEN_CHARS];
	const char* ump = GetUMPName(filename);
	if (ump != nullptr)
		ParseUMP(ump, entityString, false);

	while (ParseMapEntity(filename, entityString));

	int subdivide = atoi(ValueForKey(&entities[0], "subdivide"));
	if (subdivide >= 256 && subdivide <= 2048) {
		Verb_Printf(VERB_EXTRA, "Using subdivide %d from worldspawn.\n", subdivide);
		config.subdivideSize = subdivide;
	}

	if (footstepsCnt)
		Com_Printf("Generated footstep file with %i entries\n", footstepsCnt);
	if (materialsCnt)
		Com_Printf("Generated material file with %i entries\n", materialsCnt);

	vec3_t map_mins, map_maxs;
	ClearBounds(map_mins, map_maxs);
	for (int i = 0; i < entities[0].numbrushes; i++) {
		if (mapbrushes[i].mbBox.mins[0] > MAX_WORLD_WIDTH)
			continue;	/* no valid points */
		AddPointToBounds(mapbrushes[i].mbBox.mins, map_mins, map_maxs);
		AddPointToBounds(mapbrushes[i].mbBox.maxs, map_mins, map_maxs);
	}

	/* save a copy of the brushes */
	memcpy(mapbrushes + nummapbrushes, mapbrushes, sizeof(mapbrush_t) * nummapbrushes);

	Verb_Printf(VERB_EXTRA, "%5i brushes\n", nummapbrushes);
	Verb_Printf(VERB_EXTRA, "%5i total sides\n", nummapbrushsides);
	Verb_Printf(VERB_EXTRA, "%5i boxbevels\n", c_boxbevels);
	Verb_Printf(VERB_EXTRA, "%5i edgebevels\n", c_edgebevels);
	Verb_Printf(VERB_EXTRA, "%5i entities\n", num_entities);
	Verb_Printf(VERB_EXTRA, "%5i planes\n", nummapplanes);
	Verb_Printf(VERB_EXTRA, "size: %5.0f,%5.0f,%5.0f to %5.0f,%5.0f,%5.0f\n",
		map_mins[0], map_mins[1], map_mins[2], map_maxs[0], map_maxs[1], map_maxs[2]);
}
void ReadSetup (void)
{
   char filename[ 128 ];

   GetPathFromEnvironment( filename, ApogeePath, CONFIG );
   if (access (filename, 0) == 0)
   {
      LoadScriptFile (filename);

      // Skip MODEMNAME
      GetToken (true);

      // Skip MODEMNAME string
      GetTokenEOL (false);


      // Get Initstring

      GetToken (true);

      CheckParameter ("MODEMINITSTR", filename);

      GetTokenEOL (false);

      if (name[0] != '~')
         strcpy (&initstring[0], &name[0]);
      else if (usemodem==true)
         Error("No INITSTRING defined in SETUP.ROT please run SETUP.EXE\n");
      else
         strcpy (&initstring[0], "ATZ\0");

      // Get Hangupstring

      GetToken (true);

      CheckParameter ("MODEMHANGUP", filename);

      GetTokenEOL (false);

      if (name[0] != '~')
         strcpy (&hangupstring[0], &name[0]);
      else if (usemodem==true)
         Error("No HANGUPSTRING defined in SETUP.ROT please run SETUP.EXE\n");
      else
         strcpy (&hangupstring[0], "ATZ\0");

      GetToken (true);

      CheckParameter ("BAUDRATE", filename);

      GetToken (false);

      baudrate = atol (token);

      GetToken (true);

      CheckParameter ("COMPORT", filename);

      GetToken (false);

      if (strcmpi (token, "~"))
         comport = atoi (token);
      else
         comport = -1;

      GetToken (true);

      CheckParameter ("IRQ", filename);

      GetToken (false);

      if (strcmpi (token, "~"))
         irq = atoi (token);
      else
         irq = -1;

      GetToken (true);

      CheckParameter ("UART", filename);

      GetToken (false);

      if (strcmpi (token, "~"))
         sscanf(token,"%x", &uart);
      else
         uart = -1;

      // Get Pulse parameter

      GetToken (true);

      CheckParameter ("PULSE", filename);

      GetToken (false);

      if (!(strcmpi (token, "YES")))
         pulse=true;
      else
         pulse=false;

      free (scriptbuffer);
   }
   else
   {
      Error ("Cannot find %s Please run SETUP.EXE\n",filename);
   }
   GetPathFromEnvironment( filename, ApogeePath, ROTT );
   if (access (filename, 0) == 0)
      {
      LoadScriptFile (filename);
      GetToken (true);
      CheckParameter ("PHONENUMBER", filename);
      GetTokenEOL (false);

      if (name[0] != '~')
         strcpy (&dialstring[0], &name[0]);
      else
         dialstring[0]=0;
      free (scriptbuffer);
      }
   else
   {
      Error ("Cannot find %s Please run SETUP.EXE\n",filename);
   }

}
Exemple #26
0
int CBoxScript::ParseScriptText(LPCSTR pstrText, int nCount, CStringA& strScriptText, int nIncludeFlagIndex)
{
	CStringA strTempText;
	if(nCount >= 2 && (BYTE)pstrText[0] == 0xff && (BYTE)pstrText[1] == 0xfe)
	{
/*		int _nTempCount = WideCharToMultiByte(_AtlGetConversionACP(), 0, LPWSTR(pstrText + 2), (nCount - 2) / 2, NULL, 0, NULL, NULL);
		LPSTR _pstr = strTempText.GetBuffer(_nTempCount);

		WideCharToMultiByte(_AtlGetConversionACP(), 0, LPWSTR(pstrText + 2), (nCount - 2) / 2, _pstr, _nTempCount, NULL, NULL);
		strTempText.ReleaseBuffer(_nTempCount);
*/

//发现是Unicode则检查是否已经存在CodePage,存在就转换到当前CodePage,否则转换成UTF8同时设定m_CodePage为65001
		if (m_uiCodePage == 0)
			m_uiCodePage = CP_UTF8;

		int _nTempCount = WideCharToMultiByte(m_uiCodePage, 0, LPWSTR(pstrText + 2), (nCount - 2) / 2, NULL, 0, NULL, NULL);
		LPSTR _pstr = strTempText.GetBuffer(_nTempCount);

		WideCharToMultiByte(m_uiCodePage, 0, LPWSTR(pstrText + 2), (nCount - 2) / 2, _pstr, _nTempCount, NULL, NULL);
		strTempText.ReleaseBuffer(_nTempCount);

		pstrText = strTempText;
		nCount = strTempText.GetLength();
	}
	else if(nCount >= 3 && (BYTE)pstrText[0] == 0xEF && (BYTE)pstrText[1] == 0xBB && (BYTE)pstrText[2] == 0xBF)
	{
		pstrText += 3;
		nCount -= 3;

		if (m_uiCodePage && m_uiCodePage != CP_UTF8)
		{
			CStringW strTempTextW;
			int _nTempCount = MultiByteToWideChar(CP_UTF8, 0, pstrText, nCount, NULL, 0);
			LPWSTR _pstrW = strTempTextW.GetBuffer(_nTempCount);

			MultiByteToWideChar(CP_UTF8, 0, pstrText, nCount, _pstrW, _nTempCount);
			strTempTextW.ReleaseBuffer(_nTempCount);
			
			_nTempCount = WideCharToMultiByte(m_uiCodePage, 0, strTempTextW, strTempTextW.GetLength(), NULL, 0, NULL, NULL);
			LPSTR _pstr = strTempText.GetBuffer(_nTempCount);

			WideCharToMultiByte(m_uiCodePage, 0, strTempTextW, strTempTextW.GetLength(), _pstr, _nTempCount, NULL, NULL);
			strTempText.ReleaseBuffer(_nTempCount);

			pstrText = strTempText;
			nCount = strTempText.GetLength();
		}
		else
			m_uiCodePage = CP_UTF8;
	}
	else
	{
		UINT uiCodePage = ParseScriptTextCodePage(pstrText, nCount);
		if (uiCodePage == 0)
			uiCodePage = GetACP();

		//if (m_uiCodePage == 0)
		//	m_uiCodePage = CP_UTF8;

		if (m_uiCodePage && m_uiCodePage != uiCodePage)
		{
			CStringW strTempTextW;
			int _nTempCount = MultiByteToWideChar(uiCodePage, 0, pstrText, nCount, NULL, 0);
			LPWSTR _pstrW = strTempTextW.GetBuffer(_nTempCount);

			MultiByteToWideChar(uiCodePage, 0, pstrText, nCount, _pstrW, _nTempCount);
			strTempTextW.ReleaseBuffer(_nTempCount);
			
			_nTempCount = WideCharToMultiByte(m_uiCodePage, 0, strTempTextW, strTempTextW.GetLength(), NULL, 0, NULL, NULL);
			LPSTR _pstr = strTempText.GetBuffer(_nTempCount);

			WideCharToMultiByte(m_uiCodePage, 0, strTempTextW, strTempTextW.GetLength(), _pstr, _nTempCount, NULL, NULL);
			strTempText.ReleaseBuffer(_nTempCount);

			pstrText = strTempText;
			nCount = strTempText.GetLength();
		}
		else
		{
			m_uiCodePage = uiCodePage;
		}
	}

	static struct
	{
		char *pstrName;
		int nSize;
	}CmdName[] =
	{
		{"#include", 8},
		{"#language", 9},
		{"#debug", 6},
		{"#timeout", 8},
		{"#transaction", 12},
		{"#codepage", 9}
	};
	#define CMD_COUNT (sizeof(CmdName) / sizeof(CmdName[0]))
	int i;
	LPCSTR pstrTemp, pstrTemp1;
	int nTempCount;
	int nLineCount = 1;

	while(nCount > 0 && IsBlank(pstrText[0]))
	{
		if(pstrText[0] == '\n')
			nLineCount ++;

		pstrText ++;
		nCount --;
	}

	while(nCount > 0 && pstrText[0] == '#')
	{
		for(i = 0; i < CMD_COUNT; i ++)
			if(nCount > CmdName[i].nSize &&
				!_strnicmp(pstrText, CmdName[i].pstrName, CmdName[i].nSize) &&
				IsBlankChar(pstrText[CmdName[i].nSize]))
				break;

		if(i == CMD_COUNT)
			break;

		pstrText += CmdName[i].nSize;
		nCount -= CmdName[i].nSize;

		while(nCount > 0 && IsBlankChar(pstrText[0]))
		{
			pstrText ++;
			nCount --;
		}

		if(nCount > 0 && pstrText[0] == '\"')
		{
			pstrText ++;
			nCount --;
		}

		pstrTemp = pstrText;
		nTempCount = nCount;
		while(nTempCount > 0 && !IsLineChar(pstrTemp[0]))
		{
			pstrTemp ++;
			nTempCount --;
		}

		pstrTemp1 = pstrTemp;
		while(pstrTemp1 > pstrText && IsBlankChar(pstrTemp1[0]))
			pstrTemp1 --;

		if(pstrTemp1 > pstrText && pstrTemp1[-1] == '\"')
			pstrTemp1 --;

		CStringA strValue;

		strValue.SetString(pstrText, (int)(pstrTemp1 - pstrText));

		pstrText = pstrTemp;
		nCount = nTempCount;

		switch(i)
		{
		case 0:
			strValue.MakeLower();
			if(LoadScriptFile(BOX_CA2CT(strValue), strScriptText, nLineCount))
				return 500;
			break;
		case 1:
			m_strLanguage = strValue;
			break;
		case 2:
			m_bEnableDebug = !strValue.CompareNoCase("on") || !strValue.CompareNoCase("true");
			if(!strValue.CompareNoCase("step"))
				m_bStepDebug = TRUE;
			break;
		case 3:
			m_pHost->m_nTimeout = atoi(strValue);
			break;
		case 4:
			if(!strValue.CompareNoCase("Required"))
                m_nTransaction = 3;
			else if(!strValue.CompareNoCase("Requires_New"))
				m_nTransaction = 2;
			else if(!strValue.CompareNoCase("Supported"))
				m_nTransaction = 1;
			else if(!strValue.CompareNoCase("Not_Supported"))
				m_nTransaction = 0;
			break;
		case 5:
			//(uiCodePage)
			break;
		}

		while(nCount > 0 && IsBlank(pstrText[0]))
		{
			if(pstrText[0] == '\n')
				nLineCount ++;

			pstrText ++;
			nCount --;
		}
	}

	AddLineMap(nIncludeFlagIndex, nLineCount);

	strScriptText.Append(pstrText, nCount);
	strScriptText += _T("\r\n");

	m_nScriptLine ++;

	pstrTemp = pstrText;
	nTempCount = nCount;
	while(nTempCount > 0)
	{
		if(pstrTemp[0] == '\n')
			m_nScriptLine ++;

		pstrTemp ++;
		nTempCount --;
	}

	return 0;
}
void ProcessVCD( CUtlDict< VCDList, int >& database, CUtlSymbol& vcdname )
{
    // vprint( 0, "Processing '%s'\n", g_Analysis.symbols.String( vcdname ) );

    // Load the .vcd
    char fullname[ 512 ];
    Q_snprintf( fullname, sizeof( fullname ), "%s", g_Analysis.symbols.String( vcdname ) );

    LoadScriptFile( fullname );

    CChoreoScene *scene = ChoreoLoadScene( fullname, NULL, &g_TokenProcessor, Con_Printf );
    if ( scene )
    {
        bool first = true;
        // Now iterate the events looking for speak events
        int c = scene->GetNumEvents();
        for ( int i = 0; i < c; i++ )
        {
            CChoreoEvent *e = scene->GetEvent( i );

            if ( e->GetType() == CChoreoEvent::MOVETO )
            {
                SpewMoveto( first, fullname, e );
                first = false;
            }

            if ( e->GetType() != CChoreoEvent::SPEAK )
                continue;

            // Look up sound in sound emitter system
            char const *wavename = soundemitter->GetWavFileForSound( e->GetParameters(), NULL );
            if ( !wavename || !wavename[ 0 ] )
            {
                continue;
            }

            char fullwavename[ 512 ];
            Q_snprintf( fullwavename, sizeof( fullwavename ), "%ssound\\%s",
                        gamedir, wavename );
            Q_FixSlashes( fullwavename );

            // Now add to proper slot
            VCDList *entry = NULL;

            // Add vcd to database
            int slot = database.Find( fullwavename );
            if ( slot == database.InvalidIndex() )
            {
                VCDList nullEntry;
                slot = database.Insert( fullwavename, nullEntry );
            }

            entry = &database[ slot ];
            if ( entry->vcds.Find( vcdname ) == entry->vcds.InvalidIndex() )
            {
                entry->vcds.AddToTail( vcdname );
            }
        }

        if ( vcdonly )
        {
            CheckForOverlappingFlexTracks( scene );
        }
    }

    delete scene;
}
Exemple #28
0
long CBoxScript::Load(LPCTSTR pstrFile)
{
	m_error.Clear();

	m_strBasePath.Empty();
	m_arrayIncludeFlags.RemoveAll();

	m_nDiskFileCount = 0;
	m_nCacheFileCount = 0;
	m_nScriptLine = 0;

	CScriptHost* pNowScript = CScriptHost::GetCurrentScript();

	if(pNowScript != NULL)
		m_strBasePath = pNowScript->m_strScriptName;

	CBoxPath path;

	if(!m_strBasePath.IsEmpty() && pstrFile[0] != _T('\\'))
		path.Combine(m_strBasePath.Left(m_strBasePath.ReverseFind(_T('\\')) + 1), pstrFile);
	else path.Combine(pstrFile);

	InitScript();

	CStringA strScriptText;
	int iResult = LoadScriptFile(path.m_strPath, strScriptText);
	m_strBasePath.Empty();

	if(iResult != 0)
		return iResult;

	if(m_nCacheFileCount)
	{
		m_bStepDebug = FALSE;
		m_bEnableDebug = FALSE;
	}

	m_pHost->SetFileName(path.m_strPath);

	if(!m_pHost->Create(m_strLanguage, m_bEnableDebug, m_bStepDebug, m_nTransaction))
	{
		GetScriptErrorInfo();
		return 500;
	}

	m_pHost->SetScriptSite();

	if (m_uiCodePage)
	{
		CStringW strTempText;
		int _nTempCount = MultiByteToWideChar(m_uiCodePage, 0, strScriptText, strScriptText.GetLength(), NULL, 0);
		LPWSTR _pstr = strTempText.GetBuffer(_nTempCount);

		MultiByteToWideChar(m_uiCodePage, 0, strScriptText, strScriptText.GetLength(), _pstr, _nTempCount);
		strTempText.ReleaseBuffer(_nTempCount);
		
		if(m_pHost->Load(strTempText) != S_OK)
		{
			GetScriptErrorInfo();
			return 500;
		}
	}
	else
	{
		if(m_pHost->Load(BOX_CA2CT(strScriptText)) != S_OK)
		{
			GetScriptErrorInfo();
			return 500;
		}
	}

	if(AfterParse() != 0)
		return 500;

	return 0;
}