CDWordArray *CGhostTextBuffer:: /* virtual override */ CopyRevisionNumbers(int nStartLine, int nEndLine) const { CDWordArray *paSavedRevisionNumbers = CCrystalTextBuffer::CopyRevisionNumbers(nStartLine, nEndLine); for (int nLine = nEndLine; nLine >= nStartLine; --nLine) { if ((GetLineFlags(nLine) & LF_GHOST) != 0) paSavedRevisionNumbers->RemoveAt(nLine - nStartLine); } if ((GetLineFlags(nEndLine) & LF_GHOST) != 0) { for (int nLine = nEndLine + 1; nLine < GetLineCount(); ++nLine) if ((GetLineFlags(nLine) & LF_GHOST) == 0) { paSavedRevisionNumbers->Add(GetLineFlags(nLine)); break; } } return paSavedRevisionNumbers; }
void CCLLKDlg::StartNewGame(void) { CTime t=CTime::GetCurrentTime(); tGameTime=t; strTiShi1="系统时间:"+t.Format("%H:%M:%S"); m_StatusBar.SetText(strTiShi1,2,0); strTiShi2.Format(" 该局时间:00:00:00"); m_StatusBar.SetText(strTiShi2,1,0); strTiShi3.Format("当前游戏:%d行%d列%d种方块",m_nRow-2,m_nCol-2,m_Kind); m_StatusBar.SetText(strTiShi3,0,0); delete[] m_map; m_map=new int[m_nCol*m_nRow]; for (int iNum=0;iNum<(m_nCol*m_nRow);iNum++) { m_map[iNum]=BLANK_STATE; } srand(time(NULL)); CDWordArray tmpMap; for (int i=0;i<(m_nRow-2)*(m_nCol-2)/2;i++) { int x=rand()%m_Kind; tmpMap.Add(x); tmpMap.Add(x); } for (int i=1;i<(m_nCol-1);i++) { for (int j=1;j<(m_nRow-1);j++) { INT_PTR nIndex=(int(rand()*0.1+rand()*0.01+rand()))%tmpMap.GetSize(); m_map[i+j*m_nCol]=tmpMap.GetAt(nIndex); tmpMap.RemoveAt(nIndex); } } Invalidate(false); }