vscript additions and fixes:

vscript_client.cpp
   - Fixed local player script instance registration
   - Added CEntities::GetLocalPlayer
   - Added Con_IsVisible
   - Added IsWindowedMode
   - Added ScreenWidth
   - Added ScreenHeight
   - Added ScreenTransform
   - Added missing DoUniqueString

gameinterface.cpp
usercmd.h
usercmd.cpp
vscript_singletons.cpp
   - CNetMsgScriptHelper

vscript_singletons.cpp
   - Added hash map for CScriptSaveRestoreUtil
   - Added hash map for CScriptGameEventListener::s_GameEvents
   - Changed CScriptGameEventListener string contexts to hashes
   - Added invalid input condition on CScriptGameEventListener::ListenToGameEvent
   - Moved CDebugOverlayScriptHelper to shared code

ivscript.h
vscript_squirrel.cpp
   - Added IScriptVM::Get/Set/ClearValue (ScriptVariant_t key)

baseentity.h
baseentity.cpp
   - Added CBaseEntity::SetContextThink (ScriptSetContextThink)

vscript_server.cpp
vscript_client.cpp
vscript_funcs_shared.cpp
   - Changed the order user vscript_*.nut files are executed - after internal scripts, before mapspawn

vscript_squirrel.cpp
vscript_squirrel.nut
vscript_server.nut
vscript_shared.cpp
   - Localised all documentation under __Documentation

hl2_usermessages.cpp
   - Added usermessage ScriptMsg

c_baseplayer.cpp
   - Removed redundant check in ~C_BasePlayer
This commit is contained in:
samisalreadytaken
2020-12-25 23:07:46 +03:00
parent 6ba3cd4c03
commit ef7d9ccc0f
18 changed files with 1716 additions and 991 deletions

View File

@@ -852,10 +852,4 @@ void RegisterSharedScriptFunctions()
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptIsClient, "IsClient", "Returns true if the script is being run on the client." );
RegisterScriptSingletons();
#ifdef CLIENT_DLL
VScriptRunScript( "vscript_client", true );
#else
VScriptRunScript( "vscript_server", true );
#endif
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,12 +5,135 @@
// $NoKeywords: $
//=============================================================================
#ifndef VSCRIPT_FUNCS_MATH
#define VSCRIPT_FUNCS_MATH
#ifndef VSCRIPT_SINGLETONS
#define VSCRIPT_SINGLETONS
#ifdef _WIN32
#pragma once
#endif
void RegisterScriptSingletons();
#ifdef CLIENT_DLL
// usercmd
#define SCRIPT_NETMSG_DATA_SIZE ( ( 1 << 11 ) - 1 )
#else
// usermsg
#define SCRIPT_NETMSG_DATA_SIZE MAX_USER_MSG_DATA
#endif
#ifdef CLIENT_DLL
class CNetMsgScriptHelper : public CAutoGameSystem
#else
class CNetMsgScriptHelper
#endif
{
private:
#ifdef GAME_DLL
CRecipientFilter m_filter;
bf_read *m_MsgIn;
#else
bf_read m_MsgIn;
#endif
bf_write m_MsgOut;
byte m_MsgData[ PAD_NUMBER( SCRIPT_NETMSG_DATA_SIZE, 4 ) ];
HSCRIPT m_Hooks;
public:
#ifdef CLIENT_DLL
bool m_bWriteReady; // dt ready to send
CNetMsgScriptHelper() : m_Hooks(NULL), m_bWriteReady(false) {}
#else
CNetMsgScriptHelper() : m_Hooks(NULL) {}
#endif
public:
#ifdef CLIENT_DLL
bool Init(); // IGameSystem
static void __MsgFunc_ScriptMsg( bf_read &msg );
#endif
void LevelShutdownPreVM(); // Executed in CVScriptGameSystem
void InitPostVM();
#ifdef GAME_DLL
void RecieveMessage( bf_read *msg, CBaseEntity *pPlayer );
#else
void RecieveMessage( bf_read &msg );
#endif
void WriteToBuffer( bf_write *bf );
public:
inline void Reset();
void Start( const char *msg );
#ifdef GAME_DLL
void Send( HSCRIPT player, bool bReliable );
#else
void Send();
#endif
void Recieve( const char *msg, HSCRIPT func );
#ifdef GAME_DLL
inline void DoSendUserMsg( CRecipientFilter *filter, int type );
inline void DoSendEntityMsg( CBaseEntity *entity, bool reliable );
void SendUserMessage( HSCRIPT hPlayer, const char *msg, bool bReliable );
void SendEntityMessage( HSCRIPT hEnt, bool bReliable );
#else // CLIENT_DLL
void DispatchUserMessage( const char *msg );
#endif
#ifdef GAME_DLL
public:
void AddRecipient( HSCRIPT player );
void AddRecipientsByPVS( const Vector &pos );
void AddRecipientsByPAS( const Vector &pos );
void AddAllPlayers();
#endif // GAME_DLL
public:
void WriteInt( int iValue, int bits );
void WriteUInt( int iValue, int bits );
void WriteByte( int iValue ); // 8 bit unsigned char
void WriteChar( int iValue ); // 8 bit char
void WriteShort( int iValue ); // 16 bit short
void WriteWord( int iValue ); // 16 bit unsigned short
void WriteLong( int iValue ); // 32 bit long
void WriteFloat( float flValue );
void WriteNormal( float flValue ); // 12 bit
void WriteAngle( float flValue ); // 8 bit unsigned char
void WriteCoord( float flValue );
void WriteVec3Coord( const Vector& rgflValue );
void WriteVec3Normal( const Vector& rgflValue ); // 27 bit ( 3 + 2 * (1 + NORMAL_FRACTIONAL_BITS) )
void WriteAngles( const QAngle& rgflValue );
void WriteString( const char *sz ); // max 512 bytes at once
void WriteBool( bool bValue ); // 1 bit
void WriteEntity( HSCRIPT hEnt ); // 11 bit (entindex)
void WriteEHandle( HSCRIPT hEnt ); // 32 bit long
int ReadInt( int bits );
int ReadUInt( int bits );
int ReadByte();
int ReadChar();
int ReadShort();
int ReadWord();
int ReadLong();
float ReadFloat();
float ReadNormal();
float ReadAngle();
float ReadCoord();
const Vector& ReadVec3Coord();
const Vector& ReadVec3Normal();
const QAngle& ReadAngles();
const char* ReadString();
bool ReadBool();
HSCRIPT ReadEntity();
HSCRIPT ReadEHandle();
//int GetNumBitsLeft(); // unreliable on server because of usercmds. so just do away with it
int GetNumBitsWritten();
};
extern CNetMsgScriptHelper *g_ScriptNetMsg;
#endif