2008-07-01 11:48:17 +02:00
|
|
|
/**
|
2008-12-28 07:02:05 +01:00
|
|
|
* vim: set ts=4 :
|
|
|
|
* =============================================================================
|
|
|
|
* SourceMod
|
|
|
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
|
|
* =============================================================================
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
|
|
* Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
2008-07-01 11:48:17 +02:00
|
|
|
|
|
|
|
#ifndef _INCLUDE_SOURCEMOD_GAMEDATAFETCHER_H_
|
|
|
|
#define _INCLUDE_SOURCEMOD_GAMEDATAFETCHER_H_
|
|
|
|
|
|
|
|
#include "sourcemod.h"
|
|
|
|
#include "TextParsers.h"
|
|
|
|
#include "IThreader.h"
|
|
|
|
#include "Logger.h"
|
|
|
|
#include "LibrarySys.h"
|
|
|
|
#include "ThreadSupport.h"
|
|
|
|
#include "sm_memtable.h"
|
2008-12-28 01:50:13 +01:00
|
|
|
#include <sh_string.h>
|
|
|
|
#include <sh_list.h>
|
2008-07-01 11:48:17 +02:00
|
|
|
|
|
|
|
enum UpdateStatus
|
|
|
|
{
|
|
|
|
Update_Unknown = 0, /* Version wasn't recognised or version querying is unsupported */
|
|
|
|
Update_Current = 1, /* Server is running latest version */
|
|
|
|
Update_NewBuild = 2, /* Server is on a svn release and a newer version is available */
|
|
|
|
Update_MinorAvailable = 3, /* Server is on a release and a minor release has superceeded it */
|
|
|
|
Update_MajorAvailable = 4, /* Server is on a release and a major release has superceeded it */
|
|
|
|
Update_CriticalAvailable = 5, /* A critical update has been released (security fixes etc) */
|
|
|
|
};
|
|
|
|
|
2008-12-27 05:26:21 +01:00
|
|
|
class MD5;
|
|
|
|
|
2008-07-01 11:48:17 +02:00
|
|
|
class BuildMD5ableBuffer : public ITextListener_SMC
|
|
|
|
{
|
|
|
|
public:
|
2008-12-27 05:26:21 +01:00
|
|
|
BuildMD5ableBuffer();
|
|
|
|
~BuildMD5ableBuffer();
|
|
|
|
void ReadSMC_ParseStart();
|
|
|
|
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
|
|
|
|
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name);
|
|
|
|
void ReadSMC_ParseEnd(bool halted, bool failed);
|
|
|
|
public:
|
|
|
|
MD5 *checksum;
|
2008-07-01 11:48:17 +02:00
|
|
|
private:
|
|
|
|
BaseStringTable *stringTable;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FileData
|
|
|
|
{
|
|
|
|
SourceHook::String *filename;
|
2008-12-27 05:26:21 +01:00
|
|
|
char checksum[33];
|
2008-07-01 11:48:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class FetcherThread : public IThread
|
|
|
|
{
|
|
|
|
public:
|
2008-12-27 05:26:21 +01:00
|
|
|
FetcherThread();
|
|
|
|
~FetcherThread();
|
|
|
|
public:
|
2008-07-01 11:48:17 +02:00
|
|
|
void RunThread(IThreadHandle *pHandle);
|
|
|
|
void OnTerminate(IThreadHandle *pHandle, bool cancel);
|
|
|
|
private:
|
|
|
|
int BuildGameDataQuery(char *buffer, int maxlen);
|
|
|
|
void ProcessGameDataQuery(int SocketDescriptor);
|
2008-10-19 06:27:54 +02:00
|
|
|
int RecvData(int socketDescriptor, char *buffer, int len);
|
|
|
|
int SendData(int socketDescriptor, char *buffer, int len);
|
2008-07-01 11:48:17 +02:00
|
|
|
int ConnectSocket();
|
|
|
|
void HandleUpdateStatus(UpdateStatus status, short version[4]);
|
|
|
|
public:
|
|
|
|
SourceHook::CVector<FileData *> filenames;
|
2008-12-28 01:50:13 +01:00
|
|
|
bool needsRestart;
|
2008-12-28 07:02:05 +01:00
|
|
|
bool wasSuccess;
|
|
|
|
private:
|
2008-12-28 01:50:13 +01:00
|
|
|
UpdateStatus updateStatus;
|
2008-07-01 11:48:17 +02:00
|
|
|
BaseMemTable *memtable;
|
2008-12-28 01:50:13 +01:00
|
|
|
short build[4];
|
2008-07-01 11:48:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern bool g_blockGameDataLoad;
|
|
|
|
|
|
|
|
#endif // _INCLUDE_SOURCEMOD_GAMEDATAFETCHER_H_
|
2008-12-27 05:26:21 +01:00
|
|
|
|