Exemplo n.º 1
0
Arquivo: Modules.cpp Projeto: ex0a/znc
CString CModule::GetWebFilesPath() {
	switch (m_eType) {
		case CModInfo::GlobalModule: return "/modfiles/global/" + GetModName() + "/";
		case CModInfo::UserModule: return "/modfiles/user/" + GetModName() + "/";
		case CModInfo::NetworkModule: return "/modfiles/network/" + m_pNetwork->GetName() + "/" + GetModName() + "/";
		default: return "/";
	}
}
Exemplo n.º 2
0
bool CModule::PutModNotice(const CString& sLine) {
	if (!m_pUser)
		return false;

	if (m_pClient) {
		m_pClient->PutModNotice(GetModName(), sLine);
		return true;
	}

	return m_pUser->PutModNotice(GetModName(), sLine);
}
Exemplo n.º 3
0
	virtual void OnModCommand(const CString& sLine) {
		CString sCommand = sLine.Token(0);
		if (sCommand.Equals("cd")) {
			CString sArg = sLine.Token(1, true);
			CString sPath = CDir::ChangeDir(m_sPath, (sArg.empty() ? CString(CZNC::Get().GetHomePath()) : sArg), CZNC::Get().GetHomePath());
			CFile Dir(sPath);

			if (Dir.IsDir()) {
				m_sPath = sPath;
			} else if (Dir.Exists()) {
				PutShell("cd: not a directory [" + sPath + "]");
			} else {
				PutShell("cd: no such directory [" + sPath + "]");
			}

			PutShell("znc$");
		} else if (sCommand.Equals("SEND")) {
			CString sToNick = sLine.Token(1);
			CString sFile = sLine.Token(2);

			if ((sToNick.empty()) || (sFile.empty())) {
				PutShell("usage: Send <nick> <file>");
			} else {
				sFile = CDir::ChangeDir(m_sPath, sFile, CZNC::Get().GetHomePath());

				if (!CFile::Exists(sFile)) {
					PutShell("get: no such file [" + sFile + "]");
				} else if (!CFile::IsReg(sFile)) {
					PutShell("get: not a file [" + sFile + "]");
				} else {
					m_pUser->SendFile(sToNick, sFile, GetModName());
				}
			}
		} else if (sCommand.Equals("GET")) {
			CString sFile = sLine.Token(1);

			if (sFile.empty()) {
				PutShell("usage: Get <file>");
			} else {
				sFile = CDir::ChangeDir(m_sPath, sFile, CZNC::Get().GetHomePath());

				if (!CFile::Exists(sFile)) {
					PutShell("get: no such file [" + sFile + "]");
				} else if (!CFile::IsReg(sFile)) {
					PutShell("get: not a file [" + sFile + "]");
				} else {
					m_pUser->SendFile(m_pUser->GetCurNick(), sFile, GetModName());
				}
			}
		} else {
			RunCommand(sLine);
		}
	}
Exemplo n.º 4
0
bool CModule::PutModule(const CString& sLine) {
	if (m_pClient) {
		m_pClient->PutModule(GetModName(), sLine);
		return true;
	}

	if (m_pNetwork) {
		return m_pNetwork->PutModule(GetModName(), sLine);
	}

	if (m_pUser) {
		return m_pUser->PutModule(GetModName(), sLine);
	}

	return false;
}
Exemplo n.º 5
0
	bool BootStrap(CChan *pChan)
	{
		CString sFile;
		if (DecryptChannel(pChan->GetName(), sFile))
		{
			if (!pChan->GetBuffer().empty())
				return(true); // reloaded a module probably in this case, so just verify we can decrypt the file

			VCString vsLines;
			VCString::iterator it;

			sFile.Split("\n", vsLines);

			for (it = vsLines.begin(); it != vsLines.end(); ++it) {
				CString sLine(*it);
				sLine.Trim();
				pChan->AddBuffer(sLine);
			}
		} else
		{
			m_sPassword = "";
			CUtils::PrintError("[" + GetModName() + ".so] Failed to Decrypt [" + pChan->GetName() + "]");
			return(false);
		}

		return(true);
	}
