15 #include "messages_generated.h" 23 return [&builder](
const std::pair<int32_t, std::vector<Action>>& actionPair) {
24 auto packAction = [&builder](
const Action& action) {
25 auto actionsOffset = builder.CreateVector(action.action);
26 builder.Finish(actionsOffset);
28 fbs::ActionBuilder fbsActionBuilder(builder);
29 fbsActionBuilder.add_action(actionsOffset);
30 fbsActionBuilder.add_uid(action.uid);
31 fbsActionBuilder.add_aid(action.aid);
32 auto output = fbsActionBuilder.Finish();
33 builder.Finish(output);
37 std::vector<flatbuffers::Offset<fbs::Action>> fbsActions(actionPair.second.size());
38 std::transform(actionPair.second.begin(), actionPair.second.end(), fbsActions.begin(), packAction);
40 auto actionOffsets = builder.CreateVector(fbsActions);
41 builder.Finish(actionOffsets);
43 fbs::ActionsOfPlayerBuilder fbsActionsOfPlayerBuilder(builder);
44 fbsActionsOfPlayerBuilder.add_playerId(actionPair.first);
45 fbsActionsOfPlayerBuilder.add_actions(actionOffsets);
46 auto output = fbsActionsOfPlayerBuilder.Finish();
47 builder.Finish(output);
53 return [&builder](
const std::pair<int32_t, Resources>& resourcesPair) {
54 auto resources = resourcesPair.second;
55 fbs::ResourcesBuilder fbsResourcesBuilder(builder);
56 fbsResourcesBuilder.add_ore(resources.ore);
57 fbsResourcesBuilder.add_gas(resources.gas);
58 fbsResourcesBuilder.add_used_psi(resources.used_psi);
59 fbsResourcesBuilder.add_total_psi(resources.total_psi);
60 fbsResourcesBuilder.add_upgrades(resources.upgrades);
61 fbsResourcesBuilder.add_upgrades_level(resources.upgrades_level);
62 fbsResourcesBuilder.add_techs(resources.techs);
63 auto fbsResources = fbsResourcesBuilder.Finish();
64 builder.Finish(fbsResources);
66 fbs::ResourcesOfPlayerBuilder fbsResourcesOfPlayerBuilder(builder);
67 fbsResourcesOfPlayerBuilder.add_playerId(resourcesPair.first);
68 fbsResourcesOfPlayerBuilder.add_resources(fbsResources);
69 auto output = fbsResourcesOfPlayerBuilder.Finish();
70 builder.Finish(output);
76 return fbs::Bullet(bullet.type, bullet.x, bullet.y);
83 assert(fbsAction->action());
84 auto fbsActionInts = fbsAction->action();
86 action.
action.resize(fbsActionInts->size());
87 std::copy(fbsActionInts->begin(), fbsActionInts->end(), action.
action.begin());
88 action.
uid = fbsAction->uid();
89 action.
aid = fbsAction->aid();
93 const auto unpackResources = [](
const fbs::ResourcesOfPlayer* fbsResourcesOfPlayer) {
94 auto fbsResources = fbsResourcesOfPlayer->resources();
95 auto resources = std::make_pair(fbsResourcesOfPlayer->playerId(),
Resources()) ;
96 resources.second.ore = fbsResources->ore();
97 resources.second.gas = fbsResources->gas();
98 resources.second.used_psi = fbsResources->used_psi();
99 resources.second.total_psi = fbsResources->total_psi();
100 resources.second.upgrades = fbsResources->upgrades();
101 resources.second.upgrades_level = fbsResources->upgrades_level();
102 resources.second.techs = fbsResources->techs();
108 bullet.
type = fbsBullet->type();
109 bullet.
x = fbsBullet->x();
110 bullet.
y = fbsBullet->y();
int32_t x
Definition: frame.h:45
const auto unpackResources
Definition: flatbuffer_conversions.h:93
Copyright (c) 2015-present, Facebook, Inc.
Definition: openbwprocess.h:17
const auto packActionsOfPlayer
Definition: flatbuffer_conversions.h:22
int32_t type
Definition: frame.h:45
const auto unpackAction
Definition: flatbuffer_conversions.h:81
int32_t uid
Definition: frame.h:50
int32_t aid
Definition: frame.h:51
const auto packResourcesOfPlayer
Definition: flatbuffer_conversions.h:52
std::vector< int32_t > action
Definition: frame.h:49
int32_t y
Definition: frame.h:45
const auto unpackBullet
Definition: flatbuffer_conversions.h:106
const auto packBullet
Definition: flatbuffer_conversions.h:75