1
This commit is contained in:
parent
eb4c1e8172
commit
3e2f90bc36
@ -1,5 +1,7 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
|
#include <a8/mutable_xobject.h>
|
||||||
|
|
||||||
#include "framemaker.h"
|
#include "framemaker.h"
|
||||||
#include "human.h"
|
#include "human.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
@ -8,6 +10,52 @@
|
|||||||
#include "car.h"
|
#include "car.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
|
void FrameMaker::Debug_FullObject(Human* hum)
|
||||||
|
{
|
||||||
|
if (!hum->new_objects.empty()) {
|
||||||
|
a8::MutableXObject* out_data = a8::MutableXObject::NewArray();
|
||||||
|
for (auto& itr : hum->new_objects) {
|
||||||
|
int uniid = itr->GetUniId();
|
||||||
|
a8::MutableXObject* xobj = a8::MutableXObject::NewObject();
|
||||||
|
xobj->SetVal("uniid", uniid);
|
||||||
|
xobj->SetVal("", itr->GetEntityType());
|
||||||
|
xobj->SetVal("pos", a8::Format("%d,%d", {itr->GetPos().x, itr->GetPos().y}));
|
||||||
|
out_data->Push(*xobj);
|
||||||
|
}
|
||||||
|
hum->SendDebugMsg(a8::Format("view_debug frameno:%d server_full_obj:%s",
|
||||||
|
{
|
||||||
|
hum->room->GetFrameNo(),
|
||||||
|
out_data->ToJsonStr()
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameMaker::Debug_OutObject(Human* hum)
|
||||||
|
{
|
||||||
|
if (!hum->out_objects.empty()) {
|
||||||
|
a8::MutableXObject* out_data = a8::MutableXObject::NewArray();
|
||||||
|
for (auto& itr : hum->out_objects) {
|
||||||
|
int uniid = itr;
|
||||||
|
a8::MutableXObject* xobj = a8::MutableXObject::NewObject();
|
||||||
|
xobj->SetVal("uniid", uniid);
|
||||||
|
Entity* entity = hum->room->GetEntityByUniId(uniid);
|
||||||
|
if (entity) {
|
||||||
|
xobj->SetVal("matched", 1);
|
||||||
|
xobj->SetVal("pos", a8::Format("%d,%d", {entity->GetPos().x, entity->GetPos().y}));
|
||||||
|
} else {
|
||||||
|
xobj->SetVal("matched", 0);
|
||||||
|
xobj->SetVal("pos", a8::Format("%d,%d", {0, 0}));
|
||||||
|
}
|
||||||
|
out_data->Push(*xobj);
|
||||||
|
}
|
||||||
|
hum->SendDebugMsg(a8::Format("view_debug frameno:%d server_out_obj:%s",
|
||||||
|
{
|
||||||
|
hum->room->GetFrameNo(),
|
||||||
|
out_data->ToJsonStr()
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
||||||
{
|
{
|
||||||
cs::SMUpdate* msg = new cs::SMUpdate;
|
cs::SMUpdate* msg = new cs::SMUpdate;
|
||||||
@ -20,6 +68,9 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
|||||||
TypeConvert::ToPb(room->plane.end_point, p->mutable_end_point());
|
TypeConvert::ToPb(room->plane.end_point, p->mutable_end_point());
|
||||||
TypeConvert::ToPb(room->plane.curr_pos, p->mutable_pos());
|
TypeConvert::ToPb(room->plane.curr_pos, p->mutable_pos());
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
Debug_FullObject(hum);
|
||||||
|
#endif
|
||||||
for (auto& itr : hum->new_objects) {
|
for (auto& itr : hum->new_objects) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (hum->del_objects.find(itr->GetUniId()) != hum->del_objects.end()) {
|
if (hum->del_objects.find(itr->GetUniId()) != hum->del_objects.end()) {
|
||||||
@ -63,9 +114,11 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
if (((Human*)hum)->GetPos().ManhattanDistance(entity->GetPos()) > VIEW_RANGE + 300) {
|
if (((Human*)hum)->GetPos().ManhattanDistance(entity->GetPos()) > VIEW_RANGE + 300) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
entity->FillMFObjectPart(room, (Human*)hum, msg->add_part_objects());
|
entity->FillMFObjectPart(room, (Human*)hum, msg->add_part_objects());
|
||||||
}
|
}
|
||||||
for (auto& itr : hum->del_objects) {
|
for (auto& itr : hum->del_objects) {
|
||||||
@ -79,6 +132,9 @@ cs::SMUpdate* FrameMaker::MakeUpdateMsg(Human* hum)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
Debug_OutObject(hum);
|
||||||
|
#endif
|
||||||
for (auto& itr : hum->out_objects) {
|
for (auto& itr : hum->out_objects) {
|
||||||
msg->add_out_objids(itr);
|
msg->add_out_objids(itr);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -9,4 +9,8 @@ class FrameMaker
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
cs::SMUpdate* MakeUpdateMsg(Human* hum);
|
cs::SMUpdate* MakeUpdateMsg(Human* hum);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Debug_FullObject(Human* hum);
|
||||||
|
void Debug_OutObject(Human* hum);
|
||||||
};
|
};
|
||||||
|
@ -947,6 +947,13 @@ void Human::AddToPartObjects(Entity* entity)
|
|||||||
|
|
||||||
void Human::RemovePartObjects(Entity* entity)
|
void Human::RemovePartObjects(Entity* entity)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
SendDebugMsg(a8::Format("view_debug frameno:%d remove_part_obj:%d",
|
||||||
|
{
|
||||||
|
room->GetFrameNo(),
|
||||||
|
entity->GetUniId()
|
||||||
|
}));
|
||||||
|
#endif
|
||||||
part_objects.erase(entity);
|
part_objects.erase(entity);
|
||||||
entity->OnRemoveFromTargetPartObject(this);
|
entity->OnRemoveFromTargetPartObject(this);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user