示例#1
0
SFight* CFightFriend::AddFightToPlayer( SUser *puser, uint32 target_id )
{
    if ( NULL == puser )
        return NULL;

    std::map< uint32, SUserFriend >::iterator iter = puser->data.friend_map.find( target_id );

    if( iter == puser->data.friend_map.end() )
        return NULL;


    SFight *psfight = theFightDC.add();
    if ( NULL == psfight )
        return NULL;

    psfight->fight_type = kFightTypeFriend;
    psfight->box_randomseed = (uint32)rand_r( thread_rand_seed() );
    psfight->fight_randomseed = (uint32)rand_r( thread_rand_seed() );

    user::SetFightId( puser, psfight->fight_id );

    psfight->ack_id = puser->guid;
    AddSoldier( psfight, puser->guid, kFightLeft );

    SUser *ptarget_user = theUserDC.find( target_id );
    if ( NULL == ptarget_user )
    {
        theFightDC.del(psfight->fight_id);
        return NULL;
    }
    psfight->def_id = target_id;
    AddSoldier( psfight, target_id, kFightRight );
    //user::SetFightId( ptarget_user, psfight->fight_id );

    //初始化seqno_map
    psfight->seqno_map[puser->guid] = 0;

    SetFightInfo( psfight );
    return psfight;
}
示例#2
0
SFight* CFightCopy::AddFightToMonster( SUser *puser, uint32 target_id )
{
    if ( NULL == puser )
        return NULL;

    //7天超时
    SFight *psfight = theFightDC.add( 86400 * 7 );
    if ( NULL == psfight )
        return NULL;

    psfight->fight_type = kFightTypeCopy;
    psfight->box_randomseed = (uint32)rand_r( thread_rand_seed() );
    psfight->fight_randomseed = (uint32)rand_r( thread_rand_seed() );

    //user::SetFightId( puser, psfight->fight_id );

    psfight->ack_id = puser->guid;
    AddSoldier( psfight, puser->guid, kFightLeft );

    CMonsterData::SData *pmonster = theMonsterExt.Find( target_id );
    if ( NULL == pmonster )
    {
        theFightDC.del( psfight->fight_id );
        return NULL;
    }

    uint32 copy_id = (target_id-1)/100+1;

    psfight->def_id = target_id;

    for( std::vector<uint32>::iterator jter = pmonster->fight_monster.begin();
        jter != pmonster->fight_monster.end();
        ++jter )
    {
        AddMonster( psfight, *jter, kFightRight );
    }

    //需要判断是不是已经打通
    SCopyLog copy_log = copy::get_copy_log( puser, copy_id );
    if ( copy_log.copy_id == 0 )
        psfight->help_monster = pmonster->help_monster;

    //初始化seqno_map
    psfight->seqno_map[puser->guid] = 0;

    SetFightInfo( psfight );
    return psfight;
}
DataEditorControl::DataEditorControl(Ui::MainWindow *ui)
{
	//设置视图模型
	mSoldierTableModule = new SoldierTableModule(this);
	mSoldierTableView = ui->soldierTableView;
	mSoldierTableView->setModel(mSoldierTableModule);

	mHorseTableModule = new HorseTableModule(this);
	mHorseTableView = ui->horseTableView;
	mHorseTableView->setModel(mHorseTableModule);

	mPWeaponTableModule = new PWeaponTableModule(this);
	mPWeaponTableView = ui->pweaponTableView;
	mPWeaponTableView->setModel(mPWeaponTableModule);

	mSWeaponTableModule = new SWeaponTableModule(this);
	mSWeaponTableView = ui->sweaponTableView;
	mSWeaponTableView->setModel(mSWeaponTableModule);

	mArmorTableModule = new ArmorTableModule(this);
	mArmorTableView = ui->armorTableView;
	mArmorTableView->setModel(mArmorTableModule);

	mShieldTableModule = new ShieldTableModule(this);
	mShieldTableView = ui->shieldTableView;
	mShieldTableView->setModel(mShieldTableModule);

	mSkillTableModule = new SkillTableModule(this);
	mSkillTableView = ui->skillTableView;
	mSkillTableView->setModel(mSkillTableModule);

	mEffectTableModule = new EffectTableModule(this);
	mEffectTableView = ui->effectTableView;
	mEffectTableView->setModel(mEffectTableModule);

	mSquadTableModule = new SquadTableModule(this);
	mSquadTableView = ui->squadTableView;
	mSquadTableView->setModel(mSquadTableModule);

	mSquadSkillTableModule = new SquadSkillTableModule(this);
	mSquadSkillTableView = ui->squadSkillTableView;
	mSquadSkillTableView->setModel(mSquadSkillTableModule);

	mStringTableModule = new StringTableModule(this);
	mStringTableView = ui->stringTableView;
	mStringTableView->setModel(mStringTableModule);

	mModBox = ui->modBox;
	mLangBox = ui->langBox;
	RefreshModList();

	//连接消息
	connect(ui->addMod,SIGNAL(clicked()),this,SLOT(AddMod()));
	connect(ui->addLang,SIGNAL(clicked()),this,SLOT(AddLang()));
	connect(ui->addSoldier,SIGNAL(clicked()),this,SLOT(AddSoldier()));
	connect(ui->delSoldier,SIGNAL(clicked()),this,SLOT(DelSoldier()));
	connect(ui->addHorse,SIGNAL(clicked()),this,SLOT(AddHorse()));
	connect(ui->delHorse,SIGNAL(clicked()),this,SLOT(DelHorse()));
	connect(ui->addPWeapon,SIGNAL(clicked()),this,SLOT(AddPWeapon()));
	connect(ui->delPWeapon,SIGNAL(clicked()),this,SLOT(DelPWeapon()));
	connect(ui->addSWeapon,SIGNAL(clicked()),this,SLOT(AddSWeapon()));
	connect(ui->delSWeapon,SIGNAL(clicked()),this,SLOT(DelSWeapon()));
	connect(ui->addArmor,SIGNAL(clicked()),this,SLOT(AddArmor()));
	connect(ui->delArmor,SIGNAL(clicked()),this,SLOT(DelArmor()));
	connect(ui->addShield,SIGNAL(clicked()),this,SLOT(AddShield()));
	connect(ui->delShield,SIGNAL(clicked()),this,SLOT(DelShield()));
	connect(ui->addSkill,SIGNAL(clicked()),this,SLOT(AddSkill()));
	connect(ui->delSkill,SIGNAL(clicked()),this,SLOT(DelSkill()));
	connect(ui->addEffect,SIGNAL(clicked()),this,SLOT(AddEffect()));
	connect(ui->delEffect,SIGNAL(clicked()),this,SLOT(DelEffect()));
	connect(ui->addSquad,SIGNAL(clicked()),this,SLOT(AddSquad()));
	connect(ui->delSquad,SIGNAL(clicked()),this,SLOT(DelSquad()));
	connect(ui->addSquadSkill,SIGNAL(clicked()),this,SLOT(AddSquadSkill()));
	connect(ui->delSquadSkill,SIGNAL(clicked()),this,SLOT(DelSquadSkill()));
	connect(ui->addString,SIGNAL(clicked()),this,SLOT(AddString()));
	connect(ui->delString,SIGNAL(clicked()),this,SLOT(DelString()));

	connect(ui->squadTableView,SIGNAL(clicked(const QModelIndex &)),this,SLOT(SelectSquad(const QModelIndex &)));
}