Skip to content

Commit

Permalink
Merge branch 'master' into conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
yukani authored May 3, 2023
2 parents 4d4ab8d + 0ea6b4f commit d5f925e
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 34 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ git clone --recurse-submodules https://github.com/gta-reversed/gta-reversed-mode

You can create symbolic links for artifacts to not copy them every time you compiled the project.

Open a console in the cloned git repo's directory (administrator privileges may be needed) and type in the following commands:
```shell
cd contrib
link_asi.bat "<GAME_PATH>/scripts"
```
Replace `<GAME_PATH>` with the path to the game's root directory (i.e.: Where the `exe` is)
Open a console with administrator privileges in the git repo's directory and run `contrib\link_asi.bat` or right click `link_asi.bat` file and click `Run as administrator`, then
follow instructions at the command window.

### What to work on?
Check [this](https://github.com/gta-reversed/gta-reversed-modern/discussions/402) out for some inspiration ;)
Expand Down
34 changes: 28 additions & 6 deletions contrib/link_asi.bat
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
@echo off
rem Check for admin rights
net session >nul 2>&1
if not %errorlevel% == 0 (
echo This script needs to be run as administrator!
pause
exit
)

set pwd=%~dp0
set scriptdir=%1
set scriptname=%2

if "%scriptdir%"=="" goto :eof
:scriptdir_loop
set /p scriptdir="GTA SA 'scripts' directory path: "
if "%scriptdir%"=="" (
echo Invalid path!
goto scriptdir_loop
)

set /p scriptname="Name of the script file (default: gta_reversed): "
if "%scriptname%"=="" set scriptname="gta_reversed"

mklink %scriptdir%\%scriptname%.asi "%pwd%\..\bin\debug\gta_reversed.asi"
mklink %scriptdir%\%scriptname%.pdb "%pwd%\..\bin\debug\gta_reversed.pdb"
:scriptconf_loop
set /p scriptconf="Choose configuration to link (debug/release, default: debug): "
if "%scriptconf%"=="" set scriptconf=debug

if not "%scriptconf%"=="debug" if not "%scriptconf%"=="release" (
echo Invalid configuration! Only 'debug' and 'release' is applicable!c
goto scriptconf_loop
)

mklink "%scriptdir%\%scriptname%.asi" "%pwd%\..\bin\%scriptconf%\gta_reversed.asi"
mklink "%scriptdir%\%scriptname%.pdb" "%pwd%\..\bin\%scriptconf%\gta_reversed.pdb"

eof:
pause
8 changes: 6 additions & 2 deletions source/game_sa/Collision/Collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "TaskComplexEnterCarAsDriver.h"
#include "TaskComplexEnterCarAsPassenger.h"

#define NOTSA_VANILLA_COLLISIONS
#define NOTSA_VANILLA_COLLISIONS // TODO: move to config.h?

using Shape = CCollision::DebugSettings::ShapeShapeCollision::Shape;

Expand Down Expand Up @@ -3058,10 +3058,12 @@ bool CCollision::SphereVsEntity(CColSphere* sphere, CEntity* entity) {
}

void CCollision::InjectHooks() {
// Must be done be4 hooks are injected
#ifdef TEST_COLLISION_FUNCS
// Must be done before hooks are injected
for (auto i = 0; i < 20; i++) {
Tests(i);
}
#endif

RH_ScopedClass(CCollision);
RH_ScopedCategoryGlobal();
Expand Down Expand Up @@ -3147,6 +3149,7 @@ void CCollision::InjectHooks() {
}

void CCollision::Tests(int32 i) {
#ifdef TEST_COLLISION_FUNCS
const auto seed = (uint32)time(nullptr) + i;
srand(seed);
std::cout << "CCollision::Tests seed: " << seed << std::endl;
Expand Down Expand Up @@ -3479,4 +3482,5 @@ void CCollision::Tests(int32 i) {
Test("ProcessLineBox", Org, Rev, CmpEq, RandomLine(), RandomBox());
}*/
#endif
}
2 changes: 1 addition & 1 deletion source/game_sa/GangInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CGangInfo::CGangInfo() {
// NOTSA
size_t CGangInfo::GetNumOfWeaponChoices() const {
size_t n{};
for (; m_nGangWeapons[n] != WEAPON_UNARMED && n++ < m_nGangWeapons.size(););
for (; m_nGangWeapons[n] != WEAPON_UNARMED && ++n < m_nGangWeapons.size(););
return n;
}

Expand Down
2 changes: 1 addition & 1 deletion source/game_sa/GenericGameStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static void SaveMultipleDataToWorkBuffer(Ts&&... data) {
template<uint32 ExpectedSize, bool HasSizeHeader = true, typename... Ts>
static void LoadMultipleDataFromWorkBuffer(Ts*... out) {
if constexpr (HasSizeHeader) { // Verify size header
const auto size = LoadDataFromWorkBuffer<uint32, false>();
const auto size = LoadDataFromWorkBuffer<uint32>();
assert(size == ExpectedSize);
}
(CGenericGameStorage::LoadDataFromWorkBuffer((void*)out, sizeof(Ts)), ...); // And now load all data
Expand Down
4 changes: 2 additions & 2 deletions source/game_sa/LoadingScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CSprite2d;

// TODO: Move this to an appropriate place
static inline struct FastLoadSettings {
inline struct FastLoadSettings {
int32 SaveGameToLoad = -1; //< -2 - Don't load, -1 = Load first available, 0 <= - load from save slot
bool TriedLoadingSaveGame = false; //< [Runtime Var] Whenever `SaveGameToLoad` was tried to be loaded
uint32 SkipSaveGameLoadKey = VK_CONTROL; //< Skip auto-loading save game (If enabled)
Expand Down Expand Up @@ -37,7 +37,7 @@ static inline struct FastLoadSettings {
if (slot == -1) { // Find first valid slot and load that
CFileMgr::SetDirMyDocuments();
for (auto i = 0u; i < MAX_SAVEGAME_SLOTS; i++) {
if (std::filesystem::exists(std::format("GTASAsf{}.b", i))) {
if (std::filesystem::exists(std::format("GTASAsf{}.b", i + 1))) { // Save file IDs start from 1, not 0
return StartGame(i); // Load this slot
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/game_sa/Models/LodAtomicModelInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ void CLodAtomicModelInfo::InjectHooks()

CLodAtomicModelInfo::CLodAtomicModelInfo() : CAtomicModelInfo()
{
field_20 = 0;
field_22 = 0;
m_numChildren = 0;
m_numChildrenRendered = 0;
}

CLodAtomicModelInfo* CLodAtomicModelInfo::AsLodAtomicModelInfoPtr()
Expand Down
4 changes: 2 additions & 2 deletions source/game_sa/Models/LodAtomicModelInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class NOTSA_EXPORT_VTABLE CLodAtomicModelInfo : public CAtomicModelInfo {
public:
int16 field_20;
int16 field_22;
int16 m_numChildren;
int16 m_numChildrenRendered;

public:
CLodAtomicModelInfo();
Expand Down
11 changes: 6 additions & 5 deletions source/game_sa/Scripts/CommandParser/ReadArg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@ concept PooledType =
};

namespace detail {
//! Check if the type is an integer type excluding bool and character types.
template<typename T>
inline constexpr bool is_standard_integer = std::is_integral_v<T> && !is_any_of_type_v<T, bool, char, wchar_t, char8_t, char16_t, char32_t>;

//! Safely cast one arithmetic type to another (Checks for under/overflow in debug mode only), then casts to `T`
template<typename T, typename F>
inline T safe_arithmetic_cast(F value) {
#ifdef NOTSA_DEBUG
if constexpr (std::numeric_limits<F>::lowest() < std::numeric_limits<T>::lowest()) { // Underflow
assert(value >= static_cast<F>(std::numeric_limits<T>::lowest()));
}
if constexpr (std::numeric_limits<F>::max() >= std::numeric_limits<T>::max()) { // Overflow
assert(value <= static_cast<F>(std::numeric_limits<T>::max()));
if constexpr (is_standard_integer<T> && is_standard_integer<F>) {
assert(std::in_range<T>(value));
}
#endif
return static_cast<T>(value); // In release mode just a simple, regular cast
Expand Down
3 changes: 3 additions & 0 deletions source/game_sa/Scripts/CommandParser/Utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,7 @@ inline auto GetPedOrItsVehicle(CPed& ped) -> CPhysical& {
template<std::size_t I, typename... Ts>
using nth_element_t = typename std::tuple_element<I, std::tuple<Ts...>>::type;

template<typename T, typename... Ts>
concept is_any_of_type_v = (std::same_as<T, Ts> || ...);

}; // notsa
2 changes: 1 addition & 1 deletion source/game_sa/Scripts/Commands/Basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ void notsa::script::commands::basic::RegisterHandlers() {
REGISTER_COMMAND_HANDLER(COMMAND_ABS_LVAR_FLOAT, AbsStore<float>);

REGISTER_COMMAND_HANDLER(COMMAND_GOTO, GoTo);
REGISTER_COMMAND_HANDLER(COMMAND_GOTO_IF_FALSE, GoToIfFalse);
//REGISTER_COMMAND_HANDLER(COMMAND_GOTO_IF_FALSE, GoToIfFalse);
REGISTER_COMMAND_HANDLER(COMMAND_GOSUB, GoToSub);
REGISTER_COMMAND_HANDLER(COMMAND_RETURN_TRUE, ReturnTrue);
REGISTER_COMMAND_HANDLER(COMMAND_RETURN_FALSE, ReturnFalse);
Expand Down
8 changes: 4 additions & 4 deletions source/game_sa/Scripts/Commands/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1386,13 +1386,13 @@ void DisableCharSpeech(CPed& ped, bool stopCurrentSpeech) {
}

// SET_CHAR_WANTED_BY_POLICE
void SetCharWantedByPolice(CPed& ped) {
ped.bWantedByPolice = true;
void SetCharWantedByPolice(CPed& ped, bool state) {
ped.bWantedByPolice = state;
}

// SET_CHAR_SIGNAL_AFTER_KILL
void SetCharSignalAfterKill(CPed& ped) {
ped.bSignalAfterKill = true;
void SetCharSignalAfterKill(CPed& ped, bool state) {
ped.bSignalAfterKill = state;
}

// SET_CHAR_COORDINATES_DONT_WARP_GANG_NO_OFFSET
Expand Down
1 change: 0 additions & 1 deletion source/game_sa/Scripts/Commands/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,5 +372,4 @@ void notsa::script::commands::game::RegisterHandlers() {
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_IS_XBOX_PLAYER2_PRESSING_START);
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_FINISHED_WITH_XBOX_PLAYER2);
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_RESTORE_PLAYER_AFTER_2P_GAME);
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_IS_2PLAYER_GAME_GOING_ON);
}
2 changes: 1 addition & 1 deletion source/game_sa/Scripts/Commands/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void notsa::script::commands::player::RegisterHandlers() {
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_RESET_NUM_OF_MODELS_KILLED_BY_PLAYER);
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_GET_NUM_OF_MODELS_KILLED_BY_PLAYER);
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_SET_CAR_ONLY_DAMAGED_BY_PLAYER);
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_SET_PLAYER_NEVER_GETS_TIRED);
//REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_SET_PLAYER_NEVER_GETS_TIRED);
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_SET_PLAYER_FAST_RELOAD);
//REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_SET_EVERYONE_IGNORE_PLAYER);
REGISTER_COMMAND_UNIMPLEMENTED(COMMAND_SET_CAMERA_IN_FRONT_OF_PLAYER);
Expand Down

0 comments on commit d5f925e

Please sign in to comment.