From 0372cfc2450d0f46e56cb2f78395c6af559c974a Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Tue, 5 May 2026 19:14:45 -0700 Subject: [PATCH] FS_OSPathToRelative path in Prey will now fix preybase and then check base path. Implemented material terms for Prey in a prey build. --- neo/framework/FileSystem.cpp | 13 ++++- neo/renderer/Image_load.cpp | 11 ---- neo/renderer/Material.cpp | 106 +++++++++++++++++++---------------- neo/renderer/RenderWorld.cpp | 2 +- neo/renderer/tr_main.cpp | 14 ++--- 5 files changed, 78 insertions(+), 68 deletions(-) diff --git a/neo/framework/FileSystem.cpp b/neo/framework/FileSystem.cpp index 97aa8c43..0625d075 100644 --- a/neo/framework/FileSystem.cpp +++ b/neo/framework/FileSystem.cpp @@ -871,17 +871,26 @@ const char *idFileSystemLocal::OSPathToRelativePath( const char *OSPath ) { } #else // look for the first complete directory name +const char *basegamedir = BASE_GAMEDIR; +#ifdef PREY + base = (char*)strstr(OSPath, BASE_GAMEDIR); + if (base == NULL) { + basegamedir = "base"; + base = (char*)strstr(OSPath, "base"); + } +#else base = (char *)strstr( OSPath, BASE_GAMEDIR ); +#endif while ( base ) { char c1 = '\0', c2; if ( base > OSPath ) { c1 = *(base - 1); } - c2 = *( base + strlen( BASE_GAMEDIR ) ); + c2 = *( base + strlen(basegamedir) ); if ( ( c1 == '/' || c1 == '\\' ) && ( c2 == '/' || c2 == '\\' ) ) { break; } - base = strstr( base + 1, BASE_GAMEDIR ); + base = strstr( base + 1, basegamedir); } #endif // fs_game and fs_game_base support - look for first complete name with a mod path diff --git a/neo/renderer/Image_load.cpp b/neo/renderer/Image_load.cpp index bc762610..4007706c 100644 --- a/neo/renderer/Image_load.cpp +++ b/neo/renderer/Image_load.cpp @@ -588,17 +588,6 @@ void idImage::GenerateImage( const byte *pic, int width, int height, } } - // swap the red and alpha for rxgb support - // do this even on tga normal maps so we only have to use - // one fragment program - // if the image is precompressed ( either in palletized mode or true rxgb mode ) - // then it is loaded above and the swap never happens here -// if ( depth == TD_BUMP && globalImages->image_useNormalCompression.GetInteger() != 1 ) { -// for ( int i = 0; i < scaled_width * scaled_height * 4; i += 4 ) { -// scaledBuffer[ i + 3 ] = scaledBuffer[ i ]; -// scaledBuffer[ i ] = 0; -// } -// } // upload the main image level Bind(); diff --git a/neo/renderer/Material.cpp b/neo/renderer/Material.cpp index 49f4491d..1e14c6c0 100644 --- a/neo/renderer/Material.cpp +++ b/neo/renderer/Material.cpp @@ -570,7 +570,6 @@ int idMaterial::ParseEmitOp( idLexer &src, int a, expOpType_t opType, int priori b = ParseExpressionPriority( src, priority ); return EmitOp( a, b, opType ); } - /* ================= idMaterial::ParseTerm @@ -578,142 +577,155 @@ idMaterial::ParseTerm Returns a register index ================= */ -int idMaterial::ParseTerm( idLexer &src ) { +int idMaterial::ParseTerm(idLexer& src) { idToken token; int a, b; - src.ReadToken( &token ); + src.ReadToken(&token); - if ( token == "(" ) { - a = ParseExpression( src ); - MatchToken( src, ")" ); + if (token == "(") { + a = ParseExpression(src); + MatchToken(src, ")"); return a; } - if ( !token.Icmp( "time" ) ) { +#ifdef PREY + if (!token.Icmp("distance")) { + pd->registersAreConstant = false; + SetMaterialFlag(MF_USESDISTANCE); + return EXP_REG_DISTANCE; + } +#endif + + if (!token.Icmp("time")) { pd->registersAreConstant = false; return EXP_REG_TIME; } - if ( !token.Icmp( "parm0" ) ) { + if (!token.Icmp("parm0")) { pd->registersAreConstant = false; return EXP_REG_PARM0; } - if ( !token.Icmp( "parm1" ) ) { + if (!token.Icmp("parm1")) { pd->registersAreConstant = false; return EXP_REG_PARM1; } - if ( !token.Icmp( "parm2" ) ) { + if (!token.Icmp("parm2")) { pd->registersAreConstant = false; return EXP_REG_PARM2; } - if ( !token.Icmp( "parm3" ) ) { + if (!token.Icmp("parm3")) { pd->registersAreConstant = false; return EXP_REG_PARM3; } - if ( !token.Icmp( "parm4" ) ) { + if (!token.Icmp("parm4")) { pd->registersAreConstant = false; return EXP_REG_PARM4; } - if ( !token.Icmp( "parm5" ) ) { + if (!token.Icmp("parm5")) { pd->registersAreConstant = false; return EXP_REG_PARM5; } - if ( !token.Icmp( "parm6" ) ) { + if (!token.Icmp("parm6")) { pd->registersAreConstant = false; return EXP_REG_PARM6; } - if ( !token.Icmp( "parm7" ) ) { + if (!token.Icmp("parm7")) { pd->registersAreConstant = false; return EXP_REG_PARM7; } - if ( !token.Icmp( "parm8" ) ) { + if (!token.Icmp("parm8")) { pd->registersAreConstant = false; return EXP_REG_PARM8; } - if ( !token.Icmp( "parm9" ) ) { + if (!token.Icmp("parm9")) { pd->registersAreConstant = false; return EXP_REG_PARM9; } - if ( !token.Icmp( "parm10" ) ) { + if (!token.Icmp("parm10")) { pd->registersAreConstant = false; return EXP_REG_PARM10; } - if ( !token.Icmp( "parm11" ) ) { + if (!token.Icmp("parm11")) { pd->registersAreConstant = false; return EXP_REG_PARM11; } - if ( !token.Icmp( "global0" ) ) { + if (!token.Icmp("global0")) { pd->registersAreConstant = false; return EXP_REG_GLOBAL0; } - if ( !token.Icmp( "global1" ) ) { + if (!token.Icmp("global1")) { pd->registersAreConstant = false; return EXP_REG_GLOBAL1; } - if ( !token.Icmp( "global2" ) ) { + if (!token.Icmp("global2")) { pd->registersAreConstant = false; return EXP_REG_GLOBAL2; } - if ( !token.Icmp( "global3" ) ) { + if (!token.Icmp("global3")) { pd->registersAreConstant = false; return EXP_REG_GLOBAL3; } - if ( !token.Icmp( "global4" ) ) { + if (!token.Icmp("global4")) { pd->registersAreConstant = false; return EXP_REG_GLOBAL4; } - if ( !token.Icmp( "global5" ) ) { + if (!token.Icmp("global5")) { pd->registersAreConstant = false; return EXP_REG_GLOBAL5; } - if ( !token.Icmp( "global6" ) ) { + if (!token.Icmp("global6")) { pd->registersAreConstant = false; return EXP_REG_GLOBAL6; } - if ( !token.Icmp( "global7" ) ) { + if (!token.Icmp("global7")) { pd->registersAreConstant = false; return EXP_REG_GLOBAL7; } - if ( !token.Icmp( "fragmentPrograms" ) ) { - return GetExpressionConstant( (float) glConfig.ARBFragmentProgramAvailable ); + if (!token.Icmp("fragmentPrograms")) { +#ifdef PREY + pd->registersAreConstant = false; + return EmitOp(0, 0, OP_TYPE_FRAGMENTPROGRAMS); +#else + return GetExpressionConstant((float)glConfig.ARBFragmentProgramAvailable); +#endif } - if ( !token.Icmp( "sound" ) ) { + if (!token.Icmp("sound")) { pd->registersAreConstant = false; - return EmitOp( 0, 0, OP_TYPE_SOUND ); + return EmitOp(0, 0, OP_TYPE_SOUND); } // parse negative numbers - if ( token == "-" ) { - src.ReadToken( &token ); - if ( token.type == TT_NUMBER || token == "." ) { - return GetExpressionConstant( -(float) token.GetFloatValue() ); + if (token == "-") { + src.ReadToken(&token); + if (token.type == TT_NUMBER || token == ".") { + return GetExpressionConstant(-(float)token.GetFloatValue()); } - src.Warning( "Bad negative number '%s'", token.c_str() ); - SetMaterialFlag( MF_DEFAULTED ); + src.Warning("Bad negative number '%s'", token.c_str()); + SetMaterialFlag(MF_DEFAULTED); return 0; } - if ( token.type == TT_NUMBER || token == "." || token == "-" ) { - return GetExpressionConstant( (float) token.GetFloatValue() ); + if (token.type == TT_NUMBER || token == "." || token == "-") { + return GetExpressionConstant((float)token.GetFloatValue()); } // see if it is a table name - const idDeclTable *table = static_cast( declManager->FindType( DECL_TABLE, token.c_str(), false ) ); - if ( !table ) { - src.Warning( "Bad term '%s'", token.c_str() ); - SetMaterialFlag( MF_DEFAULTED ); + const idDeclTable* table = static_cast(declManager->FindType(DECL_TABLE, token.c_str(), false)); + if (!table) { + src.Warning("Bad term '%s'", token.c_str()); + SetMaterialFlag(MF_DEFAULTED); return 0; } // parse a table expression - MatchToken( src, "[" ); + MatchToken(src, "["); - b = ParseExpression( src ); + b = ParseExpression(src); - MatchToken( src, "]" ); + MatchToken(src, "]"); - return EmitOp( table->Index(), b, OP_TYPE_TABLE ); + return EmitOp(table->Index(), b, OP_TYPE_TABLE); } /* diff --git a/neo/renderer/RenderWorld.cpp b/neo/renderer/RenderWorld.cpp index 0a58f14b..b12855b0 100644 --- a/neo/renderer/RenderWorld.cpp +++ b/neo/renderer/RenderWorld.cpp @@ -940,7 +940,7 @@ int idRenderWorldLocal::BoundsInAreas( const idBounds &bounds, int *areas, int m assert( areas ); assert( bounds[0][0] <= bounds[1][0] && bounds[0][1] <= bounds[1][1] && bounds[0][2] <= bounds[1][2] ); - assert( bounds[1][0] - bounds[0][0] < 1e4f && bounds[1][1] - bounds[0][1] < 1e4f && bounds[1][2] - bounds[0][2] < 1e4f ); +// assert( bounds[1][0] - bounds[0][0] < 1e4f && bounds[1][1] - bounds[0][1] < 1e4f && bounds[1][2] - bounds[0][2] < 1e4f ); if ( !areaNodes ) { return numAreas; diff --git a/neo/renderer/tr_main.cpp b/neo/renderer/tr_main.cpp index 0ba2ccec..34bb229c 100644 --- a/neo/renderer/tr_main.cpp +++ b/neo/renderer/tr_main.cpp @@ -1142,13 +1142,13 @@ void R_RenderView( viewDef_t *parms ) { R_SortDrawSurfs(); // generate any subviews (mirrors, cameras, etc) before adding this view - if ( R_GenerateSubViews() ) { - // if we are debugging subviews, allow the skipping of the - // main view draw - if ( r_subviewOnly.GetBool() ) { - return; - } - } + //if ( R_GenerateSubViews() ) { + // // if we are debugging subviews, allow the skipping of the + // // main view draw + // if ( r_subviewOnly.GetBool() ) { + // return; + // } + //} // write everything needed to the demo file if ( session->writeDemo ) {