Jump to content

Blogs

Our community blogs

  1.  

    English -> Ingles

    Arabic -> Arabe

    Czech -> Chéco

    Danish -> Noruego

    German -> Alemàn

    Greek -> Griego

    Spanish -> Español

    Finnish -> Danes

    French -> Francés

    Croatian -> Croata

    Hungarian -> Húngaro

    Italian -> Italiano

    Japanese -> Japones

    Korean -> Coreano

    Dutch -> Holandes

    Polish -> Polaco

    Russian -> Ruso

    Portugese -> Portugues

    Brazilian -> Portugues brasileño

    Romanian -> Rumano

    Slovacian -> Eslovaco

    Swedish ->sueco

    Turkish -> Turco

    Indi/Indian -> Indio

    Chinese -> Chino

    Argentinian -> Argentino

    Mexican -> Mexicano

    Valencian -> Valenciano

    Catalonian -> Catalan

    Bulgarian -> Bulgaro

    Chadian -> Chadiense

    Haitian -> Haitano

    Colombian -> Colobiano

    Egyptian -> Egipcio

    Hon Kong -> Kon konense

    iraq -> Iraqui

    Jamaican -> Jamaicano

    Malvinas -> Malvinian

    Nepal -> Nepalese

    Puerto rico -> Puerto riqueño

    Zimbawe -> Zimbawense

  2. The Background

    I'm a professional developer using mainly C#. On the side, I write a ROM editor using VB.Net. They're very similar thanks to them mostly wrapping the .Net Framework, and because of how complex this application is, I'm in no hurry to rewrite it. This application knows the ins and outs of a few dozen file types and can, well, edit them. One such file type is a compiled LUA script. In order to edit these, they must first be decompiled. Rather than try to figure out that myself, I use a 3rd party tool that can do that for me (sometimes the best code is the code you didn't have to write). To use it, I point it to the compiled script on disk, and it spits out the decompiled text into its standard output. Integrating with it is simple thanks to .Net: I can use a Process object to start it, redirect its standard output, and read the decompiled text as it's written. This is all part of a larger process, where transparent to the user, I decompile a bunch of these scripts, automatically make some changes, and recompile them, all in one go, so people can play a game using different characters.

    A few days ago, I did some refactoring to it so I can more easily get notified of unsuccessful exit codes when recompiling (previously the program would just continue fine, and any files with syntax errors would simply remain unmodified). Unfortunately for me, I was in a hurry and didn't test anything except that program before I pushed the change to the master branch and let my CI server publish a development build, currently the only way for people to get precompiled versions of my application. (The CI server is Team City, since they've generously given me unlimited everything with my open source license.) Also I don't have any tests covering this part of the code.

    The Problem

    One of my application's users encountered some (well, dozens) of exceptions when my program tried to recompile the decompiled scripts. I try reproducing the issue, and I indeed find a syntax error in the same spot the newly-created error message said it was. After looking closer, I found the issue was there before the decompiled scripts were automatically modified. The script looked something like this:

    function addTheNumbers(numberA, numberB)
    function addTheNumbers(numberA, numberB)
      return numberA + numberB
      return numberA + numberB
    end
    end
    print(addTheNumbers(10, 20))
    print(addTheNumbers(10, 20))

    It should be fairly obvious what the problem here is. The lines are doubled. I facepalm on the inside and start investigating.

    The Adventure

    Because the code I changed is being called about a dozen times on different threads, I did the responsible thing and wrote a test for it. After getting my test to fail for the right reason, I look at my code, and here's what I see:

    image.png

    That looks like pretty standard stuff. The variables "captureConsoleOutput" and "captureConsoleError" are both true, telling the Process to redirect standard output and standard error, and the code will proceed to register event handlers. When I place breakpoints on the event handlers, I find that they're being hit twice per line the LUA decompiler writes. I scour the code and make sure that I only call Start once, and the event handlers are only added once as shown.

    I tried a bunch of other things too. What you see above is actually after another thing I tried. Previously, I was dumping standard output and error into the same StringBuilder , in case the program was outputting to both for some reason.

    I finally went to GitHub to check what actually changed when I did the thing mentioned in The Background above, and while it was a substantial change to the class shown above, it all seems pretty sane. But then I spot it. One crucial thing that didn't change.

    image.png

    Oh. The event handler was registered twice. I added lines 39 and 40 (the two AddHandler lines) and forgot completely about the Handles clause.

    How Events Work And Why It Took Me So Long To Spot This

    Events are magical things that can be called, and event handlers that have been registered to the event are run, being given the data that was provided when the event was called. This isn't so much like method calls as it is interrupts.

    The syntax for adding an event handler in C# looks like this:

    myEvent += myEventHandlerMethod;

    And the syntax for adding an event handler in VB.Net looks like this:

    AddHandler myEvent, AddressOf myEventHandlerMethod

    Usually C# and VB.Net are very similar thanks to the .Net Framework, but sometimes there are some differences, where one language can do a thing that the other cannot.

    There are some gotchas when it comes to events, so they need to be used with care. .Net is a framework that tries its best to clean up after you and prevent memory leaks. Simply remove all references to an object, and .Net makes it go away. But when you register an event handler to an event in another class, that event handler has a reference to the event, and by extension the class. If you get rid of the references to that class, the reference to the event is still there, and .Net can't clean it up. But you also can no longer remove the event handler since the reference to the class is gone. That's why it's important to remove event handlers as you would pointers in C/C++.

    The syntax for removing an event in C# looks like this:

    myEvent -= myEventHandlerMethod;

    And the syntax for removing an event in VB.Net looks like this:

    RemoveHandler myEvent, AddressOf myEventHandlerMethod

    To help make managing this easier, VB.Net has some extra syntax. Instead of manually adding event handlers, you can declare a variable as WithEvents, then use the Handles clause on a method, like so:

    Private WithEvents _myMemberVariable As SomeRandomClassWithEvents
    
    Private Sub _myMemberVariable_OnPropertyChanged(sender as Object, e as PropertyChangedEventArgs) Handles _myMemberVariable.PropertyChanged
        'Do the thing
    End Sub

    With no additional setup, when I assign something to _myMemberVariable, _myMemberVariable_OnPropertyChanged will automatically be run whenever _myMemberVariable.PropertyChanged is raised. If I change _myMemberVariable to some other SomeRandomClassWithEvents, it'll take care of removing the old handlers and adding the new ones for me. And setting _myMemberVariable to Nothing (aka null) will clean it up for me.

    I've been using C# a lot more lately, I've had to start doing events the old fashioned, no hand-holding way. I've been doing it for long enough now that I forgot to even check for the Handles clause when all evidence pointed to an event handler being registered twice.

    VB.Net is a fine language, and IMO it's easier to read and easier to type (not having to constantly type '{' and ':' when simply pressing enter works instead). However, it no longer has language parity with C#, meaning C# will continue to evolve, and VB.Net won't grow with it. The future is C#, and it's sad to see VB.Net be left behind.

    Guess I'll have to get around to rewriting this thing for it to be part of the future.

    • 2
      entries
    • 5
      comments
    • 616
      views

    Recent Entries

    theFlash899
    Latest Entry

    What do u like the most please tell me 

    Mario or Lugi

    i prefer Mario because he is a really good character to play with and that i also think that Lugi is a weird character to play and that i do not like him that much i am not that interested in him

     

  3. Author's Note: This is just a fun opinion piece, with very little facts substantiating my claims. More of a 'speaking from my experience' type of thing.

    Back when Neo Destiny was first up for purchase on my sunny little island, I was excited. Finally, the return of the Dark Pokémon, and also the introduction of Light Pokémon!
    Unbeknownst to me at that time, Shining Pokémon was also a secret part of the expansion. When I pulled my first Shining Celebi from a booster pack, I was thrilled to bits!
    But something felt pretty off to me: why does this card even exist?

    shining celebi card.PNG
    Image source. Chose this image, cause it shows the glittering effect.

    Shining Gyarados was in Neo Revelation possibly due to it's prominent role in the story of Gold, Silver & Crystal at the Lake of Rage. Heck, Neo Revelation's expansion symbol, booster artwork, and also card artworks heavily features the Legendary Beasts roaming throughout Johto (which potentially shows that the TCG was following the games or anime lore closely).
    All the other shinies in Neo Destiny can be encountered in-game (plus Shining Noctowl was also possibly referencing Ash's Shiny Noctowl in the anime), so why does the Shining Celebi card even exist, given it couldn't be encountered in-game?

    Of course, since I was then only exposed to the English/International versions of both the TCG and Pokémon Crystal, it was natural that this question weighed on my mind, as the card's existence was lacking context. Context that could have been much more clearer to me if I was living in Japan.


    Pokémon Crystal in Japan has connectivity to the now defunct Mobile System GB service, which updates an in-game message board every month.
    Between the months of April and May of 2001, the message on the news machine will be updated to show something that translates to "The present which exceeds time" 1.
    It was only for that period, that players will receive the GS Ball, and that can only occur after you beat some mini-game and quiz, which was only possible with a game save that has all 16 badges.
    Now, Neo Destiny was released in Japan in March 2001 2. In this timeline underlined, this card could have easily been foreshadowing the fact that players have a chance to get Shining Celebi in Ilex Forest via the event.

    And before anyone points out to that "Hey, the expansion before it, Neo Revelations, already had Celebi in it", I will like to in turn point out other key date's along our timeline:
    1. Players in Japan could first receive Celebi on their copies of Gold and Silver at a real life event in August of 2000 3.
    2. Neo Revelation in Japan was released in November 2000 4.

    Given how these events typically goes, the DVs are likely fixed, hence said previous event would have yielded only non-shiny Celebi.
    Hence based on the timeline above, players likely already knew of the existence of Celebi, but probably never seen a Shining Celebi (without hacking), not until that Shining card was first released.

    At this point, some of you may be thinking "So what?". To answer that, here is a currently unavailable Shining Pokémon that was showcased officially by the TCG before it was released to the games.

    shining volcanion.PNG
    Image source. Once again, I chose this image, cause it shows the glittering effect.

    The expansion Shining Legends was released July 2017 in Japan 5, and it was the first time in years they brought back the "Shining" prefix to the TCG series.
    Curious enough, Shining Volcanion was given a card when a distribution for it's equivalent in the core series games have yet to be done.
    And as of the date January 2018, players have yet to receive a Shining Volcanion in-game, to go with the card.

    In recent years, it is not uncommon to have a "Shiny lock" broken for the game, and be commemorated by a close release of the TCG equivalent:
    1. Shining Tapu Koko event was first released to Japan in March 2017, with the card equivalent (GX and standard) available concurrently
    2. Shining Xerneas and Shining Yveltal common serial code event ran unceremoniously in October 2016, and the cards was obtainable in July 2016
    (international versions got the Shiny Kalos Tins and the game variants pretty much concurrently, I may add.)
    3. Shining Genesect event released in Japan July 2013 to promote the movie, and the promo cards was released concurrently.

    Additionally, such types of TCG and event gift tie-ins have been occurring for other shinies as well:
    1. Shiny Silvally Event being Sep 2017 in Japan, and it's card released in the same month (GX and standard)
    2. Shiny Rayquaza Corocoro Event and the TCG campaign running concurrently in March 2015.

    It is possible for me to list non-shiny examples, to show other tied releases between TCG and events (Zoroark for EX Breakpoint, Lycanroc for Guardians Rising, Salazzle for Burning Shadows), but a bulk of these are non-Japanese, so I am not sure how relevant it would be to refer to it, when typically Japanese events breaks the shiny lock first.

    But of course, with any opinion piece, lies examples that tears through the flawed logic.
    For example, TCG alternate colored cards that did not get a game gift mirroring it's release in close proximity (random shinies like Blastoise from BW era, or Shining Arceus from the same Shining Legends expansion mentioned above, or even the limited edition Corocoro Shining Mew card from Neo Destiny era, Red Gyarados in EX Breakpoint).
    Or perhaps core series Shiny events that did not get a corresponding card mirroring it (Shiny Arceus's first release in Japan, Shiny Diancie in Japan, Shiny Jirachi event in Japan etc)

    In any case, as flawed as my logic may be, it still seems rather odd that in this era that games and cards are intimately mixing, that a card would break the shiny lock,
    but not have a corresponding event following it closely. I certainly do hope that an event for it is coming soon, as unlikely as that may be.
    So what do you think? Do leave your comments below!

    In any case, it may not be possible to get a Shining Volcanion any time soon, but if you want to obtain your very own Shining Celebi, it may be possible to get one with the upcoming Virtual Console release of Pokémon Crystal! Grab a copy on January 26, 2018!
     

    Text Sources:
    1. Regarding Celebi GS Ball Event dates. (
    link)
    2. Regarding Neo Destiny's Japanese name and launch dates. (link)
    3. First known Celebi event in Japan (link)
    4. Neo Revelation launch date (link)
    5. Shining Legends launch date (link)

  4. evandixon
    Latest Entry

    By evandixon,

    Today I learned about a feature in our new Gallery app: notes. The feature is best described using pictures.

    Capture.PNG

    One of the old Project Pokémon banners I had lying around, uploaded to a private album

    When your mouse is in the giant dark-gray area, there's some buttons. One of them is the Add Note button.

    Capture4.PNG

    The Add Note Button

    Clicking the Add Note button adds a transparent, resizable, and movable rectangle to the image, which comes with a text box that lets you add text.

    Capture3.PNG

    Once notes are added, they can be read by mousing over the image.

    Capture2.PNG

    • 0
      entries
    • 0
      comments
    • 503
      views

    No blog entries yet

  5. No blog entries yet

  6. No blog entries yet

    • 0
      entries
    • 0
      comments
    • 116
      views

    No blog entries yet

    • 0
      entries
    • 0
      comments
    • 81
      views

    No blog entries yet

    • 0
      entries
    • 0
      comments
    • 60
      views

    No blog entries yet

×