common/host.c:

put Host_GetConsoleCommands back
uquake/server.h:
	proto for SV_Frame
uquake/sv_main.c
	add SV_ClientPrintf SV_BroadcastPrintf SV_DropClient SV_Frame* from
	old host.c
This commit is contained in:
Bill Currie 2000-02-10 09:03:30 +00:00
parent 74e0de143a
commit 866f2514d0
3 changed files with 209 additions and 0 deletions

View File

@ -152,6 +152,25 @@ Host_EndGame ( char *message, ... )
#endif
}
/*
===================
Host_GetConsoleCommands
Add them exactly as if they had been typed at the console
===================
*/
void Host_GetConsoleCommands (void)
{
char *cmd;
while (1)
{
cmd = Sys_ConsoleInput ();
if (!cmd)
break;
Cbuf_AddText (cmd);
}
}
/*
Host_FilterTime
@ -190,6 +209,7 @@ Host_FilterTime ( float time )
return true;
}
/*
#ifdef QUAKEWORLD
int nopacketcount; // for Host_FrameMain

View File

@ -262,5 +262,6 @@ void SV_SpawnServer (char *server, char *startspot);
#else
void SV_SpawnServer (char *server);
#endif
void SV_Frame (void);
#endif // _SERVER_H

View File

@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <mathlib.h>
#include <net.h>
#include <cmd.h>
#include <keys.h>
server_t sv;
server_static_t svs;
@ -1208,3 +1209,190 @@ void SV_SpawnServer (char *server)
Con_DPrintf ("Server spawned.\n");
}
/*
=================
SV_ClientPrintf
Sends text across to be displayed
FIXME: make this just a stuffed echo?
=================
*/
void SV_ClientPrintf (char *fmt, ...)
{
va_list argptr;
char string[1024];
va_start (argptr, fmt);
vsnprintf (string, sizeof(string), fmt, argptr);
va_end (argptr);
MSG_WriteByte (&host_client->message, svc_print);
MSG_WriteString (&host_client->message, string);
}
/*
=================
SV_BroadcastPrintf
Sends text to all active clients
=================
*/
void SV_BroadcastPrintf (char *fmt, ...)
{
va_list argptr;
char string[1024];
int i;
va_start (argptr, fmt);
vsnprintf (string, sizeof(string), fmt, argptr);
va_end (argptr);
for (i=0 ; i<svs.maxclients ; i++)
if (svs.clients[i].active && svs.clients[i].spawned)
{
MSG_WriteByte (&svs.clients[i].message, svc_print);
MSG_WriteString (&svs.clients[i].message, string);
}
}
/*
=====================
SV_DropClient
Called when the player is getting totally kicked off the host
if (crash = true), don't bother sending signofs
=====================
*/
void SV_DropClient (qboolean crash)
{
int saveSelf;
int i;
client_t *client;
if (!crash)
{
// send any final messages (don't check for errors)
if (NET_CanSendMessage (host_client->netconnection))
{
MSG_WriteByte (&host_client->message, svc_disconnect);
NET_SendMessage (host_client->netconnection, &host_client->message);
}
if (host_client->edict && host_client->spawned)
{
// call the prog function for removing a client
// this will set the body to a dead frame, among other things
saveSelf = pr_global_struct->self;
pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
PR_ExecuteProgram (pr_global_struct->ClientDisconnect);
pr_global_struct->self = saveSelf;
}
Sys_Printf ("Client %s removed\n",host_client->name);
}
// break the net connection
NET_Close (host_client->netconnection);
host_client->netconnection = NULL;
// free the client (the body stays around)
host_client->active = false;
host_client->name[0] = 0;
host_client->old_frags = -999999;
net_activeconnections--;
// send notification to all clients
for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
{
if (!client->active)
continue;
MSG_WriteByte (&client->message, svc_updatename);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteString (&client->message, "");
MSG_WriteByte (&client->message, svc_updatefrags);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteShort (&client->message, 0);
MSG_WriteByte (&client->message, svc_updatecolors);
MSG_WriteByte (&client->message, host_client - svs.clients);
MSG_WriteByte (&client->message, 0);
}
}
/*
==================
Host_ServerFrame
==================
*/
#ifdef FPS_20
void SV_FrameMain (void)
{
// run the world state
pr_global_struct->frametime = host_frametime;
// read client messages
SV_RunClients ();
// move things around and think
// always pause in single player if in console or menus
if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) )
SV_Physics ();
}
void SV_Frame (void)
{
float save_host_frametime;
float temp_host_frametime;
// run the world state
pr_global_struct->frametime = host_frametime;
// set the time and clear the general datagram
SV_ClearDatagram ();
// check for new clients
SV_CheckForNewClients ();
temp_host_frametime = save_host_frametime = host_frametime;
while(temp_host_frametime > (1.0/72.0))
{
if (temp_host_frametime > 0.05)
host_frametime = 0.05;
else
host_frametime = temp_host_frametime;
temp_host_frametime -= host_frametime;
SV_FrameMain ();
}
host_frametime = save_host_frametime;
// send all messages to the clients
SV_SendClientMessages ();
}
#else
void SV_Frame (void)
{
// run the world state
pr_global_struct->frametime = host_frametime;
// set the time and clear the general datagram
SV_ClearDatagram ();
// check for new clients
SV_CheckForNewClients ();
// read client messages
SV_RunClients ();
// move things around and think
// always pause in single player if in console or menus
if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) )
SV_Physics ();
// send all messages to the clients
SV_SendClientMessages ();
}
#endif