示例#1
0
//Function make move type m from b position to e
void MainGame::MakeMove(GameBoardPos b, GameBoardPos e, MoveType m)
{
	if(WillMove())
	{
		int mvs = gamehistory.vhistory[currentmove].moves;
		int thrws = gamehistory.vhistory[currentmove].throws;
		if(currentmove != currentmaxmove)
		{
			gamehistory.vhistory.Remove(currentmove+1, currentmaxmove-currentmove);
			currentmaxmove = currentmove;
		}
		GameBoardField newboard[BOARDSIZE][BOARDSIZE];
		for(int i = 0; i < BOARDSIZE; i++)
		{
			for(int j = 0; j < BOARDSIZE; j++)
			{
				newboard[i][j] = gamehistory.vhistory[currentmove].GameBoardArray[i][j];
			}
		}
		newboard[b.x][b.y].type = FieldType(e);
		newboard[e.x][e.y].type = FieldType(b);
		if(m == pawn)
		{
			mvs -= GameBoardLay::BoardDistance(b, e);	
		}
		if(m == ball)
		{
			thrws--;	
		}
		if(m == end)
		{
			mvs = 0;
			thrws = 0;
		}
		gamehistory.vhistory.Add(Move(newboard, m, b, e, gamehistory.vhistory[currentmove].GetColor(), thrws, mvs));
		if(mode == editor)
		{
			gamehistory.vhistory[currentmaxmove+1].movetype = edit;
			gamehistory.vhistory.Remove(gamehistory.vhistory.GetCount()-2, 1);	
		}
		else
		{
			currentmove++;
			currentmaxmove++;	
		}
		if(thrws == 0 && mvs == 0)
		{
			if(mode != editor)
			{
				gamehistory.vhistory[currentmove].end = true;
				gamehistory.vhistory[currentmove].moves = DEFMOVES;
				gamehistory.vhistory[currentmove].throws = DEFTHROWS;
			}
		}
		unsaved = true;
	}
}
示例#2
0
void CMaps::CreateMaps( )
{
	std::shared_ptr<CSQLApi> lpSql = std::make_shared<CSQLApi>( );
	SQLPTR Maps;
	INT MapAddress = 0x0075B038;

	Clear( ( char* )( 0x0075B038 ), 0x3AA00 );
	
	for( int i = 0; i < 256; i++ )
	{
		*( int* )( 0x0075BE94 + i * 3752 ) = i;
	};

	if( lpSql->Select( Maps, "SELECT * FROM ServerDB.dbo.Maps" ) )
	{ 
		INT TotalMaps = Maps.size( );

		int c = 0;

		for( int i = 0; i < TotalMaps; i++ )
		{
			lstrcpyA( ( char* )( MapAddress + 4 ), Maps[ i ][ 2 ].c_str( ) );
			*( UINT* )( MapAddress + 196 ) = FieldType( Maps[ i ][ 3 ].c_str( ) );
			*( UINT* )( MapAddress + 3256 ) = atoi( Maps[ i ][ 4 ].c_str( ) );

			MapAddress += 3752;
			c++;
		};
	};

};
示例#3
0
  ARingGF::ARingGF(  UTT charact_, 
                       const M2_arrayint & modPolynomial,
                       const M2_arrayint & generatorPoly,
                       const PolynomialRing &originalRing)  :   
      mCharac(charact_),
      mDimension( M2arrayGetDegree(modPolynomial) ),
      mOriginalRing(&originalRing),
      mPrimitiveElement(originalRing.var(0)),
      givaroField( FieldType( charact_,mDimension, ARingGF::M2arrayToStdVec(charact_, modPolynomial), ARingGF::M2arrayToStdVec(charact_, generatorPoly) )),
      givaroRandomIterator( FieldType::randIter(givaroField )),
      mGeneratorExponent(1)
    {
      std::vector<UTT> debugGenPoly = M2arrayToStdVec(charact_, generatorPoly);
      std::cerr << "generatorPoly: ";
      for (int i=0; i<debugGenPoly.size(); i++) {
        std::cerr << debugGenPoly[i] << " ";
      }
      std::cerr << std::endl;

            /// @jakob: find out if the irreducible polynomial is checked in givaro.     
            UTT localdegree = M2arrayGetDegree(modPolynomial);
        
            if ( !( modPolynomial->len > 1 && modPolynomial->array[ localdegree ]>0 ))
            {
                std::cout << "assertion would have failed" << std::endl;
                assert(modPolynomial->len > 1);
                assert(modPolynomial->array[ localdegree ]>0);
            }
            /// debug code:
            getModPolynomialCoeffs();
    }
