Difference between revisions of "Frequently Asked Questions (Metamod:Source)"

From AlliedModders Wiki
Jump to: navigation, search
m
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
  
 
=====Q: How do I install Metamod:Source?=====
 
=====Q: How do I install Metamod:Source?=====
Please look in the [[Installing SourceMM|Installation]] section of the documentation.
+
Please look in the [[Installing Metamod:Source|Installation]] section of the documentation.
  
 
=====Q: Does Metamod: Source Create Lag?=====
 
=====Q: Does Metamod: Source Create Lag?=====
No. The library Metamod: Source is based off is called SourceHook. Unlike the original Metamod for Half-Life 1, Metamod: Source only hooks functions when a hook is declared. It does not intercept every call by default, and does not require a complex routing table for each individual call regardless of whether that call is being used.
+
No. Metamod:Source is based off a library called SourceHook. Unlike the original Metamod for Half-Life 1, Metamod:Source only hooks functions when asked to by a plugin. It does not intercept every call by default, and does not require a complex routing table for unused hooks.
  
In non-technical terms? [[SourceMM|Metamod: Source]] is only there when you need it to be. The hooking method, although complicated, is very efficient and takes advantage of some of the odder features of C++.
+
In non-technical terms? [[Metamod:Source]] is only there when you need it to be. The hooking method, although complicated, is very efficient and takes advantage of some of the odder features of C++.
  
 
And unlike the original Metamod, the binary is one tenth the size - the Half-Life 2 engine does not require a massive repository of linked entities to be exported in the same way Half-Life 1 did.
 
And unlike the original Metamod, the binary is one tenth the size - the Half-Life 2 engine does not require a massive repository of linked entities to be exported in the same way Half-Life 1 did.
  
 
=====Q: Will Server Plugins run on Metamod: Source?=====
 
=====Q: Will Server Plugins run on Metamod: Source?=====
No. You can still run them as server plugins though, and they will still work. Metamod: Source plugins are separate.
+
No. Metamod:Source plugins are separate. You can run them side by side, as long as the server plugins do not have any compatibility issues or private hooks that interfere.
 
 
=====Q: Why is Metamod:Source not a Server Plugin?=====
 
Metamod:Source is not a server plugin so it can have complete control over its environment.  This lets us (and by extension, developers) isolate exactly what they need to do, in the most minimalistic manner we choose.  It also lets you intercept the GameDLL, which you cannot do as a server plugin.
 
 
 
Once Valve fixes some crucial flaws of Server Plugins (such as better error messaging and adding unloadability) we will consider porting MM:S to that platform.
 
 
 
=====Q: Why does HL2 say 'GameDLL loaded for Metamod:Source'?=====
 
The Half-Life 2 engine has weird quirks. One of these is that it requests information before actually telling the GameDLL (mod) that it is loaded. It goes something like this:
 
 
 
#Engine loads the mod binary into memory.
 
#Engine asks mod binary for some classes.
 
#Engine asks mod for its name.
 
#Engine requests that the mod be loaded by giving it engine information.
 
 
 
As you can see, steps 2-4 are somewhat out of order. Therefore, when Metamod:Source is asked for the mod's name, it doesn't actually know it yet, as it is unable to have loaded the mod without engine information. So it passes the name "Metamod: Source" instead, and then changes the value in memory once the mod is actually loaded.
 
 
 
Unfortunately, srcds/HL2 might not catch this in time, or might not update its field, and the game name will appear as "Metamod: Source" in the server-side GUI. As the mod name doesn't change anywhere else, it is not really a problem.
 
  
 
=====Q: Is there a tutorial/example of how to write a Metamod:Source plugin?=====
 
=====Q: Is there a tutorial/example of how to write a Metamod:Source plugin?=====
Line 62: Line 45:
 
See [[SourceHook Development]].
 
See [[SourceHook Development]].
  
[[Category:Metamod:Source]]
+
[[Category:Metamod:Source Documentation]]

Latest revision as of 14:49, 22 January 2008

Frequently Asked Questions

Q: Does Metamod:Source support (some) mod?

Metamod:Source only requests the core public interfaces of Source, so it will run on all mods that work with the version of Half-Life 2 it was built for. However, this may not strictly be true depending upon which Metamod:Source API functions a plugin uses. See the supported games list for more details.

Q: How do I install Metamod:Source?

Please look in the Installation section of the documentation.

Q: Does Metamod: Source Create Lag?

No. Metamod:Source is based off a library called SourceHook. Unlike the original Metamod for Half-Life 1, Metamod:Source only hooks functions when asked to by a plugin. It does not intercept every call by default, and does not require a complex routing table for unused hooks.

In non-technical terms? Metamod:Source is only there when you need it to be. The hooking method, although complicated, is very efficient and takes advantage of some of the odder features of C++.

And unlike the original Metamod, the binary is one tenth the size - the Half-Life 2 engine does not require a massive repository of linked entities to be exported in the same way Half-Life 1 did.

Q: Will Server Plugins run on Metamod: Source?

No. Metamod:Source plugins are separate. You can run them side by side, as long as the server plugins do not have any compatibility issues or private hooks that interfere.

Q: Is there a tutorial/example of how to write a Metamod:Source plugin?

Yes, look in the source code for "stub_mm" and "sample_mm", which contain examples of how to use the Metamod:Source API. You should be familiar with C++ and the Half-Life 2 SDK in order to proceed.

Q: If I create a Metamod:Source plugin, does it have to be open source?

No. Unlike the original Metamod, we decided to use the libpng/zLib license instead of the GPL. This is because Valve does not impose the same restrictions on Server Plugins. We'd like to keep the playing field level, as well as provide everyone with the same freedom and opportunities.

Q: Can you port this to another game engine?

Every game engine is different. Currently Metamods have been developed for three major game engines: The original Metamod for Half-Life 1 (by Will Day), Quake3 MultiMod (by CyberMind), and Metamod:Source (what you're reading about now). Each one needs to be carefully designed and built upon a specific set of rules, so a direct port is usually not possible. However, Metamod:Source is built upon a library called SourceHook. SourceHook provides a fast, efficient, and simple way to create virtual hooks. Any game that uses a modern virtual interface design for engine calls can take advantage of SourceHook.

Q: How does it work? Like Metamod-P?

No. Metamod-P is a highly optimized version of Metamod for Half-Life 1 created by Jussi Kivilinna. By using dynamic link patching, it is able to resolve entity export differences between the Engine and GameDLL - this means it does not require updates for mods like the original Metamod. It also has other related optimization techniques.

Metamod: Source is different because it uses virtual function hooking - which means individual functions in classes can be dynamically altered. Half-Life 1's engine functions were passed as a list of pointers in a struct, which requires an entirely different method of interception (that is, a wrapper set of functions that act as a router to the plugins). You can think of the design in this way:

Metamod: The Engine gives the GameDLL its set of functions, and the GameDLL gives the Engine its set of functions. Metamod sits in between and actually exchanges false versions, which have new functions that allow you to decide whether to override the original calls. Metamod: Source: You can take any virtual function of a known class and declare a hook on it. The hook is applied by patching memory directly, at runtime. The only interception that occurs between the GameDLL and Engine is the factories which provide class retrieval.

Q: What's the difference between SourceMM and Metamod:Source?

We no longer use the name "SourceMM." It was getting too confused with "SourceMod," another AlliedModders project.

Q: Where can I find more about SourceHook?

See SourceHook Development.