• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NOT_REACHED函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NOT_REACHED函数的典型用法代码示例。如果您正苦于以下问题:C++ NOT_REACHED函数的具体用法?C++ NOT_REACHED怎么用?C++ NOT_REACHED使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NOT_REACHED函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CmdChangeTimetable

/**
 * Change timetable data of an order.
 * @param tile Not used.
 * @param flags Operation to perform.
 * @param p1 Various bitstuffed elements
 * - p1 = (bit  0-19) - Vehicle with the orders to change.
 * - p1 = (bit 20-27) - Order index to modify.
 * - p1 = (bit 28-29) - Timetable data to change (@see ModifyTimetableFlags)
 * @param p2 The amount of time to wait.
 * - p2 = (bit  0-15) - The data to modify as specified by p1 bits 28-29.
 *                      0 to clear times, UINT16_MAX to clear speed limit.
 * @param text unused
 * @return the cost of this operation or an error
 */
CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
    VehicleID veh = GB(p1, 0, 20);

    Vehicle *v = Vehicle::GetIfValid(veh);
    if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;

    CommandCost ret = CheckOwnership(v->owner);
    if (ret.Failed()) return ret;

    VehicleOrderID order_number = GB(p1, 20, 8);
    Order *order = v->GetOrder(order_number);
    if (order == NULL || order->IsType(OT_IMPLICIT)) return CMD_ERROR;

    ModifyTimetableFlags mtf = Extract<ModifyTimetableFlags, 28, 2>(p1);
    if (mtf >= MTF_END) return CMD_ERROR;

    int wait_time   = order->GetWaitTime();
    int travel_time = order->GetTravelTime();
    int max_speed   = order->GetMaxSpeed();
    switch (mtf) {
    case MTF_WAIT_TIME:
        wait_time = GB(p2, 0, 16);
        break;

    case MTF_TRAVEL_TIME:
        travel_time = GB(p2, 0, 16);
        break;

    case MTF_TRAVEL_SPEED:
        max_speed = GB(p2, 0, 16);
        if (max_speed == 0) max_speed = UINT16_MAX; // Disable speed limit.
        break;

    default:
        NOT_REACHED();
    }

    if (wait_time != order->GetWaitTime()) {
        switch (order->GetType()) {
        case OT_GOTO_STATION:
            if (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) return_cmd_error(STR_ERROR_TIMETABLE_NOT_STOPPING_HERE);
            break;

        case OT_CONDITIONAL:
            break;

        default:
            return_cmd_error(STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS);
        }
    }

    if (travel_time != order->GetTravelTime() && order->IsType(OT_CONDITIONAL)) return CMD_ERROR;
    if (max_speed != order->GetMaxSpeed() && (order->IsType(OT_CONDITIONAL) || v->type == VEH_AIRCRAFT)) return CMD_ERROR;

    if (flags & DC_EXEC) {
        switch (mtf) {
        case MTF_WAIT_TIME:
            /* Set time if changing the value or confirming an estimated time as timetabled. */
            if (wait_time != order->GetWaitTime() || (wait_time > 0 && !order->IsWaitTimetabled())) {
                ChangeTimetable(v, order_number, wait_time, MTF_WAIT_TIME, wait_time > 0);
            }
            break;

        case MTF_TRAVEL_TIME:
            /* Set time if changing the value or confirming an estimated time as timetabled. */
            if (travel_time != order->GetTravelTime() || (travel_time > 0 && !order->IsTravelTimetabled())) {
                ChangeTimetable(v, order_number, travel_time, MTF_TRAVEL_TIME, travel_time > 0);
            }
            break;

        case MTF_TRAVEL_SPEED:
            if (max_speed != order->GetMaxSpeed()) {
                ChangeTimetable(v, order_number, max_speed, MTF_TRAVEL_SPEED, max_speed != UINT16_MAX);
            }
            break;

        default:
            break;
        }
    }

    return CommandCost();
}
开发者ID:J0anJosep,项目名称:OpenTTD,代码行数:98,代码来源:timetable_cmd.cpp


示例2: GrayscaleToMapHeights

/**
 * Converts a given grayscale map to something that fits in OTTD map system
 * and create a map of that data.
 * @param img_width  the with of the image in pixels/tiles
 * @param img_height the height of the image in pixels/tiles
 * @param map        the input map
 */
static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map)
{
	/* Defines the detail of the aspect ratio (to avoid doubles) */
	const uint num_div = 16384;

	uint width, height;
	uint row, col;
	uint row_pad = 0, col_pad = 0;
	uint img_scale;
	uint img_row, img_col;
	TileIndex tile;

	/* Get map size and calculate scale and padding values */
	switch (_settings_game.game_creation.heightmap_rotation) {
		default: NOT_REACHED();
		case HM_COUNTER_CLOCKWISE:
			width   = MapSizeX();
			height  = MapSizeY();
			break;
		case HM_CLOCKWISE:
			width   = MapSizeY();
			height  = MapSizeX();
			break;
	}

	if ((img_width * num_div) / img_height > ((width * num_div) / height)) {
		/* Image is wider than map - center vertically */
		img_scale = (width * num_div) / img_width;
		row_pad = (1 + height - ((img_height * img_scale) / num_div)) / 2;
	} else {
		/* Image is taller than map - center horizontally */
		img_scale = (height * num_div) / img_height;
		col_pad = (1 + width - ((img_width * img_scale) / num_div)) / 2;
	}

	if (_settings_game.construction.freeform_edges) {
		for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, 0));
		for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(0, y));
	}

	/* Form the landscape */
	for (row = 0; row < height; row++) {
		for (col = 0; col < width; col++) {
			switch (_settings_game.game_creation.heightmap_rotation) {
				default: NOT_REACHED();
				case HM_COUNTER_CLOCKWISE: tile = TileXY(col, row); break;
				case HM_CLOCKWISE:         tile = TileXY(row, col); break;
			}

			/* Check if current tile is within the 1-pixel map edge or padding regions */
			if ((!_settings_game.construction.freeform_edges && DistanceFromEdge(tile) <= 1) ||
					(row < row_pad) || (row >= (height - row_pad - (_settings_game.construction.freeform_edges ? 0 : 1))) ||
					(col < col_pad) || (col >= (width  - col_pad - (_settings_game.construction.freeform_edges ? 0 : 1)))) {
				SetTileHeight(tile, 0);
			} else {
				/* Use nearest neighbour resizing to scale map data.
				 *  We rotate the map 45 degrees (counter)clockwise */
				img_row = (((row - row_pad) * num_div) / img_scale);
				switch (_settings_game.game_creation.heightmap_rotation) {
					default: NOT_REACHED();
					case HM_COUNTER_CLOCKWISE:
						img_col = (((width - 1 - col - col_pad) * num_div) / img_scale);
						break;
					case HM_CLOCKWISE:
						img_col = (((col - col_pad) * num_div) / img_scale);
						break;
				}

				assert(img_row < img_height);
				assert(img_col < img_width);

				/* Colour scales from 0 to 255, OpenTTD height scales from 0 to 15 */
				SetTileHeight(tile, map[img_row * img_width + img_col] / 16);
			}
			/* Only clear the tiles within the map area. */
			if (IsInnerTile(tile)) {
				MakeClear(tile, CLEAR_GRASS, 3);
			}
		}
	}
}
开发者ID:ComLock,项目名称:OpenTTD,代码行数:88,代码来源:heightmap.cpp


