A few changes, I hope it makes people very happy

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2555 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2007-07-27 21:24:31 +00:00
parent 981b6d05dd
commit 7b4f6508b9
8 changed files with 190 additions and 57 deletions

View File

@ -106,7 +106,7 @@ qboolean Cam_DrawViewModel(int pnum)
}
else
{
if (selfcam == 1)
if (selfcam == 1 && r_secondaryview != 3)
return true;
return false;
}
@ -500,6 +500,7 @@ void Cam_Track(int pnum, usercmd_t *cmd)
// move there locally immediately
VectorCopy(player->origin, self->origin);
}
Con_Printf("self->weaponframe = %i\n", self->weaponframe);
self->weaponframe = player->weaponframe;
return;

View File

@ -236,6 +236,7 @@ vfsfile_t *VFSOS_Open(char *osname, char *mode)
vfsosfile_t *file;
qboolean read = !!strchr(mode, 'r');
qboolean write = !!strchr(mode, 'w');
qboolean append = !!strchr(mode, 'a');
qboolean text = !!strchr(mode, 't');
char newmode[3];
int modec = 0;
@ -244,6 +245,8 @@ vfsfile_t *VFSOS_Open(char *osname, char *mode)
newmode[modec++] = 'r';
if (write)
newmode[modec++] = 'w';
if (append)
newmode[modec++] = 'a';
if (text)
newmode[modec++] = 't';
else
@ -256,7 +259,7 @@ vfsfile_t *VFSOS_Open(char *osname, char *mode)
file = Z_Malloc(sizeof(vfsosfile_t));
file->funcs.ReadBytes = strchr(mode, 'r')?VFSOS_ReadBytes:NULL;
file->funcs.WriteBytes = strchr(mode, 'w')?VFSOS_WriteBytes:NULL;
file->funcs.WriteBytes = (strchr(mode, 'w')||strchr(mode, 'a'))?VFSOS_WriteBytes:NULL;
file->funcs.Seek = VFSOS_Seek;
file->funcs.Tell = VFSOS_Tell;
file->funcs.GetLen = VFSOS_GetSize;
@ -2048,7 +2051,8 @@ vfsfile_t *FS_OpenVFS(char *filename, char *mode, int relativeto)
if (strcmp(mode, "rb"))
if (strcmp(mode, "wb"))
return NULL; //urm, unable to write/append
if (strcmp(mode, "ab"))
return NULL; //urm, unable to write/append
switch (relativeto)
{
@ -2108,7 +2112,7 @@ vfsfile_t *FS_OpenVFS(char *filename, char *mode, int relativeto)
}
//if we're meant to be writing, best write to it.
if (strchr(mode , 'w'))
if (strchr(mode , 'w') || strchr(mode , 'a'))
return VFSOS_Open(fullname, mode);
return NULL;
}

View File