Exemplo n.º 6
0
bool CModule::PutModNotice(const CString& sLine, const CString& sIdent, const CString& sHost) {
	if (!m_pUser)
		return false;
	return m_pUser->PutUser(":" + GetModNick() + "!" +
		(sIdent.empty() ? GetModName() : sIdent) + "@" + sHost +
		" NOTICE " + m_pUser->GetCurNick() + " :" + sLine,
		m_pClient);
}
Exemplo n.º 7
0
	void AddBuffer(CChan& Channel, const CString& sMessage) {
		// If they have keep buffer disabled, only add messages if no client is connected
		if (!Channel.KeepBuffer() && m_pUser->IsUserAttached())
			return;

		CString s = ":" + GetModNick() + "!" + GetModName() + "@znc.in PRIVMSG "
			+ Channel.GetName() + " :" + m_pUser->AddTimestamp(sMessage);
		Channel.AddBuffer(s);
	}
Exemplo n.º 8
0
bool CModule::PutModule(const CString& sLine, const CString& sIdent, const CString& sHost) {
	if (!m_pUser)
		return false;
	if(m_pUser->ModRepliesAsNotices())
		return PutModNotice(sLine, sIdent, sHost);
	return m_pUser->PutUser(":" + GetModNick() + "!" +
		(sIdent.empty() ? GetModName() : sIdent) + "@" + sHost +
		" PRIVMSG " + m_pUser->GetCurNick() + " :" + sLine,
		m_pClient);
}
Exemplo n.º 9
0
	bool BootStrap()
	{
		CString sFile;
		if (DecryptMessages(sFile))
		{
			VCString vsLines;
			VCString::iterator it;

			sFile.Split("\n", vsLines);

			for (it = vsLines.begin(); it != vsLines.end(); ++it) {
				CString sLine(*it);
				sLine.Trim();
				AddMessage(sLine);
			}
		} else {
			m_sPassword = "";
			CUtils::PrintError("[" + GetModName() + ".so] Failed to Decrypt Messages");
			return(false);
		}

		return(true);
	}
