/* * Called by go() and move() */ void move_user(UR_OBJECT user, RM_OBJECT rm, int teleport) { RM_OBJECT old_room; if (teleport != 2 && !has_room_access(user, rm)) { write_user(user, "That room is currently private, you cannot enter.\n"); return; } /* Reset invite room if in it */ if (user->invite_room == rm) { user->invite_room = NULL; *user->invite_by = '\0'; } if (user->vis) { switch (teleport) { case 0: vwrite_room(rm, "%s~RS %s.\n", user->recap, user->in_phrase); vwrite_room_except(user->room, user, "%s~RS %s to the %s.\n", user->recap, user->out_phrase, rm->name); break; case 1: vwrite_room(rm, "%s~RS ~FC~OLappears in an explosion of blue magic!\n", user->recap); vwrite_room_except(user->room, user, "%s~RS ~FC~OLchants a spell and vanishes into a magical blue vortex!\n", user->recap); break; case 2: write_user(user, "\n~FC~OLA giant hand grabs you and pulls you into a magical blue vortex!\n"); vwrite_room(rm, "%s~RS ~FC~OLfalls out of a magical blue vortex!\n", user->recap); #ifdef NETLINKS if (!release_nl(user)) #endif { vwrite_room_except(user->room, user, "~FC~OLA giant hand grabs~RS %s~RS ~FC~OLwho is pulled into a magical blue vortex!\n", user->recap); } break; } } else if (user->level < GOD) { write_room(rm, invisenter); write_room_except(user->room, invisleave, user); } old_room = user->room; user->room = rm; reset_access(old_room); look(user); }
/*** Write figlet lines to users that want them ***/ void write_broadcast_figlet(UR_OBJECT user, UR_OBJECT u, RM_OBJECT rm, char *fig_text) { set_crash(); if (u) { write_user(u, fig_text); return; } if (rm) { write_room(rm, fig_text); return; } write_room_except(NULL, fig_text, user); write_user(user, fig_text); }
char *myalloc(int size) #endif { char *ptr; #ifndef __STDC__ extern void *malloc(); #endif set_crash(); if ((ptr = (char*)malloc(size))==NULL) { write_room(NULL,"~FR~OLSYSTEM: Malloc failed in figlet().\n"); return NULL; } return ptr; }
/*** Write text figlets & intros ***/ void write_text_figlet(UR_OBJECT user, UR_OBJECT u, RM_OBJECT rm, char *fig_text, char *name, char *font) { char fig1[ARR_SIZE]; char fig2[ARR_SIZE]; set_crash(); if (strcmp(font,"standard")) sprintf(fig1,"~FRBanner od ~OL%s~RS~FR (%s font): ~RS%s\n", name, font, fig_text); else sprintf(fig1,"~FRBanner od ~OL%s~RS~FR: ~RS%s\n", name, fig_text); sprintf(fig2,"~FRBanner od ~OL%s~RS~FR:\n",name); if (rm) { if (!user->vis) write_monitor(user, rm, 0); write_room(rm, fig2); record(rm, fig1); return; } if (u) { if (u==user) return; if (u->afk) record_afk(u, fig1); else if (u->editing) record_edit(u, fig1); record_tell(u, fig1); sprintf(u->ltell, user->name); if (strcmp(font,"standard")) sprintf(text, "~FRBanner pre ~OL%s~RS~FR (%s font): ~RS%s\n", u->name, font, fig_text ); else sprintf(text, "~FRBanner pre ~OL%s~RS~FR: ~RS%s\n", u->name, fig_text ); write_user(user, text); record_tell(user, text); if (u->afk || u->editing) return; write_user(u, fig2); return; } for (rm=room_first; rm!=NULL; rm=rm->next) record(rm, fig1); if (!user->vis) write_monitor(user, NULL, 0); write_room_except(NULL, fig2, user); write_user(user, fig2); }
/* * put speech in a music notes */ void sing_it(UR_OBJECT user, char *inpstr) { #if !!0 static const char usage[] = "Usage: sing [<text>]\n"; #endif const char *name; /* FIXME: Use sentinel other JAILED */ if (user->muzzled != JAILED) { write_user(user, "You are muzzled, you cannot sing.\n"); return; } switch (amsys->ban_swearing) { case SBMAX: if (contains_swearing(inpstr)) { write_user(user, noswearing); return; } break; case SBMIN: if (!is_private_room(user->room)) { inpstr = censor_swear_words(inpstr); } break; case SBOFF: default: /* do nothing as ban_swearing is off */ break; } if (!user->vis) { write_monitor(user, user->room, 0); } name = user->vis ? user->recap : invisname; if (word_count < 2) { sprintf(text, "%s~RS sings a tune...BADLY!\n", name); } else { sprintf(text, "%s~RS sings o/~ %s~RS o/~\n", name, inpstr); } record(user->room, text); write_room(user->room, text); }
/* * Set room access back to public if not enough users in room */ void reset_access(RM_OBJECT rm) { UR_OBJECT u; if (!rm || is_personal_room(rm) || is_fixed_room(rm) || !is_private_room(rm)) { return; } if (room_visitor_count(rm) < amsys->min_private_users) { /* Reset any invites into the room & clear review buffer */ for (u = user_first; u; u = u->next) { if (u->invite_room == rm) { u->invite_room = NULL; } } clear_revbuff(rm); rm->access &= ~PRIVATE; write_room(rm, "Room access returned to ~FGPUBLIC.\n"); } }
void write_all_rom() { HFINDFILE hff; char filename[256]; room *rom; FILE *fp; int n=0; fp = fopen( room_file, "w"); if ( fp != NULL ) { hff = find_first_file(get_room_path(), filename, 256); if ( hff ) { do { if ( filename[0] != '.' ) { if (load_rom_from_file( atoi(&filename[1]), &rom)) printf("Unable to read binary room %d. Continuing.\n", atoi(&filename[1]) ); else { n++; write_room(fp, rom); free_rom(rom); } } } while( find_next_file( hff, filename, 256 )); close_find_file(hff); } fclose(fp); } }
/* * Unarrest a user who is currently under arrest and in jail */ void unarrest(UR_OBJECT user) { UR_OBJECT u; RM_OBJECT rm; int on; if (word_count < 2) { write_user(user, "Usage: unarrest <user>\n"); return; } u = retrieve_user(user, word[1]); if (!u) { return; } on = retrieve_user_type == 1; /* error checks */ if (u == user) { write_user(user, "You cannot unarrest yourself.\n"); return; } if (u->level != JAILED) { vwrite_user(user, "%s~RS is not under arrest!\n", u->recap); done_retrieve(u); return; } if (user->level < u->arrestby) { vwrite_user(user, "%s~RS can only be unarrested by a %s or higher.\n", u->recap, user_level[u->arrestby].name); done_retrieve(u); return; } /* do it */ u->level = u->unarrest; u->real_level = u->level; u->arrestby = JAILED; /* FIXME: Use sentinel other JAILED */ user_list_level(u->name, u->level); strcpy(u->date, (long_date(1))); sprintf(text, "~FG~OLYou have been unarrested... Now try to behave!\n"); if (!on) { send_mail(user, u->name, text, 0); vwrite_user(user, "%s has been unarrested.\n", u->name); } else { write_user(u, text); vwrite_user(user, "%s has been unarrested.\n", u->name); write_room(NULL, "The Hand of Justice reaches through the air...\n"); rm = get_room_full(amsys->default_warp); if (!rm) { vwrite_user(user, "Cannot find a room for ex-cons, so %s~RS is still in the %s!\n", u->recap, u->room->name); } else { move_user(u, rm, 2); } } write_syslog(SYSLOG, 1, "%s UNARRESTED %s\n", user->name, u->name); add_history(u->name, 1, "Was ~FGunarrested~RS by %s.\n", user->name); if (!on) { u->socket = -2; strcpy(u->site, u->last_site); } save_user_details(u, on); done_retrieve(u); }
/* * Put annoying user in jail */ void arrest(UR_OBJECT user) { UR_OBJECT u; RM_OBJECT rm; int on; if (word_count < 2) { write_user(user, "Usage: arrest <user>\n"); return; } u = retrieve_user(user, word[1]); if (!u) { return; } on = retrieve_user_type == 1; /* error checks */ if (u == user) { write_user(user, "You cannot arrest yourself.\n"); return; } if (u->level >= user->level) { write_user(user, "You cannot arrest anyone of the same or higher level than yourself.\n"); done_retrieve(u); return; } if (u->level == JAILED) { vwrite_user(user, "%s~RS has already been arrested.\n", u->recap); done_retrieve(u); return; } /* do it */ u->vis = 1; u->unarrest = u->level; u->arrestby = user->level; u->level = JAILED; u->real_level = u->level; user_list_level(u->name, u->level); strcpy(u->date, (long_date(1))); sprintf(text, "~FR~OLYou have been placed under arrest.\n"); if (!on) { send_mail(user, u->name, text, 0); vwrite_user(user, "%s has been placed under arrest.\n", u->name); } else { write_user(u, text); vwrite_user(user, "%s has been placed under arrest.\n", u->name); write_room(NULL, "The Hand of Justice reaches through the air...\n"); rm = get_room_full(amsys->default_jail); if (!rm) { vwrite_user(user, "Cannot find the jail, so %s~RS is arrested but still in the %s.\n", u->recap, u->room->name); } else { move_user(u, rm, 2); } vwrite_room_except_both(NULL, user, u, "%s~RS has been placed under arrest...\n", u->recap); } write_syslog(SYSLOG, 1, "%s ARRESTED %s (at level %s)\n", user->name, u->name, user_level[u->arrestby].name); add_history(u->name, 1, "Was ~FRarrested~RS by %s (at level ~OL%s~RS).\n", user->name, user_level[u->arrestby].name); if (!on) { u->socket = -2; strcpy(u->site, u->last_site); } save_user_details(u, on); done_retrieve(u); }
void parse_ccom(char *cmd, struct chatroom *room, struct pork_acct *acct, int priv) { struct aim_chat *ccon = room->data; struct aim_priv *a_priv = acct->data; dlist_t *temp; char sn[MAXSNLEN+1]; char msg[MAXSNLEN+1024]; char *pmsg = msg; cmd[strcspn(cmd,"/")] = '\0'; if(!strncasecmp(cmd, "op ", 3) && (priv >= FULLOPS)) { cmd += 3; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (check_if_op(sn, room)) return; ccon->oparray = dlist_add_tail(ccon->oparray, xstrdup(sn)); if (ccon->chatsends > 1) { sprintf(msg, "%s has been opped.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } else if(!strncasecmp(cmd, "deop ", 5) && (priv >= FULLOPS)) { cmd += 5; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (!check_if_op(sn, room)) return; if (temp = dlist_find(ccon->oparray, sn, (void*)strcmp)) { free(temp->data); ccon->oparray = dlist_remove(ccon->oparray, temp); if (ccon->chatsends > 1) { sprintf(msg, "%s has been deopped.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } } else if(!strncasecmp(cmd, "defullop ", 7) && (priv >= DOWNERS)) { cmd += 9; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (temp = dlist_find(ccon->fullops, sn, (void*)strcmp)) { free(temp->data); ccon->fullops = dlist_remove(ccon->fullops, temp); if (ccon->chatsends > 1) { sprintf(msg, "%s has been defullopped.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } } else if(!strncasecmp(cmd, "fullop ", 7) && (priv >= FULLOPS)) { cmd += 7; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (check_if_fullop(sn, room)) return; ccon->fullops = dlist_add_tail(ccon->fullops, xstrdup(sn)); if (ccon->chatsends > 1) { sprintf(msg, "%s has been fullopped.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } else if(!strncasecmp(cmd, "halfop ", 7) && (priv > HALFOPS)) { cmd += 7; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (check_if_halfop(sn, room)) return; ccon->halfops = dlist_add_tail(ccon->halfops, xstrdup(sn)); if (ccon->chatsends > 1) { sprintf(msg, "%s has been halfopped.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } else if(!strncasecmp(cmd, "dehalfop ", 9) && (priv > HALFOPS)) { cmd += 9; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (!check_if_halfop(sn, room)) return; if (temp = dlist_find(ccon->halfops, sn, (void*)strcmp)) { free(temp->data); ccon->halfops = dlist_remove(ccon->halfops, temp); if (ccon->chatsends > 1) { sprintf(msg, "%s has been dehalfopped.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } } else if(!strncasecmp(cmd, "kick ", 5)) { cmd += 5; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (check_if_imm(sn, room)) return; if (ccon->chatsends > 1) { snprintf(msg, MAXSNLEN+127, "kicking %s.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } if ((temp = dlist_find(ccon->banlist, sn, (void*)strcmp)) != NULL) { free(temp->data); ccon->banlist = dlist_remove(ccon->banlist, temp); } aim_chat_ban(&a_priv->aim_session, ccon->conn, sn); aim_chat_unban(&a_priv->aim_session, ccon->conn, sn); } else if(!strncasecmp(cmd, "ban ", 4) && (priv > HALFOPS)) { cmd += 4; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (check_if_imm(sn, room)) return; if (ccon->chatsends > 1) { snprintf(msg, MAXSNLEN+127, "banning %s.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } if (!dlist_find(ccon->banlist, sn, (void*)strcmp)) ccon->banlist = dlist_add_tail(ccon->banlist, xstrdup(sn)); aim_chat_ban(&a_priv->aim_session, ccon->conn, sn); } else if(!strncasecmp(cmd, "unban ", 6) && (priv > HALFOPS)) { cmd += 6; if (!aim_snvalid(cmd)) return; if (ccon->chatsends > 1) { snprintf(msg, MAXSNLEN+127, "unbanning %s.", cmd); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } if ((temp = dlist_find(ccon->banlist, cmd, (void*)strcmp)) != NULL) { free(temp->data); ccon->banlist = dlist_remove(ccon->banlist, temp); } aim_chat_unban(&a_priv->aim_session, ccon->conn, cmd); } else if(!strncasecmp(cmd, "pause ", 6) && (priv >= FULLOPS)) { cmd += 6; banpause = atoi(cmd); if (banpause < 0) banpause = 0; sprintf(msg, "autoban pause set to %g microseconds.", banpause); if (ccon->chatsends > 1) aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } else if(!strncasecmp(cmd, "help", 4) && ccon->chatsends) { char commands[MAXMSGLEN+1]; strcpy(commands, "commands are: !status, !kick, !imm"); if (priv > HALFOPS) strcat(commands,", !unimm, !ban, !unban, !ab, !unab, !aw, !unaw, !halfop, !dehalfop, !bj"); if (priv > OPS) strcat(commands,", !ak, !unak, !op, !deop, !fullop, !save, !load"); if (priv > FULLOPS) strcat(commands,", !defullop"); strcat(commands, "."); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, commands, strlen(commands), "us-ascii", "en"); } else if(!strncasecmp(cmd, "imm ", 4)) { cmd += 4; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (check_if_imm(sn, room)) return; ccon->immlist = dlist_add_tail(ccon->immlist, xstrdup(sn)); if (ccon->chatsends > 1) { sprintf(msg, "%s has been immed.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } else if(!strncasecmp(cmd, "unimm ", 6) && (priv > HALFOPS)) { cmd += 6; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (!check_if_imm(sn, room)) return; if (temp = dlist_find(ccon->immlist, sn, (void*)strcmp)) { free(temp->data); ccon->immlist = dlist_remove(ccon->immlist, temp); if (ccon->chatsends > 1) { sprintf(msg, "%s has been unimmed.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } } else if(!strncasecmp(cmd, "ak ", 3) && (priv > OPS)) { cmd += 3; if (!aim_snvalid(cmd)) return; if (check_if_ak(cmd, room)) return; normalize(sn, cmd, strlen(cmd) + 1); ccon->akarray = dlist_add_tail(ccon->akarray, xstrdup(cmd)); if (ccon->chatsends > 1) { sprintf(msg, "%s has been autokicked.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } check_akusers_in_room(room); } else if(!strncasecmp(cmd, "ab ", 3) && (priv > HALFOPS)) { cmd += 3; if (!aim_snvalid(cmd)) return; if (check_if_ab(cmd, room)) return; normalize(sn, cmd, strlen(cmd) + 1); ccon->abarray = dlist_add_tail(ccon->abarray, xstrdup(cmd)); if (ccon->chatsends > 1) { sprintf(msg, "%s has been autobanned.", sn); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } check_abusers_in_room(room); } else if(!strncasecmp(cmd, "aw ", 3) && (priv > HALFOPS)) { cmd += 3; if (check_if_aw(cmd, room)) return; ccon->awarray = dlist_add_tail(ccon->awarray, xstrdup(cmd)); if (ccon->chatsends > 1) { sprintf(msg, "%s has been autoworded.", cmd); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } else if(!strncasecmp(cmd, "unak ", 5) && (priv > OPS)) { cmd += 5; if (!aim_snvalid(cmd)) return; if (!check_if_ak(cmd, room)) return; if (temp = dlist_find(ccon->akarray, cmd, (void*)strcmp)) { free(temp->data); ccon->akarray = dlist_remove(ccon->akarray, temp); if (0) { //ccon->chatsends > 1) { sprintf(msg, "%s has been unautokicked.", cmd); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } } else if(!strncasecmp(cmd, "unab ", 5) && (priv > HALFOPS)) { cmd += 5; if (!aim_snvalid(cmd)) return; if (!check_if_ab(cmd, room)) return; if (temp = dlist_find(ccon->abarray, cmd, (void*)strcmp)) { free(temp->data); ccon->abarray = dlist_remove(ccon->abarray, temp); if (0) { //ccon->chatsends > 1) { sprintf(msg, "%s has been unautobanned.", cmd); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } } else if(!strncasecmp(cmd, "unaw ", 5) && (priv > HALFOPS)) { cmd += 5; if (!check_if_aw(cmd, room)) return; if (temp = dlist_find(ccon->awarray, cmd, (void*)strcmp)) { free(temp->data); ccon->awarray = dlist_remove(ccon->awarray, temp); if (ccon->chatsends > 1) { snprintf(msg, 1024, "%s has been unautoworded.", cmd); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } } } else if(!strncasecmp(cmd, "status ", 7) && ccon->chatsends) { strcpy(msg, ""); cmd += 7; if (!aim_snvalid(cmd)) return; partial_nick(cmd, sn, room); if (check_if_fullop(sn, room)) { sprintf(msg, "%s is a full op.", sn); } else if (check_if_op(sn, room)) { sprintf(msg, "%s is an op.", sn); } else if (check_if_halfop(sn, room)) { sprintf(msg, "%s is a half op", sn); if (check_if_imm(sn, room)) strcat(msg, " and immune"); strcat(msg, "."); } else if (check_if_imm(sn, room)) { sprintf(msg, "%s is immune.", sn); } if (strlen(msg)) aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, pmsg, strlen(msg), "us-ascii", "en"); } else if(!strncasecmp(cmd, "chatsends ", 10) && (priv >= FULLOPS)) { int chatsends; cmd += 10; chatsends = atoi(cmd); if ((chatsends >= 0) && (chatsends <= 2)) { ccon->chatsends = chatsends; if (ccon->chatsends > 1) { sprintf(msg, "chatsends now set to %d.", ccon->chatsends); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, msg, strlen(msg), "us-ascii", "en"); } } } else if(!strncasecmp(cmd, "save", 4) && (priv >= FULLOPS)) { if (!write_room(ccon)) { screen_err_msg("unable to save config for room %s.\n", ccon->title); } } else if(!strncasecmp(cmd, "load ", 5) && (priv >= FULLOPS)) { if (!read_room(ccon, &cmd[5])) { screen_err_msg("unable to load config for room %s.\n", &cmd[5]); } } else if(!strncasecmp(cmd, "bj", 2) && (priv > HALFOPS)) { ccon->banjoin = !ccon->banjoin; if (ccon->chatsends > 1) { sprintf(msg, "banjoin: %s.", ccon->banjoin?"on":"off"); aim_chat_send_im(&a_priv->aim_session, ccon->conn, 0, msg, strlen(msg), "us-ascii", "en"); } } }