Freeciv-3.3: trade_generator Class Reference

Freeciv-3.3

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< qtiles > | lines
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_city * | find_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 127 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 139 of file menu.cpp.

## ◆ calculate()

void trade_generator::calculate | ( |  | ) |

Finds trade routes to establish

Definition at line 234 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 216 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 475 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 107 of file menu.cpp.

Referenced by add_all_cities().

## ◆ discard()

void trade_generator::discard | ( |  | ) |

private

Drops all possible trade routes.

Definition at line 345 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 404 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 378 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 364 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 460 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 425 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 327 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 311 of file menu.cpp.

## ◆ remove_city()

void trade_generator::remove_city | ( | struct city * | pcity | ) |

Removes single city from trade generator

Definition at line 172 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 190 of file menu.cpp.

Referenced by add_tile().

## Field Documentation

## ◆ cities

QList<trade_city*> trade_generator::cities

Definition at line 182 of file menu.h.

Referenced by add_city(), add_tile(), calculate(), calculate_inner(), clear_trade_planing(), discard_any(), discard_one(), find_certain_routes(), find_certain_routes_inner(), find_most_free(), find_over_max(), remove_city(), and remove_virtual_city().

## ◆ 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().