Exemplo n.º 10
0
static bool ModFill( void *_mod, dr_handle mod_handle )
/*****************************************************/
// fill in mod_handle for dip to dwarf mod map
// pick up general info about mod while here for later calls
{
    mod_list    *mod = _mod;
    char        fname[MAX_PATH];
    char        *name;
    char        *path;
    dr_handle   cu_tag;
    dr_model    model;
    mod_info    *modinfo;

    modinfo = NextModInfo( mod );
    modinfo->mod_handle = mod_handle;
    InitAddrSym( modinfo->addr_sym );
    modinfo->addr_size = DRGetAddrSize( mod_handle );
    cu_tag = DRGetCompileUnitTag( mod_handle );
    modinfo->cu_tag = cu_tag;
    modinfo->stmts = DRGetStmtList( cu_tag );
    path = DRGetName( cu_tag );
    if( path != NULL ) {
        GetModName( path, fname );
        DCFree( path );
        name = DCAlloc( strlen( fname ) + 1 );
        strcpy( name, fname );
    } else {
        name = NULL;
    }
    path = DRGetProducer( cu_tag );
    if( path != NULL ) {

        df_ver version;

        if( strcmp( path, "V2.0 WATCOM" ) == 0 ) {
            version = VER_V3;
        } else if( strcmp( path, "V1.0 WATCOM" ) == 0 ) {
            version = VER_V2;
        } else if( strcmp( path, "WATCOM" ) == 0 ) {
            version = VER_V1;
        } else {
            version = VER_NONE;
        }
        if( mod->version == VER_NONE ) {
            mod->version = version;
        } else if( mod->version != version ) {
            mod->version = VER_ERROR;
        }
        DCFree( path );
    }
    modinfo->name = name;
    model = DRGetMemModelAT( cu_tag );
    if( DCCurrMAD() == MAD_X86 ) {
        switch( model ) {
        case DR_MODEL_NONE:
        case DR_MODEL_FLAT:
            modinfo->is_segment = FALSE;
            break;
        default:
            modinfo->is_segment = TRUE;
            break;
        }
    } else {
        modinfo->is_segment = FALSE;
    }
    modinfo->model = model;
    modinfo->lang = DRGetLanguageAT( cu_tag );
    modinfo->dbg_pch = DRDebugPCHDef( cu_tag );
    modinfo->has_pubnames = FALSE;
    return( TRUE );
}
Exemplo n.º 11
0
bool CModule::PutModNotice(const CString& sLine) {
    if (!m_pUser)
        return false;
    return m_pUser->PutModNotice(GetModName(), sLine, m_pClient);
}
Exemplo n.º 12
0
void RoundInit (void)
{
   // this is called at the start of each round

   g_roundEnded = false;

   // check team economics
   g_botManager->CheckTeamEconomics (TEAM_TERRORIST);
   g_botManager->CheckTeamEconomics (TEAM_COUNTER);

   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      if (g_botManager->GetBot (i))
         g_botManager->GetBot (i)->NewRound ();

      g_radioSelect[i] = 0;
   }
   g_waypoint->SetBombPosition (true);
   g_waypoint->ClearGoalScore ();

   g_bombSayString = false;
   g_timeBombPlanted = 0.0f;
   g_timeNextBombUpdate = 0.0f;

   g_leaderChoosen[TEAM_COUNTER] = false;
   g_leaderChoosen[TEAM_TERRORIST] =  false;

   g_lastRadioTime[0] = 0.0f;
   g_lastRadioTime[1] = 0.0f;
   g_botsCanPause = false;

   // SyPB Pro P.15
   char *Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/plugins-dmkd.ini", GetModName ());
   if (TryFileOpen(Plugin_INI))
   {
	   if (CVAR_GET_FLOAT("HsK_Deathmatch_Plugin_load_SyPB") == 1)
		   sypb_gamemod.SetInt (1);
	   else
		   sypb_gamemod.SetInt (0);
   }

   // SyPB Pro P.2 // SyPB Pro P.15
   Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/plugins-zplague.ini", GetModName ());
   if (TryFileOpen(Plugin_INI)) // Getting GameMod
   {
	   float delayTime = (CVAR_GET_FLOAT("zp_delay") >0) ? CVAR_GET_FLOAT("zp_delay") : CVAR_GET_FLOAT("zp_gamemode_delay");
   	   
   	   if (delayTime > 0)
   	   {
   	   	   sypb_gamemod.SetInt (2);
   	   	   sypb_walkallow.SetInt (0);
   	   	   g_DelayTimer = engine->GetTime () + delayTime + (CVAR_GET_FLOAT("mp_freezetime") / 2);  
   	   }
   }

   // SyPB Pro P.11
   Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/zombiehell.cfg", GetModName ());
   if (TryFileOpen(Plugin_INI) && CVAR_GET_FLOAT("zh_zombie_maxslots") > 0)
   {
	   sypb_gamemod.SetInt (4);
	   sypb_walkallow.SetInt (0);

	   extern ConVar sypb_quota;
	   sypb_quota.SetInt (static_cast <int> (CVAR_GET_FLOAT("zh_zombie_maxslots")));
   }
   
   // SyPB Pro P.14
   Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/bte_wpn.ini", GetModName ());
   if (TryFileOpen(Plugin_INI)) // This is CS:BTE
   {
   	   Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/plugins-ze.ini", GetModName ());
   	   if ((g_mapType & MAP_ZE) && TryFileOpen(Plugin_INI))
   	   {
   	   	   sypb_gamemod.SetInt (99);
   	   	   sypb_walkallow.SetInt (0);
   	   	   g_DelayTimer = engine->GetTime () + 24.0f;
   	   }
   	   
   	   Plugin_INI = FormatBuffer ("%s/addons/amxmodx/configs/plugins-zb1.ini", GetModName ());
   	   if (TryFileOpen(Plugin_INI))
   	   {
   	   	   sypb_gamemod.SetInt (2);
   	   	   sypb_walkallow.SetInt (0);
   	   }
   }

   g_exp.UpdateGlobalKnowledge (); // update experience data on round start

   // calculate the round mid/end in world time
   g_timeRoundStart = engine->GetTime () + engine->GetFreezeTime ();
   g_timeRoundMid = g_timeRoundStart + engine->GetRoundTime () * 60 / 2;
   g_timeRoundEnd = g_timeRoundStart + engine->GetRoundTime () * 60;
}
Exemplo n.º 13
0
void RoundInit (void)
{
   // this is called at the start of each round

   g_roundEnded = false;

   // check team economics
   g_botManager->CheckTeamEconomics (TEAM_TERRORIST);
   g_botManager->CheckTeamEconomics (TEAM_COUNTER);

   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      if (g_botManager->GetBot (i))
         g_botManager->GetBot (i)->NewRound ();

      g_radioSelect[i] = 0;
   }
   g_waypoint->SetBombPosition (true);
   g_waypoint->ClearGoalScore ();

   g_bombSayString = false;
   g_timeBombPlanted = 0.0f;
   g_timeNextBombUpdate = 0.0f;

   g_leaderChoosen[TEAM_COUNTER] = false;
   g_leaderChoosen[TEAM_TERRORIST] =  false;

   g_lastRadioTime[0] = 0.0f;
   g_lastRadioTime[1] = 0.0f;
   g_botsCanPause = false;

   // SyPB Pro P.15
   char *Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/plugins-dmkd.ini", GetModName());
   if (TryFileOpen(Plugin_INI))
   {
	   if (CVAR_GET_FLOAT("HsK_Deathmatch_Plugin_load_SyPB") == 1)
		   sypb_gamemod.SetInt(1);
	   else
		   sypb_gamemod.SetInt(0);
   }

   // SyPB Pro P.2 // SyPB Pro P.15
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/plugins-zplague.ini", GetModName());
   if (TryFileOpen(Plugin_INI)) // Getting GameMod
   {
	   float delayTime = (CVAR_GET_FLOAT("zp_delay") >0) ? CVAR_GET_FLOAT("zp_delay") : CVAR_GET_FLOAT("zp_gamemode_delay");

	   if (delayTime > 0)
	   {
		   sypb_gamemod.SetInt(2);
		   sypb_walkallow.SetInt(0);
		   g_DelayTimer = engine->GetTime() + delayTime + (CVAR_GET_FLOAT("mp_freezetime") / 2);
	   }
   }

   // SyPB Pro P.11
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/zombiehell.cfg", GetModName());
   if (TryFileOpen(Plugin_INI) && CVAR_GET_FLOAT("zh_zombie_maxslots") > 0)
   {
	   sypb_gamemod.SetInt(4);
	   sypb_walkallow.SetInt(0);

	   extern ConVar sypb_quota;
	   sypb_quota.SetInt(static_cast <int> (CVAR_GET_FLOAT("zh_zombie_maxslots")));
   }

   // SyPB Pro P.29 - Support CSBTE Final
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/bte_player.ini", GetModName());
   if (TryFileOpen(Plugin_INI))
   {
	   const int Const_GameModes = 12;
	   int bteGameModAi[Const_GameModes] =
	   {
		   0, 0, 1, 3, 0, 2, 2, 2, 2, 4, 2, 3
	   };//n, t, d, d, g, g, z, z, z, z, z, n

	   char *bteGameINI[Const_GameModes] =
	   {
		   "plugins-none",
		   "plugins-td",
		   "plugins-dm",
		   "plugins-dr",
		   "plugins-gd",
		   "plugins-ghost",
		   "plugins-zb1",
		   "plugins-zb3",
		   "plugins-zb4",
		   "plugins-ze",
		   "plugins-zse",
		   "plugins-npc"
	   };

	   for (int i = 0; i < Const_GameModes; i++)
	   {
		   if (TryFileOpen(FormatBuffer("%s/addons/amxmodx/configs/%s.ini", GetModName(), bteGameINI[i])))
		   {
			   sypb_gamemod.SetInt(bteGameModAi[i]);

			   if (bteGameModAi[i] == 2 && i != 5)
			   {
				   sypb_walkallow.SetInt(0);
				   g_DelayTimer = engine->GetTime() + 20.0f;
			   }

			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   if (i == 3 || i == 9 || i == 10)
			   {
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
			   }

			   break;
		   }
	   }
   }

   // SyPB Pro P.25 - Zombie Ai
   if (GetGameMod() == 2 || GetGameMod() == 4)
	   g_mapType |= MAP_DE;

   g_exp.UpdateGlobalKnowledge (); // update experience data on round start

   // calculate the round mid/end in world time
   g_timeRoundStart = engine->GetTime () + engine->GetFreezeTime ();
   g_timeRoundMid = g_timeRoundStart + engine->GetRoundTime () * 60 / 2;
   g_timeRoundEnd = g_timeRoundStart + engine->GetRoundTime () * 60;
}
Exemplo n.º 14
0
/*
 * Copyright (C) 2004-2011  See the AUTHORS file for details.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation.
 *
 * Buffer Saving thing, incase your shit goes out while your out
 * Author: imaginos <*****@*****.**>
 *
 * Its only as secure as your shell, the encryption only offers a slightly
 * better solution then plain text.
 */

