-
Notifications
You must be signed in to change notification settings - Fork 0
/
MARK.CPP
138 lines (105 loc) · 2.36 KB
/
MARK.CPP
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
#define Use_MsgBase
#include "proboard.hpp"
MarkedMsgList::MarkedMsgList()
{
msgList = new MessageIndex[MAX_MARKED_MSGS];
n = 0;
}
MarkedMsgList::MarkedMsgList(const MarkedMsgList &m)
{
msgList = new MessageIndex[MAX_MARKED_MSGS];
(*this) = m;
}
MarkedMsgList::~MarkedMsgList()
{
delete [] msgList;
}
void
MarkedMsgList::operator=(const MarkedMsgList& m)
{
for(int i=0 ; i < MAX_MARKED_MSGS ; i++) msgList[i] = m.msgList[i];
n = m.n;
}
bool
MarkedMsgList::add(MessageIndex& mi)
{
if(isMarked(mi)) return TRUE;
if(n < MAX_MARKED_MSGS)
{
msgList[n++] = mi;
return TRUE;
}
else
{
return FALSE;
}
}
bool
MarkedMsgList::add(Message& msg)
{
return add(MessageIndex(msg.areaNum(),msg.id));
}
bool
MarkedMsgList::isMarked(MessageIndex& mi)
{
for(int i=0 ; i<n ; i++)
{
if(msgList[i].num == mi.num && msgList[i].area == mi.area) return TRUE;
}
return FALSE;
}
void
MarkedMsgList::sort()
{
int x,y;
for(x=0;x<n-1;x++)
for(y=x+1;y<n;y++)
if(msgList[x].area > msgList[y].area)
{
MessageIndex tmp = msgList[x];
msgList[x] = msgList[y];
msgList[y] = tmp;
}
for(x=0;x<n-1;x++)
for(y=x+1;y<n;y++)
if(msgList[x].area==msgList[y].area && msgList[x].num>msgList[y].num)
{
MessageIndex tmp = msgList[x];
msgList[x] = msgList[y];
msgList[y] = tmp;
}
}
void
get_new_msgs(MarkedMsgList& marked,int area)
{
Message msg;
MsgArea ma;
io << ' ';
int start = 1;
int end = 1000;
if(area)
{
start = end = area;
}
for(int i=start ; i <= end ; i++)
{
if( (area && area != i)
|| (!user.combinedBoards.connected(i) && !area)
|| !ma.read(i)
) continue;
if( !check_access(ma.readLevel,ma.readFlags,ma.readFlagsNot)
&& !ma.sysopAccess()) continue;
if(ma.highMsg() <= ma.lastRead(user_recnr)) continue;
bool ok = msg.readFirst(READMSG_ALL,1,ma.lastRead(user_recnr) + 1,"",i);
int cnt = 0;
while(ok)
{
if(!marked.add(MessageIndex(msg.areaNum(),msg.id))) break;
io << '\b' << (("/-\\|")[cnt]) ;
cnt = (++cnt) % 4;
ok = msg.readNext(READMSG_ALL,1,"");
}
if(ok) break;
}
io << "\b \b";
}