33 lines
1.3 KiB
C++
33 lines
1.3 KiB
C++
#pragma once
|
|
#include "gateway/legacy_stream.hpp"
|
|
#include <array>
|
|
#include <bit>
|
|
#include <map>
|
|
|
|
namespace ground_fixture {
|
|
constexpr uint64_t source=0xf100000001000001ULL;
|
|
inline std::map<uint16_t,uint32_t> consecration_fields(uint32_t player){
|
|
return {{0,uint32_t(source)},{1,uint32_t(source>>32)},{2,65},{3,26573},
|
|
{4,std::bit_cast<uint32_t>(1.0f)},{6,player},
|
|
{8,1},{9,26573},{10,std::bit_cast<uint32_t>(8.0f)}};
|
|
}
|
|
inline gateway::LegacyPacket update(uint64_t guid,bool create,const std::map<uint16_t,uint32_t>& fields,
|
|
std::array<float,4> position={-8797.06f,749.067f,97.5123f,0.0f}){
|
|
using namespace gateway;
|
|
Bytes body;
|
|
le(body,1,4);le(body,0,1);le(body,create?2:0,1);
|
|
Bytes raw;le(raw,guid,8);append(body,pack_guid(raw));
|
|
if(create){
|
|
le(body,6,1);le(body,0x50,1);
|
|
for(float coordinate:position)le(body,std::bit_cast<uint32_t>(coordinate),4);
|
|
le(body,0,4);
|
|
}
|
|
std::vector<uint32_t> masks(fields.empty()?0:fields.rbegin()->first/32+1);
|
|
le(body,masks.size(),1);
|
|
for(const auto& field:fields)masks[field.first/32]|=1u<<(field.first%32);
|
|
for(auto mask:masks)le(body,mask,4);
|
|
for(const auto& field:fields)le(body,field.second,4);
|
|
return {0xa9,body};
|
|
}
|
|
}
|