├── vendor ├── raknet │ ├── EncodeClassName.cpp │ ├── SAMP │ │ ├── samp_auth.h │ │ ├── samp_netencr.h │ │ └── samp_netencr.cpp │ ├── SystemDatabaseClient.cpp │ ├── SystemDatabaseServer.cpp │ ├── RakSleep.h │ ├── SystemDatabaseClient.h │ ├── SystemDatabaseServer.h │ ├── RakAssert.h │ ├── Export.h │ ├── LinuxStrings.h │ ├── AutopatcherPatchContext.h │ ├── RakSleep.cpp │ ├── FileOperations.h │ ├── LinuxStrings.cpp │ ├── RouterInterface.h │ ├── CheckSum.h │ ├── DS_HuffmanEncodingTreeNode.h │ ├── RakNetDefines.h │ ├── Rand.h │ ├── DataCompressor.h │ ├── GetTime.h │ ├── SystemAddressList.h │ ├── DS_ByteQueue.h │ ├── PacketPool.h │ ├── _findfirst.h │ ├── ClientContextStruct.h │ ├── ExtendedOverlappedPool.h │ ├── RPCMap.h │ ├── RakNetworkFactory.cpp │ ├── InternalPacketPool.cpp │ ├── ExtendedOverlappedPool.cpp │ ├── InternalPacketPool.h │ ├── RakNetworkFactory.h │ ├── RPCNode.h │ ├── MTUSize.h │ ├── DS_MemoryPool.h │ ├── SimpleMutex.h │ ├── ReplicaEnums.h │ ├── DataCompressor.cpp │ ├── EmailSender.h │ ├── FullyConnectedMesh.h │ ├── DS_HuffmanEncodingTreeFactory.h │ ├── TelnetTransport.h │ ├── PacketPriority.h │ ├── SimpleMutex.cpp │ ├── CheckSum.cpp │ ├── DataBlockEncryptor.h │ ├── DS_HuffmanEncodingTree.h │ ├── DS_Tree.h │ ├── SHA1.h │ ├── _findfirst.cpp │ ├── AsynchronousFileIO.h │ ├── FullyConnectedMesh.cpp__ │ ├── RakNetCommandParser.h │ ├── DS_ByteQueue.cpp │ ├── ConsoleServer.h │ ├── PacketEnumerations.h │ ├── FileOperations.cpp │ ├── AutopatcherRepositoryInterface.h │ ├── GetTime.cpp │ ├── PluginInterface.cpp │ ├── SystemAddressList.cpp │ ├── SimpleTCPServer.h │ ├── DS_QueueLinkedList.h │ ├── StringTable.cpp │ ├── TCPInterface.h │ └── InternalPacket.h ├── hash │ └── md5.h └── inih │ └── cpp │ ├── INIReader.h │ └── INIReader.cpp ├── game ├── game.cpp ├── pad.cpp ├── object.cpp ├── playerped.h ├── quaternion.cpp ├── font.h ├── aimstuff.cpp ├── radarcolors.h ├── font.cpp ├── aimstuff.h ├── RW │ └── RenderWare.h ├── object.h ├── quaternion.h ├── camera.h ├── entity.h ├── util.h ├── pad.h ├── vehicle.h ├── camera.cpp └── scripting.cpp ├── keyboard.cpp ├── chatwindow.cpp ├── playertags.cpp ├── Application.mk ├── util ├── util.h ├── armhook.h ├── util.cpp └── armhook.cpp ├── checkfilehash.h ├── shpora.h ├── skinchanger.h ├── sets.h ├── debug.h ├── timer.hpp ├── servers.h ├── playerslist.h ├── textdraw.h ├── menu.h ├── customserver.h ├── spawnscreen.h ├── playertags.h ├── net ├── gangzonepool.h ├── objectpool.h ├── pickuppool.h ├── textlabelpool.h ├── playerpool.h ├── vehiclepool.h ├── objectpool.cpp ├── gangzonepool.cpp ├── playerpool.cpp └── netgame.h ├── extrakeyboard.h ├── timer.cpp ├── main.h ├── settings.h ├── Android.mk ├── dialog.h ├── debug.cpp ├── gui └── gui.h ├── chatwindow.h ├── shpora.cpp ├── keyboard.h ├── spawnscreen.cpp ├── README.md ├── modsa.h ├── settings.cpp ├── textdraw.cpp ├── playerslist.cpp ├── skinchanger.cpp └── menu.cpp /vendor/raknet/EncodeClassName.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /vendor/raknet/SAMP/samp_auth.h: -------------------------------------------------------------------------------- 1 | extern char *GenAuthKey(char *incomingKey); -------------------------------------------------------------------------------- /game/game.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qdsteam/sampmodmobile/HEAD/game/game.cpp -------------------------------------------------------------------------------- /game/pad.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qdsteam/sampmodmobile/HEAD/game/pad.cpp -------------------------------------------------------------------------------- /keyboard.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qdsteam/sampmodmobile/HEAD/keyboard.cpp -------------------------------------------------------------------------------- /chatwindow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qdsteam/sampmodmobile/HEAD/chatwindow.cpp -------------------------------------------------------------------------------- /game/object.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qdsteam/sampmodmobile/HEAD/game/object.cpp -------------------------------------------------------------------------------- /playertags.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qdsteam/sampmodmobile/HEAD/playertags.cpp -------------------------------------------------------------------------------- /game/playerped.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qdsteam/sampmodmobile/HEAD/game/playerped.h -------------------------------------------------------------------------------- /vendor/raknet/SystemDatabaseClient.cpp: -------------------------------------------------------------------------------- 1 | #include "SystemDatabaseClient.h" 2 | 3 | // TODO 4 | -------------------------------------------------------------------------------- /vendor/raknet/SystemDatabaseServer.cpp: -------------------------------------------------------------------------------- 1 | #include "SystemDatabaseServer.h" 2 | 3 | // TODO 4 | -------------------------------------------------------------------------------- /game/quaternion.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qdsteam/sampmodmobile/HEAD/game/quaternion.cpp -------------------------------------------------------------------------------- /Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := armeabi-v7a 2 | APP_PLATFORM := android-14 3 | APP_MODULES := d3d9 4 | APP_STL := gnustl_static -------------------------------------------------------------------------------- /vendor/raknet/RakSleep.h: -------------------------------------------------------------------------------- 1 | #ifndef __RAK_SLEEP_H 2 | #define __RAK_SLEEP_H 3 | 4 | void RakSleep(unsigned int ms); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /game/font.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CFont 4 | { 5 | public: 6 | static void AsciiToGxtChar(const char* ascii, uint16_t* gxt); 7 | }; -------------------------------------------------------------------------------- /vendor/raknet/SystemDatabaseClient.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYSTEM_DATABASE_CLIENT_H 2 | #define __SYSTEM_DATABASE_CLIENT_H 3 | 4 | // TODO 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /vendor/raknet/SystemDatabaseServer.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYSTEM_DATABASE_SERVER_H 2 | #define __SYSTEM_DATABASE_SERVER_H 3 | 4 | // TODO 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /util/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | uintptr_t FindLibrary(const char* library); 4 | void cp1251_to_utf8(char *out, const char *in, unsigned int len = 0); -------------------------------------------------------------------------------- /game/aimstuff.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "game.h" 3 | 4 | CAMERA_AIM* GameGetInternalAim() 5 | { 6 | return (CAMERA_AIM*)(g_libGTASA+0x8B0AE0); 7 | } -------------------------------------------------------------------------------- /game/radarcolors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void SetRadarColor(int nIndex, uint32_t dwColor); 4 | void GameResetRadarColors(); 5 | uint32_t TranslateColorCodeToRGBA(int iCode); -------------------------------------------------------------------------------- /vendor/raknet/RakAssert.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // So stupid Linux doesn't assert in release 4 | #ifdef _DEBUG 5 | #define RakAssert(x) assert(x); 6 | #else 7 | #define RakAssert(x) 8 | #endif 9 | -------------------------------------------------------------------------------- /game/font.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include "font.h" 3 | 4 | void CFont::AsciiToGxtChar(const char* ascii, uint16_t* gxt) 5 | { 6 | return (( void (*)(const char*, uint16_t*))(g_libGTASA+0x532D00+1))(ascii, gxt); 7 | } -------------------------------------------------------------------------------- /checkfilehash.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct mdFile 4 | { 5 | char szFileLocation[128]; 6 | uint32_t iCorrectDigestArray[4]; 7 | unsigned char szRawLocalDigest[16]; 8 | }; 9 | 10 | bool FileCheckSum(); 11 | bool CheckFile(mdFile* mdChkFile); -------------------------------------------------------------------------------- /game/aimstuff.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct _CAMERA_AIM 4 | { 5 | float f1x, f1y, f1z; 6 | float pos1x, pos1y, pos1z; 7 | float pos2x, pos2y, pos2z; 8 | float f2x, f2y, f2z; 9 | } CAMERA_AIM; 10 | 11 | CAMERA_AIM* GameGetInternalAim(); -------------------------------------------------------------------------------- /shpora.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CShpora 4 | { 5 | public: 6 | CShpora(); 7 | ~CShpora(); 8 | 9 | void Render(); 10 | void Clear(); 11 | void Show(bool bShow); 12 | 13 | public: 14 | bool m_bIsActive; 15 | int step; 16 | }; -------------------------------------------------------------------------------- /skinchanger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CSkinChanger 4 | { 5 | public: 6 | CSkinChanger(); 7 | ~CSkinChanger(); 8 | 9 | void Render(); 10 | void Clear(); 11 | void Show(bool bShow); 12 | 13 | public: 14 | bool m_bIsActive; 15 | }; -------------------------------------------------------------------------------- /vendor/raknet/SAMP/samp_netencr.h: -------------------------------------------------------------------------------- 1 | // https://github.com/P3ti/RakSAMP/blob/master/raknet/SAMP/samp_netencr.h 2 | 3 | /* 4 | Updated to 0.3.7 by P3ti 5 | */ 6 | extern unsigned char encrBuffer[4092]; 7 | void kyretardizeDatagram(unsigned char *buf, int len, int port, int unk); -------------------------------------------------------------------------------- /sets.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CSetsWindow 4 | { 5 | public: 6 | CSetsWindow(); 7 | ~CSetsWindow(); 8 | 9 | void Render(); 10 | void Clear(); 11 | void Show(bool bShow); 12 | 13 | public: 14 | bool m_bIsActive; 15 | char *username; 16 | char *password; 17 | }; -------------------------------------------------------------------------------- /debug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CDebug 4 | { 5 | public: 6 | CDebug(); 7 | ~CDebug(); 8 | 9 | void Render(); 10 | void Process(); 11 | 12 | void AddMessage(char* msg); 13 | void SpawnLocalPlayer(); 14 | 15 | private: 16 | uint32_t m_dwLastTick; 17 | std::vector m_Messages; 18 | }; -------------------------------------------------------------------------------- /timer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TIMERHPP 2 | #define TIMERHPP 3 | #include 4 | #include 5 | class Timer { 6 | public: 7 | Timer(); 8 | void add(std::chrono::milliseconds delay, 9 | std::function callback, 10 | bool asynchronous = true); 11 | }; 12 | #endif -------------------------------------------------------------------------------- /servers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CServersWindow 4 | { 5 | public: 6 | CServersWindow(); 7 | ~CServersWindow(); 8 | 9 | void Render(); 10 | void Clear(); 11 | void Show(bool bShow); 12 | void ShowAllServers(); 13 | 14 | public: 15 | bool m_bIsActive; 16 | int m_bMenuStep; 17 | }; -------------------------------------------------------------------------------- /vendor/raknet/Export.h: -------------------------------------------------------------------------------- 1 | // Fuck it, GCC won't compile with exports. Someone else can fix this if they want 2 | #if defined(_WIN32) && !(defined(__GNUC__) || defined(__GCCXML__)) && !defined(_RAKNET_LIB) && defined(_RAKNET_DLL) 3 | #define RAK_DLL_EXPORT __declspec(dllexport) 4 | #else 5 | #define RAK_DLL_EXPORT 6 | #endif 7 | -------------------------------------------------------------------------------- /playerslist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CPlayersList 4 | { 5 | public: 6 | CPlayersList(); 7 | ~CPlayersList(); 8 | 9 | void Render(); 10 | void Clear(); 11 | void Show(bool bShow); 12 | 13 | public: 14 | bool m_bIsActive; 15 | 16 | char* szInfo; 17 | int playersCount; 18 | bool out; 19 | }; -------------------------------------------------------------------------------- /textdraw.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CTextDraw 4 | { 5 | public: 6 | CTextDraw(); 7 | ~CTextDraw(); 8 | 9 | void Render(); 10 | void Clear(); 11 | void Show(bool bShow); 12 | void StoreTD(uint16_t wTextID); 13 | 14 | public: 15 | bool m_bIsActive; 16 | char* tdStorage; 17 | 18 | uint16_t wtID; 19 | }; -------------------------------------------------------------------------------- /vendor/raknet/LinuxStrings.h: -------------------------------------------------------------------------------- 1 | #ifndef _GCC_WIN_STRINGS 2 | #define _GCC_WIN_STRINGS 3 | 4 | #if (defined(__GNUC__) || defined(__GCCXML__)) 5 | int _stricmp(const char* s1, const char* s2); 6 | int _strnicmp(const char* s1, const char* s2, size_t n); 7 | //#ifndef __CYGWIN__ 8 | //int _unlink(const char* filename); 9 | //#endif 10 | 11 | #endif 12 | #endif 13 | -------------------------------------------------------------------------------- /menu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CMenu 4 | { 5 | public: 6 | CMenu(); 7 | ~CMenu() {}; 8 | 9 | void Render(); 10 | void Show(bool bShow); 11 | 12 | public: 13 | bool m_bEnabled; 14 | private: 15 | float m_fPosX; 16 | float m_fPosY; 17 | float m_fSizeX; 18 | float m_fSizeY; 19 | float m_fButWidth; 20 | float m_fButHeight; 21 | }; -------------------------------------------------------------------------------- /customserver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CCustomServerWindow 4 | { 5 | public: 6 | CCustomServerWindow(); 7 | ~CCustomServerWindow(); 8 | 9 | void Render(); 10 | void Clear(); 11 | void Show(bool bShow); 12 | 13 | public: 14 | bool m_bIsActive; 15 | char* address; 16 | int port; 17 | bool m_bFixer; 18 | bool m_bFixer2; 19 | }; -------------------------------------------------------------------------------- /spawnscreen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CSpawnScreen 4 | { 5 | public: 6 | CSpawnScreen(); 7 | ~CSpawnScreen() {}; 8 | 9 | void Render(); 10 | void Show(bool bShow) { m_bEnabled = bShow; } 11 | 12 | public: 13 | bool m_bEnabled; 14 | private: 15 | float m_fPosX; 16 | float m_fPosY; 17 | float m_fSizeX; 18 | float m_fSizeY; 19 | float m_fButWidth; 20 | float m_fButHeight; 21 | }; -------------------------------------------------------------------------------- /vendor/raknet/AutopatcherPatchContext.h: -------------------------------------------------------------------------------- 1 | #ifndef __AUTOPATCHER_PATCH_CONTEXT_H 2 | #define __AUTOPATCHER_PATCH_CONTEXT_H 3 | 4 | enum PatchContext 5 | { 6 | PC_HASH_WITH_PATCH, 7 | PC_WRITE_FILE, 8 | PC_ERROR_FILE_WRITE_FAILURE, 9 | PC_ERROR_PATCH_TARGET_MISSING, 10 | PC_ERROR_PATCH_APPLICATION_FAILURE, 11 | PC_ERROR_PATCH_RESULT_CHECKSUM_FAILURE, 12 | PC_NOTICE_WILL_COPY_ON_RESTART, 13 | }; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /vendor/raknet/RakSleep.cpp: -------------------------------------------------------------------------------- 1 | #if defined(_COMPATIBILITY_1) 2 | #include "Compatibility1Includes.h" 3 | #elif defined(_WIN32) 4 | #include // Sleep 5 | #elif defined(_COMPATIBILITY_2) 6 | #include "Compatibility2Includes.h" 7 | #else 8 | #include // usleep 9 | #endif 10 | 11 | void RakSleep(unsigned int ms) 12 | { 13 | #ifdef _WIN32 14 | Sleep(ms); 15 | #else 16 | usleep(ms * 1000); 17 | #endif 18 | } 19 | -------------------------------------------------------------------------------- /util/armhook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void UnFuck(uintptr_t ptr); 4 | void NOP(uintptr_t addr, unsigned int count); 5 | void WriteMemory(uintptr_t dest, uintptr_t src, size_t size); 6 | void ReadMemory(uintptr_t dest, uintptr_t src, size_t size); 7 | 8 | void SetUpHook(uintptr_t addr, uintptr_t func, uintptr_t *orig); 9 | void InstallMethodHook(uintptr_t addr, uintptr_t func); 10 | void CodeInject(uintptr_t addr, uintptr_t func, int register); -------------------------------------------------------------------------------- /vendor/raknet/FileOperations.h: -------------------------------------------------------------------------------- 1 | #ifndef __FILE_OPERATIONS_H 2 | #define __FILE_OPERATIONS_H 3 | 4 | #include "Export.h" 5 | 6 | bool RAK_DLL_EXPORT WriteFileWithDirectories( const char *path, char *data, unsigned dataLength ); 7 | bool RAK_DLL_EXPORT IsSlash(unsigned char c); 8 | void RAK_DLL_EXPORT AddSlash( char *input ); 9 | void RAK_DLL_EXPORT QuoteIfSpaces(char *str); 10 | bool RAK_DLL_EXPORT DirectoryExists(const char *directory); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /vendor/raknet/LinuxStrings.cpp: -------------------------------------------------------------------------------- 1 | 2 | #if (defined(__GNUC__) || defined(__GCCXML__)) 3 | #include 4 | int _stricmp(const char* s1, const char* s2) 5 | { 6 | return strcasecmp(s1,s2); 7 | } 8 | int _strnicmp(const char* s1, const char* s2, size_t n) 9 | { 10 | return strncasecmp(s1,s2,n); 11 | } 12 | //#ifndef __CYGWIN__ 13 | //int _unlink(const char* filename) 14 | //{ 15 | // return remove(filename); 16 | //} 17 | //#endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /vendor/raknet/RouterInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef __ROUTER_INTERFACE_H 2 | #define __ROUTER_INTERFACE_H 3 | 4 | #include "Export.h" 5 | 6 | /// On failed directed sends, RakNet can call an alternative send function to use. 7 | class RAK_DLL_EXPORT RouterInterface 8 | { 9 | public: 10 | virtual bool Send( const char *data, unsigned bitLength, PacketPriority priority, PacketReliability reliability, char orderingChannel, PlayerID playerId )=0; 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /playertags.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CPlayerTags 4 | { 5 | public: 6 | CPlayerTags(); 7 | ~CPlayerTags(); 8 | 9 | void Render(); 10 | 11 | private: 12 | ImVec2 HealthBarBDR1; 13 | ImVec2 HealthBarBDR2; 14 | ImVec2 HealthBarBG1; 15 | ImVec2 HealthBarBG2; 16 | ImVec2 HealthBar1; 17 | ImVec2 HealthBar2; 18 | 19 | ImColor HealthBarColor; 20 | ImColor HealthBarBGColor; 21 | ImColor HealthBarBDRColor; 22 | 23 | RwTexture* m_pAfk_icon; 24 | 25 | void Draw(VECTOR* vec, char* szNick, uint32_t dwColor, 26 | float fDist, float fHealth, float fArmour, bool bAfk); 27 | }; -------------------------------------------------------------------------------- /game/RW/RenderWare.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rwlpcore.h" 4 | #include "rwcore.h" 5 | 6 | /* skeleton.h */ 7 | typedef struct RsGlobalType RsGlobalType; 8 | struct RsGlobalType 9 | { 10 | const RwChar *appName; 11 | RwInt32 maximumWidth; 12 | RwInt32 maximumHeight; 13 | // useless stuff 14 | // ... 15 | }; 16 | 17 | #define RWRGBALONG(r,g,b,a) ((unsigned int) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))) 18 | 19 | /* rtpng.h */ 20 | extern RwImage* (*RtPNGImageWrite)(RwImage* image, const RwChar* imageName); 21 | extern RwImage* (*RtPNGImageRead)(const RwChar* imageName); 22 | 23 | extern RsGlobalType* RsGlobal; -------------------------------------------------------------------------------- /net/gangzonepool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_GANG_ZONES 1024 4 | 5 | typedef struct _GANG_ZONE 6 | { 7 | float fPos[4]; 8 | uint32_t dwColor; 9 | uint32_t dwAltColor; 10 | } GANG_ZONE; 11 | 12 | class CGangZonePool 13 | { 14 | public: 15 | CGangZonePool(); 16 | ~CGangZonePool(); 17 | 18 | void New(uint16_t wZone, float fMinX, float fMinY, float fMaxX, float fMaxY, uint32_t dwColor); 19 | void Delete(uint16_t wZone); 20 | 21 | void Draw(); 22 | 23 | void Flash(uint16_t wZone, uint32_t dwColor); 24 | void StopFlash(uint16_t wZone); 25 | 26 | private: 27 | GANG_ZONE *m_pGangZone[MAX_GANG_ZONES]; 28 | bool m_bSlotState[MAX_GANG_ZONES]; 29 | }; -------------------------------------------------------------------------------- /game/object.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CObject : public CEntity 4 | { 5 | public: 6 | MATRIX4X4 m_matTarget; 7 | MATRIX4X4 m_matCurrent; 8 | uint8_t m_byteMoving; 9 | float m_fMoveSpeed; 10 | bool m_bIsPlayerSurfing; 11 | 12 | CObject(int iModel, float fPosX, float fPosY, float fPosZ, VECTOR vecRot, float fDrawDistance); 13 | ~CObject(); 14 | 15 | void Process(float fElapsedTime); 16 | float DistanceRemaining(MATRIX4X4 *matPos); 17 | void EditObject(); 18 | void EnterEditObject(); 19 | 20 | void SetPos(float x, float y, float z); 21 | void MoveTo(float x, float y, float z, float speed); 22 | 23 | void InstantRotate(float x, float y, float z); 24 | }; -------------------------------------------------------------------------------- /game/quaternion.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CQuaternion 4 | { 5 | public: 6 | CQuaternion() : w(1), x(0), y(0), z(0) {}; 7 | CQuaternion(float _x, float _y, float _z, float _w) : x(_x), y(_y), z(_z), w(_w) {}; 8 | 9 | void Set(float _x, float _y, float _z, float _w) 10 | { 11 | w = _w; 12 | x = _x; 13 | y = _y; 14 | z = _z; 15 | } 16 | 17 | void Set(CQuaternion q) 18 | { 19 | w = q.w; 20 | x = q.x; 21 | y = q.y; 22 | z = q.z; 23 | } 24 | 25 | void SetFromMatrix(MATRIX4X4 mat); 26 | void GetMatrix(PMATRIX4X4 mat); 27 | void Normalize(); 28 | void Slerp(CQuaternion *pQ1, CQuaternion *pQ2, float t); 29 | 30 | public: 31 | float w; 32 | float x; 33 | float y; 34 | float z; 35 | }; -------------------------------------------------------------------------------- /extrakeyboard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // keyboard buttons 4 | #define ID_KEY_ALT 1024 5 | #define ID_KEY_TAB 1 6 | #define ID_KEY_C 2 7 | #define ID_KEY_LCTRL 4 8 | #define ID_KEY_SPACE 8 9 | #define ID_KEY_ENTER 16 10 | #define ID_KEY_LSHIFT 32 11 | #define ID_KEY_E 64 12 | #define ID_KEY_RMB 128 13 | #define ID_KEY_Q 256 14 | 15 | #define ID_KEY_TWO 320 16 | #define ID_KEY_TWOS 512 17 | 18 | #define ID_KEY_Y 65536 19 | #define ID_KEY_N 131072 20 | 21 | class CExtraKeyBoard 22 | { 23 | public: 24 | CExtraKeyBoard(); 25 | ~CExtraKeyBoard(); 26 | 27 | void Render(); 28 | void Clear(); 29 | void Show(bool bShow); 30 | 31 | void AddKeys(); 32 | 33 | public: 34 | bool m_bIsActive; 35 | uint16_t key; 36 | }; -------------------------------------------------------------------------------- /vendor/hash/md5.h: -------------------------------------------------------------------------------- 1 | // See md5.cpp for code license. 2 | 3 | 4 | #ifndef MD5_H 5 | #define MD5_H 6 | 7 | #ifdef __alpha 8 | typedef unsigned int uint32; 9 | #else 10 | typedef unsigned long uint32; 11 | #endif 12 | 13 | struct MD5Context { 14 | uint32 buf[4]; 15 | uint32 bits[2]; 16 | unsigned char in[64]; 17 | }; 18 | 19 | void MD5Init(struct MD5Context *context); 20 | void MD5Update(struct MD5Context *context, unsigned char const *buf, 21 | unsigned len); 22 | void MD5Final(unsigned char digest[16], struct MD5Context *context); 23 | void MD5Transform(uint32 buf[4], uint32 const in[16]); 24 | 25 | /* 26 | * This is needed to make RSAREF happy on some MS-DOS compilers. 27 | */ 28 | typedef struct MD5Context MD5_CTX; 29 | 30 | #endif /* !MD5_H */ -------------------------------------------------------------------------------- /game/camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CCamera 4 | { 5 | public: 6 | CCamera() { m_matPos = (MATRIX4X4*)(g_libGTASA+0x8B1104); } 7 | ~CCamera() {} 8 | 9 | // 0.3.7 10 | void SetBehindPlayer(); 11 | // 0.3.7 12 | void Restore(); 13 | // 0.3.7 14 | void SetPosition(float fX, float fY, float fZ, float fRotationX, float fRotationY, float fRotationZ); 15 | // 0.3.7 16 | void LookAtPoint(float fX, float fY, float fZ, int iType); 17 | 18 | void GetMatrix(PMATRIX4X4 mat); 19 | // 0.3.7 20 | void InterpolateCameraPos(VECTOR *posFrom, VECTOR *posTo, int time, uint8_t mode); 21 | // 0.3.7 22 | void InterpolateCameraLookAt(VECTOR *posFrom, VECTOR *posTo, int time, uint8_t mode); 23 | 24 | private: 25 | ENTITY_TYPE* m_pEntity; 26 | MATRIX4X4 *m_matPos; 27 | }; -------------------------------------------------------------------------------- /timer.cpp: -------------------------------------------------------------------------------- 1 | #include "timer.hpp" 2 | #include 3 | 4 | Timer::Timer() { 5 | } 6 | void Timer::add(std::chrono::milliseconds delay, 7 | std::function callback, 8 | bool asynchronous) { 9 | if (asynchronous) { 10 | std::thread([=]() { 11 | std::this_thread::sleep_for(std::chrono::milliseconds(delay)); 12 | callback(); 13 | }).detach(); 14 | } 15 | else { 16 | std::this_thread::sleep_for(std::chrono::milliseconds(delay)); 17 | callback(); 18 | } 19 | } 20 | 21 | // USING: Timer timer; 22 | // USING: timer.add(std::chrono::milliseconds(1000), bar, true); 23 | // USING: timer.add(std::chrono::milliseconds(500), foo); 24 | // USING: timer.add(std::chrono::milliseconds(2000), []{}, false); -------------------------------------------------------------------------------- /game/entity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CEntity 4 | { 5 | public: 6 | CEntity() {}; 7 | virtual ~CEntity() {}; 8 | 9 | // 0.3.7 10 | void GetMatrix(PMATRIX4X4 Matrix); 11 | // 0.3.7 12 | void SetMatrix(MATRIX4X4 Matrix); 13 | // 0.3.7 14 | void GetMoveSpeedVector(PVECTOR Vector); 15 | // 0.3.7 16 | void SetMoveSpeedVector(VECTOR Vector); 17 | 18 | void GetTurnSpeedVector(PVECTOR Vector); 19 | void SetTurnSpeedVector(VECTOR Vector); 20 | 21 | // 0.3.7 22 | uint16_t GetModelIndex(); 23 | // 0.3.7 24 | void TeleportTo(float fX, float fY, float fZ); 25 | 26 | bool SetModelIndex(unsigned int uiModel); 27 | // 0.3.7 28 | bool IsAdded(); 29 | // 0.3.7 30 | float GetDistanceFromCamera(); 31 | float GetDistanceFromLocalPlayerPed(); 32 | float GetDistanceFromPoint(float x, float y, float z); 33 | 34 | public: 35 | ENTITY_TYPE *m_pEntity; 36 | uint32_t m_dwGTAId; 37 | }; -------------------------------------------------------------------------------- /main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "vendor/RakNet/SAMP/samp_netencr.h" 11 | #include "vendor/RakNet/SAMP/SAMPRPC.h" 12 | #include "util/util.h" 13 | 14 | #define SAMP_VERSION "0.3.7" 15 | #define MODSA_VERSION "0.0.0.4" 16 | #define MODSA_VERCLR "Green" 17 | 18 | #define ADDRZERO "93.170.76.34" 19 | #define ADDRONE "37.143.12.132" 20 | #define ADDRTWO "37.230.139.49" 21 | #define ADDRFOUR "game.samp-mobile.com" 22 | #define ADDRLOC "192.168.0.42" 23 | 24 | #define MAX_PLAYERS 1004 25 | #define MAX_VEHICLES 2000 26 | #define MAX_PLAYER_NAME 24 27 | 28 | #define RAKSAMP_CLIENT 29 | #define NETCODE_CONNCOOKIELULZ 0x6969 30 | 31 | extern uintptr_t g_libGTASA; 32 | extern const char* g_pszStorage; 33 | 34 | void Log(const char *fmt, ...); 35 | uint32_t GetTickCount(); -------------------------------------------------------------------------------- /net/objectpool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define INVALID_OBJECT_ID 0xFFF9 4 | #define MAX_OBJECTS 1000 5 | 6 | class CObjectPool 7 | { 8 | private: 9 | bool m_bObjectSlotState[MAX_OBJECTS]; 10 | CObject *m_pObjects[MAX_OBJECTS]; 11 | 12 | public: 13 | CObjectPool(); 14 | ~CObjectPool(); 15 | 16 | bool New(uint16_t ObjectID, int iModel, VECTOR vecPos, VECTOR vecRot, float fDrawDistance = 0); 17 | bool Delete(uint16_t ObjectID); 18 | 19 | bool GetSlotState(uint16_t ObjectID) 20 | { 21 | if(ObjectID > MAX_OBJECTS) return false; 22 | return m_bObjectSlotState[ObjectID]; 23 | }; 24 | 25 | CObject *GetAt(uint16_t ObjectID) 26 | { 27 | if(ObjectID > MAX_OBJECTS || !m_bObjectSlotState[ObjectID]) return 0; 28 | return m_pObjects[ObjectID]; 29 | }; 30 | 31 | uint16_t FindIDFromGtaPtr(ENTITY_TYPE *pGtaObject); 32 | 33 | CObject *GetObjectFromGtaPtr(ENTITY_TYPE *pGtaObject); 34 | 35 | void Process(); 36 | }; -------------------------------------------------------------------------------- /net/pickuppool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_PICKUPS 4096 4 | 5 | #pragma pack(1) 6 | typedef struct _PICKUP 7 | { 8 | int iModel; 9 | int iType; 10 | float fX; 11 | float fY; 12 | float fZ; 13 | } PICKUP; 14 | 15 | typedef struct _DROPPED_WEAPON 16 | { 17 | bool bDroppedWeapon; 18 | PLAYERID fromPlayer; 19 | } DROPPED_WEAPON; 20 | 21 | #pragma pack(1) 22 | class CPickupPool 23 | { 24 | private: 25 | int m_iPickupCount; 26 | uint32_t m_dwHnd[MAX_PICKUPS]; 27 | uint32_t m_iPickupID[MAX_PICKUPS]; 28 | uint32_t m_iTimer[MAX_PICKUPS]; 29 | DROPPED_WEAPON m_droppedWeapon[MAX_PICKUPS]; 30 | PICKUP m_Pickups[MAX_PICKUPS]; 31 | 32 | 33 | public: 34 | CPickupPool(); 35 | ~CPickupPool(); 36 | 37 | void New(PICKUP* pPickup, int iPickup); 38 | void NewWeapon(PICKUP* pPickup, int iPickup); 39 | void Destroy(int iPickup); 40 | void PickedUp(int iPickup); 41 | void Process(); 42 | 43 | int GetNumberFromID(int id); 44 | }; -------------------------------------------------------------------------------- /vendor/raknet/CheckSum.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Generates and validates checksums 3 | /// 4 | /// \note I didn't write this, but took it from http://www.flounder.com/checksum.htm 5 | /// 6 | 7 | #ifndef __CHECKSUM_H 8 | #define __CHECKSUM_H 9 | 10 | /// Generates and validates checksums 11 | class CheckSum 12 | { 13 | 14 | public: 15 | 16 | /// Default constructor 17 | 18 | CheckSum() 19 | { 20 | Clear(); 21 | } 22 | 23 | void Clear() 24 | { 25 | sum = 0; 26 | r = 55665; 27 | c1 = 52845; 28 | c2 = 22719; 29 | } 30 | 31 | void Add ( unsigned int w ); 32 | 33 | 34 | void Add ( unsigned short w ); 35 | 36 | void Add ( unsigned char* b, unsigned int length ); 37 | 38 | void Add ( unsigned char b ); 39 | 40 | unsigned int Get () 41 | { 42 | return sum; 43 | } 44 | 45 | protected: 46 | unsigned short r; 47 | unsigned short c1; 48 | unsigned short c2; 49 | unsigned int sum; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_SETTINGS_STRING 0x7F 4 | 5 | struct stSettings 6 | { 7 | // client 8 | char szNickName[MAX_PLAYER_NAME+1]; 9 | char szHost[MAX_SETTINGS_STRING+1]; 10 | int iPort; 11 | char szPassword[MAX_SETTINGS_STRING+1]; 12 | 13 | // debug 14 | bool bDebug; 15 | bool bOnline; 16 | 17 | // gui 18 | char szFont[40]; 19 | float fFontSize; 20 | int iFontOutline; 21 | float fChatPosX; 22 | float fChatPosY; 23 | float fChatSizeX; 24 | float fChatSizeY; 25 | int iChatMaxMessages; 26 | float fSpawnScreenPosX; 27 | float fSpawnScreenPosY; 28 | float fSpawnScreenSizeX; 29 | float fSpawnScreenSizeY; 30 | float fHealthBarWidth; 31 | float fHealthBarHeight; 32 | 33 | // m0d_SA gui 34 | float fCheatsBoxWidth; 35 | float fCheatsBoxHeight; 36 | 37 | bool fCheatsBox; 38 | }; 39 | 40 | class CSettings 41 | { 42 | public: 43 | CSettings(); 44 | ~CSettings(); 45 | 46 | stSettings& Get() { return m_Settings; } 47 | 48 | private: 49 | struct stSettings m_Settings; 50 | }; -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := d3d9 6 | LOCAL_LDLIBS := -llog 7 | 8 | # samp 9 | FILE_LIST := $(wildcard $(LOCAL_PATH)/*.cpp) 10 | FILE_LIST += $(wildcard $(LOCAL_PATH)/game/*.cpp) 11 | FILE_LIST += $(wildcard $(LOCAL_PATH)/net/*.cpp) 12 | FILE_LIST += $(wildcard $(LOCAL_PATH)/util/*.cpp) 13 | FILE_LIST += $(wildcard $(LOCAL_PATH)/game/RW/RenderWare.cpp) 14 | FILE_LIST += $(wildcard $(LOCAL_PATH)/gui/*.cpp) 15 | 16 | # vendor 17 | FILE_LIST += $(wildcard $(LOCAL_PATH)/vendor/inih/cpp/INIReader.cpp) 18 | FILE_LIST += $(wildcard $(LOCAL_PATH)/vendor/inih/ini.c) 19 | FILE_LIST += $(wildcard $(LOCAL_PATH)/vendor/RakNet/*.cpp) 20 | FILE_LIST += $(wildcard $(LOCAL_PATH)/vendor/RakNet/SAMP/*.cpp) 21 | FILE_LIST += $(wildcard $(LOCAL_PATH)/vendor/imgui/*.cpp) 22 | FILE_LIST += $(wildcard $(LOCAL_PATH)/vendor/hash/md5.cpp) 23 | 24 | LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%) 25 | 26 | LOCAL_CPPFLAGS := -w -s -fvisibility=hidden -pthread -Wall -fpack-struct=1 -O2 -std=c++14 -fexceptions 27 | include $(BUILD_SHARED_LIBRARY) -------------------------------------------------------------------------------- /dialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define DIALOG_STYLE_MSGBOX 0 4 | #define DIALOG_STYLE_INPUT 1 5 | #define DIALOG_STYLE_LIST 2 6 | #define DIALOG_STYLE_PASSWORD 3 7 | #define DIALOG_STYLE_TABLIST 4 8 | #define DIALOG_STYLE_TABLIST_HEADERS 5 9 | 10 | class CDialogWindow 11 | { 12 | public: 13 | CDialogWindow(); 14 | ~CDialogWindow(); 15 | 16 | void Render(); 17 | void Clear(); 18 | void ShowListItems(); 19 | void ShowListInfo(); 20 | void GetListItemsCount(); 21 | void Show(bool bShow); 22 | void SetInfo(char* szInfo, int length); 23 | void ShowListItemsWithHeader(); 24 | void ShowListInfoWithHeader(); 25 | 26 | void DrawFormattedText(); 27 | 28 | public: 29 | bool m_bIsActive; 30 | uint8_t m_byteDialogStyle; 31 | uint16_t m_wDialogID; 32 | char m_utf8Title[64*3 + 1]; 33 | char* m_putf8Info; 34 | char* m_pszInfo; 35 | char* szTabInfo; 36 | char m_utf8Button1[64*3 + 1]; 37 | char m_utf8Button2[64*3 + 1]; 38 | 39 | float m_fSizeX; 40 | float m_fSizeY; 41 | 42 | int passEntering; 43 | int fxdialog; 44 | 45 | int m_selectedItem; 46 | 47 | int m_bSL; 48 | }; -------------------------------------------------------------------------------- /game/util.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | PED_TYPE* GamePool_FindPlayerPed(); 4 | PED_TYPE* GamePool_Ped_GetAt(int iID); 5 | int GamePool_Ped_GetIndex(PED_TYPE *pActor); 6 | 7 | VEHICLE_TYPE *GamePool_Vehicle_GetAt(int iID); 8 | int GamePool_Vehicle_GetIndex(VEHICLE_TYPE *pVehicle); 9 | 10 | ENTITY_TYPE *GamePool_Object_GetAt(int iID); 11 | 12 | int LineOfSight(VECTOR* start, VECTOR* end, void* colpoint, uintptr_t ent, 13 | char buildings, char vehicles, char peds, char objects, char dummies, bool seeThrough, bool camera, bool unk); 14 | 15 | bool IsPedModel(unsigned int uiModel); 16 | bool IsValidModel(unsigned int uiModelID); 17 | uint16_t GetModelReferenceCount(int nModelIndex); 18 | 19 | void InitPlayerPedPtrRecords(); 20 | void SetPlayerPedPtrRecord(uint8_t bytePlayer, uintptr_t dwPedPtr); 21 | uint8_t FindPlayerNumFromPedPtr(uintptr_t dwPedPtr); 22 | 23 | uintptr_t GetTexture(const char* texture); 24 | uintptr_t LoadTextureFromDB(const char* dbname, const char* texture); 25 | void DefinedState2d(); 26 | void SetScissorRect(void* pRect); 27 | float DegToRad(float fDegrees); 28 | // 0.3.7 29 | float FloatOffset(float f1, float f2); -------------------------------------------------------------------------------- /vendor/raknet/DS_HuffmanEncodingTreeNode.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] A single node in the Huffman Encoding Tree. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __HUFFMAN_ENCODING_TREE_NODE 19 | #define __HUFFMAN_ENCODING_TREE_NODE 20 | 21 | struct HuffmanEncodingTreeNode 22 | { 23 | unsigned char value; 24 | unsigned weight; 25 | HuffmanEncodingTreeNode *left; 26 | HuffmanEncodingTreeNode *right; 27 | HuffmanEncodingTreeNode *parent; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /game/pad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum ePadKeys 4 | { 5 | // KEY_ OnFoot InCar 6 | KEY_ACTION = 0, // TAB | ALT GR/LCTRL/NUM0 | 1 7 | KEY_CROUCH, // C | H / CAPSLOCK | 2 8 | KEY_FIRE, // LCTRL/LMB | LALT | 4 9 | KEY_SPRINT, // SPACE | W | 8 10 | KEY_SECONDARY_ATTACK, // ENTER | ENTER | 16 11 | KEY_JUMP, // LSHIFT | S | 32 12 | KEY_LOOK_RIGHT, // | E | 64 13 | KEY_HANDBRAKE, // RMB | SPACE | 128 14 | KEY_LOOK_LEFT, // | Q | 256 15 | KEY_SUBMISSION, // NUM1/MMB | 2/NUMPAD+ | 512 16 | KEY_WALK, // LALT | | 1024 17 | KEY_ANALOG_UP, // NUM8 | NUM8 | 2048 18 | KEY_ANALOG_DOWN, // NUM2 | NUM2 | 4096 19 | KEY_ANALOG_LEFT, // NUM4 | NUM4 | 8192 20 | KEY_ANALOG_RIGHT, // NUM6 | NUM6 | 16384 21 | KEY_YES, // Y | Y | 65536 22 | KEY_NO, // N | N | 131072 23 | SIZE 24 | }; 25 | 26 | typedef struct 27 | { 28 | uint16_t wKeyLR; 29 | uint16_t wKeyUD; 30 | bool bKeys[ePadKeys::SIZE]; 31 | bool bIgnoreJump; 32 | } PAD_KEYS; 33 | 34 | extern PAD_KEYS LocalPlayerKeys; 35 | extern PAD_KEYS RemotePlayerKeys[PLAYER_PED_SLOTS]; -------------------------------------------------------------------------------- /debug.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "game/game.h" 3 | #include "gui/gui.h" 4 | #include "debug.h" 5 | #include "util/armhook.h" 6 | 7 | extern CGame *pGame; 8 | 9 | CDebug::CDebug() 10 | { 11 | m_dwLastTick = GetTickCount(); 12 | } 13 | 14 | CDebug::~CDebug() 15 | { 16 | 17 | } 18 | 19 | uintptr_t (*TextureDatabaseRuntime_GetDatabase)(char *dbname); 20 | uintptr_t TextureDatabaseRuntime_GetDatabase_hook(char *dbname) 21 | { 22 | Log("TextureDatabaseRuntime_GetDatabase: %s", dbname); 23 | return TextureDatabaseRuntime_GetDatabase(dbname); 24 | } 25 | 26 | void CDebug::AddMessage(char* msg) 27 | { 28 | std::string str(msg); 29 | m_Messages.push_back(str); 30 | } 31 | 32 | void CDebug::Render() 33 | { 34 | ImGui::Begin("Debug", nullptr, ImGuiWindowFlags_NoSavedSettings); 35 | for(auto str : m_Messages) 36 | { 37 | ImGui::Text("%s", str.c_str()); 38 | } 39 | 40 | ImGui::End(); 41 | } 42 | 43 | void CDebug::Process() 44 | { 45 | 46 | } 47 | 48 | void CDebug::SpawnLocalPlayer() 49 | { 50 | Log("CDebug: SpawnLocalPlayer"); 51 | CCamera *pGameCamera = pGame->GetCamera(); 52 | pGameCamera->Restore(); 53 | pGameCamera->SetBehindPlayer(); 54 | 55 | pGame->SetWorldTime(12, 0); 56 | } -------------------------------------------------------------------------------- /vendor/raknet/RakNetDefines.h: -------------------------------------------------------------------------------- 1 | /// Define __GET_TIME_64BIT to have RakNetTime use a 64, rather than 32 bit value. A 32 bit value will overflow after about 5 weeks. 2 | /// However, this doubles the bandwidth use for sending times, so don't do it unless you have a reason to. 3 | /// Disabled by default. 4 | // #define __GET_TIME_64BIT 5 | 6 | /// Makes RakNet threadsafe 7 | /// Define this if you use the same instance of RakPeer from multiple threads 8 | /// Otherwise leave it undefined, since it makes things an order of magnitude slower. 9 | /// Disabled by default 10 | // #define _RAKNET_THREADSAFE 11 | 12 | /// Can interrupt a Sleep() if a message is incoming. Useful to define if you pass a large sleep value to RakPeer::Initialize 13 | // #define USE_WAIT_FOR_MULTIPLE_EVENTS 14 | 15 | /// Define __BITSTREAM_NATIVE_END to NOT support endian swapping in the BitStream class. This is faster and is what you should use 16 | /// unless you actually plan to have different endianness systems connect to each other 17 | /// Enabled by default. 18 | #define __BITSTREAM_NATIVE_END 19 | 20 | /// Maximum (stack) size to use with _alloca before using new and delete instead. 21 | #define MAX_ALLOCA_STACK_ALLOCATION 1048576 22 | -------------------------------------------------------------------------------- /net/textlabelpool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_TEXT_LABELS 1024 4 | #define MAX_PLAYER_TEXT_LABELS 1024 5 | #define INVALID_TEXT_LABEL 1025 6 | 7 | #define MAX_LABELS_LENGTH 2048 8 | 9 | #pragma pack(1) 10 | typedef struct _TEXT_LABELS 11 | { 12 | char text[2048+1]; 13 | char textWithoutColors[2048+1]; 14 | uint32_t color; 15 | VECTOR pos; 16 | float drawDistance; 17 | int virtualWorld; 18 | bool useLineOfSight; 19 | PLAYERID attachedToPlayerID; 20 | VEHICLEID attachedToVehicleID; 21 | VECTOR offsetCoords; 22 | float m_fTrueX; 23 | } TEXT_LABELS; 24 | 25 | class CText3DLabelsPool 26 | { 27 | private: 28 | TEXT_LABELS *m_pTextLabels[MAX_TEXT_LABELS + MAX_PLAYER_TEXT_LABELS + 2]; 29 | bool m_bSlotState[MAX_TEXT_LABELS + MAX_PLAYER_TEXT_LABELS + 2]; 30 | 31 | public: 32 | CText3DLabelsPool(); 33 | ~CText3DLabelsPool(); 34 | 35 | void CreateTextLabel(int labelID, char* text, uint32_t color, 36 | float posX, float posY, float posZ, float drawDistance, 37 | bool useLOS, PLAYERID attachedToPlayerID, VEHICLEID attachedToVehicleID); 38 | void Delete(int labelID); 39 | void AttachToPlayer(int labelID, PLAYERID playerID, VECTOR pos); 40 | void AttachToVehicle(int labelID, VEHICLEID vehicleID, VECTOR pos); 41 | void Update3DLabel(int labelID, uint32_t color, char* text); 42 | void Draw(); 43 | }; -------------------------------------------------------------------------------- /gui/gui.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "vendor/imgui/imgui.h" 3 | 4 | enum eTouchType 5 | { 6 | TOUCH_POP = 1, 7 | TOUCH_PUSH = 2, 8 | TOUCH_MOVE = 3 9 | }; 10 | 11 | class CGUI 12 | { 13 | public: 14 | CGUI(); 15 | ~CGUI(); 16 | 17 | void Render(); 18 | 19 | float ScaleX(float x) { return m_vecScale.x * x; } 20 | float ScaleY(float y) { return m_vecScale.y * y; } 21 | ImFont* GetFont() { return m_pFont; } 22 | ImFont* GetSampFont() { return m_pSampFont; } 23 | float GetFontSize() { return m_fFontSize; } 24 | 25 | bool OnTouchEvent(int type, bool multi, int x, int y); 26 | 27 | void RenderText(ImVec2& pos, ImU32 col, bool bOutline, const char* text_begin, const char* text_end = nullptr); 28 | 29 | private: 30 | void RenderRakNetStatistics(); 31 | void RenderCheatBox(); 32 | void SetupStyleColors(); 33 | 34 | private: 35 | ImFont* m_pFont; 36 | ImFont* m_pSampFont; 37 | 38 | ImVec2 m_vecScale; 39 | float m_fFontSize; 40 | float m_fCheatsBoxPosX; 41 | float m_fCheatsBoxPosY; 42 | 43 | bool m_fCheatsBox; 44 | 45 | bool m_bMousePressed; 46 | ImVec2 m_vecMousePos; 47 | 48 | bool m_bNeedClearMousePos; 49 | 50 | public: 51 | int m_gm; 52 | int m_fz; 53 | int m_wh; 54 | int m_fly; 55 | int m_nf; 56 | int m_bd; 57 | int m_gravity; 58 | int m_xyz; 59 | int m_INVIS; 60 | int m_FLASH; 61 | int m_Airbreak; 62 | }; -------------------------------------------------------------------------------- /vendor/raknet/Rand.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Random number generator 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | 19 | #ifndef __RAND_H 20 | #define __RAND_H 21 | 22 | #include "Export.h" 23 | 24 | /// Initialise seed for Random Generator 25 | /// \param[in] seed The seed value for the random number generator. 26 | extern void RAK_DLL_EXPORT seedMT( unsigned int seed ); 27 | 28 | /// \internal 29 | extern unsigned int RAK_DLL_EXPORT reloadMT( void ); 30 | 31 | /// Gets a random unsigned int 32 | /// \return an integer random value. 33 | extern unsigned int RAK_DLL_EXPORT randomMT( void ); 34 | 35 | /// Gets a random float 36 | /// \return 0 to 1.0f, inclusive 37 | extern float RAK_DLL_EXPORT frandomMT( void ); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /game/vehicle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CVehicle : public CEntity 4 | { 5 | public: 6 | CVehicle(int iType, float fPosX, float fPosY, float fPosZ, float fRotation = 0.0f, bool bSiren = false); 7 | ~CVehicle(); 8 | 9 | void LinkToInterior(int iInterior); 10 | void SetColor(int iColor1, int iColor2); 11 | 12 | void SetHealth(float fHealth); 13 | float GetHealth(); 14 | 15 | // 0.3.7 16 | bool IsOccupied(); 17 | 18 | // 0.3.7 19 | void SetInvulnerable(bool bInv); 20 | // 0.3.7 21 | bool IsDriverLocalPlayer(); 22 | // 0.3.7 23 | bool HasSunk(); 24 | 25 | void ProcessMarkers(); 26 | 27 | void RemoveEveryoneFromVehicle(); 28 | 29 | void SetWheelPopped(uint8_t bytePopped); 30 | void SetDoorState(int iState); 31 | 32 | void UpdateDamageStatus(uint32_t dwPanelDamage, uint32_t dwDoorDamage, uint8_t byteLightDamage); 33 | 34 | unsigned int GetVehicleSubtype(); 35 | 36 | void SetEngineState(int iState); 37 | void SetLightsState(int iState); 38 | int GetDoorState(); 39 | 40 | public: 41 | VEHICLE_TYPE *m_pVehicle; 42 | bool m_bIsLocked; 43 | CVehicle *m_pTrailer; 44 | uint32_t m_dwMarkerID; 45 | bool m_bIsInvulnerable; 46 | bool m_bDoorsLocked; 47 | uint8_t m_byteObjectiveVehicle; // Is this a special objective vehicle? 0/1 48 | uint8_t m_bSpecialMarkerEnabled; 49 | 50 | 51 | uint8_t m_byteColor1; 52 | uint8_t m_byteColor2; 53 | bool m_bColorChanged; 54 | float cHealth; 55 | }; -------------------------------------------------------------------------------- /vendor/raknet/DataCompressor.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief DataCompressor does compression on a block of data. Not very good compression, but it's small and fast so is something you can use per-message at runtime. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | 19 | #ifndef __DATA_COMPRESSOR_H 20 | #define __DATA_COMPRESSOR_H 21 | 22 | #include "DS_HuffmanEncodingTree.h" 23 | #include "Export.h" 24 | 25 | /// \brief Does compression on a block of data. Not very good compression, but it's small and fast so is something you can compute at runtime. 26 | class RAK_DLL_EXPORT DataCompressor 27 | { 28 | public: 29 | static void Compress( unsigned char *userData, unsigned sizeInBytes, RakNet::BitStream * output ); 30 | static unsigned DecompressAndAllocate( RakNet::BitStream * input, unsigned char **output ); 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /vendor/raknet/GetTime.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief Returns the value from QueryPerformanceCounter. This is the function RakNet uses to represent time. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __GET_TIME_H 19 | #define __GET_TIME_H 20 | 21 | #include "Export.h" 22 | #include "NetworkTypes.h" // For RakNetTime 23 | 24 | /// The namespace RakNet is not consistently used. It's only purpose is to avoid compiler errors for classes whose names are very common. 25 | /// For the most part I've tried to avoid this simply by using names very likely to be unique for my classes. 26 | namespace RakNet 27 | { 28 | /// Returns the value from QueryPerformanceCounter. This is the function RakNet uses to represent time. 29 | RakNetTime RAK_DLL_EXPORT GetTime( void ); 30 | RakNetTimeNS RAK_DLL_EXPORT GetTimeNS( void ); 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /chatwindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAX_MESSAGE_LENGTH 144 4 | #define MAX_LINE_LENGTH MAX_MESSAGE_LENGTH / 2 5 | 6 | enum eChatMessageType 7 | { 8 | CHAT_TYPE_NONE = 0, 9 | CHAT_TYPE_CHAT, 10 | CHAT_TYPE_INFO, 11 | CHAT_TYPE_DEBUG 12 | }; 13 | 14 | typedef struct 15 | { 16 | eChatMessageType eType; 17 | char utf8Message[MAX_MESSAGE_LENGTH * 3 + 1]; 18 | char szNick[MAX_PLAYER_NAME + 1]; 19 | uint32_t dwTextColor; 20 | uint32_t dwNickColor; 21 | } CHAT_WINDOW_ENTRY; 22 | 23 | class CChatWindow 24 | { 25 | friend class CGUI; 26 | public: 27 | CChatWindow(); 28 | ~CChatWindow(); 29 | 30 | void AddChatMessage(char* szNick, uint32_t dwNickColor, char* szMessage); 31 | void AddInfoMessage(char* szFormat, ...); 32 | void AddDebugMessage(char* szFormat, ...); 33 | void AddClientMessage(uint32_t dwColor, char* szStr); 34 | 35 | protected: 36 | void Render(); 37 | bool OnTouchEvent(int type, bool multi, int x, int y); 38 | 39 | public: 40 | void RenderText(const char* u8Str, float posX, float posY, uint32_t dwColor); 41 | private: 42 | void FilterInvalidChars(char* szString); 43 | void AddToChatWindowBuffer(eChatMessageType eType, char* szString, char* szNick, 44 | uint32_t dwTextColor, uint32_t dwNickColor); 45 | void PushBack(CHAT_WINDOW_ENTRY &entry); 46 | 47 | private: 48 | float m_fChatPosX, m_fChatPosY; 49 | float m_fChatSizeX, m_fChatSizeY; 50 | 51 | int m_iMaxMessages; 52 | std::list m_ChatWindowEntries; 53 | 54 | uint32_t m_dwTextColor; 55 | uint32_t m_dwInfoColor; 56 | uint32_t m_dwDebugColor; 57 | }; -------------------------------------------------------------------------------- /shpora.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "game/game.h" 3 | #include "net/netgame.h" 4 | #include "gui/gui.h" 5 | #include "vendor/imgui/imgui_internal.h" 6 | #include "keyboard.h" 7 | #include "shpora.h" 8 | 9 | #include 10 | #include 11 | 12 | extern CGUI *pGUI; 13 | extern CGame *pGame; 14 | extern CNetGame *pNetGame; 15 | extern CKeyBoard *pKeyBoard; 16 | 17 | CShpora::CShpora() 18 | { 19 | m_bIsActive = false; 20 | step = 0; 21 | } 22 | 23 | CShpora::~CShpora() 24 | { 25 | 26 | } 27 | 28 | void CShpora::Show(bool bShow) 29 | { 30 | if(pGame) 31 | pGame->FindPlayerPed()->TogglePlayerControllable(!bShow); 32 | 33 | m_bIsActive = bShow; 34 | } 35 | 36 | void CShpora::Clear() 37 | { 38 | m_bIsActive = false; 39 | step = 0; 40 | } 41 | 42 | void CShpora::Render() 43 | { 44 | if(!m_bIsActive) return; 45 | 46 | ImGuiIO &io = ImGui::GetIO(); 47 | 48 | ImGui::StyleColorsClassic(); 49 | 50 | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8,8)); 51 | 52 | ImGui::Begin("shpora", nullptr, 53 | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize); 54 | 55 | if(ImGui::Button("Close", ImVec2(125, 50))) 56 | { 57 | step = 0; 58 | Show(false); 59 | } 60 | ImGui::SetWindowSize(ImVec2(-1, -1)); 61 | ImVec2 size = ImGui::GetWindowSize(); 62 | ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x)/2), ((io.DisplaySize.y - size.y)/2)) ); 63 | ImGui::End(); 64 | 65 | ImGui::PopStyleVar(); 66 | } -------------------------------------------------------------------------------- /vendor/raknet/SystemAddressList.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief Just a class to hold a list of systems 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __SYSTEM_ID_LIST_H 19 | #define __SYSTEM_ID_LIST_H 20 | 21 | #include "NetworkTypes.h" 22 | #include "DS_OrderedList.h" 23 | 24 | class SystemAddressList 25 | { 26 | public: 27 | SystemAddressList(); 28 | SystemAddressList(PlayerID system); 29 | void AddSystem(PlayerID system); 30 | void RandomizeOrder(void); 31 | void Serialize(RakNet::BitStream *out); 32 | bool Deserialize(RakNet::BitStream *in); 33 | bool Save(const char *filename); 34 | bool Load(const char *filename); 35 | void RemoveSystem(PlayerID system); 36 | unsigned Size(void) const; 37 | PlayerID& operator[] ( const unsigned int position ) const; 38 | void Clear(void); 39 | 40 | DataStructures::List * GetList(void); 41 | 42 | protected: 43 | DataStructures::List systemList; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /vendor/raknet/DS_ByteQueue.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Byte queue 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __BYTE_QUEUE_H 19 | #define __BYTE_QUEUE_H 20 | 21 | #include "Export.h" 22 | 23 | /// The namespace DataStructures was only added to avoid compiler errors for commonly named data structures 24 | /// As these data structures are stand-alone, you can use them outside of RakNet for your own projects if you wish. 25 | namespace DataStructures 26 | { 27 | class ByteQueue 28 | { 29 | public: 30 | ByteQueue(); 31 | ~ByteQueue(); 32 | void WriteBytes(const char *in, unsigned length); 33 | bool ReadBytes(char *out, unsigned length, bool peek); 34 | unsigned GetBytesWritten(void) const; 35 | void IncrementReadOffset(unsigned length); 36 | void Clear(void); 37 | void Print(void); 38 | 39 | protected: 40 | char *data; 41 | unsigned readOffset, writeOffset, lengthAllocated; 42 | }; 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /vendor/raknet/PacketPool.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] A pool for the Packet class. I don't believe this is used any longer. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | // TODO - Remove this file from the project 19 | /* 20 | #ifndef __PACKET_POOL 21 | #define __PACKET_POOL 22 | #include "SimpleMutex.h" 23 | #include "DS_Queue.h" 24 | 25 | struct Packet; 26 | 27 | class PacketPool 28 | { 29 | 30 | public: 31 | PacketPool(); 32 | ~PacketPool(); 33 | 34 | static void AddReference(void); 35 | static void RemoveReference(void); 36 | Packet* GetPointer( void ); 37 | void ReleasePointer( Packet *p ); 38 | void ClearPool( void ); 39 | static inline PacketPool* Instance() 40 | { 41 | return I; 42 | } 43 | 44 | private: 45 | DataStructures::Queue pool; 46 | SimpleMutex poolMutex; 47 | static PacketPool *I; 48 | static int referenceCount; 49 | #ifdef _DEBUG 50 | int packetsReleased; 51 | #endif 52 | }; 53 | 54 | #endif 55 | 56 | */ -------------------------------------------------------------------------------- /vendor/raknet/_findfirst.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Original file by the_viking, fixed by Rômulo Fernandes 3 | * Should emulate windows finddata structure 4 | */ 5 | 6 | #ifndef GCC_FINDFIRST_H 7 | #define GCC_FINDFIRST_H 8 | 9 | #if (defined(__GNUC__) || defined(__GCCXML__)) && !defined(__WIN32) 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define _A_NORMAL 0x00 // Normal file 18 | #define _A_RDONLY 0x01 // Read-only file 19 | #define _A_HIDDEN 0x02 // Hidden file 20 | #define _A_SYSTEM 0x04 // System file 21 | #define _A_VOLID 0x08 // Volume ID 22 | #define _A_SUBDIR 0x10 // Subdirectory 23 | #define _A_ARCH 0x20 // File changed since last archive 24 | #define FA_NORMAL 0x00 // Synonym of _A_NORMAL 25 | #define FA_RDONLY 0x01 // Synonym of _A_RDONLY 26 | #define FA_HIDDEN 0x02 // Synonym of _A_HIDDEN 27 | #define FA_SYSTEM 0x04 // Synonym of _A_SYSTEM 28 | #define FA_LABEL 0x08 // Synonym of _A_VOLID 29 | #define FA_DIREC 0x10 // Synonym of _A_SUBDIR 30 | #define FA_ARCH 0x20 // Synonym of _A_ARCH 31 | 32 | typedef struct _finddata_t 33 | { 34 | char name[260]; 35 | int attrib; 36 | unsigned long size; 37 | } _finddata; 38 | 39 | /** Hold information about the current search 40 | */ 41 | typedef struct _findinfo_t 42 | { 43 | DIR* openedDir; 44 | char filter[260]; 45 | } _findinfo; 46 | 47 | long _findfirst(const char *name, _finddata_t *f); 48 | int _findnext(long h, _finddata_t *f); 49 | int _findclose(long h); 50 | 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /keyboard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define LAYOUT_ENG 0 4 | #define LAYOUT_RUS 1 5 | #define LAYOUT_NUM 2 6 | 7 | #define LOWER_CASE 0 8 | #define UPPER_CASE 1 9 | 10 | #define KEY_DEFAULT 0 11 | #define KEY_SHIFT 1 12 | #define KEY_BACKSPACE 2 13 | #define KEY_SWITCH 3 14 | #define KEY_SPACE 4 15 | #define KEY_SEND 5 16 | 17 | #define MAX_INPUT_LEN 0xBF 18 | 19 | struct kbKey 20 | { 21 | ImVec2 pos; 22 | ImVec2 symPos; 23 | float width; 24 | char code[2]; 25 | char name[2][4]; 26 | int type; 27 | int id; 28 | }; 29 | 30 | typedef void keyboard_callback(const char* result); 31 | 32 | class CKeyBoard 33 | { 34 | friend class CGUI; 35 | public: 36 | CKeyBoard(); 37 | ~CKeyBoard(); 38 | 39 | void Open(keyboard_callback* handler); 40 | void Close(); 41 | 42 | bool IsOpen() { return m_bEnable; } 43 | 44 | protected: 45 | void Render(); 46 | bool OnTouchEvent(int type, bool multi, int x, int y); 47 | public: 48 | bool m_bEnable; 49 | 50 | private: 51 | void InitENG(); 52 | void InitRU(); 53 | void InitNUM(); 54 | kbKey* GetKeyFromPos(int x, int y); 55 | 56 | void HandleInput(kbKey &key); 57 | void AddCharToInput(char sym); 58 | void DeleteCharFromInput(); 59 | void Send(); 60 | 61 | bool m_bInited; 62 | ImVec2 m_Size; 63 | ImVec2 m_Pos; 64 | float m_fKeySizeY; 65 | float m_fFontSize; 66 | char* buf; 67 | 68 | int m_iLayout; 69 | int m_iCase; 70 | int m_iPushedKey; 71 | 72 | std::vector m_Rows[3][4]; // eng, rus, num 73 | 74 | std::string m_sInput; 75 | int cl; 76 | char m_utf8Input[MAX_INPUT_LEN*3 + 0xF]; 77 | int m_iInputOffset; 78 | 79 | keyboard_callback *m_pHandler; 80 | }; -------------------------------------------------------------------------------- /vendor/raknet/ClientContextStruct.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Depreciated, back from when I supported IO Completion ports. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __CLIENT_CONTEXT_STRUCT_H 19 | #define __CLIENT_CONTEXT_STRUCT_H 20 | 21 | #ifdef _COMPATIBILITY_1 22 | #elif defined(_WIN32) 23 | //#include 24 | #endif 25 | #include "NetworkTypes.h" 26 | #include "MTUSize.h" 27 | 28 | class RakPeer; 29 | 30 | #ifdef __USE_IO_COMPLETION_PORTS 31 | 32 | struct ClientContextStruct 33 | { 34 | HANDLE handle; // The socket, also used as a file handle 35 | }; 36 | 37 | struct ExtendedOverlappedStruct 38 | { 39 | OVERLAPPED overlapped; 40 | char data[ MAXIMUM_MTU_SIZE ]; // Used to hold data to send 41 | int length; // Length of the actual data to send, always under MAXIMUM_MTU_SIZE 42 | unsigned int binaryAddress; 43 | unsigned short port; 44 | RakPeer *rakPeer; 45 | bool read; // Set to true for reads, false for writes 46 | }; 47 | 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /vendor/raknet/ExtendedOverlappedPool.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Depreciated] This was used for IO completion ports. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | // No longer used as I no longer support IO Completion ports 19 | /* 20 | #ifdef __USE_IO_COMPLETION_PORTS 21 | #ifndef __EXTENDED_OVERLAPPED_POOL 22 | #define __EXTENDED_OVERLAPPED_POOL 23 | #include "SimpleMutex.h" 24 | #include "ClientContextStruct.h" 25 | #include "DS_Queue.h" 26 | 27 | /// Depreciated - for IO completion ports 28 | class ExtendedOverlappedPool 29 | { 30 | 31 | public: 32 | ExtendedOverlappedPool(); 33 | ~ExtendedOverlappedPool(); 34 | ExtendedOverlappedStruct* GetPointer( void ); 35 | void ReleasePointer( ExtendedOverlappedStruct *p ); 36 | static inline ExtendedOverlappedPool* Instance() 37 | { 38 | return & I; 39 | } 40 | 41 | private: 42 | DataStructures::Queue pool; 43 | SimpleMutex poolMutex; 44 | static ExtendedOverlappedPool I; 45 | }; 46 | 47 | #endif 48 | #endif 49 | 50 | */ 51 | -------------------------------------------------------------------------------- /net/playerpool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NO_TEAM 255 4 | 5 | class CPlayerPool 6 | { 7 | public: 8 | CPlayerPool(); 9 | ~CPlayerPool(); 10 | 11 | bool Process(); 12 | 13 | // LOCAL 14 | void SetLocalPlayerName(const char* szName) { strcpy(m_szLocalPlayerName, szName); } 15 | char* GetLocalPlayerName() { return m_szLocalPlayerName; } 16 | void SetLocalPlayerID(PLAYERID MyPlayerID) 17 | { 18 | strcpy(m_szPlayerNames[MyPlayerID], m_szLocalPlayerName); 19 | m_LocalPlayerID = MyPlayerID; 20 | } 21 | PLAYERID GetLocalPlayerID() { return m_LocalPlayerID; } 22 | CLocalPlayer* GetLocalPlayer() { return m_pLocalPlayer; } 23 | 24 | // remote 25 | bool New(PLAYERID playerId, char* szPlayerName, bool bIsNPC); 26 | bool Delete(PLAYERID playerId, uint8_t byteReason); 27 | 28 | CRemotePlayer *GetAt(PLAYERID playerId) 29 | { 30 | if(playerId > MAX_PLAYERS) return nullptr; 31 | return m_pPlayers[playerId]; 32 | } 33 | 34 | bool GetSlotState(PLAYERID playerId) 35 | { 36 | if(playerId > MAX_PLAYERS) return false; 37 | return m_bPlayerSlotState[playerId]; 38 | }; 39 | 40 | void SetPlayerName(PLAYERID playerId, char* szName) { strcpy(m_szPlayerNames[playerId], szName); } 41 | char* GetPlayerName(PLAYERID playerId){ return m_szPlayerNames[playerId]; } 42 | 43 | PLAYERID FindRemotePlayerIDFromGtaPtr(PED_TYPE * pActor); 44 | 45 | private: 46 | // LOCAL 47 | PLAYERID m_LocalPlayerID; 48 | CLocalPlayer *m_pLocalPlayer; 49 | char m_szLocalPlayerName[MAX_PLAYER_NAME+1]; 50 | 51 | // REMOTE 52 | CRemotePlayer *m_pPlayers[MAX_PLAYERS]; 53 | bool m_bPlayerSlotState[MAX_PLAYERS]; 54 | char m_szPlayerNames[MAX_PLAYERS][MAX_PLAYER_NAME+1]; 55 | 56 | }; -------------------------------------------------------------------------------- /vendor/raknet/RPCMap.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] A container class for a list of RPCNodes 3 | /// 4 | /// \ingroup RAKNET_RPC 5 | /// 6 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 7 | /// 8 | /// Usage of RakNet is subject to the appropriate license agreement. 9 | /// Creative Commons Licensees are subject to the 10 | /// license found at 11 | /// http://creativecommons.org/licenses/by-nc/2.5/ 12 | /// Single application licensees are subject to the license found at 13 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 14 | /// Custom license users are subject to the terms therein. 15 | /// GPL license users are subject to the GNU General Public 16 | /// License as published by the Free 17 | /// Software Foundation; either version 2 of the License, or (at your 18 | /// option) any later version. 19 | 20 | #ifndef __RPC_MAP 21 | #define __RPC_MAP 22 | 23 | #include "RPCNode.h" 24 | #include "DS_List.h" 25 | #include "NetworkTypes.h" 26 | #include "Export.h" 27 | 28 | /// \ingroup RAKNET_RPC 29 | /// \internal 30 | /// \brief A container class for a list of RPCNodes 31 | struct RAK_DLL_EXPORT RPCMap 32 | { 33 | public: 34 | RPCMap(); 35 | ~RPCMap(); 36 | void Clear(void); 37 | RPCNode *GetNodeFromIndex(RPCIndex index); 38 | RPCNode *GetNodeFromFunctionName(int *uniqueIdentifier); 39 | RPCIndex GetIndexFromFunctionName(int *uniqueIdentifier); 40 | void AddIdentifierWithFunction(int *uniqueIdentifier, void *functionPointer, bool isPointerToMember); 41 | void AddIdentifierAtIndex(RPCIndex insertionIndex); 42 | void RemoveNode(int *uniqueIdentifier); 43 | protected: 44 | DataStructures::List rpcSet; 45 | }; 46 | 47 | #endif 48 | 49 | -------------------------------------------------------------------------------- /vendor/raknet/RakNetworkFactory.cpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// 3 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 4 | /// 5 | /// Usage of RakNet is subject to the appropriate license agreement. 6 | /// Creative Commons Licensees are subject to the 7 | /// license found at 8 | /// http://creativecommons.org/licenses/by-nc/2.5/ 9 | /// Single application licensees are subject to the license found at 10 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 11 | /// Custom license users are subject to the terms therein. 12 | /// GPL license users are subject to the GNU General Public 13 | /// License as published by the Free 14 | /// Software Foundation; either version 2 of the License, or (at your 15 | /// option) any later version. 16 | 17 | #include "LogCommandParser.h" 18 | #include "RakNetworkFactory.h" 19 | #include "RakServerInterface.h" 20 | #include "RakClientInterface.h" 21 | #include "RakServer.h" 22 | #include "RakClient.h" 23 | #include "RakPeerInterface.h" 24 | #include "RakPeer.h" 25 | 26 | RakClientInterface* RakNetworkFactory::GetRakClientInterface( void ) 27 | { 28 | return new RakClient; 29 | } 30 | RakServerInterface* RakNetworkFactory::GetRakServerInterface( void ) 31 | { 32 | return new RakServer; 33 | } 34 | RakPeerInterface* RakNetworkFactory::GetRakPeerInterface( void ) 35 | { 36 | return new RakPeer; 37 | } 38 | 39 | void RakNetworkFactory::DestroyRakClientInterface( RakClientInterface* i ) 40 | { 41 | delete ( RakClient* ) i; 42 | } 43 | void RakNetworkFactory::DestroyRakServerInterface( RakServerInterface* i ) 44 | { 45 | delete ( RakServer* ) i; 46 | } 47 | void RakNetworkFactory::DestroyRakPeerInterface( RakPeerInterface* i ) 48 | { 49 | delete ( RakPeer* ) i; 50 | } 51 | -------------------------------------------------------------------------------- /net/vehiclepool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct _NEW_VEHICLE 4 | { 5 | VEHICLEID VehicleID; 6 | int iVehicleType; 7 | VECTOR vecPos; 8 | float fRotation; 9 | uint8_t aColor1; 10 | uint8_t aColor2; 11 | float fHealth; 12 | uint8_t byteInterior; 13 | uint32_t dwDoorDamageStatus; 14 | uint32_t dwPanelDamageStatus; 15 | uint8_t byteLightDamageStatus; 16 | uint8_t byteTireDamageStatus; 17 | uint8_t byteAddSiren; 18 | uint8_t byteModSlots[14]; 19 | uint8_t bytePaintjob; 20 | uint32_t cColor1; 21 | uint32_t cColor2; 22 | uint8_t byteUnk; 23 | } NEW_VEHICLE; 24 | 25 | class CVehiclePool 26 | { 27 | public: 28 | CVehiclePool(); 29 | ~CVehiclePool(); 30 | 31 | void Process(); 32 | 33 | bool New(NEW_VEHICLE* pNewVehicle); 34 | bool Delete(VEHICLEID VehicleID); 35 | 36 | CVehicle* GetAt(VEHICLEID VehicleID) 37 | { 38 | if(VehicleID >= MAX_VEHICLES || !m_bVehicleSlotState[VehicleID]) 39 | return nullptr; 40 | return m_pVehicles[VehicleID]; 41 | } 42 | 43 | bool GetSlotState(VEHICLEID VehicleID) 44 | { 45 | if(VehicleID >= MAX_VEHICLES) 46 | return false; 47 | return m_bVehicleSlotState[VehicleID]; 48 | } 49 | 50 | VEHICLEID FindIDFromGtaPtr(VEHICLE_TYPE * pGtaVehicle); 51 | int FindGtaIDFromID(int ID); 52 | 53 | void AssignSpecialParamsToVehicle(VEHICLEID VehicleID, uint8_t byteObjective, uint8_t byteDoorsLocked); 54 | 55 | int FindNearestToLocalPlayerPed(); 56 | 57 | void LinkToInterior(VEHICLEID VehicleID, int iInterior); 58 | 59 | void NotifyVehicleDeath(VEHICLEID VehicleID); 60 | 61 | private: 62 | CVehicle* m_pVehicles[MAX_VEHICLES]; 63 | VEHICLE_TYPE* m_pGTAVehicles[MAX_VEHICLES]; 64 | bool m_bVehicleSlotState[MAX_VEHICLES]; 65 | 66 | bool m_bIsActive[MAX_VEHICLES]; 67 | bool m_bIsWasted[MAX_VEHICLES]; 68 | }; -------------------------------------------------------------------------------- /vendor/raknet/InternalPacketPool.cpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// 3 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 4 | /// 5 | /// Usage of RakNet is subject to the appropriate license agreement. 6 | /// Creative Commons Licensees are subject to the 7 | /// license found at 8 | /// http://creativecommons.org/licenses/by-nc/2.5/ 9 | /// Single application licensees are subject to the license found at 10 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 11 | /// Custom license users are subject to the terms therein. 12 | /// GPL license users are subject to the GNU General Public 13 | /// License as published by the Free 14 | /// Software Foundation; either version 2 of the License, or (at your 15 | /// option) any later version. 16 | 17 | #include "InternalPacketPool.h" 18 | #include 19 | 20 | InternalPacketPool::InternalPacketPool() 21 | { 22 | // Speed things up by not reallocating at runtime when a mutex is locked. 23 | pool.ClearAndForceAllocation( 64 ); 24 | unsigned i; 25 | for (i=0; i < 64; i++) 26 | pool.Push(new InternalPacket); 27 | } 28 | 29 | InternalPacketPool::~InternalPacketPool() 30 | { 31 | ClearPool(); 32 | } 33 | 34 | void InternalPacketPool::ClearPool( void ) 35 | { 36 | while ( pool.Size() ) 37 | delete pool.Pop(); 38 | } 39 | /* 40 | InternalPacket* InternalPacketPool::GetPointer( void ) 41 | { 42 | if ( pool.Size() ) 43 | return pool.Pop(); 44 | return new InternalPacket; 45 | 46 | } 47 | */ 48 | 49 | void InternalPacketPool::ReleasePointer( InternalPacket *p ) 50 | { 51 | if ( p == 0 ) 52 | { 53 | // Releasing a null pointer? 54 | #ifdef _DEBUG 55 | assert( 0 ); 56 | #endif 57 | return ; 58 | } 59 | 60 | #ifdef _DEBUG 61 | p->data=0; 62 | #endif 63 | //poolMutex.Lock(); 64 | pool.Push( p ); 65 | //poolMutex.Unlock(); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /net/objectpool.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "game/game.h" 3 | #include "netgame.h" 4 | 5 | extern CGame *pGame; 6 | 7 | CObjectPool::CObjectPool() 8 | { 9 | for(uint16_t ObjectID = 0; ObjectID < MAX_OBJECTS; ObjectID++) 10 | { 11 | m_bObjectSlotState[ObjectID] = false; 12 | m_pObjects[ObjectID] = 0; 13 | } 14 | } 15 | 16 | CObjectPool::~CObjectPool() 17 | { 18 | for(uint16_t i = 0; i < MAX_OBJECTS; i++) 19 | { 20 | Delete(i); 21 | } 22 | } 23 | 24 | bool CObjectPool::Delete(uint16_t ObjectID) 25 | { 26 | if(!GetSlotState(ObjectID) || !m_pObjects[ObjectID]) 27 | return false; 28 | 29 | m_bObjectSlotState[ObjectID] = false; 30 | delete m_pObjects[ObjectID]; 31 | m_pObjects[ObjectID] = 0; 32 | 33 | return true; 34 | } 35 | 36 | bool CObjectPool::New(uint16_t ObjectID, int iModel, VECTOR vecPos, VECTOR vecRot, float fDrawDistance) 37 | { 38 | if(m_pObjects[ObjectID] != 0) 39 | Delete(ObjectID); 40 | 41 | m_pObjects[ObjectID] = pGame->NewObject(iModel, vecPos.X, vecPos.Y, vecPos.Z, vecRot, fDrawDistance); 42 | 43 | if(m_pObjects[ObjectID]) 44 | { 45 | m_bObjectSlotState[ObjectID] = true; 46 | 47 | return true; 48 | } 49 | 50 | return false; 51 | } 52 | 53 | CObject *CObjectPool::GetObjectFromGtaPtr(ENTITY_TYPE *pGtaObject) 54 | { 55 | uint16_t x=1; 56 | 57 | while(x!=MAX_OBJECTS) 58 | { 59 | if(m_pObjects[x]) 60 | if(pGtaObject == m_pObjects[x]->m_pEntity) return m_pObjects[x]; 61 | 62 | x++; 63 | } 64 | 65 | return 0; 66 | } 67 | 68 | uint16_t CObjectPool::FindIDFromGtaPtr(ENTITY_TYPE* pGtaObject) 69 | { 70 | uint16_t x=1; 71 | 72 | while(x!=MAX_OBJECTS) 73 | { 74 | if(m_pObjects[x]) 75 | if(pGtaObject == m_pObjects[x]->m_pEntity) return x; 76 | 77 | x++; 78 | } 79 | 80 | return INVALID_OBJECT_ID; 81 | } 82 | 83 | void CObjectPool::Process() 84 | { 85 | } 86 | -------------------------------------------------------------------------------- /vendor/raknet/ExtendedOverlappedPool.cpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// 3 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 4 | /// 5 | /// Usage of RakNet is subject to the appropriate license agreement. 6 | /// Creative Commons Licensees are subject to the 7 | /// license found at 8 | /// http://creativecommons.org/licenses/by-nc/2.5/ 9 | /// Single application licensees are subject to the license found at 10 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 11 | /// Custom license users are subject to the terms therein. 12 | /// GPL license users are subject to the GNU General Public 13 | /// License as published by the Free 14 | /// Software Foundation; either version 2 of the License, or (at your 15 | /// option) any later version. 16 | 17 | // No longer used as I no longer support IO Completion ports 18 | /* 19 | #ifdef __USE_IO_COMPLETION_PORTS 20 | #include "ExtendedOverlappedPool.h" 21 | 22 | ExtendedOverlappedPool ExtendedOverlappedPool::I; 23 | 24 | ExtendedOverlappedPool::ExtendedOverlappedPool() 25 | {} 26 | 27 | ExtendedOverlappedPool::~ExtendedOverlappedPool() 28 | { 29 | // The caller better have returned all the packets! 30 | ExtendedOverlappedStruct * p; 31 | poolMutex.Lock(); 32 | 33 | while ( pool.Size() ) 34 | { 35 | p = pool.Pop(); 36 | delete p; 37 | } 38 | 39 | poolMutex.Unlock(); 40 | } 41 | 42 | ExtendedOverlappedStruct* ExtendedOverlappedPool::GetPointer( void ) 43 | { 44 | ExtendedOverlappedStruct * p = 0; 45 | poolMutex.Lock(); 46 | 47 | if ( pool.Size() ) 48 | p = pool.Pop(); 49 | 50 | poolMutex.Unlock(); 51 | 52 | if ( p ) 53 | return p; 54 | 55 | return new ExtendedOverlappedStruct; 56 | } 57 | 58 | void ExtendedOverlappedPool::ReleasePointer( ExtendedOverlappedStruct *p ) 59 | { 60 | poolMutex.Lock(); 61 | pool.Push( p ); 62 | poolMutex.Unlock(); 63 | } 64 | 65 | #endif 66 | 67 | */ 68 | -------------------------------------------------------------------------------- /vendor/raknet/InternalPacketPool.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Memory pool for InternalPacket* 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __INTERNAL_PACKET_POOL 19 | #define __INTERNAL_PACKET_POOL 20 | #include "DS_Queue.h" 21 | #include "InternalPacket.h" 22 | 23 | /// Handles of a pool of InternalPacket pointers. This is only here for efficiency. 24 | /// \sa InternalPacket.h 25 | class InternalPacketPool 26 | { 27 | public: 28 | 29 | /// Constructor 30 | InternalPacketPool(); 31 | 32 | /// Destructor 33 | ~InternalPacketPool(); 34 | 35 | /// Get an InternalPacket pointer. Will either allocate a new one or return one from the pool 36 | /// \return An InternalPacket pointer. 37 | InternalPacket* GetPointer( void ) 38 | {if ( pool.Size() ) 39 | return pool.Pop(); 40 | return new InternalPacket;} 41 | 42 | /// Return an InternalPacket pointer to the pool. 43 | /// \param[in] p A pointer to an InternalPacket you no longer need. 44 | void ReleasePointer( InternalPacket *p ); 45 | 46 | // Delete all InternalPacket pointers in the pool. 47 | void ClearPool( void ); 48 | 49 | private: 50 | /// Queue of internal packets 51 | DataStructures::Queue pool; 52 | }; 53 | 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /vendor/raknet/RakNetworkFactory.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief Factory class for RakServerInterface, RakClientInterface, and RakPeerInterface 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __RAK_NETWORK_FACTORY_H 19 | #define __RAK_NETWORK_FACTORY_H 20 | 21 | #include "Export.h" 22 | 23 | class RakClientInterface; 24 | class RakServerInterface; 25 | class RakPeerInterface; 26 | 27 | class RAK_DLL_EXPORT RakNetworkFactory 28 | { 29 | public: 30 | // For DLL's, these are user classes that you might want to new and delete. 31 | // You can't instantiate exported classes directly in your program. The instantiation 32 | // has to take place inside the DLL. So these functions will do the news and deletes for you. 33 | // if you're using the source or static library you don't need these functions, but can use them if you want. 34 | static RakClientInterface* GetRakClientInterface( void ); 35 | static RakServerInterface* GetRakServerInterface( void ); 36 | static RakPeerInterface* GetRakPeerInterface( void ); 37 | 38 | 39 | // To delete the object returned by the Get functions above. 40 | static void DestroyRakClientInterface( RakClientInterface* i ); 41 | static void DestroyRakServerInterface( RakServerInterface* i ); 42 | static void DestroyRakPeerInterface( RakPeerInterface* i ); 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /vendor/raknet/RPCNode.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Holds information related to a RPC 3 | /// 4 | /// \ingroup RAKNET_RPC 5 | /// 6 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 7 | /// 8 | /// Usage of RakNet is subject to the appropriate license agreement. 9 | /// Creative Commons Licensees are subject to the 10 | /// license found at 11 | /// http://creativecommons.org/licenses/by-nc/2.5/ 12 | /// Single application licensees are subject to the license found at 13 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 14 | /// Custom license users are subject to the terms therein. 15 | /// GPL license users are subject to the GNU General Public 16 | /// License as published by the Free 17 | /// Software Foundation; either version 2 of the License, or (at your 18 | /// option) any later version. 19 | 20 | #ifndef __RPC_NODE 21 | #define __RPC_NODE 22 | 23 | #include "NetworkTypes.h" 24 | #include "Export.h" 25 | 26 | class RakPeerInterface; 27 | 28 | 29 | /// \defgroup RAKNET_RPC Remote Procedure Call Subsystem 30 | /// \brief A system to call C or object member procudures on other systems, and even to return return values. 31 | 32 | /// \ingroup RAKNET_RPC 33 | /// \internal 34 | /// 35 | /// \brief Map registered procedure inside of a peer. 36 | /// 37 | struct RAK_DLL_EXPORT RPCNode 38 | { 39 | 40 | /// String identifier of the RPC 41 | int uniqueIdentifier; 42 | 43 | /// Force casting of member functions to void * 44 | union 45 | { 46 | void ( *staticFunctionPointer ) ( RPCParameters *rpcParms ); 47 | #if (defined(__GNUC__) || defined(__GCCXML__)) 48 | void (*memberFunctionPointer)(void* _this, RPCParameters *rpcParms); 49 | #else 50 | void (__cdecl *memberFunctionPointer)(void* _this, RPCParameters *rpcParms); 51 | #endif 52 | 53 | void *functionPointer; 54 | }; 55 | 56 | /// Is this a member function pointer? True if so. If false it's a regular C function. 57 | bool isPointerToMember; 58 | }; 59 | 60 | #endif 61 | 62 | -------------------------------------------------------------------------------- /spawnscreen.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "gui/gui.h" 3 | #include "spawnscreen.h" 4 | #include "chatwindow.h" 5 | #include "settings.h" 6 | 7 | #include "game/game.h" 8 | #include "net/netgame.h" 9 | 10 | extern CGUI *pGUI; 11 | extern CNetGame *pNetGame; 12 | extern CChatWindow *pChatWindow; 13 | extern CSettings *pSettings; 14 | 15 | CSpawnScreen::CSpawnScreen() 16 | { 17 | //Log("Initializing Spawn Screen.."); 18 | m_fPosX = pGUI->ScaleX( pSettings->Get().fSpawnScreenPosX ); 19 | m_fPosY = pGUI->ScaleY( pSettings->Get().fSpawnScreenPosY ); 20 | m_fSizeX = pGUI->ScaleX( pSettings->Get().fSpawnScreenSizeX ); 21 | m_fSizeY = pGUI->ScaleY( pSettings->Get().fSpawnScreenSizeY ); 22 | m_fButWidth = m_fSizeX / 3; 23 | m_fButHeight = m_fSizeY * 0.9; 24 | //Log("Spawn Screen pos: %f, %f, size: %f, %f", m_fPosX, m_fPosY, m_fSizeX, m_fSizeY); 25 | 26 | m_bEnabled = false; 27 | } 28 | 29 | void CSpawnScreen::Render() 30 | { 31 | if(!m_bEnabled) return; 32 | 33 | ImGuiIO &io = ImGui::GetIO(); 34 | CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool(); 35 | CLocalPlayer *pLocalPlayer = 0; 36 | if(pPlayerPool) pLocalPlayer = pPlayerPool->GetLocalPlayer(); 37 | 38 | ImGui::Begin("SpawnScreen", nullptr, 39 | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | 40 | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings); 41 | 42 | if (ImGui::Button("<<", ImVec2(m_fButWidth, m_fButHeight))) 43 | { 44 | pLocalPlayer->SendPrevClass(); 45 | } 46 | ImGui::SameLine(0, 5); 47 | if (ImGui::Button("Spawn", ImVec2(m_fButWidth, m_fButHeight))) 48 | { 49 | pLocalPlayer->SendSpawn(); 50 | } 51 | ImGui::SameLine(0, 5); 52 | if (ImGui::Button(">>", ImVec2(m_fButWidth, m_fButHeight))) 53 | { 54 | pLocalPlayer->SendNextClass(); 55 | } 56 | 57 | ImGui::SetWindowSize(ImVec2(-1, -1)); 58 | ImVec2 size = ImGui::GetWindowSize(); 59 | 60 | ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x)/2), ((io.DisplaySize.y * 0.95) - size.y) ) ); 61 | ImGui::End(); 62 | } -------------------------------------------------------------------------------- /vendor/raknet/MTUSize.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Defines the default maximum transfer unit. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef DEFAULT_MTU_SIZE 19 | 20 | /// The MTU size to use if RakPeer::SetMTUSize() is not called. 21 | /// \remarks I think many people forget to call RakPeer::SetMTUSize() so I'm setting this to 1500 by default for efficiency. 22 | /// \li \em 17914 16 Mbit/Sec Token Ring 23 | /// \li \em 4464 4 Mbits/Sec Token Ring 24 | /// \li \em 4352 FDDI 25 | /// \li \em 1500. The largest Ethernet packet size \b recommended. This is the typical setting for non-PPPoE, non-VPN connections. The default value for NETGEAR routers, adapters and switches. 26 | /// \li \em 1492. The size PPPoE prefers. 27 | /// \li \em 1472. Maximum size to use for pinging. (Bigger packets are fragmented.) 28 | /// \li \em 1468. The size DHCP prefers. 29 | /// \li \em 1460. Usable by AOL if you don't have large email attachments, etc. 30 | /// \li \em 1430. The size VPN and PPTP prefer. 31 | /// \li \em 1400. Maximum size for AOL DSL. 32 | /// \li \em 576. Typical value to connect to dial-up ISPs. 33 | #ifdef _COMPATIBILITY_1 34 | #define DEFAULT_MTU_SIZE 1264 35 | #else 36 | #define DEFAULT_MTU_SIZE 1500 37 | #endif 38 | 39 | /// The largest value for an UDP datagram 40 | /// \sa RakPeer::SetMTUSize() 41 | #define MAXIMUM_MTU_SIZE 576 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /vendor/raknet/DS_MemoryPool.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEMORY_POOL_H 2 | #define __MEMORY_POOL_H 3 | 4 | #include "DS_List.h" 5 | #include 6 | 7 | namespace DataStructures 8 | { 9 | template 10 | class MemoryPool 11 | { 12 | public: 13 | MemoryPool(); 14 | ~MemoryPool(); 15 | void Preallocate(unsigned numElements); 16 | MemoryBlockType *Allocate(void); 17 | void Release(MemoryBlockType *m); 18 | void Clear(void); 19 | protected: 20 | int blocksOut; 21 | DataStructures::List pool; 22 | }; 23 | 24 | template 25 | MemoryPool::MemoryPool() 26 | { 27 | #ifdef _DEBUG 28 | blocksOut=0; 29 | #endif 30 | } 31 | template 32 | MemoryPool::~MemoryPool() 33 | { 34 | #ifdef _DEBUG 35 | assert(blocksOut==0); 36 | #endif 37 | unsigned i; 38 | for (i=0; i < pool.Size(); i++) 39 | delete pool[i]; 40 | } 41 | 42 | template 43 | void MemoryPool::Preallocate(unsigned numElements) 44 | { 45 | unsigned i; 46 | for (i=pool.Size(); i < numElements; i++) 47 | { 48 | pool.Insert(new MemoryBlockType); 49 | } 50 | } 51 | 52 | template 53 | MemoryBlockType* MemoryPool::Allocate(void) 54 | { 55 | #ifdef _DEBUG 56 | blocksOut++; 57 | #endif 58 | if (pool.Size()==0) 59 | return new MemoryBlockType; 60 | else 61 | { 62 | MemoryBlockType* out; 63 | out=pool[pool.Size()-1]; 64 | pool.Del(); 65 | return out; 66 | } 67 | } 68 | template 69 | void MemoryPool::Release(MemoryBlockType *m) 70 | { 71 | pool.Insert(m); 72 | #ifdef _DEBUG 73 | assert(blocksOut>0); 74 | blocksOut--; 75 | #endif 76 | } 77 | template 78 | void MemoryPool::Clear(void) 79 | { 80 | #ifdef _DEBUG 81 | assert(blocksOut==0); 82 | #endif 83 | unsigned i; 84 | for (i=0; i < pool.Size(); i++) 85 | delete pool[i]; 86 | pool.Clear(); 87 | } 88 | } 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /vendor/raknet/SimpleMutex.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Encapsulates a mutex 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __SIMPLE_MUTEX_H 19 | #define __SIMPLE_MUTEX_H 20 | 21 | #ifdef _COMPATIBILITY_1 22 | #include "Compatibility1Includes.h" 23 | #elif defined(_WIN32) 24 | #include 25 | #else 26 | #include 27 | #include 28 | #endif 29 | #include "Export.h" 30 | /// \brief An easy to use mutex. 31 | /// 32 | /// I wrote this because the version that comes with Windows is too complicated and requires too much code to use. 33 | /// @remark Previously I used this everywhere, and in fact for a year or two RakNet was totally threadsafe. While doing profiling, I saw that this function was incredibly slow compared to the blazing performance of everything else, so switched to single producer / consumer everywhere. Now the user thread of RakNet is not threadsafe, but it's 100X faster than before. 34 | class RAK_DLL_EXPORT SimpleMutex 35 | { 36 | public: 37 | 38 | /// Constructor 39 | SimpleMutex(); 40 | 41 | // Destructor 42 | ~SimpleMutex(); 43 | 44 | // Locks the mutex. Slow! 45 | void Lock(void); 46 | 47 | // Unlocks the mutex. 48 | void Unlock(void); 49 | private: 50 | #ifdef _WIN32 51 | CRITICAL_SECTION criticalSection; /// Docs say this is faster than a mutex for single process access 52 | #else 53 | pthread_mutex_t hMutex; 54 | #endif 55 | }; 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /game/camera.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include "game.h" 3 | #include 4 | 5 | // 0.3.7 6 | void CCamera::SetBehindPlayer() 7 | { 8 | ScriptCommand(&lock_camera_position, 0); 9 | ScriptCommand(&restore_camera_to_user); 10 | m_pEntity = nullptr; 11 | ScriptCommand(&set_camera_behind_player); 12 | ScriptCommand(&restore_camera_jumpcut); 13 | } 14 | 15 | // 0.3.7 16 | void CCamera::Restore() 17 | { 18 | m_pEntity = nullptr; 19 | ScriptCommand(&restore_camera_jumpcut); 20 | } 21 | 22 | // 0.3.7 23 | void CCamera::SetPosition(float fX, float fY, float fZ, float fRotationX, float fRotationY, float fRotationZ) 24 | { 25 | ScriptCommand(&restore_camera_to_user); 26 | m_pEntity = nullptr; 27 | ScriptCommand(&set_camera_position, fX, fY, fZ, fRotationX, fRotationY, fRotationZ); 28 | } 29 | 30 | // 0.3.7 31 | void CCamera::LookAtPoint(float fX, float fY, float fZ, int iType) 32 | { 33 | ScriptCommand(&restore_camera_to_user); 34 | m_pEntity = nullptr; 35 | ScriptCommand(&point_camera, fX, fY, fZ, iType); 36 | } 37 | 38 | void CCamera::GetMatrix(PMATRIX4X4 Matrix) 39 | { 40 | Matrix->right.X = m_matPos->right.X; 41 | Matrix->right.Y = m_matPos->right.Y; 42 | Matrix->right.Z = m_matPos->right.Z; 43 | 44 | Matrix->up.X = m_matPos->up.X; 45 | Matrix->up.Y = m_matPos->up.Y; 46 | Matrix->up.Z = m_matPos->up.Z; 47 | 48 | Matrix->at.X = m_matPos->at.X; 49 | Matrix->at.Y = m_matPos->at.Y; 50 | Matrix->at.Z = m_matPos->at.Z; 51 | 52 | Matrix->pos.X = m_matPos->pos.X; 53 | Matrix->pos.Y = m_matPos->pos.Y; 54 | Matrix->pos.Z = m_matPos->pos.Z; 55 | } 56 | 57 | // 0.3.7 58 | void CCamera::InterpolateCameraPos(VECTOR *posFrom, VECTOR *posTo, int time, uint8_t mode) 59 | { 60 | ScriptCommand(&set_camera_pos_time_smooth, posFrom->X, posFrom->Y, posFrom->Z, posTo->X, posTo->Y, posTo->Z, time, mode); 61 | } 62 | 63 | // 0.3.7 64 | void CCamera::InterpolateCameraLookAt(VECTOR *posFrom, VECTOR *posTo, int time, uint8_t mode) 65 | { 66 | ScriptCommand(&lock_camera_position, 1); 67 | ScriptCommand(&point_camera_transverse, posFrom->X, posFrom->Y, posFrom->Z, posTo->X, posTo->Y, posTo->Z, time, mode); 68 | } -------------------------------------------------------------------------------- /vendor/raknet/ReplicaEnums.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief Contains enumerations used by the ReplicaManager system. This file is a lightweight header, so you can include it without worrying about linking in lots of other crap 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __REPLICA_ENUMS_H 19 | #define __REPLICA_ENUMS_H 20 | 21 | /// Replica interface flags, used to enable and disable function calls on the Replica object 22 | /// Passed to ReplicaManager::EnableReplicaInterfaces and ReplicaManager::DisableReplicaInterfaces 23 | enum 24 | { 25 | REPLICA_RECEIVE_DESTRUCTION=1<<0, 26 | REPLICA_RECEIVE_SERIALIZE=1<<1, 27 | REPLICA_RECEIVE_SCOPE_CHANGE=1<<2, 28 | REPLICA_SEND_CONSTRUCTION=1<<3, 29 | REPLICA_SEND_DESTRUCTION=1<<4, 30 | REPLICA_SEND_SCOPE_CHANGE=1<<5, 31 | REPLICA_SEND_SERIALIZE=1<<6, 32 | REPLICA_SET_ALL = 0xFF // Allow all of the above 33 | }; 34 | 35 | enum ReplicaReturnResult 36 | { 37 | /// This means call the function again later, with the same parameters 38 | REPLICA_PROCESS_LATER, 39 | /// This means we are done processing (the normal result to return) 40 | REPLICA_PROCESSING_DONE, 41 | /// This means cancel the processing - don't send any network messages and don't change the current state. 42 | REPLICA_CANCEL_PROCESS, 43 | /// Same as REPLICA_PROCESSING_DONE, where a message is sent, but does not clear the send bit. 44 | /// Useful for multi-part sends with different reliability levels. 45 | /// Only currently used by Replica::Serialize 46 | REPLICA_PROCESS_AGAIN, 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /net/gangzonepool.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "game/game.h" 3 | #include "netgame.h" 4 | 5 | extern CGame *pGame; 6 | 7 | CGangZonePool::CGangZonePool() 8 | { 9 | for(uint16_t wZone = 0; wZone < MAX_GANG_ZONES; wZone++) 10 | { 11 | m_pGangZone[wZone] = nullptr; 12 | m_bSlotState[wZone] = false; 13 | } 14 | } 15 | 16 | CGangZonePool::~CGangZonePool() 17 | { 18 | for(uint16_t wZone = 0; wZone < MAX_GANG_ZONES; wZone++) 19 | { 20 | if(m_pGangZone[wZone]) 21 | { 22 | delete m_pGangZone[wZone]; 23 | m_pGangZone[wZone] = nullptr; 24 | } 25 | } 26 | } 27 | 28 | void CGangZonePool::New(uint16_t wZone, float fMinX, float fMinY, float fMaxX, float fMaxY, uint32_t dwColor) 29 | { 30 | if(m_pGangZone[wZone]) 31 | { 32 | delete m_pGangZone[wZone]; 33 | m_pGangZone[wZone] = nullptr; 34 | m_bSlotState[wZone] = false; 35 | } 36 | 37 | GANG_ZONE *pGangZone = new GANG_ZONE; 38 | if(pGangZone) 39 | { 40 | pGangZone->fPos[0] = fMinX; 41 | pGangZone->fPos[1] = fMaxY; 42 | pGangZone->fPos[2] = fMaxX; 43 | pGangZone->fPos[3] = fMinY; 44 | pGangZone->dwColor = dwColor; 45 | pGangZone->dwAltColor = dwColor; 46 | m_pGangZone[wZone] = pGangZone; 47 | m_bSlotState[wZone] = true; 48 | } 49 | } 50 | 51 | void CGangZonePool::Delete(uint16_t wZone) 52 | { 53 | if(m_pGangZone[wZone]) 54 | { 55 | delete m_pGangZone[wZone]; 56 | m_pGangZone[wZone] = nullptr; 57 | m_bSlotState[wZone] = false; 58 | } 59 | } 60 | 61 | void CGangZonePool::Draw() 62 | { 63 | static uint32_t dwLastTick = 0; 64 | uint32_t dwTick = GetTickCount(); 65 | static uint8_t alt = 0; 66 | 67 | if(dwTick - dwLastTick >= 500) 68 | { 69 | alt = ~alt; 70 | dwLastTick = dwTick; 71 | } 72 | 73 | for(uint16_t wZone = 0; wZone < MAX_GANG_ZONES; wZone++) 74 | { 75 | if(m_bSlotState[wZone]) 76 | { 77 | pGame->DrawGangZone(m_pGangZone[wZone]->fPos, 78 | alt ? m_pGangZone[wZone]->dwAltColor : m_pGangZone[wZone]->dwColor); 79 | } 80 | } 81 | } 82 | 83 | void CGangZonePool::Flash(uint16_t wZone, uint32_t dwColor) 84 | { 85 | if(m_pGangZone[wZone]) 86 | m_pGangZone[wZone]->dwAltColor = dwColor; 87 | } 88 | 89 | void CGangZonePool::StopFlash(uint16_t wZone) 90 | { 91 | if(m_pGangZone[wZone]) 92 | m_pGangZone[wZone]->dwAltColor = m_pGangZone[wZone]->dwColor; 93 | } -------------------------------------------------------------------------------- /vendor/raknet/DataCompressor.cpp: -------------------------------------------------------------------------------- 1 | #include "DataCompressor.h" 2 | #include "DS_HuffmanEncodingTree.h" 3 | #include 4 | #include // Use string.h rather than memory.h for the PS3 5 | 6 | void DataCompressor::Compress( unsigned char *userData, unsigned sizeInBytes, RakNet::BitStream * output ) 7 | { 8 | // Don't use this for small files as you will just make them bigger! 9 | assert(sizeInBytes > 2048); 10 | 11 | unsigned int frequencyTable[ 256 ]; 12 | unsigned int i; 13 | memset(frequencyTable,0,256*sizeof(unsigned int)); 14 | for (i=0; i < sizeInBytes; i++) 15 | ++frequencyTable[userData[i]]; 16 | HuffmanEncodingTree tree; 17 | unsigned int writeOffset1, writeOffset2, bitsUsed1, bitsUsed2; 18 | tree.GenerateFromFrequencyTable(frequencyTable); 19 | output->WriteCompressed(sizeInBytes); 20 | for (i=0; i < 256; i++) 21 | output->WriteCompressed(frequencyTable[i]); 22 | output->AlignWriteToByteBoundary(); 23 | writeOffset1=output->GetWriteOffset(); 24 | output->Write((unsigned int)0); // Dummy value 25 | bitsUsed1=output->GetNumberOfBitsUsed(); 26 | tree.EncodeArray(userData, sizeInBytes, output); 27 | bitsUsed2=output->GetNumberOfBitsUsed(); 28 | writeOffset2=output->GetWriteOffset(); 29 | output->SetWriteOffset(writeOffset1); 30 | output->Write(bitsUsed2-bitsUsed1); // Go back and write how many bits were used for the encoding 31 | output->SetWriteOffset(writeOffset2); 32 | } 33 | 34 | unsigned DataCompressor::DecompressAndAllocate( RakNet::BitStream * input, unsigned char **output ) 35 | { 36 | HuffmanEncodingTree tree; 37 | unsigned int bitsUsed, destinationSizeInBytes, decompressedBytes; 38 | unsigned int frequencyTable[ 256 ]; 39 | unsigned i; 40 | 41 | input->ReadCompressed(destinationSizeInBytes); 42 | for (i=0; i < 256; i++) 43 | input->ReadCompressed(frequencyTable[i]); 44 | input->AlignReadToByteBoundary(); 45 | if (input->Read(bitsUsed)==false) 46 | { 47 | // Read error 48 | #ifdef _DEBUG 49 | assert(0); 50 | #endif 51 | return 0; 52 | } 53 | *output = new unsigned char [destinationSizeInBytes]; 54 | tree.GenerateFromFrequencyTable(frequencyTable); 55 | decompressedBytes=tree.DecodeArray(input, bitsUsed, destinationSizeInBytes, *output ); 56 | assert(decompressedBytes==destinationSizeInBytes); 57 | return destinationSizeInBytes; 58 | } 59 | -------------------------------------------------------------------------------- /vendor/raknet/EmailSender.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief Rudimentary class to send email from code. Don't expect anything fancy. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __EMAIL_SENDER_H 19 | #define __EMAIL_SENDER_H 20 | 21 | class FileList; 22 | class TCPInterface; 23 | #include "NetworkTypes.h" 24 | 25 | /// \brief Rudimentary class to send email from code. 26 | class EmailSender 27 | { 28 | public: 29 | /// Sends an email 30 | /// \param[in] hostAddress The address of the email server. 31 | /// \param[in] hostPort The port of the email server (usually 25) 32 | /// \param[in] sender The email address you are sending from. 33 | /// \param[in] recipient The email address you are sending to. 34 | /// \param[in] senderName The email address you claim to be sending from 35 | /// \param[in] recipientName The email address you claim to be sending to 36 | /// \param[in] subject Email subject 37 | /// \param[in] body Email body 38 | /// \param[in] attachedFiles List of files to attach to the email. (Can be 0 to send none). 39 | /// \param[in] doPrintf true to output SMTP info to console(for debugging?) 40 | /// \return 0 on success, otherwise a string indicating the error message 41 | char *Send(const char *hostAddress, unsigned short hostPort, const char *sender, const char *recipient, const char *senderName, const char *recipientName, const char *subject, const char *body, FileList *attachedFiles, bool doPrintf); 42 | 43 | // Returns how many bytes were written 44 | int Base64Encoding(const char *inputData, int dataLength, char *outputData, const char *base64Map); 45 | protected: 46 | char *GetResponse(TCPInterface *tcpInterface, const PlayerID &emailServer, bool doPrintf); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /net/playerpool.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "game/game.h" 3 | #include "netgame.h" 4 | #include "../playerslist.h" 5 | 6 | extern CPlayersList *pPlayersList; 7 | 8 | CPlayerPool::CPlayerPool() 9 | { 10 | m_pLocalPlayer = new CLocalPlayer(); 11 | 12 | for(PLAYERID playerId = 0; playerId < MAX_PLAYERS; playerId++) 13 | { 14 | m_bPlayerSlotState[playerId] = false; 15 | m_pPlayers[playerId] = nullptr; 16 | } 17 | } 18 | 19 | CPlayerPool::~CPlayerPool() 20 | { 21 | delete m_pLocalPlayer; 22 | m_pLocalPlayer = nullptr; 23 | 24 | for(PLAYERID playerId = 0; playerId < MAX_PLAYERS; playerId++) 25 | Delete(playerId, 0); 26 | } 27 | 28 | bool CPlayerPool::Process() 29 | { 30 | for(PLAYERID playerId = 0; playerId < MAX_PLAYERS; playerId++) 31 | { 32 | if(m_bPlayerSlotState[playerId]) 33 | m_pPlayers[playerId]->Process(); 34 | } 35 | 36 | m_pLocalPlayer->Process(); 37 | 38 | return true; 39 | } 40 | 41 | bool CPlayerPool::New(PLAYERID playerId, char *szPlayerName, bool IsNPC) 42 | { 43 | m_pPlayers[playerId] = new CRemotePlayer(); 44 | 45 | if(m_pPlayers[playerId]) 46 | { 47 | strcpy(m_szPlayerNames[playerId], szPlayerName); 48 | m_pPlayers[playerId]->SetID(playerId); 49 | m_pPlayers[playerId]->SetNPC(IsNPC); 50 | m_bPlayerSlotState[playerId] = true; 51 | 52 | return true; 53 | } 54 | 55 | return false; 56 | } 57 | 58 | bool CPlayerPool::Delete(PLAYERID playerId, uint8_t byteReason) 59 | { 60 | if(!GetSlotState(playerId) || !m_pPlayers[playerId]) 61 | return false; 62 | 63 | if(GetLocalPlayer()->IsSpectating() && GetLocalPlayer()->m_SpectateID == playerId) 64 | GetLocalPlayer()->ToggleSpectating(false); 65 | 66 | m_bPlayerSlotState[playerId] = false; 67 | delete m_pPlayers[playerId]; 68 | m_pPlayers[playerId] = nullptr; 69 | 70 | return true; 71 | } 72 | 73 | PLAYERID CPlayerPool::FindRemotePlayerIDFromGtaPtr(PED_TYPE * pActor) 74 | { 75 | CPlayerPed *pPlayerPed; 76 | 77 | for(PLAYERID playerId = 0; playerId < MAX_PLAYERS; playerId++) 78 | { 79 | if(true == m_bPlayerSlotState[playerId]) 80 | { 81 | pPlayerPed = m_pPlayers[playerId]->GetPlayerPed(); 82 | 83 | if(pPlayerPed) { 84 | PED_TYPE *pTestActor = pPlayerPed->GetGtaActor(); 85 | if((pTestActor != NULL) && (pActor == pTestActor)) // found it 86 | return m_pPlayers[playerId]->GetID(); 87 | } 88 | } 89 | } 90 | 91 | return INVALID_PLAYER_ID; 92 | } -------------------------------------------------------------------------------- /vendor/raknet/FullyConnectedMesh.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief Fully connected mesh plugin. This will connect RakPeer to all connecting peers, and all peers the connecting peer knows about. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __FULLY_CONNECTED_MESH_H 19 | #define __FULLY_CONNECTED_MESH_H 20 | 21 | class RakPeerInterface; 22 | #include "PluginInterface.h" 23 | 24 | /// \defgroup FULLY_CONNECTED_MESH_GROUP FullyConnectedMesh 25 | /// \ingroup PLUGINS_GROUP 26 | 27 | /// Fully connected mesh plugin. This will connect RakPeer to all connecting peers, and all peers the connecting peer knows about. 28 | /// \pre You must also install the ConnectionGraph plugin. If you want a password, set it there. 29 | /// \ingroup FULLY_CONNECTED_MESH_GROUP 30 | class FullyConnectedMesh : public PluginInterface 31 | { 32 | public: 33 | FullyConnectedMesh(); 34 | virtual ~FullyConnectedMesh(); 35 | 36 | // -------------------------------------------------------------------------------------------- 37 | // User functions 38 | // -------------------------------------------------------------------------------------------- 39 | // Set the password to use to connect to the other systems 40 | void Initialize(const char *password); 41 | 42 | // -------------------------------------------------------------------------------------------- 43 | // Packet handling functions 44 | // -------------------------------------------------------------------------------------------- 45 | virtual void OnDisconnect(RakPeerInterface *peer); 46 | virtual void Update(RakPeerInterface *peer); 47 | virtual PluginReceiveResult OnReceive(RakPeerInterface *peer, Packet *packet); 48 | 49 | 50 | protected: 51 | char *pw; 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SA-MP MOD Mobile 2 | 3 | Client command's: 4 | - /modsa or /ms - cheat menu. 5 | - /day | /night - toggle world time. 6 | - /skin - skin changer. 7 | - /textdraw or /td - TextDraw Click Sender. 8 | - /xyz - current coord's. 9 | - /weather clear|rainy|foggy|purple - toggle weather. 10 | - /reconnect or /rec - reconnect. 11 | - /dwe - engine hack. 12 | - /pickups or /pks - toggle pickup's. 13 | - /quit or /q - quit from the game. 14 | - /3dtxt - toggle 3DTextLabel. 15 | - /objects or /objs - toggle object's. 16 | 17 | ------------------------------------------------------------------------------ 18 | Cheats. 19 | - Wall Hack (onfoot & onvehicle) 20 | - No Fall (onfoot & onvehicle) 21 | - Invincible (onfoot & onvehicle) 22 | - Freeze (onfoot) 23 | - Invisible (onfoot) 24 | - Fly Hack (onfoot & onvehicle) 25 | - Flash (onfoot) 26 | - Behind (onfoot & onvehicle) 27 | - Gravity (onfoot & onvehicle) 28 | ---------------------------------------------------------- 29 | Harmful Cheats. 30 | - Blowup Car 31 | ---------------------------------------------------------- 32 | Weapons. 33 | - All weapons. 34 | ---------------------------------------------------------- 35 | Teleports. 36 | - All Teleports + Marker teleport (onfoot & onvehicle) 37 | ---------------------------------------------------------- 38 | Pos Master (onfoot) 39 | - 3x positions 40 | ---------------------------------------------------------- 41 | Settings. 42 | - Clear chat 43 | - Lock chat input 44 | - Render XYZ 45 | - Hide nicknames 46 | - New Players 47 | ---------------------------------------------------------- 48 | GTA Patches. 49 | - Money + 50 | - Clock 51 | - Freeze Time 52 | - Freeze Weather 53 | - Radar 54 | - Fast Firing 55 | - Car Invisibility 56 | ---------------------------------------------------------- 57 | SA-MP Patches. 58 | > Incoming RPC: 59 | - SetPlayerPos 60 | - SetPlayerHealth 61 | - ResetPlayerWeapons 62 | - SetVehicleParamsEx 63 | - Create3DTextLabel 64 | - CreateExplosion 65 | - SetPlayerName 66 | - AddGangZone 67 | - TogglePlayerControllable 68 | - ShowTextDraw 69 | - HideTextDraw 70 | - ShowMenu 71 | - HideMenu 72 | - SetGravity 73 | - SetPlayerSkin 74 | - CreateObject 75 | - ShowDialog 76 | - RemovePlayerFromVehicle 77 | - ApplyAnimations 78 | - ClearAnimations 79 | - SetVehicleVelocity 80 | - CreatePickup 81 | - SetVehicleParams 82 | 83 | > Outcoming RPC: 84 | - GetCurrentWeapon 85 | - GetPlayerPos 86 | - EnterVehicle 87 | -------------------------------------------------------------------------------- /vendor/inih/cpp/INIReader.h: -------------------------------------------------------------------------------- 1 | // Read an INI file into easy-to-access name/value pairs. 2 | 3 | // inih and INIReader are released under the New BSD license (see LICENSE.txt). 4 | // Go to the project home page for more info: 5 | // 6 | // https://github.com/benhoyt/inih 7 | 8 | #ifndef __INIREADER_H__ 9 | #define __INIREADER_H__ 10 | 11 | #include 12 | #include 13 | 14 | // Read an INI file into easy-to-access name/value pairs. (Note that I've gone 15 | // for simplicity here rather than speed, but it should be pretty decent.) 16 | class INIReader 17 | { 18 | public: 19 | // Construct INIReader and parse given filename. See ini.h for more info 20 | // about the parsing. 21 | INIReader(const std::string& filename); 22 | 23 | // Return the result of ini_parse(), i.e., 0 on success, line number of 24 | // first error on parse error, or -1 on file open error. 25 | int ParseError() const; 26 | 27 | // Get a string value from INI file, returning default_value if not found. 28 | std::string Get(const std::string& section, const std::string& name, 29 | const std::string& default_value) const; 30 | 31 | // Get an integer (long) value from INI file, returning default_value if 32 | // not found or not a valid integer (decimal "1234", "-1234", or hex "0x4d2"). 33 | long GetInteger(const std::string& section, const std::string& name, long default_value) const; 34 | 35 | // Get a real (floating point double) value from INI file, returning 36 | // default_value if not found or not a valid floating point value 37 | // according to strtod(). 38 | double GetReal(const std::string& section, const std::string& name, double default_value) const; 39 | 40 | // Get a boolean value from INI file, returning default_value if not found or if 41 | // not a valid true/false value. Valid true values are "true", "yes", "on", "1", 42 | // and valid false values are "false", "no", "off", "0" (not case sensitive). 43 | bool GetBoolean(const std::string& section, const std::string& name, bool default_value) const; 44 | 45 | private: 46 | int _error; 47 | std::map _values; 48 | static std::string MakeKey(const std::string& section, const std::string& name); 49 | static int ValueHandler(void* user, const char* section, const char* name, 50 | const char* value); 51 | }; 52 | 53 | #endif // __INIREADER_H__ 54 | -------------------------------------------------------------------------------- /vendor/raknet/DS_HuffmanEncodingTreeFactory.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Creates instances of the class HuffmanEncodingTree 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __HUFFMAN_ENCODING_TREE_FACTORY 19 | #define __HUFFMAN_ENCODING_TREE_FACTORY 20 | 21 | class HuffmanEncodingTree; 22 | 23 | /// \brief Creates instances of the class HuffmanEncodingTree 24 | /// 25 | /// This class takes a frequency table and given that frequence table, will generate an instance of HuffmanEncodingTree 26 | class HuffmanEncodingTreeFactory 27 | { 28 | public: 29 | /// Default constructor 30 | HuffmanEncodingTreeFactory(); 31 | 32 | /// Reset the frequency table. You don't need to call this unless you want to reuse the class for a new tree 33 | void Reset( void ); 34 | 35 | /// Pass an array of bytes to this to add those elements to the frequency table 36 | /// \param[in] array the data to insert into the frequency table 37 | /// \param[in] size the size of the data to insert 38 | void AddToFrequencyTable( unsigned char *array, int size ); 39 | 40 | /// Copies the frequency table to the array passed 41 | /// Retrieve the frequency table 42 | /// \param[in] _frequency The frequency table used currently 43 | void GetFrequencyTable( unsigned int _frequency[ 256 ] ); 44 | 45 | /// Returns the frequency table as a pointer 46 | /// \return the address of the frenquency table 47 | unsigned int * GetFrequencyTable( void ); 48 | 49 | /// Generate a HuffmanEncodingTree. 50 | /// You can also use GetFrequencyTable and GenerateFromFrequencyTable in the tree itself 51 | /// \return The generated instance of HuffmanEncodingTree 52 | HuffmanEncodingTree * GenerateTree( void ); 53 | 54 | private: 55 | 56 | /// Frequency table 57 | unsigned int frequency[ 256 ]; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /vendor/raknet/TelnetTransport.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief Contains TelnetTransport , used to supports the telnet transport protocol. Insecure 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __TELNET_TRANSPORT 19 | #define __TELNET_TRANSPORT 20 | 21 | #include "TransportInterface.h" 22 | #include "DS_List.h" 23 | #include "Export.h" 24 | class TCPInterface; 25 | struct TelnetClient; 26 | 27 | /// \brief Use TelnetTransport to easily allow windows telnet to connect to your ConsoleServer 28 | /// To run Windows telnet, go to your start menu, click run, and in the edit box type "telnet " where is the ip address 29 | /// of your ConsoleServer (most likely the same IP as your game). 30 | /// This implementation always echos commands. 31 | class RAK_DLL_EXPORT TelnetTransport : public TransportInterface 32 | { 33 | public: 34 | TelnetTransport(); 35 | ~TelnetTransport(); 36 | bool Start(unsigned short port, bool serverMode); 37 | void Stop(void); 38 | void Send( PlayerID playerId, const char *data, ... ); 39 | void CloseConnection( PlayerID playerId ); 40 | Packet* Receive( void ); 41 | void DeallocatePacket( Packet *packet ); 42 | PlayerID HasNewConnection(void); 43 | PlayerID HasLostConnection(void); 44 | CommandParserInterface* GetCommandParser(void); 45 | protected: 46 | 47 | struct TelnetClient 48 | { 49 | PlayerID playerId; 50 | char textInput[REMOTE_MAX_TEXT_INPUT]; 51 | unsigned cursorPosition; 52 | }; 53 | 54 | TCPInterface *tcpInterface; 55 | void AutoAllocate(void); 56 | bool ReassembleLine(TelnetTransport::TelnetClient* telnetClient, unsigned char c); 57 | 58 | // Crap this sucks but because windows telnet won't send line at a time, I have to reconstruct the lines at the server per player 59 | DataStructures::List remoteClients; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /modsa.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CModSAWindow 4 | { 5 | public: 6 | CModSAWindow(); 7 | ~CModSAWindow(); 8 | 9 | void Render(); 10 | void Clear(); 11 | void Show(bool bShow); 12 | 13 | void ToggleCheat(int cheatid); 14 | void ToggleRPC(int rpcid); 15 | void ToggleTeleport(int posid); 16 | 17 | void StoreMarkerXYZ(float x, float y, float z); 18 | void ShowFlyMenu(bool bShow); 19 | 20 | void StartBotById(int id); 21 | 22 | void ToggleNoKickTeleport(float x, float y, float z); 23 | 24 | void SetFlySets(float distance); 25 | float GetFlySets(); 26 | 27 | void ZavodBotTemp(int stepId); 28 | 29 | public: 30 | bool m_bIsActive; 31 | int m_bMenuStep; 32 | int m_bFlyHack; 33 | int m_bGodMode; 34 | int m_bWallHack; 35 | int m_bCols; 36 | int m_bINVIS; 37 | 38 | int m_bVP; 39 | int m_bVP2; 40 | int m_bVV; 41 | int m_bCO; 42 | int m_bPH; 43 | int m_bRPFV; 44 | int m_bSD; 45 | int m_bAPA; 46 | int m_bRPW; 47 | int m_bNF; 48 | int m_bCP; 49 | int m_bCP2; 50 | int m_bGCW; 51 | int m_bCA; 52 | int m_bSPP; 53 | int m_bGPP; 54 | int m_bCTL; 55 | int m_bEV; 56 | int m_bFLASH; 57 | int m_bCE; 58 | int m_bSPN; 59 | int m_bAGZ; 60 | int m_bTPC; 61 | int m_bSTD; 62 | int m_bHTD; 63 | int m_bSM; 64 | int m_bHM; 65 | int m_bSG; 66 | int m_clock; 67 | int m_bSPS; 68 | int m_bAirbreak; 69 | int fastfire; 70 | int carvisible; 71 | 72 | int protect; 73 | int m_bKrutilka; 74 | int lockinp; 75 | int lock_weather; 76 | int lock_time; 77 | int rxyz; 78 | int flock; 79 | int botzavod; 80 | int radar; 81 | 82 | float sPos1X; 83 | float sPos1Y; 84 | float sPos1Z; 85 | 86 | float sPos2X; 87 | float sPos2Y; 88 | float sPos2Z; 89 | 90 | float sPos3X; 91 | float sPos3Y; 92 | float sPos3Z; 93 | 94 | int dnames; 95 | int players; 96 | 97 | int zbot_reps; 98 | int m_bot; 99 | int extOS; 100 | int curAnim; 101 | 102 | float i_x; 103 | float i_y; 104 | float i_z; 105 | 106 | float marker_X; 107 | float marker_Y; 108 | float marker_Z; 109 | 110 | float sx; 111 | float sy; 112 | float sz; 113 | 114 | float cHealth; 115 | float xHealth; 116 | 117 | float fDist; 118 | 119 | char* m_szAddress; 120 | int m_szPort; 121 | }; -------------------------------------------------------------------------------- /game/scripting.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include "scripting.h" 3 | 4 | GAME_SCRIPT_THREAD* gst; 5 | char ScriptBuf[0xFF]; 6 | uintptr_t *pdwParamVars[18]; 7 | 8 | uint8_t ExecuteScriptBuf() 9 | { 10 | gst->dwScriptIP = (uintptr_t)ScriptBuf; 11 | (( void (*)(GAME_SCRIPT_THREAD*))(g_libGTASA+0x2E1D2C+1))(gst); 12 | 13 | return gst->condResult; 14 | } 15 | 16 | int ScriptCommand(const SCRIPT_COMMAND *pScriptCommand, ...) 17 | { 18 | va_list ap; 19 | const char* p = pScriptCommand->Params; 20 | va_start(ap, pScriptCommand); 21 | memcpy(&ScriptBuf, &pScriptCommand->OpCode, 2); 22 | int buf_pos = 2; 23 | uint16_t var_pos = 0; 24 | 25 | for(int i = 0; i < 18; i++) 26 | gst->dwLocalVar[i] = 0; 27 | 28 | while(*p) 29 | { 30 | switch(*p) 31 | { 32 | case 'i': 33 | { 34 | int i = va_arg(ap, int); 35 | ScriptBuf[buf_pos] = 0x01; 36 | buf_pos++; 37 | memcpy(&ScriptBuf[buf_pos], &i, 4); 38 | buf_pos += 4; 39 | break; 40 | } 41 | case 'f': 42 | { 43 | float f = (float)va_arg(ap, double); 44 | ScriptBuf[buf_pos] = 0x06; 45 | buf_pos++; 46 | memcpy(&ScriptBuf[buf_pos], &f, 4); 47 | buf_pos += 4; 48 | break; 49 | } 50 | case 'v': 51 | { 52 | uint32_t *v = va_arg(ap, uint32_t*); 53 | ScriptBuf[buf_pos] = 0x03; 54 | buf_pos++; 55 | pdwParamVars[var_pos] = v; 56 | gst->dwLocalVar[var_pos] = *v; 57 | memcpy(&ScriptBuf[buf_pos], &var_pos, 2); 58 | buf_pos += 2; 59 | var_pos++; 60 | break; 61 | } 62 | case 's': // If string... Updated 13th Jan 06.. (kyeman) SA string support 63 | { 64 | char* sz = va_arg(ap, char*); 65 | unsigned char aLen = strlen(sz); 66 | ScriptBuf[buf_pos] = 0x0E; 67 | buf_pos++; 68 | ScriptBuf[buf_pos] = aLen; 69 | buf_pos++; 70 | memcpy(&ScriptBuf[buf_pos],sz,aLen); 71 | buf_pos += aLen; 72 | break; 73 | } 74 | case 'z': // If the params need zero-terminating... 75 | { 76 | ScriptBuf[buf_pos] = 0x00; 77 | buf_pos++; 78 | break; 79 | } 80 | default: 81 | { 82 | return 0; 83 | } 84 | } 85 | ++p; 86 | } 87 | va_end(ap); 88 | 89 | int result = ExecuteScriptBuf(); 90 | if (var_pos) 91 | { 92 | for (int i=0; i < var_pos; i++) 93 | *pdwParamVars[i] = gst->dwLocalVar[i]; 94 | } 95 | 96 | return result; 97 | } 98 | 99 | void InitScripting() 100 | { 101 | gst = new GAME_SCRIPT_THREAD; 102 | memset(gst, 0, sizeof(GAME_SCRIPT_THREAD)); 103 | } -------------------------------------------------------------------------------- /vendor/raknet/PacketPriority.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief This file contains enumerations for packet priority and reliability enumerations. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __PACKET_PRIORITY_H 19 | #define __PACKET_PRIORITY_H 20 | 21 | /// These enumerations are used to describe when packets are delivered. 22 | enum PacketPriority 23 | { 24 | SYSTEM_PRIORITY, /// \internal Used by RakNet to send above-high priority messages. 25 | HIGH_PRIORITY, /// High priority messages are send before medium priority messages. 26 | MEDIUM_PRIORITY, /// Medium priority messages are send before low priority messages. 27 | LOW_PRIORITY, /// Low priority messages are only sent when no other messages are waiting. 28 | NUMBER_OF_PRIORITIES 29 | }; 30 | 31 | /// These enumerations are used to describe how packets are delivered. 32 | /// \note Note to self: I write this with 3 bits in the stream. If I add more remember to change that 33 | enum PacketReliability 34 | { 35 | UNRELIABLE = 6, /// Same as regular UDP, except that it will also discard duplicate datagrams. RakNet adds (6 to 17) + 21 bits of overhead, 16 of which is used to detect duplicate packets and 6 to 17 of which is used for message length. 36 | UNRELIABLE_SEQUENCED, /// Regular UDP with a sequence counter. Out of order messages will be discarded. This adds an additional 13 bits on top what is used for UNRELIABLE. 37 | RELIABLE, /// The message is sent reliably, but not necessarily in any order. Same overhead as UNRELIABLE. 38 | RELIABLE_ORDERED, /// This message is reliable and will arrive in the order you sent it. Messages will be delayed while waiting for out of order messages. Same overhead as UNRELIABLE_SEQUENCED. 39 | RELIABLE_SEQUENCED /// This message is reliable and will arrive in the sequence you sent it. Out or order messages will be dropped. Same overhead as UNRELIABLE_SEQUENCED. 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /vendor/raknet/SimpleMutex.cpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// 3 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 4 | /// 5 | /// Usage of RakNet is subject to the appropriate license agreement. 6 | /// Creative Commons Licensees are subject to the 7 | /// license found at 8 | /// http://creativecommons.org/licenses/by-nc/2.5/ 9 | /// Single application licensees are subject to the license found at 10 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 11 | /// Custom license users are subject to the terms therein. 12 | /// GPL license users are subject to the GNU General Public 13 | /// License as published by the Free 14 | /// Software Foundation; either version 2 of the License, or (at your 15 | /// option) any later version. 16 | 17 | #include "SimpleMutex.h" 18 | #include 19 | 20 | SimpleMutex::SimpleMutex() 21 | { 22 | #ifdef _WIN32 23 | // hMutex = CreateMutex(NULL, FALSE, 0); 24 | // assert(hMutex); 25 | InitializeCriticalSection(&criticalSection); 26 | #else 27 | int error = pthread_mutex_init(&hMutex, 0); 28 | assert(error==0); 29 | #endif 30 | } 31 | 32 | SimpleMutex::~SimpleMutex() 33 | { 34 | #ifdef _WIN32 35 | // CloseHandle(hMutex); 36 | DeleteCriticalSection(&criticalSection); 37 | #else 38 | pthread_mutex_destroy(&hMutex); 39 | #endif 40 | } 41 | 42 | #ifdef _WIN32 43 | #ifdef _DEBUG 44 | #include 45 | #endif 46 | #endif 47 | 48 | void SimpleMutex::Lock(void) 49 | { 50 | #ifdef _WIN32 51 | /* 52 | DWORD d = WaitForSingleObject(hMutex, INFINITE); 53 | #ifdef _DEBUG 54 | if (d==WAIT_FAILED) 55 | { 56 | LPVOID messageBuffer; 57 | FormatMessage( 58 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 59 | FORMAT_MESSAGE_FROM_SYSTEM | 60 | FORMAT_MESSAGE_IGNORE_INSERTS, 61 | NULL, 62 | GetLastError(), 63 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 64 | (LPTSTR) &messageBuffer, 65 | 0, 66 | NULL 67 | ); 68 | // Process any inserts in messageBuffer. 69 | // ... 70 | // Display the string. 71 | //MessageBox( NULL, (LPCTSTR)messageBuffer, "Error", MB_OK | MB_ICONINFORMATION ); 72 | printf("SimpleMutex error: %s", messageBuffer); 73 | // Free the buffer. 74 | LocalFree( messageBuffer ); 75 | 76 | } 77 | 78 | assert(d==WAIT_OBJECT_0); 79 | */ 80 | EnterCriticalSection(&criticalSection); 81 | 82 | #else 83 | int error = pthread_mutex_lock(&hMutex); 84 | assert(error==0); 85 | #endif 86 | } 87 | 88 | void SimpleMutex::Unlock(void) 89 | { 90 | #ifdef _WIN32 91 | // ReleaseMutex(hMutex); 92 | LeaveCriticalSection(&criticalSection); 93 | #else 94 | int error = pthread_mutex_unlock(&hMutex); 95 | assert(error==0); 96 | #endif 97 | } 98 | 99 | -------------------------------------------------------------------------------- /vendor/raknet/CheckSum.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief CheckSum implementation from http://www.flounder.com/checksum.htm 4 | * 5 | */ 6 | #include "CheckSum.h" 7 | 8 | /**************************************************************************** 9 | * CheckSum::add 10 | * Inputs: 11 | * unsigned int d: word to add 12 | * Result: void 13 | * 14 | * Effect: 15 | * Adds the bytes of the unsigned int to the CheckSum 16 | ****************************************************************************/ 17 | 18 | void CheckSum::Add ( unsigned int value ) 19 | { 20 | union 21 | { 22 | unsigned int value; 23 | unsigned char bytes[ 4 ]; 24 | } 25 | 26 | data; 27 | data.value = value; 28 | 29 | for ( unsigned int i = 0; i < sizeof( data.bytes ); i++ ) 30 | Add ( data.bytes[ i ] ) 31 | 32 | ; 33 | } // CheckSum::add(unsigned int) 34 | 35 | /**************************************************************************** 36 | * CheckSum::add 37 | * Inputs: 38 | * unsigned short value: 39 | * Result: void 40 | * 41 | * Effect: 42 | * Adds the bytes of the unsigned short value to the CheckSum 43 | ****************************************************************************/ 44 | 45 | void CheckSum::Add ( unsigned short value ) 46 | { 47 | union 48 | { 49 | unsigned short value; 50 | unsigned char bytes[ 2 ]; 51 | } 52 | 53 | data; 54 | data.value = value; 55 | 56 | for ( unsigned int i = 0; i < sizeof( data.bytes ); i++ ) 57 | Add ( data.bytes[ i ] ) 58 | 59 | ; 60 | } // CheckSum::add(unsigned short) 61 | 62 | /**************************************************************************** 63 | * CheckSum::add 64 | * Inputs: 65 | * unsigned char value: 66 | * Result: void 67 | * 68 | * Effect: 69 | * Adds the byte to the CheckSum 70 | ****************************************************************************/ 71 | 72 | void CheckSum::Add ( unsigned char value ) 73 | { 74 | unsigned char cipher = (unsigned char)( value ^ ( r >> 8 ) ); 75 | r = ( cipher + r ) * c1 + c2; 76 | sum += cipher; 77 | } // CheckSum::add(unsigned char) 78 | 79 | 80 | /**************************************************************************** 81 | * CheckSum::add 82 | * Inputs: 83 | * LPunsigned char b: pointer to byte array 84 | * unsigned int length: count 85 | * Result: void 86 | * 87 | * Effect: 88 | * Adds the bytes to the CheckSum 89 | ****************************************************************************/ 90 | 91 | void CheckSum::Add ( unsigned char *b, unsigned int length ) 92 | { 93 | for ( unsigned int i = 0; i < length; i++ ) 94 | Add ( b[ i ] ) 95 | 96 | ; 97 | } // CheckSum::add(LPunsigned char, unsigned int) 98 | -------------------------------------------------------------------------------- /settings.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "settings.h" 3 | #include "vendor/inih/cpp/INIReader.h" 4 | 5 | CSettings::CSettings() 6 | { 7 | //Log("Loading settings.."); 8 | 9 | char buff[0x7F]; 10 | sprintf(buff, "%sSAMP/settings.ini", g_pszStorage); 11 | 12 | INIReader reader(buff); 13 | 14 | if(reader.ParseError() < 0) 15 | { 16 | Log("Error: can't load %s", buff); 17 | std::terminate(); 18 | return; 19 | } 20 | 21 | // Client 22 | size_t length = 0; 23 | sprintf(buff, "QDS_User%d%d", rand() % 1000, rand() % 1000); 24 | length = reader.Get("client", "name", buff).copy(m_Settings.szNickName, MAX_PLAYER_NAME); 25 | m_Settings.szNickName[length] = '\0'; 26 | 27 | length = reader.Get("client", "host", "127.0.0.1").copy(m_Settings.szHost, MAX_SETTINGS_STRING); 28 | m_Settings.szHost[length] = '\0'; 29 | length = reader.Get("client", "password", "").copy(m_Settings.szPassword, MAX_SETTINGS_STRING); 30 | m_Settings.szPassword[length] = '\0'; 31 | m_Settings.iPort = reader.GetInteger("client", "port", 7777); 32 | 33 | // Debug 34 | m_Settings.bDebug = reader.GetBoolean("debug", "debug", true); 35 | m_Settings.bOnline = reader.GetBoolean("debug", "online", false); 36 | 37 | // gui 38 | length = reader.Get("gui", "Font", "Arial.ttf").copy(m_Settings.szFont, 35); 39 | m_Settings.szFont[length] = '\0'; 40 | m_Settings.fFontSize = reader.GetReal("gui", "FontSize", 40.0f); 41 | m_Settings.iFontOutline = reader.GetInteger("gui", "FontOutline", 1.9); 42 | 43 | // chat 44 | m_Settings.fChatPosX = reader.GetReal("gui", "ChatPosX", 325.0f); 45 | m_Settings.fChatPosY = reader.GetReal("gui", "ChatPosY", 25.0f); 46 | m_Settings.fChatSizeX = reader.GetReal("gui", "ChatSizeX", 1150.0f); 47 | m_Settings.fChatSizeY = reader.GetReal("gui", "ChatSizeY", 220.0f); 48 | m_Settings.iChatMaxMessages = reader.GetInteger("gui", "ChatMaxMessages", 10); 49 | 50 | // spawnscreen 51 | m_Settings.fSpawnScreenPosX = reader.GetReal("gui", "SpawnScreenPosX", 660.0f); 52 | m_Settings.fSpawnScreenPosY = reader.GetReal("gui", "SpawnScreenPosY", 950.0f); 53 | m_Settings.fSpawnScreenSizeX = reader.GetReal("gui", "SpawnScreenSizeX", 600.0f); 54 | m_Settings.fSpawnScreenSizeY = reader.GetReal("gui", "SpawnScreenSizeY", 100.0f); 55 | 56 | // nametags 57 | m_Settings.fHealthBarWidth = reader.GetReal("gui", "HealthBarWidth", 100.0f); 58 | m_Settings.fHealthBarHeight = reader.GetReal("gui", "HealthBarHeight", 10.0f); 59 | 60 | // m0d_SA gui 61 | m_Settings.fCheatsBoxWidth = reader.GetReal("modsa", "CheatsBoxWidth", 15.0f); 62 | m_Settings.fCheatsBoxHeight = reader.GetReal("modsa", "CheatsBoxHeight", 290.0f); 63 | m_Settings.fCheatsBox = reader.GetBoolean("modsa", "CheatsBox", true); 64 | } -------------------------------------------------------------------------------- /vendor/raknet/SAMP/samp_netencr.cpp: -------------------------------------------------------------------------------- 1 | // https://github.com/P3ti/RakSAMP/blob/master/raknet/SAMP/samp_netencr.cpp 2 | 3 | /* 4 | Updated to 0.3.7 by P3ti 5 | */ 6 | 7 | #include "main.h" 8 | 9 | int dblSpace; 10 | char buf[131072]; 11 | 12 | char GetChar(char _char) 13 | { 14 | if (_char < 32) 15 | return '.'; 16 | 17 | return _char; 18 | } 19 | 20 | unsigned char encrBuffer[4092]; 21 | #ifndef RAKSAMP_CLIENT 22 | unsigned char decrBuffer[4092]; 23 | #endif 24 | 25 | unsigned char sampEncrTable[256] = 26 | { 27 | 0x27, 0x69, 0xFD, 0x87, 0x60, 0x7D, 0x83, 0x02, 0xF2, 0x3F, 0x71, 0x99, 0xA3, 0x7C, 0x1B, 0x9D, 28 | 0x76, 0x30, 0x23, 0x25, 0xC5, 0x82, 0x9B, 0xEB, 0x1E, 0xFA, 0x46, 0x4F, 0x98, 0xC9, 0x37, 0x88, 29 | 0x18, 0xA2, 0x68, 0xD6, 0xD7, 0x22, 0xD1, 0x74, 0x7A, 0x79, 0x2E, 0xD2, 0x6D, 0x48, 0x0F, 0xB1, 30 | 0x62, 0x97, 0xBC, 0x8B, 0x59, 0x7F, 0x29, 0xB6, 0xB9, 0x61, 0xBE, 0xC8, 0xC1, 0xC6, 0x40, 0xEF, 31 | 0x11, 0x6A, 0xA5, 0xC7, 0x3A, 0xF4, 0x4C, 0x13, 0x6C, 0x2B, 0x1C, 0x54, 0x56, 0x55, 0x53, 0xA8, 32 | 0xDC, 0x9C, 0x9A, 0x16, 0xDD, 0xB0, 0xF5, 0x2D, 0xFF, 0xDE, 0x8A, 0x90, 0xFC, 0x95, 0xEC, 0x31, 33 | 0x85, 0xC2, 0x01, 0x06, 0xDB, 0x28, 0xD8, 0xEA, 0xA0, 0xDA, 0x10, 0x0E, 0xF0, 0x2A, 0x6B, 0x21, 34 | 0xF1, 0x86, 0xFB, 0x65, 0xE1, 0x6F, 0xF6, 0x26, 0x33, 0x39, 0xAE, 0xBF, 0xD4, 0xE4, 0xE9, 0x44, 35 | 0x75, 0x3D, 0x63, 0xBD, 0xC0, 0x7B, 0x9E, 0xA6, 0x5C, 0x1F, 0xB2, 0xA4, 0xC4, 0x8D, 0xB3, 0xFE, 36 | 0x8F, 0x19, 0x8C, 0x4D, 0x5E, 0x34, 0xCC, 0xF9, 0xB5, 0xF3, 0xF8, 0xA1, 0x50, 0x04, 0x93, 0x73, 37 | 0xE0, 0xBA, 0xCB, 0x45, 0x35, 0x1A, 0x49, 0x47, 0x6E, 0x2F, 0x51, 0x12, 0xE2, 0x4A, 0x72, 0x05, 38 | 0x66, 0x70, 0xB8, 0xCD, 0x00, 0xE5, 0xBB, 0x24, 0x58, 0xEE, 0xB4, 0x80, 0x81, 0x36, 0xA9, 0x67, 39 | 0x5A, 0x4B, 0xE8, 0xCA, 0xCF, 0x9F, 0xE3, 0xAC, 0xAA, 0x14, 0x5B, 0x5F, 0x0A, 0x3B, 0x77, 0x92, 40 | 0x09, 0x15, 0x4E, 0x94, 0xAD, 0x17, 0x64, 0x52, 0xD3, 0x38, 0x43, 0x0D, 0x0C, 0x07, 0x3C, 0x1D, 41 | 0xAF, 0xED, 0xE7, 0x08, 0xB7, 0x03, 0xE6, 0x8E, 0xAB, 0x91, 0x89, 0x3E, 0x2C, 0x96, 0x42, 0xD9, 42 | 0x78, 0xDF, 0xD0, 0x57, 0x5D, 0x84, 0x41, 0x7E, 0xCE, 0xF7, 0x32, 0xC3, 0xD5, 0x20, 0x0B, 0xA7 43 | }; 44 | 45 | void kyretardizeDatagram(unsigned char *buf, int len, int port, int unk) 46 | { 47 | unsigned char bChecksum = 0; 48 | for(int i = 0; i < len; i++) 49 | { 50 | unsigned char bData = buf[i]; 51 | bChecksum ^= bData & 0xAA; 52 | } 53 | encrBuffer[0] = bChecksum; 54 | 55 | unsigned char *buf_nocrc = &encrBuffer[1]; 56 | memcpy(buf_nocrc, buf, len); 57 | 58 | for(int i = 0; i < len; i++) 59 | { 60 | buf_nocrc[i] = sampEncrTable[buf_nocrc[i]]; 61 | if ( unk ) 62 | buf_nocrc[i] ^= (uint8_t)(port ^ 0xCC); 63 | unk ^= 1u; 64 | } 65 | } -------------------------------------------------------------------------------- /vendor/raknet/DataBlockEncryptor.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Encrypts and decrypts data blocks. Used as part of secure connections. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __DATA_BLOCK_ENCRYPTOR_H 19 | #define __DATA_BLOCK_ENCRYPTOR_H 20 | 21 | #include "rijndael.h" 22 | 23 | /// Encrypts and decrypts data blocks. 24 | class DataBlockEncryptor 25 | { 26 | 27 | public: 28 | 29 | /// Constructor 30 | DataBlockEncryptor(); 31 | 32 | /// Destructor 33 | ~DataBlockEncryptor(); 34 | 35 | /// \return true if SetKey has been called previously 36 | bool IsKeySet( void ) const; 37 | 38 | /// Set the encryption key 39 | /// \param[in] key The new encryption key 40 | void SetKey( const unsigned char key[ 16 ] ); 41 | 42 | /// Unset the encryption key 43 | void UnsetKey( void ); 44 | 45 | /// Encryption adds up to 15 bytes. Output should be large enough to hold this. 46 | /// Output can be the same memory block as input 47 | /// \param[in] input the input buffer to encrypt 48 | /// \param[in] inputLength the size of the @em input buffer 49 | /// \param[in] output the output buffer to store encrypted data 50 | /// \param[in] outputLength the size of the output buffer 51 | void Encrypt( unsigned char *input, int inputLength, unsigned char *output, int *outputLength ); 52 | 53 | /// Decryption removes bytes, as few as 6. Output should be large enough to hold this. 54 | /// Output can be the same memory block as input 55 | /// \param[in] input the input buffer to decrypt 56 | /// \param[in] inputLength the size of the @em input buffer 57 | /// \param[in] output the output buffer to store decrypted data 58 | /// \param[in] outputLength the size of the @em output buffer 59 | /// \return False on bad checksum or input, true on success 60 | bool Decrypt( unsigned char *input, int inputLength, unsigned char *output, int *outputLength ); 61 | 62 | protected: 63 | 64 | keyInstance keyEncrypt; 65 | keyInstance keyDecrypt; 66 | cipherInstance cipherInst; 67 | bool keySet; 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /textdraw.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "game/game.h" 3 | #include "net/netgame.h" 4 | #include "gui/gui.h" 5 | #include "vendor/imgui/imgui_internal.h" 6 | #include "keyboard.h" 7 | #include 8 | #include 9 | #include "textdraw.h" 10 | #include "settings.h" 11 | #include "timer.hpp" 12 | 13 | extern CGUI *pGUI; 14 | extern CGame *pGame; 15 | extern CNetGame *pNetGame; 16 | extern CKeyBoard *pKeyBoard; 17 | extern CSettings *pSettings; 18 | 19 | char szItemIdInputBuffer[100]; 20 | char utf8ItemIdInputBuffer[100*3]; 21 | 22 | CTextDraw::CTextDraw() 23 | { 24 | m_bIsActive = false; 25 | tdStorage = ""; 26 | } 27 | 28 | CTextDraw::~CTextDraw() 29 | { 30 | 31 | } 32 | 33 | void CTextDraw::Show(bool bShow) 34 | { 35 | m_bIsActive = bShow; 36 | } 37 | 38 | void CTextDraw::Clear() 39 | { 40 | m_bIsActive = false; 41 | tdStorage = ""; 42 | 43 | memset(szItemIdInputBuffer, 0, 100); 44 | memset(utf8ItemIdInputBuffer, 0, 100*3); 45 | } 46 | 47 | void ItemIdWindowInputHandler(const char* str) 48 | { 49 | if(!str || *str == '\0') return; 50 | strcpy(szItemIdInputBuffer, str); 51 | cp1251_to_utf8(utf8ItemIdInputBuffer, str); 52 | } 53 | 54 | void CTextDraw::StoreTD(uint16_t wTextID) 55 | { 56 | wtID = wTextID; 57 | } 58 | 59 | void CTextDraw::Render() 60 | { 61 | if(!m_bIsActive) return; 62 | 63 | ImGuiIO &io = ImGui::GetIO(); 64 | 65 | ImGui::StyleColorsClassic(); 66 | 67 | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8,8)); 68 | 69 | ImGui::Begin("> TextDraw", nullptr, 70 | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize); 71 | 72 | char str[4096]; 73 | CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool(); 74 | CLocalPlayer *pLocalPlayer = 0; 75 | if(pPlayerPool) pLocalPlayer = pPlayerPool->GetLocalPlayer(); 76 | 77 | if( ImGui::Button(utf8ItemIdInputBuffer, ImVec2(200, 45) )) 78 | { 79 | pKeyBoard->Open(&ItemIdWindowInputHandler); 80 | } 81 | 82 | ImGui::ItemSize( ImVec2(0, pGUI->GetFontSize()/2 + 5) ); 83 | 84 | if(ImGui::Button("Send", ImVec2(200, 50))) 85 | { 86 | char *id = szItemIdInputBuffer; 87 | int tid = atoi(id); 88 | 89 | pLocalPlayer->SendTextDrawClick(tid); 90 | } 91 | 92 | if(ImGui::Button("Close", ImVec2(200, 50))) 93 | { 94 | Show(false); 95 | } 96 | 97 | ImGui::SetWindowSize(ImVec2(-1, -1)); 98 | ImVec2 size = ImGui::GetWindowSize(); 99 | ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x + 435)/2), ((io.DisplaySize.y - size.y)/2)) ); 100 | ImGui::End(); 101 | 102 | ImGui::PopStyleVar(); 103 | } -------------------------------------------------------------------------------- /vendor/raknet/DS_HuffmanEncodingTree.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Generates a huffman encoding tree, used for string and global compression. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __HUFFMAN_ENCODING_TREE 19 | #define __HUFFMAN_ENCODING_TREE 20 | 21 | #include "DS_HuffmanEncodingTreeNode.h" 22 | #include "BitStream.h" 23 | #include "Export.h" 24 | #include "DS_LinkedList.h" 25 | 26 | /// This generates special cases of the huffman encoding tree using 8 bit keys with the additional condition that unused combinations of 8 bits are treated as a frequency of 1 27 | class RAK_DLL_EXPORT HuffmanEncodingTree 28 | { 29 | 30 | public: 31 | HuffmanEncodingTree(); 32 | ~HuffmanEncodingTree(); 33 | 34 | /// Pass an array of bytes to array and a preallocated BitStream to receive the output 35 | /// \param [in] input Array of bytes to encode 36 | /// \param [in] sizeInBytes size of \a input 37 | /// \param [out] output The bitstream to write to 38 | void EncodeArray( unsigned char *input, unsigned sizeInBytes, RakNet::BitStream * output ); 39 | 40 | // Decodes an array encoded by EncodeArray() 41 | unsigned DecodeArray( RakNet::BitStream * input, unsigned sizeInBits, unsigned maxCharsToWrite, unsigned char *output ); 42 | void DecodeArray( unsigned char *input, unsigned sizeInBits, RakNet::BitStream * output ); 43 | 44 | /// Given a frequency table of 256 elements, all with a frequency of 1 or more, generate the tree 45 | void GenerateFromFrequencyTable( unsigned int frequencyTable[ 256 ] ); 46 | 47 | /// Free the memory used by the tree 48 | void FreeMemory( void ); 49 | 50 | private: 51 | 52 | /// The root node of the tree 53 | 54 | HuffmanEncodingTreeNode *root; 55 | 56 | /// Used to hold bit encoding for one character 57 | 58 | 59 | struct CharacterEncoding 60 | { 61 | unsigned char* encoding; 62 | unsigned short bitLength; 63 | }; 64 | 65 | CharacterEncoding encodingTable[ 256 ]; 66 | 67 | void InsertNodeIntoSortedList( HuffmanEncodingTreeNode * node, DataStructures::LinkedList *huffmanEncodingTreeNodeList ) const; 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /vendor/raknet/DS_Tree.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Just a regular tree 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __DS_TREE_H 19 | #define __DS_TREE_H 20 | 21 | #include "Export.h" 22 | #include "DS_List.h" 23 | #include "DS_Queue.h" 24 | 25 | /// The namespace DataStructures was only added to avoid compiler errors for commonly named data structures 26 | /// As these data structures are stand-alone, you can use them outside of RakNet for your own projects if you wish. 27 | namespace DataStructures 28 | { 29 | template 30 | class RAK_DLL_EXPORT Tree 31 | { 32 | public: 33 | Tree(); 34 | Tree(TreeType &inputData); 35 | ~Tree(); 36 | void LevelOrderTraversal(DataStructures::List &output); 37 | void AddChild(TreeType &newData); 38 | void DeleteDecendants(void); 39 | 40 | TreeType data; 41 | DataStructures::List children; 42 | }; 43 | 44 | template 45 | Tree::Tree() 46 | { 47 | 48 | } 49 | 50 | template 51 | Tree::Tree(TreeType &inputData) 52 | { 53 | data=inputData; 54 | } 55 | 56 | template 57 | Tree::~Tree() 58 | { 59 | } 60 | 61 | template 62 | void Tree::LevelOrderTraversal(DataStructures::List &output) 63 | { 64 | unsigned i; 65 | Tree *node; 66 | DataStructures::Queue*> queue; 67 | 68 | for (i=0; i < children.Size(); i++) 69 | queue.Push(children[i]); 70 | 71 | while (queue.Size()) 72 | { 73 | node=queue.Pop(); 74 | output.Insert(node); 75 | for (i=0; i < node->children.Size(); i++) 76 | queue.Push(node->children[i]); 77 | } 78 | } 79 | 80 | template 81 | void Tree::AddChild(TreeType &newData) 82 | { 83 | children.Insert(new Tree(newData)); 84 | } 85 | 86 | template 87 | void Tree::DeleteDecendants(void) 88 | { 89 | DataStructures::List output; 90 | LevelOrderTraversal(output); 91 | unsigned i; 92 | for (i=0; i < output.Size(); i++) 93 | delete output[i]; 94 | } 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /vendor/raknet/SHA1.h: -------------------------------------------------------------------------------- 1 | /// \brief \b [Internal] SHA-1 computation class 2 | /// 3 | /// 100% free public domain implementation of the SHA-1 4 | /// algorithm by Dominik Reichl 5 | /// 6 | /// 7 | /// === Test Vectors (from FIPS PUB 180-1) === 8 | /// 9 | /// "abc" 10 | /// A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D 11 | /// 12 | /// "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" 13 | /// 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 14 | /// 15 | /// A million repetitions of "a" 16 | /// 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F 17 | 18 | #ifndef ___SHA1_H___ 19 | #define ___SHA1_H___ 20 | 21 | #include // Needed for file access 22 | #include // Needed for memset and memcpy 23 | #include // Needed for strcat and strcpy 24 | #include "Types.h" 25 | #include "Export.h" 26 | 27 | #define MAX_FILE_READ_BUFFER 8000 28 | 29 | #define SHA1_LENGTH 20 30 | 31 | class RAK_DLL_EXPORT CSHA1 32 | { 33 | 34 | public: 35 | // Rotate x bits to the left 36 | // #define ROL32(value, bits) (((value)<<(bits))|((value)>>(32-(bits)))) 37 | 38 | #ifdef LITTLE_ENDIAN 39 | #define SHABLK0(i) (block->l[i] = (ROL32(block->l[i],24) & 0xFF00FF00) \ 40 | | (ROL32(block->l[i],8) & 0x00FF00FF)) 41 | #else 42 | #define SHABLK0(i) (block->l[i]) 43 | #endif 44 | 45 | #define SHABLK(i) (block->l[i&15] = ROL32(block->l[(i+13)&15] ^ block->l[(i+8)&15] \ 46 | ^ block->l[(i+2)&15] ^ block->l[i&15],1)) 47 | 48 | // SHA-1 rounds 49 | #define R0(v,w,x,y,z,i) { z+=((w&(x^y))^y)+SHABLK0(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); } 50 | #define R1(v,w,x,y,z,i) { z+=((w&(x^y))^y)+SHABLK(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); } 51 | #define R2(v,w,x,y,z,i) { z+=(w^x^y)+SHABLK(i)+0x6ED9EBA1+ROL32(v,5); w=ROL32(w,30); } 52 | #define R3(v,w,x,y,z,i) { z+=(((w|x)&y)|(w&x))+SHABLK(i)+0x8F1BBCDC+ROL32(v,5); w=ROL32(w,30); } 53 | #define R4(v,w,x,y,z,i) { z+=(w^x^y)+SHABLK(i)+0xCA62C1D6+ROL32(v,5); w=ROL32(w,30); } 54 | 55 | typedef union { 56 | unsigned char c[ 64 ]; 57 | unsigned int l[ 16 ]; 58 | } SHA1_WORKSPACE_BLOCK; 59 | /* Two different formats for ReportHash(...) 60 | */ 61 | enum { REPORT_HEX = 0, 62 | REPORT_DIGIT = 1}; 63 | 64 | CSHA1(); 65 | virtual ~CSHA1(); 66 | 67 | unsigned int m_state[ 5 ]; 68 | unsigned int m_count[ 2 ]; 69 | unsigned char m_buffer[ 64 ]; 70 | unsigned char m_digest[ 20 ]; 71 | void Reset(); 72 | void Update( unsigned char* data, unsigned int len ); 73 | bool HashFile( char *szFileName ); 74 | void Final(); 75 | void ReportHash( char *szReport, unsigned char uReportType = REPORT_HEX ); 76 | void GetHash( unsigned char *uDest ); 77 | unsigned char * GetHash( void ) const; 78 | 79 | private: 80 | void Transform( unsigned int state[ 5 ], unsigned char buffer[ 64 ] ); 81 | unsigned char workspace[ 64 ]; 82 | }; 83 | 84 | #endif // ___SHA1_H___ 85 | 86 | -------------------------------------------------------------------------------- /vendor/raknet/_findfirst.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Original file by the_viking, fixed by R√¥mulo Fernandes, fixed by Emmanuel Nars 3 | * Should emulate windows finddata structure 4 | */ 5 | #if (defined(__GNUC__) || defined(__GCCXML__)) && !defined(__WIN32) 6 | #include "_findfirst.h" 7 | #include "DS_List.h" 8 | 9 | static DataStructures::List< _findinfo_t* > fileInfo; 10 | 11 | /** 12 | * _findfirst - equivalent 13 | */ 14 | long _findfirst(const char *name, _finddata_t *f) 15 | { 16 | 17 | // char* nameCopy = new char[sizeof(name)]; 18 | // memset(nameCopy, '\0', sizeof(nameCopy)); 19 | // 20 | // strcpy(nameCopy, name); 21 | // 22 | // char* filter = new char[sizeof(nameCopy)]; 23 | // memset(filter, '\0', sizeof(filter)); 24 | 25 | int length = strlen(name)+1; 26 | char* nameCopy = new char[length]; 27 | memset(nameCopy, '\0', length); 28 | 29 | strcpy(nameCopy, name); 30 | 31 | char* filter = new char[length]; 32 | memset(filter, '\0', length); 33 | 34 | char* lastSep = strrchr(nameCopy,'/'); 35 | if(!lastSep) 36 | { 37 | strcpy(filter, nameCopy); 38 | strcpy(nameCopy, "."); 39 | } 40 | else 41 | { 42 | strcpy(filter, lastSep+1); 43 | *lastSep = 0; 44 | } 45 | 46 | DIR* dir = opendir(nameCopy); 47 | 48 | if(!dir) 49 | { 50 | return -1; 51 | } 52 | 53 | _findinfo_t* fi = new _findinfo_t; 54 | strcpy(fi->filter,filter); 55 | fi->openedDir = dir; 56 | 57 | while(true) 58 | { 59 | dirent* entry = readdir(dir); 60 | if(entry == 0) 61 | break; 62 | 63 | if(fnmatch(fi->filter,entry->d_name, 200) == 0) 64 | { 65 | strcpy(f->name, entry->d_name); 66 | break; 67 | } 68 | } 69 | 70 | 71 | fileInfo.Insert(fi); 72 | return fileInfo.Size()-1; 73 | 74 | // return 0; 75 | } 76 | 77 | /** 78 | * _findnext - equivalent 79 | */ 80 | int _findnext(long h, _finddata_t *f) 81 | { 82 | 83 | _findinfo_t* fi = fileInfo[h]; 84 | 85 | while(true) 86 | { 87 | dirent* entry = readdir(fi->openedDir); 88 | if(entry == 0) 89 | return -1; 90 | 91 | if(fnmatch(fi->filter,entry->d_name, 200) == 0) 92 | { 93 | strcpy(f->name, entry->d_name); 94 | if (entry->d_type == DT_REG) 95 | f->attrib = _A_NORMAL; 96 | f->size = entry->d_reclen; 97 | return 0; 98 | } 99 | if (entry->d_type == DT_DIR) 100 | { 101 | f->attrib = _A_SUBDIR; 102 | strcpy(f->name, entry->d_name); 103 | return 0; 104 | } 105 | } 106 | 107 | return -1; 108 | } 109 | 110 | /** 111 | * _findclose - equivalent 112 | */ 113 | int _findclose(long h) 114 | { 115 | if (fileInfo.Size()>h) 116 | { 117 | _findinfo_t* fi = fileInfo[h]; 118 | fileInfo.RemoveAtIndex(h); 119 | delete fi; 120 | return 0; 121 | } 122 | else 123 | { 124 | printf("Error _findclose\n"); 125 | return -1; 126 | } 127 | 128 | } 129 | #endif 130 | -------------------------------------------------------------------------------- /vendor/raknet/AsynchronousFileIO.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] Depreciated, used for windows back when I supported IO completion ports. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | // No longer used as I no longer support IO Completion ports 19 | /* 20 | #ifdef __USE_IO_COMPLETION_PORTS 21 | 22 | #ifndef __ASYNCHRONOUS_FILE_IO_H 23 | #define __ASYNCHRONOUS_FILE_IO_H 24 | 25 | #ifdef _COMPATIBILITY_1 26 | #elif defined(_WIN32) 27 | // IP_DONTFRAGMENT is different between winsock 1 and winsock 2. Therefore, Winsock2.h must be linked againt Ws2_32.lib 28 | // winsock.h must be linked against WSock32.lib. If these two are mixed up the flag won't work correctly 29 | //#include 30 | //#include 31 | #endif 32 | #include "SimpleMutex.h" 33 | 34 | struct ExtendedOverlappedStruct; 35 | 36 | /// Provides asynch file input and ouput, either for sockets or files 37 | class AsynchronousFileIO 38 | { 39 | 40 | public: 41 | 42 | /// Default Constructor 43 | AsynchronousFileIO(); 44 | 45 | /// Destructor 46 | ~AsynchronousFileIO(); 47 | 48 | 49 | /// Associate a socket with a completion port 50 | /// \param[in] socket the socket used for communication 51 | /// \param[in] dwCompletionKey the completion port key 52 | bool AssociateSocketWithCompletionPort( SOCKET socket, DWORD dwCompletionKey );if 53 | 54 | /// Singleton instance 55 | static inline AsynchronousFileIO* Instance() 56 | { 57 | return & I; 58 | } 59 | 60 | /// Increase the number of users of this instance 61 | void IncreaseUserCount( void ); 62 | 63 | /// Decrease the number of users of this instance 64 | void DecreaseUserCount( void ); 65 | 66 | /// Stop using asynchronous IO 67 | void Shutdown( void ); 68 | 69 | /// Get the number of user of the instance 70 | int GetUserCount( void ); 71 | 72 | unsigned threadCount; 73 | bool killThreads; 74 | 75 | private: 76 | HANDLE completionPort; 77 | SimpleMutex userCountMutex; 78 | SYSTEM_INFO systemInfo; 79 | int userCount; 80 | 81 | static AsynchronousFileIO I; 82 | }; 83 | 84 | unsigned __stdcall ThreadPoolFunc( LPVOID arguments ); 85 | 86 | void WriteAsynch( HANDLE handle, ExtendedOverlappedStruct *extended ); 87 | 88 | BOOL ReadAsynch( HANDLE handle, ExtendedOverlappedStruct *extended ); 89 | 90 | #endif 91 | */ -------------------------------------------------------------------------------- /vendor/inih/cpp/INIReader.cpp: -------------------------------------------------------------------------------- 1 | // Read an INI file into easy-to-access name/value pairs. 2 | 3 | // inih and INIReader are released under the New BSD license (see LICENSE.txt). 4 | // Go to the project home page for more info: 5 | // 6 | // https://github.com/benhoyt/inih 7 | 8 | #include 9 | #include 10 | #include 11 | #include "../ini.h" 12 | #include "INIReader.h" 13 | 14 | using std::string; 15 | 16 | INIReader::INIReader(const string& filename) 17 | { 18 | _error = ini_parse(filename.c_str(), ValueHandler, this); 19 | } 20 | 21 | int INIReader::ParseError() const 22 | { 23 | return _error; 24 | } 25 | 26 | string INIReader::Get(const string& section, const string& name, const string& default_value) const 27 | { 28 | string key = MakeKey(section, name); 29 | // Use _values.find() here instead of _values.at() to support pre C++11 compilers 30 | return _values.count(key) ? _values.find(key)->second : default_value; 31 | } 32 | 33 | long INIReader::GetInteger(const string& section, const string& name, long default_value) const 34 | { 35 | string valstr = Get(section, name, ""); 36 | const char* value = valstr.c_str(); 37 | char* end; 38 | // This parses "1234" (decimal) and also "0x4D2" (hex) 39 | long n = strtol(value, &end, 0); 40 | return end > value ? n : default_value; 41 | } 42 | 43 | double INIReader::GetReal(const string& section, const string& name, double default_value) const 44 | { 45 | string valstr = Get(section, name, ""); 46 | const char* value = valstr.c_str(); 47 | char* end; 48 | double n = strtod(value, &end); 49 | return end > value ? n : default_value; 50 | } 51 | 52 | bool INIReader::GetBoolean(const string& section, const string& name, bool default_value) const 53 | { 54 | string valstr = Get(section, name, ""); 55 | // Convert to lower case to make string comparisons case-insensitive 56 | std::transform(valstr.begin(), valstr.end(), valstr.begin(), ::tolower); 57 | if (valstr == "true" || valstr == "yes" || valstr == "on" || valstr == "1") 58 | return true; 59 | else if (valstr == "false" || valstr == "no" || valstr == "off" || valstr == "0") 60 | return false; 61 | else 62 | return default_value; 63 | } 64 | 65 | string INIReader::MakeKey(const string& section, const string& name) 66 | { 67 | string key = section + "=" + name; 68 | // Convert to lower case to make section/name lookups case-insensitive 69 | std::transform(key.begin(), key.end(), key.begin(), ::tolower); 70 | return key; 71 | } 72 | 73 | int INIReader::ValueHandler(void* user, const char* section, const char* name, 74 | const char* value) 75 | { 76 | INIReader* reader = (INIReader*)user; 77 | string key = MakeKey(section, name); 78 | if (reader->_values[key].size() > 0) 79 | reader->_values[key] += "\n"; 80 | reader->_values[key] += value; 81 | return 1; 82 | } 83 | -------------------------------------------------------------------------------- /vendor/raknet/FullyConnectedMesh.cpp__: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// 3 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 4 | /// 5 | /// Usage of RakNet is subject to the appropriate license agreement. 6 | /// Creative Commons Licensees are subject to the 7 | /// license found at 8 | /// http://creativecommons.org/licenses/by-nc/2.5/ 9 | /// Single application licensees are subject to the license found at 10 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 11 | /// Custom license users are subject to the terms therein. 12 | /// GPL license users are subject to the GNU General Public 13 | /// License as published by the Free 14 | /// Software Foundation; either version 2 of the License, or (at your 15 | /// option) any later version. 16 | 17 | #include "FullyConnectedMesh.h" 18 | #include "RakPeerInterface.h" 19 | #include "PacketEnumerations.h" 20 | #include "BitStream.h" 21 | #include 22 | #include 23 | 24 | #ifdef _MSC_VER 25 | #pragma warning( push ) 26 | #endif 27 | 28 | FullyConnectedMesh::FullyConnectedMesh() 29 | { 30 | pw=0; 31 | } 32 | 33 | FullyConnectedMesh::~FullyConnectedMesh() 34 | { 35 | if (pw) 36 | delete [] pw; 37 | } 38 | 39 | void FullyConnectedMesh::Initialize(const char *password) 40 | { 41 | if (pw) 42 | delete [] pw; 43 | if (password && password[0]) 44 | { 45 | pw = new char [strlen(password)+1]; 46 | strcpy(pw, password); 47 | } 48 | else 49 | pw=0; 50 | 51 | } 52 | 53 | #ifdef _MSC_VER 54 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 55 | #endif 56 | void FullyConnectedMesh::OnDisconnect(RakPeerInterface *peer) 57 | { 58 | } 59 | #ifdef _MSC_VER 60 | #pragma warning( disable : 4701 ) // warning C4701: local variable may be used without having been initialized 61 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 62 | #endif 63 | void FullyConnectedMesh::Update(RakPeerInterface *peer) 64 | { 65 | } 66 | 67 | PluginReceiveResult FullyConnectedMesh::OnReceive(RakPeerInterface *peer, Packet *packet) 68 | { 69 | assert(packet); 70 | assert(peer); 71 | 72 | switch (packet->data[0]) 73 | { 74 | case ID_REMOTE_NEW_INCOMING_CONNECTION: // This comes from the connection graph plugin 75 | { 76 | RakNet::BitStream b(packet->data, packet->length, false); 77 | b.IgnoreBits(8); 78 | ConnectionGraphGroupID group1, group2; 79 | PlayerID node1, node2; 80 | b.Read(node1); 81 | b.Read(group1); 82 | if (peer->GetIndexFromPlayerID(node1)==-1) 83 | peer->Connect(peer->PlayerIDToDottedIP(node1), node1.port, pw, pw ? (int)strlen(pw) : 0); 84 | b.Read(node2); 85 | b.Read(group2); 86 | if (peer->GetIndexFromPlayerID(node2)==-1) 87 | peer->Connect(peer->PlayerIDToDottedIP(node2), node2.port, pw, pw ? (int)strlen(pw) : 0); 88 | break; 89 | } 90 | } 91 | 92 | return RR_CONTINUE_PROCESSING; 93 | } 94 | 95 | #ifdef _MSC_VER 96 | #pragma warning( pop ) 97 | #endif 98 | -------------------------------------------------------------------------------- /vendor/raknet/RakNetCommandParser.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief Contains RakNetCommandParser , used to send commands to an instance of RakPeer 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __RAKNET_COMMAND_PARSER 19 | #define __RAKNET_COMMAND_PARSER 20 | 21 | #include "CommandParserInterface.h" 22 | #include "Export.h" 23 | class RakPeerInterface; 24 | 25 | /// \brief This allows a console client to call most of the functions in RakPeer 26 | class RAK_DLL_EXPORT RakNetCommandParser : public CommandParserInterface 27 | { 28 | public: 29 | RakNetCommandParser(); 30 | ~RakNetCommandParser(); 31 | 32 | /// Given \a command with parameters \a parameterList , do whatever processing you wish. 33 | /// \param[in] command The command to process 34 | /// \param[in] numParameters How many parameters were passed along with the command 35 | /// \param[in] parameterList The list of parameters. parameterList[0] is the first parameter and so on. 36 | /// \param[in] transport The transport interface we can use to write to 37 | /// \param[in] playerId The player that sent this command. 38 | /// \param[in] originalString The string that was actually sent over the network, in case you want to do your own parsing 39 | bool OnCommand(const char *command, unsigned numParameters, char **parameterList, TransportInterface *transport, PlayerID playerId, const char *originalString); 40 | 41 | /// You are responsible for overriding this function and returning a static string, which will identifier your parser. 42 | /// This should return a static string 43 | /// \return The name that you return. 44 | char *GetName(void) const; 45 | 46 | /// A callback for when you are expected to send a brief description of your parser to \a playerId 47 | /// \param[in] transport The transport interface we can use to write to 48 | /// \param[in] playerId The player that requested help. 49 | void SendHelp(TransportInterface *transport, PlayerID playerId); 50 | 51 | /// Records the instance of RakPeer to perform the desired commands on 52 | /// \param[in] rakPeer The RakPeer instance, or a derived class (e.g. RakServer or RakClient) 53 | void SetRakPeerInterface(RakPeerInterface *rakPeer); 54 | protected: 55 | 56 | /// Which instance of RakPeer we are working on. Set from SetRakPeerInterface() 57 | RakPeerInterface *peer; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /vendor/raknet/DS_ByteQueue.cpp: -------------------------------------------------------------------------------- 1 | #include "DS_ByteQueue.h" 2 | #include // Memmove 3 | //#include // PS3 doesn't have this 4 | #include // realloc 5 | #include 6 | 7 | using namespace DataStructures; 8 | 9 | ByteQueue::ByteQueue() 10 | { 11 | readOffset=writeOffset=lengthAllocated=0; 12 | data=0; 13 | } 14 | ByteQueue::~ByteQueue() 15 | { 16 | Clear(); 17 | 18 | 19 | } 20 | void ByteQueue::WriteBytes(const char *in, unsigned length) 21 | { 22 | unsigned bytesWritten; 23 | bytesWritten=GetBytesWritten(); 24 | if (lengthAllocated==0 || length > lengthAllocated-bytesWritten-1) 25 | { 26 | unsigned oldLengthAllocated=lengthAllocated; 27 | unsigned newAmountToAllocate=length*2; 28 | if (newAmountToAllocate<256) 29 | newAmountToAllocate=256; 30 | lengthAllocated=lengthAllocated + newAmountToAllocate; 31 | data=(char*)realloc(data, lengthAllocated); 32 | if (writeOffset < readOffset) 33 | { 34 | if (writeOffset <= newAmountToAllocate) 35 | { 36 | memcpy(data + oldLengthAllocated, data, writeOffset); 37 | writeOffset=readOffset+bytesWritten; 38 | } 39 | else 40 | { 41 | memcpy(data + oldLengthAllocated, data, newAmountToAllocate); 42 | memmove(data, data+newAmountToAllocate, writeOffset-newAmountToAllocate); 43 | writeOffset-=newAmountToAllocate; 44 | } 45 | } 46 | } 47 | 48 | if (length <= lengthAllocated-writeOffset) 49 | memcpy(data+writeOffset, in, length); 50 | else 51 | { 52 | // Wrap 53 | memcpy(data+writeOffset, in, lengthAllocated-writeOffset); 54 | memcpy(data, in+(lengthAllocated-writeOffset), length-(lengthAllocated-writeOffset)); 55 | } 56 | writeOffset=(writeOffset+length) % lengthAllocated; 57 | } 58 | bool ByteQueue::ReadBytes(char *out, unsigned length, bool peek) 59 | { 60 | if (GetBytesWritten() < length) 61 | return false; 62 | 63 | if (length <= lengthAllocated-readOffset) 64 | memcpy(out, data+readOffset, length); 65 | else 66 | { 67 | // Wrap 68 | memcpy(out, data+readOffset, lengthAllocated-readOffset); 69 | memcpy(out+(lengthAllocated-readOffset), data, length-(lengthAllocated-readOffset)); 70 | } 71 | 72 | if (peek==false) 73 | IncrementReadOffset(length); 74 | 75 | return true; 76 | } 77 | void ByteQueue::Clear(void) 78 | { 79 | if (lengthAllocated) 80 | free(data); 81 | readOffset=writeOffset=lengthAllocated=0; 82 | data=0; 83 | } 84 | unsigned ByteQueue::GetBytesWritten(void) const 85 | { 86 | if (writeOffset>=readOffset) 87 | return writeOffset-readOffset; 88 | else 89 | return (writeOffset-1)+(lengthAllocated-readOffset); 90 | } 91 | void ByteQueue::IncrementReadOffset(unsigned length) 92 | { 93 | readOffset=(readOffset+length) % lengthAllocated; 94 | } 95 | void ByteQueue::Print(void) 96 | { 97 | unsigned i; 98 | for (i=readOffset; i!=writeOffset; i++) 99 | printf("%i ", data[i]); 100 | printf("\n"); 101 | } 102 | -------------------------------------------------------------------------------- /vendor/raknet/ConsoleServer.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief Contains ConsoleServer , used to plugin to your game to accept remote console-based connections 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __CONSOLE_SERVER_H 19 | #define __CONSOLE_SERVER_H 20 | 21 | class TransportInterface; 22 | class CommandParserInterface; 23 | 24 | #include "DS_List.h" 25 | #include "NetworkTypes.h" 26 | #include "Export.h" 27 | 28 | /// \brief The main entry point for the server portion of your remote console application support. 29 | /// ConsoleServer takes one TransportInterface and one or more CommandParserInterface (s) 30 | /// The TransportInterface will be used to send data between the server and the client. The connecting client must support the 31 | /// protocol used by your derivation of TransportInterface . TelnetTransport and RakNetTransport are two such derivations . 32 | /// When a command is sent by a remote console, it will be processed by your implementations of CommandParserInterface 33 | class RAK_DLL_EXPORT ConsoleServer 34 | { 35 | public: 36 | ConsoleServer(); 37 | ~ConsoleServer(); 38 | 39 | /// Call this with a derivation of TransportInterface so that the console server can send and receive commands 40 | /// \param[in] transportInterface Your interface to use. 41 | /// \param[in] port The port to host on. Telnet uses port 23 by default. RakNet can use whatever you want. 42 | void SetTransportProvider(TransportInterface *transportInterface, unsigned short port); 43 | 44 | /// Add an implementation of CommandParserInterface to the list of command parsers. 45 | /// \param[in] commandParserInterface The command parser referred to 46 | void AddCommandParser(CommandParserInterface *commandParserInterface); 47 | 48 | /// Remove an implementation of CommandParserInterface previously added with AddCommandParser() 49 | /// \param[in] commandParserInterface The command parser referred to 50 | void RemoveCommandParser(CommandParserInterface *commandParserInterface); 51 | 52 | /// Call update to read packet sent from your TransportInterface. 53 | /// You should do this fairly frequently. 54 | void Update(void); 55 | protected: 56 | void ListParsers(PlayerID playerId); 57 | TransportInterface *transport; 58 | DataStructures::List commandParserList; 59 | char* password[256]; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /vendor/raknet/PacketEnumerations.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief All the packet identifiers used by RakNet. Packet identifiers comprise the first byte of any message. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __PACKET_ENUMERATIONS_H 19 | #define __PACKET_ENUMERATIONS_H 20 | 21 | /// You should not edit the file PacketEnumerations.h as it is a part of RakNet static library 22 | /// To define your own message id, define an enum following the code example that follows. 23 | /// 24 | /// \code 25 | /// enum { 26 | /// ID_MYPROJECT_MSG_1 = ID_USER_PACKET_ENUM 27 | /// ID_MYPROJECT_MSG_2, 28 | /// ... 29 | /// }; 30 | /// \endcode 31 | /// 32 | /// \note All these enumerations should be casted to (unsigned char) before writing them to RakNet::BitStream 33 | 34 | enum PacketEnumeration 35 | { 36 | ID_INTERNAL_PING = 6, 37 | ID_PING, 38 | ID_PING_OPEN_CONNECTIONS, 39 | ID_CONNECTED_PONG, 40 | ID_REQUEST_STATIC_DATA, 41 | ID_CONNECTION_REQUEST, 42 | ID_AUTH_KEY, 43 | ID_BROADCAST_PINGS = 14, 44 | ID_SECURED_CONNECTION_RESPONSE, 45 | ID_SECURED_CONNECTION_CONFIRMATION, 46 | ID_RPC_MAPPING, 47 | ID_SET_RANDOM_NUMBER_SEED = 19, 48 | ID_RPC, 49 | ID_RPC_REPLY, 50 | ID_DETECT_LOST_CONNECTIONS = 23, 51 | ID_OPEN_CONNECTION_REQUEST, 52 | ID_OPEN_CONNECTION_REPLY, 53 | ID_OPEN_CONNECTION_COOKIE, 54 | ID_RSA_PUBLIC_KEY_MISMATCH = 28, 55 | ID_CONNECTION_ATTEMPT_FAILED, 56 | ID_NEW_INCOMING_CONNECTION = 30, 57 | ID_NO_FREE_INCOMING_CONNECTIONS = 31, 58 | ID_DISCONNECTION_NOTIFICATION, 59 | ID_CONNECTION_LOST, 60 | ID_CONNECTION_REQUEST_ACCEPTED, 61 | ID_FAILED_INITIALIZE_ENCRIPTION, 62 | ID_CONNECTION_BANNED = 36, 63 | ID_INVALID_PASSWORD, 64 | ID_MODIFIED_PACKET, 65 | ID_PONG, 66 | ID_TIMESTAMP, 67 | ID_RECEIVED_STATIC_DATA, 68 | ID_REMOTE_DISCONNECTION_NOTIFICATION, 69 | ID_REMOTE_CONNECTION_LOST, 70 | ID_REMOTE_NEW_INCOMING_CONNECTION, 71 | ID_REMOTE_EXISTING_CONNECTION, 72 | ID_REMOTE_STATIC_DATA, 73 | ID_ADVERTISE_SYSTEM = 55, 74 | 75 | ID_PLAYER_SYNC = 207, 76 | ID_MARKERS_SYNC = 208, 77 | ID_UNOCCUPIED_SYNC = 209, 78 | ID_TRAILER_SYNC = 210, 79 | ID_PASSENGER_SYNC = 211, 80 | ID_SPECTATOR_SYNC = 212, 81 | ID_AIM_SYNC = 203, 82 | ID_VEHICLE_SYNC = 200, 83 | ID_RCON_COMMAND = 201, 84 | ID_RCON_RESPONCE = 202, 85 | ID_WEAPONS_UPDATE = 204, 86 | ID_STATS_UPDATE = 205, 87 | ID_BULLET_SYNC = 206, 88 | }; 89 | 90 | #endif 91 | 92 | -------------------------------------------------------------------------------- /playerslist.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "game/game.h" 3 | #include "net/netgame.h" 4 | #include "game/common.h" 5 | #include "gui/gui.h" 6 | #include "playerslist.h" 7 | #include "vendor/imgui/imgui_internal.h" 8 | #include "timer.hpp" 9 | #include 10 | #include 11 | 12 | extern CGUI *pGUI; 13 | extern CGame *pGame; 14 | extern CNetGame *pNetGame; 15 | 16 | CPlayersList::CPlayersList() 17 | { 18 | m_bIsActive = false; 19 | szInfo = " "; 20 | playersCount = 0; 21 | out = false; 22 | } 23 | 24 | CPlayersList::~CPlayersList() 25 | { 26 | 27 | } 28 | 29 | void CPlayersList::Show(bool bShow) 30 | { 31 | if(pGame) 32 | pGame->FindPlayerPed()->TogglePlayerControllable(!bShow); 33 | 34 | m_bIsActive = bShow; 35 | if(bShow != false) out = false; 36 | } 37 | 38 | void CPlayersList::Clear() 39 | { 40 | m_bIsActive = false; 41 | szInfo = " "; 42 | playersCount = 0; 43 | out = false; 44 | } 45 | 46 | int lastPlayerCount = 0; 47 | void CPlayersList::Render() 48 | { 49 | if(!m_bIsActive) return; 50 | 51 | ImGuiIO &io = ImGui::GetIO(); 52 | 53 | ImGui::StyleColorsClassic(); 54 | 55 | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 8)); 56 | 57 | char motd[256]; 58 | 59 | if(pNetGame) sprintf(motd, "> %.64s", pNetGame->m_szHostName); 60 | 61 | ImGui::Begin(motd, nullptr, 62 | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove); 63 | ImGui::Text("Players: %i / 1000", playersCount); 64 | 65 | ImGui::ItemSize( ImVec2(0, 1.2) ); 66 | if(ImGui::Button("Close", ImVec2(500, 50))) 67 | { 68 | Show(false); 69 | } 70 | 71 | ImGui::ItemSize( ImVec2(0, 5) ); 72 | 73 | ImGui::Text(" ID | Name"); 74 | 75 | CPlayerPool* pPlayerPool = pNetGame->GetPlayerPool(); 76 | 77 | ImGui::BeginChild("playersChild", ImVec2(500, 650), true, 78 | ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove); 79 | 80 | char szBuf[4096] = ""; 81 | 82 | for(PLAYERID playerId = 0; playerId < playersCount; playerId++) 83 | { 84 | if(pPlayerPool->GetSlotState(playerId) == true) 85 | { 86 | CRemotePlayer* pPlayer = pPlayerPool->GetAt(playerId); 87 | uint32_t dwColor = pPlayer->GetPlayerColor(); 88 | char* pName = (char*)pPlayerPool->GetPlayerName(playerId); 89 | 90 | sprintf(szBuf, "[%i] %s", playerId, pName); 91 | ImGui::Text("%s", szBuf); 92 | } 93 | } 94 | 95 | ImGui::EndChild(); 96 | 97 | ImGui::SetWindowSize(ImVec2(-1, -1)); 98 | ImVec2 size = ImGui::GetWindowSize(); 99 | ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x)/2), ((io.DisplaySize.y - size.y)/2) ) ); 100 | ImGui::End(); 101 | ImGui::PopStyleVar(); 102 | } -------------------------------------------------------------------------------- /vendor/raknet/FileOperations.cpp: -------------------------------------------------------------------------------- 1 | #include "_findfirst.h" // For linux 2 | #include "FileOperations.h" 3 | #include 4 | #include 5 | #ifdef _WIN32 6 | // For mkdir 7 | #include 8 | #include 9 | #else 10 | #include 11 | #include 12 | #include "LinuxStrings.h" 13 | #include "_findfirst.h" 14 | #endif 15 | 16 | 17 | bool WriteFileWithDirectories( const char *path, char *data, unsigned dataLength ) 18 | { 19 | int index; 20 | FILE *fp; 21 | char *pathCopy; 22 | #ifndef _WIN32 23 | 24 | char *systemCommand; 25 | #endif 26 | 27 | if ( path == 0 || path[ 0 ] == 0 ) 28 | return false; 29 | 30 | #ifndef _WIN32 31 | 32 | systemCommand = new char [ strlen( path ) + 1 + 6 ]; 33 | 34 | #endif 35 | 36 | pathCopy = new char [ strlen( path ) + 1 ]; 37 | 38 | strcpy( pathCopy, path ); 39 | 40 | index = 0; 41 | 42 | while ( pathCopy[ index ] ) 43 | { 44 | if ( pathCopy[ index ] == '/' || pathCopy[ index ] == '\\') 45 | { 46 | pathCopy[ index ] = 0; 47 | #ifdef _WIN32 48 | _mkdir( pathCopy ); 49 | #else 50 | 51 | mkdir( pathCopy, 0744 ); 52 | #endif 53 | 54 | pathCopy[ index ] = '/'; 55 | } 56 | 57 | index++; 58 | } 59 | 60 | if (data && dataLength) 61 | { 62 | fp = fopen( path, "wb" ); 63 | 64 | if ( fp == 0 ) 65 | { 66 | delete [] pathCopy; 67 | #ifndef _WIN32 68 | delete [] systemCommand; 69 | #endif 70 | return false; 71 | } 72 | 73 | fwrite( data, 1, dataLength, fp ); 74 | 75 | fclose( fp ); 76 | } 77 | else 78 | { 79 | #ifdef _WIN32 80 | _mkdir( pathCopy ); 81 | #else 82 | mkdir( pathCopy, 0744 ); 83 | #endif 84 | } 85 | 86 | delete [] pathCopy; 87 | #ifndef _WIN32 88 | delete [] systemCommand; 89 | #endif 90 | 91 | 92 | return true; 93 | } 94 | bool IsSlash(unsigned char c) 95 | { 96 | return c=='/' || c=='\\'; 97 | } 98 | 99 | void AddSlash( char *input ) 100 | { 101 | if (input==0 || input[0]==0) 102 | return; 103 | 104 | int lastCharIndex=(int) strlen(input)-1; 105 | if (input[lastCharIndex]=='\\') 106 | input[lastCharIndex]='/'; 107 | else if (input[lastCharIndex]!='/') 108 | { 109 | input[lastCharIndex+1]='/'; 110 | input[lastCharIndex+2]=0; 111 | } 112 | } 113 | bool DirectoryExists(const char *directory) 114 | { 115 | _finddata_t fileInfo; 116 | intptr_t dir; 117 | char baseDirWithStars[560]; 118 | strcpy(baseDirWithStars, directory); 119 | AddSlash(baseDirWithStars); 120 | strcat(baseDirWithStars, "*.*"); 121 | dir=_findfirst(baseDirWithStars, &fileInfo ); 122 | if (dir==-1) 123 | return false; 124 | _findclose(dir); 125 | return true; 126 | } 127 | void QuoteIfSpaces(char *str) 128 | { 129 | unsigned i; 130 | bool hasSpace=false; 131 | for (i=0; str[i]; i++) 132 | { 133 | if (str[i]==' ') 134 | { 135 | hasSpace=true; 136 | break; 137 | } 138 | } 139 | if (hasSpace) 140 | { 141 | int len=(int)strlen(str); 142 | memmove(str+1, str, len); 143 | str[0]='\"'; 144 | str[len]='\"'; 145 | str[len+1]=0; 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /vendor/raknet/AutopatcherRepositoryInterface.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief An interface used by AutopatcherServer to get the data necessary to run an autopatcher. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | 19 | #ifndef __AUTOPATCHER_REPOSITORY_INTERFACE_H 20 | #define __AUTOPATCHER_REPOSITORY_INTERFACE_H 21 | 22 | class FileList; 23 | namespace RakNet 24 | { 25 | class BitStream; 26 | } 27 | 28 | /// An interface used by AutopatcherServer to get the data necessary to run an autopatcher. This is up to you to implement for custom repository solutions. 29 | class AutopatcherRepositoryInterface 30 | { 31 | public: 32 | /// Get list of files added and deleted since a certain date. This is used by AutopatcherServer and not usually explicitly called. 33 | /// \param[in] applicationName A null terminated string identifying the application 34 | /// \param[out] addedFiles A list of the current versions of filenames with hashes as their data that were created after \a sinceData 35 | /// \param[out] deletedFiles A list of the current versions of filenames that were deleted after \a sinceData 36 | /// \param[in] An input date, in whatever format your repository uses 37 | /// \param[out] currentDate The current server date, in whatever format your repository uses 38 | /// \return True on success, false on failure. 39 | virtual bool GetChangelistSinceDate(const char *applicationName, FileList *addedFiles, FileList *deletedFiles, const char *sinceDate, char currentDate[64])=0; 40 | 41 | /// Get patches (or files) for every file in input, assuming that input has a hash for each of those files. 42 | /// \param[in] applicationName A null terminated string identifying the application 43 | /// \param[in] input A list of files with SHA1_LENGTH byte hashes to get from the database. 44 | /// \param[out] patchList You should return list of files with either the filedata or the patch. This is a subset of \a input. The context data for each file will be either PC_WRITE_FILE (to just write the file) or PC_HASH_WITH_PATCH (to patch). If PC_HASH_WITH_PATCH, then the file contains a SHA1_LENGTH byte patch followed by the hash. The datalength is patchlength + SHA1_LENGTH 45 | /// \return True on success, false on failure. 46 | virtual bool GetPatches(const char *applicationName, FileList *input, FileList *patchList)=0; 47 | 48 | /// \return Whatever this function returns is sent from the AutopatcherServer to the AutopatcherClient when one of the above functions returns false. 49 | virtual char *GetLastError(void) const=0; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /vendor/raknet/GetTime.cpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// 3 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 4 | /// 5 | /// Usage of RakNet is subject to the appropriate license agreement. 6 | /// Creative Commons Licensees are subject to the 7 | /// license found at 8 | /// http://creativecommons.org/licenses/by-nc/2.5/ 9 | /// Single application licensees are subject to the license found at 10 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 11 | /// Custom license users are subject to the terms therein. 12 | /// GPL license users are subject to the GNU General Public 13 | /// License as published by the Free 14 | /// Software Foundation; either version 2 of the License, or (at your 15 | /// option) any later version. 16 | 17 | #include "GetTime.h" 18 | #ifdef _COMPATIBILITY_1 19 | #include "Compatibility1Includes.h" // Developers of a certain platform will know what to do here. 20 | #elif defined(_WIN32) 21 | #include 22 | #elif defined(_COMPATIBILITY_2) 23 | #include "Compatibility2Includes.h" 24 | #include 25 | #include 26 | #else 27 | #include 28 | #include 29 | #endif 30 | 31 | static bool initialized=false; 32 | #ifdef _WIN32 33 | static LARGE_INTEGER yo; 34 | #else 35 | static timeval tp, initialTime; 36 | #endif 37 | 38 | RakNetTime RakNet::GetTime( void ) 39 | { 40 | if ( initialized == false ) 41 | { 42 | #ifdef _WIN32 43 | QueryPerformanceFrequency( &yo ); 44 | // The original code shifted right 10 bits 45 | //counts = yo.QuadPart >> 10; 46 | // It gives the wrong value since 2^10 is not 1000 47 | // counts = yo.QuadPart;// / 1000; 48 | #else 49 | gettimeofday( &initialTime, 0 ); 50 | #endif 51 | 52 | initialized = true; 53 | } 54 | 55 | #ifdef _WIN32 56 | LARGE_INTEGER PerfVal; 57 | 58 | QueryPerformanceCounter( &PerfVal ); 59 | 60 | return (RakNetTime)(PerfVal.QuadPart*1000 / yo.QuadPart); 61 | #else 62 | gettimeofday( &tp, 0 ); 63 | 64 | // Seconds to ms and microseconds to ms 65 | return ( tp.tv_sec - initialTime.tv_sec ) * 1000 + ( tp.tv_usec - initialTime.tv_usec ) / 1000; 66 | 67 | #endif 68 | } 69 | 70 | 71 | RakNetTimeNS RakNet::GetTimeNS( void ) 72 | { 73 | if ( initialized == false ) 74 | { 75 | #ifdef _WIN32 76 | QueryPerformanceFrequency( &yo ); 77 | // The original code shifted right 10 bits 78 | //counts = yo.QuadPart >> 10; 79 | // It gives the wrong value since 2^10 is not 1000 80 | // counts = yo.QuadPart;// / 1000; 81 | #else 82 | gettimeofday( &initialTime, 0 ); 83 | #endif 84 | 85 | initialized = true; 86 | } 87 | 88 | #ifdef _WIN32 89 | LARGE_INTEGER PerfVal; 90 | 91 | QueryPerformanceCounter( &PerfVal ); 92 | 93 | __int64 quotient, remainder; 94 | quotient=((PerfVal.QuadPart*1000) / yo.QuadPart); 95 | remainder=((PerfVal.QuadPart*1000) % yo.QuadPart); 96 | //return (PerfVal.QuadPart*1000 / (yo.QuadPart/1000)); 97 | return quotient*1000 + (remainder*1000 / yo.QuadPart); 98 | 99 | #else 100 | gettimeofday( &tp, 0 ); 101 | 102 | return ( tp.tv_sec - initialTime.tv_sec ) * (RakNetTimeNS) 1000000 + ( tp.tv_usec - initialTime.tv_usec ); 103 | 104 | #endif 105 | } 106 | -------------------------------------------------------------------------------- /skinchanger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "main.h" 5 | #include "game/game.h" 6 | #include "net/netgame.h" 7 | #include "gui/gui.h" 8 | #include "vendor/imgui/imgui_internal.h" 9 | #include "keyboard.h" 10 | #include "skinchanger.h" 11 | #include "chatwindow.h" 12 | #include "modsa.h" 13 | #include "vendor/inih/cpp/INIReader.h" 14 | 15 | extern CGUI *pGUI; 16 | extern CGame *pGame; 17 | extern CNetGame *pNetGame; 18 | extern CKeyBoard *pKeyBoard; 19 | extern CChatWindow *pChatWindow; 20 | extern CModSAWindow *pModSAWindow; 21 | 22 | char szSkinIDInputBuffer[100]; 23 | char utf8SkinIDInputBuffer[100*3]; 24 | 25 | CSkinChanger::CSkinChanger() 26 | { 27 | m_bIsActive = false; 28 | } 29 | 30 | CSkinChanger::~CSkinChanger() 31 | { 32 | 33 | } 34 | 35 | void CSkinChanger::Show(bool bShow) 36 | { 37 | if(pGame) 38 | pGame->FindPlayerPed()->TogglePlayerControllable(!bShow); 39 | 40 | m_bIsActive = bShow; 41 | } 42 | 43 | void CSkinChanger::Clear() 44 | { 45 | m_bIsActive = false; 46 | 47 | memset(szSkinIDInputBuffer, 0, 100); 48 | memset(utf8SkinIDInputBuffer, 0, 100*3); 49 | } 50 | 51 | void SkinIDWindowInputHandler(const char* str) 52 | { 53 | if(!str || *str == '\0') return; 54 | strcpy(szSkinIDInputBuffer, str); 55 | cp1251_to_utf8(utf8SkinIDInputBuffer, str); 56 | } 57 | 58 | void CSkinChanger::Render() 59 | { 60 | if(!m_bIsActive) return; 61 | 62 | ImGuiIO &io = ImGui::GetIO(); 63 | 64 | ImGui::StyleColorsClassic(); 65 | 66 | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8,8)); 67 | 68 | ImGui::Begin("> Skin Changer", nullptr, 69 | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize); 70 | 71 | ImGui::Text("Enter the skin ID"); 72 | 73 | if( ImGui::Button(utf8SkinIDInputBuffer, ImVec2(555, 50) )) 74 | { 75 | if(!pKeyBoard->IsOpen()) 76 | pKeyBoard->Open(&SkinIDWindowInputHandler); 77 | } 78 | 79 | ImGui::ItemSize( ImVec2(0, pGUI->GetFontSize()/2 + 5) ); 80 | 81 | ImGui::SetCursorPosX((ImGui::GetWindowWidth() - 278 + ImGui::GetStyle().ItemSpacing.x) / 2); 82 | 83 | if(ImGui::Button("Apply", ImVec2(125, 50))) 84 | { 85 | char *strskinid = szSkinIDInputBuffer; 86 | unsigned int skinid = atoi(strskinid); 87 | 88 | //if(pModSAWindow->protect != 1) 89 | //{ 90 | // pGame->FindPlayerPed()->SetModelIndex(skinid); 91 | //}else{ 92 | if(skinid != 0 && skinid != 99 && skinid != 92) pGame->FindPlayerPed()->SetModelIndex(skinid); 93 | else pChatWindow->AddInfoMessage("{FFEA0A}> {FFFFFF}You can not use this skin!"); 94 | //} 95 | 96 | Show(false); 97 | } 98 | 99 | ImGui::SameLine(0, pGUI->GetFontSize()); 100 | 101 | if(ImGui::Button("Cancel", ImVec2(125, 50))) 102 | { 103 | Show(false); 104 | } 105 | 106 | ImGui::SetWindowSize(ImVec2(-1, -1)); 107 | ImVec2 size = ImGui::GetWindowSize(); 108 | ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x)/2), ((io.DisplaySize.y - size.y)/2)) ); 109 | ImGui::End(); 110 | 111 | ImGui::PopStyleVar(); 112 | } -------------------------------------------------------------------------------- /vendor/raknet/PluginInterface.cpp: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// 3 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 4 | /// 5 | /// Usage of RakNet is subject to the appropriate license agreement. 6 | /// Creative Commons Licensees are subject to the 7 | /// license found at 8 | /// http://creativecommons.org/licenses/by-nc/2.5/ 9 | /// Single application licensees are subject to the license found at 10 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 11 | /// Custom license users are subject to the terms therein. 12 | /// GPL license users are subject to the GNU General Public 13 | /// License as published by the Free 14 | /// Software Foundation; either version 2 of the License, or (at your 15 | /// option) any later version. 16 | 17 | #include "PluginInterface.h" 18 | 19 | #ifdef _MSC_VER 20 | #pragma warning( push ) 21 | #endif 22 | 23 | #ifdef _MSC_VER 24 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 25 | #endif 26 | void PluginInterface::OnAttach(RakPeerInterface *peer) 27 | { 28 | } 29 | #ifdef _MSC_VER 30 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 31 | #endif 32 | void PluginInterface::OnDetach(RakPeerInterface *peer) 33 | { 34 | } 35 | #ifdef _MSC_VER 36 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 37 | #endif 38 | void PluginInterface::OnInitialize(RakPeerInterface *peer) 39 | { 40 | } 41 | #ifdef _MSC_VER 42 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 43 | #endif 44 | void PluginInterface::Update(RakPeerInterface *peer) 45 | { 46 | } 47 | #ifdef _MSC_VER 48 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 49 | #endif 50 | PluginReceiveResult PluginInterface::OnReceive(RakPeerInterface *peer, Packet *packet) 51 | { 52 | return RR_CONTINUE_PROCESSING; 53 | } 54 | #ifdef _MSC_VER 55 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 56 | #endif 57 | void PluginInterface::OnDisconnect(RakPeerInterface *peer) 58 | { 59 | } 60 | #ifdef _MSC_VER 61 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 62 | #endif 63 | void PluginInterface::OnCloseConnection(RakPeerInterface *peer, PlayerID playerId) 64 | { 65 | } 66 | #ifdef _MSC_VER 67 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 68 | #endif 69 | void PluginInterface::OnDirectSocketSend(const char *data, const unsigned bitsUsed, PlayerID remoteSystemID) 70 | { 71 | } 72 | #ifdef _MSC_VER 73 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 74 | #endif 75 | void PluginInterface::OnDirectSocketReceive(const char *data, const unsigned bitsUsed, PlayerID remoteSystemID) 76 | { 77 | } 78 | #ifdef _MSC_VER 79 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 80 | #endif 81 | void PluginInterface::OnInternalPacket(InternalPacket *internalPacket, unsigned frameNumber, PlayerID remoteSystemID, RakNetTime time, bool isSend) 82 | { 83 | } 84 | 85 | #ifdef _MSC_VER 86 | #pragma warning( pop ) 87 | #endif 88 | -------------------------------------------------------------------------------- /util/util.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | 3 | uintptr_t FindLibrary(const char* library) 4 | { 5 | char filename[0xFF] = {0}, 6 | buffer[2048] = {0}; 7 | FILE *fp = 0; 8 | uintptr_t address = 0; 9 | 10 | sprintf( filename, "/proc/%d/maps", getpid() ); 11 | 12 | fp = fopen( filename, "rt" ); 13 | if(fp == 0) 14 | { 15 | Log("ERROR: can't open file %s", filename); 16 | goto done; 17 | } 18 | 19 | while(fgets(buffer, sizeof(buffer), fp)) 20 | { 21 | if( strstr( buffer, library ) ) 22 | { 23 | address = (uintptr_t)strtoul( buffer, 0, 16 ); 24 | break; 25 | } 26 | } 27 | 28 | done: 29 | 30 | if(fp) 31 | fclose(fp); 32 | 33 | return address; 34 | } 35 | 36 | void cp1251_to_utf8(char *out, const char *in, unsigned int len) 37 | { 38 | static const int table[128] = 39 | { 40 | // 80 41 | 0x82D0, 0x83D0, 0x9A80E2, 0x93D1, 0x9E80E2, 0xA680E2, 0xA080E2, 0xA180E2, 42 | 0xAC82E2, 0xB080E2, 0x89D0, 0xB980E2, 0x8AD0, 0x8CD0, 0x8BD0, 0x8FD0, 43 | // 90 44 | 0x92D1, 0x9880E2, 0x9980E2, 0x9C80E2, 0x9D80E2, 0xA280E2, 0x9380E2, 0x9480E2, 45 | 0, 0xA284E2, 0x99D1, 0xBA80E2, 0x9AD1, 0x9CD1, 0x9BD1, 0x9FD1, 46 | // A0 47 | 0xA0C2, 0x8ED0, 0x9ED1, 0x88D0, 0xA4C2, 0x90D2, 0xA6C2, 0xA7C2, 48 | 0x81D0, 0xA9C2, 0x84D0, 0xABC2, 0xACC2, 0xADC2, 0xAEC2, 0x87D0, 49 | // B0 50 | 0xB0C2, 0xB1C2, 0x86D0, 0x96D1, 0x91D2, 0xB5C2, 0xB6C2, 0xB7C2, 51 | 0x91D1, 0x9684E2, 0x94D1, 0xBBC2, 0x98D1, 0x85D0, 0x95D1, 0x97D1, 52 | // C0 53 | 0x90D0, 0x91D0, 0x92D0, 0x93D0, 0x94D0, 0x95D0, 0x96D0, 0x97D0, 54 | 0x98D0, 0x99D0, 0x9AD0, 0x9BD0, 0x9CD0, 0x9DD0, 0x9ED0, 0x9FD0, 55 | // D0 56 | 0xA0D0, 0xA1D0, 0xA2D0, 0xA3D0, 0xA4D0, 0xA5D0, 0xA6D0, 0xA7D0, 57 | 0xA8D0, 0xA9D0, 0xAAD0, 0xABD0, 0xACD0, 0xADD0, 0xAED0, 0xAFD0, 58 | // E0 59 | 0xB0D0, 0xB1D0, 0xB2D0, 0xB3D0, 0xB4D0, 0xB5D0, 0xB6D0, 0xB7D0, 60 | 0xB8D0, 0xB9D0, 0xBAD0, 0xBBD0, 0xBCD0, 0xBDD0, 0xBED0, 0xBFD0, 61 | // F0 62 | 0x80D1, 0x81D1, 0x82D1, 0x83D1, 0x84D1, 0x85D1, 0x86D1, 0x87D1, 63 | 0x88D1, 0x89D1, 0x8AD1, 0x8BD1, 0x8CD1, 0x8DD1, 0x8ED1, 0x8FD1 64 | }; 65 | 66 | int count = 0; 67 | 68 | while (*in) 69 | { 70 | if(len && (count >= len)) break; 71 | 72 | if (*in & 0x80) 73 | { 74 | register int v = table[(int)(0x7f & *in++)]; 75 | if (!v) 76 | continue; 77 | *out++ = (char)v; 78 | *out++ = (char)(v >> 8); 79 | if (v >>= 16) 80 | *out++ = (char)v; 81 | } 82 | else // ASCII 83 | *out++ = *in++; 84 | 85 | count++; 86 | } 87 | 88 | *out = 0; 89 | } -------------------------------------------------------------------------------- /vendor/raknet/SystemAddressList.cpp: -------------------------------------------------------------------------------- 1 | #include "SystemAddressList.h" 2 | #include "Rand.h" 3 | #include "RakAssert.h" 4 | #include "BitStream.h" 5 | #include 6 | 7 | SystemAddressList::SystemAddressList() 8 | { 9 | 10 | } 11 | SystemAddressList::SystemAddressList(PlayerID system) 12 | { 13 | systemList.Insert(system); 14 | } 15 | void SystemAddressList::AddSystem(PlayerID system) 16 | { 17 | systemList.Insert(system); 18 | } 19 | void SystemAddressList::RandomizeOrder(void) 20 | { 21 | unsigned index, size, randIndex; 22 | PlayerID temp; 23 | size = systemList.Size(); 24 | for (index=0; index < size; index++) 25 | { 26 | randIndex=index + (randomMT() % (size-index)); 27 | if (randIndex!=index) 28 | { 29 | temp=systemList[index]; 30 | systemList[index]=systemList[randIndex]; 31 | systemList[randIndex]=temp; 32 | } 33 | } 34 | } 35 | void SystemAddressList::Serialize(RakNet::BitStream *out) 36 | { 37 | out->Write((unsigned short) systemList.Size()); 38 | unsigned index; 39 | for (index=0; index < systemList.Size(); index++) 40 | out->Write(systemList[index]); 41 | } 42 | bool SystemAddressList::Deserialize(RakNet::BitStream *in) 43 | { 44 | unsigned short systemListSize; 45 | PlayerID systemAddress; 46 | unsigned index; 47 | if (in->Read(systemListSize)==false) 48 | { 49 | RakAssert(0); 50 | return false; 51 | } 52 | systemList.Clear(); 53 | for (index=0; index < systemListSize; index++) 54 | { 55 | if (in->Read(systemAddress)==false) 56 | { 57 | RakAssert(0); 58 | systemList.Clear(); 59 | return false; 60 | } 61 | systemList.Insert(systemAddress); 62 | 63 | } 64 | return true; 65 | } 66 | void SystemAddressList::RemoveSystem(PlayerID system) 67 | { 68 | unsigned i; 69 | for (i=0; i < systemList.Size(); i++) 70 | { 71 | if (systemList[i]==system) 72 | { 73 | systemList.Del(i); 74 | return; 75 | } 76 | } 77 | } 78 | DataStructures::List * SystemAddressList::GetList(void) 79 | { 80 | return &systemList; 81 | } 82 | bool SystemAddressList::Save(const char *filename) 83 | { 84 | RakNet::BitStream temp; 85 | Serialize(&temp); 86 | FILE *fp = fopen(filename, "wb"); 87 | if (fp) 88 | { 89 | fwrite(temp.GetData(), temp.GetNumberOfBytesUsed(), 1, fp); 90 | fclose(fp); 91 | return true; 92 | } 93 | return false; 94 | } 95 | bool SystemAddressList::Load(const char *filename) 96 | { 97 | FILE *fp = NULL; 98 | unsigned long fileSize; 99 | 100 | if ( ( fp = fopen( filename, "rb" ) ) == 0 ) 101 | return false; 102 | 103 | fseek( fp, 0, SEEK_END ); 104 | fileSize = ftell( fp ); 105 | fseek( fp, 0, SEEK_SET ); 106 | if (fileSize==0) 107 | { 108 | fclose(fp); 109 | return false; 110 | } 111 | unsigned char *filedata = new unsigned char [fileSize]; 112 | fread(filedata, fileSize, 1, fp); 113 | fclose(fp); 114 | 115 | RakNet::BitStream bs(filedata, fileSize, false); 116 | Deserialize(&bs); 117 | delete [] filedata; 118 | return true; 119 | } 120 | unsigned SystemAddressList::Size(void) const 121 | { 122 | return systemList.Size(); 123 | } 124 | PlayerID& SystemAddressList::operator[] ( const unsigned int position ) const 125 | { 126 | return systemList[position]; 127 | } 128 | void SystemAddressList::Clear(void) 129 | { 130 | systemList.Clear(); 131 | } 132 | -------------------------------------------------------------------------------- /vendor/raknet/SimpleTCPServer.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief A simple TCP based server allowing sends and receives. Can be connected by any TCP client, including telnet. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __SIMPLE_TCP_SERVER 19 | #define __SIMPLE_TCP_SERVER 20 | 21 | #ifdef _COMPATIBILITY_1 22 | #include "Compatibility1Includes.h" 23 | #elif defined(_WIN32) 24 | #include 25 | #include 26 | #else 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | /// Unix/Linux uses ints for sockets 34 | typedef int SOCKET; 35 | #define INVALID_SOCKET -1 36 | #define SOCKET_ERROR -1 37 | #endif 38 | 39 | #include "DS_List.h" 40 | #include "NetworkTypes.h" 41 | #include "SingleProducerConsumer.h" 42 | #include "Export.h" 43 | 44 | struct RemoteClient; 45 | 46 | /// \internal 47 | /// \brief As the name says, a simple multithreaded TCP server. Used by TelnetTransport 48 | class RAK_DLL_EXPORT SimpleTCPServer 49 | { 50 | public: 51 | SimpleTCPServer(); 52 | ~SimpleTCPServer(); 53 | 54 | /// Starts the TCP server on the indicated port 55 | bool Start(unsigned short port); 56 | 57 | /// Stops the TCP server 58 | void Stop(void); 59 | 60 | /// Sends a byte stream 61 | void Send( const char *data, unsigned length, PlayerID playerId ); 62 | 63 | /// Returns data received 64 | Packet* Receive( void ); 65 | 66 | /// Disconnects a player/address 67 | void CloseConnection( PlayerID playerId ); 68 | 69 | /// Deallocates a packet returned by Receive 70 | void DeallocatePacket( Packet *packet ); 71 | 72 | /// Queued events of new connections 73 | PlayerID HasNewConnection(void); 74 | 75 | /// Queued events of lost connections 76 | PlayerID HasLostConnection(void); 77 | protected: 78 | 79 | bool isStarted, threadRunning; 80 | SOCKET listenSocket; 81 | 82 | DataStructures::List remoteClients; 83 | DataStructures::SingleProducerConsumer outgoingMessages, incomingMessages; 84 | DataStructures::SingleProducerConsumer newConnections, lostConnections, requestedCloseConnections; 85 | 86 | #ifdef _WIN32 87 | HANDLE threadHandle; 88 | friend unsigned __stdcall UpdateTCPServerLoop( LPVOID arguments ); 89 | #else 90 | pthread_t threadHandle; 91 | friend void* UpdateTCPServerLoop( void* arguments ); 92 | #endif 93 | 94 | void DeleteRemoteClient(RemoteClient *remoteClient, fd_set *exceptionFD); 95 | }; 96 | 97 | /// Stores information about a remote client. In this case, only the socket used by that client. 98 | struct RemoteClient 99 | { 100 | SOCKET socket; 101 | PlayerID playerId; 102 | }; 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /util/armhook.cpp: -------------------------------------------------------------------------------- 1 | #include "../main.h" 2 | #include 3 | 4 | #define HOOK_PROC "\x01\xB4\x01\xB4\x01\x48\x01\x90\x01\xBD\x00\xBF\x00\x00\x00\x00" 5 | 6 | uintptr_t mmap_start = 0; 7 | uintptr_t mmap_end = 0; 8 | uintptr_t memlib_start = 0; 9 | uintptr_t memlib_end = 0; 10 | 11 | void UnFuck(uintptr_t ptr) 12 | { 13 | mprotect((void*)(ptr & 0xFFFFF000), PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC); 14 | } 15 | 16 | void NOP(uintptr_t addr, unsigned int count) 17 | { 18 | UnFuck(addr); 19 | 20 | for(uintptr_t ptr = addr; ptr != (addr+(count*2)); ptr += 2) 21 | { 22 | *(char*)ptr = 0x00; 23 | *(char*)(ptr+1) = 0x46; 24 | } 25 | 26 | cacheflush(addr, (uintptr_t)(addr + count*2), 0); 27 | } 28 | 29 | void WriteMemory(uintptr_t dest, uintptr_t src, size_t size) 30 | { 31 | UnFuck(dest); 32 | memcpy((void*)dest, (void*)src, size); 33 | cacheflush(dest, dest+size, 0); 34 | } 35 | 36 | void ReadMemory(uintptr_t dest, uintptr_t src, size_t size) 37 | { 38 | UnFuck(src); 39 | memcpy((void*)dest, (void*)src, size); 40 | } 41 | 42 | void InitHookStuff() 43 | { 44 | Log("Initializing hook system.."); 45 | memlib_start = g_libGTASA+0x180044; 46 | memlib_end = memlib_start + 0x290; 47 | 48 | mmap_start = (uintptr_t)mmap(0, PAGE_SIZE, PROT_WRITE | PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 49 | mprotect((void*)(mmap_start & 0xFFFFF000), PAGE_SIZE, PROT_READ | PROT_EXEC | PROT_WRITE); 50 | mmap_end = (mmap_start + PAGE_SIZE); 51 | } 52 | 53 | void JMPCode(uintptr_t func, uintptr_t addr) 54 | { 55 | uint32_t code = ((addr-func-4) >> 12) & 0x7FF | 0xF000 | ((((addr-func-4) >> 1) & 0x7FF | 0xB800) << 16); 56 | WriteMemory(func, (uintptr_t)&code, 4); 57 | } 58 | 59 | void WriteHookProc(uintptr_t addr, uintptr_t func) 60 | { 61 | char code[16]; 62 | memcpy(code, HOOK_PROC, 16); 63 | *(uint32_t*)&code[12] = (func | 1); 64 | WriteMemory(addr, (uintptr_t)code, 16); 65 | } 66 | 67 | void SetUpHook(uintptr_t addr, uintptr_t func, uintptr_t *orig) 68 | { 69 | Log("SetUpHook: 0x%X -> 0x%X", addr, func); 70 | 71 | if(memlib_end < (memlib_start + 0x10) || mmap_end < (mmap_start + 0x20)) 72 | { 73 | Log("SetUpHook: space limit reached"); 74 | std::terminate(); 75 | } 76 | 77 | ReadMemory(mmap_start, addr, 4); 78 | WriteHookProc(mmap_start+4, addr+4); 79 | *orig = mmap_start+1; 80 | mmap_start += 32; 81 | 82 | JMPCode(addr, memlib_start); 83 | WriteHookProc(memlib_start, func); 84 | memlib_start += 16; 85 | } 86 | 87 | void InstallMethodHook(uintptr_t addr, uintptr_t func) 88 | { 89 | Log("InstallMethodHook: func: 0x%X -> 0x%X", addr, func); 90 | 91 | UnFuck(addr); 92 | *(uintptr_t*)addr = func; 93 | } 94 | 95 | void CodeInject(uintptr_t addr, uintptr_t func, int reg) 96 | { 97 | Log("CodeInject: 0x%X -> 0x%x (register: r%d)", addr, func, reg); 98 | 99 | char injectCode[12]; 100 | 101 | injectCode[0] = 0x01; 102 | injectCode[1] = 0xA0 + reg; 103 | injectCode[2] = (0x08 * reg) + reg; 104 | injectCode[3] = 0x68; 105 | injectCode[4] = 0x87 + (0x08 * reg); 106 | injectCode[5] = 0x46; 107 | injectCode[6] = injectCode[4]; 108 | injectCode[7] = injectCode[5]; 109 | 110 | *(uintptr_t*)&injectCode[8] = func; 111 | 112 | WriteMemory(addr, (uintptr_t)injectCode, 12); 113 | } -------------------------------------------------------------------------------- /vendor/raknet/DS_QueueLinkedList.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] A queue implemented as a linked list. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __QUEUE_LINKED_LIST_H 19 | #define __QUEUE_LINKED_LIST_H 20 | 21 | #include "DS_LinkedList.h" 22 | #include "Export.h" 23 | 24 | /// The namespace DataStructures was only added to avoid compiler errors for commonly named data structures 25 | /// As these data structures are stand-alone, you can use them outside of RakNet for your own projects if you wish. 26 | namespace DataStructures 27 | { 28 | /// \brief A queue implemented using a linked list. Rarely used. 29 | template 30 | class RAK_DLL_EXPORT QueueLinkedList 31 | { 32 | 33 | public: 34 | QueueLinkedList(); 35 | QueueLinkedList( const QueueLinkedList& original_copy ); 36 | bool operator= ( const QueueLinkedList& original_copy ); 37 | QueueType Pop( void ); 38 | QueueType& Peek( void ); 39 | QueueType& EndPeek( void ); 40 | void Push( const QueueType& input ); 41 | unsigned int Size( void ); 42 | void Clear( void ); 43 | void Compress( void ); 44 | 45 | private: 46 | LinkedList data; 47 | }; 48 | 49 | template 50 | QueueLinkedList::QueueLinkedList() 51 | { 52 | } 53 | 54 | template 55 | inline unsigned int QueueLinkedList::Size() 56 | { 57 | return data.Size(); 58 | } 59 | 60 | template 61 | inline QueueType QueueLinkedList::Pop( void ) 62 | { 63 | data.Beginning(); 64 | return ( QueueType ) data.Pop(); 65 | } 66 | 67 | template 68 | inline QueueType& QueueLinkedList::Peek( void ) 69 | { 70 | data.Beginning(); 71 | return ( QueueType ) data.Peek(); 72 | } 73 | 74 | template 75 | inline QueueType& QueueLinkedList::EndPeek( void ) 76 | { 77 | data.End(); 78 | return ( QueueType ) data.Peek(); 79 | } 80 | 81 | template 82 | void QueueLinkedList::Push( const QueueType& input ) 83 | { 84 | data.End(); 85 | data.Add( input ); 86 | } 87 | 88 | template 89 | QueueLinkedList::QueueLinkedList( const QueueLinkedList& original_copy ) 90 | { 91 | data = original_copy.data; 92 | } 93 | 94 | template 95 | bool QueueLinkedList::operator= ( const QueueLinkedList& original_copy ) 96 | { 97 | if ( ( &original_copy ) == this ) 98 | return false; 99 | 100 | data = original_copy.data; 101 | } 102 | 103 | template 104 | void QueueLinkedList::Clear ( void ) 105 | { 106 | data.Clear(); 107 | } 108 | } // End namespace 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /vendor/raknet/StringTable.cpp: -------------------------------------------------------------------------------- 1 | #include "StringTable.h" 2 | #include 3 | #include 4 | #include 5 | #include "BitStream.h" 6 | #include "StringCompressor.h" 7 | 8 | StringTable* StringTable::instance=0; 9 | int StringTable::referenceCount=0; 10 | 11 | int StrAndBoolComp( char *const &key, const StrAndBool &data ) 12 | { 13 | return strcmp(key,(const char*)data.str); 14 | } 15 | 16 | StringTable::StringTable() 17 | { 18 | 19 | } 20 | 21 | StringTable::~StringTable() 22 | { 23 | unsigned i; 24 | for (i=0; i < orderedStringList.Size(); i++) 25 | { 26 | if (orderedStringList[i].b) 27 | delete [] orderedStringList[i].str; 28 | } 29 | } 30 | 31 | void StringTable::AddReference(void) 32 | { 33 | if (++referenceCount==1) 34 | { 35 | instance = new StringTable; 36 | } 37 | } 38 | void StringTable::RemoveReference(void) 39 | { 40 | assert(referenceCount > 0); 41 | 42 | if (referenceCount > 0) 43 | { 44 | if (--referenceCount==0) 45 | { 46 | delete instance; 47 | instance=0; 48 | } 49 | } 50 | } 51 | 52 | StringTable* StringTable::Instance(void) 53 | { 54 | return instance; 55 | } 56 | 57 | void StringTable::AddString(const char *str, bool copyString) 58 | { 59 | StrAndBool sab; 60 | sab.b=copyString; 61 | if (copyString) 62 | { 63 | sab.str = new char [strlen(str)+1]; 64 | strcpy(sab.str, str); 65 | } 66 | else 67 | { 68 | sab.str=(char*)str; 69 | } 70 | 71 | // If it asserts inside here you are adding duplicate strings. 72 | if (!orderedStringList.Insert(sab.str,sab)) 73 | { 74 | if (copyString) 75 | delete sab.str; 76 | } 77 | 78 | // If this assert hits you need to increase the range of StringTableType 79 | assert(orderedStringList.Size() < (StringTableType)-1); 80 | 81 | } 82 | void StringTable::EncodeString( const char *input, int maxCharsToWrite, RakNet::BitStream *output ) 83 | { 84 | unsigned index; 85 | bool objectExists; 86 | // This is fast because the list is kept ordered. 87 | index=orderedStringList.GetIndexFromKey((char*)input, &objectExists); 88 | if (objectExists) 89 | { 90 | output->Write(true); 91 | output->Write((StringTableType)index); 92 | } 93 | else 94 | { 95 | LogStringNotFound(input); 96 | output->Write(false); 97 | stringCompressor->EncodeString(input, maxCharsToWrite, output); 98 | } 99 | } 100 | 101 | bool StringTable::DecodeString( char *output, int maxCharsToWrite, RakNet::BitStream *input ) 102 | { 103 | bool hasIndex; 104 | assert(maxCharsToWrite>0); 105 | 106 | if (maxCharsToWrite==0) 107 | return false; 108 | if (!input->Read(hasIndex)) 109 | return false; 110 | if (hasIndex==false) 111 | { 112 | stringCompressor->DecodeString(output, maxCharsToWrite, input); 113 | } 114 | else 115 | { 116 | StringTableType index; 117 | if (!input->Read(index)) 118 | return false; 119 | if (index >= orderedStringList.Size()) 120 | { 121 | #ifdef _DEBUG 122 | // Critical error - got a string index out of range, which means AddString was called more times on the remote system than on this system. 123 | // All systems must call AddString the same number of types, with the same strings in the same order. 124 | assert(0); 125 | #endif 126 | return false; 127 | } 128 | 129 | strncpy(output, orderedStringList[index].str, maxCharsToWrite); 130 | output[maxCharsToWrite-1]=0; 131 | } 132 | 133 | return true; 134 | } 135 | #ifdef _MSC_VER 136 | #pragma warning( disable : 4100 ) // warning C4100: : unreferenced formal parameter 137 | #endif 138 | void StringTable::LogStringNotFound(const char *strName) 139 | { 140 | #ifdef _DEBUG 141 | printf("Efficiency Warning! Unregistered String %s sent to StringTable.\n", strName); 142 | #endif 143 | } 144 | -------------------------------------------------------------------------------- /menu.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "gui/gui.h" 3 | #include "menu.h" 4 | #include "chatwindow.h" 5 | #include "settings.h" 6 | 7 | #include "game/game.h" 8 | #include "net/netgame.h" 9 | 10 | extern CGUI *pGUI; 11 | extern CGame *pGame; 12 | extern CNetGame *pNetGame; 13 | extern CChatWindow *pChatWindow; 14 | extern CSettings *pSettings; 15 | 16 | CMenu::CMenu() 17 | { 18 | m_fPosX = pGUI->ScaleX( pSettings->Get().fSpawnScreenPosX ); 19 | m_fPosY = pGUI->ScaleY( pSettings->Get().fSpawnScreenPosY ); 20 | m_fSizeX = pGUI->ScaleX( pSettings->Get().fSpawnScreenSizeX ); 21 | m_fSizeY = pGUI->ScaleY( pSettings->Get().fSpawnScreenSizeY ); 22 | m_fButWidth = m_fSizeX / 3; 23 | m_fButHeight = m_fSizeY * 0.9; 24 | 25 | m_bEnabled = false; 26 | } 27 | 28 | void CMenu::Show(bool bShow) 29 | { 30 | if(pGame) 31 | pGame->FindPlayerPed()->TogglePlayerControllable(!bShow); 32 | m_bEnabled = bShow; 33 | } 34 | 35 | void CMenu::Render() 36 | { 37 | if(!m_bEnabled) 38 | return; 39 | 40 | ImGuiIO &io = ImGui::GetIO(); 41 | CPlayerPool *pPlayerPool = pNetGame->GetPlayerPool(); 42 | CLocalPlayer *pLocalPlayer = 0; 43 | if(pPlayerPool) pLocalPlayer = pPlayerPool->GetLocalPlayer(); 44 | 45 | MATRIX4X4 matPlayer; 46 | pLocalPlayer->GetPlayerPed()->GetMatrix(&matPlayer); 47 | 48 | ImGui::Begin("Menu", nullptr, 49 | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | 50 | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings); 51 | 52 | if (ImGui::Button("1", ImVec2(m_fButWidth, m_fButHeight))) 53 | { 54 | pGame->PlaySound(1053,matPlayer.pos.X,matPlayer.pos.Y,matPlayer.pos.Z); 55 | pLocalPlayer->SendMenuRow(0); 56 | } 57 | ImGui::SameLine(0, 5); 58 | if (ImGui::Button("2", ImVec2(m_fButWidth, m_fButHeight))) 59 | { 60 | pGame->PlaySound(1052,matPlayer.pos.X,matPlayer.pos.Y,matPlayer.pos.Z); 61 | pLocalPlayer->SendMenuRow(1); 62 | } 63 | ImGui::SameLine(0, 5); 64 | if (ImGui::Button("3", ImVec2(m_fButWidth, m_fButHeight))) 65 | { 66 | pGame->PlaySound(1052,matPlayer.pos.X,matPlayer.pos.Y,matPlayer.pos.Z); 67 | pLocalPlayer->SendMenuRow(2); 68 | } 69 | if (ImGui::Button("4", ImVec2(m_fButWidth, m_fButHeight))) 70 | { 71 | pGame->PlaySound(1052,matPlayer.pos.X,matPlayer.pos.Y,matPlayer.pos.Z); 72 | pLocalPlayer->SendMenuRow(3); 73 | } 74 | ImGui::SameLine(0, 5); 75 | if (ImGui::Button("5", ImVec2(m_fButWidth, m_fButHeight))) 76 | { 77 | pGame->PlaySound(1052,matPlayer.pos.X,matPlayer.pos.Y,matPlayer.pos.Z); 78 | pLocalPlayer->SendMenuRow(4); 79 | } 80 | ImGui::SameLine(0, 5); 81 | if (ImGui::Button("6", ImVec2(m_fButWidth, m_fButHeight))) 82 | { 83 | pGame->PlaySound(1052,matPlayer.pos.X,matPlayer.pos.Y,matPlayer.pos.Z); 84 | pLocalPlayer->SendMenuRow(5); 85 | } 86 | 87 | if (ImGui::Button("7", ImVec2(m_fButWidth, m_fButHeight))) 88 | { 89 | pGame->PlaySound(1052,matPlayer.pos.X,matPlayer.pos.Y,matPlayer.pos.Z); 90 | pLocalPlayer->SendMenuRow(6); 91 | } 92 | ImGui::SameLine(0, 5); 93 | if (ImGui::Button("8", ImVec2(m_fButWidth, m_fButHeight))) 94 | { 95 | pGame->PlaySound(1052,matPlayer.pos.X,matPlayer.pos.Y,matPlayer.pos.Z); 96 | pLocalPlayer->SendMenuRow(7); 97 | } 98 | ImGui::SameLine(0, 5); 99 | if (ImGui::Button("9", ImVec2(m_fButWidth, m_fButHeight))) 100 | { 101 | pGame->PlaySound(1052,matPlayer.pos.X,matPlayer.pos.Y,matPlayer.pos.Z); 102 | pLocalPlayer->SendMenuRow(8); 103 | } 104 | 105 | ImGui::SetWindowSize(ImVec2(-1, -1)); 106 | ImVec2 size = ImGui::GetWindowSize(); 107 | 108 | ImGui::SetWindowPos( ImVec2( ((io.DisplaySize.x - size.x)/2), ((io.DisplaySize.y * 0.95) - size.y) ) ); 109 | ImGui::End(); 110 | } -------------------------------------------------------------------------------- /vendor/raknet/TCPInterface.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief A simple TCP based server allowing sends and receives. Can be connected by any TCP client, including telnet. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __SIMPLE_TCP_SERVER 19 | #define __SIMPLE_TCP_SERVER 20 | 21 | #ifdef _COMPATIBILITY_1 22 | #include "Compatibility1Includes.h" 23 | #elif defined(_WIN32) 24 | #include 25 | #include 26 | #else 27 | #include 28 | #include 29 | #include // fd_set 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | /// Unix/Linux uses ints for sockets 36 | typedef int SOCKET; 37 | #define INVALID_SOCKET -1 38 | #define SOCKET_ERROR -1 39 | #endif 40 | 41 | #include "DS_List.h" 42 | #include "NetworkTypes.h" 43 | #include "SingleProducerConsumer.h" 44 | #include "Export.h" 45 | 46 | struct RemoteClient; 47 | 48 | /// \internal 49 | /// \brief As the name says, a simple multithreaded TCP server. Used by TelnetTransport 50 | class RAK_DLL_EXPORT TCPInterface 51 | { 52 | public: 53 | TCPInterface(); 54 | ~TCPInterface(); 55 | 56 | /// Starts the TCP server on the indicated port 57 | bool Start(unsigned short port, unsigned short maxIncomingConnections); 58 | 59 | /// Stops the TCP server 60 | void Stop(void); 61 | 62 | /// Connect to the specified host on the specified port 63 | PlayerID Connect(const char* host, unsigned short remotePort); 64 | 65 | /// Sends a byte stream 66 | void Send( const char *data, unsigned length, PlayerID playerId ); 67 | 68 | /// Returns data received 69 | Packet* Receive( void ); 70 | 71 | /// Disconnects a player/address 72 | void CloseConnection( PlayerID playerId ); 73 | 74 | /// Deallocates a packet returned by Receive 75 | void DeallocatePacket( Packet *packet ); 76 | 77 | /// Queued events of new connections 78 | PlayerID HasNewConnection(void); 79 | 80 | /// Queued events of lost connections 81 | PlayerID HasLostConnection(void); 82 | protected: 83 | 84 | bool waitForClient; 85 | bool isStarted, threadRunning; 86 | SOCKET listenSocket; 87 | 88 | // Assuming remoteClients is only used by one thread! 89 | DataStructures::List remoteClients; 90 | DataStructures::SingleProducerConsumer outgoingMessages, incomingMessages; 91 | DataStructures::SingleProducerConsumer newConnections, lostConnections, requestedCloseConnections; 92 | DataStructures::SingleProducerConsumer newRemoteClients; 93 | 94 | #ifdef _WIN32 95 | HANDLE threadHandle; 96 | friend unsigned __stdcall UpdateTCPInterfaceLoop( LPVOID arguments ); 97 | #else 98 | pthread_t threadHandle; 99 | friend void* UpdateTCPInterfaceLoop( void* arguments ); 100 | #endif 101 | 102 | void DeleteRemoteClient(RemoteClient *remoteClient, fd_set *exceptionFD); 103 | }; 104 | 105 | /// Stores information about a remote client. In this case, only the socket used by that client. 106 | struct RemoteClient 107 | { 108 | SOCKET socket; 109 | PlayerID playerId; 110 | }; 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /net/netgame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // raknet 4 | #include "vendor/RakNet/RakClientInterface.h" 5 | #include "vendor/RakNet/RakNetworkFactory.h" 6 | #include "vendor/RakNet/PacketEnumerations.h" 7 | #include "vendor/RakNet/StringCompressor.h" 8 | 9 | #include "localplayer.h" 10 | #include "remoteplayer.h" 11 | 12 | #include "playerpool.h" 13 | #include "vehiclepool.h" 14 | #include "gangzonepool.h" 15 | #include "objectpool.h" 16 | #include "pickuppool.h" 17 | #include "textlabelpool.h" 18 | 19 | #define GAMESTATE_WAIT_CONNECT 9 20 | #define GAMESTATE_CONNECTING 13 21 | #define GAMESTATE_AWAIT_JOIN 15 22 | #define GAMESTATE_CONNECTED 14 23 | #define GAMESTATE_RESTARTING 18 24 | #define GAMESTATE_NONE 0 25 | #define GAMESTATE_DISCONNECTED 4 26 | 27 | #define NETMODE_ONFOOT_SENDRATE 30 28 | #define NETMODE_INCAR_SENDRATE 30 29 | #define NETMODE_FIRING_SENDRATE 30 30 | #define NETMODE_SEND_MULTIPLIER 2 31 | 32 | #define INVALID_PLAYER_ID 0xFFFF 33 | #define INVALID_VEHICLE_ID 0xFFFF 34 | 35 | class CNetGame 36 | { 37 | public: 38 | CNetGame(char* szHostOrIp, int iPort, const char* szPlayerName, const char* szPass); 39 | ~CNetGame(); 40 | 41 | void Process(); 42 | 43 | CPlayerPool* GetPlayerPool() { return m_pPlayerPool; } 44 | CVehiclePool* GetVehiclePool() { return m_pVehiclePool; } 45 | CObjectPool* GetObjectPool() { return m_pObjectPool; } 46 | CPickupPool* GetPickupPool() { return m_pPickupPool; } 47 | CGangZonePool* GetGangZonePool() { return m_pGangZonePool; } 48 | CText3DLabelsPool* GetLabelPool() { return m_pLabelPool; } 49 | 50 | RakClientInterface* GetRakClient() { return m_pRakClient; }; 51 | 52 | int GetGameState() { return m_iGameState; } 53 | void SetGameState(int iGameState) { m_iGameState = iGameState; } 54 | 55 | void ResetVehiclePool(); 56 | void ResetObjectPool(); 57 | void ResetPickupPool(); 58 | void ResetGangZonePool(); 59 | void ResetLabelPool(); 60 | 61 | void ShutDownForGameRestart(); 62 | 63 | void SendChatMessage(const char* szMsg); 64 | void SendChatCommand(const char* szMsg); 65 | void SendDialogResponse(uint16_t wDialogID, uint8_t byteButtonID, uint16_t wListboxItem, char* szInput); 66 | 67 | void SetMapIcon(uint8_t byteIndex, float fX, float fY, float fZ, uint8_t byteIcon, int iColor, int style); 68 | void DisableMapIcon(uint8_t byteIndex); 69 | 70 | private: 71 | RakClientInterface* m_pRakClient; 72 | CPlayerPool* m_pPlayerPool; 73 | CVehiclePool* m_pVehiclePool; 74 | CObjectPool* m_pObjectPool; 75 | CPickupPool* m_pPickupPool; 76 | CGangZonePool* m_pGangZonePool; 77 | CText3DLabelsPool* m_pLabelPool; 78 | 79 | int m_iGameState; 80 | uint32_t m_dwLastConnectAttempt; 81 | 82 | uint32_t m_dwMapIcons[100]; 83 | 84 | void UpdateNetwork(); 85 | void Packet_AuthKey(Packet *p); 86 | void Packet_DisconnectionNotification(Packet *p); 87 | void Packet_ConnectionLost(Packet *p); 88 | void Packet_ConnectionSucceeded(Packet *p); 89 | void Packet_PlayerSync(Packet* pkt); 90 | void Packet_VehicleSync(Packet* pkt); 91 | void Packet_PassengerSync(Packet* pkt); 92 | void Packet_MarkersSync(Packet* pkt); 93 | 94 | public: 95 | char m_szHostName[0xFF]; 96 | char m_szHostOrIp[0x7F]; 97 | int m_iPort; 98 | 99 | bool m_bZoneNames; 100 | bool m_bUseCJWalk; 101 | bool m_bAllowWeapons; 102 | bool m_bLimitGlobalChatRadius; 103 | float m_fGlobalChatRadius; 104 | float m_fNameTagDrawDistance; 105 | bool m_bDisableEnterExits; 106 | bool m_bNameTagLOS; 107 | bool m_bManualVehicleEngineAndLight; 108 | int m_iSpawnsAvailable; 109 | bool m_bShowPlayerTags; 110 | int m_iShowPlayerMarkers; 111 | bool m_bHoldTime; 112 | uint8_t m_byteWorldTime; 113 | uint8_t m_byteWorldMinute; 114 | uint8_t m_byteWeather; 115 | float m_fGravity; 116 | int m_iDeathDropMoney; 117 | bool m_bInstagib; 118 | int m_iLagCompensation; 119 | int m_iVehicleFriendlyFire; 120 | }; -------------------------------------------------------------------------------- /vendor/raknet/InternalPacket.h: -------------------------------------------------------------------------------- 1 | /// \file 2 | /// \brief \b [Internal] A class which stores a user message, and all information associated with sending and receiving that message. 3 | /// 4 | /// This file is part of RakNet Copyright 2003 Kevin Jenkins. 5 | /// 6 | /// Usage of RakNet is subject to the appropriate license agreement. 7 | /// Creative Commons Licensees are subject to the 8 | /// license found at 9 | /// http://creativecommons.org/licenses/by-nc/2.5/ 10 | /// Single application licensees are subject to the license found at 11 | /// http://www.rakkarsoft.com/SingleApplicationLicense.html 12 | /// Custom license users are subject to the terms therein. 13 | /// GPL license users are subject to the GNU General Public 14 | /// License as published by the Free 15 | /// Software Foundation; either version 2 of the License, or (at your 16 | /// option) any later version. 17 | 18 | #ifndef __INTERNAL_PACKET_H 19 | #define __INTERNAL_PACKET_H 20 | 21 | #include "PacketPriority.h" 22 | #include "NetworkTypes.h" 23 | 24 | 25 | /// This is the counter used for holding ordered packet numbers, so we can detect out-of-order packets. It should be large enough that if the variables 26 | /// were to wrap, the newly wrapped values would no longer be in use. Warning: Too large of a value wastes bandwidth! 27 | typedef unsigned short OrderingIndexType; 28 | 29 | typedef unsigned short SplitPacketIdType; 30 | typedef unsigned int SplitPacketIndexType; 31 | 32 | 33 | /// This is the counter used for holding packet numbers, so we can detect duplicate packets. It should be large enough that if the variables 34 | /// were to wrap, the newly wrapped values would no longer be in use. Warning: Too large of a value wastes bandwidth! 35 | /// Use the smallest possible value, such that you send no more than rangeof(MessageNumberType) / GetTimeoutTime() packets per second 36 | /// For the default value of 10 seconds, this is 37 | /// unsigned char - 25.5 packets per second 38 | /// unsigned short - 6553.5 packets per second 39 | /// unsigned int - You'll run out of memory first. 40 | typedef unsigned short MessageNumberType; 41 | 42 | /// Holds a user message, and related information 43 | struct InternalPacket 44 | { 45 | ///True if this is an acknowledgment packet 46 | //bool isAcknowledgement; 47 | 48 | ///A unique numerical identifier given to this user message 49 | MessageNumberType messageNumber; 50 | /// Used only for tracking packetloss and windowing internally, this is the aggreggate packet number that a message was last sent in 51 | unsigned packetNumber; 52 | /// Was this packet number used this update to track windowing drops or increases? Each packet number is only used once per update. 53 | // bool allowWindowUpdate; 54 | ///The priority level of this packet 55 | PacketPriority priority; 56 | ///What type of reliability algorithm to use with this packet 57 | PacketReliability reliability; 58 | ///What ordering channel this packet is on, if the reliability type uses ordering channels 59 | unsigned char orderingChannel; 60 | ///The ID used as identification for ordering channels 61 | OrderingIndexType orderingIndex; 62 | ///The ID of the split packet, if we have split packets. This is the maximum number of split messages we can send simultaneously per connection. 63 | SplitPacketIdType splitPacketId; 64 | ///If this is a split packet, the index into the array of subsplit packets 65 | SplitPacketIndexType splitPacketIndex; 66 | ///The size of the array of subsplit packets 67 | SplitPacketIndexType splitPacketCount; 68 | ///When this packet was created 69 | RakNetTimeNS creationTime; 70 | ///The next time to take action on this packet 71 | RakNetTimeNS nextActionTime; 72 | ///How many bits the data is 73 | unsigned int dataBitLength; 74 | ///Buffer is a pointer to the actual data, assuming this packet has data at all 75 | unsigned char *data; 76 | /// For checking packetloss at a particular send rate 77 | unsigned histogramMarker; 78 | }; 79 | 80 | #endif 81 | 82 | --------------------------------------------------------------------------------