1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-26 19:54:14 +01:00

Fixed amb1952: Crash when first plugin listed in metaplugins.ini had an alias and was not on the first line of the file.

--HG--
branch : sourcemm-1.4.x
extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/branches/sourcemm-1.4.x%40708
This commit is contained in:
Scott Ehlert 2008-08-24 04:24:53 +00:00
parent 63e584fa28
commit 3a7197038d
2 changed files with 49 additions and 21 deletions

View File

@ -1,3 +1,7 @@
2008/??/?? 1.4.5:
- Fixed amb1952: Crash when first plugin listed in metaplugins.ini had an alias
and was not on the first line of the file.
2008/07/26 1.4.4:
- Fixed a bug where loading plugins built for MM:S 1.3 or older (API ver <= 9)
would cause a crash.

View File

@ -826,21 +826,22 @@ int LoadPluginsFromFile(const char *_file)
char buffer[255], error[255], full_path[255];
const char *ptr, *ext, *file;
size_t length;
while (!feof(fp))
while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL)
{
buffer[0] = '\0';
fgets(buffer, sizeof(buffer), fp);
length = strlen(buffer);
if (!length)
continue;
if (buffer[length-1] == '\n')
buffer[--length] = '\0';
UTIL_TrimLeft(buffer);
UTIL_TrimRight(buffer);
if (buffer[0] == '\0' || buffer[0] == ';' || strncmp(buffer, "//", 2) == 0)
length = strlen(buffer);
if (!length)
{
continue;
}
if (buffer[0] == '\0' || buffer[0] == ';' || strncmp(buffer, "//", 2) == 0)
{
continue;
}
file = buffer;
if (buffer[0] == '"')
{
@ -856,7 +857,9 @@ int LoadPluginsFromFile(const char *_file)
}
cptr++;
}
} else {
}
else
{
char *cptr = buffer;
while (*cptr)
{
@ -864,7 +867,9 @@ int LoadPluginsFromFile(const char *_file)
{
char *optr = cptr;
while (*cptr && isspace(*cptr))
{
cptr++;
}
*optr = '\0';
UTIL_TrimRight(cptr);
if (*cptr && isalpha(*cptr))
@ -889,13 +894,21 @@ int LoadPluginsFromFile(const char *_file)
if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
{
LogMessage("[META] Failed to load plugin %s. %s", buffer, error);
} else {
if (already)
skipped++;
}
else
{
if (already)
{
skipped++;
}
else
{
total++;
}
} else {
}
}
else
{
/* Attempt to find a file extension */
ptr = UTIL_GetExtension(file);
/* Add an extension if there's none there */
@ -906,7 +919,9 @@ int LoadPluginsFromFile(const char *_file)
#else
ext = "_i486.so";
#endif
} else {
}
else
{
ext = "";
}
/* Format the new path */
@ -915,26 +930,35 @@ int LoadPluginsFromFile(const char *_file)
if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
{
LogMessage("[META] Failed to load plugin %s. %s", buffer, error);
} else {
if (already)
skipped++;
}
else
{
if (already)
{
skipped++;
}
else
{
total++;
}
}
}
}
fclose(fp);
if (skipped)
{
LogMessage("[META] Loaded %d plugins from file (%d already loaded)", total, skipped);
} else {
}
else
{
LogMessage("[META] Loaded %d plugins from file.", total);
}
return total;
}
/* Wrapper function. This is called when the GameDLL thinks it's using
* the engine's real engineFactory.
*/