#define REQUIRESSL

#include "Chan.h"
#include "User.h"
#include "FileUtils.h"
#include <sys/stat.h>

#define CRYPT_VERIFICATION_TOKEN "::__:SAVEBUFF:__::"
// this is basically plain text, but so is having the pass in the command line so *shrug*
// you could at least do something kind of cool like a bunch of unprintable text
#define CRYPT_LAME_PASS "::__:NOPASS:__::"
#define CRYPT_ASK_PASS "--ask-pass"

class CSaveBuff;

class CSaveBuffJob : public CTimer
{
public:
	CSaveBuffJob(CModule* pModule, unsigned int uInterval, unsigned int uCycles, const CString& sLabel, const CString& sDescription)
		: CTimer(pModule, uInterval, uCycles, sLabel, sDescription) {}

	virtual ~CSaveBuffJob() {}

protected:
	virtual void RunJob();
};

class CSaveBuff : public CModule
{
public:
	MODCONSTRUCTOR(CSaveBuff)
	{
		m_bBootError = false;
		m_bFirstLoad = false;
	}
	virtual ~CSaveBuff()
	{
		if (!m_bBootError)
		{
			SaveBufferToDisk();
		}
	}

	virtual bool OnLoad(const CString& sArgs, CString& sMessage)
	{
		if( sArgs == CRYPT_ASK_PASS )
		{
			char *pPass = getpass( "Enter pass for savebuff: " );
			if( pPass )
				m_sPassword = CBlowfish::MD5( pPass );
			else
			{
				m_bBootError = true;
				sMessage = "Nothing retrieved from console. aborting";
			}
		}
		else if( sArgs.empty() )
			m_sPassword = CBlowfish::MD5( CRYPT_LAME_PASS );
		else
			m_sPassword = CBlowfish::MD5(sArgs);

		return( !m_bBootError );
	}

