forked from SpiritQuaddicted/reQuiem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cl_parse.c
2514 lines (2152 loc) · 58.2 KB
/
cl_parse.c
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
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// cl_parse.c -- parse a message received from the server
#include "quakedef.h"
#ifndef RQM_SV_ONLY
#define NUM_SVC (svc_updatepl+1)
static const char *svc_strings[NUM_SVC] =
{
"svc_bad",
"svc_nop",
"svc_disconnect",
"svc_updatestat",
"svc_version", // [long] server version
"svc_setview", // [short] entity number
"svc_sound", // <see code>
"svc_time", // [float] server time
"svc_print", // [string] null terminated string
"svc_stufftext", // [string] stuffed into client's console buffer
// the string should be \n terminated
"svc_setangle", // [vec3] set the view angle to this absolute value
"svc_serverinfo", // [long] version
// [string] signon string
// [string]..[0]model cache [string]...[0]sounds cache
// [string]..[0]item cache
"svc_lightstyle", // [byte] [string]
"svc_updatename", // [byte] [string]
"svc_updatefrags", // [byte] [short]
"svc_clientdata", // <shortbits + data>
"svc_stopsound", // <see code>
"svc_updatecolors", // [byte] [byte]
"svc_particle", // [vec3] <variable>
"svc_damage", // [byte] impact [byte] blood [vec3] from
"svc_spawnstatic",
"OBSOLETE svc_spawnbinary",
"svc_spawnbaseline",
"svc_temp_entity", // <variable>
"svc_setpause",
"svc_signonnum",
"svc_centerprint",
"svc_killedmonster",
"svc_foundsecret",
"svc_spawnstaticsound",
"svc_intermission",
"svc_finale", // [string] music [string] text
"svc_cdtrack", // [byte] track [byte] looptrack
"svc_sellscreen",
"svc_cutscene",
// nehahra support begin
"svc_showlmp", // [string] iconlabel [string] lmpfile [byte] x [byte] y
"svc_hidelmp", // [string] iconlabel
"svc_skybox", // [string] skyname
// nehahra support end
"?",
"?",
"?",
"svc_fog_fitz",
"?",
"?",
"?",
"?",
"?",
"?",
"?",
"?",
"svc_skyboxsize",
"svc_fog_neh",
"?",
"?"
};
static const char *svc_strings_QW[NUM_SVC];
#ifdef HEXEN2_SUPPORT
static const char *svc_strings_H2[NUM_SVC];
extern qboolean intro_playing;
extern cvar_t bgmtype, sv_flypitch, sv_walkpitch;
extern int sv_kingofhill;
extern int total_loading_size, current_loading_size, loading_stage;
#endif
extern cvar_t host_cutscenehack;
/*
const char *hipnotic_models[] =
{
"progs/armabody.mdl",
"progs/armalegs.mdl",
"progs/empathy.mdl",
"progs/g_hammer.mdl",
"progs/g_laserg.mdl",
"progs/g_prox.mdl",
"progs/grem.mdl",
"progs/h_grem.mdl",
"progs/h_scourg.mdl",
"progs/horn.mdl",
"progs/lasrspik.mdl",
"progs/lavarock.mdl",
"progs/playham.mdl",
"progs/proxbomb.mdl",
"progs/rubble1.mdl",
"progs/rubble2.mdl",
"progs/rubble3.mdl",
"progs/scor.mdl",
"progs/spikmine.mdl",
"progs/v_hammer.mdl",
"progs/v_laserg.mdl",
"progs/v_prox.mdl",
"progs/wetsuit.mdl",
NULL
};
*/
//=============================================================================
void CL_InitModelnames (void)
{
int i;
memset (cl_modelnames, 0, sizeof(cl_modelnames));
cl_modelnames[mi_player] = "progs/player.mdl";
cl_modelnames[mi_h_player] = "progs/h_player.mdl";
cl_modelnames[mi_eyes] = "progs/eyes.mdl";
cl_modelnames[mi_rocket] = "progs/missile.mdl";
cl_modelnames[mi_grenade] = "progs/grenade.mdl";
cl_modelnames[mi_spike] = "progs/spike.mdl";
cl_modelnames[mi_explo1] = "progs/s_expl.spr";
cl_modelnames[mi_explo2] = "progs/s_explod.spr";
cl_modelnames[mi_bubble] = "progs/s_bubble.spr";
cl_modelnames[mi_sng] = "progs/v_nail2.mdl"; //JDH
cl_modelnames[mi_flame0] = "progs/flame0.mdl";
cl_modelnames[mi_flame1] = "progs/flame.mdl";
cl_modelnames[mi_flame2] = "progs/flame2.mdl";
cl_modelnames[mi_gib1] = "progs/gib1.mdl";
cl_modelnames[mi_gib2] = "progs/gib2.mdl";
cl_modelnames[mi_gib3] = "progs/gib3.mdl";
cl_modelnames[mi_fish] = "progs/fish.mdl";
cl_modelnames[mi_dog] = "progs/dog.mdl";
cl_modelnames[mi_soldier] = "progs/soldier.mdl";
cl_modelnames[mi_enforcer] = "progs/enforcer.mdl";
cl_modelnames[mi_knight] = "progs/knight.mdl";
cl_modelnames[mi_hknight] = "progs/hknight.mdl";
cl_modelnames[mi_scrag] = "progs/wizard.mdl";
cl_modelnames[mi_ogre] = "progs/ogre.mdl";
cl_modelnames[mi_fiend] = "progs/demon.mdl";
cl_modelnames[mi_vore] = "progs/shalrath.mdl";
cl_modelnames[mi_shambler] = "progs/shambler.mdl";
/* moved to alias loading code
cl_modelnames[mi_h_dog] = "progs/h_dog.mdl";
cl_modelnames[mi_h_soldier] = "progs/h_guard.mdl";
cl_modelnames[mi_h_enforcer] = "progs/h_mega.mdl";
cl_modelnames[mi_h_knight] = "progs/h_knight.mdl";
// cl_modelnames[mi_h_hknight] = "progs/h_hknight.mdl";
cl_modelnames[mi_h_hknight] = "progs/h_hellkn.mdl";
cl_modelnames[mi_h_scrag] = "progs/h_wizard.mdl";
cl_modelnames[mi_h_ogre] = "progs/h_ogre.mdl";
cl_modelnames[mi_h_fiend] = "progs/h_demon.mdl";
cl_modelnames[mi_h_vore] = "progs/h_shal.mdl";
cl_modelnames[mi_h_shambler] = "progs/h_shams.mdl";
cl_modelnames[mi_h_zombie] = "progs/h_zombie.mdl";
*/
for (i=0 ; i<NUM_MODELINDEX ; i++)
{
if (!cl_modelnames[i])
Host_Error ("cl_modelnames[%d] not initialized", i); // JDH: was Sys_Error
}
}
void CL_InitMessageStrings (void)
{
int i;
for (i=0; i < NUM_SVC; i++)
{
svc_strings_QW[i] = svc_strings[i];
#ifdef HEXEN2_SUPPORT
svc_strings_H2[i] = svc_strings[i];
#endif
}
svc_strings_QW[svc_smallkick] = "svc_smallkick";
svc_strings_QW[svc_bigkick] = "svc_bigkick";
svc_strings_QW[svc_updateping] = "svc_updateping";
svc_strings_QW[svc_updateentertime] = "svc_updateentertime";
svc_strings_QW[svc_updatestatlong] = "svc_updatestatlong";
svc_strings_QW[svc_muzzleflash] = "svc_muzzleflash";
svc_strings_QW[svc_updateuserinfo] = "svc_updateuserinfo";
svc_strings_QW[svc_download] = "svc_download";
svc_strings_QW[svc_playerinfo] = "svc_playerinfo";
svc_strings_QW[svc_nails] = "svc_nails";
svc_strings_QW[svc_chokecount] = "svc_chokecount";
svc_strings_QW[svc_modellist] = "svc_modellist";
svc_strings_QW[svc_soundlist] = "svc_soundlist";
svc_strings_QW[svc_packetentities] = "svc_packetentities";
svc_strings_QW[svc_deltapacketentities] = "svc_deltapacketentities";
svc_strings_QW[svc_maxspeed] = "svc_maxspeed";
svc_strings_QW[svc_entgravity] = "svc_entgravity";
svc_strings_QW[svc_setinfo] = "svc_setinfo";
svc_strings_QW[svc_serverinfo_qw] = "svc_serverinfo_qw";
svc_strings_QW[svc_updatepl] = "svc_updatepl";
#ifdef HEXEN2_SUPPORT
svc_strings_H2[svc_raineffect] = "svc_raineffect";
svc_strings_H2[svc_particle2] = "svc_particle2";
svc_strings_H2[svc_cutscene_H2] = "svc_cutscene_H2";
svc_strings_H2[svc_midi_name] = "svc_midi_name";
svc_strings_H2[svc_updateclass] = "svc_updateclass";
svc_strings_H2[svc_particle3] = "svc_particle3";
svc_strings_H2[svc_particle4] = "svc_particle4";
svc_strings_H2[svc_set_view_flags] = "svc_set_view_flags";
svc_strings_H2[svc_clear_view_flags] = "svc_clear_view_flags";
svc_strings_H2[svc_start_effect] = "svc_start_effect";
svc_strings_H2[svc_end_effect] = "svc_end_effect";
svc_strings_H2[svc_plaque] = "svc_plaque";
svc_strings_H2[svc_particle_explosion] = "svc_particle_explosion";
svc_strings_H2[svc_set_view_tint] = "svc_set_view_tint";
svc_strings_H2[svc_reference] = "svc_reference";
svc_strings_H2[svc_clear_edicts] = "svc_clear_edicts";
svc_strings_H2[svc_update_inv] = "svc_update_inv";
svc_strings_H2[svc_setangle_interpolate] = "svc_setangle_interpolate";
svc_strings_H2[svc_update_kingofhill] = "svc_update_kingofhill";
svc_strings_H2[svc_toggle_statbar] = "svc_toggle_statbar";
svc_strings_H2[svc_sound_update_pos] = "svc_sound_update_pos";
#endif
}
void CL_InitStrings (void)
{
CL_InitModelnames ();
CL_InitMessageStrings ();
}
/*
===============
CL_EntityNum
This error checks and tracks the total number of entities
===============
*/
entity_t *CL_EntityNum (int num)
{
if (num < 0) // JDH
goto BADENTNUM;
if (num >= cl.num_entities)
{
if (num >= MAX_EDICTS)
goto BADENTNUM;
while (cl.num_entities <= num)
{
cl_entities[cl.num_entities].colormap = vid.colormap;
cl.num_entities++;
}
}
return &cl_entities[num];
BADENTNUM:
if (!cls.demoplayback)
Host_Error ("CL_EntityNum: %i is an invalid number", num);
Con_DPrintf ("\x02""Warning: invalid entity number %i; skipping to next message\n", num);
return NULL;
}
/*
==================
CL_ParseStartSoundPacket
==================
*/
qboolean CL_ParseStartSoundPacket (qboolean parse_only)
{
vec3_t pos;
int i, channel, ent, sound_num, volume, field_mask;
float attenuation;
if (cl.protocol != PROTOCOL_VERSION_QW)
{
field_mask = MSG_ReadByte ();
volume = (field_mask & SND_VOLUME) ? MSG_ReadByte() : DEFAULT_SOUND_PACKET_VOLUME;
attenuation = (field_mask & SND_ATTENUATION) ? MSG_ReadByte() / 64.0 : DEFAULT_SOUND_PACKET_ATTENUATION;
}
if ((cl.protocol == PROTOCOL_VERSION_FITZ) && (field_mask & SND_LARGEENTITY))
{
ent = (unsigned short) MSG_ReadShort ();
channel = MSG_ReadByte ();
}
else
{
channel = (unsigned short) MSG_ReadShort ();
ent = channel >> 3;
if (cl.protocol == PROTOCOL_VERSION_QW)
{
ent &= 0x03FF;
if (channel & 0x8000)
volume = MSG_ReadByte ();
else
volume = DEFAULT_SOUND_PACKET_VOLUME;
if (channel & 0x4000)
attenuation = MSG_ReadByte () / 64.0;
else
attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
}
channel &= 7;
}
if (ent > MAX_EDICTS)
{
if (cls.demoplayback) // JDH
{
Con_DPrintf ("\x02""Warning: invalid entity %i for svc_sound\n", ent);
return false;
}
Host_Error ("CL_ParseStartSoundPacket: ent = %i", ent);
}
if (((cl.protocol > PROTOCOL_VERSION_BJP) && (cl.protocol <= PROTOCOL_VERSION_BJP3)) ||
((cl.protocol == PROTOCOL_VERSION_FITZ) && (field_mask & SND_LARGESOUND)))
sound_num = (unsigned short) MSG_ReadShort();
else
sound_num = MSG_ReadByte ();
#ifdef HEXEN2_SUPPORT
if (hexen2 && (field_mask & SND_OVERFLOW))
sound_num += 255;
#endif
for (i=0 ; i<3 ; i++)
pos[i] = MSG_ReadCoord ();
if (!parse_only)
S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation);
return true;
}
/*
==================
CL_KeepaliveMessage
When the client is taking a long time to load stuff, send keepalive messages
so the server doesn't disconnect.
==================
*/
void CL_KeepaliveMessage (void)
{
float time;
static float lastmsg;
int ret;
sizebuf_t old;
byte olddata[NET_MAXMESSAGE]; // JDH: was [8192]
if (sv.active)
return; // no need if server is local
if (cls.demoplayback)
return;
// read messages from server, should just be nops
old = net_message;
memcpy (olddata, net_message.data, net_message.cursize);
do {
ret = CL_GetMessage ();
switch (ret)
{
default:
Host_Error ("CL_KeepaliveMessage: CL_GetMessage failed");
case 0:
break; // nothing waiting
case 1:
Host_Error ("CL_KeepaliveMessage: received a message");
break;
case 2:
if (MSG_ReadByte() != svc_nop)
Host_Error ("CL_KeepaliveMessage: datagram wasn't a nop");
break;
}
} while (ret);
net_message = old;
memcpy (net_message.data, olddata, net_message.cursize);
// check time
time = Sys_DoubleTime ();
if (time - lastmsg < 5)
return;
lastmsg = time;
// write out a nop
Con_Print ("--> client to server keepalive\n");
MSG_WriteByte (&cls.message, clc_nop);
NET_SendMessage (cls.netcon, &cls.message);
SZ_Clear (&cls.message);
}
/*
==================
CL_IsKnownProtocol
==================
*/
qboolean CL_IsKnownProtocol (int *prot)
{
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
// Hexen II v1.03, v1.07 use same protocol version as Quake, but with 2-byte models
return ((*prot == PROTOCOL_VERSION_STD) || (*prot == PROTOCOL_VERSION_H2_111) ||
(*prot == PROTOCOL_VERSION_H2_112));
}
#endif
if ((*prot == PROTOCOL_VERSION_STD) || (*prot == PROTOCOL_VERSION_FITZ) ||
((*prot >= PROTOCOL_VERSION_BJP) && (*prot <= PROTOCOL_VERSION_BJP3)))
return true;
// if (*prot == PROTOCOL_VERSION_DP7)
// return true;
if (cls.demoplayback)
{
if ((*prot >= PROTOCOL_VERSION_QW-2) && (*prot <= PROTOCOL_VERSION_QW))
{
*prot = PROTOCOL_VERSION_QW;
return true;
}
if (*prot == PROTOCOL_VERSION_BETA)
return true;
}
return false;
}
qboolean cl_precache_changed;
char sound_precache[MAX_SOUNDS][MAX_QPATH];
/*
==================
CL_ParseSoundlist
==================
*/
int CL_ParseSoundlist (int startnum)
{
int numsounds;
const char *str;
for (numsounds=startnum ; ; numsounds++)
{
str = MSG_ReadString ();
if (!str[0])
break;
//if (!cl_demoseek)
{
if (numsounds == MAX_SOUNDS)
Host_Error ("Server sent too many sound precaches");
if (cl_demoseek && !cl_precache_changed && sound_precache[numsounds][0])
cl_precache_changed = !COM_FilenamesEqual (sound_precache[numsounds], str);
Q_strcpy (sound_precache[numsounds], str, sizeof(sound_precache[numsounds]));
S_TouchSound (str);
}
}
return numsounds;
}
/*
==================
CL_PrecacheSounds
==================
*/
void CL_PrecacheSounds (int startnum, int numsounds)
{
int i;
/*******JDH*******/
// Con_DPrintf( " client: loading sounds...\n" );
/*******JDH*******/
S_BeginPrecaching ();
for (i=startnum ; i<numsounds ; i++)
{
cl.sound_precache[i] = S_PrecacheSound (sound_precache[i]);
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
current_loading_size++;
SCR_ShowLoadingSize ();
}
#endif
CL_KeepaliveMessage ();
}
S_EndPrecaching ();
}
char model_precache[MAX_MODELS][MAX_QPATH];
/*
==================
CL_ParseModellist
==================
*/
int CL_ParseModellist (int startnum)
{
int nummodels, i;
const char *str;
// first we go through and touch all of the precache data that still
// happens to be in the cache, so precaching something else doesn't
// needlessly purge it
for (nummodels=startnum ; ; nummodels++)
{
str = MSG_ReadString ();
if (!str[0])
break;
//if (!cl_demoseek)
{
if (nummodels == MAX_MODELS)
Host_Error ("Server sent too many model precaches");
if (cl_demoseek && !cl_precache_changed && model_precache[nummodels][0])
cl_precache_changed = !COM_FilenamesEqual (model_precache[nummodels], str);
Q_strcpy (model_precache[nummodels], str, sizeof(model_precache[nummodels]));
Mod_TouchModel (str);
for (i=0 ; i<NUM_MODELINDEX ; i++)
{
if (!strcmp(cl_modelnames[i], str))
{
cl_modelindex[i] = nummodels;
break;
}
}
}
}
return nummodels;
}
extern qboolean COM_FindSearchpath (const char *dir);
extern qboolean Mod_LoadModelFile (const char *name, void *buffer, int bufsize);
/*
==================
CL_ModelInList
==================
*/
qboolean CL_ModelInList (const char *name, const char *mlist[])
{
int i;
for (i = 0; mlist[i]; i++)
{
if (COM_FilenamesEqual(name, mlist[i]))
return true;
}
return false;
}
/*
==================
CL_LocateModels
==================
*/
/*void CL_LocateModels (int startnum, int nummodels)
{
qboolean hipnotic_canload, quoth_canload;
qboolean hipnotic_needed = false;
int i;
hipnotic_canload = (!COM_FindSearchpath ("hipnotic") && Sys_FolderExists (va("%s/hipnotic", com_basedir)));
quoth_canload = (!COM_FindSearchpath ("quoth") && Sys_FolderExists (va("%s/quoth", com_basedir)));
if (!hipnotic_canload && !quoth_canload)
return;
startnum = max(startnum, 2); // skip bsp
for (i=startnum ; i<nummodels ; i++)
{
if (model_precache[i][0] == '*')
continue;
if (Mod_LoadModelFile (model_precache[i], NULL, 0))
continue;
if (hipnotic_canload)
{
if (CL_ModelInList(model_precache[i], hipnotic_models))
hipnotic_needed = true;
}
}
}
*/
/*
==================
CL_PrecacheModels
==================
*/
void CL_PrecacheModels (int startnum, int nummodels)
{
char mapname[MAX_QPATH];
int i;
if (startnum == 1)
{
// by joe
COM_StripExtension (COM_SkipPath(model_precache[1]), mapname, sizeof(mapname));
Host_SetMapName (mapname);
/*******JDH*******/
// Con_DPrintf( " client: loading models...\n" );
/*******JDH*******/
}
// CL_LocateModels (startnum, nummodels);
// now we try to load everything else until a cache allocation fails
for (i=startnum ; i<nummodels ; i++)
{
cl.model_precache[i] = Mod_ForName (model_precache[i], false);
if (!cl.model_precache[i])
{
Con_Printf ("\x02""WARNING: Couldn't load %s\n", model_precache[i]);
if ((i == 1) || (model_precache[i][0] == '*'))
{
Host_EndGame ("Map load failed\n");
return;
}
}
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
current_loading_size++;
SCR_ShowLoadingSize ();
}
#endif
CL_KeepaliveMessage ();
}
if (cl.protocol == PROTOCOL_VERSION_QW)
{
if (MSG_ReadByte())
return; // more models coming
}
// local state
cl_entities[0].model = cl.worldmodel = cl.model_precache[1];
cl_entities[0].fullbright = 0;
noclip_anglehack = false; // noclip is turned off at start
if (cl.protocol == PROTOCOL_VERSION_QW)
{
R_NewMap ();
Hunk_Check (); // make sure nothing is hurt
}
}
extern float cl_demo_starttime, cl_demo_endtime;
/*
==================
CL_ParseServerInfo
==================
*/
void CL_ParseServerInfo (void)
{
char *str;
int i, vers, nummodels, numsounds/*, maxsounds*/;
if (!cl_demoseek)
{
if (!sv.active)
Con_Printf ("\n"); // kludge for demos/servers that don't include \n after server version string
Con_DPrintf ("Serverinfo packet received\n");
// wipe the client_state_t struct
CL_ClearState ();
}
// parse protocol version number
vers = MSG_ReadLong ();
if ((vers == PROTOCOL_VERSION_FTE) && cls.demoplayback)
{
MSG_ReadLong (); // extensions
vers = MSG_ReadLong ();
}
if (!CL_IsKnownProtocol (&vers))
{
Host_Error ("CL_ParseServerInfo: Server is using unknown protocol %i", vers);
// Con_Printf ("Server is using unknown protocol %i\n", vers);
// msg_badread = true;
return;
}
cl.protocol = vers;
if (!cl_demoseek)
{
#ifdef HEXEN2_SUPPORT
if (!hexen2)
#endif
if (vers != PROTOCOL_VERSION_STD)
{
if (cls.demoplayback)
Con_Printf ("Playing protocol %d demo ", vers);
else
Con_Printf ("Using protocol %d ", vers);
switch (vers)
{
case PROTOCOL_VERSION_QW:
Con_Print ("(QuakeWorld)");
break;
case PROTOCOL_VERSION_BJP:
case PROTOCOL_VERSION_BJP2:
case PROTOCOL_VERSION_BJP3:
Con_Printf ("(BJP%d)", vers-PROTOCOL_VERSION_BJP+1);
break;
case PROTOCOL_VERSION_FITZ:
Con_Print ("(Fitz)");
break;
case PROTOCOL_VERSION_BETA:
Con_Print ("(Quake BETA)");
break;
}
Con_Print ("\n");
}
cl_demo_starttime = 0;
cl_demo_endtime = 0;
}
if (cl.protocol == PROTOCOL_VERSION_QW)
{
MSG_ReadLong(); // server count
MSG_ReadString(); // gamedir
cl.viewentity = (MSG_ReadByte() & 0x7F) + 1; // playernum (hi-bit indicates spectator)
// these are not explicitly sent by QW server:
cl.maxclients = 32; // MAX_CLIENTS
cl.viewheight = DEFAULT_VIEWHEIGHT;
}
else
{
// parse maxclients
cl.maxclients = MSG_ReadByte ();
if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD)
{
Con_Printf ("Bad maxclients (%u) from server\n", cl.maxclients);
return;
}
if (cl.protocol != PROTOCOL_VERSION_BETA)
{
// parse gametype
cl.gametype = MSG_ReadByte ();
#ifdef HEXEN2_SUPPORT
if (hexen2 && (cl.gametype == GAME_DEATHMATCH))
sv_kingofhill = MSG_ReadShort ();
#endif
}
}
// parse signon message
str = MSG_ReadString ();
Q_strcpy (cl.levelname, str, sizeof(cl.levelname));
if (!cl_demoseek)
{
// seperate the printf's so the server message can have a color
Con_Print ("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
Con_Printf ("\x02%s\n", cl.levelname);
// JDH: these get cleared by CL_ClearState
// memset (cl.sound_precache, 0, sizeof(cl.sound_precache));
// memset (cl.model_precache, 0, sizeof(cl.model_precache));
cl_precache_changed = true;
}
else
cl_precache_changed = false;
for (i=0 ; i<NUM_MODELINDEX ; i++)
cl_modelindex[i] = -1;
if (cl.protocol == PROTOCOL_VERSION_QW)
{
for (i = 0; i < 10; i++)
MSG_ReadFloat(); // physics values
cls.signon = SIGNONS-1;
return; // sounds & models sent via separate messages
}
nummodels = CL_ParseModellist (1);
numsounds = CL_ParseSoundlist (1);
if (!cl_precache_changed)
{
memset (cl.scores, 0, cl.maxclients * sizeof(*cl.scores));
return;
}
if (cl_demoseek)
{
extern void CL_ClearMapData (void);
extern int host_hunklevel;
// this is equivalent to CL_ClearState minus the CL_ClearDynamic, which was
// already done via CL_ResetState
Mod_ClearAll ();
if (host_hunklevel)
Hunk_FreeToLowMark (host_hunklevel);
CL_ClearMapData ();
}
cl.scores = Hunk_AllocName (cl.maxclients * sizeof(*cl.scores), "scores");
// if (!cl_demoseek)
{
SCR_UpdateLoadCaption (COM_SkipPath(model_precache[1]));
// load the extra "no-flamed-torch" model
// NOTE: this is an ugly hack
#ifdef HEXEN2_SUPPORT
if (!hexen2)
#endif
{
if (nummodels == MAX_MODELS)
{
Con_DPrintf ("Server sent too many model precaches -> replacing flame0.mdl with flame.mdl\n");
cl_modelindex[mi_flame0] = cl_modelindex[mi_flame1];
}
else
{
Q_strcpy (model_precache[nummodels], cl_modelnames[mi_flame0], sizeof(model_precache[nummodels]));
cl_modelindex[mi_flame0] = nummodels++;
}
}
#ifdef HEXEN2_SUPPORT
if (hexen2 /*&& precache.value*/)
{
total_loading_size = nummodels + numsounds;
current_loading_size = 1;
loading_stage = 2;
}
#endif
// precache models
CL_PrecacheModels (1, nummodels);
CL_PrecacheSounds (1, numsounds);
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
total_loading_size = 0;
loading_stage = 0;
}
#endif
R_NewMap ();
Hunk_Check (); // make sure nothing is hurt
}
}
/*
==================
CL_ParseUpdate
Parse an entity update message from the server
If an entity's model or origin changes from frame to frame, it must be
relinked. Other attributes can change without relinking.
==================
*/
//int bitcounts[16];
extern qboolean mod_oversized;
qboolean CL_ParseUpdate (int bits)
{
int startcount, num;
model_t *model;
qboolean forcelink;
entity_t *ent;
int skin, i, colornum;
// float (*readcoord)(void);
if (cls.signon == SIGNONS - 1)
{ // first update is the final signon stage
cls.signon = SIGNONS;
CL_SignonReply ();
}
startcount = msg_readcount;
if (bits & U_MOREBITS)
bits |= (MSG_ReadByte() << 8);
if (cl.protocol == PROTOCOL_VERSION_FITZ)
{
if (bits & U_EXTEND1)
bits |= MSG_ReadByte() << 16;
if (bits & U_EXTEND2)
bits |= MSG_ReadByte() << 24;
}
#ifdef HEXEN2_SUPPORT
else if (hexen2 && (bits & U_MOREBITS2))
bits |= (MSG_ReadByte () << 16);
#endif
num = (bits & U_LONGENTITY) ? MSG_ReadShort() : MSG_ReadByte();
ent = CL_EntityNum (num);
if (!ent)
return false;
#ifdef _DEBUG
if (!ent->model && !(bits & U_MODEL))
if (!ent->baseline.modelindex || (ent->modelindex && (ent->baseline.modelindex != ent->modelindex)))
num *= 1;
if (cl_shownet.value == 2)
Con_Printf (" ent #%d\n", num);
if (num == 70)
num *= 1;
if (num+1 == cl.num_entities) // allocated a new entity
num *= 1;
#endif
// for (i=0 ; i<16 ; i++)
// if (bits & (1 << i))
// bitcounts[i]++;
#ifdef HEXEN2_SUPPORT
if (hexen2)
{
forcelink = CL_ParseUpdate_H2 (ent, num, bits);
}
else
#endif
{
forcelink = (ent->msgtime != cl.mtime_prev) ? true : false;
ent->msgtime = cl.mtime;
if (bits & U_MODEL)
{
/***************** JDH ******************/
if ((cl.protocol <= PROTOCOL_VERSION_STD) || (cl.protocol == PROTOCOL_VERSION_FITZ))
ent->modelindex = MSG_ReadByte ();
else
ent->modelindex = MSG_ReadShort ();
/***************** JDH ******************/