1
This commit is contained in:
parent
74f5bc4c4f
commit
843b7a43e2
@ -3,6 +3,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include <a8/mutable_xobject.h>
|
||||
#include <f8/udplog.h>
|
||||
|
||||
#include "netdata.h"
|
||||
|
||||
@ -1432,63 +1433,47 @@ void BattleDataContext::UseItem(int item_id)
|
||||
auto url_params = a8::MutableXObject::CreateObject();
|
||||
url_params->SetVal("c", "Battle");
|
||||
url_params->SetVal("a", "useBattleItem");
|
||||
url_params->SetVal("room_uuid", hum->room->GetRoomUuid());
|
||||
url_params->SetVal("account_id", hum->account_id);
|
||||
url_params->SetVal("session_id", hum->session_id);
|
||||
url_params->SetVal("item_id", item_id);
|
||||
url_params->SetVal("item_num", 1);
|
||||
HttpProxy::Instance()->HttpGet
|
||||
(
|
||||
[]
|
||||
[room_uuid = hum->room->GetRoomUuid(), account_id = hum->account_id]
|
||||
(bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx)
|
||||
{
|
||||
#if 0
|
||||
if (ok) {
|
||||
f8::UdpLog::Instance()->Info
|
||||
("GetBattleData ok %s",
|
||||
("UseBattleItem ok room_uuid:%s account_id:%s %s",
|
||||
{
|
||||
room_uuid,
|
||||
account_id,
|
||||
rsp_obj->ToJsonStr()
|
||||
});
|
||||
if (rsp_obj->GetType() != a8::XOT_OBJECT ||
|
||||
!rsp_obj->HasKey("errcode")) {
|
||||
cb(1, "", nullptr);
|
||||
//cb(1, "", nullptr);
|
||||
return;
|
||||
}
|
||||
int errcode = rsp_obj->Get("errcode", "").GetInt();
|
||||
std::string errmsg = rsp_obj->Get("errmsg", "").GetString();
|
||||
if (errcode) {
|
||||
cb(1, "", nullptr);
|
||||
return;
|
||||
}
|
||||
std::string room_uuid = rsp_obj->Get("room_uuid", "").GetString();
|
||||
if (room_uuid.empty()) {
|
||||
cb(1, "custom battle data error", nullptr);
|
||||
//cb(1, "custom battle data error", nullptr);
|
||||
return;
|
||||
}
|
||||
auto cur_room = RoomMgr::Instance()->GetCustomRoom(room_uuid);
|
||||
if (cur_room) {
|
||||
cb(0, "", cur_room);
|
||||
return;
|
||||
}
|
||||
|
||||
auto custom_battle = std::make_shared<CustomBattle>();
|
||||
custom_battle->Init();
|
||||
custom_battle->SetCustomRoomType(custom_room_type);
|
||||
custom_battle->ParseResult(*rsp_obj);
|
||||
if (custom_battle->GetParseOk()) {
|
||||
cb(0, "", custom_battle);
|
||||
RoomMgr::Instance()->custom_room_hash_[custom_battle->GetMatchRoomUuid()] = custom_battle;
|
||||
} else {
|
||||
cb(1, "", custom_battle);
|
||||
}
|
||||
} else {
|
||||
f8::UdpLog::Instance()->Warning
|
||||
("GetCustomBattleData error %s",
|
||||
("UseBattleItem error room_uuid:%s account_id%s",
|
||||
{
|
||||
""
|
||||
room_uuid,
|
||||
account_id
|
||||
});
|
||||
cb(1, "custom battle data error", nullptr);
|
||||
}
|
||||
#endif
|
||||
},
|
||||
url,
|
||||
url_params
|
||||
|
Loading…
x
Reference in New Issue
Block a user