Cuberite Forum
SVN Builds - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: SVN Builds (/thread-215.html)

Pages: 1 2 3 4


RE: SVN Builds - rs2k - 11-08-2011

Here's an example in cChicken.cpp


Code:
    if( (rand() % 5) == 0 )
    {
        cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_EGG, 1 ) );
        Pickup->Initialize( GetWorld() );
    }
    if( (rand() % 1) == 0 )
    {
        cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_FEATHER, 1 ) );
        Pickup->Initialize( GetWorld() );
    }


20% chance to drop an egg and 100% chance to drop a feather. Both can happen at the same time. After you run Pickup->Initialize( GetWorld() ); you can create the object again.


RE: SVN Builds - ThuGie - 11-08-2011

Weird..
When i do 2 times without the if 2 pickup i get a error.

Edit:
Code:
void cCavespider::KilledBy( cEntity* a_Killer )
{
    //0 to 1 spider eye - 1.9 pre2
    cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_SPIDER_EYE, (rand() % 1) ) );
    Pickup->Initialize( GetWorld() );
    //0 to 2 string.
    cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_STRING, (rand() % 3) ) );

    Pickup->Initialize( GetWorld() );
    cMonster::KilledBy( a_Killer );
}
Like this i get a error also when i only do once pickup->init
Also not actually dropping the spider eye just a sample.


RE: SVN Builds - FakeTruth - 11-08-2011

(rand() % 3) ranges between 0 and 2, if you want a value between 1 and 2, use (rand()%2+1)

Also, you're declaring the same variable twice (illegal)


RE: SVN Builds - Luthrandel - 11-08-2011

Variable scope issues perhaps. Enclosing the individual cPickup* Pickup ensures there's no overlap.
Code:
void cCavespider::KilledBy( cEntity* a_Killer )
{
    {
      //0 to 1 spider eye - 1.9 pre2
      cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_SPIDER_EYE, (rand() % 1) ) );
      Pickup->Initialize( GetWorld() );
    }
    {
      //0 to 2 string.
      cPickup* Pickup = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_STRING, (rand() % 3) ) );
      Pickup->Initialize( GetWorld() );
    }
    cMonster::KilledBy( a_Killer );
}



RE: SVN Builds - rs2k - 11-08-2011

I'm compiling it now. It's been going for 10 minutes now. Not quite sure what to do after Squirrel is compiled though. lol


RE: SVN Builds - FakeTruth - 11-08-2011

I think there's a bug in the makefile that makes it loopTongue So I don't think it's gonna finish any time soon. Anyway, the squirrel library compiles, but try to compile SquirrelBindings.cpp in the /source folder and it should give you those errors


RE: SVN Builds - rs2k - 11-08-2011

After changing the makefile to include squirrel_3_0_1_stable/sqplus/, I'm getting these errors:


