summaryrefslogtreecommitdiff
path: root/source/net_common.c
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2010-07-03 16:01:48 +0000
committerAndrey Nazarov <skuller@skuller.net>2010-07-03 16:01:48 +0000
commit7a914ef872a436adcdb36d21ceddba6bb24eb993 (patch)
treedafc86024742e7bbced8ef897754beff5160f1ae /source/net_common.c
parent1acd69e9a128e4f3abf06b5ae97c968c87663864 (diff)
Yet another huge commit.
Implemented new error reporting framework based on errno and custom error codes. Converted filesystem code, image and model managers, BSP loader to use the new framework and report errors more accurately. Replaced fileHandle_t with qhandle_t. Removed INVALID_LENGTH definition. Killed USE_LOADBUF code. Defined FS_FileExists(Ex) macro, implemented FS_EasyOpenFile and FS_WriteFile helper functions. When testing for free screenshot slots, open the file with O_EXCL flag to avoid race conditions (works only on glibc yet). Don't allow quake paths with high bits set. Don't tolerate any fatal errors encountered when searching for files and pass errors back to the caller. FS_Seek() now fails on files from packs instead of returning an invalid position. Fixed ‘mvdskip’ command not working properly. Avoid inefficient usage of MakeColor macro in image loading functions. Prevent memory leak in JPEG and PNG image functions after calling longjmp() by marking some local variables volatile. Added support for loading monochrome JPEG images. Fixed signed integer overflow in GetWavinfo(). Fixed missing return statement in BSP_LoadSurfEdges() causing out of range edge indices to be left uncaught. Fixed possible access to uninitialized memory in BSP_LoadLeafs() for maps with no leafs. Properly NUL terminate the buffer in SCR_ScoreDump_f(), also check for being in a level. Always free latched_string when cvar is set back to current value. Fixed a crash in ‘mvdplay’ command possible when demo file is invalid.
Diffstat (limited to 'source/net_common.c')
-rw-r--r--source/net_common.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/source/net_common.c b/source/net_common.c
index 7373341..81561fd 100644
--- a/source/net_common.c
+++ b/source/net_common.c
@@ -58,7 +58,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
-#include <errno.h>
#include <arpa/inet.h>
#ifdef __linux__
#include <linux/types.h>
@@ -128,7 +127,7 @@ static const char socketNames[NS_COUNT][8] = { "Client", "Server" };
static SOCKET udp_sockets[NS_COUNT] = { INVALID_SOCKET, INVALID_SOCKET };
static SOCKET tcp_socket = INVALID_SOCKET;
#ifdef _DEBUG
-static fileHandle_t net_logFile;
+static qhandle_t net_logFile;
#endif
// current rate measurement
@@ -310,29 +309,22 @@ static void logfile_close( void ) {
static void logfile_open( void ) {
char buffer[MAX_OSPATH];
- size_t len;
- int mode;
-
- len = Q_concat( buffer, sizeof( buffer ), "logs/",
- net_log_name->string, ".log", NULL );
- if( len >= sizeof( buffer ) ) {
- Com_WPrintf( "Oversize logfile name specified\n" );
- Cvar_Set( "net_log_enable", "0" );
- return;
- }
+ unsigned mode;
+ qhandle_t f;
mode = net_log_enable->integer > 1 ? FS_MODE_APPEND : FS_MODE_WRITE;
if( net_log_flush->integer ) {
mode |= FS_FLUSH_SYNC;
}
- FS_FOpenFile( buffer, &net_logFile, mode );
- if( !net_logFile ) {
- Com_WPrintf( "Couldn't open %s\n", buffer );
+ f = FS_EasyOpenFile( buffer, sizeof( buffer ), mode,
+ "logs/", net_log_name->string, ".log" );
+ if( !f ) {
Cvar_Set( "net_log_enable", "0" );
return;
}
+ net_logFile = f;
Com_Printf( "Logging network packets to %s\n", buffer );
}