Freeciv21
Develop your civilization from humble roots to a global empire
worklist.h File Reference
#include "registry.h"
#include "fc_types.h"
+ Include dependency graph for worklist.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  worklist
 

Macros

#define MAX_LEN_WORKLIST   64
 
#define MAX_NUM_WORKLISTS   16
 
#define worklist_iterate(_list, _p)
 
#define worklist_iterate_end
 

Functions

void worklist_init (struct worklist *pwl)
 Initialize a worklist to be empty. More...
 
int worklist_length (const struct worklist *pwl)
 Returns the number of entries in the worklist. More...
 
bool worklist_is_empty (const struct worklist *pwl)
 Returns whether worklist has no elements. More...
 
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. More...
 
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. More...
 
void worklist_advance (struct worklist *pwl)
 Remove first element from worklist. More...
 
void worklist_copy (struct worklist *dst, const struct worklist *src)
 Copy contents from worklist src to worklist dst. More...
 
void worklist_remove (struct worklist *pwl, int idx)
 Remove element from position idx. More...
 
bool worklist_append (struct worklist *pwl, const struct universal *prod)
 Adds the id to the next available slot in the worklist. More...
 
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. More...
 
bool are_worklists_equal (const struct worklist *wlist1, const struct worklist *wlist2)
 Return TRUE iff the two worklists are equal. More...
 

Macro Definition Documentation

◆ MAX_LEN_WORKLIST

#define MAX_LEN_WORKLIST   64

Definition at line 19 of file worklist.h.

◆ MAX_NUM_WORKLISTS

#define MAX_NUM_WORKLISTS   16

Definition at line 20 of file worklist.h.

◆ worklist_iterate

#define worklist_iterate (   _list,
  _p 
)
Value:
{ \
struct universal _p; \
int _p##_index = 0; \
\
while (_p##_index < worklist_length(_list)) { \
worklist_peek_ith(_list, &_p, _p##_index++);
int worklist_length(const struct worklist *pwl)
Returns the number of entries in the worklist.
Definition: worklist.cpp:51

Definition at line 47 of file worklist.h.

◆ worklist_iterate_end

#define worklist_iterate_end
Value:
} \
}

Definition at line 55 of file worklist.h.

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 183 of file worklist.cpp.

◆ worklist_advance()

void worklist_advance ( struct worklist pwl)

Remove first element from worklist.

Definition at line 98 of file worklist.cpp.

Referenced by city_set_queue().

◆ 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 138 of file worklist.cpp.

Referenced by base_city_queue_insert(), dio_get_worklist_raw(), and global_worklists_build().

◆ worklist_copy()

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

◆ 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 32 of file worklist.cpp.

Referenced by city_dialog::clear_worklist(), city_widget::clear_worlist(), create_city_virtual(), dio_get_worklist_raw(), global_worklist_alloc(), global_worklists_build(), handle_city_info(), 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 158 of file worklist.cpp.

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 60 of file worklist.cpp.

Referenced by city_set_queue(), cr_entry_building(), and worklist_change_build_target().

◆ worklist_length()

int worklist_length ( const struct worklist pwl)

◆ 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 70 of file worklist.cpp.

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 80 of file worklist.cpp.

Referenced by city_production_build_units(), 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 
)