Guest User

Untitled

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