Code:
/usr/bin/g++ -msse4 -O2 -s source/cPluginManager.cpp -c -I. -Isource -Isquirrel_3_0_1_stable/ -Isquirrel_3_0_1_stable/include -Isource/md5 -IWebServer -Isource/packets -Itolua++-1.0.93/src/lib -Ilua-5.1.4/src -Izlib-1.2.5 -IiniFile -Itolua++-1.0.93/include -Ijsoncpp-src-0.5.0/include -Ijsoncpp-src-0.5.0/src/lib_json -o build/cPluginManager.o
In file included from source/cPluginManager.cpp:16:
squirrel_3_0_1_stable/sqplus/sqplus.h: In function âvoid SqPlus::createTableSetGetHandlers(SquirrelObject&)â:
squirrel_3_0_1_stable/sqplus/sqplus.h:553: error: invalid conversion from âint (*)(SQVM*)â to âSQInteger (*)(SQVM*)â
squirrel_3_0_1_stable/sqplus/sqplus.h:553: error:   initializing argument 2 of âstatic SquirrelObject SquirrelVM::CreateFunction(SquirrelObject&, SQInteger (*)(SQVM*), const SQChar*, const SQChar*)â
squirrel_3_0_1_stable/sqplus/sqplus.h:554: error: invalid conversion from âint (*)(SQVM*)â to âSQInteger (*)(SQVM*)â
squirrel_3_0_1_stable/sqplus/sqplus.h:554: error:   initializing argument 2 of âstatic SquirrelObject SquirrelVM::CreateFunction(SquirrelObject&, SQInteger (*)(SQVM*), const SQChar*, const SQChar*)â
squirrel_3_0_1_stable/sqplus/sqplus.h: In function âvoid SqPlus::createInstanceSetGetHandlers(SquirrelObject&)â:
squirrel_3_0_1_stable/sqplus/sqplus.h:584: error: invalid conversion from âint (*)(SQVM*)â to âSQInteger (*)(SQVM*)â
squirrel_3_0_1_stable/sqplus/sqplus.h:584: error:   initializing argument 2 of âstatic SquirrelObject SquirrelVM::CreateFunction(SquirrelObject&, SQInteger (*)(SQVM*), const SQChar*, const SQChar*)â
squirrel_3_0_1_stable/sqplus/sqplus.h:585: error: invalid conversion from âint (*)(SQVM*)â to âSQInteger (*)(SQVM*)â
squirrel_3_0_1_stable/sqplus/sqplus.h:585: error:   initializing argument 2 of âstatic SquirrelObject SquirrelVM::CreateFunction(SquirrelObject&, SQInteger (*)(SQVM*), const SQChar*, const SQChar*)â
In file included from squirrel_3_0_1_stable/sqplus/sqplus.h:886,
                 from source/cPluginManager.cpp:16:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h: In function âchar SqPlus::Get(SqPlus::TypeWrapper<char>, SQVM*, int)â:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h:60: error: cannot convert âINT*â to âSQInteger*â for argument â3â to âSQRESULT sq_getinteger(SQVM*, SQInteger, SQInteger*)â
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h: In function âunsigned char SqPlus::Get(SqPlus::TypeWrapper<unsigned char>, SQVM*, int)â:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h:61: error: cannot convert âINT*â to âSQInteger*â for argument â3â to âSQRESULT sq_getinteger(SQVM*, SQInteger, SQInteger*)â
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h: In function âshort int SqPlus::Get(SqPlus::TypeWrapper<short int>, SQVM*, int)â:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h:62: error: cannot convert âINT*â to âSQInteger*â for argument â3â to âSQRESULT sq_getinteger(SQVM*, SQInteger, SQInteger*)â
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h: In function âshort unsigned int SqPlus::Get(SqPlus::TypeWrapper<short unsigned int>, SQVM*, int)â:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h:63: error: cannot convert âINT*â to âSQInteger*â for argument â3â to âSQRESULT sq_getinteger(SQVM*, SQInteger, SQInteger*)â
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h: In function âint SqPlus::Get(SqPlus::TypeWrapper<int>, SQVM*, int)â:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h:64: error: cannot convert âINT*â to âSQInteger*â for argument â3â to âSQRESULT sq_getinteger(SQVM*, SQInteger, SQInteger*)â
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h: In function âunsigned int SqPlus::Get(SqPlus::TypeWrapper<unsigned int>, SQVM*, int)â:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h:65: error: cannot convert âINT*â to âSQInteger*â for argument â3â to âSQRESULT sq_getinteger(SQVM*, SQInteger, SQInteger*)â
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h: In function âlong int SqPlus::Get(SqPlus::TypeWrapper<long int>, SQVM*, int)â:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h:66: error: cannot convert âINT*â to âSQInteger*â for argument â3â to âSQRESULT sq_getinteger(SQVM*, SQInteger, SQInteger*)â
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h: In function âlong unsigned int SqPlus::Get(SqPlus::TypeWrapper<long unsigned int>, SQVM*, int)â:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h:67: error: cannot convert âINT*â to âSQInteger*â for argument â3â to âSQRESULT sq_getinteger(SQVM*, SQInteger, SQInteger*)â
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h: In function âbool SqPlus::Get(SqPlus::TypeWrapper<bool>, SQVM*, int)â:
squirrel_3_0_1_stable/sqplus/SqPlusFunctionCallImpl.h:80: error: cannot convert âINT*â to âSQInteger*â for argument â3â to âSQRESULT sq_getinteger(SQVM*, SQInteger, SQInteger*)â



RE: SVN Builds - FakeTruth - 11-08-2011

Funky â's everywhere, what's up with that


RE: SVN Builds - FakeTruth - 11-08-2011

Since this thread has pretty much derailed into discussing development of MCServer, I've moved it


RE: SVN Builds - ThuGie - 11-08-2011

Weird this code should work right ?
Code:
void cCow::KilledBy( cEntity* a_Killer )
{
    //1 to 3 raw beef.
    int rRawBeef = rand() % 1 + 3;
    if (rRawBeef != 0) {
        cPickup* pRawBeef = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_RAW_BEEF, rRawBeef ) );
        pRawBeef->Initialize( GetWorld() );
    }
    //0 to 2 leather.
    int rLeather = rand() % 3;
    if (rLeather != 0) {
        cPickup* pLeather = new cPickup( (int)(m_Pos->x*32), (int)(m_Pos->y*32), (int)(m_Pos->z*32), cItem( E_ITEM_LEATHER, rLeather ) );
        pLeather->Initialize( GetWorld() );
    }

    cMonster::KilledBy( a_Killer );
}
Still it crashes the client when i kill a cow.