void player_domestic_trade(gint player_num, gint partner_num, gint * supply, gint * receive) { gchar *supply_desc; gchar *receive_desc; gint diff; gint idx; diff = resource_count(receive) - resource_count(supply); player_modify_statistic(player_num, STAT_RESOURCES, -diff); player_modify_statistic(partner_num, STAT_RESOURCES, diff); if (player_num == my_player_num()) { for (idx = 0; idx < NO_RESOURCE; idx++) { resource_modify(idx, supply[idx]); resource_modify(idx, -receive[idx]); } } else if (partner_num == my_player_num()) { for (idx = 0; idx < NO_RESOURCE; idx++) { resource_modify(idx, -supply[idx]); resource_modify(idx, receive[idx]); } } if (!resource_count(supply)) { if (!resource_count(receive)) { log_message(MSG_TRADE, _("%s gave %s nothing!?\n"), player_name(player_num, TRUE), player_name(partner_num, FALSE)); } else { receive_desc = resource_format_num(receive); log_message(MSG_TRADE, _("%s gave %s %s for free.\n"), player_name(player_num, TRUE), player_name(partner_num, FALSE), receive_desc); g_free(receive_desc); } } else if (!resource_count(receive)) { supply_desc = resource_format_num(supply); log_message(MSG_TRADE, _("%s gave %s %s for free.\n"), player_name(partner_num, TRUE), player_name(player_num, FALSE), supply_desc); g_free(supply_desc); } else { supply_desc = resource_format_num(supply); receive_desc = resource_format_num(receive); log_message(MSG_TRADE, _("%s gave %s %s in exchange for %s.\n"), player_name(player_num, TRUE), player_name(partner_num, FALSE), receive_desc, supply_desc); g_free(supply_desc); g_free(receive_desc); } }
gboolean can_submit_quote(void) { gint want_quote[NO_RESOURCE]; gint give_quote[NO_RESOURCE]; resource_table_get_amount(RESOURCETABLE(want_table), want_quote); resource_table_get_amount(RESOURCETABLE(give_table), give_quote); if (resource_count(want_quote) == 0 && resource_count(give_quote) == 0) return FALSE; return !quote_view_trade_exists(QUOTEVIEW(quoteview), give_quote, want_quote) && !player_is_viewer(my_player_num()); }