Skip to content

Commit 2cab8c6

Browse files
committed
wip
1 parent 32240d1 commit 2cab8c6

1 file changed

Lines changed: 15 additions & 32 deletions

File tree

src/matches/match-relay/match-relay.service.ts

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ export class MatchRelayService {
166166
match_field_0.start.protocol = 5;
167167
}
168168

169-
// Get tick/endtick from delta field (delta has endtick, full only has tick)
170169
const fragTick = fragment.full?.tick;
171170
const fragEndtick = fragment.delta?.endtick;
172171
const fragTimestamp = fragment.delta?.timestamp;
@@ -202,48 +201,32 @@ export class MatchRelayService {
202201
this.logger.log(`Creating new match broadcast for matchId ${matchId}`);
203202
this.broadcasts[matchId] = [];
204203
}
204+
205205
const broadcast = this.broadcasts[matchId];
206206

207207
if (field == "start") {
208-
response.writeHead(200);
208+
fragmentIndex = 0;
209+
}
209210

210-
if (broadcast[0] == null) {
211-
broadcast[0] = {};
212-
broadcast[0].start = {};
213-
}
211+
if (field != "start" && broadcast[0] == null) {
212+
response.writeHead(205);
213+
response.end();
214+
return;
215+
}
214216

215-
broadcast[0].start.signup_fragment = fragmentIndex;
216-
fragmentIndex = 0;
217-
} else {
218-
// For non-start fields, ensure start fragment exists at index 0
219-
// Start fragment is always at index 0, check if the start data exists
220-
if (broadcast[0] == null || broadcast[0].start?.data == null) {
221-
response.writeHead(205);
222-
response.end();
223-
return;
224-
} else {
225-
response.writeHead(200);
226-
}
227-
if (broadcast[fragmentIndex] == null) {
228-
broadcast[fragmentIndex] = {};
229-
}
230-
// Initialize field data object if it doesn't exist
231-
if (broadcast[fragmentIndex][field] == null) {
232-
broadcast[fragmentIndex][field] = {};
233-
}
217+
response.writeHead(200);
218+
if (broadcast[fragmentIndex] == null) {
219+
broadcast[fragmentIndex] = {};
234220
}
235221

236-
// Initialize field data object if it doesn't exist (for start field)
237222
if (broadcast[fragmentIndex][field] == null) {
238-
broadcast[fragmentIndex][field] = {};
223+
broadcast[fragmentIndex][field] = {
224+
...(field === "start" ? { signup_fragment: fragmentIndex } : {}),
225+
};
239226
}
240227

241228
Object.entries(request.query).forEach(([key, value]) => {
242-
const strValue = String(value);
243-
const numValue = Number(strValue);
244-
// Store query params directly in the field data object
245-
broadcast[fragmentIndex][field][key] =
246-
!isNaN(numValue) && strValue === String(numValue) ? numValue : value;
229+
broadcast[fragmentIndex][field][key] = value;
247230
});
248231

249232
const body: Buffer[] = [];

0 commit comments

Comments
 (0)