Jump to content

Fix Unhandled Empty Textureset


Exygo

Recommended Posts

  • Active Member

How the bug manifests?

Client closes without any syserr

 

How to reproduce the bug?

Let' say you got textureset/metin2_map_c1.txt and inside you got an empty string like this:

TextureSet

TextureCount 17
Start Texture001
    ""
    5.000000
    5.000000
    0.000000
    0.000000
    0
    0
    0
End Texture001
Start Texture002
    "d:\ymir work\terrainmaps\b\field\field 02.dds"
    6.000000
    6.000000
    0.000000
    0.000000
    0
    0
    0
End Texture002

 

binary/src/source/PRTerrainLib/TextureSet.cpp

Search this lin inside bool CTextureSet::SetTexture

if (!pResource->IsType(CGraphicImage::Type()))

 

And add before

	if (!pResource)
		return false;

 

Search this line inside bool CTextureSet::AddTexture

if (!pResource->IsType(CGraphicImage::Type()))

 

And add before

if (!pResource)
		return false;

 

  • Love 6
Link to comment
Share on other sites

Thanks for sharing us!

But I think this way is much better and cleaner:

if (!pResource || !pResource->IsType(CGraphicImage::Type()))

 

Hmm, with this way it just simply crash, but if I make that small if separate from the pointer check it works. Can someone explain me this?

As I know, when the program enter an if statement which contains an or gate, then check the first one and if it's true then skip the other ones. May I know wrong?

Edited by Aerrow
mistake
Link to comment
Share on other sites

  • Active Member
15 hours ago, Aerrow said:

Thanks for sharing us!

But I think this way is much better and cleaner:


if (!pResource || !pResource->IsType(CGraphicImage::Type()))

 

Hmm, with this way it just simply crash, but if I make that small if separate from the pointer check it works. Can someone explain me this?

As I know, when the program enter an if statement which contains an or gate, then check the first one and if it's true then skip the other ones. May I know wrong?

It should not count at the speed of the code or other performance criteria but depends how obssessed you are.

And yes as I know and experienced the first one should trigger the condition and then the other ones should be ignored.

But if you look down at the line with TraceError as long as the pointer is NULL he can't call ->GetFileName() from a NULL pointer :DYou should know that.

In conclusion stop trying to impress :D

  • Love 1
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.