Skip to content

Commit

Permalink
- version was increased to 0.25
Browse files Browse the repository at this point in the history
- optimized SV_DirSizeCheck - used every time on demo record start
- small optimization in Sys_listdir (used, for example, in 'cmd dlist')
- increased maximum of fps in qwdtools from 100 to 1000
- replaced last 2 dangerous strcpy with strlcpy in qwdtools
  • Loading branch information
VVD committed Oct 25, 2006
1 parent fc3ed3a commit 8bf8801
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 63 deletions.
11 changes: 10 additions & 1 deletion mvdsv/changes.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@

$Id: changes.txt,v 1.110 2006/10/24 14:05:22 vvd0 Exp $
$Id: changes.txt,v 1.111 2006/10/25 11:09:44 vvd0 Exp $

MVDSV v0.25 build 2500 (2006.10.25)
----
* qqshka <[email protected]>
- allow player move even chat userinfo present

* VVD <[email protected]>
- optimized SV_DirSizeCheck - used every time on demo record start
- small optimization in Sys_listdir (used, for example, in 'cmd dlist')
- increased maximum of fps in qwdtools from 100 to 1000
- replaced last 2 dangerous strcpy with strlcpy in qwdtools

* disconnect <[email protected]>
- field offsets cacheing (ported from ZQuake)
- made localcommand more verbose
Expand Down
3 changes: 2 additions & 1 deletion mvdsv/source/qwdtools/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$Id: defs.h,v 1.13 2006/08/01 11:58:47 vvd0 Exp $
$Id: defs.h,v 1.14 2006/10/25 11:09:45 vvd0 Exp $
*/

#ifndef __DEFS_H__
Expand Down Expand Up @@ -187,6 +187,7 @@ typedef struct
int *Int;
int opt;
} opt1;
int str_len;
int opt2;
} param_t;

Expand Down
22 changes: 10 additions & 12 deletions mvdsv/source/qwdtools/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$Id: init.c,v 1.13 2006/05/26 14:51:09 disconn3ct Exp $
$Id: init.c,v 1.14 2006/10/25 11:09:45 vvd0 Exp $
*/

