Skip to content

Commit

Permalink
Correct some configuration inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
qaisjp committed Aug 26, 2016
1 parent c5c8af9 commit a856584
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 33 deletions.
16 changes: 6 additions & 10 deletions Client/mods/deathmatch/logic/CClientCommon.h
@@ -1,15 +1,14 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* PROJECT: Multi Theft Auto
* (Shared logic for modifications)
* LICENSE: See LICENSE in the top level directory
* FILE: mods/shared_logic/CClientCommon.h
* FILE: mods/logic/CClientCommon.h
* PURPOSE: Common definitions
*
*****************************************************************************/

#ifndef __CCLIENTCOMMON_H
#define __CCLIENTCOMMON_H
#pragma once

// Defines the maximum amount of mimics (fake players)
#define MAX_MIMICS 50
Expand All @@ -25,16 +24,16 @@
#define MAX_PLAYER_NICK_LENGTH 22

// Defines the min/max size for the player nametag (who the hell came up with 22?)
#define MIN_PLAYER_NAMETAG_LENGTH 1
#define MAX_PLAYER_NAMETAG_LENGTH 22
#define MIN_PLAYER_NAMETAG_LENGTH 1
#define MAX_PLAYER_NAMETAG_LENGTH 22

#define MAX_TEAM_NAME_LENGTH 255

// Defines the minimum fade time for a transfer
#define MIN_TRANSFER_TIME 1500

// Defines the maximum size for a player name
//#define MAX_PLAYER_NAME_LENGTH 32
//#define MAX_PLAYER_NAME_LENGTH 32

// Defines the maximum size for a HTTP Download URL
#define MAX_HTTP_DOWNLOAD_URL 512
Expand All @@ -57,6 +56,3 @@ extern CCoreInterface* g_pCore;
extern CGame* g_pGame;
extern CMultiplayer* g_pMultiplayer;
extern CNet* g_pNet;

#endif

15 changes: 6 additions & 9 deletions Server/mods/deathmatch/Config.h
@@ -1,6 +1,6 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: mods/deathmatch/Config.h
* PURPOSE: Header for platform specific functions, types and defines
Expand All @@ -11,8 +11,7 @@

// Header file for platform specific functions, types and defines

#ifndef __CONFIG_H
#define __CONFIG_H
#pragma once

