コード例 #1
0
ファイル: sv_chat.c プロジェクト: ProfessorKaos64/ftequake
void SV_EndChat(void)
{
	host_client->chat.active = false;
	host_client->chat.time=0;

	ClientReliableWrite_Begin (host_client, svc_centerprint, 2);
	ClientReliableWrite_String (host_client, "");
/*
	MSG_WriteByte(&sv.reliable_datagram, svc_chat);
	MSG_WriteString(&sv.reliable_datagram, "");
*/
}
コード例 #2
0
ファイル: sv_ccmds.c プロジェクト: flwh/Alcatel_OT_985_kernel
void SV_Snap (int uid)
{
	client_t *cl;
	char		pcxname[80]; 
	char		checkname[MAX_OSPATH];
	int			i;

	for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++)
	{
		if (!cl->state)
			continue;
		if (cl->userid == uid)
			break;
	}
	if (i >= MAX_CLIENTS) {
		Con_Printf ("userid not found\n");
		return;
	}

	sprintf(pcxname, "%d-00.pcx", uid);

	sprintf(checkname, "%s/snap", gamedirfile);
	Sys_mkdir(gamedirfile);
	Sys_mkdir(checkname);
		
	for (i=0 ; i<=99 ; i++) 
	{ 
		pcxname[strlen(pcxname) - 6] = i/10 + '0'; 
		pcxname[strlen(pcxname) - 5] = i%10 + '0'; 
		sprintf (checkname, "%s/snap/%s", gamedirfile, pcxname);
		if (Sys_FileTime(checkname) == -1)
			break;	// file doesn't exist
	} 
	if (i==100) 
	{
		Con_Printf ("Snap: Couldn't create a file, clean some out.\n"); 
		return;
	}
	strcpy(cl->uploadfn, checkname);

	memcpy(&cl->snap_from, &net_from, sizeof(net_from));
	if (sv_redirected != RD_NONE)
		cl->remote_snap = true;
	else
		cl->remote_snap = false;

	ClientReliableWrite_Begin (cl, svc_stufftext, 24);
	ClientReliableWrite_String (cl, "cmd snap");
	Con_Printf ("Requesting snap from user %d...\n", uid);
}
コード例 #3
0
ファイル: sv_chat.c プロジェクト: ProfessorKaos64/ftequake
void SV_SendChat(void)
{
	int l;
	int i;
	char *s, *s2, *text;

	l = 2 + strlen(host_client->chat.maintext)+2;
	for (i = 0; i < host_client->chat.options; i++)
		l += strlen(host_client->chat.option[i].text)+2;

	s = Z_Malloc(l+1);
	s2 = s;
	text = host_client->chat.maintext;
	while(*text)
	{
		*s2 = *text ^ 128;
		text++;
		s2++;
	}
	*s2++='\n';
	*s2++='\n';
	*s2='\0';
	for (i = 0; i < host_client->chat.options; i++)
	{
		strcat(s2, host_client->chat.option[i].text);
		strcat(s2, "\n\n");
	}


	ClientReliableWrite_Begin (host_client, svc_centerprint, 2 + l);
	ClientReliableWrite_String (host_client, s);

/*
	MSG_WriteByte(&sv.reliable_datagram, svc_chat);
	if (!*host_client->chat.maintext)	//no text. don't mix with ends
		MSG_WriteString(&sv.reliable_datagram, " ");
	else
		MSG_WriteString(&sv.reliable_datagram, host_client->chat.maintext);

	MSG_WriteByte(&sv.reliable_datagram, i);
	for (i = 0; i < host_client->chat.options; i++)
		MSG_WriteString(&sv.reliable_datagram, host_client->chat.option[i].text);
*/

	host_client->chat.time = sv.time+SENDDELAY;
}
コード例 #4
0
ファイル: sv_ccmds.c プロジェクト: jogi1/camquake
void SV_Snap (int uid) {
	client_t *cl;
	char pcxname[80], checkname[MAX_OSPATH];
	int i;
	FILE *f;

	for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) {
		if (cl->state < cs_connected)
			continue;
		if (cl->userid == uid)
			break;
	}
	if (i >= MAX_CLIENTS) {
		Com_Printf ("userid not found\n");
		return;
	}

	FS_CreatePath (va("%s/snap/", com_gamedir));
	snprintf (pcxname, sizeof (pcxname), "%d-00.pcx", uid);
		
	for (i = 0; i <= 99; i++) { 
		pcxname[strlen(pcxname) - 6] = i / 10 + '0'; 
		pcxname[strlen(pcxname) - 5] = i % 10 + '0'; 
		snprintf (checkname, sizeof(checkname), "%s/snap/%s", com_gamedir, pcxname);
		if (!(f = fopen (checkname, "rb")))
			break;  // file doesn't exist
		fclose (f);
	} 
	if (i == 100) {
		Com_Printf ("Snap: Couldn't create a file, clean some out.\n"); 
		return;
	}
	strlcpy (cl->uploadfn, checkname, sizeof (cl->uploadfn));

	memcpy(&cl->snap_from, &net_from, sizeof(net_from));
	cl->remote_snap  =  (sv_redirected != RD_NONE);

	ClientReliableWrite_Begin (cl, svc_stufftext, 24);
	ClientReliableWrite_String (cl, "cmd snap\n");
	Com_Printf ("Requesting snap from user %d...\n", uid);
}
コード例 #5
0
ファイル: sv_user.c プロジェクト: flwh/Alcatel_OT_985_kernel
void SV_NextUpload (void)
{
	byte	buffer[1024];
	int		r;
	int		percent;
	int		size;
	client_t *client;

	if (!*host_client->uploadfn) {
		SV_ClientPrintf(host_client, PRINT_HIGH, "Upload denied\n");
		ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
		ClientReliableWrite_String (host_client, "stopul");

		// suck out rest of packet
		size = MSG_ReadShort ();	MSG_ReadByte ();
		msg_readcount += size;
		return;
	}

	size = MSG_ReadShort ();
	percent = MSG_ReadByte ();

	if (!host_client->upload)
	{
		host_client->upload = fopen(host_client->uploadfn, "wb");
		if (!host_client->upload) {
			Sys_Printf("Can't create %s\n", host_client->uploadfn);
			ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
			ClientReliableWrite_String (host_client, "stopul");
			*host_client->uploadfn = 0;
			return;
		}
		Sys_Printf("Receiving %s from %d...\n", host_client->uploadfn, host_client->userid);
		if (host_client->remote_snap)
			OutofBandPrintf(host_client->snap_from, "Server receiving %s from %d...\n", host_client->uploadfn, host_client->userid);
	}

	fwrite (net_message.data + msg_readcount, 1, size, host_client->upload);
	msg_readcount += size;

Con_DPrintf ("UPLOAD: %d received\n", size);

	if (percent != 100) {
		ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
		ClientReliableWrite_String (host_client, "nextul\n");
	} else {
		fclose (host_client->upload);
		host_client->upload = NULL;

		Sys_Printf("%s upload completed.\n", host_client->uploadfn);

		if (host_client->remote_snap) {
			char *p;

			if ((p = strchr(host_client->uploadfn, '/')) != NULL)
				p++;
			else
				p = host_client->uploadfn;
			OutofBandPrintf(host_client->snap_from, "%s upload completed.\nTo download, enter:\ndownload %s\n", 
				host_client->uploadfn, p);
		}
	}

}
コード例 #6
0
ファイル: sv_user.c プロジェクト: flwh/Alcatel_OT_985_kernel
void SV_Spawn_f (void)
{
	int		i;
	client_t	*client;
	edict_t	*ent;
	eval_t *val;
	int n;

	if (host_client->state != cs_connected)
	{
		Con_Printf ("Spawn not valid -- allready spawned\n");
		return;
	}

// handle the case of a level changing while a client was connecting
	if ( atoi(Cmd_Argv(1)) != svs.spawncount )
	{
		Con_Printf ("SV_Spawn_f from different level\n");
		SV_New_f ();
		return;
	}

	n = atoi(Cmd_Argv(2));

	// make sure n is valid
	if ( n < 0 || n > MAX_CLIENTS )
	{
		Con_Printf ("SV_Spawn_f invalid client start\n");
		SV_New_f ();
		return;
	}


	
// send all current names, colors, and frag counts
	// FIXME: is this a good thing?
	SZ_Clear (&host_client->netchan.message);

// send current status of all other players

	// normally this could overflow, but no need to check due to backbuf
	for (i=n, client = svs.clients + n ; i<MAX_CLIENTS ; i++, client++)
		SV_FullClientUpdateToClient (client, host_client);
	
// send all current light styles
	for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
	{
		ClientReliableWrite_Begin (host_client, svc_lightstyle, 
			3 + (sv.lightstyles[i] ? strlen(sv.lightstyles[i]) : 1));
		ClientReliableWrite_Byte (host_client, (char)i);
		ClientReliableWrite_String (host_client, sv.lightstyles[i]);
	}

	// set up the edict
	ent = host_client->edict;

	memset (&ent->v, 0, progs->entityfields * 4);
	ent->v.colormap = NUM_FOR_EDICT(ent);
	ent->v.team = 0;	// FIXME
	ent->v.netname = PR_SetString(host_client->name);

	host_client->entgravity = 1.0;
	val = GetEdictFieldValue(ent, "gravity");
	if (val)
		val->_float = 1.0;
	host_client->maxspeed = sv_maxspeed.value;
	val = GetEdictFieldValue(ent, "maxspeed");
	if (val)
		val->_float = sv_maxspeed.value;

//
// force stats to be updated
//
	memset (host_client->stats, 0, sizeof(host_client->stats));

	ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
	ClientReliableWrite_Byte (host_client, STAT_TOTALSECRETS);
	ClientReliableWrite_Long (host_client, pr_global_struct->total_secrets);

	ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
	ClientReliableWrite_Byte (host_client, STAT_TOTALMONSTERS);
	ClientReliableWrite_Long (host_client, pr_global_struct->total_monsters);

	ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
	ClientReliableWrite_Byte (host_client, STAT_SECRETS);
	ClientReliableWrite_Long (host_client, pr_global_struct->found_secrets);

	ClientReliableWrite_Begin (host_client, svc_updatestatlong, 6);
	ClientReliableWrite_Byte (host_client, STAT_MONSTERS);
	ClientReliableWrite_Long (host_client, pr_global_struct->killed_monsters);

	// get the client to check and download skins
	// when that is completed, a begin command will be issued
	ClientReliableWrite_Begin (host_client, svc_stufftext, 8);
	ClientReliableWrite_String (host_client, "skins\n" );

}