/* Site Map Server - DMS - june 98 - by Marc BARILLEY */ /* Rev. 1.1 - Sep. '98 - by Marc BARILLEY */ defcom Chide = hide;; defcom Cshow = show;; defcom Cdestroy = destroy;; defcom Cmap = map S I I;; /* file w h */ defcom Calt = alt S;; /* file */ defcom CyouAreIn = youAreIn S;; /* rectangle name */ defcom CyouAreOut = youAreOut S;; /* rectangle name */ defcom Calias = alias I /* error code */ S /* alias */ I I I I /* x y w h */ I I /* outlined color */ I /* show avatars */ I I I I S /* medot mesize mecolor mebitmap mefile */ I I I I S /* otherdot othersize othercolor otherbitmap otherfile */ I;; /* show numbers */ defcom CaddUser = addUser S S;; /* login alias */ defcom CdelUser = delUser S S;; /* login alias */ defcom Cchglogin = chglogin S S;; /* old new */ typeof map = S;; typeof altmap = S;; typeof wmap = I;; typeof hmap = I;; struct Rect = [ aliasRect : S, xRect : I, yRect : I, wRect : I, hRect : I, outlnRect : I, outlnColorRect : I, avatarRect : I, meDotRect : I, meSizeRect : I, meColorRect : I, meBitmapRect : I, meFileRect : S, otherDotRect : I, otherSizeRect : I, otherColorRect : I, otherBitmapRect : I, otherFileRect : S, numberRect : I, clientRect : [CLIENT r1] ] mkRect;; typeof rects = [Rect r1];; typeof clients = [CLIENT r1];; proto logout = fun [CLIENT] I;; /* internal */ fun equal (x, y)= x==y;; fun clientByNickname (x, nickname)= !strcmp _DMSgetLogin x nickname;; fun rectByAlias (r, alias)= !strcmp r.aliasRect alias;; /* loadDmi */ fun loadRects (l)= if l==nil then 0 else { if !strcmp hd hd l "alias2" then let mkRect [ nth_list hd l 1 atoi nth_list hd l 2 atoi nth_list hd l 3 atoi nth_list hd l 4 atoi nth_list hd l 5 atoi nth_list hd l 6 atoi nth_list hd l 7 atoi nth_list hd l 8 atoi nth_list hd l 9 atoi nth_list hd l 10 atoi nth_list hd l 11 atoi nth_list hd l 12 (if !strcmp "*" (nth_list hd l 13) then nil else (nth_list hd l 13)) atoi nth_list hd l 14 atoi nth_list hd l 15 atoi nth_list hd l 16 atoi nth_list hd l 17 (if !strcmp "*" (nth_list hd l 18) then nil else (nth_list hd l 18)) atoi nth_list hd l 19 nil] -> r in { set rects = listcat rects r::nil; if r.meBitmapRect && (strlen r.meFileRect)!=0 then _RSregister this r.meFileRect 1 r.meFileRect else nil; if r.otherBitmapRect && (strlen r.otherFileRect)!=0 then _RSregister this r.otherFileRect 1 r.otherFileRect else nil; nil } else if !strcmp hd hd l "alias" then set rects = listcat rects (mkRect [ nth_list hd l 1 atoi nth_list hd l 2 atoi nth_list hd l 3 atoi nth_list hd l 4 atoi nth_list hd l 5 atoi nth_list hd l 6 atoi nth_list hd l 7 1 1 atoi nth_list hd l 9 atoi nth_list hd l 8 0 nil 1 atoi nth_list hd l 9 atoi nth_list hd l 8 0 nil 1 nil ])::nil else nil; loadRects tl l };; fun loadDmi (l)= set map = getInfo l "mapfile"; set altmap = getInfo l "alternate"; let atoi getInfo l "wmap" -> w in set wmap = if w==nil then 140 else w; let atoi getInfo l "hmap" -> h in set hmap = if h==nil then 190 else h; loadRects l; _RSregister this map 1 map;; /* comm */ fun broad (client, comm)= _DMSsend this client comm;; fun __contact (alias, nickname)= let search_in_list rects @rectByAlias alias -> r in let search_in_list r.clientRect @clientByNickname nickname -> c in if c != nil then _DMSevent this DMSsender "select" itoa _DMSgetId c nil else nil;; fun __started ()= _DMSevent this DMSsender "entering" nil nil; let search_in_list clients @equal DMSsender -> c in set clients = if c==nil then DMSsender::clients else clients; _DMSsend this DMSsender Calt [altmap]; _DMSsend this DMSsender Calias [1 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil]; let rects -> l in while l != nil do { let hd l -> r in { _DMSsend this DMSsender Calias [ 0 r.aliasRect r.xRect r.yRect r.wRect r.hRect r.outlnRect r.outlnColorRect r.avatarRect r.meDotRect r.meSizeRect r.meColorRect r.meBitmapRect r.meFileRect r.otherDotRect r.otherSizeRect r.otherColorRect r.otherBitmapRect r.otherFileRect r.numberRect ]; let r.clientRect -> ll in while ll != nil do { let hd ll -> c in if c==DMSsender then _DMSsend this DMSsender CyouAreIn [r.aliasRect] else _DMSsend this DMSsender CaddUser [_DMSgetLogin c r.aliasRect]; set ll = tl ll; } }; set l = tl l; }; _DMSsend this DMSsender Calias [2 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil]; 0;; /* DMS */ fun logout (cli)= set clients = remove_from_list clients cli; let rects -> l in while l != nil do { let hd l -> r in if (search_in_list r.clientRect @equal cli) == nil then nil else { set r.clientRect = remove_from_list r.clientRect cli; apply_on_list clients @broad CdelUser [_DMSgetLogin cli r.aliasRect]; }; set l = tl l; }; 0;; fun activate (from, client, action, param, reply)= if !strcmp action "start" then _DMScreateClientDMI this client strbuild ((if map==nil then "*" else map)::nil)::((itoa wmap)::nil)::((itoa hmap)::nil)::nil else if !strcmp (substr action 0 3) "in_" then let search_in_list rects @rectByAlias substr action 3 (strlen action)-3 -> r in { if (search_in_list r.clientRect @equal client)==nil then set r.clientRect = listcat r.clientRect client::nil else nil; _DMSsend this client CyouAreIn [r.aliasRect]; apply_on_list (remove_from_list clients client) @broad CaddUser [_DMSgetLogin client r.aliasRect]; } else if !strcmp substr action 0 4 "out_" then let search_in_list rects @rectByAlias substr action 4 (strlen action)-4 -> r in { if (search_in_list r.clientRect @equal client)==nil then nil else set r.clientRect = remove_from_list r.clientRect client; _DMSsend this client CyouAreOut [r.aliasRect]; apply_on_list (remove_from_list clients client) @broad CdelUser [_DMSgetLogin client r.aliasRect]; } else if !strcmp action "!changeLogin" then apply_on_list clients @broad Cchglogin [param _DMSgetLogin client] else if !strcmp action "destroy" then _DMSsend this client Cdestroy [] else if !strcmp action "show" then _DMSsend this client Cshow [] else if !strcmp action "hide" then _DMSsend this client Chide [] else nil;; fun IniDMI (file)= _DMSregisterDMI this @activate @logout nil nil; loadDmi strextr _getpack _checkpack file;;