#include "global.hpp"
#include <cmath>
#include <map>
#include <sstream>
#include <SDL_types.h>
Go to the source code of this file.
Classes | |
struct | bad_lexical_cast |
Defines | |
#define | LIKELY(a) a |
#define | UNLIKELY(a) a |
#define | fxp_shift 8 |
#define | fxp_base (1 << fxp_shift) |
#define | ftofxp(x) (fixed_t((x) * fxp_base)) |
IN: float or int - OUT: fixed_t. | |
#define | fxpmult(x, y) (((x)*(y)) >> fxp_shift) |
IN: unsigned and fixed_t - OUT: unsigned. | |
#define | fxpdiv(x, y) (((x) << fxp_shift) / (y)) |
IN: unsigned and int - OUT: fixed_t. | |
#define | fxptoi(x) ( ((x)>0) ? ((x) >> fxp_shift) : (-((-(x)) >> fxp_shift)) ) |
IN: fixed_t - OUT: int. | |
Typedefs | |
typedef Sint32 | fixed_t |
Functions | |
template<typename T> | |
T & | minimum (T &a, T &b) |
Replacement for VC++'s definitions of min and max. | |
template<typename T> | |
const T & | minimum (const T &a, const T &b) |
template<typename T> | |
T & | maximum (T &a, T &b) |
template<typename T> | |
const T & | maximum (const T &a, const T &b) |
template<typename T> | |
bool | is_odd (T num) |
template<typename T> | |
bool | is_even (T num) |
int | div100rounded (int num) |
Guarantees portable results for division by 100; round towards 0. | |
int | round_damage (int base_damage, int bonus, int divisor) |
round (base_damage * bonus / divisor) to the closest integer, but up or down towards base_damage | |
int | round_double (double d) |
template<typename To, typename From> | |
To | lexical_cast (From a) |
template<typename To, typename From> | |
To | lexical_cast_default (From a, To def=To()) |
template<> | |
int | lexical_cast< int, const std::string & > (const std::string &a) |
template<> | |
int | lexical_cast< int, const char * > (const char *a) |
template<> | |
int | lexical_cast_default< int, const std::string & > (const std::string &a, int def) |
template<> | |
int | lexical_cast_default< int, const char * > (const char *a, int def) |
template<typename From> | |
std::string | str_cast (From a) |
template<typename To, typename From> | |
To | lexical_cast_in_range (From a, To def, To min, To max) |
bool | chars_equal_insensitive (char a, char b) |
bool | chars_less_insensitive (char a, char b) |
template<typename T, typename C> | |
void | push_back (T &str, C c) |
A definition of 'push_back' for strings, since some implementations don't support string::push_back. |
Definition in file util.hpp.
#define ftofxp | ( | x | ) | (fixed_t((x) * fxp_base)) |
IN: float or int - OUT: fixed_t.
Definition at line 170 of file util.hpp.
Referenced by unit_type::build_full(), game_display::draw_bar(), image::get_brightened(), image::get_semi_brightened(), game_display::new_turn(), unit_frame::redraw(), unit::redraw_unit(), display::render_unit_image(), and scale_surface().
#define fxpdiv | ( | x, | |||
y | ) | (((x) << fxp_shift) / (y)) |
IN: unsigned and int - OUT: fixed_t.
Definition at line 176 of file util.hpp.
Referenced by game_display::draw_bar(), game_display::new_turn(), and scale_surface().
#define fxpmult | ( | x, | |||
y | ) | (((x)*(y)) >> fxp_shift) |
IN: unsigned and fixed_t - OUT: unsigned.
Definition at line 173 of file util.hpp.
Referenced by adjust_surface_alpha(), brighten_image(), and game_display::draw_bar().
#define fxptoi | ( | x | ) | ( ((x)>0) ? ((x) >> fxp_shift) : (-((-(x)) >> fxp_shift)) ) |
IN: fixed_t - OUT: int.
Definition at line 179 of file util.hpp.
Referenced by game_display::draw_bar(), and scale_surface().
Definition at line 159 of file util.hpp.
Referenced by tokenizer::next_char(), and tokenizer::next_char_fast().
bool chars_equal_insensitive | ( | char | a, | |
char | b | |||
) | [inline] |
Definition at line 140 of file util.hpp.
Referenced by events::menu_handler::do_search(), and utils::word_completion().
bool chars_less_insensitive | ( | char | a, | |
char | b | |||
) | [inline] |
int div100rounded | ( | int | num | ) | [inline] |
Guarantees portable results for division by 100; round towards 0.
Definition at line 53 of file util.hpp.
Referenced by utils::apply_modifier().
bool is_even | ( | T | num | ) | [inline] |
Definition at line 50 of file util.hpp.
References is_odd().
Referenced by default_generate_map(), distance_between(), get_adjacent_tiles(), gamemap::location::get_direction(), and tiles_adjacent().
bool is_odd | ( | T | num | ) | [inline] |
Definition at line 44 of file util.hpp.
Referenced by distance_between(), game_display::draw_minimap_units(), map_editor::edit_rotate_selection(), default_map_generator::generate_map(), get_adjacent_tiles(), gamemap::location::get_direction(), display::get_location_y(), display::get_rect_hex_bounds(), image::getMinimap(), and is_even().
To lexical_cast | ( | From | a | ) | [inline] |
Definition at line 78 of file util.hpp.
Referenced by scoped_xy_unit::activate(), upload_log::add_game_result(), config::apply_diff(), attack::attack(), events::menu_handler::autosave(), check_timeout(), events::console_handler::do_control(), events::console_handler::do_droid(), game_display::draw_movement_info(), play_controller::expand_autosaves(), mp::connect::side::get_config(), hotkey::get_hotkey(), get_player_info(), help::help_text_area::handle_format_cfg(), help::help_text_area::handle_jump_cfg(), game::is_on_team(), mp::wait::join_game(), mp::connect::lists_init(), mp::connect::load_game(), image::locator::load_image_sub_file(), move_unit(), game_logic::parse_expression(), font::parse_markup(), play_game(), mp::create::process_event(), turn_info::process_network_data(), upload_log::quit(), statistics::stats::read(), wesnothd::banned::read(), events::menu_handler::recall(), network::receive_data(), map_editor::resize_dialog(), server::run(), game::send_change_controller(), events::menu_handler::send_chat_message(), events::chat_handler::send_command(), variant::serialize_to_string(), preferences::set_editor_b(), preferences::set_editor_g(), preferences::set_editor_r(), mp::gamebrowser::set_game_items(), team::set_income(), hotkey::hotkey_item::set_key(), preferences::set_scroll_speed(), tokenizer::skip_comment(), str_cast(), string2rgb(), variant::string_cast(), t_translation::string_to_number_(), track_ok(), game::transfer_ai_sides(), unit_display::unit_attack(), variable_info::variable_info(), upload_log::victory(), gamemap::write(), write_game(), and upload_log::~upload_log().
int lexical_cast< int, const char * > | ( | const char * | a | ) | [inline] |
int lexical_cast< int, const std::string & > | ( | const std::string & | a | ) | [inline] |
To lexical_cast_default | ( | From | a, | |
To | def = To() | |||
) | [inline] |
Definition at line 91 of file util.hpp.
Referenced by cfg_to_loc(), and t_translation::string_to_builder_number_().
int lexical_cast_default< int, const char * > | ( | const char * | a, | |
int | def | |||
) | [inline] |
int lexical_cast_default< int, const std::string & > | ( | const std::string & | a, | |
int | def | |||
) | [inline] |
To lexical_cast_in_range | ( | From | a, | |
To | def, | |||
To | min, | |||
To | max | |||
) | [inline] |
const T& maximum | ( | const T & | a, | |
const T & | b | |||
) | [inline] |
T& maximum | ( | T & | a, | |
T & | b | |||
) | [inline] |
Definition at line 38 of file util.hpp.
Referenced by gui::button::calculate_size(), combatant::complex_fight(), ai::do_attack_analysis(), gui2::tcontrol::get_single_line_best_size(), image::getMinimap(), preferences::resolution(), team::team(), and gui::menu::update_size().
const T& minimum | ( | const T & | a, | |
const T & | b | |||
) | [inline] |
T& minimum | ( | T & | a, | |
T & | b | |||
) | [inline] |
Replacement for VC++'s definitions of min and max.
Definition at line 32 of file util.hpp.
Referenced by blit_surface(), blur_alpha_surface(), blur_surface(), ai::choose_move(), gui::dialog_frame::draw_background(), gui::textbox::erase_selection(), gui2::tcontrol::get_multi_line_best_size(), gui::menu::imgsel_style::load_images(), unit_animation::particule::particule(), and gui::menu::update_size().
void push_back | ( | T & | str, | |
C | c | |||
) | [inline] |
A definition of 'push_back' for strings, since some implementations don't support string::push_back.
Definition at line 148 of file util.hpp.
Referenced by reports::report::add_image(), reports::report::add_text(), statistics::attack_context::attack_result(), statistics::attack_context::defend_result(), reports::report::report(), terrain_builder::rotate_rule(), utils::string_to_wstring(), font::text_to_lines(), and utils::wstring_to_string().
int round_damage | ( | int | base_damage, | |
int | bonus, | |||
int | divisor | |||
) | [inline] |
round (base_damage * bonus / divisor) to the closest integer, but up or down towards base_damage
Definition at line 61 of file util.hpp.
Referenced by reports::generate_report(), and battle_context::unit_stats::unit_stats().
int round_double | ( | double | d | ) | [inline] |
Definition at line 67 of file util.hpp.
Referenced by game_display::draw_minimap_units(), play_controller::play_slice(), display::scroll_to_tiles(), and display::scroll_to_xy().
std::string str_cast | ( | From | a | ) | [inline] |
Definition at line 116 of file util.hpp.
References lexical_cast().
Referenced by gui::progress_bar::draw_contents(), finish_save_game(), ai::move_leader_after_recruit(), t_translation::number_to_string_(), map_editor::preferences_dialog(), ai::attack_analysis::rating(), team::team(), team::team_info::team_info(), validate_side(), team::write(), and team::team_info::write().
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |