Archive

Posts Tagged ‘C++’

gm_mount2 – Use any source-engine content in GMod

February 19th, 2010 120 comments

Description
This addon allows you mounting any source-engine games in Garry’s Mod including default VALVE games, Steamworks content like D.I.P.R.I.P, Left 4 Dead and every installed SourceMod.

Prerequisites
You need to have MSVC 2010 Redistributable x86 installed, or it will not work.

Download

The full version includes spawnicons for some models (several MB). The light version doesn’t, so it is much smaller. But you have to generate the icons yourself.

SVN-Repository

Url: http://svn.daggeringcats.com/mount2
User: anon
Password: anon

Annotations for Left 4 Dead 1/2:
Left 4 Dead maps are not compatible with Garry’s Mod. Don’t try loading them – This will only cause GMod to crash.

Why another mounting addon?
You may know the orginal mounting addon and it’s extension for sourcemods. They work well but I wasn’t really satisfied with the way they work and I disliked their messy sourcecode so I wrote up my own from scratch.
My addon directly integrates into GMod and works on dedicated servers which is not possible without many modifications of the old gm_mount addon.
It also can mount Left 4 Dead and Left 4 Dead 2 which is the main purpose of this addon, which took me over 3 weeks, around 2000 lines of C++ code and much coffee to figure that out.

gm_mount2 – Mount everything in GMod – Current state

February 5th, 2010 23 comments

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 integration into GMod’s default mounting-menu.

This was done really easily and I started thinking about “why can’t garry make GMod mount L4D?”. I took some more deeper research into it and found out, that L4D and L4D2 don’t use GCF-files to store their models, sounds and everything in – They use VPK files which are unsupported for mounting in the OrangeBox version of the Source-Engine where GMod runs on.

Luckily it rushed into my mind that Nemesis, the coder of GCFScape, has a library called HLLib 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.

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 MS Detours which is known to be detectable by VAC so I searched different ways for about 3 days before I got told “VAC in GMod is active but does not ban” (yet).

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 virtual, which makes them a pain in the ass to hook. It took me 2 days with the help of mainly Jinto before I was able to hook those. If any developer is interested in, you can find my VDETOUR script here.

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.

Yes, I suck at ragdoll-posing - In the console you see what the filesystem has done etc and in the background you see Francis

Today I had my first successful attempt reading a file from within a VPK in GMod with GMod’s lua function file.Read but it just read about 500 letters at max – how silly.

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.

Update:

Today I made the successful attempt in loading a model of L4D in GMod using my module. It works flawless! No crashes etc. Now I only have to implement some minor stuff like file-searching and the lua-interface. Maybe one ore two more days and I can release it!

Categories: Blog, C++, Computer, Games, Garry's Mod, Modules Tags: , ,