From: havoc Date: Sat, 15 Oct 2011 01:53:30 +0000 (+0000) Subject: fix crashes in viewthing code X-Git-Tag: xonotic-v0.6.0~163^2~137 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=568a2a0afda742673ebd8cbce2eeded1ac70a10a;p=xonotic%2Fdarkplaces.git fix crashes in viewthing code git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11420 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/host_cmd.c b/host_cmd.c index b60af216..76478705 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -2178,19 +2178,19 @@ void Host_Viewmodel_f (void) SV_VM_Begin(); e = FindViewthing (); - SV_VM_End(); - if (!e) - return; - - m = Mod_ForName (Cmd_Argv(1), false, true, NULL); - if (!m || !m->loaded || !m->Draw) + if (e) { - Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1)); - return; + m = Mod_ForName (Cmd_Argv(1), false, true, NULL); + if (m && m->loaded && m->Draw) + { + PRVM_serveredictfloat(e, frame) = 0; + cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)] = m; + } + else + Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1)); + } - - PRVM_serveredictfloat(e, frame) = 0; - cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)] = m; + SV_VM_End(); } /* @@ -2209,16 +2209,17 @@ void Host_Viewframe_f (void) SV_VM_Begin(); e = FindViewthing (); - SV_VM_End(); - if (!e) - return; - m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)]; + if (e) + { + m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)]; - f = atoi(Cmd_Argv(1)); - if (f >= m->numframes) - f = m->numframes-1; + f = atoi(Cmd_Argv(1)); + if (f >= m->numframes) + f = m->numframes-1; - PRVM_serveredictfloat(e, frame) = f; + PRVM_serveredictfloat(e, frame) = f; + } + SV_VM_End(); } @@ -2246,15 +2247,16 @@ void Host_Viewnext_f (void) SV_VM_Begin(); e = FindViewthing (); SV_VM_End(); - if (!e) - return; - m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)]; + if (e) + { + m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)]; - PRVM_serveredictfloat(e, frame) = PRVM_serveredictfloat(e, frame) + 1; - if (PRVM_serveredictfloat(e, frame) >= m->numframes) - PRVM_serveredictfloat(e, frame) = m->numframes - 1; + PRVM_serveredictfloat(e, frame) = PRVM_serveredictfloat(e, frame) + 1; + if (PRVM_serveredictfloat(e, frame) >= m->numframes) + PRVM_serveredictfloat(e, frame) = m->numframes - 1; - PrintFrameName (m, (int)PRVM_serveredictfloat(e, frame)); + PrintFrameName (m, (int)PRVM_serveredictfloat(e, frame)); + } } /* @@ -2272,17 +2274,17 @@ void Host_Viewprev_f (void) SV_VM_Begin(); e = FindViewthing (); - SV_VM_End(); - if (!e) - return; - - m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)]; + if (e) + { + m = cl.model_precache[(int)PRVM_serveredictfloat(e, modelindex)]; - PRVM_serveredictfloat(e, frame) = PRVM_serveredictfloat(e, frame) - 1; - if (PRVM_serveredictfloat(e, frame) < 0) - PRVM_serveredictfloat(e, frame) = 0; + PRVM_serveredictfloat(e, frame) = PRVM_serveredictfloat(e, frame) - 1; + if (PRVM_serveredictfloat(e, frame) < 0) + PRVM_serveredictfloat(e, frame) = 0; - PrintFrameName (m, (int)PRVM_serveredictfloat(e, frame)); + PrintFrameName (m, (int)PRVM_serveredictfloat(e, frame)); + } + SV_VM_End(); } /*