コード例 #1
0
ファイル: friendship_box.c プロジェクト: Zhanyin/taomee
int mw_query_items_from_friendship_box_callback(sprite_t *p, uint32_t id, const char *body, int bodylen)
{
    int i = 0,j;
    uint32_t count;
    uint32_t itemid;
    uint32_t item_count;

    int pkgsize = sizeof(protocol_t);

    CHECK_BODY_LEN_GE(bodylen, 4);
    UNPKG_H_UINT32(body, count, i);
    PKG_UINT32(msg, count, pkgsize);

    CHECK_BODY_LEN(bodylen,4 + 6 * 8);
    for(j = 0; j < count; j++) {
        UNPKG_H_UINT32(body, itemid, i);
        UNPKG_H_UINT32(body, item_count, i);

        PKG_UINT32(msg, itemid, pkgsize);
        PKG_UINT32(msg, item_count, pkgsize);
    }

    init_proto_head(msg, p->waitcmd, pkgsize);
    return send_to_self(p, msg, pkgsize, 1);

}
コード例 #2
0
ファイル: friendship_box.c プロジェクト: Zhanyin/taomee
int mw_get_item_history_from_friendship_box_callback(sprite_t *p, uint32_t id, const char *body, int bodylen)
{
    typedef struct	user_item {
        uint32_t userid;
        uint32_t itemid;
        char	 name[16];
        uint32_t color;
        uint32_t is_vip;
        uint32_t stamp;
    } __attribute__((packed)) user_item_t;

    int i = 0,j;
    uint32_t count;
    int pkgsize = sizeof(protocol_t);

    CHECK_BODY_LEN_GE(bodylen, 4);
    UNPKG_H_UINT32(body, count, i);
    PKG_UINT32(msg, count, pkgsize);
    CHECK_BODY_LEN(bodylen,4 + 20 * 36);
    user_item_t* p_info = (user_item_t*)(body + 4);
    for(j = 0; j < count; j++) {
        PKG_UINT32(msg, p_info->userid, pkgsize);
        PKG_UINT32(msg, p_info->itemid, pkgsize);
        PKG_STR(msg, p_info->name, pkgsize, 16);
        PKG_UINT32(msg, p_info->color, pkgsize);
        PKG_UINT32(msg, p_info->is_vip, pkgsize);
        PKG_UINT32(msg, p_info->stamp, pkgsize);
        p_info++;
    }

    init_proto_head(msg, p->waitcmd, pkgsize);
    return send_to_self(p, msg, pkgsize, 1);
}
コード例 #3
0
ファイル: mole_homeland.c プロジェクト: Zhanyin/taomee
int homeland_root_out_callback(sprite_t* p, uint32_t id, char* buf, int len)
{
	uint32_t itms[] = {0, 1230004, 1230007, 1230009, 1230020,1230012};
	uint32_t nbr = *(uint32_t*)p->session;
	uint32_t root_type = *(uint32_t*)(p->session + 4);
	int i = sizeof(protocol_t);
	PKG_UINT32(msg, nbr, i);  // number
	init_proto_head(msg, PROTO_PLANT_DISAPPEAR, i);
	send_to_map(p, msg, i, 0);

	if (root_type == 1 && (rand() % 2) < 1) {
		int indx = rand() % (sizeof(itms)/sizeof(itms[0]));
		int count = 1;
		if (indx == 0) {
			db_change_xiaome(0, 100, 0, 0, p->id);
			p->yxb += 100;
			count = 100;
		} else {
			db_single_item_op(0, p->id, itms[indx], 1, 1);
		}
		int j = sizeof(protocol_t);
		PKG_UINT32(msg, nbr, j);
		PKG_UINT32(msg, 1, j);
		PKG_UINT32(msg, itms[indx], j);
		PKG_UINT32(msg, count, j);
		init_proto_head(msg, p->waitcmd, j);
		send_to_self(p, msg, j, 1);
	} else {
		response_proto_uint32_uint32(p, p->waitcmd, nbr, 0, 0);
	}
	if (root_type == 1)
		add_cultivate_exp(p, 2);

	return 0;
}
コード例 #4
0
ファイル: match.cpp プロジェクト: Zhanyin/taomee
int Cmatch::notify_user_info( )
{

    int l = sizeof (protocol_t);
    uint32_t gameid = 0;
    uint32_t groupid = 0;

    ant::pack(pkg, gameid, l);
    ant::pack(pkg, groupid, l);

    uint32_t count = tug_players.size();
    if (count >= 2)
    {
        return 0;
    }

    ant::pack(pkg, count, l);
    for (uint32_t i = 0; i < count; i++ )
    {
        ant::pack(pkg, tug_players[i]->id(), l);
    }

    init_proto_head(pkg, NEW_TUG_USER_INFO, l);

    for (uint32_t i = 0; i < count; i++ )
    {
        sprite_t* p = tug_players[i]->get_sprite();
        send_to_self(p, pkg, l, 1 );
    }

    return 0;
}
コード例 #5
0
ファイル: mole_homeland.c プロジェクト: Zhanyin/taomee
static inline int
rsp_plant_attr(sprite_t* p, plant_attr_t* plant, uint32_t uid)
{
	int i = sizeof(protocol_t);
	PKG_UINT32(msg, plant->number, i);
	PKG_UINT32(msg, plant->itemid, i);
	PKG_UINT16(msg, plant->x, i);
	PKG_UINT16(msg, plant->y, i);
	PKG_UINT32(msg, plant->value, i);
	PKG_UINT32(msg, plant->sickflag, i);
	PKG_UINT32(msg, plant->fruit_num, i);
	PKG_UINT32(msg, plant->fruit_status, i);
	PKG_UINT32(msg, plant->mature_time, i);
	PKG_UINT32(msg, plant->diff_mature_time, i);
	PKG_UINT32(msg, plant->cur_grow_rate, i);
	PKG_UINT32(msg, plant->earth, i);
	PKG_UINT32(msg, plant->pollinate_num, i);
	uint32_t thiefable = (plant->mature_time && get_now_tv()->tv_sec > plant->mature_time + 7*24*60*60 && p->id != uid) ? 1 : 0;
	if (plant->itemid == 1230032 && plant->mature_time)
		thiefable = 1;
	/*如果是孢子花,不能偷取*/
	if (plant->itemid == 1230055 || plant->itemid == 1230056) {
		thiefable = 0;
	}

	PKG_UINT32(msg, thiefable, i);

	init_proto_head (msg, p->waitcmd, i);
	return send_to_self (p, msg, i, 1);
}
コード例 #6
0
ファイル: mole_homeland.c プロジェクト: Zhanyin/taomee
int get_homeland_box_item_callback(sprite_t* p, uint32_t id, char* buf, int len)
{
	CHECK_BODY_LEN_GE(len, 4);

	uint32_t count;
	int k = 0;
	UNPKG_H_UINT32 (buf, count, k);
	CHECK_BODY_LEN(len, 4 + count * 8);

	int i, j = sizeof (protocol_t);
	PKG_UINT32 (msg, count, j);
	for (i = 0; i < count; i++) {
		uint32_t itm, cnt;
		UNPKG_H_UINT32 (buf, itm, k);
		UNPKG_H_UINT32 (buf, cnt, k);
		PKG_UINT32 (msg, itm, j);
		PKG_UINT32 (msg, cnt, j);
		//DEBUG_LOG ("GET HOMELAND BOX ITEM\t[%u %u]", p->id, itm);
	}

	init_proto_head (msg, p->waitcmd, j);

	DEBUG_LOG ("GET HOMELAND BOX ITEM\t[%u %d]", p->id, count);
	return send_to_self (p, msg, j, 1);

}
コード例 #7
0
ファイル: chris_cake.c プロジェクト: Zhanyin/taomee
int get_30_day_login_bonus_info_cmd(sprite_t * p,const uint8_t * body,int len)
{
    CHECK_BODY_LEN(len, 0);
    uint32_t cur_time = get_now_tv()->tv_sec;
    DEBUG_LOG("-000--last online time:%d  cur_time:%d ollast:%d", p->old_last_time, cur_time, p->ollast);
    if (p->old_last_time && (cur_time > p->old_last_time))
    {     
        if ((cur_time - p->old_last_time) > 30*24*60*60)
        {
            uint32_t itemid = 1353209;
            uint32_t count = 2;
            db_exchange_single_item_op(p, 202, itemid, count, 0);

            uint32_t itemid1 = 1353405;
            uint32_t count1 = 2;
            uint32_t itemid2 = 1353418;
            uint32_t count2 = 2;
            uint32_t dbbuf[] = {2, itemid1, 3, count1, itemid2, 1, count2};
            send_request_to_db(SVR_PROTO_ADD_ANGEL, NULL, sizeof(dbbuf), dbbuf, p->id);
            
            int j = sizeof(protocol_t);
            uint32_t flag = 1;
            PKG_UINT32(msg, flag, j);  
            PKG_UINT32(msg, 3, j);
            PKG_UINT32(msg, itemid, j);
            PKG_UINT32(msg, count, j);
            PKG_UINT32(msg, itemid1, j);
            PKG_UINT32(msg, count1, j);
            PKG_UINT32(msg, itemid2, j);
            PKG_UINT32(msg, count2, j);
            
    	    init_proto_head(msg, p->waitcmd, j);
    	    send_to_self(p, msg, j, 1);
    	    p->old_last_time = cur_time;
    	    msglog(statistic_logfile, 0x02103017,get_now_tv()->tv_sec, &(p->id), sizeof(p->id));
    	    return 0;
        }
    }

    int l = sizeof(protocol_t);
    PKG_UINT32(msg, 0, l);  
    PKG_UINT32(msg, 0, l);
    init_proto_head(msg, p->waitcmd, l);
    send_to_self(p, msg, l, 1);
    return 0;
    
}
コード例 #8
0
ファイル: homeinfo.c プロジェクト: Zhanyin/taomee
/*
 *@ add or del several neighbors from db,handle db 's reply
 */
