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
    Latios development thread

    - ¡Hello! This is my development thread, in this first post i'll show what i've done (Not much since my knowledge of Qt isn't that big and i'm still learning C++) but i'll do all what i can.
    Also here i'll discuss if i have any problem or about some ideas for the Simulator. Asking, is the best way to learn! So i'll keep this updated now. :-)
    I'll try to learn more to help more to the development of simulator! Sorry if my programming is somewhat bad. :-(

    Things done
    • sys.changePokeNature(playerId, pokeSlot, natureNum)
    • sys.teamPokeNick(playerId, pokeSlot)
    • Now Move Information in Battle shows Category. (Coyo helped me with some problems :-))
    • Get Battle Data Functions (Basically, they we're removed for now ;))
    • Server-side System Tray
    • Goto line for Script Editor
    • Sort channels by name
    • Disable Private Messages
    • sys.hostName(ip, name)
    • Reconnect feature fixed
    • Disable PMs
    • --------------------- Stuff done but yet not released ---------------------
    • Now database members have expiration time
    • sys.dbExpire(name)
    • sys.updateDatabase()
    • Tabbed PMs
    • Fixed server crash when closing
    • Fixed crashing when trying to switch authority when there's no selected member
    • Private Messages Logs
    • Fixed Replays Name
    • Moved registry to new network protocol (DataStream, etc, etc)
    • Added an extra byte on Login command to tell if server is locked
    • Now Registry shows if server is password protected
    • Registry Announcement
    • sys.sha1(text)
    • Now registry opens server descriptions / announcement link with default browser instead of in-server-listing.
    • The width of the header in server choice are now saved. Same for the server choice size.

    Things to do
    • Reconnect to battles

    On to-do list
    • Something like PSID in NetBattle, an unchangeable ID
     
    Last edited: Feb 19, 2012
  2. Slipperjeans

    Slipperjeans Loose pants

    Joined:
    Jun 27, 2010
    Messages:
    448
    Likes Received:
    0
    Spoiler tags are [.secret]
     
  3. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Coyo:

    Code (text):
    1.  
    2. return myserver->player(id)->team().poke(index).shiny();
    3.  
    Why it returns true when it should return false?
     
  4. Slipperjeans

    Slipperjeans Loose pants

    Joined:
    Jun 27, 2010
    Messages:
    448
    Likes Received:
    0
    Forgot to say it before, good luck as a dev! Now make me some functions plx.
     
  5. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    I'm not like Mystra. I'm like

    Mystra: 100%
    Latios: 2%

    :D

    Get on MSN.
     
  6. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Code (cpp):
    1.  
    2.  
    3. QScriptValue ScriptEngine::getBattleDataHP(int id, int pokeslot)
    4. {
    5.     if(!loggedIn(id) || pokeslot < 1 || pokeslot >= 6) {
    6.         return myengine.undefinedValue();
    7.     }else{
    8.         return BattleSituation::getHPData(id,pokeslot);
    9.     }
    10. }
    11.  
    It's bugging me with "cannot call member function 'bool BattleSituation::getHPData(int, int)' without object"
     
  7. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    It means that getHPData is not a static member of a class therefore it can only be called from actual object only. i.e. someobject->getHPData(blah, blah).
     
  8. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

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

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Uh... I just tryed that.

    Like this:

    Code (CPP):
    1.  
    2. BattleSituation->getHPData(id,pokeslot);
    3.  
    Hm, with that i got "expected unqualified-id before '->' token"

    Just wait, i'm still in learning and try process. ^.^
     
  10. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    does the getHPData function even exists?

    And remember somebody can have several battles going on, so you must find the right battle and get that one with someone like server->battle(battleid). But even then getHPData and all don't exist.
     
  11. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Code (CPP):
    1.  
    2. bool BattleSituation::getHPData(int player, int slot)
    3. {
    4.     PokeBattle &p = this->poke(player,slot);
    5.     return p.lifePoints();
    6. }
    7.  
    :D?
     
  12. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    BattleSituation is not an object, it's a class :} You need an instance of that class to work with. i.e. you need to learn where is it in PO.
     
  13. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    This function is dangerous because of threading problems @_@

    You have to make sure this particular battle isn't executing a turn at the same time, and if it is, wait till it's executed... Yummy stuff.
     
  14. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Hmp, for now i think i'll leave it in to do list.
     
  15. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Hmp. i should do:

    sys.getBattleData(playerId, pokeSlot, value2return) -> sys.getBattleData(src, 1, "HP");

    or do:

    sys.getBattleDataHP()
    sys.getBattleDataPP() etc?
     
  16. Slipperjeans

    Slipperjeans Loose pants

    Joined:
    Jun 27, 2010
    Messages:
    448
    Likes Received:
    0
    I think the first way is better
     
  17. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    I think other functions use something akin to 1st one. I'm not sure at the moment but stat there is not a string, but a number.

    Check setTeamPokeDV(), teamPokeDV(), teamPokeEV().
     
  18. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Code (cpp):
    1.  
    2. "WTF GOES HERE?!" callGetDataHP(BattleSituation & situation, int id, int pokeslot)
    3. {
    4.     QString valuetoreturn;
    5.     valuetoreturn = situation.getHPData(id, pokeslot);
    6.     return valuetoreturn;
    7. }
    8.  
    void: Can't be since it doesn't return values.
    bool: Can't be, it returns true or false.

    I got stuck...
     
    Last edited: Jan 1, 2011
  19. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Since your valuetoreturn is QString then it is QString. Are you sure it shouldn't be an int? I don't know what's getHPData() though :}

    Oh, and if you want just return a value you don't need to store it. Just use

    Code (cpp):
    1. return situation.getHPData(id, pokeslot);
     
  20. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Code (CPP):
    1.  
    2. QScriptValue ScriptEngine::getBattleData(int id, int pokeslot)
    3. {
    4.     if(!loggedIn(id) || pokeslot < 1 || pokeslot > 6)
    5.     {
    6.         return myengine.undefinedValue();
    7.     }else{
    8.         return callGetDataHP(BattleSituation, id, pokeslot);
    9.     }
    10. }
    11. int BattleSituation::getHPData(int player, int slot)
    12. {
    13.     PokeBattle &p = this->poke(player,slot);
    14.     return p.lifePoints();
    15. }
    16.  
    17. int callGetDataHP(BattleSituation & situation, int id, int pokeslot)
    18. {
    19.     return situation.getHPData(id, pokeslot);
    20. }
    21.  
    in callGetDataHP, i've tryed int and QString. Both gave me errors in return callGetDataHP(BattleSituation, id, pokeslot); which are:

    "expected primary-expression before ',' token" and "'callGetDataHP' was not declared in this scope"

    PS: Happy New Year ^.^
     
  21. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    If you don't need to change it it should be const BattleSituation & situation. Well, just in case. I don't know, maybe you do need it (^ ^)

    Are you sure you need callGetDataHP() and not use what's inside directly?

    Also, BattleSituation is a class, not an object. Are you familiar with object oriented programming? Maybe you need to read a few pages on wikipedia if you don't.

    EDIT: Happy New year :)
     
  22. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    ^.^ Thanks for help Mystra. I think i got all the rest of the "code".

    btw, any better form to call the "code"? Lol

    PS: Thanks to you and Coyo i'm learning much more about C++ :)
     
    Last edited: Jan 1, 2011
  23. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Hmm?
     
  24. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Nvm, don't know how to explain x)
     
  25. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    I added your changes with mystra's :)

    Not the getBattleInfo things though as it's not complete yet.
     
  26. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    When i finish them, if you add them. Put "MADE BY LATIOS (USE AT YOUR OWN RISK!) " xD
     
  27. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    We already have one "use at your own risk" function, for other reasons though XD
     
  28. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Which one? :0 :curious:
     
  29. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Code (CPP):
    1.  
    2.  
    3. int BattleSituation::getHPData(int player, int slot) const
    4. {
    5.     const PokeBattle &p = this->poke(player,slot);
    6.     return p.lifePoints();
    7. }
    8.  
    9. int callGetDataHP(const BattleSituation & situation, int id, int pokeslot)
    10. {
    11.     return situation.getHPData(id, pokeslot);
    12. }
    13.  
    14. QScriptValue ScriptEngine::getBattleData(int id, int pokeslot)
    15. {
    16.     if(!loggedIn(id) || pokeslot < 1 || pokeslot > 6)
    17.     {
    18.         return myengine.undefinedValue();
    19.     }else{
    20.         return callGetDataHP(BattleSituation, id, pokeslot); // ERROR HERE T.T
    21.     }
    22. }
    23.  
    expected primary-expression before ',' token
    'callGetDataHP' was not declared in this scope

    :points at teh compiler: Why do j00 hate me?

    I need to learn more about those C++ Errors. :goes to google:
     
  30. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    changeName()

    BattleSituation is not an object. Read about OOP lol
     
  31. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    I'm scared now. :looks in the code:

    Code (CPP):
    1.  
    2. void ScriptEngine::changeName(int playerId, QString newName)
    3.  
    :hides:
     
  32. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
  33. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Reading is a virtue here :)
     
  34. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    ^

    HOW U SAY THAT!?

    Btw. Is there any possibility to change namez here? D: :3

    Btw2: :'( 2 New Errors came :hides:
     
  35. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Code (CPP):
    1.  
    2. QString ChallengeInfo::clauseBattleText[] =
    3. {
    4.     QObject::tr("Sleep Clause prevented the sleep inducing effect of the move from working."),
    5.     QObject::tr("Freeze Clause prevented the freezing effect of the move from working."),
    6.     QObject::tr(""),
    7.     QObject::tr(""),
    8.     QObject::tr(""),
    9.     QObject::tr("The battle ended by timeout."),
    10.     QObject::tr(""),
    11.     QObject::tr(""),
    12.     QObject::tr("The Self-KO Clause acted as a tiebreaker.")
    13. };
    14.  
    Missing Text? D:
     
  36. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    "Here" is where? (^ ^)

    As for clauses I don't know, I haven't looked much on that code.
     
  37. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Yeah here.

    btw. help me with those errors. x_x my heads hurts today.

    Code (CPP):
    1.  
    2. callGetDataHP(getHPData /* i think :D */, id, pokeslot);
    3.  
    callgetDataHP & getHPData not declared in this scope.

    aw... shet. I'm going to rest a little. Head hurts alot. :s
     
  38. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    getHPData? Wasn't it a function or something? (O.o)

    Have you put them in proper classes (if needed) and wrote prototypes?
     
  39. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Back ^-^ 30 Minutes sleep. :3 I feel fine now. :>

    Code (CPP):
    1.  
    2. int callGetDataHP(const BattleSituation & situation, int id, int pokeslot)
    3. {
    4.     return situation.getHPData(id, pokeslot);
    5. }
    6.  
    Hao thiz? :D Btw. Here's how the functions will be called:

    sys.battleDataPokeName(playerId, pokeslot);
    sys.battleDataPokeNum(playerId, pokeslot);
    sys.battleDataPokeHPLeft(playerId, pokeslot);
    sys.battleDataPokeMaxHP(playerId, pokeslot);
    sys.battleDataPokeMove(playerId, pokeslot, moveslot);
    sys.battleDataPokeMovePP(playerId, pokeslot, moveslot);
    sys.battleDataPokeMoveMaxPP(playerId, pokeslot, moveslot);

    I'm missing sumething? :'(
     
    Last edited: Jan 2, 2011
  40. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

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

    good luck