示例#1
0
int EBuffer::BlockUnmark() {
    EPoint Null(-1,-1);

    SetBB(BE);
    SetBE(Null);
    SetBB(Null);
    AutoExtend = 0;
    return 1;
}
示例#2
0
int EBuffer::BlockBegin() {
    EPoint X;

    X.Row = VToR(CP.Row);
    X.Col = CP.Col;
    CheckBlock();
    SetBB(X);
    return 1;
}
示例#3
0
int EBuffer::BlockExtendEnd() {
    EPoint T, B, E;

    CheckBlock();
    B = BB;
    E = BE;
    switch (BlockMode) {
    case bmLine:
        if (ExtendGrab & 1) { B.Row = VToR(CP.Row); B.Col = 0; }
        else if (ExtendGrab & 2) { E.Row = VToR(CP.Row); E.Col = 0; }
        if (B.Row > E.Row) {
            T = B;
            B = E;
            E = T;
        }
        break;
    case bmStream:
        if (ExtendGrab & 1) { B.Col = CP.Col; B.Row = VToR(CP.Row); }
        else if (ExtendGrab & 2) { E.Col = CP.Col; E.Row = VToR(CP.Row); }
        if ((B.Row > E.Row) ||
            ((B.Row == E.Row) && (B.Col > E.Col))) {
            T = B;
            B = E;
            E = T;
        }
        break;
    case bmColumn:
        if (ExtendGrab & 1) B.Row = VToR(CP.Row);
        else if (ExtendGrab & 2) E.Row = VToR(CP.Row);
        if (ExtendGrab & 4) B.Col = CP.Col;
        else if (ExtendGrab & 8) E.Col = CP.Col;
        if (B.Row > E.Row) {
            int T;

            T = B.Row;
            B.Row = E.Row;
            E.Row = T;
        }
        if (B.Col > E.Col) {
            int T;

            T = B.Col;
            B.Col = E.Col;
            E.Col = T;
        }
        break;
    }
    SetBB(B);
    SetBE(E);
    ExtendGrab = 0;
    AutoExtend = 0;
    return 1;
}
示例#4
0
int EBuffer::BlockSelectLine() {
    int Y = VToR(CP.Row);
    if (BlockUnmark() == 0) return 0;
    BlockMode = bmStream;

    if (SetBB(EPoint(Y, 0)) == 0) return 0;
    if (Y == RCount - 1) {
        if (SetBE(EPoint(Y, LineLen(Y))) == 0) return 0;
    } else {
        if (SetBE(EPoint(Y + 1, 0)) == 0) return 0;
    }
    return 1;
}
示例#5
0
int EBuffer::BlockSelectWord() {
    int Y = VToR(CP.Row);
    PELine L = RLine(Y);
    int P;
    int C;

    if (BlockUnmark() == 0) return 0;
    BlockMode = bmStream;

    P = CharOffset(L, CP.Col);

    if (P >= L->Count) return 0;
    C = ChClassK(L->Chars[P]);

    while ((P > 0) && (C == ChClassK(L->Chars[P - 1]))) P--;
    if (SetBB(EPoint(Y, ScreenPos(L, P))) == 0) return 0;
    while ((P < L->Count) && (C == ChClassK(L->Chars[P]))) P++;
    if (SetBE(EPoint(Y, ScreenPos(L, P))) == 0) return 0;
    return 1;
}
示例#6
0
// Selects the current function.
int EBuffer::BlockMarkFunction() {
    int by, ey;

    if (BlockUnmark() == 0)
        return 0;

    if ((by = FindFunction( 0, -1)) == -1)
        return 0;
    if ((ey = FindFunction(+1, +1)) == -1)
        return 0;

    //** Start and end are known. Set the block;
    BlockMode = bmStream;
    if (SetBB(EPoint(by, 0)) == 0)
        return 0;
    if (SetBE(EPoint(ey, 0)) == 0)
        return 0;

    return 1;
}
示例#7
0
//
//	오브젝트 로딩.  모션을 읽지 않은 상태에서도 독립적으로 동작한다.
//
int		CModelObject::LoadElement( LPCTSTR szFileName, int nParts )
{
	CObject3D	*pObject3D;
	O3D_ELEMENT	*pElem;
#ifdef __XDEBUG
	if( nParts < 0 )
	{
		XERROR( "CModelObject::LoadElement : nParts 에러 - nParts = %d, %s", nParts, szFileName );
		return FAIL;
	}
	if( nParts >= MAX_ELEMENT )
		return FAIL;
//		XERROR( "CModelObject::LoadElement : nParts 에러 - nParts = %d, %s", nParts, szFileName );
#endif

	Destroy( nParts );

		
	pObject3D = g_Object3DMng.LoadObject3D( szFileName );
	//TRACE( "new Object 3D%p\n", pObject3D);
	
	if( pObject3D == NULL )
	{
		XERROR( "%s : 찾을 수 없음", MakePath( DIR_MODEL, szFileName ) );
		return FAIL;
	}

	// 스킨파츠의 경우 외부본을 읽었는지 검사.
	if( pObject3D->IsUseExternBone() )		// 외장본을 사용하는 오브젝이다.
	{
		if( m_pBone == NULL )			// 본을 아직 안읽은 상태다...
		{
#ifdef	__XDEBUG
			XERROR( "%s : 본을 로딩하지 않고 메쉬를 읽음", szFileName );		// 에러...
#endif
			return FAIL;
		}
	}
	
	pElem = &m_Element[ nParts ];
	pElem->m_pObject3D = pObject3D;
	

	memset( &g_szLastFile, 0, sizeof(char)*512 );
	strcpy( g_szLastFile, szFileName );

	if( pObject3D->GetGMOBJECT() == NULL )
	{
		XERROR( "CModelObject::LoadElement에서 튕김 : 읽은 파일명 %s", MakePath( DIR_MODEL, szFileName ) );
		return FAIL;
	}
	
	if( pObject3D->GetGMOBJECT()->m_bOpacity )
		m_dwRenderEffect = REFF_ALPHA;
//	if( pObject3D->GetGMOBJECT()->m_bReflection )
//		m_dwRenderEffect = REFF_REFLECT;
	m_bCollObj = pObject3D->IsHaveCollObj();
	if( pObject3D->m_nHavePhysique )	m_bSkin = TRUE;

	if( m_nFrameMax > 0 )	// 이미 모션이나 오브젝을 읽어서 maxframe이 있을때 이번에 읽은 오브젝틔 maxframe하고 비교. 틀리면 에러.
	{
		if( pObject3D->GetMaxFrame() )
			if( m_nFrameMax != pObject3D->GetMaxFrame() )
			{
				XERROR( "CModelObject::LoadElement - %s의 MaxFrame(%d)과 이전에 읽은 MaxFrame(%d)이 다르다.", szFileName, pObject3D->GetMaxFrame(), m_nFrameMax );
			}
	}
	if( m_nFrameMax == 0 )	// maxframe이 세팅된적이 없을때만 최초 세팅함.
		m_nFrameMax = pObject3D->GetMaxFrame();

	// 애니메이션 속도
	m_fPerSlerp = (float)((int)(pObject3D->m_fPerSlerp * 1000.0f)) / 1000.0f;		// 소숫점 3째 이하에서 오차가 생길수 있으므로 3째까지 에서 잘라버린다,.


	// 이미 본이 로딩되어 있는 상태면 m_pUpdateBone을 오브젝트의 외부뼈대로 등록함.
	if( m_pBone )
		pObject3D->SetExternBone( m_mUpdateBone, m_pBaseBoneInv );


	// 새로 읽은 Mesh의  BB를 기준으로 CModelObject의 BB를 갱신
	// 이부분계산은 현재 정확하지 않다.  Min,Max모두 Local기준인데다가
	// 사람이 창을 쥐고 있을경우 창까지 바운딩 박스에 포함되고 있다.
	if( pObject3D->m_vBBMin.x < m_vMin.x )	m_vMin.x = pObject3D->m_vBBMin.x;
	if( pObject3D->m_vBBMin.y < m_vMin.y )	m_vMin.y = pObject3D->m_vBBMin.y;
	if( pObject3D->m_vBBMin.z < m_vMin.z )	m_vMin.z = pObject3D->m_vBBMin.z;
	if( pObject3D->m_vBBMax.x > m_vMax.x )	m_vMax.x = pObject3D->m_vBBMax.x;
	if( pObject3D->m_vBBMax.y > m_vMax.y )	m_vMax.y = pObject3D->m_vBBMax.y;
	if( pObject3D->m_vBBMax.z > m_vMax.z )	m_vMax.z = pObject3D->m_vBBMax.z;
	SetBB( m_BB.m_vPos, m_vMin, m_vMax );


	// 읽어온 엘리먼트는 this의 뼈대에 부모지정이 안되어 있게 한다.
	// 만약 칼을 읽어왔다면 수동으로 SetParent()하도록 한다.
	pElem->m_nParentIdx = -1;
/*	
	// 읽은 오브젝트가 부모인덱스를 가진다면 그것을 지정함.
	// 일반적으로 오른손이 부모로 되어 있다.
	int nParentIdx = pObject3D->GetGMOBJECT()->m_nParentIdx;
	if( nParentIdx != -1 )
		SetParent( nParts, nParentIdx );
	else
		pElem->m_nParentIdx = -1;
*/
	if( pObject3D->m_nHavePhysique )	// 피지크를 가지고 있다면 스킨은 버텍스버퍼를 따로 가짐
	{
#ifdef __XDEBUG
		if( pElem->m_pnGL_VB )
			XLOG( "CModelObject::LoadElement: %s pElem->m_pnGL_VB가 남아 있다", szFileName );
#endif
		int nTotal = 0;
		pObject3D->SetLOD(0);	nTotal += pObject3D->GetMaxObject();
		pObject3D->SetLOD(1);	nTotal += pObject3D->GetMaxObject();
		pObject3D->SetLOD(2);	nTotal += pObject3D->GetMaxObject();
		pObject3D->SetLOD(0);
		
		if( nTotal <= 0 )
			XERROR( "%s LoadElement : nTotal=%d", pObject3D->m_szFileName, nTotal );

		pElem->m_pnGL_VB = new GLuint[ nTotal ];
		memset( pElem->m_pnGL_VB, 0, sizeof(GLuint) * nTotal );
		GLuint *pnGL_VB = pElem->m_pnGL_VB;
		pObject3D->SetLOD(0);		pElem->m_pnGL_VB1 = pnGL_VB;		pnGL_VB += pObject3D->GetMaxObject();
		pObject3D->SetLOD(1);		pElem->m_pnGL_VB2 = pnGL_VB;		pnGL_VB += pObject3D->GetMaxObject();
		pObject3D->SetLOD(2);		pElem->m_pnGL_VB3 = pnGL_VB;		
		pObject3D->SetLOD(0);
		pElem->m_pnGL_VBSel = pElem->m_pnGL_VB1;
	}
	
	// 버텍스 버퍼 생성
//	if( pObject3D->GetGMOBJECT()->m_Type == GMT_SKIN )
//		pObject3D->RestoreDeviceObjects( D3DPOOL_SYSTEMMEM );		// 이걸 여기서 하면 안되는 이유가 있어서 안한건데 그 이유가 기억이 안난다 -_-;;;
//	else
		pObject3D->RestoreDeviceObjects( pElem->m_pnGL_VB );		// 이걸 여기서 하면 안되는 이유가 있어서 안한건데 그 이유가 기억이 안난다 -_-;;;
	return SUCCESS;
}
示例#8
0
int EBuffer::BlockPaste(int clipboard) {
    EPoint B, E;
    int L, BL;

    if (SystemClipboard)
        GetPMClip(clipboard);

    if (SSBuffer == 0) return 0;
    if (SSBuffer->RCount == 0) return 0;
    AutoExtend = 0;
    BFI(SSBuffer, BFI_TabSize) = BFI(this, BFI_TabSize);
    BFI(SSBuffer, BFI_ExpandTabs) = BFI(this, BFI_ExpandTabs);
    BFI(SSBuffer, BFI_Undo) = 0;
    BlockUnmark();
    B.Row = VToR(CP.Row);
    B.Col = CP.Col;
    BL = B.Row;
    switch(BlockMode) {
    case bmLine:
        B.Col = 0;
        for (L = 0; L < SSBuffer->RCount; L++) {
            if (InsLine(BL, 0) == 0) return 0;
            if (InsLineText(BL, 0, SSBuffer->LineLen(L), 0, SSBuffer->RLine(L)) == 0) return 0;
            BL++;
        }
        E.Row = BL;
        E.Col = 0;
        SetBB(B);
        SetBE(E);
        break;

    case bmColumn:
        for (L = 0; L < SSBuffer->RCount; L++) {
            if (AssertLine(BL) == 0) return 0;
            if (InsLineText(BL, B.Col, SSBuffer->LineLen(L), 0, SSBuffer->RLine(L)) == 0) return 0;
            if (TrimLine(BL) == 0) return 0;
            BL++;
        }
        if (AssertLine(BL) == 0) return 0;
        E.Row = BL;
        E.Col = B.Col + SSBuffer->LineLen(0);
        SetBB(B);
        SetBE(E);
        break;

    case bmStream:
        if (SSBuffer->RCount > 1)
            if (SplitLine(B.Row, B.Col) == 0) return 0;
        if (InsLineText(B.Row, B.Col, SSBuffer->LineLen(0), 0, SSBuffer->RLine(0)) == 0) return 0;
        E = B;
        E.Col += SSBuffer->LineLen(0);
        BL++;
        if (SSBuffer->RCount > 1) {
            for (L = 1; L < SSBuffer->RCount - 1; L++) {
                if (InsLine(BL, 0) == 0) return 0;
                if (InsLineText(BL, 0, SSBuffer->LineLen(L), 0, SSBuffer->RLine(L)) == 0) return 0;
                BL++;
            }
            L = SSBuffer->RCount - 1;
            if (InsLineText(BL, 0, SSBuffer->LineLen(L), 0, SSBuffer->RLine(L)) == 0) return 0;
            E.Col = SSBuffer->LineLen(L);
            E.Row = BL;
        }
        SetBB(B);
        SetBE(E);
        break;
    }
    return 1;
}
示例#9
0
/*
Aggiorna la scacchiera e le altre strutture dati eseguendo la mossa
La verifica di legalita' viene effettuata quando:
-la mossa è una mossa di re
-il re è sotto scacco
-il re è sotto attacco x-ray
*/
int makemove(const MOVE m, const unsigned char s) {

	unsigned char from=0; /*da dove parte il pezzo*/
	unsigned char to=0; /*dove copiare il pezzo*/
	char was=0; /*cosa era il pezzo?*/
	char wh=0;
	unsigned char del=0; /*dove cancellare*/

	assert(Name(WHITE,0)==king);
	assert(Name(BLACK,0)==king);

	

	if (Piece(m.ms.to)==king) return 0;

	/*copia la chiave hash per l'unmake()*/
	BHash(N_moves) = Hash;

	/*copia la castle_exe per l'unmake()*/
	BCste(N_moves) = Cste;

	/*copia la bitboard per l'unmake()*/
	BBitb(N_moves, Side) = Bitboard(Side);


	/*Controlla che l'arrocco sia legale e sposta la torre
*/
	if (m.ms.flag & (M_OO | M_OOO)) {
			if (tree.check[Side][Ply])
				return 0;

			switch (m.ms.to) {
					case C8:

						if (attacked(C8, WHITE) || attacked(D8, WHITE))
							return 0;
						from = A8;
						to = D8;
						Cste |= cas_booo;
						break;

					case G8:
						if (attacked(F8, WHITE) || attacked(G8, WHITE))
							return 0;
						from = H8;
						to = F8;
						Cste |= cas_boo;
						break;

					case C1:
						if (attacked(C1, BLACK) || attacked(D1, BLACK))
							return 0;
						from = A1;
						to = D1;
						Cste |= cas_wooo;
						break;

					case G1:
						if (attacked(F1, BLACK) || attacked(G1, BLACK))
							return 0;
						from = H1;
						to = F1;
						Cste |= cas_woo;
						break;

					default:
						puts("Bad castle request.");
						assert(0);
					}
			/*sposta torre aggiornando la chiave hash*/
			UpdateHash(from);

			Piece(to) = Piece(from);

			Color(to) = Color(from);

			Plist(to) = Plist(from);

			Position((Color(to)), (Plist(to))) = to;

			Piece(from) = no_piece;

			Color(from) = EMPTY;

			Plist(from) = no_list;

			UpdateHash(to);

			SetBB(Side, to);

			DelBB(Side, from);
			}
	/*sposta il pezzo*/
	from = m.ms.from;

	to = m.ms.to;

	was = Piece(from);

	wh = Plist(from);
	assert(was>=0);
	assert(was<=king);

	assert(Name(Side,0)==king);
	assert(Name(Xside,0)==king);
	if (wh>0){
		assert(Name(Side,wh)!=king);
	}

	

	/*Se la mossa e' una cattura cancella il pezzo dalla casella di arrivo*/
	if (m.ms.flag & M_CAP) {
			del = to;

			/*se è una cattura en passant aggiustiamo casella*/
			if (m.ms.flag & M_ENP) {
					if (Side)
						del += DOWN;
					else
						del += UP;
			}

			

			BCapP(N_moves) = Piece(del);
			BCapPos(N_moves) = Plist(del);
			BCapC(N_moves) = Xside;
			BBitb(N_moves, Xside) = Bitboard(Xside);
			Active(Xside, (Plist(del))) = CAPTURED;
			Piece(del) = no_piece;
			Color(del) = EMPTY;
			Plist(del) = no_list;
			DelBB(Xside, del);
			}

	Piece(to) = Piece(from);
	if (m.ms.piece!=was)Piece(to)=m.ms.piece;
	Color(to) = Side;
	Plist(to) = wh;
	Position((Side), (wh)) = to;
	Piece(from) = no_piece;
	Color(from) = EMPTY;
	Plist(from) = no_list;
	SetBB(Side, to);
	DelBB(Side, from);
	/*effettuato il minimo indispensabile verifica, se opportuno, la legalità della mossa*/
	
	assert(Name(Side,0)==king);
	assert(Name(Xside,0)==king);
	if (wh>0){
		assert(Name(Side,wh)!=king);
	}
	

	if ( tree.verify[Ply] || tree.check[Side][Ply] || (m.ms.flag & M_KNG) ||(m.ms.flag & M_ENP)) {
			if (in_check(Side)) {
					/*unmake() locale*/
					Piece(from) = Piece(to);
					if (Piece(from)!=was)Piece(from)=was;
					Color(from) = Side;
					Plist(from) = wh;
					Position((Side), (wh)) = from;
					Piece(to) = no_piece;
					Color(to) = EMPTY;
					Plist(to) = no_list;
					Bitboard(Side) = BBitb(N_moves, Side);

					if (m.ms.flag & M_CAP) {
							Piece(del) = BCapP(N_moves);
							Color(del) = BCapC(N_moves);
							Plist(del) = BCapPos(N_moves);
							Active((Xside), (Plist(del))) = FREE;
							Position((Xside), (Plist(del))) = del;
							Bitboard(Xside) = BBitb(N_moves, Xside);
							assert(Name(Side,0)==king);
							assert(Name(Xside,0)==king);
							if (Plist(del)>0){
								assert(Name(Xside,Plist(del))!=king);
								}
							}
					assert(Name(Side,0)==king);
					assert(Name(Xside,0)==king);
					if (wh>0){
						assert(Name(Side,wh)!=king);
						}
					return 0;
					}

			}
	/*Selectivity*/
	if (s && ((!in_check(Xside)) || ((m.ms.flag& M_CAP)==0))) {
		/*unmake() locale*/
					Piece(from) = Piece(to);
					if (Piece(from)!=was)Piece(from)=was;
					Color(from) = Side;
					Plist(from) = wh;
					Position((Side), (wh)) = from;
					Piece(to) = no_piece;
					Color(to) = EMPTY;
					Plist(to) = no_list;
					Bitboard(Side) = BBitb(N_moves, Side);

					if (m.ms.flag & M_CAP) {
							Piece(del) = BCapP(N_moves);
							Color(del) = BCapC(N_moves);
							Plist(del) = BCapPos(N_moves);
							Active((Xside), (Plist(del))) = FREE;
							Position((Xside), (Plist(del))) = del;
							Bitboard(Xside) = BBitb(N_moves, Xside);
							assert(Name(Side,0)==king);
							assert(Name(Xside,0)==king);
							if (Plist(del)>0){
								assert(Name(Xside,Plist(del))!=king);
								}
							}
					assert(Name(Side,0)==king);
					assert(Name(Xside,0)==king);
					if (wh>0){
						assert(Name(Side,wh)!=king);
						}
					return 0;
		}
	/*back up per l'unmakemove()
	i dati per la cattura e la hash della posizione sono gia' memorizzati*/
	tree.history[N_moves].m.mi = m.mi;
	tree.history[N_moves].cast.castle_right = Cstr;
	tree.history[N_moves].enp = Enp;
	tree.history[N_moves].fifty = tree.fifty;
	tree.history[N_moves].was = was;
	tree.history[N_moves].material[Side] = Material(Side);
	tree.history[N_moves].material[Xside] = Material(Xside);
	BPBitb(N_moves, Side) = Pbitboard(Side);
	BPBitb(N_moves, Xside) = Pbitboard(Xside);

	/*aggiorna diritti arrocco*/
	UpdateHashCastle(Cstr);
	Cstr &= castle_mask[b256to64[from]] & castle_mask[b256to64[to]];
	UpdateHashCastle(Cstr);

	Hash ^= zobrist_enp[b256to64[Enp]];
	Enp = 0;
	tree.fifty++;
	/*se irreversibile...*/

	if (m.ms.flag&(M_PAW | M_CAP)) {
			tree.fifty = 0;
			

			if (m.ms.flag&M_DBP) {
					if (Side)
						Enp = to + DOWN;
					else
						Enp = to + UP;
					}

			if (m.ms.flag&M_PAW) {
					DelPBB(Side, from);

					if ((m.ms.flag&M_PRO) == 0)
						SetPBB(Side, to);
					}

			if (m.ms.flag&M_CAP) {
					tree.history[N_moves].del = del;
					Hash ^= zobrist[Xside][BCapP(N_moves)][b256to64[del]];
					Material(Xside) -= piece_value[BCapP(N_moves)];
					Num_piece(Xside, BCapP(N_moves))--;
					Pbitboard(Xside) &= (~(bit_square[del]));
					}

			Material(Side) -= piece_value[was];
			Material(Side) += piece_value[m.ms.piece];
			Num_piece(Side, was)--;
			Num_piece(Side, m.ms.piece)++;
			}

	Hash ^= zobrist_enp[b256to64[Enp]];

	Hash ^= zobrist[Side][was][b256to64[from]];
	Hash ^= zobrist[Side][m.ms.piece][b256to64[to]];
	Hash ^= zobrist_side;



	Ply++;
	N_moves++;

	Change(Side);
	Change(Xside);

	assert(Name(WHITE,0)==king);
	assert(Name(BLACK,0)==king);

	return 1;

	}