Home > Blog, C++, Computer, Games, Garry's Mod, Modules > gm_mount2 – Mount everything in GMod – Current state

gm_mount2 – Mount everything in GMod – Current state

February 5th, 2010 Leave a comment Go to 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: , ,
  1. The Eagle
    February 6th, 2010 at 12:00 | #1

    nice one, i think if its working good and you release it it can open new dimensions to gmod-players

  2. February 6th, 2010 at 23:56 | #2

    I made a successful attempt today to read/write everything within VPKs reliable.
    Still using models does not work – I have to hook up some more functions. But I think I’ll get this working.

  3. Ali3nSVK
    February 7th, 2010 at 22:15 | #3

    Hi aVoN, if you are now able to spawn L4D models, what about gibbing ? From my gameplay I know that e.g. zombie models gib. Will I be able to gib them in Gmod as well or is that another code work ? Just asking thanks.

  4. February 7th, 2010 at 23:17 | #4

    You could code scripted NPCs which gib when shot but I have not tested this yet.

    Anyway, I still have to do more test. I first thought, it does not crash but now it does (on certain models). I think I’m missing some minor stuff right now I have to fix but I’m sure I will figure that out.

  5. fonix232
    February 8th, 2010 at 18:24 | #5

    Oh good god, you did it! Now we don’t have to copy content files of games with VPk into Gmod!

    Any hope for a closed/open beta test? I don’t mind crashing my PC!

  6. February 8th, 2010 at 19:08 | #6

    Sure. When I come back home, I will setup an SVN-Repository for it.
    But note: For now, you can only do mounting manually and spawning models does not work from the menu.

    It’s current stage is “concept works – but not yet reliable” = “alpha”. Parts are undone.

  7. fonix232
    February 9th, 2010 at 21:01 | #7

    Thats great.
    BTW which language are you writing this? C++? C#?

  8. Wizard of Ass
    February 9th, 2010 at 22:10 | #8

    If you would look into the tags…

    you could see its C++

  9. February 10th, 2010 at 00:37 | #9

    Yes, C++. C# is not as fast as C++ and also not compatible with the Source-Engine’s SDK.

    Edit
    Added SVN and uploaded first alpha.
    Url: http://svn.daggeringcats.com/mount2
    Username: anon
    PW: anon

  10. fonix232
    February 10th, 2010 at 18:38 | #10

    Great.
    What the hell, you included your source code too?
    aVoN, you were a god before, but now you’re my PERSONAL god!

    I’m very impressed.
    (BTW I did not need the username/pw to check it out)

  11. fonix232
    February 10th, 2010 at 19:01 | #11

    Oh and me again.
    Stargate Resistance is out for 10 hours now!

  12. February 10th, 2010 at 19:02 | #12

    Thank you fonix.
    Yes, the sourcecode is included since it will become a GMod-Module and garry requires us to release modules with source.

    Also you do not need a PW, if you already using an SVN service of my site (such as the stargates) – Tortoise SVN (I assume you use that program) and other tools automatically try passwords of one domain if they fit.

  13. February 10th, 2010 at 20:17 | #13

    Good new: I just copied all L4D files into a GMod-Addon and checked if that crashs my game too with some models.

    It does!

    So I can be sure, my addon works flawless and it’s the L4D-Models which make the game crash (DAMN!).

    I think I’ll find out why and fix that, because there is an addon for GMod out there, which simply has copied the models of L4D but added some special files or removed some. Just have to find out which are doing havoc now.

  14. fonix232
    February 10th, 2010 at 21:28 | #14

    Uhm, I don’t use Tortoise to check out GMod addons. I use Deni’s awesome GMod SVN Updater.
    And I’ve never used your SVN with Tortoise.

    (GModSVN Updater uses a different library to handle SVN checkouts called SharpSVN, what has nothing to do with Tortoise)

    Also I’m kinda used to people who just release their app or modules and not the source code. Not that I would copy it and release under my name with a few modifications, but I would like to learn from applications. As I don’t know too much C++ (I can read the code, but if you would ask me to write an app, I would get old in the front of that PC) I like to get all sources I can.
    Again, thanks for the hard work.

    Also I would like to ask for your help. It isn’t about GMod, but mostly about programming and file format reversing. Do you want a little challenge?

  15. February 10th, 2010 at 21:35 | #15

    I just found out, my idea why it crashs was right.
    I just have to find out now, which files are responsible for it so I can blacklist them.

    I updated the SVN. Now, spawning the models from the spawnmenu SHOULD work for most models. All survivors and some infected (smoker makes me crash).

    All I did was disallowing reading files which look like anim_*.mdl or gesture_*.mdl – But I will look at which I really need and which not (tomorrow).

  16. fonix232
    February 10th, 2010 at 21:39 | #16

    That sounds good. Any way, I’m gone for SG:R for today, tomorrow I will return!

    aVoN, please, if you’re interested, e-mail me! (Admins on WP can see unpublished e-mail addresses of posters)

  17. February 12th, 2010 at 22:32 | #17

    Module is now in a state where crashes are minimal – but still happen. Something bad is happening within client.dll – Only garry can help me with this.

    I hope he will answer my mails this time – I really need his help.

  18. fonix232
    February 13th, 2010 at 09:14 | #18

    Garry? Answering e-mails? Don’t make me laugh please Grin

  19. February 13th, 2010 at 18:00 | #19

    He did in the past quite often. ROTFL
    But concerning this topic I mailed him about 4 times and din’t got any reply yet (but on IRC) Pain

  20. February 17th, 2010 at 15:18 | #20

    Just committed an update.

    L4D and L4D2 mounting seems to work perfectly now. At least I don’t get any crashes. I have no idea why it’s working now, but I changed much at the internals. Maybe I had an error somewhere I couldn’t resolve before and I did fix “automatically”.

    Games are listed in the spawnmenu in the browse tab.
    I also added spawnicons for L4D1/2 because generating them sucks. It crashed my GMod about 3 times because of the enormous amount (> 3000) of icons.

  21. February 18th, 2010 at 15:45 | #21

    I release a beta now on facepunch so people can test it: http://www.facepunch.com/showthread.php?t=896910

  1. No trackbacks yet.

