View Single Post
nergal
Veteran Member
Join Date: Apr 2012
Old 06-29-2020 , 13:55   Re: [SP] ConfigMap: StringMap & SMCParser
Reply With Quote #3

Quote:
Originally Posted by MAGNAT2645 View Post
Is there any way to include ConfigMap to Voice Changer? I just don't want to use KeyValues loop every time NormalSoundHook is called.
yes! you gotta compile it with Voice Changer. I also want to add that ConfigMap is loop-friendlier than KeyValues since all you need to do get a specific section and iterate that section, here's an example of what I mean from VSH2 which uses ConfigMap:

Code:
	static char download_keys[][] = {
		"downloads.sounds",
		"downloads.models",
		"downloads.materials"
	};
	
	for( int i; i<sizeof(download_keys); i++ ) {
		ConfigMap download_map = g_vsh2.m_hCfg.GetSection(download_keys[i]);
		if( download_map != null ) {
			for( int n; n<download_map.Size; n++ ) {
				char index[10];
				Format(index, sizeof(index), "%i", n);
				int value_size = download_map.GetSize(index);
				char[] filepath = new char[value_size];
				if( download_map.Get(index, filepath, value_size) ) {
					switch( i ) {
						case 0: PrepareSound(filepath);
						case 1: PrepareModel(filepath);
						case 2: PrepareMaterial(filepath);
					}
				}
			}
		}
	}
Have it iterate over an array of keys that map to a section, grab that section, and iterate over it as needed
__________________

Last edited by nergal; 06-29-2020 at 13:56.
nergal is offline