Exemplo n.º 1
0
void CCLITerminal::RestartTerminalSession(CLISESSION *pSession)
{
	if (pSession == NULL)
		return;

	// Callback Login
	if (m_pCLIService->m_pConstruct &&
		m_pCLIService->m_pConstruct->pfnOnLogout)
		m_pCLIService->m_pConstruct->pfnOnLogout(pSession);

	if (m_pCLIService->GetRunLevel() == RUNLEVEL_NORMAL)
	{
		pSession->bNeedUser	= TRUE;
		strcpy(pSession->szUser, "");
		strcpy(pSession->szPassword, "");
		ClearHistory(pSession);
	}

	pSession->nMode 		= CLIMODE_COMMAND;
	pSession->bLogined		= m_pCLIService->GetRunLevel() == RUNLEVEL_NORMAL ? FALSE : TRUE;
	pSession->nLoginRetry	= 0;
	pSession->nCmdLength 	= 0;
	pSession->szCommand[0]	= '\0';
	if (m_pCLIService->GetRunLevel() == RUNLEVEL_DEBUG)
	     strcpy(pSession->szPrompt, m_pCLIService->m_szDebugPrompt);
	else strcpy(pSession->szPrompt, m_pCLIService->m_szUserPrompt);

	DisplaySplash(pSession);
}
Exemplo n.º 2
0
//---------------------------------------------------------------------------
void __fastcall TCustomWinConfiguration::DefaultHistory()
{
  ClearHistory();

  std::unique_ptr<THistoryStrings> Strings;

  // Defaults for speed limits.
  Strings.reset(new THistoryStrings());
  // This is language-specifics, what has to be dealt with when changing language.
  // There's ad-hoc workaround in CopySpeedLimits.
  // If we need to solve this for another history, we should introduce
  // a generic solution, like language-specific history ("SpeedLimitEN")
  Strings->Add(LoadStr(SPEED_UNLIMITED));
  unsigned long Speed = 8192;
  while (Speed >= 8)
  {
    Strings->Add(IntToStr(int(Speed)));
    Speed = Speed / 2;
  }
  FHistory->AddObject(L"SpeedLimit", Strings.release());

  Strings.reset(new THistoryStrings());
  Strings->Add(FormatCommand(DefaultPuttyPath, L""));
  Strings->Add(FormatCommand(DefaultPuttyPath, L"-t -m \"%TEMP%\\putty.txt\" !`cmd.exe /c echo cd '!/' ; /bin/bash -login > \"%TEMP%\\putty.txt\"`"));
  Strings->Add(KittyExecutable);
  Strings->Add(FORMAT(L"%s -cmd \"cd '!/'\" !U@!@ -P !# -title \"!N\"", (KittyExecutable)));
  FHistory->AddObject(L"PuttyPath", Strings.release());
}
CReferencePolicyPlugin::~CReferencePolicyPlugin()
    {
    OstTraceFunctionEntry0( REF_CREFERENCEPOLICYPLUGIN_CREFERENCEPOLICYPLUGIN_DES_ENTRY );
    
    Cancel();
    ClearHistory(); // Remove all buffered history record.
    delete iRepository;
    delete iNotificationMan;
    iFs.Close();
    OstTraceFunctionExit0( REF_CREFERENCEPOLICYPLUGIN_CREFERENCEPOLICYPLUGIN_DES_EXIT );
    }
Exemplo n.º 4
0
void CScreenMgr::ExitScreens()
{
	// Tell the old screen that it is losing focus
	if (m_pCurrentScreen)
	{
        m_pCurrentScreen->OnFocus(LTFALSE);
	}

	//clear our screen history (no longer relevant)
	ClearHistory();
	
}
Exemplo n.º 5
0
bool
PokerHandHistory::Load(LongBinary* pBin){
	if( !pBin || pBin->GetBinarySize() == 0 )
		return false;
	void* lpBuffer = pBin->LockMemory();
	if( !lpBuffer ) return false;
	GrowableMemory mem(0, 0, false);
	mem.SetReadonlyBuffer((BYTE*)lpBuffer, (int)pBin->GetBinarySize());
	// Clear history info.
	ClearHistory();
	// Deserialize.
	bool bRet = (Deserialize(&mem) == TRUE);
	pBin->UnlockMemory();
	return bRet;
	}
