PlanetQuake | Code3Arena | Articles | << Prev | Article 11 | Next >>


  • Home/News
  • ModSource
  • Compiling
  • Help!!!
  • Submission
  • Contributors
  • Staff
  • Downloads

    < Index >
    1. Mod making 101
    2. Up 'n running
    3. Hello, QWorld!
    4. Infinite Haste
    5. Armor Piercing Rails
    6. Bouncing Rockets
    7. Cloaking
    8. Ladders
    9. Favourite Server
    10. Flame Thrower
    11. Vortex Grenades
    12. Grapple
    13. Lightning Discharge
    14. Locational Damage
    15. Leg Shots
    16. Weapon Switching
    17. Scoreboard frag-rate
    18. Vortex Grenades II
    19. Vulnerable Missiles
    20. Creating Classes
    21. Scrolling Credits
    22. Weapon Dropping
    23. Anti-Gravity Boots
    24. HUD scoreboard
    25. Flashlight and laser
    26. Weapon Positioning
    27. Weapon Reloading
    28. Progressive Zooming
    29. Rotating Doors
    30. Beheading (headshot!)
    31. Alt Weapon Fire
    32. Popup Menus I
    33. Popup Menus II
    34. Cluster Grenades
    35. Homing Rockets
    36. Spreadfire Powerup
    37. Instagib gameplay
    38. Accelerating rockets
    39. Server only Instagib
    40. Advanced Grapple Hook
    41. Unlagging your mod

    < Index >
    1. Entities
    2. Vectors
    3. Good Coding
    4. Compilers I
    5. Compilers II
    6. UI Menu Primer I
    7. UI Menu Primer II
    8. UI Menu Primer III
    9. QVM Communication, Cvars, commands
    10. Metrowerks CodeWarrior
    11. 1.27g code, bugs, batch


  • Quake3 Files
  • Quake3 Forums
  • Q3A Editing Message Board
  • Quake3 Editing


  • SumFuka
  • Calrathan
  • HypoThermia
  • WarZone

    Site Design by:
    ICEmosis Design

    ARTICLE 11 - 1.27g code, bugs, and batch files
    by HypoThermia

    With the 1.27g source code release now out for a while, I thought it best to try and collect known problems and issues together into one place. I've been searching the boards, reading the code, and receiving e-mails about this. Hopefully we can get you all up and running, fix your problems, and a few of the source code errors that slipped through testing.

    The ground we're going to cover varies from batch files that work, known bugs in the source code, including things that you can and can't fix. Some of this is a re-hash of the stuff I included in my porting tools download documentation.

    This is an ongoing article, and I'll expand it as I get more information. I'll also give credit where credit is due (I don't find all these problems!), so send in all the problems that you think will be relevant.


    1. Compiling

    Well you've got a new toy to play with, but it just doesn't quite do what you'd expect. These solutions should get you compiling and building the source code.

    There are a large number of warnings generated when this code is compiled, there's little you can do to avoid this. The untouched original code doesn't appear to have any problems because of this, but as always, you should be more careful when the warnings are introduced through your own modification.


    1.1 Batch files that work

    One of the most common problems is getting the compiling process started. There are some batch files for download that work for MSVC. Simon Hopwood sent them to me, and together we thrashed out a release that gets you up and running.

    There are several things that need sorting. DOS doesn't like two equals ('=') signs on a line when setting a variable, so the lcc command line has been moved out to a separate batch file. When compiling the Team Arena version of the source, CGAME needs to be defined when building the client. Thirdly, the LCC tools are missing from the 1.27 release, so they need to be added back in.

    There are now two user interface directories, ui contains the code for the new scripted user interface, while q3_ui is the old, familiar, Q3 interface. We must be careful to compile the source code from the correct directory, with the correct set of include paths.

    You can download the batch files and missing LCC tools by following this link. The LCC tools have been taken from the 1.17 source code release.

    Just follow the simple installation instructions and go from there. If you have 'Out of environment space' errors then take a look at the solution on the compilers page.


    1.2 Using the MSVC environment

    This report has come in from Darkmind (from an original post by i20) about compiling with MSVC. It appears that the environment provided compiles the game DLL for Team Arena, while the others are built for Q3.

    Symptoms include being unable to switch weapons using commands (only autoswitch works), and an "out of ammo" message.

    1. Make sure the active project is "game";
    2. Go in the project settings dialogue;
    3. in the C/C++ tab, look at the preprocesor definition, and make sure you remove MISSIONPACK if you are compiling for Q3A.

    Another way to fix this problem (by considering this as a project problem) is provided below.



    1.3 Using the MSVC environment II

    While the solution by Darkmind/i20 points out the problem that the MISSIONPACK define causes, there is another way to fix things in the MSVC environment. This from Stefan:

    If you're compiling for the original quake3:

    1. In MSVC, go to menu 'build' -> 'set active configuration'
    2. Choose 'cgame - Win32 Debug' and click ok.
    3. Now do your project settings. Press alt+F7, click cgame, open tab 'Link', and change the path .../Debug/cgamex86.dll to .../cgamex86.dll
    4. Now repeat for game, and q3ui, removing the reference to the /Debug dir.


    2. Getting started, general awareness

    There are a few things that you need to be aware of before diving in. They're not difficult, nor are they bugs.

    You'll find some more specific comments about source files in my source code porting tools.


    2.1 CDKEY issues

    If you provide your own user interface, you'll probably find it asking for the CD key the first time you run it. By default the UI requests a new CD key if it can't find one in the mod dir, but you should almost certainly change it so that the CDKEY in baseq3 is used instead.

    Find and change this line of code in the vmMain() function in ui_main.c:

    case UI_HASUNIQUECDKEY:  // mod authors need to observe this
    	return qfalse;


    2.2 Coding style causes VM crash

    One major problem appears to have surfaced in the VM to native code newly optimized routines. If you use fallthrough in switch case statements then your code may crash.

    The problem is very specific to the following coding style:

    1. Case statement,
    2. Some code,
    3. Fallthrough to the next case statement, no break statement used at all,
    4. Case statement

    The bug doesn't occur when step 3 is eliminated, and the code in (2) is terminated by a break.

    You'll know you're getting this error if you see the following message in your console after a crash (return to the UI):

    *** opStack corrupted in compiled code ***

    The following is an example of code that causes the problem (from my own coding work):

    static void PlayerInfo_SetAnimation( modelAnim_t* m)
    	m->playerChat = qfalse;
    	switch( m->anim ) {
    	case ANIM_CHAT:
    		m->playerChat = qtrue;
    		// fallthrough;
    	case ANIM_IDLE:
    		m->playerLegs	= LEGS_IDLE;
    		m->playerTorso	= TORSO_STAND;
    		m->playerWeapon	= -1;
    	case ANIM_RUN:
    		m->playerLegs = LEGS_RUN;

    Simply eliminating the fallthrough to the next case statement (by duplicating the code and adding a break) will cure the problem.


    2.3 New game types, GT_* flags

    With the inclusion of new game types in Team Arena, there are quite a few new GT_* flags available. They're used in too many places to "rip out" with a MISSIONPACK define. You'll also have to be careful if you've used GT_MAX_GAME_TYPE anywhere, the value has increased even if you just compile for standard Quake3.

    Also, there are numerous assumptions about single player versus team games. Make sure you've used (gametype >= GT_TEAM) to detect a team game, and the opposite gametype < GT_TEAM for one player gametypes.

    You may want to include this define in bg_public.h and use MAX_GAME_TYPE instead of GT_MAX_GAME_TYPE:

    #ifdef MISSIONPACK
    #define MAX_GAME_TYPE (GT_CTF + 1)

    Mod authors that have provided additional gametypes will have to be especially careful when making changes around this code.



    3. Known problems that can be fixed

    You're going to have to roll up your sleeves and dig into the source code for this. The collection of problems here can be fixed quite easily by reaching into the code and tweaking a few lines.


    3.1 CyberKewl bug fixes

    This first group have been collected by CyberKewl (a.k.a. Malcolm Lim), and he's provided the source code changes needed to fix them too. If you download and use this code, don't forget to credit him in your mod.

    Download here, includes recompiled QVM


    3.1.1 Voice Chat files not present in Q3A

    Status: Non-fatal, but fixes annoying messages

    Adds MISSIONPACK defines to the bot voice taunt code in ai_chat.c.

    Also removes the use of vtell and vchat commands in g_cmds.c, though I think this should be extended to vtchat as well.


    3.1.2 Path to medals

    Status: NDA released source code, fixed in official release

    This was a problem with the source code that was released to developers under the NDA agreement. The new medals for CTF play didn't have their shaders included, so the reference that loads them in cg_main.c can't find them.

    It was fixed in the final release by providing the required shaders and missing graphic.


    3.1.3 Head model not showing

    Status: Non-fatal, but fixes loss of head!

    When the player changes the headmodel, this isn't correctly loaded. An empty gap is left in the HUD once the model has been fully loaded into memory.

    This is a straight forward one line fix in CG_DrawHead() in cg_draw.c.


    3.1.4 Cvars incorrectly named

    Status: Non-fatal, but saves useful data

    The Cvar used to save the status of friendly fire in the single/multi- player map browser is now correctly spelled. A long standing typo.

    The code is in ServerOptions_Start() in ui_startserver.c, renaming to the correct strings: ui_team_friendly and ui_ctf_friendly.


    3.2 UI looping sound behaviour (VM only)

    Status: Non-fatal, allows looped sound to play properly

    The values used to map two trap system calls have been swapped in ui_syscalls.asm. This only affects VM builds.

    The CORRECT values should look like this:

    equ trap_S_StopBackgroundTrack -63
    equ trap_S_StartBackgroundTrack -64

    Thanks to Mr Elusive (and Arnout 'RR2DO2', Q3F/HH3), for posting this on the NDA board.


    3.3 Item disabling breaks powerups

    Status: Possibly fatal for DLL's, breaks respawn chains for VM

    One feature of maps is the ability to place more than one item at a given spawn point, and then chain them together so only one can possibly be seen at a time. Using the new disable_item_* values will break this chain when a disabled item attempts to spawn for the first time.

    In addition: disabling a powerup (quad, regen, etc) with DLL builds will result in a crash when the disabled item attempts to spawn.

    The previous method of modifying G_FindTeams() succeeded in breaking the opening and closing of doubled doors (as in q3ctf1). This happens because there can be entities on the map that are chained together, but don't correspond to items that are spawned.

    If you've applied the previous "fix", please return the function G_FindTeams() to its previous state.

    This fixed fix prevents disabled items from being created as entities.

    Move the function G_ItemDisabled() from g_items.c to g_spawn.c, and place it just before G_CallSpawn(). Add a check to G_CallSpawn() to prevent the item from spawning if its disabled:

    Finds the spawn function for the entity and calls it,
    returning qfalse if not found
    qboolean G_CallSpawn( gentity_t *ent ) {
    	spawn_t	*s;
    	gitem_t	*item;
    	if ( !ent->classname ) {
    		G_Printf ("G_CallSpawn: NULL classname\n");
    		return qfalse;
    	// check item spawn functions
    	for ( item=bg_itemlist+1 ; item->classname ; item++ ) {
    		if ( !strcmp(item->classname, ent->classname) ) {
    			if ( G_ItemDisabled(item) )
    				return qfalse;
    			G_SpawnItem( ent, item );
    			return qtrue;

    Remove the reference to G_ItemDisabled(), as well as the premature return, from G_SpawnItem().

    Returning qfalse free's up the entity, essentially saying it didn't have a spawn function for handling creation. We're no longer in the awkward position of having a partially initialized entity in our lists. There's also the added bonus of allowing the /give command to use disabled items again.

    Thanks go to Cinergi for originally spotting this bug, and to Ark for pointing out the flaws in my original solution. You can read more at this thread in the Quake3World forum: BUG: disable_ code can cause server crash.


    3.4 Favourite servers are corrupted when one is deleted

    Status: Non-fatal, localized data corruption

    A long standing bug (documented in my Saving your favourite server tutorial), this only corrupts the array used to store the list of ip addresses for favourite servers.

    The fix isn't difficult, and can be found in the tutorial link above.

    Most people use an external server browser anyway...


    3.5 Bots don't use the gauntlet

    Steven Conway (mod homepage) has sent in a fix for the bots not using the gauntlet. They're using uninitialized data to check the distance, and think they're too far away to use it: even when they're right up close and personal!

    This goes into ai_dmq3.c in the function BotCheckAttack() around line 3592. The single line marked in red has been moved up from below the gauntlet hit check.

    VectorSubtract(bs->aimtarget, bs->eye, dir);
    if (bs->weaponnum == WP_GAUNTLET) {
    	if (VectorLengthSquared(dir) > Square(60)) {
    if (VectorLengthSquared(dir) < Square(100))
    	fov = 120;
    	fov = 50;



    4. Known problems that need a new release

    These can vary from the difficult down to the annoying, but are beyond the reach of mod coders to fix.


    4.1 Sound looping uses wrong track

    Non-fatal, but mods providing their own music will need to use work-arounds

    When using trap_S_StartBackgroundTrack( const char *intro, const char *loop), Q3 only loops the intro music.

    Some maps and mods use an intro to get the main loop "started" (because jumping straight into the loop sounds wrong) will never actually get to the main loop.

    Thanks to Mr Elusive for posting this on the NDA board.


    4.2 Frag and time limit "reset" by server

    Status: Non-fatal, but annoying to have to correct manually

    The fraglimit and timelimit are reset by the server when a map starts. This is usually accompanied by the message "Server: fraglimit changed to X", "Server: timelimit changed to X", and "unknown cmd", where X is a previously used value.

    You have to manually set these parameters to the correct value.


    4.3 Chat text hidden by UI menu

    Status: cosmetic

    While playing a game and opening a menu that doesn't pause the action, chat text isn't drawn "under" the menu.

    Any UI menu drawn in game that relies on this chat text, won't quite work as expected. I've found this out in my own project, in the bot command menu code I added. Ideally I'd like some control over this through a console command processed in the executable.


    4.4 File scan returns a corrupted list of filenames

    Status: Non-fatal, but annoying to have to workaround

    trap_FS_GetFileList() is used to scan for files in a directory, including those in PK3 archives. Unfortunately, the list of files returned is corrupted when scanning for files in the mod root directory. The corruption takes the form of a missing first character, and only for files that are in the PK3 archive.

    There are several workarounds:

    1. Test for the existance of the file with a quick call to trap_FS_FOpenFile(), closing it again if its a valid file (returned length is >= 0).
    2. Place your files in a sub-directory within the PK3.
    3. Force scan all possible missing characters (not recommended).


    PlanetQuake | Code3Arena | Articles | << Prev | Article 11 | Next >>