Beispiel #1
0
META_FUNCTION( sn3_bf_write, WriteBitVec3Coord )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );
	Lua()->CheckType( 2, GLua::TYPE_VECTOR );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	buf->WriteBitVec3Coord( *GET_META( 2, Vector ) );

	return 0;
}
Beispiel #2
0
META_FUNCTION( sn3_bf_write, WriteBytes )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );
	Lua()->CheckType( 2, GET_META_ID( UCHARPTR ) );
	Lua()->CheckType( 3, GLua::TYPE_NUMBER );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	Lua()->Push( buf->WriteBytes( GET_META( 2, UCHARPTR ), Lua()->GetInteger( 3 ) ) );

	return 1;
}
Beispiel #3
0
META_FUNCTION( sn3_bf_write, FinishWriting )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );

	delete GET_META( 1, sn3_bf_write );

	return 0;
}
META_FUNCTION( dataFragments_t, Delete )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );

	delete GET_META( 1, dataFragments_t );

	return 0;
}
META_FUNCTION( dataFragments_t, GetFileName )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	Lua()->Push( (const char *)fragments->filename );

	return 1;
}
META_FUNCTION( dataFragments_t, GetNum )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	Lua()->PushLong( fragments->num );

	return 1;
}
META_FUNCTION( dataFragments_t, GetCompressed )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	Lua()->Push( fragments->compressed );

	return 1;
}
META_FUNCTION( dataFragments_t, SetFileHandle )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	CopyUserDataOrNull( 2, FileHandle_t, fragments->hfile, FileHandle_t );

	return 0;
}
META_FUNCTION( dataFragments_t, SetBuffer )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );
	
	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	CopyUserDataOrNull( 2, UCHARPTR, fragments->buffer, unsigned char * );
		
	return 0;
}
META_FUNCTION( UCHARPTR, Delete )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( UCHARPTR ) );

	unsigned char *ptr = (unsigned char *)GET_META( 1, UCHARPTR );

	delete[] ptr;

	return 0;
}
META_FUNCTION( dataFragments_t, GetActualSize )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	Lua()->PushLong( fragments->actualsize );

	return 1;
}
Beispiel #12
0
META_FUNCTION( sn3_bf_write, GetNumBytesLeft )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	Lua()->PushLong( buf->GetNumBytesLeft() );

	return 1;
}
META_FUNCTION( dataFragments_t, GetFileTransferID )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	Lua()->PushLong( fragments->transferid );

	return 1;
}
Beispiel #14
0
META_FUNCTION( sn3_bf_write, IsOverflowed )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	Lua()->Push( buf->IsOverflowed() );

	return 1;
}
META_FUNCTION( dataFragments_t, GetBuffer )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	PUSH_META( fragments->buffer, UCHARPTR );

	return 1;
}
META_FUNCTION( dataFragments_t, GetFileHandle )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	PUSH_META( fragments->hfile, FileHandle_t );

	return 1;
}
Beispiel #17
0
META_FUNCTION( sn3_bf_write, GetBasePointer )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	PUSH_META( buf->GetBasePointer(), UCHARPTR );

	return 1;
}
META_FUNCTION( dataFragments_t, SetActualSize )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );
	Lua()->CheckType( 2, GLua::TYPE_NUMBER );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	fragments->actualsize = Lua()->GetInteger( 2 );

	return 0;
}
Beispiel #19
0
META_FUNCTION( sn3_bf_write, WriteString )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );
	Lua()->CheckType( 2, GLua::TYPE_STRING );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	buf->WriteString( Lua()->GetString( 2 ) );

	return 0;
}
Beispiel #20
0
META_FUNCTION( sn3_bf_write, WriteFloat )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );
	Lua()->CheckType( 2, GLua::TYPE_NUMBER );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	buf->WriteFloat( Lua()->GetNumber( 2 ) );

	return 0;
}
META_FUNCTION( dataFragments_t, SetStream )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );
	Lua()->CheckType( 2 , GLua::TYPE_BOOL );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	fragments->stream = Lua()->GetBool( 2 );

	return 0;
}
META_FUNCTION( dataFragments_t, SetProgress )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );
	Lua()->CheckType( 2, GLua::TYPE_NUMBER );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	fragments->progress = Lua()->GetInteger( 2 );

	return 0;
}
META_FUNCTION( dataFragments_t, SetFileTransferID )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );
	Lua()->CheckType( 2, GLua::TYPE_NUMBER );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	fragments->transferid = Lua()->GetInteger( 2 );

	return 0;
}
Beispiel #24
0
META_FUNCTION( sn3_bf_write, WriteShort )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );
	Lua()->CheckType( 2, GLua::TYPE_NUMBER );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	buf->WriteShort( Lua()->GetInteger( 2 ) & 0xFFFF );

	return 0;
}
META_FUNCTION( INetworkStringTableContainer, FindTable )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( INetworkStringTableContainer ) );
	Lua()->CheckType( 2, GLua::TYPE_STRING );

	INetworkStringTableContainer *pContainer = GET_META( 1, INetworkStringTableContainer );

	PUSH_META( pContainer->FindTable( Lua()->GetString( 2 ) ), INetworkStringTable );

	return 1;
}
META_FUNCTION( dataFragments_t, SetFileName )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( dataFragments_t ) );
	Lua()->CheckType( 2 , GLua::TYPE_STRING );

	dataFragments_t *fragments = GET_META( 1, dataFragments_t );

	strcpy_s( fragments->filename, MAX_PATH, Lua()->GetString( 2 ) );

	return 0;
}
Beispiel #27
0
META_FUNCTION( sn3_bf_write, Seek )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );
	Lua()->CheckType( 2, GLua::TYPE_NUMBER );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	buf->SeekToBit( Lua()->GetInteger( 2 ) );

	return 0;
}
Beispiel #28
0
META_FUNCTION( sn3_bf_write, WriteUBitLong )
{
	UsesLua();

	Lua()->CheckType( 1, GET_META_ID( sn3_bf_write ) );
	Lua()->CheckType( 2, GLua::TYPE_NUMBER );
	Lua()->CheckType( 3, GLua::TYPE_NUMBER );

	sn3_bf_write *buf = GET_META( 1, sn3_bf_write );

	buf->WriteUBitLong( Lua()->GetInteger( 2 ), Lua()->GetInteger( 3 ) );

	return 0;
}
META_FUNCTION( INetworkStringTableContainer, GetTable )
{
	UsesLua();

	//Lua()->SetGlobal( "META_ID" ,  (double)GET_META_ID( INetworkStringTableContainer ) );

	Lua()->CheckType( 1, GET_META_ID( INetworkStringTableContainer ) );
	Lua()->CheckType( 2, GLua::TYPE_NUMBER );

	INetworkStringTableContainer *pContainer = GET_META( 1, INetworkStringTableContainer );

	PUSH_META( pContainer->GetTable( Lua()->GetInteger( 2 ) ), INetworkStringTable );

	return 1;
}
Beispiel #30
0
unsigned long perft(ChessBoard* start, ChessMoveGenerator* gen, 
    int depth){
    move_t *next = NULL;
    int nextCount = 0;
    if(depth==0){
        if(ChessBoard_testForCheck(start)){
            //printf("\n");
            //ChessBoard_print(start);
            checks++;
            ChessMoveGenerator_generateMoves(gen, 1, NULL);
            if(gen->nextCount==0)
                checkmates++;
        }
        return 1;
    }

    int i;
    unsigned long nodes = 0;
    ChessMoveGenerator_generateMoves(gen, 
        ChessBoard_testForCheck(start), NULL);
    ChessMoveGenerator_copyMoves(gen,
        &next, &nextCount);
    for (i = 0; i < nextCount; i++){
        ChessBoard_makeMove(start, next[i]);
        if(depth==1){
            if(next[i]&CAPTURE_MOVE_FLAG)
                captures++;
            if(next[i]&PROMOTION_MOVE_FLAG)
                promotions++;
            if(GET_META(next[i])==EN_PASSANT_MOVE)
                ep++;
        }
        nodes += perft(start, gen, depth-1);
        ChessBoard_unmakeMove(start);
    }
    free(next);
    return nodes;
}