#include <stdio.h> #include <strings.h> #include <ctype.h> #include "teeny.h" #include "match.h" /* Copyright(C) 1990, Andrew Molitor, All Rights Reserved. This software may be freely used, modified, and redistributed, as long as this copyright message is left intact, and this software is not used to develop any commercial product, or used in any product that is provided on a pay-for-use basis. No warranties whatsoever. This is not guaranteed to compile, nor, in the event that it does compile to binaries, are these binaries guaranteed to perform any function whatsoever. */ /* Basic player commands pertaining to communication. */ /* Buffer from cmds.c */ extern char cmdwork[]; do_pose(player,arg) int player; char *arg; { char *name,*p; int count; if(get_str_elt(player,NAME,&name) == -1) goto posebomb; p = cmdwork; if(name != NULL){ for(count = 0 ; count < BUFFSIZ && !isspace(*name) && *name ; count++){ *p++ = *name++; } } if(arg != NULL){ *p++ = ' '; count++; for(; count < BUFFSIZ && *arg ; count++){ *p++ = *arg++; } } *p++ = '\n'; *p = '\0'; notify_all(player,cmdwork); return; posebomb: notify_bad(player); return; } do_page(player,arg) int player; char *arg; { int pagee,ret; char *name; char *p; int location; if(arg == NULL){ notify_player(player,"Page whom?\n"); return; } if((ret = bill_player(player,1)) == -1) goto pagebomb; if(ret == 0) return; /* Find who we're supposed to page, by peering at WHO list */ pagee = match_who(arg); if(pagee == -1){ notify_player(player,"I can't find that person.\n"); return; } /* OK. Send the message. */ notify_player(pagee,"You sense that "); if(get_str_elt(player,NAME,&name) == -1) goto pagebomb; if(name != NULL){ for(p = cmdwork; *name && !isspace(*name);){ *p++ = *name++; } *p++ = '\0'; } notify_player(pagee,cmdwork); notify_player(pagee," is looking for you in "); if(get_int_elt(player,LOC,&location) == -1) goto pagebomb; if(get_str_elt(location,NAME,&name) == -1 ) goto pagebomb; if(name != NULL){ notify_player(pagee,name); } notify_player(pagee,".\n"); notify_player(player,"Your message has been sent.\n"); return; pagebomb: notify_bad(player); return; } do_say(player,arg) int player; char *arg; { char *name,*p,*q; int count; if(get_str_elt(player,NAME,&name) == -1) goto saybomb; /* Build the thing we're gonna say to everyone else */ p = cmdwork; if(name != NULL){ for(count = 0; !isspace(*name) && *name && count < BUFFSIZ - 9;count++){ *p++ = *name++; } } strcpy(p," says, \""); count += 8; p += 8; if(arg == NULL){ *p++ = '\"'; *p++ = '\n'; *p = '\0'; } else { for(q = arg; *q && count < BUFFSIZ-1; count++){ *p++ = *q++; } *p++ = '\"'; *p++ = '\n'; *p = '\0'; } /* Tell everyone else this */ notify_oall(player,cmdwork); /* Now build what we want to tell the player itself */ notify_player(player,"You say, \""); if(arg != NULL) notify_player(player,arg); notify_player(player,"\"\n"); return; saybomb: notify_bad(player); return; } do_whisper(player,argone,argtwo) int player; char *argone,*argtwo; { int whisperee,here; char *name; char *q,ch; if(get_int_elt(player,LOC,&here) == -1) goto whisperbomb; if(argone==NULL || (whisperee=match_here(player,here,argone,MAT_PLAYERS))==-1){ notify_player(player,"Whisper to whom?\n"); return; } /* OK. Tell the players */ if(get_str_elt(whisperee,NAME,&name) == -1) goto whisperbomb; /* Temporarily terminate the name. */ if(name != NULL){ for(q = name;*q && !isspace(*q);) q++; ch = *q; *q = '\0'; } notify_player(player,"You whisper, \""); if(argtwo != NULL) notify_player(player,argtwo); notify_player(player,"\" to "); if(name != NULL){ notify_player(player,name); *q = ch; } notify_player(player,".\n"); if(get_str_elt(player,NAME,&name) == -1) goto whisperbomb; /* Temporarily terminate the name. */ if(name != NULL){ for(q = name;*q && !isspace(*q);) q++; ch = *q; *q = '\0'; notify_player(whisperee,name); *q = ch; } notify_player(whisperee," whispers, \""); if(argtwo != NULL){ notify_player(whisperee,argtwo); } notify_player(whisperee,"\"\n"); return; whisperbomb: notify_bad(player); return; }