use safe strings more

This commit is contained in:
Garux 2021-01-21 16:08:53 +03:00
parent 8b204ac054
commit f3c26c791f
7 changed files with 9 additions and 19 deletions

View File

@ -27,8 +27,6 @@
//
#include "cmdlib.h"
#include "mathlib.h"
#include "polylib.h"
#include "inout.h"
#include <sys/types.h>
#include <sys/stat.h>

View File

@ -448,8 +448,7 @@ void ProcessWorldModel( void ){
/* ydnar: fog hull */
if ( ENT_READKV( &value, &entities[ 0 ], "_foghull" ) ) {
char shader[MAX_QPATH];
sprintf( shader, "textures/%s", value );
const auto shader = String64()( "textures/", value );
MakeFogHullSurfs( e, tree, shader );
}

View File

@ -1085,8 +1085,6 @@ static void ParseRawBrush( bool onlyLights ){
vec_t shift[ 2 ];
vec_t rotate = 0;
vec_t scale[ 2 ];
char name[ MAX_QPATH ];
char shader[ MAX_QPATH ];
int flags;
@ -1146,7 +1144,7 @@ static void ParseRawBrush( bool onlyLights ){
/* read shader name */
GetToken( false );
strcpy( name, token );
const auto shader = String64()( "textures/", token );
/* AP or 220? */
if ( g_brushType == BPRIMIT_UNDEFINED ){
@ -1199,7 +1197,6 @@ static void ParseRawBrush( bool onlyLights ){
}
/* set default flags and values */
sprintf( shader, "textures/%s", name );
if ( onlyLights ) {
si = &shaderInfo[ 0 ];
}

View File

@ -219,7 +219,6 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, const
mapDrawSurface_t *ds;
bspDrawVert_t *dv;
const char *picoShaderName;
char shaderName[ MAX_QPATH ];
picoVec_t *xyz, *normal, *st;
byte *color;
picoIndex_t *indexes;
@ -385,12 +384,12 @@ void InsertModel( const char *name, int skin, int frame, m4x4_t transform, const
/* shader renaming for sof2 */
if ( renameModelShaders ) {
strcpy( shaderName, picoShaderName );
auto shaderName = String64()( PathExtensionless( picoShaderName ) );
if ( spawnFlags & 1 ) {
path_set_extension( shaderName, "_RMG_BSP" );
shaderName << "_RMG_BSP";
}
else{
path_set_extension( shaderName, "_BSP" );
shaderName << "_BSP";
}
si = ShaderInfoForShader( shaderName );
}

View File

@ -221,8 +221,6 @@ void ParsePatch( bool onlyLights ){
vec_t info[ 5 ];
int i, j, k;
parseMesh_t *pm;
char texture[ MAX_QPATH ];
char shader[ MAX_QPATH ];
mesh_t m;
bspDrawVert_t *verts;
epair_t *ep;
@ -233,9 +231,9 @@ void ParsePatch( bool onlyLights ){
MatchToken( "{" );
/* get texture */
/* get shader name */
GetToken( true );
strcpy( texture, token );
const auto shader = String64()( "textures/", token );
Parse1DMatrix( 5, info );
m.width = info[0];
@ -355,7 +353,6 @@ void ParsePatch( bool onlyLights ){
pm->brushNum = entitySourceBrushes;
/* set shader */
sprintf( shader, "textures/%s", texture );
pm->shaderInfo = ShaderInfoForShader( shader );
/* set mesh */

View File

@ -1696,7 +1696,7 @@ mapDrawSurface_t *DrawSurfaceForFlare( int entNum, vec3_t origin, vec
mapDrawSurface_t *DrawSurfaceForShader( const char *shader );
void ClipSidesIntoTree( entity_t *e, tree_t *tree );
void MakeDebugPortalSurfs( tree_t *tree );
void MakeFogHullSurfs( entity_t *e, tree_t *tree, char *shader );
void MakeFogHullSurfs( entity_t *e, tree_t *tree, const char *shader );
void SubdivideFaceSurfaces( entity_t *e, tree_t *tree );
void AddEntitySurfaceModels( entity_t *e );
int AddSurfaceModels( mapDrawSurface_t *ds );

View File

@ -3046,7 +3046,7 @@ void MakeDebugPortalSurfs( tree_t *tree ){
generates drawsurfaces for a foghull (this MUST use a sky shader)
*/
void MakeFogHullSurfs( entity_t *e, tree_t *tree, char *shader ){
void MakeFogHullSurfs( entity_t *e, tree_t *tree, const char *shader ){
shaderInfo_t *si;
mapDrawSurface_t *ds;
vec3_t fogMins, fogMaxs;