config::attribute_value &config::attribute_value::operator=(const std::string &v) { // Handle some special strings. if (v.empty()) { value_ = v; return *this; } if ( v == s_yes ) { value_ = yes_no(true); return *this; } if ( v == s_no ) { value_ = yes_no(false); return *this; } if ( v == s_true ) { value_ = true_false(true); return *this; } if ( v == s_false ) { value_ = true_false(false); return *this; } // Attempt to convert to a number. char *eptr; double d = strtod(v.c_str(), &eptr); if ( *eptr == '\0' ) { // Possibly a number. See what type it should be stored in. // (All conversions will be from the string since the largest integer // type could have more precision than a double.) if ( d > 0.0 ) { // The largest type for positive integers is unsigned long long. unsigned long long ull = 0; if ( from_string_verify<unsigned long long>(v, ull) ) return *this = ull; } else { // The largest (variant) type for negative integers is int. int i = 0; if ( from_string_verify<int>(v, i) ) return *this = i; } // This does not look like an integer, so it should be a double. // However, make sure it can convert back to the same string (in // case this is a string that just looks like a numeric value). std::ostringstream tester; tester << d; if ( tester.str() == v ) { value_ = d; return *this; } } // No conversion possible. Store the string. value_ = v; return *this; }
void do_dflag( char_data* ch, char* argument ) { wizard_data* imm = (wizard_data*) ch; exit_data* exit; exit_data* back; int flags; if( !get_flags( ch, argument, &flags, "1", "dflag" ) ) return; if( ( exit = imm->exit_edit ) == NULL ) { send( ch, "Use dedit to specify direction.\n\r" ); return; } if( *argument == '\0' ) { display_flags( "Door Flags", &dflag_name[0], &dflag_name[1], &exit->exit_info, MAX_DFLAG, ch ); return; } if( !can_edit( ch, ch->in_room ) ) return; ch->in_room->area->modified = TRUE; for( int i = 0; i < MAX_DFLAG; i++ ) if( fmatches( argument, dflag_name[i] ) ) { switch_bit( &exit->exit_info, i ); if( ( back = reverse( exit ) ) != NULL && !is_set( &flags, 0 ) ) assign_bit( &back->exit_info, i, is_set( &exit->exit_info,i ) ); send( ch, "%s set %s on %sthe %s exit.\n\r", dflag_name[i], true_false( &exit->exit_info, i ), back != NULL && !is_set( &flags, 0 ) ? "both sides of " : "", dir_table[ exit->direction ].name ); return; } send( ch, "Unknown flag - see dflag with no arguments for list.\n\r" ); }