#include "defs.h"
Expand Down Expand Up @@ -197,11 +197,11 @@ int whatToStdout = 0;
#endif
param_t params[] =
{
{"-qizmo_dir", "-qd", TYPE_S, {(char *) qizmoDir}},
{"-output_dir", "-od", TYPE_S, {(char *) outputDir}},
{"-output", "-o", TYPE_S, {(char *) sworld.demo.name}},
{"-debug_file", NULL, TYPE_S, {(char *) sworld.debug.name}},
{"-log_file", NULL, TYPE_S, {(char *) sworld.log.name}},
{"-qizmo_dir", "-qd", TYPE_S, {(char *) qizmoDir}, sizeof(qizmoDir)},
{"-output_dir", "-od", TYPE_S, {(char *) outputDir}, sizeof(outputDir)},
{"-output", "-o", TYPE_S, {(char *) sworld.demo.name}, sizeof(sworld.demo.name)},
{"-debug_file", NULL, TYPE_S, {(char *) sworld.debug.name}, sizeof(sworld.debug.name)},
{"-log_file", NULL, TYPE_S, {(char *) sworld.log.name}, sizeof(sworld.log.name)},
{"-fps", NULL, TYPE_I, {(char *) &sworld.fps}},
{"-filter_spectalk", "-fs", TYPE_O, {(char *) O_FS}},
{"-filter_qizmotalk", "-fq", TYPE_O, {(char *) O_FQ}},
Expand All @@ -214,10 +214,10 @@ param_t params[] =
#ifdef _WIN32
{"-waitforkbhit", "-wait",TYPE_O, {(char *) O_WAITFORKBHIT}},
#endif
{"-stdin", NULL, (type_t) (TYPE_O | TYPE_S), {(char *) stdintype}, (int) O_STDIN},
{"-stdin", NULL, (type_t) (TYPE_O | TYPE_S), {(char *) stdintype}, sizeof(stdintype), (int) O_STDIN},
{"-stdout", NULL, TYPE_O, {(char *) O_STDOUT}},
{"-noini"},
{"-base_dir", "-bd", TYPE_S, {(char *) currentDir}},
{"-base_dir", "-bd", TYPE_S, {(char *) currentDir}, sizeof(currentDir)},
{"-msglevel", "-msg", TYPE_I, {(char *) &sworld.msglevel}},
{"-marge", "-m", TYPE_O, {(char *) O_MARGE}},
{"-range", "-r", TYPE_I, {(char *) &sworld.range}},
Expand Down Expand Up @@ -312,16 +312,14 @@ void ParseArgv(void)
i++;
if (i < com_argc && com_argv[i][0] != '-')
{
// FIXME
strcpy(param->opt1.str, com_argv[i]);
strlcpy(param->opt1.str, com_argv[i], param->str_len);
}
else
{
// if it's stdin assume qwd
if (param->opt2 == O_STDIN)
{
// FIXME
strcpy(param->opt1.str, "qwd");
strlcpy(param->opt1.str, "qwd", param->str_len);
i--;
}
else
Expand Down
48 changes: 26 additions & 22 deletions mvdsv/source/sv_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$Id: sv_demo.c,v 1.53 2006/10/23 19:45:20 disconn3ct Exp $
$Id: sv_demo.c,v 1.54 2006/10/25 11:09:45 vvd0 Exp $
*/

#include "qwsvdef.h"
Expand Down Expand Up @@ -1510,30 +1510,34 @@ qbool SV_DirSizeCheck (void)
{
dir_t dir;
file_t *list;
int i;
int n;

dir = Sys_listdir(va("%s/%s", fs_gamedir, sv_demoDir.string), ".*", SORT_BY_DATE);
if (sv_demoMaxDirSize.value && dir.size > sv_demoMaxDirSize.value*1024)
if (sv_demoMaxDirSize.value)
{
if (sv_demoClearOld.value <= 0)
{
Con_Printf("insufficient directory space, increase sv_demoMaxDirSize\n");
return false;
}
list = dir.files;
i = sv_demoClearOld.value;
Con_Printf("clearing %d old demos\n", i);
// HACK!!! HACK!!! HACK!!!
if (sv_demotxt.value) // if our server record demos and txts, then to remove
i=i*2; // 50 demos, we have to remove 50 demos and 50 txts = 50*2 = 100 files

for (; list->name[0] && i > 0; list++)
dir = Sys_listdir(va("%s/%s", fs_gamedir, sv_demoDir.string), ".*", SORT_NO/*BY_DATE*/);
if (dir.size > sv_demoMaxDirSize.value * 1024)
{
if (list->isdir)
continue;
Sys_remove(va("%s/%s/%s", fs_gamedir, sv_demoDir.string, list->name));
//Con_Printf("remove %d - %s/%s/%s\n", i, fs_gamedir, sv_demoDir.string, list->name);
i--;
if (sv_demoClearOld.value <= 0)
{
Con_Printf("Insufficient directory space, increase sv_demoMaxDirSize\n");
return false;
}
list = dir.files;
n = sv_demoClearOld.value;
Con_Printf("Clearing %d old demos\n", n);
// HACK!!! HACK!!! HACK!!!
if (sv_demotxt.value) // if our server record demos and txts, then to remove
n <<= 1; // 50 demos, we have to remove 50 demos and 50 txts = 50*2 = 100 files

qsort((void *)list, dir.numfiles, sizeof(file_t), Sys_compare_by_date);
for (; list->name[0] && n > 0; list++)
{
if (list->isdir)
continue;
Sys_remove(va("%s/%s/%s", fs_gamedir, sv_demoDir.string, list->name));
//Con_Printf("Remove %d - %s/%s/%s\n", n, fs_gamedir, sv_demoDir.string, list->name);
n--;
}
}
}
return true;
Expand Down
33 changes: 17 additions & 16 deletions mvdsv/source/sv_sys_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$Id: sv_sys_unix.c,v 1.50 2006/06/30 18:12:55 vvd0 Exp $
$Id: sv_sys_unix.c,v 1.51 2006/10/25 11:09:45 vvd0 Exp $
*/

#include "qwsvdef.h"
Expand Down Expand Up @@ -56,21 +56,22 @@ returns -1 if not present
int Sys_FileTime (char *path)
{
struct stat buf;

if (stat (path,&buf) == -1)
return -1;

return buf.st_mtime;
return stat(path, &buf) == -1 ? -1 : buf.st_mtime;
}

int Sys_FileSize (char *path)
int Sys_FileSizeTime (char *path, int *time)
{
struct stat buf;

if (stat (path,&buf) == -1)
if (stat(path, &buf) == -1)
{
*time = -1;
return 0;

return buf.st_size;
}
else
{
*time = buf.st_mtime;
return buf.st_size;
}
}


Expand Down Expand Up @@ -127,7 +128,7 @@ dir_t Sys_listdir (char *path, char *ext, int sort_type)
qbool all;

int r;
pcre *preg=NULL;
pcre *preg = NULL;
const char *errbuf;

memset(list, 0, sizeof(list));
Expand Down Expand Up @@ -173,15 +174,15 @@ dir_t Sys_listdir (char *path, char *ext, int sort_type)
{
dir.numdirs++;
list[dir.numfiles].isdir = true;
list[dir.numfiles].size = 0;
list[dir.numfiles].time = 0;
list[dir.numfiles].size = list[dir.numfiles].time = 0;
closedir(testdir);
}
else
{
list[dir.numfiles].isdir = false;
list[dir.numfiles].time = Sys_FileTime(pathname);
dir.size += (list[dir.numfiles].size = Sys_FileSize(pathname));
//list[dir.numfiles].time = Sys_FileTime(pathname);
dir.size +=
(list[dir.numfiles].size = Sys_FileSizeTime(pathname, &list[dir.numfiles].time));
}
strlcpy (list[dir.numfiles].name, oneentry->d_name, MAX_DEMO_NAME);

Expand Down
11 changes: 3 additions & 8 deletions mvdsv/source/sv_sys_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$Id: sv_sys_win.c,v 1.33 2006/08/07 13:03:59 vvd0 Exp $
$Id: sv_sys_win.c,v 1.34 2006/10/25 11:09:45 vvd0 Exp $
*/

#include "qwsvdef.h"
Expand Down Expand Up @@ -45,11 +45,7 @@ Sys_FileTime
int Sys_FileTime (char *path)
{
struct _stat buf;

if (_stat (path,&buf) == -1)
return -1;

return buf.st_mtime;
return _stat(path, &buf) == -1 ? -1 : buf.st_mtime;
}

/*
Expand Down Expand Up @@ -149,8 +145,7 @@ dir_t Sys_listdir (char *path, char *ext, int sort_type)
{
dir.numdirs++;
list[dir.numfiles].isdir = true;
list[dir.numfiles].size = 0;
list[dir.numfiles].time = 0;
list[dir.numfiles].size = list[dir.numfiles].time = 0;
}
else
{
Expand Down
6 changes: 3 additions & 3 deletions mvdsv/source/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$Id: version.h,v 1.40 2006/10/24 14:05:23 vvd0 Exp $
$Id: version.h,v 1.41 2006/10/25 11:09:45 vvd0 Exp $
*/
// version.h

Expand Down Expand Up @@ -62,8 +62,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


#define QW_VERSION "2.40"
#define QWE_VERSION "0.24.99-CVS"
#define QWE_VERNUM 0.2499
#define QWE_VERSION "0.25"
#define QWE_VERNUM 0.2500
#define SERVER_NAME "MVDSV"
#define QWDTOOLS_NAME "QWDtools"
#define PROJECT_NAME SERVER_NAME
Expand Down

0 comments on commit 8bf8801

Please sign in to comment.