@ -6,12 +6,20 @@
void Log_Dir_Callback (struct cvar_s *var, char *oldvalue);
void Log_Name_Callback (struct cvar_s *var, char *oldvalue);
typedef enum {
LOG_CONSOLE,
LOG_PLAYER,
LOG_TYPES
} logtype_t;
// cvars
#define CONLOGGROUP "Console logging"
cvar_t log_name = SCVARFC("log_name", "", CVAR_NOTFROMSERVER, Log_Name_Callback);
cvar_t log_enable[LOG_TYPES] = { SCVARF("log_enable", "0", CVAR_NOTFROMSERVER),
SCVARF("log_enable_players", "0", CVAR_NOTFROMSERVER)};
cvar_t log_name[LOG_TYPES] = { SCVARFC("log_name", "", CVAR_NOTFROMSERVER, Log_Name_Callback),
SCVARFC("log_name_players", "", CVAR_NOTFROMSERVER, Log_Name_Callback)};
cvar_t log_dir = SCVARFC("log_dir", "", CVAR_NOTFROMSERVER, Log_Dir_Callback);
cvar_t log_readable = SCVARF("log_readable", "0", CVAR_NOTFROMSERVER);
cvar_t log_enable = SCVARF("log_enable", "0", CVAR_NOTFROMSERVER);
cvar_t log_developer = SCVARF("log_developer", "0", CVAR_NOTFROMSERVER);
cvar_t log_rotate_files = SCVARF("log_rotate_files", "0", CVAR_NOTFROMSERVER);
cvar_t log_rotate_size = SCVARF("log_rotate_size", "131072", CVAR_NOTFROMSERVER);
@ -72,7 +80,7 @@ void Log_Dir_Callback (struct cvar_s *var, char *oldvalue)
}
}
// Log_Name_Callback: called when a log_dir is changed
// Log_Name_Callback: called when a log_name is changed
void Log_Name_Callback (struct cvar_s *var, char *oldvalue)
{
char *t = var->string;
@ -87,15 +95,16 @@ void Log_Name_Callback (struct cvar_s *var, char *oldvalue)
}
// Con_Log: log string to console log
void Con_Log (char *s)
void Log_String (logtype_t lognum, char *s)
{
vfsfile_t *fi;
char *d; // directory
char *f; // filename
char *t;
char logbuf[1024];
int i;
if (!log_enable.value)
if (!log_enable[lognum].value)
return;
// get directory/filename
@ -103,9 +112,23 @@ void Con_Log (char *s)
if (log_dir.string[0])
d = log_dir.string;
f = "qconsole";
if (log_name.string[0])
f = log_name.string;
f = NULL;
switch(lognum)
{
case LOG_CONSOLE:
f = "qconsole";
break;
case LOG_PLAYER:
f = "players";
break;
default:
break;
}
if (log_name[lognum].string[0])
f = log_name[lognum].string;
if (!f)
return;
// readable translation and Q3 code removal, use t for final string to write
t = logbuf;
@ -207,7 +230,7 @@ void Con_Log (char *s)
if (FS_Rename(oldf, newf, FS_BASE))
{
// rename failed, disable log and bug out
Cvar_ForceSet(&log_enable, "0");
Cvar_ForceSet(&log_enable[lognum], "0");
Con_Printf("Unable to rotate log files. Logging disabled.\n");
return;
}
@ -218,35 +241,138 @@ void Con_Log (char *s)
if (FS_Rename(f, oldf, FS_BASE))
{
// rename failed, disable log and bug out
Cvar_ForceSet(&log_enable, "0");
Cvar_ForceSet(&log_enable[lognum], "0");
Con_Printf("Unable to rename base log file. Logging disabled.\n");
return;
}
}
}
// write to log file
if (Sys_DebugLog(f, "%s", logbuf))
FS_CreatePath(f, FS_BASE);
if ((fi = FS_OpenVFS(f, "ab", FS_BASE)))
{
VFS_WRITE(fi, logbuf, strlen(logbuf));
VFS_CLOSE(fi);
}
else
{
// write failed, bug out
Cvar_ForceSet(&log_enable, "0");
Cvar_ForceSet(&log_enable[lognum], "0");
Con_Printf("Unable to write to log file. Logging disabled.\n");
return;
}
}
void Con_Log (char *s)
{
Log_String(LOG_CONSOLE, s);
}
//still to add stuff at:
//connects
//disconnects
//kicked
void SV_LogPlayer(client_t *cl, char *msg)
{
char line[2048];
snprintf(line, sizeof(line),
"%s\\%s\\%i\\%s\\%s\\%i%s\n",
msg, cl->name, cl->userid,
NET_BaseAdrToString(cl->netchan.remote_address), "??",
cl->netchan.remote_address.port, cl->userinfo);
Log_String(LOG_PLAYER, line);
}
void Log_Logfile_f (void)
{
extern char gamedirfile[];
if (log_enable[LOG_CONSOLE].value)
{
Cvar_SetValue(&log_enable[LOG_CONSOLE], 0);
Con_Printf("Logging disabled.\n");
}
else
{
char *d, *f;
d = gamedirfile;
if (log_dir.string[0])
d = log_dir.string;
f = "qconsole";
if (log_name[LOG_CONSOLE].string[0])
f = log_name[LOG_CONSOLE].string;
Con_Printf(va("Logging to %s/%s.log.\n", d, f));
Cvar_SetValue(&log_enable[LOG_CONSOLE], 1);
}
}
/*
void SV_Fraglogfile_f (void)
{
char name[MAX_OSPATH];
int i;
if (sv_fraglogfile)
{
Con_TPrintf (STL_FLOGGINGOFF);
VFS_CLOSE (sv_fraglogfile);
sv_fraglogfile = NULL;
return;
}
// find an unused name
for (i=0 ; i<1000 ; i++)
{
sprintf (name, "frag_%i.log", i);
sv_fraglogfile = FS_OpenVFS(name, "rb", FS_GAME);
if (!sv_fraglogfile)
{ // can't read it, so create this one
sv_fraglogfile = FS_OpenVFS (name, "wb", FS_GAME);
if (!sv_fraglogfile)
i=1000; // give error
break;
}
VFS_CLOSE (sv_fraglogfile);
}
if (i==1000)
{
Con_TPrintf (STL_FLOGGINGFAILED);
sv_fraglogfile = NULL;
return;
}
Con_TPrintf (STL_FLOGGINGTO, name);
}
*/
void Log_Init(void)
{
int i;
// register cvars
Cvar_Register (&log_name, CONLOGGROUP);
for (i = 0; i < LOG_TYPES; i++)
{
Cvar_Register (&log_enable[i], CONLOGGROUP);
Cvar_Register (&log_name[i], CONLOGGROUP);
}
Cvar_Register (&log_dir, CONLOGGROUP);
Cvar_Register (&log_readable, CONLOGGROUP);
Cvar_Register (&log_enable, CONLOGGROUP);
Cvar_Register (&log_developer, CONLOGGROUP);
Cvar_Register (&log_rotate_size, CONLOGGROUP);
Cvar_Register (&log_rotate_files, CONLOGGROUP);
Cvar_Register (&log_dosformat, CONLOGGROUP);
Cmd_AddCommand("logfile", Log_Logfile_f);
// cmd line options, debug options
#ifdef CRAZYDEBUGGING
Cvar_ForceSet(&log_enable, "1");
@ -254,5 +380,5 @@ void Log_Init(void)
#endif
if (COM_CheckParm("-condebug"))
Cvar_ForceSet(&log_enable, "1");
Cvar_ForceSet(&log_enable[LOG_CONSOLE], "1");
}

