Advertisement
Guest User

Untitled

a guest
Feb 24th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1.     CommandArea GetCommandArea(const CommandPacket *cp) {
  2.         byte cmd = (cp->cmd & CMD_ID_MASK);
  3.         switch (cmd) {
  4.             case CMD_BUILD_RAIL_STATION: {
  5.                 Axis axis      = Extract<Axis, 4, 1>(cp->p1);
  6.                 byte numtracks = GB(cp->p1,  8, 8);
  7.                 byte plat_len  = GB(cp->p1, 16, 8);
  8.                 if (axis == AXIS_X)
  9.                     return CommandArea(cp->tile, plat_len, numtracks);
  10.                 return CommandArea(cp->tile, numtracks, plat_len);
  11.             }
  12.  
  13.             case CMD_BUILD_AIRPORT: {
  14.                 const AirportSpec *as = AirportSpec::Get(cp->p1);
  15.                 if (!as->IsAvailable()) return CommandArea(cp->tile);
  16.                 return CommandArea(cp->tile, as->size_x, as->size_y);
  17.             }
  18.  
  19.             case CMD_PLANT_TREE:
  20.                 return CommandArea(cp->tile, cp->p2);
  21.  
  22.             case CMD_BUILD_RAILROAD_TRACK:
  23.             case CMD_REMOVE_RAILROAD_TRACK:
  24.             case CMD_BUILD_LONG_ROAD:
  25.             case CMD_REMOVE_LONG_ROAD:
  26.             case CMD_CLEAR_AREA:
  27.             case CMD_BUILD_CANAL:
  28.             case CMD_LEVEL_LAND:
  29.             case CMD_BUILD_BRIDGE:
  30.                 // TODO diagonal areas
  31.                 return CommandArea(cp->tile, cp->p1);
  32.  
  33.             default:
  34.                 return CommandArea(cp->tile);
  35.         }
  36.         NOT_REACHED();
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement