Freeciv-3.3
Loading...
Searching...
No Matches
Functions | Variables
oblig_reqs.c File Reference
#include "mem.h"
#include "actres.h"
#include "nation.h"
#include "player.h"
#include "oblig_reqs.h"

Go to the source code of this file.

Functions

static struct ae_contra_orreq_contradiction_or (int alternatives,...)
 
static void ae_contra_close (struct ae_contra_or *contra)
 
static void voblig_hard_req_reg_sub_res (struct ae_contra_or *contras, const char *error_message, va_list args)
 
static void oblig_hard_req_reg_sub_res (struct ae_contra_or *contras, const char *error_message,...)
 
static void voblig_hard_req_reg (struct ae_contra_or *contras, const char *error_message, va_list args)
 
static void oblig_hard_req_reg (struct ae_contra_or *contras, const char *error_message,...)
 
static void oblig_hard_req_register (struct requirement contradiction, bool is_target, const char *error_message,...)
 
void hard_code_oblig_hard_reqs (void)
 
void hard_code_oblig_hard_reqs_ruleset (void)
 
void oblig_hard_reqs_init (void)
 
void oblig_hard_reqs_free (void)
 
struct obligatory_req_vectoroblig_hard_reqs_get (enum action_result res)
 
struct obligatory_req_vectoroblig_hard_reqs_get_sub (enum action_sub_result res)
 

Variables

static struct obligatory_req_vector oblig_hard_reqs_r [ACTRES_NONE]
 
static struct obligatory_req_vector oblig_hard_reqs_sr [ACT_SUB_RES_COUNT]
 

Function Documentation

◆ ae_contra_close()

static void ae_contra_close ( struct ae_contra_or contra)
static

Tell an ae_contra_or that one of its users is done with it.

Parameters
contrathe ae_contra_or the user is done with.

Definition at line 76 of file oblig_reqs.c.

Referenced by oblig_hard_reqs_free().

◆ hard_code_oblig_hard_reqs()

void hard_code_oblig_hard_reqs ( void  )

Hard code the obligatory hard requirements that don't depend on the rest of the ruleset. They are sorted by requirement to make it easy to read, modify and explain them.

Definition at line 250 of file oblig_reqs.c.

Referenced by actions_init().

◆ hard_code_oblig_hard_reqs_ruleset()

void hard_code_oblig_hard_reqs_ruleset ( void  )

Hard code the obligatory hard requirements that needs access to the ruleset before they can be generated.

Definition at line 770 of file oblig_reqs.c.

Referenced by actions_rs_pre_san_gen().

◆ oblig_hard_req_reg()

static void oblig_hard_req_reg ( struct ae_contra_or contras,
const char error_message,
  ... 
)
static

Register an obligatory hard requirement for the specified action results.

Parameters
contrasif one alternative here doesn't contradict the enabler it is accepted.
error_messageerror message if an enabler contradicts all contras. Followed by a list of action results that should be unable to contradict all specified contradictions.

Definition at line 207 of file oblig_reqs.c.

Referenced by hard_code_oblig_hard_reqs(), and hard_code_oblig_hard_reqs_ruleset().

◆ oblig_hard_req_reg_sub_res()

static void oblig_hard_req_reg_sub_res ( struct ae_contra_or contras,
const char error_message,
  ... 
)
static

Register an obligatory hard requirement for the specified action sub results.

Parameters
contrasif one alternative here doesn't contradict the enabler it is accepted.
error_messageerror message if an enabler contradicts all contras. Followed by a list of action sub results that should be unable to contradict all specified contradictions.

Definition at line 140 of file oblig_reqs.c.

Referenced by hard_code_oblig_hard_reqs().

◆ oblig_hard_req_register()

static void oblig_hard_req_register ( struct requirement  contradiction,
bool  is_target,
const char error_message,
  ... 
)
static

Register an obligatory hard requirement for the action results it applies to.

The vararg parameter is a list of action ids it applies to terminated by ACTION_NONE.

Definition at line 227 of file oblig_reqs.c.

Referenced by hard_code_oblig_hard_reqs(), and hard_code_oblig_hard_reqs_ruleset().

◆ oblig_hard_reqs_free()

void oblig_hard_reqs_free ( void  )

Free resources reserved for hard reqs system.

Definition at line 827 of file oblig_reqs.c.

Referenced by actions_free().

◆ oblig_hard_reqs_get()

struct obligatory_req_vector * oblig_hard_reqs_get ( enum action_result  res)

Get obligatory requirements for action result.

Parameters
resAction result to get requirements for
Returns
Vector of obligatory requirements

Definition at line 852 of file oblig_reqs.c.

Referenced by action_enabler_suggest_repair_oblig().

◆ oblig_hard_reqs_get_sub()

struct obligatory_req_vector * oblig_hard_reqs_get_sub ( enum action_sub_result  res)

Get obligatory requirements for action with sub result.

Parameters
resAction sub result to get requirements for
Returns
Vector of obligatory requirements

Definition at line 863 of file oblig_reqs.c.

Referenced by action_enabler_suggest_repair_oblig().

◆ oblig_hard_reqs_init()

void oblig_hard_reqs_init ( void  )

Initialize hard reqs system.

Definition at line 807 of file oblig_reqs.c.

Referenced by actions_init().

◆ req_contradiction_or()

static struct ae_contra_or * req_contradiction_or ( int  alternatives,
  ... 
)
static

Returns a new array of alternative action enabler contradictions. Only one has to not contradict the enabler for it to be seen as fulfilled.

Parameters
alternativesthe number of action enabler contradictions followed by the enabler contradictions specified as alternating contradicting requirement and a bool that is TRUE if the requirement contradicts the enabler's target requirement vector and FALSE if it contradicts the enabler's actor vector.
Returns
a new array of alternative action enabler contradictions.

Definition at line 46 of file oblig_reqs.c.

Referenced by hard_code_oblig_hard_reqs(), hard_code_oblig_hard_reqs_ruleset(), and oblig_hard_req_register().

◆ voblig_hard_req_reg()

static void voblig_hard_req_reg ( struct ae_contra_or contras,
const char error_message,
va_list  args 
)
static

Register an obligatory hard requirement for the specified action results.

Parameters
contrasif one alternative here doesn't contradict the enabler it is accepted.
error_messageerror message if an enabler contradicts all contras.
argslist of action results that should be unable to contradict all specified contradictions.

Definition at line 162 of file oblig_reqs.c.

Referenced by oblig_hard_req_reg(), and oblig_hard_req_register().

◆ voblig_hard_req_reg_sub_res()

static void voblig_hard_req_reg_sub_res ( struct ae_contra_or contras,
const char error_message,
va_list  args 
)
static

Register an obligatory hard requirement for the specified action sub results.

Parameters
contrasif one alternative here doesn't contradict the enabler it is accepted.
error_messageerror message if an enabler contradicts all contras.
argslist of action sub results that should be unable to contradict all specified contradictions.

Definition at line 97 of file oblig_reqs.c.

Referenced by oblig_hard_req_reg_sub_res().

Variable Documentation

◆ oblig_hard_reqs_r

struct obligatory_req_vector oblig_hard_reqs_r[ACTRES_NONE]
static

◆ oblig_hard_reqs_sr

struct obligatory_req_vector oblig_hard_reqs_sr[ACT_SUB_RES_COUNT]
static