Permalink
Browse files

Merge pull request #828 from Unvanquished/connectionless_packet

Connectionless commands, rcon and encryption
  • Loading branch information...
mbasaglia committed Mar 26, 2016
2 parents bfe5530 + fdbe9c8 commit 62a64e42d48eea8e1e907cca786f5589976127e0
Showing with 2,248 additions and 857 deletions.
  1. +8 −0 daemon/src.cmake
  2. +9 −30 daemon/src/common/Color.cpp
  3. +19 −0 daemon/src/common/Cvar.cpp
  4. +9 −0 daemon/src/common/Cvar.h
  5. +40 −0 daemon/src/common/FileSystem.cpp
  6. +6 −0 daemon/src/common/FileSystem.h
  7. +7 −0 daemon/src/common/String.cpp
  8. +7 −0 daemon/src/common/String.h
  9. +1 −1 daemon/src/engine/client/cl_cgame.cpp
  10. +258 −72 daemon/src/engine/client/cl_main.cpp
  11. +1 −1 daemon/src/engine/client/client.h
  12. +295 −0 daemon/src/engine/framework/Crypto.cpp
  13. +115 −0 daemon/src/engine/framework/Crypto.h
  14. +11 −0 daemon/src/engine/framework/CvarSystem.cpp
  15. +2 −0 daemon/src/engine/framework/CvarSystem.h
  16. +118 −0 daemon/src/engine/framework/Network.cpp
  17. +66 −0 daemon/src/engine/framework/Network.h
  18. +91 −0 daemon/src/engine/framework/Rcon.cpp
  19. +73 −0 daemon/src/engine/framework/Rcon.h
  20. +2 −8 daemon/src/engine/qcommon/files.cpp
  21. +3 −62 daemon/src/engine/qcommon/net_chan.cpp
  22. +2 −2 daemon/src/engine/qcommon/net_ip.cpp
  23. +55 −0 daemon/src/engine/qcommon/q_shared.cpp
  24. +32 −0 daemon/src/engine/qcommon/q_shared.h
  25. +3 −2 daemon/src/engine/qcommon/qcommon.h
  26. +172 −0 daemon/src/engine/server/CryptoChallenge.cpp
  27. +179 −0 daemon/src/engine/server/CryptoChallenge.h
  28. +23 −26 daemon/src/engine/server/server.h
  29. +116 −79 daemon/src/engine/server/sv_ccmds.cpp
  30. +111 −325 daemon/src/engine/server/sv_client.cpp
  31. +2 −3 daemon/src/engine/server/sv_init.cpp
  32. +412 −246 daemon/src/engine/server/sv_main.cpp
