FS_OSPathToRelative path in Prey will now fix preybase and then check base path. Implemented material terms for Prey in a prey build.

This commit is contained in:
Justin Marshall
2026-05-05 19:14:45 -07:00
parent a51e42f312
commit 0372cfc245
5 changed files with 78 additions and 68 deletions
+11 -2
View File
@@ -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
-11
View File
@@ -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();
+59 -47
View File
@@ -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<const idDeclTable *>( 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<const idDeclTable*>(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);
}
/*
+1 -1
View File
@@ -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;
+7 -7
View File
@@ -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 ) {