int add_neighbors_callback(sprite_t* p, uint32_t id, char* buf, int len)
{
	CHECK_BODY_LEN_GE(len, 0);

	int i = sizeof(protocol_t);
	init_proto_head(msg, p->waitcmd, i);
	return send_to_self(p, msg, i, 1);
}
コード例 #9
0
ファイル: home.cpp プロジェクト: Zhanyin/taomee
int get_home_info_callback(sprite_t *p, userid_t id, uint8_t *buf, uint32_t len, uint32_t ret)
{
    CHECK_DBERR(p, ret);
    int i = sizeof(protocol_t);
    i += pkg_home_info(msg + i, (home_t *)buf);
    init_proto_head(msg, p->waitcmd, i);
    return send_to_self(p, msg, i, 1);
}
コード例 #10
0
ファイル: mole_candy.c プロジェクト: Zhanyin/taomee
int get_position_info_cmd(sprite_t* p, const uint8_t *body, int bodylen)
{
	int pos;
	int i = sizeof(protocol_t);
	for (pos = 0; pos < 4; pos ++) {
		PKG_UINT32(msg, pos_array[pos], i);
	}
	init_proto_head(msg, p->waitcmd, i);
	return send_to_self(p, msg, i, 1);
}
コード例 #11
0
ファイル: mole_sports.c プロジェクト: Zhanyin/taomee
int sports_get_task_callback(sprite_t* p, uint32_t id, char* buf, int len)
{
    CHECK_BODY_LEN(len ,4);
    uint32_t task_info = *(uint32_t*)buf;
    uint32_t result = check_task_can_get(task_info, p->tmpinfo.task_id);
    int l = sizeof(protocol_t);
    PKG_UINT32(msg, p->tmpinfo.task_id, l);
    PKG_UINT32(msg, result, l);
    init_proto_head(msg, p->waitcmd, l);
    return send_to_self(p, msg, l, 1);
}
コード例 #12
0
ファイル: match.cpp プロジェクト: Zhanyin/taomee
/**
 * @brief  告诉玩家服务器端已经获得了玩家卡牌库信息,可以开始请求卡牌队列了
 * @param  sprite_t* p 玩家指针
 * @return -1 发送失败
 * @return  0 发送成功
 */