View
@@ -136,6 +136,8 @@ set(SERVERLIST
${ENGINE_DIR}/server/sv_net_chan.cpp
${ENGINE_DIR}/server/sv_sgame.cpp
${ENGINE_DIR}/server/sv_snapshot.cpp
${ENGINE_DIR}/server/CryptoChallenge.cpp
${ENGINE_DIR}/server/CryptoChallenge.h
)
set(ENGINELIST
@@ -164,6 +166,12 @@ set(ENGINELIST
${ENGINE_DIR}/framework/System.h
${ENGINE_DIR}/framework/VirtualMachine.cpp
${ENGINE_DIR}/framework/VirtualMachine.h
${ENGINE_DIR}/framework/Crypto.cpp
${ENGINE_DIR}/framework/Crypto.h
${ENGINE_DIR}/framework/Rcon.cpp
${ENGINE_DIR}/framework/Rcon.h
${ENGINE_DIR}/framework/Network.h
${ENGINE_DIR}/framework/Network.cpp
${ENGINE_DIR}/qcommon/md5.cpp
${ENGINE_DIR}/sys/con_common.h
${ENGINE_DIR}/sys/con_common.cpp
@@ -207,28 +207,6 @@ const char* CString ( const Color32Bit& color )
} // namespace detail
/*
* Converts a hexadecimal character to the value of the digit it represents.
* Pre: ishex(ch)
*/
static CONSTEXPR_FUNCTION int gethex( char ch )
{
return ch > '9' ?
( ch >= 'a' ? ch - 'a' + 10 : ch - 'A' + 10 )
: ch - '0'
;
}
// Whether a character is a hexadecimal digit
static CONSTEXPR_FUNCTION bool ishex( char ch )
{
return ( ch >= '0' && ch <= '9' ) ||
( ch >= 'A' && ch <= 'F' ) ||
( ch >= 'a' && ch <= 'f' );
}
TokenIterator::value_type TokenIterator::NextToken(const char* input)
{
if ( !input || *input == '\0' )
@@ -250,12 +228,13 @@ TokenIterator::value_type TokenIterator::NextToken(const char* input)
{
return value_type( input, input+2, detail::Indexed( input[1] - '0' ) );
}
else if ( Str::ctolower( input[1] ) == 'x' && ishex( input[2] ) && ishex( input[3] ) && ishex( input[4] ) )
else if ( std::tolower( input[1] ) == 'x' && Str::cisxdigit( input[2] ) &&
Str::cisxdigit( input[3] ) && Str::cisxdigit( input[4] ) )
{
return value_type( input, input+5, Color(
gethex( input[2] ) / 15.f,
gethex( input[3] ) / 15.f,
gethex( input[4] ) / 15.f,
Str::GetHex( input[2] ) / 15.f,
Str::GetHex( input[3] ) / 15.f,
Str::GetHex( input[4] ) / 15.f,
1
) );
}
@@ -264,7 +243,7 @@ TokenIterator::value_type TokenIterator::NextToken(const char* input)
bool long_hex = true;
for ( int i = 0; i < 6; i++ )
{
if ( !ishex( input[i+2] ) )
if ( !Str::cisxdigit( input[i+2] ) )
{
long_hex = false;
break;
@@ -273,9 +252,9 @@ TokenIterator::value_type TokenIterator::NextToken(const char* input)
if ( long_hex )
{
return value_type( input, input+8, Color(
( (gethex( input[2] ) << 4) | gethex( input[3] ) ) / 255.f,
( (gethex( input[4] ) << 4) | gethex( input[5] ) ) / 255.f,
( (gethex( input[6] ) << 4) | gethex( input[7] ) ) / 255.f,
( (Str::GetHex( input[2] ) << 4) | Str::GetHex( input[3] ) ) / 255.f,
( (Str::GetHex( input[4] ) << 4) | Str::GetHex( input[5] ) ) / 255.f,
( (Str::GetHex( input[6] ) << 4) | Str::GetHex( input[7] ) ) / 255.f,
1
) );
}
View
@@ -106,4 +106,23 @@ namespace Cvar {
std::string GetCvarTypeName<std::string>() {
return "text";
}
std::string SerializeCvarValue(std::size_t value) {
return std::to_string(value);
}
template<>
std::string GetCvarTypeName<std::size_t>() {
return "uint";
}
bool ParseCvarValue(Str::StringRef value, std::size_t& result) {
if ( value.empty() || !Str::cisdigit(value[0]) )
{
return false;
}
result = std::stoul(value);
return true;
}
}
View
@@ -73,6 +73,10 @@ namespace Cvar {
// the user.
virtual OnValueChangedResult OnValueChanged(Str::StringRef newValue) = 0;
const std::string& Name() const {
return name;
}
protected:
std::string name;
@@ -227,6 +231,11 @@ namespace Cvar {
std::string SerializeCvarValue(std::string value);
template<>
std::string GetCvarTypeName<std::string>();
std::string SerializeCvarValue(std::size_t value);
template<>
std::string GetCvarTypeName<std::size_t>();
bool ParseCvarValue(Str::StringRef value, std::size_t& result);
// Engine calls available everywhere
@@ -2386,6 +2386,46 @@ const std::vector<PakInfo>& GetAvailablePaks()
return availablePaks;
}
std::vector<PakInfo> GetAvailableMapPaks()
{
std::vector<PakInfo> infos;
for ( const auto& pak : FS::GetAvailablePaks() )
{
if ( Str::IsPrefix("map-", pak.name) )
{
infos.push_back(pak);
}
}
return infos;
}
std::set<std::string> GetAvailableMaps()
{
std::set<std::string> maps;
#ifndef BUILD_VM
RefreshPaks();
#endif
std::error_code ignore;
for ( const auto& pak : GetAvailableMapPaks() )
{
FS::PakPath::LoadPakPrefix(pak, "maps", ignore);
}
static const std::string map_suffix = ".bsp";
for ( const auto& file : FS::PakPath::ListFiles("maps", ignore) )
{
if ( Str::IsSuffix(map_suffix, file) )
{
maps.insert( file.substr(0, file.size() - map_suffix.size()) );
}
}
return maps;
}
const std::string& GetHomePath()
{
return homePath;
@@ -506,6 +506,12 @@ std::string MakePakName(Str::StringRef name, Str::StringRef version, Util::optio
// Get the list of available paks
const std::vector<PakInfo>& GetAvailablePaks();
// Get the list of available paks that contain maps
std::vector<PakInfo> GetAvailableMapPaks();
// Get the list of available map names
std::set<std::string> GetAvailableMaps();
// Get the home path
const std::string& GetHomePath();
@@ -92,6 +92,13 @@ namespace Str {
return true;
}
int GetHex(char ch) {
return ch > '9' ?
( ch >= 'a' ? ch - 'a' + 10 : ch - 'A' + 10 )
: ch - '0'
;
}
std::string ToUpper(Str::StringRef text) {
std::string res;
res.reserve(text.size());
@@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define COMMON_STRING_H_
#include <algorithm>
#include "Compiler.h"
namespace Str {
void AssertOnTinyFormatError(std::string reason);
@@ -241,6 +242,12 @@ namespace Str {
return c;
}
/*
* Converts a hexadecimal character to the value of the digit it represents.
* Pre: cisxdigit(ch)
*/
int GetHex(char ch);
std::string ToUpper(Str::StringRef text);
std::string ToLower(Str::StringRef text);
@@ -934,7 +934,7 @@ void CL_SetCGameTime()
if ( cl.snap.serverTime < cl.oldFrameServerTime )
{
// Ridah, if this is a localhost, then we are probably loading a savegame
if ( !Q_stricmp( cls.servername, "localhost" ) )
if ( !Q_stricmp( cls.servername, "loopback" ) )
{
// do nothing?
CL_FirstSnapshot();
Oops, something went wrong.

0 comments on commit 62a64e4

Please sign in to comment.