File: YOGPlayerStoredInfo.cpp

package info (click to toggle)
glob2 0.9.4.4-5
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 34,824 kB
  • sloc: cpp: 89,685; python: 868; ansic: 259; sh: 49; makefile: 16
file content (154 lines) | stat: -rw-r--r-- 3,069 bytes parent folder | download | duplicates (5)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
  Copyright (C) 2008 Bradley Arsenault

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
  (at your option) any later version.

  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, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include "YOGPlayerStoredInfo.h"

#include "Stream.h"
#include <sstream>

YOGPlayerStoredInfo::YOGPlayerStoredInfo()
{
	banned=false;
	moderator=false;
	///The default rating is 1000
	rating = 1000;
}



void YOGPlayerStoredInfo::setMuted(boost::posix_time::ptime nunmute_time)
{
	unmute_time = nunmute_time;
}



void YOGPlayerStoredInfo::setUnmuted()
{
	unmute_time = boost::posix_time::ptime();
}



bool YOGPlayerStoredInfo::isMuted() const
{
	boost::posix_time::ptime current_time = boost::posix_time::second_clock::local_time();
	if(unmute_time == boost::posix_time::ptime() || unmute_time < current_time)
	{
		return false;
	}
	return true;
}



void YOGPlayerStoredInfo::setBanned()
{
	banned = true;
}



void YOGPlayerStoredInfo::setUnbanned()
{
	banned = false;
}



bool YOGPlayerStoredInfo::isBanned() const
{
	return banned;
}



void YOGPlayerStoredInfo::setModerator(bool isModerator)
{
	moderator=isModerator;
}



bool YOGPlayerStoredInfo::isModerator() const
{
	return moderator;
}



void YOGPlayerStoredInfo::setPlayerRating(int nrating)
{
	rating = nrating;
}



int YOGPlayerStoredInfo::getPlayerRating() const
{
	return rating;
}



void YOGPlayerStoredInfo::encodeData(GAGCore::OutputStream* stream) const
{
	stream->writeEnterSection("YOGPlayerStoredInfo");
	std::stringstream time;
	time<<unmute_time;
	stream->writeText(time.str(), "unmute_time");
	stream->writeUint8(banned, "banned");
	stream->writeUint8(moderator, "moderator");
	stream->writeUint32(rating, "rating");
	stream->writeLeaveSection();
}



void YOGPlayerStoredInfo::decodeData(GAGCore::InputStream* stream, Uint32 dataVersionMinor)
{
	stream->readEnterSection("YOGPlayerStoredInfo");
	std::string b = stream->readText("unmute_time");
	std::stringstream time;
	time<<b;
	time>>unmute_time;
	banned=stream->readUint8("banned");
	moderator=stream->readUint8("moderator");
	rating=stream->readUint32("rating");
	stream->readLeaveSection();
}



bool YOGPlayerStoredInfo::operator==(const YOGPlayerStoredInfo& rhs) const
{
	if(unmute_time == rhs.unmute_time && banned == rhs.banned && rating == rhs.rating)
		return true;
	return false;
}



bool YOGPlayerStoredInfo::operator!=(const YOGPlayerStoredInfo& rhs) const
{
	if(unmute_time != rhs.unmute_time && banned == rhs.banned && rating == rhs.rating)
		return true;
	return false;
}