├── 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