Exemplo n.º 6
0
bool
PokerHandHistory::Load(const std::string sFile){
	bool	bRet	= false;	
	BYTE*	lpData	= NULL;
	int		nSize	= 0;
	if( !Path::ReadFileContent(sFile, lpData, nSize) )
		return bRet;

	GrowableMemory mem(0, 0, false);
	mem.SetReadonlyBuffer	(lpData, nSize);
	mem.SetUsedBufferSize	(nSize);
	// Clear history info.
	ClearHistory();
	// Deserialize.
	bRet = (Deserialize(&mem) == TRUE);
	delete [] lpData;
	return bRet;
	}
Exemplo n.º 7
0
//-----------------------------------------------------------------------------
// Purpose: Called once per frame after all entities have had a chance to think
//-----------------------------------------------------------------------------
void CLagCompensationManager::FrameUpdatePostEntityThink()
{
	if ( m_bNeedsAIUpdate )
		UpdateAIIndexes(); // only bother if we haven't had one yet
	else // setting this true here ensures that the update happens at the start of the next frame
		m_bNeedsAIUpdate = true;

	if ( (gpGlobals->maxClients <= 1) || !sv_unlag.GetBool() )
	{
		ClearHistory();
		return;
	}
	
	m_flTeleportDistanceSqr = sv_lagcompensation_teleport_dist.GetFloat() * sv_lagcompensation_teleport_dist.GetFloat();

	VPROF_BUDGET( "FrameUpdatePostEntityThink", "CLagCompensationManager" );

	// remove all records before that time:
	int flDeadtime = gpGlobals->curtime - sv_maxunlag.GetFloat();

	// Iterate all active players
	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );

		CUtlFixedLinkedList< LagRecord > *track = &m_PlayerTrack[i-1];

		if ( !pPlayer )
		{
			if ( track->Count() > 0 )
			{
				track->RemoveAll();
			}

			continue;
		}

		Assert( track->Count() < 1000 ); // insanity check

		// remove tail records that are too old
		int tailIndex = track->Tail();
		while ( track->IsValidIndex( tailIndex ) )
		{
			LagRecord &tail = track->Element( tailIndex );

			// if tail is within limits, stop
			if ( tail.m_flSimulationTime >= flDeadtime )
				break;
			
			// remove tail, get new tail
			track->Remove( tailIndex );
			tailIndex = track->Tail();
		}

		// check if head has same simulation time
		if ( track->Count() > 0 )
		{
			LagRecord &head = track->Element( track->Head() );

			// check if player changed simulation time since last time updated
			if ( head.m_flSimulationTime >= pPlayer->GetSimulationTime() )
				continue; // don't add new entry for same or older time
		}

		// add new record to player track
		LagRecord &record = track->Element( track->AddToHead() );

		record.m_fFlags = 0;
		if ( pPlayer->IsAlive() )
		{
			record.m_fFlags |= LC_ALIVE;
		}

		record.m_flSimulationTime	= pPlayer->GetSimulationTime();
		record.m_vecAngles			= pPlayer->GetLocalAngles();
		record.m_vecOrigin			= pPlayer->GetLocalOrigin();
		record.m_vecMinsPreScaled	= pPlayer->CollisionProp()->OBBMinsPreScaled();
		record.m_vecMaxsPreScaled	= pPlayer->CollisionProp()->OBBMaxsPreScaled();

		int layerCount = pPlayer->GetNumAnimOverlays();
		for( int layerIndex = 0; layerIndex < layerCount; ++layerIndex )
		{
			CAnimationLayer *currentLayer = pPlayer->GetAnimOverlay(layerIndex);
			if( currentLayer )
			{
				record.m_layerRecords[layerIndex].m_cycle = currentLayer->m_flCycle;
				record.m_layerRecords[layerIndex].m_order = currentLayer->m_nOrder;
				record.m_layerRecords[layerIndex].m_sequence = currentLayer->m_nSequence;
				record.m_layerRecords[layerIndex].m_weight = currentLayer->m_flWeight;
			}
		}
		record.m_masterSequence = pPlayer->GetSequence();
		record.m_masterCycle = pPlayer->GetCycle();
	}

	// Iterate all active NPCs
	CAI_BaseNPC **ppAIs = g_AI_Manager.AccessAIs();
	int nAIs = g_AI_Manager.NumAIs();

	for ( int i = 0; i < nAIs; i++ )
	{
		CAI_BaseNPC *pNPC = ppAIs[i];
		CUtlFixedLinkedList< LagRecord > *track = &m_EntityTrack[i];

		if ( !pNPC )
		{
			track->RemoveAll();
			continue;
		}

		Assert( track->Count() < 1000 ); // insanity check

		// remove tail records that are too old
		int tailIndex = track->Tail();
		while ( track->IsValidIndex( tailIndex ) )
		{
			LagRecord &tail = track->Element( tailIndex );

			// if tail is within limits, stop
			if ( tail.m_flSimulationTime >= flDeadtime )
				break;
			
			// remove tail, get new tail
			track->Remove( tailIndex );
			tailIndex = track->Tail();
		}

		// check if head has same simulation time
		if ( track->Count() > 0 )
		{
			LagRecord &head = track->Element( track->Head() );

			// check if entity changed simulation time since last time updated
			if ( &head && head.m_flSimulationTime >= pNPC->GetSimulationTime() )
				continue; // don't add new entry for same or older time

			// Simulation Time is set when an entity moves or rotates ...
			// this error occurs when whatever entity it is that breaks it moves or rotates then, presumably?
		}

		// add new record to track
		LagRecord &record = track->Element( track->AddToHead() );

		record.m_fFlags = 0;
		if ( pNPC->IsAlive() )
		{
			record.m_fFlags |= LC_ALIVE;
		}

		record.m_flSimulationTime	= pNPC->GetSimulationTime();
		record.m_vecAngles			= pNPC->GetLocalAngles();
		record.m_vecOrigin			= pNPC->GetLocalOrigin();
		record.m_vecMaxs			= pNPC->WorldAlignMaxs();
		record.m_vecMins			= pNPC->WorldAlignMins();

		int layerCount = pNPC->GetNumAnimOverlays();
		for( int layerIndex = 0; layerIndex < layerCount; ++layerIndex )
		{
			CAnimationLayer *currentLayer = pNPC->GetAnimOverlay(layerIndex);
			if( currentLayer )
			{
				record.m_layerRecords[layerIndex].m_cycle = currentLayer->m_flCycle;
				record.m_layerRecords[layerIndex].m_order = currentLayer->m_nOrder;
				record.m_layerRecords[layerIndex].m_sequence = currentLayer->m_nSequence;
				record.m_layerRecords[layerIndex].m_weight = currentLayer->m_flWeight;
			}
		}
		record.m_masterSequence = pNPC->GetSequence();
		record.m_masterCycle = pNPC->GetCycle();
	}

    //Clear the current player.
	m_pCurrentPlayer = NULL;
}
Exemplo n.º 8
0
	virtual void LevelShutdownPostEntity()
	{
		ClearHistory();
	}