示例#4
0
    ARingGF::ARingGF(	 UTT charact_, 
                         UTT extensionDegree_)  :   
      mCharac(charact_),
      mDimension(extensionDegree_),
      mOriginalRing(0),
      givaroField(FieldType(charact_, extensionDegree_)),
      givaroRandomIterator( FieldType::randIter(givaroField ))     
    {
    
            /// @todo: remove debug code
            /// debug code:
            getModPolynomialCoeffs();
            getGeneratorCoeffs();

           /*
          
            ARingGF *testGF = new ARingGF(charact_, getModPolynomialCoeffs() );
    
            std::cerr <<"random"<< std::endl;
            ElementType rnd ;
            this->random(rnd);
            std::cerr << " rnd = "<< rnd << std::endl;
            fieldElementToM2Array(rnd);    
            fieldElementToM2Array(givaroField.one);
            fieldElementToM2Array(givaroField.zero);
            */
             
            /// end debug
    }
示例#5
0
    void CoreSchema::initCoreSchema(Schema &schema)
    {
        assert (schema.size() == 0);

        schema.addPrimitiveType<char>("char");                 // 0
        schema.addPrimitiveType<int8>("int8");                 // 1
        schema.addPrimitiveType<int16>("int16");               // 2
        schema.addPrimitiveType<int32>("int32");               // 3
        schema.addPrimitiveType<int64>("int64");               // 4
        schema.addPrimitiveType<uint8>("uint8");               // 5
        schema.addPrimitiveType<uint16>("uint16");             // 6
        schema.addPrimitiveType<uint32>("uint32");             // 7
        schema.addPrimitiveType<uint64>("uint64");             // 8
        schema.addPrimitiveType<float32>("float32");           // 9
        schema.addPrimitiveType<float64>("float64");           // 10
        schema.addPrimitiveType<RawPointer>("pointer");        // 11
        schema.addPrimitiveType<RawPointer>("tagged_pointer"); // 12
        schema << FieldType();                                 // 13
        schema << Field();                                     // 14
        schema << PrimitiveType();                             // 15
        schema << CustomType();                                // 16
        schema << Schema();                                    // 17

        // FIRST_USER_TYPEID is 256
        schema.setFreeTypeID(FIRST_USER_TYPEID);    // from 0x000d to 0x00ff, the types are reserved
                                                    // custom types should start from 0x0100

    }
示例#6
0
 ARingZZpFFPACK::ARingZZpFFPACK(UTT charact)  :   
   mFfpackField          (FieldType(static_cast<double>(charact))),
   mFfpackRandomIterator (mFfpackField),
   mCharac               (charact),
   mDimension            (1),
   mGeneratorComputed    (false)
 {
   M2_ASSERT( FieldType::getMaxModulus()>=mCharac );
 }
示例#7
0
文件: Field.cpp 项目: bencz/OrangeC
    bool Field::ILSrcDump(PELib &peLib) const
    {
        peLib.Out() << ".field";
        flags_.ILSrcDumpBeforeFlags(peLib);
        flags_.ILSrcDumpAfterFlags(peLib);
        if (FieldType()->GetBasicType() == Type::cls)
            if (FieldType()->GetClass()->Flags().Flags() & Qualifiers::Value)
                peLib.Out() << " valuetype";
            else
                peLib.Out() << " class";
        peLib.Out() << " ";
        type_->ILSrcDump(peLib);
        peLib.Out() << " '" << name_ << "'";
        switch (mode_)
        {
        case None:
            break;
        case Enum:
            peLib.Out() << " = ";
            ILSrcDumpTypeName(peLib, size_);
            peLib.Out() << "(" << (int)enumValue_ << ")";

            break;
        case Bytes:
            if (byteValue_ && byteLength_)
            {
                peLib.Out() << " at $" << name_ << std::endl;
                peLib.Out() << ".data $" << name_ << " = bytearray (" << std::endl << std::hex;
                int i;
                for (i = 0; i < byteLength_; i++)
                {
                    peLib.Out() << std::setw(2) << std::setfill('0') << (int)byteValue_[i] << " ";
                    if (i % 8 == 7 && i != byteLength_ - 1)
                        peLib.Out() << std::endl << "\t";
                }
                peLib.Out() << ")" << std::dec;
            }
            break;
        }
        peLib.Out() << std::endl;
        return true;
    }