#include <MTAPlatform.h>
#include <Common.h>
Expand All @@ -39,12 +38,12 @@ class CVaPassNext{
/*** va_pass() (passing of ... variable length arguments ***/

// Min and max number of characters in player nicknames (this must match the client's)
#define MIN_NICK_LENGTH 1
#define MAX_NICK_LENGTH 22
#define MIN_PLAYER_NICK_LENGTH 1
#define MAX_PLAYER_NICK_LENGTH 22

// Min and max number of characters in player nametags (this must match the client's)
#define MIN_NAMETAG_LENGTH 1
#define MAX_NAMETAG_LENGTH 22
#define MIN_PLAYER_NAMETAG_LENGTH 1
#define MAX_PLAYER_NAMETAG_LENGTH 22

#define MAX_TEAM_NAME_LENGTH 255

Expand Down Expand Up @@ -159,5 +158,3 @@ class CVaPassNext{

// MTA minclientversion auto update and others
#define HQCOMMS_URL "http://updatesa.multitheftauto.com/sa/server/hqcomms/"

#endif
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CConsoleCommands.cpp
Expand Up @@ -738,7 +738,7 @@ bool CConsoleCommands::Nick ( CConsole* pConsole, const char* szArguments, CClie
{
// Verify the length
size_t sizeNewNick = strlen ( szNewNick );
if ( sizeNewNick >= MIN_NICK_LENGTH && sizeNewNick <= MAX_NICK_LENGTH )
if ( sizeNewNick >= MIN_PLAYER_NICK_LENGTH && sizeNewNick <= MAX_PLAYER_NICK_LENGTH )
{
// Does the nickname differ from the previous nickname?
const char* szNick = pClient->GetNick ();
Expand Down Expand Up @@ -786,7 +786,7 @@ bool CConsoleCommands::Nick ( CConsole* pConsole, const char* szArguments, CClie
else
{
// Tell the player
pEchoClient->SendEcho ( SString ( "nick: Nick must be between %u and %u characters", MIN_NICK_LENGTH, MAX_NICK_LENGTH ) );
pEchoClient->SendEcho ( SString ( "nick: Nick must be between %u and %u characters", MIN_PLAYER_NICK_LENGTH, MAX_PLAYER_NICK_LENGTH ) );
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CGame.cpp
Expand Up @@ -1647,7 +1647,7 @@ void CGame::Packet_PlayerJoinData ( CPlayerJoinDataPacket& Packet )

// Check the size of the nick
size_t sizeNick = strlen ( szNick );
if ( sizeNick >= MIN_NICK_LENGTH && sizeNick <= MAX_NICK_LENGTH )
if ( sizeNick >= MIN_PLAYER_NICK_LENGTH && sizeNick <= MAX_PLAYER_NICK_LENGTH )
{
// Someone here with the same name?
CPlayer* pTempPlayer = m_pPlayerManager->Get ( szNick );
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CPlayer.cpp
Expand Up @@ -217,7 +217,7 @@ void CPlayer::SetNick ( const char* szNick )
g_pGame->GetConsole ()->GetWhoWas ()->Add ( szNick, inet_addr ( GetSourceIP() ), GetSerial (), GetPlayerVersion (), GetAccount ()->GetName () );
}

m_strNick.AssignLeft ( szNick, MAX_NICK_LENGTH );
m_strNick.AssignLeft ( szNick, MAX_PLAYER_NICK_LENGTH );
}

const char* CPlayer::GetSourceIP ( void )
Expand Down
Expand Up @@ -2035,7 +2035,7 @@ bool CStaticFunctionDefinitions::SetPlayerName ( CElement* pElement, const char*
{
// Verify the length
size_t sizeNewNick = strlen ( szName );
if ( sizeNewNick >= MIN_NICK_LENGTH && sizeNewNick <= MAX_NICK_LENGTH )
if ( sizeNewNick >= MIN_PLAYER_NICK_LENGTH && sizeNewNick <= MAX_PLAYER_NICK_LENGTH )
{
// Does the nickname differ from the previous nickname?
const char* szNick = pPlayer->GetNick ();
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CWhoWas.cpp
Expand Up @@ -16,7 +16,7 @@ void CWhoWas::Add ( const char* szNick, unsigned long ulIP, std::string strSeria
{
// Create the struct and copy the data over
SWhoWasEntry Entry;
Entry.strNick.AssignLeft ( szNick, MAX_NICK_LENGTH );
Entry.strNick.AssignLeft ( szNick, MAX_PLAYER_NICK_LENGTH );
Entry.ulIP = ulIP;
Entry.strSerial = strSerial;
Entry.strPlayerVersion = strPlayerVersion;
Expand Down
6 changes: 3 additions & 3 deletions Server/mods/deathmatch/logic/Utils.cpp
Expand Up @@ -715,7 +715,7 @@ bool IsNametagValid ( const char* szNick )
{
// Grab the size of the nick. Check that it's not to long or short
size_t sizeNick = strlen ( szNick );
if ( sizeNick < MIN_NICK_LENGTH || sizeNick > MAX_NAMETAG_LENGTH )
if ( sizeNick < MIN_PLAYER_NAMETAG_LENGTH || sizeNick > MAX_PLAYER_NAMETAG_LENGTH )
{
return false;
}
Expand All @@ -740,7 +740,7 @@ bool IsNickValid ( const char* szNick )
{
// Grab the size of the nick. Check that it's within the player
size_t sizeNick = strlen ( szNick );
if ( sizeNick < MIN_NICK_LENGTH || sizeNick > MAX_NICK_LENGTH )
if ( sizeNick < MIN_PLAYER_NICK_LENGTH || sizeNick > MAX_PLAYER_NICK_LENGTH )
{
return false;
}
Expand Down Expand Up @@ -961,4 +961,4 @@ CVector ConvertEulerRotationOrder ( const CVector& a_vRotation, eEulerRota
{
return a_vRotation;
}
}
}
Expand Up @@ -15,7 +15,7 @@

CPlayerChangeNickPacket::CPlayerChangeNickPacket ( const char* szNewNick )
{
m_strNewNick.AssignLeft ( szNewNick, MAX_NICK_LENGTH );
m_strNewNick.AssignLeft ( szNewNick, MAX_PLAYER_NICK_LENGTH );
}


Expand Down
Expand Up @@ -28,7 +28,7 @@ class CPlayerChangeNickPacket : public CPacket
bool Write ( NetBitStreamInterface& BitStream ) const;

inline const char* GetNewNick ( void ) { return m_strNewNick; }
inline void SetNewNick ( const char* szNewNick ) { m_strNewNick.AssignLeft( szNewNick, MAX_NICK_LENGTH ); }
inline void SetNewNick ( const char* szNewNick ) { m_strNewNick.AssignLeft( szNewNick, MAX_PLAYER_NICK_LENGTH ); }

private:
SString m_strNewNick;
Expand Down
Expand Up @@ -29,7 +29,7 @@ bool CPlayerJoinDataPacket::Read ( NetBitStreamInterface& BitStream )
m_bOptionalUpdateInfoRequired = BitStream.ReadBit ();

if ( BitStream.Read ( m_ucGameVersion ) &&
BitStream.ReadStringCharacters ( m_strNick, MAX_NICK_LENGTH ) &&
BitStream.ReadStringCharacters ( m_strNick, MAX_PLAYER_NICK_LENGTH ) &&
BitStream.Read ( reinterpret_cast < char* > ( &m_Password ), 16 ) &&
BitStream.ReadStringCharacters ( m_strSerialUser, MAX_SERIAL_LENGTH ) )
{
Expand Down
Expand Up @@ -38,7 +38,7 @@ class CPlayerJoinDataPacket : public CPacket
inline const SString& GetPlayerVersion ( void ) { return m_strPlayerVersion; };

inline const char* GetNick ( void ) { return m_strNick; };
inline void SetNick ( const char* szNick ) { m_strNick.AssignLeft( szNick, MAX_NICK_LENGTH ); };
inline void SetNick ( const char* szNick ) { m_strNick.AssignLeft( szNick, MAX_PLAYER_NICK_LENGTH ); };

inline const MD5& GetPassword ( void ) { return m_Password; };
inline void SetPassword ( const MD5& Password ) { m_Password = Password; };
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/packets/CPlayerListPacket.cpp
Expand Up @@ -53,7 +53,7 @@ bool CPlayerListPacket::Write ( NetBitStreamInterface& BitStream ) const
// Write the nick length
const char* szNickPointer = pPlayer->GetNick ();
unsigned char ucNickLength = static_cast < unsigned char > ( strlen ( szNickPointer ) );
if ( ucNickLength < MIN_NICK_LENGTH || ucNickLength > MAX_NICK_LENGTH )
if ( ucNickLength < MIN_PLAYER_NICK_LENGTH || ucNickLength > MAX_PLAYER_NICK_LENGTH )
{
BitStream.Write ( static_cast < unsigned char > ( 3 ) );
BitStream.Write ( "???", 3 );
Expand Down

0 comments on commit a856584

Please sign in to comment.