示例3: main

/* The first copy is invoked without command line arguments.
   Subsequent copies are invoked with a parameter 'depth'
   that describes how many parent processes preceded them.
   Each process spawns one or multiple recursive copies of
   itself, passing 'depth+1' as depth.

   Some children are started with the '-k' flag, which will
   result in abnormal termination.
 */
int
main (int argc, char *argv[])
{
  int n;

  n = argc > 1 ? atoi (argv[1]) : 0;
  bool is_at_root = (n == 0);
  if (is_at_root)
    msg ("begin");

  /* If -k is passed, crash this process. */
  if (argc > 2 && !strcmp(argv[2], "-k"))
    {
      consume_some_resources_and_die (n);
      NOT_REACHED ();
    }

  int howmany = is_at_root ? EXPECTED_REPETITIONS : 1;
  int i, expected_depth = -1;

  for (i = 0; i < howmany; i++)
    {
      pid_t child_pid;

      /* Spawn a child that will be abnormally terminated.
         To speed the test up, do this only for processes
         spawned at a certain depth. */
      if (n > EXPECTED_DEPTH_TO_PASS/2)
        {
          child_pid = spawn_child (n + 1, CRASH);
          if (child_pid != -1)
            {
              if (wait (child_pid) != -1)
                fail ("crashed child should return -1.");
            }
          /* If spawning this child failed, so should
             the next spawn_child below. */
        }

      /* Now spawn the child that will recurse. */
      child_pid = spawn_child (n + 1, RECURSE);

      /* If maximum depth is reached, return result. */
      if (child_pid == -1)
        return n;

      /* Else wait for child to report how deeply it was able to recurse. */
      int reached_depth = wait (child_pid);
      if (reached_depth == -1)
        fail ("wait returned -1.");

      /* Record the depth reached during the first run; on subsequent
         runs, fail if those runs do not match the depth achieved on the
         first run. */
      if (i == 0)
        expected_depth = reached_depth;
      else if (expected_depth != reached_depth)
        fail ("after run %d/%d, expected depth %d, actual depth %d.",
              i, howmany, expected_depth, reached_depth);
      ASSERT (expected_depth == reached_depth);
    }

  consume_some_resources ();

  if (n == 0)
    {
      if (expected_depth < EXPECTED_DEPTH_TO_PASS)
        fail ("should have forked at least %d times.", EXPECTED_DEPTH_TO_PASS);
      msg ("success. program forked %d times.", howmany);
      msg ("end");
    }

  return expected_depth;
}
开发者ID:robweller8,项目名称:CS439-Pintos-P2,代码行数:83,代码来源:multi-oom.c


示例4: memcache_parse_req


