/*
 * dim_c
 * dim_r
 * num_t1_players
 * num_t2_players
 * t1_flag
 * t2_flag
 * t1_jack
 * t2_jack
 * player_t 400
 */
extern int
wrap_update(maze_t * maze, Proto_Session * s) {
    if (proto_session_body_marshall_int(s, maze->dim_c) == -1) {
        fprintf(stderr, "ERROR: marhsall dim_c\n");
        return -1;
    }
    if (proto_session_body_marshall_int(s, maze->dim_r) == -1) {
        fprintf(stderr, "ERROR: marhsall dim_r\n");
        return -1;
    }
    if (proto_session_body_marshall_int(s, maze->num_t1_players) == -1) {
        fprintf(stderr, "ERROR: marhsall num_t1_players\n");
        return -1;
    }
    if (proto_session_body_marshall_int(s, maze->num_t2_players) == -1) {
        fprintf(stderr, "ERROR: marhsall num_t2_players\n");
        return -1;
    }

    if (wrap_item(maze->t1_flag, s) == -1) {
        fprintf(stderr, "ERROR: marhsall t1_flag\n");
        return -1;
    }
    if (wrap_item(maze->t2_flag, s) == -1) {
        fprintf(stderr, "ERROR: marhsall t2_flag\n");
        return -1;
    }
    if (wrap_item(maze->t1_jack, s) == -1) {
        fprintf(stderr, "ERROR: marhsall t1_jack\n");
        return -1;
    }
    if (wrap_item(maze->t2_jack, s) == -1) {
        fprintf(stderr, "ERROR: marhsall t2_jack\n");
        return -1;
    }

    int i;
    for (i = 0; i < (maze->num_t1_players + maze->num_t2_players); i++) {
        if (wrap_player((maze->players[i]), s) == -1) {
            fprintf(stderr, "ERROR: marhsall player_t\n");
            return -1;
        }
    }

    return 1;
}
예제 #2
0
static VALUE rbncurs_c_menu_items(VALUE rb_menu)
{
  MENU *menu = get_menu(rb_menu);
  ITEM **items = menu_items(menu);
  VALUE arr = Qundef;
  int i;

  if (items == NULL)
    rb_raise(rb_eRuntimeError, "Error retrieving menu items");
  arr = rb_ary_new();
  i=0;
  while (items[i] != NULL)
    rb_ary_push(arr, wrap_item(items[i++]));
  return arr;
}
예제 #3
0
/*
 * Item creation/destruction functions - mitem_new(3X) man page
 */
static VALUE rbncurs_m_new_item(VALUE dummy, VALUE name, VALUE description)
{ return wrap_item(new_item(STR2CSTR(name), STR2CSTR(description))); }
예제 #4
0
/*
 * Current menu item get/set functions - mitem_current(3X) man page
 */
static VALUE rbncurs_c_current_item(VALUE rb_menu)
{
  MENU *menu = get_menu(rb_menu);
  return wrap_item(current_item(menu));
}