Author Topic: The Newbie's Guide to Tremulous Development  (Read 20530 times)

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
The Newbie's Guide to Tremulous Development
« on: August 29, 2008, 01:46:10 pm »
I thought I'd write a guide for people who want to get started developing Tremulous and first need to be shown around a little. It would have been helpful to me, perhaps it'll be helpful to someone else. Contributions are welcome.

Note: This guide is for recent SVN. Some experience with software development and the programming language C is also useful.

Prerequisites
The first thing you need is a development environment, Subversion, and, of course, some source code.

[Instructions for Mac users]
[Instructions for Windows users]

(Note to Linux users: Most distros come with the relevant developer tools; if you don't have them installed, utilize your friendly neighborhood package manager. You will need to manually install Subversion from here.)

The source directory
The directory with your source code should look something like this:

Code: [Select]
CC
ChangeLog
configs/
COPYING
cross-make-mingw.sh
GPL
make-macosx-ub.sh
Makefile
misc/
src/
ui/
CC, COPYING, GPL: Licensing information. Not useful to newbies.
ChangeLog: A history of Tremulous's evolution from version to version. Again, not useful to newbies.
configs/: Config files required by QVMs and clients built from recent SVN.
cross-make-mingw.sh: A shell script for Mac and Linux users. It builds Windows binaries in addition to the usual ones. (Note: Requires MinGW.)
make-macosx-ub.sh: A shell script for Mac users. This builds the application bundle and a number of binaries.
Makefile: The file that tells the compiler what to compile and where to put the result(s). Don't fiddle around with this unless you know what you're doing.
misc/: Miscellaneous stuff, including the source files for the miniprograms that actually do the QVM compiling. Again, not to be diddled with.
src/: The real meat of the Tremulous code. Juicy! (But not very easy to figure out.)
ui/: Files related to Tremulous's user interface.

The source code
src/ contains a truckload of source files. cgame/, game/, and ui/ are relevant to their respective QVMs (cgame.qvm, game.qvm, and ui.qvm). I recommend starting with game/, since almost anyone can write a decent game.qvm.

Backporting
Of course, most of the Tremulous world is still using old code, which is not very compatible with the current code. This is where backporting comes into play. It's what it sounds like: Porting in a backwards direction.

So how do you backport, exactly? Well, the recommend way is to use a premade patch (such as this one by Avenger; it works like a charm). Which brings us to...

Patching
Patches, put simply, contain the differences between two versions of source code. To patch Tremulous source code, cd to your source directory and then run patch -p0 < PATCHFILE (substituting PATCHFILE for the name of the patch).

So, to backport with Avenger's patch:
1] Download the patch and drop it into your source directory.
2] cd there.
3] patch -p0 < compat.patch
4] Your code should now be backported.

You can also make your own patches. Run svn diff > patchname.patch and it should generate one for you.

Mercenaries Guild currently hosts a patch repository. You can browse it here.

Compiling
Drumroll...

If your development environment works properly, you're ready to compile! Just run make and you should end up with a directory called build/, containing a subdirectory, containing some build products and a lot of files with extensions like .d and .o. Browse around a bit and you'll see some binaries (.x86, .ppc, or .exe) and some QVMs. (Note: Avenger's patch seems to disable all QVMs except game.qvm).

Using the shell scripts
To use the shell scripts for more advanced compilation:
1] cd to your source directory.
2] ./cross-make-mingw.sh or ./make-macosx-ub.sh
Note to Mac users: For maximum compatibility, install all the SDKs that came with your version of Xcode.

Customizing the build process (This section thanks to Amanieu, benmachine, and David.)
Often, you'll want to have the compiler only build a certain item. This is done be creating a text file, Makefile.local, in your source directory.

Code: (Example Makefile.local) [Select]
BUILD_STANDALONE = 0
BUILD_CLIENT = 0
BUILD_CLIENT_SMP = 0
BUILD_SERVER = 0
BUILD_GAME_SO = 0
BUILD_GAME_QVM = 1
This would configure the build process so only QVMs are compiled. Note: BUILD_CLIENT_SMP (Symmetric MultiProcessing) only has an effect on Mac OS X.

Code: (Advanced flags) [Select]
BUILD_MASTER_SERVER = 0
USE_OPENAL_DLOPEN = 0 # 1 on windows.
USE_CURL = 1
USE_CURL_DLOPEN = 1 # 0 on windows.
USE_CODEC_VORBIS = 0
USE_MUMBLE = 1
USE_VOIP = 1
USE_INTERNAL_SPEEX = 1
USE_LOCAL_HEADERS = 1  # SDL related?

You can also add parameters to make.
release — The default.
debug — Creates debug builds instead of release builds. This makes debugging with gdb easier.
clean — Removes all build products.
toolsclean — Removes the mini-compilers that are used to build QVMs. You'll only need to do this if you've been messing around with src/tools.
distclean — Does clean, then toolsclean, then deletes build/.
dist — Bundles up your source in a .tar.bz2 archive. Doesn't compile anything.

Where to go from here
Take a look at the source, learn by example. There's plenty of information to be had if you take the time to read through it.
« Last Edit: May 13, 2014, 06:09:01 am by Undeference »