	virtual void OnIRCConnected()
	{
		// dropped this into here because there seems to have been a changed where the module is loaded before the channels.
		// this is a good trigger to tell it to backfill the channels
		if( !m_bFirstLoad )
		{
			m_bFirstLoad = true;
			AddTimer(new CSaveBuffJob(this, 60, 0, "SaveBuff", "Saves the current buffer to disk every 1 minute"));
			const vector<CChan *>& vChans = m_pUser->GetChans();
			for (u_int a = 0; a < vChans.size(); a++)
			{
				if (!vChans[a]->KeepBuffer())
					continue;

				if (!BootStrap(vChans[a]))
				{
					PutUser(":***[email protected] PRIVMSG " + vChans[a]->GetName() + " :Failed to decrypt this channel, did you change the encryption pass?");
				}
			}
		}
	}

	bool BootStrap(CChan *pChan)
	{
		CString sFile;
		if (DecryptChannel(pChan->GetName(), sFile))
		{
			if (!pChan->GetBuffer().empty())
				return(true); // reloaded a module probably in this case, so just verify we can decrypt the file

			VCString vsLines;
			VCString::iterator it;

			sFile.Split("\n", vsLines);

			for (it = vsLines.begin(); it != vsLines.end(); ++it) {
				CString sLine(*it);
				sLine.Trim();
				pChan->AddBuffer(sLine);
			}
		} else
		{
			m_sPassword = "";
			CUtils::PrintError("[" + GetModName() + ".so] Failed to Decrypt [" + pChan->GetName() + "]");
			return(false);
		}

		return(true);
	}

