Esempio n. 1
0
extern int
proto_client_init(Proto_Client_Handle *ch)
{
    Proto_Msg_Types mt;
    Proto_Client *c;

    c = (Proto_Client *)malloc(sizeof(Proto_Client));
    if (c == NULL) return -1;
    bzero(c, sizeof(Proto_Client));

    proto_client_set_session_lost_handler(c,
                                          proto_client_session_lost_default_hdlr);

    // initialize local game state
    pthread_mutex_lock(&client_data_mutex);
    playerdata.id = -1;
    gamedata.game_state = -1;
    gamedata.game_version = 0;
    pthread_mutex_unlock(&client_data_mutex);

    for (mt = PROTO_MT_EVENT_BASE_RESERVED_FIRST + 1;
            mt < PROTO_MT_EVENT_BASE_RESERVED_LAST; mt++)
        proto_client_set_event_handler(c, mt, proto_client_event_null_handler);

    proto_client_set_event_handler(c, PROTO_MT_EVENT_BASE_UPDATE, proto_client_event_update_handler);

    *ch = c;
    return 1;
}
Esempio n. 2
0
extern int
proto_client_init(Proto_Client_Handle *ch)
{
  Proto_Msg_Types mt;
  Proto_Client *c;
 
  c = (Proto_Client *)malloc(sizeof(Proto_Client));
  if (c==NULL) return -1;
  bzero(c, sizeof(Proto_Client));

  proto_client_set_session_lost_handler(c, 
			      	proto_client_session_lost_default_hdlr);

  for (mt=PROTO_MT_EVENT_BASE_RESERVED_FIRST+1;
       mt<PROTO_MT_EVENT_BASE_RESERVED_LAST; mt++)
    proto_client_set_event_handler(c, mt, proto_client_event_null_handler);

  *ch = c;
  return 1;
}