Exemplo n.º 9
0
	// IServerSystem stuff
	virtual void Shutdown()
	{
		ClearHistory();
	}
Exemplo n.º 10
0
// 主搜索例程
void SearchMain(int nDepth) {
  int i, vl, vlLast, nDraw;
  int nCurrTimer, nLimitTimer, nLimitNodes;
  bool bUnique;
#ifndef CCHESS_A3800
  int nBookMoves;
  uint32_t dwMoveStr;
  BookStruct bks[MAX_GEN_MOVES];
#endif
  // 主搜索例程包括以下几个步骤:

  // 1. 遇到和棋则直接返回
  if (Search.pos.IsDraw() || Search.pos.RepStatus(3) > 0) {
#ifndef CCHESS_A3800
    printf("nobestmove\n");
    fflush(stdout);
#endif
    return;    
  }

#ifndef CCHESS_A3800
  // 2. 从开局库中搜索着法
  if (Search.bUseBook) {
    // a. 获取开局库中的所有走法
    nBookMoves = GetBookMoves(Search.pos, Search.szBookFile, bks);
    if (nBookMoves > 0) {
      vl = 0;
      for (i = 0; i < nBookMoves; i ++) {
        vl += bks[i].wvl;
        dwMoveStr = MOVE_COORD(bks[i].wmv);
        printf("info depth 0 score %d pv %.4s\n", bks[i].wvl, (const char *) &dwMoveStr);
        fflush(stdout);
      }
      // b. 根据权重随机选择一个走法
      vl = Search.rc4Random.NextLong() % (uint32_t) vl;
      for (i = 0; i < nBookMoves; i ++) {
        vl -= bks[i].wvl;
        if (vl < 0) {
          break;
        }
      }
      __ASSERT(vl < 0);
      __ASSERT(i < nBookMoves);
      // c. 如果开局库中的着法够成循环局面,那么不走这个着法
      Search.pos.MakeMove(bks[i].wmv);
      if (Search.pos.RepStatus(3) == 0) {
        dwMoveStr = MOVE_COORD(bks[i].wmv);
        printf("bestmove %.4s", (const char *) &dwMoveStr);
        // d. 给出后台思考的着法(开局库中第一个即权重最大的后续着法)
        nBookMoves = GetBookMoves(Search.pos, Search.szBookFile, bks);
        Search.pos.UndoMakeMove();
        if (nBookMoves > 0) {
          dwMoveStr = MOVE_COORD(bks[0].wmv);
          printf(" ponder %.4s", (const char *) &dwMoveStr);
        }
        printf("\n");
        fflush(stdout);
        return;
      }
      Search.pos.UndoMakeMove();
    }
  }
#endif

  // 3. 如果深度为零则返回静态搜索值
  if (nDepth == 0) {
#ifndef CCHESS_A3800
    printf("info depth 0 score %d\n", SearchQuiesc(Search.pos, -MATE_VALUE, MATE_VALUE));
    fflush(stdout);
    printf("nobestmove\n");
    fflush(stdout);
#endif
    return;
  }

  // 4. 生成根结点的每个着法
  Search2.MoveSort.InitRoot(Search.pos, Search.nBanMoves, Search.wmvBanList);

  // 5. 初始化时间和计数器
  Search2.bStop = Search2.bPonderStop = Search2.bPopPv = Search2.bPopCurrMove = false;
  Search2.nPopDepth = Search2.vlPopValue = 0;
  Search2.nAllNodes = Search2.nMainNodes = Search2.nUnchanged = 0;
  Search2.wmvPvLine[0] = 0;
  ClearKiller(Search2.wmvKiller);
  ClearHistory();
  ClearHash();
  // 由于 ClearHash() 需要消耗一定时间,所以计时从这以后开始比较合理
  Search2.llTime = GetTime();
  vlLast = 0;
  // 如果走了10回合无用着法,那么允许主动提和,以后每隔8回合提和一次
  nDraw = -Search.pos.LastMove().CptDrw;
  if (nDraw > 5 && ((nDraw - 4) / 2) % 8 == 0) {
    Search.bDraw = true;
  }
  bUnique = false;
  nCurrTimer = 0;

  // 6. 做迭代加深搜索
  for (i = 1; i <= nDepth; i ++) {
    // 需要输出主要变例时,第一个"info depth n"是不输出的
#ifndef CCHESS_A3800
    if (Search2.bPopPv || Search.bDebug) {
      printf("info depth %d\n", i);
      fflush(stdout);
    }

    // 7. 根据搜索的时间决定,是否需要输出主要变例和当前思考的着法
    Search2.bPopPv = (nCurrTimer > 300);
    Search2.bPopCurrMove = (nCurrTimer > 3000);
#endif

    // 8. 搜索根结点
    vl = SearchRoot(i);
    if (Search2.bStop) {
      if (vl > -MATE_VALUE) {
        vlLast = vl; // 跳出后,vlLast会用来判断认输或投降,所以需要给定最近一个值
      }
      break; // 没有跳出,则"vl"是可靠值
    }

    nCurrTimer = (int) (GetTime() - Search2.llTime);
    // 9. 如果搜索时间超过适当时限,则终止搜索
    if (Search.nGoMode == GO_MODE_TIMER) {
      // a. 如果没有使用空着裁剪,那么适当时限减半(因为分枝因子加倍了)
      nLimitTimer = (Search.bNullMove ? Search.nProperTimer : Search.nProperTimer / 2);
      // b. 如果当前搜索值没有落后前一层很多,那么适当时限减半
      nLimitTimer = (vl + DROPDOWN_VALUE >= vlLast ? nLimitTimer / 2 : nLimitTimer);
      // c. 如果最佳着法连续多层没有变化,那么适当时限减半
      nLimitTimer = (Search2.nUnchanged >= UNCHANGED_DEPTH ? nLimitTimer / 2 : nLimitTimer);
      if (nCurrTimer > nLimitTimer) {
        if (Search.bPonder) {
          Search2.bPonderStop = true; // 如果处于后台思考模式,那么只是在后台思考命中后立即中止搜索。
        } else {
          vlLast = vl;
          break; // 不管是否跳出,"vlLast"都已更新
        }
      }
    } else if (Search.nGoMode == GO_MODE_NODES) {
      // nLimitNodes的计算方法与nLimitTimer是一样的
      nLimitNodes = (Search.bNullMove ? Search.nNodes : Search.nNodes / 2);
      nLimitNodes = (vl + DROPDOWN_VALUE >= vlLast ? nLimitNodes / 2 : nLimitNodes);
      nLimitNodes = (Search2.nUnchanged >= UNCHANGED_DEPTH ? nLimitNodes / 2 : nLimitNodes);
      // GO_MODE_NODES下是不延长后台思考时间的
      if (Search2.nAllNodes > nLimitNodes) {
        vlLast = vl;
        break;
      }
    }
    vlLast = vl;

    // 10. 搜索到杀棋则终止搜索
    if (vlLast > WIN_VALUE || vlLast < -WIN_VALUE) {
      break;
    }

    // 11. 是唯一着法,则终止搜索
    if (SearchUnique(1 - WIN_VALUE, i)) {
      bUnique = true;
      break;
    }
  }

#ifdef CCHESS_A3800
  Search.mvResult = Search2.wmvPvLine[0];
#else
  // 12. 输出最佳着法及其最佳应对(作为后台思考的猜测着法)
  if (Search2.wmvPvLine[0] != 0) {
    PopPvLine();
    dwMoveStr = MOVE_COORD(Search2.wmvPvLine[0]);
    printf("bestmove %.4s", (const char *) &dwMoveStr);
    if (Search2.wmvPvLine[1] != 0) {
      dwMoveStr = MOVE_COORD(Search2.wmvPvLine[1]);
      printf(" ponder %.4s", (const char *) &dwMoveStr);
    }

    // 13. 判断是否认输或提和,但是经过唯一着法检验的不适合认输或提和(因为搜索深度不够)
    if (!bUnique) {
      if (vlLast > -WIN_VALUE && vlLast < -RESIGN_VALUE) {
        printf(" resign");
      } else if (Search.bDraw && !Search.pos.NullSafe() && vlLast < DRAW_OFFER_VALUE * 2) {
        printf(" draw");
      }
    }
  } else {
    printf("nobestmove");
  }
  printf("\n");
  fflush(stdout);
#endif
}
Exemplo n.º 11
0
//---------------------------------------------------------------------------
__fastcall TCustomWinConfiguration::~TCustomWinConfiguration()
{
  ClearHistory();
  delete FHistory;
  delete FEmptyHistory;
}
Exemplo n.º 12
0
PokerHandHistory::PokerHandHistory(){
	ClearHistory();
	}