int Cmatch::notify_server_ready(sprite_t *p)
{
	int l = sizeof (protocol_t);
	init_proto_head(pkg, NEW_CARD_SERVER_READY, l);
	if (send_to_self (p, pkg, l, 1 ) == 0) {
	} else {
		ERROR_LOG("notify server ready error");
		return 0;
	}
	return 0;
}
コード例 #13
0
ファイル: tasks.c プロジェクト: Zhanyin/taomee
int get_task_tmp_info_callback(sprite_t* p, uint32_t id, char* buf, int len)
{
	CHECK_BODY_LEN(len, 40);

	int i = sizeof(protocol_t);
	memcpy(msg + sizeof(protocol_t), buf, 40);
	i += 40;

	init_proto_head(msg, p->waitcmd, i);
	return send_to_self(p, msg, i, 1);
}
コード例 #14
0
ファイル: c_link.cpp プロジェクト: Zhanyin/taomee
int c_link::do_linking_game(sprite_t* p, const uint8_t body[], int len )
{
	DEBUG_LOG( "notify client doing linking Game " );
	typedef struct{
		uint32_t x;
		uint32_t y;
	} m_point_t;

	CHECK_BODY_LEN(len, sizeof(m_point_t)*2);
		
	m_point_t point_client[2];
	int offset = 0;
	for(uint32_t k = 0; k < 2; ++k){
		ant::unpack(body, point_client[k].x, offset);
		ant::unpack(body, point_client[k].y, offset);
	}
	int ret = 0;
	uint32_t cur_player_pos = 0;
	for(uint32_t k = 0; k < 2; ++k){
		if(m_players[k] == p){
			cur_player_pos = k;
			point_t start(point_client[0].x, point_client[0].y);
			point_t end(point_client[1].x, point_client[1].y);
			ret = m_player_link[k]->find_path(start, end);
			break;
		}
	}


	if(ret != -1 ){
		score[cur_player_pos] += 100;
		if(ret != 2){
			notify_client_broadcast();
		}
	}
	int is_over_ret = ret;
	int l = sizeof(protocol_t);
	uint8_t n_msg[256] = {0};
	if(ret == -1){
		ret = 0; // for client need
	}
	else{
		ret = 1;
	}
	ant::pack( n_msg, ret, l );
	init_proto_head( n_msg, proto_linking_game_operate, l );
	send_to_self( p, n_msg, l, 1);

	if(is_over_ret == 2){
		return notify_game_over(p, false);
	}
	return 0;
}
コード例 #15
0
ファイル: moon_cake.c プロジェクト: Zhanyin/taomee
/*
 * @brief 获得自己的月饼数量 callback
 */