	void SaveBufferToDisk()
	{
		if (!m_sPassword.empty())
		{
			const vector<CChan *>& vChans = m_pUser->GetChans();
			for (u_int a = 0; a < vChans.size(); a++)
			{
				CString sPath = GetPath(vChans[a]->GetName());
				CFile File(sPath);

				if (!vChans[a]->KeepBuffer()) {
					File.Delete();
					continue;
				}

				const vector<CString> & vBuffer = vChans[a]->GetBuffer();

				CString sFile = CRYPT_VERIFICATION_TOKEN;

				for (u_int b = 0; b < vBuffer.size(); b++)
				{
						sFile += vBuffer[b] + "\n";
				}

				CBlowfish c(m_sPassword, BF_ENCRYPT);
				sFile = c.Crypt(sFile);
				if (!sPath.empty())
				{
					if (File.Open(O_WRONLY | O_CREAT | O_TRUNC, 0600)) {
						File.Chmod(0600);
						File.Write(sFile);
					}
					File.Close();
				}
			}
		}
		else
		{
			PutModule( "Password is unset usually meaning the decryption failed. You can setpass to the appropriate pass and things should start working, or setpass to a new pass and save to reinstantiate" );
		}
	}

	virtual void OnModCommand(const CString& sCmdLine)
	{
		CString sCommand = sCmdLine.Token(0);
		CString sArgs    = sCmdLine.Token(1, true);

		if (sCommand.Equals("setpass"))
		{
			PutModule("Password set to [" + sArgs + "]");
			m_sPassword = CBlowfish::MD5(sArgs);

		} else if (sCommand.Equals("dumpbuff"))
		{
			CString sFile;
			if (DecryptChannel(sArgs, sFile))
			{
				VCString vsLines;
				VCString::iterator it;

				sFile.Split("\n", vsLines);

				for (it = vsLines.begin(); it != vsLines.end(); ++it) {
					CString sLine(*it);
					sLine.Trim();
					PutModule("[" + sLine + "]");
				}
			}
			PutModule("//!-- EOF " + sArgs);
		} else if (sCommand.Equals("replay"))
		{
			Replay(sArgs);
			PutModule("Replayed " + sArgs);

		} else if (sCommand.Equals("save"))
		{
			SaveBufferToDisk();
			PutModule("Done.");
		} else
			PutModule("Unknown command [" + sCommand + "]");
	}

	void Replay(const CString & sChan)
	{
		CString sFile;
		PutUser(":***[email protected] PRIVMSG " + sChan + " :Buffer Playback...");
		if (DecryptChannel(sChan, sFile))
		{
			VCString vsLines;
			VCString::iterator it;

			sFile.Split("\n", vsLines);

			for (it = vsLines.begin(); it != vsLines.end(); ++it) {
				CString sLine(*it);
				sLine.Trim();
				PutUser(sLine);
			}
		}
		PutUser(":***[email protected] PRIVMSG " + sChan + " :Playback Complete.");
	}

