sourcemm/CSmmAPI.cpp
changeset 320 c955cb69efe3
parent 318 d601b515c839
child 326 1cefbedb2d6d
     1.1 --- a/sourcemm/CSmmAPI.cpp	Thu Apr 26 18:14:21 2007 +0000
     1.2 +++ b/sourcemm/CSmmAPI.cpp	Wed May 02 14:08:57 2007 +0000
     1.3 @@ -454,9 +454,33 @@
     1.4  
     1.5  void CSmmAPI::LoadAsVSP()
     1.6  {
     1.7 -	char command[350];
     1.8 +	size_t len;
     1.9 +	char engine_file[PATH_SIZE];
    1.10 +	char rel_path[PATH_SIZE * 2];
    1.11 +
    1.12 +	GetFileOfAddress(g_Engine.engine, engine_file, sizeof(engine_file));
    1.13 +
    1.14 +	/* Chop off the "engine" file part */
    1.15 +	len = strlen(engine_file);
    1.16 +	for (size_t i = len - 1; i >= 0 && i < len; i--)
    1.17 +	{
    1.18 +		if (engine_file[i] == '/'
    1.19 +			|| engine_file[i] == '\\')
    1.20 +		{
    1.21 +			engine_file[i] = '\0';
    1.22 +			break;
    1.23 +		}
    1.24 +	}
    1.25 +
    1.26 +	const char *usepath = g_SmmPath.c_str();
    1.27 +	if (UTIL_Relatize(rel_path, sizeof(rel_path), engine_file, g_SmmPath.c_str()))
    1.28 +	{
    1.29 +		usepath = rel_path;
    1.30 +	}
    1.31 +	
    1.32 +	char command[PATH_SIZE * 2];
    1.33  	g_VspListener.SetLoadable(true);
    1.34 -	UTIL_Format(command, sizeof(command), "plugin_load \"%s\"\n", g_SmmPath.c_str());
    1.35 +	UTIL_Format(command, sizeof(command), "plugin_load \"%s\"\n", usepath);
    1.36  	g_Engine.engine->ServerCommand(command);
    1.37  }
    1.38