mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-08-25 21:32:00 +00:00
Merge original "Adrenalin Gamer" source code by @martinwebrant.
This commit is contained in:
parent
55a3ab741a
commit
aaede2f612
cl_dll
StudioModelRenderer.cpp
aghl
AgUDPClient.hAgVGUIPassword.cppAgVGUIPassword.hAgVGuiMapBrowser.cppAgVGuiMapBrowser.hAgglobal.cppagbase64.cppagbase64.hagcrc32.cppagcrc32.hagcrc32enforcer.cppagcrc32enforcer.hagdownload.cppagdownload.hagglobal.haghudcountdown.cppaghudcountdown.haghudctf.cppaghudctf.haghudcustomtimer.cppaghudcustomtimer.haghudglobal.cppaghudglobal.haghudirc.cppaghudirc.haghudlocation.cppaghudlocation.haghudlongjump.cppaghudlongjump.haghudnextmap.cppaghudnextmap.haghudplayerid.cppaghudplayerid.haghudscoreboard.cppaghudscoreboard.haghudsettings.cppaghudsettings.haghudsplash.cppaghudsplash.haghudsuddendeath.cppaghudsuddendeath.haghudtimeout.cppaghudtimeout.haghudtimer.cppaghudtimer.haghudvote.cppaghudvote.hagicq.cppagicq.hagirc.cppagirc.haglocation.cppaglocation.hagmapi.cppagmapi.hagmatchreport.cppagmatchreport.hagminidump.cppagmodel.cppagmodel.hagmodelcheck.cppagmodelcheck.hagpak.cppagpak.hagvariablechecker.cppagvariablechecker.hagversioninfo.cppagversioninfo.hagvguiirc.cppagvguiirc.hagvguiwinamp.cppagvguiwinamp.hagwallhack.cppagwallhack.hcrossthreadsmessagingdevice.cppcrossthreadsmessagingdevice.hdbghelp.hirc.cppirc.hsocket.cppsocket.h
ammo.cppcdll_int.cppcl_util.hdeath.cppev_hldm.cpphealth.cpphud.cpphud.hhud_redraw.cpphud_spectator.cppin_camera.cppinput.cppinputw32.cppsaytext.cppstatusbar.cppview.cppdlls/aghl
@ -1587,11 +1587,19 @@ void CStudioModelRenderer::StudioRenderFinal_Software( void )
|
||||
|
||||
if( m_pCvarDrawEntities->value == 2 )
|
||||
{
|
||||
//++ BulliT
|
||||
#ifdef _DEBUG
|
||||
IEngineStudio.StudioDrawBones();
|
||||
#endif
|
||||
//-- Martin Webrant
|
||||
}
|
||||
else if( m_pCvarDrawEntities->value == 3 )
|
||||
{
|
||||
//++ BulliT
|
||||
#ifdef _DEBUG
|
||||
IEngineStudio.StudioDrawHulls();
|
||||
#endif
|
||||
//-- Martin Webrant
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1604,14 +1612,22 @@ void CStudioModelRenderer::StudioRenderFinal_Software( void )
|
||||
|
||||
if( m_pCvarDrawEntities->value == 4 )
|
||||
{
|
||||
//++ BulliT
|
||||
#ifdef _DEBUG
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
|
||||
IEngineStudio.StudioDrawHulls();
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
|
||||
#endif
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
if( m_pCvarDrawEntities->value == 5 )
|
||||
{
|
||||
//++ BulliT
|
||||
#ifdef _DEBUG
|
||||
IEngineStudio.StudioDrawAbsBBox();
|
||||
#endif
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
IEngineStudio.RestoreRenderer();
|
||||
@ -1633,11 +1649,19 @@ void CStudioModelRenderer::StudioRenderFinal_Hardware( void )
|
||||
|
||||
if( m_pCvarDrawEntities->value == 2 )
|
||||
{
|
||||
//++ BulliT
|
||||
#ifdef _DEBUG
|
||||
IEngineStudio.StudioDrawBones();
|
||||
#endif
|
||||
//-- Martin Webrant
|
||||
}
|
||||
else if( m_pCvarDrawEntities->value == 3 )
|
||||
{
|
||||
//++ BulliT
|
||||
#ifdef _DEBUG
|
||||
IEngineStudio.StudioDrawHulls();
|
||||
#endif
|
||||
//-- Martin Webrant
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1659,14 +1683,22 @@ void CStudioModelRenderer::StudioRenderFinal_Hardware( void )
|
||||
|
||||
if( m_pCvarDrawEntities->value == 4 )
|
||||
{
|
||||
//++ BulliT
|
||||
#ifdef _DEBUG
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
|
||||
IEngineStudio.StudioDrawHulls();
|
||||
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
|
||||
#endif
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
if( m_pCvarDrawEntities->value == 5 )
|
||||
{
|
||||
//++ BulliT
|
||||
#ifdef _DEBUG
|
||||
IEngineStudio.StudioDrawAbsBBox();
|
||||
#endif
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
IEngineStudio.RestoreRenderer();
|
||||
|
129
cl_dll/aghl/AgUDPClient.h
Normal file
129
cl_dll/aghl/AgUDPClient.h
Normal file
@ -0,0 +1,129 @@
|
||||
//A simple UDP client.
|
||||
|
||||
#pragma comment(lib,"wsock32.lib")
|
||||
|
||||
class AgUDPClient
|
||||
{
|
||||
public:
|
||||
static bool Init()
|
||||
{
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(MAKEWORD(1,1), &wsaData))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool Cleanup()
|
||||
{
|
||||
if (WSACleanup())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
AgUDPClient()
|
||||
{
|
||||
m_Socket = INVALID_SOCKET;
|
||||
ZeroMemory(&m_ServerAddress,sizeof(m_ServerAddress));
|
||||
}
|
||||
|
||||
bool Connect(const char* pszAddress, unsigned short usPort)
|
||||
{
|
||||
m_Socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
if (m_Socket == INVALID_SOCKET)
|
||||
return false;
|
||||
|
||||
m_ServerAddress.sin_family = AF_INET;
|
||||
m_ServerAddress.sin_port = htons(usPort);
|
||||
m_ServerAddress.sin_addr.s_addr = inet_addr(pszAddress);
|
||||
|
||||
if (m_ServerAddress.sin_addr.s_addr == INADDR_NONE)
|
||||
{
|
||||
//Resolve hostname.
|
||||
struct hostent* host = gethostbyname(pszAddress);
|
||||
if (host == NULL)
|
||||
return false; //Could not resolve hostname
|
||||
CopyMemory(&m_ServerAddress.sin_addr,
|
||||
host->h_addr_list[0],host->h_length);
|
||||
}
|
||||
|
||||
if (connect(m_Socket,(struct sockaddr *)&m_ServerAddress, sizeof(m_ServerAddress)) == SOCKET_ERROR)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WaitForRecieve(UINT uiMilliSeconds = INFINITE)
|
||||
{
|
||||
fd_set ReadSet;
|
||||
FD_ZERO(&ReadSet);
|
||||
FD_SET(m_Socket, &ReadSet);
|
||||
if (1 != select(0, &ReadSet, NULL, NULL, TimeVal(uiMilliSeconds)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WaitForSend(UINT uiMilliSeconds = INFINITE)
|
||||
{
|
||||
fd_set WriteSet;
|
||||
FD_ZERO(&WriteSet);
|
||||
FD_SET(m_Socket, &WriteSet);
|
||||
if (1 != select(0, NULL, &WriteSet, NULL, TimeVal(uiMilliSeconds)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WaitForError(UINT uiMilliSeconds = INFINITE)
|
||||
{
|
||||
fd_set ErrorSet;
|
||||
FD_ZERO(&ErrorSet);
|
||||
FD_SET(m_Socket, &ErrorSet);
|
||||
if (1 != select(0, NULL, NULL, &ErrorSet, TimeVal(uiMilliSeconds)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned long Send(const char* pData, const unsigned long lSize)
|
||||
{
|
||||
return send(m_Socket, pData, lSize, 0);
|
||||
}
|
||||
|
||||
unsigned long Receive(char* pData, const unsigned long lSize)
|
||||
{
|
||||
return recv(m_Socket, pData, lSize, 0);
|
||||
}
|
||||
|
||||
protected:
|
||||
class TimeVal
|
||||
{
|
||||
public:
|
||||
TimeVal(UINT uiMilliSeconds)
|
||||
{
|
||||
m_bNull = false;
|
||||
if (uiMilliSeconds == INFINITE)
|
||||
m_bNull = true;
|
||||
else if(uiMilliSeconds <= 0)
|
||||
{
|
||||
m_TimeVal.tv_sec = 0;
|
||||
m_TimeVal.tv_usec = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TimeVal.tv_sec = uiMilliSeconds / 1000;
|
||||
m_TimeVal.tv_usec = (uiMilliSeconds % 1000) * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
operator timeval*()
|
||||
{
|
||||
if (m_bNull)
|
||||
return NULL;
|
||||
return &m_TimeVal;
|
||||
}
|
||||
protected:
|
||||
bool m_bNull;
|
||||
timeval m_TimeVal;
|
||||
};
|
||||
|
||||
SOCKET m_Socket;
|
||||
struct sockaddr_in m_ServerAddress;
|
||||
};
|
276
cl_dll/aghl/AgVGUIPassword.cpp
Normal file
276
cl_dll/aghl/AgVGUIPassword.cpp
Normal file
@ -0,0 +1,276 @@
|
||||
//++ BulliT
|
||||
|
||||
#include<VGUI_HeaderPanel.h>
|
||||
#include<VGUI_TablePanel.h>
|
||||
#include<VGUI_LineBorder.h>
|
||||
#include<VGUI_Label.h>
|
||||
#include<VGUI_Button.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include<VGUI_TextGrid.h>
|
||||
#include<VGUI_TextEntry.h>
|
||||
#include<VGUI_EtchedBorder.h>
|
||||
#include<VGUI_LoweredBorder.h>
|
||||
#include "VGUI_ScrollPanel.h"
|
||||
#include "VGUI_TextImage.h"
|
||||
#include<VGUI_StackLayout.h>
|
||||
#include<VGUI_EditPanel.h>
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <keydefs.h>
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "AgVGuiPassword.h"
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class TextHandler : public ActionSignal
|
||||
{
|
||||
private:
|
||||
|
||||
AgVGuiPassword* _AgVGuiPassword;
|
||||
|
||||
public:
|
||||
|
||||
TextHandler(AgVGuiPassword* AgVGuiPassword)
|
||||
{
|
||||
_AgVGuiPassword=AgVGuiPassword;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_AgVGuiPassword->doConnect();
|
||||
}
|
||||
};
|
||||
|
||||
class ConnectHandler : public ActionSignal
|
||||
{
|
||||
private:
|
||||
|
||||
AgVGuiPassword* _AgVGuiPassword;
|
||||
|
||||
public:
|
||||
|
||||
ConnectHandler(AgVGuiPassword* AgVGuiPassword)
|
||||
{
|
||||
_AgVGuiPassword=AgVGuiPassword;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_AgVGuiPassword->doConnect();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TextInput : public vgui::TextEntry
|
||||
{
|
||||
public:
|
||||
TextInput(const char* text,int x,int y,int wide,int tall) : TextEntry(text,x,y,wide,tall)
|
||||
{
|
||||
};
|
||||
|
||||
virtual void keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
if (gViewPort->m_pPassword->isVisible())
|
||||
TextEntry::keyPressed(code,panel);
|
||||
};
|
||||
virtual void keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
if (gViewPort->m_pPassword->isVisible())
|
||||
TextEntry::keyTyped(code,panel);
|
||||
};
|
||||
virtual void keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
if (gViewPort->m_pPassword->isVisible())
|
||||
TextEntry::keyReleased(code,panel);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#define VGUIPASSWORD_TITLE_X XRES(16)
|
||||
#define VGUIPASSWORD_TITLE_Y YRES(16)
|
||||
#define TEXT_SIZE_Y YRES(16)
|
||||
|
||||
AgVGuiPassword::AgVGuiPassword(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0)) );
|
||||
|
||||
// Get the scheme used for the Titles
|
||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
||||
|
||||
// schemes
|
||||
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
|
||||
// SchemeHandle_t hVGUIPasswordText = pSchemes->getSchemeHandle( "Briefing Text" );
|
||||
|
||||
// color schemes
|
||||
int r, g, b, a;
|
||||
|
||||
// Create the title
|
||||
m_pLabel = new Label( "", VGUIPASSWORD_TITLE_X, VGUIPASSWORD_TITLE_Y );
|
||||
m_pLabel->setParent( this );
|
||||
m_pLabel->setFont( pSchemes->getFont(hTitleScheme) );
|
||||
m_pLabel->setFont( Scheme::sf_primary1 );
|
||||
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
m_pLabel->setFgColor( r, g, b, a );
|
||||
m_pLabel->setFgColor( Scheme::sc_primary1 );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
m_pLabel->setBgColor( r, g, b, a );
|
||||
m_pLabel->setContentAlignment( vgui::Label::a_west );
|
||||
m_pLabel->setText("Enter Password");
|
||||
|
||||
int iXSize,iYSize;
|
||||
getSize( iXSize,iYSize );
|
||||
|
||||
int iTemp = iYSize - YRES(24) - VGUIPASSWORD_TITLE_Y - BUTTON_SIZE_Y; //Hack to get it to work with Visual 7.0 beta 2
|
||||
m_pTextEntry = new TextInput("",XRES(16), iTemp, iXSize - 2*XRES(16), TEXT_SIZE_Y);
|
||||
m_pTextEntry->setParent(this);
|
||||
m_pTextEntry->addActionSignal(new TextHandler(this));
|
||||
|
||||
m_pConnect = new CommandButton("Connect",XRES(16), iYSize - YRES(16) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y);
|
||||
m_pConnect->addActionSignal(new ConnectHandler(this));
|
||||
m_pConnect->setParent(this);
|
||||
|
||||
ReadPasswords();
|
||||
}
|
||||
|
||||
|
||||
void AgVGuiPassword::doConnect()
|
||||
{
|
||||
char szPassword[256];
|
||||
szPassword[0] = '\0';
|
||||
m_pTextEntry->getText(0,szPassword,sizeof(szPassword));
|
||||
|
||||
AgAddressToPasswordMap::iterator itrPasswords = m_mapPasswords.find(m_sAddress.c_str());
|
||||
if (itrPasswords != m_mapPasswords.end())
|
||||
(*itrPasswords).second = szPassword;
|
||||
else
|
||||
m_mapPasswords.insert(AgAddressToPasswordMap::value_type(m_sAddress,szPassword));
|
||||
SavePasswords();
|
||||
|
||||
char szCMD[256];
|
||||
sprintf(szCMD,"password %s\n", szPassword);
|
||||
ClientCmd(szCMD);
|
||||
|
||||
sprintf(szCMD, "connect %s\n", m_sAddress.c_str() );
|
||||
ClientCmd(szCMD);
|
||||
|
||||
gViewPort->HidePassword();
|
||||
}
|
||||
|
||||
void AgVGuiPassword::paintBackground()
|
||||
{
|
||||
// Transparent black background
|
||||
drawSetColor( 0,0,0, 100 );
|
||||
drawFilledRect(0,0,_size[0],_size[1]);
|
||||
}
|
||||
|
||||
int AgVGuiPassword::KeyInput(int down, int keynum, const char *pszCurrentBinding)
|
||||
{
|
||||
if (!down)
|
||||
return 1;
|
||||
|
||||
if (!isVisible())
|
||||
return 1;
|
||||
|
||||
if (K_ESCAPE == keynum)
|
||||
{
|
||||
gViewPort->HidePassword();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (m_pTextEntry->hasFocus())
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void AgVGuiPassword::Connect(const char* pszHostname, const char* pszAddress, bool bPassworded)
|
||||
{
|
||||
m_sAddress = pszAddress;
|
||||
|
||||
if (!bPassworded)
|
||||
{
|
||||
doConnect();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"Enter password for %s",pszHostname);
|
||||
m_pLabel->setText(szMessage,strlen(szMessage));
|
||||
|
||||
AgString sPassword;
|
||||
AgAddressToPasswordMap::iterator itrPasswords = m_mapPasswords.find(pszAddress);
|
||||
if (itrPasswords != m_mapPasswords.end())
|
||||
sPassword = (*itrPasswords).second;
|
||||
|
||||
m_pTextEntry->setText(sPassword.c_str(),sPassword.length());
|
||||
gViewPort->ShowPassword();
|
||||
}
|
||||
}
|
||||
|
||||
void AgVGuiPassword::ReadPasswords()
|
||||
{
|
||||
char szData[4096];
|
||||
char szFile[MAX_PATH];
|
||||
sprintf(szFile,"%s/passwords.txt",AgGetDirectory());
|
||||
FILE* pFile = fopen(szFile,"r");
|
||||
if (!pFile)
|
||||
return;
|
||||
|
||||
int iRead = fread(szData,sizeof(char),sizeof(szData)-2,pFile);
|
||||
fclose(pFile);
|
||||
if (0 >= iRead)
|
||||
return;
|
||||
szData[iRead] = '\0';
|
||||
|
||||
char* pszPasswordString = strtok( szData, "\n");
|
||||
while (pszPasswordString != NULL)
|
||||
{
|
||||
char szAddress[64],szPassword[64];
|
||||
szAddress[0] = '\0';
|
||||
szPassword[0] = '\0';
|
||||
sscanf(pszPasswordString,"%s %s\n",szAddress,szPassword);
|
||||
|
||||
AgString sAddress(szAddress);
|
||||
AgString sPassword(szPassword);
|
||||
AgTrim(sAddress);
|
||||
AgTrim(sPassword);
|
||||
m_mapPasswords.insert(AgAddressToPasswordMap::value_type(sAddress,sPassword));
|
||||
pszPasswordString = strtok( NULL, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void AgVGuiPassword::SavePasswords()
|
||||
{
|
||||
char szFile[MAX_PATH];
|
||||
sprintf(szFile,"%s/passwords.txt",AgGetDirectory());
|
||||
FILE* pFile = fopen(szFile,"wb");
|
||||
if (!pFile)
|
||||
{
|
||||
// file error
|
||||
char szMsg[128];
|
||||
sprintf(szMsg,"Couldn't create/save password file %s.\n",szFile);
|
||||
ConsolePrint(szMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
//Loop and write the file.
|
||||
for (AgAddressToPasswordMap::iterator itrPasswords = m_mapPasswords.begin() ;itrPasswords != m_mapPasswords.end(); ++itrPasswords)
|
||||
fprintf(pFile,"%s %s\n",(*itrPasswords).first.c_str(),(*itrPasswords).second.c_str());
|
||||
|
||||
fflush(pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
//-- Martin Webrant
|
43
cl_dll/aghl/AgVGUIPassword.h
Normal file
43
cl_dll/aghl/AgVGUIPassword.h
Normal file
@ -0,0 +1,43 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_VGUI_Password_)
|
||||
#define _AG_VGUI_Password_
|
||||
|
||||
#include<stdarg.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class TextEntry;
|
||||
class TextPanel;
|
||||
class EditPanel;
|
||||
}
|
||||
|
||||
class AgVGuiPassword : public vgui::Panel
|
||||
{
|
||||
private:
|
||||
vgui::Label* m_pLabel;
|
||||
vgui::TextEntry* m_pTextEntry;
|
||||
CommandButton* m_pConnect;
|
||||
|
||||
AgString m_sAddress;
|
||||
typedef map<AgString, AgString, less<AgString> > AgAddressToPasswordMap;
|
||||
AgAddressToPasswordMap m_mapPasswords;
|
||||
|
||||
void ReadPasswords();
|
||||
void SavePasswords();
|
||||
|
||||
public:
|
||||
AgVGuiPassword(int x,int y,int wide,int tall);
|
||||
public:
|
||||
virtual void doConnect();
|
||||
virtual void paintBackground();
|
||||
|
||||
virtual int KeyInput(int down, int keynum, const char *pszCurrentBinding);
|
||||
|
||||
void Connect(const char* pszHostname, const char* pszAddress, bool bPassworded);
|
||||
};
|
||||
|
||||
#endif //_AG_VGUI_Password_
|
||||
|
||||
//-- Martin Webrant
|
606
cl_dll/aghl/AgVGuiMapBrowser.cpp
Normal file
606
cl_dll/aghl/AgVGuiMapBrowser.cpp
Normal file
@ -0,0 +1,606 @@
|
||||
|
||||
#include<VGUI_HeaderPanel.h>
|
||||
#include<VGUI_TablePanel.h>
|
||||
#include<VGUI_LineBorder.h>
|
||||
#include<VGUI_Label.h>
|
||||
#include<VGUI_Button.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include "VGUI_ScrollPanel.h"
|
||||
#include "VGUI_TextImage.h"
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "AgVGuiMapBrowser.h"
|
||||
#include "parsemsg.h"
|
||||
#include <keydefs.h>
|
||||
|
||||
static int g_iStartIndex = 0;
|
||||
static AgString s_sMapList;
|
||||
static bool s_bHaveAllMaps = true;
|
||||
static AgStringSet s_setMaps;
|
||||
static AgStringSet s_setLocalMaps;
|
||||
extern cvar_t* g_pcl_show_local_maps;
|
||||
|
||||
const char* GetMap(unsigned int iRow)
|
||||
{
|
||||
if (iRow < s_setMaps.size())
|
||||
{
|
||||
AgStringSet::iterator itrMaps = s_setMaps.begin();
|
||||
for (unsigned int i = 0; i < iRow && itrMaps != s_setMaps.end(); i++, itrMaps++)
|
||||
{}
|
||||
|
||||
if (itrMaps != s_setMaps.end())
|
||||
return (*itrMaps).c_str();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class MapBrowserTablePanel;
|
||||
|
||||
class MapBrowserTablePanel_InputSignal : public InputSignal
|
||||
{
|
||||
MapBrowserTablePanel* m_pMapBrowser;
|
||||
public:
|
||||
MapBrowserTablePanel_InputSignal(MapBrowserTablePanel* pMapBrowser)
|
||||
{
|
||||
m_pMapBrowser = pMapBrowser;
|
||||
}
|
||||
virtual void cursorMoved(int x,int y,Panel* panel) {};
|
||||
virtual void cursorEntered(Panel* panel){};
|
||||
virtual void cursorExited(Panel* Panel) {};
|
||||
virtual void mousePressed(MouseCode code,Panel* panel);
|
||||
virtual void mouseDoublePressed(MouseCode code,Panel* panel);
|
||||
virtual void mouseReleased(MouseCode code,Panel* panel) {};
|
||||
virtual void mouseWheeled(int delta,Panel* panel) {};
|
||||
virtual void keyPressed(KeyCode code,Panel* panel) {};
|
||||
virtual void keyTyped(KeyCode code,Panel* panel) {};
|
||||
virtual void keyReleased(KeyCode code,Panel* panel) {};
|
||||
virtual void keyFocusTicked(Panel* panel) {};
|
||||
};
|
||||
|
||||
#define CELL_HEIGHT YRES(15)
|
||||
|
||||
class MapBrowserTablePanel : public TablePanel
|
||||
{
|
||||
private:
|
||||
Label *m_pLabel;
|
||||
int m_nMouseOverRow;
|
||||
|
||||
public:
|
||||
|
||||
MapBrowserTablePanel( int x,int y,int wide,int tall,int columnCount) : TablePanel( x,y,wide,tall,columnCount)
|
||||
{
|
||||
m_pLabel = new Label( "", 0, 0 );
|
||||
|
||||
m_nMouseOverRow = 0;
|
||||
setCellEditingEnabled(false);
|
||||
}
|
||||
|
||||
public:
|
||||
void setMouseOverRow( int row )
|
||||
{
|
||||
m_nMouseOverRow = row;
|
||||
|
||||
DoUpdateMap();
|
||||
}
|
||||
|
||||
void DoChangeMap( void )
|
||||
{
|
||||
stopCellEditing();
|
||||
DoCancel();
|
||||
const char* pszMap = GetMap(m_nMouseOverRow + g_iStartIndex);
|
||||
|
||||
if (pszMap && strlen(pszMap))
|
||||
{
|
||||
char szCommand[256];
|
||||
sprintf(szCommand,"agmap %s",pszMap);
|
||||
ServerCmd(szCommand);
|
||||
}
|
||||
}
|
||||
|
||||
void DoChangeNextMap( void )
|
||||
{
|
||||
DoCancel();
|
||||
const char* pszMap = GetMap(m_nMouseOverRow + g_iStartIndex);
|
||||
|
||||
if (pszMap && strlen(pszMap))
|
||||
{
|
||||
char szCommand[256];
|
||||
sprintf(szCommand,"agnextmap %s",pszMap);
|
||||
ServerCmd(szCommand);
|
||||
}
|
||||
}
|
||||
|
||||
void DoCancel( void )
|
||||
{
|
||||
ClientCmd( "togglemapbrowser\n" );
|
||||
}
|
||||
|
||||
|
||||
void DoPrev( void )
|
||||
{
|
||||
g_iStartIndex -= getRowCount();
|
||||
if (g_iStartIndex < 0)
|
||||
g_iStartIndex = 0;
|
||||
|
||||
DoUpdateMap();
|
||||
}
|
||||
|
||||
|
||||
void DoNext( void )
|
||||
{
|
||||
g_iStartIndex += getRowCount();
|
||||
if (g_iStartIndex > (int)s_setMaps.size())
|
||||
g_iStartIndex = 0;
|
||||
|
||||
DoUpdateMap();
|
||||
}
|
||||
|
||||
void DoUpdateMap( void )
|
||||
{
|
||||
AgVGuiMapBrowser* pVGUI = (AgVGuiMapBrowser*)getParent();
|
||||
pVGUI->UpdateMap(GetMap(m_nMouseOverRow + g_iStartIndex));
|
||||
}
|
||||
|
||||
virtual int getRowCount()
|
||||
{
|
||||
int rowcount;
|
||||
int height, width;
|
||||
|
||||
getSize( width, height );
|
||||
height = max( 0, height );
|
||||
rowcount = height / CELL_HEIGHT;
|
||||
|
||||
return rowcount;
|
||||
}
|
||||
|
||||
virtual int getCellTall(int row)
|
||||
{
|
||||
return CELL_HEIGHT - 2;
|
||||
}
|
||||
|
||||
virtual Panel* getCellRenderer(int column,int row,bool columnSelected,bool rowSelected,bool cellSelected)
|
||||
{
|
||||
const char* pszMap = GetMap(row + g_iStartIndex);
|
||||
if ( row == m_nMouseOverRow )
|
||||
{
|
||||
m_pLabel->setFgColor( 255, 255, 255, 0 );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pLabel->setFgColor( 200, 240, 63, 100 );
|
||||
if (pszMap && strlen(pszMap))
|
||||
{
|
||||
AgStringSet::iterator itrLocalMaps = s_setLocalMaps.find(pszMap);
|
||||
if (itrLocalMaps == s_setLocalMaps.end())
|
||||
m_pLabel->setFgColor( 200, 0, 0, 100 );
|
||||
}
|
||||
}
|
||||
m_pLabel->setBgColor( 0, 0, 0, 200 );
|
||||
m_pLabel->setContentAlignment( vgui::Label::a_west );
|
||||
m_pLabel->setFont( Scheme::sf_primary2 );
|
||||
|
||||
if ( pszMap )
|
||||
{
|
||||
// Fill out with the correct data
|
||||
switch ( column )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_pLabel->setText( pszMap );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !row && !column )
|
||||
{
|
||||
if ( !s_bHaveAllMaps )
|
||||
{
|
||||
m_pLabel->setText( "Please wait..." );
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_pLabel->setText( "Press 'Refresh' to search for servers..." );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pLabel->setText( "" );
|
||||
}
|
||||
}
|
||||
|
||||
return m_pLabel;
|
||||
}
|
||||
|
||||
virtual Panel* startCellEditing(int column,int row)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
enum Action
|
||||
{
|
||||
Close, More, Previous, Change, ChangeNext,
|
||||
};
|
||||
|
||||
class MapBrowserHandler : public ActionSignal
|
||||
{
|
||||
Action m_act;
|
||||
MapBrowserTablePanel* m_pMapBrowser;
|
||||
public:
|
||||
MapBrowserHandler(Action act, MapBrowserTablePanel* pMapBrowser)
|
||||
{
|
||||
m_act = act;
|
||||
m_pMapBrowser = pMapBrowser;
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
switch (m_act)
|
||||
{
|
||||
case Close:
|
||||
gViewPort->ToggleMapBrowser();
|
||||
break;
|
||||
case More:
|
||||
m_pMapBrowser->DoNext();
|
||||
break;
|
||||
case Change:
|
||||
m_pMapBrowser->DoChangeMap();
|
||||
break;
|
||||
case ChangeNext:
|
||||
m_pMapBrowser->DoChangeNextMap();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void MapBrowserTablePanel_InputSignal::mousePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
int x, y;
|
||||
int therow = 2;
|
||||
|
||||
if ( code != MOUSE_LEFT )
|
||||
return;
|
||||
|
||||
panel->getApp()->getCursorPos(x,y);
|
||||
panel->screenToLocal( x, y );
|
||||
|
||||
therow = y / (CELL_HEIGHT);
|
||||
|
||||
// Figure out which row it's on
|
||||
m_pMapBrowser->setMouseOverRow( therow );
|
||||
}
|
||||
|
||||
void MapBrowserTablePanel_InputSignal::mouseDoublePressed(MouseCode code,Panel* panel)
|
||||
{
|
||||
int x, y;
|
||||
int therow = 2;
|
||||
|
||||
if ( code != MOUSE_LEFT )
|
||||
return;
|
||||
|
||||
panel->getApp()->getCursorPos(x,y);
|
||||
panel->screenToLocal( x, y );
|
||||
|
||||
therow = y / (CELL_HEIGHT-1);
|
||||
|
||||
// Figure out which row it's on
|
||||
m_pMapBrowser->setMouseOverRow( therow );
|
||||
m_pMapBrowser->DoChangeMap();
|
||||
}
|
||||
}
|
||||
|
||||
#define MAPBROWSER_TITLE_X XRES(16)
|
||||
#define MAPBROWSER_TITLE_Y YRES(16)
|
||||
|
||||
#define MAPBROWSER_BUTTON_SIZE_X XRES(100)
|
||||
#define MAPBROWSER_BUTTON_SIZE_Y YRES(24)
|
||||
#define MAPBROWSER_BUTTON_SPACER_Y YRES(8)
|
||||
#define MAPBROWSER_BUTTON_SPACER_X XRES(8)
|
||||
|
||||
#define TABLE_X XRES(8)
|
||||
#define TABLE_Y YRES(60)
|
||||
#define HEADER_SIZE_X XRES(100)
|
||||
#define HEADER_SIZE_Y 0 //YRES(18)
|
||||
|
||||
#define NUM_COLUMNS 1
|
||||
|
||||
AgVGuiMapBrowser::AgVGuiMapBrowser(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0)) );
|
||||
|
||||
// Get the scheme used for the Titles
|
||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
||||
|
||||
// schemes
|
||||
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
|
||||
SchemeHandle_t hIRCText = pSchemes->getSchemeHandle( "Briefing Text" );
|
||||
|
||||
// color schemes
|
||||
int r, g, b, a;
|
||||
|
||||
// Create the title
|
||||
m_pLabel = new Label( "", MAPBROWSER_TITLE_X, MAPBROWSER_TITLE_Y );
|
||||
m_pLabel->setParent( this );
|
||||
m_pLabel->setFont( pSchemes->getFont(hTitleScheme) );
|
||||
m_pLabel->setFont( Scheme::sf_primary1 );
|
||||
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
m_pLabel->setFgColor( r, g, b, a );
|
||||
// m_pLabel->setFgColor( Scheme::sc_primary1 );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
m_pLabel->setBgColor( r, g, b, a );
|
||||
m_pLabel->setContentAlignment( vgui::Label::a_west );
|
||||
m_pLabel->setText("AG Map Browser");
|
||||
|
||||
int iXSize,iYSize;
|
||||
getSize( iXSize,iYSize );
|
||||
|
||||
Label* pHeaderLabel = new Label("Maps");
|
||||
pHeaderLabel->setContentAlignment( vgui::Label::a_west );
|
||||
pHeaderLabel->setFgColor( Scheme::sc_primary1 );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
pHeaderLabel->setBgColor( r, g, b, a );
|
||||
pHeaderLabel->setFont( Scheme::sf_primary2 );
|
||||
|
||||
m_pHeaderPanel= new HeaderPanel(TABLE_X,TABLE_Y,HEADER_SIZE_X,HEADER_SIZE_Y);
|
||||
m_pHeaderPanel->setParent(this);
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
m_pHeaderPanel->setFgColor( r, g, b, a );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
m_pHeaderPanel->setBgColor( r, g, b, a );
|
||||
m_pHeaderPanel->addSectionPanel(pHeaderLabel);
|
||||
m_pHeaderPanel->setSliderPos( 0, HEADER_SIZE_X );
|
||||
|
||||
m_pTablePanel = new MapBrowserTablePanel( TABLE_X, TABLE_Y + HEADER_SIZE_Y, HEADER_SIZE_X, iYSize - (TABLE_Y + HEADER_SIZE_Y + MAPBROWSER_BUTTON_SIZE_Y*2 + MAPBROWSER_BUTTON_SPACER_Y), NUM_COLUMNS );
|
||||
m_pTablePanel->setParent(this);
|
||||
m_pTablePanel->setHeaderPanel(m_pHeaderPanel);
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
m_pTablePanel->setFgColor( r, g, b, a );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
m_pTablePanel->setBgColor( r, g, b, a );
|
||||
m_pTablePanel->addInputSignal(new MapBrowserTablePanel_InputSignal((MapBrowserTablePanel*)m_pTablePanel));
|
||||
|
||||
int bw = MAPBROWSER_BUTTON_SIZE_X;
|
||||
int bh = MAPBROWSER_BUTTON_SIZE_Y;
|
||||
int btny = iYSize - YRES(16) - BUTTON_SIZE_Y;//tall - MAPBROWSER_BUTTON_SIZE_Y - MAPBROWSER_BUTTON_SPACER_Y;
|
||||
int btnx = TABLE_X;
|
||||
|
||||
CommandButton* pMore = new CommandButton("More",btnx, btny, bw, bh);
|
||||
pMore->addActionSignal(new MapBrowserHandler(More,(MapBrowserTablePanel*)m_pTablePanel));
|
||||
pMore->setParent(this);
|
||||
|
||||
btnx += MAPBROWSER_BUTTON_SPACER_X + MAPBROWSER_BUTTON_SIZE_X;
|
||||
|
||||
CommandButton* pChange = new CommandButton("Change Now",btnx, btny, bw, bh);
|
||||
pChange->addActionSignal(new MapBrowserHandler(Change,(MapBrowserTablePanel*)m_pTablePanel));
|
||||
pChange->setParent(this);
|
||||
|
||||
btnx += MAPBROWSER_BUTTON_SPACER_X + MAPBROWSER_BUTTON_SIZE_X;
|
||||
|
||||
CommandButton* pChangeNext = new CommandButton("Change Next",btnx, btny, bw, bh);
|
||||
pChangeNext->addActionSignal(new MapBrowserHandler(ChangeNext,(MapBrowserTablePanel*)m_pTablePanel));
|
||||
pChangeNext->setParent(this);
|
||||
|
||||
btnx += MAPBROWSER_BUTTON_SPACER_X + MAPBROWSER_BUTTON_SIZE_X;
|
||||
|
||||
CommandButton* pClose = new CommandButton("Close",btnx, btny, bw, bh);
|
||||
pClose->addActionSignal(new MapBrowserHandler(Close,(MapBrowserTablePanel*)m_pTablePanel));
|
||||
pClose->setParent(this);
|
||||
|
||||
// Create the Scroll panel
|
||||
m_pTextScrollPanel = new CTFScrollPanel( TABLE_X + HEADER_SIZE_X + XRES(16), TABLE_Y + HEADER_SIZE_Y, iXSize - (TABLE_X + HEADER_SIZE_X + XRES(16)), iYSize - (TABLE_Y + HEADER_SIZE_Y + MAPBROWSER_BUTTON_SIZE_Y + MAPBROWSER_BUTTON_SPACER_Y + MAPBROWSER_TITLE_Y + YRES(8)));
|
||||
m_pTextScrollPanel->setParent(this);
|
||||
m_pTextScrollPanel->setScrollBarVisible(false, false);
|
||||
m_pTextScrollPanel->setScrollBarAutoVisible(true, true);
|
||||
|
||||
|
||||
// Create the text panel
|
||||
m_pTextPanel = new TextPanel( "", 0,0, 64,64);
|
||||
m_pTextPanel->setParent( m_pTextScrollPanel->getClient() );
|
||||
|
||||
// get the font and colors from the scheme
|
||||
m_pTextPanel->setFont( pSchemes->getFont(hIRCText) );
|
||||
pSchemes->getFgColor( hIRCText, r, g, b, a );
|
||||
m_pTextPanel->setFgColor( r, g, b, a );
|
||||
pSchemes->getBgColor( hIRCText, r, g, b, a );
|
||||
m_pTextPanel->setBgColor( r, g, b, a );
|
||||
m_pTextPanel->setText(gHUD.m_TextMessage.BufferedLocaliseTextString("#Map_Description_not_available"));
|
||||
|
||||
m_pTextScrollPanel->setScrollValue( 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
void AgVGuiMapBrowser::paintBackground()
|
||||
{
|
||||
// Transparent black background
|
||||
drawSetColor( 0,0,0, 100 );
|
||||
drawFilledRect(0,0,_size[0],_size[1]);
|
||||
}
|
||||
|
||||
void AgVGuiMapBrowser::UpdateMap(const char* pszMap)
|
||||
{
|
||||
char* pText = NULL;
|
||||
|
||||
if (pszMap)
|
||||
{
|
||||
char szMapFile[MAX_PATH];
|
||||
sprintf(szMapFile,"maps/%s.txt",pszMap);
|
||||
pText = (char*)gEngfuncs.COM_LoadFile(szMapFile, 5, NULL);
|
||||
}
|
||||
|
||||
//force the scrollbars on so clientClip will take them in account after the validate
|
||||
m_pTextScrollPanel->setScrollBarAutoVisible(false, false);
|
||||
m_pTextScrollPanel->setScrollBarVisible(true, true);
|
||||
m_pTextScrollPanel->validate();
|
||||
|
||||
if (pText)
|
||||
m_pTextPanel->setText(pText);
|
||||
else
|
||||
m_pTextPanel->setText(gHUD.m_TextMessage.BufferedLocaliseTextString("#Map_Description_not_available"));
|
||||
|
||||
|
||||
// Get the total size of the MOTD text and resize the text panel
|
||||
int iScrollSizeX, iScrollSizeY;
|
||||
|
||||
// First, set the size so that the client's wdith is correct at least because the
|
||||
// width is critical for getting the "wrapped" size right.
|
||||
// You'll see a horizontal scroll bar if there is a single word that won't wrap in the
|
||||
// specified width.
|
||||
m_pTextPanel->getTextImage()->setSize(m_pTextScrollPanel->getClientClip()->getWide(), m_pTextScrollPanel->getClientClip()->getTall());
|
||||
m_pTextPanel->getTextImage()->getTextSizeWrapped( iScrollSizeX, iScrollSizeY );
|
||||
|
||||
// Now resize the textpanel to fit the scrolled size
|
||||
m_pTextPanel->setSize( iScrollSizeX , iScrollSizeY );
|
||||
|
||||
//turn the scrollbars back into automode
|
||||
m_pTextScrollPanel->setScrollBarAutoVisible(true, true);
|
||||
m_pTextScrollPanel->setScrollBarVisible(false, false);
|
||||
m_pTextScrollPanel->setScrollValue( 0, 0 );
|
||||
|
||||
m_pTextScrollPanel->validate();
|
||||
|
||||
if (pText)
|
||||
gEngfuncs.COM_FreeFile(pText);
|
||||
}
|
||||
|
||||
int AgVGuiMapBrowser::MsgFunc_MapList( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
if (s_bHaveAllMaps)
|
||||
s_sMapList = "";
|
||||
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
s_bHaveAllMaps = 0 == READ_BYTE();
|
||||
s_sMapList += READ_STRING();
|
||||
|
||||
if (s_bHaveAllMaps)
|
||||
{
|
||||
s_setMaps.empty();
|
||||
AgToLower(s_sMapList);
|
||||
|
||||
int iStart = 0;
|
||||
int iEnd = 0;
|
||||
do
|
||||
{
|
||||
iEnd = s_sMapList.find("#",iStart);
|
||||
|
||||
if (-1 != iEnd)
|
||||
{
|
||||
AgString sMap = s_sMapList.substr(iStart,iEnd-iStart);
|
||||
AgTrim(sMap);
|
||||
if (sMap.length())
|
||||
{
|
||||
s_setMaps.insert(sMap);
|
||||
}
|
||||
iStart = iEnd + 1;
|
||||
}
|
||||
}
|
||||
while (-1 != iEnd);
|
||||
|
||||
s_setMaps.insert("boot_camp");
|
||||
s_setMaps.insert("bounce");
|
||||
s_setMaps.insert("datacore");
|
||||
s_setMaps.insert("lambda_bunker");
|
||||
s_setMaps.insert("snark_pit");
|
||||
s_setMaps.insert("stalkyard");
|
||||
s_setMaps.insert("subtransit");
|
||||
s_setMaps.insert("undertow");
|
||||
|
||||
((MapBrowserTablePanel*)m_pTablePanel)->DoUpdateMap();
|
||||
|
||||
s_sMapList = "";
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AgVGuiMapBrowser::GetMaps()
|
||||
{
|
||||
if (s_bHaveAllMaps && 0 == s_setMaps.size())
|
||||
{
|
||||
if (0 == s_setLocalMaps.size())
|
||||
GetLocalMaps();
|
||||
ServerCmd("maplist\n");
|
||||
}
|
||||
}
|
||||
|
||||
void AgVGuiMapBrowser::GetLocalMaps()
|
||||
{
|
||||
char szDirAG[MAX_PATH];
|
||||
char szDirVALVE[MAX_PATH];
|
||||
|
||||
strcpy(szDirAG,AgGetDirectory());
|
||||
strcat(szDirAG,"/maps");
|
||||
strcpy(szDirVALVE,AgGetDirectoryValve());
|
||||
strcat(szDirVALVE,"/maps");
|
||||
|
||||
AgStringSet setFiles;
|
||||
AgStringSet::iterator itrFiles;
|
||||
|
||||
AgDirList(szDirAG,setFiles);
|
||||
AgDirList(szDirVALVE,setFiles);
|
||||
|
||||
for (itrFiles = setFiles.begin() ;itrFiles != setFiles.end();++itrFiles)
|
||||
{
|
||||
AgString sFile = *itrFiles;
|
||||
AgToLower(sFile);
|
||||
if (!strstr(sFile.c_str(),".bsp"))
|
||||
continue;
|
||||
sFile = sFile.substr(0,sFile.length()-4);
|
||||
AgTrim(sFile);
|
||||
s_setLocalMaps.insert(sFile);
|
||||
}
|
||||
|
||||
s_setLocalMaps.insert("boot_camp");
|
||||
s_setLocalMaps.insert("bounce");
|
||||
s_setLocalMaps.insert("datacore");
|
||||
s_setLocalMaps.insert("lambda_bunker");
|
||||
s_setLocalMaps.insert("snark_pit");
|
||||
s_setLocalMaps.insert("stalkyard");
|
||||
s_setLocalMaps.insert("subtransit");
|
||||
s_setLocalMaps.insert("undertow");
|
||||
}
|
||||
|
||||
|
||||
int AgVGuiMapBrowser::KeyInput(int down, int keynum, const char *pszCurrentBinding)
|
||||
{
|
||||
if (!down)
|
||||
return 1;
|
||||
|
||||
if (!isVisible())
|
||||
return 1;
|
||||
|
||||
if (K_ESCAPE == keynum || pszCurrentBinding && 0 == _stricmp("togglemapbrowser",pszCurrentBinding))
|
||||
{
|
||||
gViewPort->ToggleMapBrowser();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (K_MWHEELUP == keynum)
|
||||
{
|
||||
((MapBrowserTablePanel*)m_pTablePanel)->DoPrev();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (K_MWHEELDOWN == keynum)
|
||||
{
|
||||
((MapBrowserTablePanel*)m_pTablePanel)->DoNext();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
70
cl_dll/aghl/AgVGuiMapBrowser.h
Normal file
70
cl_dll/aghl/AgVGuiMapBrowser.h
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
#ifndef AGVGUIMAPBROWSER_H
|
||||
#define AGVGUIMAPBROWSER_H
|
||||
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
|
||||
class AgVGuiMapBrowser : public vgui::Panel
|
||||
{
|
||||
private:
|
||||
vgui::HeaderPanel * m_pHeaderPanel;
|
||||
vgui::TablePanel* m_pTablePanel;
|
||||
CTransparentPanel* m_pBackgroundPanel;
|
||||
Label* m_pLabel;
|
||||
vgui::ScrollPanel* m_pTextScrollPanel;
|
||||
vgui::TextPanel* m_pTextPanel;
|
||||
public:
|
||||
AgVGuiMapBrowser(int x,int y,int wide,int tall);
|
||||
public:
|
||||
virtual void paintBackground();
|
||||
virtual int KeyInput(int down, int keynum, const char *pszCurrentBinding);
|
||||
|
||||
int MsgFunc_MapList(const char *pszName, int iSize, void *pbuf);
|
||||
void GetMaps();
|
||||
void GetLocalMaps();
|
||||
|
||||
void UpdateMap(const char* pszMap);
|
||||
};
|
||||
|
||||
/*
|
||||
namespace vgui
|
||||
{
|
||||
class Button;
|
||||
class TablePanel;
|
||||
class HeaderPanel;
|
||||
}
|
||||
|
||||
class CTransparentPanel;
|
||||
class CommandButton;
|
||||
|
||||
// Scoreboard positions
|
||||
#define SB_X_INDENT (20 * ((float)ScreenHeight / 640))
|
||||
#define SB_Y_INDENT (20 * ((float)ScreenHeight / 480))
|
||||
|
||||
class AgVGuiMapBrowser : public CTransparentPanel
|
||||
{
|
||||
private:
|
||||
HeaderPanel * _headerPanel;
|
||||
TablePanel* _tablePanel;
|
||||
ScrollPanel* _scrollPanel;
|
||||
|
||||
CommandButton* _ChangeMapButton;
|
||||
CommandButton* _ChangeNextMapButton;
|
||||
CommandButton* _InfoButton;
|
||||
CommandButton* _CancelButton;
|
||||
CommandButton* _NextPageButton;
|
||||
|
||||
void DoNext();
|
||||
|
||||
public:
|
||||
AgVGuiMapBrowser(int x,int y,int wide,int tall);
|
||||
public:
|
||||
virtual void setSize(int wide,int tall);
|
||||
virtual int KeyInput(int down, int keynum, const char *pszCurrentBinding);
|
||||
|
||||
int MsgFunc_MapList(const char *pszName, int iSize, void *pbuf);
|
||||
void GetMaps();
|
||||
};
|
||||
*/
|
||||
#endif
|
524
cl_dll/aghl/Agglobal.cpp
Normal file
524
cl_dll/aghl/Agglobal.cpp
Normal file
@ -0,0 +1,524 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "agglobal.h"
|
||||
#include <time.h>
|
||||
#include "agmodelcheck.h"
|
||||
|
||||
cvar_t* g_phud_spectatebar = NULL;
|
||||
cvar_t* g_phud_timer = NULL;
|
||||
cvar_t* g_phud_playerid = NULL;
|
||||
cvar_t* g_phud_settings = NULL;
|
||||
cvar_t* g_phud_weapon = NULL;
|
||||
cvar_t* g_phud_color = NULL;
|
||||
cvar_t* g_pcl_matchreport = NULL;
|
||||
cvar_t* g_pcl_playtalk = NULL;
|
||||
cvar_t* g_pcl_weaponswitch = NULL;
|
||||
//cvar_t* g_pcl_weaponweights = NULL;
|
||||
cvar_t* g_pcl_disablespecs = NULL;
|
||||
cvar_t* g_pcl_liveupdate = NULL;
|
||||
cvar_t* g_pcl_scores = NULL;
|
||||
cvar_t* g_pcl_scores_pos = NULL;
|
||||
cvar_t* g_pcl_only_team_talk = NULL;
|
||||
cvar_t* g_pcl_show_colors = NULL;
|
||||
cvar_t* g_pcl_old_scoreboard = NULL;
|
||||
cvar_t* g_pcl_ctf_volume = NULL;
|
||||
cvar_t* g_pcl_show_local_maps = NULL;
|
||||
cvar_t* g_pcl_location_keywords = NULL;
|
||||
cvar_t* g_pcl_show_banner = NULL;
|
||||
|
||||
|
||||
cvar_t* g_pirc_server = NULL;
|
||||
cvar_t* g_pirc_nick = NULL;
|
||||
cvar_t* g_pirc_port = NULL;
|
||||
cvar_t* g_pirc_userid = NULL;
|
||||
cvar_t* g_pirc_password = NULL;
|
||||
cvar_t* g_pirc_fullname = NULL;
|
||||
cvar_t* g_pirc_autojoin = NULL;
|
||||
cvar_t* g_pirc_autocommand = NULL;
|
||||
cvar_t* g_pirc_autocommand2 = NULL;
|
||||
cvar_t* g_pirc_autocommand3 = NULL;
|
||||
|
||||
// Colors
|
||||
int iNumConsoleColors = 16;
|
||||
int arrConsoleColors[16][3] =
|
||||
{
|
||||
{ 255, 170, 0 }, // HL console (default)
|
||||
{ 255, 0, 0 }, // Red
|
||||
{ 0, 255, 0 }, // Green
|
||||
{ 255, 255, 0 }, // Yellow
|
||||
{ 0, 0, 255 }, // Blue
|
||||
{ 0, 255, 255 }, // Cyan
|
||||
{ 255, 0, 255 }, // Violet
|
||||
{ 136, 136, 136 }, // Q
|
||||
{ 255, 255, 255 }, // White
|
||||
{ 0, 0, 0 }, // Black
|
||||
{ 200, 90, 70 }, // Redb
|
||||
{ 145, 215, 140 }, // Green
|
||||
{ 225, 205, 45 }, // Yellow
|
||||
{ 125, 165, 210 }, // Blue
|
||||
{ 70, 70, 70 },
|
||||
{ 200, 200, 200 },
|
||||
};
|
||||
|
||||
int arrHudColor[3] =
|
||||
{
|
||||
255, 160, 0
|
||||
};
|
||||
|
||||
extern int iTeamColors[5][3];
|
||||
extern float g_ColorConsole[3];
|
||||
//-- Martin Webrant
|
||||
#ifdef _DEBUG
|
||||
void AgTest();
|
||||
#endif
|
||||
|
||||
void AgUpdateHudColor()
|
||||
{
|
||||
//Hud color
|
||||
sscanf(CVAR_GET_STRING("hud_color"), "%i %i %i", &arrHudColor[0], &arrHudColor[1], &arrHudColor[2] );
|
||||
iTeamColors[0][0] = arrHudColor[0];
|
||||
iTeamColors[0][1] = arrHudColor[1];
|
||||
iTeamColors[0][2] = arrHudColor[2];
|
||||
|
||||
//Console color
|
||||
sscanf(CVAR_GET_STRING("con_color"), "%i %i %i", &arrConsoleColors[0][0], &arrConsoleColors[0][1], &arrConsoleColors[0][2] );
|
||||
g_ColorConsole[0] = arrConsoleColors[0][0] / 255.0;
|
||||
g_ColorConsole[1] = arrConsoleColors[0][1] / 255.0;
|
||||
g_ColorConsole[2] = arrConsoleColors[0][2] / 255.0;
|
||||
}
|
||||
|
||||
void AgGetHudColor(int &r, int &g, int &b)
|
||||
{
|
||||
r = arrHudColor[0];
|
||||
g = arrHudColor[1];
|
||||
b = arrHudColor[2];
|
||||
}
|
||||
|
||||
//extern void COM_Log( char *pszFile, char *fmt, ...);
|
||||
|
||||
void AgInitClientDll()
|
||||
{
|
||||
g_phud_spectatebar = gEngfuncs.pfnRegisterVariable ( "hud_spectatebar", "1", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_phud_timer = gEngfuncs.pfnRegisterVariable ( "hud_timer", "1", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_phud_playerid = gEngfuncs.pfnRegisterVariable ( "hud_playerid", "1", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_phud_settings = gEngfuncs.pfnRegisterVariable ( "hud_settings", "1", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_phud_weapon = gEngfuncs.pfnRegisterVariable ( "hud_weapon", "0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_phud_color = gEngfuncs.pfnRegisterVariable ( "hud_color", "255 160 0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
|
||||
g_pcl_matchreport = gEngfuncs.pfnRegisterVariable ( "cl_matchreport", "1", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pcl_playtalk = gEngfuncs.pfnRegisterVariable ( "cl_playtalk", "0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
|
||||
g_pcl_weaponswitch = gEngfuncs.pfnRegisterVariable ( "cl_autowepswitch", "1", FCVAR_CLIENTDLL|FCVAR_ARCHIVE|FCVAR_USERINFO);
|
||||
//g_pcl_weaponweights = gEngfuncs.pfnRegisterVariable ( "cl_weaponweights", "", FCVAR_CLIENTDLL|FCVAR_ARCHIVE|FCVAR_USERINFO); //weapon weight factors (for auto-switching) (-1 = noswitch)
|
||||
|
||||
g_pcl_disablespecs = gEngfuncs.pfnRegisterVariable ( "cl_disablespecs", "0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE|FCVAR_USERINFO);
|
||||
g_pcl_liveupdate = gEngfuncs.pfnRegisterVariable ( "cl_liveupdate", "0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE); //Special for Mr. T-rex :P
|
||||
g_pcl_scores = gEngfuncs.pfnRegisterVariable ( "cl_scores", "0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pcl_scores_pos = gEngfuncs.pfnRegisterVariable ( "cl_scores_pos", "30 50", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
|
||||
g_pcl_only_team_talk= gEngfuncs.pfnRegisterVariable ( "cl_only_team_talk", "0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pcl_show_colors = gEngfuncs.pfnRegisterVariable ( "cl_show_colors", "1", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pcl_old_scoreboard = gEngfuncs.pfnRegisterVariable ( "cl_old_scoreboard", "0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pcl_ctf_volume = gEngfuncs.pfnRegisterVariable ( "cl_ctf_volume", "1", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
|
||||
g_pirc_server = gEngfuncs.pfnRegisterVariable ( "irc_server", "irc.quakenet.eu.org", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pirc_port = gEngfuncs.pfnRegisterVariable ( "irc_port", "6667", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pirc_nick = gEngfuncs.pfnRegisterVariable ( "irc_nick", "", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pirc_userid = gEngfuncs.pfnRegisterVariable ( "irc_userid", "", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pirc_password = gEngfuncs.pfnRegisterVariable ( "irc_password", "", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pirc_fullname = gEngfuncs.pfnRegisterVariable ( "irc_fullname", "", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pirc_autojoin = gEngfuncs.pfnRegisterVariable ( "irc_autojoin", "#pmers", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pirc_autocommand = gEngfuncs.pfnRegisterVariable ( "irc_autocommand","", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pirc_autocommand2 = gEngfuncs.pfnRegisterVariable ( "irc_autocommand2","", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pirc_autocommand3 = gEngfuncs.pfnRegisterVariable ( "irc_autocommand3","", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
|
||||
g_pcl_show_local_maps = gEngfuncs.pfnRegisterVariable ("cl_show_local_maps", "0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
|
||||
g_pcl_location_keywords = gEngfuncs.pfnRegisterVariable ("cl_location_keywords", "0", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
g_pcl_show_banner = gEngfuncs.pfnRegisterVariable ("cl_show_banner", "1", FCVAR_CLIENTDLL|FCVAR_ARCHIVE);
|
||||
|
||||
//Can use opforce stuff
|
||||
gEngfuncs.COM_AddAppDirectoryToSearchPath("opforce","opforce");
|
||||
|
||||
//Setup colors
|
||||
AgUpdateHudColor();
|
||||
|
||||
// COM_Log(NULL,"Modulehandle - %lx\n",GetModuleHandle("client.dll"));
|
||||
}
|
||||
|
||||
|
||||
int GetColor(char cChar)
|
||||
{
|
||||
int iColor = -1;
|
||||
if (cChar >= '0' && cChar <= '9')
|
||||
iColor = cChar - '0';
|
||||
return iColor;
|
||||
}
|
||||
|
||||
int AgDrawHudStringCentered(int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b )
|
||||
{
|
||||
// calc center
|
||||
int iSizeX = 0;
|
||||
char* pszIt = (char*)szIt;
|
||||
for ( ; *pszIt != 0 && *pszIt != '\n'; pszIt++ )
|
||||
iSizeX += gHUD.m_scrinfo.charWidths[ *pszIt ]; // variable-width fonts look cool
|
||||
|
||||
//Subtract half sizex from xpos to center it.
|
||||
xpos = xpos - iSizeX / 2;
|
||||
|
||||
int rx = r, gx = g, bx = b;
|
||||
|
||||
pszIt = (char*)szIt;
|
||||
// draw the string until we hit the null character or a newline character
|
||||
for ( ; *pszIt != 0 && *pszIt != '\n'; pszIt++ )
|
||||
{
|
||||
if (*pszIt == '^')
|
||||
{
|
||||
pszIt++;
|
||||
int iColor = GetColor(*pszIt);
|
||||
if (iColor < iNumConsoleColors && iColor >= 0)
|
||||
{
|
||||
if (0 >= iColor || 0 == g_pcl_show_colors->value)
|
||||
{
|
||||
rx = r;
|
||||
gx = g;
|
||||
bx = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
rx = arrConsoleColors[iColor][0];
|
||||
gx = arrConsoleColors[iColor][1];
|
||||
bx = arrConsoleColors[iColor][2];
|
||||
}
|
||||
pszIt++;
|
||||
if (*pszIt == 0 || *pszIt == '\n')
|
||||
break;
|
||||
}
|
||||
else
|
||||
pszIt--;
|
||||
}
|
||||
|
||||
int next = xpos + gHUD.m_scrinfo.charWidths[ *pszIt ]; // variable-width fonts look cool
|
||||
if ( next > iMaxX )
|
||||
return xpos;
|
||||
TextMessageDrawChar( xpos, ypos, *pszIt, rx, gx, bx );
|
||||
xpos = next;
|
||||
}
|
||||
return xpos;
|
||||
}
|
||||
|
||||
int AgDrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b )
|
||||
{
|
||||
|
||||
int rx = r, gx = g, bx = b;
|
||||
|
||||
// draw the string until we hit the null character or a newline character
|
||||
for ( ; *szIt != 0 && *szIt != '\n'; szIt++ )
|
||||
{
|
||||
if (*szIt == '^')
|
||||
{
|
||||
szIt++;
|
||||
int iColor = GetColor(*szIt);
|
||||
if (iColor < iNumConsoleColors && iColor >= 0)
|
||||
{
|
||||
if (0 >= iColor || 0 == g_pcl_show_colors->value)
|
||||
{
|
||||
rx = r;
|
||||
gx = g;
|
||||
bx = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
rx = arrConsoleColors[iColor][0];
|
||||
gx = arrConsoleColors[iColor][1];
|
||||
bx = arrConsoleColors[iColor][2];
|
||||
}
|
||||
szIt++;
|
||||
if (*szIt == 0 || *szIt == '\n')
|
||||
break;
|
||||
}
|
||||
else
|
||||
szIt--;
|
||||
}
|
||||
|
||||
int next = xpos + gHUD.m_scrinfo.charWidths[ *szIt ]; // variable-width fonts look cool
|
||||
if ( next > iMaxX )
|
||||
return xpos;
|
||||
|
||||
TextMessageDrawChar( xpos, ypos, *szIt, rx, gx, bx );
|
||||
xpos = next;
|
||||
}
|
||||
|
||||
return xpos;
|
||||
}
|
||||
|
||||
int AgDrawConsoleString( int x, int y, const char *string, float r, float g, float b )
|
||||
{
|
||||
if (0 == g_pcl_show_colors->value)
|
||||
{
|
||||
char* pszString = strdup(string);
|
||||
AgStripColors((char*)pszString);
|
||||
int iRet = gEngfuncs.pfnDrawConsoleString( x, y, (char*) pszString );
|
||||
free(pszString);
|
||||
return iRet;
|
||||
}
|
||||
|
||||
|
||||
char szText[512];
|
||||
char* pText = szText;
|
||||
*pText = '\0';
|
||||
char* pszColor = (char*)string;
|
||||
while (*pszColor)
|
||||
{
|
||||
if ('^' == *pszColor)
|
||||
{
|
||||
int iColor = GetColor(*(pszColor+1));
|
||||
if (iColor < iNumConsoleColors && iColor >= 0)
|
||||
//User wants a new color
|
||||
{
|
||||
//Draw first part with previous color.
|
||||
*pText = '\0';
|
||||
*pszColor = '\0';
|
||||
int xPrev = gEngfuncs.pfnDrawConsoleString( x, y, (char*)szText);
|
||||
*pszColor = '^';
|
||||
pszColor++;
|
||||
pszColor++;
|
||||
|
||||
float rx = r, gx = g, bx = b;
|
||||
//Set the color.
|
||||
if (iColor > 0)
|
||||
{
|
||||
rx = arrConsoleColors[iColor][0] / 255.0;
|
||||
gx = arrConsoleColors[iColor][1] / 255.0;
|
||||
bx = arrConsoleColors[iColor][2] / 255.0;
|
||||
}
|
||||
if (!(rx == 0 && gx == 0 && bx == 0))
|
||||
gEngfuncs.pfnDrawSetTextColor(rx, gx, bx);
|
||||
|
||||
//Draw the rest of the string (that may contain new colors)
|
||||
return AgDrawConsoleString( xPrev , y, pszColor, r, g, b);
|
||||
}
|
||||
}
|
||||
*pText = *pszColor;
|
||||
pText++;
|
||||
pszColor++;
|
||||
}
|
||||
*pText = '\0';
|
||||
|
||||
if (!(r == 0 && g == 0 && b == 0))
|
||||
gEngfuncs.pfnDrawSetTextColor(r, g, b);
|
||||
|
||||
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) szText );
|
||||
/*
|
||||
int iLength = strlen(string);
|
||||
char* pszColor = strchr(string,'^');
|
||||
|
||||
if (pszColor)
|
||||
{
|
||||
//Extract color.
|
||||
++pszColor;
|
||||
int iColor = GetColor(*pszColor);
|
||||
++pszColor;
|
||||
|
||||
//Check if we got a valid color.
|
||||
if (iColor < iNumConsoleColors && iColor >= 0)
|
||||
{
|
||||
char szTerm = *(pszColor-2);
|
||||
*(pszColor-2) = '\0';
|
||||
|
||||
//Draw the first part with the previous color.
|
||||
int xPrev = gEngfuncs.pfnDrawConsoleString( x, y, (char*)string);
|
||||
*(pszColor-2) = szTerm;
|
||||
|
||||
float rx = r, gx = g, bx = b;
|
||||
//Set the color.
|
||||
if (iColor != 0)
|
||||
{
|
||||
rx = arrConsoleColors[iColor][0] / 255.0;
|
||||
gx = arrConsoleColors[iColor][1] / 255.0;
|
||||
bx = arrConsoleColors[iColor][2] / 255.0;
|
||||
}
|
||||
if (!(rx == 0 && gx == 0 && bx == 0))
|
||||
gEngfuncs.pfnDrawSetTextColor(rx, gx, bx);
|
||||
|
||||
//Draw the rest of the string (that may contain new colors)
|
||||
return AgDrawConsoleString( xPrev , y, pszColor, r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(r == 0 && g == 0 && b == 0))
|
||||
gEngfuncs.pfnDrawSetTextColor(r, g, b);
|
||||
|
||||
return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string );
|
||||
*/
|
||||
}
|
||||
|
||||
void AgStripColors(char* pszString)
|
||||
{
|
||||
char* pszIt = pszString;
|
||||
while ('\0' != *pszIt)
|
||||
{
|
||||
if ('^' == *pszIt)
|
||||
{
|
||||
++pszIt;
|
||||
if (*pszIt >= '0' && *pszIt <= '9')
|
||||
{
|
||||
--pszIt;
|
||||
memmove(pszIt,pszIt+2,strlen(pszIt+2)+1);
|
||||
}
|
||||
}
|
||||
else
|
||||
++pszIt;
|
||||
}
|
||||
}
|
||||
|
||||
AgString AgMapname()
|
||||
{
|
||||
return gHUD.m_Location.m_szMap;
|
||||
|
||||
/*
|
||||
AgString sMap;
|
||||
sMap = gEngfuncs.pfnGetLevelName();
|
||||
if (0 == sMap.size())
|
||||
return sMap;
|
||||
|
||||
sMap = sMap.substr(sMap.find("/")+1);
|
||||
sMap = sMap.substr(0,sMap.find("."));
|
||||
return sMap;
|
||||
*/
|
||||
}
|
||||
|
||||
void AgTrim(AgString& sTrim)
|
||||
{
|
||||
if (0 == sTrim.length())
|
||||
return;
|
||||
|
||||
int b = sTrim.find_first_not_of(" \t\r\n");
|
||||
int e = sTrim.find_last_not_of(" \t\r\n");
|
||||
if(b == -1) // No non-whitespaces
|
||||
sTrim = "";
|
||||
else
|
||||
sTrim = string(sTrim, b, e - b + 1);
|
||||
}
|
||||
|
||||
void AgLog(const char* pszLog)
|
||||
{
|
||||
char szFile[MAX_PATH];
|
||||
sprintf(szFile,"%s/aglog.txt", AgGetDirectory());
|
||||
FILE* pFile = fopen(szFile,"a+");
|
||||
if (!pFile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
time_t clock;
|
||||
time( &clock );
|
||||
fprintf(pFile,"%s : %s",pszLog,asctime(localtime(&clock)));
|
||||
fflush(pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
|
||||
void AgDirList(const AgString& sDir, AgStringSet& setFiles)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WIN32_FIND_DATA FindData;
|
||||
char szSearchDirectory[_MAX_PATH];
|
||||
sprintf(szSearchDirectory,"%s/*.*",sDir.c_str());
|
||||
HANDLE hFind = FindFirstFile(szSearchDirectory, &FindData);
|
||||
|
||||
if (INVALID_HANDLE_VALUE != hFind)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (!(FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
AgString sFile;
|
||||
sFile = FindData.cFileName;
|
||||
setFiles.insert(sFile);
|
||||
}
|
||||
}
|
||||
while (FindNextFile(hFind, &FindData));
|
||||
FindClose(hFind);
|
||||
}
|
||||
#else
|
||||
DIR* pDirectory = opendir(sDir.c_str());
|
||||
if (pDirectory)
|
||||
{
|
||||
struct dirent* pFile = NULL;
|
||||
|
||||
while (NULL != (pFile = readdir(pDirectory)))
|
||||
{
|
||||
AgString sFile;
|
||||
sFile = pFile->d_name;
|
||||
setFiles.insert(sFile);
|
||||
}
|
||||
closedir(pDirectory);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void AgToLower(AgString& strLower)
|
||||
{
|
||||
size_t i = 0;
|
||||
while (i < strLower.length())
|
||||
{
|
||||
strLower[i] = tolower(strLower[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char* AgGetGame()
|
||||
{
|
||||
static char szGame[MAX_PATH];
|
||||
strcpy(szGame, gEngfuncs.pfnGetGameDirectory());
|
||||
char* pszGameDir = strrchr(szGame, '/');
|
||||
if (pszGameDir)
|
||||
return pszGameDir + 1;
|
||||
return szGame;
|
||||
}
|
||||
|
||||
const char* AgGetDirectory()
|
||||
{
|
||||
static char szGame[MAX_PATH];
|
||||
strcpy(szGame, gEngfuncs.pfnGetGameDirectory());
|
||||
char* pszGameDir = strrchr(szGame, '/');
|
||||
if (pszGameDir)
|
||||
{
|
||||
return szGame;
|
||||
}
|
||||
else
|
||||
{
|
||||
static char szDirectory[MAX_PATH] = "";
|
||||
if (strlen(szDirectory))
|
||||
return szDirectory;
|
||||
|
||||
::GetCurrentDirectory(MAX_PATH, szDirectory);
|
||||
|
||||
strcat(szDirectory, "/");
|
||||
strcat(szDirectory, szGame);
|
||||
return szDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
const char* AgGetDirectoryValve()
|
||||
{
|
||||
static char szDirectory[MAX_PATH] = "";
|
||||
if (szDirectory[0] != '\0')
|
||||
return szDirectory;
|
||||
|
||||
strcpy(szDirectory, AgGetDirectory());
|
||||
int iStart = strlen(szDirectory)-1;
|
||||
while ('/' != szDirectory[iStart])
|
||||
{
|
||||
szDirectory[iStart] = '\0';
|
||||
iStart--;
|
||||
}
|
||||
szDirectory[iStart] = '\0';
|
||||
return szDirectory;
|
||||
}
|
||||
|
||||
//-- Martin Webrant
|
151
cl_dll/aghl/agbase64.cpp
Normal file
151
cl_dll/aghl/agbase64.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "agbase64.h"
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
// define the US-ASCII chars
|
||||
static char s_szBase64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\0";
|
||||
|
||||
// how many bits per byte?
|
||||
#define NUM_BITS 8
|
||||
#define BYTES_TO_READ 60 // only for my test method Encode-file
|
||||
|
||||
// define masks for Base64-encode
|
||||
static int i_aMsbMask[] = { 0xfc, 0xf0, 0xc0, 0x00 };
|
||||
static int i_aLsbMask[] = { 0x00, 0x03, 0x0f, 0x3f };
|
||||
|
||||
// Define array for conversion between chars in base64 message and their weight according to array s_szBase64
|
||||
// This could be done by counting offset in s_szBase64. But sorry, too slow!
|
||||
// start with asccii 2B (ie '+')
|
||||
static int i_a64CharWeight [] =
|
||||
{
|
||||
62, -1, -1, -1, 63, // I have defined '+' and '/'
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // I have defined 0 through 9
|
||||
-1, -1, -1, -1, -1, -1, -1, // have undefined ascii 3A to 40
|
||||
// lets define 'A' to 'Z'
|
||||
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25, // A - Z
|
||||
-1, -1, -1, -1, -1, -1, // have undefined ascii 5B to 40
|
||||
// lets define 'a' to 'z'
|
||||
26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
|
||||
49,50,51 // defined 'a' to 'z'
|
||||
};
|
||||
|
||||
static int i_aDecodeMsbMask[] = { 0x3f, 0x0f, 0x03 };
|
||||
static int i_aDecodeLsbMask[] = { 0x30, 0x3c, 0x3f };
|
||||
|
||||
|
||||
//Decodes base64-encoded string.
|
||||
//Assumptions: Incoming buffer (pszBuffer) is large enough.
|
||||
void AgBase64Decode(const char* pszString,unsigned long ulInLen,unsigned char* pszBuffer, unsigned short& usOutLen)
|
||||
{
|
||||
char* p = (char*)pszBuffer;
|
||||
const char* pszSource = (const char*)pszString;
|
||||
usOutLen = 0;
|
||||
assert(0 == (ulInLen % 4)); // base-64 coded text should always be done in parts of 4 bytes
|
||||
|
||||
while(ulInLen > 0)
|
||||
{
|
||||
int iAsciiO = i_a64CharWeight[*pszSource++ - 0x2B];
|
||||
for (int i = 1; i <= 3; i++)
|
||||
{
|
||||
int iAsciiChar = (iAsciiO & i_aDecodeMsbMask[i-1]) << (2*i);
|
||||
int iChar = i_a64CharWeight[*pszSource++ - 0x2B];
|
||||
iAsciiChar += (iChar & i_aDecodeLsbMask[i-1]) >> (6-2*i);
|
||||
iAsciiO = iChar;
|
||||
*p++ = (char)iAsciiChar;
|
||||
--ulInLen;
|
||||
if (!('\0' == *(p-1) && '\0' == iAsciiChar)) //BAD BAD BAD! need to check what chars is padded better.
|
||||
++usOutLen;
|
||||
}
|
||||
--ulInLen;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Encodes incoming string to Base64.
|
||||
//Assumptions: Incoming buffer (pszBuffer) is large enough.
|
||||
//Haven't bothered to optimize this one since we only do it when we create file.
|
||||
void AgBase64Encode(const unsigned char* pszString,unsigned long ulInLen,char* pszBuffer)
|
||||
{
|
||||
assert(pszString);
|
||||
assert(pszBuffer);
|
||||
|
||||
char* p = (char*)pszString;
|
||||
|
||||
while (ulInLen > 0)
|
||||
{
|
||||
int iAsciiO = 0;
|
||||
// encode 3 characters (will become 4 chars when Base64 encoded)
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int iAsciiN = 0;
|
||||
|
||||
if (ulInLen)
|
||||
iAsciiN = (int)*p;
|
||||
|
||||
int iMsbRightShift = NUM_BITS - (6-2*i);
|
||||
int iLsbLeftShift = NUM_BITS - iMsbRightShift;
|
||||
|
||||
int iChar64 = ((iAsciiN & i_aMsbMask[i]) >> iMsbRightShift);
|
||||
iChar64 += ((iAsciiO & i_aLsbMask[i]) << iLsbLeftShift);
|
||||
|
||||
iAsciiO = iAsciiN;
|
||||
|
||||
assert(iChar64 >= 0 && iChar64 <= 63);
|
||||
|
||||
if (i < 3)
|
||||
{
|
||||
p++;
|
||||
if (ulInLen)
|
||||
ulInLen--;
|
||||
}
|
||||
|
||||
*pszBuffer++ = s_szBase64[iChar64];
|
||||
}
|
||||
|
||||
}
|
||||
*pszBuffer = 0;
|
||||
}
|
||||
|
||||
//-- Martin Webrant
|
||||
|
||||
/*
|
||||
|
||||
static char* s_szBadCodes[] =
|
||||
{
|
||||
"glhack",
|
||||
"opengl.ini",
|
||||
"TWCheat",
|
||||
"B.teraphy",
|
||||
"Flautz",
|
||||
"sw!zz3r",
|
||||
"ANAKiN",
|
||||
"hooker.dll",
|
||||
"UPX!", //whb31
|
||||
"c:\\opengl32.dll",
|
||||
"hlh.dll",
|
||||
"GRiM-F_H",
|
||||
"ChromaxS",
|
||||
"ogc.dll",
|
||||
"Unhooker", // eller hlh.dll
|
||||
"eZ!$7v", //Swizz hack
|
||||
"coders.dll", //wh_beta4, wh_beta5
|
||||
"ogc.cfg",
|
||||
"xqz2", //xqz2_b71
|
||||
"xqb6", //xqz2_b80
|
||||
"p@gram", //XQZ2Beta85
|
||||
};
|
||||
|
||||
int ix = 0;
|
||||
for (ix = 0; ix < sizeof(s_szBadCodes)/sizeof(s_szBadCodes[0]); ix++)
|
||||
{
|
||||
char szBuff[256];
|
||||
AgBase64Encode((unsigned char*)s_szBadCodes[ix],strlen(s_szBadCodes[ix]),szBuff);
|
||||
|
||||
char szTest[512];
|
||||
sprintf(szTest,"\"%s\", //%s\n",szBuff,s_szBadCodes[ix]);
|
||||
OutputDebugString(szTest);
|
||||
}
|
||||
*/
|
11
cl_dll/aghl/agbase64.h
Normal file
11
cl_dll/aghl/agbase64.h
Normal file
@ -0,0 +1,11 @@
|
||||
//++ BulliT
|
||||
|
||||
#ifndef __AG_BASE64_H__
|
||||
#define __AG_BASE64_H__
|
||||
|
||||
void AgBase64Decode(const char* pszString, unsigned long ulInLen, unsigned char* pszBuffer, unsigned short& ulOutLen);
|
||||
void AgBase64Encode(const unsigned char* pszString, unsigned long ulInLen, char* pszBuffer);
|
||||
|
||||
#endif //__AG_BASE64_H__
|
||||
|
||||
//-- Martin Webrant
|
84
cl_dll/aghl/agcrc32.cpp
Normal file
84
cl_dll/aghl/agcrc32.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "agcrc32.h"
|
||||
|
||||
// fixed CRC32 table (read only)
|
||||
const WORD32 CRC32TAB[] =
|
||||
{
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
|
||||
|
||||
WORD32 AgCRC32(const void* pData, WORD32 lNumOfBytes)
|
||||
{
|
||||
WORD32 lX;
|
||||
WORD32 lI;
|
||||
WORD32 lNewCRC32;
|
||||
WORD8* pRun = (WORD8*) pData;
|
||||
|
||||
lNewCRC32 = 0xFFFFFFFF;
|
||||
if (lNumOfBytes == 0)
|
||||
return lNewCRC32;
|
||||
|
||||
for (lI = 0; lI < lNumOfBytes; lI++)
|
||||
{
|
||||
lX = pRun[lI] ^ (lNewCRC32 & 0x000000FF);
|
||||
lNewCRC32 >>= 8;
|
||||
lNewCRC32 ^= CRC32TAB[lX];
|
||||
}
|
||||
return lNewCRC32;
|
||||
}
|
||||
|
||||
|
||||
//-- Martin Webrant
|
18
cl_dll/aghl/agcrc32.h
Normal file
18
cl_dll/aghl/agcrc32.h
Normal file
@ -0,0 +1,18 @@
|
||||
//++ BulliT
|
||||
|
||||
#ifndef __AG_CRC32_H__
|
||||
#define __AG_CRC32_H__
|
||||
|
||||
#ifdef WIN32
|
||||
typedef unsigned __int8 WORD8; // unsigned 8bit integer, prefix "b"
|
||||
typedef unsigned __int32 WORD32; // unsigned 8bit integer, prefix "l"
|
||||
#else
|
||||
typedef unsigned char WORD8;
|
||||
typedef unsigned int WORD32;
|
||||
#endif
|
||||
|
||||
WORD32 AgCRC32(const void* pData, WORD32 lNumOfBytes);
|
||||
|
||||
#endif //__AG_CRC_H__
|
||||
|
||||
//-- Martin Webrant
|
140
cl_dll/aghl/agcrc32enforcer.cpp
Normal file
140
cl_dll/aghl/agcrc32enforcer.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
#include "agcrc32enforcer.h"
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
static char szDisconnect[] = "disconnect\n";
|
||||
|
||||
struct FILES
|
||||
{
|
||||
char* pszFile;
|
||||
WORD32 w32CheckSum;
|
||||
};
|
||||
|
||||
static FILES s_Files[] =
|
||||
{
|
||||
"gfx.wad", 1240178454,
|
||||
// "halflife.wad", 1657905259,
|
||||
"liquids.wad", 1067140096,
|
||||
"models/player/hgrunt/hgrunt.mdl", 4178952236,
|
||||
"models/player/scientist/scientist.mdl", 801952511,
|
||||
"models/player/gordon/gordon.mdl", 1899521925,
|
||||
"models/player/helmet/helmet.mdl", 413544432,
|
||||
"models/player/robo/robo.mdl", 1066728661,
|
||||
"models/player/barney/barney.mdl", 2342238586,
|
||||
"models/player/recon/recon.mdl", 196824764,
|
||||
"models/player/zombie/zombie.mdl", 2613106147,
|
||||
"models/player/gman/gman.mdl", 363240166,
|
||||
"models/player.mdl", 348061911,
|
||||
"models/flag.mdl", 1312518787,
|
||||
"models/p_crowbar.mdl", 2596481415,
|
||||
"models/p_9mmhandgun.mdl", 459325257,
|
||||
"models/p_9mmAR.mdl", 786579345,
|
||||
"models/p_357.mdl", 96835772,
|
||||
"models/p_gauss.mdl", 2413538144,
|
||||
"models/p_rpg.mdl", 3201388383,
|
||||
"models/p_crossbow.mdl", 1075131750,
|
||||
"models/p_egon.mdl", 1795269724,
|
||||
"models/p_tripmine.mdl", 2904825111,
|
||||
"models/p_satchel.mdl", 1240685151,
|
||||
"models/p_satchel_radio.mdl", 3737744643,
|
||||
"models/p_shotgun.mdl", 2602382707,
|
||||
"models/p_grenade.mdl", 3427694132,
|
||||
"models/p_squeak.mdl", 472781321,
|
||||
"models/p_hgun.mdl", 2327206545,
|
||||
// "models/player/blue/blue.mdl", 3578029767,
|
||||
// "models/player/red/red.mdl", 834545538,
|
||||
};
|
||||
|
||||
WORD32 AgCRC32EnforceFileInternal(char* pszFile)
|
||||
{
|
||||
int iLength = 0;
|
||||
void* pFile = gEngfuncs.COM_LoadFile(pszFile, 5, &iLength);
|
||||
if (pFile)
|
||||
{
|
||||
WORD32 w32CheckSumFile = AgCRC32(pFile, iLength);
|
||||
gEngfuncs.COM_FreeFile(pFile);
|
||||
return w32CheckSumFile;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool AgCRC32EnforceFile(char* pszFile, WORD32 w32CheckSum)
|
||||
{
|
||||
if (w32CheckSum != AgCRC32EnforceFileInternal(pszFile))
|
||||
{
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"File check enforced and %s is either damaged or changed. Run scandisk and reinstall file.\n", pszFile);
|
||||
AgLog(szMessage);
|
||||
ConsolePrint(szMessage);
|
||||
|
||||
ServerCmd( "say <AG Mod> Disconnected for using invalid file.\n" );
|
||||
ClientCmd( szDisconnect );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgCRC32EnforceFiles()
|
||||
{
|
||||
bool bPassed = true;
|
||||
for (int i = 0; i < sizeof(s_Files)/sizeof(s_Files[0]); i++)
|
||||
{
|
||||
if (s_Files[i].w32CheckSum != AgCRC32EnforceFileInternal(s_Files[i].pszFile))
|
||||
{
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"File check enforced and %s is either damaged or changed. Run scandisk and reinstall file.\n", s_Files[i].pszFile);
|
||||
AgLog(szMessage);
|
||||
ConsolePrint(szMessage);
|
||||
#ifndef _DEBUG
|
||||
bPassed = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (bPassed)
|
||||
{
|
||||
//Need special check for the 2 blue models...
|
||||
#define OLD_BLUE 3578029767
|
||||
#define NEW_BLUE 945015980
|
||||
#define PLAYER 348061911
|
||||
|
||||
#define OLD_RED 834545538
|
||||
#define NEW_RED 2809992869
|
||||
#define PLAYER 348061911
|
||||
WORD32 w32CheckSumBlue = AgCRC32EnforceFileInternal("models/player/blue/blue.mdl");
|
||||
WORD32 w32CheckSumRed = AgCRC32EnforceFileInternal("models/player/red/red.mdl");
|
||||
|
||||
if (!(w32CheckSumBlue == OLD_BLUE || w32CheckSumBlue == NEW_BLUE || w32CheckSumBlue == PLAYER))
|
||||
{
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"File check enforced and %s is either damaged or changed. Run scandisk and reinstall file.\n", "models/player/blue/blue.mdl");
|
||||
AgLog(szMessage);
|
||||
ConsolePrint(szMessage);
|
||||
#ifndef _DEBUG
|
||||
bPassed = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!(w32CheckSumRed == OLD_RED || w32CheckSumRed == NEW_RED || w32CheckSumRed == PLAYER))
|
||||
{
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"File check enforced and %s is either damaged or changed. Run scandisk and reinstall file.\n", "models/player/red/red.mdl");
|
||||
AgLog(szMessage);
|
||||
ConsolePrint(szMessage);
|
||||
#ifndef _DEBUG
|
||||
bPassed = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
if (!bPassed)
|
||||
{
|
||||
ServerCmd( "say <AG Mod> Disconnected for using invalid file.\n" );
|
||||
ClientCmd( szDisconnect );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
14
cl_dll/aghl/agcrc32enforcer.h
Normal file
14
cl_dll/aghl/agcrc32enforcer.h
Normal file
@ -0,0 +1,14 @@
|
||||
//++ BulliT
|
||||
|
||||
#ifndef __AG_CRC32ENFORCER_H__
|
||||
#define __AG_CRC32ENFORCER_H__
|
||||
|
||||
#include "agcrc32.h"
|
||||
|
||||
bool AgCRC32EnforceFile(char* pszFile, WORD32 w32CheckSum);
|
||||
|
||||
bool AgCRC32EnforceFiles();
|
||||
|
||||
#endif //__AG_CRC32ENFORCER_H__
|
||||
|
||||
//-- Martin Webrant
|
98
cl_dll/aghl/agdownload.cpp
Normal file
98
cl_dll/aghl/agdownload.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
// AgDownload.cpp: implementation of the AgDownload class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "agdownload.h"
|
||||
#include "urlmon.h"
|
||||
#pragma comment(lib, "urlmon.lib")
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AgDownloadCallBack : public IBindStatusCallback
|
||||
{
|
||||
protected:
|
||||
DWORD m_dwWhenToTimeout;
|
||||
public:
|
||||
AgDownloadCallBack(DWORD dwWhenToTimeout = 0)
|
||||
{
|
||||
m_dwWhenToTimeout = dwWhenToTimeout;
|
||||
}
|
||||
virtual ~AgDownloadCallBack()
|
||||
{
|
||||
};
|
||||
|
||||
// IBindStatusCallback methods. Note that the only method called by IE
|
||||
// is OnProgress(), so the others just return E_NOTIMPL.
|
||||
|
||||
STDMETHOD(OnStartBinding)(DWORD dwReserved,IBinding __RPC_FAR *pib) { return E_NOTIMPL; }
|
||||
STDMETHOD(GetPriority)(/* [out] */ LONG __RPC_FAR *pnPriority) { return E_NOTIMPL; }
|
||||
STDMETHOD(OnLowResource)(/* [in] */ DWORD reserved){ return E_NOTIMPL; }
|
||||
STDMETHOD(OnProgress)(/* [in] */ ULONG ulProgress,/* [in] */ ULONG ulProgressMax,/* [in] */ ULONG ulStatusCode,/* [in] */ LPCWSTR wszStatusText)
|
||||
{
|
||||
if (m_dwWhenToTimeout > 0 && m_dwWhenToTimeout < GetTickCount())
|
||||
return E_ABORT;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHOD(OnStopBinding)(/* [in] */ HRESULT hresult,/* [unique][in] */ LPCWSTR szError) { return E_NOTIMPL; }
|
||||
STDMETHOD(GetBindInfo)(/* [out] */ DWORD __RPC_FAR *grfBINDF,/* [unique][out][in] */ BINDINFO __RPC_FAR *pbindinfo) { return E_NOTIMPL; }
|
||||
STDMETHOD(OnDataAvailable)(/* [in] */ DWORD grfBSCF,/* [in] */ DWORD dwSize,/* [in] */ FORMATETC __RPC_FAR *pformatetc,/* [in] */ STGMEDIUM __RPC_FAR *pstgmed) { return E_NOTIMPL; }
|
||||
STDMETHOD(OnObjectAvailable)(/* [in] */ REFIID riid, /* [iid_is][in] */ IUnknown __RPC_FAR *punk) { return E_NOTIMPL; }
|
||||
STDMETHOD_(ULONG,AddRef)() { return 0; }
|
||||
STDMETHOD_(ULONG,Release)() { return 0; }
|
||||
STDMETHOD(QueryInterface)( /* [in] */ REFIID riid, /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject) { return E_NOTIMPL; }
|
||||
};
|
||||
|
||||
AgDownload::AgDownload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AgDownload::~AgDownload()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AgDownload::DownloadFile(const char* pszURL, const char* pszSaveAs)
|
||||
{
|
||||
AgDownloadCallBack callback(GetTickCount() + 7000);
|
||||
HRESULT hr = URLDownloadToFile(NULL, pszURL, pszSaveAs, 0, &callback);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
ConsolePrint("Download completed successfully!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
char szMsg[512];
|
||||
LPTSTR lpszErrorMessage;
|
||||
|
||||
if (FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, hr,
|
||||
MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&lpszErrorMessage, 0, NULL))
|
||||
{
|
||||
sprintf(szMsg, "Download failed. Error = 0x%08lX\n\n%s\n", (DWORD)hr, lpszErrorMessage);
|
||||
LocalFree(lpszErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(szMsg,"Download failed. Error = 0x%08lX\n\nNo message available.\n", (DWORD)hr);
|
||||
}
|
||||
|
||||
ConsolePrint(szMsg);
|
||||
}
|
||||
|
||||
}
|
22
cl_dll/aghl/agdownload.h
Normal file
22
cl_dll/aghl/agdownload.h
Normal file
@ -0,0 +1,22 @@
|
||||
// AgDownload.h: interface for the AgDownload class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_AGDOWNLOAD_H__67A39740_D747_4453_AC71_32320604FAAB__INCLUDED_)
|
||||
#define AFX_AGDOWNLOAD_H__67A39740_D747_4453_AC71_32320604FAAB__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
class AgDownload
|
||||
{
|
||||
public:
|
||||
AgDownload();
|
||||
virtual ~AgDownload();
|
||||
|
||||
void DownloadFile(const char* pszURL, const char* pszSaveAs);
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_AGDOWNLOAD_H__67A39740_D747_4453_AC71_32320604FAAB__INCLUDED_)
|
55
cl_dll/aghl/agglobal.h
Normal file
55
cl_dll/aghl/agglobal.h
Normal file
@ -0,0 +1,55 @@
|
||||
//++ BulliT
|
||||
|
||||
|
||||
#if !defined(_AG_GLOBAL_)
|
||||
#define _AG_GLOBAL_
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4710)
|
||||
#pragma warning(disable:4511)
|
||||
#pragma warning(disable:4512)
|
||||
#pragma warning(disable:4514)
|
||||
#pragma warning(disable:4663)
|
||||
#pragma warning(disable:4711)
|
||||
#pragma warning(disable:4710)
|
||||
#pragma warning(disable:4100)
|
||||
|
||||
#include <assert.h>
|
||||
#define NOWINRES
|
||||
#define NOIME
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#include <windows.h>
|
||||
|
||||
#define _bool_h 1
|
||||
#include <ministl/string>
|
||||
#include <ministl/list>
|
||||
#include <ministl/set>
|
||||
#include <ministl/map>
|
||||
#include <ministl/vector>
|
||||
#include <ministl/algorithm>
|
||||
typedef string AgString;
|
||||
typedef list<AgString> AgStringList;
|
||||
typedef set<AgString, less<AgString> > AgStringSet;
|
||||
|
||||
void AgInitClientDll();
|
||||
int AgDrawHudString(int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b );
|
||||
int AgDrawHudStringCentered(int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b );
|
||||
int AgDrawConsoleString( int x, int y, const char *string, float r = 0, float g = 0, float b = 0 );
|
||||
void AgSetTextColor(int r, int g, int b);
|
||||
void AgStripColors(char* pszString);
|
||||
void AgDirList(const AgString& sDir, AgStringSet& setFiles);
|
||||
|
||||
AgString AgMapname();
|
||||
void AgTrim(AgString& sTrim);
|
||||
void AgLog(const char* pszLog);
|
||||
void AgToLower(AgString& strLower);
|
||||
|
||||
void AgUpdateHudColor();
|
||||
void AgGetHudColor(int &r, int &g, int &b);
|
||||
|
||||
const char* AgGetGame();
|
||||
const char* AgGetDirectory();
|
||||
const char* AgGetDirectoryValve();
|
||||
|
||||
#endif _AG_GLOBAL_
|
||||
//-- Martin Webrant
|
137
cl_dll/aghl/aghudcountdown.cpp
Normal file
137
cl_dll/aghl/aghudcountdown.cpp
Normal file
@ -0,0 +1,137 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Countdown, Countdown )
|
||||
|
||||
|
||||
int AgHudCountdown::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Countdown );
|
||||
|
||||
m_btCountdown = -1;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudCountdown::VidInit(void)
|
||||
{
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudCountdown::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
m_btCountdown = -1;
|
||||
}
|
||||
|
||||
#define RGB_WHITEISH 0x00FFFFFF //255,255,255
|
||||
|
||||
int AgHudCountdown::Draw(float fTime)
|
||||
{
|
||||
if (gHUD.m_iIntermission)
|
||||
return 0;
|
||||
|
||||
char szText[128];
|
||||
szText[0] = '\0';
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
if (50 != m_btCountdown)
|
||||
{
|
||||
int iWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
|
||||
//int iHeight = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).bottom - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).top;
|
||||
|
||||
gHUD.DrawHudNumber( ScreenWidth / 2 - iWidth/2, gHUD.m_scrinfo.iCharHeight*10, DHN_DRAWZERO , m_btCountdown, r, g, b);
|
||||
if (0 != strlen(m_szPlayer1) && 0 != strlen(m_szPlayer2))
|
||||
{
|
||||
sprintf(szText,"%s vs %s",m_szPlayer1,m_szPlayer2);
|
||||
//Write arena text.
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight*7,ScreenWidth,szText,r,g,b);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Write match text.
|
||||
strcpy(szText,"Match about to start");
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight*7,ScreenWidth,szText,r,g,b);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != strlen(m_szPlayer1))
|
||||
{
|
||||
sprintf(szText,"Last round won by %s",m_szPlayer1);
|
||||
AgDrawHudStringCentered(ScreenWidth / 2 , gHUD.m_scrinfo.iCharHeight*7 ,ScreenWidth,szText,r,g,b);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(szText,"Waiting for players to get ready");
|
||||
AgDrawHudStringCentered(ScreenWidth / 2 , gHUD.m_scrinfo.iCharHeight*7 ,ScreenWidth,szText,r,g,b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudCountdown::MsgFunc_Countdown(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
//Update data
|
||||
m_btCountdown = READ_BYTE();
|
||||
char btSound = READ_BYTE();
|
||||
strcpy(m_szPlayer1,READ_STRING());
|
||||
strcpy(m_szPlayer2,READ_STRING());
|
||||
|
||||
if (0 <= m_btCountdown)
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
if (btSound)
|
||||
{
|
||||
//Play countdown sound
|
||||
if (0 == m_btCountdown)
|
||||
{
|
||||
gEngfuncs.pfnPlaySoundByName("barney/ba_bring.wav",1);
|
||||
}
|
||||
else if (1 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/one.wav",1);
|
||||
else if (2 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/two.wav",1);
|
||||
else if (3 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/three.wav",1);
|
||||
else if (4 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/four.wav",1);
|
||||
else if (5 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/five.wav",1);
|
||||
else if (6 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/six.wav",1);
|
||||
else if (7 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/seven.wav",1);
|
||||
else if (8 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/eight.wav",1);
|
||||
else if (9 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/nine.wav",1);
|
||||
else if (10 == m_btCountdown)
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/ten.wav",1);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-- Martin Webrant
|
23
cl_dll/aghl/aghudcountdown.h
Normal file
23
cl_dll/aghl/aghudcountdown.h
Normal file
@ -0,0 +1,23 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_COUNTDOWN_HUD_)
|
||||
#define _AG_COUNTDOWN_HUD_
|
||||
|
||||
class AgHudCountdown: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_Countdown(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
char m_btCountdown;
|
||||
char m_szPlayer1[32];
|
||||
char m_szPlayer2[32];
|
||||
};
|
||||
|
||||
#endif //_AG_COUNTDOWN_HUD_
|
||||
|
||||
//-- Martin Webrant
|
159
cl_dll/aghl/aghudctf.cpp
Normal file
159
cl_dll/aghl/aghudctf.cpp
Normal file
@ -0,0 +1,159 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <demo_api.h>
|
||||
#include "parsemsg.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "vgui_ScorePanel.h"
|
||||
|
||||
DECLARE_MESSAGE(m_CTF, CTF )
|
||||
DECLARE_MESSAGE(m_CTF, CTFSound )
|
||||
DECLARE_MESSAGE(m_CTF, CTFFlag )
|
||||
|
||||
int g_iPlayerFlag1 = 0;
|
||||
int g_iPlayerFlag2 = 0;
|
||||
|
||||
|
||||
int AgHudCTF::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( CTF );
|
||||
HOOK_MESSAGE( CTFSound );
|
||||
HOOK_MESSAGE( CTFFlag );
|
||||
|
||||
m_iFlags = 0;
|
||||
m_iFlagStatus1 = 0;
|
||||
m_iFlagStatus2 = 0;
|
||||
g_iPlayerFlag1 = 0;
|
||||
g_iPlayerFlag2 = 0;
|
||||
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudCTF::VidInit(void)
|
||||
{
|
||||
int iSprite = 0;
|
||||
iSprite = gHUD.GetSpriteIndex("icon_ctf_home");
|
||||
m_IconFlagStatus[Home].spr = gHUD.GetSprite(iSprite);
|
||||
m_IconFlagStatus[Home].rc = gHUD.GetSpriteRect(iSprite);
|
||||
|
||||
iSprite = gHUD.GetSpriteIndex("icon_ctf_stolen");
|
||||
m_IconFlagStatus[Stolen].spr = gHUD.GetSprite(iSprite);
|
||||
m_IconFlagStatus[Stolen].rc = gHUD.GetSpriteRect(iSprite);
|
||||
|
||||
iSprite = gHUD.GetSpriteIndex("icon_ctf_lost");
|
||||
m_IconFlagStatus[Lost].spr = gHUD.GetSprite(iSprite);
|
||||
m_IconFlagStatus[Lost].rc = gHUD.GetSpriteRect(iSprite);
|
||||
|
||||
iSprite = gHUD.GetSpriteIndex("icon_ctf_carry");
|
||||
m_IconFlagStatus[Carry].spr = gHUD.GetSprite(iSprite);
|
||||
m_IconFlagStatus[Carry].rc = gHUD.GetSpriteRect(iSprite);
|
||||
|
||||
m_iFlagStatus1 = 0;
|
||||
m_iFlagStatus2 = 0;
|
||||
g_iPlayerFlag1 = 0;
|
||||
g_iPlayerFlag2 = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AgHudCTF::Reset(void)
|
||||
{
|
||||
if (CTF != AgGametype() || gHUD.m_iIntermission)
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
int AgHudCTF::Draw(float fTime)
|
||||
{
|
||||
if (m_iFlagStatus1 == Off
|
||||
||m_iFlagStatus2 == Off || gHUD.m_iIntermission)
|
||||
{
|
||||
Reset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int x = 30;
|
||||
int y = ScreenHeight / 2;
|
||||
|
||||
//Draw Blue
|
||||
if (m_IconFlagStatus[m_iFlagStatus1].spr)
|
||||
{
|
||||
SPR_Set(m_IconFlagStatus[m_iFlagStatus1].spr, iTeamColors[1][0], iTeamColors[1][1], iTeamColors[1][2]);
|
||||
int yBlue = y - ((m_IconFlagStatus[m_iFlagStatus2].rc.bottom - m_IconFlagStatus[m_iFlagStatus2].rc.top) + 5);
|
||||
SPR_DrawAdditive( 0, x, yBlue, &m_IconFlagStatus[m_iFlagStatus1].rc );
|
||||
}
|
||||
//Draw Red
|
||||
if (m_IconFlagStatus[m_iFlagStatus2].spr)
|
||||
{
|
||||
//y += (m_IconFlagStatus[m_iFlagStatus2].rc.bottom - m_IconFlagStatus[m_iFlagStatus2].rc.top) + 5;
|
||||
SPR_Set(m_IconFlagStatus[m_iFlagStatus2].spr, iTeamColors[2][0], iTeamColors[2][1], iTeamColors[2][2]);
|
||||
SPR_DrawAdditive( 0, x, y, &m_IconFlagStatus[m_iFlagStatus2].rc );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudCTF::MsgFunc_CTF(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_iFlagStatus1 = READ_BYTE();
|
||||
m_iFlagStatus2 = READ_BYTE();
|
||||
|
||||
if (m_iFlagStatus1 != Off
|
||||
&&m_iFlagStatus2 != Off)
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char* s_szSounds[] =
|
||||
{
|
||||
"ctf/youhaveflag.wav",
|
||||
"ctf/teamhaveflag.wav",
|
||||
"ctf/enemyhaveflag.wav",
|
||||
"ctf/blueflagreturned.wav",
|
||||
"ctf/redflagreturned.wav",
|
||||
"ctf/bluescores.wav",
|
||||
"ctf/redscores.wav",
|
||||
"ctf/blueflagstolen.wav",
|
||||
"ctf/redflagstolen.wav",
|
||||
//Not used but can be good to have...
|
||||
"ctf/blueleads",
|
||||
"ctf/redleads",
|
||||
"ctf/teamstied",
|
||||
"ctf/suddendeath",
|
||||
"ctf/stolen"
|
||||
"ctf/capture"
|
||||
};
|
||||
|
||||
extern cvar_t* g_pcl_ctf_volume;
|
||||
int AgHudCTF::MsgFunc_CTFSound(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
int iSound = READ_BYTE();
|
||||
if (iSound >= 0 && iSound < sizeof(s_szSounds)/sizeof(s_szSounds[0]))
|
||||
gEngfuncs.pfnPlaySoundByName( s_szSounds[iSound], g_pcl_ctf_volume->value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int AgHudCTF::MsgFunc_CTFFlag(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
g_iPlayerFlag1 = READ_BYTE();
|
||||
g_iPlayerFlag2 = READ_BYTE();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-- Martin Webrant
|
35
cl_dll/aghl/aghudctf.h
Normal file
35
cl_dll/aghl/aghudctf.h
Normal file
@ -0,0 +1,35 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_CTF_HUD_)
|
||||
#define _AG_CTF_HUD_
|
||||
|
||||
|
||||
class AgHudCTF: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_CTF(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_CTFSound(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_CTFFlag(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
|
||||
HSPRITE spr;
|
||||
wrect_t rc;
|
||||
} icon_flagstatus_t;
|
||||
icon_flagstatus_t m_IconFlagStatus[4];
|
||||
enum enumFlagStatus { Off = -1, Home = 0, Stolen = 1, Lost = 2, Carry = 3};
|
||||
int m_iFlagStatus1;
|
||||
int m_iFlagStatus2;
|
||||
};
|
||||
|
||||
extern int g_iPlayerFlag1;
|
||||
extern int g_iPlayerFlag2;
|
||||
#endif //_AG_CTF_HUD_
|
||||
|
||||
//-- Martin Webrant
|
67
cl_dll/aghl/aghudcustomtimer.cpp
Normal file
67
cl_dll/aghl/aghudcustomtimer.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudCustomTimer.h"
|
||||
|
||||
DECLARE_COMMAND(m_CustomTimer, CustomTimer);
|
||||
|
||||
int AgHudCustomTimer::Init(void)
|
||||
{
|
||||
m_flTurnoff = 0;
|
||||
m_iFlags = 0;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
HOOK_COMMAND("customtimer",CustomTimer);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudCustomTimer::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudCustomTimer::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
int AgHudCustomTimer::Draw(float fTime)
|
||||
{
|
||||
if (m_flTurnoff < gHUD.m_flTime || gHUD.m_iIntermission)
|
||||
{
|
||||
gEngfuncs.pfnPlaySoundByName("fvox/bell.wav",1);
|
||||
Reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
char szText[32];
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_GREENISH);
|
||||
|
||||
sprintf(szText,"Timer %d",(int)(m_flTurnoff - gHUD.m_flTime));
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight*4 ,ScreenWidth,szText,r,g,b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AgHudCustomTimer::UserCmd_CustomTimer()
|
||||
{
|
||||
if (2 == gEngfuncs.Cmd_Argc())
|
||||
{
|
||||
m_flTurnoff = gHUD.m_flTime + atof(gEngfuncs.Cmd_Argv(1));
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-- Martin Webrant
|
23
cl_dll/aghl/aghudcustomtimer.h
Normal file
23
cl_dll/aghl/aghudcustomtimer.h
Normal file
@ -0,0 +1,23 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_CUSTOMTIMER_HUD_)
|
||||
#define _AG_CUSTOMTIMER_HUD_
|
||||
|
||||
class AgHudCustomTimer: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
|
||||
private:
|
||||
float m_flTurnoff;
|
||||
|
||||
public:
|
||||
void UserCmd_CustomTimer();
|
||||
};
|
||||
|
||||
#endif //_AG_CUSTOMTIMER_HUD_
|
||||
|
||||
//-- Martin Webrant
|
417
cl_dll/aghl/aghudglobal.cpp
Normal file
417
cl_dll/aghl/aghudglobal.cpp
Normal file
@ -0,0 +1,417 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "event_api.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "com_weapons.h"
|
||||
#include "parsemsg.h"
|
||||
#include "demo.h"
|
||||
#include "demo_api.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudglobal.h"
|
||||
#include "agmodelcheck.h"
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
#include "agwallhack.h"
|
||||
#include "agcrc32enforcer.h"
|
||||
#endif
|
||||
|
||||
#include "AgVariableChecker.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "vgui_ScorePanel.h"
|
||||
#include "AgVGuiMapBrowser.h"
|
||||
#include "AgDownload.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Global, PlaySound )
|
||||
DECLARE_MESSAGE(m_Global, CheatCheck )
|
||||
DECLARE_MESSAGE(m_Global, WhString )
|
||||
DECLARE_MESSAGE(m_Global, SpikeCheck )
|
||||
DECLARE_MESSAGE(m_Global, Gametype )
|
||||
DECLARE_MESSAGE(m_Global, AuthID )
|
||||
DECLARE_MESSAGE(m_Global, MapList )
|
||||
DECLARE_MESSAGE(m_Global, CRC32 )
|
||||
DECLARE_COMMAND(m_Global, Winamp);
|
||||
DECLARE_COMMAND(m_Global, ToggleWinamp);
|
||||
DECLARE_COMMAND(m_Global, ToggleMapBrowser);
|
||||
DECLARE_COMMAND(m_Global, LoadAuthID);
|
||||
DECLARE_COMMAND(m_Global, UnloadAuthID);
|
||||
DECLARE_COMMAND(m_Global, AgRecord);
|
||||
|
||||
int g_iPure = 1;
|
||||
BYTE g_GameType = STANDARD;
|
||||
|
||||
typedef map<int, AgString, less<int> > AgPlayerToAuthID;
|
||||
typedef map<AgString, AgString, less<AgString> > AgAuthIDToRealName;
|
||||
static AgPlayerToAuthID s_mapAuthID;
|
||||
static AgAuthIDToRealName s_mapRealName;
|
||||
|
||||
|
||||
static int s_iCheckWallhack = 0;
|
||||
extern cvar_t* g_pcl_scores;
|
||||
int AgHudGlobal::Init(void)
|
||||
{
|
||||
m_iFlags = 0;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
HOOK_MESSAGE( PlaySound );
|
||||
HOOK_MESSAGE( CheatCheck );
|
||||
HOOK_MESSAGE( WhString );
|
||||
HOOK_MESSAGE( SpikeCheck );
|
||||
HOOK_MESSAGE( Gametype );
|
||||
HOOK_MESSAGE( AuthID );
|
||||
HOOK_MESSAGE( MapList );
|
||||
HOOK_MESSAGE( CRC32 );
|
||||
HOOK_COMMAND("winamp",Winamp);
|
||||
HOOK_COMMAND("togglewinamp",ToggleWinamp);
|
||||
HOOK_COMMAND("togglemapbrowser",ToggleMapBrowser);
|
||||
HOOK_COMMAND("loadauthid",LoadAuthID);
|
||||
HOOK_COMMAND("unloadauthid",UnloadAuthID);
|
||||
HOOK_COMMAND("agrecord",AgRecord);
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudGlobal::VidInit(void)
|
||||
{
|
||||
if (!gEngfuncs.pDemoAPI->IsRecording())
|
||||
s_mapAuthID.clear();
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudGlobal::Reset(void)
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
m_fCheckColor = 0;
|
||||
}
|
||||
|
||||
int iOverLay = 0;
|
||||
|
||||
int AgHudGlobal::Draw(float fTime)
|
||||
{
|
||||
if (m_fCheckColor < gHUD.m_flTime)
|
||||
{
|
||||
AgUpdateHudColor();
|
||||
m_fCheckColor = gHUD.m_flTime + 1; //every second
|
||||
}
|
||||
if (g_pcl_scores->value < 1)
|
||||
return 1;
|
||||
|
||||
int xpos, ypos;
|
||||
xpos = 30;
|
||||
ypos = 50;
|
||||
sscanf(CVAR_GET_STRING("cl_scores_pos"), "%i %i", &xpos, &ypos);
|
||||
|
||||
int r,g,b;
|
||||
|
||||
if (gViewPort && gViewPort->m_pScoreBoard)
|
||||
{
|
||||
for (int iRow = 0, iLines = 0; iRow < gViewPort->m_pScoreBoard->m_iRows && iLines < g_pcl_scores->value; iRow++)
|
||||
{
|
||||
if (gViewPort->m_pScoreBoard->m_iIsATeam[iRow] == 1 && gHUD.m_Teamplay)
|
||||
{
|
||||
char szScore[64];
|
||||
team_info_t* team_info = &g_TeamInfo[gViewPort->m_pScoreBoard->m_iSortedRows[iRow]];
|
||||
sprintf(szScore,"%-5i %s",team_info->frags,team_info->name);
|
||||
|
||||
r = iTeamColors[team_info->teamnumber % iNumberOfTeamColors][0];
|
||||
g = iTeamColors[team_info->teamnumber % iNumberOfTeamColors][1];
|
||||
b = iTeamColors[team_info->teamnumber % iNumberOfTeamColors][2];
|
||||
|
||||
FillRGBA( xpos - 10, ypos + 2 , iOverLay, gHUD.m_scrinfo.iCharHeight * 0.9, r, g, b, 20 );
|
||||
|
||||
ScaleColors(r,g,b,135);
|
||||
|
||||
int ixposnew = gHUD.DrawHudString( xpos, ypos, ScreenWidth, szScore, r, g, b );
|
||||
iOverLay = max(ixposnew - xpos + 20,iOverLay);
|
||||
ypos += gHUD.m_scrinfo.iCharHeight * 0.9;
|
||||
iLines++;
|
||||
}
|
||||
else if (gViewPort->m_pScoreBoard->m_iIsATeam[iRow] == 0 && !gHUD.m_Teamplay)
|
||||
{
|
||||
char szScore[64];
|
||||
hud_player_info_t* pl_info = &g_PlayerInfoList[gViewPort->m_pScoreBoard->m_iSortedRows[iRow]];
|
||||
extra_player_info_t* pl_info_extra = &g_PlayerExtraInfo[gViewPort->m_pScoreBoard->m_iSortedRows[iRow]];
|
||||
sprintf(szScore,"%-5i %s",pl_info_extra->frags,pl_info->name);
|
||||
|
||||
r = iTeamColors[pl_info_extra->teamnumber % iNumberOfTeamColors][0];
|
||||
g = iTeamColors[pl_info_extra->teamnumber % iNumberOfTeamColors][1];
|
||||
b = iTeamColors[pl_info_extra->teamnumber % iNumberOfTeamColors][2];
|
||||
|
||||
FillRGBA( xpos - 10, ypos + 2, iOverLay, gHUD.m_scrinfo.iCharHeight * 0.9, r, g, b, 10 );
|
||||
|
||||
ScaleColors(r,g,b,135);
|
||||
|
||||
int ixposnew = gHUD.DrawHudString( xpos, ypos, ScreenWidth, szScore, r, g, b );
|
||||
iOverLay = max(ixposnew - xpos + 20,iOverLay);
|
||||
ypos += gHUD.m_scrinfo.iCharHeight * 0.9;
|
||||
iLines++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int AgHudGlobal::MsgFunc_PlaySound(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
vec3_t origin;
|
||||
/*int iPlayer = */READ_BYTE();
|
||||
for ( int i = 0 ; i < 3 ; i++)
|
||||
origin[i] = READ_COORD();
|
||||
char* pszSound = READ_STRING();
|
||||
|
||||
gEngfuncs.pfnPlaySoundByName( pszSound, 1);
|
||||
//this does not work - gEngfuncs.pfnPlaySoundByNameAtLocation( pszSound, 1, origin);
|
||||
|
||||
//gEngfuncs.pEventAPI->EV_PlaySound( -1, origin, 0, pszName, 1.0, ATTN_NORM, 0, PITCH_NORM );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern bool AgCRC32EnforceFiles();
|
||||
|
||||
int AgHudGlobal::MsgFunc_CheatCheck(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int iPure = READ_BYTE();
|
||||
|
||||
g_iPure = iPure;
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
if (0 < g_iPure)
|
||||
AgCRC32EnforceFiles();
|
||||
|
||||
g_VariableChecker.Activate();
|
||||
|
||||
DWORD dwTime = GetTickCount();
|
||||
|
||||
#ifdef _DEBUG
|
||||
AgLog( "Checking for spikes\n" );
|
||||
#endif //_DEBUG
|
||||
if (!g_ModelCheck.Check())
|
||||
return 1;
|
||||
|
||||
if (s_iCheckWallhack)
|
||||
{
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
#ifdef _DEBUG
|
||||
AgLog( "Checking for wallhack\n" );
|
||||
#endif //_DEBUG
|
||||
if (!g_Wallhack.Check())
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
char szTime[64];
|
||||
sprintf(szTime,"Cheat check took %dms\n",int((GetTickCount() - dwTime)));
|
||||
ConsolePrint(szTime);
|
||||
AgLog(szTime);
|
||||
#endif
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int AgHudGlobal::MsgFunc_WhString(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
g_Wallhack.AddBadStrings(READ_STRING());
|
||||
#else
|
||||
READ_STRING();
|
||||
#endif
|
||||
s_iCheckWallhack = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AgHudGlobal::MsgFunc_SpikeCheck(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
g_ModelCheck.CheckOne(READ_STRING());
|
||||
#else
|
||||
READ_STRING();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AgHudGlobal::MsgFunc_Gametype(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
g_GameType = READ_BYTE();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AgHudGlobal::MsgFunc_AuthID(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int iPlayer = READ_BYTE();
|
||||
AgString sAuthID = READ_STRING();
|
||||
|
||||
int iCutId = sAuthID.find("_");
|
||||
if (-1 != iCutId)
|
||||
sAuthID = sAuthID.substr(iCutId+1);
|
||||
|
||||
AgPlayerToAuthID::iterator itrAuthID = s_mapAuthID.find(iPlayer);
|
||||
if (itrAuthID == s_mapAuthID.end())
|
||||
s_mapAuthID.insert(AgPlayerToAuthID::value_type(iPlayer,sAuthID));
|
||||
else
|
||||
(*itrAuthID).second = sAuthID;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AgHudGlobal::MsgFunc_MapList( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
if (gViewPort && gViewPort->m_pMapBrowser)
|
||||
return gViewPort->m_pMapBrowser->MsgFunc_MapList( pszName, iSize, pbuf );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AgHudGlobal::MsgFunc_CRC32( const char *pszName, int iSize, void *pbuf )
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int iCheckSum = READ_LONG();
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
AgCRC32EnforceFile(READ_STRING(), iCheckSum);
|
||||
#else
|
||||
READ_STRING();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AgHudGlobal::UserCmd_Winamp()
|
||||
{
|
||||
gViewPort->UserCmd_Winamp();
|
||||
}
|
||||
|
||||
void AgHudGlobal::UserCmd_ToggleWinamp()
|
||||
{
|
||||
gViewPort->ToggleWinamp();
|
||||
}
|
||||
|
||||
void AgHudGlobal::UserCmd_ToggleMapBrowser()
|
||||
{
|
||||
gViewPort->ToggleMapBrowser();
|
||||
}
|
||||
|
||||
void AgHudGlobal::UserCmd_LoadAuthID()
|
||||
{
|
||||
char* pszFileName = "realnames.txt";
|
||||
if (gEngfuncs.Cmd_Argc() == 2)
|
||||
{
|
||||
char szSaveAs[MAX_PATH];
|
||||
AgString sUrl = gEngfuncs.Cmd_Argv(1);
|
||||
sprintf(szSaveAs,"%s/%s",AgGetDirectory(),pszFileName);
|
||||
sUrl = "http://" + sUrl;
|
||||
AgDownload download;
|
||||
download.DownloadFile(sUrl.c_str(), szSaveAs);
|
||||
}
|
||||
|
||||
int iFilePos = 0, iFileSize = 0;
|
||||
char* pFile = (char*)gEngfuncs.COM_LoadFile(pszFileName, 5, NULL);
|
||||
if (!pFile)
|
||||
{
|
||||
char szMessage[256];
|
||||
sprintf(szMessage, "Could not load file %s\n", pszFileName);
|
||||
ConsolePrint(szMessage);
|
||||
return;
|
||||
}
|
||||
AgString sRealNames(pFile);
|
||||
gEngfuncs.COM_FreeFile(pFile);
|
||||
|
||||
int iPosNewLine = sRealNames.find_first_of("\n");
|
||||
while (-1 != iPosNewLine)
|
||||
{
|
||||
AgString sAuthID, sRealName;
|
||||
int iPosRealName = sRealNames.find_first_of(" \t");
|
||||
sAuthID = sRealNames.substr(0,iPosRealName);
|
||||
sRealName = sRealNames.substr(iPosRealName+1,min(32,iPosNewLine - iPosRealName));
|
||||
|
||||
AgTrim(sAuthID);
|
||||
AgTrim(sRealName);
|
||||
|
||||
if ("//" != sAuthID.substr(0,2))
|
||||
{
|
||||
if (sAuthID.size() && sRealName.size())
|
||||
s_mapRealName.insert(AgAuthIDToRealName::value_type(sAuthID, sRealName));
|
||||
}
|
||||
else
|
||||
{
|
||||
AgString sComment = sRealNames.substr(2,iPosNewLine-2);
|
||||
AgTrim(sComment);
|
||||
sComment += "\n";
|
||||
ConsolePrint(sComment.c_str());
|
||||
}
|
||||
|
||||
sRealNames = sRealNames.substr(iPosNewLine+1);
|
||||
iPosNewLine = sRealNames.find_first_of("\n");
|
||||
}
|
||||
|
||||
char szCount[64];
|
||||
sprintf(szCount,"Loaded auth id's - %d\n",(int)s_mapRealName.size());
|
||||
ConsolePrint(szCount);
|
||||
}
|
||||
|
||||
void AgHudGlobal::UserCmd_UnloadAuthID()
|
||||
{
|
||||
ConsolePrint("Unloaded all auth id's\n");
|
||||
s_mapRealName.clear();
|
||||
}
|
||||
|
||||
AgString AgGetAuthID(int iPlayer)
|
||||
{
|
||||
AgPlayerToAuthID::iterator itrAuthID = s_mapAuthID.find(iPlayer);
|
||||
if (itrAuthID != s_mapAuthID.end())
|
||||
{
|
||||
return (*itrAuthID).second;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
AgString AgGetRealName(int iPlayer)
|
||||
{
|
||||
if (s_mapRealName.size())
|
||||
{
|
||||
AgString sRealName;
|
||||
AgPlayerToAuthID::iterator itrAuthID = s_mapAuthID.find(iPlayer);
|
||||
if (itrAuthID != s_mapAuthID.end())
|
||||
{
|
||||
AgAuthIDToRealName::iterator itrRealName = s_mapRealName.find((*itrAuthID).second);
|
||||
if (itrRealName != s_mapRealName.end())
|
||||
return (*itrRealName).second;
|
||||
}
|
||||
}
|
||||
return g_PlayerInfoList[iPlayer].name;
|
||||
}
|
||||
|
||||
void AgHudGlobal::UserCmd_AgRecord()
|
||||
{
|
||||
time_t t_now;
|
||||
time(&t_now);
|
||||
struct tm* now = localtime(&t_now);
|
||||
now->tm_year += 1900;
|
||||
|
||||
char szExtra[128];
|
||||
if (gEngfuncs.Cmd_Argc() == 2)
|
||||
sprintf(szExtra, "_%s",gEngfuncs.Cmd_Argv(1));
|
||||
else
|
||||
szExtra[0] = '\0';
|
||||
|
||||
char szCMD[128];
|
||||
sprintf(szCMD, "record %04d%02d%02d_%02d%02d%02d_%s%s\n",now->tm_year, now->tm_mon + 1, now->tm_mday, now->tm_hour, now->tm_min, now->tm_sec, AgMapname().c_str(), szExtra);
|
||||
ClientCmd(szCMD);
|
||||
}
|
||||
|
||||
//-- Martin Webrant
|
43
cl_dll/aghl/aghudglobal.h
Normal file
43
cl_dll/aghl/aghudglobal.h
Normal file
@ -0,0 +1,43 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_GLOBAL_HUD_)
|
||||
#define _AG_GLOBAL_HUD_
|
||||
|
||||
class AgHudGlobal: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_PlaySound(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_CheatCheck(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_WhString(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_SpikeCheck(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_Gametype(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_AuthID(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_MapList(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_CRC32(const char *pszName, int iSize, void *pbuf);
|
||||
void UserCmd_Winamp();
|
||||
void UserCmd_ToggleWinamp();
|
||||
void UserCmd_ToggleMapBrowser();
|
||||
void UserCmd_LoadAuthID();
|
||||
void UserCmd_UnloadAuthID();
|
||||
void UserCmd_AgRecord();
|
||||
protected:
|
||||
float m_fCheckColor;
|
||||
};
|
||||
|
||||
enum enumGameType { STANDARD = 0, ARENA = 1, LMS = 2, CTF = 3, ARCADE = 4, SGBOW = 5, INSTAGIB = 6};
|
||||
extern BYTE g_GameType;
|
||||
inline BYTE AgGametype()
|
||||
{
|
||||
return g_GameType;
|
||||
};
|
||||
|
||||
AgString AgGetAuthID(int iPlayer);
|
||||
AgString AgGetRealName(int iPlayer);
|
||||
|
||||
#endif //_AG_GLOBAL_HUD_
|
||||
|
||||
//-- Martin Webrant
|
194
cl_dll/aghl/aghudirc.cpp
Normal file
194
cl_dll/aghl/aghudirc.cpp
Normal file
@ -0,0 +1,194 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <lmcons.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudirc.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
|
||||
DECLARE_COMMAND(m_IRC, IRCConnect);
|
||||
DECLARE_COMMAND(m_IRC, IRCConnect2);
|
||||
DECLARE_COMMAND(m_IRC, IRCDisconnect);
|
||||
DECLARE_COMMAND(m_IRC, IRCCommand);
|
||||
DECLARE_COMMAND(m_IRC, IRCToggle);
|
||||
|
||||
extern irc::CIrcSession g_ircSession;
|
||||
extern cvar_t* g_pirc_server;
|
||||
extern cvar_t* g_pirc_nick;
|
||||
extern cvar_t* g_pirc_port;
|
||||
extern cvar_t* g_pirc_userid;
|
||||
extern cvar_t* g_pirc_password;
|
||||
extern cvar_t* g_pirc_fullname;
|
||||
|
||||
AgIRC* g_pIRC = NULL;
|
||||
|
||||
int AgHudIRC::Init(void)
|
||||
{
|
||||
m_iFlags = 0;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
HOOK_COMMAND("IRCConnect",IRCConnect);
|
||||
HOOK_COMMAND("IRCConnect2",IRCConnect2);
|
||||
HOOK_COMMAND("IRCDisconnect",IRCDisconnect);
|
||||
HOOK_COMMAND("IRC",IRCCommand);
|
||||
HOOK_COMMAND("toggleirc",IRCToggle);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudIRC::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudIRC::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
int AgHudIRC::Draw(float fTime)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AgHudIRC::UserCmd_IRCConnect()
|
||||
{
|
||||
IRCConnect(false);
|
||||
}
|
||||
|
||||
void AgHudIRC::UserCmd_IRCConnect2()
|
||||
{
|
||||
IRCConnect(true);
|
||||
}
|
||||
|
||||
|
||||
void AgHudIRC::IRCConnect(bool bSilent)
|
||||
{
|
||||
if (!gViewPort)
|
||||
return;
|
||||
|
||||
char szUser[UNLEN],szComputer[UNLEN];
|
||||
DWORD dwSize = UNLEN;
|
||||
GetComputerName(szComputer,&dwSize);
|
||||
szComputer[dwSize] = '\0';
|
||||
dwSize = UNLEN;
|
||||
GetUserName(szUser,&dwSize);
|
||||
szUser[dwSize] = '\0';
|
||||
|
||||
CIrcSessionInfo si;
|
||||
|
||||
si.sServer = gEngfuncs.pfnGetCvarString("irc_server");
|
||||
si.iPort = gEngfuncs.pfnGetCvarFloat("irc_port");
|
||||
si.sNick = gEngfuncs.pfnGetCvarString("irc_nick");
|
||||
si.sUserID = gEngfuncs.pfnGetCvarString("irc_userid");
|
||||
si.sFullName = gEngfuncs.pfnGetCvarString("irc_fullname");
|
||||
si.sPassword = gEngfuncs.pfnGetCvarString("irc_password");
|
||||
si.bIdentServer = true;
|
||||
si.iIdentServerPort = 113;
|
||||
si.sIdentServerType = "UNIX";
|
||||
|
||||
if (0 == si.sNick.size())
|
||||
{
|
||||
int iPlayer = gEngfuncs.GetLocalPlayer()->index; // Get the local player's index
|
||||
si.sNick = gEngfuncs.PlayerInfo_ValueForKey(iPlayer,"name");
|
||||
si.sNick += "|AG";
|
||||
}
|
||||
|
||||
if (0 == si.sUserID.size())
|
||||
{
|
||||
si.sUserID = szComputer;
|
||||
}
|
||||
|
||||
if (0 == si.sFullName.size())
|
||||
{
|
||||
si.sFullName = szUser;
|
||||
}
|
||||
|
||||
if (!bSilent)
|
||||
{
|
||||
if (gEngfuncs.Cmd_Argc() > 1)
|
||||
si.sServer = gEngfuncs.Cmd_Argv(1);
|
||||
|
||||
if (gEngfuncs.Cmd_Argc() > 2)
|
||||
si.iPort = atoi(gEngfuncs.Cmd_Argv(2));
|
||||
|
||||
if (gEngfuncs.Cmd_Argc() > 3)
|
||||
si.sNick = gEngfuncs.Cmd_Argv(3);
|
||||
|
||||
if (gEngfuncs.Cmd_Argc() > 4)
|
||||
si.sUserID = gEngfuncs.Cmd_Argv(4);
|
||||
|
||||
if (gEngfuncs.Cmd_Argc() > 5)
|
||||
si.sFullName = gEngfuncs.Cmd_Argv(5);
|
||||
|
||||
if (gEngfuncs.Cmd_Argc() > 6)
|
||||
si.sPassword = gEngfuncs.Cmd_Argv(6);
|
||||
}
|
||||
|
||||
if (g_pIRC)
|
||||
{
|
||||
g_pIRC->Disconnect("http://www.planethalflife.com/agmod");
|
||||
}
|
||||
else
|
||||
g_pIRC = new AgIRC();
|
||||
|
||||
if (bSilent)
|
||||
g_pIRC->SilentMode();
|
||||
|
||||
g_pIRC->Connect(&si);
|
||||
}
|
||||
|
||||
void AgHudIRC::UserCmd_IRCDisconnect()
|
||||
{
|
||||
if (!gViewPort)
|
||||
return;
|
||||
if (!g_pIRC)
|
||||
return;
|
||||
g_pIRC->Disconnect("http://www.planethalflife.com/agmod");
|
||||
delete g_pIRC;
|
||||
g_pIRC = NULL;
|
||||
}
|
||||
|
||||
void AgHudIRC::UserCmd_IRCCommand()
|
||||
{
|
||||
if (!gViewPort)
|
||||
return;
|
||||
if (!g_pIRC)
|
||||
return;
|
||||
|
||||
AgString sCommand;
|
||||
|
||||
for (int i = 1; i < gEngfuncs.Cmd_Argc(); i++ )
|
||||
{
|
||||
const char *param = gEngfuncs.Cmd_Argv( i );
|
||||
if ( param )
|
||||
{
|
||||
if (0 != sCommand.size())
|
||||
sCommand += " ";
|
||||
sCommand += param;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
g_pIRC->Command(sCommand);
|
||||
|
||||
}
|
||||
|
||||
void AgHudIRC::UserCmd_IRCToggle()
|
||||
{
|
||||
if ( gViewPort )
|
||||
{
|
||||
gViewPort->ToggleIRC();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-- Martin Webrant
|
29
cl_dll/aghl/aghudirc.h
Normal file
29
cl_dll/aghl/aghudirc.h
Normal file
@ -0,0 +1,29 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_IRC_HUD_)
|
||||
#define _AG_IRC_HUD_
|
||||
|
||||
#include "irc.h"
|
||||
#include "AgIRC.h"
|
||||
|
||||
class AgHudIRC: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
|
||||
void IRCConnect(bool bSilent);
|
||||
|
||||
public:
|
||||
void UserCmd_IRCConnect();
|
||||
void UserCmd_IRCConnect2();
|
||||
void UserCmd_IRCDisconnect();
|
||||
void UserCmd_IRCCommand();
|
||||
void UserCmd_IRCToggle();
|
||||
};
|
||||
|
||||
#endif //_AG_IRC_HUD_
|
||||
|
||||
//-- Martin Webrant
|
409
cl_dll/aghl/aghudlocation.cpp
Normal file
409
cl_dll/aghl/aghudlocation.cpp
Normal file
@ -0,0 +1,409 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudlocation.h"
|
||||
|
||||
|
||||
DECLARE_MESSAGE(m_Location, Location );
|
||||
DECLARE_MESSAGE(m_Location, InitLoc );
|
||||
DECLARE_COMMAND(m_Location, OpenLocation );
|
||||
DECLARE_COMMAND(m_Location, CloseLocation );
|
||||
DECLARE_COMMAND(m_Location, AddLocation );
|
||||
DECLARE_COMMAND(m_Location, DeleteLocation );
|
||||
DECLARE_COMMAND(m_Location, ShowLocations );
|
||||
|
||||
Vector vPlayerLocations[MAX_PLAYERS+1];
|
||||
|
||||
int AgHudLocation::Init(void)
|
||||
{
|
||||
m_fAt = 0;
|
||||
m_fNear = 0;
|
||||
m_iFlags = 0;
|
||||
m_szMap[0] = '\0';
|
||||
|
||||
for (int i = 1; i <= MAX_PLAYERS; i++)
|
||||
vPlayerLocations[i] = Vector(0,0,0);
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
HOOK_MESSAGE( Location );
|
||||
HOOK_MESSAGE( InitLoc );
|
||||
#ifdef _DEBUG
|
||||
HOOK_COMMAND("+location",OpenLocation);
|
||||
HOOK_COMMAND("-location",CloseLocation);
|
||||
#endif
|
||||
HOOK_COMMAND("agaddloc",AddLocation);
|
||||
HOOK_COMMAND("agdelloc",DeleteLocation);
|
||||
HOOK_COMMAND("aglistloc",ShowLocations);
|
||||
return 1;
|
||||
};
|
||||
|
||||
AgHudLocation::~AgHudLocation()
|
||||
{
|
||||
//Delete all.
|
||||
for (AgLocationList::iterator itrLocations = m_lstLocations.begin() ;itrLocations != m_lstLocations.end(); ++itrLocations)
|
||||
delete *itrLocations;
|
||||
m_lstLocations.clear();
|
||||
}
|
||||
|
||||
int AgHudLocation::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudLocation::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
int AgHudLocation::Draw(float fTime)
|
||||
{
|
||||
cl_entity_t* pPlayer = gEngfuncs.GetLocalPlayer(); // Get the local player's index
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_GREENISH);
|
||||
int iPos = 5;
|
||||
for (int i = 1; i < gEngfuncs.GetMaxClients(); i++ )
|
||||
{
|
||||
if (i == pPlayer->index)
|
||||
continue;
|
||||
|
||||
if ('\0' != g_PlayerExtraInfo[i].teamname[0] &&
|
||||
'\0' != g_PlayerExtraInfo[i].teamname[pPlayer->index] &&
|
||||
0 == stricmp(g_PlayerExtraInfo[i].teamname, g_PlayerExtraInfo[pPlayer->index].teamname))
|
||||
{
|
||||
//Show his location - it's a team m8.
|
||||
char szText[128];
|
||||
sprintf(szText,"%s [%s]",g_PlayerInfoList[i].name,Location(vPlayerLocations[i]).c_str());
|
||||
gHUD.DrawHudString(ScreenWidth/20, ScreenHeight/8 + gHUD.m_scrinfo.iCharHeight*iPos,ScreenWidth,szText,r,g,b);
|
||||
iPos++;
|
||||
}
|
||||
}
|
||||
|
||||
return 5 != iPos;
|
||||
}
|
||||
|
||||
|
||||
void AgHudLocation::UserCmd_OpenLocation()
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
}
|
||||
|
||||
void AgHudLocation::UserCmd_CloseLocation()
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
void AgHudLocation::UserCmd_AddLocation()
|
||||
{
|
||||
if (2 == gEngfuncs.Cmd_Argc())
|
||||
{
|
||||
AgString sLocation = gEngfuncs.Cmd_Argv(1);
|
||||
if (0 == sLocation.size())
|
||||
return;
|
||||
|
||||
AgLocation* pLocation = new AgLocation;
|
||||
pLocation->m_sLocation = sLocation;
|
||||
//pLocation->m_vPosition = vPlayerLocations[gEngfuncs.GetLocalPlayer()->index];
|
||||
pLocation->m_vPosition = gEngfuncs.GetLocalPlayer()->attachment[0];
|
||||
|
||||
m_lstLocations.push_back(pLocation);
|
||||
pLocation->Show();
|
||||
|
||||
Save();
|
||||
|
||||
char szMsg[128];
|
||||
sprintf(szMsg,"Added Location %s.\n",(const char*)sLocation.c_str());
|
||||
ConsolePrint(szMsg);
|
||||
}
|
||||
}
|
||||
|
||||
void AgHudLocation::UserCmd_DeleteLocation()
|
||||
{
|
||||
if (2 == gEngfuncs.Cmd_Argc())
|
||||
{
|
||||
AgString sLocation = gEngfuncs.Cmd_Argv(1);
|
||||
if (0 == sLocation.size())
|
||||
return;
|
||||
|
||||
for (AgLocationList::iterator itrLocations = m_lstLocations.begin() ;itrLocations != m_lstLocations.end(); ++itrLocations)
|
||||
{
|
||||
if (0 == stricmp((*itrLocations)->m_sLocation.c_str(),sLocation.c_str()))
|
||||
{
|
||||
char szMsg[128];
|
||||
sprintf(szMsg,"Deleted Location %s.\n",(const char*)sLocation.c_str());
|
||||
ConsolePrint(szMsg);
|
||||
|
||||
AgLocation* pLocation = *itrLocations;
|
||||
m_lstLocations.erase(itrLocations);
|
||||
delete pLocation;
|
||||
Save();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AgHudLocation::UserCmd_ShowLocations()
|
||||
{
|
||||
for (AgLocationList::iterator itrLocations = m_lstLocations.begin() ;itrLocations != m_lstLocations.end(); ++itrLocations)
|
||||
{
|
||||
char szMsg[128];
|
||||
sprintf(szMsg,"%s\n",(const char*)(*itrLocations)->m_sLocation.c_str());
|
||||
ConsolePrint(szMsg);
|
||||
(*itrLocations)->Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AgHudLocation::InitDistances()
|
||||
{
|
||||
if (2 > m_lstLocations.size())
|
||||
return; //No use.
|
||||
|
||||
float fMinDistance = -1;
|
||||
float fMaxdistance = 0;
|
||||
|
||||
//Calculate max/min distance between all locations.
|
||||
for (AgLocationList::iterator itrLocations = m_lstLocations.begin() ;itrLocations != m_lstLocations.end(); ++itrLocations)
|
||||
{
|
||||
for (AgLocationList::iterator itr = m_lstLocations.begin() ;itr != m_lstLocations.end(); ++itr)
|
||||
{
|
||||
if (*itrLocations != *itr)
|
||||
{
|
||||
float fDistance = ((*itr)->m_vPosition - (*itrLocations)->m_vPosition).Length();
|
||||
|
||||
if (fDistance < fMinDistance || -1 == fMinDistance)
|
||||
fMinDistance = fDistance;
|
||||
|
||||
if (fDistance > fMaxdistance)
|
||||
fMaxdistance = fDistance;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Now calculate when you are at/near a location or at atleast when its closest.
|
||||
m_fAt = fMinDistance / 2; //You are at a location if you are one fourth between to locations.
|
||||
m_fNear = fMinDistance / 1.1; //Over halfway of the mindistance you are at the "side".
|
||||
}
|
||||
|
||||
bool AgHudLocation::NearestLocation(const Vector& vPosition, AgLocation*& pLocation, float& fNearestdistance)
|
||||
{
|
||||
fNearestdistance = -1;
|
||||
pLocation = NULL;
|
||||
|
||||
for (AgLocationList::iterator itrLocations = m_lstLocations.begin() ;itrLocations != m_lstLocations.end(); ++itrLocations)
|
||||
{
|
||||
float fDistance = (vPosition - (*itrLocations)->m_vPosition).Length();
|
||||
|
||||
if (fDistance < fNearestdistance || -1 == fNearestdistance)
|
||||
{
|
||||
fNearestdistance = fDistance;
|
||||
pLocation = *itrLocations;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL != pLocation;
|
||||
}
|
||||
|
||||
extern cvar_t* g_pcl_location_keywords;
|
||||
|
||||
AgString AgHudLocation::Location(const Vector& vLocation)
|
||||
{
|
||||
AgString sLocation;
|
||||
if (2 > m_lstLocations.size())
|
||||
return sLocation;
|
||||
|
||||
AgLocation* pLocation = NULL;
|
||||
float fNearestDistance = 0;
|
||||
|
||||
if (NearestLocation(vLocation, pLocation, fNearestDistance))
|
||||
{
|
||||
if (pLocation)
|
||||
{
|
||||
/*
|
||||
#ifdef _DEBUG
|
||||
pLocation->Show();
|
||||
#endif
|
||||
*/
|
||||
if (fNearestDistance < m_fAt || g_pcl_location_keywords->value < 1)
|
||||
{
|
||||
sLocation = pLocation->m_sLocation;
|
||||
}
|
||||
else if (fNearestDistance < m_fNear)
|
||||
{
|
||||
sLocation.append("Near ");
|
||||
sLocation.append(pLocation->m_sLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
sLocation.append(pLocation->m_sLocation);
|
||||
sLocation.append(" Side");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sLocation;
|
||||
}
|
||||
|
||||
void AgHudLocation::Load()
|
||||
{
|
||||
for (AgLocationList::iterator itrLocations = m_lstLocations.begin() ;itrLocations != m_lstLocations.end(); ++itrLocations)
|
||||
delete *itrLocations;
|
||||
m_lstLocations.clear();
|
||||
|
||||
char szData[8196];
|
||||
|
||||
char szFile[MAX_PATH];
|
||||
sprintf(szFile,"%s/locs/%s.loc",AgGetDirectory(),m_szMap);
|
||||
FILE* pFile = fopen(szFile,"r");
|
||||
if (!pFile)
|
||||
{
|
||||
// file error
|
||||
char szMsg[128];
|
||||
sprintf(szMsg,"Couldn't open location file %s.\n",szFile);
|
||||
ConsolePrint(szMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
enum enumParseState { Location, X, Y, Z };
|
||||
enumParseState ParseState = Location;
|
||||
AgLocation* pLocation = new AgLocation;
|
||||
int iRead = fread(szData,sizeof(char),sizeof(szData)-2,pFile);
|
||||
if (0 >= iRead)
|
||||
return;
|
||||
szData[iRead] = '\0';
|
||||
|
||||
char* pszParse = NULL;
|
||||
pszParse = strtok(szData, "#");
|
||||
if (pszParse)
|
||||
{
|
||||
while (pszParse)
|
||||
{
|
||||
if (Location == ParseState)
|
||||
{
|
||||
pLocation->m_sLocation = pszParse;
|
||||
ParseState = X;
|
||||
}
|
||||
else if (X == ParseState)
|
||||
{
|
||||
pLocation->m_vPosition.x = atof(pszParse);
|
||||
ParseState = Y;
|
||||
}
|
||||
else if (Y == ParseState)
|
||||
{
|
||||
pLocation->m_vPosition.y = atof(pszParse);
|
||||
ParseState = Z;
|
||||
}
|
||||
else if (Z == ParseState)
|
||||
{
|
||||
pLocation->m_vPosition.z = atof(pszParse);
|
||||
m_lstLocations.push_back(pLocation);
|
||||
pLocation = new AgLocation;
|
||||
ParseState = Location;
|
||||
}
|
||||
pszParse = strtok(NULL, "#");
|
||||
}
|
||||
}
|
||||
delete pLocation;
|
||||
|
||||
fclose(pFile);
|
||||
|
||||
InitDistances();
|
||||
}
|
||||
|
||||
void AgHudLocation::Save()
|
||||
{
|
||||
InitDistances();
|
||||
|
||||
if (0 == m_lstLocations.size())
|
||||
return;
|
||||
|
||||
char szFile[MAX_PATH];
|
||||
sprintf(szFile,"%s/locs/%s.loc",AgGetDirectory(),m_szMap);
|
||||
FILE* pFile = fopen(szFile,"wb");
|
||||
if (!pFile)
|
||||
{
|
||||
// file error
|
||||
char szMsg[128];
|
||||
sprintf(szMsg,"Couldn't create/save location file %s.\n",szFile);
|
||||
ConsolePrint(szMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
//Loop and write the file.
|
||||
for (AgLocationList::iterator itrLocations = m_lstLocations.begin() ;itrLocations != m_lstLocations.end(); ++itrLocations)
|
||||
{
|
||||
//Append.
|
||||
AgLocation* pLocation = *itrLocations;
|
||||
fprintf(pFile,"%s#%f#%f#%f#",(const char*)pLocation->m_sLocation.c_str(),pLocation->m_vPosition.x,pLocation->m_vPosition.y,pLocation->m_vPosition.z);
|
||||
}
|
||||
|
||||
fflush(pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
|
||||
void AgHudLocation::ParseAndEditSayString(char* pszSay, int iPlayer)
|
||||
{
|
||||
//Make backup
|
||||
char* pszText = (char*)malloc(strlen(pszSay)+1);
|
||||
char* pszSayTemp = pszText;
|
||||
strcpy(pszText,pszSay);
|
||||
//Now parse for %L and edit it.
|
||||
|
||||
while (*pszSayTemp) //Dont overflow the string. Stop when its 200 chars.
|
||||
{
|
||||
if ('%' == *pszSayTemp)
|
||||
{
|
||||
pszSayTemp++;
|
||||
if ('l' == *pszSayTemp || 'L' == *pszSayTemp || 'd' == *pszSayTemp || 'D' == *pszSayTemp )
|
||||
{
|
||||
//Location files.
|
||||
pszSay = pszSay + sprintf(pszSay,Location(vPlayerLocations[iPlayer]).c_str());
|
||||
pszSayTemp++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
pszSay[0] = '%';
|
||||
pszSay++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
*pszSay = *pszSayTemp;
|
||||
pszSay++;
|
||||
pszSayTemp++;
|
||||
}
|
||||
*pszSay = '\0';
|
||||
|
||||
free(pszText);
|
||||
}
|
||||
|
||||
|
||||
int AgHudLocation::MsgFunc_Location(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
vec3_t origin;
|
||||
int iPlayer = READ_BYTE();
|
||||
for ( int i = 0 ; i < 3 ; i++)
|
||||
vPlayerLocations[iPlayer][i] = READ_COORD();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AgHudLocation::MsgFunc_InitLoc(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
strcpy(m_szMap,READ_STRING());
|
||||
Load();
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-- Martin Webrant
|
51
cl_dll/aghl/aghudlocation.h
Normal file
51
cl_dll/aghl/aghudlocation.h
Normal file
@ -0,0 +1,51 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_LOCATION_HUD_)
|
||||
#define _AG_LOCATION_HUD_
|
||||
#include "aglocation.h"
|
||||
|
||||
class AgHudLocation: public CHudBase
|
||||
{
|
||||
public:
|
||||
virtual ~AgHudLocation();
|
||||
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
|
||||
private:
|
||||
typedef list<AgLocation*> AgLocationList;
|
||||
AgLocationList m_lstLocations;
|
||||
float m_fAt;
|
||||
float m_fNear;
|
||||
|
||||
bool NearestLocation(const Vector& vPosition, AgLocation*& pLocation, float& fNearest);
|
||||
|
||||
|
||||
void InitDistances();
|
||||
void Load();
|
||||
void Save();
|
||||
|
||||
AgString Location(const Vector& vPosition);
|
||||
|
||||
public:
|
||||
char m_szMap[32];
|
||||
|
||||
void ParseAndEditSayString(char* pszSay, int iPlayer);
|
||||
|
||||
void UserCmd_OpenLocation();
|
||||
void UserCmd_CloseLocation();
|
||||
|
||||
void UserCmd_AddLocation();
|
||||
void UserCmd_DeleteLocation();
|
||||
void UserCmd_ShowLocations();
|
||||
|
||||
int MsgFunc_InitLoc(const char *pszName, int iSize, void *pbuf);
|
||||
int MsgFunc_Location(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
};
|
||||
|
||||
#endif //_AG_LOCATION_HUD_
|
||||
|
||||
//-- Martin Webrant
|
67
cl_dll/aghl/aghudlongjump.cpp
Normal file
67
cl_dll/aghl/aghudlongjump.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudLongjump.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Longjump, Longjump )
|
||||
|
||||
int AgHudLongjump::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Longjump );
|
||||
|
||||
m_flTurnoff = 0;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudLongjump::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudLongjump::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
int AgHudLongjump::Draw(float fTime)
|
||||
{
|
||||
if (m_flTurnoff < gHUD.m_flTime || gHUD.m_iIntermission)
|
||||
{
|
||||
Reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
char szText[32];
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_GREENISH);
|
||||
sprintf(szText,"Longjump %d",(int)(m_flTurnoff - gHUD.m_flTime));
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight*2 ,ScreenWidth,szText,r,g,b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudLongjump::MsgFunc_Longjump(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
int iTime = READ_BYTE();
|
||||
|
||||
m_flTurnoff = gHUD.m_flTime + iTime;
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-- Martin Webrant
|
21
cl_dll/aghl/aghudlongjump.h
Normal file
21
cl_dll/aghl/aghudlongjump.h
Normal file
@ -0,0 +1,21 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_LONGJUMP_HUD_)
|
||||
#define _AG_LONGJUMP_HUD_
|
||||
|
||||
class AgHudLongjump: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_Longjump(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
float m_flTurnoff;
|
||||
};
|
||||
|
||||
#endif //_AG_LONGJUMP_HUD_
|
||||
|
||||
//-- Martin Webrant
|
67
cl_dll/aghl/aghudnextmap.cpp
Normal file
67
cl_dll/aghl/aghudnextmap.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudnextmap.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Nextmap, Nextmap )
|
||||
|
||||
int AgHudNextmap::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Nextmap );
|
||||
|
||||
m_iFlags = 0;
|
||||
m_szNextmap[0] = '\0';
|
||||
m_flTurnoff = 0;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudNextmap::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudNextmap::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
int AgHudNextmap::Draw(float fTime)
|
||||
{
|
||||
if (m_flTurnoff < gHUD.m_flTime)
|
||||
{
|
||||
Reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
char szText[32];
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
sprintf(szText,"Nextmap is %s",m_szNextmap);
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight*5 ,ScreenWidth,szText,r,g,b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudNextmap::MsgFunc_Nextmap(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
strcpy(m_szNextmap,READ_STRING());
|
||||
|
||||
m_flTurnoff = gHUD.m_flTime + 10; //Display for 10 seconds.
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-- Martin Webrant
|
22
cl_dll/aghl/aghudnextmap.h
Normal file
22
cl_dll/aghl/aghudnextmap.h
Normal file
@ -0,0 +1,22 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_NEXTMAP_HUD_)
|
||||
#define _AG_NEXTMAP_HUD_
|
||||
|
||||
class AgHudNextmap: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_Nextmap(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
float m_flTurnoff;
|
||||
char m_szNextmap[32];
|
||||
};
|
||||
|
||||
#endif //_AG_NEXTMAP_HUD_
|
||||
|
||||
//-- Martin Webrant
|
106
cl_dll/aghl/aghudplayerid.cpp
Normal file
106
cl_dll/aghl/aghudplayerid.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudplayerid.h"
|
||||
|
||||
DECLARE_MESSAGE(m_PlayerId, PlayerId )
|
||||
|
||||
extern cvar_t* g_phud_playerid;
|
||||
|
||||
int AgHudPlayerId::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( PlayerId );
|
||||
|
||||
m_iPlayer = 0;
|
||||
m_bTeam = false;
|
||||
m_iHealth = 0;
|
||||
m_iArmour = 0;
|
||||
m_flTurnoff = 0.0;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudPlayerId::VidInit(void)
|
||||
{
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudPlayerId::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
m_iPlayer = 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudPlayerId::Draw(float fTime)
|
||||
{
|
||||
if (0 == g_phud_playerid->value || 0 >= m_iPlayer)
|
||||
return 1;
|
||||
|
||||
if (m_flTurnoff < gHUD.m_flTime)
|
||||
{
|
||||
Reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_PlayerInfoList[m_iPlayer].name)
|
||||
{
|
||||
char szText[64];
|
||||
if (m_bTeam)
|
||||
sprintf(szText,"%s %d/%d",g_PlayerInfoList[m_iPlayer].name,m_iHealth,m_iArmour);
|
||||
else
|
||||
sprintf(szText,"%s",g_PlayerInfoList[m_iPlayer].name);
|
||||
|
||||
int r, g, b;
|
||||
|
||||
if (m_bTeam)
|
||||
UnpackRGB(r,g,b, RGB_GREENISH);
|
||||
else
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
|
||||
if (CVAR_GET_FLOAT("hud_centerid"))
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, ScreenHeight - ScreenHeight/4,ScreenWidth,szText,r,g,b);
|
||||
else
|
||||
gHUD.DrawHudString(10, ScreenHeight - ScreenHeight/8,ScreenWidth,szText,r,g,b);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudPlayerId::MsgFunc_PlayerId(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
m_iPlayer = READ_BYTE();
|
||||
if (1 == READ_BYTE())
|
||||
m_bTeam = true;
|
||||
else
|
||||
m_bTeam = false;
|
||||
m_iHealth = READ_SHORT();
|
||||
m_iArmour = READ_SHORT();
|
||||
|
||||
if (0 == g_phud_playerid->value)
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
GetPlayerInfo(m_iPlayer, &g_PlayerInfoList[m_iPlayer]);
|
||||
|
||||
m_flTurnoff = gHUD.m_flTime + 2; //Hold for 2 seconds.
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-- Martin Webrant
|
27
cl_dll/aghl/aghudplayerid.h
Normal file
27
cl_dll/aghl/aghudplayerid.h
Normal file
@ -0,0 +1,27 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_PLAYERID_HUD_)
|
||||
#define _AG_PLAYERID_HUD_
|
||||
|
||||
class AgHudPlayerId: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_PlayerId(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
float m_flTurnoff;
|
||||
int m_iPlayer;
|
||||
bool m_bTeam;
|
||||
int m_iHealth;
|
||||
int m_iArmour;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //_AG_PLAYERID_HUD_
|
||||
|
||||
//-- Martin Webrant
|
254
cl_dll/aghl/aghudscoreboard.cpp
Normal file
254
cl_dll/aghl/aghudscoreboard.cpp
Normal file
@ -0,0 +1,254 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <demo_api.h>
|
||||
#include "parsemsg.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "vgui_ScorePanel.h"
|
||||
|
||||
|
||||
int AgHudScoreboard::Init(void)
|
||||
{
|
||||
m_bShowScoreboard = false;
|
||||
m_iFlags = 0;
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudScoreboard::VidInit(void)
|
||||
{
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
m_iFlags |= HUD_INTERMISSION; // is always drawn during an intermission
|
||||
|
||||
int iSprite = 0;
|
||||
iSprite = gHUD.GetSpriteIndex("icon_ctf_score");
|
||||
m_IconFlagScore.spr = gHUD.GetSprite(iSprite);
|
||||
m_IconFlagScore.rc = gHUD.GetSpriteRect(iSprite);
|
||||
m_bShowScoreboard = false;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AgHudScoreboard::Reset(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool AgHudScoreboard::IsVisible()
|
||||
{
|
||||
return m_bShowScoreboard;
|
||||
}
|
||||
|
||||
void AgHudScoreboard::ShowScoreboard(bool bShow)
|
||||
{
|
||||
if (bShow && gViewPort && gViewPort->m_pScoreBoard)
|
||||
gViewPort->m_pScoreBoard->RebuildTeams();
|
||||
m_bShowScoreboard = bShow;
|
||||
}
|
||||
|
||||
/* The scoreboard
|
||||
We have a minimum width of 1-320 - we could have the field widths scale with it?
|
||||
*/
|
||||
|
||||
// X positions
|
||||
// relative to the side of the scoreboard
|
||||
#define NAME_RANGE_MIN 20
|
||||
#define NAME_RANGE_MAX 145
|
||||
#define KILLS_RANGE_MIN 130
|
||||
#define KILLS_RANGE_MAX 170
|
||||
#define DIVIDER_POS 180
|
||||
#define DEATHS_RANGE_MIN 185
|
||||
#define DEATHS_RANGE_MAX 210
|
||||
#define PING_RANGE_MIN 245
|
||||
#define PING_RANGE_MAX 295
|
||||
|
||||
#define SCOREBOARD_WIDTH 320
|
||||
|
||||
// Y positions
|
||||
#define ROW_GAP 13
|
||||
#define ROW_RANGE_MIN 15
|
||||
#define ROW_RANGE_MAX ( ScreenHeight - 50 )
|
||||
#define ROW_TOP 40
|
||||
|
||||
#define TEAM_NO 0
|
||||
#define TEAM_YES 1
|
||||
#define TEAM_SPECTATORS 2
|
||||
#define TEAM_BLANK 3
|
||||
|
||||
extern int arrHudColor[3];
|
||||
|
||||
int AgHudScoreboard::Draw(float fTime)
|
||||
{
|
||||
if (!m_bShowScoreboard)
|
||||
return 1;
|
||||
|
||||
// just sort the list on the fly
|
||||
// list is sorted first by frags, then by deaths
|
||||
float list_slot = 0;
|
||||
int xpos_rel = (ScreenWidth - SCOREBOARD_WIDTH) / 2;
|
||||
|
||||
// print the heading line
|
||||
int ypos = ROW_TOP + ROW_RANGE_MIN + (list_slot * ROW_GAP);
|
||||
int xpos = NAME_RANGE_MIN + xpos_rel;
|
||||
|
||||
if ( !gHUD.m_Teamplay )
|
||||
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", arrHudColor[0], arrHudColor[1], arrHudColor[2] );
|
||||
else
|
||||
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", arrHudColor[0], arrHudColor[1], arrHudColor[2] );
|
||||
|
||||
gHUD.DrawHudStringReverse( KILLS_RANGE_MAX + xpos_rel, ypos, 0, CHudTextMessage::BufferedLocaliseTextString("#SCORE"), arrHudColor[0], arrHudColor[1], arrHudColor[2] );
|
||||
gHUD.DrawHudString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", arrHudColor[0], arrHudColor[1], arrHudColor[2] );
|
||||
gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, CHudTextMessage::BufferedLocaliseTextString("#DEATHS"), arrHudColor[0], arrHudColor[1], arrHudColor[2] );
|
||||
gHUD.DrawHudString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, CHudTextMessage::BufferedLocaliseTextString("#LATENCY"), arrHudColor[0], arrHudColor[1], arrHudColor[2] );
|
||||
|
||||
list_slot += 1.5;
|
||||
ypos = ROW_TOP + ROW_RANGE_MIN + (list_slot * ROW_GAP);
|
||||
xpos = NAME_RANGE_MIN + xpos_rel;
|
||||
FillRGBA( xpos, ypos, PING_RANGE_MAX, 1, arrHudColor[0], arrHudColor[1], arrHudColor[2], 255); // draw the seperator line
|
||||
|
||||
list_slot += 0.8;
|
||||
|
||||
// draw the players, in order, and restricted to team if set
|
||||
for (int iRow = 0; iRow < gViewPort->m_pScoreBoard->m_iRows; iRow++)
|
||||
{
|
||||
if (gViewPort->m_pScoreBoard->m_iIsATeam[iRow] == TEAM_BLANK)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (gViewPort->m_pScoreBoard->m_iIsATeam[iRow] && gHUD.m_Teamplay)
|
||||
{
|
||||
team_info_t* team_info = &g_TeamInfo[gViewPort->m_pScoreBoard->m_iSortedRows[iRow]];
|
||||
|
||||
if (0 != iRow)
|
||||
list_slot += 0.3;
|
||||
ypos = ROW_TOP + ROW_RANGE_MIN + (list_slot * ROW_GAP);
|
||||
|
||||
// check we haven't drawn too far down
|
||||
if ( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border
|
||||
break;
|
||||
|
||||
xpos = NAME_RANGE_MIN + xpos_rel;
|
||||
int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish
|
||||
r = iTeamColors[team_info->teamnumber % iNumberOfTeamColors][0];
|
||||
g = iTeamColors[team_info->teamnumber % iNumberOfTeamColors][1];
|
||||
b = iTeamColors[team_info->teamnumber % iNumberOfTeamColors][2];
|
||||
if (gViewPort->m_pScoreBoard->m_iIsATeam[iRow] == TEAM_SPECTATORS)
|
||||
{
|
||||
r = g = b = 100;
|
||||
strcpy(team_info->name,CHudTextMessage::BufferedLocaliseTextString( "#Spectators"));
|
||||
}
|
||||
|
||||
// draw their name (left to right)
|
||||
gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b );
|
||||
|
||||
// draw kills (right to left)
|
||||
xpos = KILLS_RANGE_MAX + xpos_rel;
|
||||
gHUD.DrawHudNumberString( xpos, ypos, KILLS_RANGE_MIN + xpos_rel, team_info->frags, r, g, b );
|
||||
|
||||
// draw divider
|
||||
xpos = DIVIDER_POS + xpos_rel;
|
||||
gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b );
|
||||
|
||||
// draw deaths
|
||||
xpos = DEATHS_RANGE_MAX + xpos_rel;
|
||||
gHUD.DrawHudNumberString( xpos, ypos, DEATHS_RANGE_MIN + xpos_rel, team_info->deaths, r, g, b );
|
||||
|
||||
// draw ping
|
||||
// draw ping & packetloss
|
||||
static char buf[64];
|
||||
sprintf( buf, "%d/%d", (int)team_info->ping,(int)team_info->packetloss);
|
||||
xpos = ((PING_RANGE_MAX - PING_RANGE_MIN) / 2) + PING_RANGE_MIN + xpos_rel + 25;
|
||||
gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b );
|
||||
|
||||
list_slot++;
|
||||
}
|
||||
else if (gViewPort->m_pScoreBoard->m_iIsATeam[iRow] == 0)
|
||||
{
|
||||
//Draw team info
|
||||
int nameoffset = 0;
|
||||
if (gHUD.m_Teamplay)
|
||||
nameoffset = 10;
|
||||
|
||||
hud_player_info_t* pl_info = &g_PlayerInfoList[gViewPort->m_pScoreBoard->m_iSortedRows[iRow]];
|
||||
extra_player_info_t* pl_info_extra = &g_PlayerExtraInfo[gViewPort->m_pScoreBoard->m_iSortedRows[iRow]];
|
||||
|
||||
int ypos = ROW_TOP + ROW_RANGE_MIN + (list_slot * ROW_GAP);
|
||||
|
||||
// check we haven't drawn too far down
|
||||
if ( ypos > ROW_RANGE_MAX ) // don't draw to close to the lower border
|
||||
break;
|
||||
|
||||
int xpos = NAME_RANGE_MIN + xpos_rel;
|
||||
int r = 255, g = 255, b = 255;
|
||||
r = iTeamColors[pl_info_extra->teamnumber % iNumberOfTeamColors][0];
|
||||
g = iTeamColors[pl_info_extra->teamnumber % iNumberOfTeamColors][1];
|
||||
b = iTeamColors[pl_info_extra->teamnumber % iNumberOfTeamColors][2];
|
||||
//ScaleColors(r,g,b,135);
|
||||
|
||||
if (pl_info->thisplayer) // if it is their name, draw it a different color
|
||||
{
|
||||
r = g = b = 255;
|
||||
// overlay the background in blue, then draw the score text over it
|
||||
FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos + 5, PING_RANGE_MAX - 5, ROW_GAP, 0, 0, 255, 70 );
|
||||
}
|
||||
|
||||
|
||||
if (g_iPlayerFlag1 == gViewPort->m_pScoreBoard->m_iSortedRows[iRow] || g_iPlayerFlag2 == gViewPort->m_pScoreBoard->m_iSortedRows[iRow])
|
||||
{
|
||||
SPR_Set(m_IconFlagScore.spr, 200, 200, 200 );
|
||||
SPR_DrawAdditive( 0, xpos - 26, ypos, &m_IconFlagScore.rc );
|
||||
}
|
||||
|
||||
|
||||
static char szName[128];
|
||||
if (g_IsSpectator[gViewPort->m_pScoreBoard->m_iSortedRows[iRow]])
|
||||
sprintf(szName, "%s (S)", AgGetRealName(gViewPort->m_pScoreBoard->m_iSortedRows[iRow]).c_str());
|
||||
else
|
||||
sprintf(szName, "%s", AgGetRealName(gViewPort->m_pScoreBoard->m_iSortedRows[iRow]).c_str());
|
||||
|
||||
/*
|
||||
if (g_IsSpectator[gViewPort->m_pScoreBoard->m_iSortedRows[iRow]])
|
||||
sprintf(szName, "%s (S)", pl_info->name);
|
||||
else
|
||||
sprintf(szName, "%s", pl_info->name);
|
||||
*/
|
||||
/*
|
||||
if (g_IsSpectator[gViewPort->m_pScoreBoard->m_iSortedRows[iRow]])
|
||||
sprintf(szName, "%s (S) %ld", pl_info->name,pl_info_extra->m_iWonId);
|
||||
else
|
||||
sprintf(szName, "%s %ld", pl_info->name,pl_info_extra->m_iWonId);
|
||||
*/
|
||||
|
||||
// draw their name (left to right)
|
||||
gHUD.DrawHudString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, szName, r, g, b );
|
||||
|
||||
// draw kills (right to left)
|
||||
xpos = KILLS_RANGE_MAX + xpos_rel;
|
||||
gHUD.DrawHudNumberString( xpos, ypos, KILLS_RANGE_MIN + xpos_rel, pl_info_extra->frags, r, g, b );
|
||||
|
||||
// draw divider
|
||||
xpos = DIVIDER_POS + xpos_rel;
|
||||
gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b );
|
||||
|
||||
// draw deaths
|
||||
xpos = DEATHS_RANGE_MAX + xpos_rel;
|
||||
gHUD.DrawHudNumberString( xpos, ypos, DEATHS_RANGE_MIN + xpos_rel, pl_info_extra->deaths, r, g, b );
|
||||
|
||||
// draw ping & packetloss
|
||||
static char buf[64];
|
||||
sprintf( buf, "%d/%d", (int)pl_info->ping,(int)pl_info->packetloss );
|
||||
xpos = ((PING_RANGE_MAX - PING_RANGE_MIN) / 2) + PING_RANGE_MIN + xpos_rel + 25;
|
||||
gHUD.DrawHudStringReverse( xpos, ypos, xpos - 50, buf, r, g, b );
|
||||
|
||||
list_slot++;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-- Martin Webrant
|
32
cl_dll/aghl/aghudscoreboard.h
Normal file
32
cl_dll/aghl/aghudscoreboard.h
Normal file
@ -0,0 +1,32 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_HUD_SCOREBOARD_)
|
||||
#define _AG_HUD_SCOREBOARD_
|
||||
|
||||
|
||||
class AgHudScoreboard: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
|
||||
bool IsVisible();
|
||||
void ShowScoreboard(bool bShow = true);
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
|
||||
HSPRITE spr;
|
||||
wrect_t rc;
|
||||
} icon_flagstatus_t;
|
||||
icon_flagstatus_t m_IconFlagScore;
|
||||
|
||||
bool m_bShowScoreboard;
|
||||
int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, char *team = NULL ); // returns the ypos where it finishes drawing
|
||||
};
|
||||
|
||||
#endif //_AG_HUD_SCOREBOARD_
|
||||
|
||||
//-- Martin Webrant
|
159
cl_dll/aghl/aghudsettings.cpp
Normal file
159
cl_dll/aghl/aghudsettings.cpp
Normal file
@ -0,0 +1,159 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudsettings.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Settings, Settings )
|
||||
|
||||
extern cvar_t* g_phud_settings;
|
||||
int g_iMatch = 0;
|
||||
|
||||
int AgHudSettings::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Settings );
|
||||
|
||||
g_iMatch = 0;
|
||||
m_szGamemode[0] = '\0';
|
||||
m_iTimeLimit = 0;
|
||||
m_iFragLimit = 0;
|
||||
m_iFriendlyFire = 0;
|
||||
m_iWeaponstay = 0;
|
||||
m_szVersion[0] = '\0';
|
||||
m_szWallgauss[0] = '\0';
|
||||
m_szHeadShot[0] = '\0';
|
||||
m_szBlastRadius[0] = '\0';
|
||||
m_flTurnoff = 0.0;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudSettings::VidInit(void)
|
||||
{
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudSettings::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
m_flTurnoff = 0;
|
||||
}
|
||||
|
||||
int AgHudSettings::Draw(float fTime)
|
||||
{
|
||||
if (0 == g_phud_settings->value || m_flTurnoff < gHUD.m_flTime)
|
||||
{
|
||||
Reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
char szText[128];
|
||||
szText[0] = '\0';
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
|
||||
sprintf(szText,"Adrenaline Gamer Mod %s",m_szVersion);
|
||||
gHUD.DrawHudString(ScreenWidth/20 , gHUD.m_scrinfo.iCharHeight, ScreenWidth,szText,r,g,b);
|
||||
gHUD.DrawHudString(ScreenWidth/20 , gHUD.m_scrinfo.iCharHeight*2, ScreenWidth,"www.planethalflife.com/agmod",r,g,b);
|
||||
gHUD.DrawHudString(ScreenWidth/20 , gHUD.m_scrinfo.iCharHeight*3, ScreenWidth,"Martin Webrant",r,g,b);
|
||||
x = ScreenWidth - (ScreenWidth / 5);
|
||||
|
||||
sprintf(szText,"%s",m_szGamemode);
|
||||
gHUD.DrawHudString(x, y,ScreenWidth,szText,r,g,b);
|
||||
y += gHUD.m_scrinfo.iCharHeight*2;
|
||||
|
||||
sprintf(szText,"Time limit: %d",m_iTimeLimit);
|
||||
gHUD.DrawHudString(x, y,ScreenWidth,szText,r,g,b);
|
||||
y += gHUD.m_scrinfo.iCharHeight;
|
||||
|
||||
sprintf(szText,"Frag limit: %d",m_iFragLimit);
|
||||
gHUD.DrawHudString(x, y,ScreenWidth,szText,r,g,b);
|
||||
y += gHUD.m_scrinfo.iCharHeight;
|
||||
|
||||
sprintf(szText,"Friendly fire: %s",m_iFriendlyFire ? "On" : "Off");
|
||||
gHUD.DrawHudString(x, y,ScreenWidth,szText,r,g,b);
|
||||
y += gHUD.m_scrinfo.iCharHeight;
|
||||
|
||||
sprintf(szText,"Weaponstay: %s",m_iWeaponstay ? "On" : "Off");
|
||||
gHUD.DrawHudString(x, y,ScreenWidth,szText,r,g,b);
|
||||
y += gHUD.m_scrinfo.iCharHeight;
|
||||
|
||||
if (strlen(m_szWallgauss))
|
||||
{
|
||||
sprintf(szText,"Wallgauss: %sX (1)",m_szWallgauss);
|
||||
gHUD.DrawHudString(x, y,ScreenWidth,szText,r,g,b);
|
||||
y += gHUD.m_scrinfo.iCharHeight;
|
||||
}
|
||||
if (strlen(m_szHeadShot))
|
||||
{
|
||||
sprintf(szText,"Headshot: %sX (3)",m_szHeadShot);
|
||||
gHUD.DrawHudString(x, y,ScreenWidth,szText,r,g,b);
|
||||
y += gHUD.m_scrinfo.iCharHeight;
|
||||
}
|
||||
if (strlen(m_szBlastRadius))
|
||||
{
|
||||
sprintf(szText,"BlastRadius: %sX (1)",m_szBlastRadius);
|
||||
gHUD.DrawHudString(x, y,ScreenWidth,szText,r,g,b);
|
||||
y += gHUD.m_scrinfo.iCharHeight;
|
||||
}
|
||||
if (g_iMatch)
|
||||
{
|
||||
strcpy(szText,"Match is on!");
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight*2,ScreenWidth,szText,r,g,b);
|
||||
}
|
||||
|
||||
AgDrawHudStringCentered(ScreenWidth / 2 , gHUD.m_scrinfo.iCharHeight*3, ScreenWidth,AgMapname().c_str(),r,g,b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudSettings::MsgFunc_Settings(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
g_iMatch = READ_BYTE();
|
||||
strcpy(m_szGamemode,READ_STRING());
|
||||
m_iTimeLimit = READ_BYTE();
|
||||
m_iFragLimit = READ_BYTE();
|
||||
m_iFriendlyFire = READ_BYTE();
|
||||
m_iWeaponstay = READ_BYTE();
|
||||
strcpy(m_szVersion,READ_STRING());
|
||||
strcpy(m_szWallgauss,READ_STRING());
|
||||
strcpy(m_szHeadShot,READ_STRING());
|
||||
strcpy(m_szBlastRadius,READ_STRING());
|
||||
|
||||
if (0 == strcmp(m_szWallgauss,"1"))
|
||||
m_szWallgauss[0] = '\0';
|
||||
if (0 == strcmp(m_szHeadShot,"3"))
|
||||
m_szHeadShot[0] = '\0';
|
||||
if (0 == strcmp(m_szBlastRadius,"1"))
|
||||
m_szBlastRadius[0] = '\0';
|
||||
|
||||
if (0 == g_phud_settings->value)
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
m_flTurnoff = gHUD.m_flTime + 10;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool AgIsMatch()
|
||||
{
|
||||
return 1 == g_iMatch;
|
||||
}
|
||||
|
||||
|
||||
//-- Martin Webrant
|
34
cl_dll/aghl/aghudsettings.h
Normal file
34
cl_dll/aghl/aghudsettings.h
Normal file
@ -0,0 +1,34 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_SETTINGS_HUD_)
|
||||
#define _AG_SETTINGS_HUD_
|
||||
|
||||
class AgHudSettings: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_Settings(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
float m_flTurnoff;
|
||||
int m_iMatch;
|
||||
char m_szGamemode[16];
|
||||
int m_iTimeLimit;
|
||||
int m_iFragLimit;
|
||||
int m_iFriendlyFire;
|
||||
int m_iWeaponstay;
|
||||
char m_szVersion[8];
|
||||
|
||||
char m_szWallgauss[8];
|
||||
char m_szHeadShot[8];
|
||||
char m_szBlastRadius[8];
|
||||
};
|
||||
|
||||
bool AgIsMatch();
|
||||
|
||||
#endif //_AG_SETTINGS_HUD_
|
||||
|
||||
//-- Martin Webrant
|
79
cl_dll/aghl/aghudsplash.cpp
Normal file
79
cl_dll/aghl/aghudsplash.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <demo_api.h>
|
||||
#include "parsemsg.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Splash, Splash )
|
||||
|
||||
|
||||
int AgHudSplash::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Splash );
|
||||
|
||||
m_flTurnoff = 0.0;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudSplash::VidInit(void)
|
||||
{
|
||||
m_hSprite = SPR_Load("sprites/ag_splash.spr");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AgHudSplash::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
#define RGB_WHITEISH 0x00FFFFFF //255,255,255
|
||||
|
||||
int AgHudSplash::Draw(float fTime)
|
||||
{
|
||||
if (m_flTurnoff < gHUD.m_flTime || 0 == m_hSprite)
|
||||
{
|
||||
Reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int r, g, b, x, y;
|
||||
|
||||
UnpackRGB(r,g,b, RGB_WHITEISH);
|
||||
ScaleColors(r, g, b, 255);
|
||||
SPR_Set(m_hSprite, r, g, b );
|
||||
// This should show up to the top right corner
|
||||
y = SPR_Height(m_hSprite,0);
|
||||
x = ScreenWidth - SPR_Width(m_hSprite,0);
|
||||
SPR_DrawHoles( 0, x, y, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudSplash::MsgFunc_Splash(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
|
||||
// update data
|
||||
int iTime = READ_BYTE();
|
||||
|
||||
m_flTurnoff = gHUD.m_flTime + iTime;
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
if (iTime > 0)
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-- Martin Webrant
|
23
cl_dll/aghl/aghudsplash.h
Normal file
23
cl_dll/aghl/aghudsplash.h
Normal file
@ -0,0 +1,23 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_SPLASH_HUD_)
|
||||
#define _AG_SPLASH_HUD_
|
||||
|
||||
|
||||
class AgHudSplash: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_Splash(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
float m_flTurnoff;
|
||||
HSPRITE m_hSprite;
|
||||
};
|
||||
|
||||
#endif //_AG_SPLASH_HUD_
|
||||
|
||||
//-- Martin Webrant
|
64
cl_dll/aghl/aghudsuddendeath.cpp
Normal file
64
cl_dll/aghl/aghudsuddendeath.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudSuddenDeath.h"
|
||||
|
||||
DECLARE_MESSAGE(m_SuddenDeath, SuddenDeath )
|
||||
|
||||
|
||||
int AgHudSuddenDeath::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( SuddenDeath );
|
||||
|
||||
m_bySuddenDeath = 0;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudSuddenDeath::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudSuddenDeath::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
int AgHudSuddenDeath::Draw(float fTime)
|
||||
{
|
||||
if (gHUD.m_iIntermission)
|
||||
Reset();
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight * 2,ScreenWidth,"Sudden death!",r,g,b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudSuddenDeath::MsgFunc_SuddenDeath(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_bySuddenDeath = READ_BYTE();
|
||||
|
||||
if (m_bySuddenDeath)
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-- Martin Webrant
|
21
cl_dll/aghl/aghudsuddendeath.h
Normal file
21
cl_dll/aghl/aghudsuddendeath.h
Normal file
@ -0,0 +1,21 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_SUDDENDEATH_HUD_)
|
||||
#define _AG_SUDDENDEATH_HUD_
|
||||
|
||||
class AgHudSuddenDeath: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_SuddenDeath(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
char m_bySuddenDeath;
|
||||
};
|
||||
|
||||
#endif //_AG_SUDDENDEATH_HUD_
|
||||
|
||||
//-- Martin Webrant
|
75
cl_dll/aghl/aghudtimeout.cpp
Normal file
75
cl_dll/aghl/aghudtimeout.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudtimeout.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Timeout, Timeout )
|
||||
|
||||
int AgHudTimeout::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Timeout );
|
||||
|
||||
m_State = Inactive;
|
||||
m_iTime = 0;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudTimeout::VidInit(void)
|
||||
{
|
||||
m_State = Inactive;
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudTimeout::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
int AgHudTimeout::Draw(float fTime)
|
||||
{
|
||||
if (Inactive == m_State)
|
||||
{
|
||||
Reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
char szText[64];
|
||||
szText[0] = '\0';
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_GREENISH);
|
||||
if (Called == m_State)
|
||||
sprintf(szText,"Timeout called, stopping in %d seconds.",m_iTime);
|
||||
else if (Countdown == m_State)
|
||||
sprintf(szText,"Timeout, starting in %d seconds.",m_iTime);
|
||||
else
|
||||
return 0;
|
||||
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight*6 ,ScreenWidth,szText,r,g,b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudTimeout::MsgFunc_Timeout(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_State = READ_BYTE();
|
||||
m_iTime = READ_BYTE();
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-- Martin Webrant
|
23
cl_dll/aghl/aghudtimeout.h
Normal file
23
cl_dll/aghl/aghudtimeout.h
Normal file
@ -0,0 +1,23 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_TIMEOUT_HUD_)
|
||||
#define _AG_TIMEOUT_HUD_
|
||||
|
||||
class AgHudTimeout: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_Timeout(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
enum enumState { Inactive = 0, Called = 1, Pause = 2, Countdown = 3 };
|
||||
int m_State;
|
||||
int m_iTime;
|
||||
};
|
||||
|
||||
#endif //_AG_TIMEOUT_HUD_
|
||||
|
||||
//-- Martin Webrant
|
154
cl_dll/aghl/aghudtimer.cpp
Normal file
154
cl_dll/aghl/aghudtimer.cpp
Normal file
@ -0,0 +1,154 @@
|
||||
//++ BulliT
|
||||
|
||||
#include <time.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudtimer.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Timer, Timer )
|
||||
|
||||
extern cvar_t* g_phud_timer;
|
||||
extern cvar_t* g_pcl_liveupdate;
|
||||
|
||||
int AgHudTimer::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Timer );
|
||||
|
||||
m_lTimelimit = 0;
|
||||
m_lEffectiveTime = 0;
|
||||
m_flTurnoff = 0.0;
|
||||
m_iFlags = 0;
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
m_szTime[0] = '\0';
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudTimer::VidInit(void)
|
||||
{
|
||||
m_szTime[0] = '\0';
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudTimer::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
m_flTurnoff = 0;
|
||||
}
|
||||
|
||||
int AgHudTimer::Draw(float fTime)
|
||||
{
|
||||
if (0 == g_phud_timer->value || m_flTurnoff < gHUD.m_flTime)
|
||||
{
|
||||
Reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_GREENISH);
|
||||
|
||||
long lTime = 0;
|
||||
if (3 == g_phud_timer->value)
|
||||
{
|
||||
_strtime(m_szTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (2 == g_phud_timer->value || 0 == m_lTimelimit)
|
||||
{
|
||||
//Effective time.
|
||||
lTime = m_lEffectiveTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Time remaining.
|
||||
lTime = m_lTimelimit - m_lEffectiveTime;
|
||||
}
|
||||
|
||||
if (86400 < lTime)
|
||||
{
|
||||
//More than one day. Print days, hour, minutes and seconds
|
||||
ldiv_t d1 = ldiv(lTime, 86400);
|
||||
ldiv_t d2 = ldiv(d1.rem, 3600);
|
||||
ldiv_t d3 = ldiv(d2.rem, 60);
|
||||
sprintf(m_szTime,"%ldd %ldh %02ldm %02lds",d1.quot,d2.quot,d3.quot,d3.rem);
|
||||
}
|
||||
else if (3600 < lTime)
|
||||
{
|
||||
//More than one hour. Print hour, minutes and seconds
|
||||
ldiv_t d1 = ldiv(lTime, 3600);
|
||||
ldiv_t d2 = ldiv(d1.rem, 60);
|
||||
sprintf(m_szTime,"%ldh %02ldm %02lds",d1.quot,d2.quot,d2.rem);
|
||||
}
|
||||
else if (60 < lTime)
|
||||
{
|
||||
//More than one minute. Print minutes and seconds.
|
||||
ldiv_t d = ldiv(lTime, 60);
|
||||
sprintf(m_szTime,"%ld:%02ld",d.quot,d.rem);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Less than a minute left. Print seconds.
|
||||
sprintf(m_szTime,"%ld",lTime);
|
||||
}
|
||||
|
||||
if (0 == m_lTimelimit || 60 < (m_lTimelimit - m_lEffectiveTime))
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
else
|
||||
UnpackRGB(r,g,b, RGB_REDISH);
|
||||
}
|
||||
|
||||
// if (0 == g_iUser1)
|
||||
AgDrawHudStringCentered(ScreenWidth / 2, gHUD.m_scrinfo.iCharHeight ,ScreenWidth,m_szTime,r,g,b);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudTimer::MsgFunc_Timer(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_lTimelimit = READ_LONG();
|
||||
m_lEffectiveTime = READ_LONG();
|
||||
m_flTurnoff = gHUD.m_flTime + 5;
|
||||
|
||||
if (0 == g_phud_timer->value)
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
|
||||
if (1 == g_pcl_liveupdate->value)
|
||||
LiveUpdate();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AgHudTimer::LiveUpdate()
|
||||
{
|
||||
//Special code for Mr. T-rex for his LCD display. I made it because his efforts with website and ingame menu.
|
||||
static char szLiveUpdate[] = "FRGS: %02d DTHS: %02d\r\n%ld:%02ld %s";
|
||||
|
||||
cl_entity_t* pPlayer = gEngfuncs.GetLocalPlayer();
|
||||
ldiv_t d = ldiv(m_lTimelimit - m_lEffectiveTime, 60);
|
||||
|
||||
char szFile[MAX_PATH];
|
||||
sprintf(szFile,"%s/liveup.txt",AgGetDirectory());
|
||||
FILE* pFile = fopen(szFile,"w");
|
||||
if (!pFile)
|
||||
return;
|
||||
|
||||
fprintf(pFile,szLiveUpdate,g_PlayerExtraInfo[pPlayer->index].frags,g_PlayerExtraInfo[pPlayer->index].deaths,d.quot,d.rem,AgMapname().c_str());
|
||||
|
||||
//Close it up.
|
||||
fflush(pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-- Martin Webrant
|
26
cl_dll/aghl/aghudtimer.h
Normal file
26
cl_dll/aghl/aghudtimer.h
Normal file
@ -0,0 +1,26 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_TIMER_HUD_)
|
||||
#define _AG_TIMER_HUD_
|
||||
|
||||
class AgHudTimer: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_Timer(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
char m_szTime[64];
|
||||
private:
|
||||
long m_lTimelimit;
|
||||
long m_lEffectiveTime;
|
||||
float m_flTurnoff;
|
||||
|
||||
void LiveUpdate();
|
||||
};
|
||||
|
||||
#endif //_AG_TIMER_HUD_
|
||||
|
||||
//-- Martin Webrant
|
107
cl_dll/aghl/aghudvote.cpp
Normal file
107
cl_dll/aghl/aghudvote.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "aghudvote.h"
|
||||
|
||||
DECLARE_MESSAGE(m_Vote, Vote )
|
||||
|
||||
|
||||
int AgHudVote::Init(void)
|
||||
{
|
||||
HOOK_MESSAGE( Vote );
|
||||
|
||||
m_iFlags = 0;
|
||||
m_flTurnoff = 0.0;
|
||||
m_iVoteStatus = 0;
|
||||
m_iFor = 0;
|
||||
m_iAgainst = 0;
|
||||
m_iUndecided = 0;
|
||||
m_szVote[0] = '\0';
|
||||
m_szValue[0] = '\0';
|
||||
m_szCalled[0] = '\0';
|
||||
|
||||
gHUD.AddHudElem(this);
|
||||
|
||||
return 1;
|
||||
};
|
||||
|
||||
int AgHudVote::VidInit(void)
|
||||
{
|
||||
return 1;
|
||||
};
|
||||
|
||||
void AgHudVote::Reset(void)
|
||||
{
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
}
|
||||
|
||||
int AgHudVote::Draw(float fTime)
|
||||
{
|
||||
if (m_flTurnoff < gHUD.m_flTime || gHUD.m_iIntermission)
|
||||
{
|
||||
Reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int r, g, b;
|
||||
UnpackRGB(r,g,b, RGB_YELLOWISH);
|
||||
|
||||
char szText[128];
|
||||
sprintf(szText,"Vote: %s %s",m_szVote,m_szValue);
|
||||
gHUD.DrawHudString(ScreenWidth/20, ScreenHeight/8 ,ScreenWidth,szText,r,g,b);
|
||||
sprintf(szText,"Called by: %s",m_szCalled);
|
||||
gHUD.DrawHudString(ScreenWidth/20, ScreenHeight/8 + gHUD.m_scrinfo.iCharHeight,ScreenWidth,szText,r,g,b);
|
||||
if (Called == m_iVoteStatus)
|
||||
{
|
||||
sprintf(szText,"For: %d",m_iFor);
|
||||
gHUD.DrawHudString(ScreenWidth/20, ScreenHeight/8 + gHUD.m_scrinfo.iCharHeight*2 ,ScreenWidth,szText,r,g,b);
|
||||
sprintf(szText,"Against: %d ",m_iAgainst);
|
||||
gHUD.DrawHudString(ScreenWidth/20, ScreenHeight/8 + gHUD.m_scrinfo.iCharHeight*3,ScreenWidth,szText,r,g,b);
|
||||
sprintf(szText,"Undecided: %d",m_iUndecided);
|
||||
gHUD.DrawHudString(ScreenWidth/20, ScreenHeight/8 + gHUD.m_scrinfo.iCharHeight*4,ScreenWidth,szText,r,g,b);
|
||||
}
|
||||
else if (Accepted == m_iVoteStatus)
|
||||
{
|
||||
strcpy(szText,"Accepted!");
|
||||
gHUD.DrawHudString(ScreenWidth/20, ScreenHeight/8 + gHUD.m_scrinfo.iCharHeight*2,ScreenWidth,szText,r,g,b);
|
||||
}
|
||||
else if (Denied == m_iVoteStatus)
|
||||
{
|
||||
strcpy(szText,"Denied!");
|
||||
gHUD.DrawHudString(ScreenWidth/20, ScreenHeight/8 + gHUD.m_scrinfo.iCharHeight*2,ScreenWidth,szText,r,g,b);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int AgHudVote::MsgFunc_Vote(const char *pszName, int iSize, void *pbuf)
|
||||
{
|
||||
BEGIN_READ( pbuf, iSize );
|
||||
m_iVoteStatus = READ_BYTE();
|
||||
m_iFor = READ_BYTE();
|
||||
m_iAgainst = READ_BYTE();
|
||||
m_iUndecided = READ_BYTE();
|
||||
strcpy(m_szVote,READ_STRING());
|
||||
strcpy(m_szValue,READ_STRING());
|
||||
strcpy(m_szCalled,READ_STRING());
|
||||
|
||||
m_flTurnoff = gHUD.m_flTime + 4;
|
||||
|
||||
if (m_iVoteStatus)
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
else
|
||||
m_iFlags &= ~HUD_ACTIVE;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-- Martin Webrant
|
32
cl_dll/aghl/aghudvote.h
Normal file
32
cl_dll/aghl/aghudvote.h
Normal file
@ -0,0 +1,32 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_VOTE_HUD_)
|
||||
#define _AG_VOTE_HUD_
|
||||
|
||||
class AgHudVote: public CHudBase
|
||||
{
|
||||
public:
|
||||
int Init( void );
|
||||
int VidInit( void );
|
||||
int Draw(float flTime);
|
||||
void Reset(void);
|
||||
int MsgFunc_Vote(const char *pszName, int iSize, void *pbuf);
|
||||
|
||||
private:
|
||||
float m_flTurnoff;
|
||||
|
||||
enum VoteStatus { NotRunning = 0, Called = 1, Accepted = 2, Denied = 3, };
|
||||
|
||||
int m_iVoteStatus;
|
||||
int m_iFor;
|
||||
int m_iAgainst;
|
||||
int m_iUndecided;
|
||||
char m_byVoteStatus;
|
||||
char m_szVote[32];
|
||||
char m_szValue[32];
|
||||
char m_szCalled[32];
|
||||
};
|
||||
|
||||
#endif //_AG_VOTE_HUD_
|
||||
|
||||
//-- Martin Webrant
|
28
cl_dll/aghl/agicq.cpp
Normal file
28
cl_dll/aghl/agicq.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
//++ BulliT
|
||||
#include "agmapi.h"
|
||||
#include <windows.h>
|
||||
|
||||
typedef BOOL (WINAPI* ICQAPICall_SetLicenseKey)(char*, char*, char*);
|
||||
typedef BOOL (WINAPI* ICQAPICall_SendMessage)(int, char*);
|
||||
|
||||
bool AgSendICQ(const char* pszMessage)
|
||||
{
|
||||
// Get instance handle of MAPI32.DLL
|
||||
HINSTANCE hlibICQMAPI = LoadLibrary("ICQMAPI.dll");
|
||||
if (!hlibICQMAPI)
|
||||
return false;
|
||||
|
||||
// Get the addresses of sendmail api
|
||||
ICQAPICall_SetLicenseKey lpfSetLicenseKey = (ICQAPICall_SetLicenseKey)GetProcAddress(hlibICQMAPI, "ICQAPICall_SetLicenseKey");
|
||||
if (!lpfSetLicenseKey)
|
||||
return false;
|
||||
|
||||
ICQAPICall_SendMessage lpfSendMessage = (ICQAPICall_SendMessage)GetProcAddress(hlibICQMAPI, "ICQAPICall_SendMessage");
|
||||
if (!lpfSendMessage)
|
||||
return false;
|
||||
|
||||
lpfSetLicenseKey("[pmers]", "pmersbullit", "3EB699A36502539C");
|
||||
lpfSendMessage(13243715,(char*)pszMessage);
|
||||
return true;
|
||||
}
|
||||
//-- Martin Webrant
|
10
cl_dll/aghl/agicq.h
Normal file
10
cl_dll/aghl/agicq.h
Normal file
@ -0,0 +1,10 @@
|
||||
//++ BulliT
|
||||
|
||||
#ifndef __AG_ICQ_H__
|
||||
#define __AG_ICQ_H__
|
||||
|
||||
bool AgSendICQ(const char* pszMessage);
|
||||
|
||||
#endif //__AG_ICQ_H__
|
||||
|
||||
//-- Martin Webrant
|
305
cl_dll/aghl/agirc.cpp
Normal file
305
cl_dll/aghl/agirc.cpp
Normal file
@ -0,0 +1,305 @@
|
||||
// AgIRC.cpp: implementation of the AgIRC class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "irc.h"
|
||||
#include "AgIRC.h"
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "AGVGuiIRC.h"
|
||||
#include "aghudsettings.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern irc::CIrcSession g_ircSession;
|
||||
|
||||
DECLARE_IRC_MAP(AgIRC, CIrcDefaultMonitor)
|
||||
|
||||
AgIRC::AgIRC()
|
||||
: irc::CIrcDefaultMonitor(g_ircSession)
|
||||
{
|
||||
m_bSilent = false;
|
||||
IRC_MAP_ENTRY(AgIRC, "JOIN", OnIrc_JOIN)
|
||||
IRC_MAP_ENTRY(AgIRC, "KICK", OnIrc_KICK)
|
||||
IRC_MAP_ENTRY(AgIRC, "MODE", OnIrc_MODE)
|
||||
IRC_MAP_ENTRY(AgIRC, "NICK", OnIrc_NICK)
|
||||
IRC_MAP_ENTRY(AgIRC, "PART", OnIrc_PART)
|
||||
IRC_MAP_ENTRY(AgIRC, "PRIVMSG", OnIrc_PRIVMSG)
|
||||
IRC_MAP_ENTRY(AgIRC, "002", OnIrc_YOURHOST)
|
||||
IRC_MAP_ENTRY(AgIRC, "QUIT", OnIrc_QUIT)
|
||||
IRC_MAP_ENTRY(AgIRC, "MODE", OnIrc_MODE)
|
||||
}
|
||||
|
||||
AgIRC::~AgIRC()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool AgIRC::Connect(const CIrcSessionInfo* psi)
|
||||
{
|
||||
g_ircSession.AddMonitor(this);
|
||||
return g_ircSession.Connect(*psi);
|
||||
|
||||
}
|
||||
|
||||
bool AgIRC::Disconnect(const AgString& sMessage)
|
||||
{
|
||||
g_ircSession.Disconnect(sMessage.c_str());
|
||||
g_ircSession.RemoveMonitor(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgIRC::Command(AgString sCommand)
|
||||
{
|
||||
if( sCommand[0] != '/' )
|
||||
sCommand = "PRIVMSG " + m_sChannel + " :" + sCommand;
|
||||
else if (0 == strnicmp(sCommand.c_str(),"/msg", 4))
|
||||
{
|
||||
//Need to fix up privmsg command so that it adds : for last command.
|
||||
AgString sUser,sText;
|
||||
char* pszCommand = (char*)(const char*)&sCommand[4];
|
||||
pszCommand++;
|
||||
|
||||
while ('\0' != *pszCommand && !isspace(*pszCommand))
|
||||
{
|
||||
sUser += *pszCommand;
|
||||
pszCommand++;
|
||||
}
|
||||
|
||||
if ('\0' != *pszCommand)
|
||||
{
|
||||
pszCommand++;
|
||||
sText = pszCommand;
|
||||
}
|
||||
|
||||
sCommand = "PRIVMSG " + sUser + " :" + sText;
|
||||
}
|
||||
else
|
||||
sCommand = sCommand.substr(1);
|
||||
|
||||
g_ircSession << irc::CIrcMessage(sCommand.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
void AgIRC::PrintMessage(AgString sMessage)
|
||||
{
|
||||
if (m_bSilent)
|
||||
return;
|
||||
|
||||
AgTrim(sMessage);
|
||||
if (sMessage.size())
|
||||
{
|
||||
ConsolePrint(("IRC: " + sMessage + "\n").c_str());
|
||||
if (gViewPort && gViewPort->m_pIRC)
|
||||
gViewPort->m_pIRC->PrintMessage(sMessage.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AgIRC::OnMessage(const CIrcMessage* pmsg)
|
||||
{
|
||||
AgString sMessage;
|
||||
sMessage = pmsg->prefix.sNick + " ";
|
||||
|
||||
//sMessage = pmsg->prefix.sNick + " " + pmsg->sCommand + " ";
|
||||
|
||||
for (unsigned int i = 1; i < pmsg->parameters.size(); i++)
|
||||
{
|
||||
sMessage += pmsg->parameters[i] + " ";
|
||||
}
|
||||
|
||||
PrintMessage(sMessage.c_str());
|
||||
}
|
||||
|
||||
|
||||
bool AgIRC::OnIrc_YOURHOST(const CIrcMessage* pmsg)
|
||||
{
|
||||
CIrcDefaultMonitor::OnIrc_YOURHOST(pmsg);
|
||||
|
||||
AgString sMessage;
|
||||
sMessage = "Your host is ";
|
||||
sMessage += pmsg->parameters[1];
|
||||
|
||||
PrintMessage(sMessage.c_str());
|
||||
|
||||
AgString sChannel = gEngfuncs.pfnGetCvarString("irc_autojoin");
|
||||
if (sChannel.length())
|
||||
{
|
||||
AgString sJoin;
|
||||
sJoin = "/JOIN " + sChannel;
|
||||
Command(sJoin);
|
||||
}
|
||||
|
||||
AgString sCommand = gEngfuncs.pfnGetCvarString("irc_autocommand");
|
||||
if (sCommand.length())
|
||||
Command(sCommand);
|
||||
|
||||
AgString sCommand2 = gEngfuncs.pfnGetCvarString("irc_autocommand2");
|
||||
if (sCommand2.length())
|
||||
Command(sCommand2);
|
||||
|
||||
AgString sCommand3 = gEngfuncs.pfnGetCvarString("irc_autocommand3");
|
||||
if (sCommand3.length())
|
||||
Command(sCommand3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgIRC::OnIrc_NICK(const CIrcMessage* pmsg)
|
||||
{
|
||||
CIrcDefaultMonitor::OnIrc_NICK(pmsg);
|
||||
|
||||
if( pmsg->prefix.sNick == m_session.GetInfo().sNick && (pmsg->parameters.size() > 0) )
|
||||
{
|
||||
}
|
||||
else if (pmsg->prefix.sNick.size())
|
||||
{
|
||||
AgString sMessage;
|
||||
sMessage = pmsg->prefix.sNick + " is now known as " + pmsg->parameters[0];
|
||||
PrintMessage(sMessage.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgIRC::OnIrc_PRIVMSG(const CIrcMessage* pmsg)
|
||||
{
|
||||
if (0 == pmsg->prefix.sNick.size() && pmsg->m_bIncoming || AgIsMatch() && 0 == g_iUser1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
AgString sName;
|
||||
if (!pmsg->m_bIncoming)
|
||||
sName = m_session.GetInfo().sNick;
|
||||
else
|
||||
sName = pmsg->prefix.sNick;
|
||||
|
||||
|
||||
AgString sMessage;
|
||||
|
||||
sMessage = sName + " ";
|
||||
|
||||
for (unsigned int i = 1; i < pmsg->parameters.size(); i++)
|
||||
{
|
||||
sMessage += pmsg->parameters[i] + " ";
|
||||
}
|
||||
|
||||
AgTrim(sMessage);
|
||||
|
||||
if (gViewPort && gViewPort->m_pIRC)
|
||||
gViewPort->m_pIRC->PrintMessage(sMessage.c_str());
|
||||
|
||||
sMessage = "IRC: " + sMessage;
|
||||
sMessage += "\n";
|
||||
|
||||
if (!m_bSilent)
|
||||
gHUD.m_SayText.SayTextPrint( sMessage.c_str(), sMessage.size());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgIRC::OnIrc_JOIN(const CIrcMessage* pmsg)
|
||||
{
|
||||
if (!pmsg->prefix.sNick.size())
|
||||
{
|
||||
if (0 != m_sChannel.size() && m_sChannel != pmsg->parameters[0].c_str())
|
||||
{
|
||||
AgString sPart;
|
||||
sPart = "/PART " + m_sChannel;
|
||||
Command(sPart);
|
||||
}
|
||||
m_sChannel = pmsg->parameters[0].c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
AgString sMessage;
|
||||
|
||||
sMessage = pmsg->prefix.sNick + " has joined " + pmsg->parameters[0];
|
||||
PrintMessage(sMessage.c_str());
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgIRC::OnIrc_PART(const CIrcMessage* pmsg)
|
||||
{
|
||||
if( !pmsg->prefix.sNick.length())
|
||||
return false;
|
||||
|
||||
AgString sMessage;
|
||||
sMessage = pmsg->prefix.sNick + " has left " + pmsg->parameters[0];
|
||||
PrintMessage(sMessage.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgIRC::OnIrc_KICK(const CIrcMessage* pmsg)
|
||||
{
|
||||
if( !pmsg->prefix.sNick.length() )
|
||||
return false;
|
||||
|
||||
AgString sMessage;
|
||||
sMessage = pmsg->prefix.sNick + " was kicked by " + pmsg->parameters[0];
|
||||
PrintMessage(sMessage.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgIRC::OnIrc_MODE(const CIrcMessage* pmsg)
|
||||
{
|
||||
if( !pmsg->prefix.sNick.length() )
|
||||
return false;
|
||||
if( pmsg->prefix.sNick == m_session.GetInfo().sNick )
|
||||
return false;
|
||||
|
||||
AgString sMessage;
|
||||
sMessage = pmsg->prefix.sNick + " sets mode: ";
|
||||
for (unsigned int i = 1; i < pmsg->parameters.size(); i++)
|
||||
{
|
||||
sMessage += pmsg->parameters[i] + " ";
|
||||
}
|
||||
|
||||
PrintMessage(sMessage.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgIRC::OnIrc_QUIT(const CIrcMessage* pmsg)
|
||||
{
|
||||
if( !pmsg->prefix.sNick.length() )
|
||||
return false;
|
||||
|
||||
AgString sMessage;
|
||||
sMessage = pmsg->prefix.sNick + " has quit IRC ";
|
||||
if (pmsg->parameters[0].size())
|
||||
sMessage += "(" + pmsg->parameters[0] + ")";
|
||||
PrintMessage(sMessage.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void AgIRC::OnIrcDefault(const CIrcMessage* pmsg)
|
||||
{
|
||||
CIrcDefaultMonitor::OnIrcDefault(pmsg);
|
||||
|
||||
OnMessage(pmsg);
|
||||
}
|
||||
|
||||
void AgIRC::OnIrcDisconnected()
|
||||
{
|
||||
AgString sMessage;
|
||||
sMessage = "Disconnected from " + m_session.GetInfo().sServerName;
|
||||
PrintMessage(sMessage.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AgIRC::SilentMode()
|
||||
{
|
||||
#ifndef AG_TESTCHEAT
|
||||
m_bSilent = true;
|
||||
#endif
|
||||
}
|
46
cl_dll/aghl/agirc.h
Normal file
46
cl_dll/aghl/agirc.h
Normal file
@ -0,0 +1,46 @@
|
||||
// AgIRC.h: interface for the AgIRC class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_AGIRC_H__B955D0B4_C876_4C79_BB48_522114B04B53__INCLUDED_)
|
||||
#define AFX_AGIRC_H__B955D0B4_C876_4C79_BB48_522114B04B53__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
using namespace irc;
|
||||
class AgIRC : public CIrcDefaultMonitor
|
||||
{
|
||||
protected:
|
||||
bool m_bSilent;
|
||||
AgString m_sChannel;
|
||||
bool OnIrc_YOURHOST(const CIrcMessage* pmsg);
|
||||
bool OnIrc_NICK(const CIrcMessage* pmsg);
|
||||
bool OnIrc_PRIVMSG(const CIrcMessage* pmsg);
|
||||
bool OnIrc_JOIN(const CIrcMessage* pmsg);
|
||||
bool OnIrc_PART(const CIrcMessage* pmsg);
|
||||
bool OnIrc_KICK(const CIrcMessage* pmsg);
|
||||
bool OnIrc_MODE(const CIrcMessage* pmsg);
|
||||
bool OnIrc_QUIT(const CIrcMessage* pmsg);
|
||||
|
||||
virtual void OnIrcDefault(const CIrcMessage* pmsg);
|
||||
virtual void OnIrcDisconnected();
|
||||
|
||||
void OnMessage(const CIrcMessage* pmsg);
|
||||
void PrintMessage(AgString sMessage);
|
||||
|
||||
DEFINE_IRC_MAP()
|
||||
|
||||
public:
|
||||
AgIRC();
|
||||
virtual ~AgIRC();
|
||||
|
||||
public:
|
||||
void SilentMode();
|
||||
bool Connect(const CIrcSessionInfo* psi);
|
||||
bool Command(AgString sCommand);
|
||||
bool Disconnect(const AgString& sMessage);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_AGIRC_H__B955D0B4_C876_4C79_BB48_522114B04B53__INCLUDED_)
|
35
cl_dll/aghl/aglocation.cpp
Normal file
35
cl_dll/aghl/aglocation.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "pm_defs.h"
|
||||
#include "event_api.h"
|
||||
#include "r_efx.h"
|
||||
#include "aglocation.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
AgLocation::AgLocation()
|
||||
{
|
||||
m_vPosition = Vector(0,0,0);
|
||||
}
|
||||
|
||||
AgLocation::~AgLocation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AgLocation::Show()
|
||||
{
|
||||
int iSpot = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/laserdot.spr" );
|
||||
gEngfuncs.pEfxAPI->R_TempSprite( m_vPosition, vec3_origin, 1, iSpot, kRenderTransAlpha, kRenderFxNoDissipation, 255.0, 10, FTENT_SPRCYCLE );
|
||||
}
|
||||
|
||||
//-- Martin Webrant
|
||||
|
||||
|
22
cl_dll/aghl/aglocation.h
Normal file
22
cl_dll/aghl/aglocation.h
Normal file
@ -0,0 +1,22 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_LOCATION_)
|
||||
#define _AG_LOCATION_
|
||||
|
||||
#include "agglobal.h"
|
||||
|
||||
class AgLocation
|
||||
{
|
||||
public:
|
||||
AgLocation();
|
||||
virtual ~AgLocation();
|
||||
|
||||
AgString m_sLocation;
|
||||
Vector m_vPosition;
|
||||
|
||||
void Show();
|
||||
};
|
||||
|
||||
#endif //_AG_LOCATION_
|
||||
|
||||
//-- Martin Webrant
|
39
cl_dll/aghl/agmapi.cpp
Normal file
39
cl_dll/aghl/agmapi.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
//++ BulliT
|
||||
#include "agmapi.h"
|
||||
#undef EXPORT
|
||||
#include <windows.h>
|
||||
#include <mapi.h>
|
||||
|
||||
bool AgSendMail(const char* pszMessage)
|
||||
{
|
||||
// Get instance handle of MAPI32.DLL
|
||||
HINSTANCE hlibMAPI = LoadLibrary ("MAPI32.dll");
|
||||
if (!hlibMAPI)
|
||||
return false;
|
||||
|
||||
// Get the addresses of sendmail api
|
||||
LPMAPISENDMAIL lpfMAPISendMail = (LPMAPISENDMAIL)GetProcAddress(hlibMAPI, "MAPISendMail");
|
||||
if (!lpfMAPISendMail)
|
||||
return false;
|
||||
|
||||
MapiMessage Message;
|
||||
ZeroMemory(&Message,sizeof(Message));
|
||||
Message.lpszSubject = "AGMOD Cheatdetection";
|
||||
Message.lpszNoteText = (char*)pszMessage;
|
||||
|
||||
MapiRecipDesc arMailRecipients[1];
|
||||
ZeroMemory(&arMailRecipients,sizeof(arMailRecipients));
|
||||
arMailRecipients[0].lpszName = "BulliT";
|
||||
arMailRecipients[0].lpszAddress = "SMTP:Martin Webrant";
|
||||
arMailRecipients[0].ulRecipClass = MAPI_TO;
|
||||
|
||||
Message.nRecipCount = 1;
|
||||
Message.lpRecips = arMailRecipients;
|
||||
|
||||
ULONG result = lpfMAPISendMail(NULL,NULL,&Message,0,0);
|
||||
if (SUCCESS_SUCCESS == result)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
//-- Martin Webrant
|
10
cl_dll/aghl/agmapi.h
Normal file
10
cl_dll/aghl/agmapi.h
Normal file
@ -0,0 +1,10 @@
|
||||
//++ BulliT
|
||||
|
||||
#ifndef __AG_MAPI_H__
|
||||
#define __AG_MAPI_H__
|
||||
|
||||
bool AgSendMail(const char* pszMessage);
|
||||
|
||||
#endif //__AG_MAPI_H__
|
||||
|
||||
//-- Martin Webrant
|
84
cl_dll/aghl/agmatchreport.cpp
Normal file
84
cl_dll/aghl/agmatchreport.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "parsemsg.h"
|
||||
#include "agglobal.h"
|
||||
#include "agmatchreport.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern cvar_t* g_pcl_matchreport;
|
||||
|
||||
AgMatchReport::AgMatchReport()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AgMatchReport::~AgMatchReport()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AgMatchReport::Save()
|
||||
{
|
||||
if (0 == g_pcl_matchreport->value)
|
||||
return;
|
||||
|
||||
char szFile[MAX_PATH];
|
||||
sprintf(szFile,"%s/matchreport/%s.txt",AgGetDirectory(),AgMapname().c_str());
|
||||
FILE* pFile = fopen(szFile,"a");
|
||||
if (!pFile)
|
||||
{
|
||||
// file error
|
||||
return;
|
||||
}
|
||||
|
||||
//Write the scores.
|
||||
if (gHUD.m_Teamplay)
|
||||
{
|
||||
fputs("Team/player \tFrags\tDeaths\tPing\tLoss\tAuthID\r\n",pFile);
|
||||
|
||||
//List teams and frags.
|
||||
for (int i = 1; i <= MAX_TEAMS; i++)
|
||||
{
|
||||
if (0 != strlen(g_TeamInfo[i].name))
|
||||
{
|
||||
fprintf(pFile,"%-20s\t%d\t%d\t%d\t%d\t\r\n",(const char*)g_TeamInfo[i].name,g_TeamInfo[i].frags,g_TeamInfo[i].deaths,g_TeamInfo[i].ping,g_TeamInfo[i].packetloss);
|
||||
|
||||
//Print the players for that one.
|
||||
for (int iPlayer = 1; iPlayer <= gEngfuncs.GetMaxClients(); iPlayer++)
|
||||
{
|
||||
if (g_PlayerExtraInfo[iPlayer].teamname && g_PlayerInfoList[iPlayer].name && 0 == stricmp(g_PlayerExtraInfo[iPlayer].teamname,g_TeamInfo[i].name))
|
||||
{
|
||||
fprintf(pFile,"%-20s\t%d\t%d\t%d\t%d\t%s\r\n",(const char*)g_PlayerInfoList[iPlayer].name,g_PlayerExtraInfo[iPlayer].frags,g_PlayerExtraInfo[iPlayer].deaths,g_PlayerInfoList[iPlayer].ping,g_PlayerInfoList[iPlayer].packetloss,AgGetAuthID(iPlayer).c_str());
|
||||
}
|
||||
}
|
||||
fputs("\r\n",pFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//List the frags.
|
||||
fputs("Player \tFrags\tDeaths\tPing\tLoss\tAuthID\r\n",pFile);
|
||||
for (int iPlayer = 1; iPlayer <= gEngfuncs.GetMaxClients(); iPlayer++)
|
||||
{
|
||||
if (g_PlayerInfoList[iPlayer].name != NULL && 0 != strlen(g_PlayerInfoList[iPlayer].name))
|
||||
{
|
||||
fprintf(pFile,"%-20s\t%d\t%d\t%d\t%d\t%s\r\n",(const char*)g_PlayerInfoList[iPlayer].name,g_PlayerExtraInfo[iPlayer].frags,g_PlayerExtraInfo[iPlayer].deaths,g_PlayerInfoList[iPlayer].ping,g_PlayerInfoList[iPlayer].packetloss,AgGetAuthID(iPlayer).c_str());
|
||||
}
|
||||
}
|
||||
fputs("\r\n",pFile);
|
||||
}
|
||||
|
||||
//Close it up.
|
||||
fflush(pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
//-- Martin Webrant
|
21
cl_dll/aghl/agmatchreport.h
Normal file
21
cl_dll/aghl/agmatchreport.h
Normal file
@ -0,0 +1,21 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(AFX_AGMATCHREPORT_H__0DF56E7E_7803_4FDE_BE99_6609E45A7D41__INCLUDED_)
|
||||
#define AFX_AGMATCHREPORT_H__0DF56E7E_7803_4FDE_BE99_6609E45A7D41__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
class AgMatchReport
|
||||
{
|
||||
public:
|
||||
AgMatchReport();
|
||||
virtual ~AgMatchReport();
|
||||
|
||||
void Save();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_AGMATCHREPORT_H__0DF56E7E_7803_4FDE_BE99_6609E45A7D41__INCLUDED_)
|
||||
|
||||
//-- Martin Webrant
|
151
cl_dll/aghl/agminidump.cpp
Normal file
151
cl_dll/aghl/agminidump.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
//++ BulliT
|
||||
|
||||
#ifdef AG_USE_MINIDUMP
|
||||
|
||||
#ifdef CLIENT_DLL //Only check problems on client...
|
||||
#define DUMPNAME "agclient.dmp"
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "agglobal.h"
|
||||
|
||||
/*
|
||||
#else
|
||||
#define DUMPNAME "agserver.dmp"
|
||||
#include "agglobal.h"
|
||||
#endif
|
||||
*/
|
||||
|
||||
#define VC_EXTRALEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOWINRES
|
||||
#define NOSERVICE
|
||||
#define NOMCX
|
||||
#define NOIME
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if _MSC_VER < 1300
|
||||
#define DECLSPEC_DEPRECATED
|
||||
// VC6: change this path to your Platform SDK headers
|
||||
#include "dbghelp.h" // must be XP version of file
|
||||
#else
|
||||
// VC7: ships with updated headers
|
||||
#include "dbghelp.h"
|
||||
#endif
|
||||
|
||||
// based on dbghelp.h
|
||||
typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType,
|
||||
CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
|
||||
CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
|
||||
CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam
|
||||
);
|
||||
|
||||
static LONG WINAPI TopLevelFilter( struct _EXCEPTION_POINTERS *pExceptionInfo )
|
||||
{
|
||||
LONG retval = EXCEPTION_EXECUTE_HANDLER;//EXCEPTION_CONTINUE_SEARCH;
|
||||
HWND hParent = NULL; // find a better value for your app
|
||||
|
||||
// firstly see if dbghelp.dll is around and has the function we need
|
||||
// look next to the EXE first, as the one in System32 might be old
|
||||
// (e.g. Windows 2000)
|
||||
HMODULE hDll = NULL;
|
||||
char szDbgHelpPath[MAX_PATH];
|
||||
char szMiniDump[MAX_PATH];
|
||||
|
||||
if (GetModuleFileName( GetModuleHandle("client.dll"), szDbgHelpPath, MAX_PATH ))
|
||||
{
|
||||
char *pSlash = strrchr( szDbgHelpPath, '\\' );
|
||||
if (pSlash)
|
||||
{
|
||||
strcpy( pSlash+1, "DBGHELP.DLL" );
|
||||
hDll = ::LoadLibrary( szDbgHelpPath );
|
||||
}
|
||||
}
|
||||
|
||||
if (GetModuleFileName( GetModuleHandle("client.dll"), szMiniDump, MAX_PATH ))
|
||||
{
|
||||
char *pSlash = strrchr( szMiniDump, '\\' );
|
||||
if (pSlash)
|
||||
{
|
||||
strcpy( pSlash+1, DUMPNAME );
|
||||
}
|
||||
}
|
||||
|
||||
if (hDll==NULL)
|
||||
{
|
||||
// load any version we can
|
||||
hDll = ::LoadLibrary( "DBGHELP.DLL" );
|
||||
}
|
||||
|
||||
LPCTSTR szResult = NULL;
|
||||
|
||||
if (hDll)
|
||||
{
|
||||
MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress( hDll, "MiniDumpWriteDump" );
|
||||
if (pDump)
|
||||
{
|
||||
char szScratch [MAX_PATH];
|
||||
|
||||
// create the file
|
||||
HANDLE hFile = ::CreateFile( szMiniDump, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
|
||||
if (hFile!=INVALID_HANDLE_VALUE)
|
||||
{
|
||||
_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
|
||||
|
||||
ExInfo.ThreadId = ::GetCurrentThreadId();
|
||||
ExInfo.ExceptionPointers = pExceptionInfo;
|
||||
ExInfo.ClientPointers = NULL;
|
||||
|
||||
// write the dump
|
||||
BOOL bOK = pDump( GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL );
|
||||
if (bOK)
|
||||
{
|
||||
sprintf( szScratch, "Saved dump file to '%s'", szMiniDump );
|
||||
szResult = szScratch;
|
||||
//retval = EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( szScratch, "Failed to save dump file to '%s' (error %d)", szMiniDump, GetLastError() );
|
||||
szResult = szScratch;
|
||||
}
|
||||
::CloseHandle(hFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( szScratch, "Failed to create dump file '%s' (error %d)", szMiniDump, GetLastError() );
|
||||
szResult = szScratch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
szResult = "DBGHELP.DLL too old";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
szResult = "DBGHELP.DLL not found";
|
||||
}
|
||||
|
||||
AgLog(szResult);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
class AgMiniDump
|
||||
{
|
||||
public:
|
||||
AgMiniDump()
|
||||
{
|
||||
::SetUnhandledExceptionFilter( TopLevelFilter );
|
||||
};
|
||||
};
|
||||
|
||||
AgMiniDump g_MiniDump; //The dumper.
|
||||
|
||||
#endif CLIENT_DLL
|
||||
|
||||
#endif AG_USE_MINIDUMP
|
||||
//-- Martin Webrant
|
292
cl_dll/aghl/agmodel.cpp
Normal file
292
cl_dll/aghl/agmodel.cpp
Normal file
@ -0,0 +1,292 @@
|
||||
//++ BulliT
|
||||
//Most parts written by David "Nighthawk" Flor (dflor@mach3.com) for the mod Opera (http://www.halflife.net/opera)
|
||||
//Parts of code from Valve Software mdlviewer (CalcBonePosition).
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "parsemsg.h"
|
||||
#include "com_model.h"
|
||||
#include "studio.h"
|
||||
#include "com_weapons.h"
|
||||
#include "AgModel.h"
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
void CalcBonePosition(int frame, mstudiobone_t *pbone, mstudioanim_t *panim, float *pos);
|
||||
extern int g_iPure;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
AgModel::AgModel()
|
||||
{
|
||||
m_vMinBounds = Vector(0,0,0);
|
||||
m_vMaxBounds = Vector(0,0,0);
|
||||
m_iVertexCount = 0;
|
||||
|
||||
m_vMinBone = Vector(0,0,0);
|
||||
m_vMaxBone = Vector(0,0,0);
|
||||
m_iBoneCount = 0;
|
||||
m_bCorrupt = false;
|
||||
m_bFoundAndChecked = false;
|
||||
}
|
||||
|
||||
AgModel::~AgModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AgModel::AddVertex( const Vector &vPoint )
|
||||
{
|
||||
if (m_iVertexCount == 0)
|
||||
{
|
||||
m_vMinBounds = m_vMaxBounds = vPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vMinBounds.x = min( m_vMinBounds.x, vPoint.x );
|
||||
m_vMinBounds.y = min( m_vMinBounds.y, vPoint.y );
|
||||
m_vMinBounds.z = min( m_vMinBounds.z, vPoint.z );
|
||||
|
||||
m_vMaxBounds.x = max( m_vMaxBounds.x, vPoint.x );
|
||||
m_vMaxBounds.y = max( m_vMaxBounds.y, vPoint.y );
|
||||
m_vMaxBounds.z = max( m_vMaxBounds.z, vPoint.z );
|
||||
}
|
||||
m_iVertexCount++;
|
||||
}
|
||||
|
||||
void AgModel::AddBone( const Vector &vPoint )
|
||||
{
|
||||
if (m_iBoneCount == 0)
|
||||
{
|
||||
m_vMinBone = m_vMaxBone = vPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_vMinBone.x = min( m_vMinBone.x, vPoint.x );
|
||||
m_vMinBone.y = min( m_vMinBone.y, vPoint.y );
|
||||
m_vMinBone.z = min( m_vMinBone.z, vPoint.z );
|
||||
|
||||
m_vMaxBone.x = max( m_vMaxBone.x, vPoint.x );
|
||||
m_vMaxBone.y = max( m_vMaxBone.y, vPoint.y );
|
||||
m_vMaxBone.z = max( m_vMaxBone.z, vPoint.z );
|
||||
}
|
||||
m_iBoneCount++;
|
||||
}
|
||||
|
||||
void AgModel::AddBonesToVertices( void )
|
||||
{
|
||||
Vector vAdjust;
|
||||
|
||||
if (m_iBoneCount > 0)
|
||||
{
|
||||
vAdjust = (m_vMaxBone - m_vMinBone);
|
||||
|
||||
AddVertex( vAdjust / 2 );
|
||||
AddVertex( -(vAdjust / 2) );
|
||||
|
||||
m_vMinBone = m_vMaxBone = Vector(0,0,0);
|
||||
m_iBoneCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AgModel::ReadModel(const char *szModelName)
|
||||
{
|
||||
char *pBuffer;
|
||||
char *pTempBuffer;
|
||||
char szFullName[ _MAX_PATH ];
|
||||
float flBone[3];
|
||||
|
||||
strcpy( szFullName, szModelName );
|
||||
pBuffer = (char*)gEngfuncs.COM_LoadFile( szFullName, 5, NULL );
|
||||
if (pBuffer)
|
||||
{
|
||||
studiohdr_t *pHeader;
|
||||
mstudiobodyparts_t *pBodyParts;
|
||||
mstudiomodel_t *pModel;
|
||||
long iCnt;
|
||||
long iModelCnt, iModels;
|
||||
long iVert, iVertCnt;
|
||||
vec3_t *pVert;
|
||||
mstudiobone_t *pBone;
|
||||
long iBoneCnt, iBones;
|
||||
mstudioseqdesc_t *pSequence;
|
||||
long iSequenceCnt, iSequences;
|
||||
mstudioanim_t *pAnim;
|
||||
long iFrameCnt, iFrames;
|
||||
|
||||
pHeader = (studiohdr_t *)pBuffer;
|
||||
if (10 == pHeader->version)
|
||||
{
|
||||
pTempBuffer = (pBuffer + pHeader->bodypartindex);
|
||||
pBodyParts = (mstudiobodyparts_t *)pTempBuffer;
|
||||
iModels = 0;
|
||||
for (iCnt = 0; iCnt < pHeader->numbodyparts; iCnt++)
|
||||
iModels += pBodyParts[iCnt].nummodels;
|
||||
pTempBuffer += (pHeader->numbodyparts * sizeof(mstudiobodyparts_t));
|
||||
|
||||
pModel = (mstudiomodel_t *)pTempBuffer;
|
||||
for (iModelCnt = 0; iModelCnt < iModels; iModelCnt++)
|
||||
{
|
||||
iVert = pModel[iModelCnt].numverts;
|
||||
pVert = (vec3_t *)(pBuffer + pModel[iModelCnt].vertindex);
|
||||
for (iVertCnt = 0; iVertCnt < iVert; iVertCnt++)
|
||||
{
|
||||
AddVertex( pVert[iVertCnt] );
|
||||
}
|
||||
}
|
||||
|
||||
pBone = (mstudiobone_t *)(pBuffer + pHeader->boneindex);
|
||||
iBones = pHeader->numbones;
|
||||
|
||||
pSequence = (mstudioseqdesc_t *)(pBuffer + pHeader->seqindex);
|
||||
iSequences = pHeader->numseq;
|
||||
for (iSequenceCnt = 0; iSequenceCnt < iSequences; iSequenceCnt++)
|
||||
{
|
||||
iFrames = pSequence[iSequenceCnt].numframes;
|
||||
|
||||
pTempBuffer = (pBuffer + pSequence[iSequenceCnt].animindex);
|
||||
pAnim = (mstudioanim_t *)pTempBuffer;
|
||||
for (iBoneCnt = 0; iBoneCnt < iBones; iBoneCnt++)
|
||||
{
|
||||
for (iFrameCnt = 0; iFrameCnt < iFrames; iFrameCnt++)
|
||||
{
|
||||
CalcBonePosition( iFrameCnt, pBone + iBoneCnt,
|
||||
pAnim, flBone );
|
||||
|
||||
AddBone( flBone );
|
||||
}
|
||||
}
|
||||
|
||||
AddBonesToVertices();
|
||||
}
|
||||
m_bFoundAndChecked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bCorrupt = true;
|
||||
}
|
||||
gEngfuncs.COM_FreeFile( pBuffer );
|
||||
}
|
||||
}
|
||||
|
||||
void CalcBonePosition( int frame, mstudiobone_t *pbone, mstudioanim_t *panim, float *pos )
|
||||
{
|
||||
float s = 0;
|
||||
int j, k;
|
||||
mstudioanimvalue_t *panimvalue;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
pos[j] = pbone->value[j]; // default;
|
||||
if (panim->offset[j] != 0)
|
||||
{
|
||||
panimvalue = (mstudioanimvalue_t *)((byte *)panim + panim->offset[j]);
|
||||
|
||||
k = frame;
|
||||
// find span of values that includes the frame we want
|
||||
while (panimvalue->num.total <= k)
|
||||
{
|
||||
k -= panimvalue->num.total;
|
||||
panimvalue += panimvalue->num.valid + 1;
|
||||
}
|
||||
// if we're inside the span
|
||||
if (panimvalue->num.valid > k)
|
||||
{
|
||||
// and there's more data in the span
|
||||
if (panimvalue->num.valid > k + 1)
|
||||
{
|
||||
pos[j] += (panimvalue[k+1].value * (1.0 - s) + s * panimvalue[k+2].value) * pbone->scale[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
pos[j] += panimvalue[k+1].value * pbone->scale[j];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// are we at the end of the repeating values section and there's another section with data?
|
||||
if (panimvalue->num.total <= k + 1)
|
||||
{
|
||||
pos[j] += (panimvalue[panimvalue->num.valid].value * (1.0 - s) + s * panimvalue[panimvalue->num.valid + 2].value) * pbone->scale[j];
|
||||
}
|
||||
else
|
||||
{
|
||||
pos[j] += panimvalue[panimvalue->num.valid].value * pbone->scale[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AgModel::CheckModel(const char* szModelName)
|
||||
{
|
||||
try
|
||||
{
|
||||
ReadModel(szModelName);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
m_bCorrupt = true;
|
||||
}
|
||||
|
||||
if (m_bCorrupt)
|
||||
{
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"Server enforces model check and %s seems to be corrupt.\n",szModelName);
|
||||
AgLog(szMessage);
|
||||
ConsolePrint(szMessage);
|
||||
#ifdef _DEBUG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
Vector vMaxBounds = Vector(0,0,0);
|
||||
Vector vBounds = m_vMaxBounds - m_vMinBounds;
|
||||
if ( !strnicmp( szModelName, "/models/player", 14) )
|
||||
{
|
||||
if (0 < g_iPure)
|
||||
vMaxBounds = Vector( 78, 30, 98 );
|
||||
else
|
||||
vMaxBounds = Vector( 105, 105, 105 ); //Big fucking models allowed..
|
||||
}
|
||||
else if ( !strnicmp( szModelName, "/models/p_", 9 ) )
|
||||
vMaxBounds = Vector( 42, 21, 60 );
|
||||
else if ( !strnicmp( szModelName, "/models/w_", 9 ) )
|
||||
vMaxBounds = Vector( 82, 69, 76);
|
||||
else if ( !strnicmp( szModelName, "/models/v_", 9 ) )
|
||||
vMaxBounds = Vector( 46, 55, 120 );
|
||||
else
|
||||
vMaxBounds = Vector( 100, 100, 100 );
|
||||
|
||||
if (vBounds.x > vMaxBounds.x || vBounds.y > vMaxBounds.y || vBounds.z > vMaxBounds.z)
|
||||
{
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"Server enforces model check and %s is not valid. Your model got these ranges: %.4f,%.4f,%.4f\n",szModelName,vBounds.x, vBounds.y, vBounds.z);
|
||||
AgLog(szMessage);
|
||||
sprintf(szMessage,"Server enforces model check and %s is not valid.\n",szModelName);
|
||||
ConsolePrint(szMessage);
|
||||
#ifdef _DEBUG
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgModel::IsChecked()
|
||||
{
|
||||
return m_bFoundAndChecked;
|
||||
}
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
|
||||
//-- Martin Webrant
|
46
cl_dll/aghl/agmodel.h
Normal file
46
cl_dll/aghl/agmodel.h
Normal file
@ -0,0 +1,46 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(AFX_AGMODEL_H__EC242BA8_B4C4_45B1_A6E7_1BF186C6B9CF__INCLUDED_)
|
||||
#define AFX_AGMODEL_H__EC242BA8_B4C4_45B1_A6E7_1BF186C6B9CF__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
#include "AgGlobal.h"
|
||||
|
||||
class AgModel
|
||||
{
|
||||
bool m_bCorrupt;
|
||||
bool m_bFoundAndChecked;
|
||||
|
||||
Vector m_vMinBounds;
|
||||
Vector m_vMaxBounds;
|
||||
long m_iVertexCount;
|
||||
|
||||
Vector m_vMinBone;
|
||||
Vector m_vMaxBone;
|
||||
long m_iBoneCount;
|
||||
|
||||
void AddVertex(const Vector &vPoint);
|
||||
void AddBone(const Vector &vPoint);
|
||||
void AddBonesToVertices(void);
|
||||
void ReadModel(const char* szModelName);
|
||||
|
||||
public:
|
||||
AgModel();
|
||||
virtual ~AgModel();
|
||||
|
||||
bool CheckModel(const char* szModelName);
|
||||
bool IsChecked();
|
||||
|
||||
};
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
|
||||
|
||||
#endif // !defined(AFX_AGMODEL_H__EC242BA8_B4C4_45B1_A6E7_1BF186C6B9CF__INCLUDED_)
|
||||
|
||||
//-- Martin Webrant
|
128
cl_dll/aghl/agmodelcheck.cpp
Normal file
128
cl_dll/aghl/agmodelcheck.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "com_model.h"
|
||||
#include "studio.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "dlight.h"
|
||||
#include "triangleapi.h"
|
||||
#include "studio_util.h"
|
||||
#include "r_studioint.h"
|
||||
#include "parsemsg.h"
|
||||
#include "AgModel.h"
|
||||
#include "AgModelCheck.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
|
||||
AgModelCheck g_ModelCheck;
|
||||
extern int g_iPure;
|
||||
extern engine_studio_api_t IEngineStudio;
|
||||
|
||||
static char* s_szPure1[] =
|
||||
{
|
||||
"gordon",
|
||||
"helmet",
|
||||
"zombie",
|
||||
"robo",
|
||||
"recon",
|
||||
"hgrunt",
|
||||
"gman",
|
||||
"barney",
|
||||
"gina",
|
||||
"scientist",
|
||||
"robo",
|
||||
"pmers",
|
||||
"player",
|
||||
"blue",
|
||||
"red",
|
||||
};
|
||||
|
||||
static char szDisconnect[] = "disconnect\n";
|
||||
|
||||
AgModelCheck::AgModelCheck()
|
||||
{
|
||||
m_bScannedStandard = false;
|
||||
}
|
||||
|
||||
AgModelCheck::~AgModelCheck()
|
||||
{
|
||||
// m_setChecked.erase();
|
||||
}
|
||||
|
||||
bool AgModelCheck::Check()
|
||||
{
|
||||
if (m_bScannedStandard)
|
||||
return CheckCurrent();
|
||||
|
||||
for (int i = 0; i < (sizeof(s_szPure1) / sizeof(s_szPure1[0])); i++)
|
||||
{
|
||||
if (!CheckOne(s_szPure1[i]))
|
||||
return false;
|
||||
}
|
||||
m_bScannedStandard = true;
|
||||
return CheckCurrent();
|
||||
}
|
||||
|
||||
bool AgModelCheck::CheckCurrent()
|
||||
{
|
||||
bool bPassed = true;
|
||||
|
||||
for ( int i = 1; i <= MAX_PLAYERS; i++ )
|
||||
{
|
||||
GetPlayerInfo( i, &g_PlayerInfoList[i] );
|
||||
if (NULL == g_PlayerInfoList[i].name)
|
||||
continue;
|
||||
|
||||
bPassed = CheckOne(gEngfuncs.PlayerInfo_ValueForKey(i,"model"));
|
||||
if (!bPassed)
|
||||
break;
|
||||
}
|
||||
|
||||
return bPassed;
|
||||
}
|
||||
|
||||
bool AgModelCheck::CheckOne(const char* pszModel)
|
||||
{
|
||||
bool bPassed = true;
|
||||
char szModel[MAX_PATH];
|
||||
sprintf(szModel,"/models/player/%s/%s.mdl",pszModel,pszModel);
|
||||
if (0 != m_setChecked.size() && m_setChecked.end() != m_setChecked.find(szModel))
|
||||
return true;
|
||||
|
||||
#ifdef _DEBUG
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"Checking %s\n",szModel);
|
||||
ConsolePrint(szMessage);
|
||||
#endif
|
||||
|
||||
AgModel Model;
|
||||
bPassed = Model.CheckModel(szModel);
|
||||
bool bChecked = Model.IsChecked();
|
||||
|
||||
if (!bPassed)
|
||||
{
|
||||
ServerCmd( "say <AG Mod> Disconnected for using invalid model.\n" );
|
||||
ClientCmd( szDisconnect );
|
||||
return false;
|
||||
}
|
||||
if (bChecked)
|
||||
{
|
||||
//No need to try to load it again.
|
||||
m_setChecked.insert(szModel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
|
||||
|
||||
//-- Martin Webrant
|
37
cl_dll/aghl/agmodelcheck.h
Normal file
37
cl_dll/aghl/agmodelcheck.h
Normal file
@ -0,0 +1,37 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(AFX_AGMODELCHECK_H__4596B2F8_81A4_4927_9A82_9637C7F9A3C9__INCLUDED_)
|
||||
#define AFX_AGMODELCHECK_H__4596B2F8_81A4_4927_9A82_9637C7F9A3C9__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "AgGlobal.h"
|
||||
#include "AgModel.h"
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
class AgModelCheck
|
||||
{
|
||||
typedef set<AgString, less<AgString> > AgCheckedSet;
|
||||
AgCheckedSet m_setChecked;
|
||||
bool m_bScannedStandard;
|
||||
|
||||
bool CheckCurrent();
|
||||
|
||||
public:
|
||||
AgModelCheck();
|
||||
virtual ~AgModelCheck();
|
||||
|
||||
bool Check();
|
||||
bool CheckOne(const char* pszModel);
|
||||
};
|
||||
|
||||
extern AgModelCheck g_ModelCheck;
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
|
||||
#endif // !defined(AFX_AGMODELCHECK_H__4596B2F8_81A4_4927_9A82_9637C7F9A3C9__INCLUDED_)
|
||||
|
||||
//-- Martin Webrant
|
135
cl_dll/aghl/agpak.cpp
Normal file
135
cl_dll/aghl/agpak.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "agglobal.h"
|
||||
#include "agpak.h"
|
||||
|
||||
typedef struct
|
||||
{ unsigned char magic[4]; // Name of the new WAD format
|
||||
long diroffset; // Position of WAD directory from start of file
|
||||
long dirsize; // Number of entries * 0x40 (64 char)
|
||||
} pakheader_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char filename[0x38]; // Name of the file, Unix style, with extension,
|
||||
// 50 chars, padded with '\0'.
|
||||
long offset; // Position of the entry in PACK file
|
||||
long size; // Size of the entry in PACK file
|
||||
} pakentry_t;
|
||||
|
||||
|
||||
AgPak::AgPak()
|
||||
{
|
||||
}
|
||||
|
||||
bool AgPak::GetEntries(const AgString& sPakfile, const AgString& sSearch1, const AgString& sSearch2, AgStringList& lstEntries)
|
||||
{
|
||||
AgString sSearchString1;
|
||||
AgString sSearchString2;
|
||||
sSearchString1 = sSearch1;
|
||||
sSearchString2 = sSearch2;
|
||||
AgToLower(sSearchString1);
|
||||
AgToLower(sSearchString2);
|
||||
|
||||
pakheader_t Header;
|
||||
DWORD dwRead = 0;
|
||||
HANDLE h = CreateFile(sPakfile.c_str(),GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,0);
|
||||
|
||||
//Read header.
|
||||
if (!ReadFile(h,(void*)&Header,sizeof(Header),&dwRead,NULL))
|
||||
return false;
|
||||
if (sizeof(Header) != dwRead)
|
||||
return false;
|
||||
|
||||
//Move to directory list.
|
||||
SetFilePointer(h,Header.diroffset,NULL,FILE_BEGIN);
|
||||
|
||||
//Allocate array of entries.
|
||||
pakentry_t* pEntries = (pakentry_t*)malloc(Header.dirsize);
|
||||
|
||||
//Read the entries.
|
||||
if (!ReadFile(h,(void*)pEntries,Header.dirsize,&dwRead,NULL))
|
||||
{
|
||||
free(pEntries);
|
||||
CloseHandle(h);
|
||||
return false;
|
||||
}
|
||||
CloseHandle(h);
|
||||
|
||||
if (Header.dirsize != (long)dwRead)
|
||||
{
|
||||
free(pEntries);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Calc number of entries.
|
||||
int iEntries = Header.dirsize / sizeof(pakentry_t);
|
||||
|
||||
//Read directory listing
|
||||
for (int i = 0; i < iEntries; i++)
|
||||
{
|
||||
AgString sFilename;
|
||||
sFilename = (const char*)pEntries[i].filename;
|
||||
AgToLower(sFilename);
|
||||
|
||||
if (0 != sSearchString1.length())
|
||||
{
|
||||
//Check if the file contains the search1 string.
|
||||
if (NPOS != sFilename.find(sSearchString1))
|
||||
{
|
||||
if (0 != sSearchString2.length())
|
||||
{
|
||||
if (NPOS != sFilename.find(sSearchString2))
|
||||
lstEntries.push_back(sFilename);
|
||||
}
|
||||
else
|
||||
lstEntries.push_back(sFilename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add all files
|
||||
lstEntries.push_back(sFilename);
|
||||
}
|
||||
}
|
||||
|
||||
free((void*)pEntries);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Quake PAK Format
|
||||
|
||||
Figured out by Pete McCormick (petra@force.net) I am not responsible for any damage this does, enjoy,
|
||||
and please email me any comments!
|
||||
Pete
|
||||
|
||||
=Format=
|
||||
Header
|
||||
(4 unsigned chars) signature = 'PACK'
|
||||
(4 unsigned chars, int) directory offeset
|
||||
(4 unsigned chars, int) directory lenght
|
||||
|
||||
Directory
|
||||
(56 unsigned chars, char) file name
|
||||
(4 unsigned chars, int) file position
|
||||
(4 unsigned chars, int) file lenght
|
||||
|
||||
File at each position (? unsigned chars, char) file data
|
||||
Description - The signature must be present in all PAKs; it's the way Quake knows its a real PAK file.
|
||||
The directory offset is where the directory listing starts, and the lenght is its lenght.
|
||||
In the actuall directory listing, the three options, 56 unsigned chars of a name,
|
||||
the files position and lenght, are repeating until the running total of the length (increment by 64) is reached.
|
||||
If the directory lenght mod 64 is not a even number, you know their is something wrong.
|
||||
And directories are just handled by a making the name something like "/foobar/yeahs.txt". Short and simple.
|
||||
|
||||
Tips - Put the directory entry at the end of the file, so if you added a file,
|
||||
you'd just rewrite the small directory entry instead of all the data.
|
||||
|
||||
Limits - Unknown file limit. Don't create too many though :) I would think around a 1000,
|
||||
prehaps 2000 (in which case, 2048 would be reasonible)
|
||||
*/
|
||||
|
||||
//-- Martin Webrant
|
15
cl_dll/aghl/agpak.h
Normal file
15
cl_dll/aghl/agpak.h
Normal file
@ -0,0 +1,15 @@
|
||||
//++ BulliT
|
||||
#if !defined(_AG_PAK_H_)
|
||||
#define _AG_PAK_H_
|
||||
|
||||
class AgPak
|
||||
{
|
||||
public:
|
||||
AgPak();
|
||||
bool GetEntries(const AgString& sPakfile, const AgString& sSearch1, const AgString& sSearch2, AgStringList& lstEntries);
|
||||
};
|
||||
|
||||
|
||||
#endif // !defined(_AG_PAK_H_)
|
||||
|
||||
//-- Martin Webrant
|
329
cl_dll/aghl/agvariablechecker.cpp
Normal file
329
cl_dll/aghl/agvariablechecker.cpp
Normal file
@ -0,0 +1,329 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "const.h"
|
||||
#include "com_model.h"
|
||||
#include "studio.h"
|
||||
#include "entity_state.h"
|
||||
#include "cl_entity.h"
|
||||
#include "dlight.h"
|
||||
#include "triangleapi.h"
|
||||
#include "studio_util.h"
|
||||
#include "r_studioint.h"
|
||||
#include "AgVariableChecker.h"
|
||||
#include "AgModelCheck.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
extern engine_studio_api_t IEngineStudio;
|
||||
|
||||
#define MAX_VIOLATIONS 5
|
||||
|
||||
struct VARIABLES
|
||||
{
|
||||
char szName[20];
|
||||
double dMin;
|
||||
double dMax;
|
||||
double dDefault;
|
||||
bool bKeepSame;
|
||||
bool bAllowChangeAtInit;
|
||||
};
|
||||
|
||||
static VARIABLES s_Variables[]=
|
||||
{
|
||||
//Evironment
|
||||
"r_lightmap",-1,0,-1,false,true,
|
||||
"direct",0.9,0.9,0.9,false,true,
|
||||
"brightness",0,30,1,false,true,
|
||||
"lambert",1.5,1.5,1.5,true,true,
|
||||
"cl_solid_players",1,1,1,false,true,
|
||||
"cl_himodels",0,1,0,true,false,
|
||||
//Sounds
|
||||
"s_distance",10,60,60,false,true,
|
||||
"s_min_distance",1,20,8,false,true,
|
||||
"s_max_distance",20,1000,1000,false,true,
|
||||
"s_occlude",0,1,1,false,true,
|
||||
"s_occfactor",0.20,0.25,0.25,false,true,
|
||||
"s_refgain",0.4,0.45,0.41,false,true,
|
||||
//Cheats is somehow client also?
|
||||
"sv_cheats",0,0,0,true,true,
|
||||
};
|
||||
|
||||
|
||||
static VARIABLES s_VariablesFast[]=
|
||||
{
|
||||
//Movement
|
||||
"m_pitch",-0.044,0.044,0.022,false,true,
|
||||
"cl_backspeed",300,500,400,false,true,
|
||||
"cl_sidespeed",300,500,400,false,true,
|
||||
"cl_forwardspeed",300,500,400,false,true,
|
||||
"cl_upspeed",300,500,320,false,true,
|
||||
"default_fov",30,130,90,false,true,
|
||||
//Net settings
|
||||
"cl_updaterate",15,100,30,false,true,
|
||||
"cl_cmdrate",15,100,30,false,true,
|
||||
"ex_extrapmax",1.2,1.2,1.2,false,true,
|
||||
#ifdef CLIENT_WEAPONS
|
||||
"ex_interp",0.05,0.1,0.1,false,true,
|
||||
#else
|
||||
"ex_interp",0.1,0.1,0.1,false,true,
|
||||
#endif
|
||||
// Fixed in next patch.
|
||||
"ex_minvelocity",0,0,0,false,true,
|
||||
"ex_maxspeed",750,750,750,false,true,
|
||||
"ex_maxaccel",2000,2000,2000,false,true,
|
||||
"ex_maxerrordistance",64,64,64,false,true,
|
||||
"cl_nopred",0,0,0,false,true,
|
||||
"ex_correct",0,0,0,false,true,
|
||||
"ex_diminishextrap",0,0,0,false,true,
|
||||
};
|
||||
|
||||
/*
|
||||
ex_correct
|
||||
ex_extrapmax
|
||||
ex_maxerror distance
|
||||
cl_nopred
|
||||
*/
|
||||
|
||||
static VARIABLES s_VariablesHardware[]=
|
||||
{
|
||||
//Open GL settings.
|
||||
// "lightgamma",0,3,2.5,true,false,
|
||||
// "texgamma",1,3,2,true,false,
|
||||
"gl_max_size",128,512,512,false,false,
|
||||
"gl_zmax",2048,9999,4096,false,true,
|
||||
"gl_alphamin",0.25,0.25,0.25,false,true,
|
||||
"gl_nobind",0,0,0,false,true,
|
||||
"gl_picmip",0,2,0,false,true,
|
||||
"gl_playermip",0,5,0,false,true,
|
||||
//"gl_spriteblend",1,1,1,true,true,
|
||||
"gl_monolights",0,0,0,true,true,
|
||||
};
|
||||
|
||||
static VARIABLES s_VariablesPure2[]=
|
||||
{
|
||||
"s_distance",10,10,10,false,true,
|
||||
"s_rolloff",10,10,10,false,true,
|
||||
"s_min_distance",8,8,8,false,true,
|
||||
"s_max_distance",1000,1000,1000,false,true,
|
||||
};
|
||||
|
||||
static VARIABLES s_VariablesPure3[]=
|
||||
{
|
||||
"s_a3d",0,0,0,false,true,
|
||||
};
|
||||
|
||||
|
||||
AgVariableChecker g_VariableChecker;
|
||||
static char szDisconnect[] = "disconnect\n";
|
||||
|
||||
AgVariableChecker::AgVariableChecker()
|
||||
{
|
||||
m_bHardware = false;
|
||||
m_bInit = false;
|
||||
m_dwNextCheck = m_dwNextCheckFast = m_dwNextA3D = GetTickCount();
|
||||
m_iViolations = 0;
|
||||
m_bActive = false;
|
||||
}
|
||||
|
||||
AgVariableChecker::~AgVariableChecker()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AgVariableChecker::Activate()
|
||||
{
|
||||
m_bActive = true;
|
||||
m_bInit = false;
|
||||
}
|
||||
|
||||
|
||||
bool InitVariables(VARIABLES* pvarArray,int iElements)
|
||||
{
|
||||
for (int i = 0; i < iElements; i++)
|
||||
{
|
||||
if (!gEngfuncs.pfnGetCvarPointer(pvarArray[i].szName ))
|
||||
continue;
|
||||
|
||||
double dValue = gEngfuncs.pfnGetCvarFloat(pvarArray[i].szName);
|
||||
|
||||
if (dValue < (pvarArray[i].dMin - 0.0001)
|
||||
||dValue > (pvarArray[i].dMax + 0.0001))
|
||||
{
|
||||
if (pvarArray[i].bAllowChangeAtInit)
|
||||
{
|
||||
//Correct it.
|
||||
gEngfuncs.Cvar_SetValue(pvarArray[i].szName, pvarArray[i].dDefault);
|
||||
|
||||
//This dudes standard aint good enough - corrected it for him.
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"Server enforces variables and \"%s\" was automatically reset to the HL default %f.\n",pvarArray[i].szName,pvarArray[i].dDefault);
|
||||
ConsolePrint(szMessage);
|
||||
AgLog(szMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
//This dudes standard aint good enough.
|
||||
char szMessage[256];
|
||||
sprintf(szMessage,"Server enforces variables and \"%s\" needs to be between %f and %f. Your variable is set to %f.\n",pvarArray[i].szName,pvarArray[i].dMin,pvarArray[i].dMax,dValue);
|
||||
ConsolePrint(szMessage);
|
||||
AgLog(szMessage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Save this value as default.
|
||||
pvarArray[i].dDefault = gEngfuncs.pfnGetCvarFloat(pvarArray[i].szName);
|
||||
if (pvarArray[i].bKeepSame)
|
||||
pvarArray[i].dMin = pvarArray[i].dMax = pvarArray[i].dDefault;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CheckVariables(VARIABLES* pvarArray,int iElements, short& iViolations)
|
||||
{
|
||||
for (int i = 0; i < iElements; i++)
|
||||
{
|
||||
if (!gEngfuncs.pfnGetCvarPointer(pvarArray[i].szName ))
|
||||
continue;
|
||||
|
||||
double dValue = gEngfuncs.pfnGetCvarFloat(pvarArray[i].szName);
|
||||
if (dValue < (pvarArray[i].dMin - 0.0001)
|
||||
||dValue > (pvarArray[i].dMax + 0.0001))
|
||||
{
|
||||
char szMessage[256];
|
||||
if (pvarArray[i].bKeepSame && pvarArray[i].bAllowChangeAtInit)
|
||||
sprintf(szMessage,"Server enforces variables and \"%s\" needs to be the same during the game\n",pvarArray[i].szName);
|
||||
else
|
||||
sprintf(szMessage,"Server enforces variables and \"%s\" needs to be between %f and %f.\n",pvarArray[i].szName,pvarArray[i].dMin,pvarArray[i].dMax);
|
||||
ConsolePrint(szMessage);
|
||||
|
||||
if (pvarArray[i].bAllowChangeAtInit)
|
||||
{
|
||||
//Reset to previous value.
|
||||
gEngfuncs.Cvar_SetValue(pvarArray[i].szName, pvarArray[i].dDefault);
|
||||
iViolations++;
|
||||
}
|
||||
else
|
||||
{
|
||||
iViolations = MAX_VIOLATIONS + 1;
|
||||
}
|
||||
|
||||
|
||||
sprintf(szMessage,"say <AG Mod> Warned for using variable %s with value %lf (%d violation(s)",pvarArray[i].szName,dValue,iViolations);
|
||||
ServerCmd(szMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AgVariableChecker::Init()
|
||||
{
|
||||
if (m_bInit)
|
||||
return true;
|
||||
|
||||
bool bSuccess = true;
|
||||
|
||||
m_bHardware = IEngineStudio.IsHardware() ? true : false;
|
||||
|
||||
if (!InitVariables(s_Variables,sizeof(s_Variables)/sizeof(s_Variables[0])))
|
||||
bSuccess = false;
|
||||
|
||||
if (!InitVariables(s_VariablesFast,sizeof(s_VariablesFast)/sizeof(s_VariablesFast[0])))
|
||||
bSuccess = false;
|
||||
|
||||
if (m_bHardware)
|
||||
{
|
||||
if (!InitVariables(s_VariablesHardware,sizeof(s_VariablesHardware)/sizeof(s_VariablesHardware[0])))
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
if (bSuccess)
|
||||
{
|
||||
m_bInit = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
static char szMessage[] = "Variable init failed, exiting.\n";
|
||||
ConsolePrint(szMessage);
|
||||
AgLog(szMessage);
|
||||
|
||||
ServerCmd( "say <AG Mod> Disconnected for using invalid variable.\n" );
|
||||
ClientCmd( szDisconnect );
|
||||
|
||||
Reset();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AgVariableChecker::Reset()
|
||||
{
|
||||
m_bHardware = false;
|
||||
m_bInit = false;
|
||||
m_bActive = false;
|
||||
m_iViolations = 0;
|
||||
}
|
||||
|
||||
bool AgVariableChecker::Check()
|
||||
{
|
||||
if (!m_bActive)
|
||||
return true;
|
||||
|
||||
if (!m_bInit)
|
||||
{
|
||||
return Init();
|
||||
}
|
||||
|
||||
DWORD dwNow = GetTickCount();
|
||||
if (m_dwNextCheck < dwNow)
|
||||
{
|
||||
CheckVariables(s_Variables,sizeof(s_Variables)/sizeof(s_Variables[0]),m_iViolations);
|
||||
|
||||
if (m_bHardware)
|
||||
CheckVariables(s_VariablesHardware,sizeof(s_VariablesHardware)/sizeof(s_VariablesHardware[0]),m_iViolations);
|
||||
|
||||
if (g_iPure > 1)
|
||||
CheckVariables(s_VariablesPure2,sizeof(s_VariablesPure2)/sizeof(s_VariablesPure2[0]),m_iViolations);
|
||||
|
||||
m_dwNextCheck = dwNow + 500; //500ms for the less important variables.
|
||||
}
|
||||
|
||||
if (m_dwNextCheckFast < dwNow)
|
||||
{
|
||||
CheckVariables(s_VariablesFast,sizeof(s_VariablesFast)/sizeof(s_VariablesFast[0]),m_iViolations);
|
||||
m_dwNextCheckFast = dwNow + 150; //150ms for the important variables.
|
||||
}
|
||||
|
||||
if (g_iPure > 2)
|
||||
{
|
||||
if (m_dwNextA3D < dwNow)
|
||||
{
|
||||
CheckVariables(s_VariablesPure3,sizeof(s_VariablesPure3)/sizeof(s_VariablesPure3[0]),m_iViolations);
|
||||
ClientCmd("s_disable_a3d\n");
|
||||
m_dwNextA3D = dwNow + 5000; //5 seconds .
|
||||
}
|
||||
}
|
||||
|
||||
if (m_iViolations > MAX_VIOLATIONS)
|
||||
{
|
||||
static char szMessageServer[] = "say <AG Mod> Disconnected for repeated cvar violations\n";
|
||||
static char szMessage[] = "Cheat check: Disconnected for repeated cvar violations\n";
|
||||
ServerCmd(szMessageServer);
|
||||
AgLog(szMessage);
|
||||
ConsolePrint(szMessage);
|
||||
ClientCmd(szDisconnect);
|
||||
Reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
|
||||
//-- Martin Webrant
|
72
cl_dll/aghl/agvariablechecker.h
Normal file
72
cl_dll/aghl/agvariablechecker.h
Normal file
@ -0,0 +1,72 @@
|
||||
//++ BulliT
|
||||
#if !defined(AFX_AGVARIABLECHECKER_H__73BB9962_9A14_4A89_B856_FEFB40FC1E13__INCLUDED_)
|
||||
#define AFX_AGVARIABLECHECKER_H__73BB9962_9A14_4A89_B856_FEFB40FC1E13__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
class AgVariableChecker
|
||||
{
|
||||
bool m_bActive;
|
||||
bool m_bHardware;
|
||||
bool m_bInit;
|
||||
DWORD m_dwNextCheck;
|
||||
DWORD m_dwNextCheckFast;
|
||||
DWORD m_dwNextA3D;
|
||||
short m_iViolations;
|
||||
void Reset();
|
||||
|
||||
public:
|
||||
AgVariableChecker();
|
||||
virtual ~AgVariableChecker();
|
||||
|
||||
bool Init();
|
||||
bool Check();
|
||||
void Activate();
|
||||
};
|
||||
|
||||
extern AgVariableChecker g_VariableChecker;
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
|
||||
extern int g_iPure;
|
||||
|
||||
extern cvar_t *cl_pitchspeed;
|
||||
inline float ag_cl_pitchspeed()
|
||||
{
|
||||
if (0 < g_iPure)
|
||||
return 255;
|
||||
return cl_pitchspeed->value;
|
||||
}
|
||||
|
||||
extern cvar_t *cl_pitchup;
|
||||
inline float ag_cl_pitchup()
|
||||
{
|
||||
if (0 < g_iPure)
|
||||
return 89;
|
||||
return cl_pitchup->value;
|
||||
}
|
||||
|
||||
extern cvar_t *cl_pitchdown;
|
||||
inline float ag_cl_pitchdown()
|
||||
{
|
||||
if (0 < g_iPure)
|
||||
return 89;
|
||||
return cl_pitchdown->value;
|
||||
}
|
||||
|
||||
extern cvar_t *cl_yawspeed;
|
||||
inline float ag_cl_yawspeed()
|
||||
{
|
||||
if (0 < g_iPure)
|
||||
return 210;
|
||||
return cl_yawspeed->value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // !defined(AFX_AGVARIABLECHECKER_H__73BB9962_9A14_4A89_B856_FEFB40FC1E13__INCLUDED_)
|
||||
//-- Martin Webrant
|
198
cl_dll/aghl/agversioninfo.cpp
Normal file
198
cl_dll/aghl/agversioninfo.cpp
Normal file
@ -0,0 +1,198 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
#include "AgGlobal.h"
|
||||
#include "AgVersionInfo.h"
|
||||
|
||||
#pragma comment(lib,"version.lib")
|
||||
|
||||
DWORD AgVersionInfo::SetError()
|
||||
{
|
||||
m_dwLastError = ::GetLastError();
|
||||
if (0 == m_dwLastError)
|
||||
m_dwLastError = (DWORD)-1;
|
||||
return m_dwLastError;
|
||||
}
|
||||
|
||||
DWORD AgVersionInfo::LoadVersionInfo(LPCSTR pszFileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
// get size of fileversion
|
||||
DWORD dwLen = ::GetFileVersionInfoSize((LPTSTR)pszFileName,&m_dwHandle);
|
||||
|
||||
if (0 == dwLen)
|
||||
return SetError();
|
||||
|
||||
// get data-info
|
||||
m_pszData = (char*)malloc(dwLen+16);
|
||||
BOOL bRet = ::GetFileVersionInfo((LPTSTR)pszFileName,m_dwHandle,dwLen,m_pszData);
|
||||
|
||||
if (!bRet)
|
||||
{
|
||||
//assert(FALSE);
|
||||
return SetError();
|
||||
}
|
||||
|
||||
// get VS_FIXEDFILEINFO struct
|
||||
|
||||
VS_FIXEDFILEINFO* pInfo = NULL;
|
||||
UINT uiSize = 0;
|
||||
|
||||
if (!::VerQueryValue((BYTE*)(LPCSTR)m_pszData,"\\",(LPVOID*)&pInfo,&uiSize))
|
||||
{
|
||||
//assert(FALSE);
|
||||
return SetError();
|
||||
}
|
||||
|
||||
// did we get something?
|
||||
|
||||
if (uiSize != sizeof(m_ffi))
|
||||
{
|
||||
//assert(FALSE);
|
||||
return SetError();
|
||||
}
|
||||
|
||||
// does the structure have correct signature and version?
|
||||
|
||||
if (VS_FFI_SIGNATURE != pInfo->dwSignature || VS_FFI_STRUCVERSION != pInfo->dwStrucVersion)
|
||||
{
|
||||
//assert(FALSE);
|
||||
return SetError();
|
||||
}
|
||||
|
||||
// everything ok, copy to our member-struct
|
||||
|
||||
memcpy(&m_ffi,pInfo,uiSize);
|
||||
|
||||
m_dwLastError = 0;
|
||||
return m_dwLastError;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
AgLog("LoadVersionInfo failed");
|
||||
return SetError();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL AgVersionInfo::FileVersion(int& iMajor,int& iMinor,int& iMicro,int& iState) const
|
||||
{
|
||||
//assert(!HasErrors());
|
||||
|
||||
if (HasErrors())
|
||||
return FALSE;
|
||||
|
||||
iMajor = (int)(HIWORD(m_ffi.dwFileVersionMS));
|
||||
iMinor = (int)(LOWORD(m_ffi.dwFileVersionMS));
|
||||
iMicro = (int)(HIWORD(m_ffi.dwFileVersionLS));
|
||||
iState = (int)(LOWORD(m_ffi.dwFileVersionLS));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL AgVersionInfo::ProductVersion(int& iMajor,int& iMinor,int& iMicro,int& iState) const
|
||||
{
|
||||
//assert(!HasErrors());
|
||||
|
||||
if (HasErrors())
|
||||
return FALSE;
|
||||
|
||||
iMajor = (int)(HIWORD(m_ffi.dwProductVersionMS));
|
||||
iMinor = (int)(LOWORD(m_ffi.dwProductVersionMS));
|
||||
iMicro = (int)(HIWORD(m_ffi.dwProductVersionLS));
|
||||
iState = (int)(LOWORD(m_ffi.dwProductVersionLS));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const char* AgVersionInfo::GetTextData(LPCSTR pszParameter,DWORD dwLanguage)
|
||||
{
|
||||
static char szParam[MAX_PATH];
|
||||
|
||||
// must have been initialized properly
|
||||
|
||||
assert(!HasErrors());
|
||||
|
||||
if (HasErrors())
|
||||
return "";
|
||||
|
||||
LPVOID pInfo;
|
||||
UINT uiSize;
|
||||
|
||||
if (-1 == dwLanguage)
|
||||
{
|
||||
if (-1 == m_dwDefaultLang)
|
||||
{
|
||||
// get translation table pointer
|
||||
|
||||
pInfo = NULL;
|
||||
uiSize = 0;
|
||||
|
||||
if (!::VerQueryValue((BYTE*)(LPCSTR)m_pszData,"\\VarFileInfo\\Translation",&pInfo,&uiSize))
|
||||
{
|
||||
//SetError();
|
||||
//assert(FALSE);
|
||||
return "";
|
||||
}
|
||||
|
||||
// did we get it?
|
||||
|
||||
if (0 == uiSize)
|
||||
{
|
||||
SetError();
|
||||
assert(FALSE);
|
||||
return "";
|
||||
}
|
||||
|
||||
m_dwDefaultLang = *((DWORD*)pInfo);
|
||||
}
|
||||
|
||||
dwLanguage = m_dwDefaultLang;
|
||||
}
|
||||
|
||||
// get the parameter
|
||||
|
||||
pInfo = NULL;
|
||||
uiSize = 0;
|
||||
|
||||
m_dwLastError = 0;
|
||||
|
||||
sprintf(szParam,"\\StringFileInfo\\%04x%04x\\%s",LOWORD(dwLanguage),HIWORD(dwLanguage),pszParameter);
|
||||
|
||||
if (!::VerQueryValue((BYTE*)(LPCSTR)m_pszData,szParam,&pInfo,&uiSize))
|
||||
return ""; // the parameter is currently not defined
|
||||
|
||||
// is parameter-value an empty-string?
|
||||
|
||||
if (0 == uiSize)
|
||||
return "";
|
||||
|
||||
// copy the value to our own string
|
||||
|
||||
memcpy(szParam,(LPBYTE)pInfo,uiSize);
|
||||
return szParam;
|
||||
}
|
||||
|
||||
|
||||
BOOL AgVersionInfo::IsRequiredVersion(int iReqMajor, int iReqMinor, int iReqMicro) const
|
||||
{
|
||||
assert(!HasErrors());
|
||||
|
||||
if (HasErrors())
|
||||
return FALSE;
|
||||
|
||||
int iMajor, iMinor, iMicro, iState;
|
||||
iMajor = iMinor = iMicro = iState = 0;
|
||||
FileVersion(iMajor, iMinor, iMicro, iState);
|
||||
|
||||
if ((iMajor == iReqMajor && iMinor == iReqMinor && iMicro >= iReqMicro) ||
|
||||
iMajor == iReqMajor && iMinor > iReqMinor ||
|
||||
iMajor > iReqMajor)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
169
cl_dll/aghl/agversioninfo.h
Normal file
169
cl_dll/aghl/agversioninfo.h
Normal file
@ -0,0 +1,169 @@
|
||||
#ifndef __AG_VERSION_INFO_H__
|
||||
#define __AG_VERSION_INFO_H__
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
class AgVersionInfo
|
||||
{
|
||||
public:
|
||||
|
||||
// Constructs the class.
|
||||
AgVersionInfo();
|
||||
virtual ~AgVersionInfo();
|
||||
|
||||
// Load versioninfo.
|
||||
DWORD LoadVersionInfo(LPCSTR pszFileName); // Load versioninfo on a file.
|
||||
|
||||
BOOL HasErrors() const; // Returns TRUE if versioninfo could not be retrivied.
|
||||
DWORD GetLastError() const; // Returns the windows errorcode.
|
||||
|
||||
// language independant data
|
||||
|
||||
// Get the fileversion.
|
||||
BOOL FileVersion(int& iMajor,int& iMinor,int& iMicro,int& iState) const; // Get the fileversion.
|
||||
// Get the productversion.
|
||||
BOOL ProductVersion(int& iMajor,int& iMinor,int& iMicro,int& iState) const; // Get the productversion.
|
||||
|
||||
BOOL IsDebugBuild() const; // Returns TRUE if the file contains debugging information or is compiled with debugging features enabled.
|
||||
BOOL IsInfoInferred() const; // Returns TRUE if the file's version structure was created dynamically; therefore, some of the members in this class may be empty or incorrect.
|
||||
BOOL IsPatched() const; // Returns TRUE if the file has been modified and is not identical to the original shipping file of the same version number.
|
||||
BOOL IsPreRelease() const; // Returns TRUE if the file is a development version, not a commercially released product.
|
||||
BOOL IsPrivateBuild() const; // Returns TRUE if the file was not built using standard release procedures.
|
||||
BOOL IsSpecialBuild() const; // Returns TRUE if the file was built by the original company using standard release procedures but is a variation of the normal file of the same version number.
|
||||
|
||||
DWORD FileFlag() const; // Returns a bitmask that specifies the Boolean attributes of the file. Use IsXXXX functions instead.
|
||||
DWORD OSFlag() const; // Returns: VOS_NT The file was designed for Windows NT. VOS__WINDOWS32 The file was designed for the Win32 API. For more flags see dwFileOS variable for VS_FIXEDFILEINFO in MSDN.
|
||||
DWORD TypeFlag() const; // Returns: VFT_APP The file contains an application. VFT_DLL The file contains a dynamic-link library (DLL). For more flags see dwFileType variable for VS_FIXEDFILEINFO in MSDN.
|
||||
DWORD SubtypeFlag() const; // Returns: See dwFileSubtype variable for VS_FIXEDFILEINFO in MSDN.
|
||||
|
||||
BOOL IsRequiredVersion(int iReqMajor, int iReqMinor = 0, int iReqMicro = 0) const; // Returns TRUE if the file has the required version or is newer.
|
||||
|
||||
// language dependant data
|
||||
|
||||
const char* Comments( DWORD dwLanguage = -1L); // Returns additional information that should be displayed for diagnostic purposes.
|
||||
const char* CompanyName( DWORD dwLanguage = -1L); // Returns the company that produced the file. For example, "Microsoft Corporation" or "ADRA Datasystem AB (publ)."
|
||||
const char* FileDescription( DWORD dwLanguage = -1L); // Returns the description in such a way that it can be presented to users. This string may be presented in a list box when the user is choosing files to install. For example, "ViewLine" or "Microsoft Word for Windows".
|
||||
const char* FileVersion( DWORD dwLanguage = -1L); // Returns the version of this file. For example, "3.00.001R" or "5.00.RC2".
|
||||
const char* InternalName( DWORD dwLanguage = -1L); // Returns the files internal name. For example. "UDIMEAS" or "WINWORD"
|
||||
const char* LegalCopyright( DWORD dwLanguage = -1L); // Returns all copyright notices, trademarks, and registered trademarks that apply to the file. For example "Copyright © ADRA Datasystem AB (publ) 1997- 1998"
|
||||
const char* LegalTrademarks( DWORD dwLanguage = -1L); // Returns all trademarks and registered trademarks that apply to the file. This should include the full text of all notices, legal symbols, trademark numbers, and so on. In English, this string should be in the format "UDIBAS is a trademark of ADRA Datasystem AB.".
|
||||
const char* OriginalFileName(DWORD dwLanguage = -1L); // Returns identifies the original name of the file, not including a path. This enables an application to determine whether a file has been renamed by a user.
|
||||
const char* PrivateBuild( DWORD dwLanguage = -1L); // Returns whom, where, and why this private version of the file was built.
|
||||
const char* ProductName( DWORD dwLanguage = -1L); // Returns the name of the product with which this file is distributed. For example, this string could be "Microsoft Windows".
|
||||
const char* ProductVersion( DWORD dwLanguage = -1L); // Returns the version of the product with which this file is distributed. For example, "3.00.001R" or "5.00.RC2".
|
||||
const char* SpecialBuild( DWORD dwLanguage = -1L); // Returns a description how this version of the file differs from the normal version.
|
||||
|
||||
const char* GetTextData(LPCSTR pszParameter,DWORD dwLanguage = -1L); // Do a VerQueryValue for a paramater. For example "ProductVersion".
|
||||
|
||||
protected:
|
||||
|
||||
void Init();
|
||||
DWORD SetError();
|
||||
|
||||
DWORD m_dwHandle;
|
||||
char* m_pszData;
|
||||
DWORD m_dwDefaultLang;
|
||||
VS_FIXEDFILEINFO m_ffi;
|
||||
DWORD m_dwLastError;
|
||||
};
|
||||
|
||||
// AgVersionInfo inlines //
|
||||
|
||||
inline void AgVersionInfo::Init()
|
||||
{ m_dwLastError = (DWORD)-1; m_dwDefaultLang = (DWORD)-1; m_dwHandle = (DWORD)0; memset(&m_ffi,'\0',sizeof(m_ffi)); m_pszData = NULL; }
|
||||
|
||||
inline AgVersionInfo::AgVersionInfo()
|
||||
{ Init(); }
|
||||
|
||||
inline AgVersionInfo::~AgVersionInfo()
|
||||
{
|
||||
if (m_pszData)
|
||||
free(m_pszData);
|
||||
}
|
||||
|
||||
inline BOOL AgVersionInfo::HasErrors() const
|
||||
{ return (0 != GetLastError()); }
|
||||
|
||||
inline DWORD AgVersionInfo::GetLastError() const
|
||||
{ return m_dwLastError; }
|
||||
|
||||
inline BOOL AgVersionInfo::IsDebugBuild() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return ( 0 != (VS_FF_DEBUG & FileFlag())); }
|
||||
|
||||
inline BOOL AgVersionInfo::IsInfoInferred() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return ( 0 != (VS_FF_INFOINFERRED & FileFlag())); }
|
||||
|
||||
inline BOOL AgVersionInfo::IsPatched() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return ( 0 != (VS_FF_PATCHED & FileFlag())); }
|
||||
|
||||
inline BOOL AgVersionInfo::IsPreRelease() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return ( 0 != (VS_FF_PRERELEASE & FileFlag())); }
|
||||
|
||||
inline BOOL AgVersionInfo::IsPrivateBuild() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return ( 0 != (VS_FF_PRIVATEBUILD & FileFlag())); }
|
||||
|
||||
inline BOOL AgVersionInfo::IsSpecialBuild() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return ( 0 != (VS_FF_SPECIALBUILD & FileFlag())); }
|
||||
|
||||
inline DWORD AgVersionInfo::FileFlag() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return (m_ffi.dwFileFlagsMask & m_ffi.dwFileFlags); }
|
||||
|
||||
inline DWORD AgVersionInfo::OSFlag() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return m_ffi.dwFileOS; }
|
||||
|
||||
inline DWORD AgVersionInfo::TypeFlag() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return m_ffi.dwFileType; }
|
||||
|
||||
inline DWORD AgVersionInfo::SubtypeFlag() const
|
||||
{ //AFC_ASSERT(!HasErrors());
|
||||
return m_ffi.dwFileSubtype; }
|
||||
|
||||
inline const char* AgVersionInfo::Comments(DWORD dwLanguage)
|
||||
{ return GetTextData("Comments",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::CompanyName(DWORD dwLanguage)
|
||||
{ return GetTextData("CompanyName",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::FileDescription(DWORD dwLanguage)
|
||||
{ return GetTextData("FileDescription",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::FileVersion(DWORD dwLanguage)
|
||||
{ return GetTextData("FileVersion",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::InternalName(DWORD dwLanguage)
|
||||
{ return GetTextData("InternalName",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::LegalCopyright(DWORD dwLanguage)
|
||||
{ return GetTextData("LegalCopyright",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::LegalTrademarks(DWORD dwLanguage)
|
||||
{ return GetTextData("LegalTrademarks",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::OriginalFileName(DWORD dwLanguage)
|
||||
{ return GetTextData("OriginalFileName",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::PrivateBuild(DWORD dwLanguage)
|
||||
{ return GetTextData("PrivateBuild",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::ProductName(DWORD dwLanguage)
|
||||
{ return GetTextData("ProductName",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::ProductVersion(DWORD dwLanguage)
|
||||
{ return GetTextData("ProductVersion",dwLanguage); }
|
||||
|
||||
inline const char* AgVersionInfo::SpecialBuild(DWORD dwLanguage)
|
||||
{ return GetTextData("SpecialBuild",dwLanguage); }
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
|
||||
|
||||
#endif //__AG_VERSION_INFO_H__
|
241
cl_dll/aghl/agvguiirc.cpp
Normal file
241
cl_dll/aghl/agvguiirc.cpp
Normal file
@ -0,0 +1,241 @@
|
||||
//++ BulliT
|
||||
|
||||
#include<VGUI_HeaderPanel.h>
|
||||
#include<VGUI_TablePanel.h>
|
||||
#include<VGUI_LineBorder.h>
|
||||
#include<VGUI_Label.h>
|
||||
#include<VGUI_Button.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include<VGUI_TextGrid.h>
|
||||
#include<VGUI_TextEntry.h>
|
||||
#include<VGUI_EtchedBorder.h>
|
||||
#include<VGUI_LoweredBorder.h>
|
||||
#include "VGUI_ScrollPanel.h"
|
||||
#include "VGUI_TextImage.h"
|
||||
#include<VGUI_StackLayout.h>
|
||||
#include<VGUI_EditPanel.h>
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <keydefs.h>
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "AGVGuiIRC.h"
|
||||
|
||||
extern /*irc::*/CIrcSession g_ircSession;
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class TextHandler : public ActionSignal
|
||||
{
|
||||
private:
|
||||
|
||||
AGVGuiIRC* _AGVGuiIRC;
|
||||
|
||||
public:
|
||||
|
||||
TextHandler(AGVGuiIRC* AGVGuiIRC)
|
||||
{
|
||||
_AGVGuiIRC=AGVGuiIRC;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_AGVGuiIRC->doExecCommand();
|
||||
}
|
||||
};
|
||||
|
||||
class ConnectHandler : public ActionSignal
|
||||
{
|
||||
private:
|
||||
|
||||
AGVGuiIRC* _AGVGuiIRC;
|
||||
|
||||
public:
|
||||
|
||||
ConnectHandler(AGVGuiIRC* AGVGuiIRC)
|
||||
{
|
||||
_AGVGuiIRC=AGVGuiIRC;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
_AGVGuiIRC->doConnectCommand();
|
||||
}
|
||||
};
|
||||
|
||||
class CloseHandler : public ActionSignal
|
||||
{
|
||||
public:
|
||||
CloseHandler()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
gViewPort->ToggleIRC();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class TextInput : public vgui::TextEntry
|
||||
{
|
||||
public:
|
||||
TextInput(const char* text,int x,int y,int wide,int tall) : TextEntry(text,x,y,wide,tall)
|
||||
{
|
||||
};
|
||||
|
||||
virtual void keyPressed(KeyCode code,Panel* panel)
|
||||
{
|
||||
if (gViewPort->m_pIRC->isVisible())
|
||||
TextEntry::keyPressed(code,panel);
|
||||
};
|
||||
virtual void keyTyped(KeyCode code,Panel* panel)
|
||||
{
|
||||
if (gViewPort->m_pIRC->isVisible())
|
||||
TextEntry::keyTyped(code,panel);
|
||||
};
|
||||
virtual void keyReleased(KeyCode code,Panel* panel)
|
||||
{
|
||||
if (gViewPort->m_pIRC->isVisible())
|
||||
TextEntry::keyReleased(code,panel);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#define IRC_TITLE_X XRES(16)
|
||||
#define IRC_TITLE_Y YRES(16)
|
||||
#define TEXT_SIZE_Y YRES(16)
|
||||
|
||||
AGVGuiIRC::AGVGuiIRC(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0)) );
|
||||
|
||||
// Get the scheme used for the Titles
|
||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
||||
|
||||
// schemes
|
||||
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
|
||||
SchemeHandle_t hIRCText = pSchemes->getSchemeHandle( "Briefing Text" );
|
||||
|
||||
// color schemes
|
||||
int r, g, b, a;
|
||||
|
||||
// Create the title
|
||||
Label *pLabel = new Label( "", IRC_TITLE_X, IRC_TITLE_Y );
|
||||
pLabel->setParent( this );
|
||||
pLabel->setFont( pSchemes->getFont(hTitleScheme) );
|
||||
pLabel->setFont( Scheme::sf_primary1 );
|
||||
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
pLabel->setFgColor( r, g, b, a );
|
||||
pLabel->setFgColor( Scheme::sc_primary1 );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
pLabel->setBgColor( r, g, b, a );
|
||||
pLabel->setContentAlignment( vgui::Label::a_west );
|
||||
pLabel->setText("AG IRC Client");
|
||||
|
||||
int iXSize,iYSize;
|
||||
getSize( iXSize,iYSize );
|
||||
|
||||
// Create the text panel
|
||||
m_pTextPanel = new TextPanel( "", XRES(16), IRC_TITLE_Y*2 + YRES(16), iXSize - XRES(32), iYSize - (YRES(48) + BUTTON_SIZE_Y*2 + TEXT_SIZE_Y*2));
|
||||
m_pTextPanel->setParent( this);
|
||||
|
||||
// get the font and colors from the scheme
|
||||
m_pTextPanel->setFont( pSchemes->getFont(hIRCText) );
|
||||
pSchemes->getFgColor( hIRCText, r, g, b, a );
|
||||
m_pTextPanel->setFgColor( r, g, b, a );
|
||||
pSchemes->getBgColor( hIRCText, r, g, b, a );
|
||||
m_pTextPanel->setBgColor( r, g, b, a );
|
||||
|
||||
int iTemp = iYSize - YRES(24) - TEXT_SIZE_Y - BUTTON_SIZE_Y; //Hack to get it to work with Visual 7.0 beta 2
|
||||
m_pTextEntry = new TextInput("",XRES(16), iTemp, iXSize - 2*XRES(16), TEXT_SIZE_Y);
|
||||
m_pTextEntry->setParent(this);
|
||||
m_pTextEntry->addActionSignal(new TextHandler(this));
|
||||
|
||||
m_pConnect = new CommandButton("",XRES(16), iYSize - YRES(16) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y);
|
||||
m_pConnect->addActionSignal(new ConnectHandler(this));
|
||||
m_pConnect->setParent(this);
|
||||
|
||||
CommandButton* pClose = new CommandButton("Close",iXSize - XRES(16) - CMENU_SIZE_X, iYSize - YRES(16) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y);
|
||||
pClose->addActionSignal(new CloseHandler());
|
||||
pClose->setParent(this);
|
||||
}
|
||||
|
||||
void AGVGuiIRC::doExecCommand()
|
||||
{
|
||||
char buf[2048];
|
||||
strcpy(buf,"irc ");
|
||||
m_pTextEntry->getText(0,buf+4,2040);
|
||||
m_pTextEntry->setText(null,0);
|
||||
|
||||
gEngfuncs.pfnClientCmd(buf);
|
||||
}
|
||||
|
||||
void AGVGuiIRC::doConnectCommand()
|
||||
{
|
||||
m_sText = "";
|
||||
m_pTextPanel->setText(m_sText.c_str());
|
||||
gEngfuncs.pfnClientCmd(g_ircSession ? "ircdisconnect" : "ircconnect");
|
||||
}
|
||||
|
||||
void AGVGuiIRC::paintBackground()
|
||||
{
|
||||
// Transparent black background
|
||||
drawSetColor( 0,0,0, 100 );
|
||||
drawFilledRect(0,0,_size[0],_size[1]);
|
||||
if (g_ircSession)
|
||||
m_pConnect->setText("Disconnect");
|
||||
else
|
||||
m_pConnect->setText("Connect");
|
||||
}
|
||||
|
||||
int AGVGuiIRC::KeyInput(int down, int keynum, const char *pszCurrentBinding)
|
||||
{
|
||||
if (!down)
|
||||
return 1;
|
||||
|
||||
if (!isVisible())
|
||||
return 1;
|
||||
|
||||
if (K_ESCAPE == keynum || pszCurrentBinding && 0 == _stricmp("toggleirc",pszCurrentBinding))
|
||||
{
|
||||
gViewPort->ToggleIRC();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (m_pTextEntry->hasFocus())
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AGVGuiIRC::PrintMessage(const char* pszText)
|
||||
{
|
||||
int iWide,iTall;
|
||||
m_pTextPanel->getSize(iWide,iTall);
|
||||
int iTextWide,iTextTall;
|
||||
m_pTextPanel->getTextImage()->getTextSizeWrapped(iTextWide,iTextTall);
|
||||
if ((iTextTall + 20) > iTall)
|
||||
{
|
||||
int iFind = m_sText.find("\n");
|
||||
if (NPOS != iFind)
|
||||
{
|
||||
m_sText = m_sText.substr(iFind+1);
|
||||
}
|
||||
}
|
||||
|
||||
m_sText += pszText;
|
||||
m_sText += "\n";
|
||||
m_pTextPanel->setText(m_sText.c_str());
|
||||
}
|
||||
|
||||
//-- Martin Webrant
|
38
cl_dll/aghl/agvguiirc.h
Normal file
38
cl_dll/aghl/agvguiirc.h
Normal file
@ -0,0 +1,38 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_VGUI_IRC_)
|
||||
#define _AG_VGUI_IRC_
|
||||
|
||||
#include<stdarg.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class TextEntry;
|
||||
class TextPanel;
|
||||
class EditPanel;
|
||||
}
|
||||
|
||||
class AGVGuiIRC : public vgui::Panel
|
||||
{
|
||||
private:
|
||||
vgui::TextEntry* m_pTextEntry;
|
||||
vgui::TextPanel* m_pTextPanel;
|
||||
CommandButton* m_pConnect;
|
||||
|
||||
AgString m_sText;
|
||||
|
||||
public:
|
||||
AGVGuiIRC(int x,int y,int wide,int tall);
|
||||
public:
|
||||
virtual void doExecCommand();
|
||||
virtual void doConnectCommand();
|
||||
virtual void paintBackground();
|
||||
|
||||
virtual int KeyInput(int down, int keynum, const char *pszCurrentBinding);
|
||||
void PrintMessage(const char* pszText);
|
||||
};
|
||||
|
||||
#endif //_AG_VGUI_IRC_
|
||||
|
||||
//-- Martin Webrant
|
270
cl_dll/aghl/agvguiwinamp.cpp
Normal file
270
cl_dll/aghl/agvguiwinamp.cpp
Normal file
@ -0,0 +1,270 @@
|
||||
//++ BulliT
|
||||
|
||||
#include<VGUI_HeaderPanel.h>
|
||||
#include<VGUI_TablePanel.h>
|
||||
#include<VGUI_LineBorder.h>
|
||||
#include<VGUI_Label.h>
|
||||
#include<VGUI_Button.h>
|
||||
#include<VGUI_ActionSignal.h>
|
||||
#include<VGUI_TextGrid.h>
|
||||
#include<VGUI_TextEntry.h>
|
||||
#include<VGUI_EtchedBorder.h>
|
||||
#include<VGUI_LoweredBorder.h>
|
||||
#include "VGUI_ScrollPanel.h"
|
||||
#include "VGUI_TextImage.h"
|
||||
#include<VGUI_StackLayout.h>
|
||||
#include<VGUI_EditPanel.h>
|
||||
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include <keydefs.h>
|
||||
#include "vgui_TeamFortressViewport.h"
|
||||
#include "AGVGuiWinamp.h"
|
||||
|
||||
static HWND hwnd = NULL;
|
||||
|
||||
struct WINAMP
|
||||
{
|
||||
char szCommand[16];
|
||||
UINT uiMessage;
|
||||
char szCommandButton[16];
|
||||
};
|
||||
|
||||
static WINAMP s_Commands[]=
|
||||
{
|
||||
"play" ,40045, "Play",
|
||||
"pause" ,40046, "Pause",
|
||||
"stop" ,40047, "Stop",
|
||||
"next" ,40048, "Next Track",
|
||||
"prev" ,40044, "Previous Track",
|
||||
"playcd" ,40323, "Play CD",
|
||||
"increase" ,40058, "Increase Vol.",
|
||||
"decrease" ,40059, "Decrease Vol.",
|
||||
"repeat" ,40022, "Toggle Repeat",
|
||||
"shuffle" ,40023, "Toggle Shuffle",
|
||||
"forward" ,40148, "Fast Forward",
|
||||
"rewind" ,40144, "Fast Rewind",
|
||||
};
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace
|
||||
{
|
||||
class WinampCommandHandler : public ActionSignal
|
||||
{
|
||||
private:
|
||||
char m_szCommand[256];
|
||||
public:
|
||||
WinampCommandHandler(const char* szCommand)
|
||||
{
|
||||
strcpy(m_szCommand,szCommand);
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
gEngfuncs.pfnClientCmd(m_szCommand);
|
||||
}
|
||||
};
|
||||
|
||||
class CloseHandler : public ActionSignal
|
||||
{
|
||||
public:
|
||||
CloseHandler()
|
||||
{
|
||||
}
|
||||
public:
|
||||
virtual void actionPerformed(Panel* panel)
|
||||
{
|
||||
gViewPort->ToggleWinamp();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#define WINAMP_TITLE_X XRES(16)
|
||||
#define WINAMP_TITLE_Y YRES(16)
|
||||
|
||||
#define WINAMP_TOPLEFT_BUTTON_X XRES(80)
|
||||
#define WINAMP_TOPLEFT_BUTTON_Y YRES(60)
|
||||
#define WINAMP_BUTTON_SIZE_X XRES(124)
|
||||
#define WINAMP_BUTTON_SIZE_Y YRES(24)
|
||||
#define WINAMP_BUTTON_SPACER_Y YRES(8)
|
||||
#define WINAMP_BUTTON_SPACER_X XRES(8)
|
||||
|
||||
AGVGuiWinamp::AGVGuiWinamp(int x,int y,int wide,int tall) : Panel(x,y,wide,tall)
|
||||
{
|
||||
setBorder( new LineBorder( Color(255 * 0.7,170 * 0.7,0,0)) );
|
||||
|
||||
// Get the scheme used for the Titles
|
||||
CSchemeManager *pSchemes = gViewPort->GetSchemeManager();
|
||||
|
||||
// schemes
|
||||
SchemeHandle_t hTitleScheme = pSchemes->getSchemeHandle( "Title Font" );
|
||||
// SchemeHandle_t hIRCText = pSchemes->getSchemeHandle( "Briefing Text" );
|
||||
|
||||
// color schemes
|
||||
int r, g, b, a;
|
||||
|
||||
// Create the title
|
||||
m_pLabel = new Label( "AG Winamp", WINAMP_TITLE_X, WINAMP_TITLE_Y );
|
||||
m_pLabel->setParent( this );
|
||||
m_pLabel->setFont( pSchemes->getFont(hTitleScheme) );
|
||||
m_pLabel->setFont( Scheme::sf_primary1 );
|
||||
|
||||
pSchemes->getFgColor( hTitleScheme, r, g, b, a );
|
||||
m_pLabel->setFgColor( r, g, b, a );
|
||||
m_pLabel->setFgColor( Scheme::sc_primary1 );
|
||||
pSchemes->getBgColor( hTitleScheme, r, g, b, a );
|
||||
m_pLabel->setBgColor( r, g, b, a );
|
||||
m_pLabel->setContentAlignment( vgui::Label::a_west );
|
||||
m_pLabel->setText("AG Winamp");
|
||||
|
||||
int iXSize,iYSize;
|
||||
getSize( iXSize,iYSize );
|
||||
|
||||
for (int i = 0; i < sizeof(s_Commands)/sizeof(s_Commands[0]); i++)
|
||||
{
|
||||
char szCommand[256];
|
||||
sprintf(szCommand,"winamp %s",s_Commands[i].szCommand);
|
||||
|
||||
int iXPos = WINAMP_TOPLEFT_BUTTON_X;
|
||||
int iYPos = WINAMP_TOPLEFT_BUTTON_Y + ( (WINAMP_BUTTON_SIZE_Y + WINAMP_BUTTON_SPACER_Y) * i );
|
||||
if (i > 5)
|
||||
{
|
||||
iXPos += WINAMP_BUTTON_SIZE_X + WINAMP_BUTTON_SPACER_X;
|
||||
iYPos = WINAMP_TOPLEFT_BUTTON_Y + ( (WINAMP_BUTTON_SIZE_Y + WINAMP_BUTTON_SPACER_Y) * (i-6) );
|
||||
}
|
||||
|
||||
CommandButton* pPlay = new CommandButton(s_Commands[i].szCommandButton,iXPos, iYPos, WINAMP_BUTTON_SIZE_X, WINAMP_BUTTON_SIZE_Y);
|
||||
pPlay->addActionSignal(new WinampCommandHandler(szCommand));
|
||||
pPlay->setParent(this);
|
||||
}
|
||||
|
||||
CommandButton* pClose = new CommandButton("Close",iXSize - XRES(16) - CMENU_SIZE_X, iYSize - YRES(16) - BUTTON_SIZE_Y, CMENU_SIZE_X, BUTTON_SIZE_Y);
|
||||
pClose->addActionSignal(new CloseHandler());
|
||||
pClose->setParent(this);
|
||||
}
|
||||
|
||||
void GetSongTitle(LPSTR pszSong, int iSize)
|
||||
{
|
||||
GetWindowText(hwnd,pszSong,iSize);
|
||||
char* p = pszSong + strlen(pszSong)-8;
|
||||
while (p >= pszSong)
|
||||
{
|
||||
if (!strnicmp(p,"- Winamp",8))
|
||||
break;
|
||||
p--;
|
||||
}
|
||||
if (p >= pszSong)
|
||||
p--;
|
||||
while (p >= pszSong && *p == ' ')
|
||||
p--;
|
||||
*++p = 0;
|
||||
}
|
||||
|
||||
static DWORD dwTime = 0;
|
||||
void AGVGuiWinamp::paintBackground()
|
||||
{
|
||||
// Transparent black background
|
||||
drawSetColor( 0,0,0, 100 );
|
||||
drawFilledRect(0,0,_size[0],_size[1]);
|
||||
|
||||
if (NULL == hwnd)
|
||||
return;
|
||||
|
||||
if (dwTime > GetTickCount())
|
||||
return;
|
||||
|
||||
char szSong[2048];
|
||||
GetSongTitle(szSong,sizeof(szSong));
|
||||
if (0 == strlen(szSong))
|
||||
{
|
||||
dwTime = GetTickCount() + 10000;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pLabel->setText(szSong);
|
||||
dwTime = GetTickCount() + 1000;
|
||||
}
|
||||
}
|
||||
|
||||
void AGVGuiWinamp::UserCmd_Winamp()
|
||||
{
|
||||
if (NULL == hwnd)
|
||||
hwnd = FindWindow("Winamp v1.x",NULL);
|
||||
|
||||
if (!::IsWindow(hwnd))
|
||||
{
|
||||
ConsolePrint("Could not find Winamp window.\n");
|
||||
hwnd = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (gEngfuncs.Cmd_Argc() == 1)
|
||||
{
|
||||
char szSong[2048];
|
||||
GetSongTitle(szSong,sizeof(szSong));
|
||||
strcat(szSong,"\n");
|
||||
ConsolePrint(szSong);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gEngfuncs.Cmd_Argc() < 2)
|
||||
return;
|
||||
|
||||
if (3 == gEngfuncs.Cmd_Argc() && 0 == strcmp("volume",gEngfuncs.Cmd_Argv(1)))
|
||||
{
|
||||
PostMessage(hwnd,WM_USER,atoi(gEngfuncs.Cmd_Argv(2)),122);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < sizeof(s_Commands)/sizeof(s_Commands[0]); i++)
|
||||
{
|
||||
if (0 == strcmp(s_Commands[i].szCommand,gEngfuncs.Cmd_Argv(1)))
|
||||
{
|
||||
PostMessage(hwnd,WM_COMMAND,s_Commands[i].uiMessage,0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int AGVGuiWinamp::KeyInput(int down, int keynum, const char *pszCurrentBinding)
|
||||
{
|
||||
if (!down)
|
||||
return 1;
|
||||
|
||||
if (!isVisible())
|
||||
return 1;
|
||||
|
||||
if (K_ESCAPE == keynum || pszCurrentBinding && 0 == _stricmp("togglewinamp",pszCurrentBinding))
|
||||
{
|
||||
gViewPort->ToggleWinamp();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (K_MWHEELUP == keynum || K_MWHEELDOWN == keynum)
|
||||
{
|
||||
if (NULL == hwnd)
|
||||
hwnd = FindWindow("Winamp v1.x",NULL);
|
||||
|
||||
if (!::IsWindow(hwnd))
|
||||
{
|
||||
ConsolePrint("Could not find Winamp window.\n");
|
||||
hwnd = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (K_MWHEELUP == keynum)
|
||||
PostMessage(hwnd,WM_COMMAND,40058,0);
|
||||
else
|
||||
PostMessage(hwnd,WM_COMMAND,40059,0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-- Martin Webrant
|
23
cl_dll/aghl/agvguiwinamp.h
Normal file
23
cl_dll/aghl/agvguiwinamp.h
Normal file
@ -0,0 +1,23 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(_AG_VGUI_WINAMP_)
|
||||
#define _AG_VGUI_WINAMP_
|
||||
|
||||
#include<stdarg.h>
|
||||
#include<VGUI_Panel.h>
|
||||
|
||||
class AGVGuiWinamp : public vgui::Panel
|
||||
{
|
||||
private:
|
||||
Label* m_pLabel;
|
||||
public:
|
||||
AGVGuiWinamp(int x,int y,int wide,int tall);
|
||||
public:
|
||||
void UserCmd_Winamp();
|
||||
virtual void paintBackground();
|
||||
virtual int KeyInput(int down, int keynum, const char *pszCurrentBinding);
|
||||
};
|
||||
|
||||
#endif //_AG_VGUI_WINAMP_
|
||||
|
||||
//-- Martin Webrant
|
732
cl_dll/aghl/agwallhack.cpp
Normal file
732
cl_dll/aghl/agwallhack.cpp
Normal file
@ -0,0 +1,732 @@
|
||||
//++ BulliT
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
#include "AgWallhack.h"
|
||||
#include "AgVersionInfo.h"
|
||||
#include "com_weapons.h"
|
||||
#include "agbase64.h"
|
||||
#include "agmapi.h"
|
||||
#include "agicq.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
bool CheckHooks(const char* pszModule, const char* pszMethod, BYTE* pBytesToCheck, DWORD dwSize)
|
||||
{
|
||||
bool bOK = false;
|
||||
HANDLE hProcess = ::GetCurrentProcess();
|
||||
HMODULE hModule = ::GetModuleHandle(pszModule);
|
||||
if (!hModule)
|
||||
return true; //The dll aint loaded
|
||||
LPVOID pAddress = ::GetProcAddress(hModule, pszMethod);
|
||||
|
||||
// change the page-protection for the intercepted function
|
||||
DWORD dwOldProtect;
|
||||
if (!::VirtualProtectEx(hProcess, pAddress, dwSize, PAGE_EXECUTE_READ, &dwOldProtect))
|
||||
return false;
|
||||
|
||||
//Read the bytes to see if someone hooked that function
|
||||
BYTE* pBytesInMem = (BYTE*)malloc(dwSize);
|
||||
DWORD dwRead = 0;
|
||||
if (::ReadProcessMemory(hProcess, pAddress, pBytesInMem, dwSize, &dwRead))
|
||||
{
|
||||
bOK = 0 != memcmp(pBytesInMem, pBytesToCheck, dwRead);
|
||||
|
||||
/*
|
||||
char szAddress[_MAX_PATH];
|
||||
sprintf(szAddress, "%s::%s - at %lx - %s", pszModule, pszMethod, pAddress, bOK ? "OK" : "HACK");
|
||||
AgLog(szAddress);
|
||||
|
||||
HANDLE hFile = CreateFile("c:\\temp.bin", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL);
|
||||
DWORD dwWritten;
|
||||
WriteFile(hFile, pBytesToCheck, dwRead, &dwWritten, NULL);
|
||||
CloseHandle(hFile);
|
||||
*/
|
||||
}
|
||||
|
||||
//
|
||||
// restore page protection
|
||||
//
|
||||
VirtualProtectEx(hProcess, pAddress, dwSize, dwOldProtect, &dwOldProtect);
|
||||
|
||||
free(pBytesInMem);
|
||||
|
||||
return bOK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AgWallhack g_Wallhack;
|
||||
static char szDisconnect[] = "disconnect\n";
|
||||
static char szMicrosoft[] = "Microsoft Corporation";
|
||||
static char szCDFPS[] = "cd_fps";
|
||||
|
||||
static char* s_szGoodDlls[] =
|
||||
{
|
||||
/*
|
||||
"\\ag\\cl_dlls\\client.dll",
|
||||
"\\ag\\dlls\\ag.dll",
|
||||
"\\ag\\dlls\\hl.dll",
|
||||
"\\aghl\\cl_dlls\\client.dll",
|
||||
"\\aghl\\dlls\\ag.dll",
|
||||
"\\aghl\\dlls\\hl.dll",
|
||||
*/
|
||||
"\\vgui.dll",
|
||||
"\\woncrypt.dll",
|
||||
"\\wonauth.dll",
|
||||
"\\hl_res.dll",
|
||||
"\\hw.dll",
|
||||
"\\sw.dll",
|
||||
"\\mss32.dll",
|
||||
"\\mssv12.dll",
|
||||
"\\mssv12.asi",
|
||||
"\\mp3dec.asi",
|
||||
"\\mssv29.asi",
|
||||
"\\steamvalidateuseridtickets.dll",
|
||||
"\\voice_miles.dll",
|
||||
"\\hl.exe",
|
||||
"\\cstrike.exe",
|
||||
};
|
||||
|
||||
|
||||
static char* s_szBadDlls[] =
|
||||
{
|
||||
"glhack.dll", //Famous glhack.
|
||||
"default.dll", //Cracked version of famous glhack. This one is encoded... smart fellow :P
|
||||
"hl_rem.dll", //Cracked version of famous glhack. I will stop any version by opening the dll anyway.
|
||||
"oldogl32.dll", //Famous glhack.
|
||||
"oglhack.dll",
|
||||
"ogl.dll",
|
||||
"sw!zz3r.dll",
|
||||
"hookhl.dll",
|
||||
"ogc.dll",
|
||||
};
|
||||
|
||||
static char* s_szBadStrings[] =
|
||||
{
|
||||
"Z2xoYWNr", //glhack
|
||||
"b3BlbmdsLmluaQAA", //opengl.ini
|
||||
"VFdDaGVhdAAA", //TWCheat
|
||||
"Qi50ZXJhcGh5", //B.teraphy
|
||||
"RmxhdXR6", //Flautz
|
||||
"c3chenozcgAA", //sw!zz3r
|
||||
"QU5BS2lO", //ANAKiN
|
||||
"VVBYIQAA", //UPX!
|
||||
"Yzpcb3BlbmdsMzIuZGxs", //c:\opengl32.dll
|
||||
"aGxoLmRsbAAA", //hlh.dll
|
||||
"R1JpTS1GX0gA", //GRiM-F_H
|
||||
"Q2hyb21heFMA", //ChromaxS
|
||||
"b2djLmRsbAAA", //ogc.dll
|
||||
"ZVohJDd2", //eZ!$7v Swizz hack
|
||||
"Y29kZXJzLmRsbAAA", //coders.dll wh_beta4, wh_beta5
|
||||
"b2djLmNmZwAA", //ogc.cfg
|
||||
"eHF6MgAA", //xqz2 - xqz2_b71
|
||||
"eHFiNgAA", //xqb6 - xqz2_b80
|
||||
"cEBncmFt", //p@gram - XQZ2Beta85
|
||||
"W09HQ10A", //[OGC] - from ogc 7
|
||||
"Sm9vbHoA", //Joolz - from ogc 8 -
|
||||
"dGhyb3VnaCB3YWxs", //through wall - from ogc 8 -
|
||||
"UlNEU/s19Llq", //RSDSû5ô¹j from 187 Wallhack
|
||||
"d2FsbGhhY2sA", //wallhack from SyFWallHack.dll
|
||||
"W1VHQ10A", //[UGC] from [FuRy]-immortal
|
||||
"R0xIYWNr", //GLHack
|
||||
"XDE4N0hBQ0sA", //\187HACK - 187 version 1.5, 2.0, xqz
|
||||
"THRmeGhvb2sA", //Ltfxhook - version 4
|
||||
"c2VjdXJlLmluaQAA", //secure.ini - nc-secure
|
||||
"bWFkQ29kZUhvb2sA", //madCodeHookLib - www.madshi.net hooking library that some seem to use.
|
||||
"amFpbmEA", //jaina - comes from exprtl0.dll
|
||||
"bmV0LWNvZGVycwAA", //net-coders - from net coderse hack
|
||||
// "YWltaGFjawAA", //aimhack - 187 version xqz
|
||||
"V2FsbGhhY2sA", //Wallhack - from many hacks.
|
||||
"aG9va2VyLmRsbAAA", //hooker.dll
|
||||
"VW5ob29rZXIA", //Unhooker
|
||||
//in cheats.dat "V2lyZWZyYW1l", //Wireframe - from Net coders hack.
|
||||
/*
|
||||
"T0dDAAAA", //OGC
|
||||
"b2djAAAA", //ogc
|
||||
|
||||
*/
|
||||
/*
|
||||
http://www.zone.ee/kunnchat/
|
||||
http://www.unknowncheats.com/
|
||||
http://www.cheat-network.net/chnetphp/
|
||||
*/
|
||||
};
|
||||
|
||||
AgWallhack::AgWallhack()
|
||||
{
|
||||
#ifndef _DEBUG
|
||||
#ifndef AG_TESTCHEAT
|
||||
if (IsDebuggerPresent())
|
||||
exit(-1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
m_dwHLAddressToValidate = 0L;
|
||||
int i = 0;
|
||||
for (i = 0; i < sizeof(s_szBadStrings)/sizeof(s_szBadStrings[0]); i++)
|
||||
AddBadString(s_szBadStrings[i]);
|
||||
|
||||
for (i = 0; i < sizeof(s_szBadDlls)/sizeof(s_szBadDlls[0]); i++)
|
||||
AddBadDll(s_szBadDlls[i]);
|
||||
|
||||
char szHalfLife[MAX_PATH];
|
||||
GetModuleFileName(GetModuleHandle("client.dll"),szHalfLife,sizeof(szHalfLife));
|
||||
szHalfLife[strrchr(szHalfLife,'\\') - szHalfLife] = '\0';
|
||||
szHalfLife[strrchr(szHalfLife,'\\') - szHalfLife] = '\0';
|
||||
szHalfLife[strrchr(szHalfLife,'\\') - szHalfLife] = '\0';
|
||||
strlwr(szHalfLife);
|
||||
char szDll[MAX_PATH];
|
||||
for (i = 0; i < sizeof(s_szGoodDlls)/sizeof(s_szGoodDlls[0]); i++)
|
||||
{
|
||||
sprintf(szDll,"%s%s",szHalfLife,s_szGoodDlls[i]);
|
||||
m_setGoodDlls.insert(szDll);
|
||||
}
|
||||
|
||||
/*
|
||||
unsigned short usSize = 0;
|
||||
unsigned char szSearch[256];
|
||||
AgBase64Decode("hitewalls",9,szSearch,usSize);
|
||||
OutputDebugString((char*)szSearch);
|
||||
OutputDebugString("\n");
|
||||
*/
|
||||
/*
|
||||
|
||||
AgBase64Encode((unsigned char*)"Wallhack",8,szDll);
|
||||
OutputDebugString(szDll);
|
||||
OutputDebugString("\n");
|
||||
*/
|
||||
/*
|
||||
AgBase64Encode((unsigned char*)"ownlinecheating",7,szDll);
|
||||
OutputDebugString(szDll);
|
||||
OutputDebugString("\n");
|
||||
*/
|
||||
|
||||
|
||||
m_bDoneCheck = false;
|
||||
m_iFiles = 0;
|
||||
m_dwBytes = 0;
|
||||
}
|
||||
|
||||
AgWallhack::~AgWallhack()
|
||||
{
|
||||
m_setBadStrings.clear();
|
||||
m_setBadDlls.clear();
|
||||
m_setGoodDlls.clear();
|
||||
m_setGoodSystemDlls.clear();
|
||||
}
|
||||
|
||||
void AgWallhack::AddBadDll(const char* pszDll)
|
||||
{
|
||||
if (pszDll && 0 != strlen(pszDll))
|
||||
m_setBadDlls.insert(pszDll);
|
||||
}
|
||||
|
||||
void AgWallhack::AddBadString(const char* pszString)
|
||||
{
|
||||
if (pszString && 0 != strlen(pszString))
|
||||
m_setBadStrings.insert(pszString);
|
||||
}
|
||||
|
||||
void AgWallhack::AddBadStrings(const char* pszStrings)
|
||||
{
|
||||
char* pszStringsTemp = strdup(pszStrings);
|
||||
|
||||
char* pszCheatString = strtok( pszStringsTemp, "\n");
|
||||
while (pszCheatString != NULL)
|
||||
{
|
||||
AgString strCheatString = pszCheatString;
|
||||
AgTrim(strCheatString);
|
||||
if (strCheatString.length())
|
||||
AddBadString(strCheatString.c_str());
|
||||
pszCheatString = strtok( NULL, "\n");
|
||||
}
|
||||
|
||||
free(pszStringsTemp);
|
||||
}
|
||||
|
||||
|
||||
bool AgWallhack::InitToolHelp32()
|
||||
{
|
||||
if (m_hKernel32 && m_lpfCreateToolhelp32Snapshot && m_lpfModule32First && m_lpfModule32Next)
|
||||
return true;
|
||||
|
||||
m_hKernel32 = ::LoadLibrary("kernel32.dll");
|
||||
if (NULL == m_hKernel32)
|
||||
return false;
|
||||
|
||||
m_lpfCreateToolhelp32Snapshot = (CREATETOOLHELP32SNAPSHOT) ::GetProcAddress(m_hKernel32,"CreateToolhelp32Snapshot");
|
||||
m_lpfModule32First = (MODULE32FIRST) ::GetProcAddress(m_hKernel32,"Module32First");
|
||||
m_lpfModule32Next = (MODULE32NEXT) ::GetProcAddress(m_hKernel32,"Module32Next");
|
||||
m_lpfProcess32First = (PROCESS32FIRST) ::GetProcAddress(m_hKernel32,"Process32First");
|
||||
m_lpfProcess32Next = (PROCESS32NEXT) ::GetProcAddress(m_hKernel32,"Process32Next");
|
||||
|
||||
if (NULL == m_lpfCreateToolhelp32Snapshot ||
|
||||
NULL == m_lpfModule32First ||
|
||||
NULL == m_lpfModule32Next ||
|
||||
NULL == m_lpfProcess32First ||
|
||||
NULL == m_lpfProcess32Next)
|
||||
{
|
||||
::FreeLibrary(m_hKernel32);
|
||||
m_hKernel32 = NULL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AgWallhack::Check()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
//return true;
|
||||
//m_bDoneCheck = true;
|
||||
//HMODULE x1 = LoadLibrary("E:/Dev/cheats/nC 2.1/nC-Hack.dll");
|
||||
#endif
|
||||
if (m_bDoneCheck)
|
||||
return true;
|
||||
|
||||
|
||||
if (!InitToolHelp32())
|
||||
{
|
||||
char szMessage[] = "Cheat check: This version of Windows is not supported\n";
|
||||
ServerCmd("say <AG Mod> this version of Windows is not supported.");
|
||||
AgLog(szMessage);
|
||||
ConsolePrint(szMessage);
|
||||
ClientCmd(szDisconnect);
|
||||
return false;
|
||||
}
|
||||
|
||||
int iCheck = InternalCheck();
|
||||
#ifdef _DEBUG
|
||||
char szChecked[128];
|
||||
sprintf(szChecked,"Checked for %d cheats in %d files with total data of %ld bytes\n",(int)(m_setBadStrings.size() + m_setBadDlls.size()),m_iFiles,m_dwBytes);
|
||||
ConsolePrint(szChecked);
|
||||
#endif
|
||||
|
||||
if (0 > iCheck)
|
||||
{
|
||||
char szMessage[512];
|
||||
sprintf(szMessage,"say <AG Mod> Autodisconnected, error in installation.\n");
|
||||
ServerCmd(szMessage);
|
||||
sprintf(szMessage,"Error in installation %s. (Error = %d)\n",m_sDll.c_str(),iCheck);
|
||||
AgLog(szMessage);
|
||||
ConsolePrint(szMessage);
|
||||
ClientCmd(szDisconnect);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 != iCheck)
|
||||
{
|
||||
char szMessage[512];
|
||||
sprintf(szMessage,"say <AG Mod> Disconnected for using invalid module %s.\n",m_sDll.c_str());
|
||||
ServerCmd(szMessage);
|
||||
sprintf(szMessage,"Cheat check: %s is not allowed in AG. (Code = %d)\n",m_sDll.c_str(),iCheck);
|
||||
AgLog(szMessage);
|
||||
ConsolePrint(szMessage);
|
||||
//AgSendICQ(szMessage);
|
||||
//AgSendMail(szMessage);
|
||||
#ifndef _DEBUG
|
||||
SendMessageToIRC(szMessage);
|
||||
ClientCmd(szDisconnect);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// m_bDoneCheck = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void DumpToFile(MODULEENTRY32* pME)
|
||||
{
|
||||
char szFile[MAX_PATH];
|
||||
sprintf(szFile,"%s/filedump.txt",AgGetDirectory());
|
||||
FILE* pFile = fopen(szFile,"a+");
|
||||
if (!pFile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fwrite(pME->modBaseAddr,sizeof(BYTE),pME->modBaseSize,pFile);
|
||||
fflush(pFile);
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
int AgWallhack::InternalCheck()
|
||||
{
|
||||
#ifndef _DEBUG
|
||||
#ifndef AG_TESTCHEAT
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
m_sDll = "debugger";
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
char szSystemDir[MAX_PATH];
|
||||
GetSystemDirectory(szSystemDir,sizeof(szSystemDir));
|
||||
strlwr(szSystemDir);
|
||||
|
||||
m_sDll = "";
|
||||
#ifdef _DEBUG
|
||||
DWORD dwTime = GetTickCount();
|
||||
#endif
|
||||
unsigned char szSearch[256];
|
||||
szSearch[0] = '\0';
|
||||
|
||||
HANDLE hSnapShot = m_lpfCreateToolhelp32Snapshot(TH32CS_SNAPMODULE,0);
|
||||
if (INVALID_HANDLE_VALUE == hSnapShot)
|
||||
{
|
||||
m_sDll = "toolhelp was not found";
|
||||
return -2;
|
||||
}
|
||||
|
||||
MODULEENTRY32 me;
|
||||
me.dwSize = sizeof(MODULEENTRY32);
|
||||
HMODULE hCurrent = ::GetModuleHandle("client.dll");
|
||||
|
||||
if (!GetModuleHandle("hl.exe") && !GetModuleHandle("cstrike.exe"))
|
||||
{
|
||||
m_sDll = "hl.exe or cstrike.exe was not found";
|
||||
return -3;
|
||||
}
|
||||
|
||||
BYTE byHokoHack[1] = {0xE8};
|
||||
BYTE byRegularJumpHack[1] = {0xE9};
|
||||
if ( !CheckHooks("opengl32.dll", "glBegin", byHokoHack, sizeof(byHokoHack))
|
||||
|| !CheckHooks("opengl32.dll", "glBegin", byRegularJumpHack, sizeof(byRegularJumpHack))
|
||||
)
|
||||
{
|
||||
m_sDll = "opengl32.dll (patched)";
|
||||
return 11;
|
||||
}
|
||||
|
||||
m_iFiles = 0;
|
||||
m_dwBytes = 0;
|
||||
|
||||
bool bCorrectAddress = false;
|
||||
if (m_lpfModule32First(hSnapShot,&me))
|
||||
{
|
||||
do
|
||||
{
|
||||
m_iFiles++;
|
||||
m_dwBytes += me.modBaseSize;
|
||||
|
||||
if (hCurrent != me.hModule)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
char szTime[MAX_PATH];
|
||||
if ("" == m_sDll)
|
||||
{
|
||||
sprintf(szTime,"%s %d ms\n",m_sDll.c_str(),int((GetTickCount() - dwTime)));
|
||||
AgLog(szTime);
|
||||
dwTime = GetTickCount();
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
char szFileName[MAX_PATH];
|
||||
strcpy(szFileName,me.szExePath);
|
||||
strlwr(szFileName);
|
||||
m_sDll = szFileName;
|
||||
|
||||
DWORD dwAddressInModule = (DWORD)me.modBaseAddr;
|
||||
if (m_dwHLAddressToValidate >= dwAddressInModule
|
||||
&& m_dwHLAddressToValidate <= (dwAddressInModule + me.modBaseSize))
|
||||
{
|
||||
bCorrectAddress = (0 == stricmp(&szFileName[strlen(szFileName)-6],"hl.exe")) || (0 == stricmp(&szFileName[strlen(szFileName)-11],"cstrike.exe"));
|
||||
}
|
||||
|
||||
bool bOpenGL = 0;
|
||||
if (strlen(szFileName) > 11)
|
||||
bOpenGL = 0 == strcmp(&szFileName[strlen(szFileName)-12],"opengl32.dll");
|
||||
|
||||
//Extract version resource.
|
||||
AgVersionInfo vi;
|
||||
vi.LoadVersionInfo(szFileName);
|
||||
|
||||
//Check if microsoft dll.
|
||||
if (!vi.HasErrors())
|
||||
{
|
||||
if (0 == strcmp(szMicrosoft, vi.CompanyName()))
|
||||
{
|
||||
if (!bOpenGL && me.modBaseSize > 150000L) //Most cheat dlls are usually less than 150000kb.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == strcmp(&szFileName[strlen(szFileName)-11],"shimeng.dll"))
|
||||
continue;
|
||||
|
||||
//Skip over some HL dll's
|
||||
bool bGood = false;
|
||||
AgStringSet::iterator itrGoodDlls;
|
||||
for (itrGoodDlls = m_setGoodDlls.begin() ;itrGoodDlls != m_setGoodDlls.end() && !bGood; ++itrGoodDlls)
|
||||
{
|
||||
if (0 == strcmp(m_sDll.c_str(),(*itrGoodDlls).c_str()))
|
||||
bGood = true;
|
||||
}
|
||||
|
||||
if (bGood)
|
||||
continue;
|
||||
|
||||
#ifndef AG_TESTCHEAT
|
||||
//Check bad dll's - practicly worthless :P - the rutine to open and scan the dll inside below is much better.
|
||||
AgStringSet::iterator itrWallhackDlls;
|
||||
for (itrWallhackDlls = m_setBadDlls.begin() ;itrWallhackDlls != m_setBadDlls.end(); ++itrWallhackDlls)
|
||||
{
|
||||
if (0 == strcmp(m_sDll.c_str(),(*itrWallhackDlls).c_str()))
|
||||
{
|
||||
AgLog(("Wallhack found in " + m_sDll + "\n").c_str());
|
||||
return 1; //He used an obvious cheat.
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
bool bDump = false;
|
||||
if (bDump)
|
||||
DumpToFile(&me);
|
||||
#endif //_DEBUG
|
||||
|
||||
if (bOpenGL)
|
||||
{
|
||||
//Check if dll is in windows system directory. Hacks sometimes put the passthru in c:/
|
||||
if (NULL == strstr(m_sDll.c_str(),szSystemDir))
|
||||
return 2; //The opengl32.dll driver wasn't in windows system directory.
|
||||
|
||||
//Check file size. Under 600k is wrong.
|
||||
//Check http://support.microsoft.com/servicedesks/fileversion/dllinfo.asp?sd=MSDN
|
||||
if (600000 > me.modBaseSize)
|
||||
return 3; //This dll is way to small to be the standard opengl32.dll.
|
||||
|
||||
//Extract version resource.
|
||||
if (vi.HasErrors())
|
||||
return 4; //Typically a passthruu dll's aint got any version resource.
|
||||
|
||||
//Check the version info for microsoft string. Can easily be done by hackers though
|
||||
if (0 != strcmp(szMicrosoft, vi.CompanyName()))
|
||||
return 5; //Should be Microsoft Corporation.
|
||||
|
||||
//Check the productversion.
|
||||
int iMajor, iMinor, iMicro, iState;
|
||||
vi.ProductVersion(iMajor, iMinor, iMicro, iState);
|
||||
if (iMajor < 4)
|
||||
return 6; //Should be 4 or more. Cant do any more serious check than this because of the different flavors of windows...
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
AgLog(m_sDll.c_str());
|
||||
#endif
|
||||
//Oki - brute force method to check for hacks... its easy to rename dll's you know...
|
||||
AgStringSet::iterator itrWallhackStrings;
|
||||
unsigned long i = 0;
|
||||
unsigned short x = 0;
|
||||
bool bFoundHack = true;
|
||||
unsigned char* pBuffer = NULL;
|
||||
for (itrWallhackStrings = m_setBadStrings.begin() ;itrWallhackStrings != m_setBadStrings.end(); ++itrWallhackStrings)
|
||||
{
|
||||
unsigned short usSize = 0;
|
||||
AgBase64Decode((*itrWallhackStrings).c_str(),(*itrWallhackStrings).size(),szSearch,usSize);
|
||||
const unsigned char* pszSearch = szSearch;
|
||||
i = 0;
|
||||
unsigned long lCount = me.modBaseSize - usSize;
|
||||
pBuffer = me.modBaseAddr;
|
||||
do
|
||||
{
|
||||
//bFoundHack = FastCmp(pBuffer,pszSearch,usSize);
|
||||
bFoundHack = true;
|
||||
x = 0;
|
||||
do
|
||||
{
|
||||
bFoundHack = *(pBuffer+x) == *(pszSearch+x);
|
||||
++x;
|
||||
}
|
||||
while (bFoundHack && x < usSize);
|
||||
|
||||
if (bFoundHack)
|
||||
{
|
||||
AgLog(("Wallhack found in " + m_sDll + "\n").c_str());
|
||||
return 7;
|
||||
}
|
||||
++pBuffer;
|
||||
++i;
|
||||
}
|
||||
while (i < lCount);
|
||||
}
|
||||
}
|
||||
me.dwSize = sizeof(MODULEENTRY32);
|
||||
}
|
||||
while (m_lpfModule32Next(hSnapShot,&me));
|
||||
|
||||
::CloseHandle(hSnapShot);
|
||||
}
|
||||
|
||||
if (!bCorrectAddress && !gEngfuncs.pfnGetCvarPointer(szCDFPS))
|
||||
{
|
||||
m_sDll = "ogc type hooking library";
|
||||
return 10;
|
||||
}
|
||||
return 0;
|
||||
/*
|
||||
|
||||
|
||||
HANDLE hSnapShotProcess = m_lpfCreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
|
||||
if (INVALID_HANDLE_VALUE == hSnapShotProcess)
|
||||
return -1;
|
||||
|
||||
PROCESSENTRY32 pe;
|
||||
pe.dwSize = sizeof(PROCESSENTRY32);
|
||||
DWORD th32ProcessID = GetCurrentProcessId();
|
||||
|
||||
unsigned char* pFileBuffer = NULL;
|
||||
DWORD dwBufferSize = 0;
|
||||
if (m_lpfProcess32First(hSnapShotProcess,&pe))
|
||||
{
|
||||
do
|
||||
{
|
||||
m_sDll = pe.szExeFile;
|
||||
m_iFiles++;
|
||||
if (th32ProcessID != pe.th32ProcessID)
|
||||
{
|
||||
AgVersionInfo vi;
|
||||
vi.LoadVersionInfo(pe.szExeFile);
|
||||
|
||||
//Check if microsoft dll. Let's hope that no hacker reads this source :P
|
||||
if (!vi.HasErrors())
|
||||
{
|
||||
AgString sCompanyName = vi.CompanyName();
|
||||
AgTrim(sCompanyName);
|
||||
if ("Microsoft Corporation" == vi.CompanyName())
|
||||
continue;
|
||||
}
|
||||
|
||||
//Load the dll into a buffer so it's possible to scan the contence.
|
||||
HANDLE hFile = CreateFile(pe.szExeFile,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,0);
|
||||
if (!hFile)
|
||||
return 9; //Could not load the exe.
|
||||
|
||||
DWORD dwSize = GetFileSize(hFile,NULL);
|
||||
m_dwBytes += dwSize;
|
||||
|
||||
if (dwBufferSize < dwSize)
|
||||
{
|
||||
if (pFileBuffer)
|
||||
free(pFileBuffer);
|
||||
dwBufferSize = dwSize;
|
||||
pFileBuffer = (unsigned char*)malloc(dwBufferSize);
|
||||
}
|
||||
|
||||
DWORD dwRead = 0;
|
||||
if (ReadFile(hFile,(void*)pFileBuffer,dwSize,&dwRead,NULL))
|
||||
{
|
||||
if (dwRead == dwSize)
|
||||
{
|
||||
//Oki - brute force method to check for hacks... its easy to rename dll's you know...
|
||||
AgStringSet::iterator itrWallhackStrings;
|
||||
unsigned long i = 0;
|
||||
unsigned short x = 0;
|
||||
bool bFoundHack = true;
|
||||
unsigned char* pBuffer = NULL;
|
||||
for (itrWallhackStrings = m_setBadStrings.begin() ;itrWallhackStrings != m_setBadStrings.end(); ++itrWallhackStrings)
|
||||
{
|
||||
unsigned short usSize = 0;
|
||||
AgBase64Decode((*itrWallhackStrings).c_str(),(*itrWallhackStrings).size(),szSearch,usSize);
|
||||
const unsigned char* pszSearch = szSearch;
|
||||
i = 0;
|
||||
unsigned long lCount = dwSize - usSize;
|
||||
pBuffer = pFileBuffer;
|
||||
do
|
||||
{
|
||||
//bFoundHack = FastCmp(pBuffer,pszSearch,usSize);
|
||||
bFoundHack = true;
|
||||
x = 0;
|
||||
do
|
||||
{
|
||||
bFoundHack = *(pBuffer+x) == *(pszSearch+x);
|
||||
++x;
|
||||
}
|
||||
while (bFoundHack && x < usSize);
|
||||
|
||||
if (bFoundHack)
|
||||
{
|
||||
AgLog(("Wallhack found in " + m_sDll + "\n").c_str());
|
||||
return 7;
|
||||
}
|
||||
++pBuffer;
|
||||
++i;
|
||||
}
|
||||
while (i < lCount);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
pe.dwSize = sizeof(PROCESSENTRY32);
|
||||
}
|
||||
while (TRUE == m_lpfProcess32Next(hSnapShotProcess,&pe));
|
||||
|
||||
::CloseHandle(hSnapShotProcess);
|
||||
}
|
||||
free(pFileBuffer);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
#define IRC_CHANNEL "#aghl.beta"
|
||||
#else
|
||||
#define IRC_CHANNEL "#aghl"
|
||||
#endif
|
||||
|
||||
#ifdef AG_TESTCHEAT
|
||||
#undef IRC_CHANNEL
|
||||
#define IRC_CHANNEL "#aghl.beta"
|
||||
#endif
|
||||
|
||||
void AgWallhack::SendMessageToIRC(const char* szMessage)
|
||||
{
|
||||
char szCommand[512];
|
||||
sprintf(szCommand,"irc_nick \"AGHL|CHEATER%0d\"",gEngfuncs.pfnRandomLong(0,99));
|
||||
ClientCmd(szCommand);
|
||||
|
||||
sprintf(szCommand,"irc_server \"irc.quakenet.eu.org\"");
|
||||
ClientCmd(szCommand);
|
||||
|
||||
sprintf(szCommand,"irc_port \"6667\"");
|
||||
ClientCmd(szCommand);
|
||||
|
||||
sprintf(szCommand,"irc_autojoin \"%s\"",IRC_CHANNEL);
|
||||
ClientCmd(szCommand);
|
||||
|
||||
int iPlayer = gEngfuncs.GetLocalPlayer()->index; // Get the local player's index
|
||||
|
||||
sprintf(szCommand,"irc_autocommand2 \"/msg %s %s (Authid=%s) %s\"", IRC_CHANNEL, gEngfuncs.PlayerInfo_ValueForKey(iPlayer,"name"), AgGetAuthID(iPlayer).c_str(), "was caught with a cheat. For more info see message below.");
|
||||
ClientCmd(szCommand);
|
||||
|
||||
sprintf(szCommand,"irc_autocommand3 \"/msg %s %s\"", IRC_CHANNEL, szMessage);
|
||||
ClientCmd(szCommand);
|
||||
|
||||
ClientCmd("ircconnect2");
|
||||
}
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
//-- Martin Webrant
|
||||
|
||||
|
||||
|
67
cl_dll/aghl/agwallhack.h
Normal file
67
cl_dll/aghl/agwallhack.h
Normal file
@ -0,0 +1,67 @@
|
||||
//++ BulliT
|
||||
#if !defined(AFX_AGWALLHACK_H__72F3428F_5B58_4681_A572_92EAAE5B2F91__INCLUDED_)
|
||||
#define AFX_AGWALLHACK_H__72F3428F_5B58_4681_A572_92EAAE5B2F91__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
|
||||
// ToolHelp Function Pointers so that it will work on NT4
|
||||
#include <tlhelp32.h>
|
||||
typedef HANDLE (WINAPI* CREATETOOLHELP32SNAPSHOT)(DWORD,DWORD);
|
||||
typedef BOOL (WINAPI* MODULE32FIRST)(HANDLE,LPMODULEENTRY32);
|
||||
typedef BOOL (WINAPI* MODULE32NEXT)(HANDLE,LPMODULEENTRY32);
|
||||
typedef BOOL (WINAPI* PROCESS32FIRST)(HANDLE,LPPROCESSENTRY32);
|
||||
typedef BOOL (WINAPI* PROCESS32NEXT)(HANDLE,LPPROCESSENTRY32);
|
||||
|
||||
class AgWallhack
|
||||
{
|
||||
CREATETOOLHELP32SNAPSHOT m_lpfCreateToolhelp32Snapshot;
|
||||
MODULE32FIRST m_lpfModule32First;
|
||||
MODULE32NEXT m_lpfModule32Next;
|
||||
PROCESS32FIRST m_lpfProcess32First;
|
||||
PROCESS32NEXT m_lpfProcess32Next;
|
||||
HINSTANCE m_hKernel32;
|
||||
|
||||
bool m_bDoneCheck;
|
||||
bool InitToolHelp32();
|
||||
int InternalCheck();
|
||||
|
||||
AgStringSet m_setBadStrings;
|
||||
AgStringSet m_setBadDlls;
|
||||
AgStringSet m_setGoodDlls;
|
||||
AgStringSet m_setGoodSystemDlls;
|
||||
AgString m_sDll;
|
||||
int m_iFiles;
|
||||
DWORD m_dwBytes;
|
||||
|
||||
DWORD m_dwHLAddressToValidate;
|
||||
|
||||
public:
|
||||
|
||||
AgWallhack();
|
||||
virtual ~AgWallhack();
|
||||
|
||||
void AddBadDll(const char* pszDll);
|
||||
void AddBadString(const char* pszString);
|
||||
void AddBadStrings(const char* pszStrings);
|
||||
|
||||
bool Check();
|
||||
|
||||
void SetHLAddressToValidate(DWORD dwHLAddressToValidate)
|
||||
{
|
||||
m_dwHLAddressToValidate = dwHLAddressToValidate;
|
||||
}
|
||||
|
||||
void SendMessageToIRC(const char* szMessage);
|
||||
};
|
||||
|
||||
extern AgWallhack g_Wallhack;
|
||||
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
|
||||
#endif // !defined(AFX_AGWALLHACK_H__72F3428F_5B58_4681_A572_92EAAE5B2F91__INCLUDED_)
|
||||
|
||||
//-- Martin Webrant
|
106
cl_dll/aghl/crossthreadsmessagingdevice.cpp
Normal file
106
cl_dll/aghl/crossthreadsmessagingdevice.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
// CrossThreadsMessagingDevice.cpp
|
||||
// Made by Adi Degani - http://www.codeguru.com/network/irc.html
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
|
||||
#define ASSERT
|
||||
|
||||
#include "CrossThreadsMessagingDevice.h"
|
||||
|
||||
|
||||
LPCSTR CCrossThreadsMessagingDevice::m_lpszClassName = "CCrossThreadsMessagingDevice_HiddenWindow";
|
||||
int CCrossThreadsMessagingDevice::m_iCount = 0;
|
||||
|
||||
|
||||
CCrossThreadsMessagingDevice::CCrossThreadsMessagingDevice()
|
||||
: m_hWnd(NULL), m_pMonitor(NULL)
|
||||
{
|
||||
if( m_iCount++ == 0 )
|
||||
{
|
||||
const WNDCLASS wc =
|
||||
{
|
||||
0,
|
||||
HiddenWindowProc,
|
||||
sizeof(DWORD) * 2,
|
||||
sizeof(DWORD) * 2,
|
||||
GetModuleHandle("client.dll"),
|
||||
(HICON)NULL,
|
||||
(HCURSOR)NULL,
|
||||
(HBRUSH)(COLOR_WINDOW + 1),
|
||||
(LPCSTR)NULL,
|
||||
m_lpszClassName
|
||||
};
|
||||
|
||||
if( !RegisterClass(&wc) )
|
||||
return;
|
||||
}
|
||||
|
||||
m_hWnd = CreateWindow(
|
||||
m_lpszClassName,
|
||||
"",
|
||||
WS_OVERLAPPED,
|
||||
0, 0, 0, 0,
|
||||
(HWND)NULL,
|
||||
(HMENU)NULL,
|
||||
GetModuleHandle("client.dll"),
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
CCrossThreadsMessagingDevice::~CCrossThreadsMessagingDevice()
|
||||
{
|
||||
if( ::IsWindow(m_hWnd) )
|
||||
DestroyWindow(m_hWnd);
|
||||
|
||||
if( --m_iCount == 0 )
|
||||
{
|
||||
UnregisterClass(m_lpszClassName, GetModuleHandle("client.dll"));
|
||||
}
|
||||
}
|
||||
|
||||
void CCrossThreadsMessagingDevice::Post(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
ASSERT(::IsWindow(m_hWnd));
|
||||
PostMessage(m_hWnd, HWM_DATA, wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT WINAPI CCrossThreadsMessagingDevice::HiddenWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LRESULT rc = 0;
|
||||
|
||||
CCrossThreadsMessagingDevice* pThis =
|
||||
(CCrossThreadsMessagingDevice*)GetWindowLong(hWnd, GWL_USERDATA);
|
||||
|
||||
switch( uMsg )
|
||||
{
|
||||
case WM_NCCREATE :
|
||||
{
|
||||
LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
|
||||
ASSERT(lpcs->lpCreateParams != NULL);
|
||||
SetWindowLong(hWnd, GWL_USERDATA, (LONG)lpcs->lpCreateParams);
|
||||
rc = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case HWM_DATA :
|
||||
{
|
||||
ASSERT(pThis != NULL);
|
||||
if( pThis->m_pMonitor )
|
||||
pThis->m_pMonitor->OnCrossThreadsMessage(wParam, lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
default :
|
||||
{
|
||||
rc = DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
36
cl_dll/aghl/crossthreadsmessagingdevice.h
Normal file
36
cl_dll/aghl/crossthreadsmessagingdevice.h
Normal file
@ -0,0 +1,36 @@
|
||||
// CrossThreadsMessagingDevice.h
|
||||
|
||||
#ifndef _CrossThreadsMessagingDevice_H_
|
||||
#define _CrossThreadsMessagingDevice_H_
|
||||
|
||||
|
||||
class CCrossThreadsMessagingDevice
|
||||
{
|
||||
public :
|
||||
struct ICrossThreadsMessagingDeviceMonitor
|
||||
{
|
||||
virtual void OnCrossThreadsMessage(WPARAM wParam, LPARAM lParam) = 0;
|
||||
};
|
||||
|
||||
CCrossThreadsMessagingDevice();
|
||||
virtual ~CCrossThreadsMessagingDevice();
|
||||
|
||||
void SetMonitor(ICrossThreadsMessagingDeviceMonitor* pMonitor) { m_pMonitor = pMonitor; }
|
||||
void Post(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
operator bool() const { return ::IsWindow(m_hWnd)==TRUE; }
|
||||
|
||||
private :
|
||||
enum { HWM_DATA = WM_USER + 1000 };
|
||||
static LPCSTR m_lpszClassName;
|
||||
static int m_iCount;
|
||||
HWND m_hWnd;
|
||||
ICrossThreadsMessagingDeviceMonitor* m_pMonitor;
|
||||
|
||||
static LRESULT WINAPI HiddenWindowProc(HWND, UINT, WPARAM, LPARAM);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // _CrossThreadsMessagingDevice_H_
|
||||
|
2471
cl_dll/aghl/dbghelp.h
Normal file
2471
cl_dll/aghl/dbghelp.h
Normal file
File diff suppressed because it is too large
Load Diff
603
cl_dll/aghl/irc.cpp
Normal file
603
cl_dll/aghl/irc.cpp
Normal file
@ -0,0 +1,603 @@
|
||||
// irc.cpp
|
||||
// Made by Adi Degani - http://www.codeguru.com/network/irc.html
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <Tchar.h>
|
||||
#include "agglobal.h"
|
||||
|
||||
#include "irc.h"
|
||||
|
||||
using namespace irc;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
CIrcMessage::CIrcMessage(const char* lpszCmdLine, bool bIncoming)
|
||||
: m_bIncoming(bIncoming)
|
||||
{
|
||||
ParseIrcCommand(lpszCmdLine);
|
||||
}
|
||||
|
||||
CIrcMessage::CIrcMessage(const CIrcMessage& m)
|
||||
: sCommand(m.sCommand),
|
||||
parameters(m.parameters),
|
||||
m_bIncoming(m.m_bIncoming)
|
||||
{
|
||||
prefix.sNick = m.prefix.sNick;
|
||||
prefix.sUser = m.prefix.sUser;
|
||||
prefix.sHost = m.prefix.sHost;
|
||||
}
|
||||
|
||||
void CIrcMessage::Reset()
|
||||
{
|
||||
prefix.sNick = prefix.sUser = prefix.sHost = sCommand = "";
|
||||
m_bIncoming = false;
|
||||
parameters.clear();
|
||||
}
|
||||
|
||||
CIrcMessage& CIrcMessage::operator = (const CIrcMessage& m)
|
||||
{
|
||||
if( &m != this )
|
||||
{
|
||||
sCommand = m.sCommand;
|
||||
parameters = m.parameters;
|
||||
prefix.sNick = m.prefix.sNick;
|
||||
prefix.sUser = m.prefix.sUser;
|
||||
prefix.sHost = m.prefix.sHost;
|
||||
m_bIncoming = m.m_bIncoming;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
CIrcMessage& CIrcMessage::operator = (const char* lpszCmdLine)
|
||||
{
|
||||
Reset();
|
||||
ParseIrcCommand(lpszCmdLine);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CIrcMessage::ParseIrcCommand(const char* lpszCmdLine)
|
||||
{
|
||||
const char* p1 = lpszCmdLine;
|
||||
const char* p2 = lpszCmdLine;
|
||||
|
||||
assert(lpszCmdLine != NULL);
|
||||
assert(*lpszCmdLine);
|
||||
|
||||
// prefix exists ?
|
||||
if( *p1 == ':' )
|
||||
{ // break prefix into its components (nick!user@host)
|
||||
p2 = ++p1;
|
||||
while( *p2 && !strchr(" !", *p2) )
|
||||
++p2;
|
||||
prefix.sNick.assign(p1, p2 - p1);
|
||||
if( *p2 != '!' )
|
||||
goto end_of_prefix;
|
||||
p1 = ++p2;
|
||||
while( *p2 && !strchr(" @", *p2) )
|
||||
++p2;
|
||||
prefix.sUser.assign(p1, p2 - p1);
|
||||
if( *p2 != '@' )
|
||||
goto end_of_prefix;
|
||||
p1 = ++p2;
|
||||
while( *p2 && !isspace(*p2) )
|
||||
++p2;
|
||||
prefix.sHost.assign(p1, p2 - p1);
|
||||
end_of_prefix :
|
||||
while( *p2 && isspace(*p2) )
|
||||
++p2;
|
||||
p1 = p2;
|
||||
}
|
||||
|
||||
// get command
|
||||
assert(*p1 != '\0');
|
||||
p2 = p1;
|
||||
while( *p2 && !isspace(*p2) )
|
||||
++p2;
|
||||
sCommand.assign(p1, p2 - p1);
|
||||
_strupr((char*)sCommand.c_str());
|
||||
while( *p2 && isspace(*p2) )
|
||||
++p2;
|
||||
p1 = p2;
|
||||
|
||||
// get parameters
|
||||
while( *p1 )
|
||||
{
|
||||
if( *p1 == ':' )
|
||||
{
|
||||
++p1;
|
||||
// seek end-of-message
|
||||
while( *p2 )
|
||||
++p2;
|
||||
parameters.push_back(AgString(p1, p2 - p1));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// seek end of parameter
|
||||
while( *p2 && !isspace(*p2) )
|
||||
++p2;
|
||||
parameters.push_back(AgString(p1, p2 - p1));
|
||||
// see next parameter
|
||||
while( *p2 && isspace(*p2) )
|
||||
++p2;
|
||||
p1 = p2;
|
||||
}
|
||||
} // end parameters loop
|
||||
}
|
||||
|
||||
AgString CIrcMessage::AsString() const
|
||||
{
|
||||
AgString s;
|
||||
|
||||
if( prefix.sNick.length() )
|
||||
{
|
||||
s += ":" + prefix.sNick;
|
||||
if( prefix.sUser.length() && prefix.sHost.length() )
|
||||
s += "!" + prefix.sUser + "@" + prefix.sHost;
|
||||
s += " ";
|
||||
}
|
||||
|
||||
s += sCommand;
|
||||
|
||||
for(unsigned int i=0; i < parameters.size(); i++)
|
||||
{
|
||||
s += " ";
|
||||
if( i == parameters.size() - 1 ) // is last parameter ?
|
||||
s += ":";
|
||||
s += parameters[i];
|
||||
}
|
||||
|
||||
s += endl;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
CIrcSession::CIrcSession(IIrcSessionMonitor* pMonitor)
|
||||
: m_hThread(NULL)
|
||||
{
|
||||
InitializeCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
CIrcSession::~CIrcSession()
|
||||
{
|
||||
Disconnect();
|
||||
DeleteCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
bool CIrcSession::Connect(const CIrcSessionInfo& info)
|
||||
{
|
||||
assert(m_hThread==NULL && !(bool)m_socket);
|
||||
|
||||
try
|
||||
{
|
||||
m_identServer.Start(info.sUserID.c_str());
|
||||
|
||||
if( !m_socket.Create() )
|
||||
throw "Failed to create socket!";
|
||||
|
||||
InetAddr addr(info.sServer.c_str(), (WORD)info.iPort);
|
||||
if( !m_socket.Connect(addr) )
|
||||
{
|
||||
m_socket.Close();
|
||||
throw "Failed to connect to host!";
|
||||
}
|
||||
|
||||
m_info = info;
|
||||
|
||||
// start receiving messages from host
|
||||
DWORD dwThreadId = 0;
|
||||
m_hThread = CreateThread(NULL, 0, ThreadProc, this, 0, &dwThreadId);
|
||||
Sleep(100);
|
||||
|
||||
if( info.sPassword.length() )
|
||||
m_socket.Send("PASS %s\r\n", info.sPassword.c_str());
|
||||
|
||||
m_socket.Send("NICK %s\r\n", info.sNick.c_str());
|
||||
|
||||
TCHAR szHostName[MAX_PATH];
|
||||
DWORD cbHostName = sizeof(szHostName);
|
||||
GetComputerName(szHostName, &cbHostName);
|
||||
|
||||
m_socket.Send("USER %s %s %s :%s\r\n",
|
||||
info.sUserID.c_str(), szHostName, "server", info.sFullName.c_str());
|
||||
}
|
||||
catch( const char* )
|
||||
{
|
||||
Disconnect();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
return (bool)m_socket;
|
||||
}
|
||||
|
||||
void CIrcSession::Disconnect(const char* lpszMessage)
|
||||
{
|
||||
static const DWORD dwServerTimeout = 3 * 1000;
|
||||
|
||||
if( !m_hThread )
|
||||
return;
|
||||
|
||||
m_socket.Send("QUIT :%s\r\n", lpszMessage ? lpszMessage : "bye!");
|
||||
|
||||
if( m_hThread && WaitForSingleObject(m_hThread, dwServerTimeout) != WAIT_OBJECT_0 )
|
||||
{
|
||||
m_socket.Close();
|
||||
Sleep(100);
|
||||
if( m_hThread && WaitForSingleObject(m_hThread, dwServerTimeout) != WAIT_OBJECT_0 )
|
||||
{
|
||||
TerminateThread(m_hThread, 1);
|
||||
CloseHandle(m_hThread);
|
||||
m_hThread = NULL;
|
||||
m_info.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CIrcSession::Notify(const CIrcMessage* pmsg)
|
||||
{
|
||||
// forward message to monitor objects
|
||||
EnterCriticalSection(&m_cs);
|
||||
for(CIrcSessionMonitors::iterator it = m_monitors.begin();
|
||||
it != m_monitors.end();
|
||||
it++
|
||||
)
|
||||
{
|
||||
(*it)->OnIrcMessage(pmsg);
|
||||
}
|
||||
LeaveCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
void CIrcSession::DoReceive()
|
||||
{
|
||||
// CIrcIdentServer m_identServer;
|
||||
char chBuf[1024*4+1];
|
||||
int cbInBuf = 0;
|
||||
|
||||
// if( m_info.bIdentServer )
|
||||
//m_identServer.Start(m_info.sUserID.c_str());
|
||||
//Sleep(100);
|
||||
|
||||
while( m_socket )
|
||||
{
|
||||
int cbRead;
|
||||
int nLinesProcessed = 0;
|
||||
|
||||
cbRead = m_socket.Receive((unsigned char*)chBuf+cbInBuf, sizeof(chBuf)-cbInBuf-1);
|
||||
if( cbRead <= 0 )
|
||||
break;
|
||||
cbInBuf += cbRead;
|
||||
chBuf[cbInBuf] = '\0';
|
||||
|
||||
char* pStart = chBuf;
|
||||
while( *pStart )
|
||||
{
|
||||
char* pEnd;
|
||||
|
||||
// seek end-of-line
|
||||
for(pEnd=pStart; *pEnd && *pEnd != '\r' && *pEnd != '\n'; ++pEnd)
|
||||
;
|
||||
if( *pEnd == '\0' )
|
||||
break; // uncomplete message. stop parsing.
|
||||
|
||||
++nLinesProcessed;
|
||||
|
||||
// replace end-of-line with NULLs and skip
|
||||
while( *pEnd == '\r' || *pEnd == '\n' )
|
||||
*pEnd++ = '\0';
|
||||
|
||||
if( *pStart )
|
||||
{
|
||||
// process single message by monitor objects
|
||||
CIrcMessage msg(pStart, true);
|
||||
Notify(&msg);
|
||||
}
|
||||
|
||||
cbInBuf -= pEnd - pStart;
|
||||
assert(cbInBuf >= 0);
|
||||
|
||||
pStart = pEnd;
|
||||
}
|
||||
|
||||
// discard processed messages
|
||||
if( nLinesProcessed != 0 )
|
||||
memmove(chBuf, pStart, cbInBuf+1);
|
||||
}
|
||||
|
||||
if( m_socket )
|
||||
m_socket.Close();
|
||||
|
||||
if( m_info.bIdentServer )
|
||||
m_identServer.Stop();
|
||||
|
||||
// notify monitor objects that the connection has been closed
|
||||
Notify(NULL);
|
||||
}
|
||||
|
||||
DWORD WINAPI CIrcSession::ThreadProc(LPVOID pparam)
|
||||
{
|
||||
CIrcSession* pThis = (CIrcSession*)pparam;
|
||||
try { pThis->DoReceive(); } catch( ... ) {}
|
||||
pThis->m_info.Reset();
|
||||
CloseHandle(pThis->m_hThread);
|
||||
pThis->m_hThread = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CIrcSession::AddMonitor(IIrcSessionMonitor* pMonitor)
|
||||
{
|
||||
assert(pMonitor != NULL);
|
||||
EnterCriticalSection(&m_cs);
|
||||
m_monitors.insert(pMonitor);
|
||||
LeaveCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
void CIrcSession::RemoveMonitor(IIrcSessionMonitor* pMonitor)
|
||||
{
|
||||
assert(pMonitor != NULL);
|
||||
EnterCriticalSection(&m_cs);
|
||||
m_monitors.erase(pMonitor);
|
||||
LeaveCriticalSection(&m_cs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
CIrcSessionInfo::CIrcSessionInfo()
|
||||
: iPort(0), bIdentServer(false), iIdentServerPort(0)
|
||||
{
|
||||
}
|
||||
|
||||
CIrcSessionInfo::CIrcSessionInfo(const CIrcSessionInfo& si)
|
||||
: sServer(si.sServer),
|
||||
sServerName(si.sServerName),
|
||||
iPort(si.iPort),
|
||||
sNick(si.sNick),
|
||||
sUserID(si.sUserID),
|
||||
sFullName(si.sFullName),
|
||||
sPassword(si.sPassword),
|
||||
bIdentServer(si.bIdentServer),
|
||||
sIdentServerType(si.sIdentServerType),
|
||||
iIdentServerPort(si.iIdentServerPort)
|
||||
{
|
||||
}
|
||||
|
||||
void CIrcSessionInfo::Reset()
|
||||
{
|
||||
sServer = "";
|
||||
sServerName = "";
|
||||
iPort = 0;
|
||||
sNick = "";
|
||||
sUserID = "";
|
||||
sFullName = "";
|
||||
sPassword = "";
|
||||
bIdentServer = false;
|
||||
sIdentServerType = "";
|
||||
iIdentServerPort = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
CIrcIdentServer::CIrcIdentServer()
|
||||
: m_uiPort(0), m_hThread(NULL)
|
||||
{
|
||||
m_hReady = CreateEvent(NULL,TRUE,FALSE,"IDENTEVENT");
|
||||
}
|
||||
|
||||
CIrcIdentServer::~CIrcIdentServer()
|
||||
{
|
||||
CloseHandle(m_hReady);
|
||||
Stop();
|
||||
}
|
||||
|
||||
bool CIrcIdentServer::Start(
|
||||
const char* lpszUserID,
|
||||
unsigned int uiPort,
|
||||
const char* lpszResponseType
|
||||
)
|
||||
{
|
||||
if( m_socket )
|
||||
return false;
|
||||
|
||||
if( !m_socket.Create() )
|
||||
return false;
|
||||
|
||||
if( !m_socket.Bind(InetAddr((WORD)uiPort)) )
|
||||
{
|
||||
m_socket.Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_sResponseType = lpszResponseType;
|
||||
m_sUserID = lpszUserID;
|
||||
m_uiPort = uiPort;
|
||||
|
||||
DWORD dwThreadId = 0;
|
||||
m_hThread = CreateThread(NULL, 0, ListenProc, this, 0, &dwThreadId);
|
||||
WaitForSingleObject(m_hReady,INFINITE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CIrcIdentServer::Stop()
|
||||
{
|
||||
if( m_hThread )
|
||||
{
|
||||
m_socket.Close();
|
||||
Sleep(100);
|
||||
if( WaitForSingleObject(m_hThread, 2000) != WAIT_OBJECT_0 && m_hThread )
|
||||
{
|
||||
TerminateThread(m_hThread, 1);
|
||||
CloseHandle(m_hThread);
|
||||
m_hThread = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CIrcIdentServer::DoThread()
|
||||
{
|
||||
m_socket.Listen();
|
||||
|
||||
while( (bool)m_socket )
|
||||
{
|
||||
InetAddr addr;
|
||||
|
||||
SetEvent(m_hReady);
|
||||
Socket s = m_socket.Accept(addr);
|
||||
//int iErr = WSAGetLastError();
|
||||
if( !(bool)s )
|
||||
break;
|
||||
|
||||
char szBuf[1024];
|
||||
int cbRead = s.Receive((unsigned char*)szBuf, sizeof(szBuf)-1);
|
||||
if( cbRead <= 0 )
|
||||
continue;
|
||||
szBuf[cbRead] = '\0';
|
||||
|
||||
// strip CRLF from query
|
||||
for(char* p = szBuf; *p && *p != '\r' && *p != '\n'; ++p)
|
||||
;
|
||||
*p = '\0';
|
||||
|
||||
s.Send("%s : USERID : %s : %s\r\n",
|
||||
szBuf, m_sResponseType.c_str(), m_sUserID.c_str());
|
||||
Sleep(500);
|
||||
s.Close();
|
||||
}
|
||||
|
||||
SetEvent(m_hReady);
|
||||
|
||||
m_socket.Close();
|
||||
}
|
||||
|
||||
DWORD WINAPI CIrcIdentServer::ListenProc(LPVOID pparam)
|
||||
{
|
||||
CIrcIdentServer* pThis = (CIrcIdentServer*)pparam;
|
||||
|
||||
try { pThis->DoThread(); } catch( ... ) {}
|
||||
|
||||
pThis->m_sResponseType = "";
|
||||
pThis->m_sUserID = "";
|
||||
pThis->m_uiPort = 0;
|
||||
|
||||
CloseHandle(pThis->m_hThread);
|
||||
pThis->m_hThread = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
CIrcMonitor::HandlersMap CIrcMonitor::m_handlers;
|
||||
CIrcMonitor::IrcCommandsMapsListEntry CIrcMonitor::m_handlersMapsListEntry
|
||||
= { &CIrcMonitor::m_handlers, NULL };
|
||||
|
||||
|
||||
CIrcMonitor::CIrcMonitor(CIrcSession& session)
|
||||
: m_session(session)
|
||||
{
|
||||
m_xPost.SetMonitor(this);
|
||||
}
|
||||
|
||||
CIrcMonitor::~CIrcMonitor()
|
||||
{
|
||||
}
|
||||
|
||||
void CIrcMonitor::OnIrcMessage(const CIrcMessage* pmsg)
|
||||
{
|
||||
CIrcMessage* pMsgCopy = NULL;
|
||||
if( pmsg )
|
||||
pMsgCopy = new CIrcMessage(*pmsg);
|
||||
m_xPost.Post(0, (LPARAM)pMsgCopy);
|
||||
}
|
||||
|
||||
void CIrcMonitor::OnCrossThreadsMessage(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
CIrcMessage* pmsg = (CIrcMessage*)lParam;
|
||||
|
||||
OnIrcAll(pmsg);
|
||||
|
||||
if( pmsg )
|
||||
{
|
||||
PfnIrcMessageHandler pfn = FindMethod(pmsg->sCommand.c_str());
|
||||
if( pfn )
|
||||
{
|
||||
// call member function. if it returns 'false',
|
||||
// call the default handling
|
||||
if( !(this->*pfn)(pmsg) )
|
||||
OnIrcDefault(pmsg);
|
||||
}
|
||||
else // handler not found. call default handler
|
||||
OnIrcDefault(pmsg);
|
||||
delete pmsg;
|
||||
}
|
||||
else
|
||||
OnIrcDisconnected();
|
||||
}
|
||||
|
||||
CIrcMonitor::PfnIrcMessageHandler CIrcMonitor::FindMethod(const char* lpszName)
|
||||
{
|
||||
// call the recursive version with the most derived map
|
||||
return FindMethod(GetIrcCommandsMap(), lpszName);
|
||||
}
|
||||
|
||||
CIrcMonitor::PfnIrcMessageHandler CIrcMonitor::FindMethod(IrcCommandsMapsListEntry* pMapsList, const char* lpszName)
|
||||
{
|
||||
HandlersMap::iterator it = pMapsList->pHandlersMap->find(lpszName);
|
||||
if( it != pMapsList->pHandlersMap->end() )
|
||||
return (*it).second; // found !
|
||||
else if( pMapsList->pBaseHandlersMap )
|
||||
return FindMethod(pMapsList->pBaseHandlersMap, lpszName); // try at base class
|
||||
return NULL; // not found in any map
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
DECLARE_IRC_MAP(CIrcDefaultMonitor, CIrcMonitor)
|
||||
|
||||
CIrcDefaultMonitor::CIrcDefaultMonitor(CIrcSession& session)
|
||||
: CIrcMonitor(session)
|
||||
{
|
||||
IRC_MAP_ENTRY(CIrcDefaultMonitor, "NICK", OnIrc_NICK)
|
||||
IRC_MAP_ENTRY(CIrcDefaultMonitor, "PING", OnIrc_PING)
|
||||
IRC_MAP_ENTRY(CIrcDefaultMonitor, "002", OnIrc_YOURHOST)
|
||||
IRC_MAP_ENTRY(CIrcDefaultMonitor, "005", OnIrc_BOUNCE)
|
||||
}
|
||||
|
||||
bool CIrcDefaultMonitor::OnIrc_NICK(const CIrcMessage* pmsg)
|
||||
{
|
||||
if( (m_session.GetInfo().sNick == pmsg->prefix.sNick) && (pmsg->parameters.size() > 0) )
|
||||
m_session.m_info.sNick = pmsg->parameters[0];
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CIrcDefaultMonitor::OnIrc_PING(const CIrcMessage* pmsg)
|
||||
{
|
||||
char szResponse[100];
|
||||
sprintf(szResponse, "PONG %s", pmsg->parameters[0].c_str());
|
||||
m_session << CIrcMessage(szResponse);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CIrcDefaultMonitor::OnIrc_YOURHOST(const CIrcMessage* pmsg)
|
||||
{
|
||||
static const char* lpszFmt = "Your host is %[^ \x5b,], running version %s";
|
||||
char szHostName[100], szVersion[100];
|
||||
if( sscanf(pmsg->parameters[1].c_str(), lpszFmt, &szHostName, &szVersion) > 0 )
|
||||
m_session.m_info.sServerName = szHostName;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CIrcDefaultMonitor::OnIrc_BOUNCE(const CIrcMessage* pmsg)
|
||||
{
|
||||
static const char* lpszFmt = "Try server %[^ ,], port %d";
|
||||
char szAltServer[100];
|
||||
int iAltPort = 0;
|
||||
if( sscanf(pmsg->parameters[1].c_str(), lpszFmt, &szAltServer, &iAltPort) == 2 )
|
||||
{
|
||||
}
|
||||
return false;
|
||||
}
|
257
cl_dll/aghl/irc.h
Normal file
257
cl_dll/aghl/irc.h
Normal file
@ -0,0 +1,257 @@
|
||||
// irc.h
|
||||
|
||||
#ifndef _IRC_H_
|
||||
#define _IRC_H_
|
||||
|
||||
/*
|
||||
IRC (RFC #1459) Client Implementation
|
||||
*/
|
||||
|
||||
#pragma warning (disable: 4786)
|
||||
|
||||
#include "socket.h"
|
||||
#include "CrossThreadsMessagingDevice.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
namespace irc {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const char* endl = "\r\n";
|
||||
|
||||
// RFC's Identity Server (RFC #1413)
|
||||
class CIrcIdentServer
|
||||
{
|
||||
public :
|
||||
CIrcIdentServer();
|
||||
virtual ~CIrcIdentServer();
|
||||
|
||||
bool Start(
|
||||
const char* lpszUserID,
|
||||
unsigned int uiPort = 113,
|
||||
const char* lpszResponseType = "UNIX"
|
||||
);
|
||||
void Stop();
|
||||
|
||||
HANDLE m_hReady;
|
||||
|
||||
protected :
|
||||
AgString m_sResponseType;
|
||||
unsigned int m_uiPort;
|
||||
AgString m_sUserID;
|
||||
|
||||
void DoThread();
|
||||
|
||||
private :
|
||||
Socket m_socket;
|
||||
HANDLE m_hThread;
|
||||
|
||||
static DWORD WINAPI ListenProc(LPVOID pparam);
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CIrcMessage
|
||||
{
|
||||
public :
|
||||
struct Prefix
|
||||
{
|
||||
AgString sNick, sUser, sHost;
|
||||
} prefix;
|
||||
AgString sCommand;
|
||||
vector<AgString> parameters;
|
||||
bool m_bIncoming;
|
||||
|
||||
CIrcMessage() : m_bIncoming(false) {} // default constructor
|
||||
CIrcMessage(const char* lpszCmdLine, bool bIncoming=false); // parser constructor
|
||||
CIrcMessage(const CIrcMessage& m); // copy constructor
|
||||
|
||||
void Reset();
|
||||
|
||||
CIrcMessage& operator = (const CIrcMessage& m);
|
||||
CIrcMessage& operator = (const char* lpszCmdLine);
|
||||
|
||||
AgString AsString() const;
|
||||
|
||||
private :
|
||||
void ParseIrcCommand(const char* lpszCmdLine);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct IIrcSessionMonitor
|
||||
{
|
||||
virtual void OnIrcMessage(const CIrcMessage* pmsg) = 0;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct CIrcSessionInfo
|
||||
{
|
||||
AgString sServer;
|
||||
AgString sServerName;
|
||||
unsigned int iPort;
|
||||
AgString sNick;
|
||||
AgString sUserID;
|
||||
AgString sFullName;
|
||||
AgString sPassword;
|
||||
bool bIdentServer;
|
||||
AgString sIdentServerType;
|
||||
unsigned int iIdentServerPort;
|
||||
|
||||
CIrcSessionInfo();
|
||||
CIrcSessionInfo(const CIrcSessionInfo& si);
|
||||
|
||||
void Reset();
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CIrcDefaultMonitor; // foreward
|
||||
|
||||
class CIrcSession
|
||||
{
|
||||
public :
|
||||
friend class CIrcDefaultMonitor;
|
||||
|
||||
CIrcSession(IIrcSessionMonitor* pMonitor = NULL);
|
||||
virtual ~CIrcSession();
|
||||
|
||||
void AddMonitor(IIrcSessionMonitor* pMonitor);
|
||||
void RemoveMonitor(IIrcSessionMonitor* pMonitor);
|
||||
|
||||
bool Connect(const CIrcSessionInfo& info);
|
||||
void Disconnect(const char* lpszMessage = "Bye!");
|
||||
|
||||
const CIrcSessionInfo& GetInfo() const
|
||||
{ return (const CIrcSessionInfo&)m_info; }
|
||||
|
||||
operator bool() const { return (bool)m_socket; }
|
||||
|
||||
// send-to-stream operators
|
||||
friend CIrcSession& operator << (CIrcSession& os, const CIrcMessage& m);
|
||||
|
||||
protected :
|
||||
Socket m_socket;
|
||||
CIrcSessionInfo m_info;
|
||||
|
||||
void DoReceive();
|
||||
|
||||
private :
|
||||
typedef set<IIrcSessionMonitor*, less<IIrcSessionMonitor*> > CIrcSessionMonitors;
|
||||
CIrcSessionMonitors m_monitors;
|
||||
HANDLE m_hThread;
|
||||
CRITICAL_SECTION m_cs; // protect m_monitors
|
||||
|
||||
void Notify(const CIrcMessage* pmsg);
|
||||
static DWORD WINAPI ThreadProc(LPVOID pparam);
|
||||
|
||||
CIrcIdentServer m_identServer;
|
||||
};
|
||||
|
||||
|
||||
__inline CIrcSession& operator << (CIrcSession& os, const CIrcMessage& m)
|
||||
{
|
||||
if( os )
|
||||
{
|
||||
os.m_socket.Send(m.AsString().c_str());
|
||||
os.Notify(&m);
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CIrcMonitor :
|
||||
public IIrcSessionMonitor,
|
||||
private CCrossThreadsMessagingDevice::ICrossThreadsMessagingDeviceMonitor
|
||||
{
|
||||
public :
|
||||
typedef bool (CIrcMonitor::*PfnIrcMessageHandler)(const CIrcMessage* pmsg);
|
||||
struct LessString
|
||||
{
|
||||
bool operator()(const char* s1, const char* s2) const
|
||||
{ return stricmp(s1, s2) < 0; }
|
||||
};
|
||||
typedef map<const char*, PfnIrcMessageHandler, LessString > HandlersMap;
|
||||
struct IrcCommandsMapsListEntry
|
||||
{
|
||||
HandlersMap* pHandlersMap;
|
||||
IrcCommandsMapsListEntry* pBaseHandlersMap;
|
||||
};
|
||||
|
||||
CIrcMonitor(CIrcSession& session);
|
||||
virtual ~CIrcMonitor();
|
||||
|
||||
virtual void OnIrcMessage(const CIrcMessage* pmsg);
|
||||
|
||||
protected :
|
||||
CIrcSession& m_session;
|
||||
|
||||
virtual IrcCommandsMapsListEntry* GetIrcCommandsMap()
|
||||
{ return &m_handlersMapsListEntry; }
|
||||
|
||||
virtual void OnIrcAll(const CIrcMessage* pmsg) {}
|
||||
virtual void OnIrcDefault(const CIrcMessage* pmsg) {}
|
||||
virtual void OnIrcDisconnected() {}
|
||||
|
||||
protected :
|
||||
CCrossThreadsMessagingDevice m_xPost;
|
||||
static IrcCommandsMapsListEntry m_handlersMapsListEntry;
|
||||
static HandlersMap m_handlers;
|
||||
|
||||
PfnIrcMessageHandler FindMethod(const char* lpszName);
|
||||
PfnIrcMessageHandler FindMethod(IrcCommandsMapsListEntry* pMapsList, const char* lpszName);
|
||||
|
||||
virtual void OnCrossThreadsMessage(WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
|
||||
// define an IRC command-to-member map.
|
||||
// put that macro inside the class definition (.H file)
|
||||
#define DEFINE_IRC_MAP() \
|
||||
protected : \
|
||||
virtual IrcCommandsMapsListEntry* GetIrcCommandsMap() \
|
||||
{ return &m_handlersMapsListEntry; } \
|
||||
protected : \
|
||||
static CIrcMonitor::IrcCommandsMapsListEntry m_handlersMapsListEntry; \
|
||||
static CIrcMonitor::HandlersMap m_handlers; \
|
||||
protected :
|
||||
|
||||
// IRC command-to-member map's declaration.
|
||||
// add this macro to the class's .CPP file
|
||||
#define DECLARE_IRC_MAP(this_class, base_class) \
|
||||
CIrcMonitor::HandlersMap this_class##::m_handlers; \
|
||||
CIrcMonitor::IrcCommandsMapsListEntry this_class##::m_handlersMapsListEntry \
|
||||
= { &this_class##::m_handlers, &base_class##::m_handlersMapsListEntry };
|
||||
|
||||
// map actual member functions to their associated IRC command.
|
||||
// put any number of this macro in the class's constructor.
|
||||
#define IRC_MAP_ENTRY(class_name, name, member) \
|
||||
m_handlers[(name)] = (PfnIrcMessageHandler)&class_name##::member;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CIrcDefaultMonitor : public CIrcMonitor
|
||||
{
|
||||
public :
|
||||
CIrcDefaultMonitor(CIrcSession& session);
|
||||
|
||||
DEFINE_IRC_MAP()
|
||||
|
||||
protected :
|
||||
bool OnIrc_NICK(const CIrcMessage* pmsg);
|
||||
bool OnIrc_PING(const CIrcMessage* pmsg);
|
||||
bool OnIrc_YOURHOST(const CIrcMessage* pmsg);
|
||||
bool OnIrc_BOUNCE(const CIrcMessage* pmsg);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
}; // end of namespace irc
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // _IRC_H_
|
||||
|
||||
|
152
cl_dll/aghl/socket.cpp
Normal file
152
cl_dll/aghl/socket.cpp
Normal file
@ -0,0 +1,152 @@
|
||||
// socket.cpp
|
||||
// Made by Adi Degani - http://www.codeguru.com/network/irc.html
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "socket.h"
|
||||
|
||||
#define ASSERT
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
WinsockInit::WinsockInit(WORD wVersionRequested)
|
||||
{
|
||||
m_iStatus = WSAStartup(wVersionRequested, &m_wsd);
|
||||
}
|
||||
|
||||
WinsockInit::~WinsockInit()
|
||||
{
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
InetAddr::InetAddr(WORD wPort)
|
||||
{
|
||||
memset(this, 0, sizeof(sockaddr_in));
|
||||
sin_family = AF_INET;
|
||||
sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
sin_port = htons((u_short)wPort);
|
||||
}
|
||||
|
||||
InetAddr::InetAddr(LPCSTR lpszAddress, WORD wPort)
|
||||
{
|
||||
Resolve(lpszAddress, wPort);
|
||||
}
|
||||
|
||||
InetAddr& InetAddr::operator = (LPCSTR lpszAddress)
|
||||
{
|
||||
Resolve(lpszAddress);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void InetAddr::Resolve(LPCSTR lpszAddress, WORD wPort)
|
||||
{
|
||||
memset(this, 0, sizeof(sockaddr_in));
|
||||
sin_family = AF_INET;
|
||||
sin_addr.s_addr = inet_addr((LPTSTR)lpszAddress);
|
||||
if( sin_addr.s_addr == INADDR_NONE && strcmp((LPTSTR)lpszAddress, "255.255.255.255")!=0 )
|
||||
{
|
||||
HOSTENT* lphost = gethostbyname((LPTSTR)lpszAddress);
|
||||
if( lphost )
|
||||
sin_addr.s_addr = ((IN_ADDR*)lphost->h_addr)->s_addr;
|
||||
else
|
||||
sin_addr.s_addr = INADDR_ANY;
|
||||
}
|
||||
sin_port = htons((u_short)wPort);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Socket::Socket()
|
||||
: m_sock(INVALID_SOCKET), m_bOwnSocket(false)
|
||||
{
|
||||
}
|
||||
|
||||
Socket::Socket(const Socket& s)
|
||||
: m_sock(s.m_sock), m_bOwnSocket(false)
|
||||
{
|
||||
}
|
||||
|
||||
Socket::Socket(SOCKET s)
|
||||
: m_sock(s), m_bOwnSocket(false)
|
||||
{
|
||||
}
|
||||
|
||||
Socket::~Socket()
|
||||
{
|
||||
if( m_bOwnSocket && m_sock != INVALID_SOCKET )
|
||||
Close();
|
||||
}
|
||||
|
||||
bool Socket::Create()
|
||||
{
|
||||
// _ASSERT(m_sock == INVALID_SOCKET);
|
||||
m_sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
return (m_bOwnSocket = (m_sock != INVALID_SOCKET));
|
||||
}
|
||||
|
||||
void Socket::Close()
|
||||
{
|
||||
// _ASSERT(m_sock != INVALID_SOCKET);
|
||||
shutdown(m_sock, 2);
|
||||
closesocket(m_sock);
|
||||
m_sock = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
bool Socket::Bind(const InetAddr& addr)
|
||||
{
|
||||
return bind(m_sock, (const sockaddr*)&addr, sizeof(sockaddr)) != SOCKET_ERROR;
|
||||
}
|
||||
|
||||
bool Socket::Connect(const InetAddr& addr)
|
||||
{
|
||||
return connect(m_sock, (const sockaddr*)&addr, sizeof(sockaddr)) != SOCKET_ERROR;
|
||||
}
|
||||
|
||||
bool Socket::Listen()
|
||||
{
|
||||
return listen(m_sock, 5) != SOCKET_ERROR;
|
||||
}
|
||||
|
||||
Socket Socket::Accept(InetAddr& addr)
|
||||
{
|
||||
int len = sizeof(sockaddr);
|
||||
return Socket(accept(m_sock, (sockaddr*)&addr, &len));
|
||||
}
|
||||
|
||||
int Socket::Send(const unsigned char* buf, int cbBuf)
|
||||
{
|
||||
return send(m_sock, (const char*)buf, cbBuf, 0);
|
||||
}
|
||||
|
||||
int Socket::Send(const char* fmt, ...)
|
||||
{
|
||||
va_list marker;
|
||||
va_start(marker, fmt);
|
||||
|
||||
char szBuf[1024*4];
|
||||
vsprintf(szBuf, fmt, marker);
|
||||
|
||||
va_end(marker);
|
||||
|
||||
return Send((unsigned char*)szBuf, strlen(szBuf));
|
||||
}
|
||||
|
||||
int Socket::Receive(unsigned char* buf, int cbBuf)
|
||||
{
|
||||
int n = recv(m_sock, (char*)buf, cbBuf, 0);
|
||||
return n;
|
||||
}
|
||||
|
||||
bool Socket::SetOpt(int opt, const char* pBuf, int cbBuf)
|
||||
{
|
||||
return setsockopt(m_sock, SOL_SOCKET, opt, pBuf, cbBuf) != SOCKET_ERROR;
|
||||
}
|
||||
|
||||
bool Socket::GetOpt(int opt, char* pBuf, int& cbBuf)
|
||||
{
|
||||
return getsockopt(m_sock, SOL_SOCKET, opt, pBuf, &cbBuf) != SOCKET_ERROR;
|
||||
}
|
64
cl_dll/aghl/socket.h
Normal file
64
cl_dll/aghl/socket.h
Normal file
@ -0,0 +1,64 @@
|
||||
// socket.h
|
||||
|
||||
#ifndef SOCKET_H
|
||||
#define SOCKET_H
|
||||
|
||||
#pragma comment(lib, "wsock32.lib")
|
||||
|
||||
#include <winsock.h>
|
||||
|
||||
|
||||
class WinsockInit
|
||||
{
|
||||
public :
|
||||
WSADATA m_wsd;
|
||||
int m_iStatus;
|
||||
|
||||
WinsockInit(WORD wVersionRequested = 0x0101);
|
||||
~WinsockInit();
|
||||
};
|
||||
|
||||
|
||||
class InetAddr : public sockaddr_in
|
||||
{
|
||||
public :
|
||||
InetAddr(WORD wPort = 0);
|
||||
InetAddr(LPCSTR lpszAddress, WORD wPort = 0);
|
||||
InetAddr& operator = (LPCSTR lpszAddress);
|
||||
|
||||
protected :
|
||||
void Resolve(LPCSTR lpszAddress, WORD wPort = 0);
|
||||
};
|
||||
|
||||
|
||||
class Socket
|
||||
{
|
||||
public :
|
||||
Socket();
|
||||
Socket(SOCKET s);
|
||||
Socket(const Socket& s);
|
||||
virtual ~Socket();
|
||||
|
||||
bool Create();
|
||||
void Close();
|
||||
bool Bind(const InetAddr& addr);
|
||||
bool Connect(const InetAddr& addr);
|
||||
bool Listen();
|
||||
Socket Accept(InetAddr& addr);
|
||||
int Send(const unsigned char* buf, int cbBuf);
|
||||
int Send(const char* fmt, ...);
|
||||
int Receive(unsigned char* buf, int cbBuf);
|
||||
bool SetOpt(int opt, const char* pBuf, int cbBuf);
|
||||
bool GetOpt(int opt, char* pBuf, int& cbBuf);
|
||||
operator SOCKET& () const { return (SOCKET&)m_sock; }
|
||||
operator bool() const { return m_sock != INVALID_SOCKET; }
|
||||
|
||||
protected :
|
||||
SOCKET m_sock;
|
||||
|
||||
private :
|
||||
bool m_bOwnSocket;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -28,6 +28,10 @@
|
||||
|
||||
#include "ammohistory.h"
|
||||
|
||||
//++ BulliT
|
||||
extern cvar_t* g_phud_weapon;
|
||||
//-- Martin Webrant
|
||||
|
||||
WEAPON *gpActiveSel; // NULL means off, 1 means just the menu bar, otherwise
|
||||
// this points to the active weapon menu item
|
||||
WEAPON *gpLastSel; // Last weapon menu selection
|
||||
@ -52,6 +56,11 @@ int WeaponsResource::CountAmmo( int iId )
|
||||
if( iId < 0 )
|
||||
return 0;
|
||||
|
||||
//++ BulliT
|
||||
//Fixes some crashes.
|
||||
if( iId > MAX_AMMO_TYPES )
|
||||
return 0;
|
||||
//-- Martin Webrant
|
||||
return riAmmo[iId];
|
||||
}
|
||||
|
||||
@ -911,6 +920,27 @@ int CHudAmmo::Draw( float flTime )
|
||||
SPR_DrawAdditive( 0, x, y - iOffset, &m_pWeapon->rcAmmo );
|
||||
}
|
||||
|
||||
//++ BulliT
|
||||
//Draw the weaponsprite in spectator mode.
|
||||
if( g_iUser1 == OBS_IN_EYE || 0 != g_phud_weapon->value )
|
||||
{
|
||||
if( gWR.HasAmmo( m_pWeapon ) )
|
||||
{
|
||||
ScaleColors( r, g, b, 192 );
|
||||
}
|
||||
else
|
||||
{
|
||||
UnpackRGB( r,g,b, RGB_REDISH );
|
||||
ScaleColors( r, g, b, 128 );
|
||||
}
|
||||
|
||||
SPR_Set( m_pWeapon->hInactive, r, g, b );
|
||||
x = (ScreenWidth / 1.73); //- ( ( m_pWeapon->rcInactive.right - m_pWeapon->rcInactive.left ) / 2 );
|
||||
int iOffset = ( m_pWeapon->rcInactive.bottom - m_pWeapon->rcInactive.top ) / 8;
|
||||
SPR_DrawAdditive( 0, x, y - iOffset , &m_pWeapon->rcInactive );
|
||||
}
|
||||
//-- Martin Webrant
|
||||
|
||||
// Does weapon have seconday ammo?
|
||||
if( pw->iAmmo2Type > 0 )
|
||||
{
|
||||
|
@ -21,6 +21,12 @@
|
||||
#include "hud.h"
|
||||
#include "cl_util.h"
|
||||
#include "netadr.h"
|
||||
//++ BulliT
|
||||
#include "AgVariableChecker.h"
|
||||
#include "AgGlobal.h"
|
||||
//#include "irc.h"
|
||||
#include "agwallhack.h"
|
||||
//-- Martin Webrant
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@ -30,6 +36,9 @@ extern "C"
|
||||
#include <string.h>
|
||||
|
||||
cl_enginefunc_t gEngfuncs;
|
||||
//++ BulliT
|
||||
//irc::CIrcSession g_ircSession;
|
||||
//-- Martin Webrant
|
||||
CHud gHUD;
|
||||
mobile_engfuncs_t *gMobileEngfuncs = NULL;
|
||||
void InitInput( void );
|
||||
@ -132,7 +141,12 @@ void DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server )
|
||||
PM_Move( ppmove, server );
|
||||
}
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
void* pFromModuleAddress = 0;
|
||||
int DLLEXPORT Initialize_Body( cl_enginefunc_t *pEnginefuncs, int iVersion )
|
||||
#else
|
||||
int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
|
||||
#endif
|
||||
{
|
||||
gEngfuncs = *pEnginefuncs;
|
||||
|
||||
@ -143,9 +157,26 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
|
||||
|
||||
EV_HookEvents();
|
||||
|
||||
//++ BulliT
|
||||
AgInitClientDll();
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
g_Wallhack.SetHLAddressToValidate( (DWORD)pFromModuleAddress );
|
||||
#endif
|
||||
//-- Martin Webrant
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
__declspec(naked) int Initialize( cl_enginefunc_t *pEnginefuncs, int Version )
|
||||
{
|
||||
__asm pop pFromModuleAddress;
|
||||
__asm push pFromModuleAddress;
|
||||
__asm jmp[Initialize_Body];
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
=================
|
||||
HUD_GetRect
|
||||
@ -196,6 +227,9 @@ void DLLEXPORT HUD_Init( void )
|
||||
{
|
||||
InitInput();
|
||||
gHUD.Init();
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
g_VariableChecker.Activate();
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
}
|
||||
|
||||
/*
|
||||
@ -256,7 +290,11 @@ Called by engine every frame that client .dll is loaded
|
||||
*/
|
||||
|
||||
void DLLEXPORT HUD_Frame( double time )
|
||||
{ gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
|
||||
{
|
||||
gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
|
||||
#ifdef AG_USE_CHEATPROTECTION
|
||||
g_VariableChecker.Check();
|
||||
#endif //AG_USE_CHEATPROTECTION
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -100,7 +100,31 @@ inline int TextMessageDrawChar( int x, int y, int number, int r, int g, in
|
||||
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
|
||||
}
|
||||
|
||||
inline int DrawConsoleString( int x, int y, const char *string )
|
||||
//++ BulliT
|
||||
#include "agglobal.h"
|
||||
inline int DrawConsoleString( int x, int y, const char *string, float r = 0, float g = 0, float b = 0 )
|
||||
//inline int DrawConsoleString( int x, int y, const char *string, float r = 0 )
|
||||
{
|
||||
//++ BulliT
|
||||
if( !( r == 0 && g == 0 && b == 0 ) )
|
||||
gEngfuncs.pfnDrawSetTextColor( r, g, b );
|
||||
return AgDrawConsoleString( x, y, string, r ,g, b );
|
||||
//return gEngfuncs.pfnDrawConsoleString( x, y, (char*)string );
|
||||
}
|
||||
//-- Martin Webrant
|
||||
|
||||
inline void GetConsoleStringSize( const char *string, int *width, int *height )
|
||||
{
|
||||
//++ BulliT
|
||||
char *pszString = strdup( string );
|
||||
AgStripColors( (char*)pszString );
|
||||
gEngfuncs.pfnDrawConsoleStringLen( pszString, width, height );
|
||||
free( pszString );
|
||||
//gEngfuncs.pfnDrawConsoleStringLen( string, width, height );
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
/*inline int DrawConsoleString( int x, int y, const char *string )
|
||||
{
|
||||
if( hud_textmode->value == 1 )
|
||||
return gHUD.DrawHudString( x, y, 9999, (char*)string, 255 * g_hud_text_color[0], 255 * g_hud_text_color[1], 255 * g_hud_text_color[2] );
|
||||
@ -114,6 +138,7 @@ inline void GetConsoleStringSize( const char *string, int *width, int *height )
|
||||
else
|
||||
gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height );
|
||||
}
|
||||
*/
|
||||
|
||||
inline int ConsoleStringLen( const char *string )
|
||||
{
|
||||
@ -126,12 +151,24 @@ inline int ConsoleStringLen( const char *string )
|
||||
|
||||
inline void ConsolePrint( const char *string )
|
||||
{
|
||||
gEngfuncs.pfnConsolePrint( string );
|
||||
//++ BulliT
|
||||
char *pszString = strdup( string );
|
||||
AgStripColors( (char*)pszString );
|
||||
gEngfuncs.pfnConsolePrint( pszString );
|
||||
free( pszString );
|
||||
//gEngfuncs.pfnConsolePrint( string );
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
inline void CenterPrint( const char *string )
|
||||
{
|
||||
gEngfuncs.pfnCenterPrint( string );
|
||||
//++ BulliT
|
||||
char *pszString = strdup( string );
|
||||
AgStripColors( (char*)pszString );
|
||||
gEngfuncs.pfnCenterPrint( pszString );
|
||||
free( pszString );
|
||||
//gEngfuncs.pfnCenterPrint( string );
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
// returns the players name of entity no.
|
||||
@ -167,6 +204,13 @@ extern vec3_t vec3_origin;
|
||||
|
||||
inline void UnpackRGB( int &r, int &g, int &b, unsigned long ulRGB )\
|
||||
{\
|
||||
//++ BulliT
|
||||
if( ulRGB == RGB_YELLOWISH )
|
||||
{
|
||||
AgGetHudColor( r, g, b );
|
||||
return;
|
||||
}
|
||||
//-- Martin Webrant
|
||||
r = ( ulRGB & 0xFF0000 ) >> 16;\
|
||||
g = ( ulRGB & 0xFF00 ) >> 8;\
|
||||
b = ulRGB & 0xFF;\
|
||||
|
@ -50,6 +50,10 @@ float g_ColorGreen[3] = { 0.6, 1.0, 0.6 };
|
||||
float g_ColorYellow[3] = { 1.0, 0.7, 0.0 };
|
||||
float g_ColorGrey[3] = { 0.8, 0.8, 0.8 };
|
||||
|
||||
//++ BulliT
|
||||
float g_ColorConsole[3] = { 1.0, 0.7, 0.0 };
|
||||
//-- Martin Webrant
|
||||
|
||||
float *GetClientColor( int clientIndex )
|
||||
{
|
||||
switch( g_PlayerExtraInfo[clientIndex].teamnumber )
|
||||
@ -58,7 +62,10 @@ float *GetClientColor( int clientIndex )
|
||||
case 2: return g_ColorRed;
|
||||
case 3: return g_ColorYellow;
|
||||
case 4: return g_ColorGreen;
|
||||
case 0: return g_ColorYellow;
|
||||
//case 0: return g_ColorYellow;
|
||||
//++ BulliT
|
||||
case 0: return g_ColorConsole;
|
||||
//-- Martin Webrant
|
||||
default: return g_ColorGrey;
|
||||
}
|
||||
|
||||
@ -124,8 +131,12 @@ int CHudDeathNotice::Draw( float flTime )
|
||||
|
||||
// Draw killers name
|
||||
if( rgDeathNoticeList[i].KillerColor )
|
||||
DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
|
||||
//++ BulliT
|
||||
//gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller, rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] );
|
||||
else
|
||||
//-- Martin Webrant
|
||||
x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller );
|
||||
}
|
||||
|
||||
r = 255; g = 80; b = 0;
|
||||
@ -144,8 +155,12 @@ int CHudDeathNotice::Draw( float flTime )
|
||||
if( rgDeathNoticeList[i].iNonPlayerKill == FALSE )
|
||||
{
|
||||
if( rgDeathNoticeList[i].VictimColor )
|
||||
DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
|
||||
//++ BulliT
|
||||
//gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim, rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
|
||||
else
|
||||
//-- Martin Webrant
|
||||
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1440,7 +1440,13 @@ void EV_EgonFire( event_args_t *args )
|
||||
if( EV_IsLocal( idx ) )
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation ( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 );
|
||||
|
||||
if( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction.
|
||||
//++ BulliT
|
||||
#define INSET_IN_EYE 2
|
||||
#define OBS_IN_EYE 4
|
||||
#define IS_FIRSTPERSON_SPEC ( g_iUser1 == OBS_IN_EYE || ( g_iUser1 && ( gHUD.m_Spectator.m_pip->value == INSET_IN_EYE ) ) )
|
||||
//if( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction.
|
||||
if( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value && !IS_FIRSTPERSON_SPEC ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction.
|
||||
//-- Martin Webrant
|
||||
{
|
||||
vec3_t vecSrc, vecEnd, angles, forward, right, up;
|
||||
pmtrace_t tr;
|
||||
|
@ -231,7 +231,11 @@ int CHudHealth::Draw( float flTime )
|
||||
|
||||
int iHeight = gHUD.m_iFontHeight;
|
||||
int iWidth = HealthWidth / 10;
|
||||
FillRGBA( x, y, iWidth, iHeight, 255, 160, 0, a );
|
||||
//++ BulliT
|
||||
//FillRGBA( x, y, iWidth, iHeight, 255, 160, 0, a );
|
||||
UnpackRGB( r, g, b, RGB_YELLOWISH );
|
||||
FillRGBA( x, y, iWidth, iHeight, r, g, b, a );
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
DrawDamage( flTime );
|
||||
|
@ -170,10 +170,13 @@ void CHud::Init( void )
|
||||
|
||||
HOOK_MESSAGE( ValClass );
|
||||
HOOK_MESSAGE( TeamNames );
|
||||
HOOK_MESSAGE( Feign );
|
||||
HOOK_MESSAGE( Detpack );
|
||||
HOOK_MESSAGE( BuildSt );
|
||||
HOOK_MESSAGE( RandomPC );
|
||||
//++ BulliT
|
||||
//TFC JUNK
|
||||
//HOOK_MESSAGE( Feign );
|
||||
//HOOK_MESSAGE( Detpack );
|
||||
//HOOK_MESSAGE( BuildSt );
|
||||
//HOOK_MESSAGE( RandomPC );
|
||||
//-- Martin Webrant
|
||||
HOOK_MESSAGE( ServerName );
|
||||
|
||||
HOOK_MESSAGE( Spectator );
|
||||
@ -228,8 +231,24 @@ void CHud::Init( void )
|
||||
m_TextMessage.Init();
|
||||
m_StatusIcons.Init();
|
||||
m_MOTD.Init();
|
||||
//++ BulliT
|
||||
m_Splash.Init();
|
||||
m_Countdown.Init();
|
||||
m_Timer.Init();
|
||||
m_PlayerId.Init();
|
||||
m_Settings.Init();
|
||||
m_SuddenDeath.Init();
|
||||
m_Longjump.Init();
|
||||
m_CustomTimer.Init();
|
||||
m_Timeout.Init();
|
||||
m_Global.Init();
|
||||
m_Vote.Init();
|
||||
m_Nextmap.Init();
|
||||
m_Location.Init();
|
||||
//m_IRC.Init();
|
||||
m_CTF.Init();
|
||||
m_Scoreboard.Init();
|
||||
|
||||
//-- Martin Webrant
|
||||
m_Menu.Init();
|
||||
|
||||
MsgFunc_ResetHUD( 0, 0, NULL );
|
||||
@ -254,6 +273,9 @@ CHud::~CHud()
|
||||
}
|
||||
m_pHudList = NULL;
|
||||
}
|
||||
//++ BulliT
|
||||
//m_IRC.UserCmd_IRCDisconnect();
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
// GetSpriteIndex()
|
||||
@ -396,7 +418,24 @@ void CHud::VidInit( void )
|
||||
m_AmmoSecondary.VidInit();
|
||||
m_TextMessage.VidInit();
|
||||
m_StatusIcons.VidInit();
|
||||
//++ BulliT
|
||||
m_Splash.VidInit();
|
||||
m_Countdown.VidInit();
|
||||
m_Timer.VidInit();
|
||||
m_PlayerId.VidInit();
|
||||
m_Settings.VidInit();
|
||||
m_SuddenDeath.VidInit();
|
||||
m_Longjump.VidInit();
|
||||
m_CustomTimer.VidInit();
|
||||
m_Timeout.VidInit();
|
||||
m_Global.VidInit();
|
||||
m_Vote.VidInit();
|
||||
m_Nextmap.VidInit();
|
||||
m_Location.VidInit();
|
||||
m_IRC.VidInit();
|
||||
m_CTF.VidInit();
|
||||
m_Scoreboard.VidInit();
|
||||
//-- Martin Webrant
|
||||
m_MOTD.VidInit();
|
||||
}
|
||||
|
||||
@ -511,9 +550,11 @@ int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf )
|
||||
int newfov = READ_BYTE();
|
||||
int def_fov = CVAR_GET_FLOAT( "default_fov" );
|
||||
|
||||
#ifdef CLIENT_WEAPONS
|
||||
//Weapon prediction already takes care of changing the fog. ( g_lastFOV ).
|
||||
if( cl_lw && cl_lw->value )
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
g_lastFOV = newfov;
|
||||
|
||||
|
41
cl_dll/hud.h
41
cl_dll/hud.h
@ -323,6 +323,9 @@ struct extra_player_info_t
|
||||
short playerclass;
|
||||
short teamnumber;
|
||||
char teamname[MAX_TEAM_NAME];
|
||||
//++ BulliT
|
||||
short flag;
|
||||
//-- Martin Webrant
|
||||
};
|
||||
|
||||
struct team_info_t
|
||||
@ -556,6 +559,25 @@ private:
|
||||
icon_sprite_t m_IconList[MAX_ICONSPRITES];
|
||||
};
|
||||
|
||||
//++ BulliT
|
||||
#include "AgGlobal.h"
|
||||
#include "AgHudSplash.h"
|
||||
#include "AgHudCountdown.h"
|
||||
#include "AgHudTimer.h"
|
||||
#include "AgHudPlayerId.h"
|
||||
#include "AgHudSettings.h"
|
||||
#include "AgHudSuddenDeath.h"
|
||||
#include "AgHudLongjump.h"
|
||||
#include "AgHudCustomTimer.h"
|
||||
#include "AgHudTimeout.h"
|
||||
#include "AgHudGlobal.h"
|
||||
#include "AgHudVote.h"
|
||||
#include "AgHudNextmap.h"
|
||||
#include "AgHudLocation.h"
|
||||
//#include "AgHudIRC.h"
|
||||
#include "AgHudCTF.h"
|
||||
#include "AgHudScoreboard.h"
|
||||
//-- Martin Webrant
|
||||
//
|
||||
//-----------------------------------------------------
|
||||
//
|
||||
@ -633,7 +655,24 @@ public:
|
||||
CHudStatusIcons m_StatusIcons;
|
||||
CHudScoreboard m_Scoreboard;
|
||||
CHudMOTD m_MOTD;
|
||||
|
||||
//++ BulliT
|
||||
AgHudSplash m_Splash;
|
||||
AgHudCountdown m_Countdown;
|
||||
AgHudTimer m_Timer;
|
||||
AgHudPlayerId m_PlayerId;
|
||||
AgHudSettings m_Settings;
|
||||
AgHudSuddenDeath m_SuddenDeath;
|
||||
AgHudLongjump m_Longjump;
|
||||
AgHudCustomTimer m_CustomTimer;
|
||||
AgHudTimeout m_Timeout;
|
||||
AgHudGlobal m_Global;
|
||||
AgHudVote m_Vote;
|
||||
AgHudNextmap m_Nextmap;
|
||||
AgHudLocation m_Location;
|
||||
//AgHudIRC m_IRC;
|
||||
AgHudCTF m_CTF;
|
||||
//AgHudScoreboard m_Scoreboard;
|
||||
//-- Martin Webrant
|
||||
void Init( void );
|
||||
void VidInit( void );
|
||||
void Think(void);
|
||||
|
@ -20,6 +20,11 @@
|
||||
#include "cl_util.h"
|
||||
//#include "triangleapi.h"
|
||||
|
||||
//++ BulliT
|
||||
#include <demo_api.h>
|
||||
#include "AgMatchReport.h"
|
||||
//-- Martin Webrant
|
||||
|
||||
#define MAX_LOGO_FRAMES 56
|
||||
|
||||
int grgLogoFrame[MAX_LOGO_FRAMES] =
|
||||
@ -93,6 +98,22 @@ int CHud::Redraw( float flTime, int intermission )
|
||||
if( m_flTimeDelta < 0 )
|
||||
m_flTimeDelta = 0;
|
||||
|
||||
if( m_iIntermission && !intermission )
|
||||
{
|
||||
//++ BulliT
|
||||
//Stop recording the demo.
|
||||
if( gEngfuncs.pDemoAPI->IsRecording() )
|
||||
gEngfuncs.pfnClientCmd( "stop\n" );
|
||||
//-- Martin Webrant
|
||||
}
|
||||
else if( !m_iIntermission && intermission )
|
||||
{
|
||||
//++ BulliT
|
||||
AgMatchReport Report;
|
||||
Report.Save();
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
if( m_flShotTime && m_flShotTime < flTime )
|
||||
{
|
||||
gEngfuncs.pfnClientCmd( "snapshot\n" );
|
||||
@ -194,6 +215,9 @@ const unsigned char colors[8][3] =
|
||||
|
||||
int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b )
|
||||
{
|
||||
//++ BulliT
|
||||
return AgDrawHudString( xpos, ypos, iMaxX, szIt, r, g, b );
|
||||
/*
|
||||
if( hud_textmode->value == 2 )
|
||||
{
|
||||
gEngfuncs.pfnDrawSetTextColor( r / 255.0, g / 255.0, b / 255.0 );
|
||||
@ -224,6 +248,8 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g
|
||||
}
|
||||
|
||||
return xpos;
|
||||
*/
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
int CHud::DrawHudStringLen( char *szIt )
|
||||
|
@ -133,8 +133,8 @@ int CHudSpectator::Init()
|
||||
m_drawnames = gEngfuncs.pfnRegisterVariable( "spec_drawnames", "1", 0 );
|
||||
m_drawcone = gEngfuncs.pfnRegisterVariable( "spec_drawcone", "1", 0 );
|
||||
m_drawstatus = gEngfuncs.pfnRegisterVariable( "spec_drawstatus", "1", 0 );
|
||||
m_autoDirector = gEngfuncs.pfnRegisterVariable( "spec_autodirector", "1", 0 );
|
||||
m_pip = gEngfuncs.pfnRegisterVariable( "spec_pip", "1", 0 );
|
||||
m_autoDirector = gEngfuncs.pfnRegisterVariable( "spec_autodirector", "0", 0 );
|
||||
m_pip = gEngfuncs.pfnRegisterVariable( "spec_pip", "0", 0 );
|
||||
|
||||
if( !m_drawnames || !m_drawcone || !m_drawstatus || !m_autoDirector || !m_pip )
|
||||
{
|
||||
@ -315,6 +315,16 @@ void CHudSpectator::SetSpectatorStartPosition()
|
||||
|
||||
else if( UTIL_FindEntityInMap( "info_player_coop", m_cameraOrigin, m_cameraAngles ) )
|
||||
iJumpSpectator = 1;
|
||||
//++ BulliT
|
||||
else if( UTIL_FindEntityInMap( "info_player_team1", m_cameraOrigin, m_cameraAngles ) )
|
||||
iJumpSpectator = 1;
|
||||
else if( UTIL_FindEntityInMap( "info_player_team2", m_cameraOrigin, m_cameraAngles ) )
|
||||
iJumpSpectator = 1;
|
||||
else if( UTIL_FindEntityInMap( "ctf_redspawn", m_cameraOrigin, m_cameraAngles ) )
|
||||
iJumpSpectator = 1;
|
||||
else if( UTIL_FindEntityInMap( "ctf_bluespawn", m_cameraOrigin, m_cameraAngles ) )
|
||||
iJumpSpectator = 1;
|
||||
//-- Martin Webrant
|
||||
else
|
||||
{
|
||||
// jump to 0,0,0 if no better position was found
|
||||
@ -417,9 +427,11 @@ int CHudSpectator::Draw( float flTime )
|
||||
sprintf( string, "%s", g_PlayerInfoList[i + 1].name );
|
||||
|
||||
lx = strlen( string ) * 3; // 3 is avg. character length :)
|
||||
|
||||
DrawSetTextColor( color[0], color[1], color[2] );
|
||||
DrawConsoleString( m_vPlayerPos[i][0] - lx,m_vPlayerPos[i][1], string );
|
||||
//++ BulliT
|
||||
//gEngfuncs.pfnDrawSetTextColor( color[0], color[1], color[2] );
|
||||
//DrawConsoleString( m_vPlayerPos[i][0] - lx, m_vPlayerPos[i][1], string );
|
||||
DrawConsoleString( m_vPlayerPos[i][0] - lx, m_vPlayerPos[i][1], string, color[0], color[1], color[2] );
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -736,6 +748,11 @@ void CHudSpectator::SetModes( int iNewMainMode, int iNewInsetMode )
|
||||
// if we are NOT in HLTV mode, main spectator mode is set on server
|
||||
if( !gEngfuncs.IsSpectateOnly() )
|
||||
{
|
||||
char cmdstring[32];
|
||||
|
||||
// forward command to server
|
||||
sprintf( cmdstring, "spec_mode %i", iNewMainMode );
|
||||
gEngfuncs.pfnServerCmd( cmdstring );
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1430,12 +1447,14 @@ void CHudSpectator::CheckSettings()
|
||||
// HL/TFC has no oberserver corsshair, so set it client side
|
||||
if( ( g_iUser1 == OBS_IN_EYE ) || ( g_iUser1 == OBS_ROAMING ) )
|
||||
{
|
||||
/*
|
||||
m_crosshairRect.left = 24;
|
||||
m_crosshairRect.top = 0;
|
||||
m_crosshairRect.right = 48;
|
||||
m_crosshairRect.bottom = 24;
|
||||
|
||||
SetCrosshair( m_hCrosshair, m_crosshairRect, 255, 255, 255 );
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -153,7 +153,8 @@ void DLLEXPORT CAM_Think( void )
|
||||
#endif
|
||||
vec3_t viewangles;
|
||||
|
||||
switch( (int)cam_command->value )
|
||||
//++ BulliT
|
||||
/* switch( (int)cam_command->value )
|
||||
{
|
||||
case CAM_COMMAND_TOTHIRDPERSON:
|
||||
CAM_ToThirdPerson();
|
||||
@ -165,6 +166,8 @@ void DLLEXPORT CAM_Think( void )
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*/
|
||||
//-- Martin Webrant
|
||||
|
||||
if( !cam_thirdperson )
|
||||
return;
|
||||
@ -642,7 +645,7 @@ void CAM_EndDistance( void )
|
||||
|
||||
int DLLEXPORT CL_IsThirdPerson( void )
|
||||
{
|
||||
return ( cam_thirdperson ? 1 : 0 ) || ( g_iUser1 && ( g_iUser2 == gEngfuncs.GetLocalPlayer()->index ) );
|
||||
return cam_thirdperson ? 1 : 0;
|
||||
}
|
||||
|
||||
void DLLEXPORT CL_CameraOffset( float *ofs )
|
||||
|
@ -23,6 +23,9 @@ extern "C"
|
||||
#include "usercmd.h"
|
||||
#include "const.h"
|
||||
#include "camera.h"
|
||||
//++ BulliT
|
||||
#include "AgVariableChecker.h"
|
||||
//-- Martin Webrant
|
||||
#include "in_defs.h"
|
||||
//#include "view.h"
|
||||
#include <string.h>
|
||||
@ -549,7 +552,9 @@ extern void __CmdFunc_InputPlayerSpecial( void );
|
||||
void IN_Attack2Down( void )
|
||||
{
|
||||
KeyDown( &in_attack2 );
|
||||
|
||||
//++ BulliT
|
||||
//Removed unused function that sends extra command to server. __CmdFunc_InputPlayerSpecial();
|
||||
//-- Martin Webrant
|
||||
gHUD.m_Spectator.HandleButtonsDown( IN_ATTACK2 );
|
||||
}
|
||||
|
||||
@ -736,28 +741,49 @@ void CL_AdjustAngles( float frametime, float *viewangles )
|
||||
|
||||
if( !( in_strafe.state & 1 ) )
|
||||
{
|
||||
viewangles[YAW] -= speed * cl_yawspeed->value * CL_KeyState( &in_right );
|
||||
viewangles[YAW] += speed * cl_yawspeed->value * CL_KeyState( &in_left );
|
||||
//++ BulliT
|
||||
viewangles[YAW] -= speed * ag_cl_yawspeed() * CL_KeyState( &in_right );
|
||||
viewangles[YAW] += speed * ag_cl_yawspeed() * CL_KeyState( &in_left );
|
||||
//viewangles[YAW] -= speed * cl_yawspeed->value * CL_KeyState( &in_right );
|
||||
//viewangles[YAW] += speed * cl_yawspeed->value * CL_KeyState( &in_left );
|
||||
//-- Martin Webrant
|
||||
viewangles[YAW] = anglemod( viewangles[YAW] );
|
||||
}
|
||||
|
||||
if( in_klook.state & 1 )
|
||||
{
|
||||
//++ BulliT
|
||||
viewangles[PITCH] -= speed * ag_cl_pitchspeed() * CL_KeyState( &in_forward );
|
||||
viewangles[PITCH] += speed * ag_cl_pitchspeed() * CL_KeyState( &in_back );
|
||||
/*
|
||||
viewangles[PITCH] -= speed * cl_pitchspeed->value * CL_KeyState( &in_forward );
|
||||
viewangles[PITCH] += speed * cl_pitchspeed->value * CL_KeyState( &in_back );
|
||||
*/
|
||||
//-- Martin Webrant
|
||||
}
|
||||
|
||||
up = CL_KeyState( &in_lookup );
|
||||
down = CL_KeyState( &in_lookdown );
|
||||
|
||||
viewangles[PITCH] -= speed * cl_pitchspeed->value * up;
|
||||
viewangles[PITCH] += speed * cl_pitchspeed->value * down;
|
||||
//++ BulliT
|
||||
viewangles[PITCH] -= speed * ag_cl_pitchspeed() * up;
|
||||
viewangles[PITCH] += speed * ag_cl_pitchspeed() * down;
|
||||
//viewangles[PITCH] -= speed * cl_pitchspeed->value * up;
|
||||
//viewangles[PITCH] += speed * cl_pitchspeed->value * down;
|
||||
//-- Martin Webran
|
||||
|
||||
//++ BulliT
|
||||
if( viewangles[PITCH] > ag_cl_pitchdown() )
|
||||
viewangles[PITCH] = ag_cl_pitchdown();
|
||||
if( viewangles[PITCH] < -ag_cl_pitchup() )
|
||||
viewangles[PITCH] = -ag_cl_pitchup();
|
||||
/*
|
||||
if( viewangles[PITCH] > cl_pitchdown->value )
|
||||
viewangles[PITCH] = cl_pitchdown->value;
|
||||
if( viewangles[PITCH] < -cl_pitchup->value )
|
||||
viewangles[PITCH] = -cl_pitchup->value;
|
||||
|
||||
*/
|
||||
//-- Martin Webrant
|
||||
if( viewangles[ROLL] > 50 )
|
||||
viewangles[ROLL] = 50;
|
||||
if( viewangles[ROLL] < -50 )
|
||||
|
@ -19,8 +19,12 @@
|
||||
#include "in_defs.h"
|
||||
#include "../engine/keydefs.h"
|
||||
//#include "view.h"
|
||||
#include "windows.h"
|
||||
//#include "windows.h"
|
||||
|
||||
//++ BulliT
|
||||
extern int g_iPure;
|
||||
#include "AgVariableChecker.h"
|
||||
//-- Martin Webrant
|
||||
#define MOUSE_BUTTON_COUNT 5
|
||||
|
||||
// Set this to 1 to show mouse cursor. Experimental
|
||||
@ -151,6 +155,10 @@ Force_CenterView_f
|
||||
*/
|
||||
void Force_CenterView_f( void )
|
||||
{
|
||||
//++ BulliT
|
||||
if( 0 < g_iPure )
|
||||
return;
|
||||
//-- Martin Webrant
|
||||
vec3_t viewangles;
|
||||
|
||||
if( !iMouseInUse )
|
||||
@ -349,10 +357,18 @@ void IN_MouseMove( float frametime, usercmd_t *cmd )
|
||||
if( ( in_mlook.state & 1 ) && !( in_strafe.state & 1 ) )
|
||||
{
|
||||
viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
//++ BulliT
|
||||
if( viewangles[PITCH] > ag_cl_pitchdown() )
|
||||
viewangles[PITCH] = ag_cl_pitchdown();
|
||||
if( viewangles[PITCH] < -ag_cl_pitchup() )
|
||||
viewangles[PITCH] = -ag_cl_pitchup();
|
||||
/*
|
||||
if( viewangles[PITCH] > cl_pitchdown->value )
|
||||
viewangles[PITCH] = cl_pitchdown->value;
|
||||
if( viewangles[PITCH] < -cl_pitchup->value )
|
||||
viewangles[PITCH] = -cl_pitchup->value;
|
||||
*/
|
||||
//-- Martin Webrant
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -769,11 +785,17 @@ void IN_JoyMove( float frametime, usercmd_t *cmd )
|
||||
// only absolute control support here (joy_advanced is 0)
|
||||
if( m_pitch->value < 0.0 )
|
||||
{
|
||||
viewangles[PITCH] -= ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value;
|
||||
//++ BulliT
|
||||
//viewangles[PITCH] -= ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value;
|
||||
viewangles[PITCH] -= ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * ag_cl_pitchspeed();
|
||||
//-- Martin Webrant
|
||||
}
|
||||
else
|
||||
{
|
||||
viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value;
|
||||
//++ BulliT
|
||||
//viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value;
|
||||
viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * ag_cl_pitchspeed();
|
||||
//-- Martin Webrant
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -808,7 +830,8 @@ void IN_JoyMove( float frametime, usercmd_t *cmd )
|
||||
{
|
||||
if( dwControlMap[i] == JOY_ABSOLUTE_AXIS )
|
||||
{
|
||||
viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * aspeed * cl_yawspeed->value;
|
||||
viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * aspeed * ag_cl_yawspeed();
|
||||
//viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * aspeed * cl_yawspeed->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -825,7 +848,10 @@ void IN_JoyMove( float frametime, usercmd_t *cmd )
|
||||
// pitch movement detected and pitch movement desired by user
|
||||
if( dwControlMap[i] == JOY_ABSOLUTE_AXIS )
|
||||
{
|
||||
viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value;
|
||||
//++ BulliT
|
||||
//viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value;
|
||||
viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * ag_cl_pitchspeed();
|
||||
//-- Martin Webrant
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -840,11 +866,18 @@ void IN_JoyMove( float frametime, usercmd_t *cmd )
|
||||
}
|
||||
|
||||
// bounds check pitch
|
||||
//++ BulliT
|
||||
if( viewangles[PITCH] > ag_cl_pitchdown() )
|
||||
viewangles[PITCH] = ag_cl_pitchdown();
|
||||
if( viewangles[PITCH] < -ag_cl_pitchup() )
|
||||
viewangles[PITCH] = -ag_cl_pitchup();
|
||||
/*
|
||||
if( viewangles[PITCH] > cl_pitchdown->value )
|
||||
viewangles[PITCH] = cl_pitchdown->value;
|
||||
if( viewangles[PITCH] < -cl_pitchup->value )
|
||||
viewangles[PITCH] = -cl_pitchup->value;
|
||||
|
||||
*/
|
||||
//-- Martin Webrant
|
||||
gEngfuncs.SetViewAngles( (float *)viewangles );
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,10 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
//++ BulliT
|
||||
extern cvar_t *g_pcl_playtalk;
|
||||
//-- Martin Webrant
|
||||
|
||||
extern float *GetClientColor( int clientIndex );
|
||||
|
||||
#define MAX_LINES 5
|
||||
@ -128,9 +132,11 @@ int CHudSayText::Draw( float flTime )
|
||||
// draw the first x characters in the player color
|
||||
strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 32 ) );
|
||||
buf[min( g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH + 31 )] = 0;
|
||||
DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
||||
int x = DrawConsoleString( LINE_START, y, buf );
|
||||
|
||||
//++ BulliT
|
||||
int x = DrawConsoleString( LINE_START, y, buf, g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
||||
//DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
|
||||
//int x = DrawConsoleString( LINE_START, y, buf );
|
||||
//-- Martin Webrant
|
||||
// color is reset after each string draw
|
||||
DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] );
|
||||
}
|
||||
@ -162,6 +168,16 @@ void CHudSayText::SayTextPrint( const char *pszBuf, int iBufSize, int clientInde
|
||||
int i;
|
||||
ConsolePrint( pszBuf );
|
||||
|
||||
//++ BulliT
|
||||
if( CVAR_GET_FLOAT( "cl_only_team_talk" ) == 1 )
|
||||
{
|
||||
if( 0 != strncmp( pszBuf + 1,"(T)", 3 ) && 0 != strncmp( pszBuf + 1, "(C)", 3 ) )
|
||||
{
|
||||
ConsolePrint( pszBuf );
|
||||
return;
|
||||
}
|
||||
}
|
||||
//-- Martin Webrant
|
||||
// find an empty string slot
|
||||
for( i = 0; i < MAX_LINES; i++ )
|
||||
{
|
||||
@ -198,6 +214,9 @@ void CHudSayText::SayTextPrint( const char *pszBuf, int iBufSize, int clientInde
|
||||
|
||||
strncpy( g_szLineBuffer[i], pszBuf, max( iBufSize - 1, MAX_CHARS_PER_LINE - 1 ) );
|
||||
|
||||
//++ BulliT
|
||||
gHUD.m_Location.ParseAndEditSayString( g_szLineBuffer[i],clientIndex );
|
||||
//-- Martin Webrant
|
||||
// make sure the text fits in one line
|
||||
EnsureTextFitsInOneLineAndWrapIfHaveTo( i );
|
||||
|
||||
@ -208,8 +227,10 @@ void CHudSayText::SayTextPrint( const char *pszBuf, int iBufSize, int clientInde
|
||||
}
|
||||
|
||||
m_iFlags |= HUD_ACTIVE;
|
||||
PlaySound( "misc/talk.wav", 1 );
|
||||
|
||||
//++ BulliT
|
||||
if( 0 < g_pcl_playtalk->value )
|
||||
PlaySound( "misc/talk.wav", 1 );
|
||||
//-- Martin Webrant
|
||||
if( ScreenHeight >= 480 )
|
||||
Y_START = ScreenHeight - 60;
|
||||
else
|
||||
|
@ -202,9 +202,12 @@ int CHudStatusBar::Draw( float fTime )
|
||||
}
|
||||
|
||||
if( m_pflNameColors[i] )
|
||||
DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
|
||||
|
||||
DrawConsoleString( x, y, m_szStatusBar[i] );
|
||||
//++ BulliT
|
||||
//gEngfuncs.pfnDrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
|
||||
DrawConsoleString( x, y, m_szStatusBar[i], m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] );
|
||||
else
|
||||
//-- Martin Webrant
|
||||
DrawConsoleString( x, y, m_szStatusBar[i] );
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1393,7 +1393,7 @@ void V_CalcSpectatorRefdef( struct ref_params_s * pparams )
|
||||
}
|
||||
|
||||
// predict missing client data and set weapon model ( in HLTV mode or inset in eye mode )
|
||||
if( gEngfuncs.IsSpectateOnly() )
|
||||
if( 1 ) //gEngfuncs.IsSpectateOnly() )
|
||||
{
|
||||
V_GetInEyePos( g_iUser2, pparams->simorg, pparams->cl_viewangles );
|
||||
|
||||
|
21
dlls/aghl/agadmin.cpp
Normal file
21
dlls/aghl/agadmin.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
//++ BulliT
|
||||
|
||||
#include "extdll.h"
|
||||
#include "util.h"
|
||||
#include "agglobal.h"
|
||||
#include "agadmin.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
AgAdmin::AgAdmin()
|
||||
{
|
||||
}
|
||||
|
||||
AgAdmin::~AgAdmin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//-- Martin Webrant
|
24
dlls/aghl/agadmin.h
Normal file
24
dlls/aghl/agadmin.h
Normal file
@ -0,0 +1,24 @@
|
||||
//++ BulliT
|
||||
|
||||
#if !defined(AFX_AGADMIN_H__E1E58F06_B2BD_43F9_99A0_0B3F6D6B7B16__INCLUDED_)
|
||||
#define AFX_AGADMIN_H__E1E58F06_B2BD_43F9_99A0_0B3F6D6B7B16__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
// The admin user
|
||||
class AgAdmin
|
||||
{
|
||||
public:
|
||||
AgAdmin();
|
||||
virtual ~AgAdmin();
|
||||
|
||||
AgString m_sAdmin;
|
||||
AgString m_sPassword;
|
||||
AgString m_sAuthID;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_AGADMIN_H__E1E58F06_B2BD_43F9_99A0_0B3F6D6B7B16__INCLUDED_)
|
||||
|
||||
//-- Martin Webrant
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user