/* name : dynparticles - part SERVER date : february 2007 auteur : iri pour I-Maginer (http://www.i-maginer.fr) */ typeof class = S;; struct PART = [ // couleur initcolor : S, colorcycle : S, // taille sizemax : S, sizecycle : S, sizetime : S, // expert life : S, volume : S, volA : S, volB : S, effect : S, effectA : S, effectB :S, effectC : S, // inutilisé target : S, randcolor : S, mass : S ] mkPART;; typeof part = PART;; typeof clis = [[CLIENT I] r1];; typeof initON = I;; /* supprime un client de la liste l -> [[CLIENT I] r1] : clis cli -> CLIENT : client à supprimer <- [[CLIENT I] r1] : liste à jour */ fun remove_from_clis(l, cli)= if l == nil then l else let hd l -> [c _] in if cli == c then tl l else (hd l) :: remove_from_clis tl l cli;; fun getStateByCli(l, cli)= if l == nil then 0 else let hd l -> [c state] in if cli == c then state else getStateByCli tl l cli;; fun chgState(l, cli, value)= if l == nil then nil else let hd l -> [c _] in if cli == c then [cli value] :: (tl l) else chgState tl l cli value;; fun prepareDatas()= strbuild ( "initcolor" :: part.initcolor :: nil ) :: ( "colorcycle" :: part.colorcycle :: nil ) :: ( "sizemax" :: part.sizemax :: nil ) :: ( "sizecycle" :: part.sizecycle :: nil ) :: ( "sizetime" :: part.sizetime :: nil ) :: ( "life" :: part.life :: nil ) :: ( "volume" :: part.volume :: nil ) :: ( "volA" :: part.volA :: nil ) :: ( "volB" :: part.volB :: nil ) :: ( "effect" :: part.effect :: nil ) :: ( "effectA" :: part.effectA :: nil ) :: ( "effectB" :: part.effectB :: nil ) :: ( "effectC" :: part.effectC :: nil ) :: ( "target" :: part.target :: nil ) :: ( "randcolor" :: part.randcolor :: nil ) :: ( "mass" :: part.mass :: nil ) :: nil;; /* Envoi un message vers les clients enregistrés auprès du serveur l -> [[CLIENT I] r1] : clis : liste des clients enregistrés ui -> UserI action -> S : Nom de l'action à envoyer param -> S : paramètre à envoyer <- I */ fun _broadMsg(l, ui, action, param)= if l == nil then 0 else let hd l -> [cli _] in ( UsendMessage ui cli action param; _broadMsg tl l ui action param );; /* Communications intramodules (cli/srv) ui -> UserI cli -> CLIENT action -> S param -> S p -> [Ob] <- I */ fun cbComm(ui, cli, action, param, p)= if !strcmp action "register" then ( set clis = [cli initON] :: clis; if initON == 1 then UsendMessage ui cli "start" prepareDatas else 0; 0 ) else if !strcmp action "unregister" then ( set clis = remove_from_clis clis cli; UsendMessage ui cli "stop" nil; 0 ) else if !strcmp action "start" then _broadMsg clis ui "start" prepareDatas else if !strcmp action "started" then ( set clis = chgState clis cli 1; 0 ) else if !strcmp action "color_cycleColor" then ( 0 ) else if !strcmp action "color_chgAlpha" then ( 0 ) else if !strcmp action "color_chgColor" then ( 0 ) else if !strcmp action "expert_infinit" then ( 0 ) else if !strcmp action "expert_volSphreRadius" then ( 0 ) else if !strcmp action "expert_volCone" then ( 0 ) else if !strcmp action "expert_volPlan" then ( 0 ) else if !strcmp action "expert_volLine" then ( 0 ) else if !strcmp action "expert_effectConstant" then ( 0 ) else if !strcmp action "expert_effectElectric" then ( 0 ) else if !strcmp action "expert_effectMagnetic" then ( 0 ) else if !strcmp action "expert_effectChotic0" then ( 0 ) else if !strcmp action "expert_effectChotic1" then ( 0 ) else if !strcmp action "expert_effectHelicoid" then ( 0 ) else if !strcmp action "expert_allClients" then ( 0 ) else if !strcmp action "expert_upload" then ( 0 ) else if !strcmp action "plugin_stop" then ( 0 ) else if !strcmp action "expert_billboard" then ( 0 ) else if !strcmp action "expert_rainbow" then ( 0 ) else if !strcmp action "expert_masse" then ( 0 ) else if !strcmp action "size_newSize" then ( 0 ) else 0;; /* Un client se déconnecte : il est supprimé de la liste ' clis ' o -> Ob cli -> CLIENT : client déconnecté <- I */ fun out(o, cli)= set clis = remove_from_clis clis cli; 0;; fun newOb(o)= let hd UgetParam ObUi o "init" -> tmp in set initON = if !strcmp tmp "on" then 1 else 0; let hd UgetParam ObUi o "initColor" -> p1 in let hd UgetParam ObUi o "initSizes" -> p2 in let hd UgetParam ObUi o "colorCycle" -> p3 in let hd UgetParam ObUi o "sizeCycle" -> p4 in let hd UgetParam ObUi o "maxSize" -> p5 in let hd UgetParam ObUi o "typeFX" -> p6 in let hd UgetParam ObUi o "typeVolEmitter" -> p7 in let hd UgetParam ObUi o "typeMaskEmitter" -> p8 in let hd UgetParam ObUi o "typeParticle" -> p9 in let hd UgetParam ObUi o "vectorA" -> p10 in let hd UgetParam ObUi o "vectorB" -> p11 in let hd UgetParam ObUi o "vectorC" -> p12 in set part = mkPART[ p1 p3 p5 p4 p2 "0" p7 p10 p11 p8 p10 p11 p12 p9 p9 "0" ]; UcbComm this ObUi o mkfun5 @cbComm [o]; OB_CBclientDestroyed o @out; 0;; fun IniPlug(file)= set class = getInfo strextr _getpack _checkpack file "name"; PlugRegister class @newOb nil; 0 ;;