David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: The Newbie's Guide to Tremulous Development
« Reply #1 on: August 29, 2008, 02:26:05 pm »
Where'd the original version of this go?
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #2 on: August 29, 2008, 02:31:54 pm »
I (Bomb) removed it. This is just to make things tidy.

Hendrich

  • Posts: 898
  • Turrets: +168/-149
    • TremCommands
Re: The Newbie's Guide to Tremulous Development
« Reply #3 on: August 31, 2008, 01:25:12 am »
Nice guide Bomb, I would love to see it evolve. :D

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #4 on: August 31, 2008, 01:28:22 am »
Well, if anyone wants to contribute, be my guest...

SlackerLinux

  • Spam Killer
  • *
  • Posts: 555
  • Turrets: +41/-62
Re: The Newbie's Guide to Tremulous Development
« Reply #5 on: August 31, 2008, 02:17:42 am »
adding a link to merceneries guild would probably be a good idea. there the central spot for tremulous patches
Slackware64 13.1
SlackersQVM/

Amanieu

  • Posts: 647
  • Turrets: +135/-83
    • Amanieu
Re: The Newbie's Guide to Tremulous Development
« Reply #6 on: August 31, 2008, 07:55:14 am »
You should just mention svn diff for making patches.
Quote
< kevlarman> zakk is getting his patches from shady frenchmen on irc
< kevlarman> this can't be a good sign :P

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #7 on: August 31, 2008, 02:49:39 pm »
@SlackerLinux: Done.

@Amanieu: It's mentioned in Patching.

Snake

  • Posts: 541
  • Turrets: +43/-110
    • IdeaShock
Re: The Newbie's Guide to Tremulous Development
« Reply #8 on: August 31, 2008, 09:04:39 pm »
Well Syntac(Bomb), you made it, one of my first +1, you have a really well formed guide, i hope you will kep updating it, i remmeber these old times when i messed up with the admin.c and tremulous.h, so funny :P
.

tsurano

  • Posts: 30
  • Turrets: +1/-5
Re: The Newbie's Guide to Tremulous Development
« Reply #9 on: September 19, 2008, 10:26:46 pm »
I think this should be stickied so it doesn't get lost

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #10 on: September 19, 2008, 10:41:05 pm »
Shh! That makes the moderators laugh.

fingered banana

  • Guest
Re: The Newbie's Guide to Tremulous Development
« Reply #11 on: September 20, 2008, 12:41:47 am »
newbie's developing trem? Very funny title

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #12 on: September 20, 2008, 12:55:39 am »
Apparently, you didn't read it properly.

Quote from: Thread title
The Newbie's Guide to Tremulous Development
In other words, a guide to Tremulous development. Aimed at newbies. In the hope that they will no longer be newbies after reading it.

Stealthawk

  • Posts: 15
  • Turrets: +1/-0
Re: The Newbie's Guide to Tremulous Development
« Reply #13 on: October 09, 2008, 01:51:47 am »
I don't mean to seem abit naive, but is there going to be a linux verison of this guide? Im pretty good at x86 assembly and C, and C++ isnt hard to pick up, but im used to using windows developer tools. How do you compile Trem in linux?

Found my own answer in this post.
http://tremulous.net/forum/index.php?topic=8666.0
« Last Edit: October 09, 2008, 01:56:44 am by Stealthawk »

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #14 on: October 09, 2008, 01:58:52 am »
Everything in the guide applies to Linux as well. If you're having trouble with Subversion, your distro might have a package for it. For example:

Code: [Select]
sudo apt-get install subversion
...probably.

Note: You'll need to substitute your distro's package manager for apt-get, of course.
« Last Edit: October 09, 2008, 02:01:40 am by Syntac »

Stealthawk

  • Posts: 15
  • Turrets: +1/-0
Re: The Newbie's Guide to Tremulous Development
« Reply #15 on: October 09, 2008, 02:14:19 am »
i'm getting a bunch of compile errors like the code is wrong, is there any setting in the make file i need to change or get a more up to date GCC?

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #16 on: October 09, 2008, 02:37:19 am »
If you haven't touched Makefile before, don't. I do recommend updating gcc, though.

Stealthawk

  • Posts: 15
  • Turrets: +1/-0
Re: The Newbie's Guide to Tremulous Development
« Reply #17 on: October 09, 2008, 02:50:43 am »
Ok got the latests version. Thanks for helping me so far, now i got more issues =(

make[2]: Entering directory `/home/stephan/tremulous-svn'
DED_CC src/server/sv_client.c
make[2]: i586-mingw32msvc-gcc: Command not found
make[2]: *** [build/release-mingw32-x86/ded/sv_client.o] Error 127
make[2]: Leaving directory `/home/stephan/tremulous-svn'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/home/stephan/tremulous-svn'
make: *** [release] Error 2

as far as GCC I have this.
gcc version 4.3.2 (Ubuntu 4.3.2-1ubuntu9)



Amanieu

  • Posts: 647
  • Turrets: +135/-83
    • Amanieu
Re: The Newbie's Guide to Tremulous Development
« Reply #18 on: October 09, 2008, 02:53:13 am »
Don't use cross-make-mingw.sh, just exec "make"
Quote
< kevlarman> zakk is getting his patches from shady frenchmen on irc
< kevlarman> this can't be a good sign :P

Stealthawk

  • Posts: 15
  • Turrets: +1/-0
Re: The Newbie's Guide to Tremulous Development
« Reply #19 on: October 09, 2008, 02:54:54 am »
Don't use cross-make-mingw.sh, just exec "make"

Yeah I just figured that out lol.

You rock man, thanks a bunch id give u good karma but it isnt letting me =)

