summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/quake/model.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/progs/quake/model.c')
-rw-r--r--apps/plugins/sdl/progs/quake/model.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/apps/plugins/sdl/progs/quake/model.c b/apps/plugins/sdl/progs/quake/model.c
index 7648590db4..64c53dfc3e 100644
--- a/apps/plugins/sdl/progs/quake/model.c
+++ b/apps/plugins/sdl/progs/quake/model.c
@@ -255,6 +255,18 @@ Loads a model into the cache
255*/ 255*/
256model_t *Mod_LoadModel (model_t *mod, qboolean crash) 256model_t *Mod_LoadModel (model_t *mod, qboolean crash)
257{ 257{
258 // prevents crashes
259 extern struct mutex snd_mutex;
260 extern int snd_mutex_init;
261
262 if(!snd_mutex_init)
263 {
264 rb->mutex_init(&snd_mutex);
265 snd_mutex_init = 1;
266 }
267
268 rb->mutex_lock(&snd_mutex);
269
258 //printf("loadmodel 1"); 270 //printf("loadmodel 1");
259 unsigned *buf; 271 unsigned *buf;
260 byte stackbuf[1024]; // avoid dirtying the cache heap 272 byte stackbuf[1024]; // avoid dirtying the cache heap
@@ -264,13 +276,17 @@ model_t *Mod_LoadModel (model_t *mod, qboolean crash)
264 if (Cache_Check (&mod->cache)) 276 if (Cache_Check (&mod->cache))
265 { 277 {
266 mod->needload = NL_PRESENT; 278 mod->needload = NL_PRESENT;
279 rb->mutex_unlock(&snd_mutex);
267 return mod; 280 return mod;
268 } 281 }
269 } 282 }
270 else 283 else
271 { 284 {
272 if (mod->needload == NL_PRESENT) 285 if (mod->needload == NL_PRESENT)
273 return mod; 286 {
287 rb->mutex_unlock(&snd_mutex);
288 return mod;
289 }
274 } 290 }
275 291
276// 292//
@@ -283,17 +299,23 @@ model_t *Mod_LoadModel (model_t *mod, qboolean crash)
283 299
284 //printf("loadmodel 2"); 300 //printf("loadmodel 2");
285 buf = (unsigned *)COM_LoadStackFile (mod->name, stackbuf, sizeof(stackbuf)); 301 buf = (unsigned *)COM_LoadStackFile (mod->name, stackbuf, sizeof(stackbuf));
302 //printf("LoadModel0: %08x (%08x)", buf[0], buf);
286 if (!buf) 303 if (!buf)
287 { 304 {
288 if (crash) 305 if (crash)
289 Sys_Error ("Mod_NumForName: %s not found", mod->name); 306 Sys_Error ("Mod_NumForName: %s not found", mod->name);
307
308 rb->mutex_unlock(&snd_mutex);
290 return NULL; 309 return NULL;
291 } 310 }
292 311
293// 312//
294// allocate a new model 313// allocate a new model
295// 314//
315 //printf("LoadModel1: %08x (%08x)", buf[0], buf);
316
296 COM_FileBase (mod->name, loadname); 317 COM_FileBase (mod->name, loadname);
318 //printf("LoadModel2: %08x (%08x)", buf[0], buf);
297 319
298 loadmodel = mod; 320 loadmodel = mod;
299 321
@@ -316,10 +338,12 @@ model_t *Mod_LoadModel (model_t *mod, qboolean crash)
316 break; 338 break;
317 339
318 default: 340 default:
341 //printf("unkn %08x (&=%08x), nat %08x def to brush", LittleLongUnaligned(buf[0]), &buf[0], buf[0]);
319 Mod_LoadBrushModel (mod, buf); 342 Mod_LoadBrushModel (mod, buf);
320 break; 343 break;
321 } 344 }
322 345
346 rb->mutex_unlock(&snd_mutex);
323 return mod; 347 return mod;
324} 348}
325 349