Example #1
0
int save_pvp_game_data(player_t* p, uint32_t pvp_type, bool win_flag)
{
    int idx = 0;
    uint8_t tmpbuf[1024] = {0};
    pack_h(tmpbuf, p->id, idx);
    pack_h(tmpbuf, p->role_tm, idx);
    pack(tmpbuf, p->nick, sizeof(p->nick), idx);
    pack_h(tmpbuf, static_cast<uint32_t>(p->lv), idx);
    pack_h(tmpbuf, pvp_type, idx);
    if ( win_flag ) {
        //pack_h(dbpkgbuf, static_cast<uint32_t>(1), idx);
        add_player_win_times(p, pvp_type);
    } else {
        //pack_h(dbpkgbuf, static_cast<uint32_t>(0), idx);
        add_player_do_times(p, pvp_type);
    }

    idx += pack_player_pvp_game_times(p, pvp_type, tmpbuf + idx);
	pack_h(tmpbuf, p->game_flower, idx);

    KDEBUG_LOG(p->id,"FINISH PVP GAME\t[%u] [%u] [%u %u]",
        pvp_type, win_flag, p->taotai_info->do_times, p->taotai_info->win_times);
    send_request_to_db(0, p->id, p->role_tm, dbproto_save_pvp_game_data, tmpbuf, idx);

    //记录一天进行的次数
    if (!win_flag) {
        add_swap_action_times(p, 1068);
    }

    return 0;
}
Example #2
0
void SummonHome::db_add_effect_to_all_plants(Ferilizer_t* p_ferilizer)
{
	uint32_t ownerid = p_base_home->OwnerUserId;
	uint32_t ownertm = p_base_home->OwnerRoleTime;

	int idx = 0;
	pack_h(dbpkgbuf, p_ferilizer->home_speed_per, idx);
	pack_h(dbpkgbuf, p_ferilizer->home_output_per, idx);
		
	send_request_to_db(0, ownerid, ownertm, dbproto_add_effect_to_all_plants, dbpkgbuf, idx);
}
Example #3
0
int send_roll_point(Player* p, uint32_t roll_id,  uint32_t roll_point)
{
	int idx = 0;
	idx = sizeof(btl_proto_t);
	pack_h(pkgbuf, p->id, idx);
	pack_h(pkgbuf, roll_id, idx);
	pack_h(pkgbuf, roll_point, idx);

	init_btl_proto_head(pkgbuf, p->waitcmd, idx);
	return send_to_player(p, pkgbuf, idx, 1);
}
Example #4
0
int save_pvp_game_flower(player_t* p, uint32_t pvp_type, uint32_t flower)
{
    int idx = 0;
    pack_h(dbpkgbuf, p->id, idx);
    pack_h(dbpkgbuf, p->role_tm, idx);
    pack_h(dbpkgbuf, pvp_type, idx);
    pack_h(dbpkgbuf, flower, idx);

    p->game_flower += flower;

    KDEBUG_LOG(p->id,"FINISH PVP [%u] GAME\t[%u]",pvp_type, flower);
    return send_request_to_db(0, p->id, p->role_tm, dbproto_save_pvp_game_flower, dbpkgbuf, idx);
}
Example #5
0
int db_pick_roll_item(Player* p,  roll_data& data)
{
	uint32_t itmid = data.item_id;
	const GfItem* itm = items->get_item(itmid);
    if(itm == NULL)return 0;
	int idx = 0;

	pack_h(dbpkgbuf, data.roll_id, idx);	
	pack_h(dbpkgbuf, itmid, idx);
	pack_h(dbpkgbuf, itm->db_category(), idx);
	pack_h(dbpkgbuf, itm->max(), idx);
	pack_h(dbpkgbuf, static_cast<uint32_t>(itm->duration * clothes_duration_ratio), idx);
	pack_h(dbpkgbuf, p->max_bag_grid_count,  idx);
	uint32_t pos = get_unique_item_bitpos(itmid);
	TRACE_LOG("get_unique_item_bitpos%u:%u", pos, itmid);
	if (pos && !test_bit_on(p->unique_item_bit, pos)) {
		uint8_t bit_tmp[sizeof(p->unique_item_bit)]= "";
		memcpy(bit_tmp, p->unique_item_bit, sizeof(p->unique_item_bit));
		taomee::set_bit_on(bit_tmp, pos);
		pack_h(dbpkgbuf, static_cast<uint32_t>(sizeof(bit_tmp)), idx);
		pack(dbpkgbuf, bit_tmp, sizeof(bit_tmp), idx);
	} else {
		pack_h(dbpkgbuf, 0, idx);
	}
	return send_request_to_db(p, p->id, p->role_tm, dbproto_player_pick_roll_item, dbpkgbuf, idx);
}
Example #6
0
int db_pick_fruit_callback(Player* p, userid_t id, void* body, uint32_t bodylen, uint32_t ret)
{
	int idx = sizeof(home_proto_t);
	if (ret) {
		pack_h(dbpkgbuf, ret, idx);
		pack_h(dbpkgbuf, 0, idx);
		pack_h(dbpkgbuf, 0, idx);
		pack_h(dbpkgbuf, 0, idx);
	} else {
		taomee::pack_h(pkgbuf, ret, idx);
		taomee::pack(pkgbuf, body, bodylen, idx);
	}
	init_home_proto_head(pkgbuf, p->waitcmd, idx);
	DEBUG_LOG("PICK FRUIT! %u %u ret:%u", p->id, *(uint32_t*)body, ret);
	return send_to_player(p, pkgbuf, idx, 1); 
}
Example #7
0
/** 
 * @brief 比武大会拉自己信息 
 * 
 */
