zoukankan      html  css  js  c++  java
  • 偷来的小程序

    //活动日期(星期)

    int week_day_limit = 0;
    for(int i=0;i<ac;i++)
    {
    week_day_limit |= 1 << (atoi(av[i])-1);
    }
    item.start.weekday = week_day_limit;
    item.end.weekday = week_day_limit;

    void GetWanfaTonggaoTime(SWanfaTime &start, SWanfaTime &tonggao, int beforeMinute)
    {
    int totalMin = start.hour * 60 + start.minute;
    if(totalMin >= beforeMinute)
    {
    tonggao.hour = (totalMin - beforeMinute) / 60;
    tonggao.minute = (totalMin - beforeMinute) % 60;
    tonggao.weekday = start.weekday;
    }
    else
    {
    tonggao.hour = (totalMin + 24 * 60 - beforeMinute) / 60;
    tonggao.minute = (totalMin + 24 * 60 - beforeMinute) % 60;
    tonggao.weekday = ((start.weekday >> 1) | ((start.weekday & 0x1) << 6));
    }
    }

    //让玩家获得距自己等级

    const int itemAward[][4] = {
    {30,851,2,5},{30,2370,2,5},{30,506,2,5},  
    {35,613,2,5},{35,614,2,5},{43,610,2,5},
    {43,611,1,5},{46,2310,2,5},{52,2251,1,5}
    };  //等级,道具id,道具数量,权重

    int r = Random(1,100);
    int sum = 0;
    for(uint8 k=0;k < sizeof(itemAward)/sizeof(itemAward[0]);k++)
    {
    if(level < itemAward[k][0])
    break;
    sum += itemAward[k][3];
    if(r <= sum)
    {
    pHots[i]->AddBangDingPackage(itemAward[k][1],itemAward[k][2]);
    char temp[64];
    snprintf(temp,sizeof(temp),LANGUAGE_TRANSFORM_531,GetItemName(itemAward[k][1]),itemAward[k][2]);
    strcat(buf,temp);
    break;
    }
    }

    //boost 绑定方法

    CNetMessage sysMsg;
    sysMsg.SetType(PRO_SYSTEM_INFO);
    sysMsg<<msg;

    CSocketServer &sock = SingletonSocket::instance();
    SingletonOnlineUser::instance().ForEachUser(boost::bind(SendNianShouInfo,&sock,&sysMsg,_1, min_level));

    void COnlineUser::ForEachUser(boost::function<void(CUser*)> f)
    {
    boost::recursive_mutex::scoped_lock lk(m_mutex);
    m_roleIdList.ForEach(boost::bind(EachUser,_1,_2,&f));
    }

    static bool EachUser(uint32,ShareUserPtr pUser,boost::function<void(CUser*)> *f)
    {
    CUser *p = pUser.get();
    if(p != NULL)
    {
    (*f)(p);
    }
    return true;
    }

    static void SendNianShouInfo(CSocketServer *pSock,CNetMessage *pMsg,CUser *pUser, int wanfa_min_level = 0)
    {
    if(pUser->GetLevel() >= wanfa_min_level)
    {
    pSock->SendMsg(pUser->GetSock(),*pMsg);
    }
    }

    pFight->SetCallback(boost::bind(&CFishManager::GrabFishFightEnd,this,_1,_2,_3));

    typedef boost::function<void(CUser*,bool,CFight*)> FightEndCallback;

    void SetCallback(FightEndCallback fun)
    {
    m_cbfun=fun;
    }

    void CFishManager::GrabFishFightEnd(CUser *pUser,bool win,CFight *pFight)

    void CFight::SpecialFightEnd()
    {
    CUser *pUser = GetUser(GROUP2_MAIN_POS);

    bool win=false;
    if(m_fightRes==1)
    win = true;
    if(m_cbfun)
    {
    m_cbfun(pUser,win,this);
    }

  • 相关阅读:
    bzoj1178/luogu3626 会议中心 (倍增+STL::set)
    suoi31 最近公共祖先2 (倍增lca)
    luogu4155/bzoj4444 国旗计划 (倍增)
    [BZOJ1864][Zjoi2006]三色二叉树
    [Luogu3070][USACO13JAN]岛游记Island Travels
    [Luogu2458][SDOI2006]保安站岗
    [BZOJ1191][HNOI2006]超级英雄Hero
    [BZOJ1050][HAOI2006]旅行
    [Luogu2973][USACO10HOL]赶小猪Driving Out the Piggi…
    [BZOJ1833][ZJOI2010]数字计数
  • 原文地址:https://www.cnblogs.com/barfoo/p/6293119.html
Copyright © 2011-2022 走看看