View Full Version : C++ Plugins
I'm just curious as to how you're planning on implementing the ability to make plugins using C++.
I'm already guessing they will compiled into a DLL or SO or some similar form in the end. And I'm assuming SourceMod will be modular as AMXX is to an extent with the different modules (core, engine, fun, regex, array, etc). And I'm sure many of the functions of AMXX will probably make their way to SourceMod. Obviously we can't be 100% sure as we don't have the SDK yet. But I think it's a pretty safe bet a lot of the stuff we can do with HL1 server side mods could be done with Source server side mods. So I'm guessing you may be planning similar modules.
But are C++ plugins going to importing functions from these [assumed] modules like a Windows application might use some functions from a DLL? Will the modules be exporting these functions like a DLL does? (I'm assuming these modules will compiled as DLL/SO)
...Or will these C++ plugins be more like modules in that they would use functions directly from the supposed source version of metamod?
Maybe my real question is more of how MetaEng is going to be working... As I believe you mentioned that it was responsible for allowing different languages to be used for scripting plugins. And I know you mentioned wrappers for the different languages as well, but I guess I'm still not quite grasping how all this is going to work.
I can understand if you don't to say much about MetaEng at this point. But I was just curious as I'm looking forward to coding plugins in C++ instead of Small.
BAILOPAN
10-17-2004, 15:33
MetaEng works by attaching interfaces to a central API. This API has functions like "LoadPlugin" and "ForwardCall", trivial things that are necessary for basic scripting functionality.
For example, the C++ "scripting engine" loads a plugin with LoadLibrary/dlopen. It hooks a call with GetProcAddress/dlsym. It gets function natives through a metaeng utility pointer.
You will see once I get a basic MetaEng structure in CVS, it's quite simple. The only complex part are the scripting engines, which themselves can get quite complicated.
One of the big obstacles I just solved was variadic calling (i.e. the opposite of va_arg, pushing variable numbers of arbitrary parameters). So you'll see that making C/C++ plugins will actually be quite simple (there will be a nice little SDK).
MetaEng has a central repository for a big function map, which includes native and forwarded functions (technically these are the same thing). Because of this, there is no distinction between modules and plugins. But I'll try to separate things for organization...
it's pretty complicated, I'm hoping it will work :)
Kamikizzle
10-24-2004, 13:34
hehe, sounds awesome! i can actually half-way script in C++....so maybe i'll finally be able to create plugins....;)
imported_malex
10-24-2004, 23:01
Now we just have to convince Bailopan to include perl support in the stock SourceMod distribution and we'll be all set. We also need SOAP or XMLRPC support in the stock distribution also, to have the plugins run on other machines. That would be pretty cool.
\malex\
bah who uses perl =P J/K
C++ scripting is going to be sooooo sooo nice
XxAvalanchexX
10-26-2004, 23:18
I dunno, I kinda prefer SmallC to C++ for the simplicity.
Pearl is mainly used for stutus, its one command, and an a simple output.
I really dont see how this could be used for plugin scripting.
imported_malex
10-26-2004, 23:40
Do you mean Small, the language used in AMX Mod X, AMXMod and Admin Mod? Small has no dynamically allocated variables, no structs, no pointers, and it smells funny. Adding something like perl would fix all those, and bring in a large existing base of modules for things like DB access and funky math functions and many other usefuls.
\malex\
No I ment Pearl. I have only seen Pearl used for status scrips.
BAILOPAN
10-27-2004, 00:03
Perl is a very dynamic and powerful language.
Alas I don't know if I want to use it.
imported_malex
10-27-2004, 02:17
Sorry Dygear, I meant Avalanche, he mentioned SmallC.
As for perl, it can do just about anything you want. There are loads of software written in perl that's much more complex than most AMX Mod X plugins. Perl's beauty is in that it can be used for both the small oneliners (which in perl could rival many software packages for complexity) and large complex programs. Take a look at http://search.cpan.org for some of the available extensions. Of course I haven't mentioned yet the Number One reason to use perl, perl regular expressions.
\malex\
I would rather like to see Java or C# as a scripting language though my personal preference is C++. The reason is that plugin written in C++ would require much more thorough testing because of memory management and other issues inherent to C++. On other hand I'm not sure that building JVM or CLR into SourceMod would be sensible idea, especially considering bi-platform nature of the project...
By the way, Active Scripting support under Windows can be implemented fairly quickly and can provide easy support for lots of languages which has AS scripting host such as VBScript, JScript, PerlScript, PythonScript and so on. Obviously such approach would break the community into two pieces so it must be bad idea after all...
devicenull
10-27-2004, 17:50
I would rather like to see Java or C# as a scripting language though my personal preference is C++. The reason is that plugin written in C++ would require much more thorough testing because of memory management and other issues inherent to C++. On other hand I'm not sure that building JVM or CLR into SourceMod would be sensible idea, especially considering bi-platform nature of the project...
By the way, Active Scripting support under Windows can be implemented fairly quickly and can provide easy support for lots of languages which has AS scripting host such as VBScript, JScript, PerlScript, PythonScript and so on. Obviously such approach would break the community into two pieces so it must be bad idea after all...
The problem with active scripting is its windows-specific. And it doesn't have small support :(
imported_malex
10-27-2004, 20:07
SourceMod will have an API that anyone can write a frontend for. You wouldn't be limited to whatever frontend it comes with, but could instead write one in ASP or Java or C# or some other backwards language.
\malex\
XxAvalanchexX
10-28-2004, 00:12
Do you mean Small, the language used in AMX Mod X, AMXMod and Admin Mod?
No, I mean SmallC, the language used in AMX Mod X, AMXMod and Admin Mod.
BAILOPAN
10-28-2004, 00:57
It's not called SmallC, I don't know where people get that from.
It's called Small.
It's not called SmallC, I don't know where people get that from.
It's called Small.
Just to keep things simple, quote from "The Small Booklet":
Small is a descendent of the original Small C by Ron Cain and James Hendrix, which at its turn was a subset of C. Some of the modifcations that I did to Small C, e.g. the removal of the type system and the substitution of pointers by references, were so fundamental that I could hardly call my language a "subset of C" or a "C dialect" anymore. Therefore, I stripped of the "C" from the title and kept the name "Small".
Johnny got his gun
11-14-2004, 16:50
No C#, it is icky for this line of scripting/coding.
I'm glad that we can code in c++ now, i'm trying to learn c++ as i'm going to college next year to start on a Masters/Bachelors in Computer Science, and a bunch of my classes are on programming/c++. I've got a book, anyone got any good sites?
Downtown1
11-16-2004, 21:08
So BAIL, are we still going with your own custom PHP version or are you just gonna embed Python ;)?
BAILOPAN
11-17-2004, 07:56
most likely javascript
vBulletin® v3.8.7, Copyright ©2000-2023, vBulletin Solutions, Inc.