Beispiel #1
0
// Initialise les repertoires à partir de raw_material_generation.cfg
void SetupDirectories()
{
	CSString data;
	
	if ( ! CFile::fileExists( "raw_material_generation.cfg" ) )
	{
		nlError( "raw_material_generation.cfg not found\n");
		exit( 1 );
	}
		
	data.readFromFile( "raw_material_generation.cfg" );

	LEVEL_DESIGN_PATH = data.splitFrom( "LevelDesignPath = \"").splitTo( "\"" );
	TRANSLATION_PATH = data.splitFrom( "TranslationPath = \"" ).splitTo( "\"" );

	printf( "Level Design Path : %s\nTranslation Path : %s\n\n", LEVEL_DESIGN_PATH.c_str(), TRANSLATION_PATH.c_str() );
	
	ITEM_MP_FAMILY_TYP = LEVEL_DESIGN_PATH + "leveldesign\\DFN\\game_elem\\_item\\item_mp_family.typ";
	ITEM_MP_GROUPE_TYP = LEVEL_DESIGN_PATH + "leveldesign\\DFN\\game_elem\\_item\\item_mp_group.typ";
	ITEM_MP_PARAM_DFN = LEVEL_DESIGN_PATH + "leveldesign\\DFN\\game_elem\\_item\\_item_mp_param.dfn";
	MP_DIRECTORY = LEVEL_DESIGN_PATH + "leveldesign\\game_element\\sitem\\raw_material\\";
	DEPOSIT_MPS = LEVEL_DESIGN_PATH + "leveldesign\\game_element\\deposit_system\\mps\\"; 

	RAW_MATERIAL_ASSIGN = LEVEL_DESIGN_PATH + "leveldesign\\Game_elem\\Creature\\raw_material_assignment\\";

	IC_FAMILIES_FORAGE_SOURCE = LEVEL_DESIGN_PATH + "leveldesign\\game_element\\forage_source\\_ic_families.forage_source";
	
	WK_UXT = TRANSLATION_PATH + "work\\wk.uxt";
	ITEM_WORDS_WK = TRANSLATION_PATH + "work\\item_words_wk.txt";
}
Beispiel #2
0
// Assigne une nouvelle MP à une creature
void AssignerMP( const CSString& creatureName, const CSString& materialName )
{
	// on regarde si la créature est dégénérée ou non
	if ( ( creatureName.c_str()[3] != 'c' ) && ( creatureName.c_str()[3] != 'd' ) 
		&& ( creatureName.c_str()[3] != 'f' ) && ( creatureName.c_str()[3] != 'j' )
		&& ( creatureName.c_str()[3] != 'l' ) && ( creatureName.c_str()[3] != 'p' ) )
	{
	}
	else
	{
		// lecture du fichier d'assignement
		CSString fileName = toString( "%s//_%s_mp.creature", RAW_MATERIAL_ASSIGN.c_str(), creatureName.c_str() ); 
		CSString data;

		// création si le fichier n'existe pas
		if(!CFile::fileExists(fileName))
		{
			CSString	str;
			str = "<?xml version=\"1.0\"?>\r\n";
			str+= "<FORM Version=\"0.0\" State=\"modified\">\r\n";
			str+= "  <STRUCT>\r\n";
			str+= "    <STRUCT Name=\"Harvest\">\r\n";
			str+= "    </STRUCT>\r\n";
			str+= "  </STRUCT>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "</FORM>\r\n";
			str.writeToFile( fileName );
		}

		// lecture
		data.readFromFile( fileName );

		if ( !data.contains( materialName.c_str() ) )
		{	
			// on recherche le premier numéro de MP non utilisé
			CSString str = data;
			int nb= 0;
			while ( str.contains( "Name=\"MP" ) )
			{
				str = str.splitFrom( "Name=\"MP" );
				nb = str.firstWord().atoi();
			}

			// on insère la nouvelle MP
			str = "      <STRUCT Name=\"MP";
			str += toString( "%d\">\r\n        <ATOM Name=\"AssociatedItem\"", nb+1 );
			str += toString( " Value=\"%s\"/>\r\n      </STRUCT>\r\n    </STRUCT>\r\n  </STRUCT>\r\n", materialName.c_str() );
			
			data = data.replace( "    </STRUCT>\r\n  </STRUCT>\r\n", str.c_str() );
			data.writeToFile( fileName );
		}
	}
}
Beispiel #3
0
// Retourne le numéro du groupe passé en paramètre
int GetNumeroGroupe( const CSString& groupe )
{
	CSString result;
	char buffer[100];
	char buffer2[100];
	int res;

	// *** Get the group number, and add it to group.typ if not already done
	// on recherche si le groupe est présent
	// dans le fichier item_mp_group.typ
	sprintf( buffer, "%s\" Value=\"", groupe.c_str() );
	result = GroupTypContent.splitFrom( buffer );

	// si oui, on retourne son numéro de groupe
	if ( result != "" )
		res = result.splitTo( "\"" ).atoi();
	else
	{
		// sinon, on génère un nouveau numéro :
		// on recupère le dernier numéro de groupe (le max)
		result = GroupTypContent.splitTo( "<LOG>" ).right(10);
		result.splitTo( "\"", true );
		result = result.splitTo( "\"" );

		// on ajoute 1 pour avoir un numéro non utilisé
		res = result.atoi() + 1;

		// on ajoute la nouvelle MP :
		// dans le fichier item_mp_group.typ
		sprintf( buffer, "<DEFINITION Label=\"%s\" Value=\"%d\"/>\n<LOG>", groupe.c_str(), res );
		GroupTypContent= GroupTypContent.replace( "<LOG>", buffer );
		GroupTypContent.writeToFile( ITEM_MP_GROUPE_TYP );
	}


	// *** Add the text in wk.uxt (if not done)
	// Exist in wk.uxt ???
	sprintf( buffer, "mpgroup%d\t", res );
	sprintf( buffer2, "mpgroup%d ", res );
	// if not found
	if ( !WKContent.contains(buffer) && !WKContent.contains(buffer2) )
	{
		// add it at end
		sprintf( buffer, "mpgroup%d\t\t\t[%s]\n\r\nmpSource", res, groupe.c_str() );
		WKContent= WKContent.replace( "\r\nmpSource", buffer );
		WKContent.writeToFile( WK_UXT );
	}

	return res;
}