Freeciv-3.2
Loading...
Searching...
No Matches
Public Member Functions | Data Fields | Private Member Functions
trade_generator Class Reference

#include <menu.h>

Public Member Functions

 trade_generator ()
 
void add_all_cities ()
 
void add_city (struct city *pcity)
 
void add_tile (struct tile *ptile)
 
void calculate ()
 
void clear_trade_planing ()
 
void remove_city (struct city *pcity)
 
void remove_virtual_city (struct tile *ptile)
 

Data Fields

bool hover_city
 
QList< qtileslines
 
QList< struct city * > virtual_cities
 
QList< trade_city * > cities
 

Private Member Functions

bool discard_any (trade_city *tc, int freeroutes)
 
bool discard_one (trade_city *tc)
 
int find_over_max (struct city *pcity)
 
trade_cityfind_most_free ()
 
void check_if_done (trade_city *tc1, trade_city *tc2)
 
void discard ()
 
void discard_trade (trade_city *tc1, trade_city *tc2)
 
void find_certain_routes ()
 
void find_certain_routes_inner (trade_city *tc)
 
void calculate_inner (trade_city *tc)
 

Detailed Description

Definition at line 174 of file menu.h.

Constructor & Destructor Documentation

◆ trade_generator()

trade_generator::trade_generator ( )

Constructor for trade calculator

Definition at line 79 of file menu.cpp.

Member Function Documentation

◆ add_all_cities()

void trade_generator::add_all_cities ( )

Adds all cities to trade generator

Definition at line 87 of file menu.cpp.

◆ add_city()

void trade_generator::add_city ( struct city pcity)

Adds single city to trade generator

Definition at line 125 of file menu.cpp.

Referenced by add_all_cities(), and add_tile().

◆ add_tile()

void trade_generator::add_tile ( struct tile ptile)

Adds/removes tile to trade generator

Definition at line 137 of file menu.cpp.

◆ calculate()

void trade_generator::calculate ( )

Finds trade routes to establish

Definition at line 232 of file menu.cpp.

◆ calculate_inner()

void trade_generator::calculate_inner ( trade_city tc)
private

Inner foreach() loop of trade_generator::calculate() Implemented as separate function to avoid shadow warnings about internal variables of foreach() inside foreach()

Definition at line 214 of file menu.cpp.

Referenced by calculate().

◆ check_if_done()

void trade_generator::check_if_done ( trade_city tc1,
trade_city tc2 
)
private

Marks cities with full trade routes to finish searching

Definition at line 473 of file menu.cpp.

Referenced by discard_trade(), and find_certain_routes_inner().

◆ clear_trade_planing()

void trade_generator::clear_trade_planing ( )

Clears generated routes, virtual cities, cities

Definition at line 105 of file menu.cpp.

Referenced by add_all_cities().

◆ discard()

void trade_generator::discard ( )
private

Drops all possible trade routes.

Definition at line 343 of file menu.cpp.

Referenced by calculate().

◆ discard_any()

bool trade_generator::discard_any ( trade_city tc,
int  freeroutes 
)
private

Drops all trade routes for given city

Definition at line 402 of file menu.cpp.

Referenced by discard().

◆ discard_one()

bool trade_generator::discard_one ( trade_city tc)
private

Drops one trade route for given city if possible

Definition at line 376 of file menu.cpp.

Referenced by discard().

◆ discard_trade()

void trade_generator::discard_trade ( trade_city tc,
trade_city ttc 
)
private

Drops trade routes between given cities

Definition at line 362 of file menu.cpp.

Referenced by discard_any(), and discard_one().

◆ find_certain_routes()

void trade_generator::find_certain_routes ( )
private

Adds routes for cities which can only have maximum possible trade routes

Definition at line 458 of file menu.cpp.

Referenced by calculate().

◆ find_certain_routes_inner()

void trade_generator::find_certain_routes_inner ( trade_city tc)
private

Inner foreach() loop of trade_generator::find_certain_routes() Implemented as separate function to avoid shadow warnings about internal variables of foreach() inside foreach()

Definition at line 423 of file menu.cpp.

Referenced by find_certain_routes().

◆ find_most_free()

trade_city * trade_generator::find_most_free ( )
private

Finds city with highest trade routes possible

Definition at line 325 of file menu.cpp.

Referenced by discard().

◆ find_over_max()

int trade_generator::find_over_max ( struct city pcity = nullptr)
private

Finds highest number of trade routes over maximum for all cities, skips given city

Definition at line 309 of file menu.cpp.

◆ remove_city()

void trade_generator::remove_city ( struct city pcity)

Removes single city from trade generator

Definition at line 170 of file menu.cpp.

Referenced by add_tile().

◆ remove_virtual_city()

void trade_generator::remove_virtual_city ( struct tile ptile)

Removes virtual city from trade generator

Definition at line 188 of file menu.cpp.

Referenced by add_tile().

Field Documentation

◆ cities

QList<trade_city*> trade_generator::cities

◆ hover_city

bool trade_generator::hover_city

Definition at line 179 of file menu.h.

Referenced by trade_generator().

◆ lines

QList<qtiles> trade_generator::lines

Definition at line 180 of file menu.h.

Referenced by calculate(), clear_trade_planing(), and find_certain_routes_inner().

◆ virtual_cities

QList<struct city *> trade_generator::virtual_cities

Definition at line 181 of file menu.h.

Referenced by add_tile(), clear_trade_planing(), and remove_virtual_city().