LCOV - code coverage report
Current view: top level - core/map - PMSStructs.hpp (source / functions) Coverage Total Hit
Test: coverage-src.info Lines: 100.0 % 20 20
Test Date: 2025-05-27 23:26:07 Functions: 100.0 % 3 3

            Line data    Source code
       1              : #ifndef __PMS_STRUCTS_HPP__
       2              : #define __PMS_STRUCTS_HPP__
       3              : 
       4              : #include "PMSConstants.hpp"
       5              : #include "PMSEnums.hpp"
       6              : #include <vector>
       7              : #include <cmath>
       8              : #include <array>
       9              : #include <string>
      10              : 
      11              : namespace Soldank
      12              : {
      13              : struct DOSTime
      14              : {
      15              :     unsigned short second : 5, minute : 6, hour : 5;
      16              : };
      17              : 
      18              : struct DOSDate
      19              : {
      20              :     unsigned short day : 5, month : 4, year : 7;
      21              : };
      22              : 
      23              : struct PMSCollider
      24              : {
      25              :     int active;
      26              :     float x, y, radius;
      27              : };
      28              : 
      29              : struct PMSColor
      30              : {
      31              :     unsigned char blue;
      32              :     unsigned char green;
      33              :     unsigned char red;
      34              :     unsigned char alpha;
      35              : 
      36           19 :     PMSColor()
      37           19 :         : blue(255)
      38           19 :         , green(255)
      39           19 :         , red(255)
      40           19 :         , alpha(255)
      41              :     {
      42           19 :     }
      43              : 
      44            6 :     PMSColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
      45            6 :         : blue(b)
      46            6 :         , green(g)
      47            6 :         , red(r)
      48            6 :         , alpha(a)
      49              :     {
      50            6 :     }
      51              : };
      52              : 
      53              : struct PMSVector
      54              : {
      55              :     float x;
      56              :     float y;
      57              :     float z;
      58              : };
      59              : 
      60              : struct PMSVertex
      61              : {
      62              :     float x{};
      63              :     float y{};
      64              :     float z{};
      65              :     // Those are most likely texture-related
      66              :     float rhw{};
      67              :     PMSColor color;
      68              :     // S corresponds to X axis
      69              :     float texture_s{};
      70              :     // T corresponds to Y axis
      71              :     float texture_t{};
      72              : };
      73              : 
      74              : struct PMSPolygon
      75              : {
      76              :     unsigned int id{};
      77              :     std::array<PMSVertex, 3> vertices;
      78              :     std::array<PMSVector, 3> perpendiculars{};
      79              :     PMSPolygonType polygon_type{};
      80              :     float bounciness{};
      81              : 
      82              :     /**
      83              :      * \brief Checks if the vertices are arranged in clock-wise order.
      84              :      * http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
      85              :      */
      86            1 :     bool AreVerticesClockwise()
      87              :     {
      88            1 :         float sum = 0.0F;
      89              : 
      90            4 :         for (unsigned int i = 0; i < 3; ++i) {
      91            3 :             unsigned int j = i + 1;
      92            3 :             if (j > 2) {
      93            1 :                 j = 0;
      94              :             }
      95              : 
      96            3 :             sum += (vertices.at(j).x - vertices.at(i).x) * (vertices.at(j).y + vertices.at(i).y);
      97              :         }
      98              : 
      99            1 :         return sum < 0.0F;
     100              :     }
     101              : };
     102              : 
     103              : struct PMSScenery
     104              : {
     105              :     bool active{};
     106              :     unsigned short style{};
     107              :     int width{};
     108              :     int height{};
     109              :     float x{};
     110              :     float y{};
     111              :     float rotation{};
     112              :     float scale_x{};
     113              :     float scale_y{};
     114              :     int alpha{};
     115              :     PMSColor color;
     116              :     int level{};
     117              : };
     118              : 
     119              : struct PMSTimestamp
     120              : {
     121              :     DOSTime time;
     122              :     DOSDate date;
     123              : };
     124              : 
     125              : struct PMSSceneryType
     126              : {
     127              :     std::string name;
     128              :     PMSTimestamp timestamp;
     129              : };
     130              : 
     131              : struct PMSSector
     132              : {
     133              :     std::vector<unsigned short> polygons;
     134              :     std::array<float, 4> boundaries;
     135              : };
     136              : 
     137              : struct PMSSpawnPoint
     138              : {
     139              :     int active, x, y;
     140              :     PMSSpawnPointType type;
     141              : };
     142              : 
     143              : struct PMSWayPoint
     144              : {
     145              :     bool active;
     146              :     std::array<unsigned char, 3> filler1;
     147              :     int id;
     148              :     int x, y;
     149              :     bool left, right, up, down, jet;
     150              :     unsigned char path;
     151              :     PMSSpecialAction special_action;
     152              :     unsigned char c2, c3; //?
     153              :     std::array<unsigned char, 3> filler2;
     154              :     int connections_count;
     155              :     std::array<int, 20> connections;
     156              : };
     157              : } // namespace Soldank
     158              : 
     159              : #endif
        

Generated by: LCOV version 2.0-1