/** * Check here hacker for duplicate item in trade * normal client refuse to have 2 same types of item (except equipment) in same trade window * normal client authorise only no equipped item and only from inventory * This function could end player connection if too much hack is detected * @param sd : player to check * @return -1:zeny hack, 0:all fine, 1:item hack */ int impossible_trade_check(struct map_session_data *sd) { struct item inventory[MAX_INVENTORY]; char message_to_gm[200]; int i, index; nullpo_retr(1, sd); if(sd->deal.zeny > sd->status.zeny) { pc_setglobalreg(sd,"ZENY_HACKER",1); return -1; } // get inventory of player memcpy(&inventory, &sd->status.inventory, sizeof(struct item) * MAX_INVENTORY); // remove this part: arrows can be trade and equipped // re-added! [celest] // remove equipped items (they can not be trade) for (i = 0; i < MAX_INVENTORY; i++) if (inventory[i].nameid > 0 && inventory[i].equip && !(inventory[i].equip & EQP_AMMO)) memset(&inventory[i], 0, sizeof(struct item)); // check items in player inventory for(i = 0; i < 10; i++) { if (!sd->deal.item[i].amount) continue; index = sd->deal.item[i].index; if (inventory[index].amount < sd->deal.item[i].amount) { // if more than the player have -> hack sprintf(message_to_gm, msg_txt(sd,538), sd->status.name, sd->status.account_id); // Hack on trade: character '%s' (account: %d) try to trade more items that he has. intif_wis_message_to_gm(wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); sprintf(message_to_gm, msg_txt(sd,539), inventory[index].amount, inventory[index].nameid, sd->deal.item[i].amount); // This player has %d of a kind of item (id: %d), and try to trade %d of them. intif_wis_message_to_gm(wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); // if we block people if (battle_config.ban_hack_trade < 0) { chrif_req_login_operation(-1, sd->status.name, CHRIF_OP_LOGIN_BLOCK, 0, 0, 0); // type: 1 - block set_eof(sd->fd); // forced to disconnect because of the hack // message about the ban strcpy(message_to_gm, msg_txt(sd,540)); // This player has been definitively blocked. // if we ban people } else if (battle_config.ban_hack_trade > 0) { chrif_req_login_operation(-1, sd->status.name, CHRIF_OP_LOGIN_BAN, battle_config.ban_hack_trade*60, 0, 0); // type: 2 - ban (year, month, day, hour, minute, second) set_eof(sd->fd); // forced to disconnect because of the hack // message about the ban sprintf(message_to_gm, msg_txt(sd,507), battle_config.ban_hack_trade); // This player has been banned for %d minute(s). } else // message about the ban strcpy(message_to_gm, msg_txt(sd,508)); // This player hasn't been banned (Ban option is disabled). intif_wis_message_to_gm(wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm); return 1; } inventory[index].amount -= sd->deal.item[i].amount; // remove item from inventory } return 0; }
// Sends a whisper to all GMs void tmw_GmHackMsg(ZString line) { intif_wis_message_to_gm(wisp_server_name, GmLevel::from(static_cast<uint32_t>(battle_config.hack_info_GM_level)), line); }
/*========================================== * Check here hacker for duplicate item in trade * normal client refuse to have 2 same types of item (except equipment) in same trade window * normal client authorise only no equiped item and only from inventory *------------------------------------------ */ int impossible_trade_check(struct map_session_data *sd) { struct item inventory[MAX_INVENTORY]; char message_to_gm[200]; int i, index; nullpo_retr(1, sd); if(sd->deal.zeny > sd->status.zeny) { pc_setglobalreg(sd,"ZENY_HACKER",1); return -1; } // get inventory of player memcpy(&inventory, &sd->status.inventory, sizeof(struct item) * MAX_INVENTORY); // remove this part: arrows can be trade and equiped // re-added! [celest] // remove equiped items (they can not be trade) for (i = 0; i < MAX_INVENTORY; i++) if (inventory[i].nameid > 0 && inventory[i].equip && !(inventory[i].equip & 0x8000)) memset(&inventory[i], 0, sizeof(struct item)); // check items in player inventory for(i = 0; i < 10; i++) if (sd->deal.item[i].amount < 0) { // negativ? -> hack // printf("Negativ amount in trade, by hack!\n"); // normal client send cancel when we type negativ amount return -1; } else if (sd->deal.item[i].amount > 0) { index = sd->deal.item[i].index; inventory[index].amount -= sd->deal.item[i].amount; // remove item from inventory // printf("%d items left\n", inventory[index].amount); if (inventory[index].amount < 0) { // if more than the player have -> hack // printf("A player try to trade more items that he has: hack!\n"); sprintf(message_to_gm, msg_txt(538), sd->status.name, sd->status.account_id); // Hack on trade: character '%s' (account: %d) try to trade more items that he has. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm); sprintf(message_to_gm, msg_txt(539), sd->status.inventory[index].amount, sd->status.inventory[index].nameid, sd->status.inventory[index].amount - inventory[index].amount); // This player has %d of a kind of item (id: %d), and try to trade %d of them. intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm); // if we block people if (battle_config.ban_hack_trade < 0) { chrif_char_ask_name(-1, sd->status.name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block clif_setwaitclose(sd->fd); // forced to disconnect because of the hack // message about the ban sprintf(message_to_gm, msg_txt(540), battle_config.ban_spoof_namer); // This player has been definitivly blocked. // if we ban people } else if (battle_config.ban_hack_trade > 0) { chrif_char_ask_name(-1, sd->status.name, 2, 0, 0, 0, 0, battle_config.ban_hack_trade, 0); // type: 2 - ban (year, month, day, hour, minute, second) clif_setwaitclose(sd->fd); // forced to disconnect because of the hack // message about the ban sprintf(message_to_gm, msg_txt(507), battle_config.ban_spoof_namer); // This player has been banned for %d minute(s). } else { // message about the ban sprintf(message_to_gm, msg_txt(508)); // This player hasn't been banned (Ban option is disabled). } intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, message_to_gm); return 1; } } return 0; }