Skip to content

Commit bd96bd9

Browse files
committed
Fixed loading shaders from zips
1 parent a3c52b5 commit bd96bd9

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

engine/source/materials/shaderData.cpp

+22-16
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,30 @@ GFXShader* ShaderData::getShader()
6565

6666
StringTableEntry ShaderData::getVertexShaderPath()
6767
{
68-
if (DXVertexShaderName[0] != '.')
69-
return DXVertexShaderName;
70-
char fullFilename[128];
71-
dStrncpy(fullFilename, mPath, dStrlen(mPath) + 1);
72-
dStrcat(fullFilename, DXVertexShaderName);
68+
if (dStrlen(DXVertexShaderName) > 1 && DXVertexShaderName[0] == '.' && (DXVertexShaderName[1] == '/' || DXVertexShaderName[1] == '\\'))
69+
{
70+
char fullFilename[128];
71+
dStrncpy(fullFilename, mPath, dStrlen(mPath) + 1);
72+
dStrcat(fullFilename, DXVertexShaderName + 2);
73+
74+
return StringTable->insert(fullFilename);
75+
}
7376

74-
return StringTable->insert(fullFilename);
77+
return DXVertexShaderName;
7578
}
7679

7780
StringTableEntry ShaderData::getPixelShaderPath()
7881
{
79-
if (DXPixelShaderName[0] != '.')
80-
return DXPixelShaderName;
81-
char fullFilename[128];
82-
dStrncpy(fullFilename, mPath, dStrlen(mPath) + 1);
83-
dStrcat(fullFilename, DXPixelShaderName);
82+
if (dStrlen(DXPixelShaderName) > 1 && DXPixelShaderName[0] == '.' && (DXPixelShaderName[1] == '/' || DXPixelShaderName[1] == '\\'))
83+
{
84+
char fullFilename[128];
85+
dStrncpy(fullFilename, mPath, dStrlen(mPath) + 1);
86+
dStrcat(fullFilename, DXPixelShaderName + 2);
87+
88+
return StringTable->insert(fullFilename);
89+
}
8490

85-
return StringTable->insert(fullFilename);
91+
return DXPixelShaderName;
8692
}
8793

8894
bool ShaderData::onAdd()
@@ -123,17 +129,17 @@ bool ShaderData::initShader()
123129
const char* vtexShaderPath = DXVertexShaderName;
124130
const char* pixelShaderPath = DXPixelShaderName;
125131

126-
if (vtexShaderPath != NULL && vtexShaderPath[0] == '.')
132+
if (vtexShaderPath != NULL && dStrlen(vtexShaderPath) > 1 && vtexShaderPath[0] == '.' && (vtexShaderPath[1] == '/' || vtexShaderPath[1] == '\\'))
127133
{
128134
dStrncpy(fullFilename1, mPath, dStrlen(mPath) + 1);
129-
dStrcat(fullFilename1, vtexShaderPath);
135+
dStrcat(fullFilename1, vtexShaderPath + 2);
130136
vtexShaderPath = fullFilename1;
131137
}
132138

133-
if (pixelShaderPath != NULL && pixelShaderPath[0] == '.')
139+
if (pixelShaderPath != NULL && dStrlen(pixelShaderPath) > 1 && pixelShaderPath[0] == '.' && (pixelShaderPath[1] == '/' || pixelShaderPath[1] == '\\'))
134140
{
135141
dStrncpy(fullFilename2, mPath, dStrlen(mPath) + 1);
136-
dStrcat(fullFilename2, pixelShaderPath);
142+
dStrcat(fullFilename2, pixelShaderPath + 2);
137143
pixelShaderPath = fullFilename2;
138144
}
139145

0 commit comments

Comments
 (0)