├── discord.h ├── targetver.h ├── stdafx.cpp ├── README.md ├── GTPS.APS ├── app ├── icon.ico └── icon2.ico ├── bin ├── GTPS.res ├── callbacks.obj ├── compress.obj ├── compress.nativecodeanalysis.xml ├── callbacks.nativecodeanalysis.xml ├── GTPS.tlog │ ├── CL.read.1.tlog │ ├── rc.read.1.tlog │ ├── CL.write.1.tlog │ ├── link.read.1.tlog │ ├── rc.write.1.tlog │ ├── CL.command.1.tlog │ ├── link.command.1.tlog │ ├── link.write.1.tlog │ ├── rc.command.1.tlog │ └── GTPS.lastbuildstate ├── GTPS.exe.recipe └── GTPS.Build.CppClean.log ├── libmysql.lib ├── libmysql_64.lib ├── source ├── GUI │ ├── DebugMenu.h │ ├── MainMenu.h │ ├── AboutMenu.h │ ├── TouchTestMenu.h │ ├── ParticleTestMenu.h │ ├── EnterNameMenu.h │ ├── TouchTestMenu.cpp │ ├── ParticleTestMenu.cpp │ ├── DebugMenu.cpp │ ├── MainMenu.cpp │ ├── EnterNameMenu.cpp │ └── AboutMenu.cpp ├── enet │ ├── utility.h │ ├── enet │ │ ├── utility.h │ │ ├── types.h │ │ ├── enet │ │ │ └── types.h │ │ ├── time.h │ │ ├── callbacks.h │ │ ├── list.h │ │ ├── unix.h │ │ ├── win32.h │ │ └── protocol.h │ ├── types.h │ ├── time.h │ ├── callbacks.h │ ├── list.h │ ├── unix.h │ ├── win32.h │ └── protocol.h ├── utils.h ├── proton │ ├── hash.hpp │ ├── vector.hpp │ └── rtparam.hpp ├── App.h ├── Component │ ├── ParticleTestComponent.h │ ├── TouchTestComponent.h │ ├── TouchTestComponent.cpp │ └── ParticleTestComponent.cpp ├── utils.cpp └── App.cpp ├── stdafx.h ├── enet ├── include │ ├── utility.h │ ├── types.h │ ├── time.h │ ├── callbacks.h │ ├── list.h │ ├── unix.h │ ├── win32.h │ └── protocol.h ├── callbacks.c ├── list.c ├── packet.c └── win32.c ├── resource.h ├── GTPS.vcxproj.user ├── Core_functions.h ├── proton ├── hash.hpp ├── vector.hpp └── rtparam.hpp ├── Server.sln ├── GTPS.rc ├── sandbird └── sandbird.h ├── Player_mods.h ├── discord_webhook.h ├── http.h ├── GTPS.vcxproj.filters ├── trade_system.h ├── save_system.h └── GTPS.vcxproj /discord.h: -------------------------------------------------------------------------------- 1 | #pragma once -------------------------------------------------------------------------------- /targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /stdafx.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GTOS (Growtopia Private Server)'s latest source. 2 | -------------------------------------------------------------------------------- /GTPS.APS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/GTPS.APS -------------------------------------------------------------------------------- /app/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/app/icon.ico -------------------------------------------------------------------------------- /app/icon2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/app/icon2.ico -------------------------------------------------------------------------------- /bin/GTPS.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.res -------------------------------------------------------------------------------- /libmysql.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/libmysql.lib -------------------------------------------------------------------------------- /libmysql_64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/libmysql_64.lib -------------------------------------------------------------------------------- /bin/callbacks.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/callbacks.obj -------------------------------------------------------------------------------- /bin/compress.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/compress.obj -------------------------------------------------------------------------------- /bin/compress.nativecodeanalysis.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /source/GUI/DebugMenu.h: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | 3 | Entity * DebugMenuCreate(Entity *pParentEnt); -------------------------------------------------------------------------------- /bin/callbacks.nativecodeanalysis.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /bin/GTPS.tlog/CL.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.tlog/CL.read.1.tlog -------------------------------------------------------------------------------- /bin/GTPS.tlog/rc.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.tlog/rc.read.1.tlog -------------------------------------------------------------------------------- /bin/GTPS.tlog/CL.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.tlog/CL.write.1.tlog -------------------------------------------------------------------------------- /bin/GTPS.tlog/link.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.tlog/link.read.1.tlog -------------------------------------------------------------------------------- /bin/GTPS.tlog/rc.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.tlog/rc.write.1.tlog -------------------------------------------------------------------------------- /bin/GTPS.tlog/CL.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.tlog/CL.command.1.tlog -------------------------------------------------------------------------------- /bin/GTPS.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /bin/GTPS.tlog/link.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.tlog/link.write.1.tlog -------------------------------------------------------------------------------- /bin/GTPS.tlog/rc.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zKaan/GTOSLatest/HEAD/bin/GTPS.tlog/rc.command.1.tlog -------------------------------------------------------------------------------- /stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "targetver.h" 4 | // TODO: reference additional headers your program requires here -------------------------------------------------------------------------------- /source/GUI/MainMenu.h: -------------------------------------------------------------------------------- 1 | #ifndef MainMenu_h__ 2 | #define MainMenu_h__ 3 | 4 | #include "App.h" 5 | 6 | Entity * MainMenuCreate(Entity *pParentEnt); 7 | #endif // MainMenu_h__ -------------------------------------------------------------------------------- /source/GUI/AboutMenu.h: -------------------------------------------------------------------------------- 1 | #ifndef AboutMenu_h__ 2 | #define AboutMenu_h__ 3 | #include "BaseApp.h" 4 | Entity * AboutMenuCreate(Entity *pParentEnt); 5 | 6 | 7 | #endif // AboutMenu_h__ -------------------------------------------------------------------------------- /source/GUI/TouchTestMenu.h: -------------------------------------------------------------------------------- 1 | #ifndef TouchTest_h__ 2 | #define TouchTest_h__ 3 | 4 | #include "App.h" 5 | 6 | Entity * TouchTestMenuCreate(Entity *pParentEnt); 7 | #endif // TouchTest_h__ -------------------------------------------------------------------------------- /source/GUI/ParticleTestMenu.h: -------------------------------------------------------------------------------- 1 | #ifndef ParticleTest_h__ 2 | #define ParticleTest_h__ 3 | 4 | #include "App.h" 5 | 6 | Entity * ParticleTestCreate(Entity *pParentEnt); 7 | #endif // ParticleTest_h__ -------------------------------------------------------------------------------- /bin/GTPS.tlog/GTPS.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29910:TargetPlatformVersion=10.0.18362.0: 2 | Release|x64|C:\Users\Almantas\Desktop\gtps\project_files\| 3 | -------------------------------------------------------------------------------- /source/enet/utility.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file utility.h 3 | @brief ENet utility header 4 | */ 5 | #ifndef __ENET_UTILITY_H__ 6 | #define __ENET_UTILITY_H__ 7 | 8 | #define ENET_MAX(x, y) ((x) > (y) ? (x) : (y)) 9 | #define ENET_MIN(x, y) ((x) < (y) ? (x) : (y)) 10 | 11 | #endif /* __ENET_UTILITY_H__ */ 12 | 13 | -------------------------------------------------------------------------------- /source/enet/enet/utility.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file utility.h 3 | @brief ENet utility header 4 | */ 5 | #ifndef __ENET_UTILITY_H__ 6 | #define __ENET_UTILITY_H__ 7 | 8 | #define ENET_MAX(x, y) ((x) > (y) ? (x) : (y)) 9 | #define ENET_MIN(x, y) ((x) < (y) ? (x) : (y)) 10 | 11 | #endif /* __ENET_UTILITY_H__ */ 12 | 13 | -------------------------------------------------------------------------------- /bin/GTPS.exe.recipe: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | C:\Users\Almantas\Desktop\gtps\GTPS.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /enet/include/utility.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file utility.h 3 | @brief ENet utility header 4 | */ 5 | #ifndef __ENET_UTILITY_H__ 6 | #define __ENET_UTILITY_H__ 7 | 8 | #define ENET_MAX(x, y) ((x) > (y) ? (x) : (y)) 9 | #define ENET_MIN(x, y) ((x) < (y) ? (x) : (y)) 10 | #define ENET_DIFFERENCE(x, y) ((x) < (y) ? (y) - (x) : (x) - (y)) 11 | 12 | #endif /* __ENET_UTILITY_H__ */ 13 | 14 | -------------------------------------------------------------------------------- /enet/include/types.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file types.h 3 | @brief type definitions for ENet 4 | */ 5 | #ifndef __ENET_TYPES_H__ 6 | #define __ENET_TYPES_H__ 7 | 8 | typedef unsigned char enet_uint8; /**< unsigned 8-bit type */ 9 | typedef unsigned short enet_uint16; /**< unsigned 16-bit type */ 10 | typedef unsigned int enet_uint32; /**< unsigned 32-bit type */ 11 | 12 | #endif /* __ENET_TYPES_H__ */ 13 | 14 | -------------------------------------------------------------------------------- /source/enet/types.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file types.h 3 | @brief type definitions for ENet 4 | */ 5 | #ifndef __ENET_TYPES_H__ 6 | #define __ENET_TYPES_H__ 7 | 8 | typedef unsigned char enet_uint8; /**< unsigned 8-bit type */ 9 | typedef unsigned short enet_uint16; /**< unsigned 16-bit type */ 10 | typedef unsigned int enet_uint32; /**< unsigned 32-bit type */ 11 | 12 | #endif /* __ENET_TYPES_H__ */ 13 | 14 | -------------------------------------------------------------------------------- /source/enet/enet/types.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file types.h 3 | @brief type definitions for ENet 4 | */ 5 | #ifndef __ENET_TYPES_H__ 6 | #define __ENET_TYPES_H__ 7 | 8 | typedef unsigned char enet_uint8; /**< unsigned 8-bit type */ 9 | typedef unsigned short enet_uint16; /**< unsigned 16-bit type */ 10 | typedef unsigned int enet_uint32; /**< unsigned 32-bit type */ 11 | 12 | #endif /* __ENET_TYPES_H__ */ 13 | 14 | -------------------------------------------------------------------------------- /source/enet/enet/enet/types.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file types.h 3 | @brief type definitions for ENet 4 | */ 5 | #ifndef __ENET_TYPES_H__ 6 | #define __ENET_TYPES_H__ 7 | 8 | typedef unsigned char enet_uint8; /**< unsigned 8-bit type */ 9 | typedef unsigned short enet_uint16; /**< unsigned 16-bit type */ 10 | typedef unsigned int enet_uint32; /**< unsigned 32-bit type */ 11 | 12 | #endif /* __ENET_TYPES_H__ */ 13 | 14 | -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by GTPS.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 103 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /enet/include/time.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file time.h 3 | @brief ENet time constants and macros 4 | */ 5 | #ifndef __ENET_TIME_H__ 6 | #define __ENET_TIME_H__ 7 | 8 | #define ENET_TIME_OVERFLOW 86400000 9 | 10 | #define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) 11 | #define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) 12 | #define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) 13 | #define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) 14 | 15 | #define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) 16 | 17 | #endif /* __ENET_TIME_H__ */ 18 | 19 | -------------------------------------------------------------------------------- /source/enet/time.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file time.h 3 | @brief ENet time constants and macros 4 | */ 5 | #ifndef __ENET_TIME_H__ 6 | #define __ENET_TIME_H__ 7 | 8 | #define ENET_TIME_OVERFLOW 86400000 9 | 10 | #define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) 11 | #define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) 12 | #define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) 13 | #define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) 14 | 15 | #define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) 16 | 17 | #endif /* __ENET_TIME_H__ */ 18 | 19 | -------------------------------------------------------------------------------- /source/enet/enet/time.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file time.h 3 | @brief ENet time constants and macros 4 | */ 5 | #ifndef __ENET_TIME_H__ 6 | #define __ENET_TIME_H__ 7 | 8 | #define ENET_TIME_OVERFLOW 86400000 9 | 10 | #define ENET_TIME_LESS(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW) 11 | #define ENET_TIME_GREATER(a, b) ((b) - (a) >= ENET_TIME_OVERFLOW) 12 | #define ENET_TIME_LESS_EQUAL(a, b) (! ENET_TIME_GREATER (a, b)) 13 | #define ENET_TIME_GREATER_EQUAL(a, b) (! ENET_TIME_LESS (a, b)) 14 | 15 | #define ENET_TIME_DIFFERENCE(a, b) ((a) - (b) >= ENET_TIME_OVERFLOW ? (b) - (a) : (a) - (b)) 16 | 17 | #endif /* __ENET_TIME_H__ */ 18 | 19 | -------------------------------------------------------------------------------- /enet/include/callbacks.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file callbacks.h 3 | @brief ENet callbacks 4 | */ 5 | #ifndef __ENET_CALLBACKS_H__ 6 | #define __ENET_CALLBACKS_H__ 7 | 8 | #include 9 | 10 | typedef struct _ENetCallbacks 11 | { 12 | void * (ENET_CALLBACK * malloc) (size_t size); 13 | void (ENET_CALLBACK * free) (void * memory); 14 | void (ENET_CALLBACK * no_memory) (void); 15 | } ENetCallbacks; 16 | 17 | /** @defgroup callbacks ENet internal callbacks 18 | @{ 19 | @ingroup private 20 | */ 21 | extern void * enet_malloc (size_t); 22 | extern void enet_free (void *); 23 | 24 | /** @} */ 25 | 26 | #endif /* __ENET_CALLBACKS_H__ */ 27 | 28 | -------------------------------------------------------------------------------- /source/enet/callbacks.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file callbacks.h 3 | @brief ENet callbacks 4 | */ 5 | #ifndef __ENET_CALLBACKS_H__ 6 | #define __ENET_CALLBACKS_H__ 7 | 8 | #include 9 | 10 | typedef struct _ENetCallbacks 11 | { 12 | void * (ENET_CALLBACK * malloc) (size_t size); 13 | void (ENET_CALLBACK * free) (void * memory); 14 | void (ENET_CALLBACK * no_memory) (void); 15 | } ENetCallbacks; 16 | 17 | /** @defgroup callbacks ENet internal callbacks 18 | @{ 19 | @ingroup private 20 | */ 21 | extern void * enet_malloc (size_t); 22 | extern void enet_free (void *); 23 | 24 | /** @} */ 25 | 26 | #endif /* __ENET_CALLBACKS_H__ */ 27 | 28 | -------------------------------------------------------------------------------- /source/enet/enet/callbacks.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file callbacks.h 3 | @brief ENet callbacks 4 | */ 5 | #ifndef __ENET_CALLBACKS_H__ 6 | #define __ENET_CALLBACKS_H__ 7 | 8 | #include 9 | 10 | typedef struct _ENetCallbacks 11 | { 12 | void * (ENET_CALLBACK * malloc) (size_t size); 13 | void (ENET_CALLBACK * free) (void * memory); 14 | void (ENET_CALLBACK * no_memory) (void); 15 | } ENetCallbacks; 16 | 17 | /** @defgroup callbacks ENet internal callbacks 18 | @{ 19 | @ingroup private 20 | */ 21 | extern void * enet_malloc (size_t); 22 | extern void enet_free (void *); 23 | 24 | /** @} */ 25 | 26 | #endif /* __ENET_CALLBACKS_H__ */ 27 | 28 | -------------------------------------------------------------------------------- /source/GUI/EnterNameMenu.h: -------------------------------------------------------------------------------- 1 | // *************************************************************** 2 | // EnterNameMenu - Creation date: 07/16/2009 3 | // ------------------------------------------------------------- 4 | // Robinson Technologies Copyright (C) 2009 - All Rights Reserved 5 | // 6 | // *************************************************************** 7 | // Programmer(s): Seth A. Robinson (seth@rtsoft.com) 8 | // *************************************************************** 9 | 10 | #ifndef EnterNameMenu_h__ 11 | #define EnterNameMenu_h__ 12 | #include "App.h" 13 | 14 | Entity * EnterNameMenuCreate(Entity *pParentEnt); 15 | extern string tankIDname; 16 | extern string tankIDpass; 17 | 18 | 19 | 20 | #endif // EnterNameMenu_h__ -------------------------------------------------------------------------------- /GTPS.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | C:\Users\Almantas\Desktop\gtps\ 5 | WindowsLocalDebugger 6 | 7 | 8 | false 9 | 10 | 11 | C:\Users\Almantas\Desktop\gtps\ 12 | WindowsLocalDebugger 13 | 14 | -------------------------------------------------------------------------------- /Core_functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std::chrono; 7 | using namespace std; 8 | #pragma warning(disable : 4996) 9 | 10 | 11 | 12 | inline long long GetCurrentTimeInternalSeconds() { 13 | return (duration_cast(system_clock::now().time_since_epoch())).count(); 14 | } 15 | 16 | inline void SendConsole(const string text, const string type) { 17 | const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 18 | int k = 15; 19 | if (type == "INFO") { 20 | k = 10; 21 | } else if (type == "WARN") { 22 | k = 14; 23 | } else if (type == "ERROR") { 24 | k = 12; 25 | } else if (type == "HTTP") { 26 | k = 13; 27 | } else if (type == "MYSQL") { 28 | k = 11; 29 | } else if (type == "CHAT") { 30 | k = 15; 31 | } 32 | SetConsoleTextAttribute(hConsole, k); 33 | cout << "[" + type + "]: " << text << endl; 34 | } -------------------------------------------------------------------------------- /source/utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "proton/variant.hpp" 6 | 7 | #define PRINTS(msg, ...) printf("[SERVER]: " msg, __VA_ARGS__); 8 | #define PRINTC(msg, ...) printf("[CLIENT]: " msg, __VA_ARGS__); 9 | #define MALLOC(type, ...) (type*)(malloc(sizeof(type) __VA_ARGS__)) 10 | #define get_packet_type(packet) (packet->dataLength > 3 ? *packet->data : 0) 11 | #define DO_ONCE \ 12 | ([]() { \ 13 | static char o = 0; \ 14 | return !o && ++o; \ 15 | }()) 16 | #ifdef _WIN32 17 | #define INLINE __forceinline 18 | #else //for gcc/clang 19 | #define INLINE __attribute__((always_inline)) 20 | #endif 21 | 22 | namespace utils { 23 | bool is_number(const std::string& s); 24 | } // namespace utils 25 | 26 | bool utils::is_number(const std::string& s) { 27 | return !s.empty() && std::find_if(s.begin() + (*s.data() == '-' ? 1 : 0), s.end(), [](char c) { return !std::isdigit(c); }) == s.end(); 28 | } 29 | -------------------------------------------------------------------------------- /proton/hash.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #pragma warning(disable : 4307) 5 | 6 | template 7 | class cexpr { 8 | public: 9 | static constexpr t value = val; 10 | }; 11 | namespace hs { 12 | constexpr uint32_t val_32_const = 0x811c9dc5u; 13 | constexpr uint32_t prime_32_const = 0x1000193u; 14 | constexpr uint64_t val_64_const = 0xcbf29ce484222325u; 15 | constexpr uint64_t prime_64_const = 0x100000001b3u; 16 | __forceinline constexpr uint32_t hash32(const char* const str, const uint32_t value = val_32_const) noexcept { 17 | return (str[0] == '\0') ? value : hash32(&str[1], (value ^ uint32_t(str[0])) * prime_32_const); 18 | } 19 | __forceinline constexpr uint64_t hash64(const char* const str, const uint64_t value = val_64_const) noexcept { 20 | return (str[0] == '\0') ? value : hash64(&str[1], (value ^ uint64_t(str[0])) * prime_64_const); 21 | } 22 | } // namespace hs 23 | #define fnv32(s) (cexpr::value) 24 | #define fnv64(s) (cexpr::value) -------------------------------------------------------------------------------- /source/proton/hash.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #pragma warning(disable : 4307) 5 | 6 | template 7 | class cexpr { 8 | public: 9 | static constexpr t value = val; 10 | }; 11 | namespace hs { 12 | constexpr uint32_t val_32_const = 0x811c9dc5u; 13 | constexpr uint32_t prime_32_const = 0x1000193u; 14 | constexpr uint64_t val_64_const = 0xcbf29ce484222325u; 15 | constexpr uint64_t prime_64_const = 0x100000001b3u; 16 | __forceinline constexpr uint32_t hash32(const char* const str, const uint32_t value = val_32_const) noexcept { 17 | return (str[0] == '\0') ? value : hash32(&str[1], (value ^ uint32_t(str[0])) * prime_32_const); 18 | } 19 | __forceinline constexpr uint64_t hash64(const char* const str, const uint64_t value = val_64_const) noexcept { 20 | return (str[0] == '\0') ? value : hash64(&str[1], (value ^ uint64_t(str[0])) * prime_64_const); 21 | } 22 | } // namespace hs 23 | #define fnv32(s) (cexpr::value) 24 | #define fnv64(s) (cexpr::value) -------------------------------------------------------------------------------- /enet/callbacks.c: -------------------------------------------------------------------------------- 1 | /** 2 | @file callbacks.c 3 | @brief ENet callback functions 4 | */ 5 | #define ENET_BUILDING_LIB 1 6 | #include "include/enet.h" 7 | 8 | static ENetCallbacks callbacks = { malloc, free, abort }; 9 | 10 | int 11 | enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits) 12 | { 13 | if (version < ENET_VERSION_CREATE (1, 3, 0)) 14 | return -1; 15 | 16 | if (inits -> malloc != NULL || inits -> free != NULL) 17 | { 18 | if (inits -> malloc == NULL || inits -> free == NULL) 19 | return -1; 20 | 21 | callbacks.malloc = inits -> malloc; 22 | callbacks.free = inits -> free; 23 | } 24 | 25 | if (inits -> no_memory != NULL) 26 | callbacks.no_memory = inits -> no_memory; 27 | 28 | return enet_initialize (); 29 | } 30 | 31 | ENetVersion 32 | enet_linked_version (void) 33 | { 34 | return ENET_VERSION; 35 | } 36 | 37 | void * 38 | enet_malloc (size_t size) 39 | { 40 | void * memory = callbacks.malloc (size); 41 | 42 | if (memory == NULL) 43 | callbacks.no_memory (); 44 | 45 | return memory; 46 | } 47 | 48 | void 49 | enet_free (void * memory) 50 | { 51 | callbacks.free (memory); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /source/enet/list.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file list.h 3 | @brief ENet list management 4 | */ 5 | #ifndef __ENET_LIST_H__ 6 | #define __ENET_LIST_H__ 7 | 8 | #include 9 | 10 | typedef struct _ENetListNode 11 | { 12 | struct _ENetListNode * next; 13 | struct _ENetListNode * previous; 14 | } ENetListNode; 15 | 16 | typedef ENetListNode * ENetListIterator; 17 | 18 | typedef struct _ENetList 19 | { 20 | ENetListNode sentinel; 21 | } ENetList; 22 | 23 | extern void enet_list_clear (ENetList *); 24 | 25 | extern ENetListIterator enet_list_insert (ENetListIterator, void *); 26 | extern void * enet_list_remove (ENetListIterator); 27 | extern ENetListIterator enet_list_move (ENetListIterator, void *, void *); 28 | 29 | extern size_t enet_list_size (ENetList *); 30 | 31 | #define enet_list_begin(list) ((list) -> sentinel.next) 32 | #define enet_list_end(list) (& (list) -> sentinel) 33 | 34 | #define enet_list_empty(list) (enet_list_begin (list) == enet_list_end (list)) 35 | 36 | #define enet_list_next(iterator) ((iterator) -> next) 37 | #define enet_list_previous(iterator) ((iterator) -> previous) 38 | 39 | #define enet_list_front(list) ((void *) (list) -> sentinel.next) 40 | #define enet_list_back(list) ((void *) (list) -> sentinel.previous) 41 | 42 | #endif /* __ENET_LIST_H__ */ 43 | 44 | -------------------------------------------------------------------------------- /enet/include/list.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file list.h 3 | @brief ENet list management 4 | */ 5 | #ifndef __ENET_LIST_H__ 6 | #define __ENET_LIST_H__ 7 | 8 | #include 9 | 10 | typedef struct _ENetListNode 11 | { 12 | struct _ENetListNode * next; 13 | struct _ENetListNode * previous; 14 | } ENetListNode; 15 | 16 | typedef ENetListNode * ENetListIterator; 17 | 18 | typedef struct _ENetList 19 | { 20 | ENetListNode sentinel; 21 | } ENetList; 22 | 23 | extern void enet_list_clear (ENetList *); 24 | 25 | extern ENetListIterator enet_list_insert (ENetListIterator, void *); 26 | extern void * enet_list_remove (ENetListIterator); 27 | extern ENetListIterator enet_list_move (ENetListIterator, void *, void *); 28 | 29 | extern size_t enet_list_size (ENetList *); 30 | 31 | #define enet_list_begin(list) ((list) -> sentinel.next) 32 | #define enet_list_end(list) (& (list) -> sentinel) 33 | 34 | #define enet_list_empty(list) (enet_list_begin (list) == enet_list_end (list)) 35 | 36 | #define enet_list_next(iterator) ((iterator) -> next) 37 | #define enet_list_previous(iterator) ((iterator) -> previous) 38 | 39 | #define enet_list_front(list) ((void *) (list) -> sentinel.next) 40 | #define enet_list_back(list) ((void *) (list) -> sentinel.previous) 41 | 42 | #endif /* __ENET_LIST_H__ */ 43 | 44 | -------------------------------------------------------------------------------- /source/enet/enet/list.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file list.h 3 | @brief ENet list management 4 | */ 5 | #ifndef __ENET_LIST_H__ 6 | #define __ENET_LIST_H__ 7 | 8 | #include 9 | 10 | typedef struct _ENetListNode 11 | { 12 | struct _ENetListNode * next; 13 | struct _ENetListNode * previous; 14 | } ENetListNode; 15 | 16 | typedef ENetListNode * ENetListIterator; 17 | 18 | typedef struct _ENetList 19 | { 20 | ENetListNode sentinel; 21 | } ENetList; 22 | 23 | extern void enet_list_clear (ENetList *); 24 | 25 | extern ENetListIterator enet_list_insert (ENetListIterator, void *); 26 | extern void * enet_list_remove (ENetListIterator); 27 | extern ENetListIterator enet_list_move (ENetListIterator, void *, void *); 28 | 29 | extern size_t enet_list_size (ENetList *); 30 | 31 | #define enet_list_begin(list) ((list) -> sentinel.next) 32 | #define enet_list_end(list) (& (list) -> sentinel) 33 | 34 | #define enet_list_empty(list) (enet_list_begin (list) == enet_list_end (list)) 35 | 36 | #define enet_list_next(iterator) ((iterator) -> next) 37 | #define enet_list_previous(iterator) ((iterator) -> previous) 38 | 39 | #define enet_list_front(list) ((void *) (list) -> sentinel.next) 40 | #define enet_list_back(list) ((void *) (list) -> sentinel.previous) 41 | 42 | #endif /* __ENET_LIST_H__ */ 43 | 44 | -------------------------------------------------------------------------------- /source/App.h: -------------------------------------------------------------------------------- 1 | /* 2 | * App.h 3 | * Created by Seth Robinson on 3/6/09. 4 | * For license info, check the license.txt file that should have come with this. 5 | * 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "BaseApp.h" 11 | 12 | 13 | 14 | class App: public BaseApp 15 | { 16 | public: 17 | 18 | App(); 19 | virtual ~App(); 20 | 21 | virtual bool Init(); 22 | virtual void Kill(); 23 | virtual void Draw(); 24 | virtual void OnScreenSizeChange(); 25 | virtual void Update(); 26 | virtual void OnEnterBackground(); 27 | virtual bool OnPreInitVideo(); 28 | 29 | string GetVersionString(); 30 | float GetVersion(); 31 | int GetBuild(); 32 | void GetServerInfo(string &server, uint32 &port); 33 | VariantDB * GetShared() {return &m_varDB;} 34 | Variant * GetVar(const string &keyName ); 35 | Variant * GetVarWithDefault(const string &varName, const Variant &var) {return m_varDB.GetVarWithDefault(varName, var);} 36 | int GetSpecial(); 37 | void OnExitApp(VariantList *pVarList); 38 | 39 | private: 40 | 41 | void SaveOurStuff(); 42 | 43 | bool m_bDidPostInit; 44 | VariantDB m_varDB; //holds all data we want to save/load 45 | int m_special; 46 | }; 47 | 48 | 49 | extern App g_App; 50 | 51 | App * GetApp(); 52 | const char * GetAppName(); 53 | const char * GetBundleName(); 54 | const char * GetBundlePrefix(); 55 | -------------------------------------------------------------------------------- /source/enet/unix.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file unix.h 3 | @brief ENet Unix header 4 | */ 5 | #ifndef __ENET_UNIX_H__ 6 | #define __ENET_UNIX_H__ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef MSG_MAXIOVLEN 16 | #define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN 17 | #endif 18 | 19 | typedef int ENetSocket; 20 | 21 | #define ENET_SOCKET_NULL -1 22 | 23 | #define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */ 24 | #define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */ 25 | 26 | #define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */ 27 | #define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */ 28 | 29 | typedef struct 30 | { 31 | void * data; 32 | size_t dataLength; 33 | } ENetBuffer; 34 | 35 | #define ENET_CALLBACK 36 | 37 | #define ENET_API extern 38 | 39 | typedef fd_set ENetSocketSet; 40 | 41 | #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) 42 | #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) 43 | #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset)) 44 | #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) 45 | 46 | #endif /* __ENET_UNIX_H__ */ 47 | 48 | -------------------------------------------------------------------------------- /source/enet/enet/unix.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file unix.h 3 | @brief ENet Unix header 4 | */ 5 | #ifndef __ENET_UNIX_H__ 6 | #define __ENET_UNIX_H__ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef MSG_MAXIOVLEN 16 | #define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN 17 | #endif 18 | 19 | typedef int ENetSocket; 20 | 21 | #define ENET_SOCKET_NULL -1 22 | 23 | #define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */ 24 | #define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */ 25 | 26 | #define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */ 27 | #define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */ 28 | 29 | typedef struct 30 | { 31 | void * data; 32 | size_t dataLength; 33 | } ENetBuffer; 34 | 35 | #define ENET_CALLBACK 36 | 37 | #define ENET_API extern 38 | 39 | typedef fd_set ENetSocketSet; 40 | 41 | #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) 42 | #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) 43 | #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset)) 44 | #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) 45 | 46 | #endif /* __ENET_UNIX_H__ */ 47 | 48 | -------------------------------------------------------------------------------- /Server.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30717.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GTPS", "GTPS.vcxproj", "{2C3EDE48-5A4E-4158-A05F-FBF6CAFFB61F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {2C3EDE48-5A4E-4158-A05F-FBF6CAFFB61F}.Debug|x64.ActiveCfg = Debug|x64 17 | {2C3EDE48-5A4E-4158-A05F-FBF6CAFFB61F}.Debug|x64.Build.0 = Debug|x64 18 | {2C3EDE48-5A4E-4158-A05F-FBF6CAFFB61F}.Debug|x86.ActiveCfg = Debug|Win32 19 | {2C3EDE48-5A4E-4158-A05F-FBF6CAFFB61F}.Debug|x86.Build.0 = Debug|Win32 20 | {2C3EDE48-5A4E-4158-A05F-FBF6CAFFB61F}.Release|x64.ActiveCfg = Release|x64 21 | {2C3EDE48-5A4E-4158-A05F-FBF6CAFFB61F}.Release|x64.Build.0 = Release|x64 22 | {2C3EDE48-5A4E-4158-A05F-FBF6CAFFB61F}.Release|x86.ActiveCfg = Release|Win32 23 | {2C3EDE48-5A4E-4158-A05F-FBF6CAFFB61F}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {71C9B242-838A-4CCF-8BF0-A44D5434DF98} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /enet/include/unix.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file unix.h 3 | @brief ENet Unix header 4 | */ 5 | #ifndef __ENET_UNIX_H__ 6 | #define __ENET_UNIX_H__ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #ifdef MSG_MAXIOVLEN 17 | #define ENET_BUFFER_MAXIMUM MSG_MAXIOVLEN 18 | #endif 19 | 20 | typedef int ENetSocket; 21 | 22 | #define ENET_SOCKET_NULL -1 23 | 24 | #define ENET_HOST_TO_NET_16(value) (htons (value)) /**< macro that converts host to net byte-order of a 16-bit value */ 25 | #define ENET_HOST_TO_NET_32(value) (htonl (value)) /**< macro that converts host to net byte-order of a 32-bit value */ 26 | 27 | #define ENET_NET_TO_HOST_16(value) (ntohs (value)) /**< macro that converts net to host byte-order of a 16-bit value */ 28 | #define ENET_NET_TO_HOST_32(value) (ntohl (value)) /**< macro that converts net to host byte-order of a 32-bit value */ 29 | 30 | typedef struct 31 | { 32 | void * data; 33 | size_t dataLength; 34 | } ENetBuffer; 35 | 36 | #define ENET_CALLBACK 37 | 38 | #define ENET_API extern 39 | 40 | typedef fd_set ENetSocketSet; 41 | 42 | #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) 43 | #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) 44 | #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset)) 45 | #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) 46 | 47 | #endif /* __ENET_UNIX_H__ */ 48 | 49 | -------------------------------------------------------------------------------- /source/GUI/TouchTestMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "PlatformPrecomp.h" 2 | #include "TouchTestMenu.h" 3 | #include "Entity/EntityUtils.h" 4 | #include "MainMenu.h" 5 | #include "Component/TouchTestComponent.h" 6 | 7 | void TouchTestOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from 8 | { 9 | Entity *pEntClicked = pVList->m_variant[1].GetEntity(); 10 | 11 | LogMsg("Clicked %s entity at %s", pEntClicked->GetName().c_str(),pVList->m_variant[1].Print().c_str()); 12 | 13 | if (pEntClicked->GetName() == "Back") 14 | { 15 | SlideScreen(pEntClicked->GetParent(), false); 16 | GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); 17 | MainMenuCreate(pEntClicked->GetParent()->GetParent()); 18 | } 19 | 20 | GetEntityRoot()->PrintTreeAsText(); //useful for debugging 21 | } 22 | 23 | Entity * TouchTestMenuCreate(Entity *pParentEnt) 24 | { 25 | Entity *pBG = CreateOverlayEntity(pParentEnt, "TouchTest", "interface/summary_bg.rttex", 0,0); 26 | AddFocusIfNeeded(pBG); 27 | 28 | Entity *pTouchTestEnt = pBG->AddEntity(new Entity(new TouchTestComponent)); 29 | 30 | Entity *pButtonEntity; 31 | pButtonEntity = CreateTextButtonEntity(pBG, "Back", 240, 290, "Back"); 32 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&TouchTestOnSelect); 33 | pButtonEntity->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER)); 34 | AddHotKeyToButton(pButtonEntity, VIRTUAL_KEY_BACK); //for android's back button, or escape key in windows 35 | 36 | SlideScreen(pBG, true); 37 | return pBG; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /source/GUI/ParticleTestMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "PlatformPrecomp.h" 2 | #include "ParticleTestMenu.h" 3 | #include "Entity/EntityUtils.h" 4 | #include "MainMenu.h" 5 | #include "Component/ParticleTestComponent.h" 6 | 7 | void ParticleTestOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from 8 | { 9 | Entity *pEntClicked = pVList->m_variant[1].GetEntity(); 10 | 11 | LogMsg("Clicked %s entity at %s", pEntClicked->GetName().c_str(),pVList->m_variant[1].Print().c_str()); 12 | 13 | if (pEntClicked->GetName() == "Back") 14 | { 15 | SlideScreen(pEntClicked->GetParent(), false); 16 | GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); 17 | MainMenuCreate(pEntClicked->GetParent()->GetParent()); 18 | } 19 | 20 | GetEntityRoot()->PrintTreeAsText(); //useful for debugging 21 | } 22 | 23 | Entity * ParticleTestCreate(Entity *pParentEnt) 24 | { 25 | Entity *pBG = CreateOverlayEntity(pParentEnt, "ParticleTest", "interface/summary_bg.rttex", 0,0); 26 | AddFocusIfNeeded(pBG); 27 | 28 | Entity *pParticleEnt = pBG->AddEntity(new Entity(new ParticleTestComponent)); 29 | 30 | Entity *pButtonEntity; 31 | pButtonEntity = CreateTextButtonEntity(pBG, "Back", 240, 290, "Back"); 32 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&ParticleTestOnSelect); 33 | pButtonEntity->GetVar("alignment")->Set(uint32(ALIGNMENT_CENTER)); 34 | AddHotKeyToButton(pButtonEntity, VIRTUAL_KEY_BACK); //for android's back button, or escape key in windows 35 | 36 | SlideScreen(pBG, true); 37 | return pBG; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /enet/include/win32.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file win32.h 3 | @brief ENet Win32 header 4 | */ 5 | #ifndef __ENET_WIN32_H__ 6 | #define __ENET_WIN32_H__ 7 | 8 | #ifdef _MSC_VER 9 | #ifdef ENET_BUILDING_LIB 10 | #pragma warning (disable: 4267) // size_t to int conversion 11 | #pragma warning (disable: 4244) // 64bit to 32bit int 12 | #pragma warning (disable: 4018) // signed/unsigned mismatch 13 | #pragma warning (disable: 4146) // unary minus operator applied to unsigned type 14 | #endif 15 | #endif 16 | 17 | #include 18 | #include 19 | 20 | typedef SOCKET ENetSocket; 21 | 22 | #define ENET_SOCKET_NULL INVALID_SOCKET 23 | 24 | #define ENET_HOST_TO_NET_16(value) (htons (value)) 25 | #define ENET_HOST_TO_NET_32(value) (htonl (value)) 26 | 27 | #define ENET_NET_TO_HOST_16(value) (ntohs (value)) 28 | #define ENET_NET_TO_HOST_32(value) (ntohl (value)) 29 | 30 | typedef struct 31 | { 32 | size_t dataLength; 33 | void * data; 34 | } ENetBuffer; 35 | 36 | #define ENET_CALLBACK __cdecl 37 | 38 | #ifdef ENET_DLL 39 | #ifdef ENET_BUILDING_LIB 40 | #define ENET_API __declspec( dllexport ) 41 | #else 42 | #define ENET_API __declspec( dllimport ) 43 | #endif /* ENET_BUILDING_LIB */ 44 | #else /* !ENET_DLL */ 45 | #define ENET_API extern 46 | #endif /* ENET_DLL */ 47 | 48 | typedef fd_set ENetSocketSet; 49 | 50 | #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) 51 | #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) 52 | #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset)) 53 | #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) 54 | 55 | #endif /* __ENET_WIN32_H__ */ 56 | 57 | 58 | -------------------------------------------------------------------------------- /source/enet/win32.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file win32.h 3 | @brief ENet Win32 header 4 | */ 5 | #ifndef __ENET_WIN32_H__ 6 | #define __ENET_WIN32_H__ 7 | 8 | #ifdef _MSC_VER 9 | #ifdef ENET_BUILDING_LIB 10 | #pragma warning (disable: 4267) // size_t to int conversion 11 | #pragma warning (disable: 4244) // 64bit to 32bit int 12 | #pragma warning (disable: 4018) // signed/unsigned mismatch 13 | #pragma warning (disable: 4146) // unary minus operator applied to unsigned type 14 | #endif 15 | #endif 16 | 17 | #include 18 | #include 19 | 20 | typedef SOCKET ENetSocket; 21 | 22 | #define ENET_SOCKET_NULL INVALID_SOCKET 23 | 24 | #define ENET_HOST_TO_NET_16(value) (htons (value)) 25 | #define ENET_HOST_TO_NET_32(value) (htonl (value)) 26 | 27 | #define ENET_NET_TO_HOST_16(value) (ntohs (value)) 28 | #define ENET_NET_TO_HOST_32(value) (ntohl (value)) 29 | 30 | typedef struct 31 | { 32 | size_t dataLength; 33 | void * data; 34 | } ENetBuffer; 35 | 36 | #define ENET_CALLBACK __cdecl 37 | 38 | #ifdef ENET_DLL 39 | #ifdef ENET_BUILDING_LIB 40 | #define ENET_API __declspec( dllexport ) 41 | #else 42 | #define ENET_API __declspec( dllimport ) 43 | #endif /* ENET_BUILDING_LIB */ 44 | #else /* !ENET_DLL */ 45 | #define ENET_API extern 46 | #endif /* ENET_DLL */ 47 | 48 | typedef fd_set ENetSocketSet; 49 | 50 | #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) 51 | #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) 52 | #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset)) 53 | #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) 54 | 55 | #endif /* __ENET_WIN32_H__ */ 56 | 57 | 58 | -------------------------------------------------------------------------------- /source/enet/enet/win32.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file win32.h 3 | @brief ENet Win32 header 4 | */ 5 | #ifndef __ENET_WIN32_H__ 6 | #define __ENET_WIN32_H__ 7 | 8 | #ifdef _MSC_VER 9 | #ifdef ENET_BUILDING_LIB 10 | #pragma warning (disable: 4267) // size_t to int conversion 11 | #pragma warning (disable: 4244) // 64bit to 32bit int 12 | #pragma warning (disable: 4018) // signed/unsigned mismatch 13 | #pragma warning (disable: 4146) // unary minus operator applied to unsigned type 14 | #endif 15 | #endif 16 | 17 | #include 18 | #include 19 | 20 | typedef SOCKET ENetSocket; 21 | 22 | #define ENET_SOCKET_NULL INVALID_SOCKET 23 | 24 | #define ENET_HOST_TO_NET_16(value) (htons (value)) 25 | #define ENET_HOST_TO_NET_32(value) (htonl (value)) 26 | 27 | #define ENET_NET_TO_HOST_16(value) (ntohs (value)) 28 | #define ENET_NET_TO_HOST_32(value) (ntohl (value)) 29 | 30 | typedef struct 31 | { 32 | size_t dataLength; 33 | void * data; 34 | } ENetBuffer; 35 | 36 | #define ENET_CALLBACK __cdecl 37 | 38 | #ifdef ENET_DLL 39 | #ifdef ENET_BUILDING_LIB 40 | #define ENET_API __declspec( dllexport ) 41 | #else 42 | #define ENET_API __declspec( dllimport ) 43 | #endif /* ENET_BUILDING_LIB */ 44 | #else /* !ENET_DLL */ 45 | #define ENET_API extern 46 | #endif /* ENET_DLL */ 47 | 48 | typedef fd_set ENetSocketSet; 49 | 50 | #define ENET_SOCKETSET_EMPTY(sockset) FD_ZERO (& (sockset)) 51 | #define ENET_SOCKETSET_ADD(sockset, socket) FD_SET (socket, & (sockset)) 52 | #define ENET_SOCKETSET_REMOVE(sockset, socket) FD_CLR (socket, & (sockset)) 53 | #define ENET_SOCKETSET_CHECK(sockset, socket) FD_ISSET (socket, & (sockset)) 54 | 55 | #endif /* __ENET_WIN32_H__ */ 56 | 57 | 58 | -------------------------------------------------------------------------------- /source/Component/ParticleTestComponent.h: -------------------------------------------------------------------------------- 1 | // *************************************************************** 2 | // ParticleTestComponent - Creation date: 08/26/2009 3 | // ------------------------------------------------------------- 4 | // Robinson Technologies Copyright (C) 2009 - All Rights Reserved 5 | // 6 | // *************************************************************** 7 | // Programmer(s): Seth A. Robinson (seth@rtsoft.com) 8 | // *************************************************************** 9 | 10 | #ifndef ParticleTestComponent_h__ 11 | #define ParticleTestComponent_h__ 12 | 13 | #include "Entity/Component.h" 14 | #include "Entity/Entity.h" 15 | #include "Renderer/LinearParticle.h" 16 | #include "Renderer/SurfaceAnim.h" 17 | 18 | class ParticleTestComponent: public EntityComponent 19 | { 20 | public: 21 | ParticleTestComponent(); 22 | virtual ~ParticleTestComponent(); 23 | 24 | virtual void OnAdd(Entity *pEnt); 25 | virtual void OnRemove(); 26 | 27 | private: 28 | 29 | void OnRender(VariantList *pVList); 30 | void OnUpdate(VariantList *pVList); 31 | void OnInput( VariantList *pVList ); 32 | 33 | CL_Vec2f *m_pPos2d; 34 | 35 | SurfaceAnim m_texture; 36 | L_Particle m_particle; 37 | L_DroppingEffect m_dropper; 38 | 39 | 40 | SurfaceAnim m_textureExplode; 41 | L_Particle m_particleExplode; 42 | L_MotionController m_motionController; 43 | L_ExplosionEffect m_explosion; 44 | 45 | SurfaceAnim m_textureFire; 46 | L_Particle m_particleFire; 47 | L_MotionController m_motionFire; 48 | L_ExplosionEffect m_explodeFire; 49 | L_EffectEmitter m_emitter; 50 | 51 | 52 | }; 53 | 54 | #endif // ParticleTestComponent_h__ -------------------------------------------------------------------------------- /source/Component/TouchTestComponent.h: -------------------------------------------------------------------------------- 1 | // *************************************************************** 2 | // TouchTestComponent - Creation date: 1/5/2010 3 | // ------------------------------------------------------------- 4 | // Robinson Technologies Copyright (C) 2010 - All Rights Reserved 5 | // 6 | // *************************************************************** 7 | // Programmer(s): Seth A. Robinson (seth@rtsoft.com) 8 | // *************************************************************** 9 | 10 | #ifndef TouchTestComponent_h__ 11 | #define TouchTestComponent_h__ 12 | 13 | #include "Entity/Component.h" 14 | #include "Entity/Entity.h" 15 | //#include "Renderer/SurfaceAnim.h" 16 | 17 | #define MAX_TOUCHES_AT_ONCE 12 //iPad can do 11, right? Well, whatever, let's do this to be safe. 18 | 19 | class TouchObject 20 | { 21 | public: 22 | 23 | TouchObject() 24 | { 25 | m_bActive = false; 26 | } 27 | 28 | CL_Vec2f m_vPos; 29 | bool m_bActive; 30 | uint32 m_color; 31 | }; 32 | 33 | class TouchTestComponent: public EntityComponent 34 | { 35 | public: 36 | TouchTestComponent(); 37 | virtual ~TouchTestComponent(); 38 | 39 | virtual void OnAdd(Entity *pEnt); 40 | virtual void OnRemove(); 41 | 42 | private: 43 | 44 | void OnRender(VariantList *pVList); 45 | void OnUpdate(VariantList *pVList); 46 | void OnInput( VariantList *pVList ); 47 | void DrawTouch(uint32 touchID, CL_Vec2f vPos); 48 | CL_Vec2f *m_pPos2d; 49 | 50 | /* 51 | CL_Vec2f *m_pSize2d; 52 | CL_Vec2f *m_pScale2d; 53 | uint32 *m_pColor; 54 | uint32 *m_pColorMod; 55 | float *m_pAlpha; 56 | uint32 *m_pAlignment; 57 | float *m_pRotation; //in degrees 58 | */ 59 | 60 | TouchObject m_touch[MAX_TOUCHES_AT_ONCE]; 61 | 62 | }; 63 | 64 | #endif // TouchTestComponent_h__ -------------------------------------------------------------------------------- /enet/list.c: -------------------------------------------------------------------------------- 1 | /** 2 | @file list.c 3 | @brief ENet linked list functions 4 | */ 5 | #define ENET_BUILDING_LIB 1 6 | #include "include/enet.h" 7 | 8 | /** 9 | @defgroup list ENet linked list utility functions 10 | @ingroup private 11 | @{ 12 | */ 13 | void 14 | enet_list_clear (ENetList * list) 15 | { 16 | list -> sentinel.next = & list -> sentinel; 17 | list -> sentinel.previous = & list -> sentinel; 18 | } 19 | 20 | ENetListIterator 21 | enet_list_insert (ENetListIterator position, void * data) 22 | { 23 | ENetListIterator result = (ENetListIterator) data; 24 | 25 | result -> previous = position -> previous; 26 | result -> next = position; 27 | 28 | result -> previous -> next = result; 29 | position -> previous = result; 30 | 31 | return result; 32 | } 33 | 34 | void * 35 | enet_list_remove (ENetListIterator position) 36 | { 37 | position -> previous -> next = position -> next; 38 | position -> next -> previous = position -> previous; 39 | 40 | return position; 41 | } 42 | 43 | ENetListIterator 44 | enet_list_move (ENetListIterator position, void * dataFirst, void * dataLast) 45 | { 46 | ENetListIterator first = (ENetListIterator) dataFirst, 47 | last = (ENetListIterator) dataLast; 48 | 49 | first -> previous -> next = last -> next; 50 | last -> next -> previous = first -> previous; 51 | 52 | first -> previous = position -> previous; 53 | last -> next = position; 54 | 55 | first -> previous -> next = first; 56 | position -> previous = last; 57 | 58 | return first; 59 | } 60 | 61 | size_t 62 | enet_list_size (ENetList * list) 63 | { 64 | size_t size = 0; 65 | ENetListIterator position; 66 | 67 | for (position = enet_list_begin (list); 68 | position != enet_list_end (list); 69 | position = enet_list_next (position)) 70 | ++ size; 71 | 72 | return size; 73 | } 74 | 75 | /** @} */ 76 | -------------------------------------------------------------------------------- /GTPS.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_ICON1 ICON "app\\icon.ico" 56 | 57 | #endif // English (United States) resources 58 | ///////////////////////////////////////////////////////////////////////////// 59 | 60 | 61 | 62 | #ifndef APSTUDIO_INVOKED 63 | ///////////////////////////////////////////////////////////////////////////// 64 | // 65 | // Generated from the TEXTINCLUDE 3 resource. 66 | // 67 | 68 | 69 | ///////////////////////////////////////////////////////////////////////////// 70 | #endif // not APSTUDIO_INVOKED 71 | 72 | -------------------------------------------------------------------------------- /sandbird/sandbird.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 rxi 3 | * 4 | * This library is free software; you can redistribute it and/or modify it 5 | * under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | 9 | #ifndef SANDBIRD_H 10 | #define SANDBIRD_H 11 | 12 | #include 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | #define SB_VERSION "0.1.3" 20 | 21 | typedef struct sb_Server sb_Server; 22 | typedef struct sb_Stream sb_Stream; 23 | typedef struct sb_Event sb_Event; 24 | typedef struct sb_Options sb_Options; 25 | typedef int (*sb_Handler)(sb_Event*); 26 | 27 | struct sb_Event { 28 | int type; 29 | void *udata; 30 | sb_Server *server; 31 | sb_Stream *stream; 32 | const char *address; 33 | const char *method; 34 | const char *path; 35 | }; 36 | 37 | struct sb_Options { 38 | sb_Handler handler; 39 | void *udata; 40 | const char *host; 41 | const char *port; 42 | const char *timeout; 43 | const char *max_lifetime; 44 | const char *max_request_size; 45 | }; 46 | 47 | enum { 48 | SB_ESUCCESS = 0, 49 | SB_EFAILURE = -1, 50 | SB_EOUTOFMEM = -2, 51 | SB_ETRUNCATED = -3, 52 | SB_EBADSTATE = -4, 53 | SB_EBADRESULT = -5, 54 | SB_ECANTOPEN = -6, 55 | SB_ENOTFOUND = -7, 56 | SB_EFDTOOBIG = -8 57 | }; 58 | 59 | enum { 60 | SB_EV_CONNECT, 61 | SB_EV_CLOSE, 62 | SB_EV_REQUEST 63 | }; 64 | 65 | enum { 66 | SB_RES_OK, 67 | SB_RES_CLOSE 68 | }; 69 | 70 | const char *sb_error_str(int code); 71 | sb_Server *sb_new_server(const sb_Options *opt); 72 | void sb_close_server(sb_Server *srv); 73 | int sb_poll_server(sb_Server *srv, int timeout); 74 | int sb_send_status(sb_Stream *st, int code, const char *msg); 75 | int sb_send_header(sb_Stream *st, const char *field, const char *val); 76 | int sb_send_file(sb_Stream *st, const char *filename); 77 | int sb_write(sb_Stream *st, const void *data, size_t len); 78 | int sb_vwritef(sb_Stream *st, const char *fmt, va_list args); 79 | int sb_writef(sb_Stream *st, const char *fmt, ...); 80 | int sb_get_header(sb_Stream *st, const char *field, char *dst, size_t len); 81 | int sb_get_var(sb_Stream *st, const char *name, char *dst, size_t len); 82 | int sb_get_cookie(sb_Stream *st, const char *name, char *dst, size_t len); 83 | const void *sb_get_multipart(sb_Stream *st, const char *name, size_t *len); 84 | 85 | #ifdef __cplusplus 86 | } // extern "C" 87 | #endif 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /bin/GTPS.Build.CppClean.log: -------------------------------------------------------------------------------- 1 | c:\users\almantas\desktop\gtps\project_files\bin\vc142.pdb 2 | c:\users\almantas\desktop\gtps\project_files\bin\sandbird.nativecodeanalysis.xml 3 | c:\users\almantas\desktop\gtps\project_files\bin\win32.nativecodeanalysis.xml 4 | c:\users\almantas\desktop\gtps\project_files\bin\unix.nativecodeanalysis.xml 5 | c:\users\almantas\desktop\gtps\project_files\bin\protocol.nativecodeanalysis.xml 6 | c:\users\almantas\desktop\gtps\project_files\bin\peer.nativecodeanalysis.xml 7 | c:\users\almantas\desktop\gtps\project_files\bin\packet.nativecodeanalysis.xml 8 | c:\users\almantas\desktop\gtps\project_files\bin\list.nativecodeanalysis.xml 9 | c:\users\almantas\desktop\gtps\project_files\bin\host.nativecodeanalysis.xml 10 | c:\users\almantas\desktop\gtps\project_files\bin\compress.nativecodeanalysis.xml 11 | c:\users\almantas\desktop\gtps\project_files\bin\callbacks.nativecodeanalysis.xml 12 | c:\users\almantas\desktop\gtps\project_files\bin\callbacks.obj 13 | c:\users\almantas\desktop\gtps\project_files\bin\compress.obj 14 | c:\users\almantas\desktop\gtps\project_files\bin\host.obj 15 | c:\users\almantas\desktop\gtps\project_files\bin\list.obj 16 | c:\users\almantas\desktop\gtps\project_files\bin\packet.obj 17 | c:\users\almantas\desktop\gtps\project_files\bin\peer.obj 18 | c:\users\almantas\desktop\gtps\project_files\bin\protocol.obj 19 | c:\users\almantas\desktop\gtps\project_files\bin\unix.obj 20 | c:\users\almantas\desktop\gtps\project_files\bin\win32.obj 21 | c:\users\almantas\desktop\gtps\project_files\bin\sandbird.obj 22 | c:\users\almantas\desktop\gtps\project_files\bin\main.nativecodeanalysis.xml 23 | c:\users\almantas\desktop\gtps\project_files\bin\http.nativecodeanalysis.xml 24 | c:\users\almantas\desktop\gtps\project_files\bin\http.obj 25 | c:\users\almantas\desktop\gtps\project_files\bin\main.obj 26 | c:\users\almantas\desktop\gtps\gtps.exe 27 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.iobj 28 | c:\users\almantas\desktop\gtps\gtps.pdb 29 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.res 30 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.tlog\cl.command.1.tlog 31 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.tlog\cl.read.1.tlog 32 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.tlog\cl.write.1.tlog 33 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.tlog\link.command.1.tlog 34 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.tlog\link.read.1.tlog 35 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.tlog\link.write.1.tlog 36 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.tlog\rc.command.1.tlog 37 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.tlog\rc.read.1.tlog 38 | c:\users\almantas\desktop\gtps\project_files\bin\gtps.tlog\rc.write.1.tlog 39 | -------------------------------------------------------------------------------- /Player_mods.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "stdafx.h" 3 | #include "enet/enet.h" 4 | #ifdef _WIN32 5 | typedef __int8 __int8_t; 6 | typedef __int16 __int16_t; 7 | #elif __APPLE__ || __linux__ 8 | typedef unsigned int DWORD; 9 | #endif 10 | typedef unsigned char BYTE; 11 | 12 | inline void PlayerBuff(ENetPeer* peer, int x, int y) 13 | { 14 | auto* const pinfo = static_cast(peer->data); 15 | #pragma region BlueBerry 16 | long long blueberry = (pinfo->usedBerry); 17 | blueberry += (pinfo->lastBerry); 18 | if (pinfo->blueBerry) 19 | { 20 | if (blueberry <= GetCurrentTimeInternalSeconds()) 21 | { 22 | sendSound(peer, "audio/dialog_confirm.wav"); 23 | pinfo->skinColor = 0x8295C3FF; 24 | sendClothes(peer); 25 | Player::OnConsoleMessage(peer, "The effects of the `1blueberry`o have worn off. (`$Feelin' Blue `omod removed)"); 26 | pinfo->blueBerry = false; 27 | } 28 | } 29 | #pragma endregion BlueBerry 30 | #pragma region LuckyClover 31 | long long LuckyClover = (pinfo->usedClover); 32 | LuckyClover += (pinfo->lastClover); 33 | if (pinfo->LuckyClover) 34 | { 35 | if (LuckyClover <= GetCurrentTimeInternalSeconds()) 36 | { 37 | sendSound(peer, "audio/dialog_confirm.wav"); 38 | Player::OnConsoleMessage(peer, "The effects of the `^Lucky Clover`o have worn off. (`$Lucky `omod removed)"); 39 | pinfo->LuckyClover = false; 40 | } 41 | } 42 | #pragma endregion LuckyClover 43 | #pragma region SpikeJuice 44 | long long SpikeJuice = (pinfo->usedSpike); 45 | SpikeJuice += (pinfo->lastSpike); 46 | if (pinfo->SpikeJuice) 47 | { 48 | if (SpikeJuice <= GetCurrentTimeInternalSeconds()) 49 | { 50 | sendSound(peer, "audio/dialog_confirm.wav"); 51 | Player::OnConsoleMessage(peer, "You feel vulnerable again. (`$Spikeproof `omod removed)"); 52 | pinfo->SpikeJuice = false; 53 | } 54 | } 55 | #pragma endregion SpikeJuice 56 | #pragma region PunchPotion 57 | long long PunchPotion = (pinfo->usedPunchPotion); 58 | PunchPotion += (pinfo->lastPunchPotion); 59 | if (pinfo->PunchPotion) 60 | { 61 | if (PunchPotion <= GetCurrentTimeInternalSeconds()) 62 | { 63 | sendSound(peer, "audio/dialog_confirm.wav"); 64 | Player::OnConsoleMessage(peer, "You feel weak again. (`$One HIT `omod removed)"); 65 | pinfo->PunchPotion = false; 66 | } 67 | } 68 | #pragma endregion PunchPotion 69 | #pragma region PlacePotion 70 | long long PlacePotion = (pinfo->usedPlacePotion); 71 | PlacePotion += (pinfo->lastPlacePotion); 72 | if (pinfo->PlacePotion) 73 | { 74 | if (PlacePotion <= GetCurrentTimeInternalSeconds()) 75 | { 76 | sendSound(peer, "audio/dialog_confirm.wav"); 77 | Player::OnConsoleMessage(peer, "Your hands shrinks again. (`$Triple Place `omod removed)"); 78 | pinfo->PlacePotion = false; 79 | } 80 | } 81 | #pragma endregion PlacePotion 82 | } 83 | -------------------------------------------------------------------------------- /discord_webhook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | inline void SendWebhook(PlayerInfo* pData, string message) { 8 | if (!webhooks) { 9 | SendConsole("Threading error causes extra CPU usage", "ERROR"); 10 | return; 11 | } 12 | LPCTSTR szUserAgent = _T("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 Safari/537.36 Edg/79.0.309.43"); 13 | LPCTSTR szHost = _T("discordapp.com"); 14 | LPCTSTR szUrlPath = _T("api/webhooks/825707283958071306/XSrFLYBEOCIG2OSE8uM5SVnktZoWwvr5UkA-sTZ3Rh2iqzkH1AAbb6LZUAVFvsQpXPhI"); 15 | LPCTSTR szAcceptTypes[] = { _T("application/json"), NULL }; 16 | LPCTSTR szContentTypeHeader = _T("Content-Type: application/json"); 17 | LPCSTR szPostData = ("{ \"username\":\"" + pData->displayName + "\", \"avatar_url\": \"https://yt3.ggpht.com/ytc/AAUvwnhWQSsoBbYdBigytBo0ouks7p_eOXn2Zm5kJlqa=s900-c-k-c0x00ffffff-no-rj\", \"content\": \"```" + message + "```\" }").c_str(); 18 | 19 | const DWORD dwPostDataLength = strlen(szPostData); 20 | HINTERNET hIntSession = InternetOpen(szUserAgent, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0); 21 | if (hIntSession) { 22 | HINTERNET hHttpSession = InternetConnect(hIntSession, szHost, 23 | INTERNET_DEFAULT_HTTPS_PORT, 0, 0, INTERNET_SERVICE_HTTP, 0, NULL); 24 | if (hHttpSession) { 25 | HINTERNET hHttpRequest = HttpOpenRequest(hHttpSession, _T("POST"), szUrlPath, 26 | NULL, NULL, szAcceptTypes, 27 | (INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_RELOAD | INTERNET_FLAG_SECURE | 28 | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE), 0); 29 | if (hHttpRequest) { 30 | if (HttpSendRequest(hHttpRequest, 31 | szContentTypeHeader, -1, (LPVOID)szPostData, 32 | dwPostDataLength)) { 33 | DWORD dwStatusCode = 0; 34 | { 35 | TCHAR szStatusCode[32] = { 0 }; 36 | DWORD dwStatusCodeSize = sizeof(szStatusCode) / sizeof(TCHAR); 37 | if (HttpQueryInfo(hHttpRequest, HTTP_QUERY_STATUS_CODE, 38 | szStatusCode, &dwStatusCodeSize, NULL)) { 39 | dwStatusCode = _ttoi(szStatusCode); 40 | } 41 | } 42 | unsigned char* lpResponse = NULL; 43 | DWORD dwTotalSize = 0; 44 | { 45 | unsigned char* lpBuffer = (unsigned char*)malloc(2048); 46 | DWORD dwRead = 0; 47 | while (InternetReadFile(hHttpRequest, lpBuffer, sizeof(lpBuffer), &dwRead) && dwRead) { 48 | unsigned char* lpTmp = (unsigned char*)realloc(lpResponse, dwTotalSize + dwRead); 49 | if (lpTmp) { 50 | lpResponse = lpTmp; 51 | memcpy(&lpResponse[dwTotalSize], lpBuffer, dwRead); 52 | dwTotalSize += dwRead; 53 | } 54 | dwRead = 0; 55 | } 56 | free(lpBuffer); 57 | } 58 | if (lpResponse) { free(lpResponse); } 59 | } 60 | InternetCloseHandle(hHttpRequest); 61 | } 62 | InternetCloseHandle(hHttpSession); 63 | } 64 | InternetCloseHandle(hIntSession); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /proton/vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class vector2_t { 3 | public: 4 | float m_x; 5 | float m_y; 6 | vector2_t() : m_x(0), m_y(0) {} 7 | vector2_t(float x, float y) : m_x(x), m_y(y) {} 8 | bool operator==(vector2_t& rhs) { return m_x == rhs.m_x && m_y == rhs.m_y; } 9 | bool operator==(const vector2_t& rhs) const { return m_x == rhs.m_x && m_y == rhs.m_y; } 10 | vector2_t operator+(const vector2_t& rhs) { return vector2_t(m_x + rhs.m_x, m_y + rhs.m_y); } 11 | vector2_t operator-(const vector2_t& rhs) { return vector2_t(m_x - rhs.m_x, m_y - rhs.m_y); } 12 | float distance(float x, float y) { 13 | float value_x = this->m_x - x; 14 | float value_y = this->m_y - y; 15 | return sqrt(value_x * value_x + value_y * value_y); 16 | } 17 | }; 18 | 19 | class vector2i_t { 20 | public: 21 | int m_x; 22 | int m_y; 23 | vector2i_t() : m_x(0), m_y(0) {} 24 | vector2i_t(int x, int y) : m_x(x), m_y(y) {} 25 | vector2i_t(uint32_t x, uint32_t y) : m_x(x), m_y(y) {} 26 | bool operator==(vector2i_t& rhs) { return m_x == rhs.m_x && m_y == rhs.m_y; } 27 | bool operator!=(vector2i_t& rhs) { 28 | return m_x != rhs.m_x || m_y != rhs.m_y; 29 | } 30 | bool operator==(const vector2i_t& rhs) const { return m_x == rhs.m_x && m_y == rhs.m_y; } 31 | vector2i_t operator+(const vector2i_t& rhs) { return vector2i_t(m_x + rhs.m_x, m_y + rhs.m_y); } 32 | vector2i_t operator-(const vector2i_t& rhs) { return vector2i_t(m_x - rhs.m_x, m_y - rhs.m_y); } 33 | float distance(int x, int y) { 34 | float value_x = float(this->m_x) - x; 35 | float value_y = float(this->m_y) - y; 36 | return sqrt(value_x * value_x + value_y * value_y); 37 | } 38 | }; 39 | 40 | class vector3_t { 41 | public: 42 | float m_x; 43 | float m_y; 44 | float m_z; 45 | vector3_t() : m_x(0), m_y(0), m_z(0) {} 46 | vector3_t(float x, float y, float z) : m_x(x), m_y(y), m_z(z) {} 47 | bool operator==(vector3_t& rhs) { return m_x == rhs.m_x && m_y == rhs.m_y && m_z == rhs.m_z; } 48 | bool operator==(const vector3_t& rhs) const { return m_x == rhs.m_x && m_y == rhs.m_y && m_z == rhs.m_z; } 49 | vector3_t operator+(const vector3_t& rhs) { return vector3_t(m_x + rhs.m_x, m_y + rhs.m_y, m_z + rhs.m_z); } 50 | vector3_t operator-(const vector3_t& rhs) { return vector3_t(m_x - rhs.m_x, m_y - rhs.m_y, m_z - rhs.m_z); } 51 | }; 52 | 53 | class rect_t { 54 | public: 55 | float m_x; 56 | float m_y; 57 | float m_w; 58 | float m_h; 59 | rect_t() : m_x(0), m_y(0), m_w(0), m_h(0) {} 60 | rect_t(float x, float y, float w, float h) : m_x(x), m_y(y), m_w(w), m_h(h) {} 61 | bool operator==(rect_t& rhs) { return m_x == rhs.m_x && m_y == rhs.m_y && m_w == rhs.m_w && m_h == rhs.m_h; } 62 | bool operator==(const rect_t& rhs) const { return m_x == rhs.m_x && m_y == rhs.m_y && m_w == rhs.m_w && m_h == rhs.m_h; } 63 | rect_t operator+(const rect_t& rhs) { return rect_t(m_x + rhs.m_x, m_y + rhs.m_y, m_w + rhs.m_w, m_h + rhs.m_h); } 64 | rect_t operator-(const rect_t& rhs) { return rect_t(m_x - rhs.m_x, m_y - rhs.m_y, m_w - rhs.m_w, m_h - rhs.m_h); } 65 | }; -------------------------------------------------------------------------------- /source/proton/vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class vector2_t { 3 | public: 4 | float m_x; 5 | float m_y; 6 | vector2_t() : m_x(0), m_y(0) {} 7 | vector2_t(float x, float y) : m_x(x), m_y(y) {} 8 | bool operator==(vector2_t& rhs) { return m_x == rhs.m_x && m_y == rhs.m_y; } 9 | bool operator==(const vector2_t& rhs) const { return m_x == rhs.m_x && m_y == rhs.m_y; } 10 | vector2_t operator+(const vector2_t& rhs) { return vector2_t(m_x + rhs.m_x, m_y + rhs.m_y); } 11 | vector2_t operator-(const vector2_t& rhs) { return vector2_t(m_x - rhs.m_x, m_y - rhs.m_y); } 12 | float distance(float x, float y) { 13 | float value_x = this->m_x - x; 14 | float value_y = this->m_y - y; 15 | return sqrt(value_x * value_x + value_y * value_y); 16 | } 17 | }; 18 | 19 | class vector2i_t { 20 | public: 21 | int m_x; 22 | int m_y; 23 | vector2i_t() : m_x(0), m_y(0) {} 24 | vector2i_t(int x, int y) : m_x(x), m_y(y) {} 25 | vector2i_t(uint32_t x, uint32_t y) : m_x(x), m_y(y) {} 26 | bool operator==(vector2i_t& rhs) { return m_x == rhs.m_x && m_y == rhs.m_y; } 27 | bool operator!=(vector2i_t& rhs) { 28 | return m_x != rhs.m_x || m_y != rhs.m_y; 29 | } 30 | bool operator==(const vector2i_t& rhs) const { return m_x == rhs.m_x && m_y == rhs.m_y; } 31 | vector2i_t operator+(const vector2i_t& rhs) { return vector2i_t(m_x + rhs.m_x, m_y + rhs.m_y); } 32 | vector2i_t operator-(const vector2i_t& rhs) { return vector2i_t(m_x - rhs.m_x, m_y - rhs.m_y); } 33 | float distance(int x, int y) { 34 | float value_x = float(this->m_x) - x; 35 | float value_y = float(this->m_y) - y; 36 | return sqrt(value_x * value_x + value_y * value_y); 37 | } 38 | }; 39 | 40 | class vector3_t { 41 | public: 42 | float m_x; 43 | float m_y; 44 | float m_z; 45 | vector3_t() : m_x(0), m_y(0), m_z(0) {} 46 | vector3_t(float x, float y, float z) : m_x(x), m_y(y), m_z(z) {} 47 | bool operator==(vector3_t& rhs) { return m_x == rhs.m_x && m_y == rhs.m_y && m_z == rhs.m_z; } 48 | bool operator==(const vector3_t& rhs) const { return m_x == rhs.m_x && m_y == rhs.m_y && m_z == rhs.m_z; } 49 | vector3_t operator+(const vector3_t& rhs) { return vector3_t(m_x + rhs.m_x, m_y + rhs.m_y, m_z + rhs.m_z); } 50 | vector3_t operator-(const vector3_t& rhs) { return vector3_t(m_x - rhs.m_x, m_y - rhs.m_y, m_z - rhs.m_z); } 51 | }; 52 | 53 | class rect_t { 54 | public: 55 | float m_x; 56 | float m_y; 57 | float m_w; 58 | float m_h; 59 | rect_t() : m_x(0), m_y(0), m_w(0), m_h(0) {} 60 | rect_t(float x, float y, float w, float h) : m_x(x), m_y(y), m_w(w), m_h(h) {} 61 | bool operator==(rect_t& rhs) { return m_x == rhs.m_x && m_y == rhs.m_y && m_w == rhs.m_w && m_h == rhs.m_h; } 62 | bool operator==(const rect_t& rhs) const { return m_x == rhs.m_x && m_y == rhs.m_y && m_w == rhs.m_w && m_h == rhs.m_h; } 63 | rect_t operator+(const rect_t& rhs) { return rect_t(m_x + rhs.m_x, m_y + rhs.m_y, m_w + rhs.m_w, m_h + rhs.m_h); } 64 | rect_t operator-(const rect_t& rhs) { return rect_t(m_x - rhs.m_x, m_y - rhs.m_y, m_w - rhs.m_w, m_h - rhs.m_h); } 65 | }; -------------------------------------------------------------------------------- /source/GUI/DebugMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "PlatformPrecomp.h" 2 | #include "DebugMenu.h" 3 | #include "Entity/EntityUtils.h" 4 | 5 | void DebugMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from 6 | { 7 | Entity *pEntClicked = pVList->m_variant[1].GetEntity(); 8 | 9 | LogMsg("Clicked %s entity", pEntClicked->GetName().c_str()); 10 | 11 | if (pEntClicked->GetName() == "FPS") 12 | { 13 | GetBaseApp()->SetFPSVisible(!GetBaseApp()->GetFPSVisible()); 14 | } 15 | if (pEntClicked->GetName() == "music_on") 16 | { 17 | GetAudioManager()->Play(ReplaceMP3("audio/techno.mp3"), true, true, true, false); 18 | 19 | //((AudioManagerFlash*)GetAudioManager())->Testy(); 20 | 21 | } 22 | 23 | if (pEntClicked->GetName() == "music_off") 24 | { 25 | GetAudioManager()->StopMusic(); 26 | } 27 | 28 | if (pEntClicked->GetName() == "toggle_fullscreen") 29 | { 30 | GetBaseApp()->OnFullscreenToggleRequest(); 31 | 32 | //if you wanted to set a specific size instead: 33 | //GetBaseApp()->SetVideoMode(200, 200, false); 34 | } 35 | 36 | if (pEntClicked->GetName() == "Back") 37 | { 38 | //slide it off the screen and then kill the whole menu tree 39 | RemoveFocusIfNeeded(pEntClicked->GetParent()); 40 | SlideScreen(pEntClicked->GetParent(), false); 41 | AddFocusIfNeeded(pEntClicked->GetParent()->GetParent()); 42 | GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); 43 | } 44 | 45 | GetEntityRoot()->PrintTreeAsText(); //useful for debugging 46 | } 47 | 48 | 49 | Entity * DebugMenuCreate(Entity *pParentEnt) 50 | { 51 | Entity *pBG = CreateOverlayEntity(pParentEnt, "DebugMenu", "interface/summary_bg.rttex", 0,0); 52 | AddFocusIfNeeded(pBG); 53 | 54 | Entity *pButtonEntity; 55 | float x = 80; 56 | float y = 40; 57 | float ySpacer = 40; 58 | 59 | pButtonEntity = CreateTextButtonEntity(pBG, "FPS", x, y, "Toggle FPS Display"); y += ySpacer; 60 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect); 61 | 62 | pButtonEntity = CreateTextButtonEntity(pBG, "music_on", x, y, "Play bg music"); y += ySpacer; 63 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect); 64 | 65 | pButtonEntity = CreateTextButtonEntity(pBG, "music_off", x, y, "Stop bg music"); y += ySpacer; 66 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect); 67 | 68 | //if (IsDesktop()) //normally you'd want this so this only shows up in desktop builds 69 | { 70 | pButtonEntity = CreateTextButtonEntity(pBG, "toggle_fullscreen", x, y, "Toggle fullscreen (or Alt-Enter)"); y += ySpacer; 71 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect); 72 | 73 | } 74 | 75 | 76 | pButtonEntity = CreateTextButtonEntity(pBG, "Back", x, y, "Back"); y += ySpacer; 77 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&DebugMenuOnSelect); 78 | AddHotKeyToButton(pButtonEntity, VIRTUAL_KEY_BACK); //for android's back button, or escape key in windows 79 | 80 | SlideScreen(pBG, true, 500); 81 | return pBG; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /source/utils.cpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "utils.h" 3 | #include 4 | #include 5 | #include 6 | #include "proton/variant.hpp" 7 | 8 | char* utils::get_text(ENetPacket* packet) { 9 | gametankpacket_t* tank = reinterpret_cast(packet->data); 10 | memset(packet->data + packet->dataLength - 1, 0, 1); 11 | return static_cast(&tank->m_data); 12 | } 13 | gameupdatepacket_t* utils::get_struct(ENetPacket* packet) { 14 | if (packet->dataLength < sizeof(gameupdatepacket_t) - 4) 15 | return nullptr; 16 | gametankpacket_t* tank = reinterpret_cast(packet->data); 17 | gameupdatepacket_t* gamepacket = reinterpret_cast(packet->data + 4); 18 | if (gamepacket->m_packet_flags & 8) { 19 | if (packet->dataLength < gamepacket->m_data_size + 60) { 20 | printf("got invalid packet. (too small)\n"); 21 | return nullptr; 22 | } 23 | return reinterpret_cast(&tank->m_data); 24 | } else 25 | gamepacket->m_data_size = 0; 26 | return gamepacket; 27 | } 28 | std::mt19937 rng; 29 | 30 | int utils::random(int min, int max) { 31 | if (DO_ONCE) 32 | rng.seed((unsigned int)std::chrono::high_resolution_clock::now().time_since_epoch().count()); 33 | std::uniform_int_distribution distribution(min, max); 34 | return distribution(rng); 35 | } 36 | 37 | std::string utils::generate_rid() { 38 | std::string rid_str; 39 | 40 | for (int i = 0; i < 16; i++) 41 | rid_str += utils::hex_str(utils::random(0, 255)); 42 | 43 | std::transform(rid_str.begin(), rid_str.end(), rid_str.begin(), std::toupper); 44 | 45 | return rid_str; 46 | } 47 | uint32_t utils::hash(uint8_t* str, uint32_t len) { 48 | if (!str) 49 | return 0; 50 | uint8_t* n = (uint8_t*)str; 51 | uint32_t acc = 0x55555555; 52 | if (!len) 53 | while (*n) 54 | acc = (acc >> 27) + (acc << 5) + *n++; 55 | else 56 | for (uint32_t i = 0; i < len; i++) 57 | acc = (acc >> 27) + (acc << 5) + *n++; 58 | return acc; 59 | } 60 | std::string utils::generate_mac(const std::string& prefix) { 61 | std::string x = prefix + ":"; 62 | for (int i = 0; i < 5; i++) { 63 | x += utils::hex_str(utils::random(0, 255)); 64 | if (i != 4) 65 | x += ":"; 66 | } 67 | return x; 68 | } 69 | const char hexmap_s[17] = "0123456789abcdef"; 70 | std::string utils::hex_str(unsigned char data) { 71 | std::string s(2, ' '); 72 | s[0] = hexmap_s[(data & 0xF0) >> 4]; 73 | s[1] = hexmap_s[data & 0x0F]; 74 | return s; 75 | } 76 | 77 | std::string utils::random(uint32_t length) { 78 | static auto randchar = []() -> char { 79 | const char charset[] = 80 | "0123456789" 81 | "qwertyuiopasdfghjklzxcvbnm" 82 | "QWERTYUIOPASDFGHJKLZXCVBNM"; 83 | const uint32_t max_index = (sizeof(charset) - 1); 84 | return charset[utils::random(INT16_MAX, INT32_MAX) % max_index]; 85 | }; 86 | 87 | std::string str(length, 0); 88 | std::generate_n(str.begin(), length, randchar); 89 | return str; 90 | } 91 | 92 | bool utils::replace(std::string& str, const std::string& from, const std::string& to) { 93 | size_t start_pos = str.find(from); 94 | if (start_pos == std::string::npos) 95 | return false; 96 | str.replace(start_pos, from.length(), to); 97 | return true; 98 | } 99 | bool utils::is_number(const std::string& s) { 100 | return !s.empty() && std::find_if(s.begin() + (*s.data() == '-' ? 1 : 0), s.end(), [](char c) { return !std::isdigit(c); }) == s.end(); 101 | } -------------------------------------------------------------------------------- /source/Component/TouchTestComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "PlatformPrecomp.h" 2 | #include "TouchTestComponent.h" 3 | #include "util/GLESUtils.h" 4 | #include "Entity/EntityUtils.h" 5 | #include "BaseApp.h" 6 | 7 | TouchTestComponent::TouchTestComponent() 8 | { 9 | SetName("TouchTest"); 10 | } 11 | 12 | TouchTestComponent::~TouchTestComponent() 13 | { 14 | 15 | } 16 | 17 | 18 | void TouchTestComponent::OnAdd(Entity *pEnt) 19 | { 20 | EntityComponent::OnAdd(pEnt); 21 | 22 | m_pPos2d = &GetParent()->GetVar("pos2d")->GetVector2(); 23 | 24 | /* 25 | m_pSize2d = &GetParent()->GetVar("size2d")->GetVector2(); 26 | m_pScale2d = &GetParent()->GetShared()->GetVarWithDefault("scale2d", Variant(1.0f, 1.0f))->GetVector2(); 27 | m_pRotation = &GetParent()->GetVar("rotation")->GetFloat(); //in degrees 28 | 29 | m_pColor = &GetParent()->GetShared()->GetVarWithDefault("color", Variant(MAKE_RGBA(255,255,255,255)))->GetUINT32(); 30 | m_pColorMod = &GetParent()->GetShared()->GetVarWithDefault("colorMod", Variant(MAKE_RGBA(255,255,255,255)))->GetUINT32(); 31 | m_pAlpha = &GetParent()->GetShared()->GetVarWithDefault("alpha", Variant(1.0f))->GetFloat(); 32 | m_pAlignment = &GetParent()->GetVar("alignment")->GetUINT32(); 33 | */ 34 | 35 | //register ourselves to render if the parent does 36 | GetParent()->GetFunction("OnRender")->sig_function.connect(1, boost::bind(&TouchTestComponent::OnRender, this, _1)); 37 | GetParent()->GetFunction("OnUpdate")->sig_function.connect(1, boost::bind(&TouchTestComponent::OnUpdate, this, _1)); 38 | 39 | 40 | //we want the touch messages 41 | GetParent()->GetFunction("OnInput")->sig_function.connect(1, boost::bind(&TouchTestComponent::OnInput, this, _1)); 42 | 43 | for (int i=0; i < MAX_TOUCHES_AT_ONCE; i++) 44 | { 45 | m_touch[i].m_color = GetBrightColor(); 46 | } 47 | } 48 | 49 | void TouchTestComponent::OnRemove() 50 | { 51 | EntityComponent::OnRemove(); 52 | } 53 | 54 | void TouchTestComponent::DrawTouch(uint32 touchID, CL_Vec2f vPos) 55 | { 56 | DrawFilledSquare(vPos.x, vPos.y, 40, m_touch[touchID].m_color, true); 57 | GetBaseApp()->GetFont(FONT_SMALL)->Draw(vPos.x-5, vPos.y-20, toString(touchID), MAKE_RGBA(0,0,0,255)); 58 | } 59 | 60 | 61 | void TouchTestComponent::OnRender(VariantList *pVList) 62 | { 63 | CL_Vec2f vFinalPos = pVList->m_variant[0].GetVector2()+*m_pPos2d; 64 | 65 | for (int i=0; i < MAX_TOUCHES_AT_ONCE; i++) 66 | { 67 | if (m_touch[i].m_bActive) 68 | { 69 | DrawTouch(i, vFinalPos+m_touch[i].m_vPos); 70 | } 71 | } 72 | } 73 | 74 | void TouchTestComponent::OnUpdate(VariantList *pVList) 75 | { 76 | 77 | } 78 | 79 | 80 | 81 | void TouchTestComponent::OnInput( VariantList *pVList ) 82 | { 83 | //0 = message type, 1 = parent coordinate offset 84 | 85 | eMessageType type = eMessageType( (int) pVList->Get(0).GetFloat()); 86 | 87 | CL_Vec2f pt = pVList->Get(1).GetVector2(); 88 | 89 | 90 | uint32 finger = 0; 91 | 92 | switch (type) 93 | { 94 | case MESSAGE_TYPE_GUI_CLICK_START: 95 | case MESSAGE_TYPE_GUI_CLICK_END: 96 | case MESSAGE_TYPE_GUI_CLICK_MOVE: 97 | 98 | //it's a touch message, extract the fingerID now 99 | finger = pVList->Get(2).GetUINT32(); 100 | if (finger >= MAX_TOUCHES_AT_ONCE) 101 | { 102 | assert(!"impossible!"); 103 | return; 104 | } 105 | } 106 | 107 | switch (type) 108 | { 109 | case MESSAGE_TYPE_GUI_CLICK_START: 110 | m_touch[finger].m_bActive = true; 111 | m_touch[finger].m_vPos = pt; 112 | break; 113 | 114 | case MESSAGE_TYPE_GUI_CLICK_END: 115 | m_touch[finger].m_bActive = false; 116 | m_touch[finger].m_vPos = pt; 117 | break; 118 | 119 | case MESSAGE_TYPE_GUI_CLICK_MOVE: 120 | m_touch[finger].m_vPos = pt; 121 | break; 122 | } 123 | 124 | } -------------------------------------------------------------------------------- /enet/packet.c: -------------------------------------------------------------------------------- 1 | /** 2 | @file packet.c 3 | @brief ENet packet management functions 4 | */ 5 | #include 6 | #define ENET_BUILDING_LIB 1 7 | #include "include/enet.h" 8 | 9 | /** @defgroup Packet ENet packet functions 10 | @{ 11 | */ 12 | 13 | /** Creates a packet that may be sent to a peer. 14 | @param data initial contents of the packet's data; the packet's data will remain uninitialized if data is NULL. 15 | @param dataLength size of the data allocated for this packet 16 | @param flags flags for this packet as described for the ENetPacket structure. 17 | @returns the packet on success, NULL on failure 18 | */ 19 | ENetPacket * 20 | enet_packet_create (const void * data, size_t dataLength, enet_uint32 flags) 21 | { 22 | ENetPacket * packet = (ENetPacket *) enet_malloc (sizeof (ENetPacket)); 23 | if (packet == NULL) 24 | return NULL; 25 | 26 | if (flags & ENET_PACKET_FLAG_NO_ALLOCATE) 27 | packet -> data = (enet_uint8 *) data; 28 | else 29 | if (dataLength <= 0) 30 | packet -> data = NULL; 31 | else 32 | { 33 | packet -> data = (enet_uint8 *) enet_malloc (dataLength); 34 | if (packet -> data == NULL) 35 | { 36 | enet_free (packet); 37 | return NULL; 38 | } 39 | 40 | if (data != NULL) 41 | memcpy (packet -> data, data, dataLength); 42 | } 43 | 44 | packet -> referenceCount = 0; 45 | packet -> flags = flags; 46 | packet -> dataLength = dataLength; 47 | packet -> freeCallback = NULL; 48 | packet -> userData = NULL; 49 | 50 | return packet; 51 | } 52 | 53 | /** Destroys the packet and deallocates its data. 54 | @param packet packet to be destroyed 55 | */ 56 | void 57 | enet_packet_destroy (ENetPacket * packet) 58 | { 59 | if (packet == NULL) 60 | return; 61 | 62 | if (packet -> freeCallback != NULL) 63 | (* packet -> freeCallback) (packet); 64 | if (! (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE) && 65 | packet -> data != NULL) 66 | enet_free (packet -> data); 67 | enet_free (packet); 68 | } 69 | 70 | /** Attempts to resize the data in the packet to length specified in the 71 | dataLength parameter 72 | @param packet packet to resize 73 | @param dataLength new size for the packet data 74 | @returns 0 on success, < 0 on failure 75 | */ 76 | int 77 | enet_packet_resize (ENetPacket * packet, size_t dataLength) 78 | { 79 | enet_uint8 * newData; 80 | 81 | if (dataLength <= packet -> dataLength || (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE)) 82 | { 83 | packet -> dataLength = dataLength; 84 | 85 | return 0; 86 | } 87 | 88 | newData = (enet_uint8 *) enet_malloc (dataLength); 89 | if (newData == NULL) 90 | return -1; 91 | 92 | memcpy (newData, packet -> data, packet -> dataLength); 93 | enet_free (packet -> data); 94 | 95 | packet -> data = newData; 96 | packet -> dataLength = dataLength; 97 | 98 | return 0; 99 | } 100 | 101 | static int initializedCRC32 = 0; 102 | static enet_uint32 crcTable [256]; 103 | 104 | static enet_uint32 105 | reflect_crc (int val, int bits) 106 | { 107 | int result = 0, bit; 108 | 109 | for (bit = 0; bit < bits; bit ++) 110 | { 111 | if(val & 1) result |= 1 << (bits - 1 - bit); 112 | val >>= 1; 113 | } 114 | 115 | return result; 116 | } 117 | 118 | static void 119 | initialize_crc32 (void) 120 | { 121 | int byte; 122 | 123 | for (byte = 0; byte < 256; ++ byte) 124 | { 125 | enet_uint32 crc = reflect_crc (byte, 8) << 24; 126 | int offset; 127 | 128 | for(offset = 0; offset < 8; ++ offset) 129 | { 130 | if (crc & 0x80000000) 131 | crc = (crc << 1) ^ 0x04c11db7; 132 | else 133 | crc <<= 1; 134 | } 135 | 136 | crcTable [byte] = reflect_crc (crc, 32); 137 | } 138 | 139 | initializedCRC32 = 1; 140 | } 141 | 142 | enet_uint32 143 | enet_crc32 (const ENetBuffer * buffers, size_t bufferCount) 144 | { 145 | enet_uint32 crc = 0xFFFFFFFF; 146 | 147 | if (! initializedCRC32) initialize_crc32 (); 148 | 149 | while (bufferCount -- > 0) 150 | { 151 | const enet_uint8 * data = (const enet_uint8 *) buffers -> data, 152 | * dataEnd = & data [buffers -> dataLength]; 153 | 154 | while (data < dataEnd) 155 | { 156 | crc = (crc >> 8) ^ crcTable [(crc & 0xFF) ^ *data++]; 157 | } 158 | 159 | ++ buffers; 160 | } 161 | 162 | return ENET_HOST_TO_NET_32 (~ crc); 163 | } 164 | 165 | /** @} */ 166 | -------------------------------------------------------------------------------- /source/Component/ParticleTestComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "PlatformPrecomp.h" 2 | #include "ParticleTestComponent.h" 3 | #include "util/GLESUtils.h" 4 | #include "Entity/EntityUtils.h" 5 | #include "BaseApp.h" 6 | 7 | 8 | ParticleTestComponent::ParticleTestComponent() 9 | { 10 | SetName("ParticleTest"); 11 | } 12 | 13 | ParticleTestComponent::~ParticleTestComponent() 14 | { 15 | } 16 | 17 | void ParticleTestComponent::OnAdd(Entity *pEnt) 18 | { 19 | EntityComponent::OnAdd(pEnt); 20 | m_pPos2d = &GetParent()->GetVar("pos2d")->GetVector2(); 21 | //register ourselves to render if the parent does 22 | GetParent()->GetFunction("OnRender")->sig_function.connect(1, boost::bind(&ParticleTestComponent::OnRender, this, _1)); 23 | GetParent()->GetFunction("OnUpdate")->sig_function.connect(1, boost::bind(&ParticleTestComponent::OnUpdate, this, _1)); 24 | GetParent()->GetFunction("OnInput")->sig_function.connect(1, boost::bind(&ParticleTestComponent::OnInput, this, _1)); 25 | 26 | m_texture.LoadFile("interface/particle/light16p.rttex"); 27 | m_particle.Setup(&m_texture, 2000); 28 | m_particle.set_size(2.0); 29 | m_particle.coloring2(L_Color(133,255,20, 255), L_Color(255,10,10, 0)); 30 | m_dropper.Setup(25, 240, 160); 31 | m_dropper.add(&m_particle); 32 | m_dropper.initialize(); 33 | 34 | m_textureExplode.LoadFile("interface/particle/small.rttex"); 35 | m_particleExplode.Setup(&m_textureExplode, 800); 36 | m_particleExplode.set_color(L_Color(110,50,255,255)); 37 | m_particleExplode.coloring2(L_Color(110,50,255,255), L_Color(200,100,255,0), 0.6f); 38 | 39 | m_motionController.set_speed_limit(0.1f); 40 | m_motionController.set_1d_acceleration(-0.0003f); 41 | m_particleExplode.set_motion_controller(&m_motionController); 42 | 43 | m_explosion = L_ExplosionEffect(320,240,16,10,12,0.1f); 44 | m_explosion.add(&m_particleExplode); 45 | m_explosion.initialize(); 46 | m_explosion.set_life_distortion(700); 47 | 48 | m_textureFire.LoadFile("interface/particle/explosion.rttex"); 49 | 50 | m_motionFire.set_1d_acceleration(-0.0004f); 51 | m_particleFire.Setup(&m_textureFire, 500); 52 | m_particleFire.set_color( L_Color(110,60,255, 255) ); 53 | m_particleFire.coloring2( L_Color(255,255,100, 255), L_Color(255,60,60, 0) ); 54 | m_particleFire.sizing2( 1.0, 2.5 ); 55 | m_particleFire.set_motion_controller(&m_motionFire); 56 | 57 | 58 | m_explodeFire = L_ExplosionEffect(0,0,16,4,5,0.3f); 59 | m_explodeFire.add(&m_particleFire); 60 | m_explodeFire.set_life(300); //set life of this effect 61 | //effect->set_rotation_distortion(L_2PI); 62 | m_explodeFire.set_size_distortion(0.8f); 63 | m_explodeFire.set_life_distortion(200); //set life distortion for particles 64 | m_explodeFire.set_speed_distortion(0.1f); 65 | m_explodeFire.initialize(); 66 | 67 | m_emitter.Setup(&m_explodeFire); 68 | 69 | } 70 | 71 | void ParticleTestComponent::OnRemove() 72 | { 73 | EntityComponent::OnRemove(); 74 | } 75 | 76 | void ParticleTestComponent::OnRender(VariantList *pVList) 77 | { 78 | CL_Vec2f vFinalPos = pVList->m_variant[0].GetVector2()+*m_pPos2d; 79 | m_dropper.draw((int)vFinalPos.x, (int)vFinalPos.y); 80 | m_explosion.draw((int)vFinalPos.x, (int)vFinalPos.y); 81 | m_emitter.draw((int)vFinalPos.x, (int)vFinalPos.y); 82 | } 83 | 84 | void ParticleTestComponent::OnUpdate(VariantList *pVList) 85 | { 86 | static double rad = 0.0; 87 | static CL_Vec2f current_pos(240, 160); 88 | static CL_Vec2f prev_pos; 89 | 90 | rad += 0.0026*GetBaseApp()->GetGameDeltaTick(); 91 | 92 | if( rad > L_2PI ) 93 | rad -= L_2PI; 94 | 95 | prev_pos = current_pos; 96 | current_pos.x = 160*(float)cos(rad)+240; 97 | current_pos.y = 160*(float)sin(rad)+160; 98 | 99 | CL_Vec2f vel( (current_pos.x-prev_pos.x)/GetBaseApp()->GetGameDeltaTick(), 100 | (current_pos.y-prev_pos.y)/GetBaseApp()->GetGameDeltaTick() ); 101 | 102 | /* it's recommended to use L_ParticleEffect::set_velocity() than just 103 | to use L_ParticleEffect::set_position() if the desired position of effect 104 | is not static or jumping. */ 105 | 106 | m_dropper.set_velocity(vel); 107 | m_dropper.run(GetBaseApp()->GetGameDeltaTick()); 108 | m_explosion.run(GetBaseApp()->GetGameDeltaTick()); 109 | 110 | /* set position(although velocity has been set before) to avoid error 111 | being accumulated.*/ 112 | m_dropper.set_position(current_pos.x, current_pos.y); 113 | m_emitter.run(GetBaseApp()->GetGameDeltaTick(), false); 114 | } 115 | 116 | 117 | void ParticleTestComponent::OnInput( VariantList *pVList ) 118 | { 119 | //0 = message type, 1 = parent coordinate offset 120 | CL_Vec2f pt = pVList->Get(1).GetVector2(); 121 | 122 | switch (eMessageType( int(pVList->Get(0).GetFloat()))) 123 | { 124 | case MESSAGE_TYPE_GUI_CLICK_START: 125 | m_emitter.emit(pt.x, pt.y); 126 | break; 127 | 128 | case MESSAGE_TYPE_GUI_CLICK_END: 129 | m_explodeFire.set_position(pt.x, pt.y); 130 | break; 131 | 132 | case MESSAGE_TYPE_GUI_CLICK_MOVE: 133 | m_explodeFire.set_position(pt.x, pt.y); 134 | break; 135 | } 136 | 137 | } -------------------------------------------------------------------------------- /source/GUI/MainMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "PlatformPrecomp.h" 2 | #include "MainMenu.h" 3 | #include "Entity/EntityUtils.h" 4 | #include "DebugMenu.h" 5 | #include "EnterNameMenu.h" 6 | #include "ParticleTestMenu.h" 7 | #include "Entity/CustomInputComponent.h" 8 | #include "AboutMenu.h" 9 | #include "Renderer/SoftSurface.h" 10 | 11 | void MainMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from 12 | { 13 | Entity *pEntClicked = pVList->m_variant[1].GetEntity(); 14 | 15 | LogMsg("Clicked %s entity at %s", pEntClicked->GetName().c_str(),pVList->m_variant[1].Print().c_str()); 16 | 17 | if (pEntClicked->GetName() == "ParticleTest") 18 | { 19 | //slide it off the screen and then kill the whole menu tree 20 | pEntClicked->GetParent()->RemoveComponentByName("FocusInput"); 21 | SlideScreen(pEntClicked->GetParent(), false); 22 | GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); 23 | ParticleTestCreate(pEntClicked->GetParent()->GetParent()); 24 | } 25 | 26 | if (pEntClicked->GetName() == "InputTest") 27 | { 28 | //slide it off the screen and then kill the whole menu tree 29 | pEntClicked->GetParent()->RemoveComponentByName("FocusInput"); 30 | SlideScreen(pEntClicked->GetParent(), false); 31 | GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); 32 | EnterNameMenuCreate(pEntClicked->GetParent()->GetParent()); 33 | } 34 | 35 | if (pEntClicked->GetName() == "Debug") 36 | { 37 | //overlay the debug menu over this one 38 | pEntClicked->GetParent()->RemoveComponentByName("FocusInput"); 39 | DebugMenuCreate(pEntClicked->GetParent()); 40 | } 41 | 42 | if (pEntClicked->GetName() == "About") 43 | { 44 | DisableAllButtonsEntity(pEntClicked->GetParent()); 45 | SlideScreen(pEntClicked->GetParent(), false); 46 | 47 | //kill this menu entirely, but we wait half a second while the transition is happening before doing it 48 | GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); 49 | 50 | //create the new menu 51 | AboutMenuCreate(pEntClicked->GetParent()->GetParent()); 52 | } 53 | 54 | GetEntityRoot()->PrintTreeAsText(); //useful for debugging 55 | } 56 | 57 | Entity * MainMenuCreate(Entity *pParentEnt) 58 | { 59 | 60 | /* 61 | //Example of loading a jpg and saving out a bmp 62 | SoftSurface s; 63 | s.LoadFile("interface/cosmo.jpg", SoftSurface::COLOR_KEY_NONE); 64 | s.WriteBMPOut("cosmo.bmp"); 65 | */ 66 | 67 | /* 68 | //Test of how measure text works 69 | rtRectf twolines; 70 | GetBaseApp()->GetFont(FONT_SMALL)->MeasureText( &twolines,"the top line is longer\nshorter" , 1); 71 | 72 | rtRectf singleline; 73 | GetBaseApp()->GetFont(FONT_SMALL)->MeasureText( &singleline, "the top line is longer", 1); 74 | 75 | LogMsg( string("Two lines rect: "+PrintRect(twolines)).c_str()); 76 | LogMsg( string("Single line rect: "+PrintRect(singleline)).c_str()); 77 | */ 78 | 79 | 80 | //Entity *pBG = CreateOverlayEntity(pParentEnt, "MainMenu", "interface/summary_bg.rttex", 0,0); 81 | Entity *pBG = pParentEnt->AddEntity(new Entity); 82 | 83 | AddFocusIfNeeded(pBG); 84 | 85 | //for android, so the back key (or escape on windows) will quit out of the game 86 | EntityComponent *pComp = pBG->AddComponent(new CustomInputComponent); 87 | //tell the component which key has to be hit for it to be activated 88 | pComp->GetFunction("OnActivated")->sig_function.connect(1, boost::bind(&App::OnExitApp, GetApp(), _1)); 89 | pComp->GetVar("keycode")->Set(uint32(VIRTUAL_KEY_BACK)); 90 | 91 | Entity *pButtonEntity; 92 | float x = 200; 93 | float y = 160; 94 | float ySpacer = 45; 95 | 96 | 97 | //If we wanted a rect color bg we could do the folowing 98 | //CreateOverlayRectEntity(pBG,GetScreenRect(),MAKE_RGBA(255,0,0,255)); 99 | 100 | //let's add a background image to test the jpg loading 101 | //CreateOverlayEntity(pBG, "Cosmo", "interface/cosmo.jpg",0,0); 102 | Entity* Menu = NULL; 103 | Menu = CreateOverlayEntity(pBG, "AboutMenu", "ui/large/game_title.rttex", 60, 0); 104 | Menu->GetVar("scale2d")->Set(CL_Vec2f(0.5, 0.5)); 105 | 106 | pButtonEntity = CreateTextButtonEntity(pBG, "InputTest", x, y, "Play"); y += ySpacer; 107 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&MainMenuOnSelect); 108 | 109 | //pButtonEntity = CreateTextButtonEntity(pBG, "InputTest", x, y, "Text Input Test"); y += ySpacer; 110 | //pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&MainMenuOnSelect); 111 | 112 | pButtonEntity = CreateTextButtonEntity(pBG, "Debug", x, y, "Settings"); y += ySpacer; 113 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&MainMenuOnSelect); 114 | 115 | /*pButtonEntity = CreateTextButtonEntity(pBG, "About", x, y, "About"); y += ySpacer; 116 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&MainMenuOnSelect);*/ 117 | 118 | SlideScreen(pBG, true); 119 | SlideScreen(Menu, true); 120 | 121 | return pBG; 122 | } 123 | 124 | -------------------------------------------------------------------------------- /proton/rtparam.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "../utils.h" 6 | #include 7 | 8 | class rtvar { 9 | public: 10 | class pair { 11 | public: 12 | std::string m_key{}; 13 | std::vector m_values{}; 14 | std::string m_value; 15 | pair() { 16 | } 17 | pair(std::string key, std::initializer_list values) : m_key(key), m_values(values) { 18 | } 19 | bool operator==( const rtvar::pair& rst) { 20 | return m_key == rst.m_key && m_values[0] == rst.m_values[0]; 21 | } 22 | static pair parse(std::string str) { 23 | pair ret{}; 24 | if (!str.length()) { // we dont want to parse empty string so m_pairs vector wont make the app crash 25 | //ret.append("empty"); 26 | return ret; 27 | } 28 | std::string token; 29 | std::stringstream ss(str); 30 | bool key = true, first = true; 31 | while (std::getline(ss, token, '|')) { 32 | if (key) { 33 | ret.m_key = token; 34 | key = false; 35 | } else { 36 | if (!first) 37 | ret.m_value.append("|"); 38 | ret.m_value.append(token); 39 | ret.m_values.push_back(token); 40 | first = false; 41 | } 42 | } 43 | return ret; 44 | } 45 | std::string serialize() { 46 | std::string ret{}; 47 | ret.append(m_key); 48 | for (auto& val : m_values) { 49 | ret.append("|"); 50 | ret.append(val); 51 | } 52 | return ret; 53 | } 54 | }; 55 | rtvar() { 56 | } 57 | rtvar(std::initializer_list pairs) : m_pairs(pairs) { 58 | } 59 | static rtvar parse(std::string str) { 60 | rtvar ret{}; 61 | std::stringstream ss(str); 62 | std::string token{}; 63 | while (std::getline(ss, token, '\n')) 64 | ret.append(token); 65 | return ret; 66 | } 67 | pair& append(std::string str) { 68 | pair p = pair::parse(str); 69 | m_pairs.push_back(p); 70 | return m_pairs.back(); 71 | } 72 | pair& get(int i) { 73 | if ((unsigned)i >= m_pairs.size()) 74 | return m_pairs[0]; 75 | return m_pairs[i]; 76 | } 77 | bool valid() { 78 | if (m_pairs.size() < 1) 79 | return false; 80 | 81 | if (m_pairs[0].m_values.size() < 1) 82 | return false; 83 | 84 | return true; 85 | } 86 | pair* find(const std::string& key) { 87 | int inx = 0; 88 | for (auto pair : m_pairs) { 89 | if (pair.m_key == key) //we cant return local pairs addr 90 | return &m_pairs[inx]; 91 | inx++; 92 | } 93 | return nullptr; 94 | } 95 | 96 | std::string get(const std::string& key) { 97 | auto pair = find(key); 98 | if (pair) 99 | return pair->m_value; 100 | return ""; 101 | } 102 | void set(const std::string& key, std::string value) { 103 | auto pair = find(key); 104 | if (pair && pair->m_values.size() >= 1) 105 | pair->m_values[0] = value; 106 | } 107 | std::string serialize() { 108 | std::string ret{}; 109 | for (auto& val : m_pairs) { 110 | ret.append(val.serialize()); 111 | ret.append("\n"); 112 | } 113 | if (ret != "") 114 | ret.erase(ret.end()); 115 | return ret; 116 | } 117 | bool validate_ints(std::vector vals) { 118 | for (auto str : vals) { 119 | auto pair = this->find(str); 120 | if (!pair) 121 | return false; 122 | if (!utils::is_number(pair->m_value)) 123 | return false; 124 | } 125 | return true; 126 | } 127 | bool validate_int(std::string str) { 128 | auto pair = this->find(str); 129 | if (!pair) 130 | return false; 131 | if (!utils::is_number(pair->m_value)) 132 | return false; 133 | return true; 134 | } 135 | inline int get_int(const std::string& key) { //this does not chekc if it exists, it assumes validate_ints has been consulated beforehand 136 | return atoi(find(key)->m_value.c_str()); 137 | } 138 | inline long long get_long(const std::string& key) { //assumes validate_ints 139 | return atoll(find(key)->m_value.c_str()); 140 | } 141 | size_t size() const { 142 | return m_pairs.size(); 143 | } 144 | void remove(const std::string& key) { 145 | auto pair = find(key); 146 | if (pair) { 147 | auto& ref = *pair; 148 | m_pairs.erase(std::remove(m_pairs.begin(), m_pairs.end(), ref), m_pairs.end()); 149 | } 150 | } 151 | 152 | private: 153 | //i could use std::map but for the sake of simplicity i dont, i want the code to be as readable as possible 154 | std::vector m_pairs{}; 155 | }; 156 | class rtvar_opt { //optimized version of rtvars (really nothing more than a container) when only needing to append strings 157 | private: 158 | std::string m_var{}; 159 | 160 | public: 161 | rtvar_opt() { 162 | } 163 | rtvar_opt(std::string start) { 164 | m_var = start; 165 | } 166 | void append(std::string str) { 167 | m_var = m_var.append("\n" + str); 168 | } 169 | std::string get() { 170 | return m_var; 171 | } 172 | }; 173 | -------------------------------------------------------------------------------- /source/proton/rtparam.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "../utils.h" 6 | #include 7 | 8 | class rtvar { 9 | public: 10 | class pair { 11 | public: 12 | std::string m_key{}; 13 | std::vector m_values{}; 14 | std::string m_value; 15 | pair() { 16 | } 17 | pair(std::string key, std::initializer_list values) : m_key(key), m_values(values) { 18 | } 19 | bool operator==( const rtvar::pair& rst) { 20 | return m_key == rst.m_key && m_values[0] == rst.m_values[0]; 21 | } 22 | static pair parse(std::string str) { 23 | pair ret{}; 24 | if (!str.length()) { // we dont want to parse empty string so m_pairs vector wont make the app crash 25 | //ret.append("empty"); 26 | return ret; 27 | } 28 | std::string token; 29 | std::stringstream ss(str); 30 | bool key = true, first = true; 31 | while (std::getline(ss, token, '|')) { 32 | if (key) { 33 | ret.m_key = token; 34 | key = false; 35 | } else { 36 | if (!first) 37 | ret.m_value.append("|"); 38 | ret.m_value.append(token); 39 | ret.m_values.push_back(token); 40 | first = false; 41 | } 42 | } 43 | return ret; 44 | } 45 | std::string serialize() { 46 | std::string ret{}; 47 | ret.append(m_key); 48 | for (auto& val : m_values) { 49 | ret.append("|"); 50 | ret.append(val); 51 | } 52 | return ret; 53 | } 54 | }; 55 | rtvar() { 56 | } 57 | rtvar(std::initializer_list pairs) : m_pairs(pairs) { 58 | } 59 | static rtvar parse(std::string str) { 60 | rtvar ret{}; 61 | std::stringstream ss(str); 62 | std::string token{}; 63 | while (std::getline(ss, token, '\n')) 64 | ret.append(token); 65 | return ret; 66 | } 67 | pair& append(std::string str) { 68 | pair p = pair::parse(str); 69 | m_pairs.push_back(p); 70 | return m_pairs.back(); 71 | } 72 | pair& get(int i) { 73 | if ((unsigned)i >= m_pairs.size()) 74 | return m_pairs[0]; 75 | return m_pairs[i]; 76 | } 77 | bool valid() { 78 | if (m_pairs.size() < 1) 79 | return false; 80 | 81 | if (m_pairs[0].m_values.size() < 1) 82 | return false; 83 | 84 | return true; 85 | } 86 | pair* find(const std::string& key) { 87 | int inx = 0; 88 | for (auto pair : m_pairs) { 89 | if (pair.m_key == key) //we cant return local pairs addr 90 | return &m_pairs[inx]; 91 | inx++; 92 | } 93 | return nullptr; 94 | } 95 | 96 | std::string get(const std::string& key) { 97 | auto pair = find(key); 98 | if (pair) 99 | return pair->m_value; 100 | return ""; 101 | } 102 | void set(const std::string& key, std::string value) { 103 | auto pair = find(key); 104 | if (pair && pair->m_values.size() >= 1) 105 | pair->m_values[0] = value; 106 | } 107 | std::string serialize() { 108 | std::string ret{}; 109 | for (auto& val : m_pairs) { 110 | ret.append(val.serialize()); 111 | ret.append("\n"); 112 | } 113 | if (ret != "") 114 | ret.erase(ret.end()); 115 | return ret; 116 | } 117 | bool validate_ints(std::vector vals) { 118 | for (auto str : vals) { 119 | auto pair = this->find(str); 120 | if (!pair) 121 | return false; 122 | if (!utils::is_number(pair->m_value)) 123 | return false; 124 | } 125 | return true; 126 | } 127 | bool validate_int(std::string str) { 128 | auto pair = this->find(str); 129 | if (!pair) 130 | return false; 131 | if (!utils::is_number(pair->m_value)) 132 | return false; 133 | return true; 134 | } 135 | inline int get_int(const std::string& key) { //this does not chekc if it exists, it assumes validate_ints has been consulated beforehand 136 | return atoi(find(key)->m_value.c_str()); 137 | } 138 | inline long long get_long(const std::string& key) { //assumes validate_ints 139 | return atoll(find(key)->m_value.c_str()); 140 | } 141 | size_t size() const { 142 | return m_pairs.size(); 143 | } 144 | void remove(const std::string& key) { 145 | auto pair = find(key); 146 | if (pair) { 147 | auto& ref = *pair; 148 | m_pairs.erase(std::remove(m_pairs.begin(), m_pairs.end(), ref), m_pairs.end()); 149 | } 150 | } 151 | 152 | private: 153 | //i could use std::map but for the sake of simplicity i dont, i want the code to be as readable as possible 154 | std::vector m_pairs{}; 155 | }; 156 | class rtvar_opt { //optimized version of rtvars (really nothing more than a container) when only needing to append strings 157 | private: 158 | std::string m_var{}; 159 | 160 | public: 161 | rtvar_opt() { 162 | } 163 | rtvar_opt(std::string start) { 164 | m_var = start; 165 | } 166 | void append(std::string str) { 167 | m_var = m_var.append("\n" + str); 168 | } 169 | std::string get() { 170 | return m_var; 171 | } 172 | }; 173 | -------------------------------------------------------------------------------- /http.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sandbird/sandbird.h" 3 | #pragma comment(lib, "ws2_32.lib") 4 | #pragma comment(lib, "winmm.lib") 5 | #pragma comment(lib, "shlwapi.lib") 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "Core_functions.h" 11 | 12 | namespace http { 13 | int handler(sb_Event* evt); 14 | void run(int port, std::string ip, int w_port); 15 | extern std::map cooldown = { 16 | 17 | }; 18 | } 19 | 20 | std::string http_port = ""; 21 | std::string http_ip = ""; 22 | sb_Options options; 23 | sb_Server* http_server; 24 | string header_server_ip = "127.0.0.1"; 25 | int header_configPort = 17091; 26 | 27 | std::string format(const char* msg, ...) { 28 | char fmt[1024] = { 0 }; 29 | va_list va; 30 | va_start(va, msg); 31 | vsnprintf(fmt, 1024, msg, va); 32 | va_end(va); 33 | return std::string(fmt); 34 | } 35 | 36 | uint8_t* read_file(const char* file, uint32_t* size) { 37 | FILE* fp; 38 | fopen_s(&fp, file, "rb"); 39 | if (!fp) { 40 | string file_name = file; 41 | SendConsole("Failed to read " + file_name + " returned 404", "ERROR"); 42 | return nullptr; 43 | } 44 | fseek(fp, 0, SEEK_END); 45 | const uint32_t fsize = ftell(fp); 46 | fseek(fp, 0, SEEK_SET); 47 | uint8_t* data = static_cast(malloc(fsize)); 48 | if (data) { 49 | memset(data, 0, fsize); 50 | fread(data, fsize, 1, fp); 51 | fclose(fp); 52 | if (size) 53 | *size = fsize; 54 | return data; 55 | } 56 | return nullptr; 57 | } 58 | 59 | 60 | 61 | int http::handler(sb_Event* evt) { 62 | if (evt->type == SB_EV_REQUEST) { 63 | string address = evt->address; 64 | string request = evt->method; 65 | if (strstr(evt->path, "/growtopia/server_data.php") != nullptr && request == "POST") { 66 | try { 67 | long long current_time = GetCurrentTimeInternalSeconds(); 68 | sb_send_status(evt->stream, 200, "OK"); 69 | sb_send_header(evt->stream, "Content-Type", "text/plain"); 70 | string req_address = address; 71 | char reply[1024]; 72 | string info = "server|" + header_server_ip + "\nport|" + to_string(header_configPort) + "\ntype|1\n#maint|`4Oh no! `oWait 0 seconds before logging in again!\nbeta_server|%s\nbeta_port|1945\nbeta_type|1\nmeta|ni.com\nRTENDMARKERBS1001\n"; 73 | if (cooldown.find(address) == cooldown.end()) { 74 | goto ok; 75 | } else if (cooldown.at(address) > current_time) { 76 | info = "server|" + header_server_ip + "\nport|" + to_string(header_configPort) + "\ntype|1\nmaint|`4Oh no! `oWait " + to_string(cooldown.at(address) - current_time) + " seconds before logging in again!\nbeta_server|%s\nbeta_port|1945\nbeta_type|1\nmeta|ni.com\nRTENDMARKERBS1001\n"; 77 | memcpy(reply, info.c_str(), info.size() + 1); 78 | sb_writef(evt->stream, format(reply, http_ip.c_str(), http_port.c_str(), http_ip.c_str()).c_str()); 79 | } else { 80 | ok: 81 | if (cooldown.find(address) == cooldown.end()) { 82 | cooldown.insert({ address, (GetCurrentTimeInternalSeconds() + (6)) }); 83 | } else { 84 | cooldown.at(address) = (GetCurrentTimeInternalSeconds() + (6)); 85 | } 86 | memcpy(reply, info.c_str(), info.size() + 1); 87 | sb_writef(evt->stream, format(reply, http_ip.c_str(), http_port.c_str(), http_ip.c_str()).c_str()); 88 | } 89 | } catch (const std::out_of_range& e) { 90 | cout << e.what() << endl; 91 | } 92 | } else if ((strstr(evt->path, "/game/") != NULL && request == "GET" || strstr(evt->path, "/social/") != NULL && request == "GET" || strstr(evt->path, "/interface/") != NULL && request == "GET" || strstr(evt->path, "/audio/") != NULL) && request == "GET") { 93 | uint32_t size = 0; 94 | const char* path = evt->path + 1; 95 | uint8_t* content = read_file(path, &size); 96 | if (content) { 97 | sb_send_status(evt->stream, 200, "OK"); 98 | sb_send_header(evt->stream, "Content-Type", "application/x-www-form-urlencoded"); 99 | sb_send_header(evt->stream, "Content-Length", format("%d", size).c_str()); 100 | sb_send_header(evt->stream, "beserver", "06"); 101 | sb_send_header(evt->stream, "Connection", "keep-alive"); 102 | sb_send_header(evt->stream, "Accept-Ranges", "bytes"); 103 | sb_write(evt->stream, content, size); 104 | } 105 | } else if (strstr(evt->path, "/render/") != NULL && request == "GET") { 106 | string path = evt->path + 1; 107 | ifstream read_map(path); 108 | if (!read_map.is_open()) { 109 | return SB_RES_CLOSE; 110 | } 111 | std::stringstream sstr; 112 | while (read_map >> sstr.rdbuf()); 113 | string test = sstr.str(); 114 | sb_send_status(evt->stream, 200, "OK"); 115 | sb_send_header(evt->stream, "Content-Type", "text/html"); 116 | sb_writef(evt->stream, test.c_str()); 117 | } else { 118 | return SB_RES_CLOSE; 119 | } 120 | } 121 | return SB_RES_OK; 122 | } 123 | 124 | #ifdef _WIN32 125 | #include 126 | #endif 127 | 128 | void util_sleep(int32_t ms) { 129 | #ifdef _WIN32 130 | Sleep(ms); 131 | #else 132 | usleep(ms * 1000); 133 | #endif 134 | 135 | } 136 | void http::run(int port, string ip, int w_port) { 137 | header_server_ip = ip; 138 | header_configPort = w_port; 139 | http_port = to_string(port); 140 | http_ip = "0.0.0.0"; 141 | options.handler = handler; 142 | options.host = http_ip.c_str(); 143 | options.port = http_port.c_str(); 144 | http_server = sb_new_server(&options); 145 | if (!http_server) { 146 | SendConsole("HTTP failed to start service, is " + http_ip + ":" + http_port + " already running?", "HTTP"); 147 | system("PAUSE"); 148 | exit(0); 149 | } else { 150 | SendConsole("HTTP service started, listening on " + http_ip + ":" + http_port, "HTTP"); 151 | } while (true) { 152 | sb_poll_server(http_server, 10); 153 | util_sleep(1); 154 | } 155 | sb_close_server(http_server); 156 | } -------------------------------------------------------------------------------- /enet/include/protocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file protocol.h 3 | @brief ENet protocol 4 | */ 5 | #ifndef __ENET_PROTOCOL_H__ 6 | #define __ENET_PROTOCOL_H__ 7 | 8 | #include "types.h" 9 | 10 | enum 11 | { 12 | ENET_PROTOCOL_MINIMUM_MTU = 576, 13 | ENET_PROTOCOL_MAXIMUM_MTU = 4096, 14 | ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32, 15 | ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096, 16 | ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 65536, 17 | ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1, 18 | ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255, 19 | ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xFFF, 20 | ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024 21 | }; 22 | 23 | typedef enum _ENetProtocolCommand 24 | { 25 | ENET_PROTOCOL_COMMAND_NONE = 0, 26 | ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1, 27 | ENET_PROTOCOL_COMMAND_CONNECT = 2, 28 | ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3, 29 | ENET_PROTOCOL_COMMAND_DISCONNECT = 4, 30 | ENET_PROTOCOL_COMMAND_PING = 5, 31 | ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6, 32 | ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7, 33 | ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8, 34 | ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9, 35 | ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10, 36 | ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, 37 | ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12, 38 | ENET_PROTOCOL_COMMAND_COUNT = 13, 39 | 40 | ENET_PROTOCOL_COMMAND_MASK = 0x0F 41 | } ENetProtocolCommand; 42 | 43 | typedef enum _ENetProtocolFlag 44 | { 45 | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7), 46 | ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6), 47 | 48 | ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14), 49 | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15), 50 | ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME, 51 | 52 | ENET_PROTOCOL_HEADER_SESSION_MASK = (3 << 12), 53 | ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12 54 | } ENetProtocolFlag; 55 | 56 | #ifdef _MSC_VER 57 | #pragma pack(push, 1) 58 | #define ENET_PACKED 59 | #elif defined(__GNUC__) || defined(__clang__) 60 | #define ENET_PACKED __attribute__ ((packed)) 61 | #else 62 | #define ENET_PACKED 63 | #endif 64 | 65 | typedef struct _ENetProtocolHeader 66 | { 67 | enet_uint16 peerID; 68 | enet_uint16 sentTime; 69 | } ENET_PACKED ENetProtocolHeader; 70 | 71 | typedef struct _ENetProtocolCommandHeader 72 | { 73 | enet_uint8 command; 74 | enet_uint8 channelID; 75 | enet_uint16 reliableSequenceNumber; 76 | } ENET_PACKED ENetProtocolCommandHeader; 77 | 78 | typedef struct _ENetProtocolAcknowledge 79 | { 80 | ENetProtocolCommandHeader header; 81 | enet_uint16 receivedReliableSequenceNumber; 82 | enet_uint16 receivedSentTime; 83 | } ENET_PACKED ENetProtocolAcknowledge; 84 | 85 | typedef struct _ENetProtocolConnect 86 | { 87 | ENetProtocolCommandHeader header; 88 | enet_uint16 outgoingPeerID; 89 | enet_uint8 incomingSessionID; 90 | enet_uint8 outgoingSessionID; 91 | enet_uint32 mtu; 92 | enet_uint32 windowSize; 93 | enet_uint32 channelCount; 94 | enet_uint32 incomingBandwidth; 95 | enet_uint32 outgoingBandwidth; 96 | enet_uint32 packetThrottleInterval; 97 | enet_uint32 packetThrottleAcceleration; 98 | enet_uint32 packetThrottleDeceleration; 99 | enet_uint32 connectID; 100 | enet_uint32 data; 101 | } ENET_PACKED ENetProtocolConnect; 102 | 103 | typedef struct _ENetProtocolVerifyConnect 104 | { 105 | ENetProtocolCommandHeader header; 106 | enet_uint16 outgoingPeerID; 107 | enet_uint8 incomingSessionID; 108 | enet_uint8 outgoingSessionID; 109 | enet_uint32 mtu; 110 | enet_uint32 windowSize; 111 | enet_uint32 channelCount; 112 | enet_uint32 incomingBandwidth; 113 | enet_uint32 outgoingBandwidth; 114 | enet_uint32 packetThrottleInterval; 115 | enet_uint32 packetThrottleAcceleration; 116 | enet_uint32 packetThrottleDeceleration; 117 | enet_uint32 connectID; 118 | } ENET_PACKED ENetProtocolVerifyConnect; 119 | 120 | typedef struct _ENetProtocolBandwidthLimit 121 | { 122 | ENetProtocolCommandHeader header; 123 | enet_uint32 incomingBandwidth; 124 | enet_uint32 outgoingBandwidth; 125 | } ENET_PACKED ENetProtocolBandwidthLimit; 126 | 127 | typedef struct _ENetProtocolThrottleConfigure 128 | { 129 | ENetProtocolCommandHeader header; 130 | enet_uint32 packetThrottleInterval; 131 | enet_uint32 packetThrottleAcceleration; 132 | enet_uint32 packetThrottleDeceleration; 133 | } ENET_PACKED ENetProtocolThrottleConfigure; 134 | 135 | typedef struct _ENetProtocolDisconnect 136 | { 137 | ENetProtocolCommandHeader header; 138 | enet_uint32 data; 139 | } ENET_PACKED ENetProtocolDisconnect; 140 | 141 | typedef struct _ENetProtocolPing 142 | { 143 | ENetProtocolCommandHeader header; 144 | } ENET_PACKED ENetProtocolPing; 145 | 146 | typedef struct _ENetProtocolSendReliable 147 | { 148 | ENetProtocolCommandHeader header; 149 | enet_uint16 dataLength; 150 | } ENET_PACKED ENetProtocolSendReliable; 151 | 152 | typedef struct _ENetProtocolSendUnreliable 153 | { 154 | ENetProtocolCommandHeader header; 155 | enet_uint16 unreliableSequenceNumber; 156 | enet_uint16 dataLength; 157 | } ENET_PACKED ENetProtocolSendUnreliable; 158 | 159 | typedef struct _ENetProtocolSendUnsequenced 160 | { 161 | ENetProtocolCommandHeader header; 162 | enet_uint16 unsequencedGroup; 163 | enet_uint16 dataLength; 164 | } ENET_PACKED ENetProtocolSendUnsequenced; 165 | 166 | typedef struct _ENetProtocolSendFragment 167 | { 168 | ENetProtocolCommandHeader header; 169 | enet_uint16 startSequenceNumber; 170 | enet_uint16 dataLength; 171 | enet_uint32 fragmentCount; 172 | enet_uint32 fragmentNumber; 173 | enet_uint32 totalLength; 174 | enet_uint32 fragmentOffset; 175 | } ENET_PACKED ENetProtocolSendFragment; 176 | 177 | typedef union _ENetProtocol 178 | { 179 | ENetProtocolCommandHeader header; 180 | ENetProtocolAcknowledge acknowledge; 181 | ENetProtocolConnect connect; 182 | ENetProtocolVerifyConnect verifyConnect; 183 | ENetProtocolDisconnect disconnect; 184 | ENetProtocolPing ping; 185 | ENetProtocolSendReliable sendReliable; 186 | ENetProtocolSendUnreliable sendUnreliable; 187 | ENetProtocolSendUnsequenced sendUnsequenced; 188 | ENetProtocolSendFragment sendFragment; 189 | ENetProtocolBandwidthLimit bandwidthLimit; 190 | ENetProtocolThrottleConfigure throttleConfigure; 191 | } ENET_PACKED ENetProtocol; 192 | 193 | #ifdef _MSC_VER 194 | #pragma pack(pop) 195 | #endif 196 | 197 | #endif /* __ENET_PROTOCOL_H__ */ 198 | 199 | -------------------------------------------------------------------------------- /GTPS.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {e6a1ac8d-5237-4849-be40-8f9993354cb3} 18 | 19 | 20 | {9a2d26c5-6820-4892-b9c8-a4353a91b80e} 21 | 22 | 23 | {b2ac7b5f-7448-4da6-8e75-181b51d502d8} 24 | 25 | 26 | {f379db0d-0db4-446a-acca-a8a6903d4e5e} 27 | 28 | 29 | {e760e961-d15d-4d63-a3ea-2e5135b10b31} 30 | 31 | 32 | {1f56f4b3-e667-4af3-bf5e-161f85e9e258} 33 | 34 | 35 | {9609f1dc-6d9d-4cc5-9460-8d5d75245888} 36 | 37 | 38 | {363f6056-81a4-4798-bcf8-7ccb81dfdd94} 39 | 40 | 41 | 42 | 43 | Header Files\http 44 | 45 | 46 | Header Files\http 47 | 48 | 49 | Header Files\discord 50 | 51 | 52 | Header Files\server 53 | 54 | 55 | Header Files\server 56 | 57 | 58 | Header Files\server 59 | 60 | 61 | Header Files\server 62 | 63 | 64 | Header Files\server 65 | 66 | 67 | Header Files\core 68 | 69 | 70 | Header Files\http 71 | 72 | 73 | Header Files\bot 74 | 75 | 76 | Header Files\server 77 | 78 | 79 | Header Files\enet 80 | 81 | 82 | Header Files\enet 83 | 84 | 85 | Header Files\enet 86 | 87 | 88 | Header Files\enet 89 | 90 | 91 | Header Files\enet 92 | 93 | 94 | Header Files\enet 95 | 96 | 97 | Header Files\enet 98 | 99 | 100 | Header Files\enet 101 | 102 | 103 | Header Files\enet 104 | 105 | 106 | Header Files\server 107 | 108 | 109 | Header Files\server 110 | 111 | 112 | 113 | 114 | Header Files\http 115 | 116 | 117 | Source Files\http 118 | 119 | 120 | Source Files 121 | 122 | 123 | Source Files\enet 124 | 125 | 126 | Source Files\enet 127 | 128 | 129 | Source Files\enet 130 | 131 | 132 | Source Files\enet 133 | 134 | 135 | Source Files\enet 136 | 137 | 138 | Source Files\enet 139 | 140 | 141 | Source Files\enet 142 | 143 | 144 | Source Files\enet 145 | 146 | 147 | Source Files\enet 148 | 149 | 150 | 151 | 152 | Resource Files 153 | 154 | 155 | Resource Files 156 | 157 | 158 | 159 | 160 | Resource Files 161 | 162 | 163 | -------------------------------------------------------------------------------- /source/enet/protocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file protocol.h 3 | @brief ENet protocol 4 | */ 5 | #ifndef __ENET_PROTOCOL_H__ 6 | #define __ENET_PROTOCOL_H__ 7 | 8 | #include "enet/types.h" 9 | 10 | enum 11 | { 12 | ENET_PROTOCOL_MINIMUM_MTU = 576, 13 | ENET_PROTOCOL_MAXIMUM_MTU = 4096, 14 | ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32, 15 | ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096, 16 | ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 65536, 17 | ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1, 18 | ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255, 19 | ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xFFF, 20 | ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024 21 | }; 22 | 23 | typedef enum _ENetProtocolCommand 24 | { 25 | ENET_PROTOCOL_COMMAND_NONE = 0, 26 | ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1, 27 | ENET_PROTOCOL_COMMAND_CONNECT = 2, 28 | ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3, 29 | ENET_PROTOCOL_COMMAND_DISCONNECT = 4, 30 | ENET_PROTOCOL_COMMAND_PING = 5, 31 | ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6, 32 | ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7, 33 | ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8, 34 | ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9, 35 | ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10, 36 | ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, 37 | ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12, 38 | ENET_PROTOCOL_COMMAND_COUNT = 13, 39 | 40 | ENET_PROTOCOL_COMMAND_MASK = 0x0F 41 | } ENetProtocolCommand; 42 | 43 | typedef enum _ENetProtocolFlag 44 | { 45 | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7), 46 | ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6), 47 | 48 | ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14), 49 | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15), 50 | ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME, 51 | 52 | ENET_PROTOCOL_HEADER_SESSION_MASK = (3 << 12), 53 | ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12 54 | } ENetProtocolFlag; 55 | 56 | #ifdef _MSC_VER 57 | #pragma pack(push, 1) 58 | #define ENET_PACKED 59 | #elif defined(__GNUC__) || defined(__clang__) 60 | #define ENET_PACKED __attribute__ ((packed)) 61 | #else 62 | #define ENET_PACKED 63 | #endif 64 | 65 | typedef struct _ENetProtocolHeader 66 | { 67 | enet_uint16 peerID; 68 | enet_uint16 sentTime; 69 | } ENET_PACKED ENetProtocolHeader; 70 | 71 | typedef struct _ENetProtocolCommandHeader 72 | { 73 | enet_uint8 command; 74 | enet_uint8 channelID; 75 | enet_uint16 reliableSequenceNumber; 76 | } ENET_PACKED ENetProtocolCommandHeader; 77 | 78 | typedef struct _ENetProtocolAcknowledge 79 | { 80 | ENetProtocolCommandHeader header; 81 | enet_uint16 receivedReliableSequenceNumber; 82 | enet_uint16 receivedSentTime; 83 | } ENET_PACKED ENetProtocolAcknowledge; 84 | 85 | typedef struct _ENetProtocolConnect 86 | { 87 | ENetProtocolCommandHeader header; 88 | enet_uint16 outgoingPeerID; 89 | enet_uint8 incomingSessionID; 90 | enet_uint8 outgoingSessionID; 91 | enet_uint32 mtu; 92 | enet_uint32 windowSize; 93 | enet_uint32 channelCount; 94 | enet_uint32 incomingBandwidth; 95 | enet_uint32 outgoingBandwidth; 96 | enet_uint32 packetThrottleInterval; 97 | enet_uint32 packetThrottleAcceleration; 98 | enet_uint32 packetThrottleDeceleration; 99 | enet_uint32 connectID; 100 | enet_uint32 data; 101 | } ENET_PACKED ENetProtocolConnect; 102 | 103 | typedef struct _ENetProtocolVerifyConnect 104 | { 105 | ENetProtocolCommandHeader header; 106 | enet_uint16 outgoingPeerID; 107 | enet_uint8 incomingSessionID; 108 | enet_uint8 outgoingSessionID; 109 | enet_uint32 mtu; 110 | enet_uint32 windowSize; 111 | enet_uint32 channelCount; 112 | enet_uint32 incomingBandwidth; 113 | enet_uint32 outgoingBandwidth; 114 | enet_uint32 packetThrottleInterval; 115 | enet_uint32 packetThrottleAcceleration; 116 | enet_uint32 packetThrottleDeceleration; 117 | enet_uint32 connectID; 118 | } ENET_PACKED ENetProtocolVerifyConnect; 119 | 120 | typedef struct _ENetProtocolBandwidthLimit 121 | { 122 | ENetProtocolCommandHeader header; 123 | enet_uint32 incomingBandwidth; 124 | enet_uint32 outgoingBandwidth; 125 | } ENET_PACKED ENetProtocolBandwidthLimit; 126 | 127 | typedef struct _ENetProtocolThrottleConfigure 128 | { 129 | ENetProtocolCommandHeader header; 130 | enet_uint32 packetThrottleInterval; 131 | enet_uint32 packetThrottleAcceleration; 132 | enet_uint32 packetThrottleDeceleration; 133 | } ENET_PACKED ENetProtocolThrottleConfigure; 134 | 135 | typedef struct _ENetProtocolDisconnect 136 | { 137 | ENetProtocolCommandHeader header; 138 | enet_uint32 data; 139 | } ENET_PACKED ENetProtocolDisconnect; 140 | 141 | typedef struct _ENetProtocolPing 142 | { 143 | ENetProtocolCommandHeader header; 144 | } ENET_PACKED ENetProtocolPing; 145 | 146 | typedef struct _ENetProtocolSendReliable 147 | { 148 | ENetProtocolCommandHeader header; 149 | enet_uint16 dataLength; 150 | } ENET_PACKED ENetProtocolSendReliable; 151 | 152 | typedef struct _ENetProtocolSendUnreliable 153 | { 154 | ENetProtocolCommandHeader header; 155 | enet_uint16 unreliableSequenceNumber; 156 | enet_uint16 dataLength; 157 | } ENET_PACKED ENetProtocolSendUnreliable; 158 | 159 | typedef struct _ENetProtocolSendUnsequenced 160 | { 161 | ENetProtocolCommandHeader header; 162 | enet_uint16 unsequencedGroup; 163 | enet_uint16 dataLength; 164 | } ENET_PACKED ENetProtocolSendUnsequenced; 165 | 166 | typedef struct _ENetProtocolSendFragment 167 | { 168 | ENetProtocolCommandHeader header; 169 | enet_uint16 startSequenceNumber; 170 | enet_uint16 dataLength; 171 | enet_uint32 fragmentCount; 172 | enet_uint32 fragmentNumber; 173 | enet_uint32 totalLength; 174 | enet_uint32 fragmentOffset; 175 | } ENET_PACKED ENetProtocolSendFragment; 176 | 177 | typedef union _ENetProtocol 178 | { 179 | ENetProtocolCommandHeader header; 180 | ENetProtocolAcknowledge acknowledge; 181 | ENetProtocolConnect connect; 182 | ENetProtocolVerifyConnect verifyConnect; 183 | ENetProtocolDisconnect disconnect; 184 | ENetProtocolPing ping; 185 | ENetProtocolSendReliable sendReliable; 186 | ENetProtocolSendUnreliable sendUnreliable; 187 | ENetProtocolSendUnsequenced sendUnsequenced; 188 | ENetProtocolSendFragment sendFragment; 189 | ENetProtocolBandwidthLimit bandwidthLimit; 190 | ENetProtocolThrottleConfigure throttleConfigure; 191 | } ENET_PACKED ENetProtocol; 192 | 193 | #ifdef _MSC_VER 194 | #pragma pack(pop) 195 | #endif 196 | 197 | #endif /* __ENET_PROTOCOL_H__ */ 198 | 199 | -------------------------------------------------------------------------------- /source/enet/enet/protocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | @file protocol.h 3 | @brief ENet protocol 4 | */ 5 | #ifndef __ENET_PROTOCOL_H__ 6 | #define __ENET_PROTOCOL_H__ 7 | 8 | #include "enet/types.h" 9 | 10 | enum 11 | { 12 | ENET_PROTOCOL_MINIMUM_MTU = 576, 13 | ENET_PROTOCOL_MAXIMUM_MTU = 4096, 14 | ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32, 15 | ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096, 16 | ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 65536, 17 | ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1, 18 | ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255, 19 | ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xFFF, 20 | ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024 21 | }; 22 | 23 | typedef enum _ENetProtocolCommand 24 | { 25 | ENET_PROTOCOL_COMMAND_NONE = 0, 26 | ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1, 27 | ENET_PROTOCOL_COMMAND_CONNECT = 2, 28 | ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3, 29 | ENET_PROTOCOL_COMMAND_DISCONNECT = 4, 30 | ENET_PROTOCOL_COMMAND_PING = 5, 31 | ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6, 32 | ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7, 33 | ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8, 34 | ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9, 35 | ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10, 36 | ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11, 37 | ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12, 38 | ENET_PROTOCOL_COMMAND_COUNT = 13, 39 | 40 | ENET_PROTOCOL_COMMAND_MASK = 0x0F 41 | } ENetProtocolCommand; 42 | 43 | typedef enum _ENetProtocolFlag 44 | { 45 | ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 << 7), 46 | ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 << 6), 47 | 48 | ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 << 14), 49 | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 << 15), 50 | ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED | ENET_PROTOCOL_HEADER_FLAG_SENT_TIME, 51 | 52 | ENET_PROTOCOL_HEADER_SESSION_MASK = (3 << 12), 53 | ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12 54 | } ENetProtocolFlag; 55 | 56 | #ifdef _MSC_VER 57 | #pragma pack(push, 1) 58 | #define ENET_PACKED 59 | #elif defined(__GNUC__) || defined(__clang__) 60 | #define ENET_PACKED __attribute__ ((packed)) 61 | #else 62 | #define ENET_PACKED 63 | #endif 64 | 65 | typedef struct _ENetProtocolHeader 66 | { 67 | enet_uint16 peerID; 68 | enet_uint16 sentTime; 69 | } ENET_PACKED ENetProtocolHeader; 70 | 71 | typedef struct _ENetProtocolCommandHeader 72 | { 73 | enet_uint8 command; 74 | enet_uint8 channelID; 75 | enet_uint16 reliableSequenceNumber; 76 | } ENET_PACKED ENetProtocolCommandHeader; 77 | 78 | typedef struct _ENetProtocolAcknowledge 79 | { 80 | ENetProtocolCommandHeader header; 81 | enet_uint16 receivedReliableSequenceNumber; 82 | enet_uint16 receivedSentTime; 83 | } ENET_PACKED ENetProtocolAcknowledge; 84 | 85 | typedef struct _ENetProtocolConnect 86 | { 87 | ENetProtocolCommandHeader header; 88 | enet_uint16 outgoingPeerID; 89 | enet_uint8 incomingSessionID; 90 | enet_uint8 outgoingSessionID; 91 | enet_uint32 mtu; 92 | enet_uint32 windowSize; 93 | enet_uint32 channelCount; 94 | enet_uint32 incomingBandwidth; 95 | enet_uint32 outgoingBandwidth; 96 | enet_uint32 packetThrottleInterval; 97 | enet_uint32 packetThrottleAcceleration; 98 | enet_uint32 packetThrottleDeceleration; 99 | enet_uint32 connectID; 100 | enet_uint32 data; 101 | } ENET_PACKED ENetProtocolConnect; 102 | 103 | typedef struct _ENetProtocolVerifyConnect 104 | { 105 | ENetProtocolCommandHeader header; 106 | enet_uint16 outgoingPeerID; 107 | enet_uint8 incomingSessionID; 108 | enet_uint8 outgoingSessionID; 109 | enet_uint32 mtu; 110 | enet_uint32 windowSize; 111 | enet_uint32 channelCount; 112 | enet_uint32 incomingBandwidth; 113 | enet_uint32 outgoingBandwidth; 114 | enet_uint32 packetThrottleInterval; 115 | enet_uint32 packetThrottleAcceleration; 116 | enet_uint32 packetThrottleDeceleration; 117 | enet_uint32 connectID; 118 | } ENET_PACKED ENetProtocolVerifyConnect; 119 | 120 | typedef struct _ENetProtocolBandwidthLimit 121 | { 122 | ENetProtocolCommandHeader header; 123 | enet_uint32 incomingBandwidth; 124 | enet_uint32 outgoingBandwidth; 125 | } ENET_PACKED ENetProtocolBandwidthLimit; 126 | 127 | typedef struct _ENetProtocolThrottleConfigure 128 | { 129 | ENetProtocolCommandHeader header; 130 | enet_uint32 packetThrottleInterval; 131 | enet_uint32 packetThrottleAcceleration; 132 | enet_uint32 packetThrottleDeceleration; 133 | } ENET_PACKED ENetProtocolThrottleConfigure; 134 | 135 | typedef struct _ENetProtocolDisconnect 136 | { 137 | ENetProtocolCommandHeader header; 138 | enet_uint32 data; 139 | } ENET_PACKED ENetProtocolDisconnect; 140 | 141 | typedef struct _ENetProtocolPing 142 | { 143 | ENetProtocolCommandHeader header; 144 | } ENET_PACKED ENetProtocolPing; 145 | 146 | typedef struct _ENetProtocolSendReliable 147 | { 148 | ENetProtocolCommandHeader header; 149 | enet_uint16 dataLength; 150 | } ENET_PACKED ENetProtocolSendReliable; 151 | 152 | typedef struct _ENetProtocolSendUnreliable 153 | { 154 | ENetProtocolCommandHeader header; 155 | enet_uint16 unreliableSequenceNumber; 156 | enet_uint16 dataLength; 157 | } ENET_PACKED ENetProtocolSendUnreliable; 158 | 159 | typedef struct _ENetProtocolSendUnsequenced 160 | { 161 | ENetProtocolCommandHeader header; 162 | enet_uint16 unsequencedGroup; 163 | enet_uint16 dataLength; 164 | } ENET_PACKED ENetProtocolSendUnsequenced; 165 | 166 | typedef struct _ENetProtocolSendFragment 167 | { 168 | ENetProtocolCommandHeader header; 169 | enet_uint16 startSequenceNumber; 170 | enet_uint16 dataLength; 171 | enet_uint32 fragmentCount; 172 | enet_uint32 fragmentNumber; 173 | enet_uint32 totalLength; 174 | enet_uint32 fragmentOffset; 175 | } ENET_PACKED ENetProtocolSendFragment; 176 | 177 | typedef union _ENetProtocol 178 | { 179 | ENetProtocolCommandHeader header; 180 | ENetProtocolAcknowledge acknowledge; 181 | ENetProtocolConnect connect; 182 | ENetProtocolVerifyConnect verifyConnect; 183 | ENetProtocolDisconnect disconnect; 184 | ENetProtocolPing ping; 185 | ENetProtocolSendReliable sendReliable; 186 | ENetProtocolSendUnreliable sendUnreliable; 187 | ENetProtocolSendUnsequenced sendUnsequenced; 188 | ENetProtocolSendFragment sendFragment; 189 | ENetProtocolBandwidthLimit bandwidthLimit; 190 | ENetProtocolThrottleConfigure throttleConfigure; 191 | } ENET_PACKED ENetProtocol; 192 | 193 | #ifdef _MSC_VER 194 | #pragma pack(pop) 195 | #endif 196 | 197 | #endif /* __ENET_PROTOCOL_H__ */ 198 | 199 | -------------------------------------------------------------------------------- /trade_system.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | string FormatTradeItems(vector tradeItems) 4 | { 5 | string fmt = ""; 6 | for (auto& t : tradeItems) 7 | { 8 | fmt += "add_slot|" + to_string(t.id) + "|" + to_string(t.count) + "\n"; 9 | } 10 | return fmt; 11 | } 12 | 13 | void update_trade(ENetPeer* peer, int userID, bool silent = false) { 14 | PlayerInfo* pData = GetPeerData(peer); 15 | for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { 16 | if (currentPeer->state != ENET_PEER_STATE_CONNECTED) continue; 17 | if (isHere(peer, currentPeer)) { 18 | if (pData->trade_netid == static_cast(currentPeer->data)->netID || pData->netID == static_cast(currentPeer->data)->trade_netid) { 19 | Player::OnTradeStatus(currentPeer, static_cast(currentPeer->data)->netID, "`oSelect an item from the inventory.``", "", FormatTradeItems(static_cast(currentPeer->data)->tradeItems) + "\nlocked|0\nreset_locks|1\naccepted|0\n"); 20 | Player::OnTradeStatus(currentPeer, pData->netID, "`o" + pData->displayName + "`o's offer.``", "", FormatTradeItems(pData->tradeItems) + "\nlocked|0\nreset_locks|1\naccepted|0\n"); 21 | if (!silent) if (static_cast(currentPeer->data)->trade) Player::OnTextOverlay(currentPeer, "The deal has changed"); 22 | Player::OnTradeStatus(peer, pData->netID, "`o" + pData->displayName + "`oSelect an item from the inventory.``", "", FormatTradeItems(pData->tradeItems) + "\nlocked|0\nreset_locks|1\naccepted|0\n"); 23 | Player::OnTradeStatus(peer, static_cast(currentPeer->data)->netID, "`o" + static_cast(currentPeer->data)->displayName + "`o's offer.``", "", FormatTradeItems(static_cast(currentPeer->data)->tradeItems) + "\nlocked|0\nreset_locks|1\naccepted|0\n"); 24 | if (!silent) { 25 | Player::OnTextOverlay(peer, "The deal has changed"); 26 | Player::PlayAudio(currentPeer, "audio/tile_removed.wav", 0); 27 | Player::PlayAudio(peer, "audio/tile_removed.wav", 0); 28 | } 29 | pData->trade_accept = false; 30 | static_cast(currentPeer->data)->trade_accept = false; 31 | //break; 32 | } 33 | } 34 | } 35 | } 36 | 37 | void UpdateTradeAcceptedStatus(ENetPeer* peer, int showOverlay = 0, bool self = false) { 38 | for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { 39 | if (currentPeer->state != ENET_PEER_STATE_CONNECTED) continue; 40 | if (static_cast(peer->data)->trade_netid == static_cast(currentPeer->data)->netID) { 41 | Player::OnTradeStatus(currentPeer, static_cast(peer->data)->netID, "`o" + static_cast(peer->data)->displayName + "`o's offer.``", "", FormatTradeItems(static_cast(peer->data)->tradeItems) + "\nlocked|1\naccepted|" + to_string(static_cast(peer->data)->trade_accept) + "\n"); 42 | Player::OnTradeStatus(currentPeer, static_cast(currentPeer->data)->netID, "`o" + static_cast(currentPeer->data)->displayName + "`o's offer.``", "", FormatTradeItems(static_cast(currentPeer->data)->tradeItems) + "\nlocked|1\naccepted|" + to_string(static_cast(currentPeer->data)->trade_accept) + "\n"); 43 | if (self) { 44 | Player::OnTradeStatus(peer, static_cast(peer->data)->netID, "`o" + static_cast(peer->data)->displayName + "`o's offer.``", "", FormatTradeItems(static_cast(peer->data)->tradeItems) + "\nlocked|1\naccepted|" + to_string(static_cast(peer->data)->trade_accept) + "\n"); 45 | Player::OnTradeStatus(peer, static_cast(currentPeer->data)->netID, "`o" + static_cast(currentPeer->data)->displayName + "`o's offer.``", "", FormatTradeItems(static_cast(currentPeer->data)->tradeItems) + "\nlocked|1\naccepted|" + to_string(static_cast(currentPeer->data)->trade_accept) + "\n"); 46 | } 47 | break; 48 | } 49 | } 50 | } 51 | 52 | inline void end_trade(ENetPeer* peer, bool cancelled = false, bool cancel = false) { 53 | for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { 54 | if (currentPeer->state != ENET_PEER_STATE_CONNECTED) continue; 55 | if (isHere(peer, currentPeer)) { 56 | if (static_cast(currentPeer->data)->netID == static_cast(peer->data)->trade_netid) { 57 | if (cancel) { 58 | Player::OnTextOverlay(currentPeer, static_cast(peer->data)->displayName + " `whas canceled the trade"); 59 | } 60 | else if (cancelled) { 61 | Player::OnTalkBubble(currentPeer, static_cast(currentPeer->data)->netID, "`6[```4Trade canceled by " + static_cast(peer->data)->displayName + "`4!```6]``", 0, false); 62 | Player::OnConsoleMessage(currentPeer, "`6[```4Trade canceled by " + static_cast(peer->data)->displayName + "`4!```6]``"); 63 | Player::OnTextOverlay(currentPeer, "`6[```4Trade canceled by " + static_cast(peer->data)->displayName + "`4!```6]``"); 64 | } else { 65 | Player::OnConsoleMessage(currentPeer, static_cast(peer->data)->displayName + " `ois too busy to trade!"); 66 | Player::OnTextOverlay(currentPeer, static_cast(peer->data)->displayName + " `wis too busy to trade!"); 67 | } 68 | Player::OnForceTradeEnd(currentPeer); 69 | static_cast(currentPeer->data)->trade_netid = -1; 70 | static_cast(currentPeer->data)->trade = false; 71 | static_cast(currentPeer->data)->trade_accept = false; 72 | static_cast(currentPeer->data)->trade_confirmed = false; 73 | static_cast(currentPeer->data)->tradeItems.clear(); 74 | break; 75 | } 76 | } 77 | } 78 | if (cancel) { 79 | Player::OnTextOverlay(peer, static_cast(peer->data)->displayName + " `whas canceled the trade"); 80 | } 81 | else if (cancelled) { 82 | Player::OnTalkBubble(peer, static_cast(peer->data)->netID, "`6[```4Trade canceled by " + static_cast(peer->data)->displayName + "`4!```6]``", 0, false); 83 | Player::OnConsoleMessage(peer, "`6[```4Trade canceled by " + static_cast(peer->data)->displayName + "`4!```6]``"); 84 | Player::OnTextOverlay(peer, "`6[```4Trade canceled by " + static_cast(peer->data)->displayName + "`4!```6]``"); 85 | } else { 86 | Player::OnConsoleMessage(peer, static_cast(peer->data)->displayName + " `ois too busy to trade!"); 87 | Player::OnTextOverlay(peer, static_cast(peer->data)->displayName + " `wis too busy to trade!"); 88 | } 89 | Player::OnForceTradeEnd(peer); 90 | static_cast(peer->data)->trade_netid = -1; 91 | static_cast(peer->data)->trade = false; 92 | static_cast(peer->data)->tradeItems.clear(); 93 | static_cast(peer->data)->trade_accept = false; 94 | static_cast(peer->data)->trade_confirmed = false; 95 | } 96 | 97 | inline void start_trade(ENetPeer* peer1, ENetPeer* peer2) { 98 | PlayerInfo* pinfo = (PlayerInfo*)peer1->data; 99 | PlayerInfo* pinfo2 = (PlayerInfo*)peer2->data; 100 | bool illegal_trade = false; 101 | for (auto& f : pinfo->tradeItems) { 102 | auto contains = false; 103 | SearchInventoryItem(peer1, f.id, f.count, contains); 104 | if (!contains) { 105 | illegal_trade = true; 106 | break; 107 | } 108 | } if (illegal_trade) { 109 | pinfo->tradeItems.clear(); 110 | } for (auto& f : pinfo2->tradeItems) { 111 | auto contains = false; 112 | SearchInventoryItem(peer2, f.id, f.count, contains); 113 | if (!contains) { 114 | illegal_trade = true; 115 | break; 116 | } 117 | } if (illegal_trade) { 118 | pinfo2->tradeItems.clear(); 119 | } 120 | pinfo->trade = true; 121 | pinfo2->trade = true; 122 | pinfo->trade_confirmed = false; 123 | pinfo2->trade_confirmed = false; 124 | Player::OnTradeStatus(peer1, pinfo->netID, "`oSelect an item from the inventory.``", "", FormatTradeItems(pinfo->tradeItems) + "\nlocked|0\nreset_locks|1\naccepted|" + to_string(pinfo->trade_accept) + "\n"); 125 | Player::OnTradeStatus(peer1, pinfo2->netID, "`w" + pinfo2->displayName + "`o's offer.``", "", FormatTradeItems(pinfo2->tradeItems) + "\nlocked|0\naccepted|" + to_string(pinfo2->trade_accept) + "\n"); 126 | Player::OnTradeStatus(peer2, pinfo2->netID, "`oSelect an item from the inventory.``", "", FormatTradeItems(pinfo2->tradeItems) + "\nlocked|0\naccepted|" + to_string(pinfo2->trade_accept) + "\n"); 127 | Player::OnTradeStatus(peer2, pinfo->netID, "`w" + pinfo->displayName + "`o's offer.``", "", FormatTradeItems(pinfo->tradeItems) + "\nlocked|0\nreset_locks|1\naccepted|" + to_string(pinfo->trade_accept) + "\n"); 128 | update_trade(peer1, static_cast(peer1->data)->trade_netid, true); 129 | } -------------------------------------------------------------------------------- /save_system.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | inline void save_manager() { 5 | while (true) { 6 | Sleep(60000); 7 | global_loop_tick++; 8 | if (global_loop_tick >= 6) { 9 | threads.push_back(std::thread(WorldEvents)); 10 | global_loop_tick = 0; 11 | } 12 | LoadEvents(); 13 | for (ENetPeer* currentPeer = server->peers; currentPeer < &server->peers[server->peerCount]; ++currentPeer) { 14 | if (currentPeer->state != ENET_PEER_STATE_CONNECTED || currentPeer->data == NULL) continue; 15 | if (!static_cast(currentPeer->data)->haveGrowId || static_cast(currentPeer->data)->currentWorld == "EXIT" || !static_cast(currentPeer->data)->isIn) continue; 16 | if (static_cast(currentPeer->data)->isCursed) { 17 | auto cooldownleft = calcBanDuration(static_cast(currentPeer->data)->lastCursed); 18 | if (cooldownleft < 1) { 19 | Player::OnConsoleMessage(currentPeer, "You are no longer bound to the netherworld, you're free to go. (`$Curse ``mod removed)"); 20 | static_cast(currentPeer->data)->skinColor = 0x8295C3FF; 21 | sendClothes(currentPeer); 22 | static_cast(currentPeer->data)->isCursed = false; 23 | send_state(currentPeer); 24 | static_cast(currentPeer->data)->lastCursed = 0; 25 | } 26 | } 27 | if (static_cast(currentPeer->data)->Fishing && !static_cast(currentPeer->data)->TriggerFish && static_cast(currentPeer->data)->FishPosX != 0 && static_cast(currentPeer->data)->FishPosY != 0) { 28 | if (rand() % 100 <= 50) { 29 | static_cast(currentPeer->data)->TriggerFish = true; 30 | for (auto currentPeers = server->peers; currentPeers < &server->peers[server->peerCount]; ++currentPeers) { 31 | if (currentPeers->state != ENET_PEER_STATE_CONNECTED) continue; 32 | if (isHere(currentPeer, currentPeers)) { 33 | Player::OnParticleEffect(currentPeers, 36, static_cast(currentPeer->data)->FishPosX, static_cast(currentPeer->data)->FishPosY, 0); 34 | Player::PlayAudio(currentPeers, "audio/splash.wav", 0); 35 | } 36 | } 37 | } 38 | } 39 | if (static_cast(currentPeer->data)->isDuctaped) { 40 | auto cooldownleft = calcBanDuration(static_cast(currentPeer->data)->lastMuted); 41 | if (cooldownleft < 1) { 42 | Player::OnConsoleMessage(currentPeer, "You've free to talk again! (`$Muted`` mod removed)"); 43 | static_cast(currentPeer->data)->taped = false; 44 | static_cast(currentPeer->data)->isDuctaped = false; 45 | static_cast(currentPeer->data)->cantsay = false; 46 | static_cast(currentPeer->data)->lastMuted = 0; 47 | send_state(currentPeer); 48 | sendClothes(currentPeer); 49 | } 50 | } 51 | if (static_cast(currentPeer->data)->SurgeryCooldown) { 52 | auto cooldownleft = calcBanDuration(static_cast(currentPeer->data)->SurgeryTime); 53 | if (cooldownleft < 1) { 54 | Player::OnConsoleMessage(currentPeer, "You've paid your debt to society! (`$Malpractice`` mod removed)"); 55 | sendSound(currentPeer, "audio/dialog_confirm.wav"); 56 | static_cast(currentPeer->data)->SurgeryCooldown = false; 57 | static_cast(currentPeer->data)->SurgeryTime = 0; 58 | } 59 | } 60 | if (static_cast(currentPeer->data)->PunchPotion) { 61 | auto cooldownleft = calcBanDuration(static_cast(currentPeer->data)->usedPunchPotion); 62 | if (cooldownleft < 1) { 63 | Player::OnConsoleMessage(currentPeer, "You feel weak again. (`$One HIT `omod removed)"); 64 | sendSound(currentPeer, "audio/dialog_confirm.wav"); 65 | static_cast(currentPeer->data)->PunchPotion = false; 66 | static_cast(currentPeer->data)->usedPunchPotion = 0; 67 | } 68 | } 69 | if (static_cast(currentPeer->data)->PlacePotion) { 70 | auto cooldownleft = calcBanDuration(static_cast(currentPeer->data)->usedPlacePotion); 71 | if (cooldownleft < 1) { 72 | Player::OnConsoleMessage(currentPeer, "Your hands shrinks again. (`$Triple Place `omod removed)"); 73 | sendSound(currentPeer, "audio/dialog_confirm.wav"); 74 | static_cast(currentPeer->data)->PlacePotion = false; 75 | static_cast(currentPeer->data)->usedPlacePotion = 0; 76 | } 77 | } 78 | if (static_cast(currentPeer->data)->GeigerCooldown) { 79 | auto cooldownleft = calcBanDuration(static_cast(currentPeer->data)->GeigerTime); 80 | if (cooldownleft < 1) { 81 | Player::OnConsoleMessage(currentPeer, "You've no longer radioactive! (`$Irradiated`` mod removed)"); 82 | sendSound(currentPeer, "audio/dialog_confirm.wav"); 83 | if (static_cast(currentPeer->data)->cloth_necklace != 4656) { 84 | static_cast(currentPeer->data)->haveGeigerRadiation = false; 85 | send_state(currentPeer); 86 | } 87 | static_cast(currentPeer->data)->GeigerCooldown = false; 88 | static_cast(currentPeer->data)->GeigerTime = 0; 89 | } 90 | } 91 | save_playerinfo(static_cast(currentPeer->data)); 92 | } try { 93 | for (int i = 0; i < worlds.size(); i++) { 94 | if (worlds.at(i).name != "EXIT" && worlds.at(i).name != "error") { 95 | try { 96 | WorldInfo info = worlds.at(i); 97 | if (info.saved) continue; 98 | json j; 99 | json WorldTiles = json::array(); 100 | int current_update_id = 0; 101 | const int square = info.width * info.height; 102 | json WorldDropped = json::array(); 103 | for (int i = 0; i < square; i++) { 104 | json tile; 105 | tile["fg"] = info.items.at(i).foreground; 106 | tile["bg"] = info.items.at(i).background; 107 | tile["s"] = info.items.at(i).sign; 108 | tile["r"] = info.items.at(i).flipped; 109 | tile["int"] = info.items.at(i).intdata; 110 | tile["l"] = info.items.at(i).label; 111 | tile["d"] = info.items.at(i).destWorld; 112 | tile["did"] = info.items.at(i).destId; 113 | tile["crid"] = info.items.at(i).currId; 114 | tile["p"] = info.items.at(i).password; 115 | tile["mid"] = info.items.at(i).mid; 116 | tile["mc"] = info.items.at(i).mc; 117 | tile["rm"] = info.items.at(i).rm; 118 | tile["open"] = info.items.at(i).opened; 119 | tile["vc"] = info.items.at(i).vcount; 120 | tile["vd"] = info.items.at(i).vdraw; 121 | tile["vid"] = info.items.at(i).vid; 122 | tile["vp"] = info.items.at(i).vprice; 123 | tile["how"] = info.items.at(i).monitorname; 124 | tile["mon"] = info.items.at(i).monitoronline; 125 | tile["spl"] = info.items.at(i).spliced; 126 | tile["a"] = info.items.at(i).activated; 127 | tile["sgt"] = info.items.at(i).growtime; 128 | tile["sfc"] = info.items.at(i).fruitcount; 129 | tile["w"] = info.items.at(i).water; 130 | tile["f"] = info.items.at(i).fire; 131 | tile["red"] = info.items.at(i).red; 132 | tile["gre"] = info.items.at(i).green; 133 | tile["blu"] = info.items.at(i).blue; 134 | tile["es"] = info.items.at(i).evolvestage; 135 | WorldTiles.push_back(tile); 136 | tile.clear(); 137 | } for (int i = 0; i < info.droppedItems.size(); i++) { 138 | json droppedJ; 139 | droppedJ["c"] = static_cast(info.droppedItems.at(i).count); 140 | droppedJ["id"] = static_cast(info.droppedItems.at(i).id); 141 | droppedJ["x"] = info.droppedItems.at(i).x; 142 | droppedJ["y"] = info.droppedItems.at(i).y; 143 | droppedJ["uid"] = info.droppedItems.at(i).uid; 144 | WorldDropped.push_back(droppedJ); 145 | droppedJ.clear(); 146 | } 147 | j["name"] = info.name; 148 | j["owner"] = info.owner; 149 | string world_admins = ""; 150 | for (int i = 0; i < info.accessed.size(); i++) { 151 | world_admins += info.accessed.at(i) + "|"; 152 | } 153 | j["admins"] = world_admins; 154 | j["nuked"] = info.isNuked; 155 | j["public"] = info.isPublic; 156 | j["weather"] = info.weather; 157 | j["publicBlock"] = info.publicBlock; 158 | j["silence"] = info.silence; 159 | j["update_id"] = 0; 160 | j["disableDrop"] = info.DisableDrop; 161 | j["category"] = info.category; 162 | j["rating"] = info.rating; 163 | j["entrylevel"] = info.entrylevel; 164 | j["width"] = info.width; 165 | j["height"] = info.height; 166 | j["tiles"] = WorldTiles; 167 | j["dropped"] = WorldDropped; 168 | j["rainbow"] = info.rainbow; 169 | ofstream write_player("save/worlds/_" + info.name + ".json"); 170 | write_player << j << std::endl; 171 | write_player.close(); 172 | j.clear(); 173 | WorldTiles.clear(); 174 | WorldDropped.clear(); 175 | info.saved = true; 176 | } 177 | catch (const std::out_of_range& e) { 178 | std::cout << e.what() << std::endl; 179 | } 180 | catch (std::exception& e) { 181 | cout << e.what() << endl; 182 | } 183 | } 184 | } 185 | } 186 | catch (const std::out_of_range& e) { 187 | std::cout << e.what() << std::endl; 188 | } if (GlobalMaintenance) { 189 | SendConsole("Worlds are now saved! server shutted down as requested by one player", "INFO"); 190 | system("PAUSE"); 191 | exit(0); 192 | } 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /source/App.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * App.cpp 3 | * Created by Seth Robinson on 3/6/09. 4 | * For license info, check the license.txt file that should have come with this. 5 | * 6 | */ 7 | 8 | #include "PlatformPrecomp.h" 9 | #include "App.h" 10 | #include "GUI/MainMenu.h" 11 | #include "Renderer/LinearParticle.h" 12 | #include "Entity/EntityUtils.h"//create the classes that our globally library expects to exist somewhere. 13 | #include "Renderer/SoftSurface.h" 14 | #include "GUI/AboutMenu.h" 15 | 16 | SurfaceAnim g_surf; 17 | 18 | MessageManager g_messageManager; 19 | MessageManager * GetMessageManager() {return &g_messageManager;} 20 | 21 | FileManager g_fileManager; 22 | FileManager * GetFileManager() {return &g_fileManager;} 23 | 24 | #ifdef __APPLE__ 25 | 26 | #if TARGET_OS_IPHONE == 1 27 | //it's an iPhone or iPad 28 | //#include "Audio/AudioManagerOS.h" 29 | //AudioManagerOS g_audioManager; 30 | #include "Audio/AudioManagerDenshion.h" 31 | 32 | AudioManagerDenshion g_audioManager; 33 | #else 34 | //it's being compiled as a native OSX app 35 | #include "Audio/AudioManagerFMOD.h" 36 | AudioManagerFMOD g_audioManager; //dummy with no sound 37 | 38 | //in theory, CocosDenshion should work for the Mac builds, but right now it seems to want a big chunk of 39 | //Cocos2d included so I'm not fiddling with it for now 40 | 41 | //#include "Audio/AudioManagerDenshion.h" 42 | //AudioManagerDenshion g_audioManager; 43 | #endif 44 | 45 | #else 46 | 47 | #if defined RT_WEBOS || defined RTLINUX || defined PLATFORM_HTML5 48 | #include "Audio/AudioManagerSDL.h" 49 | AudioManagerSDL g_audioManager; //sound in windows/WebOS/Linux/html5 50 | //AudioManager g_audioManager; //to disable sound 51 | #elif defined ANDROID_NDK 52 | #include "Audio/AudioManagerAndroid.h" 53 | AudioManagerAndroid g_audioManager; //sound for android 54 | #elif defined PLATFORM_BBX 55 | #include "Audio/AudioManagerBBX.h" 56 | //AudioManager g_audioManager; //to disable sound 57 | AudioManagerBBX g_audioManager; 58 | #elif defined PLATFORM_FLASH 59 | //AudioManager g_audioManager; //to disable sound 60 | #include "Audio/AudioManagerFlash.h" 61 | AudioManagerFlash *g_audioManager = new AudioManagerFlash; 62 | #else 63 | 64 | 65 | //in windows 66 | //AudioManager g_audioManager; //to disable sound 67 | 68 | #ifdef RT_USE_SDL_AUDIO 69 | #include "Audio/AudioManagerSDL.h" 70 | AudioManagerSDL g_audioManager; //sound in windows and WebOS 71 | 72 | #elif defined RT_FLASH_TEST 73 | #include "Audio/AudioManagerFlash.h" 74 | AudioManagerFlash g_audioManager; 75 | #else 76 | #include "Audio/AudioManagerAudiere.h" 77 | AudioManagerAudiere g_audioManager; //Use Audiere for audio 78 | #endif 79 | //#include "Audio/AudioManagerFMOD.h" 80 | //AudioManagerFMOD g_audioManager; //if we wanted FMOD sound in windows 81 | 82 | #endif 83 | #endif 84 | 85 | #if defined PLATFORM_FLASH 86 | AudioManager * GetAudioManager(){return g_audioManager;} 87 | #else 88 | AudioManager * GetAudioManager(){return &g_audioManager;} 89 | #endif 90 | 91 | App *g_pApp = NULL; 92 | BaseApp * GetBaseApp() 93 | { 94 | if (!g_pApp) 95 | { 96 | #ifndef NDEBUG 97 | LogMsg("Creating app object"); 98 | #endif 99 | g_pApp = new App; 100 | } 101 | 102 | return g_pApp; 103 | } 104 | 105 | App * GetApp() 106 | { 107 | return g_pApp; 108 | } 109 | 110 | App::App() 111 | { 112 | m_bDidPostInit = false; 113 | } 114 | 115 | App::~App() 116 | { 117 | L_ParticleSystem::deinit(); 118 | #ifdef PLATFORM_FLASH 119 | SAFE_DELETE(g_audioManager); 120 | #endif 121 | } 122 | 123 | void App::OnExitApp(VariantList *pVarList) 124 | { 125 | LogMsg("Exiting the app"); 126 | 127 | OSMessage o; 128 | o.m_type = OSMessage::MESSAGE_FINISH_APP; 129 | GetBaseApp()->AddOSMessage(o); 130 | } 131 | 132 | bool App::Init() 133 | { 134 | //SetDefaultAudioClickSound("audio/enter.wav"); 135 | SetDefaultButtonStyle(Button2DComponent::BUTTON_STYLE_CLICK_ON_TOUCH_RELEASE); 136 | //SetManualRotationMode(true); //commented out, so iOS will handle rotations, plays better with 3rd party libs and looks cool 137 | 138 | bool bScaleScreenActive = true; //if true, we'll stretch every screen to the coords below 139 | int scaleToX = 480; 140 | int scaleToY = 320; 141 | 142 | switch (GetEmulatedPlatformID()) 143 | { 144 | //special handling for certain platforms to tweak the video settings 145 | 146 | case PLATFORM_ID_WEBOS: 147 | //if we do this, everything will be stretched/zoomed to fit the screen 148 | if (IsIPADSize) 149 | { 150 | //doesn't need rotation 151 | SetLockedLandscape(false); //because it's set in the app manifest, we don't have to rotate ourselves 152 | SetupScreenInfo(GetPrimaryGLX(), GetPrimaryGLY(), ORIENTATION_PORTRAIT); 153 | if (bScaleScreenActive) 154 | SetupFakePrimaryScreenSize(scaleToX,scaleToY); //game will think it's this size, and will be scaled up 155 | } 156 | else 157 | { 158 | //but the phones do 159 | SetLockedLandscape(true); //we don't allow portrait mode for this game 160 | if (bScaleScreenActive) 161 | SetupFakePrimaryScreenSize(scaleToX,scaleToY); //game will think it's this size, and will be scaled up 162 | } 163 | 164 | break; 165 | 166 | case PLATFORM_ID_IOS: 167 | SetLockedLandscape(true); //we stay in portrait but manually rotate, gives better fps on older devices 168 | if (bScaleScreenActive) 169 | SetupFakePrimaryScreenSize(scaleToX,scaleToY); //game will think it's this size, and will be scaled up 170 | break; 171 | 172 | default: 173 | 174 | //Default settings for other platforms 175 | 176 | SetLockedLandscape(false); //we don't allow portrait mode for this game 177 | SetupScreenInfo(GetPrimaryGLX(), GetPrimaryGLY(), ORIENTATION_PORTRAIT); 178 | if (bScaleScreenActive) 179 | SetupFakePrimaryScreenSize(scaleToX,scaleToY); //game will think it's this size, and will be scaled up 180 | } 181 | 182 | L_ParticleSystem::init(2000); 183 | 184 | if (m_bInitted) 185 | { 186 | return true; 187 | } 188 | 189 | if (!BaseApp::Init()) return false; 190 | 191 | 192 | LogMsg("Save path is %s", GetSavePath().c_str()); 193 | 194 | if (!GetFont(FONT_SMALL)->Load("ui/font_century_gothic_bigx2.rtfont")) 195 | { 196 | LogMsg("Can't load font 1"); 197 | return false; 198 | } 199 | if (!GetFont(FONT_LARGE)->Load("ui/font_century_gothic_big.rtfont")) 200 | { 201 | LogMsg("Can't load font 2"); 202 | return false; 203 | } 204 | if (!GetFont(FONT_GT)->Load("ui/font_century_gothic_bigx2.rtfont")) 205 | { 206 | LogMsg("Can't load font 3"); 207 | return false; 208 | } 209 | //GetFont(FONT_SMALL)->SetSmoothing(false); //if we wanted to disable bilinear filtering on the font 210 | 211 | GetBaseApp()->SetFPSVisible(true); 212 | 213 | bool bFileExisted; 214 | m_varDB.Load("save.dat", &bFileExisted); 215 | 216 | //preload audio 217 | GetAudioManager()->Preload("audio/blank.wav"); 218 | GetAudioManager()->Preload("audio/click.wav"); 219 | //GetAudioManager()->Preload("audio/techno.mp3"); 220 | return true; 221 | } 222 | 223 | void App::SaveOurStuff() 224 | { 225 | LogMsg("Saving our stuff"); 226 | m_varDB.Save("save.dat"); 227 | } 228 | 229 | void App::Kill() 230 | { 231 | SaveOurStuff(); 232 | BaseApp::Kill(); 233 | g_pApp = NULL; 234 | } 235 | 236 | void App::Update() 237 | { 238 | BaseApp::Update(); 239 | 240 | if (!m_bDidPostInit) 241 | { 242 | m_bDidPostInit = true; 243 | m_special = GetSystemData() != C_PIRATED_NO; 244 | 245 | //build a dummy entity called "GUI" to put our GUI menu entities under 246 | Entity *pGUIEnt = GetEntityRoot()->AddEntity(new Entity("GUI")); 247 | MainMenuCreate(pGUIEnt); 248 | 249 | } 250 | 251 | } 252 | 253 | void App::Draw() 254 | { 255 | PrepareForGL(); 256 | // glClearColor(0.6,0.6,0.6,1); 257 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 258 | CLEAR_GL_ERRORS(); //needed for html5 259 | 260 | BaseApp::Draw(); 261 | } 262 | 263 | void App::OnEnterBackground() 264 | { 265 | BaseApp::OnEnterBackground(); 266 | SaveOurStuff(); 267 | 268 | } 269 | void App::OnScreenSizeChange() 270 | { 271 | BaseApp::OnScreenSizeChange(); 272 | } 273 | 274 | void App::GetServerInfo( string &server, uint32 &port ) 275 | { 276 | #if defined (_DEBUG) && defined(WIN32) 277 | server = "localhost"; 278 | port = 8080; 279 | 280 | //server = "www.rtsoft.com"; 281 | //port = 80; 282 | #else 283 | 284 | server = "rtsoft.com"; 285 | port = 80; 286 | #endif 287 | } 288 | 289 | int App::GetSpecial() 290 | { 291 | return m_special; //1 means pirated copy 292 | } 293 | 294 | Variant * App::GetVar( const string &keyName ) 295 | { 296 | return GetShared()->GetVar(keyName); 297 | } 298 | 299 | std::string App::GetVersionString() 300 | { 301 | return "V0.7"; 302 | } 303 | 304 | float App::GetVersion() 305 | { 306 | return 0.7f; 307 | } 308 | 309 | int App::GetBuild() 310 | { 311 | return 1; 312 | } 313 | 314 | const char * GetAppName() {return "SimpleApp";} 315 | 316 | //for palm webos and android 317 | const char * GetBundlePrefix() 318 | { 319 | const char * bundlePrefix = "com.rtsoft."; 320 | return bundlePrefix; 321 | } 322 | 323 | const char * GetBundleName() 324 | { 325 | const char * bundleName = "rtsimpleapp"; 326 | return bundleName; 327 | } 328 | 329 | bool App::OnPreInitVideo() 330 | { 331 | //only called for desktop systems 332 | //override in App.* if you want to do something here. You'd have to 333 | //extern these vars from main.cpp to change them... 334 | 335 | //SetEmulatedPlatformID(PLATFORM_ID_WINDOWS); 336 | #if defined (_DEBUG) && defined(WINAPI) 337 | SetPrimaryScreenSize(1024, 768); 338 | SetupScreenInfo(1024, 768, ORIENTATION_DONT_CARE); 339 | #endif 340 | return true; //no error 341 | } 342 | -------------------------------------------------------------------------------- /GTPS.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {2c3ede48-5a4e-4158-a05f-fbf6caffb61f} 25 | GTPS 26 | 10.0 27 | Growtopia 28 | 29 | 30 | 31 | Application 32 | true 33 | v142 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v142 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v142 47 | Unicode 48 | 49 | 50 | Application 51 | v142 52 | true 53 | MultiByte 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | false 78 | C:\Users\Almantas\Desktop\gtps\ 79 | C:\Users\Almantas\Desktop\gtps\project_files\bin\ 80 | C:\Users\Almantas\Desktop\gtps\project_files\curl\builds\libcurl-vc-x86-release-static-ipv6-sspi-schannel\include;$(IncludePath) 81 | C:\Users\Almantas\Desktop\gtps\project_files\curl\builds\libcurl-vc-x86-release-static-ipv6-sspi-schannel\lib;$(LibraryPath) 82 | 83 | 84 | true 85 | 86 | 87 | C:\Users\Almantas\Desktop\gtps\project_files\bin\ 88 | C:\Users\Almantas\Desktop\gtps\ 89 | C:\curl-7.70.0\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl\include;$(IncludePath) 90 | C:\curl-7.70.0\builds\libcurl-vc-x86-release-static-ipv6-sspi-winssl\lib;$(LibraryPath) 91 | 92 | 93 | 94 | Level3 95 | true 96 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 97 | true 98 | 99 | 100 | Console 101 | true 102 | 103 | 104 | 105 | 106 | Level3 107 | true 108 | true 109 | true 110 | _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING;WIN32;NDEBUG;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) 111 | true 112 | 113 | 114 | Console 115 | true 116 | true 117 | false 118 | libmysql.lib;Ws2_32.lib;libcurl_a.lib;Crypt32.lib;Wldap32.lib;Normaliz.lib;ws2_32.lib;winmm.lib;%(AdditionalDependencies) 119 | false 120 | UseLinkTimeCodeGeneration 121 | 122 | 123 | 124 | 125 | Level3 126 | true 127 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 128 | true 129 | 130 | 131 | Console 132 | true 133 | 134 | 135 | 136 | 137 | true 138 | _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 139 | true 140 | %(AdditionalIncludeDirectories) 141 | false 142 | /analyze:stacksize163840 %(AdditionalOptions) 143 | MaxSpeed 144 | Speed 145 | true 146 | Level3 147 | 148 | 149 | Console 150 | true 151 | true 152 | UseLinkTimeCodeGeneration 153 | MachineX64 154 | 67108864 155 | 67108864 156 | 67108864 157 | 67108864 158 | wininet.lib;libcurl_a.lib;Ws2_32.lib;Crypt32.lib;Wldap32.lib;Normaliz.lib;%(AdditionalDependencies) 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /source/GUI/EnterNameMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "PlatformPrecomp.h" 2 | #include "EnterNameMenu.h" 3 | #include "Entity/EntityUtils.h" 4 | #include "AboutMenu.h" 5 | #include "MainMenu.h" 6 | 7 | 8 | 9 | string tankIDname = ""; 10 | string tankIDpass = ""; 11 | 12 | string HighScoreNameFilter(string s) 13 | { 14 | string temp; 15 | 16 | for (unsigned int i=0; i < s.length(); i++) 17 | { 18 | if ( 19 | (s[i] >= 65 && s[i] <= 90) 20 | || (s[i] >= 97 && s[i] <= 122) 21 | ) 22 | { 23 | temp += s[i]; 24 | } 25 | } 26 | 27 | return temp; 28 | } 29 | 30 | void EnterNameMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from 31 | { 32 | Entity *pEntClicked = pVList->m_variant[1].GetEntity(); 33 | 34 | //LogMsg("Clicked %s entity at %s", pEntClicked->GetName().c_str(),pVList->m_variant[0].Print().c_str()); 35 | 36 | if (pEntClicked->GetName() == "check_question") 37 | { 38 | bool bChecked = pEntClicked->GetVar("checked")->GetUINT32()!=0; 39 | if (bChecked) 40 | { 41 | GetEntityRoot()->GetEntityByName("guestname_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(1)); 42 | GetEntityRoot()->GetEntityByName("name_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(0)); 43 | GetEntityRoot()->GetEntityByName("pass_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(0)); 44 | } else 45 | { 46 | GetEntityRoot()->GetEntityByName("guestname_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(0)); 47 | GetEntityRoot()->GetEntityByName("name_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(1)); 48 | GetEntityRoot()->GetEntityByName("pass_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(1)); 49 | } 50 | 51 | //either way, save it to our db which will get saved when the app closes. 52 | GetApp()->GetVar("like_checkboxes")->Set(uint32(bChecked)); 53 | 54 | } 55 | 56 | if (pEntClicked->GetName() == "Connect") 57 | { 58 | string name = GetEntityRoot()->GetEntityByName("name_input_box")->GetComponentByName("InputTextRender")->GetVar("text")->GetString(); 59 | string name3 = GetEntityRoot()->GetEntityByName("guestname_input_box")->GetComponentByName("InputTextRender")->GetVar("text")->GetString(); 60 | string name6 = GetEntityRoot()->GetEntityByName("pass_input_box")->GetComponentByName("InputTextRender")->GetVar("text")->GetString(); 61 | GetApp()->GetVar("name")->Set(name); //save it to our database so we can remember the default 62 | GetApp()->GetVar("pass")->Set(name6); //save it to our database so we can remember the default 63 | GetApp()->GetVar("guestname")->Set(name3); //save it to our database so we can remember the default 64 | tankIDname = name; 65 | tankIDpass = name6; 66 | //LogMsg("Read %s for the name", GetApp()->GetVar("name")->GetString().c_str()); 67 | SlideScreen(pEntClicked->GetParent(), false); 68 | GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); 69 | AboutMenuCreate(pEntClicked->GetParent()->GetParent()); 70 | } 71 | 72 | if (pEntClicked->GetName() == "Back") 73 | { 74 | DisableAllButtonsEntity(pEntClicked->GetParent()); 75 | SlideScreen(pEntClicked->GetParent(), false); 76 | GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); 77 | MainMenuCreate(pEntClicked->GetParent()->GetParent()); 78 | return; 79 | } 80 | 81 | } 82 | 83 | Entity * EnterNameMenuCreate(Entity *pParentEnt) 84 | { 85 | Entity* pBG = CreateOverlayEntity(pParentEnt, "EnterNameMenu", "ui/large/generic_menu.rttex", 0, 0); 86 | pBG->GetVar("scale2d")->Set(CL_Vec2f(0.47, 0.47)); 87 | AddFocusIfNeeded(pBG); 88 | 89 | Entity* pButtonEntity; 90 | CL_Vec2f vTextAreaPos = CL_Vec2f(240,10); 91 | CL_Vec2f vTextAreaBounds = CL_Vec2f(384,170); 92 | CL_Vec2f vTextAreaPos2 = CL_Vec2f(20, 35); 93 | CL_Vec2f vTextAreaBounds2 = CL_Vec2f(384, 170); 94 | 95 | pButtonEntity = CreateTextLabelEntity(pBG, "guestname", vTextAreaPos2.x, vTextAreaPos2.y, "Name: "); 96 | //pButtonEntity->GetVar("scale2d")->Set(CL_Vec2f(0.5f, 0.5f)); 97 | //pButtonEntity->GetComponentByName("TextRender")->GetVar("font")->Set(uint32(FONT_LARGE)); 98 | float nameWidth3 = pButtonEntity->GetVar("size2d")->GetVector2().x; 99 | 100 | //create input box 101 | pButtonEntity = CreateInputTextEntity(pBG, "guestname_input_box", vTextAreaPos2.x + nameWidth3, vTextAreaPos2.y, GetApp()->GetShared()->GetVarWithDefault("guestname", string("SolidWatch"))->GetString()); 102 | //pButtonEntity->GetVar("scale2d")->Set(CL_Vec2f(0.5f, 0.5f)); 103 | pButtonEntity->GetVar("size2d")->Set(CL_Vec2f(130, 22)); 104 | 105 | EntityComponent* pTextRenderComp3 = pButtonEntity->GetComponentByName("InputTextRender"); 106 | 107 | //To allow spaces and punctuation, we active loose filtering. Use FILTERING_STRICT instead for say, a highscore name 108 | pTextRenderComp3->GetVar("filtering")->Set(uint32(InputTextRenderComponent::FILTERING_LOOSE)); 109 | 110 | //you also need to do this for loose filtering to make sure the best keyboard is chosen on the device 111 | pTextRenderComp3->GetVar("inputType")->Set(uint32(InputTextRenderComponent::INPUT_TYPE_ASCII_FULL)); 112 | 113 | //control how many characters the user can enter 114 | pTextRenderComp3->GetVar("inputLengthMax")->Set(uint32(18)); 115 | 116 | //string title = "`$Input some stuff!"; 117 | //pButtonEntity = CreateTextLabelEntity(pBG, "title", vTextAreaPos.x, vTextAreaPos.y, title); 118 | //pButtonEntity->GetComponentByName("TextRender")->GetVar("font")->Set(uint32(FONT_LARGE)); 119 | //pButtonEntity->GetVar("scale2d")->Set(CL_Vec2f(0.6f, 0.6f)); 120 | vTextAreaPos.y += 25; 121 | 122 | //string msg = "`wEnter your name, then click Connect to go online!"; 123 | //Entity* pText = CreateTextBoxEntity(pBG, "text", vTextAreaPos, vTextAreaBounds, msg); 124 | //pText->GetVar("font")->Set(uint32(FONT_GT)); 125 | 126 | bool bLikeCheckboxes = GetApp()->GetVar("like_checkboxes")->GetUINT32() != 0; 127 | Entity* pCheckbox = CreateCheckbox(pBG, "check_question", "I have a `$GrowID", vTextAreaPos.x, vTextAreaPos.y, bLikeCheckboxes); 128 | pCheckbox->GetFunction("OnButtonSelected")->sig_function.connect(&EnterNameMenuOnSelect); 129 | 130 | float nameEntryY = vTextAreaPos.y + pCheckbox->GetVar("size2d")->GetVector2().y; //get the exact size that the 131 | //final word wrapped text actually took. 132 | nameEntryY += 10; //add some spacer too 133 | 134 | pButtonEntity = CreateTextLabelEntity(pBG, "name", vTextAreaPos.x, nameEntryY, "GrowID: "); 135 | //pButtonEntity->GetVar("scale2d")->Set(CL_Vec2f(0.5f, 0.5f)); 136 | //pButtonEntity->GetComponentByName("TextRender")->GetVar("font")->Set(uint32(FONT_LARGE)); 137 | float nameWidth = pButtonEntity->GetVar("size2d")->GetVector2().x; 138 | 139 | //create input box 140 | pButtonEntity = CreateInputTextEntity(pBG, "name_input_box", vTextAreaPos.x+nameWidth, nameEntryY, GetApp()->GetShared()->GetVarWithDefault("name", string(""))->GetString()); 141 | //pButtonEntity->GetVar("scale2d")->Set(CL_Vec2f(0.5f, 0.5f)); 142 | pButtonEntity->GetVar("size2d")->Set(CL_Vec2f(130, 22)); 143 | 144 | EntityComponent *pTextRenderComp = pButtonEntity->GetComponentByName("InputTextRender"); 145 | 146 | //To allow spaces and punctuation, we active loose filtering. Use FILTERING_STRICT instead for say, a highscore name 147 | pTextRenderComp->GetVar("filtering")->Set(uint32(InputTextRenderComponent::FILTERING_LOOSE)); 148 | 149 | //you also need to do this for loose filtering to make sure the best keyboard is chosen on the device 150 | pTextRenderComp->GetVar("inputType")->Set(uint32(InputTextRenderComponent::INPUT_TYPE_ASCII_FULL)); 151 | 152 | //control how many characters the user can enter 153 | pTextRenderComp->GetVar("inputLengthMax")->Set(uint32(18)); 154 | 155 | nameEntryY += 35; //add some spacer too 156 | pButtonEntity = CreateTextLabelEntity(pBG, "pass", vTextAreaPos.x, nameEntryY, "Password: "); 157 | //pButtonEntity->GetVar("scale2d")->Set(CL_Vec2f(0.5f, 0.5f)); 158 | //pButtonEntity->GetComponentByName("TextRender")->GetVar("font")->Set(uint32(FONT_LARGE)); 159 | float nameWidth2 = pButtonEntity->GetVar("size2d")->GetVector2().x; 160 | 161 | //create input box 162 | pButtonEntity = CreateInputTextEntity(pBG, "pass_input_box", vTextAreaPos.x + nameWidth2, nameEntryY, GetApp()->GetShared()->GetVarWithDefault("pass", string(""))->GetString()); 163 | //pButtonEntity->GetVar("scale2d")->Set(CL_Vec2f(0.5f, 0.5f)); 164 | pButtonEntity->GetVar("size2d")->Set(CL_Vec2f(130, 22)); 165 | 166 | EntityComponent* pTextRenderComp2 = pButtonEntity->GetComponentByName("InputTextRender"); 167 | 168 | //To allow spaces and punctuation, we active loose filtering. Use FILTERING_STRICT instead for say, a highscore name 169 | pTextRenderComp2->GetVar("filtering")->Set(uint32(InputTextRenderComponent::FILTERING_LOOSE)); 170 | 171 | //you also need to do this for loose filtering to make sure the best keyboard is chosen on the device 172 | pTextRenderComp2->GetVar("inputType")->Set(uint32(InputTextRenderComponent::INPUT_TYPE_ASCII_FULL)); 173 | 174 | //control how many characters the user can enter 175 | pTextRenderComp2->GetVar("inputLengthMax")->Set(uint32(18)); 176 | 177 | string title = "`wEnter your name, then click Connect to go online."; 178 | pButtonEntity = CreateTextLabelEntity(pBG, "title", vTextAreaPos2.x, vTextAreaPos2.y + 120, title); 179 | 180 | string title3 = "`wAn optional `$GrowID `wlets you play on multiple\ndevices without losing your stuff. To get one,\n`$Connect `wwithout one, then choose the `$Get GrowID\n`woption from the pause menu. It's free!"; 181 | pButtonEntity = CreateTextLabelEntity(pBG, "title", vTextAreaPos2.x, vTextAreaPos2.y + 160, title3); 182 | 183 | //show *'s, password mode 184 | //pTextRenderComp->GetVar("visualStyle")->Set((uint32)InputTextRenderComponent::STYLE_PASSWORD); 185 | 186 | 187 | //if you wanted text to appear until it's activated: 188 | //pTextRenderComp->GetVar("placeHolderText")->Set("Tap here to enter your name"); 189 | 190 | //to change the font of the text in the input box 191 | 192 | //the connect button 193 | 194 | if (!bLikeCheckboxes) 195 | { 196 | 197 | GetEntityRoot()->GetEntityByName("guestname_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(0)); 198 | GetEntityRoot()->GetEntityByName("name_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(1)); 199 | GetEntityRoot()->GetEntityByName("pass_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(1)); 200 | 201 | } 202 | else 203 | { 204 | GetEntityRoot()->GetEntityByName("guestname_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(1)); 205 | GetEntityRoot()->GetEntityByName("name_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(0)); 206 | GetEntityRoot()->GetEntityByName("pass_input_box")->GetComponentByName("InputTextRender")->GetVar("disabled")->Set(uint32(0)); 207 | } 208 | 209 | pButtonEntity = CreateTextButtonEntity(pBG, "Connect", vTextAreaPos2.x + 320, GetScreenSizeYf() - 30, "Connect", false); 210 | pButtonEntity->GetShared()->GetFunction("OnButtonSelected")->sig_function.connect(&EnterNameMenuOnSelect); 211 | Entity* pEnt = CreateTextButtonEntity(pBG, "Back", vTextAreaPos2.x, GetScreenSizeYf() - 30, "Back", false); 212 | pEnt->GetFunction("OnButtonSelected")->sig_function.connect(&EnterNameMenuOnSelect); 213 | SetupTextEntity(pEnt, FONT_SMALL); 214 | AddHotKeyToButton(pEnt, VIRTUAL_KEY_BACK); 215 | 216 | SlideScreen(pBG, true); 217 | return pBG; 218 | } 219 | 220 | 221 | -------------------------------------------------------------------------------- /enet/win32.c: -------------------------------------------------------------------------------- 1 | /** 2 | @file win32.c 3 | @brief ENet Win32 system specific functions 4 | */ 5 | #ifdef _WIN32 6 | 7 | #define ENET_BUILDING_LIB 1 8 | #include "include/enet.h" 9 | #include 10 | #include 11 | 12 | static enet_uint32 timeBase = 0; 13 | 14 | int 15 | enet_initialize (void) 16 | { 17 | WORD versionRequested = MAKEWORD (1, 1); 18 | WSADATA wsaData; 19 | 20 | if (WSAStartup (versionRequested, & wsaData)) 21 | return -1; 22 | 23 | if (LOBYTE (wsaData.wVersion) != 1|| 24 | HIBYTE (wsaData.wVersion) != 1) 25 | { 26 | WSACleanup (); 27 | 28 | return -1; 29 | } 30 | 31 | timeBeginPeriod (1); 32 | 33 | return 0; 34 | } 35 | 36 | void 37 | enet_deinitialize (void) 38 | { 39 | timeEndPeriod (1); 40 | 41 | WSACleanup (); 42 | } 43 | 44 | enet_uint32 45 | enet_host_random_seed (void) 46 | { 47 | return (enet_uint32) timeGetTime (); 48 | } 49 | 50 | enet_uint32 51 | enet_time_get (void) 52 | { 53 | return (enet_uint32) timeGetTime () - timeBase; 54 | } 55 | 56 | void 57 | enet_time_set (enet_uint32 newTimeBase) 58 | { 59 | timeBase = (enet_uint32) timeGetTime () - newTimeBase; 60 | } 61 | 62 | int 63 | enet_address_set_host_ip (ENetAddress * address, const char * name) 64 | { 65 | enet_uint8 vals [4] = { 0, 0, 0, 0 }; 66 | int i; 67 | 68 | for (i = 0; i < 4; ++ i) 69 | { 70 | const char * next = name + 1; 71 | if (* name != '0') 72 | { 73 | long val = strtol (name, (char **) & next, 10); 74 | if (val < 0 || val > 255 || next == name || next - name > 3) 75 | return -1; 76 | vals [i] = (enet_uint8) val; 77 | } 78 | 79 | if (* next != (i < 3 ? '.' : '\0')) 80 | return -1; 81 | name = next + 1; 82 | } 83 | 84 | memcpy (& address -> host, vals, sizeof (enet_uint32)); 85 | return 0; 86 | } 87 | 88 | int 89 | enet_address_set_host (ENetAddress * address, const char * name) 90 | { 91 | struct hostent * hostEntry; 92 | 93 | hostEntry = gethostbyname (name); 94 | if (hostEntry == NULL || 95 | hostEntry -> h_addrtype != AF_INET) 96 | return enet_address_set_host_ip (address, name); 97 | 98 | address -> host = * (enet_uint32 *) hostEntry -> h_addr_list [0]; 99 | 100 | return 0; 101 | } 102 | 103 | int 104 | enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameLength) 105 | { 106 | char * addr = inet_ntoa (* (struct in_addr *) & address -> host); 107 | if (addr == NULL) 108 | return -1; 109 | else 110 | { 111 | size_t addrLen = strlen(addr); 112 | if (addrLen >= nameLength) 113 | return -1; 114 | memcpy (name, addr, addrLen + 1); 115 | } 116 | return 0; 117 | } 118 | 119 | int 120 | enet_address_get_host (const ENetAddress * address, char * name, size_t nameLength) 121 | { 122 | struct in_addr in; 123 | struct hostent * hostEntry; 124 | 125 | in.s_addr = address -> host; 126 | 127 | hostEntry = gethostbyaddr ((char *) & in, sizeof (struct in_addr), AF_INET); 128 | if (hostEntry == NULL) 129 | return enet_address_get_host_ip (address, name, nameLength); 130 | else 131 | { 132 | size_t hostLen = strlen (hostEntry -> h_name); 133 | if (hostLen >= nameLength) 134 | return -1; 135 | memcpy (name, hostEntry -> h_name, hostLen + 1); 136 | } 137 | 138 | return 0; 139 | } 140 | 141 | int 142 | enet_socket_bind (ENetSocket socket, const ENetAddress * address) 143 | { 144 | struct sockaddr_in sin; 145 | 146 | memset (& sin, 0, sizeof (struct sockaddr_in)); 147 | 148 | sin.sin_family = AF_INET; 149 | 150 | if (address != NULL) 151 | { 152 | sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); 153 | sin.sin_addr.s_addr = address -> host; 154 | } 155 | else 156 | { 157 | sin.sin_port = 0; 158 | sin.sin_addr.s_addr = INADDR_ANY; 159 | } 160 | 161 | return bind (socket, 162 | (struct sockaddr *) & sin, 163 | sizeof (struct sockaddr_in)) == SOCKET_ERROR ? -1 : 0; 164 | } 165 | 166 | int 167 | enet_socket_get_address (ENetSocket socket, ENetAddress * address) 168 | { 169 | struct sockaddr_in sin; 170 | int sinLength = sizeof (struct sockaddr_in); 171 | 172 | if (getsockname (socket, (struct sockaddr *) & sin, & sinLength) == -1) 173 | return -1; 174 | 175 | address -> host = (enet_uint32) sin.sin_addr.s_addr; 176 | address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); 177 | 178 | return 0; 179 | } 180 | 181 | int 182 | enet_socket_listen (ENetSocket socket, int backlog) 183 | { 184 | return listen (socket, backlog < 0 ? SOMAXCONN : backlog) == SOCKET_ERROR ? -1 : 0; 185 | } 186 | 187 | ENetSocket 188 | enet_socket_create (ENetSocketType type) 189 | { 190 | return socket (PF_INET, type == ENET_SOCKET_TYPE_DATAGRAM ? SOCK_DGRAM : SOCK_STREAM, 0); 191 | } 192 | 193 | int 194 | enet_socket_set_option (ENetSocket socket, ENetSocketOption option, int value) 195 | { 196 | int result = SOCKET_ERROR; 197 | switch (option) 198 | { 199 | case ENET_SOCKOPT_NONBLOCK: 200 | { 201 | u_long nonBlocking = (u_long) value; 202 | result = ioctlsocket (socket, FIONBIO, & nonBlocking); 203 | break; 204 | } 205 | 206 | case ENET_SOCKOPT_BROADCAST: 207 | result = setsockopt (socket, SOL_SOCKET, SO_BROADCAST, (char *) & value, sizeof (int)); 208 | break; 209 | 210 | case ENET_SOCKOPT_REUSEADDR: 211 | result = setsockopt (socket, SOL_SOCKET, SO_REUSEADDR, (char *) & value, sizeof (int)); 212 | break; 213 | 214 | case ENET_SOCKOPT_RCVBUF: 215 | result = setsockopt (socket, SOL_SOCKET, SO_RCVBUF, (char *) & value, sizeof (int)); 216 | break; 217 | 218 | case ENET_SOCKOPT_SNDBUF: 219 | result = setsockopt (socket, SOL_SOCKET, SO_SNDBUF, (char *) & value, sizeof (int)); 220 | break; 221 | 222 | case ENET_SOCKOPT_RCVTIMEO: 223 | result = setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, (char *) & value, sizeof (int)); 224 | break; 225 | 226 | case ENET_SOCKOPT_SNDTIMEO: 227 | result = setsockopt (socket, SOL_SOCKET, SO_SNDTIMEO, (char *) & value, sizeof (int)); 228 | break; 229 | 230 | case ENET_SOCKOPT_NODELAY: 231 | result = setsockopt (socket, IPPROTO_TCP, TCP_NODELAY, (char *) & value, sizeof (int)); 232 | break; 233 | 234 | default: 235 | break; 236 | } 237 | return result == SOCKET_ERROR ? -1 : 0; 238 | } 239 | 240 | int 241 | enet_socket_get_option (ENetSocket socket, ENetSocketOption option, int * value) 242 | { 243 | int result = SOCKET_ERROR, len; 244 | switch (option) 245 | { 246 | case ENET_SOCKOPT_ERROR: 247 | len = sizeof(int); 248 | result = getsockopt (socket, SOL_SOCKET, SO_ERROR, (char *) value, & len); 249 | break; 250 | 251 | default: 252 | break; 253 | } 254 | return result == SOCKET_ERROR ? -1 : 0; 255 | } 256 | 257 | int 258 | enet_socket_connect (ENetSocket socket, const ENetAddress * address) 259 | { 260 | struct sockaddr_in sin; 261 | int result; 262 | 263 | memset (& sin, 0, sizeof (struct sockaddr_in)); 264 | 265 | sin.sin_family = AF_INET; 266 | sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); 267 | sin.sin_addr.s_addr = address -> host; 268 | 269 | result = connect (socket, (struct sockaddr *) & sin, sizeof (struct sockaddr_in)); 270 | if (result == SOCKET_ERROR && WSAGetLastError () != WSAEWOULDBLOCK) 271 | return -1; 272 | 273 | return 0; 274 | } 275 | 276 | ENetSocket 277 | enet_socket_accept (ENetSocket socket, ENetAddress * address) 278 | { 279 | SOCKET result; 280 | struct sockaddr_in sin; 281 | int sinLength = sizeof (struct sockaddr_in); 282 | 283 | result = accept (socket, 284 | address != NULL ? (struct sockaddr *) & sin : NULL, 285 | address != NULL ? & sinLength : NULL); 286 | 287 | if (result == INVALID_SOCKET) 288 | return ENET_SOCKET_NULL; 289 | 290 | if (address != NULL) 291 | { 292 | address -> host = (enet_uint32) sin.sin_addr.s_addr; 293 | address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); 294 | } 295 | 296 | return result; 297 | } 298 | 299 | int 300 | enet_socket_shutdown (ENetSocket socket, ENetSocketShutdown how) 301 | { 302 | return shutdown (socket, (int) how) == SOCKET_ERROR ? -1 : 0; 303 | } 304 | 305 | void 306 | enet_socket_destroy (ENetSocket socket) 307 | { 308 | if (socket != INVALID_SOCKET) 309 | closesocket (socket); 310 | } 311 | 312 | int 313 | enet_socket_send (ENetSocket socket, 314 | const ENetAddress * address, 315 | const ENetBuffer * buffers, 316 | size_t bufferCount) 317 | { 318 | struct sockaddr_in sin; 319 | DWORD sentLength = 0; 320 | 321 | if (address != NULL) 322 | { 323 | memset (& sin, 0, sizeof (struct sockaddr_in)); 324 | 325 | sin.sin_family = AF_INET; 326 | sin.sin_port = ENET_HOST_TO_NET_16 (address -> port); 327 | sin.sin_addr.s_addr = address -> host; 328 | } 329 | 330 | if (WSASendTo (socket, 331 | (LPWSABUF) buffers, 332 | (DWORD) bufferCount, 333 | & sentLength, 334 | 0, 335 | address != NULL ? (struct sockaddr *) & sin : NULL, 336 | address != NULL ? sizeof (struct sockaddr_in) : 0, 337 | NULL, 338 | NULL) == SOCKET_ERROR) 339 | { 340 | if (WSAGetLastError () == WSAEWOULDBLOCK) 341 | return 0; 342 | 343 | return -1; 344 | } 345 | 346 | return (int) sentLength; 347 | } 348 | 349 | int 350 | enet_socket_receive (ENetSocket socket, 351 | ENetAddress * address, 352 | ENetBuffer * buffers, 353 | size_t bufferCount) 354 | { 355 | INT sinLength = sizeof (struct sockaddr_in); 356 | DWORD flags = 0, 357 | recvLength = 0; 358 | struct sockaddr_in sin; 359 | 360 | if (WSARecvFrom (socket, 361 | (LPWSABUF) buffers, 362 | (DWORD) bufferCount, 363 | & recvLength, 364 | & flags, 365 | address != NULL ? (struct sockaddr *) & sin : NULL, 366 | address != NULL ? & sinLength : NULL, 367 | NULL, 368 | NULL) == SOCKET_ERROR) 369 | { 370 | switch (WSAGetLastError ()) 371 | { 372 | case WSAEWOULDBLOCK: 373 | case WSAECONNRESET: 374 | return 0; 375 | } 376 | 377 | return -1; 378 | } 379 | 380 | if (flags & MSG_PARTIAL) 381 | return -1; 382 | 383 | if (address != NULL) 384 | { 385 | address -> host = (enet_uint32) sin.sin_addr.s_addr; 386 | address -> port = ENET_NET_TO_HOST_16 (sin.sin_port); 387 | } 388 | 389 | return (int) recvLength; 390 | } 391 | 392 | int 393 | enet_socketset_select (ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocketSet * writeSet, enet_uint32 timeout) 394 | { 395 | struct timeval timeVal; 396 | 397 | timeVal.tv_sec = timeout / 1000; 398 | timeVal.tv_usec = (timeout % 1000) * 1000; 399 | 400 | return select (maxSocket + 1, readSet, writeSet, NULL, & timeVal); 401 | } 402 | 403 | int 404 | enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout) 405 | { 406 | fd_set readSet, writeSet; 407 | struct timeval timeVal; 408 | int selectCount; 409 | 410 | timeVal.tv_sec = timeout / 1000; 411 | timeVal.tv_usec = (timeout % 1000) * 1000; 412 | 413 | FD_ZERO (& readSet); 414 | FD_ZERO (& writeSet); 415 | 416 | if (* condition & ENET_SOCKET_WAIT_SEND) 417 | FD_SET (socket, & writeSet); 418 | 419 | if (* condition & ENET_SOCKET_WAIT_RECEIVE) 420 | FD_SET (socket, & readSet); 421 | 422 | selectCount = select (socket + 1, & readSet, & writeSet, NULL, & timeVal); 423 | 424 | if (selectCount < 0) 425 | return -1; 426 | 427 | * condition = ENET_SOCKET_WAIT_NONE; 428 | 429 | if (selectCount == 0) 430 | return 0; 431 | 432 | if (FD_ISSET (socket, & writeSet)) 433 | * condition |= ENET_SOCKET_WAIT_SEND; 434 | 435 | if (FD_ISSET (socket, & readSet)) 436 | * condition |= ENET_SOCKET_WAIT_RECEIVE; 437 | 438 | return 0; 439 | } 440 | 441 | #endif 442 | 443 | -------------------------------------------------------------------------------- /source/GUI/AboutMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "PlatformPrecomp.h" 2 | #include "AboutMenu.h" 3 | #include "EnterNameMenu.h" 4 | #include "Entity/EntityUtils.h" 5 | #include "Entity/RenderScissorComponent.h" 6 | #include "enet/enet.h" 7 | #include "App.h" 8 | #include 9 | #include "proton/hash.hpp" 10 | #include "proton/rtparam.hpp" 11 | #include "proton/variant.hpp" 12 | #define get_packet_type(packet) (packet->dataLength > 3 ? *packet->data : 0) 13 | 14 | struct gameupdatepacket_t { 15 | uint8_t m_type; 16 | uint8_t m_netid; 17 | uint8_t m_jump_amount; 18 | uint8_t m_count; 19 | int32_t m_player_flags; 20 | int32_t m_item; 21 | int32_t m_packet_flags; 22 | float m_struct_flags; 23 | int32_t m_int_data; 24 | float m_vec_x; 25 | float m_vec_y; 26 | float m_vec2_x; 27 | float m_vec2_y; 28 | float m_particle_time; 29 | uint32_t m_state1; 30 | uint32_t m_state2; 31 | uint32_t m_data_size; 32 | uint32_t m_data; 33 | }; 34 | 35 | enum { 36 | PACKET_STATE = 0, 37 | PACKET_CALL_FUNCTION, 38 | PACKET_UPDATE_STATUS, 39 | PACKET_TILE_CHANGE_REQUEST, 40 | PACKET_SEND_MAP_DATA, 41 | PACKET_SEND_TILE_UPDATE_DATA, 42 | PACKET_SEND_TILE_UPDATE_DATA_MULTIPLE, 43 | PACKET_TILE_ACTIVATE_REQUEST, 44 | PACKET_TILE_APPLY_DAMAGE, 45 | PACKET_SEND_INVENTORY_STATE, 46 | PACKET_ITEM_ACTIVATE_REQUEST, 47 | PACKET_ITEM_ACTIVATE_OBJECT_REQUEST, 48 | PACKET_SEND_TILE_TREE_STATE, 49 | PACKET_MODIFY_ITEM_INVENTORY, 50 | PACKET_ITEM_CHANGE_OBJECT, 51 | PACKET_SEND_LOCK, 52 | PACKET_SEND_ITEM_DATABASE_DATA, 53 | PACKET_SEND_PARTICLE_EFFECT, 54 | PACKET_SET_ICON_STATE, 55 | PACKET_ITEM_EFFECT, 56 | PACKET_SET_CHARACTER_STATE, 57 | PACKET_PING_REPLY, 58 | PACKET_PING_REQUEST, 59 | PACKET_GOT_PUNCHED, 60 | PACKET_APP_CHECK_RESPONSE, 61 | PACKET_APP_INTEGRITY_FAIL, 62 | PACKET_DISCONNECT, 63 | PACKET_BATTLE_JOIN, 64 | PACKET_BATTLE_EVEN, 65 | PACKET_USE_DOOR, 66 | PACKET_SEND_PARENTAL, 67 | PACKET_GONE_FISHIN, 68 | PACKET_STEAM, 69 | PACKET_PET_BATTLE, 70 | PACKET_NPC, 71 | PACKET_SPECIAL, 72 | PACKET_SEND_PARTICLE_EFFECT_V2, 73 | GAME_ACTIVE_ARROW_TO_ITEM, 74 | GAME_SELECT_TILE_INDEX 75 | }; 76 | 77 | enum { 78 | NET_MESSAGE_UNKNOWN = 0, 79 | NET_MESSAGE_SERVER_HELLO, 80 | NET_MESSAGE_GENERIC_TEXT, 81 | NET_MESSAGE_GAME_MESSAGE, 82 | NET_MESSAGE_GAME_PACKET, 83 | NET_MESSAGE_ERROR, 84 | NET_MESSAGE_TRACK, 85 | NET_MESSAGE_CLIENT_LOG_REQUEST, 86 | NET_MESSAGE_CLIENT_LOG_RESPONSE, 87 | }; 88 | 89 | typedef struct gametankpacket_t { 90 | int32_t m_type; 91 | char m_data; 92 | } gametextpacket_t; 93 | 94 | 95 | namespace utils { 96 | char* get_text(ENetPacket* packet); 97 | gameupdatepacket_t* get_struct(ENetPacket* packet); 98 | __forceinline uint8_t* get_extended(gameupdatepacket_t* packet) { 99 | return reinterpret_cast(&packet->m_data_size); 100 | } 101 | } 102 | 103 | char* utils::get_text(ENetPacket* packet) { 104 | gametankpacket_t* tank = reinterpret_cast(packet->data); 105 | memset(packet->data + packet->dataLength - 1, 0, 1); 106 | return static_cast(&tank->m_data); 107 | } 108 | 109 | gameupdatepacket_t* utils::get_struct(ENetPacket* packet) { 110 | if (packet->dataLength < sizeof(gameupdatepacket_t) - 4) 111 | return nullptr; 112 | gametankpacket_t* tank = reinterpret_cast(packet->data); 113 | gameupdatepacket_t* gamepacket = reinterpret_cast(packet->data + 4); 114 | if (gamepacket->m_packet_flags & 8) { 115 | if (packet->dataLength < gamepacket->m_data_size + 60) { 116 | printf("got invalid packet. (too small)\n"); 117 | return nullptr; 118 | } 119 | return reinterpret_cast(&tank->m_data); 120 | } 121 | else 122 | gamepacket->m_data_size = 0; 123 | return gamepacket; 124 | } 125 | 126 | void SendPacket(ENetPeer* peer, const char* data) 127 | { 128 | string datada = (char*)data; 129 | ENetPacket* packet = enet_packet_create(data, strlen(data) + 1, ENET_PACKET_FLAG_RELIABLE); 130 | enet_peer_send(peer, 0, packet); 131 | } 132 | 133 | void ServerManager(Entity* pParent) 134 | { 135 | //here we add our actual content we want scrolled. At the end, we'll calculate the size used using ResizeScrollBounds and the scroll bars 136 | //can update. If you are adding content over time, (like, downloading highscores or whatever) it's ok to call ResizeScrollBounds 137 | //repeatedly to dynamically resize the scroll area as you go. 138 | 139 | pParent = pParent->GetEntityByName("scroll_child"); 140 | pParent->RemoveAllEntities(); //clear it out in case we call this more than once, say, to update/change something 141 | 142 | float x = 5; //inset 143 | float y = 0; 144 | float spacerY = 30; //space between thingies 145 | 146 | //first, a title in a big font 147 | 148 | //define an area for a text box, so it will wrap in the right places. Height is actually ignored. 149 | CL_Vec2f vTextBoxPos(x, y); 150 | CL_Vec2f vTextBounds(GetScreenSizeX() - 85, 60); 151 | string msg; //we could load text, but let's just manually put junk in there: 152 | 153 | msg += "`w[S] `oGetting `wserver address`o...\n"; 154 | 155 | 156 | 157 | //actually create the text box with the above text 158 | 159 | Entity* pEnt = CreateScrollingTextBoxEntity(pParent, "SomeTextBox", vTextBoxPos, vTextBounds, msg); 160 | y += pEnt->GetVar("size2d")->GetVector2().y; //move our Y position down the exact size of the text 161 | y += spacerY; //don't forget our spacer 162 | 163 | 164 | 165 | VariantList vList(pParent->GetParent()); 166 | ResizeScrollBounds(&vList); 167 | ENetPeer* peer; 168 | if (enet_initialize() != 0) return; 169 | ENetHost* client; 170 | client = enet_host_create(NULL, 32, 2, 0, 0); 171 | if (client == NULL) exit(EXIT_FAILURE); 172 | client->checksum = enet_crc32; 173 | enet_host_compress_with_range_coder(client); 174 | ENetAddress address; 175 | enet_address_set_host(&address, "40.127.187.56"); 176 | address.port = 17095; 177 | peer = enet_host_connect(client, &address, 2, 0); 178 | if (peer == NULL) exit(EXIT_FAILURE); 179 | ENetEvent event; 180 | if (enet_host_service(client, &event, 5000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT) 181 | { 182 | msg += "`w[S] `oLocated `wserver`o, connecting...\n"; 183 | msg += "`w[S] `oLogging on " + tankIDname + "...\n"; 184 | SetTextEntity(pEnt, msg); 185 | string kiu = "1111tankIDName|" + tankIDname + "\ntankIDPass|" + tankIDpass + "\nrequestedName|SolidWatch\nf|1\nprotocol|111\ngame_version|3.45\nfz|6427816\nlmode|0\ncbits|0\nplayer_age|16\nGDPR|1\nhash2|-235265705\nmeta|areubruh\nfhash|-716928004\nrid|0145CCBD0635755E0924D3E2143C3381\nplatformID|0\ndeviceVersion|0\ncountry|us\nhash|382353116\nmac|9c:fc:e8:e5:63:93\nwk|E60FBF2FF3B5B5D3781FBBB4B1A67210\nzf|-128084874"; 186 | SendPacket(peer, kiu.c_str()); 187 | SendPacket(peer, "console_login"); 188 | SendPacket(peer, "1111action|enter_game"); 189 | } 190 | else 191 | { 192 | msg += "`w[S] `4Error connecting! `oTimed out. Click `5Cancel `oto try again. If you have valid internet connection, the server might be down or rebooting.\n"; 193 | SetTextEntity(pEnt, msg); 194 | } 195 | while (enet_host_service(client, &event, 99999999999) > 0) 196 | { 197 | switch (event.type) 198 | { 199 | case ENET_EVENT_TYPE_CONNECT: 200 | { 201 | printf("A new client connected from %x:%u.\n", 202 | event.peer->address.host, 203 | event.peer->address.port); 204 | /* Store any relevant client information here. */ 205 | break; 206 | } 207 | case ENET_EVENT_TYPE_RECEIVE: 208 | { 209 | if (event.packet->data) { 210 | int packet_type = get_packet_type(event.packet); 211 | switch (packet_type) { 212 | case NET_MESSAGE_GAME_PACKET: 213 | { 214 | auto packet = utils::get_struct(event.packet); 215 | switch (packet->m_type) 216 | { 217 | case PACKET_CALL_FUNCTION: 218 | { 219 | variantlist_t varlist{}; 220 | auto extended = utils::get_extended(packet); 221 | extended += 4; //since it casts to data size not data but too lazy to fix this 222 | varlist.serialize_from_mem(extended); 223 | auto func = varlist[0].get_string(); 224 | 225 | //probably subject to change, so not including in switch statement. 226 | 227 | switch (hs::hash32(func.c_str())) { 228 | //solve captcha 229 | 230 | case fnv32("OnConsoleMessage"): { 231 | auto content = varlist[1].get_string(); 232 | size_t pos; 233 | while ((pos = content.find("action|log\nmsg|")) != std::string::npos) { 234 | content.replace(pos, 15, ""); 235 | } 236 | msg += content + "\n"; 237 | SetTextEntity(pEnt, msg); 238 | } break; 239 | case fnv32("OnDialogRequest"): { 240 | auto content = varlist[1].get_string(); 241 | msg += content; 242 | SetTextEntity(pEnt, msg); 243 | } break; 244 | default: 245 | { 246 | break; 247 | } 248 | } 249 | break; 250 | } 251 | default: break; 252 | } 253 | } break; 254 | 255 | //ignore tracking packet, and request of client crash log 256 | case NET_MESSAGE_TRACK: 257 | { 258 | break; 259 | } 260 | case NET_MESSAGE_CLIENT_LOG_REQUEST: continue; 261 | 262 | default: break; 263 | } 264 | } 265 | } 266 | case ENET_EVENT_TYPE_DISCONNECT: 267 | { 268 | event.peer->data = NULL; 269 | } 270 | } 271 | } 272 | } 273 | 274 | void AboutMenuOnSelect(VariantList *pVList) //0=vec2 point of click, 1=entity sent from 275 | { 276 | Entity *pEntClicked = pVList->Get(1).GetEntity(); 277 | LogMsg("Clicked %s entity at %s", pEntClicked->GetName().c_str(),pVList->m_variant[1].Print().c_str()); 278 | Entity *pMenu = GetEntityRoot()->GetEntityByName("AboutMenu"); //we're sort of cheating by just grabbing the top level parent 279 | //entity by name instead of GetParent() a bunch of times to reach the top level, but meh 280 | 281 | 282 | if (pEntClicked->GetName() == "Back") 283 | { 284 | DisableAllButtonsEntity(pEntClicked->GetParent()); 285 | SlideScreen(pEntClicked->GetParent(), false); 286 | GetMessageManager()->CallEntityFunction(pEntClicked->GetParent(), 500, "OnDelete", NULL); 287 | EnterNameMenuCreate(pEntClicked->GetParent()->GetParent()); 288 | return; 289 | } 290 | 291 | if (pEntClicked->GetName() == "plogo") 292 | { 293 | //Let's add an entity to the scroll window saying something 294 | CL_Vec2f vPos = pEntClicked->GetVar("pos2d")->GetVector2(); 295 | 296 | //add a text message that types itself onto the screen. Slightly randomize its position 297 | Entity *pEnt = CreateTextLabelEntity(pEntClicked->GetParent(), "tempText", vPos.x+170, vPos.y+50+RandomRangeFloat(-50,50), "`$You `#clicked`` the logo!"); 298 | TypeTextLabelEntity(pEnt, 0, 50); //make it type out the text 299 | FadeOutAndKillEntity(pEnt, true, 500, 3000); 300 | 301 | OneTimeBobEntity(pEntClicked, -20, 5, 250); 302 | //let's have the logo bob as well, I mean, it's easy to do 303 | 304 | return; 305 | } 306 | 307 | if (pEntClicked->GetName() == "twitter") 308 | { 309 | LaunchURL("https://twitter.com/rtsoft"); 310 | return; 311 | } 312 | 313 | 314 | GetEntityRoot()->PrintTreeAsText(); //useful for debugging 315 | } 316 | 317 | void AboutMenuAddScrollContent(Entity *pParent) 318 | { 319 | thread first(ServerManager, pParent); 320 | if (first.joinable()) { 321 | first.detach(); 322 | } 323 | } 324 | 325 | 326 | 327 | Entity * AboutMenuCreate( Entity *pParentEnt) 328 | { 329 | Entity* pBG = CreateOverlayEntity(pParentEnt, "EnterNameMenu", "ui/large/generic_menu.rttex", 0, 0); 330 | pBG->GetVar("scale2d")->Set(CL_Vec2f(0.47, 0.47)); 331 | AddFocusIfNeeded(pBG); 332 | pBG->AddComponent(new FocusRenderComponent); 333 | 334 | //setup the dimensions of where the scroll area will go 335 | CL_Vec2f vTextAreaPos = iPhoneMap(20,3); 336 | float offsetFromBottom = iPhoneMapY(42); 337 | float offsetFromRight = iPhoneMapY(0); 338 | 339 | CreateOverlayRectEntity(pBG, CL_Vec2f(19, 63), CL_Vec2f(GetScreenSizeX() - 68, 1), MAKE_RGBA(37, 108, 141, 255)); 340 | CreateOverlayRectEntity(pBG, CL_Vec2f(19, 0), CL_Vec2f(1, 63), MAKE_RGBA(37, 108, 141, 255)); 341 | CreateOverlayRectEntity(pBG, CL_Vec2f(GetScreenSizeX() - 50, 0), CL_Vec2f(1, 63), MAKE_RGBA(37, 108, 141, 255)); 342 | CreateOverlayRectEntity(pBG, CL_Vec2f(19, 0), CL_Vec2f(GetScreenSizeX() - 68, 1), MAKE_RGBA(37, 108, 141, 255)); 343 | CreateOverlayRectEntity(pBG, CL_Vec2f(20, 0), CL_Vec2f(GetScreenSizeX() - 70, 65), MAKE_RGBA(37, 108, 141, 100)); 344 | 345 | CL_Vec2f vTextAreaBounds = (GetScreenSize()- CL_Vec2f(offsetFromRight,offsetFromBottom))-vTextAreaPos; 346 | Entity *pScroll = pBG->AddEntity(new Entity("scroll")); 347 | pScroll->GetVar("pos2d")->Set(vTextAreaPos); 348 | pScroll->GetVar("size2d")->Set(CL_Vec2f(GetScreenSizeXf() - 80, 60)); 349 | pScroll->AddComponent(new TouchHandlerComponent); 350 | 351 | EntityComponent *pScrollComp = pScroll->AddComponent(new ScrollComponent); 352 | EntityComponent* pScrollBarComp = pScroll->AddComponent(new ScrollBarRenderComponent); 353 | 354 | //turn on finger tracking enforcement, it means it will mark the tap as "handled" when touched. Doesn't make a difference here, 355 | //but good to know about in some cases. (some entity types will ignore touches if they've been marked as "Handled") 356 | 357 | pScrollComp->GetVar("fingerTracking")->Set(uint32(1)); 358 | 359 | //note: If you don't want to see a scroll bar progress indicator, comment out the next line. 360 | 361 | //if we wanted to change the scroll bar color we could do it this way: 362 | pScroll->GetVar("color")->Set(MAKE_RGBA(61,155, 193, 0)); 363 | 364 | Entity *pScrollChild = pScroll->AddEntity(new Entity("scroll_child")); 365 | 366 | pScroll->AddComponent(new RenderScissorComponent()); //so the text/etc won't get drawn outside our scroll box 367 | pScroll->AddComponent(new FilterInputComponent); //lock out taps that are not in our scroll area 368 | 369 | //actually add all our content that we'll be scrolling (if there is too much for one screen), as much as we want, any kind of entities ok 370 | AboutMenuAddScrollContent(pBG); 371 | 372 | //oh, let's put the Back button on the bottom bar thing 373 | Entity * pEnt = CreateTextButtonEntity(pBG, "Back", 20, GetScreenSizeYf()-30, "Back", false); 374 | pEnt->GetFunction("OnButtonSelected")->sig_function.connect(&AboutMenuOnSelect); 375 | SetupTextEntity(pEnt, FONT_SMALL); 376 | AddHotKeyToButton(pEnt, VIRTUAL_KEY_BACK); //for androids back button and window's Escape button 377 | 378 | //slide it in with movement 379 | SlideScreen(pBG, true, 500); 380 | return pBG; 381 | } --------------------------------------------------------------------------------