Exemplo n.º 13
0
void
PokerHandHistory::StartHand(PokerTableInfo* pInfo, __int64 nHandId, int nRakePercent, int nHandStartSec, int nRoundStartSec){
	ClearHistory(); // Clear previous history info.

	m_nHandId				= nHandId;
	m_nTableId				= pInfo->m_nTableId;
	m_nTournamentId			= pInfo->m_nTournamentId;
	m_sTableName			= pInfo->m_sTableName;
	m_cGameType				= (BYTE)pInfo->m_cGameTypeId;
	m_shSubType				= (short)pInfo->m_shSubTypeId;
	m_cMaxSeatCt			= (char)pInfo->m_cMaxPlayersCt;
	m_cDealer				= pInfo->m_cDealerSeat;
	m_cSmallBlind			= pInfo->m_cSBSeat;
	m_cBigBlind				= pInfo->m_cBBSeat;
	m_cRakePercent			= (char)nRakePercent;
	m_cCurrencyId			= pInfo->m_cCurrencyId;

	m_cHandStartSec			= (char)nHandStartSec;
	m_cHandFinishStartSec	= 0;
	m_cRoundStartSec		= (char)nRoundStartSec;

	m_nSmallBlindAmount		= pInfo->m_nSmallBlindAmount;
	m_nBigBlindAmount		= pInfo->m_nBigBlindAmount;
	m_nAnteAmount			= pInfo->m_nAnteAmount;

	m_cTableCard1			= -1; // Hidden card
	m_cTableCard2			= -1;
	m_cTableCard3			= -1;
	m_cTableCard4			= -1;
	m_cTableCard5			= -1;

	// Copy seat info list. {{
	int nLoop	= 0, nCt	= pInfo->m_seats.GetCount();
	while( nLoop < nCt ){
		PokerTableSeatInfo* pSeatInfo = pInfo->m_seats.GetAt(nLoop);
		if( !pSeatInfo ){
			m_listSeats.Add(NULL);
			nLoop ++;
			continue;
			}

		// Copy seat info.
		PokerTableSeatInfo* pSeatInfoCopy = new PokerTableSeatInfo();
		pSeatInfo->Copy(pSeatInfoCopy);
		pSeatInfoCopy->SetSession(NULL);

#ifdef _SERVER
		
#else
		pSeatInfoCopy->SetCard1(pSeatInfo->GetCard1());
		pSeatInfoCopy->SetCard2(pSeatInfo->GetCard2());
		pSeatInfoCopy->SetCard3(pSeatInfo->GetCard3());
		pSeatInfoCopy->SetCard4(pSeatInfo->GetCard4());
#endif
		pSeatInfoCopy->SetBalance	(pSeatInfoCopy->GetBalance() + pSeatInfoCopy->GetPotAmount());
		pSeatInfoCopy->SetPotAmount	(0);
		pSeatInfoCopy->SetTotalPot	(0);
		m_listSeats.Add(pSeatInfoCopy);
		nLoop ++;
		}
	// }}
	}