//.........这里部分代码省略.........
                        break;
                    }

                    break;
                }

                switch (r->type) {
                case MSG_REQ_MC_GET:
                case MSG_REQ_MC_GETS:
                case MSG_REQ_MC_DELETE:
                case MSG_REQ_MC_CAS:
                case MSG_REQ_MC_SET:
                case MSG_REQ_MC_ADD:
                case MSG_REQ_MC_REPLACE:
                case MSG_REQ_MC_APPEND:
                case MSG_REQ_MC_PREPEND:
                case MSG_REQ_MC_INCR:
                case MSG_REQ_MC_DECR:
                    if (ch == CR) {
                        goto error;
                    }
                    state = SW_SPACES_BEFORE_KEY;
                    break;

                case MSG_REQ_MC_QUIT:
                    p = p - 1; /* go back by 1 byte */
                    state = SW_CRLF;
                    break;

                case MSG_UNKNOWN:
                    goto error;

                default:
                    NOT_REACHED();
                }

            } else if (!islower(ch)) {
                goto error;
            }

            break;

        case SW_SPACES_BEFORE_KEY:
            if (ch != ' ') {
                r->token = p;
                r->key_start = p;
                state = SW_KEY;
            }

            break;

        case SW_KEY:
            if (ch == ' ' || ch == CR) {
                if ((p - r->key_start) > MEMCACHE_MAX_KEY_LENGTH) {
                    log_error("parsed bad req %"PRIu64" of type %d with key "
                              "prefix '%.*s...' and length %d that exceeds "
                              "maximum key length", r->id, r->type, 16,
                              r->key_start, p - r->key_start);
                    goto error;
                }
                r->key_end = p;
                r->token = NULL;

                /* get next state */
                if (memcache_storage(r)) {
                    state = SW_SPACES_BEFORE_FLAGS;
开发者ID:Almasty,项目名称:twemproxy,代码行数:67,代码来源:nc_memcache.c


示例5: call_make_storage_req

static void
call_make_storage_req(struct context *ctx, struct call *call, uint32_t key_id,
                      long int key_vlen)
{
    struct opt *opt = &ctx->opt;
    int len;
    uint32_t i;

    for (i = 0; i < REQ_IOV_LEN; i++) {
        struct iovec *iov = &call->req.iov[i];

        switch (i) {
        case REQ_IOV_METHOD:
            iov->iov_base = req_strings[opt->method].data;
            iov->iov_len = req_strings[opt->method].len;
            break;

        case REQ_IOV_KEY:
            len = mcp_scnprintf(call->req.keyname, sizeof(call->req.keyname),
                                "%.*s%08"PRIx32" ", opt->prefix.len,
                                opt->prefix.data, key_id);
            iov->iov_base = call->req.keyname;
            iov->iov_len = (size_t)len;
            break;

        case REQ_IOV_FLAG:
            iov->iov_base = msg_strings[MSG_ZERO].data;
            iov->iov_len  = msg_strings[MSG_ZERO].len;
            break;

        case REQ_IOV_EXPIRY:
            len = mcp_scnprintf(call->req.expiry, sizeof(call->req.expiry),
                                "%"PRIu32" ", opt->expiry);
            iov->iov_base = call->req.expiry;
            iov->iov_len = (size_t)len;
            break;

        case REQ_IOV_VLEN:
            len = mcp_scnprintf(call->req.keylen, sizeof(call->req.keylen),
                                "%ld ", key_vlen);
            iov->iov_base = call->req.keylen;
            iov->iov_len = (size_t)len;
            break;

        case REQ_IOV_CAS:
            if (opt->method == REQ_CAS) {
                iov->iov_base = "1 ";
                iov->iov_len = 2;
            } else {
                iov->iov_base = NULL;
                iov->iov_len = 0;
            }
            break;

        case REQ_IOV_NOREPLY:
            if (opt->use_noreply) {
                iov->iov_base = msg_strings[MSG_NOREPLY].data;
                iov->iov_len = msg_strings[MSG_NOREPLY].len;
                call->req.noreply = 1;
            } else {
                iov->iov_base = NULL;
                iov->iov_len = 0;
                call->req.noreply = 0;
            }
            break;

        case REQ_IOV_CRLF:
            iov->iov_base = msg_strings[MSG_CRLF].data;
            iov->iov_len = msg_strings[MSG_CRLF].len;
            break;

        case REQ_IOV_VALUE:
            ASSERT(key_vlen >= 0 && key_vlen <= sizeof(ctx->buf1m));
            iov->iov_base = ctx->buf1m;
            iov->iov_len = (size_t)key_vlen;
            break;

        case REQ_IOV_CRLF2:
            iov->iov_base = msg_strings[MSG_CRLF].data;
            iov->iov_len = msg_strings[MSG_CRLF].len;
            break;

        default:
            NOT_REACHED();
        }
        call->req.send += iov->iov_len;
    }
}
开发者ID:AsamQi,项目名称:twemperf,代码行数:88,代码来源:mcp_call.c


示例6: GetAvailableVideoMode


//.........这里部分代码省略.........
	/* Free any previously allocated shadow surface */
	if (_sdl_screen != NULL && _sdl_screen != _sdl_realscreen) SDL_CALL SDL_FreeSurface(_sdl_screen);

	if (_sdl_realscreen != NULL) {
		if (_requested_hwpalette != want_hwpalette) {
			/* SDL (at least the X11 driver), reuses the
			 * same window and palette settings when the bpp
			 * (and a few flags) are the same. Since we need
			 * to hwpalette value to change (in particular
			 * when switching between fullscreen and
			 * windowed), we restart the entire video
			 * subsystem to force creating a new window.
			 */
			DEBUG(driver, 0, "SDL: Restarting SDL video subsystem, to force hwpalette change");
			SDL_CALL SDL_QuitSubSystem(SDL_INIT_VIDEO);
			SDL_CALL SDL_InitSubSystem(SDL_INIT_VIDEO);
			ClaimMousePointer();
			SetupKeyboard();
		}
	}
	/* Remember if we wanted a hwpalette. We can't reliably query
	 * SDL for the SDL_HWPALETTE flag, since it might get set even
	 * though we didn't ask for it (when SDL creates a shadow
	 * surface, for example). */
	_requested_hwpalette = want_hwpalette;

	/* DO NOT CHANGE TO HWSURFACE, IT DOES NOT WORK */
	newscreen = SDL_CALL SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE | (want_hwpalette ? SDL_HWPALETTE : 0) | (_fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE));
	if (newscreen == NULL) {
		DEBUG(driver, 0, "SDL: Couldn't allocate a window to draw on");
		return false;
	}
	_sdl_realscreen = newscreen;

	if (bpp == 8 && (_sdl_realscreen->flags & SDL_HWPALETTE) != SDL_HWPALETTE) {
		/* Using an 8bpp blitter, if we didn't get a hardware
		 * palette (most likely because we didn't request one,
		 * see above), we'll have to set up a shadow surface to
		 * render on.
		 *
		 * Our palette will be applied to this shadow surface,
		 * while the real screen surface will use the shared
		 * system palette (which will partly contain our colors,
		 * but most likely will not have enough free color cells
		 * for all of our colors). SDL can use these two
		 * palettes at blit time to approximate colors used in
		 * the shadow surface using system colors automatically.
		 *
		 * Note that when using an 8bpp blitter on a 32bpp
		 * system, SDL will create an internal shadow surface.
		 * This shadow surface will have SDL_HWPALLETE set, so
		 * we won't create a second shadow surface in this case.
		 */
		DEBUG(driver, 1, "SDL: using shadow surface");
		newscreen = SDL_CALL SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, bpp, 0, 0, 0, 0);
		if (newscreen == NULL) {
			DEBUG(driver, 0, "SDL: Couldn't allocate a shadow surface to draw on");
			return false;
		}
	}

	/* Delay drawing for this cycle; the next cycle will redraw the whole screen */
	_num_dirty_rects = 0;

	_screen.width = newscreen->w;
	_screen.height = newscreen->h;
	_screen.pitch = newscreen->pitch / (bpp / 8);
	_screen.dst_ptr = newscreen->pixels;
	_sdl_screen = newscreen;

	/* When in full screen, we will always have the mouse cursor
	 * within the window, even though SDL does not give us the
	 * appropriate event to know this. */
	if (_fullscreen) _cursor.in_window = true;

	Blitter *blitter = BlitterFactory::GetCurrentBlitter();
	blitter->PostResize();

	InitPalette();
	switch (blitter->UsePaletteAnimation()) {
		case Blitter::PALETTE_ANIMATION_NONE:
		case Blitter::PALETTE_ANIMATION_VIDEO_BACKEND:
			UpdatePalette();
			break;

		case Blitter::PALETTE_ANIMATION_BLITTER:
			if (VideoDriver::GetInstance() != NULL) blitter->PaletteAnimate(_local_palette);
			break;

		default:
			NOT_REACHED();
	}

	seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
	SDL_CALL SDL_WM_SetCaption(caption, caption);

	GameSizeChanged();

	return true;
}
开发者ID:Junky2008,项目名称:OpenTTD,代码行数:101,代码来源:sdl_v.cpp


