/* Copyright (C) 1991, Marcus J. Ranum. All rights reserved. */ #ifndef lint static char RCSid[] = "$Header: /usr/users/mjr/hacks/umud/RCS/do_go.c,v 1.3 91/09/19 12:56:10 mjr Exp $"; #endif /* configure all options BEFORE including system stuff. */ #include "config.h" #include "mud.h" #include "look.h" #include "vars.h" /* core implementation of player movement */ int player_go(argc,argv,who,from,to) int argc; char *argv[]; char *who; char *from; char *to; { char *cp; char *dst; char hm[MAXOID]; dst = ut_getatt(to,0,typ_obj,var_dest,(char *)0); /* make sure destination is valid && exists */ if(dst == (char *)0) goto fail; /* check locks */ if(bool_locked(who,to,from,var_lock,0)) goto fail; /* Try to move. If not in cache, try a remote go */ if(!strcmp(dst,"home")){ if(!ut_home(who,hm)) goto fail; dst = hm; /* ut_home() guarantees that it's local */ } if(!cache_check(dst)){ if(xact_sendplayer(who,from,dst)){ /* Failed remote go. */ goto fail; } else { /* Succeeded remote go. succ/osucc & 'has left' */ (void)activate(ACTIV_PONLY,who,to,from,var_succ,argc,argv); if(!ut_flagged(who,var_isdark)) (void)activate(ACTIV_ECAST,who,to,from,var_osucc,argc,argv); if(!ut_flagged(who,var_isdark)) { cp = ut_name(who); ut_roombcast(from,who,cp," has left.\n",(char *)0); } /* TinyLink */ xact_tinylink(who); io_logoff(who); return(0); } } /* Local go operation. */ /* move - any of these fail, and, well, whoops. */ if(ut_listdel(who,from,var_ply,who)) return(1); if(ut_listadd(who,dst,var_ply,who)) return(1); if(ut_set(who,who,typ_obj,var_loc,dst)) return(1); /* drop/odrop */ (void)activate(ACTIV_PONLY,who,to,dst,var_drop,argc,argv); if(!ut_flagged(who,var_isdark)) (void)activate(ACTIV_ECAST,who,to,dst,var_odrop,argc,argv); /* arrived/left */ if(!ut_flagged(who,var_isdark)) { /* succ/osucc */ (void)activate(ACTIV_PONLY,who,to,from,var_succ,argc,argv); if(!ut_flagged(who,var_isdark)) (void)activate(ACTIV_ECAST,who,to,from,var_osucc,argc,argv); cp = ut_name(who); ut_roombcast(from,who,cp," has left.\n",(char *)0); ut_roombcast(dst,who,cp," has arrived.\n",(char *)0); } /* print thang's @desc */ lookat(who,ut_loc(who),LOOK_NAME|LOOK_PLAY|LOOK_CONT); return(0); fail: if(!activate(ACTIV_PONLY,who,to,from,var_fail,argc,argv)) say(who,"you can't go there.\n",(char *)0); if(!ut_flagged(who,var_isdark)) (void)activate(ACTIV_ECAST,who,to,from,var_ofail,argc,argv); return(1); }