int db_get_self_contest_info_callback(player_t *p, userid_t uid, void *body, uint32_t bodylen,
		uint32_t ret)
{
	CHECK_DBERR(p, ret);
	self_contest_t * pkg = reinterpret_cast<self_contest_t*>(body);

	int idx = sizeof(cli_proto_t);
	taomee::pack(pkgbuf, pkg->team_id, idx);
	p->team_id = pkg->team_id;
    p->contest_win_stage = pkg->win_stage;
	int j = 0;
	int ifx = idx + 4;
	for (int i = 935; i <= 938; i++) {
		kill_boss_data * kill = get_player_kill_boss_data(p, i, 1); 
		if (kill) {
			j++;
			taomee::pack(pkgbuf, kill->boss_id_, ifx);
			taomee::pack(pkgbuf, kill->kill_time_, ifx);	
		}
	}
	taomee::pack(pkgbuf, j, idx);
	init_cli_proto_head(pkgbuf, p, p->waitcmd, ifx);
	send_to_player(p, pkgbuf, ifx, 1);

    //send_request_to_db(p, p->id, p->role_tm, dbproto_get_taotai_game_info, 0, 0);
    idx = 0;
    pack_h(dbpkgbuf, static_cast<uint32_t>(2), idx); //Three section of contest
    send_request_to_db(p, p->id, p->role_tm, dbproto_get_pvp_game_info, dbpkgbuf, idx);

    return 0;
}
Example #8
0
void Plant::pack_plant_info_h(void * pkg, int & idx)
{
	pack_h(pkg, plant_id_, idx);
	pack_h(pkg, plant_tm_, idx);
	pack_h(pkg, field_id_, idx);
	pack_h(pkg, status, idx);
	pack_h(pkg, status_tm, idx);
	//pack_h(pkg, status_duration, idx);
	pack_h(pkg, water_tm, idx);
	pack_h(pkg, fruit_cnt, idx);
	pack_h(pkg, speed_per, idx);
	pack_h(pkg, output_per, idx);
}
Example #9
0
int save_advance_game_data(player_t* p, bool win_flag)
{
   // ERROR_LOG("save_pvp_advance_game_data:%u", p->id);
    int idx = 0;
    pack_h(dbpkgbuf, p->id, idx);
    pack_h(dbpkgbuf, p->role_tm, idx);
    if ( win_flag ) {
        pack_h(dbpkgbuf, static_cast<uint32_t>(1), idx);
        p->advance_info->win_times += 1;
    } else {
		p->advance_info->do_times += 1;
        pack_h(dbpkgbuf, static_cast<uint32_t>(0), idx);
    }
    KDEBUG_LOG(p->id,"FINISH PVP ADVANCE GAME\t[%u %u]", p->advance_info->do_times, p->advance_info->win_times);
    //send_request_to_db(0, p->id, p->role_tm, dbproto_save_advance_game_data, dbpkgbuf, idx);
    return 0;
}
Example #10
0
int save_taotai_game_data(player_t* p, bool win_flag)
{
    TRACE_LOG("save_pvp_monster_game_data:%u", p->id);
    int idx = 0;
    pack_h(dbpkgbuf, p->id, idx);
    pack_h(dbpkgbuf, p->role_tm, idx);
    //pack_h(dbpkgbuf, p->role_type, idx);
    //pack(dbpkgbuf, p->nick, sizeof(p->nick), idx);
    //pack_h(dbpkgbuf, p->team_number, idx);
    p->taotai_info->do_times += 1;
    if ( win_flag ) {
        pack_h(dbpkgbuf, static_cast<uint32_t>(1), idx);
        p->taotai_info->win_times += 1;
    } else {
        pack_h(dbpkgbuf, static_cast<uint32_t>(0), idx);
    }
    KDEBUG_LOG(p->id,"FINISH PVP MONSTAR GAME\t[%u %u]", p->taotai_info->do_times, p->taotai_info->win_times);
    //send_request_to_db(0, p->id, p->role_tm, dbproto_save_taotai_game_data, dbpkgbuf, idx);
    return 0;
}
Example #11
0
int pack_player_pvp_game_times(player_t* p, uint32_t pvp_type, uint8_t * buf)
{
    int idx = 0;
    if (pvp_type == 0) {
        pack_h(buf, p->taotai_info->do_times, idx);
        pack_h(buf, p->taotai_info->win_times, idx);
    } else if (pvp_type == 1) {
        pack_h(buf, p->advance_info->do_times, idx);
        pack_h(buf, p->advance_info->win_times, idx);
    } else if (pvp_type == 2) {
        pack_h(buf, p->final_info->do_times, idx);
        pack_h(buf, p->final_info->win_times, idx);
    } else {
        pack_h(buf, static_cast<uint32_t>(0), idx);
        pack_h(buf, static_cast<uint32_t>(0), idx);
    }
    return idx;
}
Example #12
0
int db_get_contest_team_info_callback(player_t * p, userid_t uid, void * body,uint32_t bodylen,
		uint32_t ret)
{
	CHECK_DBERR(p, ret);
	uint32_t team_cnt = 0;
	int ifx = 0;
	taomee::unpack_h(body, team_cnt, ifx);
	CHECK_VAL_EQ(bodylen - 4, team_cnt * sizeof(contest_team_rsp_t));
	static uint8_t tmpbuf[8192];
	int idx = sizeof(cli_proto_t);
	taomee::pack(tmpbuf, team_cnt, idx);
//	ERROR_LOG("get team_cnt =%u", team_cnt);
	for (uint32_t i = 0; i < team_cnt; i++) {
		contest_team_rsp_t * team = reinterpret_cast<contest_team_rsp_t*>((char*)(body) + 4
			   	 + i *sizeof(contest_team_rsp_t));
		taomee::pack(tmpbuf, team->team_id, idx);
	//	ERROR_LOG("team id = %u", team->team_id);
		taomee::pack(tmpbuf, team->leader_id, idx);
		taomee::pack(tmpbuf, team->leader_tm, idx);
		taomee::pack(tmpbuf, team->leader_name, 16, idx); 
		taomee::pack(tmpbuf, team->team_member, idx);
	//	ERROR_LOG("team member = %u", team->team_member);
		taomee::pack(tmpbuf, team->team_plant, idx);
	//	ERROR_LOG("team plant =%u", team->team_plant);
        if ( is_valid_uid(team->leader_tm) ) {
            p->contest_leader_flag = 1;
        }
		if (team->team_id == p->team_id && p->waitcmd == cli_proto_player_gain_item) {
			if (get_unique_item_bitpos(13098)) {
				if (!test_bit_on(p->unique_item_bit, 68)) {
					uint32_t type = 2;
					uint32_t add_num = (team->team_plant / team->team_member);
					if (add_num == 0) {
						add_num ++;
					}
					int ifx = 0;
					uint32_t item_id = 1302001;
					uint32_t max_bag_grid_count = get_player_total_item_bag_grid_count(p); 
					if (!p->my_packs->check_enough_bag_item_grid(p, item_id, add_num)) {
						return send_header_to_player(p, p->waitcmd, cli_err_bag_no_space, 1); 
					}
					pack_h(dbpkgbuf, type, ifx);
					pack_h(dbpkgbuf, item_id, ifx);
					pack_h(dbpkgbuf, add_num, ifx);
					pack_h(dbpkgbuf, max_bag_grid_count, ifx);
					return send_request_to_db(p, p->id, p->role_tm,
						   	dbproto_add_item, dbpkgbuf, ifx);
				} else {
						return send_header_to_player(p, p->waitcmd, cli_err_ever_limit_time_act, 1);
				}
			} 
		}

		//ERROR_LOG("TEAM ID=%u LEADER_ID=%u LEADER_TM=%u", team->team_id, team->leader_id, team->leader_tm);
		if (team->team_id == p->team_id && team->leader_id == p->id && 
				 team->leader_tm == p->role_tm) {
//			if (!is_player_achievement_data_exist(p, 112)) {
//				do_achieve_type_logic(p, 112);
//                //add_title_interface(p, enum_achieve_title);
//			}
            do_special_title_logic(p, 105);
		}
	}
	init_cli_proto_head(tmpbuf, p, p->waitcmd, idx);
	return send_to_player(p, tmpbuf, idx, 1);
}
/** Pack a list of widgets horizontally, and make them all the same width. */
inline rhea::constraint_list
pack_equal_h(std::initializer_list<const widget&> wl, double spacing = 0.0)
{
    return combine({pack_h(wl, spacing), chain(wl, equal_width)});
}