Esempio n. 1
0
Player::Player (Game *game) :
_name( "Nameless hero" ),
_level( START_LEVEL ),
_exp(0),
_initiative(0),
_selectedItem( nullptr ),
_target( nullptr ),
_game( game )
{
	_powerups[static_cast<uint8_t>(Powerups::HEALTH)] = 0;
	_powerups[static_cast<uint8_t>(Powerups::MANA)] = 0;
	_powerups[static_cast<uint8_t>(Powerups::DAMAGE)] = 0;
	for (uint8_t i = 0; i < 4; ++i) _inventory[i] = nullptr;
	Field *field = nullptr;
	while (true)
	{
		field = _game->GetBattlefield()->GetRandomField();
		if (field->HaveEnemy() || field->HaveItem() || field->HavePowerup() ) continue;
		break;
	}
	_position = field;

	CalculateStats();
	Heal();
	Recover();
	LookAround();
}
void *TapeDrive::ProcessCmd(short mt_op, daddr_t mt_count)
{
  static struct mtget otstat;           // original tape status
  int status = ioctl(fileno(file), MTIOCGET, (char *)&otstat);
  if (status < 0)
    reportErrSys("ioctl4");
  DOASSERT(status >= 0, "Cannot get tape status");

  for(int attempt = 0; attempt < 10; attempt++) {
      if (attempt > 0) {
          cout << "Sleeping 2 seconds..." << endl;
          sleep(2);
          cout << "Recovering..." << endl;
          Recover(otstat, mt_op, mt_count);
          cout << "Retrying..." << endl;
      }
      status = ProcessCmdNR(mt_op, mt_count);
      if (status >= 0)
          break;
      cout << "Tape command " << mt_op << ", count " << mt_count
           << " failed, attempt " << attempt << endl;
  }
  
  return (void *)0;
}
Esempio n. 3
0
/**
@SYMTestCaseID          SYSLIB-DBMS-CT-0637
@SYMTestCaseDesc        Streaming conversions test
@SYMTestPriority        Medium
@SYMTestActions         Test the database definition and enquiry functions 
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void Test()
	{
	test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0637 Build without transactions "));
	CreateDatabaseL();
	TUint time1,size1;
	BuildTable(KRecords,EFalse,time1,size1);
	CloseDatabaseL();
	test.Next(_L("Build with transactions"));
	CreateDatabaseL();
	TUint time2,size2;
	BuildTable(KRecords,ETrue,time2,size2);
	test.Printf(_L("Transaction performance: time %4.2f, size %4.2f\n"),TReal(time1)/TReal(time2),TReal(size1)/TReal(size2));
	test.Next(_L("Build Int index"));
	Execute(_L("create unique index int on table (int)"));
	test.Next(_L("Break index"));
	BreakIndex();
	test.Next(_L("Build Text index"));
	Execute(_L("create unique index text on table (text)"));
	test.Next(_L("Recover"));
	test (TheDatabase.IsDamaged());
	CloseDatabaseL();
	OpenDatabase();
	test (TheDatabase.IsDamaged());
	Recover();
	test.Next(_L("Drop table"));
	Execute(_L("drop table table"));
	CloseDatabaseL();
	}
Esempio n. 4
0
doublereal F77_SUB(d1mach) (integer *i)
{
switch(*i){
    case 1: return DBL_MIN;
    case 2: return DBL_MAX;
    case 3: return DBL_EPSILON/FLT_RADIX;
    case 4: return DBL_EPSILON;
    case 5: return log10(FLT_RADIX);
    default: Recover("Invalid argument to d1mach()", 0L);
    }
}
Esempio n. 5
0
void Player::LevelUp()
{
 	while (_exp >= _expMax)
 	{
 	 	_level++;
 	 	_exp -= _expMax;
		CalculateStats();
 	 	Heal();
 	 	Recover();
 	}
}
Esempio n. 6
0
int bbcp_Node::Outgoing(bbcp_Protocol *protocol)
{
   int i, retc;
   bbcp_Link *link;

// Establish the control connection first
//
   if (link = bbcp_Net.Connect(bbcp_Config.CBhost, bbcp_Config.CBport, 3))
      if ((retc = protocol->Login(link, 0)) < 0)
         {delete link; link = 0;}

// Now establish all data channels if we have a control channel
//
   if (link)
      {pthread_t tid, T_id[BBCP_MAXSTREAMS];

       // Start threads for data connections
       //
       for (i = 0; i < bbcp_Config.Streams; i++)
           {if ((retc=bbcp_Thread_Start(bbcp_Connect,(void *)protocol,&tid))<0)
               {bbcp_Emsg("Outgoing", retc, "starting connect thread");
                _exit(100);
               }
            T_id[i] = tid;
#ifdef CRAY_X1E
            usleep(1);
#endif
           }
       for (i = 0; i < bbcp_Config.Streams; i++)
           {if (!(link = (bbcp_Link *)bbcp_Thread_Wait(T_id[i]))) break;
            link->LinkNum = dlcount; data_link[dlcount++] = link;
           }
       }
   iocount = dlcount;

// Make sure we have all of the required links
//
   if (dlcount < bbcp_Config.Streams) return Recover("Connect");

// Determine what the actual window size is (only if verbose)
//
   if (bbcp_Config.Options & bbcp_BLAB) chkWsz(data_link[0]->FD());

// Initialize the buddy pipeline; a patented way of ensuring maximum parallelism
//
   if (dlcount > 1 && (bbcp_Config.Options & (bbcp_SRC|bbcp_ORDER)))
      {i = dlcount-1;
       data_link[i]->setBuddy(data_link[0]);
       while(i--) data_link[i]->setBuddy(data_link[i+1]);
       bbcp_Link::setNudge();
      }
   return 0;
}
Esempio n. 7
0
int bbcp_Node::Incomming(bbcp_Protocol *protocol)
{
    int i, retc, minport, maxport;
    bbcp_Link *link;

// Find the port number we should use for incomming connections
//
   bbcp_Net.findPort(minport, maxport);

// Set up the default ports first if we didn't find specified ones
//
   if (minport || maxport
   || ((retc = bbcp_Net.Bind(BBCP_DFLTMINPORT, BBCP_DFLTMAXPORT, 1, -1)) < 0))
   if ((retc = bbcp_Net.Bind(minport, maxport,
               bbcp_Config.bindtries, bbcp_Config.bindwait)) < 0)
      return retc;

// Report the port number we have chosen
//
   protocol->setCBPort(retc);

// Establish all of the connections
//
   while(dlcount < bbcp_Config.Streams)
       {if (!(link = bbcp_Net.Accept())) break;
        if (!(retc = protocol->Login(link, 1))) 
           {link->LinkNum = dlcount; data_link[dlcount++] = link;}
           else if (retc < 0) {delete link; break;}
       }

// Unbind the network and make sure we have all of the agreed upon links
//
   bbcp_Net.unBind();
   if (dlcount < bbcp_Config.Streams) return Recover("Accept");
   iocount = dlcount;

// Initialize the buddy pipeline; a patented way of ensuring maximum parallelism
//
   if (dlcount > 1 && (bbcp_Config.Options & (bbcp_SRC|bbcp_ORDER)))
      {i = dlcount-1;
       data_link[i]->setBuddy(data_link[0]);
       while(i--) data_link[i]->setBuddy(data_link[i+1]);
       bbcp_Link::setNudge();
      }

// Determine what the actual window size is (only if verbose)
//
   if (bbcp_Config.Options & bbcp_BLAB) chkWsz(data_link[0]->FD());
   return 0;
}
Esempio n. 8
0
int main(){
	int start,end,size;
	int m;
	GetFree();
	getchar();
    m=window();
	if(m==2) find=L;
	while(m){
		switch(m){
		case 1:	    
			SortList();  
			printf("\n空闲链表情况:\n");
			PrintList();
			printf("请输入进程需要的空闲区大小:");
			scanf("%d",&size);
			Assign(size); printf("\n按任意键继续");
			break;
		case 2:	   
			SortList();  
			printf("\n空闲链表情况:\n");
			PrintList();
			printf("请输入进程需要的空闲区大小:");
			scanf("%d",&size);
			NF_Assign(size);printf("\n按任意键继续");
			break;
		case 3:	    
			BFSortList();  
			printf("\n空闲链表情况:\n");
			PrintList();
			printf("请输入进程需要的空闲区大小:");
			scanf("%d",&size);
			Assign(size);printf("\n按任意键继续");
			break;
		case 4:	    
			printf("请输入回收区的首地址和中止地址:");
			scanf("%d %d",&start,&end);								
			Recover(start,end);
			break;	
		case 0:	    
			exit(0);
		default : 
			printf("\n\t\t输入错误,请重新输入"); getchar(); 
		}
		getchar();
		m=window();
	}
return 0;
}
Esempio n. 9
0
/**
@SYMTestCaseID          SYSLIB-DBMS-CT-0579
@SYMTestCaseDesc        Tests the database definition and enquiry functions
@SYMTestPriority        Medium
@SYMTestActions        	Executes the index and bookmark tests
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void BigTestL()
	{
	test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0579 Table "));
	CreateDatabaseL();
	BuildTable(KRecords);
	test(TheTable.Open(TheDatabase,KTableName)==KErrNone);
	TheTable.EndL();
	IterateL(TheTable.EPrevious);
	TheTable.BeginningL();
	IterateL(TheTable.ENext);
	TheTable.EndL();
	IterateL(TheTable.EPrevious);
	TheTable.Close();
	test.Next(_L("Int32 Index"));
	CDbKey *key=CDbKey::NewLC();
	key->AddL(KColumnInt);
	key->MakeUnique();
	TestIndex(KIndexInt,*key);
	test.Next(_L("Text[200] Index"));
	key->Clear();
	key->AddL(KColumnText);
	key->MakeUnique();
	TestIndex(KIndexText,*key);
	test.Next(_L("Bookmarks"));
	TestBookmark();
	test.Next(_L("Int32 Index"));
#ifndef __TOOLS2__
	TheTimer.Start(_L("drop"));
#endif
	test(TheDatabase.DropIndex(KIndexInt,KTableName)==KErrNone);
#ifndef __TOOLS2__
	TheTimer.Stop();
#endif
	key->Clear();
	key->AddL(KColumnInt);
	key->MakeUnique();
	TestIndex(KIndexInt,*key);
	CleanupStack::PopAndDestroy();
	test.Next(_L("Break & Recover"));
	BreakIndex();
	Recover();
	test.Next(_L("Drop Indexes"));
	DropIndexes();
	test.Next(_L("Delete all records"));
	DeleteTable();
	CloseDatabaseL();
	test.End();
	}
Esempio n. 10
0
//已战胜全部精英BOSS
UINT16 CCollectGas::OpenGenGasTab(PKT_CLIGS_OPEN_GEN_GAS_TAB_ACK& stAck)
{
    if(!m_poOwner->GetBuild(EBK_COLLECTGAS))
    {
        return ERR_OPEN_GEN_GAS_TAB::ID_COLLECT_GAS_UNLOCK;
    }

    Recover();
    GetDT_GEN_GAS_DATA_CLI(stAck.stGenGasInfo);

    DT_INSTANCE_ID &stDT_INSTANCE_ID = m_poOwner->GetInstance().GetMaxEliteInstanceID();
    SGasNumProp * poGasNumProp = CCollectGasPropMgr::Instance()->GetNextGenGasNumProp((UINT8)m_poOwner->GetLevel(), m_poOwner->GetDT_PLAYER_BASE_DATA().byVipLevel, stDT_INSTANCE_ID.byTownIdx, stDT_INSTANCE_ID.byInstanceIdx);
    if (NULL == poGasNumProp)
    {
        SDStrcpy(stAck.aszTipsInfo, CMsgDefMgr::Instance()->GetErrMsg("HAVE_WIN_ALL_ELITE") .c_str());
        return ERR_OPEN_GEN_GAS_TAB::ID_SUCCESS;
    }
    //获取副本信息
    SInstanceProp *poInstanceProp = CInstancePropMgr::Instance()->GetInstanceProp(EIT_ELITE, poGasNumProp->byTownIdx, poGasNumProp->byInstanceIdx);
    if (NULL == poInstanceProp)
    {
        SDStrcpy(stAck.aszTipsInfo, CMsgDefMgr::Instance()->GetErrMsg("HAVE_WIN_ALL_ELITE") .c_str());
        SYS_CRITICAL(_SDT("[%s: %d]: OpenGenGasTab configure failed!"), MSG_MARK); //配置出错,当前配置的副本在精武英雄副本中找不到

        return ERR_OPEN_GEN_GAS_TAB::ID_SUCCESS;
    }

    //CHAR	szNum[56] = {0};
    //sprintf(szNum, "%u", poGasNumProp->byValue);
    //SDStrcat(stAck.aszTipsInfo, SDGBK2UTF8("战胜精英").c_str());
    //SDStrcat(stAck.aszTipsInfo, poInstanceProp->strName.c_str());
    //SDStrcat(stAck.aszTipsInfo, SDGBK2UTF8(",每天聚魂次数增至").c_str());
    //SDStrcat(stAck.aszTipsInfo, SDGBK2UTF8(szNum).c_str());
    //SDStrcat(stAck.aszTipsInfo, SDGBK2UTF8("次").c_str());

    vector<string> vecFillMsg;
    CHAR szBuff[32] = {0};
    sprintf(szBuff, "%s", poInstanceProp->strName.c_str());
    vecFillMsg.push_back(szBuff);
    sprintf(szBuff, "%u", poGasNumProp->byValue);
    vecFillMsg.push_back(szBuff);
    SDStrncpy(stAck.aszTipsInfo, CMsgDefMgr::Instance()->GetErrMsg("OPEN_GEN_GAS_PROMPT", &vecFillMsg).c_str(), MAX_GEN_GAS_INFO_LEN - 1);

    return ERR_OPEN_GEN_GAS_TAB::ID_SUCCESS;
}
BOOL CDurableFileController::Recover(CDurableFile* pcFirst, ...)
{
	va_list			vaMarker;
	CDurableFile*	pc;
	int				iCount;

	iCount = 0;
	pc = pcFirst;

	va_start(vaMarker, pcFirst);
	while (pc != NULL)
	{
		pc->AddFile();
		iCount++;
		pc = va_arg(vaMarker, CDurableFile*);
	}
	va_end(vaMarker);

	return Recover();
}
Esempio n. 12
0
UINT16 CCollectGas::CollectGas(DT_GEN_GAS_DATA_CLI& DT_GEN_GAS_DATA_CLI)
{
    if(!m_poOwner->GetBuild(EBK_COLLECTGAS))
    {
        return ERR_COLLECT_GAS::ID_COLLECT_GAS_UNLOCK;
    }
    Recover();
    //引导阶段
    if(m_poOwner->CKGuide(EGF_GASCOLLECT))
    {
        UINT32  dwCollectGas = CCollectGasPropMgr::Instance()->GetGuidePurpleGas(m_poOwner);
        m_poOwner->AddScience(dwCollectGas, CRecordMgr::EAST_GAS );
        m_poOwner->AddGuideRecord(EGF_GASCOLLECT);
    }
    else
    {
        if(0 == m_stCollectData.byCollectState)
        {
            GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
            return ERR_COLLECT_GAS::ID_UN_GEN;
        }

        for(UINT8 byIdx = 0; byIdx < MAX_GAS_BALL_NUM; byIdx++)
        {
            DT_GAS_BALL_DATA& stDT_GAS_BALL_DATA = m_stCollectData.astGasBollInfo[byIdx];
            UINT32 dwGetGas = CCollectGasPropMgr::Instance()->GetGas(m_poOwner, stDT_GAS_BALL_DATA.byKind, stDT_GAS_BALL_DATA.byLevel);
            m_poOwner->AddScience(dwGetGas, CRecordMgr::EAST_GAS, stDT_GAS_BALL_DATA.byLevel);
        }
    }
    m_stCollectData.byCollectState = 0; //修改状态0生成
    memset(&m_stCollectData.astGasBollInfo, 0x00, sizeof(DT_GAS_BALL_DATA) * MAX_GAS_BALL_NUM);
    GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);

    m_stCollectData.wLastGoldRandomUpNum = 0;
    m_stCollectData.qwLastGoldRandomUpTime = 0;

    m_stCollectData.byLastGoldFullUpNum = 0;
    m_stCollectData.qwLastGoldFullUpTime = 0;
    return ERR_COLLECT_GAS::ID_SUCCESS;
}
Esempio n. 13
0
static void give_thing (dbref giver, dbref recipient, int key, char *what)
{
dbref	thing, loc;
char	*str, *sp;

	init_match(giver, what, TYPE_THING);
	match_possession();
	match_me();
	thing = match_result();

	switch (thing) {
	case NOTHING:
		notify(giver, "You don't have that!");
		return;
	case AMBIGUOUS:
		notify(giver, "I don't know which you mean!");
		return;
	}

	if (thing == giver) {
		notify(giver, "You can't give yourself away!");
		return;
	}

	if (((Typeof(thing) != TYPE_THING) &&
	     (Typeof(thing) != TYPE_PLAYER)) ||
	    !(Enter_ok(recipient) || controls(giver, recipient))) {
		notify(giver, "Permission denied.");
		return;
	}
	if ((Flags3(thing) & NOMOVE) && !Wizard(giver)) {
		notify(giver, "Permission denied.");
		return;
	}

	if (!could_doit(giver, thing, A_LGIVE,1)) {
		sp = str = alloc_lbuf("do_give.gfail");
		safe_str((char *)"You can't give ", str, &sp);
		safe_str(Name(thing), str, &sp);
		safe_str((char *)" away.", str, &sp);
		*sp = '\0';

		did_it(giver, thing, A_GFAIL, str, A_OGFAIL, NULL,
			A_AGFAIL, (char **)NULL, 0);
		free_lbuf(str);
		return;
	}
	if (!could_doit(thing, recipient, A_LRECEIVE,1)) {
		sp = str = alloc_lbuf("do_give.rfail");
		safe_str(Name(recipient), str, &sp);
		safe_str((char *)" doesn't want ", str, &sp);
		safe_str(Name(thing), str, &sp);
		safe_chr('.', str, &sp);
		*sp = '\0';

		did_it(giver, recipient, A_RFAIL, str, A_ORFAIL, NULL,
			A_ARFAIL, (char **)NULL, 0);
		free_lbuf(str);
		return;
	}
	loc = Location(giver);
	if ( !Good_obj(loc) || loc == NOTHING || loc == AMBIGUOUS || Recover(loc) || Going(loc) )
           loc = giver;
	if (!could_doit(giver, loc, A_LGIVETO, 1)) {
		sp = str = alloc_lbuf("do_giveto.rfail");
		safe_str((char *)"You can not give ", str, &sp);
		safe_str(Name(thing), str, &sp);
		safe_str((char *)" away at this location.", str, &sp);
		*sp = '\0';
		notify(giver, str);
		free_lbuf(str);
		return;
	}

	move_via_generic(thing, recipient, giver, 0);
	divest_object(thing);
	
	if (!(key & GIVE_QUIET)) {
		str = alloc_lbuf("do_give.thing.ok");
		strcpy(str, Name(giver));
		notify_with_cause(recipient, giver,
			unsafe_tprintf("%s gave you %s.", str, Name(thing)));
		notify(giver, "Given.");
		notify_with_cause(thing, giver,
			unsafe_tprintf("%s gave you to %s.", str, Name(recipient)));
		free_lbuf(str);
	}
	else {
		notify(giver, "Given. (quiet)");
	}
	did_it(giver, thing, A_DROP, NULL, A_ODROP, NULL, A_ADROP,
		(char **)NULL, 0);
	did_it(recipient, thing, A_SUCC, NULL, A_OSUCC, NULL, A_ASUCC,
		(char **)NULL, 0);
}
Esempio n. 14
0
int main ( int argc, char *argv[] )
{   
    int i=0;
    char middlestring[4]={0};
    char MesHex[4]={0};
    //need two array to put in the values
    //need 4 arguments -- encrypt, key, filein, fileout
    if ( argc < 4 ) 
    {
        printf( "Not enough arguments");

    } else {   

        uint32_t key = atoi(argv[2]);

        // Open the in and out files
        FILE *out;
        FILE *infile;

        if ((infile = fopen( argv[3], "r" )) == NULL) printf("ERROR: Could not open: %s\n",argv[2]);
        if ((out = fopen(argv[4], "wb")) == NULL) printf("ERROR: Could not open: %s\n",argv[3]);
 
        if (strcmp(argv[1], "encrypt") == 0) {
            uint32_t x;
            uint32_t wr;
            /* read one character at a time from file, stopping at EOF, which
               indicates the end of the file.  Note that the idiom of "assign
               to a variable, check the value" used below works because
               the assignment statement evaluates to the value assigned. */

            while  ( ( x = fgetc( infile ) ) != EOF ) {
                wr = encrypt(x, key);
                middlestring[i]=wr;
                i++;
                if (i==3) {
                  i = 0;
                }
                //putc(wr, out);
                   
            }
            PlayPermute(MesHex,middlestring);
            for(i=0;i<4;i++)
            {
               putc(MesHex[i],out); 
            }

            fclose( infile );
            fclose( out );
        } else if (strcmp(argv[1], "decrypt") == 0) {
            uint32_t x;
            uint32_t wr;
            /* read one character at a time from file, stopping at EOF, which
               indicates the end of the file.  Note that the idiom of "assign
               to a variable, check the value" used below works because
               the assignment statement evaluates to the value assigned. */

            while  ( ( x = fgetc( infile ) ) != EOF ) {
                //wr = decrypt(x, key);
                middlestring[i]=x;
                i++;
                if (i == 3) {
                  i = 0;
                }
                //putc(wr, out);
            }
            Recover(MesHex,middlestring);
            for(i=0;i<4;i++)
            {  
               wr = decrypt(MesHex[i], key);
               putc(wr,out); 
            }
            fclose( infile );
            fclose( out );
        }
    }
}
Esempio n. 15
0
UINT16 CCollectGas::GenGas(UINT8 byFlag,  DT_GEN_GAS_DATA_CLI& DT_GEN_GAS_DATA_CLI)
{
    if(!m_poOwner->GetBuild(EBK_COLLECTGAS))
    {
        return ERR_GEN_GAS_BALL::ID_COLLECT_GAS_UNLOCK;
    }
    Recover();

    //如果当前处理收集状态,直接返回成功
    if (1 == m_stCollectData.byCollectState)
    {
        GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
        return ERR_GEN_GAS_BALL::ID_SUCCESS;
    }

    if(0 == CanGenNum())
    {
        GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
        return ERR_GEN_GAS_BALL::ID_REACH_MAX_NUM;
    }

    if (0 == byFlag)
    {
        UINT32 dwCostCoin = 0;
        dwCostCoin = CLuamgr::Instance()->GetFuncCost(m_poOwner, EGCF_GENCOIN, m_stCollectData.wLastCoinGenNum, 0);

        if(m_poOwner->GetDT_PLAYER_BASE_DATA().qwCoin < dwCostCoin)
        {
            GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
            return ERR_COMMON::ID_COIN_NOT_ENOUGH;
        }
        m_poOwner->DecCoin(dwCostCoin, CRecordMgr::EDCT_GENGAS);
        m_stCollectData.wLastCoinGenNum++;
        m_stCollectData.qwLastCoinGenTime = SDTimeSecs();
		CPlayerMedal* poPlayerMedal = m_poOwner->GetPlayerMedal();
		if ( NULL != poPlayerMedal)
		{
			poPlayerMedal->CheckMedalBySmallType( EMST_GATHER_SCIENCE_GOLD);
		}
    }
    else
    {
        if(!CVipPropMgr::Instance()->CkOpenFunc(EVF_GENGAS, m_poOwner->GetDT_PLAYER_BASE_DATA().byVipLevel))
        {
            return ERR_GEN_GAS_BALL::ID_VIP_NOT_ENOUGH_UNLOCK;
        }

        UINT32 dwCostGold = 0;
        dwCostGold = CLuamgr::Instance()->GetFuncCost(m_poOwner, EGCF_GENGOLD, m_stCollectData.wLastGoldGenNum, 0);

        if(m_poOwner->GetDT_PLAYER_BASE_DATA().qwGold < dwCostGold)
        {
            GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
            return ERR_COMMON::ID_GOLD_NOT_ENOUGH;
        }
        m_poOwner->DecGold(dwCostGold, CRecordMgr::EDCT_GENGAS);
        m_stCollectData.wLastGoldGenNum++;
        m_stCollectData.qwLastGoldGenTime = SDTimeSecs();
		CPlayerMedal* poPlayerMedal = m_poOwner->GetPlayerMedal();
		if ( NULL != poPlayerMedal)
		{
			poPlayerMedal->CheckMedalBySmallType( EMST_GATHER_SCIENCE_GOLD);
		}
    }

    for(UINT8 byIdx = 0; byIdx < MAX_GAS_BALL_NUM; byIdx++)
    {
        CCollectGasPropMgr::Instance()->GenGas(m_poOwner, byFlag, m_stCollectData.astGasBollInfo[byIdx]);
    }
    m_stCollectData.byCollectState = 1; //收集状态,0生成,1收取
    GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
    return ERR_GEN_GAS_BALL::ID_SUCCESS;
}
Esempio n. 16
0
UINT16 CCollectGas::UpGasLevel(UINT8 byFullLevelFlag, DT_GEN_GAS_DATA_CLI& DT_GEN_GAS_DATA_CLI)
{
    if(!m_poOwner->GetBuild(EBK_COLLECTGAS))
    {
        return ERR_UP_GAS_BALL_LEVEL::ID_COLLECT_GAS_UNLOCK;
    }
    Recover();
    if(0 == m_stCollectData.byCollectState)
    {
        GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
        return ERR_UP_GAS_BALL_LEVEL::ID_UN_GEN;
    }

    if (m_stCollectData.byLastGoldFullUpNum > 0)
    {
        GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
        return ERR_UP_GAS_BALL_LEVEL::ID_COLLECT_GAS_FULL;
    }


    UINT32 dwCostGold = 0;
    if(byFullLevelFlag)
    {
        if(!CVipPropMgr::Instance()->CkOpenFunc(EVF_GENGASFULL, m_poOwner->GetDT_PLAYER_BASE_DATA().byVipLevel))
        {
            return ERR_UP_GAS_BALL_LEVEL::ID_VIP_NOT_ENOUGH_UNLOCK;
        }

        dwCostGold = CLuamgr::Instance()->GetFuncCost(m_poOwner, EGCF_GENUPGOLDFULL, 0);
    }
    else
    {
        UINT16 wTotalFreeCommonUpGasNum = CLuamgr::Instance()->GetTotalFreeCommonUpGasNum();
        if(m_stCollectData.wLastGoldRandomUpNum < wTotalFreeCommonUpGasNum)
        {
            dwCostGold = 0;
        }
        else
        {
            dwCostGold = CLuamgr::Instance()->GetFuncCost(m_poOwner, EGCF_GENUPGOLD, m_stCollectData.wLastGoldRandomUpNum);
        }
    }

    if(m_poOwner->GetDT_PLAYER_BASE_DATA().qwGold < dwCostGold)
    {
        GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
        return ERR_COMMON::ID_GOLD_NOT_ENOUGH;
    }

    for(UINT8 byIdx = 0; byIdx < MAX_GAS_BALL_NUM; byIdx++)
    {
        CCollectGasPropMgr::Instance()->UpGasBallLevel(m_poOwner, byFullLevelFlag, m_stCollectData.astGasBollInfo[byIdx]);
    }

    m_poOwner->DecGold(dwCostGold, CRecordMgr::EDGT_UPGASLEVEL);
    if(byFullLevelFlag)
    {
        m_stCollectData.byLastGoldFullUpNum++;
        m_stCollectData.qwLastGoldFullUpTime = SDTimeSecs();
    }
    else
    {
        m_stCollectData.wLastGoldRandomUpNum++;
        m_stCollectData.qwLastGoldRandomUpTime = SDTimeSecs();
    }

    GetDT_GEN_GAS_DATA_CLI(DT_GEN_GAS_DATA_CLI);
    return ERR_UP_GAS_BALL_LEVEL::ID_SUCCESS;
}