1use super::{prelude::*, NetMessage, NetEnum};
2
3#[vtable]
4pub struct NetChannelHandler {
5 #[offset(1)] pub ConnectionStart: extern "C" fn(chan: *mut NetChannel),
8
9 pub ConnectionClosing: extern "C" fn(reason: *const c_char),
11
12 pub ConnectionCrashed: extern "C" fn(reason: *const c_char),
14
15 pub PacketStart: extern "C" fn(incoming_seq: c_int, outgoing_ack: c_int),
17
18 pub PacketEnd: extern "C" fn(),
19
20 pub FileRequested: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
22
23 pub FileReceived: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
25
26 pub FileDenied: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
28
29 pub FileSent: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
31 pub ShouldAcceptFile: extern "C" fn(filename: *const c_char, transfer_id: c_uint) -> bool,
32}
33
34#[vtable]
35pub struct NetChannel {
36 info: *mut *mut NetChannelInfo,
37 #[skip(27)] pub SetDataRate: extern "C" fn(rate: c_float),
39 pub RegisterMessage: extern "C" fn(msg: *mut NetMessage) -> bool,
40 pub StartStreaming: extern "C" fn(challenge_nr: c_uint) -> bool,
41 pub ResetStreaming: extern "C" fn(),
42 pub SetTimeout: extern "C" fn(seconds: c_float),
43 pub SetDemoRecorder: extern "C" fn(recorder: *mut c_void),
44 pub SetChallengeNr: extern "C" fn(challenge_nr: c_uint),
45 pub Reset: extern "C" fn(),
46 pub Clear: extern "C" fn(),
47 #[check(36)]
48 pub Shutdown: extern "C" fn(reason: *const c_char),
49 pub ProcessPlayback: extern "C" fn(),
50 pub ProcessStream: extern "C" fn() -> bool,
51 pub ProcessPacket: extern "C" fn(packet: *mut c_void, has_header: bool) -> bool,
52 pub SendNetMsg: extern "C" fn(msg: &NetMessage, force_reliable: bool, voice: bool),
53 #[skip(1)]
54 pub SendFile: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
55 pub DenyFile: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
56 #[deprecated]
57 pub RequestFile_Old: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
58 pub SetChoked: extern "C" fn(),
59 pub SendDatagram: extern "C" fn(data: *mut c_void),
60 pub Transmit: extern "C" fn(only_reliable: bool) -> bool,
62 #[skip(1)]
63 pub GetMsgHandler: extern "C" fn() -> *mut NetChannelHandler,
64 pub GetDropNumber: extern "C" fn() -> c_int,
65 pub GetSocket: extern "C" fn() -> c_int,
66 pub GetChallengeNr: extern "C" fn() -> c_uint,
67
68 }
70
71#[vtable]
72pub struct NetChannelInfo {
73 pub ty: NetEnum,
74
75 pub GetName: extern "C" fn() -> *const c_char,
76 pub GetAddress: extern "C" fn() -> *const c_char,
77 pub GetTime: extern "C" fn() -> c_float,
78 pub GetTimeConnected: extern "C" fn() -> c_float,
79 pub GetBufferSize: extern "C" fn() -> c_int,
80 pub GetDataRate: extern "C" fn() -> c_int,
81 pub IsLoopback: extern "C" fn() -> bool,
82 pub IsTimingOut: extern "C" fn() -> bool,
83 pub IsPlayback: extern "C" fn() -> bool,
84 pub GetLatency: extern "C" fn(flow: c_int) -> c_float,
85 pub GetAvgLatency: extern "C" fn(flow: c_int) -> c_float,
86 pub GetAvgLoss: extern "C" fn(flow: c_int) -> c_float,
87 pub GetAvgChoke: extern "C" fn(flow: c_int) -> c_float,
88 pub GetAvgData: extern "C" fn(flow: c_int) -> c_float,
89 pub GetAvgPackets: extern "C" fn(flow: c_int) -> c_float,
90 pub GetTotalData: extern "C" fn(flow: c_int) -> c_int,
91 pub GetSequenceNr: extern "C" fn(flow: c_int) -> c_int,
92 pub IsValidPacket: extern "C" fn(flow: c_int, frame_number: c_int) -> bool,
93 pub GetPacketTime: extern "C" fn(flow: c_int, frame_number: c_int) -> c_float,
94 pub GetPacketBytes: extern "C" fn(flow: c_int, frame_number: c_int) -> c_int,
95 pub GetStreamProgress:
96 extern "C" fn(flow: c_int, received: *mut c_int, total: *mut c_int) -> bool,
97 pub GetTimeSinceLastReceived: extern "C" fn() -> c_float,
98 pub GetCommandInterpolationAmount: extern "C" fn(flow: c_int, frame_number: c_int) -> c_float,
99 pub GetPacketResponseLatency: extern "C" fn(
100 flow: c_int,
101 frame_number: c_int,
102 latencyms: *mut c_int,
103 pnchoke: *mut c_int
104 ) -> c_float,
105 pub GetRemoteFramerate: extern "C" fn(
106 pflFrameTime: *mut c_float,
107 pflFrameTimeStdDeviation: *mut c_float
108 ) -> c_float,
109 #[check(25)]
110 pub GetTimeoutSeconds: extern "C" fn() -> c_float
111}
112
113#[vtable]
114pub struct CNetChan {
115 pub GetName: extern "C" fn() -> *const c_char,
116 pub GetAddress: extern "C" fn() -> *const c_char,
117 pub GetTime: extern "C" fn() -> c_float,
118 pub GetTimeConnected: extern "C" fn() -> c_float,
119 pub GetBufferSize: extern "C" fn() -> c_int,
120 pub GetDataRate: extern "C" fn() -> c_int,
121 pub IsLoopback: extern "C" fn() -> bool,
122 pub IsTimingOut: extern "C" fn() -> bool,
123 pub IsPlayback: extern "C" fn() -> bool,
124 pub GetLatency: extern "C" fn(flow: c_int) -> c_float,
125 pub GetAvgLatency: extern "C" fn(flow: c_int) -> c_float,
126 pub GetAvgLoss: extern "C" fn(flow: c_int) -> c_float,
127 pub GetAvgChoke: extern "C" fn(flow: c_int) -> c_float,
128 pub GetAvgData: extern "C" fn(flow: c_int) -> c_float,
129 pub GetAvgPackets: extern "C" fn(flow: c_int) -> c_float,
130 pub GetTotalData: extern "C" fn(flow: c_int) -> c_int,
131 pub GetSequenceNr: extern "C" fn(flow: c_int) -> c_int,
132 pub IsValidPacket: extern "C" fn(flow: c_int, frame_number: c_int) -> bool,
133 pub GetPacketTime: extern "C" fn(flow: c_int, frame_number: c_int) -> c_float,
134 pub GetPacketBytes: extern "C" fn(flow: c_int, frame_number: c_int) -> c_int,
135 pub GetStreamProgress:
136 extern "C" fn(flow: c_int, received: *mut c_int, total: *mut c_int) -> bool,
137 pub GetTimeSinceLastReceived: extern "C" fn() -> c_float,
138 pub GetCommandInterpolationAmount: extern "C" fn(flow: c_int, frame_number: c_int) -> c_float,
139 pub GetPacketResponseLatency: extern "C" fn(
140 flow: c_int,
141 frame_number: c_int,
142 latencyms: *mut c_int,
143 pnchoke: *mut c_int
144 ) -> c_float,
145 pub GetRemoteFramerate: extern "C" fn(
146 pflFrameTime: *mut c_float,
147 pflFrameTimeStdDeviation: *mut c_float
148 ) -> c_float,
149 #[check(25)]
150 pub GetTimeoutSeconds: extern "C" fn() -> c_float,
151
152 #[skip(1)] pub SetDataRate: extern "C" fn(rate: c_float),
154 pub RegisterMessage: extern "C" fn(msg: *mut NetMessage) -> bool,
155 pub StartStreaming: extern "C" fn(challenge_nr: c_uint) -> bool,
156 pub ResetStreaming: extern "C" fn(),
157 pub SetTimeout: extern "C" fn(seconds: c_float),
158 pub SetDemoRecorder: extern "C" fn(recorder: *mut c_void),
159 pub SetChallengeNr: extern "C" fn(challenge_nr: c_uint),
160 pub Reset: extern "C" fn(),
161 pub Clear: extern "C" fn(),
162 #[check(36)]
163 pub Shutdown: extern "C" fn(reason: *const c_char),
164 pub ProcessPlayback: extern "C" fn(),
165 pub ProcessStream: extern "C" fn() -> bool,
166 pub ProcessPacket: extern "C" fn(packet: *mut c_void, has_header: bool) -> bool,
167 pub SendNetMsg: extern "C" fn(msg: &NetMessage, force_reliable: bool, voice: bool),
168 #[skip(1)]
169 pub SendFile: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
170 pub DenyFile: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
171 #[deprecated]
172 pub RequestFile_Old: extern "C" fn(filename: *const c_char, transfer_id: c_uint),
173 pub SetChoked: extern "C" fn(),
174 pub SendDatagram: extern "C" fn(data: *mut c_void),
175 pub Transmit: extern "C" fn(only_reliable: bool) -> bool,
177 #[skip(1)]
178 pub GetMsgHandler: extern "C" fn() -> *mut NetChannelHandler,
179 pub GetDropNumber: extern "C" fn() -> c_int,
180 pub GetSocket: extern "C" fn() -> c_int,
181 pub GetChallengeNr: extern "C" fn() -> c_uint,
182}