	CString GetPath(const CString & sChannel)
	{
		CString sBuffer = m_pUser->GetUserName() + sChannel.AsLower();
		CString sRet = GetSavePath();
		sRet += "/" + CBlowfish::MD5(sBuffer, true);
		return(sRet);
	}

#ifdef LEGACY_SAVEBUFF /* event logging is deprecated now in savebuf. Use buffextras module along side of this */
	CString SpoofChanMsg(const CString & sChannel, const CString & sMesg)
	{
		CString sReturn = ":*" + GetModName() + "[email protected] PRIVMSG " + sChannel + " :" + CString(time(NULL)) + " " + sMesg;
		return(sReturn);
	}
Exemplo n.º 15
0
static bool ModFill( void *_mod, drmem_hdl mod_handle )
/*****************************************************/
// fill in mod_handle for dip to dwarf mod map
// pick up general info about mod while here for later calls
{
    mod_list    *mod = _mod;
    char        fname[MAX_PATH];
    char        *name;
    char        *path;
    drmem_hdl   cu_tag;
    dr_model    model;
    mod_info    *modinfo;

    modinfo = NextModInfo( mod );
    modinfo->mod_handle = mod_handle;
    InitAddrSym( modinfo->addr_sym );
    modinfo->addr_size = DRGetAddrSize( mod_handle );
    cu_tag = DRGetCompileUnitTag( mod_handle );
    modinfo->cu_tag = cu_tag;
    modinfo->stmts = DRGetStmtList( cu_tag );
    path = DRGetName( cu_tag );
    if( path != NULL ) {
        GetModName( path, fname );
        DCFree( path );
        name = DCAlloc( strlen( fname ) + 1 );
        strcpy( name, fname );
    } else {
        name = NULL;
    }
    path = DRGetProducer( cu_tag );
    if( path != NULL ) {
        df_ver wat_producer_ver;

        if( memcmp( path, DWARF_WATCOM_PRODUCER_V3, sizeof( DWARF_WATCOM_PRODUCER_V3 ) - 1 ) == 0 ) {
            wat_producer_ver = VER_V3;
        } else if( memcmp( path, DWARF_WATCOM_PRODUCER_V2, sizeof( DWARF_WATCOM_PRODUCER_V2 ) - 1 ) == 0 ) {
            wat_producer_ver = VER_V2;
        } else if( memcmp( path, DWARF_WATCOM_PRODUCER_V1, sizeof( DWARF_WATCOM_PRODUCER_V1 ) - 1 ) == 0 ) {
            wat_producer_ver = VER_V1;
        } else {
            wat_producer_ver = VER_NONE;
        }
        if( mod->wat_producer_ver == VER_NONE ) {
            mod->wat_producer_ver = wat_producer_ver;
        } else if( mod->wat_producer_ver != wat_producer_ver ) {
            mod->wat_producer_ver = VER_ERROR;
        }
        DCFree( path );
    }
    modinfo->name = name;
    model = DRGetMemModelAT( cu_tag );
    if( DCCurrMAD() == MAD_X86 ) {
        switch( model ) {
        case DR_MODEL_NONE:
        case DR_MODEL_FLAT:
            modinfo->is_segment = false;
            break;
        default:
            modinfo->is_segment = true;
            break;
        }
    } else {
        modinfo->is_segment = false;
    }
    modinfo->model = model;
    modinfo->lang = DRGetLanguageAT( cu_tag );
    modinfo->dbg_pch = DRDebugPCHDef( cu_tag );
    modinfo->has_pubnames = false;
    return( true );
}
Exemplo n.º 16
0
void RoundInit (void)
{
   // this is called at the start of each round

   g_roundEnded = false;

   // SyPB Pro P.35 - Game Mode Setting
   if (GetGameMod() == 0)
   {
	   // check team economics
	   g_botManager->CheckTeamEconomics(TEAM_TERRORIST);
	   g_botManager->CheckTeamEconomics(TEAM_COUNTER);
   }

   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      if (g_botManager->GetBot (i))
         g_botManager->GetBot (i)->NewRound ();

      g_radioSelect[i] = 0;
   }
   g_waypoint->SetBombPosition (true);
   g_waypoint->ClearGoalScore ();

   // SyPB Pro P.38 - Zombie Mode Human Camp 
   g_waypoint->InitTypes(1);

   g_bombSayString = false;
   g_timeBombPlanted = 0.0f;
   g_timeNextBombUpdate = 0.0f;

   g_leaderChoosen[TEAM_COUNTER] = false;
   g_leaderChoosen[TEAM_TERRORIST] =  false;

   g_lastRadioTime[0] = 0.0f;
   g_lastRadioTime[1] = 0.0f;
   g_botsCanPause = false;

   g_entityIdAPI.RemoveAll();
   g_entityTeamAPI.RemoveAll();
   g_entityActionAPI.RemoveAll();

   // SyPB Pro P.15
   char *Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/plugins-dmkd.ini", GetModName());
   if (TryFileOpen(Plugin_INI))
   {
	   if (CVAR_GET_FLOAT("HsK_Deathmatch_Plugin_load_SyPB") == 1)
		   sypb_gamemod.SetInt(1);
	   else
		   sypb_gamemod.SetInt(0);
   }

   // SyPB Pro P.35 - ZP5.0 Fixed
   char *zpGameVersion[] =
   {
	   "plugins-zplague",  // ZP4.3
	   "plugins-zp50_ammopacks", // ZP5.0
	   "plugins-zp50_money" //ZP5.0
   };

