1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 //
21 // cg_parse.c
22 //
23
24 #include "cg_local.h"
25
26 /*
27 ================
28 CG_ParseClientinfo
29
30 Load the skin, icon, and model for a client
31 ================
32 */
CG_ParseClientinfo(int player)33 void CG_ParseClientinfo (int player)
34 {
35 cg.gloomCheckClass = (cg.playerNum == player) ? qTrue : qFalse;
36
37 CG_LoadClientinfo (&cg.clientInfo[player], cg.configStrings[player+CS_PLAYERSKINS]);
38 }
39
40
41 /*
42 =================
43 CG_ParseConfigString
44 =================
45 */
CG_ParseConfigString(int num,char * str)46 void CG_ParseConfigString (int num, char *str)
47 {
48 char oldCfgStr[MAX_CFGSTRLEN];
49
50 if (num < 0 || num >= MAX_CFGSTRINGS)
51 Com_Error (ERR_DROP, "CG_ParseConfigString: bad num");
52
53 strncpy (oldCfgStr, cg.configStrings[num], sizeof (oldCfgStr));
54 oldCfgStr[sizeof(oldCfgStr)-1] = '\0';
55
56 strcpy (cg.configStrings[num], str);
57
58 // Do something apropriate
59 if (num >= CS_LIGHTS && num < CS_LIGHTS+MAX_CS_LIGHTSTYLES) {
60 // Lightstyle
61 CG_SetLightstyle (num-CS_LIGHTS);
62 }
63 else if (num >= CS_MODELS && num < CS_MODELS+MAX_CS_MODELS) {
64 // Model
65 if (cg.mapLoading || cg.mapLoaded) {
66 cg.modelCfgDraw[num-CS_MODELS] = cgi.R_RegisterModel (cg.configStrings[num]);
67 if (cg.configStrings[num][0] == '*')
68 cg.modelCfgClip[num-CS_MODELS] = cgi.CM_InlineModel (cg.configStrings[num]);
69 else
70 cg.modelCfgClip[num-CS_MODELS] = NULL;
71 }
72 else {
73 cg.modelCfgClip[num-CS_MODELS] = NULL;
74 cg.modelCfgDraw[num-CS_MODELS] = NULL;
75 }
76 }
77 else if (num >= CS_SOUNDS && num < CS_SOUNDS+MAX_CS_SOUNDS) {
78 // Sound
79 if (cg.configStrings[num][0])
80 cg.soundCfgStrings[num-CS_SOUNDS] = cgi.Snd_RegisterSound (cg.configStrings[num]);
81 }
82 else if (num >= CS_IMAGES && num < CS_IMAGES+MAX_CS_IMAGES) {
83 // Image
84 cg.imageCfgStrings[num-CS_IMAGES] = CG_RegisterPic (cg.configStrings[num]);
85 }
86 else if (num == CS_MAXCLIENTS) {
87 // Max client count
88 if (!cg.attractLoop)
89 cg.maxClients = atoi (cg.configStrings[CS_MAXCLIENTS]);
90 }
91 else if (num >= CS_PLAYERSKINS && num < CS_PLAYERSKINS+MAX_CS_CLIENTS) {
92 // Skin
93 if (strcmp (oldCfgStr, str))
94 CG_ParseClientinfo (num-CS_PLAYERSKINS);
95 }
96 }
97
98 /*
99 ==============================================================
100
101 SERVER MESSAGE PARSING
102
103 ==============================================================
104 */
105
106 static qBool in_parseSequence = qFalse;
107
108 /*
109 ==============
110 CG_StartServerMessage
111
112 Called by the client BEFORE all server messages have been parsed
113 ==============
114 */
CG_StartServerMessage(void)115 void CG_StartServerMessage (void)
116 {
117 in_parseSequence = qTrue;
118 }
119
120
121 /*
122 ==============
123 CG_EndServerMessage
124
125 Called by the client AFTER all server messages have been parsed
126 ==============
127 */
CG_EndServerMessage(int realTime)128 void CG_EndServerMessage (int realTime)
129 {
130 in_parseSequence = qFalse;
131
132 cg.realTime = realTime;
133
134 CG_AddNetgraph ();
135 SCR_UpdatePING ();
136 }
137
138
139 /*
140 ==============
141 CG_ParseServerMessage
142
143 Parses command operations known to the game dll
144 Returns qTrue if the message was parsed
145 ==============
146 */
CG_ParseServerMessage(int command)147 qBool CG_ParseServerMessage (int command)
148 {
149 switch (command) {
150 case SVC_CENTERPRINT:
151 SCR_ParseCenterPrint ();
152 return qTrue;
153
154 case SVC_INVENTORY:
155 Inv_ParseInventory ();
156 return qTrue;
157
158 case SVC_LAYOUT:
159 HUD_CopyLayout ();
160 return qTrue;
161
162 case SVC_MUZZLEFLASH:
163 CG_ParseMuzzleFlash ();
164 return qTrue;
165
166 case SVC_MUZZLEFLASH2:
167 CG_ParseMuzzleFlash2 ();
168 return qTrue;
169
170 case SVC_TEMP_ENTITY:
171 CG_ParseTempEnt ();
172 return qTrue;
173
174 default:
175 return qFalse;
176 }
177 }
178