Click to Insert Smiley

SmileBig SmileGrinLaughLOLFrownBig FrownWinkKissRazzAngelAngryReally AngryConfusedNeutralThinkingChicCoolNerdSillyDrunken RazzMad RazzEvil GrinMeanPissed OffReally PissedCurseShoutGrit TeethCryWeepSide FrownWiltSmugDisdainRoll EyesSarcasmLoserTalk to the HandShyBeat UpPainShameBeautyBlushCuteLashesKissingKiss BlowKissedHeh!SmirkSnickerGiggleIn LoveDroolEek!ShockSickSuspenseTrembleDazedHypnotizedFoot in MouthMoney MouthQuietShut MouthDOH!IDKQuestionLyingStruggleSweatStopByeGo AwayWavingTime OutCall MeOn the PhoneMeetingSecretHandshakeHigh FiveHug LeftHug RightClapDanceJumpFingers CrossedVictoryYawnSleepyPrayWorshipWaitingAlienClownCowboyCyclopsDevilDoctorFemale FighterMale FighterMohawkMusicPartyPirateSkywalkerSnowmanSoldierGhostSkeletonEatStarvingVampireZombie KillerBunnyCatCat 2ChickChickenChicken 2CowCow 2DogDog 2DuckGoatHippoKoalaLionMonkeyMonkey 2MousePandaPigPig 2SheepSheep 2ReindeerSnailTigerTurtleFemaleMaleHeartBroken HeartRoseDead RosePeaceYin YangUS FlagMoonStarSunCloudyRainThunderUmbrellaRainbowMusic NoteYesNoAirplaneCarIslandAnnouncebrbBeerDrinkLiquorCakeCoffeePizzaWatermelonBowlPlateCanMailCellPhoneCameraFilmTVClockLampSearchCoinsComputerConsolePresentSoccerCloverPumpkinBombHammerKnifeHandcuffsPillPoopCigarette