Added script_local implemented by gir489.

Added sanity checks to premake to see if the user did a proper recursive pull, and to warn them if they didn't.
This commit is contained in:
gir489 2020-02-22 20:47:17 -05:00
parent 01d48cd314
commit fc3e5ab791
4 changed files with 67 additions and 11 deletions

View File

@ -0,0 +1,31 @@
#include "common.hpp"
#include "pointers.hpp"
#include "script_local.hpp"
#include "gta\script_thread.hpp"
namespace big
{
script_local::script_local(rage::scrThread* thread, std::size_t index) :
m_index(index), m_stack(thread->m_stack)
{
}
script_local::script_local(PVOID stack, std::size_t index) :
m_index(index), m_stack(stack)
{
}
script_local script_local::at(std::ptrdiff_t index)
{
return script_local(m_stack, m_index + index);
}
script_local script_local::at(std::ptrdiff_t index, std::size_t size)
{
return script_local(m_stack, m_index + 1 + (index * size));
}
void *script_local::get()
{
return reinterpret_cast<uintptr_t*>((uintptr_t)m_stack + (m_index * sizeof(uintptr_t)));
}
}

View File

@ -0,0 +1,31 @@
#pragma once
#include "common.hpp"
namespace big
{
class script_local
{
public:
explicit script_local(rage::scrThread* thread, std::size_t index);
explicit script_local(PVOID stack, std::size_t index);
script_local at(std::ptrdiff_t index);
script_local at(std::ptrdiff_t index, std::size_t size);
template <typename T>
std::enable_if_t<std::is_pointer_v<T>, T> as()
{
return static_cast<T>(get());
}
template <typename T>
std::enable_if_t<std::is_lvalue_reference_v<T>, T> as()
{
return *static_cast<std::add_pointer_t<std::remove_reference_t<T>>>(get());
}
private:
void *get();
std::size_t m_index;
PVOID m_stack;
};
}

View File

@ -18,17 +18,8 @@ To build BigBaseV2 you need:
To set up the build environment, run the following commands in a terminal: To set up the build environment, run the following commands in a terminal:
```dos ```dos
git clone https://github.com/Pocakking/BigBaseV2.git --recurse-submodules git clone https://gir489@bitbucket.org/gir489/bigbasev2-fix.git --recurse-submodules
cd BigBaseV2 cd BigBaseV2-fix
GenerateProjects.bat GenerateProjects.bat
``` ```
Now, you will be able to open the solution, and simply build it in Visual Studio. Now, you will be able to open the solution, and simply build it in Visual Studio.
It is reccomended you generate the project each time you add a file instead of adding it directly to Visual Studio.
## Credits
Pocakking - Original creator.
gir489 - Implementer and wrote the g3log crash handler and added test cases.
datlimabean04 - Wrote the g3log and settings implementation.

View File

@ -142,6 +142,9 @@ workspace "BigBaseV2"
if(file_exists("vendor\\g3log\\src\\g3log\\generated_definitions.hpp") == false) then if(file_exists("vendor\\g3log\\src\\g3log\\generated_definitions.hpp") == false) then
file = io.open("vendor\\g3log\\src\\g3log\\generated_definitions.hpp", "w") file = io.open("vendor\\g3log\\src\\g3log\\generated_definitions.hpp", "w")
if(file == nil) then
premake.error("Failed to locate vendor directories. Try doing git pull --recurse-submodules.")
end
file:write("// AUTO GENERATED MACRO DEFINITIONS FOR G3LOG\n\n\n/* ==========================================================================\n*2015 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes\n* with no warranties. This code is yours to share, use and modify with no\n\n*strings attached and no restrictions or obligations.\n* \n* For more information see g3log/LICENSE or refer refer to http://unlicense.org\n\n*============================================================================*/\n#pragma once\n\n\n// CMake induced definitions below. See g3log/Options.cmake for details."); file:write("// AUTO GENERATED MACRO DEFINITIONS FOR G3LOG\n\n\n/* ==========================================================================\n*2015 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes\n* with no warranties. This code is yours to share, use and modify with no\n\n*strings attached and no restrictions or obligations.\n* \n* For more information see g3log/LICENSE or refer refer to http://unlicense.org\n\n*============================================================================*/\n#pragma once\n\n\n// CMake induced definitions below. See g3log/Options.cmake for details.");
end end