   for (int i = 0; i < 3; i++)
   {
	   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/%s.ini", GetModName(), zpGameVersion[i]);
	   if (TryFileOpen(Plugin_INI))
	   {
		   float delayTime = CVAR_GET_FLOAT("zp_delay") + 2.0f;
		   if (i != 0)
			   delayTime = CVAR_GET_FLOAT("zp_gamemode_delay") + 0.2f;

		   if (delayTime > 0)
		   {
			   sypb_gamemod.SetInt(2);
			   sypb_walkallow.SetInt(0);
			   //g_DelayTimer = engine->GetTime() + delayTime + 6.0f;

			   // SyPB Pro P.34 - ZP TIME FIXED
			   g_DelayTimer = engine->GetTime() + delayTime;// +1.99f;
			   break;
		   }
	   }
   }

   // SyPB Pro P.11
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/zombiehell.cfg", GetModName());
   if (TryFileOpen(Plugin_INI) && CVAR_GET_FLOAT("zh_zombie_maxslots") > 0)
   {
	   sypb_gamemod.SetInt(4);
	   sypb_walkallow.SetInt(0);

	   extern ConVar sypb_quota;
	   sypb_quota.SetInt(static_cast <int> (CVAR_GET_FLOAT("zh_zombie_maxslots")));
   }

   // SyPB Pro P.29 - Support CSBTE Final
   Plugin_INI = FormatBuffer("%s/addons/amxmodx/configs/bte_player.ini", GetModName());
   if (TryFileOpen(Plugin_INI))
   {
	   const int Const_GameModes = 13;
	   int bteGameModAi[Const_GameModes] =
	   {
		   0, 0, 1, 3, 0, 2, 2, 2, 2, 4, 2, 3, 2
	   };//1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13

	   char *bteGameINI[Const_GameModes] =
	   {
		   "plugins-none", //1
		   "plugins-td",   //2
		   "plugins-dm",   //3
		   "plugins-dr",   //4
		   "plugins-gd",   //5
		   "plugins-ghost",//6
		   "plugins-zb1",  //7
		   "plugins-zb3",  //8
		   "plugins-zb4",  //9 
		   "plugins-ze",   //10
		   "plugins-zse",  //11
		   "plugins-npc",  //12
		   "plugins-zb5"   //13
	   };

	   for (int i = 0; i < Const_GameModes; i++)
	   {
		   if (TryFileOpen(FormatBuffer("%s/addons/amxmodx/configs/%s.ini", GetModName(), bteGameINI[i])))
		   {
			   //sypb_gamemod.SetInt(bteGameModAi[i]);

			   if (bteGameModAi[i] == 2 && i != 5)
			   {
				   sypb_walkallow.SetInt(0);
				   g_DelayTimer = engine->GetTime() + 20.0f + CVAR_GET_FLOAT("mp_freezetime");
			   }

			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   ServerPrint("*** CS:BTE [%s] - GameMod Setting [%d] ***", bteGameINI[i], bteGameModAi[i]);
			   if (i == 3 || i == 9)
			   {
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");
				   ServerPrint("***** SyPB not support the mode now :( *****");

				   sypb_gamemod.SetInt(10);
			   }
			   else
				   sypb_gamemod.SetInt(bteGameModAi[i]);

			   // SyPB Pro P.36 - bte support 
			   g_gameVersion = CSVER_CZERO;

			   break;
		   }
	   }
   }

   // SyPB Pro P.38 - Base Change 
   if (GetGameMod() != 0)
	   g_mapType |= MAP_DE;

   // SyPB Pro P.35 - Game Mode Setting
   if (GetGameMod () == 0)
	   g_exp.UpdateGlobalKnowledge (); // update experience data on round start

   // calculate the round mid/end in world time
   g_timeRoundStart = engine->GetTime () + engine->GetFreezeTime ();
   g_timeRoundMid = g_timeRoundStart + engine->GetRoundTime () * 60 / 2;
   g_timeRoundEnd = g_timeRoundStart + engine->GetRoundTime () * 60;
}
Exemplo n.º 17
0
	virtual EModRet OnDCCUserSend(const CNick& RemoteNick, unsigned long uLongIP, unsigned short uPort, const CString& sFile, unsigned long uFileSize) {
		if (RemoteNick.GetNick().Equals(GetModNick())) {
			CString sLocalFile = CDir::ChangeDir(m_sPath, sFile, CZNC::Get().GetHomePath());

			m_pUser->GetFile(m_pUser->GetCurNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize, GetModName());

			return HALT;
		}

		return CONTINUE;
	}