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);
    }

  • 相关阅读:
    asp.net中virtual和abstract的区别分析
    .NET中的Timer类型用法详解
    类型参数的约束(C# 编程指南)T
    SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
    jquery的$.extend和$.fn.extend作用及区别
    类型参数约束 : Controller where T : class,new()
    asp.net获取当前网址url的各种属性(文件名、参数、域名 等)的代码
    字符串一级指针的内存模型图(盲点,以前自己懵懂)
    字符串的基本操作,初始化和赋值之类的区别,和数据名是一个常量指针不可以改变和赋值(盲点众多)
    关于内存四区和指针的修改问题
  • 原文地址:https://www.cnblogs.com/barfoo/p/6293119.html
Copyright © 2011-2022 走看看