[IMaterial] Correct constant reading

This commit is contained in:
momo5502 2016-12-27 00:12:07 +01:00
parent a56e28db74
commit ea90c4be6b

View File

@ -101,15 +101,19 @@ namespace Assets
for (char i = 0; i < material->constantCount; ++i) for (char i = 0; i < material->constantCount; ++i)
{ {
std::string constName = reader.readString(); for (int j = 0; j < 12; ++j)
strncpy_s(material->constantTable[i].name, 12, constName.data(), 12); {
material->constantTable[i].name[j] = reader.readByte();
}
std::string constName(material->constantTable[i].name, 12);
constName.push_back('0');
material->constantTable[i].nameHash = Game::R_HashString(constName.data()); material->constantTable[i].nameHash = Game::R_HashString(constName.data());
float* literal = reader.readArray<float>(4); material->constantTable[i].literal[0] = reader.read<float>();
material->constantTable[i].literal[0] = literal[0]; material->constantTable[i].literal[1] = reader.read<float>();
material->constantTable[i].literal[1] = literal[1]; material->constantTable[i].literal[2] = reader.read<float>();
material->constantTable[i].literal[2] = literal[2]; material->constantTable[i].literal[3] = reader.read<float>();
material->constantTable[i].literal[3] = literal[3];
} }
material->stateBitTable = reader.readArray<Game::GfxStateBits>(material->stateBitsCount); material->stateBitTable = reader.readArray<Game::GfxStateBits>(material->stateBitsCount);