Documentation ¶
Overview ¶
mvd2text is for parsing MVD2 demos in their text format
Index ¶
- Constants
- type BaseFrame
- type Block
- type ConfigString
- type DM2Parser
- func (d *DM2Parser) ApplyPacket(packet *pb.Packet) error
- func (demo *DM2Parser) GetTextProto() *pb.DM2Demo
- func (demo *DM2Parser) Marshal() ([]byte, error)
- func (demo *DM2Parser) NextPacket() (message.Buffer, int, error)
- func (p *DM2Parser) RegisterCallback(event int, dofunc func(any))
- func (p *DM2Parser) Unmarshal() error
- func (p *DM2Parser) UnregisterCallback(msgtype int)
- func (demo *DM2Parser) WriteTextProto(filename string) error
- type DemoFile
- type Entity
- type MVD2File
- type MVDGameState
- type Player
- type ServerData
- type Stat
Constants ¶
const ( MVDMagic = 843339341 // {'M','V','D','2'} MaxMessageLength = 32768 // 0x8000 MaxPacketLength = 1400 // default Q2 UDP packet len MaxStats = 32 // playerstate stats uint32 bitmask MaxQpath = 64 // max len for file path MaxStringChars = 1024 // biggest string to deal with MaxConfigStrings = 2080 // CS_MAX MaxClients = 256 // hard limit MaxEdicts = 1024 // hard limit ProtocolVersion = 37 // major q2 protocol version ProtocolMinimum = 2009 // minor proto version required ProtocolCurrent = 2010 // minor proto version MVD2CMDBits = 5 MVD2CMDMask = ((1 << MVD2CMDBits) - 1) )
const ( MVDSvcBad = iota MVDSvcNop MVDSvcDisconnect MVDSvcReconnect MVDSvcServerData MVDSvcConfigString MVDSvcFrame MVDSvcFrameNoDelta MVDSvcUnicast MVDSvcUnicastR MVDSvcMulticastAll MVDSvcMulticastPHS MVDSvcMulticastPVS MVDSvcMulticastAllR MVDSvcMulticastPHSR MVDSvcMulticastPVSR MVDSvcSound MVDSvcPrint MVDSvcStuffText MVDSvcMax )
const ( SvcBad = iota SvcMuzzleFlash SvcMuzzleFlash2 SvcTemporaryEntity SvcLayout SvcInventory SvcNoOperation SvcDisconnect SvcReconnect SvcSound SvcPrint SvcStuffText SvcServerData SvcConfigString SvcSpawnBaseline SvcCenterprint SvcDownload SvcPlayerInfo SvcPacketEntities SvcDeltaPacketEntities SvcFrame SvcMax )
const ( FlagNoMessages = 1 << 0 FlagReverved1 = 1 << 1 FlagReverved2 = 1 << 2 )
Stream flags (3 bits)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigString ¶ added in v1.0.87
type DM2Parser ¶ added in v1.0.233
type DM2Parser struct {
// contains filtered or unexported fields
}
func NewDM2Demo ¶ added in v1.0.233
Read the entire binary demo file into memory
func (*DM2Parser) ApplyPacket ¶ added in v1.0.233
ApplyPacket will add all the messages from the packet to the current demo.
func (*DM2Parser) GetTextProto ¶ added in v1.0.233
func (*DM2Parser) Marshal ¶ added in v1.0.233
Convert the textproto demo back into a quake 2 playable binary demo. The returned byte slice just needs to be written to a file as is.
func (*DM2Parser) NextPacket ¶ added in v1.0.233
Demos are organized by "lumps" of data that are essentially packets. Even though all the data is already known, each lump represents a server packet's worth of game data. Each packet is prefixed with a 32 bit integer of the size of the packet and then a bunch of individual messages.
The default packet size for protocol 34 is 1390 bytes. Demos created by modern clients using protocols 35/36 will still write demos for protocol 34 to maximize compatability. Although it is possible to force these clients to record in their native protocol version.
func (*DM2Parser) RegisterCallback ¶ added in v1.0.233
RegisterCallback allows for a custom function to be called at specific points while a demo is being parsed.
`event` is an index corresponding to what you want your callback to be associated with. These match up with the SVC* server messages.
`dofunc` is the function definition to be called at that event. The argument is set to `any` to accept any type, but this arg should be the parsed server message proto. Inside the dofunc, the arg will need to be casted to the appropriate type. Something like:
printMsg := argname.(*pb.Print)
func (*DM2Parser) UnregisterCallback ¶ added in v1.0.233
Dynamically remove a particular callback
func (*DM2Parser) WriteTextProto ¶ added in v1.0.233
Turn a parsed demo structure back into a binary file
type DemoFile ¶ added in v1.0.87
type DemoFile struct {
Blocks []Block
}
func ParseMVD2TextDemo ¶ added in v1.0.87
type MVD2File ¶ added in v1.0.87
type MVD2File struct { Filename string Handle *os.File Position int // needed? Msg *message.Buffer }
func OpenMVD2File ¶ added in v1.0.87
Open the demo file and return an demo struct. Checks if the first 4 bytes match the MVDMagic value.
func (*MVD2File) Close ¶ added in v1.0.87
func (d *MVD2File) Close()
If the demo file is open (has a valid handle), close it
func (*MVD2File) ParseConfigString ¶ added in v1.0.87
func (d *MVD2File) ParseConfigString()