Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: HLD_Prophecy on November 07, 2015, 08:20:33 pm

Title: Wierd Error: Assert?
Post by: HLD_Prophecy on November 07, 2015, 08:20:33 pm
Upon trying to launch my mod-in-progress, I'm getting this strange error:

Code: [Select]
Assert: mp->nverts > 1
File: modelread.cpp
Line: 2780

ntdll.dll! ZwWaitForSingleObject + 21 bytes
kernel32.dll! WaitForSingleObjectEx + 67 bytes
kernel32.dll! WaitForSingleObject + 18 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! SCP_DumpStack + 354 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! WinAssert + 194 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! model_maybe_fixup_subsys_path + 169 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! model_set_subsys_path_nums + 307 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! model_load + 3732 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! techroom_select_new_entry + 450 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! techroom_do_frame + 782 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! game_do_state + 333 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! gameseq_process_events + 237 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! game_main + 782 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! WinMain + 330 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! __tmainCRTStartup + 358 bytes
fs2_open_3_7_2_NO-SSE-DEBUG.exe! WinMainCRTStartup + 15 bytes
kernel32.dll! BaseThreadInitThunk + 18 bytes
ntdll.dll! RtlInitializeExceptionChain + 99 bytes
ntdll.dll! RtlInitializeExceptionChain + 54 bytes

I've done some model and table edits recently so they may be the cause. Anyone know what this means?
Title: Re: Wierd Error: Assert?
Post by: niffiwan on November 07, 2015, 08:31:15 pm
From a quick look at the code I'd say one of your pof subsystem paths doesn't have enough vertices (i.e. points). Unfortunately the Assert doesn't tell you which subsystem has the problem... or even which ship  :blah:

(for any other coders looking at this)
Code: [Select]
// ensure that the subsys path is at least SUBSYS_PATH_DIST from the
// second last to last point.
void model_maybe_fixup_subsys_path(polymodel *pm, int path_num)
{
vec3d *v1, *v2, dir;
float dist;
int index_1, index_2;

Assert( (path_num >= 0) && (path_num < pm->n_paths) );

model_path *mp;
mp = &pm->paths[path_num];

Assert(mp != NULL);
Assert(mp->nverts > 1);

index_1 = 1;
index_2 = 0;

v1 = &mp->verts[index_1].pos;
v2 = &mp->verts[index_2].pos;

dist = vm_vec_dist(v1, v2);
if (dist < (SUBSYS_PATH_DIST - 10))
{
vm_vec_normalized_dir(&dir, v2, v1);
vm_vec_scale_add(v2, v1, &dir, SUBSYS_PATH_DIST);
}
}
Title: Re: Wierd Error: Assert?
Post by: AdmiralRalwood on November 07, 2015, 08:31:59 pm
Presumably he knows which ship he just tried to select when it crashed, but yes, that could be made a more informative assertion.
Title: Re: Wierd Error: Assert?
Post by: niffiwan on November 07, 2015, 09:07:23 pm
FYI, I've created a PR (https://github.com/scp-fs2open/fs2open.github.com/pull/422) to change the Assert into an Error and provide some useful info.

Edit: it's been committed so the next nightly should tell you which ship, path & parent path has the issue.
Title: Re: Wierd Error: Assert?
Post by: HLD_Prophecy on November 09, 2015, 08:38:40 pm
Problem solved!

Sooo... I took a closer gander at the .pof (It's the GTB Kronus [http://www.hard-light.net/wiki/index.php/GTB_Kronus (http://www.hard-light.net/wiki/index.php/GTB_Kronus)] for future reference) and it turns out that the turret paths were empty. They each had one object labeled "Vertex 1" but this was basically empty. No paths. So I used the PCS Auto-Generate function to generate paths, and hey presto!

Works fine now, thanks a bunch! FRED'ers here are so helpful. You guys really go the distance. Making good progress on my mod now.  :)