Giter Site home page Giter Site logo

gta-reversed / gta-reversed-modern Goto Github PK

View Code? Open in Web Editor NEW
523.0 25.0 88.0 13.42 MB

Reimplementation of GTA:SA 1.0 US

CMake 0.07% C 19.05% Batchfile 0.01% Lua 0.08% C++ 80.72% Python 0.07%
source-code gtasa mtasa multitheftauto grandtheftauto plugin-sdk modern-cpp bug-fix bug-fixing windows

gta-reversed-modern's Introduction

gtasa-reversed Build Status

A project to reverse Grand Theft Auto San Andreas completely, and to rewrite and document every function.

What exactly is this project?

Building this project will result in a DLL file that can be injected into GTA:SA using any ASI loader out there. After the DLL file has been injected, the ingame functions will be replaced by the reversed ones. The game will behave the same. Now if we make any changes to the reversed code, it will take effect in the game. The goal is to keep reversing until we have the entire game reversed to compile a standalone executable.

Progress

The progress of reversed classes can be tracked here. (needs to be updated) We currently estimate that about 50-60% of the code is done. Since this project is done as a hobby, and worked on at irregular intervals, there's no real time estimate.

Coding Guidelines

Before you start writing code, please make sure to read the coding guidelines for this project.

Requirements

Build Instructions

You can either build with Premake5 or CMake; that's up to you, but a C++20 capable compiler [with <ranges>, <format> support] is required.

First clone the project, including the submodules:

git clone --recurse-submodules https://github.com/gta-reversed/gta-reversed-modern.git
Premake5
  1. Execute premake5.bat

  2. You'll find gta_reversed.sln shortcut in the same folder as premake5.

  3. Open it, and once the project has loaded, just hit CTRL + SHIFT + B

CMake
  1. Sadly CMake requires VS22, because since CMake v3.20.4 cxx_20 maps to std=c++20 instead of std=c++latest. If you really want to avoid VS22, you can either downgrade your CMake, or change c++20 to c++latest manually in the project settings... Or just use premake5 instead.

  2. Download and install the latest version of CMake for windows from HERE and make sure to add it to your PATH.

