Custom Train Tracks: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (add active commits, move to onlyinclude)
m (fix typo)
 
(39 intermediate revisions by the same user not shown)
Line 4: Line 4:
|-
|-
|'''Status'''
|'''Status'''
|<span style="color:orange">Working on</span>
|<span style="color:orange">Work in progress</span>
|-
|-
|'''Branch'''
|'''Branch'''
|[https://github.com/multitheftauto/mtasa-blue/tree/custom-train-tracks custom-train-tracks]
|[https://github.com/multitheftauto/mtasa-blue/tree/feature/custom-train-tracks feature/custom-train-tracks]
|-
|'''Branch version'''
|1.5.3
|}
 
=== Functions ===
* [[createTrack]]
* [[removeDefaultTrack]]
* [[resetDefaultTrack]]
* [[setTrackLength]]
* [[getTrackLength]]
 
=== Media ===
* [https://www.youtube.com/watch?v=S_Q3Gk4jVr0&user=UCbl-5xYsT5KwnrfGdW9LYPQ MTA:SA Custom train tracks #1]</onlyinclude>
 
== Development ==
=== API ===
<syntaxhighlight lang="lua">
-- trainNode is a Vector3, or table of three coordinates
-- nodes is a table of trainNodes
 
track = TrainTrack(...nodes) -- createTrack(node1, node2, node3, ...)
track:getNodes() returns a table of Vector3s
track:getLength() -- getTrainTrack(track)
-- Default track functions
TrainTrack.removeDefault(int trackID)
TrainTrack.resetDefault(int trackID)
 
-- These functions already exist, but I'm not sure how these lengths are used or what they are for
 
</syntaxhighlight>
 
=== Findings ===
All information related custom train tracks are stored here.
 
==== Files ====
<syntaxhighlight lang="lua">
MTA10/game_sa
** CTrainTrackManagerSA.{cpp,h}
** CTrainTrackSA.{cpp,h}
 
MTA10/mods/shared_logic
** CClientTrainTrack.{cpp,h}
** luadefs/CLuaTrainTrackDefs.{cpp,h} -- contain definitions for the Lua API
 
MTA10/sdk/game
** CTrainTrack.h
** CTrainTrackManager.h
 
MTA10_Server/mods/deathmatch/logic
** CTrainTrackManager.{cpp,h}
** CTrainTrack.{cpp,h}
** luadefs/CLuaTrainTrackDefs.{cpp,h} -- contain definitions for the Lua API
</syntaxhighlight>
 
==== m_OriginalTrainTrackData ====
The [https://pastebin.mtasa.com/748483851 m_OriginalTrainTrackData array] contains the same values in CTrainTrackManager.cpp and CTrainTrackManagerSA.cpp.
 
The Init function is structured like so (pay special attention to the comments):
<syntaxhighlight lang="lua">
typedef struct
{
    short sX;              // x coordinate times 8
    short sY;              // y coordinate times 8
    short sZ;              // z coordinate times 8
    float fRailDistance;    // on-rail distance ( leave the client to calculate this )
    void Init ( short sX, short sY, short sZ, unsigned short sRailDistance, WORD padding )
    {
        this->sX = sX;
        this->sY = sY;
        this->sZ = sZ;
        this->fRailDistance = sRailDistance;
    }
} SRailNode;
</syntaxhighlight>
 
We need to make sense of the following things:
 
* Why is padding an argument here? (It doesn't do anything, and when Init() is called, real values are provided)
* Why are values repeated several times?
* Why does the last repeat have slightly different values?
 
=== Issues ===
* There may be some issues (relating to infinite loops) if a track runs across another or crosses another
** Infinite loop occurs at 006f8fda, see [http://i.imgur.com/HvBWAFm.png call stack]. Occurs when a track of two nodes have same x/y, but different z. Only occurs for tracks that ONLY consist of nodes atop each other.
*** Possible solution: when creation tracks, ensure that atleast one of the nodes has a different x/y to any other node.
* Tracks may not be cleaned up -> See CTrainTrackManager::ResetTracks
* See CTrainTrackManager and CTrainTrackManagerSA - why is this file so big? Why are coordinates provided multiple times for the same track? Which ones are right?
* <strike>int CWorldSA::FindClosestRailTrackNode needs updating. It needs to use MAX_TOTAL_TRACKS and the train manager.</strike> [https://github.com/multitheftauto/mtasa-blue/commit/09e3ee8f25810c17742728f038786b6a223c5296 See 09e3ee8f25810c17742]
 
=== Re-merge ===
<section name="This section has been archived" collapse="true">
{| class="wikitable" style="width: auto; table-layout: fixed;"
|-
|'''Status'''
|<span style="color:red">Abandoned</span>
|-
|'''Branch'''
|[https://github.com/multitheftauto/mtasa-blue/tree/custom-train-tracks-old custom-train-tracks-old] (renamed from custom-train-tracks)
|-
|-
|'''Branch version'''
|'''Branch version'''
|1.4
|1.4
|}</onlyinclude>
|}
= Functions =
* [[createTrainTrack]]
* [[destroyTrainTrack]]
* [[setTrainTrackLength]]
* [[getTrainTrackLength]]
* [[setTrainTrackNumberOfNodes]]
* [[getTrainTrackNumberOfNodes]]
* [[getTrainTrackID]]
* [[getVehicleTrainTrack]]
* [[setVehicleTrainTrack]]
* [[getTrainTrackPosition]]


= Media =
The old '''custom-train-tracks''' branch contains commits cherry-picked and other merges from the 1.4 branch. The first task in updating this branch is to distinguish between merge commits and actual branch commits:
None.


= Active Commits =
* new branch [https://github.com/multitheftauto/mtasa-blue/commit/45d1a266e8f3e50d9605610a32210a9a9a6e145a 45d1a266e8f3e50d9605610a32210a9a9a6e145a]
The old '''custom-train-tracks''' branch contains commits cherry-picked and other merges from the 1.4 branch. The first task in updating this branch is to single out these commits:
* Added missing files and fixed compile errors [https://github.com/multitheftauto/mtasa-blue/commit/e2c5fcb83fa7df633f040dc6b0c048e2cd72bbb3 e2c5fcb83fa7df633f040dc6b0c048e2cd72bbb3]
* Small fix [https://github.com/multitheftauto/mtasa-blue/commit/76248682a3fdf8bf24c5d7e73f2bac4536f93069 76248682a3fdf8bf24c5d7e73f2bac4536f93069]
* ... Fixed crash 0013368B, 00133606, a memory leak a… [https://github.com/multitheftauto/mtasa-blue/commit/88b64d51526b342e22c4581ad9c2fa6b1632c2e1 88b64d51526b342e22c4581ad9c2fa6b1632c2e1]
* ... Fixed a crash with applying upgrades to vehicle… [https://github.com/multitheftauto/mtasa-blue/commit/3dd27775c0d371339337a162e59ef8320a6c6bb5 3dd27775c0d371339337a162e59ef8320a6c6bb5]
* ... Fixed #5618 - "Heli Rotors are not in ghostmode… [https://github.com/multitheftauto/mtasa-blue/commit/38d4e2da33466fee7f199981db24056a086e3376 38d4e2da33466fee7f199981db24056a086e3376]
* ... Fixed #7801 - "warpPedIntoVehicle can cause des… [https://github.com/multitheftauto/mtasa-blue/commit/6a394e0dc265628ba328ab94ce00e40ff3409eff 6a394e0dc265628ba328ab94ce00e40ff3409eff]
* ... Addendum to previous commit [https://github.com/multitheftauto/mtasa-blue/commit/7489405bbe5d590a3b6a259c5f49784238d1b739 7489405bbe5d590a3b6a259c5f49784238d1b739]
* ... Fixed a recently introduced server crash when u… [https://github.com/multitheftauto/mtasa-blue/commit/70fa16ea69c398487085ab46dd5970fa723b0e27 70fa16ea69c398487085ab46dd5970fa723b0e27]
* ... Applied patch from DirtY_iCE - "vehicle upgrade… [https://github.com/multitheftauto/mtasa-blue/commit/e521b274325f15fc9d2bb0f6830edb15680a9582 e521b274325f15fc9d2bb0f6830edb15680a9582]
* ... Fixed peds being ejected from vehicles and warp… [https://github.com/multitheftauto/mtasa-blue/commit/d0c6d1f8c4786c4f581ef5546f8ed7db60c401aa d0c6d1f8c4786c4f581ef5546f8ed7db60c401aa]
* ... Fixed #7803 - "spoilers" [https://github.com/multitheftauto/mtasa-blue/commit/191491f2ccdc65157309c561d01c5920867f81c8 191491f2ccdc65157309c561d01c5920867f81c8]
* ... Merged revisions(s) 5605-6091 from trunk [https://github.com/multitheftauto/mtasa-blue/commit/dc8f3ca4316d5da9212e752841c65fe328d88cf6 dc8f3ca4316d5da9212e752841c65fe328d88cf6]
* Fixed some crashes [https://github.com/multitheftauto/mtasa-blue/commit/92a1f4290625b07b651166cd333d3c43dad7ab0f 92a1f4290625b07b651166cd333d3c43dad7ab0f]
* ... Merged revision(s) 6092-6137 from trunk [https://github.com/multitheftauto/mtasa-blue/commit/61976a30a1edda6150d1840833ab8ac2d22ae59a 61976a30a1edda6150d1840833ab8ac2d22ae59a]


* new branch [https://github.com/multitheftauto/mtasa-blue/commit/45d1a266e8f3e50d9605610a32210a9a9a6e145a 45d1a266e8f3e50d9605610a32210a9a9a6e145a]
This means that there are only four commits that need to be merged into the new branch. <strike>There is currently a packet issue introduced by the merge that needs to be fixed.</strike>
</section>
[[Category: Development]]

Latest revision as of 22:12, 3 October 2016

This branch makes it possible to make your own train tracks.

Status Work in progress
Branch feature/custom-train-tracks
Branch version 1.5.3

Functions

Media

Development

API

-- trainNode is a Vector3, or table of three coordinates
-- nodes is a table of trainNodes

track = TrainTrack(...nodes) -- createTrack(node1, node2, node3, ...)
track:getNodes() returns a table of Vector3s
track:getLength() -- getTrainTrack(track)
-- Default track functions
TrainTrack.removeDefault(int trackID)
TrainTrack.resetDefault(int trackID)

-- These functions already exist, but I'm not sure how these lengths are used or what they are for

Findings

All information related custom train tracks are stored here.

Files

MTA10/game_sa
** CTrainTrackManagerSA.{cpp,h}
** CTrainTrackSA.{cpp,h}

MTA10/mods/shared_logic
** CClientTrainTrack.{cpp,h}
** luadefs/CLuaTrainTrackDefs.{cpp,h} -- contain definitions for the Lua API

MTA10/sdk/game
** CTrainTrack.h
** CTrainTrackManager.h

MTA10_Server/mods/deathmatch/logic
** CTrainTrackManager.{cpp,h}
** CTrainTrack.{cpp,h}
** luadefs/CLuaTrainTrackDefs.{cpp,h} -- contain definitions for the Lua API

m_OriginalTrainTrackData

The m_OriginalTrainTrackData array contains the same values in CTrainTrackManager.cpp and CTrainTrackManagerSA.cpp.

The Init function is structured like so (pay special attention to the comments):

typedef struct
{
    short sX;               // x coordinate times 8
    short sY;               // y coordinate times 8
    short sZ;               // z coordinate times 8
    float fRailDistance;    // on-rail distance ( leave the client to calculate this )
    void Init ( short sX, short sY, short sZ, unsigned short sRailDistance, WORD padding )
    {
        this->sX = sX;
        this->sY = sY;
        this->sZ = sZ;
        this->fRailDistance = sRailDistance;
    }
} SRailNode;

We need to make sense of the following things:

  • Why is padding an argument here? (It doesn't do anything, and when Init() is called, real values are provided)
  • Why are values repeated several times?
  • Why does the last repeat have slightly different values?

Issues

  • There may be some issues (relating to infinite loops) if a track runs across another or crosses another
    • Infinite loop occurs at 006f8fda, see call stack. Occurs when a track of two nodes have same x/y, but different z. Only occurs for tracks that ONLY consist of nodes atop each other.
      • Possible solution: when creation tracks, ensure that atleast one of the nodes has a different x/y to any other node.
  • Tracks may not be cleaned up -> See CTrainTrackManager::ResetTracks
  • See CTrainTrackManager and CTrainTrackManagerSA - why is this file so big? Why are coordinates provided multiple times for the same track? Which ones are right?
  • int CWorldSA::FindClosestRailTrackNode needs updating. It needs to use MAX_TOTAL_TRACKS and the train manager. See 09e3ee8f25810c17742

Re-merge

Click to expand [+]
This section has been archived