Switch to vc++ 142, updates to cmake sys

This commit is contained in:
Grinch_ 2021-01-05 12:29:26 +06:00
parent 233fcd244f
commit ff8a21eaf3
19 changed files with 244 additions and 487 deletions

View File

@ -17,9 +17,9 @@
"_UNICODE"
],
"windowsSdkVersion": "10.0.10240.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe",
"compilerPath": "cl.exe",
"cStandard": "c99",
"cppStandard": "c++14",
"cppStandard": "c++20",
"intelliSenseMode": "msvc-x86",
"configurationProvider": "ms-vscode.cmake-tools"
}

View File

@ -62,7 +62,12 @@
"xmemory0": "cpp",
"xstddef": "cpp",
"xtr1common": "cpp",
"xtree": "cpp"
"xtree": "cpp",
"iomanip": "cpp",
"*.def": "cpp",
"atomic": "cpp",
"compare": "cpp",
"concepts": "cpp"
},
"C_Cpp.errorSquiggles": "Enabled",
"C_Cpp.intelliSenseEngineFallback": "Enabled"

View File

@ -1,286 +1,194 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(CheatMenu CXX)
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
set(PROJECT_NAME CheatMenu)
project(${PROJECT_NAME} CXX)
################################################################################
# Configure paths
################################################################################
set(GTA_SA_DIR F:/GTASanAndreas)
# Can ignore the below paths if you got them (yes by default) in system paths
# Can ignore the below paths if you got them in system paths
set(PLUGIN_SDK_DIR $ENV{PLUGIN_SDK_DIR})
set(DX9_DIR $ENV{DIRECTX9_SDK_DIR})
set(DIRECTX9_SDK_DIR $ENV{DIRECTX9_SDK_DIR})
################################################################################
################################################################################
# This contains the utility functions needed for sub project, src/CMakeLists.txt
# Need to clean things up later, maybe switch to original cmake alternatives
# CMake-Converter https://github.com/pavelliavonau/cmakeconverter
# Tested with MSVC v140
################################################################################
################################################################################
# Wrap each token of the command with condition
################################################################################
cmake_policy(PUSH)
cmake_policy(SET CMP0054 NEW)
macro(prepare_commands)
unset(TOKEN_ROLE)
unset(COMMANDS)
foreach(TOKEN ${ARG_COMMANDS})
if("${TOKEN}" STREQUAL "COMMAND")
set(TOKEN_ROLE "KEYWORD")
elseif("${TOKEN_ROLE}" STREQUAL "KEYWORD")
set(TOKEN_ROLE "CONDITION")
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
set(TOKEN_ROLE "COMMAND")
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
set(TOKEN_ROLE "ARG")
endif()
if("${TOKEN_ROLE}" STREQUAL "KEYWORD")
list(APPEND COMMANDS "${TOKEN}")
elseif("${TOKEN_ROLE}" STREQUAL "CONDITION")
set(CONDITION ${TOKEN})
elseif("${TOKEN_ROLE}" STREQUAL "COMMAND")
list(APPEND COMMANDS "$<$<NOT:${CONDITION}>:${DUMMY}>$<${CONDITION}:${TOKEN}>")
elseif("${TOKEN_ROLE}" STREQUAL "ARG")
list(APPEND COMMANDS "$<${CONDITION}:${TOKEN}>")
endif()
endforeach()
endmacro()
cmake_policy(POP)
################################################################################
# Transform all the tokens to absolute paths
################################################################################
macro(prepare_output)
unset(OUTPUT)
foreach(TOKEN ${ARG_OUTPUT})
if(IS_ABSOLUTE ${TOKEN})
list(APPEND OUTPUT "${TOKEN}")
else()
list(APPEND OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/${TOKEN}")
endif()
endforeach()
endmacro()
################################################################################
# Parse add_custom_command_if args.
#
# Input:
# PRE_BUILD - Pre build event option
# PRE_LINK - Pre link event option
# POST_BUILD - Post build event option
# TARGET - Target
# OUTPUT - List of output files
# DEPENDS - List of files on which the command depends
# COMMANDS - List of commands(COMMAND condition1 commannd1 args1 COMMAND
# condition2 commannd2 args2 ...)
# Output:
# OUTPUT - Output files
# DEPENDS - Files on which the command depends
# COMMENT - Comment
# PRE_BUILD - TRUE/FALSE
# PRE_LINK - TRUE/FALSE
# POST_BUILD - TRUE/FALSE
# TARGET - Target name
# COMMANDS - Prepared commands(every token is wrapped in CONDITION)
# NAME - Unique name for custom target
# STEP - PRE_BUILD/PRE_LINK/POST_BUILD
################################################################################
function(add_custom_command_if_parse_arguments)
cmake_parse_arguments("ARG" "PRE_BUILD;PRE_LINK;POST_BUILD" "TARGET;COMMENT" "DEPENDS;OUTPUT;COMMANDS" ${ARGN})
if(WIN32)
set(DUMMY "cd.")
elseif(UNIX)
set(DUMMY "true")
endif()
prepare_commands()
prepare_output()
set(DEPENDS "${ARG_DEPENDS}")
set(COMMENT "${ARG_COMMENT}")
set(PRE_BUILD "${ARG_PRE_BUILD}")
set(PRE_LINK "${ARG_PRE_LINK}")
set(POST_BUILD "${ARG_POST_BUILD}")
set(TARGET "${ARG_TARGET}")
if(PRE_BUILD)
set(STEP "PRE_BUILD")
elseif(PRE_LINK)
set(STEP "PRE_LINK")
elseif(POST_BUILD)
set(STEP "POST_BUILD")
endif()
set(NAME "${TARGET}_${STEP}")
set(OUTPUT "${OUTPUT}" PARENT_SCOPE)
set(DEPENDS "${DEPENDS}" PARENT_SCOPE)
set(COMMENT "${COMMENT}" PARENT_SCOPE)
set(PRE_BUILD "${PRE_BUILD}" PARENT_SCOPE)
set(PRE_LINK "${PRE_LINK}" PARENT_SCOPE)
set(POST_BUILD "${POST_BUILD}" PARENT_SCOPE)
set(TARGET "${TARGET}" PARENT_SCOPE)
set(COMMANDS "${COMMANDS}" PARENT_SCOPE)
set(STEP "${STEP}" PARENT_SCOPE)
set(NAME "${NAME}" PARENT_SCOPE)
endfunction()
################################################################################
# Add conditional custom command
#
# Generating Files
# The first signature is for adding a custom command to produce an output:
# add_custom_command_if(
# <OUTPUT output1 [output2 ...]>
# <COMMANDS>
# <COMMAND condition command1 [args1...]>
# [COMMAND condition command2 [args2...]]
# [DEPENDS [depends...]]
# [COMMENT comment]
#
# Build Events
# add_custom_command_if(
# <TARGET target>
# <PRE_BUILD | PRE_LINK | POST_BUILD>
# <COMMAND condition command1 [args1...]>
# [COMMAND condition command2 [args2...]]
# [COMMENT comment]
#
# Input:
# output - Output files the command is expected to produce
# condition - Generator expression for wrapping the command
# command - Command-line(s) to execute at build time.
# args - Command`s args
# depends - Files on which the command depends
# comment - Display the given message before the commands are executed at
# build time.
# PRE_BUILD - Run before any other rules are executed within the target
# PRE_LINK - Run after sources have been compiled but before linking the
# binary
# POST_BUILD - Run after all other rules within the target have been
# executed
################################################################################
function(add_custom_command_if)
add_custom_command_if_parse_arguments(${ARGN})
if(OUTPUT AND TARGET)
message(FATAL_ERROR "Wrong syntax. A TARGET and OUTPUT can not both be specified.")
endif()
if(OUTPUT)
add_custom_command(OUTPUT ${OUTPUT}
${COMMANDS}
DEPENDS ${DEPENDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
elseif(TARGET)
if(PRE_BUILD AND NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio")
add_custom_target(
${NAME}
${COMMANDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
add_dependencies(${TARGET} ${NAME})
else()
add_custom_command(
TARGET ${TARGET}
${STEP}
${COMMANDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT ${COMMENT})
endif()
else()
message(FATAL_ERROR "Wrong syntax. A TARGET or OUTPUT must be specified.")
endif()
endfunction()
################################################################################
# Use props file for a target and configs
# use_props(<target> <configs...> <props_file>)
# Inside <props_file> there are following variables:
# PROPS_TARGET - <target>
# PROPS_CONFIG - One of <configs...>
# PROPS_CONFIG_U - Uppercase PROPS_CONFIG
# Input:
# target - Target to apply props file
# configs - Build configurations to apply props file
# props_file - CMake script
################################################################################
macro(use_props TARGET CONFIGS PROPS_FILE)
set(PROPS_TARGET "${TARGET}")
foreach(PROPS_CONFIG ${CONFIGS})
string(TOUPPER "${PROPS_CONFIG}" PROPS_CONFIG_U)
get_filename_component(ABSOLUTE_PROPS_FILE "${PROPS_FILE}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
if(EXISTS "${ABSOLUTE_PROPS_FILE}")
include("${ABSOLUTE_PROPS_FILE}")
else()
message(WARNING "Corresponding cmake file from props \"${ABSOLUTE_PROPS_FILE}\" doesn't exist")
endif()
endforeach()
endmacro()
################################################################################
# Function for MSVC precompiled headers
# add_precompiled_header(<target> <precompiled_header> <precompiled_source>)
# Input:
# target - Target to which add precompiled header
# precompiled_header - Name of precompiled header
# precompiled_source - Name of precompiled source file
################################################################################
function(add_precompiled_header TARGET PRECOMPILED_HEADER PRECOMPILED_SOURCE)
get_target_property(SOURCES "${TARGET}" SOURCES)
list(REMOVE_ITEM SOURCES "${PRECOMPILED_SOURCE}")
if(MSVC)
set(PRECOMPILED_BINARY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.pch")
set_source_files_properties(
"${PRECOMPILED_SOURCE}"
PROPERTIES
COMPILE_OPTIONS "/Yc${PRECOMPILED_HEADER};/Fp${PRECOMPILED_BINARY}"
OBJECT_OUTPUTS "${PRECOMPILED_BINARY}")
set_source_files_properties(
${SOURCES}
PROPERTIES
COMPILE_OPTIONS "$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/Yu${PRECOMPILED_HEADER};/Fp${PRECOMPILED_BINARY}>"
OBJECT_DEPENDS "${PRECOMPILED_BINARY}")
endif()
list(INSERT SOURCES 0 "${PRECOMPILED_SOURCE}")
set_target_properties("${TARGET}" PROPERTIES SOURCES "${SOURCES}")
endfunction()
################################################################################
# Add compile options to source file
# source_file_compile_options(<source_file> [compile_options...])
# Input:
# source_file - Source file
# compile_options - Options to add to COMPILE_FLAGS property
################################################################################
function(source_file_compile_options SOURCE_FILE)
if("${ARGC}" LESS_EQUAL "1")
return()
endif()
get_source_file_property(COMPILE_OPTIONS "${SOURCE_FILE}" COMPILE_OPTIONS)
if(COMPILE_OPTIONS)
list(APPEND COMPILE_OPTIONS ${ARGN})
else()
set(COMPILE_OPTIONS "${ARGN}")
endif()
set_source_files_properties("${SOURCE_FILE}" PROPERTIES COMPILE_OPTIONS "${COMPILE_OPTIONS}")
endfunction()
################################################################################
# Sub-projects
# Required projects
################################################################################
add_subdirectory(src/vendor)
add_subdirectory(src)
################################################################################
# Source groups
################################################################################
set(src_files
"src/Animation.cpp"
"src/Animation.h"
"src/CheatMenu.cpp"
"src/CheatMenu.h"
"src/Events.cpp"
"src/Events.h"
"src/Game.cpp"
"src/Game.h"
"src/Hook.cpp"
"src/Hook.h"
"src/Json.cpp"
"src/Json.h"
"src/Menu.cpp"
"src/Menu.h"
"src/MenuInfo.h"
"src/NeonAPI.cpp"
"src/NeonAPI.h"
"src/Paint.cpp"
"src/Paint.h"
"src/pch.cpp"
"src/pch.h"
"src/Ped.cpp"
"src/Ped.h"
"src/Player.cpp"
"src/Player.h"
"src/Teleport.cpp"
"src/Teleport.h"
"src/Ui.cpp"
"src/Ui.h"
"src/Util.cpp"
"src/Util.h"
"src/Vehicle.cpp"
"src/Vehicle.h"
"src/Visual.cpp"
"src/Visual.h"
"src/VKeys.h"
"src/Weapon.cpp"
"src/Weapon.h"
)
################################################################################
# Target
################################################################################
add_library(${PROJECT_NAME} SHARED ${src_files})
target_precompile_headers(${PROJECT_NAME} PUBLIC "src/pch.h")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
)
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${GTA_SA_DIR}/$<0:>/"
SUFFIX ".asi"
MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}
)
################################################################################
# Include directories
################################################################################
include_directories(
"${PLUGIN_SDK_DIR}/plugin_sa"
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa"
"${PLUGIN_SDK_DIR}/shared"
"${PLUGIN_SDK_DIR}/shared/game"
"${DIRECTX9_SDK_DIR}/include"
)
################################################################################
# Compile definitions
################################################################################
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Release>:"
"_NDEBUG"
">"
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"_CRT_SECURE_NO_WARNINGS;"
"_CRT_NON_CONFORMING_SWPRINTFS;"
"GTASA;"
"GTAGAME_NAME=\"San Andreas\";"
"GTAGAME_ABBR=\"SA\";"
"GTAGAME_ABBRLOW=\"sa\";"
"GTAGAME_PROTAGONISTNAME=\"CJ\";"
"GTAGAME_CITYNAME=\"San Andreas\";"
"_LA_SUPPORT;"
"_DX9_SDK_INSTALLED;"
"PLUGIN_SGV_10US;"
"_MBCS"
)
################################################################################
# Compile and link options
################################################################################
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/O2;
/Oi;
/Gy
>
$<$<CONFIG:Debug>:
/Od
/DEBUG:FULL
>
/std:c++latest;
/sdl-;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
/w44005
)
string(CONCAT FILE_CL_OPTIONS
"/Y-"
)
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/OPT:REF;
/LTCG;
/OPT:ICF;
>
$<$<CONFIG:Debug>:
/DEBUG:FULL;
/SAFESEH:NO;
>
/SUBSYSTEM:WINDOWS
)
endif()
################################################################################
# Pre build events
################################################################################
add_custom_command(
TARGET ${PROJECT_NAME}
PRE_BUILD
COMMAND taskkill /f /fi "imagename eq gta_sa.exe"
)
################################################################################
# Dependencies
################################################################################
target_link_libraries(${PROJECT_NAME} PUBLIC
optimized plugin
debug plugin_d
d3d9
d3dx9
d3d11
d3dx11
XInput9_1_0
Vendor
)
target_link_directories(${PROJECT_NAME} PUBLIC
"${PLUGIN_SDK_DIR}/output/lib/"
"${DIRECTX9_SDK_DIR}/lib/x86/"
"$<$<CONFIG:Release>:"
"vendor/Release/"
">"
"$<$<CONFIG:Debug>:"
"vendor/Debug/"
">"
)

View File

@ -21,13 +21,13 @@ A portuguese translation of the menu is [here](https://github.com/Dowglass/Cheat
## Installation
1. Install [DirectX9](https://www.microsoft.com/en-us/download/details.aspx?id=35) & [Visual C++ Redistributable 2015 x86](https://download.microsoft.com/download/9/3/F/93FCF1E7-E6A4-478B-96E7-D4B285925B00/vc_redist.x86.exe) if not already installed.
1. Install [DirectX9](https://www.microsoft.com/en-us/download/details.aspx?id=35) & [Visual C++ Redistributable 2019 x86](hhttps://aka.ms/vs/16/release/vc_redist.x86.exe) if not already installed.
2. If your game version isn't v1.0 then you'll need to [downgrade](https://gtaforums.com/topic/927016-san-andreas-downgrader/).
3. Install [asi loader](https://www.gtagarage.com/mods/show.php?id=21709) & [silent patch](https://gtaforums.com/topic/669045-silentpatch/)
4. Download CheatMenu and extract everything in game directory (replace if necessary).
## Building
You'll need to install Visual Studio 2015 (v140), [DirectX9 SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6812) & [Plugin SDK](https://github.com/DK22Pac/plugin-sdk).
You'll need to install Visual Studio 2019 (v142), [DirectX9 SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6812) & [Plugin SDK](https://github.com/DK22Pac/plugin-sdk).
## Projects used
1. [ImGui](https://github.com/ocornut/imgui)

View File

@ -1,174 +0,0 @@
################################################################################
# Source groups
################################################################################
set(src_files
"Animation.cpp"
"Animation.h"
"CheatMenu.cpp"
"CheatMenu.h"
"Events.cpp"
"Events.h"
"Game.cpp"
"Game.h"
"Hook.cpp"
"Hook.h"
"Json.cpp"
"Json.h"
"Menu.cpp"
"Menu.h"
"MenuInfo.h"
"NeonAPI.cpp"
"NeonAPI.h"
"Paint.cpp"
"Paint.h"
"pch.cpp"
"pch.h"
"Ped.cpp"
"Ped.h"
"Player.cpp"
"Player.h"
"Teleport.cpp"
"Teleport.h"
"Ui.cpp"
"Ui.h"
"Util.cpp"
"Util.h"
"Vehicle.cpp"
"Vehicle.h"
"Visual.cpp"
"Visual.h"
"VKeys.h"
"Weapon.cpp"
"Weapon.h"
)
################################################################################
# Target
################################################################################
add_library(${PROJECT_NAME} SHARED ${src_files})
add_precompiled_header(${PROJECT_NAME} "pch.h" "pch.cpp")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
)
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${GTA_SA_DIR}/$<0:>/"
SUFFIX ".asi"
MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}
)
################################################################################
# Include directories
################################################################################
include_directories(
"${PLUGIN_SDK_DIR}/plugin_sa"
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa"
"${PLUGIN_SDK_DIR}/shared"
"${PLUGIN_SDK_DIR}/shared/game"
"${DX9_DIR}/include"
)
################################################################################
# Compile definitions
################################################################################
target_compile_definitions(${PROJECT_NAME} PRIVATE
"$<$<CONFIG:Release>:"
"_NDEBUG"
">"
"$<$<CONFIG:Debug>:"
"_DEBUG"
">"
"_CRT_SECURE_NO_WARNINGS;"
"_CRT_NON_CONFORMING_SWPRINTFS;"
"GTASA;"
"GTAGAME_NAME=\"San Andreas\";"
"GTAGAME_ABBR=\"SA\";"
"GTAGAME_ABBRLOW=\"sa\";"
"GTAGAME_PROTAGONISTNAME=\"CJ\";"
"GTAGAME_CITYNAME=\"San Andreas\";"
"_LA_SUPPORT;"
"_DX9_SDK_INSTALLED;"
"PLUGIN_SGV_10US;"
"_MBCS"
)
################################################################################
# Compile and link options
################################################################################
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/O2;
/Oi;
/Gy
>
$<$<CONFIG:Debug>:
/Od
>
/std:c++latest;
/sdl-;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
/w44005
)
string(CONCAT FILE_CL_OPTIONS
"/Y-"
)
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:
/OPT:REF;
/LTCG;
/OPT:ICF;
>
$<$<CONFIG:Debug>:
/DEBUG:FULL;
/SAFESEH:NO;
>
/SUBSYSTEM:WINDOWS
)
endif()
################################################################################
# Pre build events
################################################################################
add_custom_command_if(
TARGET ${PROJECT_NAME}
PRE_BUILD
COMMANDS
COMMAND $<CONFIG:Release> taskkill /f /fi "imagename eq gta_sa.exe"
COMMAND $<CONFIG:Debug> taskkill /f /fi "imagename eq gta_sa.exe"
)
################################################################################
# Dependencies
################################################################################
target_link_libraries(${PROJECT_NAME} PUBLIC
optimized plugin
debug plugin_d
d3d9
d3dx9
d3d11
d3dx11
XInput9_1_0
Vendor
)
target_link_directories(${PROJECT_NAME} PUBLIC
"${PLUGIN_SDK_DIR}/output/lib/"
"${DX9_DIR}/lib/x86/"
"$<$<CONFIG:Release>:"
"vendor/Release/"
">"
"$<$<CONFIG:Debug>:"
"vendor/Debug/"
">"
)

View File

@ -162,13 +162,13 @@ void Hook::ShowMouse(bool state)
{
patch::SetUChar(0x6194A0, 0xC3);
patch::Nop(0x53F417, 5); // don't call CPad__getMouseState
patch::SetRaw(0x53F41F, "\x33\xC0\x0F\x84", 4); // disable camera mouse movement
patch::SetRaw(0x53F41F, (void*)"\x33\xC0\x0F\x84", 4); // disable camera mouse movement
}
else
{
patch::SetRaw(0x541DF5, "\xE8\x46\xF3\xFE\xFF", 5); // call CControllerConfigManager::AffectPadFromKeyBoard
patch::SetRaw(0x53F417, "\xE8\xB4\x7A\x20\x00", 5); // call CPad__getMouseState
patch::SetRaw(0x53F41F, "\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement
patch::SetRaw(0x541DF5, (void*)"\xE8\x46\xF3\xFE\xFF", 5); // call CControllerConfigManager::AffectPadFromKeyBoard
patch::SetRaw(0x53F417, (void*)"\xE8\xB4\x7A\x20\x00", 5); // call CPad__getMouseState
patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement
// jz loc_53F526 -> jl loc_53F526
patch::SetUChar(0x6194A0, 0xE9); // jmp setup
}

View File

@ -5,7 +5,7 @@ CJson::CJson(const char* name)
{
file_path = "./CheatMenu/json/"+ std::string(name) +".json";
if (std::experimental::filesystem::exists(file_path))
if (fs::exists(file_path))
{
try
{

View File

@ -231,17 +231,19 @@ void Menu::ProcessCommands()
if (wep_name == "jetpack")
{
Weapon::GiveWeaponToPlayer(std::string("-1"));
std::string weapon = "-1";
Weapon::GiveWeaponToPlayer(weapon);
CHud::SetHelpMessage("Weapon given", false, false, false);
}
else
{
eWeaponType weapon = CWeaponInfo::FindWeaponType((char*)wep_name.c_str());
std::string weapon_name = std::to_string(weapon);
CWeaponInfo* pweaponinfo = CWeaponInfo::GetWeaponInfo(weapon, 1);
if (wep_name != "" && pweaponinfo->m_nModelId1 != -1)
{
Weapon::GiveWeaponToPlayer(std::to_string(weapon));
Weapon::GiveWeaponToPlayer(weapon_name);
CHud::SetHelpMessage("Weapon given", false, false, false);
}
else
@ -258,7 +260,8 @@ void Menu::ProcessCommands()
int model = Vehicle::GetModelFromName(veh_name.c_str());
if (model != 0)
{
Vehicle::SpawnVehicle(std::to_string(model));
std::string smodel = std::to_string(model);
Vehicle::SpawnVehicle(smodel);
CHud::SetHelpMessage("Vehicle spawned", false, false, false);
}
else

View File

@ -169,9 +169,10 @@ void Ped::Main()
for (int i = 0; i != 10; ++i)
{
CVector pos = FindPlayerPed()->GetPosition();
CZone *zone = &CZone();
CZone szone = CZone();
CZone *pZone = &szone;
CZoneExtraInfo *zone_info = CTheZones::GetZoneInfo(&pos, &zone);
CZoneExtraInfo *zone_info = CTheZones::GetZoneInfo(&pos, &pZone);
int density = zone_info->m_nGangDensity[i];
if (ImGui::SliderInt(Ped::gang_names[i].c_str(), &density, 0, 127))

View File

@ -43,9 +43,9 @@ Player::Player()
// Custom skins setup
if (LoadLibraryW(L"modloader.asi"))
{
if (std::experimental::filesystem::is_directory(custom_skins::dir))
if (fs::is_directory(custom_skins::dir))
{
for (auto &p : std::experimental::filesystem::recursive_directory_iterator(custom_skins::dir))
for (auto &p : fs::recursive_directory_iterator(custom_skins::dir))
{
if (p.path().extension() == ".dff")
{
@ -58,7 +58,7 @@ Player::Player()
}
}
}
else std::experimental::filesystem::create_directory(custom_skins::dir);
else fs::create_directory(custom_skins::dir);
modloader_installed = true;
}

View File

@ -35,7 +35,7 @@ protected:
public:
static void Main();
static void TeleportPlayer(bool get_marker = false, CVector* pos = &CVector(0,0,0), short interior_id = 0);
static void TeleportPlayer(bool get_marker = false, CVector* pos = new CVector(0,0,0), short interior_id = 0);
static void TeleportToLocation(std::string& rootkey, std::string& loc_name, std::string& loc);
static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val);

View File

@ -364,7 +364,11 @@ void Ui::DrawJSON(CJson& json, std::vector<std::string>& combo_items, std::strin
{
if (ImGui::MenuItem(name.c_str()) && func_left_click != nullptr)
{
func_left_click(std::string(root.key()),std::string(_data.key()), std::string(_data.value()));
std::string root_key = root.key();
std::string data_key = _data.key();
std::string data_val = _data.value();
func_left_click(root_key,data_key,data_val);
}
if (ImGui::IsItemClicked(1) && func_right_click != nullptr)
@ -462,7 +466,7 @@ void Ui::DrawImages(std::vector<std::unique_ptr<TextureStructure>> &img_vec, ImV
{
int images_in_row = static_cast<int>(ImGui::GetWindowContentRegionWidth() / image_size.x);
image_size.x = ImGui::GetWindowContentRegionWidth() / images_in_row - ImGuiStyleVar_ItemSpacing*0.65f;
image_size.x = ImGui::GetWindowContentRegionWidth() / images_in_row - int(ImGuiStyleVar_ItemSpacing)*0.65f;
int images_count = 1;

View File

@ -26,7 +26,7 @@ void Util::ClearCharTasksVehCheck(CPed* ped)
void Util::LoadTexturesInDirRecursive(const char *path, const char *file_ext,std::vector<std::string>& category_vec, std::vector<std::unique_ptr<TextureStructure>> &store_vec)
{
std::string folder = "";
for (auto &p : std::experimental::filesystem::recursive_directory_iterator(path))
for (auto &p : fs::recursive_directory_iterator(path))
{
if (p.path().extension() == file_ext)
{
@ -151,7 +151,7 @@ int Util::GetLargestGangInZone()
for (int i = 0; i != 10; ++i)
{
CVector pos = FindPlayerPed()->GetPosition();
CZone *zone = &CZone();
CZone *zone = new CZone();
CZoneExtraInfo *zone_info = CTheZones::GetZoneInfo(&pos, &zone);
int density = zone_info->m_nGangDensity[i];
@ -161,6 +161,7 @@ int Util::GetLargestGangInZone()
max_density = density;
gang_id = i;
}
delete zone;
}
return gang_id;

View File

@ -256,7 +256,7 @@ void Vehicle::ParseVehiclesIDE()
{
std::string file_path = std::string(paths::GetGameDirPathA()) + "/data/vehicles.ide";
if (std::experimental::filesystem::exists(file_path))
if (fs::exists(file_path))
{
std::ifstream file(file_path);
std::string line;
@ -301,7 +301,7 @@ void Vehicle::ParseCarcolsDAT()
{
std::string file_path = std::string(paths::GetGameDirPathA()) + "/data/carcols.dat";
if (std::experimental::filesystem::exists(file_path))
if (fs::exists(file_path))
{
std::ifstream file(file_path);
std::string line;
@ -483,7 +483,7 @@ void Vehicle::SpawnVehicle(std::string &smodel)
CStreaming::RequestModel(imodel, PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false);
if (spawner::license_text != "")
if (spawner::license_text[0] != '\0')
Command<Commands::CUSTOM_PLATE_FOR_NEXT_CAR>(imodel, spawner::license_text);
int hveh = 0;
@ -992,7 +992,7 @@ void Vehicle::Main()
ImVec2 size = Ui::GetSize();
int btns_in_row = ImGui::GetWindowContentRegionWidth() / (size.y * 2);
int btn_size = (ImGui::GetWindowContentRegionWidth() - ImGuiStyleVar_ItemSpacing*(btns_in_row - 0.6*btns_in_row)) / btns_in_row;
int btn_size = (ImGui::GetWindowContentRegionWidth() - int(ImGuiStyleVar_ItemSpacing)*(btns_in_row - 0.6*btns_in_row)) / btns_in_row;
ImGui::BeginChild("Colorss");
@ -1060,7 +1060,7 @@ Only some vehicles will have them.");
int count = (int)carcols_color_values.size();
ImVec2 size = Ui::GetSize();
int btns_in_row = ImGui::GetWindowContentRegionWidth() / (size.y * 2);
int btn_size = (ImGui::GetWindowContentRegionWidth() - ImGuiStyleVar_ItemSpacing*(btns_in_row - 0.6*btns_in_row)) / btns_in_row;
int btn_size = (ImGui::GetWindowContentRegionWidth() - int(ImGuiStyleVar_ItemSpacing)*(btns_in_row - 0.6*btns_in_row)) / btns_in_row;
ImGui::BeginChild("Neonss");
@ -1176,7 +1176,8 @@ Only some vehicles will have them.");
ImGui::BeginChild("HandlingChild");
Ui::EditRadioButtonAddressEx("Abs", phandling + 0x9C, std::vector<Ui::NamedValue>{{ "On", 1 }, { "Off", 0 }});
static std::vector<Ui::NamedValue> abs{{ "On", 1 }, { "Off", 0 }};
Ui::EditRadioButtonAddressEx("Abs", phandling + 0x9C, abs);
Ui::EditFloat("Anti dive multiplier", phandling + 0xC4, 0.0f, 0.0f, 1.0f);
Ui::EditFloat("Brake bias", phandling + 0x98, 0.0f, 0.0f, 1.0f);
@ -1188,13 +1189,17 @@ Only some vehicles will have them.");
Ui::EditFloat("Damping level", phandling + 0xB0, -10.0f, -10.0f, 10.0f); // test later
Ui::EditFloat("Drag mult", phandling + 0x10, 0.0f, 0.0f, 30.0f);
Ui::EditRadioButtonAddressEx("Drive type", phandling + 0x74, std::vector<Ui::NamedValue>{ { "Front wheel drive", 70 }, { "Rear wheel drive", 82 }, { "Four wheel drive", 52 }});
static std::vector<Ui::NamedValue> drive_type{ { "Front wheel drive", 70 }, { "Rear wheel drive", 82 }, { "Four wheel drive", 52 }};
Ui::EditRadioButtonAddressEx("Drive type", phandling + 0x74, drive_type);
Ui::EditFloat("Engine acceleration", phandling + 0x7C, 0.0f, 0.0f, 49.0f, 12500.0f);
Ui::EditFloat("Engine inertia", phandling + 0x80, 0.0f, 0.0f, 400.0f);
Ui::EditRadioButtonAddressEx("Engine type", phandling + 0x75, std::vector<Ui::NamedValue>{ { "Petrol", 80 }, { "Diseal", 68 }, { "Electric", 69 }});
Ui::EditRadioButtonAddressEx("Front lights", phandling + 0xDC, std::vector<Ui::NamedValue>{ { "Long", 0 }, { "Small", 1 }, { "Big", 2 }, { "Tall", 3 }});
static std::vector<Ui::NamedValue> engine_type{ { "Petrol", 80 }, { "Diseal", 68 }, { "Electric", 69 }};
Ui::EditRadioButtonAddressEx("Engine type", phandling + 0x75, engine_type);
std::vector<Ui::NamedValue> front_lights{ { "Long", 0 }, { "Small", 1 }, { "Big", 2 }, { "Tall", 3 }};
Ui::EditRadioButtonAddressEx("Front lights", phandling + 0xDC, front_lights);
Ui::EditFloat("Force level", phandling + 0xAC, -10.0f, -10.0f, 10.0f); // test later
@ -1212,7 +1217,8 @@ Only some vehicles will have them.");
Ui::EditAddress<BYTE>("Number of gears", phandling + 0x76, 1, 1, 10);
Ui::EditAddress<BYTE>("Percent submerged", phandling + 0x20, 10, 10, 120);
Ui::EditRadioButtonAddressEx("Rear lights", phandling + 0xDD, std::vector<Ui::NamedValue>{ { "Long", 0 }, { "Small", 1 }, { "Big", 2 }, { "Tall", 3 }});
static std::vector<Ui::NamedValue> rear_lights{ { "Long", 0 }, { "Small", 1 }, { "Big", 2 }, { "Tall", 3 }};
Ui::EditRadioButtonAddressEx("Rear lights", phandling + 0xDD, rear_lights);
Ui::EditFloat("Seat offset distance", phandling + 0xD4, 0.0f, 0.0f, 1.0f);
Ui::EditFloat("Steering lock", phandling + 0xA0, 10.0f, 10.0f, 50.0f);

View File

@ -74,7 +74,7 @@ public:
static void AddComponent(const std::string& component, const bool display_message = true);
static void RemoveComponent(const std::string& component, const bool display_message = true);
static std::string GetNameFromModel(int model);
static int Vehicle::GetModelFromName(const char* name);
static int GetModelFromName(const char* name);
static void SpawnVehicle(std::string &name);
static int GetRandomTrainIdForModel(int model);
static void ParseVehiclesIDE();

View File

@ -210,8 +210,10 @@ void Visual::Main()
Ui::ColorPickerAddress("Health bar + debt color", 0xBAB22C, ImVec4(180,25,29,255));
Ui::ColorPickerAddress("Main menu title border color", 0xBAB240, ImVec4(0,0,0,255));
Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54,104,44,255));
Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, std::vector<Ui::NamedValue>{{ "No outline", 0 }, { "Thin outline" ,1 }, { "Default outline" ,2 }});
Ui::EditRadioButtonAddressEx("Money font style", 0x58F57F, std::vector<Ui::NamedValue>{ { "Style 1", 1 }, { "Style 2" ,2 }, { "Default style" ,3 }});
static std::vector<Ui::NamedValue> font_outline{{ "No outline", 0 }, { "Thin outline" ,1 }, { "Default outline" ,2 }};
Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline);
static std::vector<Ui::NamedValue> style{ { "Style 1", 1 }, { "Style 2" ,2 }, { "Default style" ,3 }};
Ui::EditRadioButtonAddressEx("Money font style", 0x58F57F, style);
Ui::EditAddress<float>("Radar Height", 0x866B74, 0, 76, 999);
Ui::EditAddress<float>("Radar Width", 0x866B78, 0, 94, 999);
Ui::EditAddress<float>("Radar X position", 0x858A10, -999, 40, 999);
@ -220,7 +222,8 @@ void Visual::Main()
Ui::ColorPickerAddress("Radio station color", 0xBAB24C, ImVec4(150,150,150,255));
Ui::ColorPickerAddress("Styled text color", 0xBAB258, ImVec4(226,192,99,255));
Ui::ColorPickerAddress("Text color", 0xBAB234, ImVec4(50,60,127,255));
Ui::EditRadioButtonAddressEx("Wanted star border", 0x58DD41, std::vector<Ui::NamedValue>{ { "No border", 0 }, { "Default" ,1 }, { "Bold border" ,2 }});
static std::vector<Ui::NamedValue> star_border{ { "No border", 0 }, { "Default" ,1 }, { "Bold border" ,2 }};
Ui::EditRadioButtonAddressEx("Wanted star border", 0x58DD41, star_border);
Ui::ColorPickerAddress("Wanted star color + some text", 0xBAB244, ImVec4(144,98,16,255));
ImGui::EndTabItem();

View File

@ -64,7 +64,7 @@
// Globals
typedef std::vector<std::pair<std::string, void(*)(void)>> unsortedMap;
using namespace plugin;
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
enum Renderer
{

View File

@ -71,6 +71,7 @@ target_compile_options(${PROJECT_NAME} PRIVATE
>
$<$<CONFIG:Debug>:
/Od
/DEBUG:FULL
>
/std:c++latest;
/sdl-;

View File

@ -46,9 +46,8 @@ public:
DataT& get(const ObjT* obj)
{
auto& it = _pool.find(obj);
if (it != _pool.end())
return *it->second;
if (_pool.find(obj) != _pool.end())
return *_pool.find(obj)->second;
return *(_pool[obj] = std::make_unique<DataT>(obj));
}