42 iworld->
cities =
new QHash<int, const struct city *>;
43 iworld->
units =
new QHash<int, const struct unit *>;
54 iworld->
units =
nullptr;
63 const struct city *old;
65 if (iworld->
cities->contains(pcity->
id)) {
66 old = iworld->
cities->value(pcity->
id);
68 "IDEX: city collision: new %d %p %s, old %d %p %s",
72 iworld->
cities->insert(pcity->
id, pcity);
81 const struct unit *old;
83 if (iworld->
units->contains(punit->
id)) {
84 old = iworld->
units->value(punit->
id);
86 "IDEX: unit collision: new %d %p %s, old %d %p %s",
90 iworld->
units->insert(punit->
id, punit);
99 const struct city *old;
101 if (!iworld->
units->contains(pcity->
id)) {
106 "IDEX: city unreg mismatch: "
107 "unreg %d %p %s, old %d %p %s",
120 const struct unit *old;
122 if (!iworld->
units->contains(punit->
id)) {
127 "IDEX: unit unreg mismatch: "
128 "unreg %d %p %s, old %d %p %s",
132 iworld->
units->remove(punit->
id);
141 const struct city *pcity;
143 pcity = iworld->
cities->value(
id);
145 return const_cast<struct
city *
>(pcity);
154 const struct unit *punit;
156 punit = iworld->
units->value(
id);
158 return const_cast<struct
unit *
>(punit);
const char * city_name_get(const struct city *pcity)
Return the name of the city.
void idex_free(struct world *iworld)
Free the hashs.
void idex_register_unit(struct world *iworld, struct unit *punit)
Register a unit into idex, with current punit->id.
struct unit * idex_lookup_unit(struct world *iworld, int id)
Lookup unit with given id.
void idex_unregister_city(struct world *iworld, struct city *pcity)
Remove a city from idex, with current pcity->id.
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 poin...
struct city * idex_lookup_city(struct world *iworld, int id)
Lookup city with given id.
void idex_unregister_unit(struct world *iworld, struct unit *punit)
Remove a unit from idex, with current punit->id.
void idex_register_city(struct world *iworld, struct city *pcity)
Register a city into idex, with current pcity->id.
#define fc_assert_ret_msg(condition, message,...)
QHash< int, const struct city * > * cities
QHash< int, const struct unit * > * units
const char * unit_rule_name(const struct unit *punit)
Return the (untranslated) rule name of the unit.