summaryrefslogtreecommitdiff
path: root/src/models.c
diff options
context:
space:
mode:
authorjussi2023-04-10 14:33:15 +0300
committerjussi2023-04-10 14:33:15 +0300
commit1cbadf56f33641e85fc634a326c0db6935947c23 (patch)
tree666551c4a62d77b840fa83948c60df3b6ab726ea /src/models.c
parent8abed46dfdc73e616891f86099bfcebdf03caede (diff)
downloadreilua-enhanced-1cbadf56f33641e85fc634a326c0db6935947c23.tar.gz
reilua-enhanced-1cbadf56f33641e85fc634a326c0db6935947c23.tar.bz2
reilua-enhanced-1cbadf56f33641e85fc634a326c0db6935947c23.zip
New argument style for gui and easings.
Diffstat (limited to 'src/models.c')
-rw-r--r--src/models.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/models.c b/src/models.c
index 3ab5b99..963bd56 100644
--- a/src/models.c
+++ b/src/models.c
@@ -1728,10 +1728,17 @@ int lmodelsLoadModel( lua_State *L ) {
lua_pushinteger( L, -1 );
return 1;
}
- int i = newModel();
- *state->models[i] = LoadModel( lua_tostring( L, 1 ) );
- lua_pushinteger( L, i );
+ if ( FileExists( lua_tostring( L, 1 ) ) ) {
+ int i = newModel();
+ *state->models[i] = LoadModel( lua_tostring( L, 1 ) );
+ lua_pushinteger( L, i );
+ return 1;
+ }
+ else {
+ lua_pushinteger( L, -1 );
+ return 1;
+ }
return 1;
}
@@ -2063,21 +2070,19 @@ int lmodelsLoadModelAnimations( lua_State *L ) {
lua_pushinteger( L, -1 );
return 1;
}
- int i = 0;
- for ( i = 0; i < state->animationCount; i++ ) {
- if ( state->animations[i] == NULL ) {
- break;
- }
- }
- state->animations[i] = malloc( sizeof( ModelAnimations ) );
- state->animations[i]->animations = LoadModelAnimations( lua_tostring( L, 1 ), &state->animations[i]->animCount );
- checkAnimationRealloc( i );
-
- lua_pushinteger( L, i );
- lua_pushinteger( L, state->animations[i]->animCount );
+ if ( FileExists( lua_tostring( L, 1 ) ) ) {
+ int i = newAnimation();
+ state->animations[i]->animations = LoadModelAnimations( lua_tostring( L, 1 ), &state->animations[i]->animCount );
+ lua_pushinteger( L, i );
+ lua_pushinteger( L, state->animations[i]->animCount );
- return 2;
+ return 2;
+ }
+ else {
+ lua_pushinteger( L, -1 );
+ return 1;
+ }
}
/*