<commit_before>/*
Copyright (c) 2014-2021 AscEmu Team <http://www.ascemu.org>
This file is released under the MIT license. See README-MIT for more information.
*/

#pragma once

struct KeyFrame;
struct TransportTemplate;
struct GameObjectProperties;
class Transporter;

namespace MovementNew
{
    template <typename length_type> class Spline;
}

typedef MovementNew::Spline<double>                         TransportSpline;
typedef std::vector<KeyFrame>                               KeyFrameVec;
typedef std::unordered_map<uint32_t, TransportTemplate>     TransportTemplates;
typedef std::set<Transporter*>                              TransporterSet;
typedef std::unordered_map<uint32_t, Transporter*>          TransporterMap;
typedef std::unordered_map<uint32_t, TransporterSet>        TransporterInstancedMap;
typedef std::unordered_map<uint32_t, std::set<uint32_t>>    TransportInstanceMap;

typedef std::vector<DBC::Structures::TaxiPathNodeEntry const*> TaxiPathNodeList;
typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;

typedef std::map<uint32_t, DBC::Structures::TransportAnimationEntry const*> TransportPathContainer;
#if VERSION_STRING >= WotLK
typedef std::map<uint32_t, DBC::Structures::TransportRotationEntry const*> TransportPathRotationContainer;
#endif

struct PathNode
{
    uint32_t mapid;
    float x, y, z;
    uint32_t flags;
    uint32_t delay;
    uint32_t ArrivalEventID;
    uint32_t DepartureEventID;
};

class TransportPath
{
public:
    inline void setLength(const unsigned int sz)
    {
        i_nodes.resize(sz);
    }

    inline size_t size(void) const { return i_nodes.size(); }
    inline void resize(unsigned int sz) { i_nodes.resize(sz); }
    inline void clear(void) { i_nodes.clear(); }
    inline PathNode* getNodes(void) { return static_cast<PathNode*>(&i_nodes[0]); }
    float getTotalLength(void)
    {
        float len = 0, xd, yd, zd;
        for (unsigned int idx = 1; idx < i_nodes.size(); ++idx)
        {
            xd = i_nodes[idx].x - i_nodes[idx - 1].x;
            yd = i_nodes[idx].y - i_nodes[idx - 1].y;
            zd = i_nodes[idx].z - i_nodes[idx - 1].z;
            len += (float)std::sqrt(xd * xd + yd * yd + zd * zd);
        }
        return len;
    }

    PathNode & operator[](const unsigned int idx) { return i_nodes[idx]; }
    const PathNode & operator()(const unsigned int idx) const { return i_nodes[idx]; }

protected:
    std::vector<PathNode> i_nodes;
};

struct KeyFrame
{
    explicit KeyFrame(PathNode node) : Index(0), Node(node), InitialOrientation(0.0f),
        DistSinceStop(-1.0f), DistUntilStop(-1.0f), DistFromPrev(-1.0f), TimeFrom(0.0f), TimeTo(0.0f),
        Teleport(false), ArriveTime(0), DepartureTime(0), Spline(nullptr), NextDistFromPrev(0.0f), NextArriveTime(0)
    {
    }

    uint32_t Index;
    PathNode Node;
    float InitialOrientation;
    float DistSinceStop;
    float DistUntilStop;
    float DistFromPrev;
    float TimeFrom;
    float TimeTo;
    bool Teleport;
    uint32_t ArriveTime;
    uint32_t DepartureTime;
    std::shared_ptr<TransportSpline> Spline;

    // Data needed for next frame
    float NextDistFromPrev;
    uint32_t NextArriveTime;

    bool isTeleportFrame() const { return Teleport; }
    bool isStopFrame() const { return Node.flags == 2; }
};

struct TransportTemplate
{
    TransportTemplate() : inInstance(false), pathTime(0), accelTime(0.0f), accelDist(0.0f), entry(0) { }
    ~TransportTemplate() = default;

    uint32_t lowguid;
    std::set<uint32_t> mapsUsed;
    bool inInstance;
    uint32_t pathTime;
    KeyFrameVec keyFrames;
    float accelTime;
    float accelDist;

    uint32_t entry;
};

