Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smxlink Segmentation fault #35

Open
Elatronion opened this issue Jul 22, 2021 · 6 comments
Open

smxlink Segmentation fault #35

Elatronion opened this issue Jul 22, 2021 · 6 comments

Comments

@Elatronion
Copy link

smxlink cositantly crashes at certain strcasecmp.
I think I fixed the issue by modifying the if, something like this:

const char* attribute_shading = smxPrimitive->Attribute( "shading" );
if( attribute_shading && strcasecmp( "F", attribute_shading ) == 0 ) {
// ...

over

if( strcasecmp( "F", smxPrimitive->Attribute( "shading" ) ) == 0 ) {
// ...

The main issue seemed to be that smxPrimitive->Attribute( "shading" ) was returning NULL.

Moreover, once "fixed" the outputted file seemed to not have been converted correctly.
Using the n00bdemo as an example, I converted some of the existing smx files to smd and found that my converted files did not match the premade ones. Mine were slightly larger.
star freezes the program when they are supposed to appear during the starting animation.
petscum doesn't cause problems, but was completely invisible or simply not there.

Note:
I am using Linux (Pop!_OS 21.04)
Everything else works like a charm, all example projects compile, etc.

@Lameguy64
Copy link
Owner

Have you tried converting with a scale (-s) parameter? The scale value is used when converting the vertices of the model from floats to fixed point integers. Think I used a value of 100 for the models. If the objects still appear too small try a larger value.

@Elatronion
Copy link
Author

That's good to know, I tried with a scale of 100 and 1000 and sadly saw no difference in results. At times I did notice a small vertex explosion. (the red line, I increased the brightness to actually see it, it's quite dark)
image
It only appears on screen at certain angles.

It is completely possible that my attempt to fix the segmentation fault I had with smxlink has done nothing more than permit the program to persist with faulty data. I didn't do anything clever, simply checked if the data existed before using it. The program probably needs that data. I think it's fair to assume you weren't getting segmentation faults during your conversions.
Meaning, that data did, in fact, exists for you and, for some reason, not for me.

@Lameguy64
Copy link
Owner

What version of tinyxml2 are you using exactly? It should not be possible for the shading attribute to return NULL as all the primitive entires in SMX files always contain shading attribute and all the SMX files I've provided with n00bDEMO do have them. I have a feeling smxtool is parsing the wrong element group for primitives for some reason.

Pardon for being quite slow to respond... Been busy with stuff lately.

@Elatronion
Copy link
Author

It's quite alright, there's no rush! :)

Unless I am mistaken, I'm using tinyxml2 8.0.0.
It is quite the mystery, wish I knew more how smx and smd files worked. Perhaps you have some sources?
I really have no idea what the problem could be, I don't know enough. :/

What I find quite odd is how I converted the very same smd files to smx and have not had the same results.
The start of the issue was that smxlink itself was actually crashing (Segmentation fault) and outputting a file with nothing in it.
I don't suppose you have a newer version of smxlink than the one in this repo? (0.25b)
I'm yet to check if older versions exist, perhaps an update broke something, idk.

@Lameguy64
Copy link
Owner

I haven't done any changes to smxlink since I last used it on n00bDEMO I'm afraid. This is going to be a tricky one to find for me as I've never had a problem with it whatsoever and neither everyone else it seems.

@Elatronion
Copy link
Author

How curious, I'll attempt to use different version of tinyxml2 (when I get around to it). I really have no idea what the problem could be otherwise... By default, smxlink simply crashes, so I'll see if I can somehow get a different result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants