Commit Graph

49 Commits

Author SHA1 Message Date
Ozkan Sezer 338da9a4c8 dropped CVAR_SERVERINFO flag from the cmdline cvar: sending cmdline upon
CCREQ_RULE_INFO is evil...
while I was there, did some whitespace clean-up in common.c.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@568 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-12-28 23:40:27 +00:00
Ozkan Sezer 1928f2e1b8 * first shot at cvar flag system and cvar layer clean-ups :
- removed the archive and server members of cvar_t structure
  which are now represented by the CVAR_ARCHIVE, CVAR_NOTIFY
  and CVAR_SERVERINFO flags.
- added new Cvar_SetROM and Cvar_SetValueROM functions to 
  set vars marked as CVAR_ROM (read-only vars) programaticaly
- added Cvar_SetCallback() as a new function to assign (or
  remove) a callback function to a cvar.
- changed Cvar_RegisterVariable() to only accept a var pointer
  as in original quake
- moved notification handling from Cvar_Set() to callbacks.
- changed Cvar_Set() so that it doesn't reallocate the var's
  string buffer if nothing is changed, nor does it run the
  var's callback.
- changed the 'registered' and 'cmdline' cvars to be read-only
  so that the users can't change it using the console.  (and
  with 'registered' flagged as CVAR_ROM, the 'static_registered'
  thing is no longer required)
- added comment that sending cmdline upon CCREQ_RULE_INFO is
  evil...
- more to follow later.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@566 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-12-28 22:01:33 +00:00
Ozkan Sezer d0093d0b80 common.c (q_vsnprintf): Don't attempt to nul terminate the buffer
if zero size was passed. From Sander van Dijk.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@563 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-12-27 19:32:17 +00:00
Ozkan Sezer ef0062741c added COM_ExtractExtension() helper.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@561 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-12-27 14:00:33 +00:00
Ozkan Sezer fb2f45126e changed many strcpy and strncpy into q_strlcpy
and strcat and strncat into q_strlcat

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@560 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-12-27 13:15:31 +00:00
Ozkan Sezer 983af887bf changed many sprintf() calls into q_snprintf().
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@557 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-12-27 10:50:42 +00:00
Ozkan Sezer 07b572b642 better buffer size safety with COM_StripExtension, COM_FileBase and COM_DefaultExtension
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@554 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-12-27 08:04:02 +00:00
Ozkan Sezer 573f49d920 added FS_fgets(). From Sander van Dijk.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@541 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-12-24 12:03:29 +00:00
Ozkan Sezer 162f18573e removed the LoadBufFile method
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@475 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-08-03 19:22:29 +00:00
Ozkan Sezer 701ae6882c a little syncing with uhexen2.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@460 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-06-12 12:25:22 +00:00
Ozkan Sezer 45498a99a4 replaced COM_FileExtension by a slightly better version from uhexen2,
renamed it to COM_FileGetExtension, added a prototype to common.h.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@454 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-05-20 20:38:11 +00:00
Ozkan Sezer a85d8dcd6a made global host_parms a pointer, set in main(). adjusted places where
host_parms is used. made COM_Init() and Host_Init() to take no arguments.
made Sys_Init() to set host_parms->userdir: at present, it is set to
host_parms->basedir, to be changed properly when user directories are
implemented.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@443 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-04-19 16:41:45 +00:00
Ozkan Sezer 3f006ac62f * common.c (COM_FileExists): changed return type to qboolean.
(COM_filelength): new procedure.
(COM_FindFile): adjustments to avoid multiple file open/close operations just a
little.
* common.h (COM_FileExists): adjusted prototype.
* bgmusic.c (BGM_PlayCDtrack): adjusted for COM_FileExists() return type change.
* sys_sdl_win.c, sys_sdl_unix.c (Sys_filelength): changed return type to long.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@408 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-02-10 17:25:43 +00:00
Ozkan Sezer f707439e86 * common.c (FS_fread): fixed coding style.
* bgmusic.c:  minor updates from uhexen2.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@406 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-02-08 11:00:29 +00:00
Ozkan Sezer 11270d5b2c changed makefiles to use 1/0 instead of yes/no for the codec options.
made quakespasm custom conback embedding optional, still defaulting to 1.
the code requires USE_QS_CONBACK preprocessor definition.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@392 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-12 09:32:22 +00:00
Ozkan Sezer ceb1dd2186 made COM_FindFile to accept both file and handle as NULL. Added
COM_FileExists as a new helper procedure which calls COM_FindFile
with both file and handle parameters as NULL.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@373 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-05 18:01:15 +00:00
Ozkan Sezer c583b5b541 common.c (searchpath_t): Added new member `path_id', an unsigned
int identifier assigned to the game directory. Remember that main
<install_dir>/game1 and the unix <userdir>/game1 have the same id.
The id starts as 1 for the first data1 directory. For every new
directory, the value is the left-shifted version of the previous
one.  Made COM_FindFile() to accept a path_id pointer argument
and storing the id in it if it isn't NULL. Made COM_OpenFile(),
COM_FOpenFile() and all COM_Load* functions to accept a path_id
pointer argument similarly. Adjusted callers accordingly.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@370 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-02 21:45:16 +00:00
Ozkan Sezer e28dfd7d70 Removed support for -proghack and -path. I think no one misses them.
Made COM_FindFile() static to common.c. Removed COM_CopyFile(), no
callers at the moment.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@369 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-02 21:42:54 +00:00
Ozkan Sezer 1dac8dd81d removed the useless msg_suppress_1 thing.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@365 af15c1b1-3010-417e-b628-4374ebc0bcbd
2011-01-01 12:27:02 +00:00
Ozkan Sezer 9aad4f2759 common.c, common.h: Added LOADFILE_* defines for use with COM_LoadFile,
for easier reading. Added COM_LoadZoneFile(), COM_LoadMallocFile() and
COM_LoadBufFile() from uhexen2. Added comments after their prototypes
in common.h.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@361 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-12-31 10:29:38 +00:00
Ozkan Sezer 6d2ae18a82 killed all references to Draw_BeginDisc
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@357 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-12-30 23:28:08 +00:00
Ozkan Sezer 165598051c backports from uHexen2 tree:
* common.c, common.h: Added new structure fshandle_t. Added new procedures
  FS_fread, FS_fseek, FS_ftell, FS_rewind, FS_feof, FS_ferror and FS_fclose.
  The new FS_*() stdio replacements are necessary if one is to perform non-
  sequential reads on files reopened on pak files because bookkeeping about
  file start/end positions is needed. Allocating and filling in the fshandle_t
  structure is the users' responsibility when the file is initially opened.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@353 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-12-30 16:50:15 +00:00
Ozkan Sezer 56a7b2e6fd added file_from_pak as a new flobal, made COM_FindFile() to set it properly.
from quakeworld sources.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@352 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-12-30 16:35:16 +00:00
Ozkan Sezer e08d6cf1e3 replaced all usess of vsprintf by q_vsnprintf
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@320 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-08-31 16:57:12 +00:00
Ozkan Sezer 20c394edea added q_snprintf and q_vsnprintf from uhexen2. always use our wrapper
versions to ensure consistent behavior accross platforms.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@319 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-08-31 14:09:00 +00:00
Ozkan Sezer b1585b3039 more fixes for deprecated conversion from string constant to char*:
handle the -safe command line switch using a new global safemode,
check for safemode in the related driver init functions and remove
the safeargvs & co from common.c and COM_InitArgv().


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@307 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-08-29 12:55:41 +00:00
Ozkan Sezer 906df3f650 const correctness changes.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@300 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-08-29 02:22:55 +00:00
Ozkan Sezer efde005b7f * common.c: Renamed the empty Test_f function of johnfitz to FitzTezt_f.
Renamed its associated console command to fitztest.
* net_dgrm.c: Renamed back Net_Test_f to Test_f. Added back the test,
test2 and ban console commands.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@209 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-06-21 09:58:12 +00:00
Ozkan Sezer c24d592580 host_cmd.c, console.c, gl_draw.c, image.c, gl_model.c, r_sprite.c, cl_parse.c,
gl_warp.c, host.c, gl_mesh.c, gl_sky.c, gl_texmgr.c, cvar.c, sv_main.c, cvar.h,
gl_screen.c, r_brush.c, gl_vidsdl.c, zone.c, cl_main.c, cmd.c, snd_dma.c,
snd_mem.c, common.c, sv_phys.c: Added explicit casts to eliminate -Wc++-compat
warnings.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@170 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-05-31 07:42:36 +00:00
Ozkan Sezer 65a7f903e5 main_sdl.c (main): Remove leading linefeed from the init message.
common.c (COM_InitArgv): Move the leading linefeed to the end of message.

Index: main_sdl.c
===================================================================
--- main_sdl.c	(revision 157)
+++ main_sdl.c	(working copy)
@@ -58,7 +58,7 @@
 	if (!parms.membase)
 		Sys_Error ("Not enough memory free; check disk space\n");
 
-	Con_Printf("\nFitzQuake %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
+	Con_Printf("FitzQuake %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
 	Con_Printf("SDL port (c) Sleepwalkr, Baker\n");
 	Con_Printf("QuakeSpasm %1.2f.%d (c) Ozkan Sezer, Stevenaaus\n", FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH);
 
Index: common.c
===================================================================
--- common.c	(revision 157)
+++ common.c	(working copy)
@@ -1150,7 +1150,7 @@
 	if (n > 0 && com_cmdline[n-1] == ' ')
 		com_cmdline[n-1] = 0; //johnfitz -- kill the trailing space
 
-	Con_Printf("\nCommand line: %s",com_cmdline);
+	Con_Printf("Command line: %s\n", com_cmdline);
 
 	safe = false;
 


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@158 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-04-27 07:15:19 +00:00
Ozkan Sezer 53746a85c9 Constified Con_DebugLog, Con_Print, Con_Printf, Con_Warning, Con_DPrintf,
Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, Con_LogCenterPrint,
Con_NotifyBox, PL_ErrorDialog, PR_RunError, Host_EndGame, Host_Error,
SV_ClientPrintf, SV_BroadcastPrintf, Host_ClientCommands, Sys_DebugLog,
Sys_Error, Sys_Printf, BOPS_Error and va. Added noreturn attribute to
Sys_Error, Sys_Quit, BOPS_Error, PR_RunError, Host_EndGame and Host_Error.
Added format printf attribute to Con_DebugLog, Con_Printf, Con_Warning,
Con_DPrintf, Con_DPrintf2, Con_SafePrintf, Con_CenterPrintf, PL_ErrorDialog,
PR_RunError, Host_EndGame, Host_Error, SV_ClientPrintf, SV_BroadcastPrintf,
Host_ClientCommands, Sys_DebugLog, Sys_Error, Sys_Printf and va. Adjusted
Host_Status_f and NET_Ban_f for the new attributes. Fixed broken format
strings in Con_Dump_f, Mod_LoadTexinfo, PR_AllocStringSlots and FloorDivMod.
Defined __attribute__ macros in quakedef.h so that we don't break non-gcc
compilers.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@154 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-04-26 16:30:40 +00:00
Ozkan Sezer 610567cb8a common.c (COM_Parse): commented out the check for ':' in regular word parsing
so that a command line like "+connect ip:port2 works.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@102 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-03-06 13:35:05 +00:00
Ozkan Sezer 14a1493f73 quakedef.h (quakeparms_t): removed the cachedir member which doesn't serve
any purpose for quite some time. added userdir as a new member, user's
directory on UNIX platforms. if user directories are enabled, basedir
and userdir will point to different memory locations, otherwise to the same.
this member will be enabled/used later.
common.c: removed all references to cachedir and com_cachedir which don't
serve any purpose for quite some time.
main (main): removed assingment to cachedir member.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@96 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-03-01 12:50:12 +00:00
Ozkan Sezer 3724ddbb02 common.c (com_basedir): added new global char array.
(COM_InitFilesystem): used global com_basedir instead of the automatic
basedir variable.
common.h (com_basedir): added extern.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@95 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-03-01 11:55:13 +00:00
Ozkan Sezer 0f91628b0d common.c (va): made va() to cycle between four static buffers so that we
can call it one after another. will be needed later.
(get_va_buffer): new helper for va().


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@92 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-03-01 10:28:12 +00:00
Ozkan Sezer f0c318cafe common.c (Q_strncasecmp): fix it so that it properly returns negative and
positive values.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@87 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-27 08:00:57 +00:00
Ozkan Sezer eb9e15a9b3 the custom embedded comback image is intended to replace the id1 image ..
* .. when running in fitz-compatibility mode (-fitz command line switch)
* .. or when the mods themselves did not provide their own conback image
themselves, ie. the "Q" conback image of id1 is just not wanted. So, just
modify/corrupt the gfx/conback.lmp filename in the id1/pak0.pak file list,
achieving the intention that way.
common.c (kill_id1_conback): new QuakeSpasm customization helper.
 (COM_InitFilesystem): call kill_id1_conback() just after adding the id1
directory to the search path when not running in fitzmode.
gl_draw.c (Draw_ConbackPic): when not running in fitzmode, do search for
the gfx/conback.lmp file before loading the embedded custom image to see
whether the mod provided its own conback image.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@76 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-20 08:50:31 +00:00
Ozkan Sezer e3d6b98d8b common.c (COM_FindFile): commented out the debug messages about finding
and not finding a file.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@74 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-20 08:20:20 +00:00
Ozkan Sezer c31e8931a8 common.c (COM_Init): move the -fitz command line switch check before the
filesystem initialization.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@73 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-20 08:14:30 +00:00
Ozkan Sezer 4065ce7280 common.c (COM_Init): updated endianism check.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@48 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-18 12:00:31 +00:00
Ozkan Sezer 44ad29724b common.c, common.h: added check for '-fitz' command line switch which, if true,
makes quakespasm to run in fitzquake mode and disable custom quakespasm hacks.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@47 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-18 11:45:18 +00:00
Ozkan Sezer 9e861e3102 64 bit compatibility effort, 1/nn: type correctness work in common.c,
common.h, gl_vidsdl.c, mathlib.h, zone.c, zone.h. added Z_Realloc as a
new function (will be used later.) next step will be type correctness
work in opengl stuff.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@33 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-16 21:22:20 +00:00
Ozkan Sezer 8f3d2c5c7b common.c, common.h: constified the replacement string library functions.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@27 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-16 13:02:22 +00:00
Ozkan Sezer 68fc38c3a6 chase.c, cl_input.c, cl_parse.c, client.h, common.c, common.h, console.h,
cvar.h, draw.h, gl_draw.c, gl_fog.c, gl_mesh.c, gl_model.c, gl_model.h,
gl_rmain.c, gl_rmisc.c, gl_screen.c, gl_sky.c, gl_texmgr.c, glquake.h,
host.c, keys.c, keys.h, main.c, menu.c, menu.h, pr_cmds.c, quakedef.h,
r_alias.c, r_brush.c, r_part.c, r_sprite.c, r_world.c, sbar.c, sbar.h,
screen.h, snd_dma.c, snd_mem.c, snd_mix.c, sv_main.c, sys_sdl.c, vid.h,
view.h, world.c, world.h:  Loads of warning fixes about missing function
prototypes, missing parens around &, missing braces leading to ambiguous
else statements and unused and uninitialized variables. There are still a
couple of unitialised variables here and there, but not much. The warnings
about strict aliasing violations need taking care of.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@21 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-16 12:01:07 +00:00
Ozkan Sezer 73aef81aca common.c (COM_InitArgv): remove the trailing whitespace added at the end
of cmdline string only if there is one. print out the command line as an
informational message.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@19 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-16 10:10:58 +00:00
Ozkan Sezer 3a5b43816d common.c (COM_FindFile): Made PackFile debug message prints into Con_DPrintf so
that they don't spam the console.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@9 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-16 08:40:26 +00:00
Ozkan Sezer 5c023d21ad common.c (COM_LoadFile): Commented out the Draw_BeginDisc call. It causes core
dumps when called excessively in big mods.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@8 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-16 08:25:33 +00:00
Ozkan Sezer 383e3900ea common.c (COM_FileBase): fix an old quake bug where it can start hunting
whole memory for the nul terminator.


git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@3 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-15 23:30:23 +00:00
Ozkan Sezer db613ab35d initial import of SDL port of Fitzquake-0.85 / 20090510 sources.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@2 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-15 23:26:55 +00:00