Project

General

Profile

Feature #1573 ยป 0074-Send-tiledefs-to-client.patch

Marko Lindqvist, 07/06/2025 12:01 AM

View differences:

client/packhand.c
#include "spaceship.h"
#include "specialist.h"
#include "style.h"
#include "tiledef.h"
#include "traderoutes.h"
#include "unit.h"
#include "unitlist.h"
......
proad->flags = p->flags;
}
/************************************************************************//**
Handle a packet about a particular tiledef type.
****************************************************************************/
void handle_ruleset_tiledef(const struct packet_ruleset_tiledef *p)
{
struct tiledef *td = tiledef_by_number(p->id);
fc_assert_ret_msg(td != nullptr, "Bad tiledef %d.", p->id);
names_set(&td->name, nullptr, p->name, p->rule_name);
extra_type_iterate(pextra) {
if (BV_ISSET(p->extras, extra_index(pextra))) {
extra_type_list_append(td->extras, pextra);
}
} extra_type_iterate_end;
}
/************************************************************************//**
Handle a packet about a particular goods type.
****************************************************************************/
common/networking/packets.def
Max used id:
============
Max id: 519
Max id: 520
Packets are not ordered by their id, but by their category. New packet
with higher id may get added to existing category, and not to the end of file.
......
REQUIREMENT giver_reqs[*], receiver_reqs[*], either_reqs[*];
end
PACKET_RULESET_TILEDEF = 520; sc, lsend
UINT8 id;
STRING name[MAX_LEN_NAME];
STRING rule_name[MAX_LEN_NAME];
BV_EXTRAS extras;
end
/**************************************************************************
Ruleset control values: single values, all of which are needed before
sending other ruleset data. After sending this packet, resend every
server/ruleset/ruleload.c
static void send_ruleset_extras(struct conn_list *dest);
static void send_ruleset_bases(struct conn_list *dest);
static void send_ruleset_roads(struct conn_list *dest);
static void send_ruleset_tiledefs(struct conn_list *dest);
static void send_ruleset_goods(struct conn_list *dest);
static void send_ruleset_governments(struct conn_list *dest);
static void send_ruleset_styles(struct conn_list *dest);
......
} extra_type_by_cause_iterate_end;
}
/**********************************************************************//**
Send the tiledefs ruleset information (all individual tiledef types)
to the specified connections.
**************************************************************************/
static void send_ruleset_tiledefs(struct conn_list *dest)
{
struct packet_ruleset_tiledef packet;
tiledef_iterate(td) {
bv_extras extras;
packet.id = tiledef_number(td);
sz_strlcpy(packet.name, untranslated_name(&td->name));
sz_strlcpy(packet.rule_name, rule_name_get(&td->name));
BV_CLR_ALL(extras);
extra_type_list_iterate(td->extras, pextra) {
BV_SET(extras, extra_index(pextra));
} extra_type_list_iterate_end;
packet.extras = extras;
lsend_packet_ruleset_tiledef(dest, &packet);
} tiledef_iterate_end;
}
/**********************************************************************//**
Send the goods ruleset information (all individual goods types) to the
specified connections.
......
send_ruleset_roads(dest);
send_ruleset_resources(dest);
send_ruleset_terrain(dest);
send_ruleset_tiledefs(dest);
send_ruleset_goods(dest);
send_ruleset_buildings(dest);
send_ruleset_styles(dest);
    (1-1/1)