示例7: rsp_forward_stats

static void
rsp_forward_stats(struct context *ctx, struct msg *msg, struct conn *s_conn,
                  struct conn *c_conn)
{
    struct msg *pmsg;
    struct server *server;

    ASSERT(!s_conn->client && !s_conn->proxy);
    ASSERT(c_conn->client && !c_conn->proxy);
    ASSERT(!msg->request && msg->peer != NULL);

    server = s_conn->owner;
    pmsg = msg->peer;

    stats_server_incr(ctx, server, responses);
    stats_server_incr_by(ctx, server, response_bytes, msg->mlen);

    switch (msg->type) {
    case MSG_RSP_NUM:
        stats_server_incr(ctx, server, num);
        break;

    case MSG_RSP_STORED:
        stats_server_incr(ctx, server, stored);
        break;

    case MSG_RSP_NOT_STORED:
        stats_server_incr(ctx, server, not_stored);
        break;

    case MSG_RSP_EXISTS:
        stats_server_incr(ctx, server, exists);
        break;

    case MSG_RSP_NOT_FOUND:
        stats_server_incr(ctx, server, not_found);
        break;

    case MSG_RSP_END:
        stats_server_incr(ctx, server, end);
        break;

    case MSG_RSP_VALUE:
        stats_server_incr(ctx, server, value);
        break;

    case MSG_RSP_DELETED:
        stats_server_incr(ctx, server, deleted);
        break;

    case MSG_RSP_ERROR:
        log_debug(LOG_INFO, "rsp error type %d from s %d for req %"PRIu64" "
                  "type %d from c %d", msg->type, s_conn->sd, pmsg->id,
                  pmsg->type, c_conn->sd);
        stats_server_incr(ctx, server, error);
        break;

    case MSG_RSP_CLIENT_ERROR:
        log_debug(LOG_INFO, "rsp error type %d from s %d for req %"PRIu64" "
                  "type %d from c %d", msg->type, s_conn->sd, pmsg->id,
                  pmsg->type, c_conn->sd);
        stats_server_incr(ctx, server, client_error);
        break;

    case MSG_RSP_SERVER_ERROR:
        log_debug(LOG_INFO, "rsp error type %d from s %d for req %"PRIu64" "
                  "type %d from c %d", msg->type, s_conn->sd, pmsg->id,
                  pmsg->type, c_conn->sd);
        stats_server_incr(ctx, server, server_error);
        break;

    default:
        NOT_REACHED();
    }
}
开发者ID:adityashanbhag,项目名称:twemproxy,代码行数:75,代码来源:nc_response.c


示例8: parse_named_action