Drakotsu

  • Posts: 110
  • Turrets: +2/-1
Re: The Newbie's Guide to Tremulous Development
« Reply #20 on: October 28, 2008, 12:39:02 am »
When I CD to tremulous,
and use this command:
patch -p0 < compat.patch

It replies:
'patch' is not recognizable as an internal or external command, operable program or batch file.
(that happends on windows command prompt)

This happends on Mysys:
cd tremulous
patch -p0 < compat.patch

Reply:
No such file or directory.

Help? xP

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #21 on: October 28, 2008, 12:51:18 am »
*sigh*

Does compat.patch actually exist?

Drakotsu

  • Posts: 110
  • Turrets: +2/-1
Re: The Newbie's Guide to Tremulous Development
« Reply #22 on: October 28, 2008, 12:52:05 am »
yes it does exist,
I downloaded avengers backport patch, and put it in the source directory, just like the guide said.

windows command promt isnt recognizing patch as a command and mysys is saying that the file or path was not found or does not exist (when i try to patch -p0 < compat.patch
« Last Edit: October 28, 2008, 01:21:31 am by Drakotsu »

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #23 on: October 28, 2008, 01:53:37 am »
Code: [Select]
cd path/to/source/directory
ls compat.patch
If it finds anything, I don't know what your problem is.

Drakotsu

  • Posts: 110
  • Turrets: +2/-1
Re: The Newbie's Guide to Tremulous Development
« Reply #24 on: October 28, 2008, 04:09:05 am »
Well now im getting this error when compiling..

make[2]: Entering directory `/home/stephan/tremulous-svn'
DED_CC src/server/sv_client.c
make[2]: i586-mingw32msvc-gcc: Command not found
make[2]: *** [build/release-mingw32-x86/ded/sv_client.o] Error 127
make[2]: Leaving directory `/home/stephan/tremulous-svn'
make[1]: *** [targets] Error 2
make[1]: Leaving directory `/home/stephan/tremulous-svn'
make: *** [release] Error 2

Im on windows xppro sp3.

And im pretty sure i used just 'make'
« Last Edit: October 28, 2008, 04:25:19 am by Drakotsu »

UniqPhoeniX

  • Spam Killer
  • *
  • Posts: 1376
  • Turrets: +66/-32
Re: The Newbie's Guide to Tremulous Development
« Reply #25 on: October 28, 2008, 05:02:40 am »
yes it does exist,
I downloaded avengers backport patch, and put it in the source directory, just like the guide said.

windows command promt isnt recognizing patch as a command and mysys is saying that the file or path was not found or does not exist (when i try to patch -p0 < compat.patch
Try restarting, I had same problem and restart fixed it.

Drakotsu

  • Posts: 110
  • Turrets: +2/-1
Re: The Newbie's Guide to Tremulous Development
« Reply #26 on: October 28, 2008, 05:18:15 am »
Hm..another error, one right after another.
With mysys when i do this..

cd tremulous
patch -p0 < svn_950_to_tjw_s_tremded.patch

it sais..

"cant find file to patch at input line 5. Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
Index: src/game/bg_public.h
--- src/game/bg_public.h (revision 954)
+++ src/game/bg_public.h (working copy)"

Please help..=[
« Last Edit: October 28, 2008, 06:23:13 am by Drakotsu »

Thomsen

  • Posts: 55
  • Turrets: +7/-1
Re: The Newbie's Guide to Tremulous Development
« Reply #27 on: October 28, 2008, 04:37:05 pm »
make sure you are in the trunk, so that's one above the src/ (go up with "Cd ..")

Syntac

  • Posts: 841
  • Turrets: +118/-104
    • Syntac's Stuff
Re: The Newbie's Guide to Tremulous Development
« Reply #28 on: October 28, 2008, 08:22:54 pm »
Drakotsu: You couldn't have just used make if it was throwing an "unknown command" error. Type "make" and hit return. That's all you have to do. Don't use the shell script.

Drakotsu

  • Posts: 110
  • Turrets: +2/-1
Re: The Newbie's Guide to Tremulous Development
« Reply #29 on: October 28, 2008, 09:56:29 pm »
Read plz syntac.
I said that windows console was throwing unknown cmd.

When i used mysys it gave me that error..and im not using shell commands..
The error in mysys is

"cant find file to patch at input line 5. Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
Index: src/game/bg_public.h
--- src/game/bg_public.h (revision 954)
+++ src/game/bg_public.h (working copy)"