void delete_received(player *p,char *str) { int number,count=0; int *make,*scan; char *oldstack; note *deleted; number=atoi(str); if (number<=0) { tell_player(p,"Format: delete <mail number>\n"); return; } if (!(p->saved)) { tell_player(p,"You have no save information, and therefore no mail either.\n"); return; } scan=p->saved->mail_received; if (!scan) { tell_player(p,"You have recieved no mail to delete.\n"); return; } oldstack=stack; align(stack); make=(int *)stack; for(number--;number;number--) if (*scan) { *make++=*scan++; count++; } else break; if (!*scan) { tell_player(p,"Not that many pieces of mail.\n"); stack=oldstack; return; } deleted=find_note(*scan++); while(*scan) { *make++=*scan++; count++; } *make++=0; count++; if (p->saved->mail_received) FREE(p->saved->mail_received); if (count!=1) { p->saved->mail_received=(int *)MALLOC(sizeof(int)*count); memcpy(p->saved->mail_received,stack,sizeof(int)*count); } else p->saved->mail_received=0; if (deleted) { deleted->read_count--; if (!(deleted->read_count)) unlink_mail(deleted); } tell_player(p,"Mail deleted....\n"); stack=oldstack; }
void intercom_unbanish_name(player * p, char *str) { nameban *prev, *scan; char *oldstack; if (!*str) { tell_player(p, "Format: intercom unbanish_name <name>\n"); return; } if (p->flags & BLOCK_SU) { tell_player(p, "Please go on duty to do that.\n"); return; } scan = nameban_anchor; prev = 0; while (scan) { if (scan->name[0] && !strcasecmp(scan->name, str)) { if (scan->type == 1) tell_player(p, " Name unbarred.\n"); else tell_player(p, " Name unbanished.\n"); oldstack = stack; sprintf(oldstack, "-=> %s allows the name '%s' to use the " "intercom.\n", p->name, str); stack = end_string(oldstack); su_wall(oldstack); stack = oldstack; if (prev) prev->next = scan->next; else nameban_anchor = scan->next; if (scan->type == 2) sync_banish_names(); FREE(scan); return; } prev = scan; scan = scan->next; } tell_player(p, " That name is not in the banished list.\n"); return; }
void show_exits(player * p, char *str) { if (p->saved_flags & SHOW_EXITS) { tell_player(p, " You won't see exits when you enter a room now.\n"); p->saved_flags &= ~SHOW_EXITS; } else { tell_player(p, " When you enter a room you will now see the exits.\n"); p->saved_flags |= SHOW_EXITS; } }
void reset_session(player * p, char *str) { char *oldstack = stack; player *scan; if (config_flags & cfNOSWEAR) str = filter_rude_words(str); if (strlen(str) > 55) { tell_player(p, " Too long a session name ...\n"); stack = oldstack; return; } if (*str) { if (strstr(str, "^")) sprintf(session, "%s^N", str); else sprintf(session, "%s", str); sprintf(stack, " You reset the session message to be '%s^N'\n", str); stack = end_string(stack); tell_player(p, oldstack); /* reset comments */ for (scan = flatlist_start; scan; scan = scan->flat_next) strncpy(scan->comment, "", MAX_COMMENT - 3); stack = oldstack; sprintf(stack, "%s resets the session to be '%s'\n", p->name, str); stack = end_string(stack); command_type |= EVERYONE; for (scan = flatlist_start; scan; scan = scan->flat_next) if (scan != p && !(scan->custom_flags & YES_SESSION)) tell_player(scan, oldstack); stack = oldstack; p_sess = p; strcpy(sess_name, p->name); sprintf(stack, "%s- %s", p->name, session); stack = end_string(stack); log("session", oldstack); stack = oldstack; } session_reset = 0; tell_player(p, " Session timer reset.\n"); }
void intercom_unbar_name(player * p, char *str) { nameban *scan, *prev; char *oldstack; if (!*str) { tell_player(p, " Format: intercom unbar_name <name>.\n"); return; } if (p->flags & BLOCK_SU) { tell_player(p, "Please go on duty to do that.\n"); return; } scan = nameban_anchor; prev = 0; while (scan) { if (scan->name[0] && !strcasecmp(scan->name, str)) { if (scan->type == 2) { tell_player(p, " They are banished, you need to use intercom " "unbanish_name to re-permit them.\n"); return; } tell_player(p, " Name unbanished.\n"); oldstack = stack; sprintf(oldstack, "-=> %s allows the name '%s' to use the " "intercom.\n", p->name, str); stack = end_string(oldstack); su_wall(oldstack); stack = oldstack; if (prev) prev->next = scan->next; else nameban_anchor = scan->next; FREE(scan); return; } prev = scan; scan = scan->next; } tell_player(p, " No such name in the intercom barred lists.\n"); return; }
void pager(player * p, char *text, int page) { ed_info *e; int length = 0, lines = 0; char *scan; if (p->saved_flags & NO_PAGER && !page) { tell_player(p, text); return; } if (p->edit_info) { tell_player(p, " You are currently already in the pager/editor!\n"); return; } /* scan whole of string, if its a newline then increase lines, and inc length -again-?? Of course - this routine below can't actually cope with overwrapping lines */ for (scan = text; *scan; scan++, length++) { if (*scan == '\n') lines++; } if (lines > (TERM_LINES + 1)) { e = (ed_info *) MALLOC(sizeof(ed_info)); if(e==NULL) { tell_player(p, " Eeek, can't enter pager right now.\n"); return; } memset(e, 0, sizeof(ed_info)); p->edit_info = e; e->buffer = (char *) MALLOC(length+1); if(e->buffer==NULL) { tell_player(p, " Eeek, can't enter pager right now.\n"); free(e); return; } memset(e->buffer, 0, length+1); strncpy(e->buffer, text, length); e->current = e->buffer; e->max_size = lines; e->size = 0; e->input_copy = p->input_to_fn; e->flag_copy = p->flags; p->input_to_fn = pager_fn; p->flags &= ~PROMPT; } draw_page(p, text, 1); }
void add_intercom_server(player * p, char *str) { char *name, *abbr, *addr, *port, *oldstack; name = str; abbr = 0; addr = 0; port = 0; if (*name) { abbr = strchr(name, ':'); if (abbr) { *abbr++ = '\0'; if (*abbr) { addr = strchr(abbr, ':'); if (addr) { *addr++ = '\0'; if (*addr) { port = strchr(addr, ':'); if (port) *port++ = '\0'; } } } } } if (!port || !*port || !*addr || !*abbr || !name || !*name) { tell_player(p, "Format: add_server " "<name>:<abbreviation>:<address>:<port>\n"); return; } oldstack = stack; sprintf(oldstack, " Sending request to intercom to add %s to the database, " "at address %s %s, abbreviated to %s.\n", name, addr, port, abbr); stack = end_string(oldstack); tell_player(p, oldstack); stack = oldstack; send_to_intercom(p, "%c%s:%s:%s:%s:%s:O", ADD_NEW_LINK, p->name, name, abbr, addr, port); return; }
void toggle_quiet_edit(player *p,char *str) { restore_flags(p); if (!strcmp("off",str)) p->saved_flags &= ~QUIET_EDIT; else if (!strcmp("on",str)) p->saved_flags |= QUIET_EDIT; else p->saved_flags ^= QUIET_EDIT; if (p->saved_flags&QUIET_EDIT) tell_player(p,"You will block tells and shouts upon editing.\n"); else tell_player(p,"You won't block shouts and tells on editing.\n"); save_flags(p); }
cmd_read(int x){ if(!x){ tell_player(THISP, "\n~~~ Table of Contents ~~~\n "); cmd_dir(); tell_player(THISP, "\n~~~ Usage: read <#> ~~~"); } else { x = x-1; mixed f = get_dir(to_string(CONTENT)); if(x < sizeof(f)){ THISP->more_string( read_file(to_string(CONTENT) + f[x])); tell_room(ENV(THISP), PNAME+" studies a book carefully.\n", ({THISP})); }
void intercom_banish(player * p, char *str) { if (!*str) { tell_player(p, " Format: banish <name|alias>\n"); return; } if (p->flags & BLOCK_SU) { tell_player(p, "Please go on duty to do that.\n"); return; } send_to_intercom(p, "%c%s:%s", BANISH_SITE, p->name, str); return; }
void intercom_bar_name(player * p, char *str) { nameban *new_var; char *oldstack; if (!*str) { tell_player(p, " Format: intercom bar_name <name>.\n"); return; } if (p->flags & BLOCK_SU) { tell_player(p, "Please go on duty to do that.\n"); return; } if (strlen(str) > MAX_NAME - 1) str[MAX_NAME - 1] = 0; if (check_intercom_banished_name(str)) { tell_player(p, " That name is already barred.\n"); return; } new_var = (nameban *) MALLOC(sizeof(nameban)); memset(new_var, 0, sizeof(nameban)); if (nameban_anchor) new_var->next = nameban_anchor; nameban_anchor = new_var; strcpy(new_var->name, str); new_var->type = 1; oldstack = stack; sprintf(oldstack, " The name '%s' is now barred from the intercom.\n", str); stack = end_string(oldstack); tell_player(p, oldstack); sprintf(oldstack, "-=> %s bars the name '%s' from using the intercom.\n", p->name, str); stack = end_string(oldstack); su_wall(oldstack); stack = oldstack; return; }
/* the dreaded pager B-) */ int draw_page(player * p, char *text, int drawme) { int end_line = 0, n; float perc; ed_info *e; char *oldstack; oldstack = stack; for (n = TERM_LINES + 1; n; n--, end_line++) { while (*text && *text != '\n') *stack++ = *text++; if (!*text) break; *stack++ = *text++; } *stack++ = 0; if(drawme) tell_player(p, oldstack); if (*text && p->edit_info) { e = p->edit_info; end_line += e->size; perc = (((float)end_line/(float)e->max_size)*100); sprintf(oldstack, "(Pager: lines %d-%d of %d (%d%%)) p/N/f/l/r/q/?: " ,e->size+1, end_line, e->max_size, (int) perc); stack = end_string(oldstack); do_prompt(p, oldstack); } stack = oldstack; return *text; }
void edit_forward_line(player *p,char *str) { char *c; ed_info *e; e=p->edit_info; c=e->current; if (!*c) { tell_player(p,"Can't go forward, bottom of buffer.\n"); return; } while(*c && *c!='\n') c++; if (*c) c++; e->current=c; if (!*c) tell_player(p,"Reached bottom of buffer.\n"); else edit_view_line(p,0); }
void edit_stats(player *p,char *str) { int words=0,lines=0,blip=0; char *scan,*oldstack; oldstack=stack; for(scan=p->edit_info->buffer;*scan;scan++) { switch(*scan) { case ' ': if (blip) words++; blip=0; break; case '\n': if (blip) words++; blip=0; lines++; break; default: blip=1; } } sprintf(oldstack,"Used %d bytes out of %d, in %d lines and %d words.\n", p->edit_info->size,p->edit_info->max_size,lines,words); stack=end_string(stack); tell_player(p,oldstack); stack=oldstack; }
int draw_page(player *p,char *text) { int end_line=0,n; ed_info *e; char *oldstack; oldstack=stack; for(n=TERM_LINES-3;n;n--,end_line++) { while(*text && *text!='\n') *stack++=*text++; if (!*text) break; *stack++=*text++; } *stack++=0; tell_player(p,oldstack); if (*text && p->edit_info) { e=p->edit_info; end_line+=e->size; sprintf(oldstack,"(Pager: lines %d to %d, from a total %d)", e->size,end_line,e->max_size); stack=end_string(oldstack); do_prompt(p,oldstack); } stack=oldstack; return *text; }
void phase4( object arg ) { tell_player( arg, "There is definitely something shifting " "down in the darkness. You can make out a huge dark shape." ); call_out( "phase5", 5, THISP ); }
void phase5( object arg ) { tell_player( arg, "You hit the ground with a resounding thud. " "Your limbs twist and contort." ); THISP->move_player( "&&", FROOM "pit", 1 ); arg->DeathSequence( arg, "fell too far" ); }
mixed cmd(string str) { object target; if(!str || str == "") str = "me"; if(str == "me") str = this_player()->GetKeyName(); if(!target = present(str, environment(this_player()))){ write("They're not here."); return 1; } if(!living(target)) { write("That's not a living thing."); return 1; } if(creatorp(target) && !archp(this_player()) && target != this_player()){ write("That's impolite."); tell_player(target,capitalize(this_player()->GetKeyName())+ " just tried to anglicize you."); return 1; } target->SetNativeLanguage("English"); if(target == this_player()) str = "yourself"; else str = capitalize(str); write("You anglicize "+str+"."); if(target != this_player()) tell_object(target, capitalize(this_player()->GetKeyName())+" anglicizes you."); return 1; }
void send_to_intercom(player * p, const char *fmt,...) { va_list varlist; char *oldstack; oldstack = stack; if (p && intercom_fd < 1) { tell_player(p, " The intercom is currently down.\n"); return; } va_start(varlist, fmt); vsprintf(stack, fmt, varlist); va_end(varlist); if (oldstack[strlen(oldstack) - 1] == (char) INCOMPLETE_MESSAGE || oldstack[strlen(oldstack) - 1] == (char) END_MESSAGE) stack = end_string(oldstack); else { stack = strchr(oldstack, 0); *stack++ = (char) END_MESSAGE; *stack++ = '\0'; } if (intercom_fd > 0) write(intercom_fd, oldstack, strlen(oldstack)); stack = oldstack; }
void sub_command(player *p,char *str,struct command *comlist) { char *oldstack,*rol; void (*fn)(); oldstack=stack; while(comlist->text) { if ((!comlist->level) || ((p->residency)&(comlist->level))) { rol=do_match(str,comlist); if (rol) { last_com=comlist; stack_check=stack; fn=comlist->function; (*fn)(p,rol); if (stack!=stack_check) bad_stack(); sys_flags &= ~(FAILED_COMMAND|PIPE|ROOM_TAG|FRIEND_TAG|EVERYONE_TAG); command_type=0; return; } } comlist++; } rol=str; while(*rol && !isspace(*rol)) rol++; *rol=0; sprintf(oldstack,"Cannot find sub command '%s'\n",str); stack=end_string(oldstack); tell_player(p,oldstack); stack=oldstack; }
void exit_mail_mode(player *p,char *str) { if (p->input_to_fn != mail_command) return; tell_player(p,"Leaving mail mode.\n"); p->input_to_fn=0; p->flags|=PROMPT; }
void dest_note(player *p,char *str) { note *n; if (!*str) { tell_player(p,"Format: dest_note <number>\n"); return; } n=find_note(atoi(str)); if (!n) { tell_player(p,"Can't find note with that number.\n"); return; } remove_any_note(n); tell_player(p,"Note removed\n"); }
void list_all_notes(player *p,char *str) { char *oldstack; int count=0,hash; note *scan; oldstack=stack; strcpy(stack," All notes --\n"); stack=strchr(stack,0); for (hash=0;hash<=NOTE_HASH_SIZE;count=0,hash++) { for (scan=n_hash[hash];scan;scan=scan->hash_next) count++; sprintf(stack,"%3d notes in bucket %2d",count,hash); stack=strchr(stack,0); if (hash&1) strcpy(stack," -- "); else strcpy(stack,"\n"); stack=strchr(stack,0); } strcpy(stack," --\n"); stack=strchr(stack,0); stack++; tell_player(p,oldstack); stack=oldstack; }
void report_idea(player * p, char *str) { if (!*str) { tell_player(p, " Format: idea <whatever you thought of>\n"); return; } if (strlen(str) > 480) { tell_player(p, " Please make it a little smaller.\n"); return; } TELLPLAYER(p, "%s%s\n%s ... logged as idea, thank you.\n", LINE, str, LINE); LOGF("idea", "%s - %s ", p->name, str); SW_BUT(p, " -=*> Idea log from %s: %s\n", p->name, str); }
void match_commands(player * p, char *str) { struct command *comlist; char *rol, *oldstack, *space; void (*fn) (); oldstack = stack; while (*str && *str == ' ') str++; space = strchr(str, 0); space--; while (*space == ' ') *space-- = 0; if (!*str) return; if (isalpha(*str)) comlist = coms[((int) (tolower(*str)) - (int) 'a' + 1)]; else comlist = coms[0]; while (comlist->text) { if (((!comlist->level) || ((p->residency) & (comlist->level))) && ((!comlist->andlevel) || ((p->residency) & (comlist->andlevel)))) { rol = do_match(str, comlist); if (rol) { last_com = comlist; stack_check = stack; fn = comlist->function; (*fn) (p, rol); if (stack != stack_check) bad_stack(); sys_flags &= ~(FAILED_COMMAND | PIPE | ROOM_TAG | FRIEND_TAG | EVERYONE_TAG); command_type = 0; return; } } comlist++; } p->antipipe++; /* if (p->antipipe > 30) { quit(p, 0); return; } */ rol = str; while (*rol && !isspace(*rol)) rol++; *rol = 0; sprintf(oldstack, " Cannot find command '%s'\n", str); stack = end_string(oldstack); tell_player(p, oldstack); stack = oldstack; }
void edit_back_line(player *p,char *str) { char *c; ed_info *e; e=p->edit_info; c=e->current; if (c==e->buffer) { tell_player(p,"Can't go back any more, top of buffer.\n"); return; } c-=2; while(c!=e->buffer && *c!='\n') c--; if (c==e->buffer) tell_player(p,"Reached top of buffer.\n"); else c++; e->current=c; edit_view_line(p,0); }
void read_scroll(){ tell_player(this_player(), "\nThe scroll crumbles into dust...\n"); this_player()->eventMoveLiving("/domains/diku-alfa/room/30.zon/3001.c", this_player()->GetName()+" disappears!", this_player()->GetName()+" appears in the middle of the room."); this_object()->eventDestruct(); }
int start( object arg ) { string player = arg->query_real_name(); if( !find_player( player ) ) return 0; tell_player( arg, "The air starts to get hotter." ); call_out( "phase2", 5, THISP ); }
void intercom_update_servers(player * p, char *str) { tell_player(p, " Requesting talker lists from all connected talkers.\n"); send_to_intercom(p, "%c", REQUEST_SERVER_LIST); return; }
void set_comment(player * p, char *str) { char *oldstack; player *scan; oldstack = stack; if (!*str) { tell_player(p, " You reset your session comment.\n"); strncpy(p->comment, "", MAX_COMMENT - 3); return; } if (p->custom_flags & YES_SESSION) { tell_player(p, " You are ignoring sessions - type \"muffle session\" to toggle.\n"); return; } if (strstr(str, "^")) { tell_player(p, " Sorry, but you can't have colour in your session comment.\n"); return; } if (strstr(str, "&")) { tell_player(p, " Sorry, but you can't have dynatext in your session comment.\n"); return; } if (config_flags & cfNOSWEAR) str = filter_rude_words(str); strncpy(p->comment, str, MAX_COMMENT - 3); sprintf(stack, " You set your session comment to be '%s'\n", p->comment); stack = end_string(stack); tell_player(p, oldstack); stack = oldstack; /* Inform everyone else who is listening to session information */ for (scan = flatlist_start; scan; scan = scan->flat_next) if (scan != p && !(scan->custom_flags & YES_SESSION)) TELLPLAYER(scan, " -=*> %s sets %s session comment to be '%s'\n", p->name, gstring_possessive(p), p->comment); }