Example #1
0
	GameMessage(const flatbuffers::FlatBufferBuilder& builder, int type)
	{
		setBodyLength(builder.GetSize());
		setType(type);

		std::memcpy(getBody(), builder.GetBufferPointer(), _body_length);
		encodeHeader();	
	}
flatbuffers::Offset<LogData> SampleEnvironmentEventDouble::getSEEvent(
    flatbuffers::FlatBufferBuilder &builder) {
  auto nameOffset = builder.CreateString(m_name);
  auto valueOffset = CreateDouble(builder, m_value);
  auto timestamp = getTimestamp();
  return CreateLogData(builder, nameOffset, Value_Double, valueOffset.Union(),
                       timestamp);
}
 virtual flatbuffers::Offset<DeadCreator::Action> getActionObject(flatbuffers::FlatBufferBuilder& builder) override
 {
     auto switchInfo = DeadCreator::CreateSwitchInfo2(builder,
                                                      builder.CreateString(_name.getSwitchName()),
                                                      static_cast<DeadCreator::SwitchStatus2>(_status.getSwitchStatus()),
                                                      _name.getSwitchIndex());
     
     auto obj = DeadCreator::CreateSetSwitch(builder, switchInfo);
     return DeadCreator::CreateAction(builder, DeadCreator::ActionBase_SetSwitch, obj.Union());
 }
Example #4
0
void serialize(flatbuffers::FlatBufferBuilder &builder, std::vector<boost::property_tree::ptree> data,int playerNumber) {
	auto board = snakedata::Createboarddata(builder, data.at(0).get<int>("table.width"), data.at(0).get<int>("table.height"));
	auto snakefood = snakedata::Createsnakefooddata(builder,data.at(0).get<int>("snakefood.x"), data.at(0).get<int>("snakefood.y"));
	std::vector<flatbuffers::Offset<snakedata::snakebodydata>> allsnakesdata;
	
	for (int j = 0; j < data.size(); j++) {
		std::vector<flatbuffers::Offset<snakedata::snakebodypoint>> snakebodypoints;
		for (int i = 0; i < data.at(j).get<int>("snakebody.length"); i++) {
			snakebodypoints.push_back(snakedata::Createsnakebodypoint(builder, data.at(j).get<int>("snakebody.point." + std::to_string(i) + ".x"), data.at(j).get<int>("snakebody.point." + std::to_string(i) + ".y")));
		};
		auto snakebodypointsvector = builder.CreateVector(snakebodypoints);
		allsnakesdata.push_back(snakedata::Createsnakebodydata(builder,snakebodypointsvector));
	}
	auto allsnakesdatavector = builder.CreateVector(allsnakesdata);
	
	auto gamestatus = builder.CreateString(data.at(playerNumber).get<std::string>("game_status"));
	auto gamescore = data.at(playerNumber).get<int>("game_score");
	auto numberofsnakes = data.size();
	auto snake_data = snakedata::Createsnakepacketdata(builder,allsnakesdatavector, board,snakefood,gamestatus,gamescore,numberofsnakes);
	snakedata::FinishsnakepacketdataBuffer(builder, snake_data);
		
}