1
0
mirror of https://github.com/anope/anope.git synced 2026-07-02 18:13:12 +02:00

Moved moduleGetLangString() to Module::GetLangString().

Also changed modules_unload_all() to not delete a module directly, but instead call ModuleManager::UnloadModule().

git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1801 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
cyberbotx
2008-11-27 05:35:34 +00:00
parent 3964ead17e
commit c0c73e4abd
2 changed files with 15 additions and 21 deletions
+8
View File
@@ -233,6 +233,14 @@ class CoreExport Module
**/
void DeleteLanguage(int langNumber);
/**
* Get the text of the given lanugage string in the corrent language, or
* in english.
* @param u The user to send the message to
* @param number The message number
**/
const char *GetLangString(User *u, int number);
/** Add a module message to the IRCD message hash
* @param m the Message to add
* @param pos the Position to add the message to, e.g. MOD_HEAD, MOD_TAIL, MOD_UNIQUE
+7 -21
View File
@@ -136,13 +136,8 @@ void modules_unload_all(bool fini, bool unload_proto)
mh = MODULE_HASH[idx];
while (mh) {
next = mh->next;
if (unload_proto || (mh->m->type != PROTOCOL)) {
mod_current_module = mh->m;
mod_current_module_name = mh->m->name.c_str();
mod_current_module_name = NULL;
delete mh->m;
}
if (unload_proto || (mh->m->type != PROTOCOL))
ModuleManager::UnloadModule(mh->m, NULL);
mh = next;
}
}
@@ -1266,36 +1261,27 @@ void moduleNoticeLang(char *source, User * u, int number, ...)
}
}
/**
* Get the text of the given lanugage string in the corrent language, or
* in english.
* @param u The user to send the message to
* @param number The message number
**/
const char *moduleGetLangString(User * u, int number)
const char *Module::GetLangString(User * u, int number)
{
int lang = NSDefLanguage;
if ((mod_current_module_name) && (!mod_current_module || mod_current_module_name != mod_current_module->name))
mod_current_module = findModule(mod_current_module_name);
/* Find the users lang, and use it if we can */
if (u && u->na && u->na->nc)
lang = u->na->nc->language;
/* If the users lang isnt supported, drop back to English */
if (mod_current_module->lang[lang].argc == 0)
if (this->lang[lang].argc == 0)
lang = LANG_EN_US;
/* If the requested lang string exists for the language */
if (mod_current_module->lang[lang].argc > number) {
return mod_current_module->lang[lang].argv[number];
if (this->lang[lang].argc > number) {
return this->lang[lang].argv[number];
/* Return an empty string otherwise, because we might be used without
* the return value being checked. If we would return NULL, bad things
* would happen!
*/
} else {
alog("%s: INVALID language string call, language: [%d], String [%d]", mod_current_module->name.c_str(), lang, number);
alog("%s: INVALID language string call, language: [%d], String [%d]", this->name.c_str(), lang, number);
return "";
}
}