summaryrefslogtreecommitdiff
path: root/engine/networkstringtablecontainerserver.h
blob: 7f21546c825bfa149e6802331139280c105958e5 (plain) (blame)
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
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef NETWORKSTRINGTABLECONTAINERSERVER_H
#define NETWORKSTRINGTABLECONTAINERSERVER_H
#ifdef _WIN32
#pragma once
#endif

#include "inetworkstringtableserver.h"
#include "utlvector.h"
#include "bitbuf.h"

class CNetworkStringTableServer;
class client_t;
class bf_write_t;

//-----------------------------------------------------------------------------
// Purpose: Implements game .dll string table interface
//-----------------------------------------------------------------------------
class CNetworkStringTableContainerServer : public INetworkStringTableServer
{
public:
	// Contstruction
							CNetworkStringTableContainerServer( void );
							~CNetworkStringTableContainerServer( void );

	// Implement INetworkStringTableServer
	virtual TABLEID			CreateStringTable( const char *tableName, int maxentries );
	virtual int				GetNumStrings( TABLEID stringTable );
	virtual int				GetMaxStrings( TABLEID stringTable );

	virtual int				AddString( TABLEID stringTable, const char *value, int length = 0, const void *userdata = 0 );
	virtual void			SetString( TABLEID stringTable, int stringNumber, const char *value );
	virtual void			SetStringUserData( TABLEID stringTable, int stringNumber, int length = 0, const void *userdata = 0 );
	virtual const char		*GetString( TABLEID stringTable, int stringNumber );
	virtual const void		*GetStringUserData( TABLEID stringTable, int stringNumber, int *length = 0 );

	virtual int				FindStringIndex( TABLEID stringTable, char const *string );

	virtual const char		*GetTableName( TABLEID stringTable );

	// Table accessors
	TABLEID					FindTable( const char *tableName );
	CNetworkStringTableServer *GetTable( TABLEID stringTable );

	// Delete all tables
	void					RemoveAllTables( void );

	// Guards so game .dll can't create tables at the wrong time
	void					AllowCreation( void );
	void					DisallowCreation( void );

	// Print table data to console
	void					Dump( void );

private:
	// Guard
	bool					m_bAllowCreation;

	CUtlVector < CNetworkStringTableServer * > m_Tables;
};

extern CNetworkStringTableContainerServer *networkStringTableContainerServer;

#endif // NETWORKSTRINGTABLECONTAINERSERVER_H