//-----------------------------------------------------------------------------
// Purpose: Called once per frame after all entities have had a chance to think
//-----------------------------------------------------------------------------
void CLagCompensationManager::FrameUpdatePostEntityThink()
{
	if ( (gpGlobals->maxClients <= 1) || !sv_unlag.GetBool() )
	{
		ClearHistory();
		return;
	}
	
	m_flTeleportDistanceSqr = sv_lagcompensation_teleport_dist.GetFloat() * sv_lagcompensation_teleport_dist.GetFloat();

	VPROF_BUDGET( "FrameUpdatePostEntityThink", "CLagCompensationManager" );

	// remove all records before that time:
	int flDeadtime = gpGlobals->curtime - sv_maxunlag.GetFloat();

	// Iterate all active players
	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );

		CUtlFixedLinkedList< LagRecord > *track = &m_PlayerTrack[i-1];

		if ( !pPlayer )
		{
			if ( track->Count() > 0 )
			{
				track->RemoveAll();
			}

			continue;
		}

		Assert( track->Count() < 1000 ); // insanity check

		// remove tail records that are too old
		int tailIndex = track->Tail();
		while ( track->IsValidIndex( tailIndex ) )
		{
			LagRecord &tail = track->Element( tailIndex );

			// if tail is within limits, stop
			if ( tail.m_flSimulationTime >= flDeadtime )
				break;
			
			// remove tail, get new tail
			track->Remove( tailIndex );
			tailIndex = track->Tail();
		}

		// check if head has same simulation time
		if ( track->Count() > 0 )
		{
			LagRecord &head = track->Element( track->Head() );

			// check if player changed simulation time since last time updated
			if ( head.m_flSimulationTime >= pPlayer->GetSimulationTime() )
				continue; // don't add new entry for same or older time
		}

		// add new record to player track
		LagRecord &record = track->Element( track->AddToHead() );

		record.m_fFlags = 0;
		if ( pPlayer->IsAlive() )
		{
			record.m_fFlags |= LC_ALIVE;
		}

		record.m_flSimulationTime	= pPlayer->GetSimulationTime();
		record.m_vecAngles			= pPlayer->GetLocalAngles();
		record.m_vecOrigin			= pPlayer->GetLocalOrigin();
		record.m_vecMinsPreScaled	= pPlayer->CollisionProp()->OBBMinsPreScaled();
		record.m_vecMaxsPreScaled	= pPlayer->CollisionProp()->OBBMaxsPreScaled();

		int layerCount = pPlayer->GetNumAnimOverlays();
		for( int layerIndex = 0; layerIndex < layerCount; ++layerIndex )
		{
			CAnimationLayer *currentLayer = pPlayer->GetAnimOverlay(layerIndex);
			if( currentLayer )
			{
				record.m_layerRecords[layerIndex].m_cycle = currentLayer->m_flCycle;
				record.m_layerRecords[layerIndex].m_order = currentLayer->m_nOrder;
				record.m_layerRecords[layerIndex].m_sequence = currentLayer->m_nSequence;
				record.m_layerRecords[layerIndex].m_weight = currentLayer->m_flWeight;
			}
		}
		record.m_masterSequence = pPlayer->GetSequence();
		record.m_masterCycle = pPlayer->GetCycle();
	}

	//Clear the current player.
	m_pCurrentPlayer = NULL;
}
Exemplo n.º 15
0
LRESULT CALLBACK WindowProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	const int borderedge = 0; //  8;
	const int topspace = 0;

	static HWND hwndScintilla = 0;
	HWND hWnd = 0;
	char *szBuffer = 0;
	RECT rect;

	static UINT_PTR tid = 0;

	switch (message)
	{
	case WM_INITDIALOG:
	case WM_CREATE:

		exitpending = false;

		::GetClientRect(hwndDlg, &rect);

		{
			HMENU hMenu = (HMENU)::LoadMenu(ghModule, MAKEINTRESOURCE(IDR_CONSOLEMENU));
			if (hMenu != INVALID_HANDLE_VALUE){
				::SetMenu(hwndDlg, hMenu);

				DWORD dw;
				if (CRegistryUtils::GetRegDWORD(HKEY_CURRENT_USER, &dw, REGISTRY_KEY, REGISTRY_VALUE_CONSOLE_ON_TOP) && dw)
				{
					CheckMenuItem(
						hMenu,
						ID_CONSOLE_ALWAYSONTOP ,
						MF_CHECKED
						);
				}
			}
		}


		hwndScintilla = CreateWindowExA(0,
			"Scintilla", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPCHILDREN,
			borderedge,
			borderedge + topspace,
			rect.right - 2 * borderedge,
			rect.bottom - 2 * borderedge - topspace,
			hwndDlg, 0, ghModule, NULL);

		if (hwndScintilla)
		{

			lpfnEditWndProc = (WNDPROC)SetWindowLongPtr(hwndScintilla, GWLP_WNDPROC, (LONG_PTR)SubClassProc);
			::SetFocus(hwndScintilla);

			fn = (sptr_t(__cdecl *)(sptr_t*, int, uptr_t, sptr_t))SendMessage(hwndScintilla, SCI_GETDIRECTFUNCTION, 0, 0);
			ptr = (sptr_t*)SendMessage(hwndScintilla, SCI_GETDIRECTPOINTER, 0, 0);

			char buffer[64];
			DWORD dw;

			fn(ptr, SCI_SETCODEPAGE, SC_CP_UTF8, 0);
			SetConsoleDefaults();
			
			fn(ptr, SCI_SETMARGINWIDTHN, 1, 0);

			std::list< std::string > loglist;
			getLogText(loglist);
			for (std::list< std::string >::iterator iter = loglist.begin(); iter != loglist.end(); iter++)
			{
				if (!strncmp(iter->c_str(), DEFAULT_PROMPT, 2) || !strncmp(iter->c_str(), CONTINUATION_PROMPT, 2))
				{
					AppendLog(iter->c_str(), 0, 0);
				}
				else AppendLog(iter->c_str(), 1, 0);
			}
			Prompt();

			//if (!wlInit) 
			initWordList();

			tid = ::SetTimer(hwndDlg, TIMERID_FLUSHBUFFER, 1000, TimerProc);

		}
		else
		{
			DWORD dwErr = ::GetLastError();
			char sz[64];
			sprintf_s(sz, 64, "FAILED: 0x%x", dwErr);
			OutputDebugStringA(sz);
			::MessageBoxA(0, sz, "ERR", MB_OK);
			EndDialog(hwndDlg, IDCANCEL);
			return TRUE;
		}
		hWndConsole = hwndDlg;

		if (rectConsole.right == rectConsole.left)
		{
			::SetWindowPos(hwndDlg, HWND_TOP, 0, 0, 600, 400, SWP_NOZORDER);
		}
		else
		{
			::SetWindowPos(hwndDlg, HWND_TOP, rectConsole.left, rectConsole.top,
				rectConsole.right - rectConsole.left, rectConsole.bottom - rectConsole.top,
				SWP_NOZORDER);
		}

		break;

	case WM_SIZE:
	case WM_WINDOWPOSCHANGED:
	case WM_SIZING:
		::GetClientRect(hwndDlg, &rect);
		::SetWindowPos(hwndScintilla, HWND_TOP,
			borderedge,
			borderedge + topspace,
			rect.right - 2 * borderedge,
			rect.bottom - 2 * borderedge - topspace,
			SWP_NOMOVE | SWP_NOZORDER | SWP_DEFERERASE);
		if ( message == WM_SIZE ) UpdateConsoleWidth();
		break;

	case WM_ERASEBKGND:
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->code)
		{
		case SCN_MODIFIED: // what am I trapping this for? // A: was thinking about handling PASTE
		{
			// SCNotification *scn = (SCNotification*)lParam;
			// DebugOut("Modified: 0x%x\n", scn->modificationType);
		}

		case SCN_CHARADDED:
		{
			SCNotification *scn = (SCNotification*)lParam;
			// DebugOut("CA: %x\n", scn->ch);

			// I think because I switched to utf-8 I'm gettings
			// double notifications

			if (scn->ch) testAutocomplete();
		}
			break;
		}
		break;

	case WM_SETFOCUS:
		::SetFocus(hwndScintilla);
		break;

	case WM_APPEND_LOG:
		AppendLog((const char*)lParam);
		break;

	case WM_DESTROY:
		::GetWindowRect(hwndDlg, &rectConsole);
		if (tid)
		{
			::KillTimer(hwndDlg, tid);
			tid = 0;
		}
		hWndConsole = 0;
		::PostQuitMessage(0);
		break;

	case WM_CALL_COMPLETE:
		CallComplete((PARSE_STATUS_2)wParam, lParam);
		break;

	case WM_COMMAND:

		switch (LOWORD(wParam))
		{
		case WM_CLEAR_BUFFER:
		case ID_CONSOLE_CLEARHISTORY:
			ClearHistory();
			break;

		case ID_CONSOLE_INSTALLPACKAGES:
			SafeCall(SCC_INSTALLPACKAGES, 0, 0);
			break;

		case ID_CONSOLE_HOMEDIRECTORY:
			BERT_HomeDirectory();
			break;

		case ID_CONSOLE_RELOADSTARTUPFILE:
			SafeCall(SCC_RELOAD_STARTUP, 0, 0);
			break;

		case WM_REBUILD_WORDLISTS:
			initWordList();
			break;

		case ID_CONSOLE_CONSOLEOPTIONS:
			ConsoleOptions(hwndDlg);
			break;

		case ID_CONSOLE_ALWAYSONTOP:
			ToggleOnTop(hwndDlg);
			reopenWindow = true;
			::SetFocus(hWndExcel);
			ShowWindow(hwndDlg, SW_HIDE);
			::PostMessage(hwndDlg, WM_DESTROY, 0, 0);
			break;

		// this message is used in case the close console command
		// is called interactively; in that event we will be in the middle
		// of a COM call and we don't want to break here.  wait until the
		// call is complete.  if it's called some other way (such as from
		// excel, which it should not be), then you can close.
		case WM_CLOSE_CONSOLE_ASYNC:
			if (inputlock) {
				exitpending = true;
				break;
			}

		case ID_CONSOLE_CLOSECONSOLE:
		case WM_CLOSE_CONSOLE:
		case IDOK:
		case IDCANCEL:
			::GetWindowRect(hwndDlg, &rectConsole);
			if (tid)
			{
				::KillTimer(hwndDlg, tid);
				tid = 0;
			}
			EndDialog(hwndDlg, wParam);
			::CloseWindow(hwndDlg);
			hWndConsole = 0;
			::PostQuitMessage(0);
			return TRUE;


		}
		break;
	}

	return DefWindowProc(hwndDlg, message, wParam, lParam);

	return FALSE;
}