本文整理汇总了C++中Order::AssignOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ Order::AssignOrder方法的具体用法?C++ Order::AssignOrder怎么用?C++ Order::AssignOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order::AssignOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Order
/**
* Create an order backup for the given vehicle.
* @param v The vehicle to make a backup of.
* @param user The user that is requesting the backup.
*/
OrderBackup::OrderBackup(const Vehicle *v, uint32 user)
{
this->user = user;
this->tile = v->tile;
this->orderindex = v->cur_implicit_order_index;
this->group = v->group_id;
this->service_interval = v->service_interval;
if (v->name != NULL) this->name = strdup(v->name);
/* If we have shared orders, store the vehicle we share the order with. */
if (v->IsOrderListShared()) {
this->clone = (v->FirstShared() == v) ? v->NextShared() : v->FirstShared();
} else {
/* Else copy the orders */
Order **tail = &this->orders;
/* Count the number of orders */
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
Order *copy = new Order();
copy->AssignOrder(*order);
*tail = copy;
tail = ©->next;
}
}
示例2: Load_ORDR
static void Load_ORDR()
{
if (IsSavegameVersionBefore(5, 2)) {
/* Version older than 5.2 did not have a ->next pointer. Convert them
* (in the old days, the orderlist was 5000 items big) */
size_t len = SlGetFieldLength();
if (IsSavegameVersionBefore(5)) {
/* Pre-version 5 had another layout for orders
* (uint16 instead of uint32) */
len /= sizeof(uint16);
uint16 *orders = MallocT<uint16>(len + 1);
SlArray(orders, len, SLE_UINT16);
for (size_t i = 0; i < len; ++i) {
Order *o = new (i) Order();
o->AssignOrder(UnpackVersion4Order(orders[i]));
}
free(orders);
} else if (IsSavegameVersionBefore(5, 2)) {
len /= sizeof(uint32);
uint32 *orders = MallocT<uint32>(len + 1);
SlArray(orders, len, SLE_UINT32);
for (size_t i = 0; i < len; ++i) {
new (i) Order(orders[i]);
}
free(orders);
}
/* Update all the next pointer */
Order *o;
FOR_ALL_ORDERS(o) {
/* Delete invalid orders */
if (o->IsType(OT_NOTHING)) {
delete o;
continue;
}
/* The orders were built like this:
* While the order is valid, set the previous will get its next pointer set */
Order *prev = Order::GetIfValid(order_index - 1);
if (prev != NULL) prev->next = o;
}
} else {