bool
BContactField::IsEqual(BContactField* field)
{
	if (FieldType() != field->FieldType())
		return false;

	if (Label().Compare(field->Label()) != 0)
		return false;

	/*for (int i = 0; i < CountUsages(); i++)
		AddUsage(field->GetUsage(i));*/
	return true;
}
status_t
BContactField::CopyDataFrom(BContactField* field)
{
	if (FieldType() != field->FieldType())
		return B_ERROR;

	SetLabel(field->Label());

	for (int i = 0; i < field->CountUsages(); i++)
		AddUsage(field->GetUsage(i));

	return B_OK;
}
示例#10
0
void PrintItemTree(Item* item, int indent)
{
#ifdef PURE_LIBRARY
	BHERROR("NOT IMPLEMENTED! Depends on MySQL code.");
#else
	static const char* name_of[] = {
			"FIELD_ITEM", "FUNC_ITEM", "SUM_FUNC_ITEM", "STRING_ITEM", "INT_ITEM",
			"REAL_ITEM", "NULL_ITEM", "VARBIN_ITEM", "COPY_STR_ITEM", "FIELD_AVG_ITEM",
			"DEFAULT_VALUE_ITEM", "PROC_ITEM", "COND_ITEM", "REF_ITEM", "FIELD_STD_ITEM",
			"FIELD_VARIANCE_ITEM", "INSERT_VALUE_ITEM", "SUBSELECT_ITEM", "ROW_ITEM",
			"CACHE_ITEM", "TYPE_HOLDER", "PARAM_ITEM", "TRIGGER_FIELD_ITEM", "DECIMAL_ITEM",
			"XPATH_NODESET", "XPATH_NODESET_CMP", "VIEW_FIXER_ITEM" };
	static const char* sum_name_of[] =  {
	    "COUNT_FUNC", "COUNT_DISTINCT_FUNC", "SUM_FUNC", "SUM_DISTINCT_FUNC", "AVG_FUNC",
	    "AVG_DISTINCT_FUNC", "MIN_FUNC", "MAX_FUNC", "STD_FUNC",
	    "VARIANCE_FUNC", "SUM_BIT_FUNC", "UDF_SUM_FUNC", "GROUP_CONCAT_FUNC" };

	for(int i = 0; i <= indent; i++)
		fprintf(stderr, "*");
	fprintf(stderr, " ");
	indent += 1;

	if(!item) {
		fprintf(stderr, "NULL item\n");
		return;
	}

	const char* name;
    Item::Type type = item->type();

	if((int)type < sizeof(name_of)/sizeof(*name_of))
		name = name_of[type];
	else name = "BHFIELD_ITEM";

	const char* result = "<unknown result type>";
    switch (item->result_type()) {
		case STRING_RESULT: result = "STRING_RESULT"; break;
		case INT_RESULT: result = "INT_RESULT"; break;
		case REAL_RESULT: result = "REAL_RESULT"; break;
		case DECIMAL_RESULT: result = "DECIMAL_RESULT"; break;
    }
    fprintf(stderr, "%s %s @%p %s %s max_length=%d",
    		name, item->full_name(),  (void*)item,
    		FieldType(item->field_type()), result, item->max_length);

    if(item->result_type() == DECIMAL_RESULT)
    	fprintf(stderr, " [prec=%d,dec=%d,int=%d]",
    			item->decimal_precision(), (int)item->decimals, item->decimal_int_part());

    switch(type) {
		case Item::FUNC_ITEM: {
			Item_func* func = static_cast <Item_func*> (item);

			fprintf(stderr, " func_name=%s\n", func->func_name());
			String str;
			// GA, print function takes extra argument but do not use it in the base class.
			func->print(&str,QT_ORDINARY);
			fprintf(stderr, " f contents: %s\n", str.c_ptr_safe());

			Item** args = func->arguments();
			for(uint i = 0; i < func->argument_count(); i++)
				PrintItemTree(args[i], indent);
			return;
		}
		case Item::COND_ITEM: {
			Item_cond* cond = static_cast <Item_cond*> (item);

			fprintf(stderr, " func_name=%s\n", cond->func_name());

			List_iterator<Item> li(*cond->argument_list());
			Item* arg;
			while ((arg = li++))
				PrintItemTree(arg, indent);
			return;
		}
		case Item::SUM_FUNC_ITEM: {
			Item_sum* sum_func = static_cast <Item_sum*> (item);

			uint index = sum_func->sum_func();
			const char* sumname;
			if (index >= sizeof(sum_name_of)/sizeof(*sum_name_of))
				sumname = "<UNKNOWN>";
			else
				sumname = sum_name_of[index];

			fprintf(stderr, "  %s\n", sumname);

			Item** args = sum_func->args;
			uint args_count = sum_func->arg_count;
			for(uint i=0; i < args_count; i++)
				PrintItemTree(args[i], indent);
			return;
		}
		case Item::REF_ITEM: {
			Item_ref* ref = static_cast<Item_ref*> (item);
			Item* real = ref->real_item();
			fprintf(stderr, "\n");
			if(ref != real) PrintItemTree(real, indent);
			return;
		}
		case Item::INT_ITEM: {
			Item_int_with_ref* int_ref = dynamic_cast<Item_int_with_ref*>(item);
			if(!int_ref)
				break;
			// else item is an instance of Item_int_with_ref, not Item_int
			fprintf(stderr, " [Item_int_with_ref]\n");
			PrintItemTree(int_ref->real_item(), indent);
			return;
		}
		case Item::SUBSELECT_ITEM:
			Item_subselect* ss = dynamic_cast<Item_subselect*>(item);
			fprintf(stderr, " subselect type %d\n", ss->substype());
			String str;
			// GA, print function takes extra argument but do not use it.
			ss->get_unit()->print(&str, QT_ORDINARY);
			fprintf(stderr, "%s\n", str.c_ptr_safe());
    }

    fprintf(stderr, "\n");
#endif
}
示例#11
0
void DataTypeDecimal<T>::deserializeBinary(IColumn & column, ReadBuffer & istr) const
{
    typename FieldType::NativeType x;
    readBinary(x, istr);
    static_cast<ColumnType &>(column).getData().push_back(FieldType(x));
}