Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gta-reversed/gta-reversed-modern …
Browse files Browse the repository at this point in the history
…into reverse/CPedGroup
  • Loading branch information
Pirulax committed Jul 12, 2023
2 parents a85468d + 163ddc6 commit 353cd15
Show file tree
Hide file tree
Showing 264 changed files with 10,419 additions and 4,406 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
[submodule "libs/imgui"]
path = libs/imgui
url = ../../ocornut/imgui.git
branch = docking
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
61 changes: 48 additions & 13 deletions docs/CodingGuidelines.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
* Please check and try to eliminate warnings from your code.

### Code style
* 4 space indentation, LF line endings.
* If some rule about something is not specified here, refer to how it's done in the code.
* Some classes may have *helper* functions to make code more readable. (usually denoted by *NOTSA* or *Helpers*) Try looking for and use them.
* 4 space indentation, LF line endings
* No hungarian notation [It's useless]
* If some rule about something is not specified here, refer to how it's done in the code
* Some classes may have *helper* functions to make code more readable. (Denoted by *NOTSA*) - Try adding new ones, or looking for and using them.
* Prefer `get`-ters/`set`-ters over raw member access
* Use range-based for loops as much as possible.
* We encourage you to write modern C++, but if that's not your style, please keep the following in mind:
```cpp
for (auto& element : array); // <-- GOOD

Expand All @@ -17,23 +20,55 @@ for (int i = 0; i < std::size(array); i++); // <-- BAD
```cpp
for (auto&& [i, e] : notsa::enumerate(array));
```
* If there's a dynamic `count` variable associated with a fixed size array, use `std::span` or `rng::views::take`. E.g.:
```cpp
// Bad
for (auto i = 0u; i < m_numThings; i++);

// Good
for (auto& thing : std::span{ m_things, m_numThings });
// Also good
for (auto& thing : m_things | rng::views::take(m_numThings));

* Use `f` in float literals, omitting it makes them double. (e.g. `1.0f`)
* Use `std` library for generic functions like `min`, `max`, `lerp` etc.
* Function prototypes must look like it's from Android symbols. Except for output parameters like `T*` can be changed to `T&` to make the code prettier.
* Use lambdas for repetitive procedures in functions.
* Use `constexpr` variables instead of macros.
// ^ If these funcs are called more than once, make a helper function in the header. Like below:
auto GetActiveThings() {
return std::span{ m_things, m_numThings }
}
* Use `f` in float literals [As omitting it would make them a `double`] (e.g. `1.0f`)
* Use `std` library for generic functions like `min`, `max`, `lerp`, etc...
* `CVector` is interchangible with 3 floats [As is `CVector2D` with 2 floats] for function args
* Use lambdas for repetitive procedures in functions
* Use `constexpr` variables instead of macros
* Use `static inline` instead of `extern` and `static` in headers:
```cpp
class Foo {
static uint32& m_FooCount; // Bad

static inline auto& m_FooCount = StaticRef<uint32, 0xDEADBEEF>(); // Good
}
```
#### Types
* Use `auto` in function bodies if the variables' type is guessable.
* Guess for enum values, at least leave a TODO comment for it.
* Take care of const correctness. (e.g. `const char*` over `char*`)
* Guess for enum values [Or at least leave a `TODO` comment]
* Take care of const correctness [Especially of class methods] (e.g. `const char*` over `char*`)
* Try to use SA types over RW as much as possible, **except** `RwMatrix`. (e.g. `CVector` for `RwV3d`, `CRGBA` for `RwRGBA`)
* Use fixed width integer types (e.g. `uint8`, `int32`).
* Use `std::array` for arrays most of the time. Do not use it if the variable is just a pair of values or something basic like that.
* Do not use Win32 types. (e.g. `DWORD` -> `uint32`)
* Do not use Win32 integer types. [Except for Win32 exclusive code] (e.g. `DWORD` -> `uint32`)
* For array sizes, etc.. prefer using `unsigned` types over `signed` ones
* Whenever possible use `std::array` over `C-Style` array [as the former has bounds checking in debug mode, and can help us discover many bugs]
#### Fixing bugs
Whenever you find a bug, we encourage you to fix it [and/or at least] leave a comment explaining what the bug is.
Bug fixes should only be active if `notsa::IsFixBugs()` returns `true`.
If that's not possible [due to code complexity], then wrap into an `#ifdef`:
```c
#ifdef FIX_BUGS
// Bug fixing code here
#endif
```

### Contributing
Please make sure to test your contribution before opening a PR. Guess what places/missions are affected by your code and test them. Use debug menu (F7) for quick access to stuff.
Please make sure to test your code before opening a PR. Guess what places/missions are affected by your code and test them. Use debug menu (F7) for quick access to stuff.

If you don't know how to test the code or think you have not tested enough specify it in the PR message.
2 changes: 1 addition & 1 deletion libs/imgui
Submodule imgui updated 189 files
124 changes: 124 additions & 0 deletions libs/premake5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
project "ogg"
language "C++"
kind "StaticLib"
targetname "ogg"
warnings "Off"

vpaths {
["Headers/*"] = {"ogg/**.h",},
["Sources/*"] = {"ogg/**.c",},
["*"] = {"premake5.lua", "CMakeLists.txt"}
}

files {
"ogg/**.h",
"ogg/**.c"
}

includedirs {
"vorbis/include",
"ogg/include",
"ogg/include"
}

project "vorbis"
language "C++"
kind "StaticLib"
targetname "vorbis"
warnings "Off"

vpaths {
["Headers/*"] = {"vorbis/**.h",},
["Sources/*"] = {"vorbis/**.c",},
["*"] = {"premake5.lua", "CMakeLists.txt"}
}

files {
"vorbis/win32/vorbis.def",
"vorbis/lib/**.*"
}

removefiles {
"vorbis/lib/psytune.c",
"vorbis/lib/tone.c",
"vorbis/lib/misc.c",
"vorbis/lib/psy.h",
}

includedirs {
"vorbis/include",
"ogg/include",
"%{cfg.targetdir}"
}

project "vorbisenc"
language "C++"
kind "StaticLib"
targetname "vorbisenc"
warnings "Off"

vpaths {
["Sources/*"] = {"vorbis/**.c",},
["*"] = {"premake5.lua", "CMakeLists.txt"}
}

files {
"vorbis/lib/vorbisenc.c",
"/vorbis/win32/vorbisenc.def"
}

includedirs {
"vorbis/include",
"ogg/include",
"%{cfg.targetdir}"
}


project "vorbisfile"
language "C++"
kind "StaticLib"
targetname "vorbisfile"
warnings "Off"

vpaths {
["Sources/*"] = {"vorbis/**.c",},
["*"] = {"premake5.lua", "CMakeLists.txt"}
}

files {
"vorbis/lib/vorbisfile.c",
"/vorbis/win32/vorbisfile.def"
}

includedirs {
"vorbis/include",
"ogg/include",
"%{cfg.targetdir}"
}

project "imgui"
language "C++"
kind "StaticLib"
targetname "imgui"
warnings "Off"

vpaths {
["Headers/*"] = {"imgui/**.h*",},
["Sources/*"] = {"imgui/**.c*",},
["*"] = {"premake5.lua", "CMakeLists.txt"}
}

files {
"imgui/backends/imgui_impl_win32.h",
"imgui/backends/imgui_impl_win32.cpp",
"imgui/backends/imgui_impl_dx9.h",
"imgui/backends/imgui_impl_dx9.cpp",
"imgui/misc/cpp/*.*",
"imgui/*.*",
}

includedirs {
"imgui",
"imgui/backends",
"imgui/misc/cpp"
}
Loading

0 comments on commit 353cd15

Please sign in to comment.