Board makeMove(Board b, int moveIndex, int player) { short i, j; for ( i = -1; i < 2; i++ ) { for ( j = -1; j < 2; j++ ) { b = captureLine(b, moveIndex, player, i, j); } } b.mask = TOGGLE_BIT(b.mask, moveIndex); b.owner = GET_BIT(b.owner, moveIndex) ^ player ? TOGGLE_BIT(b.owner, moveIndex) : b.owner; // printf("move %i is legal.\n", moveIndex); return b; }
Board captureLine(Board b, int moveIndex, int player, short dX, short dY) { Board bc = b; while ( 1 ) { // Left side out of bounds if( dX < 0 && moveIndex % 8 == 0) { return b; } // Right side out of bounds if ( dX > 0 && moveIndex % 8 == 7) { return b; } moveIndex += dX + dY * 8; // Upper edge & lower edge out of bounds if ( moveIndex < 0 || moveIndex > 63 ) { return b; } else if ( ! GET_BIT(b.mask, moveIndex) ) { return b; } else if ( GET_BIT(b.owner, moveIndex) ^ player){ bc.owner = TOGGLE_BIT(bc.owner, moveIndex); } else { return bc; } } return b; // Never reached, included for compiler warnings }
void FramePool::release_frame(unsigned long _frame_no) { int bit_position = _frame_no % 32; int index_of_frame = (_frame_no - START_OFFSET) / 32; if (IS_SET (frame_map[index_of_frame], bit_position)) frame_map[index_of_frame] = TOGGLE_BIT(frame_map[index_of_frame], bit_position); }
/* Area Interpreter, called by do_aedit. */ void aedit (CHAR_DATA * ch, char *argument) { AREA_DATA *pArea; char command[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH]; int cmd; int value; EDIT_AREA (ch, pArea); smash_tilde (argument); strcpy (arg, argument); argument = one_argument (argument, command); if (!IS_BUILDER (ch, pArea)) { send_to_char ("AEdit: Insufficient security to modify area.\n\r", ch); edit_done (ch); return; } if (!str_cmp (command, "done")) { edit_done (ch); return; } if (command[0] == '\0') { aedit_show (ch, argument); return; } if ((value = flag_value (area_flags, command)) != NO_FLAG) { TOGGLE_BIT (pArea->area_flags, value); send_to_char ("Flag toggled.\n\r", ch); return; } /* Search Table and Dispatch Command. */ for (cmd = 0; aedit_table[cmd].name != NULL; cmd++) { if (!str_prefix (command, aedit_table[cmd].name)) { if ((*aedit_table[cmd].olc_fun) (ch, argument)) { SET_BIT (pArea->area_flags, AREA_CHANGED); return; } else return; } } /* Default to Standard Interpreter. */ interpret (ch, arg); return; }
/* policy_plru_access */ int policy_plru_access(cache_handle_t *cache, const uint64_t line_id, const load_t load) { static policy_plru_t *way_addr = NULL; static uint64_t *plru_mask = NULL; static uint64_t set = UINT64_MAX; static int way = 0, i = 0; int bit = 0, bit_set = 0, bit_offset = 0; /* calculate set for this address */ set = line_id; CACHE_SIM_LINE_ID_TO_SET(set); /* calculate the base address for the PLRU mask of this set */ plru_mask = (uint64_t *)((uint64_t)cache->data + (set * sizeof(uint64_t))); /* calculate the base address of the first way on the set */ way_addr = (policy_plru_t *)((uint64_t)cache->data + (cache->total_sets * sizeof(uint64_t)) + (set * cache->associativity * sizeof(policy_plru_t))); /* iterate across all the ways of the set */ for (way = 0; way < cache->associativity; way++, way_addr++) { /* check if data is present */ if (line_id == way_addr->line_id) { #ifdef DEBUG printf("HIT line id [%018p] set [%2d:%d]\n", line_id, set, way); #endif /* update PLRU mask by inverting the bits used by this way */ for (i = 0; i < (int)log2(cache->associativity); i++) { /* find out which bit should be toggled */ bit = bit_set + bit_offset; /* toggle it */ TOGGLE_BIT(*plru_mask, bit); /* add the bit offset */ bit_offset = way >> ((int)log2(cache->associativity) - 1 - i); /* move to the next set of bits */ bit_set <<= 1; bit_set++; } /* if the hit was on a prefetched line */ if (LOAD_PREFETCH == way_addr->load) { /* reset load reason */ way_addr->load = LOAD_ACCESS; return (CACHE_SIM_L1_HIT + CACHE_SIM_L1_HIT_PREFETCH); } return CACHE_SIM_L1_HIT; } }
unsigned long FramePool::get_frame() { /* * This function will traverse through the array of structures and * returns the first frame which is accessible and has not been * allocated to any other process. */ int bit_map_index = (base_frame_number - START_OFFSET) / 32; bool frame_found = false; int i, j; unsigned long frame_number; int limit; if(managament_frame_number == 0) limit = base_frame_number - START_OFFSET + number_of_frames_managed; else { limit = base_frame_number + number_of_frames_managed; } for ( i = bit_map_index ; i < limit / 32; i++) { if (frame_map[i] != 0xFFFFFFFF) /* This check is made to check if there are any free frames. * If the map is set to all ones, this would mean there are no free frames * in this bitmap array */ { for ( j = 0; j <= 31; j++ ) { if (IS_SET(frame_map[i], j)) continue; else { frame_map[i] = TOGGLE_BIT(frame_map[i], j); frame_found = true; break; } } if (frame_found) break; } } if (frame_found) { frame_number = j + i*32 + START_OFFSET; return frame_number; } else { return 0; } }
void do_hero( CHAR_DATA *ch, char *argument ) { // char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *d; if (ch->level < LEVEL_HERO) { send_to_one(ch, "You must be a hero to use this command."); return; } if (argument[0] == '\0' ) { TOGGLE_BIT(ch->comm,COMM_NOHERO); send_to_one(ch, "Hero channel toggled."); return; } else { if (IS_SET(ch->comm,COMM_QUIET)|| IS_SET(ch->comm,COMM_NOCHANNELS) || IS_SET(ch->comm, COMM_NOHERO)) { send_to_one(ch, "You can't herotalk like that!"); return; } } send_to_one( ch, "{B[{Y%s{B] %s{x", ch->name, argument ); for ( d = descriptor_list; d != NULL; d = d->next ) { CHAR_DATA *victim; victim = d->original ? d->original : d->character; if ( d->connected == CON_PLAYING && d->character != ch && d->character->level >= LEVEL_HERO && !IS_SET(victim->comm,COMM_NOHERO) && !IS_SET(victim->comm,COMM_QUIET) ) { send_to_one(d->character,"{B[{Y%s{B] %s{x", ch->name,argument); } } }
//Keith's compressed channels void do_auction( CHAR_DATA *ch, char *argument ) { // char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *d; if (argument[0] == '\0' ) { TOGGLE_BIT(ch->comm,COMM_NOAUCTION); send_to_one(ch, "{aAuction channel toggled.{x"); return; } else /* auction message sent, turn auction on if it is off */ { if (IS_SET(ch->comm,COMM_QUIET)|| IS_SET(ch->comm,COMM_NOCHANNELS) || IS_SET(ch->comm, COMM_NOAUCTION)) { send_to_char("You can't auction like that!\n\r",ch); return; } } send_to_one( ch, "{aYou auction {A'%s{a'{x\n\r", argument ); for ( d = descriptor_list; d != NULL; d = d->next ) { CHAR_DATA *victim; victim = d->original ? d->original : d->character; if ( d->connected == CON_PLAYING && d->character != ch && !IS_SET(victim->comm,COMM_NOAUCTION) && !IS_SET(victim->comm,COMM_QUIET) ) { send_to_one(d->character,"{a%s auctions '{A%s{a'{x", ch->name,argument); } } }
bool filter_input(WINDOW *win, int c) { char buf[18]; int i, t; switch (c) { case 'm': TOGGLE_BITSET(conf.filter_stype[WLAN_FRAME_TYPE_MGMT], 0xffff, uint16_t); break; case 'c': TOGGLE_BITSET(conf.filter_stype[WLAN_FRAME_TYPE_CTRL], 0xffff, uint16_t); break; case 'd': TOGGLE_BITSET(conf.filter_stype[WLAN_FRAME_TYPE_DATA], 0xffff, uint16_t); break; case 'r': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_ARP); break; case 'M': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_ICMP); break; case 'i': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_IP); break; case 'V': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_UDP); break; case 'W': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_TCP); break; case 'I': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_OLSR); break; case 'K': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_BATMAN); break; case 'Z': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_MESHZ); break; case '!': TOGGLE_BIT(conf.filter_mode, WLAN_MODE_AP); break; case '@': TOGGLE_BIT(conf.filter_mode, WLAN_MODE_STA); break; case '#': TOGGLE_BIT(conf.filter_mode, WLAN_MODE_IBSS); break; case '%': TOGGLE_BIT(conf.filter_mode, WLAN_MODE_4ADDR); break; case '^': TOGGLE_BIT(conf.filter_mode, WLAN_MODE_UNKNOWN); break; case '_': echo(); print_centered(win, FILTER_WIN_HEIGHT-1, FILTER_WIN_WIDTH, "[ Enter new BSSID and ENTER ]"); mvwprintw(win, THIRD_ROW + 1, MODE_COL + 4, ">"); mvwgetnstr(win, THIRD_ROW + 1, MODE_COL + 7, buf, 17); noecho(); convert_string_to_mac(buf, conf.filterbssid); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': i = c - '1'; if (MAC_NOT_EMPTY(conf.filtermac[i]) && conf.filtermac_enabled[i]) { conf.filtermac_enabled[i] = 0; } else { echo(); print_centered(win, FILTER_WIN_HEIGHT-1, FILTER_WIN_WIDTH, "[ Enter new MAC %d and ENTER ]", i+1); mvwprintw(win, THIRD_ROW + 1 + i, MAC_COL + 4, ">"); mvwgetnstr(win, THIRD_ROW + 1 + i, MAC_COL + 7, buf, 17); noecho(); /* just enable old MAC if user pressed return only */ if (*buf == '\0' && MAC_NOT_EMPTY(conf.filtermac[i])) conf.filtermac_enabled[i] = 1; else { convert_string_to_mac(buf, conf.filtermac[i]); if (MAC_NOT_EMPTY(conf.filtermac[i])) conf.filtermac_enabled[i] = true; } } break; case '0': conf.filter_off = conf.filter_off ? 0 : 1; break; case '*': conf.filter_badfcs = conf.filter_badfcs ? 0 : 1; break; default: for (t = 0; t < WLAN_NUM_TYPES; t++) { for (i = 0; i < WLAN_NUM_STYPES; i++) { if (stype_names[t][i].c == c) { TOGGLE_BIT(conf.filter_stype[t], BIT(i)); goto out; } } } return false; // not found } out: /* recalculate filter flag */ conf.do_macfilter = 0; for (i = 0; i < MAX_FILTERMAC; i++) { if (conf.filtermac_enabled[i]) conf.do_macfilter = 1; } net_send_filter_config(); update_filter_win(win); return true; }
/* Edit class information -Thoric */ void do_setclass( CHAR_DATA *ch, char *argument ) { char arg1[MIL]; char arg2[MIL]; struct class_type *Class; int cl, value, i; set_char_color( AT_PLAIN, ch ); smash_tilde( argument ); argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if ( !VLD_STR( arg1 ) ) { send_to_char( "Syntax: setclass <class> <field> <value>\r\n", ch ); send_to_char( "Syntax: setclass <class> create\r\n", ch ); send_to_char( "\r\nField being one of:\r\n", ch ); send_to_char( " name filename prime thac0 thac32 nocombo\r\n", ch ); send_to_char( " hpmin hpmax manamin manamax expbase mtitle ftitle\r\n", ch ); send_to_char( " second, deficient affected resist suscept\r\n", ch ); send_to_char( " race starting reclass1 reclass2 reclass3\r\n", ch ); return; } if ( is_number( arg1 ) && ( cl = atoi( arg1 ) ) >= 0 && cl < MAX_CLASS ) Class = class_table[cl]; else { Class = NULL; for ( cl = 0; cl < MAX_CLASS && class_table[cl]; cl++ ) { if ( !class_table[cl]->who_name ) continue; if ( !str_cmp( class_table[cl]->who_name, arg1 ) ) { Class = class_table[cl]; break; } } } if ( !str_cmp( arg2, "create" ) && Class ) { send_to_char( "That class already exists!\r\n", ch ); return; } if ( !Class && str_cmp( arg2, "create" ) ) { send_to_char( "No such class.\r\n", ch ); return; } if ( !str_cmp( arg2, "save" ) ) { DESCRIPTOR_DATA *d; write_class_file( cl ); send_to_char( "&CUpdating class for all players now.\r\n", ch ); for ( d = first_descriptor; d; d = d->next ) { if ( d->character ) update_aris( d->character ); } return; } if ( !str_cmp( arg2, "create" ) ) { if ( MAX_PC_CLASS >= MAX_CLASS ) { send_to_char( "You need to up MAX_CLASS in mud and make clean.\r\n", ch ); return; } if ( ( create_new_class( MAX_PC_CLASS, arg1 ) ) == FALSE ) { send_to_char( "Couldn't create a new class.\r\n", ch ); return; } write_class_file( MAX_PC_CLASS ); MAX_PC_CLASS++; write_class_list( ); send_to_char( "Done.\r\n", ch ); return; } if ( !argument ) { send_to_char( "You must specify an argument.\r\n", ch ); return; } if ( !str_cmp( arg2, "name" ) ) { if ( !VLD_STR( argument ) ) { send_to_char( "Can't set a class name to nothing.\r\n", ch ); return; } if ( VLD_STR( Class->who_name ) ) STRFREE( Class->who_name ); Class->who_name = STRALLOC( ( argument ) ); send_to_char( "Class name is set.\r\n", ch ); return; } if ( !str_cmp( arg2, "filename" ) ) { if ( !VLD_STR( argument ) ) { send_to_char( "Can't set a filename to nothing.\r\n", ch ); return; } if ( VLD_STR( Class->filename ) ) STRFREE( Class->filename ); Class->filename = STRALLOC( ( argument ) ); send_to_char( "Filename is set.\r\n", ch ); return; } if ( !str_cmp( arg2, "starting" ) ) { Class->starting = !Class->starting; ch_printf( ch, "That class is now a %s class.\r\n", Class->starting ? "starting" : "non-starting" ); return; } // Start of the nocombo aurgument! -Taon if ( !str_cmp( arg2, "nocombo" ) ) { for ( i = 0; i < MAX_CLASS; i++ ) { if ( class_table[i] && VLD_STR( class_table[i]->who_name ) ) { if ( !str_cmp( argument, class_table[i]->who_name ) ) { TOGGLE_BIT( Class->combo_restriction, 1 << i ); send_to_char( "Done!\r\n", ch ); send_to_char ( "Note this still isnt complete, as far as the nanny function is concerned!\r\n", ch ); return; } } } return; } if ( !str_cmp( arg2, "race" ) ) { for ( i = 0; i < MAX_RACE; i++ ) { if ( !str_cmp( argument, race_table[i]->race_name ) ) { TOGGLE_BIT( Class->race_restriction, 1 << i ); /* k, that's boggling */ send_to_char( "Done.\r\n", ch ); return; } } send_to_char( "No such race.\r\n", ch ); return; } if ( !str_cmp( arg2, "reclass1" ) ) { Class->reclass1 = 0; for ( i = 0; i < MAX_CLASS; i++ ) { if ( class_table[i] && VLD_STR( class_table[i]->who_name ) ) { if ( !str_cmp( argument, class_table[i]->who_name ) ) { Class->reclass1 = i; send_to_char( "Done.\r\n", ch ); return; } } } send_to_char( "No such class. Reclass1 cleared.\r\n", ch ); return; } if ( !str_cmp( arg2, "reclass2" ) ) { Class->reclass2 = 0; for ( i = 0; i < MAX_CLASS; i++ ) { if ( class_table[i] && VLD_STR( class_table[i]->who_name ) ) { if ( !str_cmp( argument, class_table[i]->who_name ) ) { Class->reclass2 = i; send_to_char( "Done.\r\n", ch ); return; } } } send_to_char( "No such class. Reclass2 cleared.\r\n", ch ); return; } if ( !str_cmp( arg2, "reclass3" ) ) { Class->reclass3 = 0; for ( i = 0; i < MAX_CLASS; i++ ) { if ( class_table[i] && VLD_STR( class_table[i]->who_name ) ) { if ( !str_cmp( argument, class_table[i]->who_name ) ) { Class->reclass3 = i; send_to_char( "Done.\r\n", ch ); return; } } } send_to_char( "No such class. Reclass3 cleared.\r\n", ch ); return; } if ( !str_cmp( arg2, "second" ) ) { int x = get_atype( argument ); if ( x < APPLY_STR || ( x > APPLY_CON && x != APPLY_LCK && x != APPLY_CHA ) ) send_to_char( "Invalid second attribute!\r\n", ch ); else { Class->attr_second = x; send_to_char( "Done.\r\n", ch ); } return; } if ( !str_cmp( arg2, "affected" ) ) { if ( !VLD_STR( argument ) ) { send_to_char( "Usage: setclass <class> affected <flag> [flag]...\r\n", ch ); return; } while ( VLD_STR( argument ) ) { argument = one_argument( argument, arg2 ); value = get_aflag( arg2 ); if ( value < 0 || value > MAX_BITS ) ch_printf( ch, "Unknown flag: %s\r\n", arg2 ); else xTOGGLE_BIT( Class->affected, value ); } send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "resist" ) ) { if ( !VLD_STR( argument ) ) { send_to_char( "Usage: setclass <class> resist <flag> [flag]...\r\n", ch ); return; } while ( VLD_STR( argument ) ) { argument = one_argument( argument, arg2 ); value = get_risflag( arg2 ); if ( value < 0 || value > 31 ) ch_printf( ch, "Unknown flag: %s\r\n", arg2 ); else TOGGLE_BIT( Class->resist, 1 << value ); } send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "suscept" ) ) { if ( !VLD_STR( argument ) ) { send_to_char( "Usage: setclass <class> suscept <flag> [flag]...\r\n", ch ); return; } while ( VLD_STR( argument ) ) { argument = one_argument( argument, arg2 ); value = get_risflag( arg2 ); if ( value < 0 || value > 31 ) ch_printf( ch, "Unknown flag: %s\r\n", arg2 ); else TOGGLE_BIT( Class->suscept, 1 << value ); } send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "deficient" ) ) { int x = get_atype( argument ); if ( x < APPLY_STR || ( x > APPLY_CON && x != APPLY_LCK && x != APPLY_CHA ) ) send_to_char( "Invalid deficient attribute!\r\n", ch ); else { Class->attr_deficient = x; send_to_char( "Done.\r\n", ch ); } return; } if ( !str_cmp( arg2, "prime" ) ) { int x = get_atype( argument ); if ( x < APPLY_STR || ( x > APPLY_CON && x != APPLY_LCK && x != APPLY_CHA ) ) send_to_char( "Invalid prime attribute!\r\n", ch ); else { Class->attr_prime = x; send_to_char( "Done.\r\n", ch ); } return; } if ( !str_cmp( arg2, "thac0" ) ) { Class->thac0_00 = atoi( argument ); send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "thac32" ) ) { Class->thac0_32 = atoi( argument ); send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "hpmin" ) ) { Class->hp_min = atoi( argument ); send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "hpmax" ) ) { Class->hp_max = atoi( argument ); send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "manamin" ) ) { Class->mana_min = atoi( argument ); send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "manamax" ) ) { Class->mana_max = atoi( argument ); send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "expbase" ) ) { Class->exp_base = atoi( argument ); send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "craftbase" ) ) { Class->craft_base = atoi( argument ); send_to_char( "Craft base is now set.\r\n", ch ); return; } if ( !str_cmp( arg2, "mtitle" ) ) { char arg3[MIL]; int x; argument = one_argument( argument, arg3 ); if ( arg3[0] == '\0' || argument[0] == '\0' ) { send_to_char( "Syntax: setclass <class> mtitle <level> <title>\r\n", ch ); return; } if ( !VLD_STR( argument ) ) { send_to_char( "What would you like to set the mtitle_table to?\r\n", ch ); return; } if ( ( x = atoi( arg3 ) ) < 0 || x > MAX_LEVEL ) { send_to_char( "Invalid level.\r\n", ch ); return; } STRFREE( title_table[cl][x][0] ); title_table[cl][x][0] = STRALLOC( argument ); send_to_char( "Done.\r\n", ch ); return; } if ( !str_cmp( arg2, "ftitle" ) ) { char arg3[MIL]; int x; argument = one_argument( argument, arg3 ); if ( arg3[0] == '\0' || argument[0] == '\0' ) { send_to_char( "Syntax: setclass <class> ftitle <level> <title>\r\n", ch ); return; } if ( !VLD_STR( argument ) ) { send_to_char( "What would you like to set the ftitle_table to?\r\n", ch ); return; } if ( ( x = atoi( arg3 ) ) < 0 || x > MAX_LEVEL ) { send_to_char( "Invalid level.\r\n", ch ); return; } STRFREE( title_table[cl][x][1] ); title_table[cl][x][1] = STRALLOC( argument ); send_to_char( "Done.\r\n", ch ); return; } do_setclass( ch, ( char * ) "" ); return; }
void medit_parse(struct descriptor_data *d, char *arg) { int i = -1; char *oldtext = NULL; if (OLC_MODE(d) > MEDIT_NUMERICAL_RESPONSE) { i = atoi(arg); if (!*arg || (!isdigit(arg[0]) && ((*arg == '-') && !isdigit(arg[1])))) { SEND_TO_Q("Field must be numerical, try again : ", d); return; } } else { /* String response. */ if (!genolc_checkstring(d, arg)) return; } switch (OLC_MODE(d)) { /*-------------------------------------------------------------------*/ case MEDIT_CONFIRM_SAVESTRING: /* * Ensure mob has MOB_ISNPC set or things will go pear shaped. */ SET_BIT(MOB_FLAGS(OLC_MOB(d)), MOB_ISNPC); switch (*arg) { case 'y': case 'Y': /* * Save the mob in memory and to disk. */ SEND_TO_Q("Saving mobile to memory.\r\n", d); medit_save_internally(d); sprintf(buf, "OLC: %s edits mob %d", GET_NAME(d->character), OLC_NUM(d)); mudlog(buf, CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE); /* FALL THROUGH */ case 'n': case 'N': cleanup_olc(d, CLEANUP_ALL); return; default: SEND_TO_Q("Invalid choice!\r\n", d); SEND_TO_Q("Do you wish to save the mobile? : ", d); return; } break; /*-------------------------------------------------------------------*/ case MEDIT_MAIN_MENU: i = 0; switch (*arg) { case 'q': case 'Q': if (OLC_VAL(d)) { /* Anything been changed? */ SEND_TO_Q("Do you wish to save the changes to the mobile? (y//n) : ", d); OLC_MODE(d) = MEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': OLC_MODE(d) = MEDIT_SEX; medit_disp_sex(d); return; case '2': OLC_MODE(d) = MEDIT_ALIAS; i--; break; case '3': OLC_MODE(d) = MEDIT_S_DESC; i--; break; case '4': OLC_MODE(d) = MEDIT_L_DESC; i--; break; case '5': OLC_MODE(d) = MEDIT_D_DESC; send_editor_help(d); SEND_TO_Q("Enter mob description:\r\n\r\n", d); if (OLC_MOB(d)->player.description) { SEND_TO_Q(OLC_MOB(d)->player.description, d); oldtext = str_dup(OLC_MOB(d)->player.description); } string_write(d, &OLC_MOB(d)->player.description, MAX_MOB_DESC, 0, oldtext); OLC_VAL(d) = 1; return; case '6': OLC_MODE(d) = MEDIT_LEVEL; i++; break; case '7': OLC_MODE(d) = MEDIT_ALIGNMENT; i++; break; case '8': OLC_MODE(d) = MEDIT_HITROLL; i++; break; case '9': OLC_MODE(d) = MEDIT_DAMROLL; i++; break; case 'a': case 'A': OLC_MODE(d) = MEDIT_NDD; i++; break; case 'b': case 'B': OLC_MODE(d) = MEDIT_SDD; i++; break; case 'c': case 'C': OLC_MODE(d) = MEDIT_NUM_HP_DICE; i++; break; case 'd': case 'D': OLC_MODE(d) = MEDIT_SIZE_HP_DICE; i++; break; case 'e': case 'E': OLC_MODE(d) = MEDIT_ADD_HP; i++; break; case 'f': case 'F': OLC_MODE(d) = MEDIT_AC; i++; break; case 'g': case 'G': OLC_MODE(d) = MEDIT_EXP; i++; break; case 'h': case 'H': OLC_MODE(d) = MEDIT_GOLD; i++; break; case 'i': case 'I': OLC_MODE(d) = MEDIT_POS; medit_disp_positions(d); return; case 'j': case 'J': OLC_MODE(d) = MEDIT_DEFAULT_POS; medit_disp_positions(d); return; case 'k': case 'K': OLC_MODE(d) = MEDIT_ATTACK; medit_disp_attack_types(d); return; case 'l': case 'L': OLC_MODE(d) = MEDIT_NPC_FLAGS; medit_disp_mob_flags(d); return; case 'm': case 'M': OLC_MODE(d) = MEDIT_AFF_FLAGS; medit_disp_aff_flags(d); return; case 'n': case 'N': OLC_MODE(d) = MEDIT_CLASS; medit_disp_class_flags(d); return; case 'r': case 'R': OLC_MODE(d) = MEDIT_RACE; medit_disp_race_flags(d); return; case 's': case 'S': OLC_MODE(d) = MEDIT_MSIZE; medit_disp_size_flags(d); return; case 'w': case 'W': OLC_MODE(d) = MEDIT_WEIGHT; send_to_char("Please enter the mobiles weight in pounds: ", d->character); return; #if CONFIG_OASIS_MPROG case 'p': case 'P': OLC_MODE(d) = MEDIT_MPROG; medit_disp_mprog(d); return; #endif default: medit_disp_menu(d); return; } if (i == 0) break; else if (i == 1) SEND_TO_Q("\r\nEnter new value : ", d); else if (i == -1) SEND_TO_Q("\r\nEnter new text :\r\n] ", d); else SEND_TO_Q("Oops...\r\n", d); return; /*-------------------------------------------------------------------*/ case MEDIT_ALIAS: if (GET_ALIAS(OLC_MOB(d))) free(GET_ALIAS(OLC_MOB(d))); GET_ALIAS(OLC_MOB(d)) = str_udup(arg); break; /*-------------------------------------------------------------------*/ case MEDIT_S_DESC: if (GET_SDESC(OLC_MOB(d))) free(GET_SDESC(OLC_MOB(d))); GET_SDESC(OLC_MOB(d)) = str_udup(arg); break; /*-------------------------------------------------------------------*/ case MEDIT_L_DESC: if (GET_LDESC(OLC_MOB(d))) free(GET_LDESC(OLC_MOB(d))); if (arg && *arg) { strcpy(buf, arg); strcat(buf, "\r\n"); GET_LDESC(OLC_MOB(d)) = str_dup(buf); } else GET_LDESC(OLC_MOB(d)) = str_dup("undefined"); break; /*-------------------------------------------------------------------*/ case MEDIT_D_DESC: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: medit_parse(): Reached D_DESC case!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; /*-------------------------------------------------------------------*/ #if CONFIG_OASIS_MPROG case MEDIT_MPROG_COMLIST: /* * We should never get here, but if we do, bail out. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: medit_parse(): Reached MPROG_COMLIST case!", BRF, LVL_BUILDER, TRUE); break; #endif /*-------------------------------------------------------------------*/ case MEDIT_NPC_FLAGS: if ((i = atoi(arg)) <= 0) break; else if (i <= NUM_MOB_FLAGS) TOGGLE_BIT(MOB_FLAGS(OLC_MOB(d)), 1 << (i - 1)); medit_disp_mob_flags(d); return; /*-------------------------------------------------------------------*/ case MEDIT_AFF_FLAGS: if ((i = atoi(arg)) <= 0) break; else if (i <= NUM_AFF_FLAGS) TOGGLE_BIT(AFF_FLAGS(OLC_MOB(d)), 1 << (i - 1)); medit_disp_aff_flags(d); return; /*-------------------------------------------------------------------*/ #if CONFIG_OASIS_MPROG case MEDIT_MPROG: if ((i = atoi(arg)) == 0) medit_disp_menu(d); else if (i == OLC_MTOTAL(d)) { struct mob_prog_data *temp; CREATE(temp, struct mob_prog_data, 1); temp->next = OLC_MPROGL(d); temp->type = -1; temp->arglist = NULL; temp->comlist = NULL; OLC_MPROG(d) = temp; OLC_MPROGL(d) = temp; OLC_MODE(d) = MEDIT_CHANGE_MPROG; medit_change_mprog (d); } else if (i < OLC_MTOTAL(d)) { struct mob_prog_data *temp; int x = 1; for (temp = OLC_MPROGL(d); temp && x < i; temp = temp->next) x++; OLC_MPROG(d) = temp; OLC_MODE(d) = MEDIT_CHANGE_MPROG; medit_change_mprog (d); } else if (i == (OLC_MTOTAL(d) + 1)) { SEND_TO_Q("Which mob prog do you want to purge? ", d); OLC_MODE(d) = MEDIT_PURGE_MPROG; } else medit_disp_menu(d); return; case MEDIT_PURGE_MPROG: if ((i = atoi(arg)) > 0 && i < OLC_MTOTAL(d)) { struct mob_prog_data *temp; int x = 1; for (temp = OLC_MPROGL(d); temp && x < i; temp = temp->next) x++; OLC_MPROG(d) = temp; REMOVE_FROM_LIST(OLC_MPROG(d), OLC_MPROGL(d), next); free(OLC_MPROG(d)->arglist); free(OLC_MPROG(d)->comlist); free(OLC_MPROG(d)); OLC_MPROG(d) = NULL; OLC_VAL(d) = 1; } medit_disp_mprog(d); return; case MEDIT_CHANGE_MPROG: if ((i = atoi(arg)) == 1) medit_disp_mprog_types(d); else if (i == 2) { SEND_TO_Q("Enter new arg list: ", d); OLC_MODE(d) = MEDIT_MPROG_ARGS; } else if (i == 3) { SEND_TO_Q("Enter new mob prog commands:\r\n", d); /* * Pass control to modify.c for typing. */ OLC_MODE(d) = MEDIT_MPROG_COMLIST; if (OLC_MPROG(d)->comlist) { SEND_TO_Q(OLC_MPROG(d)->comlist, d); oldtext = str_dup(OLC_MPROG(d)->comlist); } string_write(d, &OLC_MPROG(d)->comlist, MAX_STRING_LENGTH, 0, oldtext); OLC_VAL(d) = 1; } else medit_disp_mprog(d); return; #endif /*-------------------------------------------------------------------*/ /* * Numerical responses. */ #if CONFIG_OASIS_MPROG case MEDIT_MPROG_TYPE: /* * This calculation may be off by one too many powers of 2? * Someone who actually uses MobProgs will have to check. */ OLC_MPROG(d)->type = (1 << LIMIT(atoi(arg), 0, NUM_PROGS - 1)); OLC_VAL(d) = 1; medit_change_mprog(d); return; case MEDIT_MPROG_ARGS: OLC_MPROG(d)->arglist = str_dup(arg); OLC_VAL(d) = 1; medit_change_mprog(d); return; #endif case MEDIT_SEX: GET_SEX(OLC_MOB(d)) = LIMIT(i, 0, NUM_GENDERS - 1); break; case MEDIT_HITROLL: GET_HITROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); break; case MEDIT_DAMROLL: GET_DAMROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); break; case MEDIT_NDD: GET_NDD(OLC_MOB(d)) = LIMIT(i, 0, 30); break; case MEDIT_SDD: GET_SDD(OLC_MOB(d)) = LIMIT(i, 0, 127); break; case MEDIT_NUM_HP_DICE: GET_HIT(OLC_MOB(d)) = LIMIT(i, 0, 30); break; case MEDIT_SIZE_HP_DICE: GET_MANA(OLC_MOB(d)) = LIMIT(i, 0, 1000); break; case MEDIT_ADD_HP: GET_MOVE(OLC_MOB(d)) = LIMIT(i, 0, 30000); break; case MEDIT_AC: GET_AC(OLC_MOB(d)) = LIMIT(i, 10, 200); break; case MEDIT_EXP: GET_EXP(OLC_MOB(d)) = MAX(i, 0); break; case MEDIT_GOLD: add_money_to_char(OLC_MOB(d), MAX(i, 0), COPPER_COINS); break; case MEDIT_POS: GET_POS(OLC_MOB(d)) = LIMIT(i, 0, NUM_POSITIONS - 1); break; case MEDIT_DEFAULT_POS: GET_DEFAULT_POS(OLC_MOB(d)) = LIMIT(i, 0, NUM_POSITIONS - 1); break; case MEDIT_ATTACK: GET_ATTACK(OLC_MOB(d)) = LIMIT(i, 0, NUM_ATTACK_TYPES - 1); break; case MEDIT_LEVEL: GET_LEVEL(OLC_MOB(d)) = i; break; case MEDIT_ALIGNMENT: GET_ALIGNMENT(OLC_MOB(d)) = LIMIT(i, -1000, 1000); break; case MEDIT_CLASS: GET_CLASS(OLC_MOB(d)) = MAX(0, MIN(NUM_NPC_CLASS, atoi(arg))); break; case MEDIT_RACE: GET_RACE(OLC_MOB(d)) = MAX(0, MIN(NUM_NPC_RACE, atoi(arg))); // INT, WIS, STR, DEX, CON, CHA GET_INT(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][0]; GET_WIS(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][1]; GET_STR(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][2]; GET_DEX(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][3]; GET_CON(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][4]; GET_CHA(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][5]; GET_HIT(OLC_MOB(d)) = mob_hp[i][0]; GET_MANA(OLC_MOB(d)) = mob_hp[i][2]; GET_MOVE(OLC_MOB(d)) = mob_hp[i][3]; break; case MEDIT_WEIGHT: GET_MOB_WEIGHT(OLC_MOB(d)) = LIMIT(i, 1, 1000); break; case MEDIT_MSIZE: GET_MOB_SIZE(OLC_MOB(d)) = atoi(arg); break; /*-------------------------------------------------------------------*/ default: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: medit_parse(): Reached default case!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; }
void do_deaf( CHAR_DATA *ch, char *argument) { TOGGLE_BIT(ch->comm,COMM_DEAF); send_to_one(ch, "Deaf mode toggled."); }
void trigedit_parse(struct descriptor_data *d, char *arg) { int i = 0; switch (OLC_MODE(d)) { case TRIGEDIT_MAIN_MENU: switch (tolower(*arg)) { case 'q': if (OLC_VAL(d)) { /* Anything been changed? */ if (!GET_TRIG_TYPE(OLC_TRIG(d))) { write_to_output(d, "Invalid Trigger Type! Answer a to abort quit!\r\n"); } write_to_output(d, "Do you wish to save your changes? : "); OLC_MODE(d) = TRIGEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': OLC_MODE(d) = TRIGEDIT_NAME; write_to_output(d, "Name: "); break; case '2': OLC_MODE(d) = TRIGEDIT_INTENDED; write_to_output(d, "0: Mobiles, 1: Objects, 2: Rooms: "); break; case '3': OLC_MODE(d) = TRIGEDIT_TYPES; trigedit_disp_types(d); break; case '4': OLC_MODE(d) = TRIGEDIT_NARG; write_to_output(d, "Numeric argument: "); break; case '5': OLC_MODE(d) = TRIGEDIT_ARGUMENT; write_to_output(d, "Argument: "); break; case '6': OLC_MODE(d) = TRIGEDIT_COMMANDS; write_to_output(d, "Enter trigger commands: (/s saves /h for help)\r\n\r\n"); d->backstr = NULL; if (OLC_STORAGE(d)) { write_to_output(d, "%s", OLC_STORAGE(d)); d->backstr = strdup(OLC_STORAGE(d)); } d->str = &OLC_STORAGE(d); d->max_str = MAX_CMD_LENGTH; d->mail_to = 0; OLC_VAL(d) = 1; break; default: trigedit_disp_menu(d); return; } return; case TRIGEDIT_CONFIRM_SAVESTRING: switch(tolower(*arg)) { case 'y': trigedit_save(d); mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE, "OLC: %s edits trigger %d", GET_NAME(d->character), OLC_NUM(d)); /* fall through */ case 'n': cleanup_olc(d, CLEANUP_ALL); return; case 'a': /* abort quitting */ break; default: write_to_output(d, "Invalid choice!\r\n"); write_to_output(d, "Do you wish to save the trigger? : "); return; } break; case TRIGEDIT_NAME: smash_tilde(arg); if (OLC_TRIG(d)->name) free(OLC_TRIG(d)->name); OLC_TRIG(d)->name = strdup((arg && *arg) ? arg : "undefined"); OLC_VAL(d)++; break; case TRIGEDIT_INTENDED: if ((atoi(arg)>=MOB_TRIGGER) || (atoi(arg)<=WLD_TRIGGER)) OLC_TRIG(d)->attach_type = atoi(arg); OLC_VAL(d)++; break; case TRIGEDIT_NARG: OLC_TRIG(d)->narg = LIMIT(atoi(arg), 0, 100); OLC_VAL(d)++; break; case TRIGEDIT_ARGUMENT: smash_tilde(arg); OLC_TRIG(d)->arglist = (*arg?strdup(arg):NULL); OLC_VAL(d)++; break; case TRIGEDIT_TYPES: if ((i = atoi(arg)) == 0) break; else if (!((i < 0) || (i > NUM_TRIG_TYPE_FLAGS))) TOGGLE_BIT((GET_TRIG_TYPE(OLC_TRIG(d))), 1 << (i - 1)); OLC_VAL(d)++; trigedit_disp_types(d); return; case TRIGEDIT_COMMANDS: break; } OLC_MODE(d) = TRIGEDIT_MAIN_MENU; trigedit_disp_menu(d); }
void wedit_parse(struct descriptor_data *d, char *arg) { int number ; switch (OLC_MODE(d)) { case WEDIT_CONFIRM_SAVESTRING: switch (*arg) { case 'y': case 'Y': wedit_save_internally(d); sprintf(buf, "OLC: %s edits wild element %d.", GET_NAME(d->character), OLC_NUM(d)); mudlog(buf, CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE); /* * Do NOT free strings! Just the wild element structure. */ cleanup_olc(d, CLEANUP_STRUCTS); send_to_char("Wild element saved to memory.\r\n", d->character); break; case 'n': case 'N': /* * Free everything up, including strings, etc. */ cleanup_olc(d, CLEANUP_ALL); break; default: send_to_char("Invalid choice!\r\nDo you wish to save this wild element internally? : ", d->character); break; } return; case WEDIT_MAIN_MENU: switch (*arg) { case 'q': case 'Q': if (OLC_VAL(d)) /* Something has been modified. */ { send_to_char("Do you wish to save this wild element internally? : ", d->character); OLC_MODE(d) = WEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': send_to_char("Enter wild type name:-\r\n] ", d->character); OLC_MODE(d) = WEDIT_NAME; break; case '2': OLC_MODE(d) = WEDIT_DESC; #if defined(CLEAR_SCREEN) SEND_TO_Q("\x1B[H\x1B[J", d); #endif SEND_TO_Q("Enter wild type description: (/s saves /h for help)\r\n\r\n", d); d->backstr = NULL; if (OLC_WILD(d)->description) { SEND_TO_Q(OLC_WILD(d)->description, d); d->backstr = str_dup(OLC_WILD(d)->description); } d->str = &OLC_WILD(d)->description; d->max_str = MAX_ROOM_DESC; d->mail_to = 0; OLC_VAL(d)=1; break; case '3': send_to_char("Enter wild type symbol: \r\n", d->character); OLC_MODE(d) = WEDIT_SYMBOL; break; case '4': wedit_disp_color_menu(d); break; case '5': wedit_disp_flag_menu(d); break; case '6': wedit_disp_sector_menu(d); break; case '7': send_to_char("Enter wild type movement cost: \r\n", d->character); OLC_MODE(d) = WEDIT_MOVE_COST; break; case '8': send_to_char("Enter wild type altitudine: \r\n", d->character); OLC_MODE(d) = WEDIT_ALTITUDINE; break; case '9': if (OLC_WILD(d)->can_enter==TRUE) OLC_WILD(d)->can_enter=FALSE; else OLC_WILD(d)->can_enter=TRUE; OLC_VAL(d) = 1; wedit_disp_menu(d); break; case 'a': case 'A': send_to_char("This hasn't been implemented yet\r\n", d->character); wedit_disp_menu(d); break; default: send_to_char("Invalid choice!\r\n", d->character); wedit_disp_menu(d); break; } return; case WEDIT_NAME: if (OLC_WILD(d)->name) free(OLC_WILD(d)->name); if (strlen(arg) > MAX_ROOM_NAME) arg[MAX_ROOM_NAME - 1] = '\0'; OLC_WILD(d)->name = str_dup((arg && *arg) ? arg : "undefined"); break; case WEDIT_DESC: /* * We will NEVER get here, we hope. */ mudlog("SYSERR: Reached WEDIT_DESC case in parse_wedit", BRF, LVL_BUILDER, TRUE); break; case WEDIT_SYMBOL: if (!*arg) { send_to_char("Invalid choice!", d->character); wedit_disp_menu(d); return; } else OLC_WILD(d)->symbol = *arg; break; case WEDIT_COLOR: number = atoi(arg); if (number < 1 || number > NUM_WILD_COLOR) { send_to_char("Invalid choice!", d->character); wedit_disp_color_menu(d); return; } else OLC_WILD(d)->color = number; break; case WEDIT_FLAGS: number = atoi(arg); if ((number < 0) || (number > NUM_ROOM_FLAGS)) { send_to_char("That is not a valid choice!\r\n", d->character); wedit_disp_flag_menu(d); } else if (number == 0) break; else { /* * Toggle the bit. */ TOGGLE_BIT(OLC_WILD(d)->room_flags, 1 << (number - 1)); wedit_disp_flag_menu(d); } return; case WEDIT_SECTOR: number = atoi(arg); if (number < 0 || number >= NUM_ROOM_SECTORS) { send_to_char("Invalid choice!", d->character); wedit_disp_sector_menu(d); return; } else OLC_WILD(d)->sector_type = number; break; case WEDIT_MOVE_COST: number = atoi(arg); if (number < 1 || number > MAX_WILD_MOVE_COST) { send_to_char("Invalid choice!", d->character); wedit_disp_menu(d); return; } else OLC_WILD(d)->move_cost = number; break; case WEDIT_ALTITUDINE: number = atoi(arg); if (number < 1 || number > MAX_WILD_ALTITUDINE) { send_to_char("Invalid choice!", d->character); wedit_disp_menu(d); return; } else OLC_WILD(d)->altitudine = number; break; default: /* * We should never get here. */ mudlog("SYSERR: Reached default case in parse_wedit", BRF, LVL_BUILDER, TRUE); break; } /* * If we get this far, something has been changed. */ OLC_VAL(d) = 1; wedit_disp_menu(d); }
int filter_input(WINDOW *win, int c) { char buf[18]; int i; switch (c) { case 'm': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_MGMT); if (conf.filter_pkt & PKT_TYPE_MGMT) conf.filter_pkt |= PKT_TYPE_ALL_MGMT; else conf.filter_pkt &= ~PKT_TYPE_ALL_MGMT; break; case 'b': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_BEACON); break; case 'p': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_PROBE); break; case 'a': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_ASSOC); break; case 'u': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_AUTH); break; case 'c': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_CTRL); if (conf.filter_pkt & PKT_TYPE_CTRL) conf.filter_pkt |= PKT_TYPE_ALL_CTRL; else conf.filter_pkt &= ~PKT_TYPE_ALL_CTRL; break; case 'r': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_CTS | PKT_TYPE_RTS); break; case 'k': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_ACK); break; case 'd': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_DATA); if (conf.filter_pkt & PKT_TYPE_DATA) conf.filter_pkt |= PKT_TYPE_ALL_DATA; else conf.filter_pkt &= ~PKT_TYPE_ALL_DATA; break; case 'q': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_QDATA); break; case 'n': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_NULL); break; case 'R': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_ARP); break; case 'P': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_ICMP); break; case 'I': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_IP); break; case 'U': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_UDP); break; case 'T': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_TCP); break; case 'O': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_OLSR|PKT_TYPE_OLSR_LQ|PKT_TYPE_OLSR_GW); break; case 'B': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_BATMAN); break; case 'M': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_MESHZ); break; case 's': echo(); print_centered(win, FILTER_MAX, 57, "[ Enter new BSSID and ENTER ]"); mvwprintw(win, 5, MAC_COL + 4, ">"); mvwgetnstr(win, 5, MAC_COL + 7, buf, 17); noecho(); convert_string_to_mac(buf, conf.filterbssid); break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': i = c - '1'; if (MAC_NOT_EMPTY(conf.filtermac[i]) && conf.filtermac_enabled[i]) { conf.filtermac_enabled[i] = 0; } else { echo(); print_centered(win, FILTER_MAX, 57, "[ Enter new MAC %d and ENTER ]", i+1); mvwprintw(win, 9 + i, MAC_COL + 4, ">"); mvwgetnstr(win, 9 + i, MAC_COL + 7, buf, 17); noecho(); /* just enable old MAC if user pressed return only */ if (*buf == '\0' && MAC_NOT_EMPTY(conf.filtermac[i])) conf.filtermac_enabled[i] = 1; else { convert_string_to_mac(buf, conf.filtermac[i]); if (MAC_NOT_EMPTY(conf.filtermac[i])) conf.filtermac_enabled[i] = true; } } break; case 'o': conf.filter_off = conf.filter_off ? 0 : 1; break; default: return 0; } /* convenience: */ /* if one of the individual mgmt frames is deselected we dont want to see all mgmt frames */ if ((conf.filter_pkt & PKT_TYPE_ALL_MGMT) != PKT_TYPE_ALL_MGMT) conf.filter_pkt = conf.filter_pkt & ~PKT_TYPE_MGMT; /* same for ctl */ if ((conf.filter_pkt & PKT_TYPE_ALL_CTRL) != PKT_TYPE_ALL_CTRL) conf.filter_pkt = conf.filter_pkt & ~PKT_TYPE_CTRL; /* same for data */ if ((conf.filter_pkt & PKT_TYPE_ALL_DATA) != PKT_TYPE_ALL_DATA) conf.filter_pkt = conf.filter_pkt & ~PKT_TYPE_DATA; /* recalculate filter flag */ conf.do_macfilter = 0; for (i = 0; i < MAX_FILTERMAC; i++) { if (conf.filtermac_enabled[i]) conf.do_macfilter = 1; } net_send_filter_config(); update_filter_win(win); return 1; }
void do_mpmset( CHAR_DATA * ch, const char *argument ) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; char log_buf[MAX_STRING_LENGTH]; char outbuf[MAX_STRING_LENGTH]; CHAR_DATA *victim; int value, v2; int minattr, maxattr; /* * A desc means switched.. too many loopholes if we allow that.. */ if ( !IS_NPC( ch ) || IS_AFFECTED( ch, AFF_CHARM ) || ch->desc ) { send_to_char( "Huh?\r\n", ch ); return; } smash_tilde( argument ); argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); mudstrlcpy( arg3, argument, MAX_INPUT_LENGTH ); if ( !*arg1 ) { progbug( "MpMset: no args", ch ); return; } if ( ( victim = get_char_room( ch, arg1 ) ) == NULL ) { progbug( "MpMset: no victim", ch ); return; } if ( IS_IMMORTAL( victim ) ) { send_to_char( "You can't do that!\r\n", ch ); return; } if ( IS_NPC( victim ) && xIS_SET( victim->act, ACT_PROTOTYPE ) ) { progbug( "MpMset: victim is proto", ch ); return; } if ( IS_NPC( victim ) ) { minattr = 1; maxattr = 25; } else { minattr = 3; maxattr = 18; } value = is_number( arg3 ) ? atoi( arg3 ) : -1; if ( atoi( arg3 ) < -1 && value == -1 ) value = atoi( arg3 ); if ( !str_cmp( arg2, "str" ) ) { if ( value < minattr || value > maxattr ) { progbug( "MpMset: Invalid str", ch ); return; } victim->perm_str = value; return; } if ( !str_cmp( arg2, "int" ) ) { if ( value < minattr || value > maxattr ) { progbug( "MpMset: Invalid int", ch ); return; } victim->perm_int = value; return; } if ( !str_cmp( arg2, "wis" ) ) { if ( value < minattr || value > maxattr ) { progbug( "MpMset: Invalid wis", ch ); return; } victim->perm_wis = value; return; } if ( !str_cmp( arg2, "dex" ) ) { if ( value < minattr || value > maxattr ) { progbug( "MpMset: Invalid dex", ch ); return; } victim->perm_dex = value; return; } if ( !str_cmp( arg2, "con" ) ) { if ( value < minattr || value > maxattr ) { progbug( "MpMset: Invalid con", ch ); return; } victim->perm_con = value; return; } if ( !str_cmp( arg2, "cha" ) ) { if ( value < minattr || value > maxattr ) { progbug( "MpMset: Invalid cha", ch ); return; } victim->perm_cha = value; return; } if ( !str_cmp( arg2, "lck" ) ) { if ( value < minattr || value > maxattr ) { progbug( "MpMset: Invalid lck", ch ); return; } victim->perm_lck = value; return; } if ( !str_cmp( arg2, "sav1" ) ) { if ( value < -30 || value > 30 ) { progbug( "MpMset: Invalid sav1", ch ); return; } victim->saving_poison_death = value; return; } if ( !str_cmp( arg2, "sav2" ) ) { if ( value < -30 || value > 30 ) { progbug( "MpMset: Invalid sav2", ch ); return; } victim->saving_wand = value; return; } if ( !str_cmp( arg2, "sav3" ) ) { if ( value < -30 || value > 30 ) { progbug( "MpMset: Invalid sav3", ch ); return; } victim->saving_para_petri = value; return; } if ( !str_cmp( arg2, "sav4" ) ) { if ( value < -30 || value > 30 ) { progbug( "MpMset: Invalid sav4", ch ); return; } victim->saving_breath = value; return; } if ( !str_cmp( arg2, "sav5" ) ) { if ( value < -30 || value > 30 ) { progbug( "MpMset: Invalid sav5", ch ); return; } victim->saving_spell_staff = value; return; } if ( !str_cmp( arg2, "sex" ) ) { if ( value < 0 || value > 2 ) { progbug( "MpMset: Invalid sex", ch ); return; } victim->sex = value; return; } if ( !str_cmp( arg2, "class" ) ) { if ( IS_NPC( victim ) ) /* Broken by Haus... fixed by Thoric */ { if ( value >= MAX_NPC_CLASS || value < 0 ) { progbug( "MpMset: Invalid npc class", ch ); return; } victim->Class = value; return; } progbug( "MpMset: can't set pc class", ch ); } if ( !str_cmp( arg2, "race" ) ) { value = get_npc_race( arg3 ); if ( value < 0 ) value = atoi( arg3 ); if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc race", ch ); return; } if ( value < 0 || value >= MAX_NPC_RACE ) { progbug( "MpMset: Invalid npc race", ch ); return; } victim->race = value; return; } if ( !str_cmp( arg2, "armor" ) ) { if ( value < -300 || value > 300 ) { send_to_char( "AC range is -300 to 300.\r\n", ch ); return; } victim->armor = value; return; } if ( !str_cmp( arg2, "level" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc level", ch ); return; } if ( value < 0 || value > LEVEL_AVATAR + 5 ) { progbug( "MpMset: Invalid npc level", ch ); return; } victim->level = value; return; } if ( !str_cmp( arg2, "numattacks" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc numattacks", ch ); return; } if ( value < 0 || value > 20 ) { progbug( "MpMset: Invalid npc numattacks", ch ); return; } victim->numattacks = value; return; } if ( !str_cmp( arg2, "gold" ) ) { victim->gold = value; return; } if ( !str_cmp( arg2, "hitroll" ) ) { victim->hitroll = URANGE( 0, value, 85 ); return; } if ( !str_cmp( arg2, "damroll" ) ) { victim->damroll = URANGE( 0, value, 65 ); return; } if ( !str_cmp( arg2, "hp" ) ) { if ( value < 1 || value > 32700 ) { progbug( "MpMset: Invalid hp", ch ); return; } victim->max_hit = value; return; } if ( !str_cmp( arg2, "mana" ) ) { if ( value < 0 || value > 30000 ) { progbug( "MpMset: Invalid mana", ch ); return; } victim->max_mana = value; return; } if ( !str_cmp( arg2, "move" ) ) { if ( value < 0 || value > 30000 ) { progbug( "MpMset: Invalid move", ch ); return; } victim->max_move = value; return; } if ( !str_cmp( arg2, "practice" ) ) { if ( value < 0 || value > 100 ) { progbug( "MpMset: Invalid practice", ch ); return; } victim->practice = value; return; } if ( !str_cmp( arg2, "align" ) ) { if ( value < -1000 || value > 1000 ) { progbug( "MpMset: Invalid align", ch ); return; } victim->alignment = value; return; } /* non-functional for now -- Blod if ( !str_cmp( arg2, "quest" ) ) { if ( IS_NPC(victim) ) { progbug("MpMset: can't set npc quest", ch); return; } if ( value < 0 || value > 500 ) { progbug("MpMset: Invalid pc quest", ch); return; } victim->pcdata->quest = value; return; } */ if ( !str_cmp( arg2, "questplus" ) ) { if ( IS_NPC( victim ) ) { progbug( "MpMset: can't set npc qp", ch ); return; } if ( value < 0 || value > 5000 ) { progbug( "MpMset: Invalid pc qp", ch ); return; } snprintf( log_buf, MAX_STRING_LENGTH, "%s raising glory of %s by %d ...", ch->name, victim->name, value ); log_string( log_buf ); victim->pcdata->quest_curr += value; victim->pcdata->quest_accum += value; return; } if ( !str_cmp( arg2, "favor" ) ) { if ( IS_NPC( victim ) ) { progbug( "MpMset: can't set npc favor", ch ); return; } if ( value < -2500 || value > 2500 ) { progbug( "MpMset: Invalid pc favor", ch ); return; } victim->pcdata->favor = value; return; } if ( !str_cmp( arg2, "mentalstate" ) ) { if ( value < -100 || value > 100 ) { progbug( "MpMset: Invalid mentalstate", ch ); return; } victim->mental_state = value; return; } if ( !str_cmp( arg2, "emotion" ) ) { if ( value < -100 || value > 100 ) { progbug( "MpMset: Invalid emotion", ch ); return; } victim->emotional_state = value; return; } if ( !str_cmp( arg2, "thirst" ) ) { if ( IS_NPC( victim ) ) { progbug( "MpMset: can't set npc thirst", ch ); return; } if ( value < 0 || value > 100 ) { progbug( "MpMset: Invalid pc thirst", ch ); return; } victim->pcdata->condition[COND_THIRST] = value; return; } if ( !str_cmp( arg2, "drunk" ) ) { if ( IS_NPC( victim ) ) { progbug( "MpMset: can't set npc drunk", ch ); return; } if ( value < 0 || value > 100 ) { progbug( "MpMset: Invalid pc drunk", ch ); return; } victim->pcdata->condition[COND_DRUNK] = value; return; } if ( !str_cmp( arg2, "full" ) ) { if ( IS_NPC( victim ) ) { progbug( "MpMset: can't set npc full", ch ); return; } if ( value < 0 || value > 100 ) { progbug( "MpMset: Invalid pc full", ch ); return; } victim->pcdata->condition[COND_FULL] = value; return; } if ( !str_cmp( arg2, "blood" ) ) { if ( IS_NPC( victim ) ) { progbug( "MpMset: can't set npc blood", ch ); return; } if ( value < 0 || value > MAX_LEVEL + 10 ) { progbug( "MpMset: Invalid pc blood", ch ); return; } victim->pcdata->condition[COND_BLOODTHIRST] = value; return; } if ( !str_cmp( arg2, "name" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc name", ch ); return; } STRFREE( victim->name ); victim->name = STRALLOC( arg3 ); return; } if ( !str_cmp( arg2, "deity" ) ) { DEITY_DATA *deity; if ( IS_NPC( victim ) ) { progbug( "MpMset: can't set npc deity", ch ); return; } if ( arg3[0] == '\0' ) { STRFREE( victim->pcdata->deity_name ); victim->pcdata->deity_name = STRALLOC( "" ); victim->pcdata->deity = NULL; return; } deity = get_deity( arg3 ); if ( !deity ) { progbug( "MpMset: Invalid deity", ch ); return; } STRFREE( victim->pcdata->deity_name ); victim->pcdata->deity_name = QUICKLINK( deity->name ); victim->pcdata->deity = deity; return; } if ( !str_cmp( arg2, "short" ) ) { STRFREE( victim->short_descr ); victim->short_descr = STRALLOC( arg3 ); return; } if ( !str_cmp( arg2, "long" ) ) { STRFREE( victim->long_descr ); mudstrlcpy( buf, arg3, MAX_STRING_LENGTH ); mudstrlcat( buf, "\r\n", MAX_STRING_LENGTH ); victim->long_descr = STRALLOC( buf ); return; } if ( !str_cmp( arg2, "title" ) ) { if ( IS_NPC( victim ) ) { progbug( "MpMset: can't set npc title", ch ); return; } set_title( victim, arg3 ); return; } if ( !str_cmp( arg2, "spec" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc spec", ch ); return; } if ( !str_cmp( arg3, "none" ) ) { victim->spec_fun = NULL; return; } if ( ( victim->spec_fun = spec_lookup( arg3 ) ) == 0 ) { progbug( "MpMset: Invalid spec", ch ); return; } return; } if ( !str_cmp( arg2, "flags" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc flags", ch ); return; } if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no flags", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_actflag( arg3 ); if ( value < 0 || value >= MAX_BITS ) progbug( "MpMset: Invalid flag", ch ); else { if ( value == ACT_PROTOTYPE ) progbug( "MpMset: can't set prototype flag", ch ); else if ( value == ACT_IS_NPC ) progbug( "MpMset: can't remove npc flag", ch ); else xTOGGLE_BIT( victim->act, value ); } } return; } if ( !str_cmp( arg2, "affected" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't modify pc affected", ch ); return; } if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no affected", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_aflag( arg3 ); if ( value < 0 || value >= MAX_BITS ) progbug( "MpMset: Invalid affected", ch ); else xTOGGLE_BIT( victim->affected_by, value ); } return; } /* * save some more finger-leather for setting RIS stuff * Why there's can_modify checks here AND in the called function, Ill * never know, so I removed them.. -- Alty */ if ( !str_cmp( arg2, "r" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 ); do_mpmset( ch, outbuf ); return; } if ( !str_cmp( arg2, "i" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 ); do_mpmset( ch, outbuf ); return; } if ( !str_cmp( arg2, "s" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 ); do_mpmset( ch, outbuf ); return; } if ( !str_cmp( arg2, "ri" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 ); do_mpmset( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 ); do_mpmset( ch, outbuf ); return; } if ( !str_cmp( arg2, "rs" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 ); do_mpmset( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 ); do_mpmset( ch, outbuf ); return; } if ( !str_cmp( arg2, "is" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 ); do_mpmset( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 ); do_mpmset( ch, outbuf ); return; } if ( !str_cmp( arg2, "ris" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 ); do_mpmset( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 ); do_mpmset( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 ); do_mpmset( ch, outbuf ); return; } if ( !str_cmp( arg2, "resistant" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc resistant", ch ); return; } if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no resistant", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_risflag( arg3 ); if ( value < 0 || value > 31 ) progbug( "MpMset: Invalid resistant", ch ); else TOGGLE_BIT( victim->resistant, 1 << value ); } return; } if ( !str_cmp( arg2, "immune" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc immune", ch ); return; } if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no immune", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_risflag( arg3 ); if ( value < 0 || value > 31 ) progbug( "MpMset: Invalid immune", ch ); else TOGGLE_BIT( victim->immune, 1 << value ); } return; } if ( !str_cmp( arg2, "susceptible" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc susceptible", ch ); return; } if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no susceptible", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_risflag( arg3 ); if ( value < 0 || value > 31 ) progbug( "MpMset: Invalid susceptible", ch ); else TOGGLE_BIT( victim->susceptible, 1 << value ); } return; } if ( !str_cmp( arg2, "part" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc part", ch ); return; } if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no part", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_partflag( arg3 ); if ( value < 0 || value > 31 ) progbug( "MpMset: Invalid part", ch ); else TOGGLE_BIT( victim->xflags, 1 << value ); } return; } if ( !str_cmp( arg2, "attack" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc attack", ch ); return; } if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no attack", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_attackflag( arg3 ); if ( value < 0 ) progbug( "MpMset: Invalid attack", ch ); else xTOGGLE_BIT( victim->attacks, value ); } return; } if ( !str_cmp( arg2, "defense" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc defense", ch ); return; } if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no defense", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_defenseflag( arg3 ); if ( value < 0 || value >= MAX_BITS ) progbug( "MpMset: Invalid defense", ch ); else xTOGGLE_BIT( victim->defenses, value ); } return; } if ( !str_cmp( arg2, "pos" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc pos", ch ); return; } if ( value < 0 || value > POS_STANDING ) { progbug( "MpMset: Invalid pos", ch ); return; } victim->position = value; return; } if ( !str_cmp( arg2, "defpos" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc defpos", ch ); return; } if ( value < 0 || value > POS_STANDING ) { progbug( "MpMset: Invalid defpos", ch ); return; } victim->defposition = value; return; } if ( !str_cmp( arg2, "speaks" ) ) { if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no speaks", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_langflag( arg3 ); v2 = get_langnum( arg3 ); if ( value == LANG_UNKNOWN ) progbug( "MpMset: Invalid speaks", ch ); else if ( !IS_NPC( victim ) ) { if ( !( value &= VALID_LANGS ) ) { progbug( "MpMset: Invalid player language", ch ); continue; } if ( v2 == -1 ) ch_printf( ch, "Unknown language: %s\r\n", arg3 ); else TOGGLE_BIT( victim->speaks, 1 << v2 ); } else { if ( v2 == -1 ) ch_printf( ch, "Unknown language: %s\r\n", arg3 ); else TOGGLE_BIT( victim->speaks, 1 << v2 ); } } if ( !IS_NPC( victim ) ) { REMOVE_BIT( victim->speaks, race_table[victim->race]->language ); if ( !knows_language( victim, victim->speaking, victim ) ) victim->speaking = race_table[victim->race]->language; } return; } if ( !str_cmp( arg2, "speaking" ) ) { if ( !IS_NPC( victim ) ) { progbug( "MpMset: can't set pc speaking", ch ); return; } if ( !argument || argument[0] == '\0' ) { progbug( "MpMset: no speaking", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_langflag( arg3 ); if ( value == LANG_UNKNOWN ) progbug( "MpMset: Invalid speaking", ch ); else { v2 = get_langnum( arg3 ); if ( v2 == -1 ) ch_printf( ch, "Unknown language: %s\r\n", arg3 ); else TOGGLE_BIT( victim->speaks, 1 << v2 ); } } return; } progbug( "MpMset: Invalid field", ch ); return; }
void do_quiet ( CHAR_DATA *ch, char * argument) { TOGGLE_BIT(ch->comm,COMM_QUIET); send_to_one(ch, "Quiet mode toggled."); }
void do_afk ( CHAR_DATA *ch, char * argument) { TOGGLE_BIT(ch->comm,COMM_AFK); send_to_one(ch, "AFK mode toggled."); }
void sedit_parse(struct descriptor_data *d, char *arg) { int i; if (OLC_MODE(d) > SEDIT_NUMERICAL_RESPONSE) { if (!isdigit(arg[0]) && ((*arg == '-') && (!isdigit(arg[1])))) { write_to_output(d, "Field must be numerical, try again : "); return; } } switch (OLC_MODE(d)) { /*-------------------------------------------------------------------*/ case SEDIT_CONFIRM_SAVESTRING: switch (*arg) { case 'y': case 'Y': sedit_save_internally(d); mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE, "OLC: %s edits shop %d", GET_NAME(d->character), OLC_NUM(d)); if (CONFIG_OLC_SAVE) { sedit_save_to_disk(real_zone_by_thing(OLC_NUM(d))); write_to_output(d, "Shop saved to disk.\r\n"); } else write_to_output(d, "Shop saved to memory.\r\n"); cleanup_olc(d, CLEANUP_STRUCTS); return; case 'n': case 'N': cleanup_olc(d, CLEANUP_ALL); return; default: write_to_output(d, "Invalid choice!\r\nDo you wish to save your changes? : "); return; } break; /*-------------------------------------------------------------------*/ case SEDIT_MAIN_MENU: i = 0; switch (*arg) { case 'q': case 'Q': if (OLC_VAL(d)) { /* Anything been changed? */ write_to_output(d, "Do you wish to save your changes? : "); OLC_MODE(d) = SEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '0': OLC_MODE(d) = SEDIT_KEEPER; write_to_output(d, "Enter vnum number of shop keeper : "); return; case '1': OLC_MODE(d) = SEDIT_OPEN1; i++; break; case '2': OLC_MODE(d) = SEDIT_CLOSE1; i++; break; case '3': OLC_MODE(d) = SEDIT_OPEN2; i++; break; case '4': OLC_MODE(d) = SEDIT_CLOSE2; i++; break; case '5': OLC_MODE(d) = SEDIT_BUY_PROFIT; i++; break; case '6': OLC_MODE(d) = SEDIT_SELL_PROFIT; i++; break; case '7': OLC_MODE(d) = SEDIT_NOITEM1; i--; break; case '8': OLC_MODE(d) = SEDIT_NOITEM2; i--; break; case '9': OLC_MODE(d) = SEDIT_NOCASH1; i--; break; case 'a': case 'A': OLC_MODE(d) = SEDIT_NOCASH2; i--; break; case 'b': case 'B': OLC_MODE(d) = SEDIT_NOBUY; i--; break; case 'c': case 'C': OLC_MODE(d) = SEDIT_BUY; i--; break; case 'd': case 'D': OLC_MODE(d) = SEDIT_SELL; i--; break; case 'e': case 'E': sedit_no_trade_menu(d); return; case 'f': case 'F': sedit_shop_flags_menu(d); return; case 'r': case 'R': sedit_rooms_menu(d); return; case 'p': case 'P': sedit_products_menu(d); return; case 't': case 'T': sedit_namelist_menu(d); return; default: sedit_disp_menu(d); return; } if (i == 0) break; else if (i == 1) write_to_output(d, "\r\nEnter new value : "); else if (i == -1) write_to_output(d, "\r\nEnter new text :\r\n] "); else write_to_output(d, "Oops...\r\n"); return; /*-------------------------------------------------------------------*/ case SEDIT_NAMELIST_MENU: switch (*arg) { case 'a': case 'A': sedit_types_menu(d); return; case 'd': case 'D': write_to_output(d, "\r\nDelete which entry? : "); OLC_MODE(d) = SEDIT_DELETE_TYPE; return; case 'q': case 'Q': break; } break; /*-------------------------------------------------------------------*/ case SEDIT_PRODUCTS_MENU: switch (*arg) { case 'a': case 'A': write_to_output(d, "\r\nEnter new product vnum number : "); OLC_MODE(d) = SEDIT_NEW_PRODUCT; return; case 'd': case 'D': write_to_output(d, "\r\nDelete which product? : "); OLC_MODE(d) = SEDIT_DELETE_PRODUCT; return; case 'q': case 'Q': break; } break; /*-------------------------------------------------------------------*/ case SEDIT_ROOMS_MENU: switch (*arg) { case 'a': case 'A': write_to_output(d, "\r\nEnter new room vnum number : "); OLC_MODE(d) = SEDIT_NEW_ROOM; return; case 'c': case 'C': sedit_compact_rooms_menu(d); return; case 'l': case 'L': sedit_rooms_menu(d); return; case 'd': case 'D': write_to_output(d, "\r\nDelete which room? : "); OLC_MODE(d) = SEDIT_DELETE_ROOM; return; case 'q': case 'Q': break; } break; /*-------------------------------------------------------------------*/ /* * String edits. */ case SEDIT_NOITEM1: if (genolc_checkstring(d, arg)) modify_string(&S_NOITEM1(OLC_SHOP(d)), arg); break; case SEDIT_NOITEM2: if (genolc_checkstring(d, arg)) modify_string(&S_NOITEM2(OLC_SHOP(d)), arg); break; case SEDIT_NOCASH1: if (genolc_checkstring(d, arg)) modify_string(&S_NOCASH1(OLC_SHOP(d)), arg); break; case SEDIT_NOCASH2: if (genolc_checkstring(d, arg)) modify_string(&S_NOCASH2(OLC_SHOP(d)), arg); break; case SEDIT_NOBUY: if (genolc_checkstring(d, arg)) modify_string(&S_NOBUY(OLC_SHOP(d)), arg); break; case SEDIT_BUY: if (genolc_checkstring(d, arg)) modify_string(&S_BUY(OLC_SHOP(d)), arg); break; case SEDIT_SELL: if (genolc_checkstring(d, arg)) modify_string(&S_SELL(OLC_SHOP(d)), arg); break; case SEDIT_NAMELIST: if (genolc_checkstring(d, arg)) { struct shop_buy_data new_entry; BUY_TYPE(new_entry) = OLC_VAL(d); BUY_WORD(new_entry) = strdup(arg); add_to_type_list(&(S_NAMELISTS(OLC_SHOP(d))), &new_entry); } sedit_namelist_menu(d); return; /*-------------------------------------------------------------------*/ /* * Numerical responses. */ case SEDIT_KEEPER: i = atoi(arg); if ((i = atoi(arg)) != -1) if ((i = real_mobile(i)) == NOBODY) { write_to_output(d, "That mobile does not exist, try again : "); return; } S_KEEPER(OLC_SHOP(d)) = i; if (i == -1) break; /* * Fiddle with special procs. */ S_FUNC(OLC_SHOP(d)) = mob_index[i].func != shop_keeper ? mob_index[i].func : NULL; mob_index[i].func = shop_keeper; break; case SEDIT_OPEN1: S_OPEN1(OLC_SHOP(d)) = LIMIT(atoi(arg), 0, 28); break; case SEDIT_OPEN2: S_OPEN2(OLC_SHOP(d)) = LIMIT(atoi(arg), 0, 28); break; case SEDIT_CLOSE1: S_CLOSE1(OLC_SHOP(d)) = LIMIT(atoi(arg), 0, 28); break; case SEDIT_CLOSE2: S_CLOSE2(OLC_SHOP(d)) = LIMIT(atoi(arg), 0, 28); break; case SEDIT_BUY_PROFIT: sscanf(arg, "%f", &S_BUYPROFIT(OLC_SHOP(d))); break; case SEDIT_SELL_PROFIT: sscanf(arg, "%f", &S_SELLPROFIT(OLC_SHOP(d))); break; case SEDIT_TYPE_MENU: OLC_VAL(d) = LIMIT(atoi(arg), 0, NUM_ITEM_TYPES - 1); write_to_output(d, "Enter namelist (return for none) :-\r\n] "); OLC_MODE(d) = SEDIT_NAMELIST; return; case SEDIT_DELETE_TYPE: remove_from_type_list(&(S_NAMELISTS(OLC_SHOP(d))), atoi(arg)); sedit_namelist_menu(d); return; case SEDIT_NEW_PRODUCT: if ((i = atoi(arg)) != -1) if ((i = real_object(i)) == NOTHING) { write_to_output(d, "That object does not exist, try again : "); return; } if (i > 0) add_to_int_list(&(S_PRODUCTS(OLC_SHOP(d))), i); sedit_products_menu(d); return; case SEDIT_DELETE_PRODUCT: remove_from_int_list(&(S_PRODUCTS(OLC_SHOP(d))), atoi(arg)); sedit_products_menu(d); return; case SEDIT_NEW_ROOM: if ((i = atoi(arg)) != -1) if ((i = real_room(i)) == NOWHERE) { write_to_output(d, "That room does not exist, try again : "); return; } if (i >= 0) add_to_int_list(&(S_ROOMS(OLC_SHOP(d))), atoi(arg)); sedit_rooms_menu(d); return; case SEDIT_DELETE_ROOM: remove_from_int_list(&(S_ROOMS(OLC_SHOP(d))), atoi(arg)); sedit_rooms_menu(d); return; case SEDIT_SHOP_FLAGS: if ((i = LIMIT(atoi(arg), 0, NUM_SHOP_FLAGS)) > 0) { TOGGLE_BIT(S_BITVECTOR(OLC_SHOP(d)), 1 << (i - 1)); sedit_shop_flags_menu(d); return; } break; case SEDIT_NOTRADE: if ((i = LIMIT(atoi(arg), 0, NUM_TRADERS)) > 0) { TOGGLE_BIT(S_NOTRADE(OLC_SHOP(d)), 1 << (i - 1)); sedit_no_trade_menu(d); return; } break; /*-------------------------------------------------------------------*/ default: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: sedit_parse(): Reached default case!"); write_to_output(d, "Oops...\r\n"); break; } /*-------------------------------------------------------------------*/ /* * END OF CASE * If we get here, we have probably changed something, and now want to * return to main menu. Use OLC_VAL as a 'has changed' flag. */ OLC_VAL(d) = 1; sedit_disp_menu(d); }
void oedit_parse(struct descriptor_data *d, char *arg) { int number, max_val, min_val; char *oldtext = NULL; struct board_info *tmp; struct obj_data *obj; obj_rnum robj; switch (OLC_MODE(d)) { case OEDIT_CONFIRM_SAVESTRING: switch (*arg) { case 'y': case 'Y': oedit_save_internally(d); mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE, "OLC: %s edits obj %d", GET_NAME(d->character), OLC_NUM(d)); if (CONFIG_OLC_SAVE) { oedit_save_to_disk(real_zone_by_thing(OLC_NUM(d))); write_to_output(d, "Object saved to disk.\r\n"); } else write_to_output(d, "Object saved to memory.\r\n"); if (GET_OBJ_TYPE(OLC_OBJ(d)) == ITEM_BOARD) { if ((tmp=locate_board(GET_OBJ_VNUM(OLC_OBJ(d)))) != NULL) { save_board(tmp); } else { tmp = create_new_board(GET_OBJ_VNUM(OLC_OBJ(d))); BOARD_NEXT(tmp) = bboards; bboards = tmp; } } /* Fall through. */ case 'n': case 'N': cleanup_olc(d, CLEANUP_ALL); return; case 'a': /* abort quit */ case 'A': oedit_disp_menu(d); return; default: write_to_output(d, "Invalid choice!\r\n"); write_to_output(d, "Do you wish to save your changes? : \r\n"); return; } case OEDIT_MAIN_MENU: /* * Throw us out to whichever edit mode based on user input. */ switch (*arg) { case 'q': case 'Q': if (STATE(d) != CON_IEDIT) { if (OLC_VAL(d)) { /* Something has been modified. */ write_to_output(d, "Do you wish to save your changes? : "); OLC_MODE(d) = OEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); } else { send_to_char(d->character, "\r\nCommitting iedit changes.\r\n"); obj = OLC_IOBJ(d); *obj = *(OLC_OBJ(d)); GET_ID(obj) = max_obj_id++; /* find_obj helper */ add_to_lookup_table(GET_ID(obj), (void *)obj); if (GET_OBJ_VNUM(obj) != NOTHING) { /* remove any old scripts */ if (SCRIPT(obj)) { extract_script(obj, OBJ_TRIGGER); SCRIPT(obj) = NULL; } free_proto_script(obj, OBJ_TRIGGER); robj = real_object(GET_OBJ_VNUM(obj)); copy_proto_script(&obj_proto[robj], obj, OBJ_TRIGGER); assign_triggers(obj, OBJ_TRIGGER); } SET_BIT_AR(GET_OBJ_EXTRA(obj), ITEM_UNIQUE_SAVE); /* Xap - ought to save the old pointer, free after assignment I suppose */ mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE, "OLC: %s iedit a unique #%d", GET_NAME(d->character), GET_OBJ_VNUM(obj)); if (d->character) { REMOVE_BIT_AR(PLR_FLAGS(d->character), PLR_WRITING); STATE(d) = CON_PLAYING; act("$n stops using OLC.", TRUE, d->character, 0, 0, TO_ROOM); } free(d->olc); d->olc = NULL; } return; case '1': write_to_output(d, "Enter namelist : "); OLC_MODE(d) = OEDIT_EDIT_NAMELIST; break; case '2': write_to_output(d, "Enter short desc : "); OLC_MODE(d) = OEDIT_SHORTDESC; break; case '3': write_to_output(d, "Enter long desc :-\r\n| "); OLC_MODE(d) = OEDIT_LONGDESC; break; case '4': OLC_MODE(d) = OEDIT_ACTDESC; send_editor_help(d); write_to_output(d, "Enter action description:\r\n\r\n"); if (OLC_OBJ(d)->action_description) { write_to_output(d, "%s", OLC_OBJ(d)->action_description); oldtext = strdup(OLC_OBJ(d)->action_description); } string_write(d, &OLC_OBJ(d)->action_description, MAX_MESSAGE_LENGTH, 0, oldtext); OLC_VAL(d) = 1; break; case '5': oedit_disp_type_menu(d); OLC_MODE(d) = OEDIT_TYPE; break; case '6': oedit_disp_extra_menu(d); OLC_MODE(d) = OEDIT_EXTRAS; break; case '7': oedit_disp_wear_menu(d); OLC_MODE(d) = OEDIT_WEAR; break; case '8': write_to_output(d, "Enter weight : "); OLC_MODE(d) = OEDIT_WEIGHT; break; case '9': write_to_output(d, "Enter cost : "); OLC_MODE(d) = OEDIT_COST; break; case 'a': case 'A': write_to_output(d, "Enter cost per day : "); OLC_MODE(d) = OEDIT_COSTPERDAY; break; case 'b': case 'B': write_to_output(d, "Enter timer : "); OLC_MODE(d) = OEDIT_TIMER; break; case 'c': case 'C': /* * Clear any old values */ GET_OBJ_VAL(OLC_OBJ(d), 0) = 0; GET_OBJ_VAL(OLC_OBJ(d), 1) = 0; GET_OBJ_VAL(OLC_OBJ(d), 2) = 0; GET_OBJ_VAL(OLC_OBJ(d), 3) = 0; OLC_VAL(d) = 1; oedit_disp_val1_menu(d); break; case 'd': case 'D': oedit_disp_prompt_apply_menu(d); break; case 'e': case 'E': /* * If extra descriptions don't exist. */ if (OLC_OBJ(d)->ex_description == NULL) { CREATE(OLC_OBJ(d)->ex_description, struct extra_descr_data, 1); OLC_OBJ(d)->ex_description->next = NULL; } OLC_DESC(d) = OLC_OBJ(d)->ex_description; oedit_disp_extradesc_menu(d); break; case 'm': case 'M': write_to_output(d, "Enter new minimum level: "); OLC_MODE(d) = OEDIT_LEVEL; break; case 'p': case 'P': oedit_disp_perm_menu(d); OLC_MODE(d) = OEDIT_PERM; break; case 's': case 'S': if (STATE(d) != CON_IEDIT) { OLC_SCRIPT_EDIT_MODE(d) = SCRIPT_MAIN_MENU; dg_script_menu(d); } else { write_to_output(d, "\r\nScripts cannot be modified on individual objects.\r\nEnter choice : "); } return; default: oedit_disp_menu(d); break; } return; /* * end of OEDIT_MAIN_MENU */ case OLC_SCRIPT_EDIT: if (dg_script_edit_parse(d, arg)) return; break; case OEDIT_EDIT_NAMELIST: if (!genolc_checkstring(d, arg)) break; if (OLC_OBJ(d)->name) free(OLC_OBJ(d)->name); OLC_OBJ(d)->name = str_udup(arg); break; case OEDIT_SHORTDESC: if (!genolc_checkstring(d, arg)) break; if (OLC_OBJ(d)->short_description) free(OLC_OBJ(d)->short_description); OLC_OBJ(d)->short_description = str_udup(arg); break; case OEDIT_LONGDESC: if (!genolc_checkstring(d, arg)) break; if (OLC_OBJ(d)->description) free(OLC_OBJ(d)->description); OLC_OBJ(d)->description = str_udup(arg); break; case OEDIT_TYPE: number = atoi(arg); if ((number < 1) || (number >= NUM_ITEM_TYPES)) { write_to_output(d, "Invalid choice, try again : "); return; } else GET_OBJ_TYPE(OLC_OBJ(d)) = number; /* what's the boundschecking worth if we don't do this ? -- Welcor */ GET_OBJ_VAL(OLC_OBJ(d), 0) = GET_OBJ_VAL(OLC_OBJ(d), 1) = GET_OBJ_VAL(OLC_OBJ(d), 2) = GET_OBJ_VAL(OLC_OBJ(d), 3) = 0; break; case OEDIT_EXTRAS: number = atoi(arg); if ((number < 0) || (number > NUM_ITEM_FLAGS)) { oedit_disp_extra_menu(d); return; } else if (number == 0) break; else { TOGGLE_BIT_AR(GET_OBJ_EXTRA(OLC_OBJ(d)), number - 1); oedit_disp_extra_menu(d); return; } case OEDIT_WEAR: number = atoi(arg); if ((number < 0) || (number > NUM_ITEM_WEARS)) { write_to_output(d, "That's not a valid choice!\r\n"); oedit_disp_wear_menu(d); return; } else if (number == 0) /* Quit. */ break; else { TOGGLE_BIT_AR(GET_OBJ_WEAR(OLC_OBJ(d)), (number - 1)); oedit_disp_wear_menu(d); return; } case OEDIT_WEIGHT: GET_OBJ_WEIGHT(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_WEIGHT); break; case OEDIT_COST: GET_OBJ_COST(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_COST); break; case OEDIT_COSTPERDAY: GET_OBJ_RENT(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_RENT); break; case OEDIT_TIMER: switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_PORTAL: GET_OBJ_TIMER(OLC_OBJ(d)) = LIMIT(atoi(arg), -1, MAX_OBJ_TIMER); break; default: GET_OBJ_TIMER(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_TIMER); break; } break; case OEDIT_LEVEL: GET_OBJ_LEVEL(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, LVL_IMPL); break; case OEDIT_PERM: if ((number = atoi(arg)) == 0) break; if (number > 0 && number <= NUM_AFF_FLAGS) { /* Setting AFF_CHARM on objects like this is dangerous. */ if (number != AFF_CHARM) { TOGGLE_BIT_AR(GET_OBJ_PERM(OLC_OBJ(d)), number); } } oedit_disp_perm_menu(d); return; case OEDIT_VALUE_1: /* * Lucky, I don't need to check any of these for out of range values. * Hmm, I'm not so sure - Rv */ switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_WEAPON: GET_OBJ_VAL(OLC_OBJ(d), 0) = MIN(MAX(atoi(arg), -50), 50); break; case ITEM_CONTAINER: GET_OBJ_VAL(OLC_OBJ(d), 0) = LIMIT(atoi(arg), -1, MAX_CONTAINER_SIZE); break; default: GET_OBJ_VAL(OLC_OBJ(d), 0) = atoi(arg); } /* * proceed to menu 2 */ oedit_disp_val2_menu(d); return; case OEDIT_VALUE_2: /* * Here, I do need to check for out of range values. */ number = atoi(arg); switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_SCROLL: case ITEM_POTION: if (number == 0 || number == -1) GET_OBJ_VAL(OLC_OBJ(d), 1) = -1; else GET_OBJ_VAL(OLC_OBJ(d), 1) = LIMIT(number, 1, NUM_SPELLS-1); oedit_disp_val3_menu(d); break; case ITEM_CONTAINER: case ITEM_VEHICLE: case ITEM_HATCH: case ITEM_WINDOW: case ITEM_PORTAL: /* * Needs some special handling since we are dealing with flag values * here. */ if (number < 0 || number > 4) oedit_disp_container_flags_menu(d); else if (number != 0) { TOGGLE_BIT(GET_OBJ_VAL(OLC_OBJ(d), 1), 1 << (number - 1)); OLC_VAL(d) = 1; oedit_disp_val2_menu(d); } else oedit_disp_val3_menu(d); break; case ITEM_WEAPON: GET_OBJ_VAL(OLC_OBJ(d), 1) = LIMIT(number, 1, MAX_WEAPON_NDICE); oedit_disp_val3_menu(d); break; default: GET_OBJ_VAL(OLC_OBJ(d), 1) = number; oedit_disp_val3_menu(d); } return; case OEDIT_VALUE_3: number = atoi(arg); /* * Quick'n'easy error checking. */ switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_SCROLL: case ITEM_POTION: if (number == 0 || number == -1) { GET_OBJ_VAL(OLC_OBJ(d), 2) = -1; oedit_disp_val4_menu(d); return; } min_val = 1; max_val = NUM_SPELLS - 1; break; case ITEM_WEAPON: min_val = 1; max_val = MAX_WEAPON_SDICE; break; case ITEM_WAND: case ITEM_STAFF: min_val = 0; max_val = 20; break; case ITEM_DRINKCON: case ITEM_FOUNTAIN: min_val = 0; max_val = NUM_LIQ_TYPES - 1; break; case ITEM_KEY: min_val = 0; max_val = 32099; break; default: min_val = -32000; max_val = 32000; } GET_OBJ_VAL(OLC_OBJ(d), 2) = LIMIT(number, min_val, max_val); oedit_disp_val4_menu(d); return; case OEDIT_VALUE_4: number = atoi(arg); switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_SCROLL: case ITEM_POTION: if (number == 0 || number == -1) { GET_OBJ_VAL(OLC_OBJ(d), 3) = -1; oedit_disp_menu(d); return; } min_val = 1; max_val = NUM_SPELLS - 1; break; case ITEM_WAND: case ITEM_STAFF: min_val = 1; max_val = NUM_SPELLS - 1; break; case ITEM_WEAPON: min_val = 0; max_val = NUM_ATTACK_TYPES - 1; break; default: min_val = -32000; max_val = 32000; break; } GET_OBJ_VAL(OLC_OBJ(d), 3) = LIMIT(number, min_val, max_val); break; case OEDIT_PROMPT_APPLY: if ((number = atoi(arg)) == 0) break; else if (number < 0 || number > MAX_OBJ_AFFECT) { oedit_disp_prompt_apply_menu(d); return; } OLC_VAL(d) = number - 1; OLC_MODE(d) = OEDIT_APPLY; oedit_disp_apply_menu(d); return; case OEDIT_APPLY: if ((number = atoi(arg)) == 0) { OLC_OBJ(d)->affected[OLC_VAL(d)].location = 0; OLC_OBJ(d)->affected[OLC_VAL(d)].modifier = 0; oedit_disp_prompt_apply_menu(d); } else if (number < 0 || number >= NUM_APPLIES) oedit_disp_apply_menu(d); else { int counter; /* add in check here if already applied.. deny builders another */ if (GET_LEVEL(d->character) < LVL_IMPL) { for (counter = 0; counter < MAX_OBJ_AFFECT; counter++) { if (OLC_OBJ(d)->affected[counter].location == number) { write_to_output(d, "Object already has that apply."); return; } } } OLC_OBJ(d)->affected[OLC_VAL(d)].location = number; write_to_output(d, "Modifier : "); OLC_MODE(d) = OEDIT_APPLYMOD; } return; case OEDIT_APPLYMOD: OLC_OBJ(d)->affected[OLC_VAL(d)].modifier = atoi(arg); oedit_disp_prompt_apply_menu(d); return; case OEDIT_EXTRADESC_KEY: if (genolc_checkstring(d, arg)) { if (OLC_DESC(d)->keyword) free(OLC_DESC(d)->keyword); OLC_DESC(d)->keyword = str_udup(arg); } oedit_disp_extradesc_menu(d); return; case OEDIT_EXTRADESC_MENU: switch ((number = atoi(arg))) { case 0: if (!OLC_DESC(d)->keyword || !OLC_DESC(d)->description) { struct extra_descr_data *temp; if (OLC_DESC(d)->keyword) free(OLC_DESC(d)->keyword); if (OLC_DESC(d)->description) free(OLC_DESC(d)->description); /* * Clean up pointers */ REMOVE_FROM_LIST(OLC_DESC(d), OLC_OBJ(d)->ex_description, next); free(OLC_DESC(d)); OLC_DESC(d) = NULL; } break; case 1: OLC_MODE(d) = OEDIT_EXTRADESC_KEY; write_to_output(d, "Enter keywords, separated by spaces :-\r\n| "); return; case 2: OLC_MODE(d) = OEDIT_EXTRADESC_DESCRIPTION; send_editor_help(d); write_to_output(d, "Enter the extra description:\r\n\r\n"); if (OLC_DESC(d)->description) { write_to_output(d, "%s", OLC_DESC(d)->description); oldtext = strdup(OLC_DESC(d)->description); } string_write(d, &OLC_DESC(d)->description, MAX_MESSAGE_LENGTH, 0, oldtext); OLC_VAL(d) = 1; return; case 3: /* * Only go to the next description if this one is finished. */ if (OLC_DESC(d)->keyword && OLC_DESC(d)->description) { struct extra_descr_data *new_extra; if (OLC_DESC(d)->next) OLC_DESC(d) = OLC_DESC(d)->next; else { /* Make new extra description and attach at end. */ CREATE(new_extra, struct extra_descr_data, 1); OLC_DESC(d)->next = new_extra; OLC_DESC(d) = OLC_DESC(d)->next; } } /* * No break - drop into default case. */ default: oedit_disp_extradesc_menu(d); return; } break; default: mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: Reached default case in oedit_parse()!"); write_to_output(d, "Oops...\r\n"); break; }
void do_mposet( CHAR_DATA * ch, const char *argument ) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; char buf[MAX_STRING_LENGTH]; OBJ_DATA *obj; char outbuf[MAX_STRING_LENGTH]; int value, tmp; /* * A desc means switched.. too many loopholes if we allow that.. */ if ( !IS_NPC( ch ) || IS_AFFECTED( ch, AFF_CHARM ) || ch->desc ) { send_to_char( "Huh?\r\n", ch ); return; } smash_tilde( argument ); argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); mudstrlcpy( arg3, argument, MAX_INPUT_LENGTH ); if ( !*arg1 ) { progbug( "MpOset: no args", ch ); return; } if ( ( obj = get_obj_here( ch, arg1 ) ) == NULL ) { progbug( "MpOset: no object", ch ); return; } if ( IS_OBJ_STAT( obj, ITEM_PROTOTYPE ) ) { progbug( "MpOset: can't set prototype items", ch ); return; } separate_obj( obj ); value = atoi( arg3 ); if ( !str_cmp( arg2, "value0" ) || !str_cmp( arg2, "v0" ) ) { obj->value[0] = value; return; } if ( !str_cmp( arg2, "value1" ) || !str_cmp( arg2, "v1" ) ) { obj->value[1] = value; return; } if ( !str_cmp( arg2, "value2" ) || !str_cmp( arg2, "v2" ) ) { obj->value[2] = value; return; } if ( !str_cmp( arg2, "value3" ) || !str_cmp( arg2, "v3" ) ) { obj->value[3] = value; return; } if ( !str_cmp( arg2, "value4" ) || !str_cmp( arg2, "v4" ) ) { obj->value[4] = value; return; } if ( !str_cmp( arg2, "value5" ) || !str_cmp( arg2, "v5" ) ) { obj->value[5] = value; return; } if ( !str_cmp( arg2, "type" ) ) { if ( !argument || argument[0] == '\0' ) { progbug( "MpOset: no type", ch ); return; } value = get_otype( argument ); if ( value < 1 ) { progbug( "MpOset: Invalid type", ch ); return; } obj->item_type = ( short ) value; return; } if ( !str_cmp( arg2, "flags" ) ) { if ( !argument || argument[0] == '\0' ) { progbug( "MpOset: no flags", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_oflag( arg3 ); if ( value < 0 || value >= MAX_BITS ) progbug( "MpOset: Invalid flag", ch ); else { if ( value == ITEM_PROTOTYPE ) progbug( "MpOset: can't set prototype flag", ch ); else xTOGGLE_BIT( obj->extra_flags, value ); } } return; } if ( !str_cmp( arg2, "wear" ) ) { if ( !argument || argument[0] == '\0' ) { progbug( "MpOset: no wear", ch ); return; } while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); value = get_wflag( arg3 ); if ( value < 0 || value > 31 ) progbug( "MpOset: Invalid wear", ch ); else TOGGLE_BIT( obj->wear_flags, 1 << value ); } return; } if ( !str_cmp( arg2, "level" ) ) { obj->level = value; return; } if ( !str_cmp( arg2, "weight" ) ) { obj->weight = value; return; } if ( !str_cmp( arg2, "cost" ) ) { obj->cost = value; return; } if ( !str_cmp( arg2, "timer" ) ) { obj->timer = value; return; } if ( !str_cmp( arg2, "name" ) ) { STRFREE( obj->name ); obj->name = STRALLOC( arg3 ); return; } if ( !str_cmp( arg2, "short" ) ) { STRFREE( obj->short_descr ); obj->short_descr = STRALLOC( arg3 ); if ( obj == supermob_obj ) { STRFREE( supermob->short_descr ); supermob->short_descr = QUICKLINK( obj->short_descr ); } /* * Feature added by Narn, Apr/96 * * If the item is not proto, add the word 'rename' to the keywords * * if it is not already there. */ if ( str_infix( "mprename", obj->name ) ) { snprintf( buf, MAX_STRING_LENGTH, "%s %s", obj->name, "mprename" ); STRFREE( obj->name ); obj->name = STRALLOC( buf ); } return; } if ( !str_cmp( arg2, "long" ) ) { STRFREE( obj->description ); mudstrlcpy( buf, arg3, MAX_STRING_LENGTH ); obj->description = STRALLOC( buf ); return; } if ( !str_cmp( arg2, "actiondesc" ) ) { if ( strstr( arg3, "%n" ) || strstr( arg3, "%d" ) || strstr( arg3, "%l" ) ) { progbug( "MpOset: Illegal actiondesc", ch ); return; } STRFREE( obj->action_desc ); obj->action_desc = STRALLOC( arg3 ); return; } if ( !str_cmp( arg2, "affect" ) ) { AFFECT_DATA *paf; short loc; int bitv; argument = one_argument( argument, arg2 ); if ( arg2[0] == '\0' || !argument || argument[0] == 0 ) { progbug( "MpOset: Bad affect syntax", ch ); send_to_char( "Usage: oset <object> affect <field> <value>\r\n", ch ); return; } loc = get_atype( arg2 ); if ( loc < 1 ) { progbug( "MpOset: Invalid affect field", ch ); return; } if ( loc >= APPLY_AFFECT && loc < APPLY_WEAPONSPELL ) { bitv = 0; while ( argument[0] != '\0' ) { argument = one_argument( argument, arg3 ); if ( loc == APPLY_AFFECT ) value = get_aflag( arg3 ); else value = get_risflag( arg3 ); if ( value < 0 || value > 31 ) progbug( "MpOset: bad affect flag", ch ); else SET_BIT( bitv, 1 << value ); } if ( !bitv ) return; value = bitv; } else { argument = one_argument( argument, arg3 ); value = atoi( arg3 ); } CREATE( paf, AFFECT_DATA, 1 ); paf->type = -1; paf->duration = -1; paf->location = loc; paf->modifier = value; xCLEAR_BITS( paf->bitvector ); paf->next = NULL; LINK( paf, obj->first_affect, obj->last_affect, next, prev ); ++top_affect; return; } if ( !str_cmp( arg2, "rmaffect" ) ) { AFFECT_DATA *paf; short loc, count; if ( !argument || argument[0] == '\0' ) { progbug( "MpOset: no rmaffect", ch ); return; } loc = atoi( argument ); if ( loc < 1 ) { progbug( "MpOset: Invalid rmaffect", ch ); return; } count = 0; for ( paf = obj->first_affect; paf; paf = paf->next ) { if ( ++count == loc ) { UNLINK( paf, obj->first_affect, obj->last_affect, next, prev ); DISPOSE( paf ); send_to_char( "Removed.\r\n", ch ); --top_affect; return; } } progbug( "MpOset: rmaffect not found", ch ); return; } /* * save some finger-leather */ if ( !str_cmp( arg2, "ris" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "r" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "i" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "s" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "ri" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "rs" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect resistant %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } if ( !str_cmp( arg2, "is" ) ) { snprintf( outbuf, MAX_STRING_LENGTH, "%s affect immune %s", arg1, arg3 ); do_mposet( ch, outbuf ); snprintf( outbuf, MAX_STRING_LENGTH, "%s affect susceptible %s", arg1, arg3 ); do_mposet( ch, outbuf ); return; } /* * Make it easier to set special object values by name than number * -Thoric */ tmp = -1; switch ( obj->item_type ) { case ITEM_WEAPON: if ( !str_cmp( arg2, "weapontype" ) ) { unsigned int x; value = -1; for ( x = 0; x < sizeof( attack_table ) / sizeof( attack_table[0] ); x++ ) if ( !str_cmp( arg3, attack_table[x] ) ) value = x; if ( value < 0 ) { progbug( "MpOset: Invalid weapon type", ch ); return; } tmp = 3; break; } if ( !str_cmp( arg2, "condition" ) ) tmp = 0; break; case ITEM_ARMOR: if ( !str_cmp( arg2, "condition" ) ) tmp = 3; if ( !str_cmp( arg2, "ac" ) ) tmp = 1; break; case ITEM_SALVE: if ( !str_cmp( arg2, "slevel" ) ) tmp = 0; if ( !str_cmp( arg2, "maxdoses" ) ) tmp = 1; if ( !str_cmp( arg2, "doses" ) ) tmp = 2; if ( !str_cmp( arg2, "delay" ) ) tmp = 3; if ( !str_cmp( arg2, "spell1" ) ) tmp = 4; if ( !str_cmp( arg2, "spell2" ) ) tmp = 5; if ( tmp >= 4 && tmp <= 5 ) value = skill_lookup( arg3 ); break; case ITEM_SCROLL: case ITEM_POTION: case ITEM_PILL: if ( !str_cmp( arg2, "slevel" ) ) tmp = 0; if ( !str_cmp( arg2, "spell1" ) ) tmp = 1; if ( !str_cmp( arg2, "spell2" ) ) tmp = 2; if ( !str_cmp( arg2, "spell3" ) ) tmp = 3; if ( tmp >= 1 && tmp <= 3 ) value = skill_lookup( arg3 ); break; case ITEM_STAFF: case ITEM_WAND: if ( !str_cmp( arg2, "slevel" ) ) tmp = 0; if ( !str_cmp( arg2, "spell" ) ) { tmp = 3; value = skill_lookup( arg3 ); } if ( !str_cmp( arg2, "maxcharges" ) ) tmp = 1; if ( !str_cmp( arg2, "charges" ) ) tmp = 2; break; case ITEM_CONTAINER: if ( !str_cmp( arg2, "capacity" ) ) tmp = 0; if ( !str_cmp( arg2, "cflags" ) ) tmp = 1; if ( !str_cmp( arg2, "key" ) ) tmp = 2; break; case ITEM_SWITCH: case ITEM_LEVER: case ITEM_PULLCHAIN: case ITEM_BUTTON: if ( !str_cmp( arg2, "tflags" ) ) { tmp = 0; value = get_trigflag( arg3 ); } break; } if ( tmp >= 0 && tmp <= 3 ) { obj->value[tmp] = value; return; } progbug( "MpOset: Invalid field", ch ); return; }
bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch(keycode) { // acts like a momentary function layer press case FUN_LAY: if (record->event.pressed) { layer_on(_FUNC); if (CHECK_BIT(keyboard_state, 1)) { layer_on(_MOUSE); } else { layer_off(_MOUSE); } // turns on function layer status SET_BIT(keyboard_state, 0); } // key released else { layer_off(_FUNC); layer_off(_MOUSE); // turns off function layer status CLEAR_BIT(keyboard_state, 0); } break; case MOU_TOG: if(record->event.pressed) { // toggles navigation layer state TOGGLE_BIT(keyboard_state, 1); // if FN is pressed down while hitting this key, the correct layer will be updated, // so that the FN key doesn't need to be pressed down again to start using the functionality if (CHECK_BIT(keyboard_state, 0)) { if (CHECK_BIT(keyboard_state, 1)) { layer_on(_MOUSE); } else { layer_off(_MOUSE); } } } break; case WIN_LCK: if (record->event.pressed) { // toggles windows key lock state TOGGLE_BIT(keyboard_state, 2); } break; // uses seperate WIN_KEY so that WIN_LCK does not affect Mac Layer's KC_LGUI case WIN_KEY: // checks if windows key lock is off to allow key to be pressed if (!CHECK_BIT(keyboard_state, 2)) { if (record->event.pressed) { SEND_STRING(SS_DOWN(X_LGUI)); return false; } // key released else { SEND_STRING(SS_UP(X_LGUI)); return false; } } break; } return true; };
void redit_parse( DESCRIPTOR_DATA *d , char *arg ) { ROOM_DATA *room = d->character->dest_buf; ROOM_DATA *tmp; EXIT_DATA *pexit = d->character->spare_ptr; EXTRA_DESCR_DATA *ed = d->character->spare_ptr; char arg1[MIL]; char buf[MSL]; int number = 0; switch ( OLC_MODE(d) ) { case REDIT_CONFIRM_SAVESTRING: switch ( *arg ) { case 'y': case 'Y': /* redit_save_internally(d); */ send_log( NULL, LOG_OLC, "OLC: %s edits room %d", d->character->name, OLC_NUM(d) ); cleanup_olc( d ); send_to_char( d->character, "Room saved to memory.\r\n" ); break; case 'n': case 'N': cleanup_olc( d ); break; default: send_to_char( d->character, "Invalid choice!\r\n" ); send_to_char( d->character, "Do you wish to save this room internally? : " ); break; } return; case REDIT_MAIN_MENU: switch ( *arg ) { case 'q': case 'Q': /* if ( OLC_CHANGE(d) ) { *. Something has been modified .* send_to_char( d->character, "Do you wish to save this room internally? : " ); OLC_MODE(d) = REDIT_CONFIRM_SAVESTRING; } else */ cleanup_olc( d ); return; case '1': send_to_char( d->character, "Enter room name:-\r\n| " ); OLC_MODE(d) = REDIT_NAME; break; case '2': OLC_MODE(d) = REDIT_DESC; d->character->substate = SUB_ROOM_DESCR; d->character->last_cmd = do_redit_reset; send_to_char( d->character, "Enter room description:-\r\n" ); if ( !room->description ) room->description = str_dup( "" ); start_editing( d->character, room->description ); break; case '3': redit_disp_flag_menu(d); break; case '4': redit_disp_sector_menu(d); break; case '5': send_to_char( d->character, "How many people can fit in the room? " ); OLC_MODE(d) = REDIT_TUNNEL; break; case '6': send_to_char( d->character, "How long before people are teleported out? " ); OLC_MODE(d) = REDIT_TELEDELAY; break; case '7': send_to_char( d->character, "Where are they teleported to? " ); OLC_MODE(d) = REDIT_TELEVNUM; break; case 'a': case 'A': redit_disp_exit_menu(d); break; case 'b': case 'B': redit_disp_extradesc_menu(d); break; default: send_to_char( d->character, "Invalid choice!" ); redit_disp_menu(d); break; } return; case REDIT_NAME: DISPOSE( room->name ); room->name = str_dup( arg ); olc_log( d, "Changed name to %s", room->name ); break; case REDIT_DESC: /* we will NEVER get here */ send_log( NULL, LOG_OLC, "redit_parse: reached REDIT_DESC case in redit_parse" ); break; case REDIT_FLAGS: if ( is_number(arg) ) { number = atoi( arg ); if ( number == 0 ) break; else if ( number < 0 || number >= MAX_ROOM ) { send_to_char( d->character, "Invalid flag, try again: " ); return; } else { number--; /* Offset for 0 */ TOGGLE_BIT( room->flags, number ); olc_log( d, "%s the room flag %s", HAS_BIT( room->flags, number ) ? "Added" : "Removed", code_name(NULL, number, CODE_ROOM) ); } } else { while ( VALID_STR(arg) ) { arg = one_argument( arg, arg1 ); number = code_num( NULL, arg1, CODE_ROOM ); if ( number > 0 ) { TOGGLE_BIT( room->flags, number ); olc_log( d, "%s the room flag %s", HAS_BIT( room->flags, number ) ? "Added" : "Removed", code_name( NULL, number, CODE_ROOM) ); } } } redit_disp_flag_menu(d); return; case REDIT_SECTOR: number = atoi( arg ); if ( number < 0 || number >= MAX_SECTOR ) { send_to_char( d->character, "Invalid choice!" ); redit_disp_sector_menu(d); return; } else room->sector = number; olc_log( d, "Changed sector to %s", code_name(NULL, number, CODE_SECTOR) ); break; case REDIT_TUNNEL: number = atoi( arg ); room->tunnel = URANGE( 0, number, 1000 ); olc_log( d, "Changed tunnel amount to %d", room->tunnel ); break; case REDIT_TELEDELAY: number = atoi( arg ); room->tele_delay = number; olc_log( d, "Changed teleportation delay to %d", room->tele_delay ); break; case REDIT_TELEVNUM: number = atoi( arg ); room->tele_vnum = URANGE( 1, number, MAX_VNUM-1 ); olc_log( d, "Changed teleportation vnum to %d", room->tele_vnum ); break; case REDIT_EXIT_MENU: switch ( toupper(arg[0]) ) { default: if ( is_number(arg) ) { number = atoi( arg ); pexit = get_exit_num( room, number ); d->character->spare_ptr = pexit; redit_disp_exit_edit(d); return; } redit_disp_exit_menu( d ); return; case 'A': OLC_MODE(d) = REDIT_EXIT_ADD; redit_disp_exit_dirs( d ); return; case 'R': OLC_MODE(d) = REDIT_EXIT_DELETE; send_to_char( d->character, "Delete which exit? " ); return; case 'Q': d->character->spare_ptr = NULL; break; } break; case REDIT_EXIT_EDIT: switch ( toupper(arg[0]) ) { case 'Q': d->character->spare_ptr = NULL; redit_disp_exit_menu(d); return; case '1': /* OLC_MODE(d) = REDIT_EXIT_DIR; redit_disp_exit_dirs(d); */ send_to_char( d->character, "This option can only be changed by remaking the exit.\r\n" ); break; case '2': OLC_MODE(d) = REDIT_EXIT_VNUM; send_to_char( d->character, "Which room does this exit go to? " ); return; case '3': OLC_MODE(d) = REDIT_EXIT_KEY; send_to_char( d->character, "What is the vnum of the key to this exit? " ); return; case '4': OLC_MODE(d) = REDIT_EXIT_KEYWORD; send_to_char( d->character, "What is the keyword to this exit? " ); return; case '5': OLC_MODE(d) = REDIT_EXIT_FLAGS; redit_disp_exit_flag_menu(d); return; case '6': OLC_MODE(d) = REDIT_EXIT_DESC; send_to_char( d->character, "Description:\r\n] " ); return; } redit_disp_exit_edit(d); return; case REDIT_EXIT_DESC: if ( !VALID_STR(arg) ) { DISPOSE( pexit->description ); pexit->description = str_dup( "" ); } else { sprintf( buf, "%s\r\n", arg ); DISPOSE( pexit->description ); pexit->description = str_dup( buf ); } olc_log( d, "Changed %s description to %s", code_name( NULL, pexit->vdir, CODE_DIR), arg ? arg : "none" ); redit_disp_exit_edit(d); return; case REDIT_EXIT_ADD: if ( is_number( arg ) ) { number = atoi( arg ); if ( number < 0 || number >= MAX_DIR ) { send_to_char( d->character, "Invalid direction, try again: " ); return; } d->character->tempnum = number; } else { number = get_dir(arg); pexit = get_exit( room, number ); if ( pexit ) { send_to_char( d->character, "An exit in that direction already exists.\r\n" ); redit_disp_exit_menu(d); return; } d->character->tempnum = number; } OLC_MODE(d) = REDIT_EXIT_ADD_VNUM; send_to_char( d->character, "Which room does this exit go to? " ); return; case REDIT_EXIT_ADD_VNUM: number = atoi( arg ); if ( (tmp = get_room_index(NULL, number)) == NULL ) { send_to_char( d->character, "Non-existant room.\r\n" ); OLC_MODE(d) = REDIT_EXIT_MENU; redit_disp_exit_menu(d); return; } pexit = make_exit( room, tmp, d->character->tempnum ); DISPOSE( pexit->keyword ); DISPOSE( pexit->description ); pexit->keyword = str_dup( "" ); pexit->description = str_dup( "" ); pexit->key = -1; pexit->flags = 0; act( AT_ADMIN, "$n reveals a hidden passage!", d->character, NULL, NULL, TO_ROOM ); d->character->spare_ptr = pexit; olc_log( d, "Added %s exit to %d", code_name( NULL, pexit->vdir, CODE_DIR), pexit->vnum ); OLC_MODE(d) = REDIT_EXIT_EDIT; redit_disp_exit_edit(d); return; case REDIT_EXIT_DELETE: if ( !is_number( arg ) ) { send_to_char( d->character, "Exit must be specified in a number.\r\n" ); redit_disp_exit_menu(d); } number = atoi( arg ); pexit = get_exit_num( room, number ); if ( !pexit ) { send_to_char( d->character, "That exit does not exist.\r\n" ); redit_disp_exit_menu(d); } olc_log( d, "Removed %s exit", code_name( NULL, pexit->vdir, CODE_DIR) ); extract_exit( room, pexit ); redit_disp_exit_menu( d ); return; case REDIT_EXIT_VNUM: number = atoi( arg ); if ( number < 1 || number >= MAX_VNUM ) { send_to_char( d->character, "Invalid room number, try again : " ); return; } if ( get_room_index(NULL, number) == NULL ) { send_to_char( d->character, "That room does not exist, try again: " ); return; } pexit->vnum = number; olc_log( d, "%s exit vnum changed to %d", code_name( NULL, pexit->vdir, CODE_DIR), pexit->vnum ); redit_disp_exit_menu( d ); return; case REDIT_EXIT_KEYWORD: DISPOSE( pexit->keyword ); pexit->keyword = str_dup( arg ); olc_log( d, "Changed %s keyword to %s", code_name( NULL, pexit->vdir, CODE_DIR), pexit->keyword ); redit_disp_exit_edit( d ); return; case REDIT_EXIT_KEY: number = atoi( arg ); if ( number < 1 || number >= MAX_VNUM ) send_to_char( d->character, "Invalid vnum, try again: " ); else { pexit->key = number; redit_disp_exit_edit( d ); } olc_log( d, "%s key vnum is now %d", code_name( NULL, pexit->vdir, CODE_DIR), pexit->key ); return; case REDIT_EXIT_FLAGS: number = atoi( arg ); if ( number == 0 ) { redit_disp_exit_edit( d ); return; } if ( number < 0 || number >= MAX_EXIT || ((number-1) == EXIT_RES1) || ((number-1) == EXIT_RES2) || ((number-1) == EXIT_PORTAL) ) { send_to_char( d->character, "That's not a valid choice!\r\n" ); redit_disp_exit_flag_menu( d ); } number -= 1; TOGGLE_BIT( pexit->flags, number ); olc_log( d, "%s %s to %s exit", HAS_BIT(pexit->flags, number) ? "Added" : "Removed", code_name(NULL, number, CODE_EXIT), code_name(NULL, pexit->vdir, CODE_DIR) ); redit_disp_exit_flag_menu( d ); return; case REDIT_EXTRADESC_DELETE: ed = redit_find_extradesc( room, atoi(arg) ); if ( !ed ) { send_to_char( d->character, "Not found, try again: " ); return; } olc_log( d, "Deleted exdesc %s", ed->keyword ); UNLINK( ed, room->first_extradescr, room->last_extradescr, next, prev ); DISPOSE( ed->keyword ); DISPOSE( ed->description ); DISPOSE( ed ); top_ed--; redit_disp_extradesc_menu(d); return; case REDIT_EXTRADESC_CHOICE: switch ( toupper( arg[0] ) ) { case 'Q': if ( !ed->keyword || !ed->description ) { send_to_char( d->character, "No keyword and/or description, junking..." ); UNLINK( ed, room->first_extradescr, room->last_extradescr, next, prev ); DISPOSE( ed->keyword ); DISPOSE( ed->keyword ); DISPOSE( ed ); top_ed--; } d->character->spare_ptr = NULL; redit_disp_extradesc_menu(d); return; case '1': OLC_MODE(d) = REDIT_EXTRADESC_KEY; send_to_char( d->character, "Keywords, seperated by spaces: " ); return; case '2': OLC_MODE(d) = REDIT_EXTRADESC_DESCRIPTION; d->character->substate = SUB_ROOM_EXTRA; d->character->last_cmd = do_redit_reset; send_to_char( d->character, "Enter new extradesc description: \r\n" ); start_editing( d->character, ed->description ); return; } break; case REDIT_EXTRADESC_KEY: /* if ( SetRExtra( room, arg ) ) { send_to_char( d->character, "A extradesc with that keyword already exists.\r\n" ); redit_disp_extradesc_menu(d); return; } */ olc_log( d, "Changed exkey %s to %s", ed->keyword, arg ); DISPOSE( ed->keyword ); ed->keyword = str_dup( arg ); oedit_disp_extra_choice(d); OLC_MODE(d) = REDIT_EXTRADESC_CHOICE; return; case REDIT_EXTRADESC_MENU: switch ( toupper( arg[0] ) ) { case 'Q': break; case 'A': CREATE( ed, EXTRA_DESCR_DATA, 1 ); LINK( ed, room->first_extradescr, room->last_extradescr, next, prev ); ed->keyword = str_dup( "" ); ed->description = str_dup( "" ); top_ed++; d->character->spare_ptr = ed; olc_log( d, "Added new exdesc" ); oedit_disp_extra_choice(d); OLC_MODE(d) = REDIT_EXTRADESC_CHOICE; return; case 'R': OLC_MODE(d) = REDIT_EXTRADESC_DELETE; send_to_char( d->character, "Delete which extra description? " ); return; default: if ( is_number(arg) ) { ed = redit_find_extradesc( room, atoi(arg) ); if ( !ed ) { send_to_char( d->character, "Not found, try again: " ); return; } d->character->spare_ptr = ed; oedit_disp_extra_choice(d); OLC_MODE(d) = REDIT_EXTRADESC_CHOICE; } else redit_disp_extradesc_menu(d); return; } break; default: /* we should never get here */ send_log( NULL, LOG_OLC, "redit_parse: reached default case in parse_redit" ); break; } /* chiude lo switch */ /* Log the changes, so we can keep track of those sneaky bastards */ /* Don't log on the flags cause it does that above */ /* if ( OLC_MODE(d) != REDIT_FLAGS ) olc_log( d, arg ); */ /*. If we get this far, something has be changed .*/ OLC_CHANGE(d) = TRUE; redit_disp_menu(d); }
void nanny(DESCRIPTOR_DATA *d, char *input) { int i; char buf[MAX_STRING_LENGTH]; DESCRIPTOR_DATA *dt; switch(d->state) { case STATE_GET_NAME: if (input[0] == 0) { sckoutput(d->socket, "Fine, then.\n"); wipe_descriptor(d); return; } i = check_string(input, 4, 12, 0); if (i == 1) send_to_descriptor(d, "Your name must have at least 4 letters.\n"); else if (i == 2) send_to_descriptor(d, "Your name can contain at most 12 letters.\n"); else if (i == 4 || i == 3) send_to_descriptor(d, "Your name can contain only letters.\n"); else { input[0] = UPPER(input[0]); load_account(input, d->acc); d->acc->d = d; if (d->acc->name[0] == 0) { check_address(d->ip, d->acc->name); if (d->acc->name[0] != 0 && stricmp(input, d->acc->name)) send_to_descriptor(d, "#RWARNING:#n Your IP is linked to an existing account. It is against the rules to have multiple accounts.\n\n"); strlcpy(d->acc->name, input, 32); snprintf(buf, MAX_STRING_LENGTH, "Are you sure you want the name %s? ", input); send_to_descriptor(d, buf); d->state = STATE_CONFIRM_NAME; return; } send_to_descriptor(d, "Password? "); send_to_descriptor(d, password_on); d->state = STATE_GET_PASS; return; } send_to_descriptor(d, "What do you want your account name to be? "); break; case STATE_GET_PASS: send_to_descriptor(d, password_off); if (!strcmp(d->acc->password, input)) { /* check to see if someone else is logged in under this account */ for (dt = dhead; dt; dt = dt->next) { if (dt == d || dt->acc == NULL) continue; if (!stricmp(d->acc->name, dt->acc->name)) { /* d = new connection, dt = old */ if (dt->socket > 0 && dt->state != STATE_LINKDEAD) { sckoutput(dt->socket, "\n\nYou have been kicked off.\n"); close(dt->socket); } dt->socket = d->socket; d->socket = -1; /* this is mandatory because wipe_descriptor closes d->socket */ wipe_descriptor(d); d = dt; if (d->state != STATE_PLAYING && d->state != STATE_LINKDEAD) send_to_descriptor(d, "\nYou have kicked someone off while they were logging in. Sending you to the account menu.\n"); else { destroy_all_events(d->acc->ch, EVENT_LINKDEAD); setup_char_events(d->acc->ch); d->acc->ch->idle = 0; syslog("RECONNECT", "%s (on %s@%s) has reconnected.", d->acc->ch->name, d->acc->name, d->ip); d->state = STATE_PLAYING; send_to_descriptor(d, "\n#RReconnected.#n\n"); return; } } } syslog("LOGIN", "%s@%s has logged in.", d->acc->name, d->ip); d->state = STATE_ACCT_MENU; d->acc->logins++; save_account(d->acc); show_account_menu(d, 0); snprintf(buf, MAX_STRING_LENGTH, "#1[#2Last connection from #R%s#2 at #R%s#2.#1]\n", d->acc->lasthost, d->acc->lasttime); save_address(d); send_to_descriptor(d, buf); if (d->acc->failed == 1) snprintf(buf, MAX_STRING_LENGTH, "#1[#RWARNING:#2 1 failed login attempt since your last connection.#1]\n"); else if (d->acc->failed > 1) snprintf(buf, MAX_STRING_LENGTH, "#1[#RWARNING:#2 %d failed login attempts since your last connection.#1]\n", d->acc->failed); if (d->acc->failed > 0) { send_to_descriptor(d, buf); d->acc->failed = 0; save_account(d->acc); } send_to_descriptor(d, "#nWhat is your choice? "); return; } sckoutput(d->socket, "Incorrect password. Logging you off...\n"); syslog("PASSWORD", "%s@%s -- incorrect password! Logged off.", d->acc->name, d->ip); d->acc->failed++; save_account(d->acc); wipe_descriptor(d); break; case STATE_CONFIRM_NAME: if (input[0] == 'y' || input[0] == 'Y') { send_to_descriptor(d, "What do you want your password to be? "); syslog("NEW", "New account %s is being created.", d->acc->name); d->state = STATE_NEW_PASS; send_to_descriptor(d, password_on); return; } send_to_descriptor(d, "Okay. What do you want your name to be? "); d->state = STATE_GET_NAME; break; case STATE_NEW_PASS: send_to_descriptor(d, password_off); if (input[0] == 0) { send_to_descriptor(d, "\nWhat do you want your password to be? "); send_to_descriptor(d, password_on); return; } i = check_string(input, 4, 12, 1); if (i == 1) send_to_descriptor(d, "\nYour password must have at least 4 characters.\n"); else if (i == 2) send_to_descriptor(d, "\nYour password can contain at most 12 characters.\n"); else if (i == 4) send_to_descriptor(d, "\nYour password can contain only letters and numbers.\n"); else { strlcpy(d->acc->password, input, 32); send_to_descriptor(d, "\nPlease retype your password for confirmation. "); send_to_descriptor(d, password_on); d->state = STATE_CONFIRM_PASS; return; } send_to_descriptor(d, "\nWhat do you want your password to be? "); send_to_descriptor(d, password_on); break; case STATE_CONFIRM_PASS: send_to_descriptor(d, password_off); if (strcmp(d->acc->password, input)) { send_to_descriptor(d, "\nYour passwords must match exactly.\nWhat do you want your password to be? "); d->state = STATE_NEW_PASS; d->acc->password[0] = 0; send_to_descriptor(d, password_on); return; } send_to_descriptor(d, "\nDo you want ANSI color? "); d->state = STATE_GET_ANSI; break; case STATE_GET_ANSI: d->acc->aflags = 0; if (input[0] == 'y' || input[0] == 'Y') SET_BIT(d->acc->aflags, AFLAG_ANSI); else if (input[0] == 'n' || input[0] == 'N') ; else { send_to_descriptor(d, "Please type yes or no.\nDo you want ANSI color? "); return; } for (dt = dhead; dt; dt = dt->next) { if (dt == d) continue; if (!stricmp(d->acc->name, dt->acc->name) && (dt->state > STATE_GET_PASS || dt->state < STATE_CONFIRM_NAME)) { sckoutput(d->socket, "You have been kicked off.\n"); wipe_descriptor(d); return; } } d->acc->logins = 1; d->acc->changes = time(NULL); strlcpy(d->acc->email, "Unset", 128); d->state = STATE_ACCT_MENU; log_time(d->acc->firsttime); save_address(d); show_account_menu(d, 1); save_account(d->acc); break; case STATE_ACCT_MENU: switch (input[0]) { case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': i = atoi(input); if (i > d->acc->charcount) { send_to_descriptor(d, "Unknown option.\nWhat is your choice? "); return; } if (d->acc->status[i - 1] == CHSTATUS_DELETED) { send_to_descriptor(d, "You are unable to log onto that player.\nWhat is your choice? "); return; } { d->acc->ch = load_character(d->acc, d->acc->character[i - 1]); d->acc->ch->acc = d->acc; d->acc->ch->d = d; setup_char_events(d->acc->ch); d->state = STATE_PLAYING; d->acc->cur_char = i - 1; ++d->acc->chlogins[i - 1]; destroy_d_events(d, EVENT_LOGINIDLE); if (d->acc->ch->level >= LEVEL_IMMORTAL) d->acc->status[i - 1] = CHSTATUS_IMMORTAL; if (!IS_SET(d->acc->ch->cflags, CFLAG_OLDPLAYER)) { syslog("LOGIN", "%s (on %s@%s) is now playing for the first time!", d->acc->ch->name, d->acc->name, d->ip); login_msg_new(d->acc->ch); SET_BIT(d->acc->ch->cflags, CFLAG_OLDPLAYER); if (IS_SET(d->acc->ch->cflags, CFLAG_HARDCORE)) d->acc->ch->plane = PLANE_HNEWBIE; else d->acc->ch->plane = PLANE_NEWBIE; d->acc->ch->maxhp = 1000; d->acc->ch->maxmove = 1000; d->acc->ch->maxmana = 1000; d->acc->ch->hp = d->acc->ch->maxhp; d->acc->ch->move = d->acc->ch->maxmove; d->acc->ch->mana = d->acc->ch->maxmana; d->acc->ch->level = LEVEL_MORTAL; d->acc->ch->sightradius = 5; /* pwipe: increase this to 50 */ strlcpy(d->acc->ch->prompt, "#1[#2%pP#1] #1[#2%h#1/#2%HH %m#1/#2%MM %v#1/#2%VV#1]#n> ", 256); send_to_char(d->acc->ch, "\nWelcome to Undertow. This is a completely custom MUD. We recommend that you read #RHELP NEWBIE#n.\n"); } else { syslog("LOGIN", "%s (on %s@%s) is now playing.", d->acc->ch->name, d->acc->name, d->ip); login_msg(d->acc->ch); do_look(d->acc->ch, ""); } save_account(d->acc); } break; case 'r': case 'R': if (new_changes(d->acc) == 0) { send_to_descriptor(d, "There are no new changes.\nWhat is your choice? "); return; } show_changes(d->acc, -1); send_to_descriptor(d, "\n#nWhat is your choice? "); break; case 'c': case 'C': d->state = STATE_CONFIG_MENU; show_account_settings(d); break; case 's': case 'S': send_who(d); send_to_descriptor(d, "#nWhat is your choice? "); break; case 'n': case 'N': if (d->acc->charcount >= MAX_CHARS_PER_ACCOUNT) { send_to_descriptor(d, "You have met your maximum amount of characters for this account.\nWhat is your choice?"); return; } d->state = STATE_NEW_CHAR; send_to_descriptor(d, "What do you want your name to be? "); break; case 'd': case 'D': if (d->acc->charcount == 0) { send_to_descriptor(d, "You have no characters to delete.\nWhat is your choice? "); return; } show_delete_menu(d); d->state = STATE_DELETE_CHAR; break; case 'q': case 'Q': save_account(d->acc); syslog("QUIT", "%s@%s quit at the login screen.", d->acc->name, d->ip); sckoutput(d->socket, "Goodbye.\n"); wipe_descriptor(d); break; case '\0': show_account_menu(d, 1); break; default: send_to_descriptor(d, "Unknown option.\nWhat is your choice? "); break; } break; case STATE_CONFIG_MENU: switch (input[0]) { case 'r': case 'R': d->state = STATE_ACCT_MENU; show_account_menu(d, 1); break; case 'a': case 'A': TOGGLE_BIT(d->acc->aflags, AFLAG_ANSI); if (IS_SET(d->acc->aflags, AFLAG_ANSI)) { if (IS_SET(d->acc->aflags, AFLAG_ANSI_SPARSE)) send_to_descriptor(d, "Your prompts will now be colored. If you want full color, turn Full ANSI Color on.\nWhat is your choice? "); else send_to_descriptor(d, "Welcome to the wonderful world of #Rc#Yo#Gl#Co#Mr#n!\nWhat is your choice? "); } else send_to_descriptor(d, "ANSI color turned off.\nWhat is your choice? "); break; case 'f': case 'F': TOGGLE_BIT(d->acc->aflags, AFLAG_ANSI_SPARSE); if (!IS_SET(d->acc->aflags, AFLAG_ANSI)) send_to_descriptor(d, "You would probably notice a subsequent color level change if you had color on.\nWhat is your choice? "); else if (IS_SET(d->acc->aflags, AFLAG_ANSI_SPARSE)) send_to_descriptor(d, "You will now only see colored prompts.\nWhat is your choice? "); else send_to_descriptor(d, "You will now see full color.\nWhat is your choice? "); break; case 'l': case 'L': TOGGLE_BIT(d->acc->aflags, AFLAG_REPLYLOCK); if (IS_SET(d->acc->aflags, AFLAG_REPLYLOCK)) send_to_descriptor(d, "You will now reply only to the last person to whom you sent a tell.\nWhat is your choice? "); else send_to_descriptor(d, "You will now reply to the person who most recently sent you a tell.\nWhat is your choice? "); break; case 'p': case 'P': TOGGLE_BIT(d->acc->aflags, AFLAG_PUBLIC_EMAIL); if (IS_SET(d->acc->aflags, AFLAG_PUBLIC_EMAIL)) send_to_descriptor(d, "Your email address is now public.\nWhat is your choice? "); else send_to_descriptor(d, "Your email address is now private.\nWhat is your choice? "); break; case 'c': case 'C': d->state = STATE_CHANGE_PASS1; send_to_descriptor(d, "What is your current password? "); send_to_descriptor(d, password_on); break; case 'e': case 'E': d->state = STATE_SET_EMAIL; send_to_descriptor(d, "What is your email address? "); break; case '\0': show_account_settings(d); break; case 'd': case 'D': SET_BIT(d->acc->aflags, AFLAG_ANSI); REMOVE_BIT(d->acc->aflags, AFLAG_ANSI_SPARSE); REMOVE_BIT(d->acc->aflags, AFLAG_PUBLIC_EMAIL); strlcpy(d->acc->email, "Unset", 128); send_to_descriptor(d, "Reverted to default settings.\nWhat is your choice?"); break; default: send_to_descriptor(d, "Unknown option.\nWhat is your choice? "); break; } break; case STATE_CHANGE_PASS1: send_to_descriptor(d, password_off); if (input[0] == 0) { d->state = STATE_CONFIG_MENU; send_to_descriptor(d, "\nWhat is your choice? "); return; } if (strcmp(d->acc->password, input)) { send_to_descriptor(d, "\nIncorrect password.\nWhat is your choice? "); d->state = STATE_CONFIG_MENU; return; } d->state = STATE_CHANGE_PASS2; d->acc->temp[0] = 0; send_to_descriptor(d, "\nWhat do you want your new password to be? "); send_to_descriptor(d, password_on); break; case STATE_CHANGE_PASS2: send_to_descriptor(d, password_off); if (input[0] == 0) { d->state = STATE_CONFIG_MENU; send_to_descriptor(d, "\nWhat is your choice? "); return; } i = check_string(input, 4, 12, 1); if (i == 1) send_to_descriptor(d, "\nYour password must have at least 4 characters.\n"); else if (i == 2) send_to_descriptor(d, "\nYour password can contain at most 12 characters.\n"); else if (i == 4) send_to_descriptor(d, "\nYour password can contain only letters and numbers.\n"); else { strlcpy(d->acc->temp, input, 128); send_to_descriptor(d, "\nPlease retype your password for confirmation. "); d->state = STATE_CHANGE_PASS3; send_to_descriptor(d, password_on); return; } send_to_descriptor(d, "\nWhat do you want your password to be? "); send_to_descriptor(d, password_on); break; case STATE_CHANGE_PASS3: send_to_descriptor(d, password_off); if (input[0] == 0) { d->state = STATE_CONFIG_MENU; send_to_descriptor(d, "\nWhat is your choice? "); return; } if (strcmp(d->acc->temp, input)) { send_to_descriptor(d, "\nPasswords must match exactly.\nWhat is your choice? "); d->state = STATE_CONFIG_MENU; return; } strlcpy(d->acc->password, input, 32); send_to_descriptor(d, "\nYour password is now changed.\nWhat is your choice? "); d->state = STATE_CONFIG_MENU; save_account(d->acc); break; case STATE_SET_EMAIL: i = check_string(input, -1, 47, 0); if (i == 2) send_to_descriptor(d, "Your email can contain at most 47 characters.\n"); else if (strlen(input) == 0) { strlcpy(d->acc->email, "Unset", 128); d->state = STATE_CONFIG_MENU; send_to_descriptor(d, "Your email address is now unset.\nWhat is your choice? "); } else { replace(input, buf, "%", "", MAX_STRING_LENGTH); replace(buf, input, "~", "-", MAX_STRING_LENGTH); strlcpy(d->acc->email, input, 128); d->state = STATE_CONFIG_MENU; snprintf(buf, MAX_STRING_LENGTH, "Your email address is now %s.\nWhat is your choice? ", input); send_to_descriptor(d, buf); return; } send_to_descriptor(d, "What is your email address? "); break; case STATE_DELETE_CHAR: if (input[0] == 'r' || input[0] == 'R') { d->state = STATE_ACCT_MENU; show_account_menu(d, 1); return; } if (input[0] == 0) { show_delete_menu(d); return; } i = atoi(input); if (i < 1 || i > d->acc->charcount) send_to_descriptor(d, "Out of bounds.\nWhich character do you want to delete? "); else { d->acc->name[15] = --i; snprintf(buf, MAX_STRING_LENGTH, "Are you sure you want to delete %s?", d->acc->character[i]); send_to_descriptor(d, buf); d->state = STATE_CONFIRM_DEL; } break; case STATE_CONFIRM_DEL: if (input[0] == 'y' || input[0] == 'Y') { i = d->acc->name[15]; d->acc->name[15] = 0; snprintf(buf, MAX_STRING_LENGTH, "%s has been deleted.\nWhat is your choice? ", d->acc->character[i]); send_to_descriptor(d, buf); syslog("DELETION", "%s (on %s@%s) has selfdeleted.", d->acc->character[i], d->acc->name, d->ip); d->state = STATE_ACCT_MENU; d->acc->chtime[i] = 0; snprintf(buf, MAX_STRING_LENGTH, "rm -f account/%s.chr", d->acc->character[i]); to_lower(buf); system(buf); d->acc->charcount--; while (i < d->acc->charcount) { strlcpy(d->acc->character[i], d->acc->character[i + 1], 32); i++; } save_account(d->acc); return; } d->state = STATE_ACCT_MENU; show_account_menu(d, 1); break; case STATE_NEW_CHAR: i = 0; if (input[0] == 0) { d->state = STATE_ACCT_MENU; show_account_menu(d, 1); return; } i = check_string(input, 4, 12, 0); if (i == 1) send_to_descriptor(d, "Your name must have atleast 4 letters.\n"); else if (i == 2) send_to_descriptor(d, "Your name can contain at most 12 letters.\n"); else if (i == 4 || i == 3) send_to_descriptor(d, "Your name can contain only letters.\n"); else { input[0] = UPPER(input[0]); for (dt = dhead; dt; dt = dt->next) if ((d != dt) && !stricmp(input, dt->acc->character[dt->acc->charcount])) i = 1; if (i == 0 && char_exists(input)) i = 1; if (i) { snprintf(buf, MAX_STRING_LENGTH, "The name %s is already taken.\nWhat do you want your name to be? ", input); send_to_descriptor(d, buf); return; } strlcpy(d->acc->character[d->acc->charcount], input, 32); snprintf(buf, MAX_STRING_LENGTH, "Are you sure you want the name %s? ", input); send_to_descriptor(d, buf); d->state = STATE_CONFIRM_CHAR; return; } send_to_descriptor(d, "What do you want your name to be? "); break; case STATE_CONFIRM_CHAR: if (input[0] == 'y' || input[0] == 'Y') { if (d->acc->logins == 1) { d->state = STATE_ACCT_MENU; finish_creation(d, 0); return; } d->state = STATE_GET_HARDCORE; send_to_descriptor(d, "Do you want this character to be hardcore (death = deletion)? "); } else { d->state = STATE_ACCT_MENU; show_account_menu(d, 1); } break; case STATE_GET_HARDCORE: finish_creation(d, input[0] == 'y' || input[0] == 'Y'); break; } }
void trigedit_parse(struct descriptor_data *d, char *arg) { int i = 0; char *backstr = NULL; switch (OLC_MODE(d)) { case TRIGEDIT_MAIN_MENU: switch (tolower(*arg)) { case 'q': if (OLC_VAL(d)) { /* Anything been changed? */ if (!GET_TRIG_TYPE(OLC_TRIG(d))) { send_to_char("Invalid Trigger Type! Answer a to abort quit!\r\n", d->character); } send_to_char("Do you wish to save the changes to the trigger? (y/n): ", d->character); OLC_MODE(d) = TRIGEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': OLC_MODE(d) = TRIGEDIT_NAME; send_to_char("Name: ", d->character); break; case '2': OLC_MODE(d) = TRIGEDIT_INTENDED; send_to_char("0: Mobiles, 1: Objects, 2: Rooms: ", d->character); break; case '3': OLC_MODE(d) = TRIGEDIT_TYPES; trigedit_disp_types(d); break; case '4': OLC_MODE(d) = TRIGEDIT_NARG; send_to_char("Numeric argument: ", d->character); break; case '5': OLC_MODE(d) = TRIGEDIT_ARGUMENT; send_to_char("Argument: ", d->character); break; case '6': OLC_MODE(d) = TRIGEDIT_COMMANDS; clear_screen(d); if (OLC_STORAGE(d)) { write_to_output(d, FALSE, "%s", OLC_STORAGE(d)); backstr = str_dup(OLC_STORAGE(d)); } string_write(d, &OLC_STORAGE(d), MAX_CMD_LENGTH, 0, STATE(d)); OLC_VAL(d) = 1; break; default: trigedit_disp_menu(d); return; } return; case TRIGEDIT_CONFIRM_SAVESTRING: switch(tolower(*arg)) { case 'y': trigedit_save(d); sprintf(buf, "OLC: %s edits trigger %d", GET_NAME(d->character), OLC_NUM(d)); mudlog(buf, CMP, MAX(RIGHTS_TRIGGERS, GET_INVIS_LEV(d->character)), TRUE); /* fall through */ case 'n': cleanup_olc(d, CLEANUP_ALL); return; case 'a': /* abort quitting */ break; default: send_to_char("Invalid choice!\r\n", d->character); send_to_char("Do you wish to save the trigger? : ", d->character); return; } break; case TRIGEDIT_NAME: if (OLC_TRIG(d)->name) free(OLC_TRIG(d)->name); OLC_TRIG(d)->name = str_dup((arg && *arg) ? arg : "undefined"); OLC_VAL(d)++; break; case TRIGEDIT_INTENDED: if ((atoi(arg)>=MOB_TRIGGER) || (atoi(arg)<=WLD_TRIGGER)) OLC_TRIG(d)->attach_type = atoi(arg); OLC_VAL(d)++; break; case TRIGEDIT_NARG: OLC_TRIG(d)->narg = atoi(arg); OLC_VAL(d)++; break; case TRIGEDIT_ARGUMENT: OLC_TRIG(d)->arglist = (*arg?str_dup(arg):NULL); OLC_VAL(d)++; break; case TRIGEDIT_TYPES: if ((i = atoi(arg)) == 0) break; else if (!((i < 0) || (i > NUM_TRIG_TYPE_FLAGS))) TOGGLE_BIT((GET_TRIG_TYPE(OLC_TRIG(d))), 1ULL << (i - 1)); OLC_VAL(d)++; trigedit_disp_types(d); return; case TRIGEDIT_COMMANDS: break; } OLC_MODE(d) = TRIGEDIT_MAIN_MENU; trigedit_disp_menu(d); }
void oedit_parse(struct descriptor_data *d, char *arg) { int number, max_val, min_val; char *oldtext = NULL; switch (OLC_MODE(d)) { case OEDIT_CONFIRM_SAVESTRING: switch (*arg) { case 'y': case 'Y': write_to_output(d, "Saving object to memory.\r\n"); oedit_save_internally(d); mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE, "OLC: %s edits obj %d", GET_NAME(d->character), OLC_NUM(d)); /* Fall through. */ case 'n': case 'N': cleanup_olc(d, CLEANUP_ALL); return; default: write_to_output(d, "Invalid choice!\r\n"); write_to_output(d, "Do you wish to save this object internally?\r\n"); return; } case OEDIT_MAIN_MENU: /* * Throw us out to whichever edit mode based on user input. */ switch (*arg) { case 'q': case 'Q': if (OLC_VAL(d)) { /* Something has been modified. */ write_to_output(d, "Do you wish to save this object internally? : "); OLC_MODE(d) = OEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': write_to_output(d, "Enter namelist : "); OLC_MODE(d) = OEDIT_EDIT_NAMELIST; break; case '2': write_to_output(d, "Enter short desc : "); OLC_MODE(d) = OEDIT_SHORTDESC; break; case '3': write_to_output(d, "Enter long desc :-\r\n| "); OLC_MODE(d) = OEDIT_LONGDESC; break; case '4': OLC_MODE(d) = OEDIT_ACTDESC; send_editor_help(d); write_to_output(d, "Enter action description:\r\n\r\n"); if (OLC_OBJ(d)->action_description) { write_to_output(d, "%s", OLC_OBJ(d)->action_description); oldtext = strdup(OLC_OBJ(d)->action_description); } string_write(d, &OLC_OBJ(d)->action_description, MAX_MESSAGE_LENGTH, 0, oldtext); OLC_VAL(d) = 1; break; case '5': oedit_disp_type_menu(d); OLC_MODE(d) = OEDIT_TYPE; break; case '6': oedit_disp_extra_menu(d); OLC_MODE(d) = OEDIT_EXTRAS; break; case '7': oedit_disp_wear_menu(d); OLC_MODE(d) = OEDIT_WEAR; break; case '8': write_to_output(d, "Enter weight : "); OLC_MODE(d) = OEDIT_WEIGHT; break; case '9': write_to_output(d, "Enter cost : "); OLC_MODE(d) = OEDIT_COST; break; case 'a': case 'A': write_to_output(d, "Enter cost per day : "); OLC_MODE(d) = OEDIT_COSTPERDAY; break; case 'b': case 'B': write_to_output(d, "Enter timer : "); OLC_MODE(d) = OEDIT_TIMER; break; case 'c': case 'C': /* * Clear any old values */ GET_OBJ_VAL(OLC_OBJ(d), 0) = 0; GET_OBJ_VAL(OLC_OBJ(d), 1) = 0; GET_OBJ_VAL(OLC_OBJ(d), 2) = 0; GET_OBJ_VAL(OLC_OBJ(d), 3) = 0; oedit_disp_val1_menu(d); break; case 'd': case 'D': oedit_disp_prompt_apply_menu(d); break; case 'e': case 'E': /* * If extra descriptions don't exist. */ if (OLC_OBJ(d)->ex_description == NULL) { CREATE(OLC_OBJ(d)->ex_description, struct extra_descr_data, 1); OLC_OBJ(d)->ex_description->next = NULL; } OLC_DESC(d) = OLC_OBJ(d)->ex_description; oedit_disp_extradesc_menu(d); break; case 'm': case 'M': write_to_output(d, "Enter new minimum level: "); OLC_MODE(d) = OEDIT_LEVEL; break; case 'p': case 'P': oedit_disp_perm_menu(d); OLC_MODE(d) = OEDIT_PERM; break; case 's': case 'S': OLC_SCRIPT_EDIT_MODE(d) = SCRIPT_MAIN_MENU; dg_script_menu(d); return; default: oedit_disp_menu(d); break; } return; /* * end of OEDIT_MAIN_MENU */ case OLC_SCRIPT_EDIT: if (dg_script_edit_parse(d, arg)) return; break; case OEDIT_EDIT_NAMELIST: if (!genolc_checkstring(d, arg)) break; if (OLC_OBJ(d)->name) free(OLC_OBJ(d)->name); OLC_OBJ(d)->name = str_udup(arg); break; case OEDIT_SHORTDESC: if (!genolc_checkstring(d, arg)) break; if (OLC_OBJ(d)->short_description) free(OLC_OBJ(d)->short_description); OLC_OBJ(d)->short_description = str_udup(arg); break; case OEDIT_LONGDESC: if (!genolc_checkstring(d, arg)) break; if (OLC_OBJ(d)->description) free(OLC_OBJ(d)->description); OLC_OBJ(d)->description = str_udup(arg); break; case OEDIT_TYPE: number = atoi(arg); if ((number < 1) || (number >= NUM_ITEM_TYPES)) { write_to_output(d, "Invalid choice, try again : "); return; } else GET_OBJ_TYPE(OLC_OBJ(d)) = number; break; case OEDIT_EXTRAS: number = atoi(arg); if ((number < 0) || (number > NUM_ITEM_FLAGS)) { oedit_disp_extra_menu(d); return; } else if (number == 0) break; else { TOGGLE_BIT(GET_OBJ_EXTRA(OLC_OBJ(d)), 1 << (number - 1)); oedit_disp_extra_menu(d); return; } case OEDIT_WEAR: number = atoi(arg); if ((number < 0) || (number > NUM_ITEM_WEARS)) { write_to_output(d, "That's not a valid choice!\r\n"); oedit_disp_wear_menu(d); return; } else if (number == 0) /* Quit. */ break; else { TOGGLE_BIT(GET_OBJ_WEAR(OLC_OBJ(d)), 1 << (number - 1)); oedit_disp_wear_menu(d); return; } case OEDIT_WEIGHT: GET_OBJ_WEIGHT(OLC_OBJ(d)) = atoi(arg); break; case OEDIT_COST: GET_OBJ_COST(OLC_OBJ(d)) = atoi(arg); break; case OEDIT_COSTPERDAY: GET_OBJ_RENT(OLC_OBJ(d)) = atoi(arg); break; case OEDIT_TIMER: GET_OBJ_TIMER(OLC_OBJ(d)) = atoi(arg); break; case OEDIT_LEVEL: GET_OBJ_LEVEL(OLC_OBJ(d)) = atoi(arg); break; case OEDIT_PERM: if ((number = atoi(arg)) == 0) break; if (number > 0 && number <= NUM_AFF_FLAGS) TOGGLE_BIT(GET_OBJ_PERM(OLC_OBJ(d)), 1 << (number - 1)); oedit_disp_perm_menu(d); return; case OEDIT_VALUE_1: /* * Lucky, I don't need to check any of these for out of range values. * Hmm, I'm not so sure - Rv */ GET_OBJ_VAL(OLC_OBJ(d), 0) = atoi(arg); /* * proceed to menu 2 */ oedit_disp_val2_menu(d); return; case OEDIT_VALUE_2: /* * Here, I do need to check for out of range values. */ number = atoi(arg); switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_SCROLL: case ITEM_POTION: if (number < 0 || number >= NUM_SPELLS) oedit_disp_val2_menu(d); else { GET_OBJ_VAL(OLC_OBJ(d), 1) = number; oedit_disp_val3_menu(d); } break; case ITEM_CONTAINER: /* * Needs some special handling since we are dealing with flag values * here. */ if (number < 0 || number > 4) oedit_disp_container_flags_menu(d); else if (number != 0) { TOGGLE_BIT(GET_OBJ_VAL(OLC_OBJ(d), 1), 1 << (number - 1)); OLC_VAL(d) = 1; oedit_disp_val2_menu(d); } else oedit_disp_val3_menu(d); break; default: GET_OBJ_VAL(OLC_OBJ(d), 1) = number; oedit_disp_val3_menu(d); } return; case OEDIT_VALUE_3: number = atoi(arg); /* * Quick'n'easy error checking. */ switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_SCROLL: case ITEM_POTION: min_val = -1; max_val = NUM_SPELLS - 1; break; case ITEM_WEAPON: min_val = 1; max_val = 50; break; case ITEM_WAND: case ITEM_STAFF: min_val = 0; max_val = 20; break; case ITEM_DRINKCON: case ITEM_FOUNTAIN: min_val = 0; max_val = NUM_LIQ_TYPES - 1; break; case ITEM_KEY: min_val = 0; max_val = 32099; break; default: min_val = -32000; max_val = 32000; } GET_OBJ_VAL(OLC_OBJ(d), 2) = LIMIT(number, min_val, max_val); oedit_disp_val4_menu(d); return; case OEDIT_VALUE_4: number = atoi(arg); switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_SCROLL: case ITEM_POTION: min_val = -1; max_val = NUM_SPELLS - 1; break; case ITEM_WAND: case ITEM_STAFF: min_val = 1; max_val = NUM_SPELLS - 1; break; case ITEM_WEAPON: min_val = 0; max_val = NUM_ATTACK_TYPES - 1; break; default: min_val = -32000; max_val = 32000; break; } GET_OBJ_VAL(OLC_OBJ(d), 3) = LIMIT(number, min_val, max_val); break; case OEDIT_PROMPT_APPLY: if ((number = atoi(arg)) == 0) break; else if (number < 0 || number > MAX_OBJ_AFFECT) { oedit_disp_prompt_apply_menu(d); return; } OLC_VAL(d) = number - 1; OLC_MODE(d) = OEDIT_APPLY; oedit_disp_apply_menu(d); return; case OEDIT_APPLY: if ((number = atoi(arg)) == 0) { OLC_OBJ(d)->affected[OLC_VAL(d)].location = 0; OLC_OBJ(d)->affected[OLC_VAL(d)].modifier = 0; oedit_disp_prompt_apply_menu(d); } else if (number < 0 || number >= NUM_APPLIES) oedit_disp_apply_menu(d); else { int counter; /* add in check here if already applied.. deny builders another */ if (GET_LEVEL(d->character) < LVL_IMPL) { for (counter = 0; counter < MAX_OBJ_AFFECT; counter++) { if (OLC_OBJ(d)->affected[counter].location == number) { write_to_output(d, "Object already has that apply."); return; } } } OLC_OBJ(d)->affected[OLC_VAL(d)].location = number; write_to_output(d, "Modifier : "); OLC_MODE(d) = OEDIT_APPLYMOD; } return; case OEDIT_APPLYMOD: OLC_OBJ(d)->affected[OLC_VAL(d)].modifier = atoi(arg); oedit_disp_prompt_apply_menu(d); return; case OEDIT_EXTRADESC_KEY: if (genolc_checkstring(d, arg)) { if (OLC_DESC(d)->keyword) free(OLC_DESC(d)->keyword); OLC_DESC(d)->keyword = str_udup(arg); } oedit_disp_extradesc_menu(d); return; case OEDIT_EXTRADESC_MENU: switch ((number = atoi(arg))) { case 0: if (!OLC_DESC(d)->keyword || !OLC_DESC(d)->description) { struct extra_descr_data **tmp_desc; if (OLC_DESC(d)->keyword) free(OLC_DESC(d)->keyword); if (OLC_DESC(d)->description) free(OLC_DESC(d)->description); /* * Clean up pointers */ for (tmp_desc = &(OLC_OBJ(d)->ex_description); *tmp_desc; tmp_desc = &((*tmp_desc)->next)) { if (*tmp_desc == OLC_DESC(d)) { *tmp_desc = NULL; break; } } free(OLC_DESC(d)); } break; case 1: OLC_MODE(d) = OEDIT_EXTRADESC_KEY; write_to_output(d, "Enter keywords, separated by spaces :-\r\n| "); return; case 2: OLC_MODE(d) = OEDIT_EXTRADESC_DESCRIPTION; send_editor_help(d); write_to_output(d, "Enter the extra description:\r\n\r\n"); if (OLC_DESC(d)->description) { write_to_output(d, "%s", OLC_DESC(d)->description); oldtext = strdup(OLC_DESC(d)->description); } string_write(d, &OLC_DESC(d)->description, MAX_MESSAGE_LENGTH, 0, oldtext); OLC_VAL(d) = 1; return; case 3: /* * Only go to the next description if this one is finished. */ if (OLC_DESC(d)->keyword && OLC_DESC(d)->description) { struct extra_descr_data *new_extra; if (OLC_DESC(d)->next) OLC_DESC(d) = OLC_DESC(d)->next; else { /* Make new extra description and attach at end. */ CREATE(new_extra, struct extra_descr_data, 1); OLC_DESC(d)->next = new_extra; OLC_DESC(d) = OLC_DESC(d)->next; } } /* * No break - drop into default case. */ default: oedit_disp_extradesc_menu(d); return; } break; default: mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: Reached default case in oedit_parse()!"); write_to_output(d, "Oops...\r\n"); break; }
/*************************************************************************** * change_exit * * change the values of an exit ***************************************************************************/ static bool change_exit(struct char_data *ch, const char *argument, int door) { struct room_index_data *room; char command[MAX_INPUT_LENGTH]; char arg[MAX_INPUT_LENGTH]; int value; EDIT_ROOM(ch, room); /* set the exit flags - needs full argument */ if ((value = flag_value(exit_flags, argument)) != NO_FLAG) { struct room_index_data *pToRoom; int rev; if (!room->exit[door]) { send_to_char("Exit does not exist.\n\r", ch); return false; } /* this room */ TOGGLE_BIT(room->exit[door]->rs_flags, value); room->exit[door]->exit_info = room->exit[door]->rs_flags; /* connected room */ pToRoom = room->exit[door]->u1.to_room; rev = rev_dir[door]; if (pToRoom->exit[rev] != NULL) { pToRoom->exit[rev]->rs_flags = room->exit[door]->rs_flags; pToRoom->exit[rev]->exit_info = room->exit[door]->exit_info; } send_to_char("Exit flag toggled.\n\r", ch); return true; } /* parse the arguments */ argument = one_argument(argument, command); one_argument(argument, arg); if (command[0] == '\0' && argument[0] == '\0') { move_char(ch, door, true); return false; } if (command[0] == '?') { show_help(ch->desc, "OLC_EXIT", NULL); return false; } if (!str_cmp(command, "delete")) { struct room_index_data *pToRoom; int rev; if (!room->exit[door]) { send_to_char("REdit: Cannot delete a null exit.\n\r", ch); return false; } /* remove ToRoom exit */ rev = rev_dir[door]; pToRoom = room->exit[door]->u1.to_room; if (pToRoom->exit[rev]) { free_exit(pToRoom->exit[rev]); pToRoom->exit[rev] = NULL; } /* remove this exit */ free_exit(room->exit[door]); room->exit[door] = NULL; send_to_char("Exit unlinked.\n\r", ch); return true; } if (!str_cmp(command, "link")) { struct exit_data *pExit; struct room_index_data *toRoom; if (arg[0] == '\0' || !is_number(arg)) { send_to_char("Syntax: [direction] link [vnum]\n\r", ch); return false; } value = parse_int(arg); if (!(toRoom = get_room_index(value))) { send_to_char("REdit: Cannot link to non-existant room.\n\r", ch); return false; } if (!IS_BUILDER(ch, toRoom->area)) { send_to_char("REdit: Cannot link to that area.\n\r", ch); return false; } if (toRoom->exit[rev_dir[door]]) { send_to_char("REdit: Remote side's exit already exists.\n\r", ch); return false; } if (!room->exit[door]) room->exit[door] = new_exit(); room->exit[door]->u1.to_room = toRoom; room->exit[door]->orig_door = door; door = rev_dir[door]; pExit = new_exit(); pExit->u1.to_room = room; pExit->orig_door = door; toRoom->exit[door] = pExit; send_to_char("Two-way link established.\n\r", ch); return true; } if (!str_cmp(command, "dig")) { char buf[MAX_STRING_LENGTH]; if (arg[0] == '\0' || !is_number(arg)) { send_to_char("Syntax: [direction] dig <vnum>\n\r", ch); return false; } redit_create(ch, arg); sprintf(buf, "link %s", arg); change_exit(ch, buf, door); return true; } if (!str_cmp(command, "room")) { struct room_index_data *toRoom; if (arg[0] == '\0' || !is_number(arg)) { send_to_char("Syntax: [direction] room [vnum]\n\r", ch); return false; } value = parse_int(arg); if (!(toRoom = get_room_index(value))) { send_to_char("REdit: Cannot link to non-existant room.\n\r", ch); return false; } if (!room->exit[door]) room->exit[door] = new_exit(); room->exit[door]->u1.to_room = toRoom; room->exit[door]->orig_door = door; send_to_char("One-way link established.\n\r", ch); return true; } if (!str_cmp(command, "key")) { struct objectprototype *key; if (arg[0] == '\0' || !is_number(arg)) { send_to_char("Syntax: [direction] key [vnum]\n\r", ch); return false; } if (!room->exit[door]) { send_to_char("Exit does not exist.\n\r", ch); return false; } value = parse_int(arg); if (!(key = objectprototype_getbyvnum(value))) { send_to_char("REdit: Key doesn't exist.\n\r", ch); return false; } if (key->item_type != ITEM_KEY) { send_to_char("REdit: Object is not a key.\n\r", ch); return false; } room->exit[door]->key = value; send_to_char("Exit key set.\n\r", ch); return true; } if (!str_cmp(command, "name")) { if (arg[0] == '\0') { send_to_char("Syntax: [direction] name [string]\n\r", ch); send_to_char(" [direction] name none\n\r", ch); return false; } if (!room->exit[door]) { send_to_char("Exit does not exist.\n\r", ch); return false; } free_string(room->exit[door]->keyword); if (str_cmp(arg, "none")) room->exit[door]->keyword = str_dup(arg); else room->exit[door]->keyword = str_dup(""); send_to_char("Exit name set.\n\r", ch); return true; } if (!str_prefix(command, "description")) { if (arg[0] == '\0') { if (!room->exit[door]) { send_to_char("Exit does not exist.\n\r", ch); return false; } string_append(ch, &room->exit[door]->description); return true; } send_to_char("Syntax: [direction] desc\n\r", ch); return false; } return false; }
/* main loop (of sorts).. basically interpreter throws all input to here. */ void oedit_parse(struct descriptor_data *d, char *arg) { int number, max_val, min_val; char *oldtext = NULL; switch (OLC_MODE(d)) { case OEDIT_CONFIRM_SAVESTRING: switch (*arg) { case 'y': case 'Y': oedit_save_internally(d); mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE, "OLC: %s edits obj %d", GET_NAME(d->character), OLC_NUM(d)); if (CONFIG_OLC_SAVE) { oedit_save_to_disk(real_zone_by_thing(OLC_NUM(d))); write_to_output(d, "Object saved to disk.\r\n"); } else write_to_output(d, "Object saved to memory.\r\n"); cleanup_olc(d, CLEANUP_ALL); return; case 'n': case 'N': /* If not saving, we must free the script_proto list. */ OLC_OBJ(d)->proto_script = OLC_SCRIPT(d); free_proto_script(OLC_OBJ(d), OBJ_TRIGGER); cleanup_olc(d, CLEANUP_ALL); return; case 'a': /* abort quit */ case 'A': oedit_disp_menu(d); return; default: write_to_output(d, "Invalid choice!\r\n"); write_to_output(d, "Do you wish to save your changes? : \r\n"); return; } case OEDIT_MAIN_MENU: /* Throw us out to whichever edit mode based on user input. */ switch (*arg) { case 'q': case 'Q': if (OLC_VAL(d)) { /* Something has been modified. */ write_to_output(d, "Do you wish to save your changes? : "); OLC_MODE(d) = OEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': write_to_output(d, "Enter keywords : "); OLC_MODE(d) = OEDIT_KEYWORD; break; case '2': write_to_output(d, "Enter short desc : "); OLC_MODE(d) = OEDIT_SHORTDESC; break; case '3': write_to_output(d, "Enter long desc :-\r\n| "); OLC_MODE(d) = OEDIT_LONGDESC; break; case '4': OLC_MODE(d) = OEDIT_ACTDESC; send_editor_help(d); write_to_output(d, "Enter action description:\r\n\r\n"); if (OLC_OBJ(d)->action_description) { write_to_output(d, "%s", OLC_OBJ(d)->action_description); oldtext = strdup(OLC_OBJ(d)->action_description); } string_write(d, &OLC_OBJ(d)->action_description, MAX_MESSAGE_LENGTH, 0, oldtext); OLC_VAL(d) = 1; break; case '5': oedit_disp_type_menu(d); OLC_MODE(d) = OEDIT_TYPE; break; case '6': oedit_disp_extra_menu(d); OLC_MODE(d) = OEDIT_EXTRAS; break; case '7': oedit_disp_wear_menu(d); OLC_MODE(d) = OEDIT_WEAR; break; case '8': write_to_output(d, "Enter weight : "); OLC_MODE(d) = OEDIT_WEIGHT; break; case '9': write_to_output(d, "Enter cost : "); OLC_MODE(d) = OEDIT_COST; break; case 'a': case 'A': write_to_output(d, "Enter cost per day : "); OLC_MODE(d) = OEDIT_COSTPERDAY; break; case 'b': case 'B': write_to_output(d, "Enter timer : "); OLC_MODE(d) = OEDIT_TIMER; break; case 'c': case 'C': /* Clear any old values */ GET_OBJ_VAL(OLC_OBJ(d), 0) = 0; GET_OBJ_VAL(OLC_OBJ(d), 1) = 0; GET_OBJ_VAL(OLC_OBJ(d), 2) = 0; GET_OBJ_VAL(OLC_OBJ(d), 3) = 0; OLC_VAL(d) = 1; oedit_disp_val1_menu(d); break; case 'd': case 'D': oedit_disp_prompt_apply_menu(d); break; case 'e': case 'E': /* If extra descriptions don't exist. */ if (OLC_OBJ(d)->ex_description == NULL) { CREATE(OLC_OBJ(d)->ex_description, struct extra_descr_data, 1); OLC_OBJ(d)->ex_description->next = NULL; } OLC_DESC(d) = OLC_OBJ(d)->ex_description; oedit_disp_extradesc_menu(d); break; case 'm': case 'M': write_to_output(d, "Enter new minimum level: "); OLC_MODE(d) = OEDIT_LEVEL; break; case 'p': case 'P': oedit_disp_perm_menu(d); OLC_MODE(d) = OEDIT_PERM; break; case 's': case 'S': OLC_SCRIPT_EDIT_MODE(d) = SCRIPT_MAIN_MENU; dg_script_menu(d); return; case 'w': case 'W': write_to_output(d, "Copy what object? "); OLC_MODE(d) = OEDIT_COPY; break; case 'x': case 'X': write_to_output(d, "Are you sure you want to delete this object? "); OLC_MODE(d) = OEDIT_DELETE; break; default: oedit_disp_menu(d); break; } return; /* end of OEDIT_MAIN_MENU */ case OLC_SCRIPT_EDIT: if (dg_script_edit_parse(d, arg)) return; break; case OEDIT_KEYWORD: if (!genolc_checkstring(d, arg)) break; if (OLC_OBJ(d)->name) free(OLC_OBJ(d)->name); OLC_OBJ(d)->name = str_udup(arg); break; case OEDIT_SHORTDESC: if (!genolc_checkstring(d, arg)) break; if (OLC_OBJ(d)->short_description) free(OLC_OBJ(d)->short_description); OLC_OBJ(d)->short_description = str_udup(arg); break; case OEDIT_LONGDESC: if (!genolc_checkstring(d, arg)) break; if (OLC_OBJ(d)->description) free(OLC_OBJ(d)->description); OLC_OBJ(d)->description = str_udup(arg); break; case OEDIT_TYPE: number = atoi(arg); if ((number < 0) || (number >= NUM_ITEM_TYPES)) { write_to_output(d, "Invalid choice, try again : "); return; } else GET_OBJ_TYPE(OLC_OBJ(d)) = number; /* what's the boundschecking worth if we don't do this ? -- Welcor */ GET_OBJ_VAL(OLC_OBJ(d), 0) = GET_OBJ_VAL(OLC_OBJ(d), 1) = GET_OBJ_VAL(OLC_OBJ(d), 2) = GET_OBJ_VAL(OLC_OBJ(d), 3) = 0; break; case OEDIT_EXTRAS: number = atoi(arg); if ((number < 0) || (number > NUM_ITEM_FLAGS)) { oedit_disp_extra_menu(d); return; } else if (number == 0) break; else { TOGGLE_BIT_AR(GET_OBJ_EXTRA(OLC_OBJ(d)), (number - 1)); oedit_disp_extra_menu(d); return; } case OEDIT_WEAR: number = atoi(arg); if ((number < 0) || (number > NUM_ITEM_WEARS)) { write_to_output(d, "That's not a valid choice!\r\n"); oedit_disp_wear_menu(d); return; } else if (number == 0) /* Quit. */ break; else { TOGGLE_BIT_AR(GET_OBJ_WEAR(OLC_OBJ(d)), (number - 1)); oedit_disp_wear_menu(d); return; } case OEDIT_WEIGHT: GET_OBJ_WEIGHT(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_WEIGHT); break; case OEDIT_COST: GET_OBJ_COST(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_COST); break; case OEDIT_COSTPERDAY: GET_OBJ_RENT(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_RENT); break; case OEDIT_TIMER: GET_OBJ_TIMER(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_TIMER); break; case OEDIT_LEVEL: GET_OBJ_LEVEL(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, LVL_IMPL); break; case OEDIT_PERM: if ((number = atoi(arg)) == 0) break; if (number > 0 && number <= NUM_AFF_FLAGS) { /* Setting AFF_CHARM on objects like this is dangerous. */ if (number != AFF_CHARM) { TOGGLE_BIT_AR(GET_OBJ_AFFECT(OLC_OBJ(d)), number); } } oedit_disp_perm_menu(d); return; case OEDIT_VALUE_1: number = atoi(arg); switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_FURNITURE: if (number < 0 || number > MAX_PEOPLE) oedit_disp_val1_menu(d); else { GET_OBJ_VAL(OLC_OBJ(d), 0) = number; oedit_disp_val2_menu(d); } break; case ITEM_WEAPON: GET_OBJ_VAL(OLC_OBJ(d), 0) = MIN(MAX(atoi(arg), -50), 50); break; case ITEM_CONTAINER: GET_OBJ_VAL(OLC_OBJ(d), 0) = LIMIT(atoi(arg), -1, MAX_CONTAINER_SIZE); break; default: GET_OBJ_VAL(OLC_OBJ(d), 0) = atoi(arg); } /* proceed to menu 2 */ oedit_disp_val2_menu(d); return; case OEDIT_VALUE_2: /* Here, I do need to check for out of range values. */ number = atoi(arg); switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_SCROLL: case ITEM_POTION: if (number == 0 || number == -1) GET_OBJ_VAL(OLC_OBJ(d), 1) = -1; else GET_OBJ_VAL(OLC_OBJ(d), 1) = LIMIT(number, 1, NUM_SPELLS); oedit_disp_val3_menu(d); break; case ITEM_CONTAINER: /* Needs some special handling since we are dealing with flag values here. */ if (number < 0 || number > 4) oedit_disp_container_flags_menu(d); else if (number != 0) { TOGGLE_BIT(GET_OBJ_VAL(OLC_OBJ(d), 1), 1 << (number - 1)); OLC_VAL(d) = 1; oedit_disp_val2_menu(d); } else oedit_disp_val3_menu(d); break; case ITEM_WEAPON: GET_OBJ_VAL(OLC_OBJ(d), 1) = LIMIT(number, 1, MAX_WEAPON_NDICE); oedit_disp_val3_menu(d); break; default: GET_OBJ_VAL(OLC_OBJ(d), 1) = number; oedit_disp_val3_menu(d); } return; case OEDIT_VALUE_3: number = atoi(arg); /* Quick'n'easy error checking. */ switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_SCROLL: case ITEM_POTION: if (number == 0 || number == -1) { GET_OBJ_VAL(OLC_OBJ(d), 2) = -1; oedit_disp_val4_menu(d); return; } min_val = 1; max_val = NUM_SPELLS; break; case ITEM_WEAPON: min_val = 1; max_val = MAX_WEAPON_SDICE; break; case ITEM_WAND: case ITEM_STAFF: min_val = 0; max_val = 20; break; case ITEM_DRINKCON: case ITEM_FOUNTAIN: min_val = 0; max_val = NUM_LIQ_TYPES - 1; number--; break; case ITEM_KEY: min_val = 0; max_val = 65099; break; default: min_val = -65000; max_val = 65000; } GET_OBJ_VAL(OLC_OBJ(d), 2) = LIMIT(number, min_val, max_val); oedit_disp_val4_menu(d); return; case OEDIT_VALUE_4: number = atoi(arg); switch (GET_OBJ_TYPE(OLC_OBJ(d))) { case ITEM_SCROLL: case ITEM_POTION: if (number == 0 || number == -1) { GET_OBJ_VAL(OLC_OBJ(d), 3) = -1; oedit_disp_menu(d); return; } min_val = 1; max_val = NUM_SPELLS; break; case ITEM_WAND: case ITEM_STAFF: min_val = 1; max_val = NUM_SPELLS; break; case ITEM_WEAPON: min_val = 0; max_val = NUM_ATTACK_TYPES - 1; break; default: min_val = -65000; max_val = 65000; break; } GET_OBJ_VAL(OLC_OBJ(d), 3) = LIMIT(number, min_val, max_val); break; case OEDIT_PROMPT_APPLY: if ((number = atoi(arg)) == 0) break; else if (number < 0 || number > MAX_OBJ_AFFECT) { oedit_disp_prompt_apply_menu(d); return; } OLC_VAL(d) = number - 1; OLC_MODE(d) = OEDIT_APPLY; oedit_disp_apply_menu(d); return; case OEDIT_APPLY: if (((number = atoi(arg)) == 0) || ((number = atoi(arg)) == 1)) { OLC_OBJ(d)->affected[OLC_VAL(d)].location = 0; OLC_OBJ(d)->affected[OLC_VAL(d)].modifier = 0; oedit_disp_prompt_apply_menu(d); } else if (number < 0 || number > NUM_APPLIES) oedit_disp_apply_menu(d); else { int counter; /* add in check here if already applied.. deny builders another */ if (GET_LEVEL(d->character) < LVL_IMPL) { for (counter = 0; counter < MAX_OBJ_AFFECT; counter++) { if (OLC_OBJ(d)->affected[counter].location == number) { write_to_output(d, "Object already has that apply."); return; } } } OLC_OBJ(d)->affected[OLC_VAL(d)].location = number - 1; write_to_output(d, "Modifier : "); OLC_MODE(d) = OEDIT_APPLYMOD; } return; case OEDIT_APPLYMOD: OLC_OBJ(d)->affected[OLC_VAL(d)].modifier = atoi(arg); oedit_disp_prompt_apply_menu(d); return; case OEDIT_EXTRADESC_KEY: if (genolc_checkstring(d, arg)) { if (OLC_DESC(d)->keyword) free(OLC_DESC(d)->keyword); OLC_DESC(d)->keyword = str_udup(arg); } oedit_disp_extradesc_menu(d); return; case OEDIT_EXTRADESC_MENU: switch ((number = atoi(arg))) { case 0: if (!OLC_DESC(d)->keyword || !OLC_DESC(d)->description) { struct extra_descr_data *temp; if (OLC_DESC(d)->keyword) free(OLC_DESC(d)->keyword); if (OLC_DESC(d)->description) free(OLC_DESC(d)->description); /* Clean up pointers */ REMOVE_FROM_LIST(OLC_DESC(d), OLC_OBJ(d)->ex_description, next); free(OLC_DESC(d)); OLC_DESC(d) = NULL; } break; case 1: OLC_MODE(d) = OEDIT_EXTRADESC_KEY; write_to_output(d, "Enter keywords, separated by spaces :-\r\n| "); return; case 2: OLC_MODE(d) = OEDIT_EXTRADESC_DESCRIPTION; send_editor_help(d); write_to_output(d, "Enter the extra description:\r\n\r\n"); if (OLC_DESC(d)->description) { write_to_output(d, "%s", OLC_DESC(d)->description); oldtext = strdup(OLC_DESC(d)->description); } string_write(d, &OLC_DESC(d)->description, MAX_MESSAGE_LENGTH, 0, oldtext); OLC_VAL(d) = 1; return; case 3: /* Only go to the next description if this one is finished. */ if (OLC_DESC(d)->keyword && OLC_DESC(d)->description) { struct extra_descr_data *new_extra; if (OLC_DESC(d)->next) OLC_DESC(d) = OLC_DESC(d)->next; else { /* Make new extra description and attach at end. */ CREATE(new_extra, struct extra_descr_data, 1); OLC_DESC(d)->next = new_extra; OLC_DESC(d) = OLC_DESC(d)->next; } } /* No break - drop into default case. */ default: oedit_disp_extradesc_menu(d); return; } break; case OEDIT_COPY: if ((number = real_object(atoi(arg))) != NOTHING) { oedit_setup_existing(d, number); } else write_to_output(d, "That object does not exist.\r\n"); break; case OEDIT_DELETE: if (*arg == 'y' || *arg == 'Y') { if (delete_object(GET_OBJ_RNUM(OLC_OBJ(d))) != NOTHING) write_to_output(d, "Object deleted.\r\n"); else write_to_output(d, "Couldn't delete the object!\r\n"); cleanup_olc(d, CLEANUP_ALL); } else if (*arg == 'n' || *arg == 'N') { oedit_disp_menu(d); OLC_MODE(d) = OEDIT_MAIN_MENU; } else write_to_output(d, "Please answer 'Y' or 'N': "); return; default: mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: Reached default case in oedit_parse()!"); write_to_output(d, "Oops...\r\n"); break; }