(* Time interface.  Could be better *)
unit timeing;
interface
uses dos,crt,records,detector;

procedure timeinit;
procedure timedeinit;
PROCEDURE ADDTIME;
PROCEDURE TAKETIME;
procedure checktime;
function  timer:integer;

const     timeleft:integer=10;
var       logontime : integer;
          lasttime  : integer;
          timebar   : integer;

implementation

uses userstuf,IO,BARINFO,protcomm;


PROCEDURE ADDTIME;
BEGIN
INC(logontime,1);
InfoBar(CURRENTBAR,'');
checktime;
END;

PROCEDURE TAKETIME;
BEGIN
DEC(logontime,1);
InfoBar(CURRENTBAR,'');
checktime;
END;

function timer:integer;
  var r:registers;
      h, m, s, hund : Word;
begin
   GetTime(h,m,s,hund);
   timer:=h*60+m;
end;

procedure checktime;
var timeon:integer;
    t:integer;
    oldtimer:integer;
begin
oldtimer:=timeleft;
timeon:=logontime-timer;
t:=user.time+timeon;
timeleft:=t;
if timeleft<>oldtimer then infobar(currentbar,'');
{inc(timebar);
if timebar=2000 then begin
                    InfoBar(CURRENTBAR);
                    timebar:=1;
                    end;}
if timeleft=0 then begin
                   printfile(CONFIG.TEXTFILE_DIR+'NOTIME.ANS',basicmci,false);
                   delay(100);
                   loggedoff:=true;
                   hungup:=true;
                   hangup;
                   DELAY(100);
                   end;
end;

procedure timeinit;
begin
   fillchar(user,sizeof(user),0);
   user.time:=10;
   timeleft:=10;
   USER.TIMEPERDAY:=10;
   timebar:=1;
end;


procedure timedeinit;
var userx:longint;
begin
  user.time:=timeleft;
  userx:=finduser(user.alias,true);
  {writeuserInfo(userx);}
  fillchar(user,sizeof(user),#0);
  user.time:=10;
  timeleft:=10;
  USER.TIMEPERDAY:=10;
end;

begin
end.