Skip to content

Commit

Permalink
Merge pull request #203 from AsherGlick/filter_empty_filters
Browse files Browse the repository at this point in the history
Preventing multiflag filters from writing empty proto messages
  • Loading branch information
AsherGlick authored Nov 5, 2023
2 parents 26fed52 + 61c6415 commit 125d243
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ void proto_to_{{attribute_name}}({{proto_field_cpp_type}} input, {{class_name}}*

void {{attribute_name}}_to_proto({{class_name}} value, std::function<void({{proto_field_cpp_type}}*)> setter) {
{{proto_field_cpp_type}}* proto_{{attribute_name}} = new {{proto_field_cpp_type}}();
bool should_write = false;
{% for n, attribute_variable in enumerate(attribute_variables)%}
proto_{{attribute_name}}->set_{{attribute_variable.attribute_name}}(value.{{attribute_variable.attribute_name}});
should_write |= value.{{attribute_variable.attribute_name}};
{% endfor %}
setter(proto_{{attribute_name}});
if (should_write) {
setter(proto_{{attribute_name}});
}
}
12 changes: 11 additions & 1 deletion xml_converter/src/attribute/festival_filter_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,22 @@ void proto_to_festival_filter(waypoint::FestivalFilter input, FestivalFilter* va

void festival_filter_to_proto(FestivalFilter value, std::function<void(waypoint::FestivalFilter*)> setter) {
waypoint::FestivalFilter* proto_festival_filter = new waypoint::FestivalFilter();
bool should_write = false;
proto_festival_filter->set_dragonbash(value.dragonbash);
should_write |= value.dragonbash;
proto_festival_filter->set_festival_of_the_four_winds(value.festival_of_the_four_winds);
should_write |= value.festival_of_the_four_winds;
proto_festival_filter->set_halloween(value.halloween);
should_write |= value.halloween;
proto_festival_filter->set_lunar_new_year(value.lunar_new_year);
should_write |= value.lunar_new_year;
proto_festival_filter->set_super_adventure_festival(value.super_adventure_festival);
should_write |= value.super_adventure_festival;
proto_festival_filter->set_wintersday(value.wintersday);
should_write |= value.wintersday;
proto_festival_filter->set_none(value.none);
setter(proto_festival_filter);
should_write |= value.none;
if (should_write) {
setter(proto_festival_filter);
}
}
29 changes: 28 additions & 1 deletion xml_converter/src/attribute/map_type_filter_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,29 +238,56 @@ void proto_to_map_type_filter(waypoint::MapTypeFilter input, MapTypeFilter* valu

void map_type_filter_to_proto(MapTypeFilter value, std::function<void(waypoint::MapTypeFilter*)> setter) {
waypoint::MapTypeFilter* proto_map_type_filter = new waypoint::MapTypeFilter();
bool should_write = false;
proto_map_type_filter->set_unknown_map(value.unknown_map);
should_write |= value.unknown_map;
proto_map_type_filter->set_redirect_map(value.redirect_map);
should_write |= value.redirect_map;
proto_map_type_filter->set_character_create_map(value.character_create_map);
should_write |= value.character_create_map;
proto_map_type_filter->set_pvp_map(value.pvp_map);
should_write |= value.pvp_map;
proto_map_type_filter->set_gvg_map(value.gvg_map);
should_write |= value.gvg_map;
proto_map_type_filter->set_instance_map(value.instance_map);
should_write |= value.instance_map;
proto_map_type_filter->set_public_map(value.public_map);
should_write |= value.public_map;
proto_map_type_filter->set_tournament_map(value.tournament_map);
should_write |= value.tournament_map;
proto_map_type_filter->set_tutorial_map(value.tutorial_map);
should_write |= value.tutorial_map;
proto_map_type_filter->set_user_tournament_map(value.user_tournament_map);
should_write |= value.user_tournament_map;
proto_map_type_filter->set_center_map(value.center_map);
should_write |= value.center_map;
proto_map_type_filter->set_eternal_battlegrounds_map(value.eternal_battlegrounds_map);
should_write |= value.eternal_battlegrounds_map;
proto_map_type_filter->set_bluehome_map(value.bluehome_map);
should_write |= value.bluehome_map;
proto_map_type_filter->set_blue_borderlands_map(value.blue_borderlands_map);
should_write |= value.blue_borderlands_map;
proto_map_type_filter->set_green_home_map(value.green_home_map);
should_write |= value.green_home_map;
proto_map_type_filter->set_green_borderlands_map(value.green_borderlands_map);
should_write |= value.green_borderlands_map;
proto_map_type_filter->set_red_home_map(value.red_home_map);
should_write |= value.red_home_map;
proto_map_type_filter->set_red_borderlands_map(value.red_borderlands_map);
should_write |= value.red_borderlands_map;
proto_map_type_filter->set_fortunes_vale_map(value.fortunes_vale_map);
should_write |= value.fortunes_vale_map;
proto_map_type_filter->set_jump_puzzle_map(value.jump_puzzle_map);
should_write |= value.jump_puzzle_map;
proto_map_type_filter->set_obsidian_sanctum_map(value.obsidian_sanctum_map);
should_write |= value.obsidian_sanctum_map;
proto_map_type_filter->set_edge_of_the_mists_map(value.edge_of_the_mists_map);
should_write |= value.edge_of_the_mists_map;
proto_map_type_filter->set_public_mini_map(value.public_mini_map);
should_write |= value.public_mini_map;
proto_map_type_filter->set_wvw_lounge_map(value.wvw_lounge_map);
setter(proto_map_type_filter);
should_write |= value.wvw_lounge_map;
if (should_write) {
setter(proto_map_type_filter);
}
}
15 changes: 14 additions & 1 deletion xml_converter/src/attribute/mount_filter_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,28 @@ void proto_to_mount_filter(waypoint::MountFilter input, MountFilter* value, bool

void mount_filter_to_proto(MountFilter value, std::function<void(waypoint::MountFilter*)> setter) {
waypoint::MountFilter* proto_mount_filter = new waypoint::MountFilter();
bool should_write = false;
proto_mount_filter->set_raptor(value.raptor);
should_write |= value.raptor;
proto_mount_filter->set_springer(value.springer);
should_write |= value.springer;
proto_mount_filter->set_skimmer(value.skimmer);
should_write |= value.skimmer;
proto_mount_filter->set_jackal(value.jackal);
should_write |= value.jackal;
proto_mount_filter->set_griffon(value.griffon);
should_write |= value.griffon;
proto_mount_filter->set_roller_beetle(value.roller_beetle);
should_write |= value.roller_beetle;
proto_mount_filter->set_warclaw(value.warclaw);
should_write |= value.warclaw;
proto_mount_filter->set_skyscale(value.skyscale);
should_write |= value.skyscale;
proto_mount_filter->set_skiff(value.skiff);
should_write |= value.skiff;
proto_mount_filter->set_seige_turtle(value.seige_turtle);
setter(proto_mount_filter);
should_write |= value.seige_turtle;
if (should_write) {
setter(proto_mount_filter);
}
}
14 changes: 13 additions & 1 deletion xml_converter/src/attribute/profession_filter_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,26 @@ void proto_to_profession_filter(waypoint::ProfessionFilter input, ProfessionFilt

void profession_filter_to_proto(ProfessionFilter value, std::function<void(waypoint::ProfessionFilter*)> setter) {
waypoint::ProfessionFilter* proto_profession_filter = new waypoint::ProfessionFilter();
bool should_write = false;
proto_profession_filter->set_guardian(value.guardian);
should_write |= value.guardian;
proto_profession_filter->set_warrior(value.warrior);
should_write |= value.warrior;
proto_profession_filter->set_engineer(value.engineer);
should_write |= value.engineer;
proto_profession_filter->set_ranger(value.ranger);
should_write |= value.ranger;
proto_profession_filter->set_thief(value.thief);
should_write |= value.thief;
proto_profession_filter->set_elementalist(value.elementalist);
should_write |= value.elementalist;
proto_profession_filter->set_mesmer(value.mesmer);
should_write |= value.mesmer;
proto_profession_filter->set_necromancer(value.necromancer);
should_write |= value.necromancer;
proto_profession_filter->set_revenant(value.revenant);
setter(proto_profession_filter);
should_write |= value.revenant;
if (should_write) {
setter(proto_profession_filter);
}
}
77 changes: 76 additions & 1 deletion xml_converter/src/attribute/specialization_filter_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,77 +703,152 @@ void proto_to_specialization_filter(waypoint::SpecializationFilter input, Specia

void specialization_filter_to_proto(SpecializationFilter value, std::function<void(waypoint::SpecializationFilter*)> setter) {
waypoint::SpecializationFilter* proto_specialization_filter = new waypoint::SpecializationFilter();
bool should_write = false;
proto_specialization_filter->set_elementalist_tempest(value.elementalist_tempest);
should_write |= value.elementalist_tempest;
proto_specialization_filter->set_engineer_scrapper(value.engineer_scrapper);
should_write |= value.engineer_scrapper;
proto_specialization_filter->set_guardian_dragonhunter(value.guardian_dragonhunter);
should_write |= value.guardian_dragonhunter;
proto_specialization_filter->set_mesmer_chronomancer(value.mesmer_chronomancer);
should_write |= value.mesmer_chronomancer;
proto_specialization_filter->set_necromancer_reaper(value.necromancer_reaper);
should_write |= value.necromancer_reaper;
proto_specialization_filter->set_ranger_druid(value.ranger_druid);
should_write |= value.ranger_druid;
proto_specialization_filter->set_revenant_herald(value.revenant_herald);
should_write |= value.revenant_herald;
proto_specialization_filter->set_thief_daredevil(value.thief_daredevil);
should_write |= value.thief_daredevil;
proto_specialization_filter->set_warrior_berserker(value.warrior_berserker);
should_write |= value.warrior_berserker;
proto_specialization_filter->set_elementalist_weaver(value.elementalist_weaver);
should_write |= value.elementalist_weaver;
proto_specialization_filter->set_engineer_holosmith(value.engineer_holosmith);
should_write |= value.engineer_holosmith;
proto_specialization_filter->set_guardian_firebrand(value.guardian_firebrand);
should_write |= value.guardian_firebrand;
proto_specialization_filter->set_mesmer_mirage(value.mesmer_mirage);
should_write |= value.mesmer_mirage;
proto_specialization_filter->set_necromancer_scourge(value.necromancer_scourge);
should_write |= value.necromancer_scourge;
proto_specialization_filter->set_ranger_soulbeast(value.ranger_soulbeast);
should_write |= value.ranger_soulbeast;
proto_specialization_filter->set_revenant_renegade(value.revenant_renegade);
should_write |= value.revenant_renegade;
proto_specialization_filter->set_thief_deadeye(value.thief_deadeye);
should_write |= value.thief_deadeye;
proto_specialization_filter->set_warrior_spellbreaker(value.warrior_spellbreaker);
should_write |= value.warrior_spellbreaker;
proto_specialization_filter->set_elementalist_catalyst(value.elementalist_catalyst);
should_write |= value.elementalist_catalyst;
proto_specialization_filter->set_engineer_mechanist(value.engineer_mechanist);
should_write |= value.engineer_mechanist;
proto_specialization_filter->set_guardian_willbender(value.guardian_willbender);
should_write |= value.guardian_willbender;
proto_specialization_filter->set_mesmer_virtuoso(value.mesmer_virtuoso);
should_write |= value.mesmer_virtuoso;
proto_specialization_filter->set_necromancer_harbinger(value.necromancer_harbinger);
should_write |= value.necromancer_harbinger;
proto_specialization_filter->set_ranger_untamed(value.ranger_untamed);
should_write |= value.ranger_untamed;
proto_specialization_filter->set_revenant_vindicator(value.revenant_vindicator);
should_write |= value.revenant_vindicator;
proto_specialization_filter->set_thief_specter(value.thief_specter);
should_write |= value.thief_specter;
proto_specialization_filter->set_warrior_bladesworn(value.warrior_bladesworn);
should_write |= value.warrior_bladesworn;
proto_specialization_filter->set_elementalist_air(value.elementalist_air);
should_write |= value.elementalist_air;
proto_specialization_filter->set_elementalist_arcane(value.elementalist_arcane);
should_write |= value.elementalist_arcane;
proto_specialization_filter->set_elementalist_earth(value.elementalist_earth);
should_write |= value.elementalist_earth;
proto_specialization_filter->set_elementalist_fire(value.elementalist_fire);
should_write |= value.elementalist_fire;
proto_specialization_filter->set_elementalist_water(value.elementalist_water);
should_write |= value.elementalist_water;
proto_specialization_filter->set_engineer_alchemy(value.engineer_alchemy);
should_write |= value.engineer_alchemy;
proto_specialization_filter->set_engineer_explosives(value.engineer_explosives);
should_write |= value.engineer_explosives;
proto_specialization_filter->set_engineer_firearms(value.engineer_firearms);
should_write |= value.engineer_firearms;
proto_specialization_filter->set_engineer_inventions(value.engineer_inventions);
should_write |= value.engineer_inventions;
proto_specialization_filter->set_engineer_tools(value.engineer_tools);
should_write |= value.engineer_tools;
proto_specialization_filter->set_guardian_honor(value.guardian_honor);
should_write |= value.guardian_honor;
proto_specialization_filter->set_guardian_radiance(value.guardian_radiance);
should_write |= value.guardian_radiance;
proto_specialization_filter->set_guardian_valor(value.guardian_valor);
should_write |= value.guardian_valor;
proto_specialization_filter->set_guardian_virtues(value.guardian_virtues);
should_write |= value.guardian_virtues;
proto_specialization_filter->set_guardian_zeal(value.guardian_zeal);
should_write |= value.guardian_zeal;
proto_specialization_filter->set_mesmer_chaos(value.mesmer_chaos);
should_write |= value.mesmer_chaos;
proto_specialization_filter->set_mesmer_domination(value.mesmer_domination);
should_write |= value.mesmer_domination;
proto_specialization_filter->set_mesmer_dueling(value.mesmer_dueling);
should_write |= value.mesmer_dueling;
proto_specialization_filter->set_mesmer_illusions(value.mesmer_illusions);
should_write |= value.mesmer_illusions;
proto_specialization_filter->set_mesmer_inspiration(value.mesmer_inspiration);
should_write |= value.mesmer_inspiration;
proto_specialization_filter->set_necromancer_blood_magic(value.necromancer_blood_magic);
should_write |= value.necromancer_blood_magic;
proto_specialization_filter->set_necromancer_curses(value.necromancer_curses);
should_write |= value.necromancer_curses;
proto_specialization_filter->set_necromancer_death_magic(value.necromancer_death_magic);
should_write |= value.necromancer_death_magic;
proto_specialization_filter->set_necromancer_soul_reaping(value.necromancer_soul_reaping);
should_write |= value.necromancer_soul_reaping;
proto_specialization_filter->set_necromancer_spite(value.necromancer_spite);
should_write |= value.necromancer_spite;
proto_specialization_filter->set_ranger_beastmastery(value.ranger_beastmastery);
should_write |= value.ranger_beastmastery;
proto_specialization_filter->set_ranger_marksmanship(value.ranger_marksmanship);
should_write |= value.ranger_marksmanship;
proto_specialization_filter->set_ranger_nature_magic(value.ranger_nature_magic);
should_write |= value.ranger_nature_magic;
proto_specialization_filter->set_ranger_skirmishing(value.ranger_skirmishing);
should_write |= value.ranger_skirmishing;
proto_specialization_filter->set_ranger_wilderness_survival(value.ranger_wilderness_survival);
should_write |= value.ranger_wilderness_survival;
proto_specialization_filter->set_revenant_corruption(value.revenant_corruption);
should_write |= value.revenant_corruption;
proto_specialization_filter->set_revenant_devastation(value.revenant_devastation);
should_write |= value.revenant_devastation;
proto_specialization_filter->set_revenant_invocation(value.revenant_invocation);
should_write |= value.revenant_invocation;
proto_specialization_filter->set_revenant_retribution(value.revenant_retribution);
should_write |= value.revenant_retribution;
proto_specialization_filter->set_revenant_salvation(value.revenant_salvation);
should_write |= value.revenant_salvation;
proto_specialization_filter->set_thief_acrobatics(value.thief_acrobatics);
should_write |= value.thief_acrobatics;
proto_specialization_filter->set_thief_critical_strikes(value.thief_critical_strikes);
should_write |= value.thief_critical_strikes;
proto_specialization_filter->set_thief_deadly_arts(value.thief_deadly_arts);
should_write |= value.thief_deadly_arts;
proto_specialization_filter->set_thief_shadow_arts(value.thief_shadow_arts);
should_write |= value.thief_shadow_arts;
proto_specialization_filter->set_thief_trickery(value.thief_trickery);
should_write |= value.thief_trickery;
proto_specialization_filter->set_warrior_arms(value.warrior_arms);
should_write |= value.warrior_arms;
proto_specialization_filter->set_warrior_defense(value.warrior_defense);
should_write |= value.warrior_defense;
proto_specialization_filter->set_warrior_discipline(value.warrior_discipline);
should_write |= value.warrior_discipline;
proto_specialization_filter->set_warrior_strength(value.warrior_strength);
should_write |= value.warrior_strength;
proto_specialization_filter->set_warrior_tactics(value.warrior_tactics);
setter(proto_specialization_filter);
should_write |= value.warrior_tactics;
if (should_write) {
setter(proto_specialization_filter);
}
}
10 changes: 9 additions & 1 deletion xml_converter/src/attribute/species_filter_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,18 @@ void proto_to_species_filter(waypoint::SpeciesFilter input, SpeciesFilter* value

void species_filter_to_proto(SpeciesFilter value, std::function<void(waypoint::SpeciesFilter*)> setter) {
waypoint::SpeciesFilter* proto_species_filter = new waypoint::SpeciesFilter();
bool should_write = false;
proto_species_filter->set_asura(value.asura);
should_write |= value.asura;
proto_species_filter->set_charr(value.charr);
should_write |= value.charr;
proto_species_filter->set_human(value.human);
should_write |= value.human;
proto_species_filter->set_norn(value.norn);
should_write |= value.norn;
proto_species_filter->set_sylvari(value.sylvari);
setter(proto_species_filter);
should_write |= value.sylvari;
if (should_write) {
setter(proto_species_filter);
}
}

0 comments on commit 125d243

Please sign in to comment.