Bug 4339 - fix up the levelShot command hack
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: GIT MASTER
Hardware: All All
: P3 minor
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2009-11-11 12:26 EST by /dev/humancontroller
Modified: 2011-02-08 13:10:08 EST
1 user (show)

See Also:


Attachments
remove the abusable levelshot command and related hacks (4.71 KB, patch)
2011-02-07 00:41 EST, /dev/humancontroller
reimplement the levelshot hack in a simpler and more secure way (2.20 KB, patch)
2011-02-07 13:10 EST, /dev/humancontroller
combined patch (5.56 KB, patch)
2011-02-07 13:12 EST, /dev/humancontroller
Simple patch (829 bytes, patch)
2011-02-08 12:48 EST, Zack Middleton
Simple patch w/ sp fix (1.13 KB, patch)
2011-02-08 12:58 EST, Zack Middleton

Description /dev/humancontroller 2009-11-11 12:26:20 EST
Often, devmap mode is used for having a type of game, not "development". So servers are sometimes in devmap mode, publicly. There is a game command "levelShot" which will automatically put the game into the intermission state. Comments say it's a development facility, browse them for an explanation. A hacky/outdated one I'd say: on a public devmap server, anyone can silently cut the game with this command.

When the game receives a "levelShot" command from any client, if sv_cheats is true, then the game will go into the intermission state and send everyone the "clientLevelShot" command. For non-local clients the engine (!) drops the command, and for local clients (on which a server is currently running) the cgame would stop drawing 2D graphics and then the engine takes a screenshot, by which time the player camera should be in the intermission view.

I'd remove the whole hack'o'rama, but let's be a bit more zakkish, Timboish and Undeferenceish:

The "levelShot" command should be implemented as a local console command, not a client command. The game should, in response to the command, execute console commands to create screenshots. These commands will not be valid on dedicated servers, just like the current behaviour, only a bit more cleanly. The engine-side dropping of "clientLevelShot" could be still supported for old cgames.

(Other things include the hud not showing up until restarting manually in case of a map restart.)
Comment 1 Thilo Schulz 2011-02-04 08:40:28 EST
You can reopen this bug when you have a patch for this which is reasonably clean. Otherwise, I don't see why we should support this developer mode specially for some border cases (namely the server running devmap is not a dedicated server). I don't feel like cleaning this up.
Comment 2 /dev/humancontroller 2011-02-07 00:39:56 EST
(In reply to comment #1)
> I don't see why we should support this developer mode
> specially for some border cases (namely the server running devmap is not a
> dedicated server)

Nothing keeps a server in developer mode from being dedicated. (You do know that developer mode means that sv_cheats is true, do you?)
Comment 3 /dev/humancontroller 2011-02-07 00:41:59 EST
Created attachment 2581 [details]
remove the abusable levelshot command and related hacks

As a supplement, you can provide a readme on how to make levelshots in the game (during intermission, do: set cg_draw2d 0; screenshot levelshot;).
Comment 4 Thilo Schulz 2011-02-07 08:54:15 EST
> Nothing keeps a server in developer mode from being dedicated. (You do know
> that developer mode means that sv_cheats is true, do you?)

In your first post you said this bug only appears if sv_cheats is 1 AND the local server running is not a dedicated server, but has a client on top as well. So where is the problem?

I looked at your patch. Isn't there another way to fix this besides just removing all of the command? What is it used for anyways?
Comment 5 /dev/humancontroller 2011-02-07 11:38:34 EST
(In reply to comment #4)
> In your first post you said this bug only appears if sv_cheats is 1 AND the
> local server running is not a dedicated server, but has a client on top as
> well. So where is the problem?
No, the game is stopped in either case. However, if there is a local client running, then the outcome may even be useful.

> I looked at your patch. Isn't there another way to fix this besides just
> removing all of the command? What is it used for anyways?
I can move the hack to a console-only command, which will allow only a local or rconned client to put the game into an intermission state via this feature; the command will make the game spit out some other commands, which will execute successfully only if a client is running, and print "command not found messages" otherwise. A patch will follow shortly.

Apparently this feature was used during development to easily make screenshots taken from the "intermission camera location" of each map, for use in map thumbnails. I don't see a need for it, as a thumbnail for a custom map doesn't need to follow this convention, furthermore, such screenshots can be taken with little effort, without the help of this hack. Allow me to quote the code comments:

	// the clientLevelShot command is used during development
	// to generate 128*128 screenshots from the intermission
	// point of levels for the menu system to use
	// we pass it along to the cgame to make apropriate adjustments,
	// but we also clear the console and notify lines here

/*
==================
Cmd_LevelShot_f

This is just to help generate the level pictures
for the menus.  It goes to the intermission immediately
and sends over a command to the client to resize the view,
hide the scoreboard, and take a special screenshot
==================
*/
Comment 6 /dev/humancontroller 2011-02-07 13:10:04 EST
Created attachment 2582 [details]
reimplement the levelshot hack in a simpler and more secure way

Well, this is what I came up with. The levelshot command still client-to-server command (not a console command), but it will only do anything when it is issued by the local client (I assume this implies that both the (graphical) client and the server modules are running).
Comment 7 /dev/humancontroller 2011-02-07 13:12:53 EST
Created attachment 2583 [details]
combined patch
Comment 8 Zack Middleton 2011-02-08 12:48:12 EST
Created attachment 2584 [details]
Simple patch

Only allow levelshot to be used the "localhost" client, which is only true for client in the same binary as the server.

Reset cg.levelShot at map restart to fix no 2D issue.
Comment 9 Zack Middleton 2011-02-08 12:58:00 EST
Created attachment 2585 [details]
Simple patch w/ sp fix

Same as above but uses enum GT_SINGLE_PLAYER.
Comment 10 Thilo Schulz 2011-02-08 13:08:03 EST
ok, check out r1873, all should be fixed here.