<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Daggering Cats &#187; Modules</title>
	<atom:link href="http://www.daggeringcats.com/index.php/category/games/garrys-mod/modules/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.daggeringcats.com</link>
	<description>... because we want the Bra!</description>
	<lastBuildDate>Sat, 07 Aug 2010 05:24:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>gm_mount2 &#8211; Mount everything in GMod &#8211; Current state</title>
		<link>http://www.daggeringcats.com/index.php/2010/02/05/gm_mount2-mount-everything-in-gmod-current-state/</link>
		<comments>http://www.daggeringcats.com/index.php/2010/02/05/gm_mount2-mount-everything-in-gmod-current-state/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 22:05:46 +0000</pubDate>
		<dc:creator>aVoN</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Computer]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Garry's Mod]]></category>
		<category><![CDATA[Modules]]></category>
		<category><![CDATA[GMod]]></category>
		<category><![CDATA[Module]]></category>

		<guid isPermaLink="false">http://www.daggeringcats.com/index.php/2010/02/05/gm_mount2-mount-everything-in-gmod-current-state/</guid>
		<description><![CDATA[In the past two weeks, I have been working on gm_mount2, an adaption but also totally rewrite from scratch of this addon for GMod. My intention first was making it mount games automatically if you install it serverside (the way it is in that link needs heavy modifications to make it run) and an easy [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.daggeringcats.com/wordpress/wp-content/uploads/2010/02/gm_mount21.png" rel="shadowbox[post-606];player=img;"></a><a href="http://www.daggeringcats.com/wordpress/wp-content/uploads/2010/02/gm_mount21.png" rel="shadowbox[post-606];player=img;"><img class="alignright size-medium wp-image-607" title="gm_mount2" src="http://www.daggeringcats.com/wordpress/wp-content/uploads/2010/02/gm_mount21-300x187.png" alt="" width="300" height="187" /></a>In the past two weeks, I have been working on gm_mount2, an adaption but also totally rewrite from scratch of <a href="http://www.facepunch.com/showthread.php?t=637181">this addon</a> for GMod.</p>
<p>My intention first was making it mount games automatically if you install it serverside (the way it is in that link needs heavy modifications to make it run) and an easy integration into GMod&#8217;s default mounting-menu.</p>
<p>This was done really easily and I started thinking about &#8220;why can&#8217;t garry make GMod mount L4D?&#8221;. I took some more deeper research into it and found out, that L4D and L4D2 don&#8217;t use <a href="http://developer.valvesoftware.com/wiki/GCF">GCF-files</a> to store their models, sounds and everything in &#8211; They use <a href="http://developer.valvesoftware.com/wiki/VPK">VPK files</a> which are unsupported for mounting in the OrangeBox version of the Source-Engine where GMod runs on.</p>
<p>Luckily it rushed into my mind that <a href="http://nemesis.thewavelength.net">Nemesis</a>, the coder of <a href="http://nemesis.thewavelength.net/index.php?c=76">GCFScape</a>, has a library called <a href="http://nemesis.thewavelength.net/index.php?c=108">HLLib</a> which allows reading from VPK containers. It took me around 2 hours to figure out how HLLib works and I made my first successful attempt in reading from VPKs.</p>
<p>But now the torture began: How shall I tell GMod to read from VPKs? My idea was overriding default FileIO functions of Source which are stored in the interface IFileSystem and IBaseFileSystem. My idea was using <a href="http://research.microsoft.com/en-us/projects/detours/">MS Detours</a> which is known to be detectable by <a href="http://supportwiki.steampowered.com/wiki/Valve_Anti-Cheat_System_%28VAC%29">VAC</a> so I searched different ways for about 3 days before I got told &#8220;<a href="http://www.facepunch.com/showthread.php?t=886944">VAC in GMod is active but does not ban</a>&#8221; (yet).</p>
<p>So the plan was clear: Detouring the methods of the interface and intercept if a file within a VPK is requested. It was all so clear and easy in my head but I got beaten down by reality really fast again. The methods of the interface I have to hook/overwrite are <a href="http://en.wikipedia.org/wiki/Virtual_function">virtual</a>, which makes them a pain in the ass to hook. It took me 2 days with the help of mainly <a href="http://cdbarrett.com/">Jinto</a> before I was able to hook those. If any developer is interested in, you can find my <a href="http://www.daggeringcats.com/images//cpp/detours/virtualmember.h" target="_blank">VDETOUR script here</a>.</p>
<p>Hooking now worked but I first had to figure our a fast and efficient way of tracing opened files so I can tell it’s either a file within a VPK or a “normal file”. This took me 3 more days.</p>
<div id="attachment_609" class="wp-caption alignright" style="width: 310px"><a href="http://www.daggeringcats.com/wordpress/wp-content/uploads/2010/02/francis.png" rel="shadowbox[post-606];player=img;"><img class="size-medium wp-image-609" title="francis" src="http://www.daggeringcats.com/wordpress/wp-content/uploads/2010/02/francis-300x232.png" alt="" width="300" height="232" /></a><p class="wp-caption-text">Yes, I suck at ragdoll-posing - In the console you  see what the filesystem has done etc and in the background you see  Francis</p></div>
<p>Today I had my first successful attempt reading a file from within a VPK in GMod with GMod’s lua function <a href="http://wiki.garrysmod.com/?title=File.Read" target="_blank">file.Read</a> <span style="text-decoration: line-through;">but it just read about 500 letters at max – how silly</span>.</p>
<p>Recapitulation: It was a pain in the ass to implement. Especially because my lack of knowledge of GMod’s internals. It could have been so much easier to implement if I’d be the mod-coder.</p>
<p><strong>Update</strong>:</p>
<p>Today I made the successful attempt in loading a model of L4D in GMod using my module. It works flawless! <span style="text-decoration: line-through;">No crashes etc</span>. Now I only have to implement some minor stuff like file-searching and the lua-interface. <span style="text-decoration: line-through;">Maybe one ore two more days and I can release it</span>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.daggeringcats.com/index.php/2010/02/05/gm_mount2-mount-everything-in-gmod-current-state/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>
