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

r_drawworld 0 fails (fix) #107

Open
Baker7 opened this issue Nov 14, 2023 · 4 comments · May be fixed by #229
Open

r_drawworld 0 fails (fix) #107

Baker7 opened this issue Nov 14, 2023 · 4 comments · May be fixed by #229

Comments

@Baker7
Copy link

Baker7 commented Nov 14, 2023

r_drawworld 0 sometimes does not work ...

cl_screen.c

	// if CSQC is loaded, it is required to provide the CSQC_UpdateView function,
	// and won't render a view if it does not call that.
	if (cl.csqc_loaded) {
		CL_VM_UpdateView(r_stereo_side ? 0.0 : max(0.0, cl.time - cl.oldtime));
	}
	else
	{
		cl.csqc_vidvars.drawworld = r_drawworld.integer != 0; // Baker: this line missing

		// Prepare the scene mesh for rendering - this is lightning beams and other effects rendered as normal surfaces
		CL_MeshEntities_Scene_FinalizeRenderEntity();

		CL_UpdateEntityShading();
		R_RenderView(0, NULL, NULL, r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
	}
@hemebond
Copy link
Contributor

hemebond commented Apr 13, 2024

@Baker7 What does adding that line do? Is it because cl.csqc_vidvars.drawworld is not set in that code branch/path, but is set in the first?

Can you also give me an example of how I would test the fix, please?

@Baker7
Copy link
Author

Baker7 commented Apr 13, 2024

To test: Start up a map

Type r_drawworld 0 ... it should draw entities and such, but not map. Then type r_drawworld 1, it should draw everything again.

r_drawworld 0 can be invaluable during engine or map testing, you can see every entity being draw from your view.

You can also use it to determine if something is an entity.

// if CSQC is loaded, it is required to provide the CSQC_UpdateView function,
	// and won't render a view if it does not call that.
	if (cl.csqc_loaded) {
		CL_VM_UpdateView(r_stereo_side ? 0.0 : max(0.0, cl.time - cl.oldtime));
	}
	else
	{
		cl.csqc_vidvars.drawworld = r_drawworld.integer != 0; // Baker: this line missing <===== ===== ==== JUST ADD THIS

		// Prepare the scene mesh for rendering - this is lightning beams and other effects rendered as normal surfaces
		CL_MeshEntities_Scene_FinalizeRenderEntity();

		CL_UpdateEntityShading();
		R_RenderView(0, NULL, NULL, r_refdef.view.x, r_refdef.view.y, r_refdef.view.width, r_refdef.view.height);
	}

@hemebond
Copy link
Contributor

hemebond commented Apr 13, 2024

I tried adding that line and it caused a segfault in demo1, when the player takes a grenade to the face, when r_drawworld is 0.

    Engine Crash: Segmentation fault    
./darkplaces-sdl(CL_ParticleExplosion+0x19c)[0x55dfa2ea5e43]
./darkplaces-sdl(+0xd2eb0)[0x55dfa2ea7eb0]
./darkplaces-sdl(+0xd8c3c)[0x55dfa2eadc3c]
./darkplaces-sdl(CL_ParticleBox+0x1f)[0x55dfa2eadd6d]
./darkplaces-sdl(CL_ParticleEffect+0x21)[0x55dfa2eadd94]
./darkplaces-sdl(+0xc59cc)[0x55dfa2e9a9cc]
./darkplaces-sdl(CL_ParseServerMessage+0x2c72)[0x55dfa2e9e277]
./darkplaces-sdl(CL_ReadDemoMessage+0x334)[0x55dfa2e7e179]
./darkplaces-sdl(CL_Frame+0x355)[0x55dfa2e92be5]
./darkplaces-sdl(Host_Main+0x1b6)[0x55dfa2f2f328]
./darkplaces-sdl(main+0x1f4)[0x55dfa304abff]
/lib/x86_64-linux-gnu/libc.so.6(+0x276ca)[0x7f19948856ca]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85)[0x7f1994885785]
./darkplaces-sdl(_start+0x21)[0x55dfa2e4cd71]
DarkPlaces-Quake Linux, buildstring: v20140513-1463-g58dc7879~ Apr 14 2024 debug
Segmentation fault
diff --git a/cl_screen.c b/cl_screen.c
index 04d25a01..6f0d3ccc 100644
--- a/cl_screen.c
+++ b/cl_screen.c
@@ -1686,6 +1686,8 @@ static void SCR_DrawScreen (void)
                        CL_VM_UpdateView(r_stereo_side ? 0.0 : max(0.0, cl.time - cl.oldtime));
                else
                {
+                       cl.csqc_vidvars.drawworld = r_drawworld.integer != 0;
+
                        // Prepare the scene mesh for rendering - this is lightning beams and other effects rendered as normal surfaces
                        CL_MeshEntities_Scene_FinalizeRenderEntity();

@hemebond hemebond linked a pull request Dec 17, 2024 that will close this issue
@hemebond
Copy link
Contributor

It no longer crashes during the demo so I've raised a PR to implement the change.

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