GUI
  1. Open CMake GUI

  2. Set the Source and Build directories (Don't forget to append "Bin" after the path for build), like this:

Capture

  1. Click configure, then you will see a dialogue box. Choose the IDE you have (In the image below it's VS2019) and "Win32", then click Finish.

CMakeSettings

  1. Once the configuration is complete, click the Generate button.

  2. You'll find GTASA.sln in the Bin folder.

CLI
  1. Open Command Prompt in the gta-reversed directory and run cmake -Bbuild -H. -A Win32.

  2. To open the Visual Studio project, simply run cmake --open build or open build/GTASA.sln manually.

  3. Once the configuration is complete, click the Generate button.

  4. You'll find GTASA.sln in Bin folder.

Game

To install all the necessary files, run install.py with administrator privileges [Necessary to create symlinks on Windows] in the root directory. Alternatively, you can install them by yourself:

You can download them in a single archive. Using other plugins is strongly discouraged and we provide no support.

To run the game with the Modern plugin, you just need to run the "Local Windows Debugger" in Visual Studio.

What to work on?

Check this out for some inspiration ;)

Credits

gta-reversed-modern's People

Contributors

afskyy avatar amyrahmady avatar batuaksoy avatar bigbossbro08 avatar botder avatar codenulls avatar crosroad95 avatar dependabot[bot] avatar forkerer avatar frouk3 avatar imring avatar izzotop avatar jaapionl avatar lex3a avatar majesticcoding avatar maxtorcoder avatar mikuauahdark avatar mrjohndev avatar pirulax avatar plakapenka avatar simplyceo avatar sociopart avatar sorpdev avatar spmn avatar temajm avatar theartemmaps avatar unnunu avatar user-grinch avatar vladik01-11 avatar yukani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gta-reversed-modern's Issues

ScanBigBuildingList - Crash

ScanBigBuildingList causes a crash because it tries to add to many entities to the render list using AddEntityToRenderList (which is where it actually crashes, because ms_nNoOfVisibleEntities is incremented to some absurdly high value).

Unhooking it fixes the problem.

Fireman disappearing from firetruck

Seems to happen only the first time they come out.
Unhooking CWorld::Process doesn't help.
Possible way to trace the issue may be to hook CWorld::Remove or CPopulation::RemovePed and see where it's called from.
image

Fix ProcessColModels

  • Turns out Dumper uses disks... And I haven't implemented disks. (upd: Izzotop: MonsterTruck and cranes uses too)
  • Also, there seems to be some collision bug when you stick the car to a wall.

Breaking door

Sometimes when entering to interior or vice versa, the door breaks.

image
image

Location
image

CTaskSimpleInAir::ProcessPed

Describe the bug
Incorrect fall animation.

To Reproduce
Steps to reproduce the behavior:

FindPlayerPed()->GetPosition() += { 0.0f, 0.0f, 2000.f };
Video
8mb.video-TEk-5y4O688s.mp4

Add better search functionality to Hooks tool

The original idea (Refer here for the final implementation):

Right now it's only possible to search by class name, but not by function name.
I propose the following format:

  • <namespace (class)>::<function name>
  • Just like in C++, it's possible to refer to the global namespace by typing :: (without anything before ::)
  • If there's no :: or there's nothing after it we just filter the namespace list

Eg.:

  • CWorld::Process - Should yield CWorld with all functions whose name starts with Process
  • ::Process - All functions starting with Process
  • Process:: - All functions inside the Process class/namespace
  • Entity/:: - All functions inside the Entity category (Note the trailing / at the end - It is needed to differentiate between a class and category)
  • Entity/Ped:: - Similar to above, but only show functions inside the Entity/Ped category.
  • Entity:: - All functions inside the Entity class

For now this should be enough, in another PR fuzzy search could be added, to make stuff like:

  • World::Process -> Would display all classes which contain the word "Word" and have a function whose name contains Process

image

Game hangs in cutscenes

Can't play missions (duh) and start a new game.

Faulty func: CClothes::RebuildCutscenePlayer

Fix double con/destruction of classes with a c/dtor that isn't reversed

Describe the bug
Right now classes with a c/dtor that isn't reversed will be double con/destructed, because when our ctor is called we call the original ctor, and then compiler will con/destruct all members over again.

To Reproduce
CPed is a good example: It has no reversed dtor. If one would add it, and just plugin::Call the original one they would experience a crash (likely in CMatrixLink)

Expected behavior
All classes with an c/dtor that hasn't been reversed should get reversed.

Additional context
Fixing this may fix quite some random issues.

Add RH_ScopedVirtualInstall

It should be similar to RH_ScopedInstall, but it should take the address of the _Reversed function instead.
Eg.: RH_ScopedVirtualInstall(GetTaskType, 0xdeadbeef) Should expand to something like InstallHook("ClassName", "GetTaskType", &GetTaskType_Reversed)

Adding this macro will get rid of the ugly _Reversed prefix in the GUI.

Fix rendering issues

  • CRenderer::ScanSectorList - Problem with alpha on the road
  • CRenderer::ScanBigBuildingList - Loop seems to go-on forever, and crashes in AddMovingEntityPtr (because numVisibleEntityPtrs is too high)
  • CVisibilityPlugins. Produces bad render while only they hooked

Also maybe CRenderer::AddEntityToRenderList is wrong.

Try hook/unhook CRenderer::ScanBigBuildingList several time and bug will apear.

Images

image
image

Questions

I'm curious how long it might be before there is a standalone executable at the rate this project is moving? Further, once it does reach a complete state where it matches the original in function, would this project then start working on adding new features on top of the game? Like say optimizing it, fixing bugs, adding a few tweaks, and maybe custom textures and sounds to replace the original?

Add `locked` option to ReversibleHooks

An option to "lock" hooks would be nice (that is, the hook's state can't be changed from the GUI).
Would be very useful in situations like #220 where we want to install hooks which always unhooked.

Phone still rings while using a jetpack

Describe the bug
Game still rings the phone for a frame-perfect time then dismiss while using a jetpack. Phone shouldn't ring at the first place.

To Reproduce
Steps to reproduce the behavior:

  1. Load the save I uploaded below.
  2. Get outside and enter the jetpack.
  3. Wait for the phone ring, this is the bug.

Additional context
vlcsnap-2022-02-12-23h05m54s289
(took a while to catch the perfect frame ๐Ÿ˜„)

GTASAsf7.zip

Sandbag physics broken

2022-02-05.20-01-48.mp4

Faulty func: CPhysical::??? (also punching bags after unhooked ApplyForce crashes the game)

Fix `ProcessEntityCollision` not overridden in some classes

Describe the bug
There are a few classes that originally overwrote ProcessEntityCollision, yet we don't (which causes issues).
I've fixed CAutomobile in 11ed5a7, but there are still a few classes that don't override it. (CTrailer, CBoat, etc)

To Reproduce
See original VTables

Starting `Initial 2` mission crashes the game

Describe the bug
Starting Initial 2 mission crashes the game

To Reproduce

  1. Start the Initial 2 mission

Screenshots

image

Additional context
Crashes in CCarGenerator, this is always 0xE27AB0 (Which causes a write access violation)

Unlock master branch

Here's a list of stuff we gotta fix:

  • #148
  • #81
  • #90
  • #91
  • Fix CWaterCannon (For whatever reason cannons are stuck in the air shooting water when a new game/save is loaded) #113
  • Test CStats::FindMaxNumberOfGroupMembers crashes the game while recruiting - Only crashes for @yukani
  • #159
  • Grass -> 0x4106D0 then both 0x538440 and 0x5B5000 - Grass not visible on models
  • Resolve bugs in CColStore::AddRef and CColStore::RemoveRef (see funcs)
  • #83
  • #103
  • #111
  • #112
  • #119
  • #117
  • #118
  • #142
  • #149
  • #121
  • #164
  • #171
  • #185
  • Fix CAutomobile
  • #272

HooksModule: Entering "\:" then deleting ":" will cause an assert

This isn't really the issue of HooksModule, it's just where it "comes out".
It's SplitStringView being garbage (Sadly only C++23 has the required stuff that we'd need to get rid of this function).
Using tne range-constructor of string_view (c++23) it works fine, so I'll probably do that.
Until then, don't enter such strings :D

