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 #757429 ยป 0002-protocol-causes-and-rmcauses-are-bit-vectors.patch

Sveinung Kvilhaugsvik, 2018-06-04 09:34 AM

View differences:

client/packhand.c
names_set(&pextra->name, NULL, p->name, p->rule_name);
pextra->category = p->category;
pextra->causes = p->causes;
pextra->rmcauses = p->rmcauses;
pextra->causes = 0;
for (i = 0; i < EC_COUNT; i++) {
if (BV_ISSET(p->causes, i)) {
pextra->causes |= (1 << i);
}
}
pextra->rmcauses = 0;
for (i = 0; i < ERM_COUNT; i++) {
if (BV_ISSET(p->rmcauses, i)) {
pextra->rmcauses |= (1 << i);
}
}
extra_to_category_list(pextra, pextra->category);
common/fc_types.h
#define SPECENUM_VALUE8 EC_RESOURCE
#define SPECENUM_VALUE8NAME "Resource"
#define SPECENUM_COUNT EC_COUNT
#define SPECENUM_BITVECTOR bv_causes
#include "specenum_gen.h"
#define EC_NONE EC_COUNT
#define EC_SPECIAL (EC_NONE + 1)
......
#define EC_NATURAL_DEFENSIVE (EC_NONE + 3)
#define EC_LAST (EC_NONE + 4)
/* packets.def and struct extra_type reserve 16 bits (0-15) for these. */
/* struct extra_type reserve 16 bits (0-15) for these. */
FC_STATIC_ASSERT(EC_COUNT < 16, extra_causes_over_limit);
/* Used in the network protocol. */
......
#define SPECENUM_VALUE3 ERM_DISAPPEARANCE
#define SPECENUM_VALUE3NAME "Disappear"
#define SPECENUM_COUNT ERM_COUNT
#define SPECENUM_BITVECTOR bv_rmcauses
#include "specenum_gen.h"
#define ERM_NONE ERM_COUNT
/* packets.def and struct extra_type reserve 8 bits (0-7) for these. */
/* struct extra_type reserve 8 bits (0-7) for these. */
FC_STATIC_ASSERT(ERM_COUNT < 8, extra_rmcauses_over_limit);
#define SPECENUM_NAME extra_unit_seen_type
common/networking/packets.def
type BV_BASES = bitvector(bv_bases)
type BV_ROADS = bitvector(bv_roads)
type BV_ROAD_FLAGS = bitvector(bv_road_flags)
type BV_CAUSES = bitvector(bv_causes)
type BV_RMCAUSES = bitvector(bv_rmcauses)
type BV_CITY_OPTIONS = bitvector(bv_city_options)
type BV_IMPR_FLAGS = bitvector(bv_impr_flags)
type BV_IMPRS = bitvector(bv_imprs)
......
STRING name[MAX_LEN_NAME];
STRING rule_name[MAX_LEN_NAME];
UINT8 category;
UINT16 causes;
UINT8 rmcauses;
BV_CAUSES causes;
BV_RMCAUSES rmcauses;
STRING activity_gfx[MAX_LEN_NAME];
STRING act_gfx_alt[MAX_LEN_NAME];
STRING act_gfx_alt2[MAX_LEN_NAME];
server/ruleset.c
sz_strlcpy(packet.rule_name, rule_name_get(&e->name));
packet.category = e->category;
packet.causes = e->causes;
packet.rmcauses = e->rmcauses;
BV_CLR_ALL(packet.causes);
for (j = 0; j < EC_COUNT; j++) {
if (is_extra_caused_by(e, j)) {
BV_SET(packet.causes, j);
}
}
BV_CLR_ALL(packet.rmcauses);
for (j = 0; j < ERM_COUNT; j++) {
if (is_extra_removed_by(e, j)) {
BV_SET(packet.rmcauses, j);
}
}
sz_strlcpy(packet.activity_gfx, e->activity_gfx);
sz_strlcpy(packet.act_gfx_alt, e->act_gfx_alt);
    (1-1/1)