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
Coyo: Code (text): return myserver->player(id)->team().poke(index).shiny(); Why it returns true when it should return false?
Code (cpp): QScriptValue ScriptEngine::getBattleDataHP(int id, int pokeslot) { if(!loggedIn(id) || pokeslot < 1 || pokeslot >= 6) { return myengine.undefinedValue(); }else{ return BattleSituation::getHPData(id,pokeslot); } } It's bugging me with "cannot call member function 'bool BattleSituation::getHPData(int, int)' without object"
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).
Thanks. For learning Qt you can see Qt Demo, Qt Assistant, and the examples that are already in Qt Creator. You can also see Qt's doc at http://doc.qt.nokia.com/4.6/overviews.html. ^^
Uh... I just tryed that. Like this: Code (CPP): BattleSituation->getHPData(id,pokeslot); Hm, with that i got "expected unqualified-id before '->' token" Just wait, i'm still in learning and try process. ^.^
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.
Code (CPP): bool BattleSituation::getHPData(int player, int slot) { PokeBattle &p = this->poke(player,slot); return p.lifePoints(); } :D?
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.
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.
Hmp. i should do: sys.getBattleData(playerId, pokeSlot, value2return) -> sys.getBattleData(src, 1, "HP"); or do: sys.getBattleDataHP() sys.getBattleDataPP() etc?
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().
Code (cpp): "WTF GOES HERE?!" callGetDataHP(BattleSituation & situation, int id, int pokeslot) { QString valuetoreturn; valuetoreturn = situation.getHPData(id, pokeslot); return valuetoreturn; } void: Can't be since it doesn't return values. bool: Can't be, it returns true or false. I got stuck...
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): return situation.getHPData(id, pokeslot);
Code (CPP): QScriptValue ScriptEngine::getBattleData(int id, int pokeslot) { if(!loggedIn(id) || pokeslot < 1 || pokeslot > 6) { return myengine.undefinedValue(); }else{ return callGetDataHP(BattleSituation, id, pokeslot); } } int BattleSituation::getHPData(int player, int slot) { PokeBattle &p = this->poke(player,slot); return p.lifePoints(); } int callGetDataHP(BattleSituation & situation, int id, int pokeslot) { return situation.getHPData(id, pokeslot); } 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 ^.^
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 :)
^.^ 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++ :)
Code (CPP): int BattleSituation::getHPData(int player, int slot) const { const PokeBattle &p = this->poke(player,slot); return p.lifePoints(); } int callGetDataHP(const BattleSituation & situation, int id, int pokeslot) { return situation.getHPData(id, pokeslot); } QScriptValue ScriptEngine::getBattleData(int id, int pokeslot) { if(!loggedIn(id) || pokeslot < 1 || pokeslot > 6) { return myengine.undefinedValue(); }else{ return callGetDataHP(BattleSituation, id, pokeslot); // ERROR HERE T.T } } 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:
I'm scared now. :looks in the code: Code (CPP): void ScriptEngine::changeName(int playerId, QString newName) :hides:
Wow wtf. But...! Copypaste failed! @_@ there should be a getHPData :D i think http://en.wikipedia.org/wiki/Object-oriented_programming That too much :(
^ HOW U SAY THAT!? Btw. Is there any possibility to change namez here? D: :3 Btw2: :'( 2 New Errors came :hides:
Code (CPP): QString ChallengeInfo::clauseBattleText[] = { QObject::tr("Sleep Clause prevented the sleep inducing effect of the move from working."), QObject::tr("Freeze Clause prevented the freezing effect of the move from working."), QObject::tr(""), QObject::tr(""), QObject::tr(""), QObject::tr("The battle ended by timeout."), QObject::tr(""), QObject::tr(""), QObject::tr("The Self-KO Clause acted as a tiebreaker.") }; Missing Text? D:
Yeah here. btw. help me with those errors. x_x my heads hurts today. Code (CPP): callGetDataHP(getHPData /* i think :D */, id, pokeslot); callgetDataHP & getHPData not declared in this scope. aw... shet. I'm going to rest a little. Head hurts alot. :s
getHPData? Wasn't it a function or something? (O.o) Have you put them in proper classes (if needed) and wrote prototypes?
Back ^-^ 30 Minutes sleep. :3 I feel fine now. :> Code (CPP): int callGetDataHP(const BattleSituation & situation, int id, int pokeslot) { return situation.getHPData(id, pokeslot); } 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? :'(