|
@@ -43,7 +43,7 @@ struct area_list:single_base<area_list,int,std::shared_ptr<area>>
|
|
|
area_list();
|
|
|
|
|
|
std::vector<std::shared_ptr<area>> get_area(const point&pt);
|
|
|
- static void init_from_db()
|
|
|
+ void init_from_db()
|
|
|
{
|
|
|
}
|
|
|
};
|
|
@@ -86,55 +86,7 @@ struct area_hover
|
|
|
struct area_tool
|
|
|
{
|
|
|
std::vector<std::shared_ptr<area_hover>> m_clist;
|
|
|
- void on_point(int card_id,const point&pt,double speed)
|
|
|
- {
|
|
|
- std::vector<std::shared_ptr<area>> areas=area_list::instance()->get_area(pt);//找出所有的区域
|
|
|
- std::sort(areas.begin(),areas.end(),[](std::shared_ptr<area>&l,std::shared_ptr<area>&r){
|
|
|
- return l->id()<r->id();
|
|
|
- });
|
|
|
-
|
|
|
- auto c1=m_clist.begin(),ce=m_clist.end();
|
|
|
- auto a1=areas.begin() ,ae=areas.end();
|
|
|
-
|
|
|
- std::vector<std::shared_ptr<area_hover>> nlist;
|
|
|
-
|
|
|
- while (c1!=ce && a1!=ae)
|
|
|
- {
|
|
|
- if ((*c1)->id()<(*a1)->id())
|
|
|
- {
|
|
|
- do_leave_biz(card_id,*c1,speed);
|
|
|
- ++c1;
|
|
|
- }
|
|
|
- else if ((*a1)->id()<(*c1)->id())
|
|
|
- {
|
|
|
- nlist.push_back(std::make_shared<area_hover>(*a1,pt,speed));
|
|
|
- do_enter_biz(card_id,nlist.back(),speed);
|
|
|
- ++a1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- nlist.push_back(*c1);
|
|
|
- do_hover_biz(card_id,nlist.back(),speed);
|
|
|
- ++c1,++a1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- while(c1!=ce)
|
|
|
- {
|
|
|
- do_leave_biz(card_id,*c1,speed);
|
|
|
- ++c1;
|
|
|
- }
|
|
|
-
|
|
|
- while(a1!=ae)
|
|
|
- {
|
|
|
- nlist.push_back(std::make_shared<area_hover>(*a1,pt,speed));
|
|
|
- do_enter_biz(card_id,nlist.back(),speed);
|
|
|
- ++a1;
|
|
|
- }
|
|
|
-
|
|
|
- m_clist=std::move(nlist);
|
|
|
- }
|
|
|
-
|
|
|
+ void on_point(int card_id,const point&pt,double speed);
|
|
|
|
|
|
//检测是否超时
|
|
|
void on_timer(int card_id)
|
|
@@ -147,12 +99,12 @@ struct area_tool
|
|
|
a->m_area->on_hover(card_id,a,speed);
|
|
|
}
|
|
|
|
|
|
- void do_enter_biz(int card_id,std::shared_ptr<area_hover> a,double speed)
|
|
|
+ void do_enter_biz(int card_id,std::shared_ptr<area_hover>&a,double speed)
|
|
|
{
|
|
|
a->m_area->on_enter(card_id,a,speed);
|
|
|
}
|
|
|
|
|
|
- void do_leave_biz(int card_id,std::shared_ptr<area_hover> a,double speed)
|
|
|
+ void do_leave_biz(int card_id,std::shared_ptr<area_hover>&a,double speed)
|
|
|
{
|
|
|
a->m_area->on_leave(card_id,a,speed);
|
|
|
}
|