static void
parse_named_action(enum ofputil_action_code code, const struct flow *flow,
                   char *arg, struct ofpbuf *ofpacts)
{
    struct ofpact_tunnel *tunnel;
    uint16_t vid;
    ovs_be32 ip;
    uint8_t pcp;
    uint8_t tos;

    switch (code) {
    case OFPUTIL_ACTION_INVALID:
        NOT_REACHED();

    case OFPUTIL_OFPAT10_OUTPUT:
    case OFPUTIL_OFPAT11_OUTPUT:
        parse_output(arg, ofpacts);
        break;

    case OFPUTIL_OFPAT10_SET_VLAN_VID:
    case OFPUTIL_OFPAT11_SET_VLAN_VID:
        vid = str_to_u32(arg);
        if (vid & ~VLAN_VID_MASK) {
            ovs_fatal(0, "%s: not a valid VLAN VID", arg);
        }
        ofpact_put_SET_VLAN_VID(ofpacts)->vlan_vid = vid;
        break;

    case OFPUTIL_OFPAT10_SET_VLAN_PCP:
    case OFPUTIL_OFPAT11_SET_VLAN_PCP:
        pcp = str_to_u32(arg);
        if (pcp & ~7) {
            ovs_fatal(0, "%s: not a valid VLAN PCP", arg);
        }
        ofpact_put_SET_VLAN_PCP(ofpacts)->vlan_pcp = pcp;
        break;

    case OFPUTIL_OFPAT12_SET_FIELD:
        set_field_parse(arg, ofpacts);
        break;

    case OFPUTIL_OFPAT10_STRIP_VLAN:
    case OFPUTIL_OFPAT11_POP_VLAN:
        ofpact_put_STRIP_VLAN(ofpacts);
        break;

    case OFPUTIL_OFPAT10_SET_DL_SRC:
    case OFPUTIL_OFPAT11_SET_DL_SRC:
        str_to_mac(arg, ofpact_put_SET_ETH_SRC(ofpacts)->mac);
        break;

    case OFPUTIL_OFPAT10_SET_DL_DST:
    case OFPUTIL_OFPAT11_SET_DL_DST:
        str_to_mac(arg, ofpact_put_SET_ETH_DST(ofpacts)->mac);
        break;

    case OFPUTIL_OFPAT10_SET_NW_SRC:
    case OFPUTIL_OFPAT11_SET_NW_SRC:
        str_to_ip(arg, &ip);
        ofpact_put_SET_IPV4_SRC(ofpacts)->ipv4 = ip;
        break;

    case OFPUTIL_OFPAT10_SET_NW_DST:
    case OFPUTIL_OFPAT11_SET_NW_DST:
        str_to_ip(arg, &ip);
        ofpact_put_SET_IPV4_DST(ofpacts)->ipv4 = ip;
        break;

    case OFPUTIL_OFPAT10_SET_NW_TOS:
    case OFPUTIL_OFPAT11_SET_NW_TOS:
        tos = str_to_u32(arg);
        if (tos & ~IP_DSCP_MASK) {
            ovs_fatal(0, "%s: not a valid TOS", arg);
        }
        ofpact_put_SET_IPV4_DSCP(ofpacts)->dscp = tos;
        break;

    case OFPUTIL_OFPAT11_DEC_NW_TTL:
        NOT_REACHED();

    case OFPUTIL_OFPAT10_SET_TP_SRC:
    case OFPUTIL_OFPAT11_SET_TP_SRC:
        ofpact_put_SET_L4_SRC_PORT(ofpacts)->port = str_to_u32(arg);
        break;

    case OFPUTIL_OFPAT10_SET_TP_DST:
    case OFPUTIL_OFPAT11_SET_TP_DST:
        ofpact_put_SET_L4_DST_PORT(ofpacts)->port = str_to_u32(arg);
        break;

    case OFPUTIL_OFPAT10_ENQUEUE:
        parse_enqueue(arg, ofpacts);
        break;

    case OFPUTIL_NXAST_RESUBMIT:
        parse_resubmit(arg, ofpacts);
        break;

    case OFPUTIL_NXAST_SET_TUNNEL:
    case OFPUTIL_NXAST_SET_TUNNEL64:
//.........这里部分代码省略.........
开发者ID:vthakkar,项目名称:ovs-vxlan,代码行数:101,代码来源:ofp-parse.c


示例9: parse_ofp_str

/* Convert 'str_' (as described in the Flow Syntax section of the ovs-ofctl man
 * page) into 'fm' for sending the specified flow_mod 'command' to a switch.
 * If 'actions' is specified, an action must be in 'string' and may be expanded
 * or reallocated.
 *
 * To parse syntax for an OFPT_FLOW_MOD (or NXT_FLOW_MOD), use an OFPFC_*
 * constant for 'command'.  To parse syntax for an OFPST_FLOW or
 * OFPST_AGGREGATE (or NXST_FLOW or NXST_AGGREGATE), use -1 for 'command'. */
void
parse_ofp_str(struct ofputil_flow_mod *fm, int command, const char *str_,
              bool verbose)
{
    enum {
        F_OUT_PORT = 1 << 0,
        F_ACTIONS = 1 << 1,
        F_TIMEOUT = 1 << 3,
        F_PRIORITY = 1 << 4,
        F_FLAGS = 1 << 5,
    } fields;
    char *string = xstrdup(str_);
    char *save_ptr = NULL;
    char *act_str = NULL;
    char *name;

    switch (command) {
    case -1:
        fields = F_OUT_PORT;
        break;

    case OFPFC_ADD:
        fields = F_ACTIONS | F_TIMEOUT | F_PRIORITY | F_FLAGS;
        break;

    case OFPFC_DELETE:
        fields = F_OUT_PORT;
        break;

    case OFPFC_DELETE_STRICT:
        fields = F_OUT_PORT | F_PRIORITY;
        break;

    case OFPFC_MODIFY:
        fields = F_ACTIONS | F_TIMEOUT | F_PRIORITY | F_FLAGS;
        break;

    case OFPFC_MODIFY_STRICT:
        fields = F_ACTIONS | F_TIMEOUT | F_PRIORITY | F_FLAGS;
        break;

    default:
        NOT_REACHED();
    }

    match_init_catchall(&fm->match);
    fm->priority = OFP_DEFAULT_PRIORITY;
    fm->cookie = htonll(0);
    fm->cookie_mask = htonll(0);
    if (command == OFPFC_MODIFY || command == OFPFC_MODIFY_STRICT) {
        /* For modify, by default, don't update the cookie. */
        fm->new_cookie = htonll(UINT64_MAX);
    } else{
        fm->new_cookie = htonll(0);
    }
    fm->table_id = 0xff;
    fm->command = command;
    fm->idle_timeout = OFP_FLOW_PERMANENT;
    fm->hard_timeout = OFP_FLOW_PERMANENT;
    fm->buffer_id = UINT32_MAX;
    fm->out_port = OFPP_NONE;
    fm->flags = 0;
    if (fields & F_ACTIONS) {
        act_str = strstr(string, "action");
        if (!act_str) {
            ofp_fatal(str_, verbose, "must specify an action");
        }
        *act_str = '\0';

        act_str = strchr(act_str + 1, '=');
        if (!act_str) {
            ofp_fatal(str_, verbose, "must specify an action");
        }

        act_str++;
    }
    for (name = strtok_r(string, "=, \t\r\n", &save_ptr); name;
         name = strtok_r(NULL, "=, \t\r\n", &save_ptr)) {
        const struct protocol *p;

        if (parse_protocol(name, &p)) {
            match_set_dl_type(&fm->match, htons(p->dl_type));
            if (p->nw_proto) {
                match_set_nw_proto(&fm->match, p->nw_proto);
            }
        } else if (fields & F_FLAGS && !strcmp(name, "send_flow_rem")) {
            fm->flags |= OFPFF_SEND_FLOW_REM;
        } else if (fields & F_FLAGS && !strcmp(name, "check_overlap")) {
            fm->flags |= OFPFF_CHECK_OVERLAP;
        } else {
            char *value;

//.........这里部分代码省略.........
开发者ID:vthakkar,项目名称:ovs-vxlan,代码行数:101,代码来源:ofp-parse.c


示例10: syscall_handler

static void
syscall_handler (struct intr_frame *f)
{
/*  printf ("system call!\n");//TODO remove
  thread_exit ();*/
  uint32_t ret_val;

  offset = f->esp;
  int sys_call = (int) next_arg();

  char *tmp; //TODO remove
  


  switch (sys_call) {
  case SYS_HALT:
    power_off();
    NOT_REACHED ();

  case SYS_EXIT:
    syscall_exit((int) next_arg());
    NOT_REACHED ();

  case SYS_EXEC:
    ret_val = exec();
    break;

  case SYS_WAIT:
    ret_val = process_wait((tid_t) next_arg());
    break;

  case SYS_CREATE:
//    printf("test\n");
//    printf("file_name: %s, size: %d\n", next_str(), next_arg());
    tmp = next_str();
    ret_val = filesys_create(tmp, next_arg());
    break;

  case SYS_REMOVE:
    ret_val = filesys_remove(next_str());
    break;

  case SYS_OPEN:
    next_str();
    break;

  case SYS_FILESIZE:
    next_arg();
    break;

  case SYS_READ:
    /* next_arg(); next_arg(); next_arg(); */
	 ret_val = syscall_read();
    break;

  case SYS_WRITE:
    //FIXME this is just a temporary function to print to console unil real call is implemented
    /*if ((int) next_arg() == STDOUT_FILENO) {
      printf("%s", (char *) next_arg());
    }*/
	 ret_val = syscall_write();
    break;

  case SYS_SEEK:

    break;

  case SYS_TELL:

    break;

  case SYS_CLOSE:

    break;

  default:
    //TODO print error message
    break;
  }
  f->eax = ret_val;
}
开发者ID:coweatyou,项目名称:school,代码行数:81,代码来源:syscall.c


示例11: assert

/**
 * Stages cargo for unloading. The cargo is sorted so that packets to be
 * transferred, delivered or kept are in consecutive chunks in the list. At the
 * same time the designation_counts are updated to reflect the size of those
 * chunks.
 * @param accepted If the cargo will be accepted at the station.
 * @param current_station ID of the station.
 * @param next_station ID of the station the vehicle will go to next.
 * @param order_flags OrderUnloadFlags that will apply to the unload operation.
 * @param ge GoodsEntry for getting the flows.
 * @param payment Payment object for registering transfers.
 * return If any cargo will be unloaded.
 */
bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationID next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment)
{
	this->AssertCountConsistency();
	assert(this->action_counts[MTA_LOAD] == 0);
	this->action_counts[MTA_TRANSFER] = this->action_counts[MTA_DELIVER] = this->action_counts[MTA_KEEP] = 0;
	Iterator deliver = this->packets.end();
	Iterator it = this->packets.begin();
	uint sum = 0;

	bool force_keep = (order_flags & OUFB_NO_UNLOAD) != 0;
	bool force_unload = (order_flags & OUFB_UNLOAD) != 0;
	bool force_transfer = (order_flags & (OUFB_TRANSFER | OUFB_UNLOAD)) != 0;
	assert(this->count > 0 || it == this->packets.end());
	while (sum < this->count) {
		CargoPacket *cp = *it;

		this->packets.erase(it++);
		StationID cargo_next = INVALID_STATION;
		MoveToAction action = MTA_LOAD;
		if (force_keep) {
			action = MTA_KEEP;
		} else if (force_unload && accepted && cp->source != current_station) {
			action = MTA_DELIVER;
		} else if (force_transfer) {
			action = MTA_TRANSFER;
			cargo_next = ge->GetVia(cp->source, current_station, next_station);
			assert((cargo_next != next_station || cargo_next == INVALID_STATION) &&
					cargo_next != current_station);
		} else {
			/* Rewrite an invalid source station to some random other one to
			 * avoid keeping the cargo in the vehicle forever. */
			if (cp->source == INVALID_STATION && !ge->flows.empty()) {
				cp->source = ge->flows.begin()->first;
			}
			cargo_next = ge->GetVia(cp->source);
			if (cargo_next == INVALID_STATION) {
				action = (accepted && cp->source != current_station) ? MTA_DELIVER : MTA_KEEP;
			} else if (cargo_next == current_station) {
				action = MTA_DELIVER;
			} else if (cargo_next == next_station) {
				action = MTA_KEEP;
			} else {
				action = MTA_TRANSFER;
			}
		}
		Money share;
		switch (action) {
			case MTA_KEEP:
				this->packets.push_back(cp);
				if (deliver == this->packets.end()) --deliver;
				break;
			case MTA_DELIVER:
				this->packets.insert(deliver, cp);
				break;
			case MTA_TRANSFER:
				this->packets.push_front(cp);
				/* Add feeder share here to allow reusing field for next station. */
				share = payment->PayTransfer(cp, cp->count);
				cp->AddFeederShare(share);
				this->feeder_share += share;
				cp->next_station = cargo_next;
				break;
			default:
				NOT_REACHED();
		}
		this->action_counts[action] += cp->count;
		sum += cp->count;
	}
	this->AssertCountConsistency();
	return this->action_counts[MTA_DELIVER] > 0 || this->action_counts[MTA_TRANSFER] > 0;
}
开发者ID:Ayutac,项目名称:OpenTTD,代码行数:84,代码来源:cargopacket.cpp


示例12: GetViewport

/**
 * Build a path from #_path_builder xpos/ypos to the mouse cursor position.
 * @param mousexy Mouse position.
 */
void PathBuildManager::ComputeNewLongPath(const Point32 &mousexy)
{
	static const TrackSlope slope_prios_down[] = {TSL_DOWN, TSL_FLAT, TSL_UP,   TSL_INVALID}; // Order of preference when going down.
	static const TrackSlope slope_prios_flat[] = {TSL_FLAT, TSL_UP,   TSL_DOWN, TSL_INVALID}; // Order of preference when at the right height.
	static const TrackSlope slope_prios_up[]   = {TSL_UP,   TSL_FLAT, TSL_DOWN, TSL_INVALID}; // Order of preference when going up.

	Viewport *vp = GetViewport();
	if (vp == nullptr) return;

	int c1, c2, c3;
	switch (vp->orientation) {
		case VOR_NORTH: c1 =  1; c2 =  2; c3 =  2; break;
		case VOR_EAST:  c1 = -1; c2 = -2; c3 =  2; break;
		case VOR_SOUTH: c1 =  1; c2 = -2; c3 = -2; break;
		case VOR_WEST:  c1 = -1; c2 =  2; c3 = -2; break;
		default: NOT_REACHED();
	}

	XYZPoint16 path_pos(0, 0, 0);
	path_pos.y = this->pos.y * 256 + 128;
	int32 lambda_y = path_pos.y - mousexy.y; // Distance to constant Y plane at current tile cursor.
	path_pos.x = this->pos.x * 256 + 128;
	int32 lambda_x = path_pos.x - mousexy.x; // Distance to constant X plane at current tile cursor.

	if (abs(lambda_x) < abs(lambda_y)) {
		/* X constant. */
		path_pos.x /= 256;
		path_pos.y = Clamp<int32>(mousexy.y + c1 * lambda_x, 0, _world.GetYSize() * 256 - 1) / 256;
		path_pos.z = Clamp<int32>(vp->view_pos.z + c3 * lambda_x, 0, WORLD_Z_SIZE * 256 - 1) / 256;
	} else {
		/* Y constant. */
		path_pos.x = Clamp<int32>(mousexy.x + c1 * lambda_y, 0, _world.GetXSize() * 256 - 1) / 256;
		path_pos.y /= 256;
		path_pos.z = Clamp<int32>(vp->view_pos.z + c2 * lambda_y, 0, WORLD_Z_SIZE * 256 - 1) / 256;
	}

	if (this->long_pos != path_pos) {
		this->long_pos = path_pos;

		_additions.Clear();
		path_pos = this->pos;
		/* Find the right direction from the selected tile to the current cursor location. */
		TileEdge direction;
		Point16 dxy;
		for (direction = EDGE_BEGIN; direction < EDGE_COUNT; direction++) {
			dxy = _tile_dxy[direction];
			if (!GoodDirection(dxy.x, path_pos.x, this->long_pos.x) || !GoodDirection(dxy.y, path_pos.y, this->long_pos.y)) continue;
			break;
		}
		if (direction == EDGE_COUNT) return;

		/* 'Walk' to the cursor as long as possible. */
		while (path_pos.x != this->long_pos.x || path_pos.y != this->long_pos.y) {
			uint8 slopes = CanBuildPathFromEdge(path_pos, direction);
			const TrackSlope *slope_prio;
			/* Get order of slope preference. */
			if (path_pos.z > this->long_pos.z) {
				slope_prio = slope_prios_down;
			} else if (path_pos.z == this->long_pos.z) {
				slope_prio = slope_prios_flat;
			} else {
				slope_prio = slope_prios_up;
			}
			/* Find best slope, and take it. */
			while (*slope_prio != TSL_INVALID && (slopes & (1 << *slope_prio)) == 0) slope_prio++;
			if (*slope_prio == TSL_INVALID) break;

			path_pos.x += dxy.x;
			path_pos.y += dxy.y;

			const Voxel *v = _world.GetVoxel(path_pos);
			if (v != nullptr && HasValidPath(v)) {
				if (!ChangePath(path_pos, this->path_type, false)) break;

				if (*slope_prio == TSL_UP) path_pos.z++;
			} else {
				if (*slope_prio == TSL_UP) {
					if (!BuildUpwardPath(path_pos, static_cast<TileEdge>((direction + 2) & 3), this->path_type, false)) break;
					path_pos.z++;
				} else if (*slope_prio == TSL_DOWN) {
					v = _world.GetVoxel(path_pos + XYZPoint16(0, 0, -1));

					if (v != nullptr && HasValidPath(v)) {
						if (!ChangePath(path_pos + XYZPoint16(0, 0, -1), this->path_type, false)) break;
					} else {
						if (!BuildDownwardPath(path_pos, static_cast<TileEdge>((direction + 2) & 3), this->path_type, false)) break;
					}
					path_pos.z--;
				} else {
					if (!BuildFlatPath(path_pos, this->path_type, false)) break;
				}
			}
		}
		vp->EnableWorldAdditions();
		vp->EnsureAdditionsAreVisible();
	}
//.........这里部分代码省略.........
开发者ID:Qwertie-,项目名称:FreeRCT,代码行数:101,代码来源:path_build.cpp


示例13: dmsg_parse

static struct ring_msg *
dmsg_parse(struct dmsg *dmsg)
{
	//rstatus_t status;
	uint8_t *p, *q, *start, *end, *pipe_p;
	uint8_t *host_id, *host_addr, *ts, *node_state;
	uint32_t k, delimlen, host_id_len, host_addr_len, ts_len, node_state_len;
	char delim[] = ",,,";
	delimlen = 3;


	/* parse "host_id1,generation_ts1,host_state1,host_broadcast_address1|host_id2,generation_ts2,host_state2,host_broadcast_address2" */
	/* host_id = dc-rack-token */
	//p = dmsg->data + dmsg->mlen - 1;
	//p = dmsg->owner->pos + dmsg->owner->mlen - 1;
	p = dmsg->payload + dmsg->plen - 1;
	end = p;

	//start = dmsg->data;
	//start = dmsg->owner->pos;
	start = dmsg->payload;

	log_debug(LOG_VERB, "parsing msg '%.*s'", dmsg->plen, start);
	host_id = NULL;
	host_addr = NULL;
	ts = NULL;
	node_state = NULL;

	host_id_len = 0;
	host_addr_len = 0;
	ts_len = 0;
	node_state_len = 0;
	pipe_p = start;
	int count = 0;

	do {
		q = dn_strrchr(p, start, '|');
		count++;
		p = q - 1;
	} while (q != NULL);

	struct ring_msg *ring_msg = create_ring_msg_with_size(count, true);
	if (ring_msg == NULL) {
		log_debug(LOG_ERR, "Error: unable to create a new ring msg!");
		//we just drop this msg
		return NULL;
	}

	struct server_pool *sp = (struct server_pool *) dmsg->owner->owner->owner;
	ring_msg->sp = sp;
	ring_msg->cb = gossip_msg_peer_update;

	count = 0;
	//p = dmsg->data + dmsg->mlen - 1;
    p = dmsg->payload + dmsg->plen - 1;

	do {

		for (k = 0; k < sizeof(delim)-1; k++) {
			q = dn_strrchr(p, start, delim[k]);

			switch (k) {
			case 0:
				host_addr = q + 1;
				host_addr_len = (uint32_t)(p - host_addr + 1);
				break;
			case 1:
				node_state = q + 1;
				node_state_len = (uint32_t)(p - node_state + 1);

				break;
			case 2:
				ts = q + 1;
				ts_len = (uint32_t)(p - ts + 1);

				break;

			default:
				NOT_REACHED();
			}
			p = q - 1;

		}

		if (k != delimlen) {
			loga("Error: this is insanely bad");
			return NULL;// DN_ERROR;
		}

		pipe_p = dn_strrchr(p, start, '|');

		if (pipe_p == NULL) {
			pipe_p = start;
		} else {
			pipe_p = pipe_p + 1;
			p = pipe_p - 2;
		}

		//host_id = dmsg->data;
		//host_id_len = dmsg->mlen - (host_addr_len + node_state_len + ts_len + 3);
//.........这里部分代码省略.........
开发者ID:bpoweski,项目名称:dynomite,代码行数:101,代码来源:dyn_dnode_msg.c


示例14: dyn_parse_core


//.........这里部分代码省略.........
			p -= 1;
			if (dmsg->mlen > 0)  {
				dmsg->data = p;
				p += dmsg->mlen - 1;
				state = DYN_SPACES_BEFORE_PAYLOAD_LEN;
			} else {
				goto error;
			}

			break;

		case DYN_SPACES_BEFORE_PAYLOAD_LEN: //this only need in dynomite's custome msg
			log_debug(LOG_DEBUG, "DYN_SPACES_BEFORE_PAYLOAD_LEN");
			if (ch == ' ') {
				break;
			} else if (ch == '*') {
				state = DYN_PAYLOAD_LEN;
				num = 0;
			} else {
				goto error;
			}

			break;

		case DYN_PAYLOAD_LEN:
			if (isdigit(ch))  {
				num = num*10 + (ch - '0');
			} else {
				if (ch == CR)  {
					log_debug(LOG_DEBUG, "Payload len: %d", num);
					dmsg->plen = num;
					state = DYN_CRLF_BEFORE_DONE;
					num = 0;
				} else {
					goto error;
				}
			}
			break;

		case DYN_CRLF_BEFORE_DONE:
			//log_debug(LOG_DEBUG, "DYN_CRLF_BEFORE_DONE");
			if (*p == LF) {
				state = DYN_DONE;
			} else {
				goto error;
			}

			break;

		case DYN_DONE:
			//log_debug(LOG_DEBUG, "DYN_DONE");
			r->pos = p;
			dmsg->payload = p;
			r->dyn_state = DYN_DONE;
			b->pos = p;
			goto done;
			break;

		default:
			NOT_REACHED();
			break;

		}

	}

	done:

	dmsg->owner = r;
	dmsg->source_address = r->owner->addr;
    //r->mlen = mbuf_length(b);
	//log_debug(LOG_DEBUG, "at done with p at %d", p);
	dmsg_dump(r->dmsg);
	log_hexdump(LOG_VERB, b->pos, mbuf_length(b), "dyn: parsed req %"PRIu64" res %d "
			"type %d state %d rpos %d of %d", r->id, r->result, r->type,
			r->dyn_state, r->pos - b->pos, b->last - b->pos);


	return true;

	skip:
	//log_debug(LOG_DEBUG, "This is not a dyn message");
	dmsg->type = DMSG_UNKNOWN;
	dmsg->owner = r;
	dmsg->source_address = r->owner->addr;
	return true;

	error:
	log_debug(LOG_ERR, "at error");
	r->result = MSG_PARSE_ERROR;
	r->state = state;
	errno = EINVAL;

	log_hexdump(LOG_INFO, b->pos, mbuf_length(b), "parsed bad req %"PRIu64" "
			"res %d type %d state %d", r->id, r->result, r->type,
			r->state);
	return false;

	return true;    //fix me
}
开发者ID:bpoweski,项目名称:dynomite,代码行数:101,代码来源:dyn_dnode_msg.c


示例15: DrawTrainDetails

/**
 * Draw the details for the given vehicle at the given position
 *
 * @param v     current vehicle
 * @param left  The left most coordinate to draw
 * @param right The right most coordinate to draw
 * @param y     The y coordinate
 * @param vscroll_pos Position of scrollbar
 * @param vscroll_cap Number of lines currently displayed
 * @param det_tab Selected details tab
 */
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
{
	/* draw the first 3 details tabs */
	if (det_tab != TDW_TAB_TOTALS) {
		bool rtl = _dynlang.text_dir == TD_RTL;
		Direction dir = rtl ? DIR_E : DIR_W;
		int x = rtl ? right : left;
		int sprite_y_offset = 4 + (FONT_HEIGHT_NORMAL - 10) / 2;
		int line_height = WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM;
		for (; v != NULL && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
			GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);

			/* Draw sprites */
			int dx = 0;
			int px = x;
			const Train *u = v;
			do {
				Point offset;
				int width = u->GetDisplayImageWidth(&offset);
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
					SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
					DrawSprite(u->GetImage(dir), pal, px + (rtl ? -offset.x : offset.x), y - line_height * vscroll_pos + sprite_y_offset + offset.y);
				}
				px += rtl ? -width : width;
				dx += width;
				u = u->Next();
			} while (u != NULL && u->IsArticulatedPart());

			bool separate_sprite_row = (dx > TRAIN_DETAILS_MAX_INDENT);
			if (separate_sprite_row) {
				vscroll_pos--;
				dx = 0;
			}

			uint num_lines = max(1u, _cargo_summary.Length());
			for (uint i = 0; i < num_lines; i++) {
				int sprite_width = max<int>(dx, TRAIN_DETAILS_MIN_INDENT) + 3;
				int data_left  = left + (rtl ? 0 : sprite_width);
				int data_right = right - (rtl ? sprite_width : 0);
				if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
					int py = y - line_height * vscroll_pos;
					if (i > 0 || separate_sprite_row) {
						if (vscroll_pos != 0) GfxFillRect(left, py - WD_MATRIX_TOP - 1, right, py - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][5]);
					}
					switch (det_tab) {
						case TDW_TAB_CARGO:
							if (i < _cargo_summary.Length()) {
								TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py);
							} else {
								DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
							}
							break;

						case TDW_TAB_INFO:
							if (i == 0) TrainDetailsInfoTab(v, data_left, data_right, py);
							break;

						case TDW_TAB_CAPACITY:
							if (i < _cargo_summary.Length()) {
								TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py);
							} else {
								DrawString(data_left, data_right, py, STR_VEHICLE_INFO_NO_CAPACITY);
							}
							break;

						default: NOT_REACHED();
					}
				}
				vscroll_pos--;
			}
		}
	} else {
		CargoArray act_cargo;
		CargoArray max_cargo;
		Money feeder_share = 0;

		for (const Vehicle *u = v; u != NULL; u = u->Next()) {
			act_cargo[u->cargo_type] += u->cargo.Count() 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NOT_USED函数代码示例发布时间:2022-05-30
下一篇:
C++ NOT_IMPL函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap