-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathClientNet.bb
More file actions
1827 lines (1725 loc) · 67.9 KB
/
ClientNet.bb
File metadata and controls
1827 lines (1725 loc) · 67.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Global TradePackets = 0
Global TradeMsg1$, TradeMsg2$, TradeMsg3$
Global newEntityX#,newEntityY#,newEntityZ#
Global oldEntityX#,oldEntityY#,oldEntityZ#
; Track the currently-playing P_Music handles so the next P_Music can
; release them. Used to leak one sound and one channel per zone change.
Global CurrentMusicSound = 0
Global CurrentMusicChannel = 0
; Single entry point for "we lost the server connection" outcomes.
;
; Today this is the same `RuntimeError(LS_LostConnection)` that the 12
; previous in-line callers had -- a controlled crash with a localized
; message. Consolidating to one function gives a single place to swap
; in a reconnect dialog (the long-horizon INTENT item) without having
; to find and modify every disconnect path again.
;
; Callers should branch to this immediately on detecting
; RN_HostHasLeft / RN_Disconnected / PeerToHostNotFound and similar
; RakNet conditions. The function does not return.
Function OnLostConnection()
RuntimeError(LanguageString$(LS_LostConnection))
End Function
; Connects to the server
Function Connect()
; Attempt connection
Port = 11002
Repeat
PeerToHost = RCE_Connect(ServerHost$, ServerPort, Port, Me\Name$, "", "Data\Logs\Client Connection.txt", True)
Port = Port + 1
Until PeerToHost <> RN_ConnectionInUse And PeerToHost <> RN_PortInUse
Select PeerToHost
Case PeerToHostNotFound : RuntimeError(LanguageString$(LS_InvalidHost) + " (" + ServerHost$ + ")")
Case RN_TimedOut : RuntimeError(LanguageString$(LS_NoResponse))
Case RN_ServerFull : RuntimeError(LanguageString$(LS_TooManyPlayers))
End Select
Pa$ = RCE_StrFromInt$(Len(UName$), 1) + UName$ + RCE_StrFromInt$(Len(PWord$), 1) + PWord$
RCE_Send(Connection, PeerToHost, P_StartGame, Pa$ + Chr$(SelectedCharacter), True)
; Await reply
Done = 0
; After-cursor walk: trailing Delete M during For-Each would corrupt
; the cursor on the next step when multiple messages are queued
; (the server fans out P_StartGame plus any chat/disconnect packets
; that crossed the wire in the same tick).
Local M.RCE_Message = First RCE_Message
Local MNext.RCE_Message = Null
While Done < 13
Delay 10
; We get signal!
M = First RCE_Message
While M <> Null
MNext = After M
If M\MessageType = P_StartGame
; Error message
If M\MessageData$ = "N" Then RuntimeError(LanguageString$(LS_AlreadyInGame))
; Action bar data
If Len(M\MessageData$) > 2
SlotNum = RCE_IntFromStr(Left$(M\MessageData$, 1))
Offset = 2
For i = 1 To 3
; Get slot data
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, Offset, 2))
Slot$ = Mid$(M\MessageData$, Offset + 2, NameLen)
Offset = Offset + 2 + NameLen
; Set up slot
If Slot$ <> ""
; Ability
If Left$(Slot$, 1) = "S"
SpellName$ = Mid$(Slot$, 2)
; Must be memorised
If RequireMemorise
For j = 0 To 9
If Me\MemorisedSpells[j] <> 5000
Sp.Spell = SpellsList(Me\KnownSpells[Me\MemorisedSpells[j]])
If Sp\Name$ = SpellName$
ActionBarSlots(SlotNum) = j - 10
Exit
EndIf
EndIf
Next
; Must be known
Else
For j = 0 To 999
If Me\SpellLevels[j] > 0
Sp.Spell = SpellsList(Me\KnownSpells[j])
If Sp\Name$ = SpellName$
ActionBarSlots(SlotNum) = j - 1000
Exit
EndIf
EndIf
Next
EndIf
; Item
ElseIf Left$(Slot$, 1) = "I"
ActionBarSlots(SlotNum) = RCE_IntFromStr(Mid$(Slot$, 2))
EndIf
Else
ActionBarSlots(SlotNum) = 65535
EndIf
SlotNum = SlotNum + 1
Next
; My actor's runtime ID and XP bar level
Else
Me\RuntimeID = RCE_IntFromStr(M\MessageData$)
RuntimeIDList(Me\RuntimeID) = Me
EndIf
Delete M : Done = Done + 1
ElseIf M\MessageType = PeerToHostHasLeft
OnLostConnection()
Delete M
EndIf
M = MNext
Wend
RCE_Update()
RCE_CreateMessages()
Cls
Flip VSync
Wend
UpdateActionBarIcons()
; Success
WriteLog(MainLog, "Successfully connected to server")
End Function
; Processes all network messages
Function UpdateNetwork()
; Incoming messages
; After-cursor walk: the trailing Delete M before Next would corrupt
; the For-Each cursor on the next step. This dispatcher runs every
; frame and processes the full RCE_Message backlog -- a typical tick
; carries many packets (per-actor updates, chat, effects, etc.), so
; the For-Each + Delete pattern reliably skips messages and risks a
; use-after-free on the cursor advance.
Local M.RCE_Message = First RCE_Message
Local MNext.RCE_Message = Null
While M <> Null
MNext = After M
; What happen?
Select M\MessageType
; Scripted progress bar
Case P_ProgressBar ; :)
; Create new
If Left$(M\MessageData$, 1) = "C"
Red = RCE_IntFromStr(Mid$(M\MessageData$, 2, 1))
Green = RCE_IntFromStr(Mid$(M\MessageData$, 3, 1))
Blue = RCE_IntFromStr(Mid$(M\MessageData$, 4, 1))
X# = RCE_FloatFromStr#(Mid$(M\MessageData$, 5, 4))
Y# = RCE_FloatFromStr#(Mid$(M\MessageData$, 9, 4))
W# = RCE_FloatFromStr#(Mid$(M\MessageData$, 13, 4))
H# = RCE_FloatFromStr#(Mid$(M\MessageData$, 17, 4))
Max = RCE_IntFromStr(Mid$(M\MessageData$, 25, 2))
Value = RCE_IntFromStr(Mid$(M\MessageData$, 27, 2))
DisplayText$ = Mid$(M\MessageData$, 29)
PBar = GY_CreateProgressBar(0, X#, Y#, W#, H#, Value, Max, Red, Green, Blue)
GY_CreateLabel(PBar, 0.5, 0.5 - (0.015 / H#), DisplayText$, 255, 255, 255, Justify_Centre)
RCE_Send(Connection, PeerToHost, P_ProgressBar, "C" + Mid$(M\MessageData$, 21, 4) + RCE_StrFromInt$(PBar), True)
; Update
ElseIf Left$(M\MessageData$, 1) = "U"
PBar = RCE_IntFromStr(Mid$(M\MessageData$, 2, 4))
Value = RCE_IntFromStr(Mid$(M\MessageData$, 6, 2))
GY_UpdateProgressBar(PBar, Value)
; Delete
ElseIf Left$(M\MessageData$, 1) = "D"
PBar = RCE_IntFromStr(Mid$(M\MessageData$, 2))
GY_FreeGadget(PBar)
EndIf
; Reposition an actor
Case P_RepositionActor
RuntimeID = RCE_IntFromStr(Mid$(M\MessageData$, 2, 2))
AI.ActorInstance = RuntimeIDList(RuntimeID)
If AI <> Null
; Move
If Left$(M\MessageData$, 1) = "M"
AI\X# = RCE_FloatFromStr(Mid$(M\MessageData$, 4, 4))
Y# = RCE_FloatFromStr(Mid$(M\MessageData$, 8, 4))
AI\Z# = RCE_FloatFromStr(Mid$(M\MessageData$, 12, 4))
MoveCamera = RCE_IntFromStr(Mid$(M\MessageData$, 16, 1))
AI\DestX# = AI\X#
AI\DestZ# = AI\Z#
PositionEntity(AI\CollisionEN, AI\X#, Y#, AI\Z#)
; Ignore collision
If RCE_IntFromStr(Mid$(M\MessageData$, 16, 1)) = 0 Then ResetEntity(AI\CollisionEN)
; Move the camera directly to the new spot, otherwise it will fly there
If MoveCamera = False Then PositionEntity(Cam, AI\X#, Y#, AI\Z#)
; Rotate
Else
AI\Yaw# = RCE_FloatFromStr(Mid$(M\MessageData$, 4))
RotateEntity(AI\CollisionEN, 0, AI\Yaw#, 0)
EndIf
EndIf
; Floating number (for damage or whatever)
Case P_FloatingNumber
RuntimeID = RCE_IntFromStr(Mid$(M\MessageData$, 1, 2))
AI.ActorInstance = RuntimeIDList(RuntimeID)
If AI <> Null
Amount = RCE_IntFromStr(Mid$(M\MessageData$, 3, 4))
cR = RCE_IntFromStr(Mid$(M\MessageData$, 7, 1))
cG = RCE_IntFromStr(Mid$(M\MessageData$, 8, 1))
cB = RCE_IntFromStr(Mid$(M\MessageData$, 9, 1))
CreateFloatingNumber(AI, Amount, cR, cG, cB)
EndIf
; Projectile created
Case P_Projectile
; Get source and target actor instance
RuntimeID = RCE_IntFromStr(Mid$(M\MessageData$, 1, 2))
AI.ActorInstance = RuntimeIDList(RuntimeID)
RuntimeID = RCE_IntFromStr(Mid$(M\MessageData$, 3, 2))
TargetAI.ActorInstance = RuntimeIDList(RuntimeID)
; Target is valid
If TargetAI <> Null And AI <> Null
; Get projectile data
MeshID = RCE_IntFromStr(Mid$(M\MessageData$, 5, 2))
TexID1 = RCE_IntFromStr(Mid$(M\MessageData$, 7, 2))
TexID2 = RCE_IntFromStr(Mid$(M\MessageData$, 9, 2))
Homing = RCE_IntFromStr(Mid$(M\MessageData$, 11, 1))
Speed# = Float#(RCE_IntFromStr(Mid$(M\MessageData$, 12, 1))) / 50.0
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, 13, 1))
Emitter1$ = ""
If NameLen > 0 Then Emitter1$ = Mid$(M\MessageData$, 14, NameLen)
Emitter2$ = Mid$(M\MessageData$, 14 + NameLen)
; Create it
CreateProjectile(AI, TargetAI, MeshID, Homing, Speed#, Emitter1$, Emitter2$, TexID1, TexID2)
EndIf
; An actor has jumped
Case P_Jump
AI.ActorInstance = RuntimeIDList(RCE_IntFromStr(M\MessageData$))
If AI <> Null
PlayAnimation(AI, 3, 0.05, Anim_Jump)
AI\Y# = JumpStrength# * Gravity#
EndIf
; Item health updated
Case P_ItemHealth
SlotI = RCE_IntFromStr(Left$(M\MessageData$, 1))
Health = RCE_IntFromStr(Right$(M\MessageData$, 2))
If Me\Inventory\Items[SlotI] <> Null Then Me\Inventory\Items[SlotI]\ItemHealth = Health
; Owned scenery selected {##}
Case P_SelectScenery
Sc.Scenery = Object.Scenery(RCE_IntFromStr(M\MessageData$))
If Sc <> Null
If Sc\AnimationMode = 3 ;And Sc\SceneryID > 0 {##}
If AnimTime(Sc\EN) > 0.0
Animate(Sc\EN, 3, -1.0, 0, 1.0)
Else
Animate(Sc\EN, 3, 1.0, 0, 1.0)
EndIf
EndIf
EndIf
; Actor appearance (clothes, face, etc.) changed
Case P_AppearanceUpdate
AI.ActorInstance = RuntimeIDList(RCE_IntFromStr(Mid$(M\MessageData$, 2, 2)))
If AI <> Null
Select Left$(M\MessageData$, 1)
; Entire actor
Case "C"
ID = RCE_IntFromStr(Right$(M\MessageData$, 2))
AI\Actor = ActorList(ID)
If AI\Actor\Genders = 2 And AI\Gender <> 1 Then AI\Gender = 1
If (AI\Actor\Genders = 1 Or AI\Actor\Genders = 3) And AI\Gender <> 0 Then AI\Gender = 0
X# = EntityX#(AI\CollisionEN)
Y# = EntityY#(AI\CollisionEN)
Z# = EntityZ#(AI\CollisionEN)
FreeActorInstance3D(AI)
Result = LoadActorInstance3D(AI, 0.05)
If Result = False
; Same DoS surface as P_NewActor (see line ~1432
; comment): server picks the Race, missing mesh
; here used to crash every observer. For other
; actors, drop them; we'll pick them up again on
; their next P_NewActor. For Me, the failure is
; unrecoverable (no body to control) -- keep the
; RuntimeError as the controlled crash.
If AI <> Me
WriteLog(MainLog, "P_AppearanceUpdate C: missing mesh for race '" + AI\Actor\Race$ + "' (RNID=" + AI\RNID + "), dropping actor")
; Sweep homing projectiles first -- dropping this in-zone actor
; otherwise leaves a dangling ProjectileInstance\Target (#457).
FreeProjectilesTargeting(AI)
SafeFreeActorInstance(AI)
Else
RuntimeError("Could not load actor mesh for " + AI\Actor\Race$ + "!")
EndIf
Else
AI\Y# = 0.0
PositionEntity(AI\CollisionEN, X#, Y#, Z#)
ResetEntity(AI\CollisionEN)
If AI = Me
EntityType(Me\CollisionEN, C_Player)
FreeEntity(Me\NametagEN)
Me\NametagEN = 0
Bonce = FindChild(Me\EN, "Head")
If Bonce = 0 Then RuntimeError(Me\Actor\Race$ + " actor mesh is missing a 'Head' joint!")
CamHeight# = EntityDistance#(Bonce, Me\CollisionEN)
EndIf
EndIf
; Gender
Case "G"
AI\Gender = Asc(Right$(M\MessageData$, 1))
; Wire byte arrives 0..255 but Gender is a 0/1
; selector for Male/Female mesh + hair + face +
; body lookups in LoadActorInstance3D below.
; Clamp at the receive site -- the server's
; P_CreateCharacter handler already clamps on
; persistence (#199); this mirrors that for the
; in-session P_AppearanceUpdate path.
If AI\Gender < 0 Or AI\Gender > 1 Then AI\Gender = 0
X# = EntityX#(AI\CollisionEN)
Y# = EntityY#(AI\CollisionEN)
Z# = EntityZ#(AI\CollisionEN)
FreeActorInstance3D(AI)
Result = LoadActorInstance3D(AI, 0.05)
If Result = False
If AI <> Me
WriteLog(MainLog, "P_AppearanceUpdate G: missing mesh for race '" + AI\Actor\Race$ + "' (RNID=" + AI\RNID + "), dropping actor")
; Sweep homing projectiles first -- dropping this in-zone actor
; otherwise leaves a dangling ProjectileInstance\Target (#457).
FreeProjectilesTargeting(AI)
SafeFreeActorInstance(AI)
Else
RuntimeError("Could not load actor mesh for " + AI\Actor\Race$ + "!")
EndIf
Else
AI\Y# = 0.0
PositionEntity(AI\CollisionEN, X#, Y#, Z#)
ResetEntity(AI\CollisionEN)
EndIf
; Beard
Case "D"
AI\Beard = Asc(Right$(M\MessageData$, 1))
; Beard indexes BeardIDs[4]; clamp the wire byte
; (0..255) at the receive site so the BeardOK
; gate below (and any LoadActorInstance3D
; reload) sees a valid index.
If AI\Beard < 0 Or AI\Beard > 4 Then AI\Beard = 0
Bonce = FindChild(AI\EN, "Head")
If Bonce = 0
; Beard is decorative. If the actor mesh has
; no Head joint, just skip the update -- no
; reason to crash the client.
WriteLog(MainLog, "P_AppearanceUpdate D: race '" + AI\Actor\Race$ + "' mesh missing 'Head' joint, skipping beard")
Else
; Remove old beard
BeardEN = FindChild(Bonce, "Beard")
If BeardEN <> 0 Then FreeEntity(BeardEN)
; Apply new beard. Same bounds + short-circuit-safe
; guard as the Actors3D LoadActorInstance3D path.
Local BeardOK = False
If AI\Beard >= 0 And AI\Beard <= 4
If AI\Actor\BeardIDs[AI\Beard] > -1 And AI\Actor\BeardIDs[AI\Beard] < 65535
BeardOK = True
EndIf
EndIf
If BeardOK
ID = AI\Actor\BeardIDs[AI\Beard]
BeardEN = GetMesh(ID, True)
If BeardEN <> 0
EntityParent(BeardEN, Bonce, False)
PositionEntity(BeardEN, LoadedMeshX#(ID), LoadedMeshY#(ID), LoadedMeshZ#(ID))
ScaleEntity(BeardEN, LoadedMeshScales#(ID), LoadedMeshScales#(ID), LoadedMeshScales#(ID))
; Correct rotation for Max models
If AI\TeamID = True Then TurnEntity(BeardEN, 0, 180, 90)
NameEntity(BeardEN, "Beard")
EndIf
EndIf
EndIf
; Hair
Case "H"
AI\Hair = Asc(Right$(M\MessageData$, 1))
; Hair indexes Male/FemaleHairIDs[4]; clamp the
; wire byte (0..255) before SetActorHat's
; fallback path uses it as an array index.
If AI\Hair < 0 Or AI\Hair > 4 Then AI\Hair = 0
If AI\Inventory\Items[SlotI_Hat] = Null Then SetActorHat(AI, -1)
; Face
Case "F"
AI\FaceTex = Asc(Right$(M\MessageData$, 1))
; Wire arrives as Asc (0..255) but MaleFaceIDs /
; FemaleFaceIDs are Field [4] (5 slots). Out of
; range reads past the array into adjacent Actor
; fields. Clamp at the receive site so every
; downstream lookup is safe. Similar reasoning
; for AI\BodyTex which is also indexed below.
If AI\FaceTex < 0 Or AI\FaceTex > 4 Then AI\FaceTex = 0
If AI\BodyTex < 0 Or AI\BodyTex > 4 Then AI\BodyTex = 0
; Repaint
If AI\Gender = 0
FaceTex = AI\Actor\MaleFaceIDs[AI\FaceTex]
BodyTex = AI\Actor\MaleBodyIDs[AI\BodyTex]
Else
FaceTex = AI\Actor\FemaleFaceIDs[AI\FaceTex]
BodyTex = AI\Actor\FemaleBodyIDs[AI\BodyTex]
EndIf
If CountSurfaces(AI\EN) > 1 And FaceTex < 65535
; Find which surface is body
Br = GetSurfaceBrush(GetSurface(AI\EN, 1)) : T = GetBrushTexture(Br)
Name$ = TextureName$(T)
FreeTexture T : FreeBrush(Br)
FaceSurface = GetSurface(AI\EN, 2)
BodySurface = GetSurface(AI\EN, 1)
If Instr(Upper$(Name$), "HEAD") > 0
FaceSurface = GetSurface(AI\EN, 1)
BodySurface = GetSurface(AI\EN, 2)
EndIf
; Paint
Br = CreateBrush()
BrushTexture(Br, GetTexture(BodyTex))
PaintSurface(BodySurface, Br)
BrushTexture(Br, GetTexture(FaceTex))
PaintSurface(FaceSurface, Br)
FreeBrush(Br)
UnloadTexture(BodyTex)
UnloadTexture(FaceTex)
Else
EntityTexture AI\EN, GetTexture(BodyTex)
UnloadTexture(BodyTex)
EndIf
; Body
Case "B"
AI\BodyTex = Asc(Right$(M\MessageData$, 1))
; Same bounds as the Face case above -- BodyTex
; is Asc 0..255 but MaleBodyIDs / FemaleBodyIDs
; are Field [4]. FaceTex may already be valid
; from a prior packet; bound it defensively too.
If AI\BodyTex < 0 Or AI\BodyTex > 4 Then AI\BodyTex = 0
If AI\FaceTex < 0 Or AI\FaceTex > 4 Then AI\FaceTex = 0
; Repaint
If AI\Gender = 0
FaceTex = AI\Actor\MaleFaceIDs[AI\FaceTex]
BodyTex = AI\Actor\MaleBodyIDs[AI\BodyTex]
Else
FaceTex = AI\Actor\FemaleFaceIDs[AI\FaceTex]
BodyTex = AI\Actor\FemaleBodyIDs[AI\BodyTex]
EndIf
If CountSurfaces(AI\EN) > 1 And FaceTex < 65535
; Find which surface is body
Br = GetSurfaceBrush(GetSurface(AI\EN, 1)) : T = GetBrushTexture(Br)
Name$ = TextureName$(T)
FreeTexture T : FreeBrush(Br)
FaceSurface = GetSurface(AI\EN, 2)
BodySurface = GetSurface(AI\EN, 1)
If Instr(Upper$(Name$), "HEAD") > 0
FaceSurface = GetSurface(AI\EN, 1)
BodySurface = GetSurface(AI\EN, 2)
EndIf
; Paint
Br = CreateBrush()
BrushTexture(Br, GetTexture(BodyTex))
PaintSurface(BodySurface, Br)
BrushTexture(Br, GetTexture(FaceTex))
PaintSurface(FaceSurface, Br)
FreeBrush(Br)
UnloadTexture(BodyTex)
UnloadTexture(FaceTex)
Else
EntityTexture AI\EN, GetTexture(BodyTex)
UnloadTexture(BodyTex)
EndIf
End Select
EndIf
; Party changed
Case P_PartyUpdate
Offset = 1
For i = 0 To 6
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, Offset, 1))
PartyName$(i) = Mid$(M\MessageData$, Offset + 1, NameLen)
Offset = Offset + 1 + NameLen
GY_UpdateLabel(LPartyName(i), PartyName$(i), 0, 255, 0)
Next
; Actor effect added, removed, or updated
Case P_ActorEffect
; Added
If Left$(M\MessageData$, 1) = "A"
EI.EffectIcon = New EffectIcon
EI\ID = RCE_IntFromStr(Mid$(M\MessageData$, 2, 4))
EI\TextureID = RCE_IntFromStr(Mid$(M\MessageData$, 6, 2))
EI\Name$ = Mid$(M\MessageData$, 8)
UpdateEffectIcons()
; Effect updated
ElseIf Left$(M\MessageData$, 1) = "E"
Att = RCE_IntFromStr(Mid$(M\MessageData$, 2, 1))
Amount = RCE_IntFromStr(Mid$(M\MessageData$, 3, 4))
If Att >= 0 And Att < 40 And Me <> Null
Me\Attributes\Value[Att] = Me\Attributes\Value[Att] + Amount
EndIf
; Removed
ElseIf Left$(M\MessageData$, 1) = "R"
ID = RCE_IntFromStr(Mid$(M\MessageData$, 2, 4))
For EI.EffectIcon = Each EffectIcon
If EI\ID = ID
Delete EI
UpdateEffectIcons()
Exit
EndIf
Next
; The "R" payload must carry 40*4=160 bytes of per-attribute
; deltas starting at offset 6. A hostile or truncated server
; packet could send fewer bytes; Mid$ would return zero-
; padded reads and the loop would silently zero attributes
; on the client. Bail the per-attribute walk unless the
; full delta block is present.
If Me <> Null And Len(M\MessageData$) >= 6 + 40 * 4
For i = 0 To 39
Amount = RCE_IntFromStr(Mid$(M\MessageData$, 6 + (i * 4), 4))
Me\Attributes\Value[i] = Me\Attributes\Value[i] - Amount
Next
EndIf
EndIf
; Trading updated
Case P_UpdateTrading
If TradingVisible = True
Slot = RCE_IntFromStr(Mid$(M\MessageData$, 1, 1))
Amount = RCE_IntFromStr(Mid$(M\MessageData$, 2, 2))
; Remove item
If Amount = 0
For i = 0 To 31
If ServerTradeIDs(i) = Slot
ServerTradeIDs(i) = 0
TradeAmounts(i) = 0
If TradeItems(i) <> Null Then FreeItemInstance(TradeItems(i))
GYG.GY_Gadget = Object.GY_Gadget(BSlotsHis(i))
GYB.GY_Button = Object.GY_Button(GYG\TypeHandle)
EntityTexture GYB\Gadget\EN, GYB\UserTexture
GY_SetButtonLabel(BSlotsHis(i), "")
Exit
EndIf
Next
; Add item
Else
For i = 0 To 31
If TradeItems(i) = Null
ServerTradeIDs(i) = Slot
TradeAmounts(i) = Amount
TradeItems(i) = ItemInstanceFromString(Mid$(M\MessageData$, 4))
GYG.GY_Gadget = Object.GY_Gadget(BSlotsHis(i))
GYB.GY_Button = Object.GY_Button(GYG\TypeHandle)
EntityTexture GYB\Gadget\EN, GetTexture(TradeItems(i)\Item\ThumbnailTexID)
If TradeAmounts(i) > 1
GY_SetButtonLabel(BSlotsHis(i), TradeAmounts(i), 100, 255, 0, True)
Else
GY_SetButtonLabel(BSlotsHis(i), "")
EndIf
Exit
EndIf
Next
EndIf
EndIf
; Trading closed
Case P_CloseTrading
If TradingVisible = True
GY_GadgetAlpha(WTrading, 0.0, True)
GY_Modal = False
TradingVisible = False
EndIf
; Trading opened
Case P_OpenTrading
If TradePackets < 3
TradePackets = TradePackets + 1
Num = Mid$(M\MessageData$, 1, 1)
Total = Mid$(M\MessageData$, 2, 1)
If Num = 1 Then TradeMsg1$ = Mid$(M\MessageData$, 3)
If Num = 2 Then TradeMsg2$ = Mid$(M\MessageData$, 3)
If Num = 3 Then TradeMsg3$ = Mid$(M\MessageData$, 3)
If TradePackets = Total And TradingVisible = False
; Assemble message
TradePackets = 0
M\MessageData$ = TradeMsg1$ + TradeMsg2$ + TradeMsg3$
; Clear trading window
GY_GadgetAlpha(WTrading, 0.85, True)
GY_ActivateWindow(WTrading)
TradingVisible = True
GY_Modal = True
GY_UpdateLabel(LTradingGold, LanguageString$(LS_Money) + " " + Money$(Me\Gold))
GY_UpdateLabel(LTradingCost, LanguageString$(LS_Cost) + " " + Money$(0))
For i = 0 To 31
If TradeItems(i) <> Null Then FreeItemInstance(TradeItems(i))
TradeAmounts(i) = 0
GYG.GY_Gadget = Object.GY_Gadget(BSlotsHis(i))
GYB.GY_Button = Object.GY_Button(GYG\TypeHandle)
EntityTexture GYB\Gadget\EN, GYB\UserTexture
GY_SetButtonState(BSlotsHis(i), True)
GY_LockGadget(BSlotsHis(i), True)
GY_SetButtonLabel(BSlotsHis(i), "")
GYG.GY_Gadget = Object.GY_Gadget(BSlotsMine(i))
GYB.GY_Button = Object.GY_Button(GYG\TypeHandle)
EntityTexture GYB\Gadget\EN, GYB\UserTexture
GY_SetButtonState(BSlotsMine(i), True)
GY_LockGadget(BSlotsMine(i), True)
GY_SetButtonLabel(BSlotsMine(i), "")
If Me\Inventory\Items[i + SlotI_Backpack] <> Null
EntityTexture GYB\Gadget\EN, GetTexture(Me\Inventory\Items[i + SlotI_Backpack]\Item\ThumbnailTexID)
GY_SetButtonState(BSlotsMine(i), False)
If Me\Inventory\Amounts[i + SlotI_Backpack] > 1
GY_SetButtonLabel(BSlotsMine(i), Me\Inventory\Amounts[i + SlotI_Backpack], 100, 255, 0, True)
Else
GY_SetButtonLabel(BSlotsMine(i), "")
EndIf
GY_LockGadget(BSlotsMine(i), False)
EndIf
Next
; Trade with NPC or scenery object
TradeWith$ = Left$(M\MessageData$, 1)
If TradeWith$ = "N" Or TradeWith$ = "S"
If TradeWith$ = "S"
GY_GadgetAlpha(LTradingCost, 0.0)
TradeType = 3
Else
TradeType = 1
EndIf
GY_GadgetAlpha(BCostUp, 0.0)
GY_GadgetAlpha(BCostDown, 0.0)
Offset = 2
Num = 0
LockTextures()
While Offset < Len(M\MessageData$)
; TradeItems / TradeAmounts / ServerTradeIDs /
; BSlotsHis are all Dim'd (31) = 32 slots. A
; malformed P_OpenTrading payload longer than
; 32 items would Dim-OOB the client. Stop
; walking once the slot table is full.
If Num < 0 Or Num > 31 Then Exit
Item.ItemInstance = ItemInstanceFromString(Mid$(M\MessageData$, Offset, ItemInstanceStringLength()))
TradeItems(Num) = Item
Offset = Offset + ItemInstanceStringLength()
TradeAmounts(Num) = RCE_IntFromStr(Mid$(M\MessageData$, Offset, 2))
ServerTradeIDs(Num) = RCE_IntFromStr(Mid$(M\MessageData$, Offset + 2, 4))
Offset = Offset + 6
GYG.GY_Gadget = Object.GY_Gadget(BSlotsHis(Num))
GYB.GY_Button = Object.GY_Button(GYG\TypeHandle)
EntityTexture GYB\Gadget\EN, GetTexture(Item\Item\ThumbnailTexID)
GY_SetButtonState(BSlotsHis(Num), False)
If TradeAmounts(Num) > 1
GY_SetButtonLabel(BSlotsHis(Num), TradeAmounts(Num), 100, 255, 0, True)
Else
GY_SetButtonLabel(BSlotsHis(Num), "")
EndIf
GY_LockGadget(BSlotsHis(Num), False)
Num = Num + 1
Wend
UnlockTextures()
; Trade with player
ElseIf TradeWith$ = "P"
TradeType = 2
TradeCost = 0
EndIf
EndIf
EndIf
; Screen flash
Case P_ScreenFlash
Red = RCE_IntFromStr(Mid$(M\MessageData$, 1, 1))
Green = RCE_IntFromStr(Mid$(M\MessageData$, 2, 1))
Blue = RCE_IntFromStr(Mid$(M\MessageData$, 3, 1))
Alpha# = RCE_IntFromStr(Mid$(M\MessageData$, 4, 1)) / 255.0
Length = RCE_IntFromStr(Mid$(M\MessageData$, 5, 4))
TexID = RCE_IntFromStr(Mid$(M\MessageData$, 9, 2))
ScreenFlash(Red, Green, Blue, TexID, Length, Alpha#)
; Received XP points, or somebody got a level-up
Case P_XPUpdate
; The position of my XP bar changed
If Left(M\MessageData$, 1) = "B"
Me\XPBarLevel = RCE_IntFromStr(Mid$(M\MessageData$, 2))
UpdateXPBar()
; I received XP points
ElseIf Left(M\MessageData$, 1) = "M"
XP = RCE_IntFromStr(Mid$(M\MessageData$, 2))
Me\XP = Me\XP + XP
Output(Str$(XP) + " " + LanguageString$(LS_XPReceived), 255, 225, 100)
; Another actor's level changed
ElseIf Left(M\MessageData$, 1) = "L"
RuntimeID = RCE_IntFromStr(Mid$(M\MessageData$, 2, 2))
Level = RCE_IntFromStr(Mid$(M\MessageData$, 4, 2))
AI.ActorInstance = RuntimeIDList(RuntimeID)
If AI <> Null Then AI\Level = Level
; My level has been changed
ElseIf Left(M\MessageData$, 1) = "U"
Level = RCE_IntFromStr(Mid$(M\MessageData$, 2))
Me\Level = Level
Me\XP = 0
EndIf
; Animate actor
Case P_AnimateActor
RuntimeID = RCE_IntFromStr(Left$(M\MessageData$, 2))
A.ActorInstance = RuntimeIDList(RuntimeID)
If A <> Null
FixedSpeed = RCE_IntFromStr(Mid$(M\MessageData$, 3, 1))
Speed# = RCE_FloatFromStr#(Mid$(M\MessageData$, 4, 4))
Anim$ = Mid$(M\MessageData$, 8)
If A\Gender = 0
ID = FindAnimation(AnimList(A\Actor\MAnimationSet), Anim$)
Else
ID = FindAnimation(AnimList(A\Actor\FAnimationSet), Anim$)
EndIf
If ID > -1
PlayAnimation(A, 3, Speed#, ID, FixedSpeed)
A\DestX# = EntityX#(A\CollisionEN)
A\DestZ# = EntityZ#(A\CollisionEN)
EndIf
EndIf
; Actor speech
Case P_Speech
ID = RCE_IntFromStr(Mid$(M\MessageData$, 1, 2))
AI.ActorInstance = RuntimeIDList(RCE_IntFromStr(Mid$(M\MessageData$, 3, 2)))
If AI <> Null Then PlayActorSound(AI, ID)
; Sound effect
Case P_Sound
ID = RCE_IntFromStr(Mid$(M\MessageData$, 1, 2))
Name$ = GetSoundName$(ID)
S = GetSound(ID)
If Asc(Right$(Name$, 1)) = True
AI.ActorInstance = RuntimeIDList(RCE_IntFromStr(Mid$(M\MessageData$, 3, 2)))
If AI <> Null
Channel = EmitSound(S, AI\CollisionEN)
If Channel <> 0 Then ChannelVolume(Channel, DefaultVolume#)
EndIf
Else
Channel = PlaySound(S)
If Channel <> 0 Then ChannelVolume(Channel, DefaultVolume#)
EndIf
; Music. Each P_Music packet loads and starts looping a sound;
; the previous code never stopped the prior channel or freed
; the prior sound handle, so every zone-transition leaked one
; sound and one channel for the life of the session.
Case P_Music
Name$ = GetMusicName$(RCE_IntFromStr(Mid$(M\MessageData$, 1, 2)))
If CurrentMusicChannel <> 0 Then StopChannel CurrentMusicChannel
If CurrentMusicSound <> 0 Then FreeSound CurrentMusicSound
CurrentMusicChannel = 0
CurrentMusicSound = 0
CurrentMusicSound = LoadSound("Data\Music\" + Name$, False)
If CurrentMusicSound <> 0
LoopSound CurrentMusicSound
CurrentMusicChannel = PlaySound(CurrentMusicSound)
If CurrentMusicChannel <> 0 Then ChannelVolume(CurrentMusicChannel, DefaultVolume#)
EndIf
; Particles effect
Case P_CreateEmitter
TexID = RCE_IntFromStr(Mid$(M\MessageData$, 1, 2))
Time = RCE_IntFromStr(Mid$(M\MessageData$, 3, 4))
RuntimeID = RCE_IntFromStr(Mid$(M\MessageData$, 7, 2))
XPos# = RCE_FloatFromStr#(Mid$(M\MessageData$, 9, 4))
YPos# = RCE_FloatFromStr#(Mid$(M\MessageData$, 13, 4))
ZPos# = RCE_FloatFromStr#(Mid$(M\MessageData$, 17, 4))
Name$ = Mid$(M\MessageData$, 21)
; Reject path-traversal names from a hostile / compromised
; server. Without these checks, a server could pass "..\..\<x>"
; to navigate out of Data\Emitter Configs, and a non-existent
; file would RuntimeError the client (DoS by any malicious
; server sending one packet).
ValidEmitter = True
If Len(Name$) < 1 Or Len(Name$) > 240 Then ValidEmitter = False
If ValidEmitter
For nameI = 1 To Len(Name$)
Local nameCh = Asc(Mid$(Name$, nameI, 1))
; Reject control bytes, drive-letter ':', and slashes.
If nameCh < 32 Or nameCh > 126 Or nameCh = 58 Or nameCh = 47 Or nameCh = 92
ValidEmitter = False
Exit
EndIf
Next
EndIf
If ValidEmitter And Instr(Name$, "..") > 0 Then ValidEmitter = False
If ValidEmitter
Em.ScriptedEmitter = New ScriptedEmitter
Em\Length = Time
Em\StartTime = MilliSecs()
Config = RP_LoadEmitterConfig("Data\Emitter Configs\" + Name$ + ".rpc", GetTexture(TexID), Cam)
; Soft-fail (log + drop) instead of RuntimeError on missing
; or unloadable emitter -- any server can otherwise hard-
; kill clients with one packet referencing a non-existent
; name.
If Config = 0
WriteLog(MainLog, "P_CreateEmitter: failed to load " + Name$)
Delete Em
Else
Em\EN = RP_CreateEmitter(Config)
AI.ActorInstance = RuntimeIDList(RuntimeID)
If AI <> Null
EntityParent(Em\EN, AI\CollisionEN)
RotateEntity(Em\EN, EntityPitch#(AI\CollisionEN), EntityYaw#(AI\CollisionEN), EntityRoll#(AI\CollisionEN))
If AI = Me Then Em\AttachedToPlayer = True
EndIf
PositionEntity Em\EN, XPos#, YPos#, ZPos#
EndIf
EndIf
; Known spell update
Case P_KnownSpellUpdate
; Spell added
If Left$(M\MessageData$, 1) = "A"
; KnownSpells / SpellLevels are Field[999] (1000 slots).
; The global `Spells` counter grew unchecked from the
; previous handler; a malformed or hostile server could
; spam P_KnownSpellUpdate "A" past 999 and OOB-write the
; client. Drop further adds once the slot table is full.
If Spells >= 0 And Spells <= 999 And Me\SpellLevels[Spells] = 0
DebugLog "Spell creation entered"
Offset = 2
Me\SpellLevels[Spells] = RCE_IntFromStr(Mid$(M\MessageData$, Offset, 2))
Sp.Spell = New Spell
Sp\ID = RCE_IntFromStr(Mid$(M\MessageData$, Offset + 2, 2))
; SpellsList is Dim'd 65534. Wire field carries 0..65535;
; clamp Sp\ID before the Dim write to avoid an OOB
; assignment that would corrupt adjacent globals.
If Sp\ID < 0 Or Sp\ID > 65534
Delete Sp
Goto SkipKnownSpellAdd
EndIf
SpellsList(Sp\ID) = Sp
Me\KnownSpells[Spells] = Sp\ID
Sp\ThumbnailTexID = RCE_IntFromStr(Mid$(M\MessageData$, Offset + 4, 2))
Sp\RechargeTime = RCE_IntFromStr(Mid$(M\MessageData$, Offset + 6, 2))
Offset = Offset + 8
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, Offset, 2))
Sp\Name$ = Mid$(M\MessageData$, Offset + 2, NameLen)
Offset = Offset + 2 + NameLen
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, Offset, 2))
Sp\Description$ = Mid$(M\MessageData$, Offset + 2, NameLen)
Offset = Offset + 2 + NameLen
If RCE_IntFromStr(Mid$(M\MessageData$, Offset, 1)) = True And Memorised < 10
Me\MemorisedSpells[Memorised] = Spells
Memorised = Memorised + 1
EndIf
Spells = Spells + 1
SortSpells()
.SkipKnownSpellAdd
EndIf
; Spell removed
ElseIf Left$(M\MessageData$, 1) = "D"
Name$ = Upper$(Mid$(M\MessageData$, 2))
; Remove the spell from spellbar
found = False
If ActionBarStart = 2
Offset = 12
ElseIf ActionBarStart = 3
Offset = 24
EndIf
For i = 0 To 11
slot = i + offset
If ActionBarSlots(slot) < 0
; MemorisedSpells is Field[9]; KnownSpells is Field[999];
; ClientSpellNameMatches bound-checks SpellsList[65534]
; + Null-checks the slot. Stale slot would otherwise
; deref SpellsList(...)\Name$ on a Null and crash.
If RequireMemorise
Num = ActionBarSlots(slot) + 10
If Num >= 0 And Num <= 9
Mem = Me\MemorisedSpells[Num]
If Mem >= 0 And Mem <= 999
If ClientSpellNameMatches%(Me\KnownSpells[Mem], Name$) Then found = True
EndIf
EndIf
Else
Num = ActionBarSlots(slot) + 1000
If Num >= 0 And Num <= 999
If ClientSpellNameMatches%(Me\KnownSpells[Num], Name$) Then found = True
EndIf
EndIf
If found = True
ActionBarSlots(slot) = 0
GYG.GY_Gadget = Object.GY_Gadget(BActionBar(i))
GYB.GY_Button = Object.GY_Button(GYG\TypeHandle)
EntityTexture GYB\Gadget\EN, GYB\UserTexture
EndIf
found = False
EndIf
Next
; Remove memorised
For i = 0 To 9
If Me\MemorisedSpells[i] <> 5000
Mem = Me\MemorisedSpells[i]
If Mem >= 0 And Mem <= 999
If ClientSpellNameMatches%(Me\KnownSpells[Mem], Name$) Then Me\MemorisedSpells[i] = 5000
EndIf
EndIf
Next
; Remove known
For i = 0 To 999
If Me\SpellLevels[i] > 0
If ClientSpellNameMatches%(Me\KnownSpells[i], Name$)
Me\KnownSpells[i] = 0
Me\SpellLevels[i] = 0
EndIf
EndIf
Next
If SpellsVisible Then UpdateSpellbook()
; Spell level update
ElseIf Left$(M\MessageData$, 1) = "L"
Level = RCE_IntFromStr(Mid$(M\MessageData$, 2, 4))
Name$ = Upper$(Mid$(M\MessageData$, 6))
For i = 0 To 999
If Me\SpellLevels[i] > 0
If ClientSpellNameMatches%(Me\KnownSpells[i], Name$) Then Me\SpellLevels[i] = Level
EndIf
Next
If SpellsVisible Then UpdateSpellbook()
EndIf
; Name change
Case P_NameChange
RuntimeID = RCE_IntFromStr(Left$(M\MessageData$, 2))
A.ActorInstance = RuntimeIDList(RuntimeID)
If A <> Null
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, 3, 1))
A\Name$ = Mid$(M\MessageData$, 4, NameLen)
A\Tag$ = Mid$(M\MessageData$, 4 + NameLen)
If A <> Me Then CreateActorNametag(A)
EndIf
; Gold change
Case P_GoldChange
Amount = RCE_IntFromStr(Mid$(M\MessageData$, 2))
If Left$(M\MessageData$, 1) = "D" Then Amount = 0 - Amount
Me\Gold = Me\Gold + Amount
If Me\Gold < 0 Then Me\Gold = 0
If InventoryVisible = True Then GY_UpdateLabel(LInventoryGold, Money$(Me\Gold))
; Quest log update
Case P_QuestLog
; New entry
If Left$(M\MessageData$, 1) = "N"
For i = 0 To 499
If QuestLog\EntryName$[i] = ""
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, 2, 1))
QuestLog\EntryName$[i] = Mid$(M\MessageData$, 3, NameLen)
Offset = 3 + NameLen
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, Offset, 2))
QuestLog\EntryStatus$[i] = Mid$(M\MessageData$, Offset + 2, NameLen)
Output(LanguageString$(LS_QuestLogUpdate), 255, 225, 100)
Exit
EndIf
Next
; Status update
ElseIf Left$(M\MessageData$, 1) = "U"
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, 2, 1))
Name$ = Upper$(Mid$(M\MessageData$, 3, NameLen))
Offset = 3 + NameLen
For i = 0 To 499
If Upper$(QuestLog\EntryName$[i]) = Name$
NameLen = RCE_IntFromStr(Mid$(M\MessageData$, Offset, 2))
QuestLog\EntryStatus$[i] = Mid$(M\MessageData$, Offset + 2, NameLen)
Output(LanguageString$(LS_QuestLogUpdate), 255, 225, 100)
Exit
EndIf
Next
; Quest deleted
ElseIf Left$(M\MessageData$, 1) = "D"
Name$ = Upper$(Mid$(M\MessageData$, 2))
For i = 0 To 499
If Upper$(QuestLog\EntryName$[i]) = Name$
QuestLog\EntryName$[i] = ""
QuestLog\EntryStatus$[i] = ""
Exit
EndIf
Next
EndIf
If QuestLogVisible Then RedrawQuestLog()
; Character stat update
Case P_StatUpdate
A.ActorInstance = RuntimeIDList(RCE_IntFromStr(Mid$(M\MessageData$, 2, 2)))
; A can be Null if the server names a RuntimeID we haven't
; created yet (race on actor spawn) -- guard before any
; field access. Attribute index also comes off the wire