/* ================ CL_ParseLightStyle ================ */ void CL_ParseLightStyle( sizebuf_t *msg ) { int style; const char *s; style = BF_ReadByte( msg ); s = BF_ReadString( msg ); CL_SetLightstyle( style, s ); }
/* ================ CL_ParseConfigString ================ */ void CL_ParseConfigString(void) { int i; char * s; i = MSG_ReadShort(&net_message); if (i < 0 || i >= MAX_CONFIGSTRINGS) { Com_Error(ERR_DROP, "configstring > MAX_CONFIGSTRINGS"); } s = MSG_ReadString(&net_message); strcpy(cl.configstrings[i], s); // do something apropriate if (i >= CS_LIGHTS && i < CS_LIGHTS + MAX_LIGHTSTYLES) { CL_SetLightstyle(i - CS_LIGHTS); } else if (i == CS_CDTRACK) { if (cl.refresh_prepped) { CDAudio_Play(atoi(cl.configstrings[CS_CDTRACK]), true); } } else if (i >= CS_MODELS && i < CS_MODELS + MAX_MODELS) { if (cl.refresh_prepped) { cl.model_draw[i - CS_MODELS] = re.RegisterModel(cl.configstrings[i]); if (cl.configstrings[i][0] == '*') cl.model_clip[i - CS_MODELS] = CM_InlineModel(cl.configstrings[i]); else cl.model_clip[i - CS_MODELS] = NULL; } } else if (i >= CS_SOUNDS && i < CS_SOUNDS + MAX_MODELS) { if (cl.refresh_prepped) cl.sound_precache[i - CS_SOUNDS] = S_RegisterSound(cl.configstrings[i]); } else if (i >= CS_IMAGES && i < CS_IMAGES + MAX_MODELS) { if (cl.refresh_prepped) cl.image_precache[i - CS_IMAGES] = re.RegisterPic(cl.configstrings[i]); } else if (i >= CS_PLAYERSKINS && i < CS_PLAYERSKINS + MAX_CLIENTS) { if (cl.refresh_prepped) CL_ParseClientinfo(i - CS_PLAYERSKINS); } }
static void SetLight_f(bool usage, int argc, char **argv) { if (usage || argc != 3) { appPrintf("Usage: setlight <style> <value=0..2>\n"); return; } if (!cls.cheatsEnabled) return; int style = atoi(argv[1]); if (style < 0 || style > 255) { appWPrintf("bad style: %d\n", style); return; } char str[2]; str[0] = appRound(atof(argv[2]) * ('m' - 'a')) + 'a'; str[1] = 0; CL_SetLightstyle(style, str); }
/* ================ CL_ParseConfigString ================ */ void CL_ParseConfigString (void) { size_t length; int i; char *s; char olds[MAX_QPATH]; i = MSG_ReadShort (&net_message); if (i < 0 || i >= MAX_CONFIGSTRINGS) Com_Error (ERR_DROP, "CL_ParseConfigString: configstring %d >= MAX_CONFIGSTRINGS", i); s = MSG_ReadString(&net_message); Q_strncpy (olds, cl.configstrings[i], sizeof(olds)-1); //Com_Printf ("cs: %i=%s\n", LOG_GENERAL, i, MakePrintable (s)); //r1ch: only allow statusbar to overflow /*if (i >= CS_STATUSBAR && i < CS_AIRACCEL) strncpy (cl.configstrings[i], s, (sizeof(cl.configstrings[i]) * (CS_AIRACCEL - i))-1); else Q_strncpy (cl.configstrings[i], s, sizeof(cl.configstrings[i])-1);*/ //r1: overflow may be desired by some mods in stats programs for example. who knows. length = strlen(s); if (length >= (sizeof(cl.configstrings[0]) * (MAX_CONFIGSTRINGS-i)) - 1) Com_Error (ERR_DROP, "CL_ParseConfigString: configstring %d exceeds available space", i); //r1: don't allow basic things to overflow if (i != CS_NAME && i < CS_GENERAL) { if (i >= CS_STATUSBAR && i < CS_AIRACCEL) { strncpy (cl.configstrings[i], s, (sizeof(cl.configstrings[i]) * (CS_AIRACCEL - i))-1); } else { if (length >= MAX_QPATH) Com_Printf ("WARNING: Configstring %d of length %d exceeds MAX_QPATH.\n", LOG_CLIENT|LOG_WARNING, i, (int)length); Q_strncpy (cl.configstrings[i], s, sizeof(cl.configstrings[i])-1); } } else { strcpy (cl.configstrings[i], s); } // do something apropriate if (i == CS_AIRACCEL) { pm_airaccelerate = (qboolean)atoi(cl.configstrings[CS_AIRACCEL]); } else if (i >= CS_LIGHTS && i < CS_LIGHTS+MAX_LIGHTSTYLES) { CL_SetLightstyle (i - CS_LIGHTS); } #ifdef CD_AUDIO else if (i == CS_CDTRACK) { if (cl.refresh_prepped) CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true); } #endif else if (i >= CS_MODELS && i < CS_MODELS+MAX_MODELS) { if (cl.refresh_prepped) { cl.model_draw[i-CS_MODELS] = re.RegisterModel (cl.configstrings[i]); if (cl.configstrings[i][0] == '*') cl.model_clip[i-CS_MODELS] = CM_InlineModel (cl.configstrings[i]); else cl.model_clip[i-CS_MODELS] = NULL; } //r1: load map whilst connecting to save a bit of time /*if (i == CS_MODELS + 1) { CM_LoadMap (cl.configstrings[CS_MODELS+1], true, &i); if (i && i != atoi(cl.configstrings[CS_MAPCHECKSUM])) Com_Error (ERR_DROP, "Local map version differs from server: 0x%.8x != 0x%.8x\n", i, atoi(cl.configstrings[CS_MAPCHECKSUM])); }*/ } else if (i >= CS_SOUNDS && i < CS_SOUNDS+MAX_MODELS) { if (cl.refresh_prepped) cl.sound_precache[i-CS_SOUNDS] = S_RegisterSound (cl.configstrings[i]); } else if (i >= CS_IMAGES && i < CS_IMAGES+MAX_MODELS) { if (cl.refresh_prepped) re.RegisterPic (cl.configstrings[i]); } else if (i == CS_MAXCLIENTS) { if (!cl.attractloop) cl.maxclients = atoi(cl.configstrings[CS_MAXCLIENTS]); } else if (i >= CS_PLAYERSKINS && i < CS_PLAYERSKINS+MAX_CLIENTS) { //r1: hack to avoid parsing non-skins from mods that overload CS_PLAYERSKINS //FIXME: how reliable is CS_MAXCLIENTS? i -= CS_PLAYERSKINS; if (i < cl.maxclients) { if (cl.refresh_prepped && strcmp(olds, s)) CL_ParseClientinfo (i); } else { Com_DPrintf ("CL_ParseConfigString: Ignoring out-of-range playerskin %d (%s)\n", i, MakePrintable(s, 0)); } } }
/* ================ CL_ParseConfigString ================ */ void CL_ParseConfigString (void) { int32_t i; char *s; char olds[MAX_QPATH]; char scratch[1024]; i = MSG_ReadShort (&net_message); if (i < 0 || i >= MAX_CONFIGSTRINGS) Com_Error (ERR_DROP, "configstring > MAX_CONFIGSTRINGS"); s = MSG_ReadString(&net_message); strncpy (olds, cl.configstrings[i], sizeof(olds)); olds[sizeof(olds) - 1] = 0; strcpy (cl.configstrings[i], s); // do something apropriate // Knightmare- 1/2/2002- BIG UGLY HACK for old demos or // connected to server using old protocol // Changed config strings require different parsing if ( LegacyProtocol()) { if (i >= OLD_CS_LIGHTS && i < OLD_CS_LIGHTS+MAX_LIGHTSTYLES) CL_SetLightstyle (i - OLD_CS_LIGHTS); else if (i == CS_CDTRACK) { if (cl.refresh_prepped) CL_PlayBackgroundTrack (); } else if (i >= CS_MODELS && i < CS_MODELS+OLD_MAX_MODELS) { if (cl.refresh_prepped) { cl.model_draw[i-CS_MODELS] = R_RegisterModel (cl.configstrings[i]); if (cl.configstrings[i][0] == '*') cl.model_clip[i-CS_MODELS] = CM_InlineModel (cl.configstrings[i]); else cl.model_clip[i-CS_MODELS] = NULL; } } else if (i >= OLD_CS_SOUNDS && i < OLD_CS_SOUNDS+OLD_MAX_SOUNDS) { if (cl.refresh_prepped) cl.sound_precache[i-OLD_CS_SOUNDS] = S_RegisterSound (cl.configstrings[i]); } else if (i >= OLD_CS_IMAGES && i < OLD_CS_IMAGES+OLD_MAX_IMAGES) { if (cl.refresh_prepped) cl.image_precache[i-OLD_CS_IMAGES] = R_DrawFindPic (cl.configstrings[i]); } else if (i >= OLD_CS_PLAYERSKINS && i < OLD_CS_PLAYERSKINS+MAX_CLIENTS) { if (cl.refresh_prepped && strcmp(olds, s)) CL_ParseClientinfo (i-OLD_CS_PLAYERSKINS); } else if (i >= OLD_CS_ITEMS && i < OLD_CS_ITEMS + MAX_ITEMS) { int j; int item = i - OLD_CS_ITEMS; int32_t token; Com_sprintf (scratch, sizeof(scratch), "use %s", cl.configstrings[i]); token = Q_STLookup(&key_table, scratch); cl.inventorykey[item] = -1; if (token >= 0) { for (j=0; j<MAX_KEYEVENTS; j++) { if (keytokens[j] == token) { cl.inventorykey[item] = j; break; } } } } } else // new configstring offsets { if (i >= CS_LIGHTS && i < CS_LIGHTS+MAX_LIGHTSTYLES) CL_SetLightstyle (i - CS_LIGHTS); else if (i == CS_CDTRACK) { if (cl.refresh_prepped) CL_PlayBackgroundTrack (); } else if (i >= CS_MODELS && i < CS_MODELS+MAX_MODELS) { if (cl.refresh_prepped) { cl.model_draw[i-CS_MODELS] = R_RegisterModel (cl.configstrings[i]); if (cl.configstrings[i][0] == '*') cl.model_clip[i-CS_MODELS] = CM_InlineModel (cl.configstrings[i]); else cl.model_clip[i-CS_MODELS] = NULL; } } else if (i >= CS_SOUNDS && i < CS_SOUNDS+MAX_SOUNDS) //Knightmare- was MAX_MODELS { if (cl.refresh_prepped) cl.sound_precache[i-CS_SOUNDS] = S_RegisterSound (cl.configstrings[i]); } else if (i >= CS_IMAGES && i < CS_IMAGES+MAX_IMAGES) //Knightmare- was MAX_MODELS { if (cl.refresh_prepped) cl.image_precache[i-CS_IMAGES] = R_DrawFindPic (cl.configstrings[i]); } else if (i >= CS_PLAYERSKINS && i < CS_PLAYERSKINS+MAX_CLIENTS) { if (cl.refresh_prepped && strcmp(olds, s)) CL_ParseClientinfo (i-CS_PLAYERSKINS); } else if (i >= CS_ITEMS && i < CS_ITEMS + MAX_ITEMS) { int j; int item = i - CS_ITEMS; int32_t token; Com_sprintf (scratch, sizeof(scratch), "use %s", cl.configstrings[i]); token = Q_STLookup(&key_table, scratch); cl.inventorykey[item] = -1; if (token >= 0) { for (j=0; j<MAX_KEYEVENTS; j++) { if (keytokens[j] == token) { cl.inventorykey[item] = j; break; } } } } } //end Knightmare }
void CL_ParseConfigString(void) { int i, length; char *s; char olds[MAX_QPATH]; i = MSG_ReadShort(&net_message); if ((i < 0) || (i >= MAX_CONFIGSTRINGS)) { Com_Error(ERR_DROP, "configstring > MAX_CONFIGSTRINGS"); } s = MSG_ReadString(&net_message); Q_strlcpy(olds, cl.configstrings[i], sizeof(olds)); length = strlen(s); if (length > sizeof(cl.configstrings) - sizeof(cl.configstrings[0])*i - 1) { Com_Error(ERR_DROP, "CL_ParseConfigString: oversize configstring"); } strcpy(cl.configstrings[i], s); /* do something apropriate */ if ((i >= CS_LIGHTS) && (i < CS_LIGHTS + MAX_LIGHTSTYLES)) { CL_SetLightstyle(i - CS_LIGHTS); } else if (i == CS_CDTRACK) { if (cl.refresh_prepped) { #ifdef CDA CDAudio_Play((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10), true); #endif #ifdef OGG /* OGG/Vorbis */ if ((int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10) < 10) { char tmp[3] = "0"; OGG_ParseCmd(strcat(tmp, cl.configstrings[CS_CDTRACK])); } else { OGG_ParseCmd(cl.configstrings[CS_CDTRACK]); } #endif } } else if ((i >= CS_MODELS) && (i < CS_MODELS + MAX_MODELS)) { if (cl.refresh_prepped) { cl.model_draw[i - CS_MODELS] = R_RegisterModel(cl.configstrings[i]); if (cl.configstrings[i][0] == '*') { cl.model_clip[i - CS_MODELS] = CM_InlineModel(cl.configstrings[i]); } else { cl.model_clip[i - CS_MODELS] = NULL; } } } else if ((i >= CS_SOUNDS) && (i < CS_SOUNDS + MAX_MODELS)) { if (cl.refresh_prepped) { cl.sound_precache[i - CS_SOUNDS] = S_RegisterSound(cl.configstrings[i]); } } else if ((i >= CS_IMAGES) && (i < CS_IMAGES + MAX_MODELS)) { if (cl.refresh_prepped) { cl.image_precache[i - CS_IMAGES] = Draw_FindPic(cl.configstrings[i]); } } else if ((i >= CS_PLAYERSKINS) && (i < CS_PLAYERSKINS + MAX_CLIENTS)) { if (cl.refresh_prepped && strcmp(olds, s)) { CL_ParseClientinfo(i - CS_PLAYERSKINS); } } }
/* ================ CL_ParseConfigString ================ */ void CL_ParseConfigString (sizebuf_t *msg) { int i, length; char *s; char olds[MAX_QPATH]; i = MSG_ReadShort (msg); if ((unsigned)i >= MAX_CONFIGSTRINGS) Com_Error (ERR_DROP, "configstring > MAX_CONFIGSTRINGS"); Q_strncpyz (olds, cl.configstrings[i], sizeof(olds)); s = MSG_ReadString(msg); length = strlen(s); if (i != CS_NAME && i < CS_GENERAL) { if (i >= CS_STATUSBAR && i < CS_AIRACCEL) { Q_strncpyz(cl.configstrings[i], s, MAX_QPATH * (CS_AIRACCEL - i)); } else { if (length >= MAX_QPATH) Com_Printf ("WARNING: Configstring %d of length %d exceeds MAX_QPATH.\n", i, length); Q_strncpyz(cl.configstrings[i], s, MAX_QPATH); } } else { Q_strncpyz(cl.configstrings[i], s, MAX_QPATH * (MAX_CONFIGSTRINGS - i)); } // do something apropriate if(i == CS_AIRACCEL) { cl.pmp.airaccelerate = atoi(cl.configstrings[CS_AIRACCEL]) ? true : false; } else if (i >= CS_LIGHTS && i < CS_LIGHTS+MAX_LIGHTSTYLES) { CL_SetLightstyle (i - CS_LIGHTS); } else if (i == CS_CDTRACK) { #ifdef CD_AUDIO if (cl.refresh_prepped) CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true); #endif } else if (i >= CS_MODELS && i < CS_MODELS+MAX_MODELS) { if( i == CS_MODELS + 1 ) { if( length > 9 ) { Q_strncpyz( cls.mapname, s + 5, sizeof( cls.mapname ) ); // skip "maps/" cls.mapname[strlen( cls.mapname ) - 4] = 0; // cut off ".bsp" } } if (cl.refresh_prepped) { cl.model_draw[i-CS_MODELS] = R_RegisterModel (cl.configstrings[i]); if (cl.configstrings[i][0] == '*') cl.model_clip[i-CS_MODELS] = CM_InlineModel (cl.configstrings[i]); else cl.model_clip[i-CS_MODELS] = NULL; } } else if (i >= CS_SOUNDS && i < CS_SOUNDS+MAX_MODELS) { if (cl.refresh_prepped) cl.sound_precache[i-CS_SOUNDS] = S_RegisterSound (cl.configstrings[i]); } else if (i >= CS_IMAGES && i < CS_IMAGES+MAX_MODELS) { if (cl.refresh_prepped) cl.image_precache[i-CS_IMAGES] = Draw_FindPic (cl.configstrings[i]); } else if (i == CS_MAXCLIENTS) { cl.maxclients = atoi(cl.configstrings[CS_MAXCLIENTS]); clamp(cl.maxclients, 0, MAX_CLIENTS); } else if (i >= CS_PLAYERSKINS && i < CS_PLAYERSKINS+MAX_CLIENTS) { if (cl.refresh_prepped && strcmp(olds, s)) CL_ParseClientinfo (i-CS_PLAYERSKINS); } }