int get_swap_mooncake_callback2(sprite_t* p, get_mooncake_cbk_pack_t* cbk_pack)
{
	if (cbk_pack->sytle_id == 0 || cbk_pack->sytle_id > 3) {	//判断是否吃过月饼
		return send_to_self_error(p, p->waitcmd, -ERR_swap_mooncake_not_enough, 1);
	}
	uint32_t uid = *(uint32_t*)p->session;
	uint32_t swap_cnt = *(uint32_t*)(p->session + 4);
	uint32_t swap_item = *(uint32_t*)(p->session + 8);
//	DEBUG_LOG("swap mooncake cbk2: mid[%u], uid[%u], itmid[%u], itmcnt[%u]", p->id, uid, cbk_pack->item_id, cbk_pack->count);

	if (swap_cnt > cbk_pack->count || swap_item == cbk_pack->item_id) {	//判断自己要兑换的月饼数量是否足够
		return send_to_self_error(p, p->waitcmd, -ERR_swap_mooncake_not_enough, 1);
	}

	db_swap_mooncake(p->id, cbk_pack->item_id, swap_item, swap_cnt);
	db_swap_mooncake(uid, swap_item, cbk_pack->item_id, swap_cnt);

	uint32_t msgbuf[2] = {p->id, 1};
	msglog(statistic_logfile, 0x0409B480, get_now_tv()->tv_sec, msgbuf, sizeof(msgbuf));
	msgbuf[0] = uid;
	msglog(statistic_logfile, 0x0409B480, get_now_tv()->tv_sec, msgbuf, sizeof(msgbuf));

	int l = sizeof(protocol_t);
	PKG_UINT32(msg, 1, l);
	PKG_UINT32(msg, swap_item, l);
	PKG_UINT32(msg, swap_cnt, l);
	init_proto_head(msg, p->waitcmd, l);
	send_to_self(p, msg, l, 1);

	sprite_t* s = get_sprite(uid);
	if (uid == p->id || s == NULL) {
		//return send_to_self_error(p, p->waitcmd, -ERR_swap_mooncake_state_err, 1);
		return 0;
	}
	l = sizeof(protocol_t);
	PKG_UINT32(msg, 1, l);
	PKG_UINT32(msg, cbk_pack->item_id, l);
	PKG_UINT32(msg, swap_cnt, l);
	return send_to_self(s, msg, l, 0);
}
コード例 #16
0
ファイル: mysvrlist.cpp プロジェクト: Zhanyin/taomee
int send_recommeded_svr_list(usr_info_t* p, svr_info_t* svrs, uint32_t online_cnt, int max_online_id)
{
    int idx = sizeof(cli_login_pk_header_t);
    taomee::pack(my_cli_buf, max_online_id, idx);
    taomee::pack(my_cli_buf, *(uint32_t*)p->tmpinfo, idx);
    taomee::pack(my_cli_buf, online_cnt, idx);
    TRACE_LOG("max_online=%u online_cnt=%u",max_online_id,online_cnt);
    for (uint32_t i = 0; i != online_cnt; ++i) {
        taomee::pack(my_cli_buf, svrs[i].id, idx);
        taomee::pack(my_cli_buf, svrs[i].users, idx);
        taomee::pack(my_cli_buf, svrs[i].ip, 16, idx);
        taomee::pack(my_cli_buf, svrs[i].port, idx);
        taomee::pack(my_cli_buf, svrs[i].friends, idx);
    	TRACE_LOG("online=[%u %u %16s %u %u]",svrs[i].id,svrs[i].users,svrs[i].ip,svrs[i].port,svrs[i].friends);
    }

    // pkg the frd id and timestamp
    uint32_t friendcount = *(uint32_t*)(p->tmpinfo + 4);
    uint32_t blackcount = *(uint32_t*)(p->tmpinfo + 8);
    //uint32_t* frd_timestamp = (uint32_t*)(p->tmpinfo + 8 + sizeof(userid_t) * MAX_FRIEND_NUM);
    uint32_t* friend_id = (uint32_t*)(p->tmpinfo + 12);
    uint32_t* black_id = (uint32_t*)(p->tmpinfo + 12 + sizeof(userid_t) * friendcount);

    taomee::pack(my_cli_buf, friendcount, idx);
    TRACE_LOG("friend_cnt=%u",friendcount);
    for (uint32_t i = 0; i < friendcount; i++ ) {
        taomee::pack(my_cli_buf, friend_id[i], idx);
    	TRACE_LOG("friend_id=%u",friend_id[i]);
        //taomee::pack(my_cli_buf, frd_timestamp[i], idx);
    }
    taomee::pack(my_cli_buf, blackcount, idx);
    TRACE_LOG("black_cnt=%u",blackcount);
    for (uint32_t i = 0; i < blackcount; i++ ) {
        taomee::pack(my_cli_buf, black_id[i], idx);
    	TRACE_LOG("black_id=%u",black_id[i]);
        //taomee::pack(my_cli_buf, black_timestamp[i], idx);
    }

    init_proto_head(my_cli_buf, idx, PROTO_GET_RECOMMEND_SVR_LIST, p->uid, SUCCESS);

#ifndef TW_VER  
    statistic_info_t info;
    uint32_t msglog_type;
    info.user_id = p->uid;
    msglog_type = MOLE_LOGIN_OFFSET + p->channel;
	if (p->channel > 56) 
		msglog_type = MOLE_NOT_NORMAL_LOG_CHANNEL;
    statistic_msglog(msglog_type, (void *)&info, sizeof info);
#endif

	return send_to_self(p, my_cli_buf, idx);
}
コード例 #17
0
ファイル: mole_sports.c プロジェクト: Zhanyin/taomee
int sports_get_task_cmd(sprite_t *p, const uint8_t *body, int bodylen)
{
    CHECK_BODY_LEN(bodylen, 0);
    if(!p->tmpinfo.task_id) {
        int l = sizeof(protocol_t);
        PKG_UINT32(msg, 0, l);
        PKG_UINT32(msg, 0, l);
        init_proto_head(msg, p->waitcmd, l);
        return send_to_self(p, msg, l, 1);

    }
    return send_request_to_db(SVR_PROTO_SPORT_GET_TASK, p, 0, NULL, p->id);
}
コード例 #18
0
ファイル: homeinfo.c プロジェクト: Zhanyin/taomee
/*
 *@ get all vip's home information
 */
