void V_AddViewWeapon (float bob) { vec3_t forward, right, up; centity_t *cent; int gunmodel = V_CurrentWeaponModel(); extern cvar_t scr_fov; cent = &cl.viewent; TP_ParseWeaponModel(cl.model_precache[gunmodel]); if (!cl_drawgun.value || (cl_drawgun.value == 2 && scr_fov.value > 90) || ((view_message.flags & (PF_GIB|PF_DEAD))) || cl.stats[STAT_ITEMS] & IT_INVISIBILITY || cl.stats[STAT_HEALTH] <= 0 || !Cam_DrawViewModel()) { cent->current.modelindex = 0; //no model return; } //angles cent->current.angles[YAW] = r_refdef.viewangles[YAW]; cent->current.angles[PITCH] = -r_refdef.viewangles[PITCH]; cent->current.angles[ROLL] = r_refdef.viewangles[ROLL]; //origin AngleVectors (r_refdef.viewangles, forward, right, up); VectorCopy (r_refdef.vieworg, cent->current.origin); VectorMA (cent->current.origin, bob * 0.4, forward, cent->current.origin); if (r_viewmodeloffset.string[0]) { float offset[3]; int size = sizeof(offset)/sizeof(offset[0]); ParseFloats(r_viewmodeloffset.string, offset, &size); VectorMA (cent->current.origin, offset[0], right, cent->current.origin); VectorMA (cent->current.origin, -offset[1], up, cent->current.origin); VectorMA (cent->current.origin, offset[2], forward, cent->current.origin); } // fudge position around to keep amount of weapon visible roughly equal with different FOV if (scr_viewsize.value == 110) cent->current.origin[2] += 1; else if (scr_viewsize.value == 100) cent->current.origin[2] += 2; else if (scr_viewsize.value == 90) cent->current.origin[2] += 1; else if (scr_viewsize.value == 80) cent->current.origin[2] += 0.5; if (cent->current.modelindex != gunmodel) { cl.viewent.frametime = -1; } else { if (cent->current.frame != view_message.weaponframe) { cent->frametime = cl.time; cent->oldframe = cent->current.frame; } } cent->current.modelindex = gunmodel; cent->current.frame = view_message.weaponframe; }
/* ================ CG_ParseMinimapZone ================ */ static qboolean CG_ParseMinimapZone( minimapZone_t* z, char **text ) { char* token; qboolean hasImage = qfalse; qboolean hasBounds = qfalse; z->scale = 1.0f; if( !*(token = COM_Parse( text )) || Q_stricmp( token, "{" ) ) { CG_Printf( S_ERROR "expected a { at the beginning of a zones\n" ); return qfalse; } while(1) { if( !*(token = COM_Parse( text )) ) { break; } if( !Q_stricmp( token, "bounds" ) ) { if( !ParseFloats( z->boundsMin, 3, text) || !ParseFloats( z->boundsMax, 3, text) ) { CG_Printf( S_ERROR "error while parsing 'bounds'\n" ); return qfalse; } hasBounds = qtrue; } else if( !Q_stricmp( token, "image") ) { if( !*(token = COM_Parse( text )) ) { CG_Printf( S_ERROR "error while parsing the image name while parsing 'image'\n" ); } z->image = trap_R_RegisterShader( token, RSF_DEFAULT ); if( !ParseFloats( z->imageMin, 2, text) || !ParseFloats( z->imageMax, 2, text) ) { CG_Printf( S_ERROR "error while parsing 'image'\n" ); return qfalse; } hasImage = qtrue; } else if( !Q_stricmp( token, "scale" )) { if( !*(token = COM_Parse( text )) ) { CG_Printf( S_ERROR "error while parsing the value while parsing 'scale'\n" ); } z->scale = atof( token ); } else if( !Q_stricmp( token, "}" ) ) { break; } else { Com_Printf( S_ERROR "unknown token '%s'\n", token ); } } if( Q_stricmp( token, "}" ) ) { CG_Printf( S_ERROR "expected a } at the end of a zone\n"); return qfalse; } if( !hasBounds ) { CG_Printf( S_ERROR "missing bounds in the zone\n" ); return qfalse; } if( !hasImage ) { CG_Printf( S_ERROR "missing image in the zone\n" ); return qfalse; } return qtrue; }
NOXREF int ParseDirective(const char *pText) { NOXREFCHECK; if (pText && pText[0] == '$') { float tempFloat[8]; if (IsToken(pText, "position")) { if (ParseFloats(pText, tempFloat, 2)) { gMessageParms.x = tempFloat[0]; gMessageParms.y = tempFloat[1]; } } else if (IsToken(pText, "effect")) { if (ParseFloats(pText, tempFloat, 1)) { gMessageParms.effect = (int)tempFloat[0]; } } else if (IsToken(pText, "fxtime")) { if (ParseFloats(pText, tempFloat, 1)) { gMessageParms.fxtime = tempFloat[0]; } } else if (IsToken(pText, "color2")) { if (ParseFloats(pText, tempFloat, 3)) { gMessageParms.r2 = (int)tempFloat[0]; gMessageParms.g2 = (int)tempFloat[1]; gMessageParms.b2 = (int)tempFloat[2]; } } else if (IsToken(pText, "color")) { if (ParseFloats(pText, tempFloat, 3)) { gMessageParms.r1 = (int)tempFloat[0]; gMessageParms.g1 = (int)tempFloat[1]; gMessageParms.b1 = (int)tempFloat[2]; } } else if (IsToken(pText, "fadein")) { if (ParseFloats(pText, tempFloat, 1)) { gMessageParms.fadein = tempFloat[0]; } } else if (IsToken(pText, "fadeout")) { if (ParseFloats(pText, tempFloat, 3)) { gMessageParms.fadeout = tempFloat[0]; } } else if (IsToken(pText, "holdtime")) { if (ParseFloats(pText, tempFloat, 3)) { gMessageParms.holdtime = tempFloat[0]; } } else { Con_DPrintf("Unknown token: %s\n", pText); } return 1; } return 0; }
/* ================ CG_ParseMinimap ================ */ static qboolean CG_ParseMinimap( minimap_t* m, const char* filename ) { char text_buffer[ 20000 ]; char* text; char* token; m->nZones = 0; m->lastZone = -1; m->scale = 1.0f; m->bgColor[3] = 1.0f; //Initialise the bgColor to black if( !BG_ReadWholeFile( filename, text_buffer, sizeof(text_buffer) ) ) { return qfalse; } text = text_buffer; if( !*(token = COM_Parse( &text )) || Q_stricmp( token, "{" ) ) { CG_Printf( S_ERROR "expected a { at the beginning of %s\n", filename ); return qfalse; } while(1) { if( !*(token = COM_Parse( &text )) ) { break; } if( !Q_stricmp( token, "zone" ) ){ m->nZones ++; if( m->nZones > MAX_MINIMAP_ZONES ) { CG_Printf( S_ERROR "reached the zone number limit (%i) in %s\n", MAX_MINIMAP_ZONES, filename ); return qfalse; } if( !CG_ParseMinimapZone( &m->zones[m->nZones - 1], &text ) ) { CG_Printf( S_ERROR "error while reading zone n°%i in %s\n", m->nZones, filename ); return qfalse; } } else if( !Q_stricmp( token, "backgroundColor") ) { if( !ParseFloats( m->bgColor, 4, &text) ) { CG_Printf( S_ERROR "error while parsing 'backgroundColor' in %s\n", filename ); return qfalse; } } else if( !Q_stricmp( token, "globalScale") ) { if( !ParseFloats( &m->scale, 1, &text) ) { CG_Printf( S_ERROR "error while parsing 'globalScale' in %s\n", filename ); return qfalse; } } else if( !Q_stricmp( token, "}" ) ) { break; } else { Com_Printf( S_ERROR "%s: unknown token '%s'\n", filename, token ); } } if( Q_stricmp( token, "}" ) ) { CG_Printf( S_ERROR "expected a } at the end of %s\n", filename ); return qfalse; } return qtrue; }