Skip to content

Latest commit

 

History

History
402 lines (377 loc) · 12 KB

misc1.pas

File metadata and controls

402 lines (377 loc) · 12 KB
 
Nov 18, 2000
Nov 18, 2000
1
2
3
4
5
6
7
8
(*****************************************************************************)
(*> <*)
(*> MISC1 .PAS - Written by Eric Oman <*)
(*> <*)
(*> Various miscellaneous functions used by the BBS. <*)
(*> <*)
(*> <*)
(*****************************************************************************)
Nov 25, 2000
Nov 25, 2000
9
{$A+,B+,E+,F+,I+,L+,N-,O+,R-,S+,V-}
Nov 18, 2000
Nov 18, 2000
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
unit misc1;
interface
uses
crt, dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
common;
procedure reqchat(x:astr);
procedure TimeBank(s:astr);
function ctp(t,b:longint):astr;
procedure vote;
implementation
uses mail2;
procedure reqchat(x:astr);
var c,ii,i:integer;
r:char;
chatted:boolean;
s,why:astr;
begin
why:='';
if (pos(';',x)<>0) then why:=copy(x,pos(';',x)+1,length(x));
if (why='') then why:='^3Why do you want to chat?';
nl;
if ((chatt<systat.maxchat) or (cso)) then begin
sprint(why);
chatted:=FALSE;
prt(':'); mpl(70); inputl(s,70);
if (s<>'') then begin
inc(chatt);
if ((not sysop) or (rchat in thisuser.ac)) then
if (length(s)<64) then
sysoplog(#3#4+'Chat attempt: "'+#3#5+s+#3#4+'"')
else begin
sysoplog(#3#4+'Chat attempt:');
sl1(#3#4+' "'+#3#5+s+#3#4+'"');
end
else begin
sl1(#3#4+'Chat: "'+#3#5+s+#3#4+'"');
commandline('Press <SPACE> to chat or <ENTER> to SHUT UP for rest of call');
nl;
sprint(fstring.chatcall1);
nl;
ii:=0; c:=0;
repeat
inc(ii);
if (outcom) then sendcom1(^G);
sprompt(fstring.chatcall2);
if (outcom) then sendcom1(^G);
if (shutupchatcall) then delay(1500)
else
for i:=1 to 5 do begin
sound(800); delay(33);
sound(1300); delay(35);
sound(1700); delay(37);
sound(2100); delay(39);
sound(3200); delay(45);
sound(2100); delay(39);
sound(1700); delay(37);
sound(1300); delay(35);
sound(800);
end;
nosound;
if (keypressed) then begin
r:=readkey;
case r of
#32:begin
commandline('');
chatted:=TRUE; chatt:=0;
pap:=0;
chat;
end;
^M:shutupchatcall:=TRUE;
end;
end;
until ((chatted) or (ii=9) or (hangup));
commandline('');
end;
if (not chatted) then begin
chatr:=s;
printf('nosysop');
if (value(x)<>0) then begin
irt:='Tried chatting.';
imail(value(x));
end;
end else
chatr:='';
tleft;
end;
end else begin
printf('goaway');
irt:='Tried chatting (more than '+cstr(systat.maxchat)+' times!)';
sysoplog('Tried chatting more than '+cstr(systat.maxchat)+' times');
imail(value(x));
end;
end;
procedure TimeBank(s:astr);
var lng,maxperday,maxever:longint;
zz:integer;
oc:astr;
c:char;
function cantdeposit:boolean;
begin
cantdeposit:=TRUE;
if ((thisuser.timebankadd>=maxperday) and (maxperday<>0)) then exit;
if ((thisuser.timebank>=maxever) and (maxever<>0)) then exit;
cantdeposit:=FALSE;
end;
begin
maxperday:=value(s); maxever:=0;
if (pos(';',s)<>0) then maxever:=value(copy(s,pos(';',s)+1,length(s)));
if ((maxever<>0) and (thisuser.timebank>maxever)) then
thisuser.timebank:=maxever;
nl; nl;
sprint('^5Telegard Time Bank v'+ver);
nl;
if (not cantdeposit) then
sprint('^3A^1)dd time to your account.');
sprint('^3G^1)oodbye, log off now.');
sprint('^3Q^1)uit to BBS.');
if (choptime=0.0) then
sprint('^3W^1)ithdraw time from your account.');
nl;
if (choptime<>0.0) then
sprint(#3#7+'You cannot withdraw time during this call.');
if (cantdeposit) then begin
if ((thisuser.timebankadd>=maxperday) and (maxperday<>0)) then
sprint(#3#7+'You cannot add any more time to your account today.');
if ((thisuser.timebank>=maxever) and (maxever<>0)) then
sprint(#3#7+'You cannot add any more time to your account!');
end;
nl;
sprompt(#3#5+'In your account: '+#3#3+cstr(thisuser.timebank)+
#3#5+' Time left online: '+#3#3+cstr(trunc(nsl) div 60));
if (thisuser.timebankadd<>0) then
sprompt(' ^5Deposited today: ^3'+cstr(thisuser.timebankadd));
nl;
sprompt(#3#5+'Account limits: '+#3#3);
if (maxever<>0) then sprompt(cstr(maxever)+' max')
else sprompt('No max limit');
if (maxperday<>0) then sprompt(' / '+cstr(maxperday)+' per day');
nl; nl;
prt('Time Bank :');
oc:='QG';
if (choptime=0.0) then oc:=oc+'W';
if (not cantdeposit) then oc:=oc+'A';
onek(c,oc);
case c of
'A':begin
prt('Add how many minutes? '); inu(zz); lng:=zz;
nl;
if (not badini) then
if (lng>0) then
if (lng>trunc(nsl) div 60) then
sprint(#3#7+'You don''t have that much time left to deposit!')
else
if (lng+thisuser.timebankadd>maxperday) and (maxperday<>0) then
sprint(#3#7+'You can only add '+cstr(maxperday)+' minutes to your account per day!')
else
if (lng+thisuser.timebank>maxever) and (maxever<>0) then
sprint(#3#7+'Your account deposit limit is '+cstr(maxever)+' minutes!')
else begin
inc(thisuser.timebankadd,lng);
inc(thisuser.timebank,lng);
dec(thisuser.tltoday,lng);
sprint('^5In your account: ^3'+cstr(thisuser.timebank)+
'^5 Time left online: ^3'+cstr(trunc(nsl) div 60));
sysoplog('TimeBank: Deposited '+cstr(lng)+' minutes.');
end;
end;
'G':hangup:=TRUE;
'W':begin
prt('Withdraw how many minutes? '); inu(zz); lng:=zz;
nl;
if (not badini) then
if (lng>thisuser.timebank) then
sprint(#3#7+'You don''t have that much time left in your account!')
else
if (lng>0) then begin
dec(thisuser.timebankadd,lng);
if (thisuser.timebankadd<0) then thisuser.timebankadd:=0;
dec(thisuser.timebank,lng);
inc(thisuser.tltoday,lng);
sprint('^5In your account: ^3'+cstr(thisuser.timebank)+
'^5 Time left online: ^3'+cstr(trunc(nsl) div 60));
sysoplog('TimeBank: Withdrew '+cstr(lng)+' minutes.');
end;
end;
end;
end;
function ctp(t,b:longint):astr;
var s,s1:astr;
n:real;
begin
if ((t=0) or (b=0)) then begin
ctp:=' 0.0%';
exit;
end;
n:=(t*100)/b;
str(n:5:1,s);
s:=s+'%';
ctp:=s;
(*
s:=cstr((t*100) div b);
if (length(s)=1) then s:=' '+s;
s:=s+'.';
if (length(s)=3) then s:=' '+s;
n:=t/(b+0.0005);
s1:=cstr(trunc(n*1000) mod 10);
ctp:=s+s1+'%';
*)
end;
function vote1x(answeringall:boolean; qnum:integer; var vd:vdatar):boolean;
var s,pva:astr;
i,tv:integer;
c:char;
abort,next,changed,doneyet,b:boolean;
procedure showvotes(stats,nocom:boolean);
var s:astr;
i:integer;
begin
cls;
sprint('Current standings for Question #'+cstr(qnum)+' :');
nl; sprint(#3#7+vd.question); nl;
tv:=0;
for i:=1 to vd.numa do inc(tv,vd.answ[i].numres);
if (tv=0) then tv:=1;
sprint('Users voting: '+#3#3+ctp(tv,systat.numusers)); nl;
abort:=FALSE; i:=1;
if (nocom) then begin
sprint(#3#0+' 0:No Comment');
pva:='Q0';
end else
pva:='';
while (i<=vd.numa) do begin
if (not abort) then begin
s:=#3#5+cstr(i)+#3#7+':'+#3#3+vd.answ[i].ans;
if (stats) then
s:=mln(s,41+length(cstr(i)))+#3#4+' :'+#3#0+mn(vd.answ[i].numres,3)+
#3#4+':'+#3#0+ctp(vd.answ[i].numres,tv)+#3#4+':';
if (i=thisuser.vote[qnum]) then s:=#3#8+'*'+s else s:=' '+s;
printacr(' '+s,abort,next);
end;
pva:=pva+cstr(i);
inc(i);
end;
end;
begin
changed:=FALSE;
if (vd.numa<>0) then begin
doneyet:=(thisuser.vote[qnum]<>0);
showvotes(doneyet,not systat.forcevoting);
nl;
sprint(#3#5+'Your vote: '+#3#3+vd.answ[thisuser.vote[qnum]].ans);
if (not (rvoting in thisuser.ac)) and (not hangup) then begin
if (answeringall) then b:=TRUE else b:=pynq('Change it? ');
if (b) then begin
nl; prt('Which number (0-'+cstr(vd.numa)+') ? ');
onek(s[1],pva);
s[0]:=#1; i:=value(s);
if (s<>'') and (i>=0) and (i<=vd.numa) then begin
if (thisuser.vote[qnum]<>0) then
dec(vd.answ[thisuser.vote[qnum]].numres);
thisuser.vote[qnum]:=i;
if (i<>0) then inc(vd.answ[i].numres);
changed:=TRUE;
if (not answeringall) then showvotes(TRUE,FALSE);
end;
end;
end;
end else
if (not answeringall) then print('Inactive question.');
vote1x:=changed;
end;
procedure vote;
var vdata:file of vdatar;
vd:vdatar;
i,j,int2,vna:integer;
s,i1,ij:astr;
abort,next,done,lq,waschanged:boolean;
procedure getvote(qnum:integer);
begin
seek(vdata,qnum-1); read(vdata,vd);
end;
procedure vote1(answeringall:boolean; qnum:integer);
begin
getvote(qnum);
if (vote1x(answeringall,qnum,vd)) then begin
seek(vdata,qnum-1);
write(vdata,vd);
waschanged:=TRUE;
end;
end;
begin
s:=''; done:=FALSE; lq:=TRUE; waschanged:=FALSE;
assign(vdata,systat.gfilepath+'voting.dat');
{$I-} reset(vdata); {$I+}
if (ioresult<>0) then print('No voting today.')
else begin
sysoplog('Entered voting booths');
repeat
done:=FALSE;
ij:='Q?';
abort:=FALSE;
if (lq) then begin
cls;
printacr(#3#5+'Current Questions:',abort,next);
nl;
end;
int2:=0;
for i:=1 to numvoteqs do begin
seek(vdata,i-1); read(vdata,vd);
if vd.numa<>0 then begin
inc(int2);
if (lq) and (not abort) then begin
if (thisuser.vote[i]=0) then i1:=#3+#8+'* ' else i1:=' ';
i1:=i1+#3#5+cstr(i)+#3#7+': '+#3#3+vd.question;
printacr(i1,abort,next);
end;
ij:=ij+cstr(i);
end;
end;
lq:=FALSE;
if (int2=0) then begin
print('No voting questions now.');
done:=TRUE;
end else begin
nl;
prt('Which question (##,L:ist,A:nswer all,Q:uit) : ');
input(s,2);
i:=value(s);
if (s='A') then begin
j:=0;
i:=1;
while ((i<=numvoteqs) and (not hangup)) do begin
getvote(i);
if ((vd.numa<>0) and (thisuser.vote[i]=0)) then begin
vote1(TRUE,i);
inc(j);
end;
inc(i);
end;
if (j=0) then begin nl; sprint(#3#7+'No more questions need answering!'); end;
end;
if ((s='Q') or (s='')) then done:=TRUE;
if ((s='L') or (s='?')) then lq:=TRUE;
if (i>=1) and (i<=numvoteqs) then vote1(FALSE,i);
end;
if (systat.forcevoting) and (done) then begin
vna:=0;
for i:=1 to numvoteqs do begin
seek(vdata,i-1); read(vdata,vd);
if ((vd.numa<>0) and (thisuser.vote[i]=0)) then inc(vna);
end;
if (vna<>0) then begin
nl;
print('Voting is mandatory - all questions must be answered.');
done:=FALSE;
end;
end;
until (done) or (hangup);
close(vdata);
if (waschanged) then begin
nl;
sprint(#3#3+fstring.thanxvote);
end;
end;
end;
end.