int get_vip_home_list_cmd(sprite_t *p, const uint8_t *body, int bodylen)
{
	CHECK_BODY_LEN(bodylen, 0);
	int i, count = 0;

	traverse_sprites(pkg_vip_home_list, &count);
	i = sizeof(protocol_t);
	PKG_UINT32(msg, count, i);

	i = count * 24 + 4 + sizeof(protocol_t);
	init_proto_head(msg, p->waitcmd, i);
	return send_to_self(p, msg, i, 1);
}
コード例 #19
0
ファイル: profession_work.c プロジェクト: Zhanyin/taomee
/* @brief give client info about what is add
 */
int do_profession_work_callback(sprite_t *p)
{
	uint32_t type = *(uint32_t *)p->session;
	uint32_t mul = *(uint32_t *)(p->session + 4);

	int i, j = sizeof(protocol_t);
	PKG_UINT32(msg, work_config[type].out_cnt, j);
	for (i = 0; i != work_config[type].out_cnt; ++i) {
			PKG_UINT32(msg, work_config[type].out_item[i].itm->id, j);
			PKG_UINT32(msg, work_config[type].out_item[i].count * mul, j);
	}
	init_proto_head(msg, p->waitcmd, j);
	return send_to_self(p, msg, j, 1);
}
コード例 #20
0
// Mark a frame as ready-to-send. Must have come from get_tx_frame() using this
// same interface. Yes, we will see packets we generate on the RX ring.
int send_tx_frame(interface *i,void *frame){
	const omphalos_ctx *octx = get_octx();
	struct tpacket_hdr *thdr = frame;
	int ret = 0;

	assert(thdr->tp_status == TP_STATUS_PREPARING);
	if(octx->mode != OMPHALOS_MODE_SILENT){
		int self,out;

		categorize_tx(i,(const char *)frame + thdr->tp_mac,&self,&out);
		if(self){
			int r;

			r = send_to_self(i,frame);
			if(r < 0){
				++i->txerrors;
			}else{
				i->txbytes += r;
				++i->txframes;
			}
			ret |= r < 0 ? -1 : 0;
		}
		if(out){
			uint32_t tplen = thdr->tp_len;
			int r;

			//thdr->tp_status = TP_STATUS_SEND_REQUEST;
			//r = send(i->fd,NULL,0,0);
			r = send(i->fd,(const char *)frame + thdr->tp_mac,tplen,0);
			if(r == 0){
				r = tplen;
			}
			//diagnostic("Transmitted %d on %s",ret,i->name);
			if(r < 0){
				diagnostic("Error out-TXing %u on %s (%s)",tplen,i->name,strerror(errno));
				++i->txerrors;
			}else{
				i->txbytes += r;
				++i->txframes;
			}
			ret |= r < 0 ? -1 : 0;
		}
		thdr->tp_status = TP_STATUS_AVAILABLE;
	}else{
		abort_tx_frame(i,frame);
		ret = 0;
	}
	return ret;
}
コード例 #21
0
ファイル: homeinfo.c プロジェクト: Zhanyin/taomee
/*
 *@ get home hot from db, handle db 's reply
 */
