summaryrefslogtreecommitdiff
path: root/plugins/WinterSpeak/src/AnnounceDatabase.cpp
blob: de701214d8ce2a50a7e760ef7140b87790acd6c3 (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
#include "stdafx.h"
#include "AnnounceDatabase.h"


//------------------------------------------------------------------------------
namespace
{
	const char *SPEAK        = "speak_announce";
	const char *STATUS_FLAGS = "status_flags";
	const char *EVENT_FLAGS  = "event_flags";
	const char *MAX_MSG_SIZE = "max_msg_size";
}

//------------------------------------------------------------------------------
// public:
//------------------------------------------------------------------------------
AnnounceDatabase::AnnounceDatabase() : m_status_flags(0), m_event_flags(0), m_max_msg(0)
{	
	load();
}

//------------------------------------------------------------------------------
AnnounceDatabase::~AnnounceDatabase()
{
}

//------------------------------------------------------------------------------
bool AnnounceDatabase::getStatusFlag(StatusFlag flag) const
{
	return ((m_status_flags & (1 << flag)) != 0);
}

//------------------------------------------------------------------------------
void AnnounceDatabase::setStatusFlag(StatusFlag flag, bool state)
{ 
	if (state)
	{
		m_status_flags |= (1 << flag);
	}
	else
	{
		m_status_flags &= ~(1 << flag);
	}
}

//------------------------------------------------------------------------------
bool AnnounceDatabase::getEventFlag(EventFlag flag) const
{
	return ((m_event_flags & (1 << flag)) != 0);
}

//------------------------------------------------------------------------------
void AnnounceDatabase::setEventFlag(EventFlag flag, bool state)
{ 
	if (state)
	{
		m_event_flags |= (1 << flag);
	}
	else
	{
		m_event_flags &= ~(1 << flag);
	}
}

//------------------------------------------------------------------------------
void AnnounceDatabase::load()
{
	m_status_flags = db_get_dw(0, SPEAK, STATUS_FLAGS, 0xffff);
	m_event_flags  = db_get_dw(0, SPEAK, EVENT_FLAGS, 0xffff);
	m_max_msg      = db_get_dw(0, SPEAK, MAX_MSG_SIZE, 50);
}

//------------------------------------------------------------------------------
void 
AnnounceDatabase::save()
{
	db_set_dw(0, SPEAK, STATUS_FLAGS, m_status_flags);
	db_set_dw(0, SPEAK, EVENT_FLAGS, m_event_flags);
	db_set_dw(0, SPEAK, MAX_MSG_SIZE, m_max_msg);
}

//==============================================================================