Feature #1294 ยป 0038-cm.c-Replace-NULL-with-nullptr.patch
| common/aicore/cm.c | ||
|---|---|---|
|
{
|
||
|
struct cm_result *result;
|
||
|
/* initialise all values */
|
||
|
/* Initialise all values */
|
||
|
result = fc_calloc(1, sizeof(*result));
|
||
|
result->city_radius_sq = pcity ? city_map_radius_sq_get(pcity)
|
||
|
: CITY_MAP_MAX_RADIUS_SQ;
|
||
| ... | ... | |
|
= fc_calloc(city_map_tiles(result->city_radius_sq),
|
||
|
sizeof(*result->worker_positions));
|
||
|
/* test if the city pointer is valid; the cm_result struct can be
|
||
|
/* Test if the city pointer is valid; the cm_result struct can be
|
||
|
* returned as it uses the maximal possible value for the size of
|
||
|
* 'worker_positions' (= city_map_tiles(CITY_MAP_MAX_RADIUS_SQ))*/
|
||
|
fc_assert_ret_val(pcity != NULL, result);
|
||
|
fc_assert_ret_val(pcity != nullptr, result);
|
||
|
return result;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
void cm_result_destroy(struct cm_result *result)
|
||
|
{
|
||
|
if (result != NULL) {
|
||
|
if (result->worker_positions != NULL) {
|
||
|
if (result != nullptr) {
|
||
|
if (result->worker_positions != nullptr) {
|
||
|
FC_FREE(result->worker_positions);
|
||
|
}
|
||
|
FC_FREE(result);
|
||
| ... | ... | |
|
int type)
|
||
|
{
|
||
|
/* Sanity check the index. */
|
||
|
fc_assert_ret_val(0 <= type, NULL);
|
||
|
fc_assert_ret_val(state->lattice.size > type, NULL);
|
||
|
fc_assert_ret_val(0 <= type, nullptr);
|
||
|
fc_assert_ret_val(state->lattice.size > type, nullptr);
|
||
|
return state->lattice.p[type];
|
||
|
}
|
||
| ... | ... | |
|
Retrieve a tile of a particular type by index. For a given tile type
|
||
|
there are a certain number of tiles (1 or more), which may be iterated
|
||
|
over using this function for index. Don't call this for is_specialist
|
||
|
types. See also tile_type_num_tiles().
|
||
|
types.
|
||
|
See also tile_type_num_tiles().
|
||
|
****************************************************************************/
|
||
|
static const struct cm_tile *tile_get(const struct cm_tile_type *ptype, int j)
|
||
|
{
|
||
|
fc_assert_ret_val(!ptype->is_specialist, NULL);
|
||
|
fc_assert_ret_val(0 <= j, NULL);
|
||
|
fc_assert_ret_val(j < ptype->tiles.size, NULL);
|
||
|
fc_assert_ret_val(!ptype->is_specialist, nullptr);
|
||
|
fc_assert_ret_val(0 <= j, nullptr);
|
||
|
fc_assert_ret_val(j < ptype->tiles.size, nullptr);
|
||
|
return &ptype->tiles.p[j];
|
||
|
}
|
||
| ... | ... | |
|
print_performance(performance.current);
|
||
|
#endif /* PRINT_TIME_STATS_EVERY_QUERY */
|
||
|
performance.current = NULL;
|
||
|
performance.current = nullptr;
|
||
|
#endif /* GATHER_TIME_STATS */
|
||
|
}
|
||
| ... | ... | |
|
/* Refresh the city. Otherwise the CM can give wrong results or just be
|
||
|
* slower than necessary. Note that cities are often passed in in an
|
||
|
* unrefreshed state (which should probably be fixed). */
|
||
|
city_refresh_from_main_map(nmap, pcity, NULL);
|
||
|
city_refresh_from_main_map(nmap, pcity, nullptr);
|
||
|
cm_find_best_solution(state, param, result, negative_ok);
|
||
|
cm_state_free(state);
|
||
| ... | ... | |
|
void cm_result_from_main_map(struct cm_result *result,
|
||
|
const struct city *pcity)
|
||
|
{
|
||
|
cm_result_copy(result, pcity, NULL);
|
||
|
cm_result_copy(result, pcity, nullptr);
|
||
|
}
|
||
|
/************************************************************************//**
|
||
| ... | ... | |
|
* city_map_tiles(result->city_radius_sq));
|
||
|
city_tile_iterate_index(nmap, result->city_radius_sq, pcenter, ptile, ctindex) {
|
||
|
if (workers_map == NULL) {
|
||
|
if (workers_map == nullptr) {
|
||
|
/* Use the main map */
|
||
|
struct city *pwork = tile_worked(ptile);
|
||
|
result->worker_positions[ctindex] = (NULL != pwork && pwork == pcity);
|
||
|
result->worker_positions[ctindex] = (pwork != nullptr && pwork == pcity);
|
||
|
} else {
|
||
|
result->worker_positions[ctindex] = workers_map[ctindex];
|
||
|
}
|
||
| ... | ... | |
|
cindex) {
|
||
|
struct city *pwork = tile_worked(ptile);
|
||
|
if (NULL != pwork && pwork == pcity) {
|
||
|
if (pwork != nullptr && pwork == pcity) {
|
||
|
int cx, cy;
|
||
|
city_tile_index_to_xy(&cx, &cy, cindex,
|
||