Edit:
Actually, the fix would be this I think:

if (&*rng.begin() != str.end()) {
    return std::string_view(&*rng.begin(), std::ranges::distance(rng));
} else {
    return "";
}

Missing stubs for classes

Car door stuff
  • CTaskSimpleCarGoToPointNearDoorUntilDoorNotInUse
  • CTaskComplexOpenDriverDoor
  • CTaskComplexOpenPassengerDoor
Seek Pos Calculator's
  • CEntitySeekPosCalculatorDriving
  • CEntitySeekPosCalculatorEntitySurface
  • CEntitySeekPosCalculatorVehicleId
  • CTaskComplexSeekEntityAiming
Simple Interior Tasks
  • CTaskInteriorBeInHouse
  • CTaskInteriorBeInOffice
  • CTaskInteriorBeInShop
  • CTaskInteriorGoToInfo
  • CTaskInteriorLieInBed
  • CTaskInteriorShopKeeper
  • CTaskInteriorSitAtDesk
  • CTaskInteriorSitInChair
  • CTaskInteriorUseInfo
CTaskSimpleCar...
  • CTaskSimpleCarOpenLockedDoorFromOutside
  • CTaskSimpleCarSetPedSlowDraggedOut
  • CTaskSimpleCarShuffle
  • CTaskSimpleCarSlowBeDraggedOut
HurtPedWithCar
  • CTaskSimpleHurtPedWithCar
  • CTaskSimpleKillPedWithCar
  • CTaskComplexHitPedWithCar
Simple Tasks
  • CTaskSimpleDuckToggle - Script
  • CTaskSimpleFinishBrain - Script
  • CTaskSimpleOnEscalator
  • CTaskSimpleSetCharIgnoreWeaponRangeFlag
  • CTaskSimpleSetKindaStayInSamePlace
  • CTaskSimpleWaitUntilLeaderAreaCodesMatch
CTaskComplexKill...
  • CTaskComplexKillCriminal
CTaskComplexFollow...
  • CTaskComplexFollowLeaderAnyMeans
  • CTaskComplexFollowPatrolRoute
CTaskComplexEnterCar...
  • CTaskComplexEnterCarAsDriverTimed
  • CTaskComplexEnterCarAsPassengerTimed
Complex Tasks
  • CTaskComplexFallToDeath
  • CTaskComplexWalkAlongsidePed
  • CTaskComplexEvasiveDiveAndGetUp
CTaskComplexUseClosestFreeScriptedAttractor...
  • CTaskComplexUseClosestFreeScriptedAttractor
  • CTaskComplexUseClosestFreeScriptedAttractorRun
  • CTaskComplexUseClosestFreeScriptedAttractorSprint
CTaskComplexUseEffect... (Needed for CTaskComplexUseClosestFreeScriptedAttractor)
  • CTaskComplexUseEffect
  • CTaskComplexUseEffectRunning
  • CTaskComplexUseEffectSprinting
Unused
  • CTaskComplexFollowNodeRouteShooting
  • CTaskComplexFallAndStayDown
  • CTaskComplexExtinguishFireOnFoot
  • CTaskSimpleRunAnimLoopedMiddle
  • CTaskSimpleBeHitWhileMoving
  • CTaskSimpleChat
  • CTaskSimpleDuckWhileShotsWhizzing
  • CTaskComplexGoToPointUntilCollisionAndStandStill
  • CTaskComplexKillAllThreats
  • CTaskComplexUseAttractorPartner
  • CTaskComplexPresentIDToCop
  • CTaskComplexReactToAttack
  • CTaskSimpleHailTaxi
  • CTaskSimpleHailTaxiAndPause
  • CTaskComplexUseEntryExit
  • CTaskSimpleWaitForPizza
  • CTaskSimpleTriggerEvent
CTaskComplexUseAttractor
  • CTaskComplexUsePairedAttractor

Fix CClouds::MovingFogRender

Issue

How it looks like

image

How it should look like

image

Reproduce
Turn on foggy weather through debug menu.
Make sure CClouds::MovingFogRender is hooked.

Task pool gets full, makes game crash

Describe the bug
The task pool (eg.: CPool) is full after some chasing by cops. Now, I'm not sure if it's because I was in a Rhino, but I'm pretty sure the vanilla game doesnt crash even when youre chased by the police in a Rhino.
From the video you can see I crash when there's a lot of stuff going on around me. I guess that's related as well.

To Reproduce

  1. Take Rhino (I don't even think you need a vehicle)
  2. Make yourself Wanted thru the cheat debug menu
  3. Start running from them
  4. Crash

Expected behavior
To not crash xddd

Screenshots
I'll post a video

Additional context
We probably have a mem leak somewhere. Good start would be the task manager/CPedIntel
dmp here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.