127 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
33 lines
1.8 KiB
C++
33 lines
1.8 KiB
C++
#pragma once
|
|
#include "gateway/protocol.hpp"
|
|
#include <bit>
|
|
namespace gateway {
|
|
struct MirrorTimerPacket {uint32_t opcode;Bytes body;};
|
|
// Source Player::SendMirrorTimerStart/Pause/Stop and native70334
|
|
// MiscPackets writers. Source client timers: fatigue0, breath1, feign-death2;
|
|
// source environmental3 is server-only and never sent by SendMirrorTimers.
|
|
// Keep server values, scale, frozen state and spell identity; synthesize no
|
|
// environmental damage, local countdown, timer start or cancellation.
|
|
inline MirrorTimerPacket forever_mirror_timer(uint32_t opcode,std::span<const uint8_t> body) {
|
|
if(opcode!=0x1d9 && opcode!=0x1da && opcode!=0x1db)throw Error("unsupported source mirror timer opcode");
|
|
Reader r(body);auto timer=r.le(4);
|
|
if(timer>2)throw Error("unsupported source client mirror timer");
|
|
MirrorTimerPacket out{opcode==0x1d9?0x4701bbu:opcode==0x1da?0x4701bcu:0x4701bdu,Bytes{uint8_t(timer)}};
|
|
if(opcode==0x1d9){
|
|
auto value=r.le(4),maximum=r.le(4),scale=r.le(4),paused=r.le(1),spell=r.le(4);r.end();
|
|
// Source durations/IDs are uint32; target writer represents int32.
|
|
// Unsupported unsigned values must not become negative/native sentinels.
|
|
if(value>0x7fffffff || !maximum || maximum>0x7fffffff || value>maximum || paused>1 || spell>0x7fffffff)
|
|
throw Error("unrepresentable source mirror timer start");
|
|
le(out.body,value,4);le(out.body,maximum,4);le(out.body,scale,4);le(out.body,spell,4);
|
|
// Native paused is Bits<1>, not the source's uint8 boolean, and follows
|
|
// SpellID rather than preceding it. ByteBuffer writes its high bit.
|
|
le(out.body,paused?0x80:0,1);
|
|
}else if(opcode==0x1da){
|
|
auto paused=r.le(1);r.end();if(paused>1)throw Error("invalid source mirror timer pause");
|
|
le(out.body,paused?0x80:0,1);
|
|
}else r.end();
|
|
return out;
|
|
}
|
|
}
|