diff options
| author | jussi | 2022-07-26 16:33:04 +0300 |
|---|---|---|
| committer | jussi | 2022-07-26 16:33:04 +0300 |
| commit | 4f54a0a4992358c633e5e3535e2980211028f3a2 (patch) | |
| tree | 05a52f180c6e200b90811d2ec7baef7a7c2c13a8 /src/models.c | |
| parent | 314d0412a53b8e012ec183c503a69cc32e24ab34 (diff) | |
| download | reilua-enhanced-4f54a0a4992358c633e5e3535e2980211028f3a2.tar.gz reilua-enhanced-4f54a0a4992358c633e5e3535e2980211028f3a2.tar.bz2 reilua-enhanced-4f54a0a4992358c633e5e3535e2980211028f3a2.zip | |
Create material using correct texture source.
Diffstat (limited to 'src/models.c')
| -rw-r--r-- | src/models.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/models.c b/src/models.c index ef5e493..fc294e0 100644 --- a/src/models.c +++ b/src/models.c @@ -1554,7 +1554,13 @@ int lmodelsCreateMaterial( lua_State *L ) { while ( lua_next( L, t4 ) != 0 ) { if ( strcmp( "texture", (char*)lua_tostring( L, -2 ) ) == 0 && lua_isnumber( L, -1 ) ) { - state->materials[i]->maps[map].texture = *state->textures[ lua_tointeger( L, -1 ) ]; + size_t texId = lua_tointeger( L, -1 ); + + if ( !validSourceTexture( texId ) ) { + lua_pushboolean( L, false ); + return 1; + } + state->materials[i]->maps[map].texture = *texturesGetSourceTexture( texId ); } else if ( strcmp( "color", (char*)lua_tostring( L, -2 ) ) == 0 && lua_istable( L, -1 ) ) { state->materials[i]->maps[map].color = uluaGetColor( L ); |
