mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 11:35:05 +08:00
engine: global refactoring of connectionless packets, now they can be customized from single protocol.h header
This commit is contained in:
@@ -16,15 +16,6 @@ GNU General Public License for more details.
|
||||
#include "common.h"
|
||||
#include "server.h"
|
||||
|
||||
#define SOURCE_QUERY_DETAILS 'T'
|
||||
#define SOURCE_QUERY_DETAILS_RESPONSE 'I'
|
||||
|
||||
#define SOURCE_QUERY_RULES 'V'
|
||||
#define SOURCE_QUERY_RULES_RESPONSE 'E'
|
||||
|
||||
#define SOURCE_QUERY_PLAYERS 'U'
|
||||
#define SOURCE_QUERY_PLAYERS_RESPONSE 'D'
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_SourceQuery_Details
|
||||
@@ -41,7 +32,8 @@ static void SV_SourceQuery_Details( netadr_t from )
|
||||
|
||||
MSG_Init( &buf, "TSourceEngineQuery", answer, sizeof( answer ));
|
||||
|
||||
MSG_WriteByte( &buf, SOURCE_QUERY_DETAILS_RESPONSE );
|
||||
MSG_WriteDword( &buf, 0xFFFFFFFFU );
|
||||
MSG_WriteByte( &buf, S2A_GOLDSRC_INFO );
|
||||
MSG_WriteByte( &buf, PROTOCOL_VERSION );
|
||||
|
||||
MSG_WriteString( &buf, hostname.string );
|
||||
@@ -69,7 +61,7 @@ static void SV_SourceQuery_Details( netadr_t from )
|
||||
MSG_WriteByte( &buf, GI->secure );
|
||||
MSG_WriteString( &buf, XASH_VERSION );
|
||||
|
||||
Netchan_OutOfBand( NS_SERVER, from, MSG_GetNumBytesWritten( &buf ), MSG_GetData( &buf ));
|
||||
NET_SendPacket( NS_SERVER, MSG_GetNumBytesWritten( &buf ), MSG_GetData( &buf ), from );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -87,7 +79,8 @@ static void SV_SourceQuery_Rules( netadr_t from )
|
||||
|
||||
MSG_Init( &buf, "TSourceEngineQueryRules", answer, sizeof( answer ));
|
||||
|
||||
MSG_WriteByte( &buf, SOURCE_QUERY_RULES_RESPONSE );
|
||||
MSG_WriteDword( &buf, 0xFFFFFFFFU );
|
||||
MSG_WriteByte( &buf, S2A_GOLDSRC_RULES );
|
||||
|
||||
pos = MSG_GetNumBitsWritten( &buf );
|
||||
MSG_WriteShort( &buf, 0 );
|
||||
@@ -117,7 +110,7 @@ static void SV_SourceQuery_Rules( netadr_t from )
|
||||
MSG_SeekToBit( &buf, pos, SEEK_SET );
|
||||
MSG_WriteShort( &buf, cvar_count );
|
||||
|
||||
Netchan_OutOfBand( NS_SERVER, from, total, MSG_GetData( &buf ));
|
||||
NET_SendPacket( NS_SERVER, total, MSG_GetData( &buf ), from );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +132,8 @@ static void SV_SourceQuery_Players( netadr_t from )
|
||||
|
||||
MSG_Init( &buf, "TSourceEngineQueryPlayers", answer, sizeof( answer ));
|
||||
|
||||
MSG_WriteByte( &buf, SOURCE_QUERY_PLAYERS_RESPONSE );
|
||||
MSG_WriteDword( &buf, 0xFFFFFFFFU );
|
||||
MSG_WriteByte( &buf, S2A_GOLDSRC_PLAYERS );
|
||||
|
||||
pos = MSG_GetNumBitsWritten( &buf );
|
||||
MSG_WriteByte( &buf, 0 );
|
||||
@@ -168,7 +162,7 @@ static void SV_SourceQuery_Players( netadr_t from )
|
||||
MSG_SeekToBit( &buf, pos, SEEK_SET );
|
||||
MSG_WriteByte( &buf, count );
|
||||
|
||||
Netchan_OutOfBand( NS_SERVER, from, total, MSG_GetData( &buf ));
|
||||
NET_SendPacket( NS_SERVER, total, MSG_GetData( &buf ), from );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,24 +171,18 @@ static void SV_SourceQuery_Players( netadr_t from )
|
||||
SV_SourceQuery_HandleConnnectionlessPacket
|
||||
==================
|
||||
*/
|
||||
qboolean SV_SourceQuery_HandleConnnectionlessPacket( const char *c, netadr_t from )
|
||||
void SV_SourceQuery_HandleConnnectionlessPacket( const char *c, netadr_t from )
|
||||
{
|
||||
switch( c[0] )
|
||||
{
|
||||
case SOURCE_QUERY_DETAILS:
|
||||
case A2S_GOLDSRC_INFO:
|
||||
SV_SourceQuery_Details( from );
|
||||
return true;
|
||||
|
||||
case SOURCE_QUERY_RULES:
|
||||
break;
|
||||
case A2S_GOLDSRC_RULES:
|
||||
SV_SourceQuery_Rules( from );
|
||||
return true;
|
||||
|
||||
case SOURCE_QUERY_PLAYERS:
|
||||
break;
|
||||
case A2S_GOLDSRC_PLAYERS:
|
||||
SV_SourceQuery_Players( from );
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user