Coyo's development thread

Discussion in 'Development General' started by coyotte508, Aug 9, 2010.

  1. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

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

    This is more like a reminder to myself, and also so what you see what could come soon. You can comment of course, but please be useful ^_^

    Other programmers are free to steal some of my tasks if it's not in the "Things to do soon" part.

    Things to do soon

    - Work on 5th gen

    Things to do sooner or later

    - Update the French Translation

    Things to do eventually

    - Gens one and two
    - Redo the GUI as in Sgt. Padawan's thread
    - Curse and Encore in doubles - target selection
    - Fix the PPs of Mimic / then switching back / Bug (even though it doesn't have a competitive effect)
    - Redo the selection of pokemon in the Teambuilder

    Ideas for the future

    - Add battle replays
    - Give servers compatibility for IRC clients (only chatting of course)
    - Add plugins clientside for stylesheets and music

    Recent adds

    [secret]- Give an option to servers, to trade bandwith for lag. This is done by disabling Nagle's algorithm (see wikipedia), which buffers data until a response from the other is received.
    - Icon size reduced
    - Third generation
    - Tiers in a tree
    - Allow battlers to set the default tier of a team in the teambuilder
    - Add themes
    [/secret]

    Nitpicks

    - Ban thing
    - ladder thing
    - Spite's message in 3G
    - Raichu's VoltTackle + Egg move
    - Damage in doubles in 3G
    - Load team window open causing troubles - make it non modal
    - When forced into idle, the option in the menu bar isn't updated
    - 3G moves with 4G abilities for under evos

    Nitpicks fixed

    [secret] - sys.createChannel -> join it -> sys.kick everyone form the chan -> try to close it twice = crash
    - Toxic's failing message thing
    - Give 255 happiness to pokémons when they have return, when importing
    - Sprites when changing gen in 3G
    - Insomnia's failing message
    - Self-KO clause
    - Avoid generating move lists when checking a moveset everytime
    [/secret]

    I'll try to keep it a bit up-to-date.
     
    Last edited: Oct 7, 2010
  2. Gilad

    Gilad ¯\(°_°)/¯

    Joined:
    May 13, 2010
    Messages:
    378
    Likes Received:
    2
    i sent you the 22x22 icons already, i saved them on the internet and ot in my PC, so i can't zip it and send you. :\
     
  3. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    It's been fixed, thanks.
     
  4. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Did the long awaited Self KO clause ^^
     
  5. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
  6. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    You fixed that team builder bug with locked slots? Cool (^. ^) I wanted to do it once, but forgot… (^ ^)'
     
  7. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    It was really annoying :)
     
  8. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    What is used to make PO installer for Windows? It seems weird that there are so many errors about it. Maybe we should publish md5 checksums for it? And update it when new versions are out of course.
     
  9. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Inno Setup Compiler
     
  10. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Latest version? Hmm, let's try md5 way if you can (^ ^) How can Windows users check md5 sums I wonder…
     
  11. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    me too lol
     
  12. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    I dunno what changed in makefiles but I demand release branch that can be compiled.

    Code (text):
    1.  
    2. /usr/bin/ld: cannot find -lutilities
    3. collect2: ld returned 1 exit status
    4.  
     
  13. nixeagle

    nixeagle New Member

    Joined:
    Mar 21, 2011
    Messages:
    11
    Likes Received:
    0
    Should be fixed as soon as coyotte merges the makefile changes in my branch to the release branch.

    My theory as to why things broke is at the time coyotte508 merged origin/nixeagle into origin/release and origin/master I had a broken makefile in my branch.

    Vie discussions on PO we know the makefile in origin/nixeagle works. :)
     
  14. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    RAWR! XD
     
  15. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    And this is why i'm mad. D:
     
  16. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    What do you think, would that be possible to extend sys.stopEvent() with an optional parameter 'reason'? Like, sys.stopEvent("Reason text here."). And then use that message in some events like before login, so that client get the message printed? Or… somehow make it possible to do a sys.send* functions to work when you call sys.stopEvent() in before login event.
     
  17. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    it's just the socket system that closes the connection too early, nothing to do with scripts. With boost sockets it happens a lot less.
     
  18. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Oh… I'll look when Boost sockets will be stable for us then. If not… maybe some string can be send with the event itself. Assuming it is stored somewhere. We'll see then. Thanks (^. ^)
     
  19. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Even if the problem with boost sockets remain, the solution is not in scripts. It's in handling qt sockets a different way, as in waiting for the disconnect signal before deleting it (and put a maximum time of like 5 seconds) but any change to that has to be done with utmost care.
     
  20. Pokemonexperte-Martin

    Pokemonexperte-Martin Member

    Joined:
    May 15, 2010
    Messages:
    76
    Likes Received:
    0
    What exactily is the socket problem?
     
  21. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Actually the crash appeared to probably not be related to boost sockets. And the general problem is that when sockets are closed, i delete them instead of waiting for some signals so all connections are interrupted and they don't get the last message sent to them sometimes (which may be kicking message or message saying server is full). This doesn't happen with boost sockets for which you can set a "linger time".
     
  22. Pokemonexperte-Martin

    Pokemonexperte-Martin Member

    Joined:
    May 15, 2010
    Messages:
    76
    Likes Received:
    0
    Did you try qsocket.waitForDisconnected(); ?

    (Just a side node?!) When using SFML, lowTCPDelay could be guilty...

    If you really need linger: there is no api method in Qt, but you can do it yourself low-level.
    See http://www.qtcentre.org/threads/3037-qt-network-performance?p=16565#post16565 (Disable the Nagle (TCP No Delay) algorithm)

    and

    Code (text):
    1.  
    2. struct linger l;
    3. l.l_onoff = 1;
    4. l.l_linger = 30;
    5. setsockopt(sockID, SOL_SOCKET, SO_LINGER, &l, sizeof(l));
    6.  
     
  23. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Don't worry...
     
  24. Blastcore

    Blastcore Developer

    Joined:
    Jul 19, 2010
    Messages:
    763
    Likes Received:
    1
    Hm? I've been looking the new posts, but? I missed something?

    Sorry again, Coyo, Mystra... School is killing me off Q_Q Fuu exams, exams and more exams.
     
  25. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Well, it's not that I'm that active ATM %)
     
  26. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    1 day window before release. DO IT NAO!
     
  27. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Then make a sticky in developer's den with release schedule, and I post one day before?
     
  28. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
  29. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    [​IMG]Drag and drop works now for QRCode stuff!
     
  30. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    /me has Unaware… (^ ^)'
     
  31. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    PO Client can export teams through QR Code, with a client plugin.

    Now you can drag directly from it onto the desktop or a file uploader, so that it can be used in RMTs much more easily. (You had to screenshot, cut, and all before)
     
  32. Lamperi

    Lamperi I see what you did there

    Joined:
    Apr 25, 2010
    Messages:
    2,647
    Likes Received:
    11
    At least you can with newest Windows client ^_^
     
  33. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Doesn't work on linux/mac?

    Otherwise, here is what I'm really going to work on from now on: the battle logging system.

    So here is what I'm going to do:

    have a class called ConvertInput
    have a class called BattleManager
    have a class called BattleData
    have a class called BattleScene
    have a class called BattleOutput

    All the classes will communicate through the use of commands. Now that I think about it, it resembles Qt's Signals & Slot mechanism, but I didn't think about that at all when planning this.

    A command is basically an enum (to identify the function called) with a tuple of variadic template arguments (first time I'll get to use those, seriously hope minGW supports them now. Otherwise I'll create like 9 different functions, not death).

    Each class will store its function pointers in HashTables, which allows classes to implement only some of the functions. When a function is called, it checks the hashtable, if it's there then it calls the function with the template arguments in the command.

    The advantage of commands is redirecting and storing them, without any code duplication. Since it's pretty much really interoperable, all classes answer to the same protocols. BattleOutput, BattleScene will be able to convey commands to data or not, allowing for example each of them to have their own BattleData, have a shared BattleData, or have a BattleData supplied with info by something else. I really like the fact to be able to establish/cut connections between objects. For example, too, commands can be used in a battle scene to create a scope of battle datas containing the future states one by one, examine them, and decide how to proceed, if the battle scene needs some foreknowledge before animating. (Like making foes lose HP at the same time in doubles)

    It also makes things very easy if you want to implement converters and all. BattleManager is basically a hub of commands, creating all the other elements needed and the connections between them. BattleData can handle commands just fine to update its state.

    Anyhow, here is THE PLAN: [​IMG]

    With that, we'll have everything at disposal: replays, logs in different formats stored server or client side, warstory maker, log analyzer, battle stats maker, possibility to add plugins pretty easily to the server to check what happens in a battle, and the base for future PO animations (and I looked at Qt Doc, actually it's very possible). Why not make a plugin to convert battle commands to something javascript could read, and python would just have to pass it through? (Far future, though) Tons of possibilities. AI being one of them too. I've got to give credits to aeo for his awesome replay viewer that made me realize part of this :o

    That means I will work a bit less on network protocol, but feel free to contribute to it w/o me. I will also have not much time for the webclient.

    This'll make me remember some metaprogramming, yay!

    Anyhow, I'm glad I got something I can invest myself in with enthusiasm, hope it won't fade down.
     
  34. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    I don't compile any plugins. They require Qt higher that 4.6.x last time it was mentioned here.

    EDIT: Mah diamond, y u take it, infidels!
     
  35. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Simple invocation relay & storage stuff: (not using function pointers anymore, pure template!)
    Code (c++):
    1. template <MyEnumValue, ...Params> void receiveCommand(...Args) {
    2.   if (shouldInvoke<MyEnumValue>(Args...)) {
    3.     invoke_function<MyEnumValue, Params...>(Args...);
    4.   }
    5.   for (output in myoutputs) {
    6.     output.receiveCommand<MyEnum MyEnumValue, Params...>(Args...);
    7.   }
    8.   if (shouldStore<MyEnumValue>(Args...)) {
    9.     commandList.append(new Command<MyEnumValue, Params...>(Args...));
    10.   }
    11. }
    12.  
    13. void unpackCommands() {
    14.   for (Command *c in commandList) {
    15.     c->apply_on(this);
    16.   }
    17. }
    18.  
    19. /* for each battle function */
    20.  
    21. void template<MyBattleFunctionEnumValue, ...Params> invoke_function(...Args) {
    22.    myBattleFunction(std::forward<Params...>(Args...));
    23. }
    24.  
    25. /* Battle Command storage */
    26.  
    27. struct AbstractCommand {
    28.     virtual void template<class T> apply_on(T & other) = 0;
    29. };
    30.  
    31. template<...Params>
    32. struct Command {
    33.     typedef std::forward<Params...> tupleType;
    34.    
    35.     Command(Params&&... params) : m_tuple(params...){
    36.     }
    37.    
    38.     void template<class T> apply_on(T &other) {
    39.         std::function f(void(T*, Params...)) = &T::receiveCommand<Params...>;
    40.         unpack_tuple<f, extend_tuple<&other, m_tuple> >();
    41.     }
    42.    
    43.     tupleType m_tuple;
    44. };
    45.  
    46.  
    http://stackoverflow.com/questions/...e-function-arguments?answertab=active#tab-top

    link above in order to unpack tuples.

    Not sure when to use && when unpacking.

    Maybe a wrapper for outputs to call proper invoke_command in order to not make every invoke virtual.

    That way it'll be pretty flexible. If you have no idea what I mean, wait till I do real code, I'm just posting this here as a keep-safe.

    Didn't find a way to use lambda functions yet. But variadic template are already pretty nifty. C++0x here I come!
     
    Last edited: Aug 30, 2011
  36. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    [secret]
    Code (C++):
    1. #include <utility>
    2. #include <iostream>
    3. #include <functional>
    4.  
    5. void print(const char* s) {
    6.   while (*s) {
    7.     if (*s == '%' && *++s != '%')
    8.       throw "invalid format string: missing arguments";
    9.     std::cout << *s++;
    10.   }
    11. }
    12.  
    13. template<typename T, typename... Args>
    14. void print(const char* s, const T& value, const Args&... args) {
    15.   while (*s) {
    16.     if (*s == '%' && *++s != '%') {
    17.       std::cout << value;
    18.       print(++s, args...);
    19.       return;
    20.     }
    21.     std::cout << *s++;
    22.   }
    23.   throw "extra arguments provided to printf";
    24. }
    25.  
    26. template <class T>
    27. class Foo {
    28. public:
    29.     template <class Y> void test(decltype(&Y::doStuff) ) {
    30.         ((T*)(this))->doStuff();
    31.     }
    32.  
    33.     template <typename Y> void test(...) {
    34.         print("Sweet victory\n");
    35.     }
    36.  
    37.     void testStuff() {
    38.         test<T>(NULL);
    39.     }
    40. };
    41.  
    42. class Test : public Foo<Test>
    43. {
    44. public:
    45.     void doStuff() {
    46.         print("Hello, success\n");
    47.     }
    48. };
    49.  
    50. class Test2 : public Foo<Test2>
    51. {
    52. };
    53.  
    54. int main()
    55. {
    56.     Test x;
    57.     Test2 y;
    58.     x.testStuff();
    59.     y.testStuff();
    60.  
    61.     return 0;
    62. }
    63.  
    [/secret]Found a way to test if a function belongs to a class. Wonderful!
     
  37. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    [secret]
    Code (C++):
    1. enum class {
    2.     LaySpikes,
    3.     RemoveSpikes,
    4.     InflictDamage
    5. } MClass;
    6.  
    7. class Invoker
    8. {
    9. public:
    10.     virtual void invoke(Command *){};
    11. };
    12.  
    13. class BattleInvoker<T> : public Invoker
    14. {
    15. public:
    16.     void invoke(Command *c) {
    17.         c->applyOn(this);
    18.     }
    19. protected:
    20.     template<class Y, std::same_type<void,decltype(&Y::laySpikes)> ,LaySpikes, int>
    21.     mReceiveCommand (int field) {
    22.         composite->laySpikes(field);
    23.     }
    24.  
    25.     template<class Y, int, LaySpikes, int> void
    26.     mReceiveCommand (...) {
    27.     }
    28. public:
    29.     template<MClass en, typename ...Params>
    30.     void receiveCommand(...Args) {
    31.         mReceiveCommand<T, 1, en, Params...>(Args...);
    32.     }
    33. protected:
    34.  
    35.     T *composite;
    36. };
    37.  
    38. class CommandManager
    39. {
    40. public:
    41.     CommandManager(Invoker *inv = NULL) : inv(inv) {
    42.  
    43.     }
    44.  
    45. protected:
    46.     Invoker *inv;
    47. };
    48.  
    49. template<>
    50. class BattleCommandManager : public CommandManager
    51. {
    52.     BattleCommandManager() : CommandManager(new BattleInvoker<BattleCommandManager>){
    53.  
    54.     }
    55. };
    56.  
    57. template<class T>
    58. class BattleCommandManager : public CommandManager
    59. {
    60.     BattleCommandManager() : CommandManager(new BattleInvoker<T>){
    61.  
    62.     }
    63. };
    [/secret]If I can specialize templates outside of class decl, it'll be even more win.
     
  38. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Can't virtual template functions.

    Still, can do stuff.
     
  39. coyotte508

    coyotte508 Well-Known Member Administrator Server Owner Administrator Server Owner

    Joined:
    Apr 21, 2010
    Messages:
    6,363
    Likes Received:
    168
    Did the base command headers with templates.

    A bit cryptic, I understand, but as soon as there will be battle classes it'll be easier.
     
  40. Mystra

    Mystra Active Member

    Joined:
    Jul 12, 2010
    Messages:
    1,389
    Likes Received:
    4
    Just to be sure… Current git code can be compiled right now to get a new release? With new github thing I'm no longer sure (^ ^)'