Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/advisors/advchoice.h File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
advchoice.h File Reference

Go to the source code of this file.

## Data Structures

struct | adv_choice

## Macros

#define | adv_choice_set_use(_choice, _use)
#define | adv_choice_mark(_choice)
#define | adv_choice_log_info(_choice, _loc1, _loc2)
#define | adv_choice_log_int(_choice, _loc1, _loc2)
#define | ADV_CHOICE_LOG(_choice) adv_choice_log_int((_choice), __FILE__, __FC_LINE__)
#define | ADV_CHOICE_ASSERT(c)

## Enumerations

enum | choice_type { CT_NONE = 0 , CT_BUILDING = 1 , CT_CIVILIAN , CT_ATTACKER , CT_DEFENDER , CT_LAST }

## Functions

void | adv_init_choice (struct adv_choice *choice)
void | adv_deinit_choice (struct adv_choice *choice)
struct adv_choice * | adv_new_choice (void)
void | adv_free_choice (struct adv_choice *choice)
struct adv_choice * | adv_better_choice (struct adv_choice *first, struct adv_choice *second)
struct adv_choice * | adv_better_choice_free (struct adv_choice *first, struct adv_choice *second)
bool | is_unit_choice_type (enum choice_type type)
const char * | adv_choice_rule_name (const struct adv_choice *choice)
static void | adv_choice_copy (struct adv_choice *dest, struct adv_choice *src)
static const char * | adv_choice_get_use (const struct adv_choice *choice)

## Macro Definition Documentation

## ◆ ADV_CHOICE_ASSERT

#define ADV_CHOICE_ASSERT | ( |  | c | ) |

Value:
do { \
if ((c).want > 0) { \
fc_assert((c).type > CT_NONE && (c).type < CT_LAST); \
if (!is_unit_choice_type((c).type)) { \
int _iindex = improvement_index((c).value.building); \
fc_assert(_iindex >= 0 && _iindex < improvement_count()); \
} else { \
int _uindex = utype_index((c).value.utype); \
fc_assert(_uindex >= 0 && _uindex < utype_count()); \
} \
} \
} while (FALSE);
CT_LAST
@ CT_LAST
Definition advchoice.h:42
CT_NONE
@ CT_NONE
Definition advchoice.h:37
is_unit_choice_type
bool is_unit_choice_type(enum choice_type type)
Definition advchoice.c:115
type
GType type
Definition repodlgs.c:1312
improvement_index
Impr_type_id improvement_index(const struct impr_type *pimprove)
Definition improvement.c:173
improvement_count
Impr_type_id improvement_count(void)
Definition improvement.c:162
FALSE
#define FALSE
Definition support.h:47
utype_count
Unit_type_id utype_count(void)
Definition unittype.c:80
utype_index
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91

Definition at line 100 of file advchoice.h.

## ◆ ADV_CHOICE_LOG

#define ADV_CHOICE_LOG | ( |  | _choice | ) | adv_choice_log_int((_choice), __FILE__, __FC_LINE__)

Definition at line 95 of file advchoice.h.

## ◆ adv_choice_log_info

#define adv_choice_log_info | ( |  | _choice,
|  |  | _loc1,
|  |  | _loc2
| ) |  |

Definition at line 87 of file advchoice.h.

## ◆ adv_choice_log_int

#define adv_choice_log_int | ( |  | _choice,
|  |  | _loc1,
|  |  | _loc2
| ) |  |

Definition at line 88 of file advchoice.h.

## ◆ adv_choice_mark

#define adv_choice_mark | ( |  | _choice | ) |

Definition at line 86 of file advchoice.h.

## ◆ adv_choice_set_use

#define adv_choice_set_use | ( |  | _choice,
|  |  | _use
| ) |  |

Definition at line 85 of file advchoice.h.

## Enumeration Type Documentation

## ◆ choice_type

enum choice_type

Enumerator
CT_NONE |
CT_BUILDING |
CT_CIVILIAN |
CT_ATTACKER |
CT_DEFENDER |
CT_LAST |

Definition at line 36 of file advchoice.h.

## Function Documentation

## ◆ adv_better_choice()

struct adv_choice * adv_better_choice | ( | struct adv_choice * | first,
|  | struct adv_choice * | second
| ) |  |

Return better one of the choices given. In case of a draw, first one is preferred.

Definition at line 85 of file advchoice.c.

Referenced by dai_city_choose_build().

## ◆ adv_better_choice_free()

struct adv_choice * adv_better_choice_free | ( | struct adv_choice * | first,
|  | struct adv_choice * | second
| ) |  |

Return better one of the choices given, and free the other.

Definition at line 98 of file advchoice.c.

Referenced by domestic_advisor_choose_build().

## ◆ adv_choice_copy()

static void adv_choice_copy | ( | struct adv_choice * | dest,
|  | struct adv_choice * | src
| ) |  |

inlinestatic

Definition at line 79 of file advchoice.h.

Referenced by dai_city_choose_build(), dai_manage_cities(), dai_spend_gold(), military_advisor_choose_build(), texai_check_messages(), and texai_refresh().

## ◆ adv_choice_get_use()

static const char * adv_choice_get_use | ( | const struct adv_choice * | choice | ) |

inlinestatic

Definition at line 89 of file advchoice.h.

## ◆ adv_choice_rule_name()

const char * adv_choice_rule_name | ( | const struct adv_choice * | choice | ) |

Return the (untranslated) rule name of the adv_choice. You don't have to free the return pointer.

Definition at line 124 of file advchoice.c.

Referenced by dai_city_choose_build(), dai_spend_gold(), and military_advisor_choose_build().

## ◆ adv_deinit_choice()

void adv_deinit_choice | ( | struct adv_choice * | choice | ) |

Clear choice without freeing it itself

Definition at line 46 of file advchoice.c.

Referenced by dai_city_free(), military_advisor_choose_build(), and texai_city_free().

## ◆ adv_free_choice()

void adv_free_choice | ( | struct adv_choice * | choice | ) |

Free dynamically allocated choice.

Definition at line 71 of file advchoice.c.

Referenced by adv_better_choice_free(), dai_city_choose_build(), dai_manage_cities(), kill_something_with(), and texai_check_messages().

## ◆ adv_init_choice()

void adv_init_choice | ( | struct adv_choice * | choice | ) |

Sets the values of the choice to initial values.

Definition at line 31 of file advchoice.c.

Referenced by adv_new_choice(), dai_city_alloc(), dai_do_build_city(), dai_spend_gold(), military_advisor_choose_build(), and texai_city_alloc().

## ◆ adv_new_choice()

struct adv_choice * adv_new_choice | ( | void |  | ) |

Dynamically allocate a new choice.

Definition at line 59 of file advchoice.c.

Referenced by domestic_advisor_choose_build(), kill_something_with(), and military_advisor_choose_build().

## ◆ is_unit_choice_type()

bool is_unit_choice_type | ( | enum choice_type | type | ) |

Does choice type refer to unit

Definition at line 115 of file advchoice.c.

Referenced by adjust_ai_unit_choice(), and dai_spend_gold().