mirror of
https://github.com/rehlds/metamod-r.git
synced 2024-12-26 14:45:34 +03:00
Refactoring #2
This commit is contained in:
parent
58d54dfa4f
commit
40bf18a55b
@ -275,7 +275,6 @@ MPlugin* MPluginList::add(MPlugin* padd)
|
|||||||
// Read plugins.ini at server startup.
|
// Read plugins.ini at server startup.
|
||||||
bool MPluginList::ini_startup()
|
bool MPluginList::ini_startup()
|
||||||
{
|
{
|
||||||
FILE *fp;
|
|
||||||
char line[MAX_STRBUF_LEN];
|
char line[MAX_STRBUF_LEN];
|
||||||
int n, ln;
|
int n, ln;
|
||||||
MPlugin *pmatch;
|
MPlugin *pmatch;
|
||||||
@ -287,7 +286,7 @@ bool MPluginList::ini_startup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
full_gamedir_path(m_inifile, m_inifile);
|
full_gamedir_path(m_inifile, m_inifile);
|
||||||
fp = fopen(m_inifile, "r");
|
FILE* fp = fopen(m_inifile, "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
META_ERROR("ini: Unable to open plugins file '%s': %s", m_inifile, strerror(errno));
|
META_ERROR("ini: Unable to open plugins file '%s': %s", m_inifile, strerror(errno));
|
||||||
@ -353,13 +352,12 @@ bool MPluginList::ini_startup()
|
|||||||
// Re-read plugins.ini looking for added/deleted/changed plugins.
|
// Re-read plugins.ini looking for added/deleted/changed plugins.
|
||||||
bool MPluginList::ini_refresh()
|
bool MPluginList::ini_refresh()
|
||||||
{
|
{
|
||||||
FILE *fp;
|
|
||||||
char line[MAX_STRBUF_LEN];
|
char line[MAX_STRBUF_LEN];
|
||||||
int n, ln;
|
int n, ln;
|
||||||
MPlugin pl_temp;
|
MPlugin pl_temp;
|
||||||
MPlugin *pl_found, *pl_added;
|
MPlugin *pl_found, *pl_added;
|
||||||
|
|
||||||
fp = fopen(m_inifile, "r");
|
FILE* fp = fopen(m_inifile, "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
{
|
{
|
||||||
META_ERROR("ini: Unable to open plugins file '%s': %s", m_inifile, strerror(errno));
|
META_ERROR("ini: Unable to open plugins file '%s': %s", m_inifile, strerror(errno));
|
||||||
@ -559,8 +557,7 @@ bool MPluginList::load()
|
|||||||
// Update list of loaded plugins from ini file, and load any new/changed plugins.
|
// Update list of loaded plugins from ini file, and load any new/changed plugins.
|
||||||
bool MPluginList::refresh(PLUG_LOADTIME now)
|
bool MPluginList::refresh(PLUG_LOADTIME now)
|
||||||
{
|
{
|
||||||
int i, ndone = 0, nkept = 0, nloaded = 0, nunloaded = 0, nreloaded = 0, ndelayed = 0;
|
int ndone = 0, nkept = 0, nloaded = 0, nunloaded = 0, nreloaded = 0, ndelayed = 0;
|
||||||
MPlugin* iplug;
|
|
||||||
|
|
||||||
if (!ini_refresh())
|
if (!ini_refresh())
|
||||||
{
|
{
|
||||||
@ -569,9 +566,9 @@ bool MPluginList::refresh(PLUG_LOADTIME now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
META_LOG("dll: Updating plugins...");
|
META_LOG("dll: Updating plugins...");
|
||||||
for (i = 0; i < m_max_loaded_count; i++)
|
for (int i = 0; i < m_max_loaded_count; i++)
|
||||||
{
|
{
|
||||||
iplug = &m_plist[i];
|
auto iplug = &m_plist[i];
|
||||||
if (iplug->m_status < PL_VALID)
|
if (iplug->m_status < PL_VALID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -668,7 +665,6 @@ void MPluginList::retry_all(PLUG_LOADTIME now)
|
|||||||
void MPluginList::show(int source_index)
|
void MPluginList::show(int source_index)
|
||||||
{
|
{
|
||||||
int n = 0, r = 0;
|
int n = 0, r = 0;
|
||||||
MPlugin *pl;
|
|
||||||
char desc[15 + 1], file[16 + 1], vers[7 + 1]; // plus 1 for term null
|
char desc[15 + 1], file[16 + 1], vers[7 + 1]; // plus 1 for term null
|
||||||
|
|
||||||
if (source_index <= 0)
|
if (source_index <= 0)
|
||||||
@ -681,7 +677,7 @@ void MPluginList::show(int source_index)
|
|||||||
|
|
||||||
for (int i = 0; i < m_max_loaded_count; i++)
|
for (int i = 0; i < m_max_loaded_count; i++)
|
||||||
{
|
{
|
||||||
pl = &m_plist[i];
|
auto pl = &m_plist[i];
|
||||||
if (pl->m_status < PL_VALID)
|
if (pl->m_status < PL_VALID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -725,12 +721,11 @@ void MPluginList::show(int source_index)
|
|||||||
void MPluginList::show_client(edict_t *pEntity)
|
void MPluginList::show_client(edict_t *pEntity)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
MPlugin *pl;
|
|
||||||
META_CLIENT(pEntity, "Currently running plugins:");
|
META_CLIENT(pEntity, "Currently running plugins:");
|
||||||
|
|
||||||
for (int i = 0; i < m_max_loaded_count; i++)
|
for (int i = 0; i < m_max_loaded_count; i++)
|
||||||
{
|
{
|
||||||
pl = &m_plist[i];
|
auto pl = &m_plist[i];
|
||||||
if (pl->m_status != PL_RUNNING || !pl->m_info)
|
if (pl->m_status != PL_RUNNING || !pl->m_info)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -14,30 +14,12 @@ char *UTIL_VarArgs(char *format, ...)
|
|||||||
|
|
||||||
short FixedSigned16(float value, float scale)
|
short FixedSigned16(float value, float scale)
|
||||||
{
|
{
|
||||||
int output;
|
return (short)clamp(int(value * scale), SHRT_MIN, SHRT_MAX);
|
||||||
|
|
||||||
output = (int)(value * scale);
|
|
||||||
|
|
||||||
if (output > 32767)
|
|
||||||
output = 32767;
|
|
||||||
|
|
||||||
if (output < -32768)
|
|
||||||
output = -32768;
|
|
||||||
|
|
||||||
return (short)output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short FixedUnsigned16(float value, float scale)
|
unsigned short FixedUnsigned16(float value, float scale)
|
||||||
{
|
{
|
||||||
int output;
|
return (unsigned short)clamp(int(value * scale), 0, USHRT_MAX);
|
||||||
|
|
||||||
output = (int)(value * scale);
|
|
||||||
if (output < 0)
|
|
||||||
output = 0;
|
|
||||||
if (output > 0xFFFF)
|
|
||||||
output = 0xFFFF;
|
|
||||||
|
|
||||||
return (unsigned short)output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const char *pMessage)
|
void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const char *pMessage)
|
||||||
@ -76,7 +58,7 @@ void UTIL_HudMessage(edict_t *pEntity, const hudtextparms_t &textparms, const ch
|
|||||||
else {
|
else {
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
strncpy(tmp, pMessage, sizeof tmp - 1);
|
strncpy(tmp, pMessage, sizeof tmp - 1);
|
||||||
tmp[sizeof tmp - 1] = 0;
|
tmp[sizeof tmp - 1] = '\0';
|
||||||
WRITE_STRING(tmp);
|
WRITE_STRING(tmp);
|
||||||
}
|
}
|
||||||
MESSAGE_END();
|
MESSAGE_END();
|
||||||
|
@ -122,8 +122,7 @@ char *trimbuf(char *str)
|
|||||||
void NormalizePath(char *path)
|
void NormalizePath(char *path)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char *cp;
|
for (char* cp = path; *cp; cp++)
|
||||||
for (cp = path; *cp; cp++)
|
|
||||||
{
|
{
|
||||||
if (isupper(*cp))
|
if (isupper(*cp))
|
||||||
*cp = tolower(*cp);
|
*cp = tolower(*cp);
|
||||||
|
Loading…
Reference in New Issue
Block a user