int get_home_hot_callback(sprite_t* p, uint32_t id, char* buf, int len)
{
	CHECK_BODY_LEN(len, sizeof(home_hot_info_t));

	int i = sizeof(protocol_t);
	home_hot_info_t* ret = (void*)buf;

	PKG_UINT32(msg, id, i);
	PKG_UINT32(msg, ret->hot, i);
	PKG_UINT32(msg, ret->flower, i);
	PKG_UINT32(msg, ret->mud, i);

	init_proto_head(msg, p->waitcmd, i);
	return send_to_self(p, msg, i, 1);
}
コード例 #22
0
ファイル: xhx_server.c プロジェクト: Zhanyin/taomee
int deal_xhx_event(sprite_t* p, uint32_t type)
{
	uint32_t msg_type = 0;
	uint32_t attireid = 0;
	switch (type) {
	case 1://从小花仙带回花宝猪,标记花宝猪任务小花仙部分完成
		{
			//uint32_t db_buf1[] = {10000, 3};
			//send_request_to_db(SVR_PROTO_SET_CONTINUE_LOGIN_VALUE, NULL, sizeof(db_buf1), db_buf1, p->id);
			attireid = 1351126;
			msg_type = 2;
		}
		break;
	case 2://小仙果,从小花仙获得小仙果,加入到摩尔庄园数据库,每天1次
		{
			attireid = 1351127;
			msg_type = 3;
			//db_set_sth_done(NULL, 50005, 1, p->id);
		}
		break;
	case 3://进入虫虫谷,添加一个临时物品标记用户时从小花仙过来的。
		{
			attireid = 1351128;
		}
		break;
	case 4://小花仙获得拉菲花
		{
			attireid = 1351129;
			msg_type = 4;
		}
		break;
	default:
		break;
	}
	if (attireid != 0) {
		//uint32_t db_buf[]={0, 1, 0, 0, 99, attireid, 1, 99999};
		//send_request_to_db(SVR_PROTO_EXCHG_ITEM, NULL, sizeof(db_buf), db_buf, p->id);
	}

	if (msg_type != 0) {//前端主动通知包,通知前端带回花宝猪、获得小仙果
		DEBUG_LOG("send to flash: msg uid[%u] type[%u] cmd[%d]", p->id, msg_type, PROTO_XHX_ADD_ITEMS);
		int l = sizeof(protocol_t);
		PKG_UINT32(msg, msg_type, l);
		init_proto_head(msg, PROTO_XHX_ADD_ITEMS, l);
		send_to_self(p, msg, l, 0);
	}
	return 0;
}
コード例 #23
0
ファイル: mysvrlist.cpp プロジェクト: Zhanyin/taomee
int send_ranged_svrlist(usr_info_t* p, svr_info_t* svrs, uint32_t online_cnt)
{
	//make a response package to the flash client
	int idx = sizeof(cli_login_pk_header_t);
	taomee::pack(my_cli_buf, online_cnt, idx);
	for (uint32_t i = 0; i != online_cnt; ++i) {
		taomee::pack(my_cli_buf, svrs[i].id, idx);
		taomee::pack(my_cli_buf, svrs[i].users, idx);
		taomee::pack(my_cli_buf, svrs[i].ip, 16, idx);
		taomee::pack(my_cli_buf, svrs[i].port, idx);
		taomee::pack(my_cli_buf, svrs[i].friends, idx);
    	TRACE_LOG("online=[%u %u %16s %u %u]",svrs[i].id,svrs[i].users,svrs[i].ip,svrs[i].port,svrs[i].friends);
	}
	init_proto_head(my_cli_buf, idx, PROTO_GET_RANGED_SVR_LIST, p->uid, SUCCESS);
    return send_to_self(p, my_cli_buf, idx);
}
コード例 #24
0
ファイル: pasture.c プロジェクト: Zhanyin/taomee
int purchase_pasture_milk_callback(sprite_t *p, uint32_t id, char *buf, int len)
{
	CHECK_BODY_LEN(len, sizeof(uint32_t) * 2);
	uint32_t milk_storage, day_count;
	uint32_t l = 0;
	uint32_t offset = sizeof(protocol_t);
	UNPKG_H_UINT32(buf, milk_storage, l);
	PKG_UINT32(msg, milk_storage, offset);
	purchase_award_t awards;
	memset(&awards, 0, sizeof(purchase_award_t));
	UNPKG_H_UINT32(buf, day_count, l);
	if(day_count <= 3){
		awards.count = 2;
		awards.items[0].itemid = 1270044;
		awards.items[0].count = 1;
		awards.items[1].itemid = 190293;
		awards.items[1].count = 1;
		uint32_t msgbuff_1[2] = { id, 1 };
		msglog(statistic_logfile, 0x0408B3EF, get_now_tv()->tv_sec, msgbuff_1, sizeof(msgbuff_1));
	}
	else if(day_count > 3 && day_count <= 7){

		awards.count = 2;
		awards.items[0].itemid = 180073;
		awards.items[0].count = 1;
		awards.items[1].itemid = 0;
		awards.items[1].count = 500;
	}
	else{
		awards.count = 1;
		awards.items[0].itemid = 0;
		awards.items[0].count = 500;

	}
	PKG_UINT32(msg, awards.count, offset);
	uint32_t k =0;
	for(; k < awards.count; ++k){
		db_exchange_single_item_op(p, 202, awards.items[k].itemid, awards.items[k].count, 0);
		PKG_UINT32(msg, awards.items[k].itemid, offset);
		PKG_UINT32(msg, awards.items[k].count, offset);
	}
 	uint32_t msgbuff_2[2] = { id, 1 };
	msglog(statistic_logfile, 0x0408B3D9, get_now_tv()->tv_sec, msgbuff_2, sizeof(msgbuff_2));

	init_proto_head(msg, p->waitcmd, offset);
	return send_to_self(p, msg, offset, 1);
}
コード例 #25
0
ファイル: christmas_sock.c プロジェクト: Zhanyin/taomee
int check_christmas_sock_gift_callback(sprite_t* p, uint32_t id, char* buf, int len)
{
	typedef struct {
		uint32_t sock_cnt;
		uint32_t is_get;
	}__attribute__((packed)) check_christmas_gift_cbk_pack_t;
	CHECK_BODY_LEN(len, sizeof(check_christmas_gift_cbk_pack_t));
	check_christmas_gift_cbk_pack_t* cbk_pack = (check_christmas_gift_cbk_pack_t*)buf;
	
	uint32_t friend_id = *(uint32_t*)(p->session);
	uint32_t opt_flag = *(uint32_t*)(p->session + 4);
	DEBUG_LOG("check christmas sock gift: uid[%u] fid[%u] cnt[%u] is_get[%u]", p->id, friend_id, cbk_pack->sock_cnt, cbk_pack->is_get);

	int l = sizeof(protocol_t);
	uint32_t ret_state = 0;
	if (opt_flag == 1) {	//查询
		if (cbk_pack->is_get != 0) {
			ret_state = (cbk_pack->sock_cnt == 0) ? 2 : 1;
		}
		PKG_UINT32(msg, ret_state, l);
		PKG_UINT32(msg, 0, l);
	} else {	//领取
		if (cbk_pack->is_get != 0) {
			ret_state = 1;
			PKG_UINT32(msg, ret_state, l);
			PKG_UINT32(msg, 0, l);
		} else {
			ret_state = (cbk_pack->sock_cnt == 0) ? 2 : 0;
			PKG_UINT32(msg, ret_state, l);
			DEBUG_LOG("check christmas sock gift:ret_state[%u]", ret_state);
			if (ret_state == 2) {
				PKG_UINT32(msg, 0, l);
			} else {
				if (cbk_pack->sock_cnt > 3) {
					cbk_pack->sock_cnt = 3;
				}
				PKG_UINT32(msg, cbk_pack->sock_cnt, l);
				pack_christmas_sock_gift(p, msg, cbk_pack->sock_cnt, &l);
			
				send_request_to_db(SVR_PROTO_SET_CHRISTMAS_GIFT, NULL, 4, &friend_id, p->id);
			}
		}
	}
	init_proto_head(msg, p->waitcmd, l);
	return send_to_self(p, msg, l, 1);
}
コード例 #26
0
ファイル: xhx_server.c プロジェクト: Zhanyin/taomee
int xhx_check_user_callback(sprite_t * p, uint32_t id, char * buf, int len)
{
	uint32_t count;
	int i = 0;
	UNPKG_H_UINT32(buf, count, i);
	uint32_t ret_state = 0;
	if (count == 0) {
		int l = sizeof(protocol_t);
		PKG_UINT32(msg, ret_state, l);
		init_proto_head(msg, p->waitcmd, l);
		return send_to_self(p, msg, l, 1);
	}
	
	uint32_t daytype = 50006;
	*(uint32_t*)p->session = daytype;
	return send_request_to_db(SVR_PROTO_CHK_IF_STH_DONE, p, 4, &daytype, p->id);
}
コード例 #27
0
ファイル: christmas_sock.c プロジェクト: Zhanyin/taomee
int christmas_sock_send_bonus_to_client(sprite_t * p)
{
    DEBUG_LOG("--userid %u --", p->id);
    send_request_to_db(SVR_PROTO_ROOMINFO_DEL_CHRISTMAS_SOCK_INFO, NULL, 0, NULL, p->id);

    int j = sizeof(protocol_t);

    uint32_t i = 0;
    for (i = 0; i < p->sess_len ; i++)
    {
        PKG_UINT32(msg, *(uint32_t*)(p->session + i*4), j);
    }

	init_proto_head(msg, p->waitcmd, j);
	send_to_self(p, msg, j, 1);
	return 0;
}
コード例 #28
0
ファイル: mole_cup.c プロジェクト: Zhanyin/taomee
int chk_cup_history_callback(sprite_t* p, uint32_t id, char* buf, int len)
{
	CHECK_BODY_LEN_GE(len, 4);

	uint32_t date, grpid;
	int i = 0, j = 0, k = sizeof(protocol_t), cnt;
	UNPKG_H_UINT32(buf, cnt, i);
	memset(msg + k, 0, 21);
	for ( ; j != cnt; ++j ) {
		UNPKG_H_UINT32(buf, date, i);
		UNPKG_H_UINT32(buf, grpid, i);
		//
		PKG_UINT8(msg, grpid, k);
	}
	init_proto_head(msg, p->waitcmd, 38);
	return send_to_self(p, msg, 38, 1);
}
コード例 #29
0
ファイル: new_tug.cpp プロジェクト: Zhanyin/taomee
/**
 * @brief 给准备好的玩家发送本次游戏的卡牌队列
 * @param
 * @return
 */
