Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Parse() [2/2]

static void System.IPv6AddressHelper.Parse ( ReadOnlySpan< char > address,
Span< ushort > numbers,
int start,
ref string scopeId )
inlinestaticpackage

Definition at line 287 of file IPv6AddressHelper.cs.

288 {
289 int num = 0;
290 int num2 = 0;
291 int num3 = -1;
292 bool flag = true;
293 int num4 = 0;
294 if (address[start] == '[')
295 {
296 start++;
297 }
298 int i = start;
299 while (i < address.Length && address[i] != ']')
300 {
301 switch (address[i])
302 {
303 case '%':
304 if (flag)
305 {
306 numbers[num2++] = (ushort)num;
307 flag = false;
308 }
309 start = i;
310 for (i++; i < address.Length && address[i] != ']' && address[i] != '/'; i++)
311 {
312 }
313 scopeId = new string(address.Slice(start, i - start));
314 for (; i < address.Length && address[i] != ']'; i++)
315 {
316 }
317 break;
318 case ':':
319 {
320 numbers[num2++] = (ushort)num;
321 num = 0;
322 i++;
323 if (address[i] == ':')
324 {
325 num3 = num2;
326 i++;
327 }
328 else if (num3 < 0 && num2 < 6)
329 {
330 break;
331 }
332 for (int j = i; j < address.Length && address[j] != ']' && address[j] != ':' && address[j] != '%' && address[j] != '/' && j < i + 4; j++)
333 {
334 if (address[j] == '.')
335 {
336 for (; j < address.Length && address[j] != ']' && address[j] != '/' && address[j] != '%'; j++)
337 {
338 }
339 num = IPv4AddressHelper.ParseHostNumber(address, i, j);
340 numbers[num2++] = (ushort)(num >> 16);
341 numbers[num2++] = (ushort)num;
342 i = j;
343 num = 0;
344 flag = false;
345 break;
346 }
347 }
348 break;
349 }
350 case '/':
351 if (flag)
352 {
353 numbers[num2++] = (ushort)num;
354 flag = false;
355 }
356 for (i++; address[i] != ']'; i++)
357 {
358 num4 = num4 * 10 + (address[i] - 48);
359 }
360 break;
361 default:
362 num = num * 16 + Uri.FromHex(address[i++]);
363 break;
364 }
365 }
366 if (flag)
367 {
368 numbers[num2++] = (ushort)num;
369 }
370 if (num3 <= 0)
371 {
372 return;
373 }
374 int num5 = 7;
375 int num6 = num2 - 1;
376 if (num6 != num5)
377 {
378 for (int num7 = num2 - num3; num7 > 0; num7--)
379 {
380 numbers[num5--] = numbers[num6];
381 numbers[num6--] = 0;
382 }
383 }
384 }
ReadOnlySpan< T > Slice(int start)

References System.Uri.FromHex(), System.ReadOnlySpan< T >.Length, System.IPv4AddressHelper.ParseHostNumber(), System.ReadOnlySpan< T >.Slice(), and System.start.