Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #751250 ยป 0001-Freeciv-web-send-expected-income-to-the-player.patch

Sveinung Kvilhaugsvik, 2018-05-04 07:45 PM

View differences:

client/packhand.c
}
/************************************************************************//**
This is a packet that only the web-client needs. The regular client has no
use for it.
TODO: Do not generate code calling this in the C-client.
****************************************************************************/
void handle_web_player_info_addition(int playerno, int expected_income)
{
}
/************************************************************************//**
Receive a research info packet.
****************************************************************************/
void handle_research_info(const struct packet_research_info *packet)
common/networking/packets.def
TURN granary_turns;
UINT16 buy_gold_cost;
end
PACKET_WEB_PLAYER_INFO_ADDITION = 257; sc, is-info
PLAYER playerno; key
UINT32 expected_income;
end
server/plrhand.c
struct rgbcolor;
static void package_player_common(struct player *plr,
struct packet_player_info *packet);
struct packet_player_info *packet,
struct packet_web_player_info_addition *
web_packet);
static void package_player_diplstate(struct player *plr1,
struct player *plr2,
......
enum plr_info_level min_info_level);
static void package_player_info(struct player *plr,
struct packet_player_info *packet,
struct packet_web_player_info_addition *
web_packet,
struct player *receiver,
enum plr_info_level min_info_level);
static enum plr_info_level player_info_level(struct player *plr,
......
struct conn_list *dest)
{
struct packet_player_info info;
struct packet_web_player_info_addition web_info;
fc_assert_ret(src != NULL);
......
dest = game.est_connections;
}
package_player_common(src, &info);
package_player_common(src, &info, &web_info);
conn_list_iterate(dest, pconn) {
if (NULL == pconn->playing && pconn->observer) {
/* Global observer. */
package_player_info(src, &info, pconn->playing, INFO_FULL);
package_player_info(src, &info, &web_info, pconn->playing, INFO_FULL);
} else if (NULL != pconn->playing) {
/* Players (including regular observers) */
package_player_info(src, &info, pconn->playing, INFO_MINIMUM);
package_player_info(src, &info, &web_info,
pconn->playing, INFO_MINIMUM);
} else {
package_player_info(src, &info, NULL, INFO_MINIMUM);
package_player_info(src, &info, &web_info, NULL, INFO_MINIMUM);
}
send_packet_player_info(pconn, &info);
web_send_packet(player_info_addition, pconn, &web_info);
} conn_list_iterate_end;
}
......
Package player information that is always sent.
**************************************************************************/
static void package_player_common(struct player *plr,
struct packet_player_info *packet)
struct packet_player_info *packet,
struct packet_web_player_info_addition *
web_packet)
{
int i;
struct music_style *music;
......
packet->wonders[i] = plr->wonders[i];
}
packet->science_cost = plr->ai_common.science_cost;
#ifdef FREECIV_WEB
web_packet->playerno = player_number(plr);
#endif /* FREECIV_WEB */
}
/**********************************************************************//**
......
**************************************************************************/
static void package_player_info(struct player *plr,
struct packet_player_info *packet,
struct packet_web_player_info_addition *
web_packet,
struct player *receiver,
enum plr_info_level min_info_level)
{
......
} else {
packet->culture = 0;
}
#ifdef FREECIV_WEB
if (info_level >= INFO_FULL) {
web_packet->expected_income = player_get_expected_income(plr);
} else {
web_packet->expected_income = 0;
}
#endif /* FREECIV_WEB */
}
/**********************************************************************//**
    (1-1/1)