Saturday, August 25, 2012

Getting -hijack working

While working on my latest Portal 2 map, I noticed I chose the wrong compile settings (Expert -> default) versus what I normally choose (basic -> no vrad). Both have extra command line parameters, but have different resolutions and it was the resolution that tipped me off (I usually hit F9 immediately followed by Enter and don't see the compile window). This wasn't a big issue since the map is relatively small and vrad doesn't take that long (5 seconds or so). However, when I went for a recompile, I changed back to the basic compile window and found -hijack working again. Subsequent recompiles using either compile window worked fine as well.

The annoyance since DLC 1


For those who have been following this blog or my YouTube videos, you'll know that I've been having problems getting -hijack working after Valve released Portal 2 dlc. So, I was ecstatic for a bit...then I closed the game and in the next instance -hijack stopped working. This prompted me to look at the options I had to see if they matched up.








The expert window had "+sv_lan 1" in it, but that was really it. That change didn't have an effect on whether -hijack worked, so I decided to look at how the game started up by making the compile window wait for keypress before closing.

For the working -hijack (expert compile), this is what it showed:

"g:\valve\steam\steamapps\common\portal 2\portal2.exe" -hijack -game "g:\valve\steam\steamapps\common\portal 2\portal2" +map "temp" +sv_lan 1 -novid -sw -w 1152 -h 864


The broken -hijack compile showed this:

g:\valve\steam\steam.exe -applaunch 620 -game "g:\valve\steam\steamapps\common\portal 2\portal2" -hijack -novid -sw -w 1440 -h 900 +map "temp"


So, a basic compile runs the game through Steam instead of the Portal2 executable directly. After seeing this, I opened up Process Explorer to see what each runline turned into.

Working:

"g:\valve\steam\steamapps\common\portal 2\portal2.exe" -hijack -game "g:\valve\steam\steamapps\common\portal 2\portal2" +map "temp" +sv_lan 1 -novid -sw -w 1152 -h 864 


Not Working:

"G:\Valve\Steam\steamapps\common\Portal 2\portal2.exe" -game portal2 -steam  -game "g:\valve\steam\steamapps\common\portal 2\portal2" -hijack -novid -sw -w 1440 -h 900 +map temp  -novid
(I don't know why -novid has two spaces infront of it instead of one.)


Running the game with or without the -steam parameter didn't change anything. So I tried messing with the order, specifically where -hijack was placed. No change. Using either runline didn't make a difference. They both worked perfectly. This lead me to believe it was the initial start that made the difference. Maybe Steam wasn't passing -hijack through and was continually blocking it as part of some "is the game running" check that hasn't taken -hijack into account.

And...that was it (perhaps not the speculation bit). If Portal 2 is started via Steam, -hijack doesn't work. Starting portal2.exe directly eliminates this problem. Huh.

I don't know if this applies to other Source games as I currently only develop for Portal 2, so if you're having this same problem, try it. Stick your parameters into an expert compile and use it instead of the basic compile window...or batch it all.

I tried batch compiling Test Map Pack 3 or 4 a few times...vrad threw a fit and botched the lighting in all of the maps. I had to execute one after the other in separate commands by hand. Placing line after line in a batch file was not to vrad's liking.

No comments:

Post a Comment