1
0
Fork 0

(svn r978) Fixed an endianess issue with the new Order system. Thanks to Bjarni, Oskar and Tron

release/0.4.5
Celestar 2004-12-08 15:26:57 +00:00
parent 547a2d1f9f
commit 6fd3fc10e3
2 changed files with 10 additions and 5 deletions

View File

@ -827,6 +827,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN)); DoCommandP(v->tile, v->index, 0, NULL, CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN));
break; break;
case 5: /* center main view */ case 5: /* center main view */
DEBUG(misc, 0) ("Train: %d, Velocity: %d, Current Order: %i:%d:%x:%x", v->index, v->cur_speed, v->cur_order_index, v->current_order.station, v->current_order.flags, v->current_order.type);
ScrollMainWindowTo(v->x_pos, v->y_pos); ScrollMainWindowTo(v->x_pos, v->y_pos);
break; break;
case 6: /* goto depot */ case 6: /* goto depot */

View File

@ -4,8 +4,13 @@
#include "vehicle_gui.h" #include "vehicle_gui.h"
typedef struct Order { typedef struct Order {
#ifdef TTD_LITTLE_ENDIAN /* XXX hack to avoid savegame revision bump */
uint8 type:4; uint8 type:4;
uint8 flags:4; uint8 flags:4;
#else
uint8 flags:4;
uint8 type:4;
#endif
uint8 station; uint8 station;
} Order; } Order;
@ -16,11 +21,10 @@ static inline uint16 PackOrder(const Order *order)
static inline Order UnpackOrder(uint16 packed) static inline Order UnpackOrder(uint16 packed)
{ {
Order order = { Order order;
(packed & 0x000f), order.type = (packed & 0x000f);
(packed & 0x00f0) >> 4, order.flags = (packed & 0x00f0) >> 4,
(packed & 0xff00) >> 8 order.station = (packed & 0xff00) >> 8;
};
return order; return order;
} }