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

Crash when loading hdr lightmaps #59

Closed
AntiAnti opened this issue Mar 7, 2024 · 1 comment · Fixed by taysta/TaystJK#175
Closed

Crash when loading hdr lightmaps #59

AntiAnti opened this issue Mar 7, 2024 · 1 comment · Fixed by taysta/TaystJK#175

Comments

@AntiAnti
Copy link

AntiAnti commented Mar 7, 2024

It's quite weird. I get this crash when loading my baked lighting on laptop. It doesn't happen on desktop PC (why??) and doesn't happen on laptop with lighting baked by SomaZ (for t1_rail). The crash happens when it tries to load non-existing sky texture, but I didn't dig deeper. Anyway, solution is quite simple.

R_FindImageFile function in tr_image.cpp tries to load HDR image and then checks if it succeed by testing output buffer:

		R_LoadHDRImage(filename, &pic, &width, &height);
		if (pic == NULL)
			...

The problem is, R_LoadHDRImage doesn't reset buffer to NULL if it failed.
So, in shared/rd-rend2/tr_image_stb.cpp need to add three lines:

// Loads a HDR image from file.
void R_LoadHDRImage( const char *filename, byte **data, int *width, int *height )
{
	byte *buf = NULL;
	int x, y, n;

	int len = ri.FS_ReadFile (filename, (void **)&buf);
	if ( len <= 0 || buf == NULL )
	{
		// reset output varialbes
		*data = NULL;
		*width = 0;
		*height = 0;

		return;
	}
	...

SomaZ added a commit that referenced this issue Mar 7, 2024
@SomaZ
Copy link
Owner

SomaZ commented Mar 7, 2024

Meh, forgot to co-author you. Sorry about that. Hope that's ok.

taysta pushed a commit to taysta/TaystJK that referenced this issue Mar 11, 2024
taysta added a commit to taysta/TaystJK that referenced this issue Mar 11, 2024
* [rend2] Reset output in R_LoadHDRImage

Fixes SomaZ#59

---------

Co-authored-by: SomaZ <17459161+SomaZ@users.noreply.github.com>
SomaZ added a commit that referenced this issue Mar 21, 2024
@SomaZ SomaZ closed this as completed Mar 24, 2024
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

Successfully merging a pull request may close this issue.

2 participants