/************************************************************************** Log message for bodyguards. They will appear like this 2: Polish Mech. Inf.[485] bodyguard (38,22){Riflemen:574@37,23} was ... note that these messages are likely to wrap if long. **************************************************************************/ void BODYGUARD_LOG(int level, const struct unit *punit, const char *msg) { char buffer[500]; int minlevel = MIN(LOGLEVEL_BODYGUARD, level); const struct unit *pcharge; const struct city *pcity; int id = -1; int charge_x = -1; int charge_y = -1; const char *type = "guard"; const char *s = "none"; if (punit->debug) { minlevel = LOG_TEST; } else if (minlevel > fc_log_level) { return; } pcity = game_find_city_by_number(punit->ai.charge); pcharge = game_find_unit_by_number(punit->ai.charge); if (pcharge) { charge_x = pcharge->tile->x; charge_y = pcharge->tile->y; id = pcharge->id; type = "bodyguard"; s = unit_rule_name(pcharge); } else if (pcity) { charge_x = pcity->tile->x; charge_y = pcity->tile->y; id = pcity->id; type = "cityguard"; s = city_name(pcity); } /* else perhaps the charge died */ my_snprintf(buffer, sizeof(buffer), "%s %s[%d] %s (%d,%d){%s:%d@%d,%d} ", nation_rule_name(nation_of_unit(punit)), unit_rule_name(punit), punit->id, type, TILE_XY(punit->tile), s, id, charge_x, charge_y); cat_snprintf(buffer, sizeof(buffer), "%s", msg); if (punit->debug) { notify_conn(NULL, NULL, E_AI_DEBUG, ftc_log, "%s", buffer); } freelog(minlevel, "%s", buffer); }
/**************************************************************** Fills the buf with proper text which should be displayed on the helpbuild wonder button. *****************************************************************/ static void get_help_build_wonder_button_label(char* buf, int bufsize, bool* help_build_possible) { struct city* destcity = game_find_city_by_number(caravan_city_id); struct unit* caravan = game_find_unit_by_number(caravan_unit_id); if (destcity && caravan && unit_can_help_build_wonder(caravan, destcity)) { my_snprintf(buf, bufsize, _("Help build _Wonder (%d remaining)"), impr_build_shield_cost(destcity->production.value.building) - destcity->shield_stock); *help_build_possible = TRUE; } else { my_snprintf(buf, bufsize, _("Help build _Wonder")); *help_build_possible = FALSE; } }
/************************************************************************** Update city dialogs when the given unit's status changes. This typically means updating both the unit's home city (if any) and the city in which it is present (if any). **************************************************************************/ void refresh_unit_city_dialogs(struct unit *punit) { freelog(LOG_VERBOSE, "Port Me %s [@%s:%d]", __func__, __FILE__, __LINE__); #if 0 /* Demo code */ struct city *pcity_sup, *pcity_pre; struct city_dialog *pdialog; pcity_sup = game_find_city_by_number(punit->homecity); pcity_pre = tile_city(punit->tile); if (pcity_sup && (pdialog = get_city_dialog(pcity_sup))) { city_dialog_update_supported_units(pdialog); } if (pcity_pre && (pdialog = get_city_dialog(pcity_pre))) { city_dialog_update_present_units(pdialog); } #endif }