![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "world_object.h"
Include dependency graph for idex.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Functions | |
| void | idex_init (struct world *iworld) |
| idex = ident index: a lookup table for quick mapping of unit and city id values to unit and city pointers. More... | |
| void | idex_free (struct world *iworld) |
| Free the hashs. More... | |
| void | idex_register_city (struct world *iworld, struct city *pcity) |
| Register a city into idex, with current pcity->id. More... | |
| void | idex_register_unit (struct world *iworld, struct unit *punit) |
| Register a unit into idex, with current punit->id. More... | |
| void | idex_unregister_city (struct world *iworld, struct city *pcity) |
| Remove a city from idex, with current pcity->id. More... | |
| void | idex_unregister_unit (struct world *iworld, struct unit *punit) |
| Remove a unit from idex, with current punit->id. More... | |
| struct city * | idex_lookup_city (struct world *iworld, int id) |
| Lookup city with given id. More... | |
| struct unit * | idex_lookup_unit (struct world *iworld, int id) |
| Lookup unit with given id. More... | |
| void idex_free | ( | struct world * | iworld | ) |
Free the hashs.
Definition at line 49 of file idex.cpp.
Referenced by game_free(), game_reset(), and texai_world_close().
| void idex_init | ( | struct world * | iworld | ) |
idex = ident index: a lookup table for quick mapping of unit and city id values to unit and city pointers.
Method: use separate hash tables for each type. Means code duplication for city/unit cases, but simplicity advantages. Don't have to manage memory at all: store pointers to unit and city structs allocated elsewhere, and keys are pointers to id values inside the structs.
Note id values should probably be unsigned int: here leave as plain int so can use pointers to pcity->id etc. Initialize. Should call this at the start before use.
Definition at line 40 of file idex.cpp.
Referenced by game_init(), game_reset(), and texai_world_init().
Lookup city with given id.
Returns nullptr if the city is not registered (which is not an error).
Definition at line 139 of file idex.cpp.
Referenced by api_find_city(), game_city_by_number(), player_city_by_number(), texai_city_destruction_recv(), texai_city_info_recv(), and texai_map_city().
Lookup unit with given id.
Returns nullptr if the unit is not registered (which is not an error).
Definition at line 152 of file idex.cpp.
Referenced by api_find_unit(), game_unit_by_number(), player_unit_by_number(), texai_unit_destruction_recv(), texai_unit_info_recv(), and texai_unit_moved_recv().
Register a city into idex, with current pcity->id.
Call this when pcity created.
Definition at line 61 of file idex.cpp.
Referenced by create_city(), handle_city_info(), handle_city_short_info(), handle_tile_info(), sg_load_player_cities(), and texai_city_info_recv().
Register a unit into idex, with current punit->id.
Call this when punit created.
Definition at line 79 of file idex.cpp.
Referenced by create_unit_full(), handle_unit_packet_common(), sg_load_player_units(), and texai_unit_info_recv().
Remove a city from idex, with current pcity->id.
Call this when pcity deleted.
Definition at line 97 of file idex.cpp.
Referenced by game_remove_city(), packhand_free(), and texai_city_destruction_recv().
Remove a unit from idex, with current punit->id.
Call this when punit deleted.
Definition at line 118 of file idex.cpp.
Referenced by game_remove_unit(), and texai_unit_destruction_recv().