/*========================================== * 取引要請 *------------------------------------------ */ void trade_tradeack(dumb_ptr<map_session_data> sd, int type) { dumb_ptr<map_session_data> target_sd; nullpo_retv(sd); if ((target_sd = map_id2sd(account_to_block(sd->trade_partner))) != nullptr) { clif_tradestart(target_sd, type); clif_tradestart(sd, type); if (type == 4) { // Cancel sd->deal_locked = 0; sd->trade_partner = AccountId(); target_sd->deal_locked = 0; target_sd->trade_partner = AccountId(); } if (sd->npc_id) npc_event_dequeue(sd); if (target_sd->npc_id) npc_event_dequeue(target_sd); //close STORAGE window if it's open. It protects from spooffing packets [Lupus] if (sd->state.storage_open) storage_storageclose(sd); } }
/*========================================== * 取引キャンセル *------------------------------------------ */ void trade_tradecancel(dumb_ptr<map_session_data> sd) { dumb_ptr<map_session_data> target_sd; int trade_i; nullpo_retv(sd); if ((target_sd = map_id2sd(account_to_block(sd->trade_partner))) != nullptr) { for (trade_i = 0; trade_i < TRADE_MAX; trade_i++) { //give items back (only virtual) if (sd->deal_item_amount[trade_i] != 0) { assert (sd->deal_item_index[trade_i].ok()); clif_additem(sd, sd->deal_item_index[trade_i].unshift(), sd->deal_item_amount[trade_i], PickupFail::OKAY); sd->deal_item_index[trade_i] = IOff2::from(0); sd->deal_item_amount[trade_i] = 0; } if (target_sd->deal_item_amount[trade_i] != 0) { assert (target_sd->deal_item_index[trade_i].ok()); clif_additem(target_sd, target_sd->deal_item_index[trade_i].unshift(), target_sd->deal_item_amount[trade_i], PickupFail::OKAY); target_sd->deal_item_index[trade_i] = IOff2::from(0); target_sd->deal_item_amount[trade_i] = 0; } } if (sd->deal_zeny) { sd->deal_zeny = 0; clif_updatestatus(sd, SP::ZENY); } if (target_sd->deal_zeny) { clif_updatestatus(target_sd, SP::ZENY); target_sd->deal_zeny = 0; } sd->deal_locked = 0; sd->trade_partner = AccountId(); target_sd->deal_locked = 0; target_sd->trade_partner = AccountId(); clif_tradecancelled(sd); clif_tradecancelled(target_sd); } }
/* Process response to party invitation. */ int party_reply_invite(dumb_ptr<map_session_data> sd, AccountId account_id, int flag) { nullpo_retz(sd); /* There is no pending invitation. */ if (!sd->party_invite || !sd->party_invite_account) return 0; /* * Only one invitation can be pending, so these have to be the same. Since * the client continues to send the wrong ID, and it's already managed on * this side of things, the sent ID is being ignored. */ account_id = sd->party_invite_account; /* The invitation was accepted. */ if (flag == 1) intif_party_addmember(sd->party_invite, sd->status_key.account_id); /* The invitation was rejected. */ else { /* This is the player who sent the invitation. */ dumb_ptr<map_session_data> tsd = nullptr; sd->party_invite = PartyId(); sd->party_invite_account = AccountId(); if ((tsd = map_id2sd(account_to_block(account_id)))) clif_party_inviteack(tsd, sd->status_key.name, 1); } return 0; }
void NetworkManager::removeAccount(const QString &protocol, const QString &id) { AccountAction *action = new AccountAction(Action::RemoveAccount); action->account = AccountId(id, protocol); m_actions << action; trySend(); }
void tmw_AutoBan(dumb_ptr<map_session_data> sd, ZString reason, int length) { if (length == 0 || sd->auto_ban_info.in_progress) return; sd->auto_ban_info.in_progress = 1; AString hack_msg = STRPRINTF("[GM] %s has been autobanned for %s spam"_fmt, sd->status_key.name, reason); tmw_GmHackMsg(hack_msg); AString fake_command = STRPRINTF("@autoban %s %dh (%s spam)"_fmt, sd->status_key.name, length, reason); log_atcommand(sd, fake_command); AString anotherbuf = STRPRINTF("You have been banned for %s spamming. Please do not spam."_fmt, reason); clif_displaymessage(sd->sess, anotherbuf); /* type: 2 - ban(year, month, day, hour, minute, second) */ HumanTimeDiff ban_len {}; ban_len.hour = length; chrif_char_ask_name(AccountId(), sd->status_key.name, 2, ban_len); clif_setwaitclose(sd->sess); }
// パーティが追加された int party_member_added(PartyId party_id, AccountId account_id, int flag) { dumb_ptr<map_session_data> sd = map_id2sd(account_to_block(account_id)), sd2; PartyPair p = party_search(party_id); if (sd == nullptr) { if (flag == 0) { if (battle_config.error_log) PRINTF("party: member added error %d is not online\n"_fmt, account_id); intif_party_leave(party_id, account_id); // キャラ側に登録できなかったため脱退要求を出す } return 0; } sd2 = map_id2sd(account_to_block(sd->party_invite_account)); sd->party_invite = PartyId(); sd->party_invite_account = AccountId(); if (!p) { PRINTF("party_member_added: party %d not found.\n"_fmt, party_id); intif_party_leave(party_id, account_id); return 0; } if (flag == 1) { // 失敗 if (sd2 != nullptr) clif_party_inviteack(sd2, sd->status_key.name, 0); return 0; } // 成功 sd->party_sended = 0; sd->status.party_id = party_id; if (sd2 != nullptr) clif_party_inviteack(sd2, sd->status_key.name, 2); // いちおう競合確認 party_check_conflict(sd); party_send_xy_clear(p); return 0; }
void NetworkManager::sendMessage(const qutim_sdk_0_3::Message &message) { MessageAction *action = new MessageAction(); ChatUnit *contact = const_cast<ChatUnit*>(message.chatUnit()->getHistoryUnit()); action->account = AccountId(contact->account()); action->contact = contact->id(); action->time = message.time(); action->text = message.text(); action->incoming = message.isIncoming(); if (message.property("otrEncrypted", false)) action->encryption << QLatin1String("otr"); if (message.property("pgpEncrypted", false) || (encryptedMessageIdInited && encryptedMessageId == message.id())) { action->encryption << QLatin1String("pgp"); } if (message.property("autoreply", false)) action->encryption << QLatin1String("autoreply"); m_actions << action; trySend(); }
// パーティメンバが脱退した int party_member_leaved(PartyId party_id, AccountId account_id, CharName name) { dumb_ptr<map_session_data> sd = map_id2sd(account_to_block(account_id)); PartyPair p = party_search(party_id); if (p) { int i; for (i = 0; i < MAX_PARTY; i++) if (p->member[i].account_id == account_id) { clif_party_leaved(p, sd, account_id, name, 0x00); p->member[i].account_id = AccountId(); p->member[i].sd = nullptr; } } if (sd != nullptr && sd->status.party_id == party_id) { sd->status.party_id = PartyId(); sd->party_sended = 0; } return 0; }
/*========================================== * 取引許諾(trade押し) *------------------------------------------ */ void trade_tradecommit(dumb_ptr<map_session_data> sd) { dumb_ptr<map_session_data> target_sd; int trade_i; nullpo_retv(sd); if ((target_sd = map_id2sd(account_to_block(sd->trade_partner))) != nullptr) { MAP_LOG_PC(sd, " TRADECOMMIT WITH %d GIVE %d GET %d"_fmt, target_sd->status_key.char_id, sd->deal_zeny, target_sd->deal_zeny); if ((sd->deal_locked >= 1) && (target_sd->deal_locked >= 1)) { // both have pressed 'ok' if (sd->deal_locked < 2) { sd->deal_locked = 2; } // set locked to 2 if (target_sd->deal_locked == 2) { // the other one pressed 'trade' too if (sd->deal_zeny > sd->status.zeny) { sd->deal_zeny = 0; trade_tradecancel(sd); MAP_LOG_PC(sd, " TRADECANCEL"_fmt); return; } if (target_sd->deal_zeny > target_sd->status.zeny) { target_sd->deal_zeny = 0; trade_tradecancel(sd); MAP_LOG_PC(sd, " TRADECANCEL"_fmt); return; } sd->trade_partner = AccountId(); target_sd->trade_partner = AccountId(); for (trade_i = 0; trade_i < TRADE_MAX; trade_i++) { if (sd->deal_item_amount[trade_i] != 0) { assert (sd->deal_item_index[trade_i].ok()); IOff0 n = sd->deal_item_index[trade_i].unshift(); PickupFail flag = pc_additem(target_sd, &sd->status.inventory[n], sd->deal_item_amount[trade_i]); if (flag == PickupFail::OKAY) pc_delitem(sd, n, sd->deal_item_amount[trade_i], 1); else clif_additem(sd, n, sd->deal_item_amount[trade_i], PickupFail::OKAY); sd->deal_item_index[trade_i] = IOff2::from(0); sd->deal_item_amount[trade_i] = 0; } if (target_sd->deal_item_amount[trade_i] != 0) { assert (target_sd->deal_item_index[trade_i].ok()); IOff0 n = target_sd->deal_item_index[trade_i].unshift(); PickupFail flag = pc_additem(sd, &target_sd->status.inventory[n], target_sd->deal_item_amount[trade_i]); if (flag == PickupFail::OKAY) pc_delitem(target_sd, n, target_sd->deal_item_amount[trade_i], 1); else clif_additem(target_sd, n, target_sd->deal_item_amount[trade_i], PickupFail::OKAY); target_sd->deal_item_index[trade_i] = IOff2::from(0); target_sd->deal_item_amount[trade_i] = 0; } } if (sd->deal_zeny) { int deal = sd->deal_zeny; sd->deal_zeny = 0; sd->status.zeny -= deal; clif_updatestatus(sd, SP::ZENY); target_sd->status.zeny += deal; clif_updatestatus(target_sd, SP::ZENY); } if (target_sd->deal_zeny) { int deal = target_sd->deal_zeny; target_sd->deal_zeny = 0; target_sd->status.zeny -= deal; clif_updatestatus(target_sd, SP::ZENY); sd->status.zeny += deal; clif_updatestatus(sd, SP::ZENY); } sd->deal_locked = 0; target_sd->deal_locked = 0; clif_tradecompleted(sd, 0); clif_tradecompleted(target_sd, 0); MAP_LOG_PC(sd, " TRADEOK"_fmt); } } } }