Esempio n. 1
0
File: save.c Progetto: jdolan/q2pro
static int write_level_file(void)
{
    char        name[MAX_OSPATH];
    int         i;
    char        *s;
    size_t      len;
    byte        portalbits[MAX_MAP_PORTAL_BYTES];
    qerror_t    ret;

    // write magic
    MSG_WriteLong(SAVE_MAGIC2);
    MSG_WriteLong(SAVE_VERSION);

    // write configstrings
    for (i = 0; i < MAX_CONFIGSTRINGS; i++) {
        s = sv.configstrings[i];
        if (!s[0])
            continue;

        len = strlen(s);
        if (len > MAX_QPATH)
            len = MAX_QPATH;

        MSG_WriteShort(i);
        MSG_WriteData(s, len);
        MSG_WriteByte(0);
    }
    MSG_WriteShort(MAX_CONFIGSTRINGS);

    len = CM_WritePortalBits(&sv.cm, portalbits);
    MSG_WriteByte(len);
    MSG_WriteData(portalbits, len);

    len = Q_snprintf(name, MAX_QPATH, "save/" SAVE_CURRENT "/%s.sv2", sv.name);
    if (len >= MAX_QPATH)
        ret = -1;
    else
        ret = FS_WriteFile(name, msg_write.data, msg_write.cursize);

    SZ_Clear(&msg_write);

    if (ret < 0)
        return -1;

    // write game level
    len = Q_snprintf(name, MAX_OSPATH,
                     "%s/save/" SAVE_CURRENT "/%s.sav", fs_gamedir, sv.name);
    if (len >= MAX_OSPATH)
        return -1;

    ge->WriteLevel(name);
    return 0;
}
Esempio n. 2
0
/*
================
rvDebuggerClient::InspectVariable

Instructs the client to inspect the given variable at the given callstack depth.  The
variable is inspected by sending a DBMSG_INSPECTVARIABLE message to the server which
will in turn respond back to the client with the variable value
================
*/
void rvDebuggerClient::InspectVariable ( const char* name, int callstackDepth )
{
	msg_t	 msg;
	byte	 buffer[MAX_MSGLEN];
	
	MSG_Init( &msg, buffer, sizeof( buffer ) );
	MSG_WriteShort ( &msg, (int)DBMSG_INSPECTVARIABLE );
	MSG_WriteShort ( &msg, (short)(mCallstack.Num()-callstackDepth) );
	MSG_WriteString ( &msg, name );
	
	SendPacket ( msg.data, msg.cursize );
}
Esempio n. 3
0
void GTH_SendMessageRequestItemSyncItem()
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage,	EXTEND_SECOND);
		MSG_WriteShort(&netMessage, ITEM_EXTEND_SYSTEM);
		MSG_WriteShort(&netMessage,	REQUEST_ITEM_SYNC_TIME);
		NET_SendMessage(&gsSocket, &netMessage);
	}
	MSG_EndWriting(&netMessage);	
}
Esempio n. 4
0
/*
=================
Netchan_TransmitNextFragment

Send one fragment of the current message
=================
*/
void Netchan_TransmitNextFragment( netchan_t *chan )
{
	msg_t send;
	byte  send_buf[ MAX_PACKETLEN ];
	int   fragmentLength;

	// write the packet header
	MSG_InitOOB( &send, send_buf, sizeof( send_buf ) );   // <-- only do the oob here

	MSG_WriteLong( &send, chan->outgoingSequence | FRAGMENT_BIT );

	// send the qport if we are a client
	if ( chan->sock == NS_CLIENT )
	{
		MSG_WriteShort( &send, qport->integer );
	}

	// copy the reliable message to the packet first
	fragmentLength = FRAGMENT_SIZE;

	if ( chan->unsentFragmentStart  + fragmentLength > chan->unsentLength )
	{
		fragmentLength = chan->unsentLength - chan->unsentFragmentStart;
	}

	MSG_WriteShort( &send, chan->unsentFragmentStart );
	MSG_WriteShort( &send, fragmentLength );
	MSG_WriteData( &send, chan->unsentBuffer + chan->unsentFragmentStart, fragmentLength );

	// send the datagram
	NET_SendPacket( chan->sock, send.cursize, send.data, chan->remoteAddress );

	if ( showpackets->integer )
	{
		Com_Printf( "%s send %4i : s=%i fragment=%i,%i\n"
		            , netsrcString[ chan->sock ]
		            , send.cursize
		            , chan->outgoingSequence
		            , chan->unsentFragmentStart, fragmentLength );
	}

	chan->unsentFragmentStart += fragmentLength;

	// this exit condition is a little tricky, because a packet
	// that is exactly the fragment length still needs to send
	// a second packet of zero length so that the other side
	// can tell there aren't more to follow
	if ( chan->unsentFragmentStart == chan->unsentLength && fragmentLength != FRAGMENT_SIZE )
	{
		chan->outgoingSequence++;
		chan->unsentFragments = qfalse;
	}
}
Esempio n. 5
0
void CHelperManager_Encoder::SendMessage_Helper_StackOpen(playerCharacter_t* pHelper)
{
		MSG_BeginWriting(&netMessage);
		MSG_Clear( &netMessage );
		{
			MSG_WriteByte(&netMessage, EXTEND_SECOND);
			MSG_WriteShort ( &netMessage, HELPER_SYSTEM );
			MSG_WriteShort(&netMessage, SC_STACK_OPEN_Req_toPlayer);
			NET_SendMessage(&pHelper->sock, &netMessage);
		}
		MSG_EndWriting(&netMessage);
}
Esempio n. 6
0
void CGs_To_Cc::Send(playerCharacter_t* pPlayer,int SystemType,int mainType, int subType)
{
	MSG_BeginWriting( &netMessage );
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);
		MSG_WriteShort(&netMessage, SystemType);
		MSG_WriteShort(&netMessage, mainType);		
		MSG_WriteShort(&netMessage, subType);		
		NET_SendMessage(&pPlayer->sock, &netMessage);
	}
	MSG_EndWriting(&netMessage);
}
Esempio n. 7
0
void CHelperManager_Encoder::SendMessage_Helper_Helppoint(playerCharacter_t* pHelper)
{
		MSG_BeginWriting(&netMessage);
		MSG_Clear( &netMessage );
		{
			MSG_WriteByte(&netMessage, EXTEND_SECOND);
			MSG_WriteShort ( &netMessage, HELPER_SYSTEM );
			MSG_WriteShort(&netMessage, SC_CONFIRM_HELPPOINT_Res_toPlayer);
			MSG_WriteLong(&netMessage, pHelper->tHelper.tPoint.iHelpPoint);	
			NET_SendMessage(&pHelper->sock, &netMessage);
		}
		MSG_EndWriting(&netMessage);
}
Esempio n. 8
0
void CGMCtrl::TransmitePacket_cs_request_AUTHstate(void)
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);
		MSG_WriteShort(&netMessage, GMsystem);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::GMsystem_NProtect);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::tagNProtect::cs_request_AUTHstate);		
		NET_SendMessage(&gsSocket, &netMessage);
	}
	MSG_EndWriting( &netMessage );
}
Esempio n. 9
0
//
// SV_UpdateMasterServer
//
void SV_UpdateMasterServer(masterserver &m)
{
		SZ_Clear(&ml_message);
		MSG_WriteLong(&ml_message, CHALLENGE);

		// send out actual port, because NAT may present an incorrect port to the master
		if(natport)
			MSG_WriteShort(&ml_message, natport);
		else
			MSG_WriteShort(&ml_message, port);

		NET_SendPacket(ml_message, m.masteraddr);
}
Esempio n. 10
0
void CGMCtrl::TransmitePacket_cs_request_AUTH_dll_change(const char* in_strDLLFileName)
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);
		MSG_WriteShort(&netMessage, GMsystem);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::GMsystem_NProtect);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::tagNProtect::cs_request_AUTH_dll_change);
		MSG_WriteString(&netMessage,(char*)in_strDLLFileName);		
		NET_SendMessage(&gsSocket, &netMessage);
	}
	MSG_EndWriting( &netMessage );
}
Esempio n. 11
0
// 2000-05-02 NVS SVC by Maddes
void NVS_WriteShort (int dest, int c, sizebuf_t *sb)
{
	int	i;

	switch (dest)
	{
	case MSG_INIT:
		if (sv.nvs_msgsignon->conversion_tab[sv.nvs_msgserver->numwrites-sv.nvs_msgwrites])
		{
			if (sb)				// special signon
			{
				MSG_WriteShort (sb, c);
			}
			else
			{
				MSG_WriteShort (&sv.signon, c);
			}
		}
		break;

	case MSG_ONE:
	case MSG_ALL:
	case MSG_BROADCAST:
		for (i=0 ; i<svs.maxclients ; i++)
		{
			if (NVS_CheckClient(&svs.clients[i]))
			{
				if (dest == MSG_BROADCAST)	// unreliable
				{
					MSG_WriteShort (&svs.clients[i].datagram, c);
				}
				else if (dest == MSG_ONE && sb)	// special reliable MSG_ONE
				{
					MSG_WriteShort (sb, c);
				}
				else				// reliable MSG_ONE, MSG_ALL
				{
					MSG_WriteShort (&svs.clients[i].message, c);
				}
			}
		}
		break;

	default:
		Host_Error ("NVS_WriteShort: bad destination");
		break;
	}

	NVS_CheckCounter();
}
Esempio n. 12
0
void CGMCtrl::TransmitePacket_NProtect_sc_response_AUTH(playerCharacter_t* pPlayer) const
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);		
		MSG_WriteShort(&netMessage, GMsystem);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::GMsystem_NProtect);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::tagNProtect::sc_response_AUTH);
		MSG_WriteLong(&netMessage,  m_cpServerStateDataCtrl->isNProtectAUTH());
		NET_SendMessage( &(pPlayer->sock), &netMessage );
	}
	MSG_EndWriting(&netMessage);
}
Esempio n. 13
0
void CHelperManager_Encoder::SendMessage_Invite_Respond_toTaker( 
	playerCharacter_t* pTaker,int errorCode)
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);
		MSG_WriteShort(&netMessage, HELPER_SYSTEM);
		MSG_WriteShort(&netMessage, SC_INVITE_Res_toTAKER);
		MSG_WriteShort(&netMessage, errorCode);
		NET_SendMessage(&pTaker->sock, &netMessage);
	}
	MSG_EndWriting(&netMessage);
}
Esempio n. 14
0
void GTH_SendMessage_GambleSystem_Active(BOOL bActive)
{	
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage,	 EXTEND_SECOND);
		MSG_WriteShort(&netMessage,  GAMBLE_SYSTEM );		
		MSG_WriteShort(&netMessage,  ACTIVE_SYSTEM_REQUEST );
		MSG_WriteLong(&netMessage,   bActive);
		
		NET_SendMessage(&gsSocket, &netMessage); 
	}
	MSG_EndWriting( &netMessage );
}
Esempio n. 15
0
void SV_FullClientUpdate (client_t *client, sizebuf_t *buf)
{
	int		i;
	char	info[MAX_INFO_STRING];

//	Con_Printf("%s\n", __thisfunc__);
	i = client - svs.clients;

//	Sys_Printf("%s:  Updated frags for client %d\n", __thisfunc__, i);

	MSG_WriteByte (buf, svc_updatedminfo);
	MSG_WriteByte (buf, i);
	MSG_WriteShort (buf, client->old_frags);
	MSG_WriteByte (buf, (client->playerclass<<5)|((int)client->edict->v.level&31));

	if (dmMode.integer == DM_SIEGE)
	{
		MSG_WriteByte (buf, svc_updatesiegeinfo);
		MSG_WriteByte (buf, (int)ceil(timelimit.value));
		MSG_WriteByte (buf, (int)ceil(fraglimit.value));

		MSG_WriteByte (buf, svc_updatesiegeteam);
		MSG_WriteByte (buf, i);
		MSG_WriteByte (buf, client->siege_team);

		MSG_WriteByte (buf, svc_updatesiegelosses);
		MSG_WriteByte (buf, PR_GLOBAL_STRUCT(defLosses));
		MSG_WriteByte (buf, PR_GLOBAL_STRUCT(attLosses));

		MSG_WriteByte (buf, svc_time);//send server time upon connection
		MSG_WriteFloat (buf, sv.time);
	}

	MSG_WriteByte (buf, svc_updateping);
	MSG_WriteByte (buf, i);
	MSG_WriteShort (buf, SV_CalcPing (client));

	MSG_WriteByte (buf, svc_updateentertime);
	MSG_WriteByte (buf, i);
	MSG_WriteFloat (buf, realtime - client->connection_started);

	strcpy (info, client->userinfo);
	Info_RemovePrefixedKeys (info, '_');	// server passwords, etc

	MSG_WriteByte (buf, svc_updateuserinfo);
	MSG_WriteByte (buf, i);
	MSG_WriteLong (buf, client->userid);
	MSG_WriteString (buf, info);
}
Esempio n. 16
0
void Server_MakeStatic(ServerEntity_t *ent)
{
	int	i,bits=0;

	if(ent->alpha == ENTALPHA_ZERO)
	{
		ED_Free(ent);
		return;
	}

	if(SV_ModelIndex(ent->v.model) & 0xFF00)
		bits |= B_LARGEMODEL;
	if((int)(ent->v.frame) & 0xFF00)
		bits |= B_LARGEFRAME;
	if(ent->alpha != ENTALPHA_DEFAULT)
		bits |= B_ALPHA;

	if(bits)
	{
		MSG_WriteByte(&sv.signon, SVC_SPAWNSTATIC2);
		MSG_WriteByte(&sv.signon, bits);
	}
	else
		MSG_WriteByte(&sv.signon, svc_spawnstatic);

	if(bits & B_LARGEMODEL)
		MSG_WriteShort(&sv.signon, SV_ModelIndex(ent->v.model));
	else
		MSG_WriteByte(&sv.signon, SV_ModelIndex(ent->v.model));

	if(bits & B_LARGEFRAME)
		MSG_WriteShort(&sv.signon,ent->v.frame);
	else
		MSG_WriteByte(&sv.signon,ent->v.frame);

	MSG_WriteByte(&sv.signon,ent->Model.fScale);
	MSG_WriteByte(&sv.signon,ent->v.colormap);
	MSG_WriteByte(&sv.signon,ent->Model.iSkin);
	for (i=0 ; i<3 ; i++)
	{
		MSG_WriteCoord(&sv.signon, ent->v.origin[i]);
		MSG_WriteAngle(&sv.signon, ent->v.angles[i]);
	}

	if (bits & B_ALPHA)
		MSG_WriteByte (&sv.signon, ent->alpha);

	ED_Free (ent);
}
Esempio n. 17
0
void CHelperManager::MemberList_Request_Update_OtherServer ( playerCharacter_t* pHelper, int fstate )
{
	MSG_BeginWriting ( &netMessage );
	MSG_Clear( &netMessage );
	{

		MSG_WriteByte(&netMessage, EXTEND_SECOND);
		MSG_WriteShort ( &netMessage, HELPER_SYSTEM );
		MSG_WriteShort ( &netMessage, SS_REQUEST_UPDATE_MemberList_toServer);
		MSG_WriteString ( &netMessage, pHelper->name );
		MSG_WriteByte ( &netMessage, fstate );
		NET_SendUnreliableMessage ( &localSocket, &netMessage );
	}
	MSG_EndWriting(&netMessage);
}
Esempio n. 18
0
inline void CGMCtrl::TransmitePacket_NProtect_gsms_request_change(const BOOL in_bEnable) const
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);		
		MSG_WriteShort(&netMessage, GMsystem);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::GMsystem_NProtect);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::tagNProtect::gsms_request_change);
		MSG_WriteLong(&netMessage,in_bEnable);
		NET_SendUnreliableMessage(&localSocket, &netMessage);		
	}
	MSG_EndWriting(&netMessage);

}
Esempio n. 19
0
void CGMCtrl::TransmitePacket_NProtect_sc_response_AUTH_dll_change(playerCharacter_t* in_pPlayer,const BOOL in_bSuccess,const char* in_strDLLname)
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);		
		MSG_WriteShort(&netMessage, GMsystem);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::GMsystem_NProtect);
		MSG_WriteShort(&netMessage, tagExtendSecondPacket_GMsystem::tagNProtect::sc_response_AUTH_dll_change);
		MSG_WriteLong(&netMessage,in_bSuccess);
		MSG_WriteString(&netMessage,(char*)in_strDLLname);
		NET_SendMessage( &(in_pPlayer->sock), &netMessage );
	}
	MSG_EndWriting(&netMessage);
}
Esempio n. 20
0
void CWeatherSystem::GTH_SendUserNotice(char *notice)
{
	MSG_BeginWriting( &netMessage );
	
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);
		MSG_WriteShort(&netMessage, WEATHER_SYSTEM );		
		MSG_WriteShort(&netMessage, CC_WEATHER_SYSTEM );		
		MSG_WriteByte(&netMessage, CC_WEATHER_SYSTEM_NOTICE);		
		MSG_WriteString(&netMessage, notice);
		NET_SendMessage(&gsSocket, &netMessage);
	}
	MSG_EndWriting(&netMessage);		
}
Esempio n. 21
0
void CWeatherSystem::GTH_SendMessage_Request_WorldState(int worldidx)
{	
	MSG_BeginWriting( &netMessage );
	
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage, EXTEND_SECOND);
		MSG_WriteShort(&netMessage, WEATHER_SYSTEM );		
		MSG_WriteShort(&netMessage, CC_WEATHER_SYSTEM );
		MSG_WriteByte(&netMessage, CC_WEATHER_SYSTEM_REQUEST_WORLD_STATE);		
		MSG_WriteByte(&netMessage, worldidx);					
		NET_SendMessage(&gsSocket, &netMessage);
	}
	MSG_EndWriting(&netMessage);	
}
Esempio n. 22
0
void CHelperManager_Encoder::SendMessage_Helppoint_toHelper(
	playerCharacter_t* pc, char* pGiverName, int HelpPoint)
{
		MSG_BeginWriting(&netMessage);
		MSG_Clear( &netMessage );
		{
			MSG_WriteByte(&netMessage, EXTEND_SECOND);
			MSG_WriteShort ( &netMessage, HELPER_SYSTEM );
			MSG_WriteShort(&netMessage, SC_SENDHELPPOINT_toHelper);
			MSG_WriteString(&netMessage,pGiverName);
			MSG_WriteLong(&netMessage,HelpPoint);
			NET_SendMessage(&pc->sock, &netMessage);
		}
		MSG_EndWriting(&netMessage);
}
Esempio n. 23
0
void SV_CreateClientGameStateMessage( client_t *client, msg_t *msg ) {
	int			start;
	entityState_t	*base, nullstate;

	// NOTE, MRE: all server->client messages now acknowledge
	// let the client know which reliable clientCommands we have received
	MSG_WriteLong( msg, client->lastClientCommand );

	// send any server commands waiting to be sent first.
	// we have to do this cause we send the client->reliableSequence
	// with a gamestate and it sets the clc.serverCommandSequence at
	// the client side
	SV_UpdateServerCommandsToClient( client, msg );

	// send the gamestate
	MSG_WriteByte( msg, svc_gamestate );
	MSG_WriteLong( msg, client->reliableSequence );

	// write the configstrings
	for ( start = 0 ; start < MAX_CONFIGSTRINGS ; start++ ) {
		if (sv.configstrings[start][0]) {
			MSG_WriteByte( msg, svc_configstring );
			MSG_WriteShort( msg, start );
			MSG_WriteBigString( msg, sv.configstrings[start] );
		}
	}

	// write the baselines
	Com_Memset( &nullstate, 0, sizeof( nullstate ) );
	for ( start = 0 ; start < MAX_GENTITIES; start++ ) {
		base = &sv.svEntities[start].baseline;
		if ( !base->number ) {
			continue;
		}
		MSG_WriteByte( msg, svc_baseline );
		MSG_WriteDeltaEntity( msg, &nullstate, base, qtrue );
	}

	MSG_WriteByte( msg, svc_EOF );

	MSG_WriteLong( msg, client - svs.clients);

	// write the checksum feed
	MSG_WriteLong( msg, sv.checksumFeed);

	// For old RMG system.
	MSG_WriteShort ( msg, 0 );
}
Esempio n. 24
0
/*
================
SV_New_f

Sends the first message from the server to a connected client.
This will be sent on the initial connection and upon each server load.
================
*/
void SV_New_f(void)
{
    char * gamedir;
    int playernum;
    edict_t * ent;

    Com_DPrintf("New() from %s\n", sv_client->name);

    if (sv_client->state != cs_connected)
    {
        Com_Printf("New not valid -- already spawned\n");
        return;
    }

    // demo servers just dump the file message
    if (sv.state == ss_demo)
    {
        SV_BeginDemoserver();
        return;
    }

    //
    // serverdata needs to go over for all types of servers
    // to make sure the protocol is right, and to set the gamedir
    //
    gamedir = Cvar_VariableString("gamedir");

    // send the serverdata
    MSG_WriteByte(&sv_client->netchan.message, svc_serverdata);
    MSG_WriteLong(&sv_client->netchan.message, PROTOCOL_VERSION);
    MSG_WriteLong(&sv_client->netchan.message, svs.spawncount);
    MSG_WriteByte(&sv_client->netchan.message, sv.attractloop);
    MSG_WriteString(&sv_client->netchan.message, gamedir);

    if (sv.state == ss_cinematic || sv.state == ss_pic)
        playernum = -1;
    else
        playernum = sv_client - svs.clients;

    MSG_WriteShort(&sv_client->netchan.message, playernum);

    // send full levelname
    MSG_WriteString(&sv_client->netchan.message, sv.configstrings[CS_NAME]);

    //
    // game server
    //
    if (sv.state == ss_game)
    {
        // set up the entity for the client
        ent = EDICT_NUM(playernum + 1);
        ent->s.number = playernum + 1;
        sv_client->edict = ent;
        memset(&sv_client->lastcmd, 0, sizeof(sv_client->lastcmd));

        // begin fetching configstrings
        MSG_WriteByte(&sv_client->netchan.message, svc_stufftext);
        MSG_WriteString(&sv_client->netchan.message, va("cmd configstrings %i 0\n", svs.spawncount));
    }
}
Esempio n. 25
0
/*
==================
SV_NextDownload_f
==================
*/
static void SV_NextDownload_f (void)
{
	byte	buffer[1024];
	int		r;
	int		percent;
	int		size;

	if (!host_client->download)
		return;

	r = host_client->downloadsize - host_client->downloadcount;
	if (r > 1024)
		r = 1024;
	r = fread (buffer, 1, r, host_client->download);
	MSG_WriteByte (&host_client->netchan.message, svc_download);
	MSG_WriteShort (&host_client->netchan.message, r);

	host_client->downloadcount += r;
	size = host_client->downloadsize;
	if (!size)
		size = 1;
	percent = host_client->downloadcount*100/size;
	MSG_WriteByte (&host_client->netchan.message, percent);
	SZ_Write (&host_client->netchan.message, buffer, r);

	if (host_client->downloadcount != host_client->downloadsize)
		return;

	fclose (host_client->download);
	host_client->download = NULL;
}
Esempio n. 26
0
void Game_AmbientSound(MathVectorf_t *vPosition,const char *cPath,int iVolume,int iAttenuation)
{
	char		**cCheck;
	int			i,iSoundNumber;
	bool		bLarge = false;

	for(iSoundNumber = 0,cCheck = sv.sound_precache; *cCheck; cCheck++,iSoundNumber++)
		if(!strcmp(*cCheck,cPath))
			break;

	if(!*cCheck)
		Console_ErrorMessage(false,(char*)cPath,"Sound was not registered.");

	if(iSoundNumber > 255)
		bLarge = true;

	if(bLarge)
		MSG_WriteByte(&sv.signon,svc_spawnstaticsound2);
	else
		MSG_WriteByte(&sv.signon,svc_spawnstaticsound);

	for(i = 0; i < 3; i++)
		MSG_WriteCoord(&sv.signon,vPosition[i]);

	if(bLarge)
		MSG_WriteShort(&sv.signon,iSoundNumber);
	else
		MSG_WriteByte(&sv.signon,iSoundNumber);

	MSG_WriteByte(&sv.signon,iVolume);
	MSG_WriteByte(&sv.signon,iAttenuation*64);
}
Esempio n. 27
0
void	GTH_SendMessageRequestItemTimeSet(const enum sItemUseTimeInfo::enumInventoryType type, int iItemIdx, int iinvenIdx)
{
	MSG_BeginWriting(&netMessage);
	MSG_Clear( &netMessage );
	{
		MSG_WriteByte(&netMessage,	EXTEND_SECOND);
		MSG_WriteShort(&netMessage, ITEM_EXTEND_SYSTEM);
		MSG_WriteShort(&netMessage,	REQUEST_ITEM_TIME_SET);	
		
		MSG_WriteLong(&netMessage,	(int)type);
		MSG_WriteLong(&netMessage,	iItemIdx);
		MSG_WriteLong(&netMessage,	iinvenIdx);		
		NET_SendMessage(&gsSocket, &netMessage);
	}
	MSG_EndWriting(&netMessage);	
}
Esempio n. 28
0
/*
==================
SV_NextDownload_f
==================
*/
void SV_NextDownload_f(void){
	int	percent, size, r;

	if(!sv_client->download)
		return;

	r = sv_client->downloadsize - sv_client->downloadcount;
	if(r > 1024)
		r = 1024;

	MSG_WriteByte(&sv_client->netchan.message, svc_download);
	MSG_WriteShort(&sv_client->netchan.message, r);

	sv_client->downloadcount += r;
	size = sv_client->downloadsize;
	if(!size)
		size = 1;
	percent = sv_client->downloadcount * 100 / size;
	MSG_WriteByte(&sv_client->netchan.message, percent);
	SZ_Write(&sv_client->netchan.message,
			  sv_client->download + sv_client->downloadcount - r, r);

	if(sv_client->downloadcount != sv_client->downloadsize)
		return;

	FS_FreeFile(sv_client->download);
	sv_client->download = NULL;
}
Esempio n. 29
0
/*
================
SV_FindIndex

================
*/
int SV_FindIndex (char *name, int start, int max, qboolean create)
{
	int		i;
	
	if (!name || !name[0])
		return 0;

	for (i=1 ; i<max && sv.configstrings[start+i][0] ; i++)
		if (!strcmp(sv.configstrings[start+i], name))
			return i;

	if (!create)
		return 0;

	if (i == max)
		Com_Error (ERR_DROP, "*Index: overflow");

	strncpy (sv.configstrings[start+i], name, sizeof(sv.configstrings[i]));

	if (sv.state != ss_loading)
	{	// send the update to everyone
		SZ_Clear (&sv.multicast);
		MSG_WriteChar (&sv.multicast, svc_configstring);
		MSG_WriteShort (&sv.multicast, start+i);
		MSG_WriteString (&sv.multicast, name);
		SV_Multicast (vec3_origin, MULTICAST_ALL_R);
	}

	return i;
}
Esempio n. 30
0
/*
=====================
SV_DropClient

Called when the player is getting totally kicked off the host
if (crash = true), don't bother sending signofs
=====================
*/
void SV_DropClient (bool crash)
{
	int		saveSelf;
	int		i;
	client_t *client;

	if (!host_client->active)
		return;

	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);
	}

	/*if (host_client->netconnection->proquake_connection == MOD_QSMACK)
		qsmackActive = false;*/

// 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);
	}
}