Blastcore development thread

Discussion in 'Development General' started by Blastcore, Dec 31, 2010.

  1. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Okay, so i'm trying (TRYING) to implement RBY. I need to add the RBY (1st gen) to Team Builder. But, since we have this: for (int i = 0; i < NUMBER_GENS; i++) { (and NUMBER_GENS is 5, it wont show B/W (5th gen) since i'm adding another one before it. But if i increase it, i feel like i'll have to touch 3/4 of the code in the moves.cpp and moves1.cpp because of gen()

    Any idea?

    Short Explain:

    NUMBER_GENS = 5

    Since we have Stadium, if we include RBY we'll have 6. I need to change NUMBER_GENS, but if i change it i feel like i'll need to touch 3/4 of the moves/1.cpp to fix gen() stuff.
     
  2. Crystal Moogle

    Crystal Moogle Ayaya~ Administrator Administrator

    Joined:
    Jul 19, 2010
    Messages:
    3,205
    Likes Received:
    531
    PO Trainer Name:
    Hanako
    Just get rid of Stadium~
     
  3. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    That would be the same as doing RBY, since i don't know which moves are different on Stadium. I would need to look up around 4000 lines of code lol

    I've also figured it out. x:
     
    Last edited: May 31, 2012
  4. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    Stadium and RBY are both gen 1. Implement subgen support if you want both.
     
  5. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Message to Lamperi: I've been trying to get rid of the crash but no success on it:


    Code (text):
    1. std::vector<int> && BattleBase::sortedBySpeed()
    2. {
    3.     std::vector<int> ret;
    4.  
    5.     std::vector<std::pair<int, int> > speeds;
    6.  
    7.     for (int i =0; i < numberOfSlots(); i++) {
    8.         if (!koed(i)) {
    9.             speeds.push_back(std::pair<int, int>(i, getStat(i, Speed)));
    10.         }
    11.     }
    12.  
    13.     if (speeds.size() == 0)
    14.         return std::move(ret);
    15.  
    16.     std::sort(speeds.begin(), speeds.end(), &comparePair);
    17.  
    18.     /* Now for the speed tie */
    19.     for (unsigned i = 0; i < speeds.size()-1;) {
    20.         unsigned  j;
    21.         for (j = i+1; j < speeds.size(); j++) {
    22.             if (speeds[j].second != speeds[i].second) {
    23.                 break;
    24.             }
    25.         }
    26.  
    27.         if (j != i +1) {
    28.             std::random_shuffle(speeds.begin() + i, speeds.begin() + j);
    29.         }
    30.  
    31.         i = j;
    32.     }
    33.  
    34.     /* Now assigning, removing the pairs */
    35.     for (unsigned i =0; i < speeds.size(); i++) {
    36.         ret.push_back(speeds[i].first);
    37.     }
    38.     return std::move(ret);
    39. }
    If i add qDebug() << "Test" before returns it just doesn't crash and does this:

    Crash is caused by doing this:

    0 msvcrt!memmove C:\Windows\system32\msvcrt.dll 0 0x7602a160
    1 msvcrt!memmove C:\Windows\system32\msvcrt.dll 0 0x7602a0fd
    2 std::__copy_move<false, true, std::random_access_iterator_tag>::__copy_m<int> stl_algobase.h 378 0x585f56
    3 std::__copy_move_a<false, int const*, int*> stl_algobase.h 397 0x5a23ab
    4 std::__copy_move_a2<false, __gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int> > >, int*> stl_algobase.h 436 0x5a3029
    5 std::copy<__gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int> > >, int*> stl_algobase.h 468 0x5a5f76
    6 std::__uninitialized_copy<true>::uninitialized_copy<__gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int> > >, int*> stl_uninitialized.h 93 0x59834f
    7 std::uninitialized_copy<__gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int> > >, int*> stl_uninitialized.h 117 0x5a41bf
    8 std::__uninitialized_copy_a<__gnu_cxx::__normal_iterator<int const*, std::vector<int, std::allocator<int> > >, int*, int> stl_uninitialized.h 257 0x5a505f
    9 std::vector<int, std::allocator<int> >::vector stl_vector.h 243 0x59cdbe
    10 QForeachContainer<std::vector<int, std::allocator<int> > >::QForeachContainer qglobal.h 2251 0x51080a
    11 BattleRBY::analyzeChoices battlerby.cpp 155 0x491341
    12 BattleRBY::beginTurn battlerby.cpp 37 0x490d89
    13 BattleBase::run battlebase.cpp 219 0x487f64
    14 ContextSwitcher::runNewCalleeS contextswitch.cpp 99 0x6b2c7888
    15 coro_init coro.c 91 0x6b2c8383
    16 ?? 0 0xabababab
    17 ?? 0 0xabababab
    18 ?? 0

    Any idea, Lamperi? =/ Already got mad at this x: Line 155 of battlerby.cpp is this: foreach(int i, playersByOrder) {
     
  6. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Hey Apple! Long time i don't write here. Anyways, for what i've been discussing:

    "sql.createIfNotExists(table_name, col1, col2, col3, ..)
    sql.getRows(table_name, where clause) //Returns an array of objects like {col1: val1, col2: val2, ...}
    sql.removeRows(table_name, where clause)
    sql.existRow(table_name, where clause)
    sql.updateRow(table_name, where clause, val1, val2, val3, ..)
    sql.insertRow(table_name, val1, val2, ...)"

    Fine, i can look into it, doesn't seems to be pretty hard. But i still think we should (we can discuss it with some other people such as Lamperi before i do it) be able to set a separate Database from the Server's one.
     
  7. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Just use a separate database from the pokemon one for scripts, and make all the script sql commands use that database?
     
  8. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    So, instead of using sys. It's a new QObject which contains all the database stuff, right? (Like Actual ScriptEngine but instead calling it SQLEngine)

    class SQLEngine : public QObject
    {
    [...]
    }

    sql.foo1()
    sql.foo2(foo1, foo2, foo3, ...)
    sql.foo3(foo1, foo2, foo3, foo4, foo5)
     
  9. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
  10. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    this looks great actually
     
  11. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    A stupid question, but, if it takes time to check something in a database, does it hang the server?
     
  12. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    If you do it in the main thread yes, but there's already background threads to work with the server. Do things in background if possible.
     
  13. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    First time i think about something! Yay, knew i had to do it in a QThread. :x
     
  14. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Actually you do it in a qthread only for asynchroneous stuff, otherwise do it in the main thread. (Maybe give the two options to the script user)
     
  15. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    One SQL statement is not too slow, but if they grow or returns lots of stuff then it should be better to asynchronize them.
     
  16. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    @coyo Are the crashes on XP still there?
     
  17. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168