Loading

Paste #pgau7ddof

  1. Index: src/rail.h
  2. ===================================================================
  3. --- src/rail.h  (revision 27686)
  4. +++ src/rail.h  (working copy)
  5. @@ -113,7 +113,8 @@
  6.  /**
  7.   * This struct contains all the info that is needed to draw and construct tracks.
  8.   */
  9. -struct RailtypeInfo {
  10. +class RailtypeInfo {
  11. +public:
  12.     /**
  13.      * Struct containing the main sprites. @note not all sprites are listed, but only
  14.      *  the ones used directly in the code
  15. Index: src/rail_cmd.cpp
  16. ===================================================================
  17. --- src/rail_cmd.cpp    (revision 27686)
  18. +++ src/rail_cmd.cpp    (working copy)
  19. @@ -47,8 +47,6 @@
  20.  RailType _sorted_railtypes[RAILTYPE_END];
  21.  uint8 _sorted_railtypes_size;
  22.  
  23. -assert_compile(sizeof(_original_railtypes) <= sizeof(_railtypes));
  24. -
  25.  /** Enum holding the signal offset in the sprite sheet according to the side it is representing. */
  26.  enum SignalOffsets {
  27.     SIGNAL_TO_SOUTHWEST,
  28. @@ -66,8 +64,11 @@
  29.   */
  30.  void ResetRailTypes()
  31.  {
  32. -   memset(_railtypes, 0, sizeof(_railtypes));
  33. -   memcpy(_railtypes, _original_railtypes, sizeof(_original_railtypes));
  34. +   assert_compile(lengthof(_original_railtypes) <= lengthof(_railtypes));
  35. +
  36. +   uint i = 0;
  37. +   for (; i < lengthof(_original_railtypes); i++) _railtypes[i] = _original_railtypes[i];
  38. +   for (; i < lengthof(_railtypes);          i++) _railtypes[i] = RailtypeInfo(); // zero-init
  39.  }
  40.  
  41.  void ResolveRailTypeGUISprites(RailtypeInfo *rti)
  42. @@ -151,11 +152,9 @@
  43.  
  44.         if (rti->label == 0) {
  45.             /* Set up new rail type */
  46. -           memcpy(rti, &_railtypes[RAILTYPE_RAIL], sizeof(*rti));
  47. +           *rti = _original_railtypes[RAILTYPE_RAIL];
  48.             rti->label = label;
  49. -           /* Clear alternate label list. Can't use Reset() here as that would free
  50. -            * the data pointer of RAILTYPE_RAIL and not our new rail type. */
  51. -           new (&rti->alternate_labels) RailTypeLabelList;
  52. +           rti->alternate_labels.Clear();
  53.  
  54.             /* Make us compatible with ourself. */
  55.             rti->powered_railtypes    = (RailTypes)(1 << rt);
  56.  

Comments