View File

@ -87,7 +87,9 @@ qboolean PPL_ShouldDraw(void)
}
else
{
if (currententity->flags & Q2RF_EXTERNALMODEL)
if (currententity->flags & Q2RF_WEAPONMODEL)
return false;
if (currententity->flags & Q2RF_EXTERNALMODEL && r_secondaryview != 3)
return false;
// if (currententity->keynum == (cl.viewentity[r_refdef.currentplayernum]?cl.viewentity[r_refdef.currentplayernum]:(cl.playernum[r_refdef.currentplayernum]+1)))
// return false;

View File

@ -183,39 +183,6 @@ void SV_Quit_f (void)
Sys_Quit ();
}
/*
============
SV_Logfile_f
============
*/
void SV_Logfile_f (void)
{
extern cvar_t log_enable, log_dir, log_name;
extern char gamedirfile[];
if (log_enable.value)
{
Cvar_SetValue(&log_enable, 0);
Con_Printf("Logging disabled.\n");
}
else
{
char *d, *f;
d = gamedirfile;
if (log_dir.string[0])
d = log_dir.string;
f = "qconsole";
if (log_name.string[0])
f = log_name.string;
Con_Printf(va("Logging to %s/%s.log.\n", d, f));
Cvar_SetValue(&log_enable, 1);
}
}
/*
============
SV_Fraglogfile_f
@ -308,6 +275,7 @@ void SV_God_f (void)
if (!SV_SetPlayer ())
return;
SV_LogPlayer(host_client, "god cheat");
sv_player->v->flags = (int)sv_player->v->flags ^ FL_GODMODE;
if ((int)sv_player->v->flags & FL_GODMODE)
SV_ClientTPrintf (host_client, PRINT_HIGH, STL_GODON);
@ -327,6 +295,7 @@ void SV_Noclip_f (void)
if (!SV_SetPlayer ())
return;
SV_LogPlayer(host_client, "noclip cheat");
if (sv_player->v->movetype != MOVETYPE_NOCLIP)
{
sv_player->v->movetype = MOVETYPE_NOCLIP;
@ -366,6 +335,8 @@ void SV_Give_f (void)
return;
}
SV_LogPlayer(host_client, "give cheat");
if (!svprogfuncs)
return;
@ -663,6 +634,8 @@ void SV_Kick_f (void)
// print directly, because the dropped client won't get the
// SV_BroadcastPrintf message
SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUWEREKICKED);
SV_LogPlayer(cl, "kicked");
SV_DropClient (cl);
}
@ -714,6 +687,7 @@ void SV_BanName_f (void)
// print directly, because the dropped client won't get the
// SV_BroadcastPrintf message
SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUWEREBANNED);
SV_LogPlayer(cl, "banned name");
SV_DropClient (cl);
}
@ -768,6 +742,7 @@ void SV_BanIP_f (void)
// print directly, because the dropped client won't get the
// SV_BroadcastPrintf message
SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUWEREBANNED);
SV_LogPlayer(cl, "banned ip");
SV_DropClient (cl);
}
}
@ -995,6 +970,7 @@ void SV_ForceName_f (void)
while((cl = SV_GetClientForString(Cmd_Argv(1), &clnum)))
{
Info_SetValueForKey(cl->userinfo, "name", Cmd_Argv(2), MAX_INFO_STRING);
SV_LogPlayer(cl, "name forced");
SV_ExtractFromUserinfo(cl);
Q_strncpyz(cl->name, Cmd_Argv(2), sizeof(cl->namebuf));
i = cl - svs.clients;
@ -1021,6 +997,7 @@ void SV_CripplePlayer_f (void)
{
if (!cl->iscrippled)
{
SV_LogPlayer(cl, "crippled");
if (persist)
{
cl->iscrippled = 2;
@ -1034,6 +1011,7 @@ void SV_CripplePlayer_f (void)
}
else
{
SV_LogPlayer(cl, "uncrippled");
cl->iscrippled = false;
SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUARNTCRIPPLED);
}
@ -1054,6 +1032,7 @@ void SV_Mute_f (void)
{
if (!cl->ismuted)
{
SV_LogPlayer(cl, "muted");
if (persist)
{
cl->ismuted = 2;
@ -1067,6 +1046,7 @@ void SV_Mute_f (void)
}
else
{
SV_LogPlayer(cl, "unmuted");
cl->ismuted = false;
SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUARNTMUTED);
}
@ -1087,6 +1067,7 @@ void SV_Cuff_f (void)
{
if (!cl->iscuffed)
{
SV_LogPlayer(cl, "cuffed");
if (persist)
{
cl->iscuffed = 2;
@ -1100,6 +1081,7 @@ void SV_Cuff_f (void)
}
else
{
SV_LogPlayer(cl, "uncuffed");
cl->iscuffed = false;
SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUARNTCUFFED);
}
@ -1968,7 +1950,6 @@ void SV_InitOperatorCommands (void)
Cvar_Set(&sv_cheats, "1");
}
Cmd_AddCommand ("logfile", SV_Logfile_f);
Cmd_AddCommand ("fraglogfile", SV_Fraglogfile_f);
Cmd_AddCommand ("snap", SV_Snap_f);

View File

@ -1750,7 +1750,7 @@ void SV_WritePlayersToClient (client_t *client, edict_t *clent, qbyte *pvs, size
else if (client->spectator)
{
clst.health=100;
if (client->spec_track && ent == clent)
if (client->spec_track == j+1)
clst.spectator = 2;
else
clst.spectator = 1;

View File

@ -1231,7 +1231,7 @@ void SVC_GetChallenge (void)
if (sv_listen_qw.value || svs.gametype != GT_PROGS)
Netchan_OutOfBand(NS_SERVER, net_from, over-buf, buf);
if (sv_listen_dp.value)
if (sv_listen_dp.value && (sv_listen_nq.value || sv_bigcoords.value || !sv_listen_qw.value))
{
//dp (protocol6 upwards) can respond to this (and fte won't get confused because the challenge will be wrong)
buf = va("challenge "DISTRIBUTION"%i", svs.challenges[i].challenge);

View File

@ -326,6 +326,8 @@ void SV_New_f (void)
ClientReliableWrite_Byte (host_client, sv.edicts->v->sounds);
else
ClientReliableWrite_Byte (host_client, 0);
SV_LogPlayer(host_client, "new (QW)");
}
#define GAME_DEATHMATCH 0
#define GAME_COOP 1
@ -373,14 +375,17 @@ void SVNQ_New_f (void)
{
#ifdef NQPROT
case SCP_NETQUAKE:
SV_LogPlayer(host_client, "new (NQ)");
MSG_WriteLong (&host_client->netchan.message, NQ_PROTOCOL_VERSION);
MSG_WriteByte (&host_client->netchan.message, 16);
break;
case SCP_DARKPLACES6:
SV_LogPlayer(host_client, "new (DP6)");
MSG_WriteLong (&host_client->netchan.message, DP6_PROTOCOL_VERSION);
MSG_WriteByte (&host_client->netchan.message, sv.allocated_client_slots);
break;
case SCP_DARKPLACES7:
SV_LogPlayer(host_client, "new (DP7)");
MSG_WriteLong (&host_client->netchan.message, DP7_PROTOCOL_VERSION);
MSG_WriteByte (&host_client->netchan.message, sv.allocated_client_slots);
break;
@ -2725,6 +2730,8 @@ void SV_SetInfo_f (void)
}
}
SV_LogPlayer(host_client, "userinfo changed");
PR_ClientUserInfoChanged(Cmd_Argv(1), oldval, Info_ValueForKey(host_client->userinfo, Cmd_Argv(1)));
}
@ -2742,6 +2749,8 @@ void SV_ShowServerinfo_f (void)
void SV_NoSnap_f(void)
{
SV_LogPlayer(host_client, "refused snap");
if (*host_client->uploadfn) {
*host_client->uploadfn = 0;
SV_BroadcastTPrintf (PRINT_HIGH, STL_SNAPREFUSED, host_client->name);
@ -2930,6 +2939,7 @@ void Cmd_Notarget_f (void)
return;
}
SV_LogPlayer(host_client, "notarget cheat");
if ((int) (sv_player->v->flags = (int) sv_player->v->flags ^ FL_NOTARGET) & FL_NOTARGET)
SV_ClientPrintf (host_client, PRINT_HIGH, "notarget ON\n");
else
@ -2945,6 +2955,7 @@ void Cmd_God_f (void)
return;
}
SV_LogPlayer(host_client, "god cheat");
if ((int) (sv_player->v->flags = (int) sv_player->v->flags ^ FL_GODMODE) & FL_GODMODE)
SV_ClientPrintf (host_client, PRINT_HIGH, "godmode ON\n");
else
@ -2966,6 +2977,7 @@ void Cmd_Give_f (void)
t = Cmd_Argv(1);
v = atoi (Cmd_Argv(2));
SV_LogPlayer(host_client, "give cheat");
if (strlen(t) == 1 && (Cmd_Argc() == 3 || (*t>='0' && *t <= '9')))
{
switch (t[0])
@ -3017,6 +3029,7 @@ void Cmd_Noclip_f (void)
return;
}
SV_LogPlayer(host_client, "noclip cheat");
if (sv_player->v->movetype != MOVETYPE_NOCLIP)
{
sv_player->v->movetype = MOVETYPE_NOCLIP;
@ -3042,6 +3055,7 @@ void Cmd_Fly_f (void)
return;
}
SV_LogPlayer(host_client, "fly cheat");
if (sv_player->v->movetype != MOVETYPE_FLY)
{
sv_player->v->movetype = MOVETYPE_FLY;
@ -3077,6 +3091,7 @@ void Cmd_SetPos_f(void)
Con_Printf ("setpos %i %i %i\n", (int)sv_player->v->origin[0], (int)sv_player->v->origin[1], (int)sv_player->v->origin[2]);
return;
}
SV_LogPlayer(host_client, "setpos cheat");
if (sv_player->v->movetype != MOVETYPE_NOCLIP)
{
sv_player->v->movetype = MOVETYPE_NOCLIP;
@ -3201,6 +3216,8 @@ void Cmd_Join_f (void)
// send notification to all clients
host_client->sendinfo = true;
SV_LogPlayer(host_client, "joined");
}
@ -3286,6 +3303,8 @@ void Cmd_Observe_f (void)
// send notification to all clients
host_client->sendinfo = true;
SV_LogPlayer(host_client, "observing");
}
void Cmd_FPSList_f(void)