Пример #1
0
///////////////////////////////////////////////////////////////////////
// Read from disk file
///////////////////////////////////////////////////////////////////////
void ACEND_LoadNodes(void)
{
	FILE *pIn;
	int i,j;
	char tempname[MAX_QPATH] = "";
	char filename[MAX_QPATH] = "";
	//char filename[60];
	int version;

	// Knightmare- rewote this
	sprintf (tempname, "nav/%s.nod", level.mapname);
	GameDirRelativePath (tempname, filename);
	//strcpy(filename,"ace\\nav\\");
	//strcat(filename,level.mapname);
	//strcat(filename,".nod");

	if((pIn = fopen(filename, "rb" )) == NULL)
    {
		// Create item table
		safe_bprintf(PRINT_MEDIUM, "ACE: No node file found, creating new one...");
		ACEIT_BuildItemNodeTable(false);
		safe_bprintf(PRINT_MEDIUM, "done.\n");
		return; 
	}

	// determine version
	fread(&version,sizeof(int),1,pIn); // read version
	
	if(version == 1) 
	{
		safe_bprintf(PRINT_MEDIUM,"ACE: Loading node table...");

		fread(&numnodes,sizeof(int),1,pIn); // read count
		fread(&num_items,sizeof(int),1,pIn); // read facts count
		
		fread(nodes,sizeof(node_t),numnodes,pIn);

		for(i=0;i<numnodes;i++)
			for(j=0;j<numnodes;j++)
				fread(&path_table[i][j],sizeof(int16_t),1,pIn); // write count
	
		// Knightmare- is this needed?  It's all re-built anyway, and may cause problems.
		// The item_table array is better left blank.
		//fread(item_table,sizeof(item_table_t),num_items,pIn);
		fclose(pIn);
	}
	else
	{
		// Create item table
		safe_bprintf(PRINT_MEDIUM, "ACE: No node file found, creating new one...");
		ACEIT_BuildItemNodeTable(false);
		safe_bprintf(PRINT_MEDIUM, "done.\n");
		return; // bail
	}
	
	safe_bprintf(PRINT_MEDIUM, "done.\n");
	
	ACEIT_BuildItemNodeTable(true);

}
Пример #2
0
///////////////////////////////////////////////////////////////////////
// Read from disk file
///////////////////////////////////////////////////////////////////////
void ACEND_LoadNodes(void)
{
	FILE *pIn;
	int i,j;
	char filename[60];
	int version;

	strcpy(filename,"ace_botroutes/");
	strcat(filename,level.mapname);
	strcat(filename,".nod");

	if((pIn = fopen(filename, "rb" )) == NULL)
    {
		// Create item table
		safe_bprintf(PRINT_MEDIUM, "ACE: No node file found, creating new one...");
		ACEIT_BuildItemNodeTable(false);
		safe_bprintf(PRINT_MEDIUM, "done.\n");
		return; 
	}

	// determin version
	fread(&version,sizeof(int),1,pIn); // read version
	
	if(version == 1) 
	{
		safe_bprintf(PRINT_MEDIUM,"ACE: Loading node table...");

		fread(&numnodes,sizeof(int),1,pIn); // read count
		fread(&num_items,sizeof(int),1,pIn); // read facts count
		
		fread(nodes,sizeof(node_t),numnodes,pIn);

		for(i=0;i<numnodes;i++)
			for(j=0;j<numnodes;j++)
				fread(&path_table[i][j],sizeof(short int),1,pIn); // write count
	
		fread(item_table,sizeof(item_table_t),num_items,pIn);
		fclose(pIn);
	}
	else
	{
		// Create item table
		safe_bprintf(PRINT_MEDIUM, "ACE: No node file found, creating new one...");
		ACEIT_BuildItemNodeTable(false);
		safe_bprintf(PRINT_MEDIUM, "done.\n");
		return; // bail
	}
	
	safe_bprintf(PRINT_MEDIUM, "done.\n");
	
	ACEIT_BuildItemNodeTable(true);

}
Пример #3
0
// Read from disk file
void ACEND_LoadNodes(void)
{
	fileHandle_t    file;
	int             i, j;
	char            filename[MAX_QPATH];
	int             version;
	char            mapname[MAX_QPATH];

	trap_Cvar_VariableStringBuffer("mapname", mapname, sizeof(mapname));
	Com_sprintf(filename, sizeof(filename), "nav/%s.nod", mapname);

	trap_FS_FOpenFile(filename, &file, FS_READ);
	if(!file)
	{
		// Create item table
		G_Printf("ACE: No node file '%s' found\n", filename);
		//ACEIT_BuildItemNodeTable(qfalse);
		//G_Printf("done.\n");
		return;
	}

	// determin version
	trap_FS_Read(&version, sizeof(int), file);	// read version

	if(version == 1)
	{
		G_Printf("ACE: Loading node table '%s'...\n", filename);

		trap_FS_Read(&numNodes, sizeof(int), file);	// read count
		trap_FS_Read(&nodes, sizeof(node_t) * numNodes, file);

		for(i = 0; i < numNodes; i++)
			for(j = 0; j < numNodes; j++)
				trap_FS_Read(&path_table[i][j], sizeof(short int), file);	// write count

		if(ace_showNodes.integer)
		{
			for(i = 0; i < numNodes; i++)
				ACEND_ShowNode(i);
		}
	}
	else
	{
		// Create item table
		G_Printf("ACE: '%s' has wrong version %i\n", filename, version);
		//ACEIT_BuildItemNodeTable(qfalse);
		//G_Printf("done.\n");
	}

	trap_FS_FCloseFile(file);

	G_Printf("done.\n");
	G_Printf("%i nodes loaded\n", numNodes);

	ACEIT_BuildItemNodeTable(qtrue);
}