Jump to content

Wanna contribute, need some help


Recommended Posts

Well, MTA build-in OOP math kind of sucks. I wanna add some new functions and classes to enrich its functionality, so it will open the usage of some advanced techniques for nubs.

I have problems compiling MTA SA source. IRC chat seems to be non-responsive, and it's kickinng all the time, so I'll post my questions here:

1. projects "breakpad" and "Shared" set to skipped - is that correct? (I've messed a lot with project settings trying to fix missing "d3dx9.h", so not sure what is the right setting should be).

2. I have these errors (VS 2015):

1>------ Build started: Project: DirectX9GUIRenderer, Configuration: Debug Win32 ------
2>------ Build started: Project: pthread, Configuration: Debug Win32 ------
1>  DirectX9GUIRenderer.vcxproj -> D:\MTA SA\mtasa-blue\Build\bin\x86\Debug\DirectX9GUIRenderer_d.lib
3>------ Build started: Project: pcre, Configuration: Debug Win32 ------
4>------ Build started: Project: curl, Configuration: Debug Win32 ------
5>------ Skipped Build: Project: breakpad, Configuration: Debug Win32 ------
5>Project not selected to build for this solution configuration 
2>  pthread.vcxproj -> D:\MTA SA\mtasa-blue\Build\..\Bin\server\pthread_d.dll
2>  pthread.vcxproj -> ..\Bin\server\pthread_d.pdb (Full PDB)
2>  Недопустимое число параметров
2>  Не удается найти указанный файл.
2>  Не удается найти указанный файл.
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: The command "IF EXIST ..\Bin\server\pthread_d.dll\ (xcopy /Q /E /Y /I ..\Bin\server\pthread_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mta\ > nul) ELSE (xcopy /Q /Y /I ..\Bin\server\pthread_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mta\ > nul)
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: copy D:\MTA SA\mtasa-blue\Build\..\Bin\server\pthread_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mta\pthread.dll
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: copy D:\MTA SA\mtasa-blue\Build\..\Bin\server\pthread_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\server\pthread.dll
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :VCEnd" exited with code 1.
3>  pcre.vcxproj -> D:\MTA SA\mtasa-blue\Build\..\Bin\server\mods\deathmatch\pcre3_d.dll
3>  pcre.vcxproj -> ..\Bin\server\mods\deathmatch\pcre3_d.pdb (Full PDB)
3>  Недопустимое число параметров
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: The command "IF EXIST ..\Bin\server\mods\deathmatch\pcre3_d.dll\ (xcopy /Q /E /Y /I ..\Bin\server\mods\deathmatch\pcre3_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mods\deathmatch\ > nul) ELSE (xcopy /Q /Y /I ..\Bin\server\mods\deathmatch\pcre3_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mods\deathmatch\ > nul)
3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :VCEnd" exited with code 4.
6>------ Skipped Build: Project: Shared (Shared\Shared), Configuration: Debug Win32 ------
6>Project not selected to build for this solution configuration 
7>------ Build started: Project: XML, Configuration: Debug Win32 ------
4>  curl.vcxproj -> D:\MTA SA\mtasa-blue\Build\..\Bin\server\libcurl_d.dll
4>  curl.vcxproj -> ..\Bin\server\libcurl_d.pdb (Full PDB)
7>  XML.vcxproj -> D:\MTA SA\mtasa-blue\Build\..\Bin\server\xmll_d.dll
7>  XML.vcxproj -> ..\Bin\server\xmll_d.pdb (Full PDB)
4>  Недопустимое число параметров
4>  Не удается найти указанный файл.
4>  Не удается найти указанный файл.
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: The command "IF EXIST ..\Bin\server\libcurl_d.dll\ (xcopy /Q /E /Y /I ..\Bin\server\libcurl_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mta\ > nul) ELSE (xcopy /Q /Y /I ..\Bin\server\libcurl_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mta\ > nul)
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: copy D:\MTA SA\mtasa-blue\Build\..\Bin\server\libcurl_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mta\libcurl.dll
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: copy D:\MTA SA\mtasa-blue\Build\..\Bin\server\libcurl_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\server\libcurl.dll
4>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :VCEnd" exited with code 1.
7>  Недопустимое число параметров
7>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: The command "IF EXIST ..\Bin\server\xmll_d.dll\ (xcopy /Q /E /Y /I ..\Bin\server\xmll_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mta\ > nul) ELSE (xcopy /Q /Y /I ..\Bin\server\xmll_d.dll D:\MTA SA\mtasa-blue\Build\..\Bin\mta\ > nul)
7>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(133,5): error MSB3073: :VCEnd" exited with code 4.
========== Build: 1 succeeded, 4 failed, 34 up-to-date, 2 skipped ==========

 

Link to comment
1 hour ago, AfterAll14 said:

projects "breakpad" and "Shared" set to skipped - is that correct? (I've messed a lot with project settings trying to fix missing "d3dx9.h", so not sure what is the right setting should be).

d3dx9.h is part of the (legacy) DirectX SDK which is not shipped with the Windows SDK included in Visual Studio. Instead, you've to download and install it separately from https://www.microsoft.com/en-us/download/details.aspx?id=6812

After installing, undo all your changes and regenerate the solutions.

Link to comment

Yes, I followed those instructions. No matter what I do, I still get this error:  Microsoft.CppCommon.targets(133,5): error MSB3073 .

And there's no meaningful explanation how to fix it anywhere around the internet.

 

So, today Microsoft dickheads won :( I'll try again tomorrow

79652_Mortal_Kombat2.jpg

Edited by AfterAll14
  • Like 2
Link to comment

Update:

So, today was the day. I've managed to add some functions to extend Vector3 class.

After successfull build I've started the server and joined, checked that everything works and quit. Then I took a look into server log and something scared me: some guy named "NeedyNurse32" somehow joined my server:

log1.jpg

I was like "wtf? how did he managed to join custom server?!!". I immediately shut down the server and set up password in "mtaserver.conf". It took me a while to realize that the guy was actually me. I simply forgot that MTA assigns random nickname when you launch it first time xD xD xD.

So, moving on, I've tested functions performance, and results were quite humiliating:

mta_screen_2016_12_28_18_41_25.png

As you can see Lua is executing same functions about 3-4 times faster than c++. At this point I thought that there's no sense to continue, as the whole purpose of making funcs in c++ was to increase performance. It looked like the cost of transition between c++ and lua was way too high, and running math library in native Lua code turned out to be faster than offloading it to c++.

But... I didn't take into count how much MTA debug version was slower from release version. It took me a while to build release version (it's not mentioned on wiki, but apart from 2010 DirectX SDK you also need 2009 DirectX SDK to build in that config with no errors). And release mode it's a totally different story :):

mta_screen_2016_12_28_18_43_18.png

It's still far from perfect, transition cost still looks like a problem for c++, but moving on into more complex structures the difference should grow exponentially :).

Edited by AfterAll14
  • Like 1
Link to comment

Can anyone tell me what are those statements for?

file: CEntitySA.h
static_assert(sizeof(XYZ) == 0x54, "Invalid size for XYZ"); //line 105
static_assert(sizeof(XYZStore) == 0x1FC, "Invalid size for XYZStore"); //line 118
static_assert(sizeof(CEntitySAInterface) == 0x38, "Invalid size for CEntitySAInterface"); //line 244

I changed Vectors precision from float to double, and it gives me :~load of errors caused by the change of the classes sizes.

Link to comment

Ok, gave up on trying to switch precision. Looks like you have to rewrite 90% of the MTA code for that :S.

But still wanna get answer for the question above. I'm going to add one extra variable to CMatrix class, which will result in change of size for several classes that contain CMatrix objects, which will trigger those asserts.

Link to comment

It's been basically forever since I wrote any MTA code, but CMatrix and CVector are classes that need to match those in GTA - so their sizes can't be changed. You may have already realised this!

This also applies to any class that is suffixed with Interface.

Link to comment

@eAi Yeah, I already figured that out. Even rotation angles are calculated using hacked function in GTASA.

New classes are inherited from CMatrix and CVector, so original classes are same. But new ones have double precision and tons of new features :).

@4O4 Why not zero lines? :D

Edited by AfterAll14
Link to comment

It's pretty unusual for games to use double precision floating points - for example both Unity and Unreal don't support it (of course, you can use 64 bit floating point numbers, but everything internal uses 32 bit floats).

Link to comment

Depends on. For precise dynamic calculations (when matrix transformations occur several hundred times per second) using float will result in non-orthogonal relative positions for main axises in relatively short space of time. And, ofc, precision errors will grow as you go away from zero point (0,0,0), which will result in weird object behaviour.

As for commercial engines - they use 32bit as there's no sense in 64bit (graphics cards work in 32bit internally).

Anyways, I made it so that you can switch precision in 1 click. So if there would be any serious performance issues it can be easily adjusted. But from what I've tested so far there's absolutely zero impact on performance. Other factors (Lua->C++->Lua conversion, internal Lua speed) are so huge, you can go with 128bits without any difference :D

Edited by AfterAll14
  • Like 1
Link to comment

Another pro for using double in vectors is that Lua uses them internally anyway. We should be careful about the exact position where we convert the precision though (as GTA requires 32-bit in the end as eAi said and MTA uses float all over the place too).

1 hour ago, AfterAll14 said:

using float will result in non-orthogonal relative positions for main axises

That's of course true. However, afaik most engines use a modified (more numerical stable) Gram-Schmidt algorithm to re-orthogonalise such matrices. MTA's CMatrix class might even have the algorithm already implemented (not sure though). Also, such precision problems are normally not that bad as long as you're only talking about the "visual experience" and not going to implement a high-precision, deterministic physics engine.

1 hour ago, AfterAll14 said:

New classes are inherited from CMatrix and CVector

Do such classes have the fields twice (float + double) then?

Link to comment

Yeah, they do have double fields. Thats far from perfect decision, creates misleading references. But MTA architecture is such that it is the only way to make them work.

I may rewrite this in future. But this will require rewriting huge chunk of all functions.

As for now - I just want to make sure they work and not creating any bugs.

  • Like 1
Link to comment

So... I found a flaw in MTA OOP concept, that compromises the whole idea of OOP being OOP. Take a look at this code:

local M = Matrix( Vector3(10, 0, 0) )
M.position:normalize()

This code won't work. When you use .position MTA calls its internal function GetPosition() which creates new Vector3 object and pushes it into a script.

This means original position of matrix is not changed.

I tried to fix it, but atm I ran into situation where OOP methods are not recognized by Lua :S. (What I did - replaced vPos/vRight/vUp/vFront vectors in CLuaMatrix with pointers to CLuaVector3D objects, and pushed em into script alongside matrix when Create() is called).

If you have ideas how to fix it without rewriting whole OOP code - put it on the table please.

Link to comment
On 07/01/2017 at 2:38 PM, AfterAll14 said:

So... I found a flaw in MTA OOP concept, that compromises the whole idea of OOP being OOP. Take a look at this code:


local M = Matrix( Vector3(10, 0, 0) )
M.position:normalize()

This code won't work. When you use .position MTA calls its internal function GetPosition() which creates new Vector3 object and pushes it into a script.

This means original position of matrix is not changed.

I tried to fix it, but atm I ran into situation where OOP methods are not recognized by Lua :S. (What I did - replaced vPos/vRight/vUp/vFront vectors in CLuaMatrix with pointers to CLuaVector3D objects, and pushed em into script alongside matrix when Create() is called).

If you have ideas how to fix it without rewriting whole OOP code - put it on the table please.

I wouldn't say that breaks OOP - it's a fairly common situation (for example, Unity would behave exactly the same way). Perhaps .position should be be a function called GetPosition?

I'm way out of the loop on this stuff though!

Link to comment
  • 5 months later...

@eAi: `element.position` returns the same thing as `element:getPosition()`. Thinking back on it now, whilst doing `localPlayer.vehicle` is extremely convenient, having it for almost every function is a fundamental design flaw. 

@AfterAll14: the vectors are mutable, but i think some of those utility functions only return new versions with the operation applied. You should do `M.position = M.position:normalize()`. Any updates on your progress?

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...