1
This commit is contained in:
parent
c25c30c765
commit
564851eae8
@ -1,5 +1,8 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
|
|
||||||
#include <a8/mutable_xobject.h>
|
#include <a8/mutable_xobject.h>
|
||||||
#include <a8/websocketclient.h>
|
#include <a8/websocketclient.h>
|
||||||
|
|
||||||
@ -33,7 +36,6 @@ behaviac::EBTStatus AndroidAgent::SearchEnemy(int range)
|
|||||||
|
|
||||||
bool AndroidAgent::NetIsConnected()
|
bool AndroidAgent::NetIsConnected()
|
||||||
{
|
{
|
||||||
a8::XPrintf("NetIsConnected\n", {});
|
|
||||||
return true;
|
return true;
|
||||||
return owner_->GetWebSocket()->Connected() != 0;
|
return owner_->GetWebSocket()->Connected() != 0;
|
||||||
}
|
}
|
||||||
@ -134,7 +136,6 @@ behaviac::EBTStatus AndroidAgent::CoLogin()
|
|||||||
behaviac::EBTStatus AndroidAgent::CoConnectBattleServer()
|
behaviac::EBTStatus AndroidAgent::CoConnectBattleServer()
|
||||||
{
|
{
|
||||||
PRE_ENTER_COROUTINE();
|
PRE_ENTER_COROUTINE();
|
||||||
a8::XPrintf("CoConnectBattleServer socket_id:%d\n", {owner_->GetSocketId()});
|
|
||||||
auto context = MAKE_BTCONTEXT
|
auto context = MAKE_BTCONTEXT
|
||||||
(
|
(
|
||||||
std::function<void (a8::WebSocketClient*, int)> old_on_error;
|
std::function<void (a8::WebSocketClient*, int)> old_on_error;
|
||||||
@ -158,7 +159,7 @@ behaviac::EBTStatus AndroidAgent::CoConnectBattleServer()
|
|||||||
owner_->GetWebSocket()->on_connect =
|
owner_->GetWebSocket()->on_connect =
|
||||||
[this, context] (a8::WebSocketClient* )
|
[this, context] (a8::WebSocketClient* )
|
||||||
{
|
{
|
||||||
a8::XPrintf("id:%d WebSocketClient on_connect\n", {context->socket_id});
|
//a8::XPrintf("id:%d WebSocketClient on_connect\n", {context->socket_id});
|
||||||
context->pending = false;
|
context->pending = false;
|
||||||
context->connect_ok = true;
|
context->connect_ok = true;
|
||||||
};
|
};
|
||||||
@ -219,6 +220,7 @@ behaviac::EBTStatus AndroidAgent::CoJoin()
|
|||||||
if (!owner_->IsJoinOk()) {
|
if (!owner_->IsJoinOk()) {
|
||||||
return behaviac::BT_RUNNING;
|
return behaviac::BT_RUNNING;
|
||||||
}
|
}
|
||||||
|
++Perf::Instance()->join_ok_times;
|
||||||
return behaviac::BT_SUCCESS;
|
return behaviac::BT_SUCCESS;
|
||||||
};
|
};
|
||||||
return StartCoroutine(co);
|
return StartCoroutine(co);
|
||||||
@ -236,11 +238,15 @@ behaviac::EBTStatus AndroidAgent::CoUpdateGame()
|
|||||||
#if 1
|
#if 1
|
||||||
++Perf::Instance()->update_times;
|
++Perf::Instance()->update_times;
|
||||||
if (owner_->GetWebSocket()->Connected()) {
|
if (owner_->GetWebSocket()->Connected()) {
|
||||||
|
std::shared_ptr<glm::vec3> sand_table_target_pos;
|
||||||
if (a8::XGetTickCount() - last_dir_tick_ > 3000) {
|
if (a8::XGetTickCount() - last_dir_tick_ > 3000) {
|
||||||
curr_dir_ = glm::vec3(0.0f, 0.0f, 1.0f);
|
curr_dir_ = glm::vec3(0.0f, 0.0f, 1.0f);
|
||||||
GlmHelper::RotateY(curr_dir_, a8::RandAngle());
|
GlmHelper::RotateY(curr_dir_, glm::radians((float(rand() % 360))));
|
||||||
last_dir_tick_ = a8::XGetTickCount();
|
last_dir_tick_ = a8::XGetTickCount();
|
||||||
++Perf::Instance()->chg_dir_times;
|
++Perf::Instance()->chg_dir_times;
|
||||||
|
sand_table_target_pos = std::make_shared<glm::vec3>(0.0f, 0.0f, 0.0f);
|
||||||
|
sand_table_target_pos->x = a8::RandEx(100, 2000);
|
||||||
|
sand_table_target_pos->z = a8::RandEx(100, 2000);
|
||||||
}
|
}
|
||||||
if (a8::XGetTickCount() - last_send_tick_ > 80) {
|
if (a8::XGetTickCount() - last_send_tick_ > 80) {
|
||||||
last_send_tick_ = a8::XGetTickCount();
|
last_send_tick_ = a8::XGetTickCount();
|
||||||
@ -249,6 +255,9 @@ behaviac::EBTStatus AndroidAgent::CoUpdateGame()
|
|||||||
cs::CMMove msg;
|
cs::CMMove msg;
|
||||||
ToPb(curr_dir_, msg.mutable_move_dir());
|
ToPb(curr_dir_, msg.mutable_move_dir());
|
||||||
ToPb(curr_dir_, msg.mutable_attack_dir());
|
ToPb(curr_dir_, msg.mutable_attack_dir());
|
||||||
|
if (sand_table_target_pos) {
|
||||||
|
ToPb(*sand_table_target_pos.get(), msg.mutable_sand_table_target_pos());
|
||||||
|
}
|
||||||
msg.set_shot_start(1);
|
msg.set_shot_start(1);
|
||||||
msg.set_shot_hold(1);
|
msg.set_shot_hold(1);
|
||||||
owner_->SendMsg(msg);
|
owner_->SendMsg(msg);
|
||||||
@ -259,7 +268,7 @@ behaviac::EBTStatus AndroidAgent::CoUpdateGame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a8::XPrintf("disconnect\n", {});
|
//a8::XPrintf("disconnect\n", {});
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return behaviac::BT_SUCCESS;
|
return behaviac::BT_SUCCESS;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include "base_agent.h"
|
#include "base_agent.h"
|
||||||
|
#include "tracemgr.h"
|
||||||
|
#include "perf.h"
|
||||||
|
|
||||||
#include <f8/btmgr.h>
|
#include <f8/btmgr.h>
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ void Perf::UnInit()
|
|||||||
void Perf::Output()
|
void Perf::Output()
|
||||||
{
|
{
|
||||||
f8::UdpLog::Instance()->Info
|
f8::UdpLog::Instance()->Info
|
||||||
("perf login_ok:%d login_fail:%d enter_ok:%d enter_fail:%d connect_ok:%d connect_fail:%d chg_dir:%d send_move:%d update:%d",
|
("perf login_ok:%d login_fail:%d enter_ok:%d enter_fail:%d connect_ok:%d connect_fail:%d join_ok:%d chg_dir:%d send_move:%d update:%d",
|
||||||
{
|
{
|
||||||
login_ok_times,
|
login_ok_times,
|
||||||
login_fail_times,
|
login_fail_times,
|
||||||
@ -33,6 +33,7 @@ void Perf::Output()
|
|||||||
enter_fail_times,
|
enter_fail_times,
|
||||||
connect_ok_times,
|
connect_ok_times,
|
||||||
connect_fail_times,
|
connect_fail_times,
|
||||||
|
join_ok_times,
|
||||||
chg_dir_times,
|
chg_dir_times,
|
||||||
send_move_times,
|
send_move_times,
|
||||||
update_times
|
update_times
|
||||||
|
@ -19,11 +19,11 @@ private:
|
|||||||
long long enter_fail_times = 0;
|
long long enter_fail_times = 0;
|
||||||
long long connect_ok_times = 0;
|
long long connect_ok_times = 0;
|
||||||
long long connect_fail_times = 0;
|
long long connect_fail_times = 0;
|
||||||
|
long long join_ok_times = 0;
|
||||||
long long chg_dir_times = 0;
|
long long chg_dir_times = 0;
|
||||||
long long send_move_times = 0;
|
long long send_move_times = 0;
|
||||||
long long update_times = 0;
|
long long update_times = 0;
|
||||||
|
|
||||||
private:
|
|
||||||
void Output();
|
void Output();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -15,8 +15,11 @@
|
|||||||
|
|
||||||
void Player::Update()
|
void Player::Update()
|
||||||
{
|
{
|
||||||
if (agent_) {
|
if (a8::XGetTickCount() - last_update_tick_ > 50) {
|
||||||
agent_->Exec();
|
last_update_tick_ = a8::XGetTickCount();
|
||||||
|
if (agent_) {
|
||||||
|
agent_->Exec();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ private:
|
|||||||
bool is_login_success_ = false;
|
bool is_login_success_ = false;
|
||||||
bool net_connected_ = false;
|
bool net_connected_ = false;
|
||||||
bool join_ok_ = false;
|
bool join_ok_ = false;
|
||||||
|
long long last_update_tick_ = 0;
|
||||||
|
|
||||||
std::shared_ptr<a8::WebSocketClient> web_socket_;
|
std::shared_ptr<a8::WebSocketClient> web_socket_;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ void PlayerMgr::Init()
|
|||||||
account_id_hash_[hum->GetAccountId()] = hum;
|
account_id_hash_[hum->GetAccountId()] = hum;
|
||||||
socket_id_hash_[hum->GetSocketId()] = hum;
|
socket_id_hash_[hum->GetSocketId()] = hum;
|
||||||
++count;
|
++count;
|
||||||
if (count >= 1) {
|
if (count >= 2000) {
|
||||||
f8::Timer::Instance()->DeleteCurrentTimer();
|
f8::Timer::Instance()->DeleteCurrentTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user