Loading

Paste #pw40ohj1e

  1.  
  2. static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf, RoadType basetype)
  3. {
  4.     ChangeInfoResult ret = CIR_SUCCESS;
  5.  
  6.     extern RoadtypeInfo _roadtypes[ROADTYPE_END][ROADSUBTYPE_END];
  7.  
  8.     if (id + numinfo > ROADTYPE_END) {
  9.         grfmsg(1, "RoadTypeReserveInfo: Road type %u is invalid, max %u, ignoring", id + numinfo, ROADTYPE_END);
  10.         return CIR_INVALID_ID;
  11.     }
  12.  
  13.     for (int i = 0; i < numinfo; i++) {
  14.         switch (prop) {
  15.             case 0x08: // Label of rail type
  16.             {
  17.                 RoadTypeLabel rtl = buf->ReadDWord();
  18.                 rtl = BSWAP32(rtl);
  19.  
  20.                 RoadType rt = GetRoadTypeByLabel(rtl, basetype, false);
  21.                 if (rt == INVALID_ROADTYPE) {
  22.                     /* Set up new road type */
  23.                     rt = AllocateRoadType(rtl, basetype);
  24.                 }
  25.  
  26.                 _cur.grffile->roadtype_map[basetype][id + i] = rt;
  27.                 break;
  28.             }
  29.             case 0x09: // Toolbar caption of roadtype
  30.             case 0x0A: // Menu text
  31.             case 0x0B: // Build window caption
  32.             case 0x0C: // Autoreplace text
  33.             case 0x0D: // New loco
  34.             case 0x13: // Construction cost
  35.             case 0x14: // Speed limit
  36.             case 0x1B: // Name of roadtype
  37.             case 0x1C: // Maintenance cost factor
  38.                 buf->ReadWord();
  39.                 break;
  40.  
  41.             case 0x1D: // Alternate road type label list
  42.                 if (_cur.grffile->roadtype_map[basetype][id + i] != INVALID_ROADTYPE) {
  43.                     int n = buf->ReadByte();
  44.                     for (int j = 0; j != n; j++) {
  45.                         *_roadtypes[basetype][_cur.grffile->roadtype_map[basetype][id + i]].alternate_labels.Append() = BSWAP32(buf->ReadDWord());
  46.                     }
  47.                     break;
  48.                 }
  49.                 grfmsg(1, "RoadTypeReserveInfo: Ignoring property 1D for road type %u because no label was set", id + i);
  50.                 /* FALL THROUGH */
  51.  
  52.             case 0x0E: // Compatible roadtype list
  53.             case 0x0F: // Powered roadtype list
  54.             case 0x18: // Roadtype list required for date introduction
  55.             case 0x19: // Introduced roadtype list
  56.                 for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord();
  57.                 break;
  58.  
  59.             case 0x10: // Road Type flags
  60.             case 0x11: // Curve speed advantage
  61.             case 0x12: // Station graphic
  62.             case 0x15: // Acceleration model
  63.             case 0x16: // Map colour
  64.             case 0x1A: // Sort order
  65.                 buf->ReadByte();
  66.                 break;
  67.  
  68.             case 0x17: // Introduction date
  69.                 buf->ReadDWord();
  70.                 break;
  71.  
  72.             default:
  73.                 ret = CIR_UNKNOWN;
  74.                 break;
  75.         }
  76.  
  77.         grfmsg(0, "RoadTypeReserveInfo: Road type property found 0x%02X, num info %u", prop, numinfo);
  78.     }
  79.  
  80.     return ret;
  81. }
  82.  
  83. static ChangeInfoResult RoadTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf)
  84. {
  85.     return RoadTypeReserveInfo(id, numinfo, prop, buf, ROADTYPE_ROAD);
  86. }
  87.  
  88. static ChangeInfoResult TramTypeReserveInfo(uint id, int numinfo, int prop, ByteReader *buf)
  89. {
  90.     return RoadTypeReserveInfo(id, numinfo, prop, buf, ROADTYPE_TRAM);
  91. }

Comments