Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/worklist.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Functions
worklist.c File Reference
`#include <stdarg.h>`
`#include <string.h>`
`#include "log.h"`
`#include "mem.h"`
`#include "support.h"`
`#include "city.h"`
`#include "requirements.h"`
`#include "unit.h"`
`#include "worklist.h"`

Go to the source code of this file.

## Functions

void | worklist_init (struct worklist *pwl)
int | worklist_length (const struct worklist *pwl)
bool | worklist_is_empty (const struct worklist *pwl)
bool | worklist_peek (const struct worklist *pwl, struct universal *prod)
bool | worklist_peek_ith (const struct worklist *pwl, struct universal *prod, int idx)
void | worklist_advance (struct worklist *pwl)
void | worklist_copy (struct worklist *dst, const struct worklist *src)
void | worklist_remove (struct worklist *pwl, int idx)
bool | worklist_append (struct worklist *pwl, const struct universal *prod)
bool | worklist_insert (struct worklist *pwl, const struct universal *prod, int idx)
bool | are_worklists_equal (const struct worklist *wlist1, const struct worklist *wlist2)

## Function Documentation

## ◆ are_worklists_equal()

bool are_worklists_equal | ( | const struct worklist * | wlist1,
|  | const struct worklist * | wlist2
| ) |  |

Return TRUE iff the two worklists are equal.

Definition at line 192 of file worklist.c.

Referenced by send_packet_city_info_100(), send_packet_city_info_101(), send_packet_city_info_102(), send_packet_city_info_103(), send_packet_city_worklist_100(), and send_packet_city_worklist_101().

## ◆ worklist_advance()

void worklist_advance | ( | struct worklist * | pwl | ) |

Remove first element from worklist.

Definition at line 104 of file worklist.c.

Referenced by city_set_queue(), and remove_item_from_worklist().

## ◆ worklist_append()

bool worklist_append | ( | struct worklist * | pwl,
|  | const struct universal * | prod
| ) |  |

Adds the id to the next available slot in the worklist. 'id' is the ID of the unit/building to be produced; is_unit specifies whether it's a unit or a building. Returns TRUE if successful.

Definition at line 147 of file worklist.c.

Referenced by add_global_worklist(), add_target_to_worklist(), base_city_queue_insert(), commit_worklist(), dio_get_worklist_raw(), and global_worklists_build().

## ◆ worklist_copy()

void worklist_copy | ( | struct worklist * | dst,
|  | const struct worklist * | src
| ) |  |

Copy contents from worklist src to worklist dst.

Definition at line 112 of file worklist.c.

Referenced by city_get_queue(), city_set_queue(), dsend_packet_city_worklist(), global_worklist_set(), global_worklists_build(), global_worklists_unbuild(), handle_city_info(), handle_city_worklist(), package_city(), popup_worklist_editor(), refresh_worklist(), and set_global_worklist().

## ◆ worklist_init()

void worklist_init | ( | struct worklist * | pwl | ) |

Initialize a worklist to be empty. For elements, only really need to set [0], but initialize the rest to avoid junk values in savefile.

Definition at line 38 of file worklist.c.

Referenced by city_queue_clear(), city_dialog::clear_worklist(), clear_worklist_foreach_func(), city_widget::clear_worlist(), commit_worklist(), create_city_virtual(), dio_get_worklist_raw(), global_worklist_alloc(), global_worklists_build(), handle_city_info(), set_global_worklist(), worklist_load(), and worklist_load().

## ◆ worklist_insert()

bool worklist_insert | ( | struct worklist * | pwl,
|  | const struct universal * | prod,
|  | int | idx
| ) |  |

Inserts the production at the location idx in the worklist, thus moving all subsequent entries down. 'id' specifies the unit/building to be produced; is_unit tells whether it's a unit or building. Returns TRUE if successful.

Definition at line 167 of file worklist.c.

Referenced by base_city_queue_insert(), city_get_queue(), production_widget::prod_selected(), city_dialog::worklist_down(), and city_dialog::worklist_up().

## ◆ worklist_is_empty()

bool worklist_is_empty | ( | const struct worklist * | pwl | ) |

Returns whether worklist has no elements.

Definition at line 66 of file worklist.c.

Referenced by add_global_worklist(), city_dialog_update_building(), city_set_queue(), cr_entry_building(), real_city_report_dialog_update_city(), real_info_city_report_dialog_update(), remove_item_from_worklist(), set_global_worklist(), and worklist_change_build_target().

## ◆ worklist_length()

int worklist_length | ( | const struct worklist * | pwl | ) |

Returns the number of entries in the worklist. The returned value can also be used as the next available worklist index (assuming that len < MAX_LEN_WORKLIST).

Definition at line 57 of file worklist.c.

Referenced by add_global_worklist(), add_target_to_worklist(), base_city_queue_insert(), city_build_unit(), city_production_build_units(), city_queue_insert_worklist(), city_dialog::dbl_click_p(), dio_put_worklist_raw(), city_widget::display_list_menu(), global_worklist_save(), global_worklists_build(), global_worklists_save(), global_worklists_unbuild(), menu_item_callback(), menu_item_callback(), ok_worklist_editor_callback(), popup_worklist_editor(), production_widget::prod_selected(), refresh_worklist(), refresh_worklist_count_label(), remove_item_from_worklist(), set_global_worklist(), city_dialog::update_improvements(), worklist_append(), worklist_change_build_target(), and worklist_next_to_last_impr_or_unit_iterate().

## ◆ worklist_peek()

bool worklist_peek | ( | const struct worklist * | pwl,
|  | struct universal * | prod
| ) |  |

Fill in the id and is_unit values for the head of the worklist if the worklist is non-empty. Return 1 iff id and is_unit are valid.

Definition at line 76 of file worklist.c.

Referenced by city_set_queue().

## ◆ worklist_peek_ith()

bool worklist_peek_ith | ( | const struct worklist * | pwl,
|  | struct universal * | prod,
|  | int | idx
| ) |  |

Fill in the id and is_unit values for the ith element in the worklist. If the worklist has fewer than idx elements, return FALSE.

Definition at line 86 of file worklist.c.

Referenced by city_production_build_units(), city_worklist_commit(), set_global_worklist(), worklist_change_build_target(), city_dialog::worklist_down(), worklist_peek(), and city_dialog::worklist_up().

## ◆ worklist_remove()

void worklist_remove | ( | struct worklist * | pwl,
|  | int | idx
| ) |  |

Remove element from position idx.

Definition at line 122 of file worklist.c.

Referenced by city_build_unit(), city_get_queue(), city_worklist_commit(), city_dialog::dbl_click_p(), ok_worklist_editor_callback(), production_widget::prod_selected(), remove_item_from_worklist(), worklist_advance(), worklist_change_build_target(), city_dialog::worklist_down(), and city_dialog::worklist_up().