1.1 --- a/core/smn_lang.cpp Fri Mar 28 06:21:34 2008 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,115 +0,0 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod
1.8 - * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
1.9 - * =============================================================================
1.10 - *
1.11 - * This program is free software; you can redistribute it and/or modify it under
1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
1.13 - * Free Software Foundation.
1.14 - *
1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.17 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.18 - * details.
1.19 - *
1.20 - * You should have received a copy of the GNU General Public License along with
1.21 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.22 - *
1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.26 - * by the Valve Corporation. You must obey the GNU General Public License in
1.27 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.28 - * this exception to all derivative works. AlliedModders LLC defines further
1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.30 - * or <http://www.sourcemod.net/license.php>.
1.31 - *
1.32 - * Version: $Id$
1.33 - */
1.34 -
1.35 -#include "PluginSys.h"
1.36 -#include "Translator.h"
1.37 -#include "LibrarySys.h"
1.38 -#include "sm_stringutil.h"
1.39 -#include "PlayerManager.h"
1.40 -
1.41 -static cell_t sm_LoadTranslations(IPluginContext *pCtx, const cell_t *params)
1.42 -{
1.43 - char *filename;
1.44 - unsigned int index;
1.45 - CPlugin *pl = (CPlugin *)g_PluginSys.FindPluginByContext(pCtx->GetContext());
1.46 -
1.47 - pCtx->LocalToString(params[1], &filename);
1.48 -
1.49 - /* Check if there is no extension */
1.50 - const char *ext = g_LibSys.GetFileExtension(filename);
1.51 - if (!ext || (strcmp(ext, "cfg") && strcmp(ext, "txt")))
1.52 - {
1.53 - /* Append one */
1.54 - static char new_file[PLATFORM_MAX_PATH];
1.55 - UTIL_Format(new_file, sizeof(new_file), "%s.txt", filename);
1.56 - filename = new_file;
1.57 - }
1.58 -
1.59 - index = g_Translator.FindOrAddPhraseFile(filename);
1.60 - pl->AddLangFile(index);
1.61 -
1.62 - return 1;
1.63 -}
1.64 -
1.65 -static cell_t sm_SetGlobalTransTarget(IPluginContext *pContext, const cell_t *params)
1.66 -{
1.67 - g_SourceMod.SetGlobalTarget(params[1]);
1.68 -
1.69 - return 1;
1.70 -}
1.71 -
1.72 -static cell_t sm_GetClientLanguage(IPluginContext *pContext, const cell_t *params)
1.73 -{
1.74 - CPlayer *player = g_Players.GetPlayerByIndex(params[1]);
1.75 - if (!player || !player->IsConnected())
1.76 - {
1.77 - return pContext->ThrowNativeError("Invalid client index %d", params[1]);
1.78 - }
1.79 -
1.80 - return g_Translator.GetClientLanguage(params[1]);
1.81 -}
1.82 -
1.83 -static cell_t sm_GetServerLanguage(IPluginContext *pContext, const cell_t *params)
1.84 -{
1.85 - return g_Translator.GetServerLanguage();
1.86 -}
1.87 -
1.88 -static cell_t sm_GetLanguageCount(IPluginContext *pContext, const cell_t *params)
1.89 -{
1.90 - return g_Translator.GetLanguageCount();
1.91 -}
1.92 -
1.93 -static cell_t sm_GetLanguageInfo(IPluginContext *pContext, const cell_t *params)
1.94 -{
1.95 - const char *code;
1.96 - const char *name;
1.97 -
1.98 - if (!g_Translator.GetLanguageInfo(params[1], &code, &name))
1.99 - {
1.100 - return pContext->ThrowNativeError("Invalid language number %d", params[1]);
1.101 - }
1.102 -
1.103 - pContext->StringToLocalUTF8(params[2], params[3], code, NULL);
1.104 - pContext->StringToLocalUTF8(params[4], params[5], name, NULL);
1.105 -
1.106 - return 1;
1.107 -}
1.108 -
1.109 -REGISTER_NATIVES(langNatives)
1.110 -{
1.111 - {"LoadTranslations", sm_LoadTranslations},
1.112 - {"SetGlobalTransTarget", sm_SetGlobalTransTarget},
1.113 - {"GetClientLanguage", sm_GetClientLanguage},
1.114 - {"GetServerLanguage", sm_GetServerLanguage},
1.115 - {"GetLanguageCount", sm_GetLanguageCount},
1.116 - {"GetLanguageInfo", sm_GetLanguageInfo},
1.117 - {NULL, NULL},
1.118 -};