int Cnew_tug::send_player_cards(sprite_t* p)
{
	Cplayer * p_player = NULL;
	int l = sizeof (protocol_t);
	for (uint32_t i = 0; i < players.size(); i++)
	{
		if (players[i] != NULL)
		{
			if (players[i]->get_sprite() == p)
			{
				p_player = players[i];
				break ;
			}
		}
	}

	if (p_player == NULL)
	{
		return GER_end_of_game;
	}

	int size = p_player->get_card_size();
	ant::pack(pkg, p->id, l);

	DEBUG_LOG("Cnew_tug::player userid:%u ",p->id);

	ant::pack(pkg, (uint8_t)size, l);
	for (int j = 0; j < size; j++)
	{
		uint8_t id = p_player->get_card_id(j);
		ant::pack(pkg, id, l);
	}

	init_proto_head(pkg, NEW_TUG_GET_CARDS, l);
	if (send_to_self(p, pkg, l, completed) != 0)
	{
		ERROR_LOG("Send cards array error");
		return 0;
	}

	DEBUG_LOG("userid:%u Send cards array leave ", p->id);

	return 0;

}
コード例 #30
0
ファイル: homemap.cpp プロジェクト: Zhanyin/taomee
static void send_to_self_op(userid_t uid, sprite_where_t* spwhere, uint8_t* body, int len)
{
	KDEBUG_LOG(uid,"send_to_self_op");

	sprite_t* p = get_sprite(uid);
	if (p) {
		send_to_self(p, body, len, 0);
		protocol_t* proto = (protocol_t *)body;
		if (noti_cli_war_update_score_cmd == ntohs(proto->cmd)) {
			int i = sizeof(protocol_t) + 4;
			uint32_t uid;
			UNPKG_UINT32(body, uid, i);
			if (p->id == uid)
				p->uiflag = 1;
		}
		log_buf(p->id, body, len);
	}
}