Quakespasm Mining ...

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Quakespasm Mining ...

Post by Baker »

QuakeSpasm is fork of FitzQuake 0.85 SDL and quite a neat engine. Well, there actually never was a FitzQuake 0.85 SDL.

Someone took FitzQuake 0.85 and FitzQuake 0.80 SDL and made a "FitzQuake 0.85 SDL" in 6 hours after reading FitzQuake 0.85 might not happen until 2010. :D Yeah, I'm not uber leet like some of the guys here but I kick ass at grunt work. Anyways ...

http://quakespasm.sourceforge.net/

I like looking through engine changes to see what kind of things people think are important.

Here is a list of changes I found in Quakespasm that interested me ...

1. Looks like "buffer-safeness" in va(...) Might be straight from DarkPlaces.

Code: Select all

/*
============
va

does a varargs printf into a temp buffer. cycles between
4 different static buffers. the number of buffers cycled
is defined in VA_NUM_BUFFS.
FIXME: make this buffer size safe someday
============
*/
#define	VA_NUM_BUFFS	4
#define	VA_BUFFERLEN	1024

static char *get_va_buffer(void)
{
	static char va_buffers[VA_NUM_BUFFS][VA_BUFFERLEN];
	static int buffer_idx = 0;
	buffer_idx = (buffer_idx + 1) & (VA_NUM_BUFFS - 1);
	return va_buffers[buffer_idx];
}

char *va (const char *format, ...)
{
	va_list		argptr;
	char		*va_buf;

	va_buf = get_va_buffer ();
	va_start (argptr, format);
	vsprintf (va_buf, format, argptr);
	va_end (argptr);

	return va_buf;
}
2. Endianness detector

Code: Select all

void COM_Init (char *basedir)
{
	int	i = 0x12345678;
		/*    U N I X */

	/*
	BE_ORDER:  12 34 56 78
		   U  N  I  X

	LE_ORDER:  78 56 34 12
		   X  I  N  U

	PDP_ORDER: 34 12 78 56
		   N  U  X  I
	*/
	if ( *(char *)&i == 0x12 )
		bigendien = true;
	else if ( *(char *)&i == 0x78 )
		bigendien = false;
	else /* if ( *(char *)&i == 0x34 ) */
		Sys_Error ("Unsupported endianism.");
3. Nice to know! Probably why I couldn't get Travail to run on my Mac with my "FitzQuake 0.85 SDL" and I couldn't think of a test strategy plus I had no free time in the middle of '09 ...

COM_LoadFile

Code: Select all

	// Draw_BeginDisc causes core dumps when called excessively in big mods S.A.
4. Yes, make video mode state detection less of a pain ...

vid.h

Code: Select all

// moved here for global use -- kristian
typedef enum { NO_MODE=-1, MODE_WINDOWED, MODE_FULLSCREEN_DEFAULT } modestate_t;
5. Removal of this. You know, I've never checked original WinQuake and GLQuake to see what happens when you press pause. Does it release the mouse? It does in WinQuake for sure as I just tested it. GLQuake 0.95 does not.

Code: Select all

void VID_HandlePause (qboolean pause);
// called only on Win32, when pause happens, so the mouse can be released
6. S_Init?

Hmmm ... sound system restart capability? Or maybe SDL needs that on video mode change?

Code: Select all

void S_Init (void)
{
	if (snd_initialized)
	{
		Con_Printf("Sound is already initialized\n");
		return;
	}
7. Yeah it is kind of dumb to do disconnect from a single player game, running demo or server if someone types "map" with no arguments.

Code: Select all

void Host_Map_f (void)
{
	int		i;
	char	name[MAX_QPATH];

	if (Cmd_Argc() < 2)	//no map name given
	{
		if (cls.state == ca_dedicated)
		{
			if (sv.active)
				Con_Printf ("Current map: %s\n", sv.name);
			else
				Con_Printf ("Server not active\n");
		}
		else if (cls.state == ca_connected)
		{
			Con_Printf ("Current map: %s ( %s )\n", cl.levelname, cl.mapname);
		}
		else
		{
			Con_Printf ("map <levelname>: start a new server\n");
		}
		return;
	}
8. You got me. No clue ... thread safety? I notice pr_edict.c is quite re-written.

Was ...

Code: Select all

		if (sv.paused)
		{
			SV_BroadcastPrintf ("%s paused the game\n", pr_strings + sv_player->v.netname);
		}
		else
		{
			SV_BroadcastPrintf ("%s unpaused the game\n",pr_strings + sv_player->v.netname);
		}
Now ...

Code: Select all

		if (sv.paused)
		{
			SV_BroadcastPrintf ("%s paused the game\n", PR_GetString(sv_player->v.netname));
		}
		else
		{
			SV_BroadcastPrintf ("%s unpaused the game\n",PR_GetString(sv_player->v.netname));
		}
9. I'm not sure if this right to do, but interesting. Type map "xxx" and the console goes away. Do a changelevel and the console stays. Strange but ...

Host_Changelevel_f

Code: Select all

	IN_Activate();	// -- S.A.
	key_dest = key_game;	// remove console or menu
I don't know if Quakespasm can run as a dedicated server (FitzQuake can), but that seems inappropriate. Sure you could understand doing that in single player or even a listen server, though.

10. All instances of index variables are renamed to "idx" in net_sdlnet.c. Maybe a compiler thinks "index" is a reserved word or something special or maybe it was annoying for some other reason.

11. Ah! So that's how FitzQuake reloads textures from models and maps if a bpp change happens .... it stores the offset of the texture in the texture manager.

Code: Select all

					offset = (src_offset_t)(mt+1) - (src_offset_t)mod_base;
					if (Mod_CheckFullbrights ((byte *)(tx+1), pixels))
					{
						tx->gltexture = TexMgr_LoadImage (loadmodel, texturename, tx->width, tx->height,
							SRC_INDEXED, (byte *)(tx+1), loadmodel->name, offset, TEXPREF_MIPMAP | TEXPREF_NOBRIGHT);
						sprintf (texturename, "%s:%s_glow", loadmodel->name, tx->name);
						tx->fullbright = TexMgr_LoadImage (loadmodel, texturename, tx->width, tx->height,
							SRC_INDEXED, (byte *)(tx+1), loadmodel->name, offset, TEXPREF_MIPMAP | TEXPREF_FULLBRIGHT);
					}
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Post Reply