struct SERVER_DECL TransportAnimation
{
    TransportAnimation() : TotalTime(0) { }
<commit_msg>Resolve "V730 Not all members of a class are initialized inside the constructor. Consider inspecting: lowguid. world TransporterHandler.h 107"<commit_after>/*
Copyright (c) 2014-2021 AscEmu Team <http://www.ascemu.org>
This file is released under the MIT license. See README-MIT for more information.
*/

#pragma once

struct KeyFrame;
struct TransportTemplate;
struct GameObjectProperties;
class Transporter;

namespace MovementNew
{
    template <typename length_type> class Spline;
}

typedef MovementNew::Spline<double>                         TransportSpline;
typedef std::vector<KeyFrame>                               KeyFrameVec;
typedef std::unordered_map<uint32_t, TransportTemplate>     TransportTemplates;
typedef std::set<Transporter*>                              TransporterSet;
typedef std::unordered_map<uint32_t, Transporter*>          TransporterMap;
typedef std::unordered_map<uint32_t, TransporterSet>        TransporterInstancedMap;
typedef std::unordered_map<uint32_t, std::set<uint32_t>>    TransportInstanceMap;

typedef std::vector<DBC::Structures::TaxiPathNodeEntry const*> TaxiPathNodeList;
typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;

typedef std::map<uint32_t, DBC::Structures::TransportAnimationEntry const*> TransportPathContainer;
#if VERSION_STRING >= WotLK
typedef std::map<uint32_t, DBC::Structures::TransportRotationEntry const*> TransportPathRotationContainer;
#endif

struct PathNode
{
    uint32_t mapid;
    float x, y, z;
    uint32_t flags;
    uint32_t delay;
    uint32_t ArrivalEventID;
    uint32_t DepartureEventID;
};

class TransportPath
{
public:
    inline void setLength(const unsigned int sz)
    {
        i_nodes.resize(sz);
    }

    inline size_t size(void) const { return i_nodes.size(); }
    inline void resize(unsigned int sz) { i_nodes.resize(sz); }
    inline void clear(void) { i_nodes.clear(); }
    inline PathNode* getNodes(void) { return static_cast<PathNode*>(&i_nodes[0]); }
    float getTotalLength(void)
    {
        float len = 0, xd, yd, zd;
        for (unsigned int idx = 1; idx < i_nodes.size(); ++idx)
        {
            xd = i_nodes[idx].x - i_nodes[idx - 1].x;
            yd = i_nodes[idx].y - i_nodes[idx - 1].y;
            zd = i_nodes[idx].z - i_nodes[idx - 1].z;
            len += (float)std::sqrt(xd * xd + yd * yd + zd * zd);
        }
        return len;
    }

    PathNode & operator[](const unsigned int idx) { return i_nodes[idx]; }
    const PathNode & operator()(const unsigned int idx) const { return i_nodes[idx]; }

protected:
    std::vector<PathNode> i_nodes;
};

struct KeyFrame
{
    explicit KeyFrame(PathNode node) : Index(0), Node(node), InitialOrientation(0.0f),
        DistSinceStop(-1.0f), DistUntilStop(-1.0f), DistFromPrev(-1.0f), TimeFrom(0.0f), TimeTo(0.0f),
        Teleport(false), ArriveTime(0), DepartureTime(0), Spline(nullptr), NextDistFromPrev(0.0f), NextArriveTime(0)
    {
    }

    uint32_t Index;
    PathNode Node;
    float InitialOrientation;
    float DistSinceStop;
    float DistUntilStop;
    float DistFromPrev;
    float TimeFrom;
    float TimeTo;
    bool Teleport;
    uint32_t ArriveTime;
    uint32_t DepartureTime;
    std::shared_ptr<TransportSpline> Spline;

    // Data needed for next frame
    float NextDistFromPrev;
    uint32_t NextArriveTime;

    bool isTeleportFrame() const { return Teleport; }
    bool isStopFrame() const { return Node.flags == 2; }
};

struct TransportTemplate
{
    TransportTemplate() : lowguid(0), inInstance(false), pathTime(0), accelTime(0.0f), accelDist(0.0f), entry(0) { }
    ~TransportTemplate() = default;

    uint32_t lowguid;
    std::set<uint32_t> mapsUsed;
    bool inInstance;
    uint32_t pathTime;
    KeyFrameVec keyFrames;
    float accelTime;
    float accelDist;

    uint32_t entry;
};

struct SERVER_DECL TransportAnimation
{
    TransportAnimation() : TotalTime(0) { }

{'fraction_non_alphanumeric': 0.10884086444007858, 'fraction_numerical': 0.021872953503601834, 'mean_word_length': 3.537136066547831, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6528631', 'n_tokens_mistral': 2593, 'n_tokens_neox': 2442, 'n_words': 579}