Difference between revisions of "Installing New Modules"

From ASSS Wiki
Jump to: navigation, search
m (removed my name)
m (added titles for compilng on windows, i don't know how someone else can write it)
Line 67: Line 67:
 
</pre>
 
</pre>
 
The ''-f'' switch tells make to use ''some.mk'' instead of the default which is 'Makefile'. Also two commands are used so you can spot any errors during compilation.
 
The ''-f'' switch tells make to use ''some.mk'' instead of the default which is 'Makefile'. Also two commands are used so you can spot any errors during compilation.
 +
 +
=== With Dev C++ ===
 +
-write me-
 +
 +
=== With MSVC ===
 +
-write me-
  
 
=== By hand ===
 
=== By hand ===
You may need to execute the commands to compile from source, and then move the resulting .so file to the bin directory using install.
+
You may need to execute the commands to compile from source, and then move the resulting .so file to the bin directory using install if running ASSS on Linux. If you are running ASSS on Windows and are updating a module you should shutdown the server before copying the .dll file to the bin directory.
  
 
== Python modules ==
 
== Python modules ==

Revision as of 07:34, 17 January 2005

When you want to add more functionality to your server you can install new custom modules. Differences in server versions often mean something will break in a module, compiling from source can help fix this.

C modules

Using the ASSS Makefile

The Makefile distributed with ASSS is designed to allow adding new code to it easily. This is probably the easiest way to get a new module compiling, because all the correct compiler flags are supplied for you.

Create a directory for your module as a subdirectory of src, the directory containing all the ASSS code.

$ cd asss-1.3.5/src
$ mkdir mymod

Create a mymod.mk file within that directory that looks like this:

mymod/mymod.$(SO): mymod/mymod.o

All *.mk files (let's call them "Makefile fragments") in any subdirectories will be included by the big Makefile automatically. Two fragments come in the contrib directory in the ASSS package, which you might want to look at as examples.

Note that we use a Makefile variable, $(SO), instead of typing .so directly. That's so that the same Makefile works on windows, where modules have to be named mymod.dll instead of mymod.so. Also note that all the filenames have to be prefixed with the directory they're in. That's because make considers all files relative to the directory it runs in.

Now compile your module and copy it into your bin directory:

$ make mymod/mymod.so
... compiler output ...
$ install mymod/mymod.so ../bin

Note that you have to specify the target name manually; it won't get built or copy by default if you just type make. If you do want your custom module to get built and copied automatically, along with the rest of ASSS, when you type just make, add this line at the top of the Makefile fragment:

ALL_STUFF += mymod/mymod.$(SO)

Also note that you can list more than one .o file on the line. All will be compiled into the same shared library.

The module specifier for this new module will be mymod:mymod, for use in modules.conf or with ?insmod.

Using a custom Makefile

Sometimes you might want to create your own Makefile, if you need to use custom compilation options, or a different source file layout. Here is a very basic one (they can get very long).

# simple makefile

OUTFILE = somefile.so
MODULES = autoturret.o

CC = gcc -std=gnu99 -pipe
CFLAGS = -s -O2 -Wall

all: ${OUTFILE}

${OUTFILE}: ${MODULES}
	${CC} -fPIC -shared -o ${OUTFILE} ${MODULES}

install: ${OUTFILE}
	install ${OUTFILE} ../bin/${OUTFILE}

clean:
	rm -f ${OUTFILE} ${MODULES}

You can change the name of the resulting file with OUTFILE and add more modules on the MODULES line. Note: the indentation must be a tab and not a bunch of spaces.

To use a makefile one would type something like this:

$ make -f some.mk
$ make -f some.mk install

The -f switch tells make to use some.mk instead of the default which is 'Makefile'. Also two commands are used so you can spot any errors during compilation.

With Dev C++

-write me-

With MSVC

-write me-

By hand

You may need to execute the commands to compile from source, and then move the resulting .so file to the bin directory using install if running ASSS on Linux. If you are running ASSS on Windows and are updating a module you should shutdown the server before copying the .dll file to the bin directory.

Python modules

No compiling is necessary. Move the .py file to the bin directory. There may be 'softcoded' settings within the .py file, so examine any comments near the top of the file for instructions.

Configuring

It is a good idea to examine any documents that came with the module. There may be comments at the top of the source code and if you are unsure you can do a search on the file for 'cfg->Get', which will return all customisable settings this module reads.

$ grep 'cfg->Get' src/module.c
$ grep 'cfg.Get' bin/module.py

I suggest putting module settings in their own .conf file and include this from your arena.conf.

There may also be commands that you must set the permissions for. You can add new commands to the group files found in conf/groupdef.dir. Prefix cmd_ to the command to allow users to send the command publicly and privcmd_ for team and private targets.

Finally you must load the module. Either add an entry to conf/modules.conf or use ?insmod. Some modules are arena specific, in which case you must also add it to your arena.conf Modules:AttahModules setting or use ?attmod.

If you have any questions left chances are they have already been answered at the Module FAQ.