MapleScala

Page 1 of 4 1234 LastLast
Results 1 to 15 of 51
  1. #1
    Valued Member Minike is offline
    MemberRank
    Apr 2013 Join Date
    115Posts

    MapleScala

    I guess I have been lurking here to long again, so here I am to share something
    I have decided I wanted to learn Scala and the best way of doing such is obviously writing a source from scratch.

    The version I have chosen for is v83, simply because it is one of the version where public sources already exists for and it also has nice piece of nostalgic feeling to it.
    While I doubt I will be able to fling out a complete source, I will see how far I can get by smashing a few keys here and there

    After fighting a whole day with the lack of unsigned values, I managed to finish packet decryption, after that I threw it on Github, which its link can be found here;
    https://github.com/Yaminike/MapleScala

    The packages I will be using are;
    Akka, for its TCP and Actor handling
    Scalatest, for unit tests
    ScalikeJDBC, for database connectivity

    Any other packages I will probably figure out on the go.
    I wont be using any packages for the AES handling, as, well, I already wrote my own (as mentioned above)

    Feel free to help me out by creating pull request, but keep in mind this is a project that merily exists to easy my boredom.


  2. #2
    Proficient Member Borlea is offline
    MemberRank
    Jan 2014 Join Date
    151Posts

    Re: MapleScala

    Hopefully you continue this long enough for it to get somewhere, people usually lose dedication before that happens.

  3. #3
    Valued Member Minike is offline
    MemberRank
    Apr 2013 Join Date
    115Posts

    Re: MapleScala

    Quote Originally Posted by Borlea View Post
    Hopefully you continue this long enough for it to get somewhere, people usually lose dedication before that happens.
    Yeah, the major share of projects end up that way.
    Though I think sharing the crypto I wrote is quite useful on its own

    Anyhow, today wasted most of the day fixing crypto related bugs.
    Currently it seems sending any data causes the client to disconnect, so I will work on that tomorrow

    Update:

    Encryption / Decryption works now
    Last edited by Minike; 27-06-15 at 04:14 PM.

  4. #4
    Valued Member Burgundy is offline
    MemberRank
    Mar 2015 Join Date
    126Posts

    Re: MapleScala

    It's always refreshing to see new languages being utilized for maple sources. Scala seems quite interesting, I wish you the best.

  5. #5
    Valued Member Minike is offline
    MemberRank
    Apr 2013 Join Date
    115Posts

    Re: MapleScala

    I just pushed another update to git.
    Currently registering a PIN and using it to login works, I actually ended up writing quite a lot of code as unlike any Odin sources, I want a proper login system.
    All user authorization goes through a single class, the "AuthHandler", this so it would be easier to split the load between multiple servers in the future.
    I also encountered a few security flaws in MoopleDev, so I was quite entertained while doing this.
    Last edited by Minike; 28-05-15 at 11:05 AM.

  6. #6
    Account Upgraded | Title Enabled! Darter is offline
    MemberRank
    Feb 2008 Join Date
    253Posts

    Re: MapleScala

    Quote Originally Posted by Minike View Post
    Yeah, the major share of projects end up that way.
    Though I think sharing the crypto I wrote is quite useful on its own

    Anyhow, today wasted most of the day fixing crypto related bugs.
    Currently it seems sending any data causes the client to disconnect, so I will work on that tomorrow

    Update:

    Encryption / Decryption works now
    what IDE are you using?

  7. #7
    Valued Member Minike is offline
    MemberRank
    Apr 2013 Join Date
    115Posts

    Re: MapleScala

    Quote Originally Posted by Darter View Post
    what IDE are you using?
    I use IntelliJ as its one of the few IDEs that actually run Scala properly.
    Though on that image, I ran the server by starting it on activator

  8. #8
    jRvdJxwvjhs Linkerzz is offline
    MemberRank
    Nov 2008 Join Date
    NorwayLocation
    345Posts

    Re: MapleScala

    This is very interesting. Any updates?

  9. #9
    Valued Member Minike is offline
    MemberRank
    Apr 2013 Join Date
    115Posts

    Re: MapleScala

    Quote Originally Posted by Linkerzz View Post
    This is very interesting. Any updates?
    Most code up to character selection is finished, though I did not have any time yet to write anything beyond that.
    And as this is still a solo project, there has been little progress.

  10. #10
    Valued Member Minike is offline
    MemberRank
    Apr 2013 Join Date
    115Posts

    Re: MapleScala

    Today I ported @aaronweiss his PKGNX to Scala, mainly because I found the XML reading support of Scala to be utterly horrible.
    Though I have only added the Lazy loading variant and non-audio / bitmap types

    I also got characters to display (without equips) and they are loading from the database

  11. #11
    Account Upgraded | Title Enabled! aaronweiss is offline
    MemberRank
    Apr 2012 Join Date
    351Posts

    Re: MapleScala

    You do know that Scala has complete interoperability with Java, right? There's no reason to make a non-specification-compliant version of pkgnx just to use Scala. This is especially relevant because what you wrote is not even idiomatic Scala as it's in Java-style (idiomatic Scala is functional!).
    Last edited by aaronweiss; 25-06-15 at 04:44 PM.

  12. #12
    Valued Member Minike is offline
    MemberRank
    Apr 2013 Join Date
    115Posts

    Re: MapleScala

    Quote Originally Posted by aaronweiss View Post
    You do know that Scala has complete interoperability with Java, right? There's no reason to make a non-specification-compliant version of pkgnx just to use Scala. This is especially relevant because what you wrote is not even idiomatic Scala as it's in Java-style (idiomatic Scala is functional!).
    I ported it to Scala 1 on 1 for now so I have the possibility of changing it later.
    I am fully aware Scala has interoperability with Java, but like I said, this way I would lose the freedom of directly editing it as Scala.

    On a side note;
    The tone in your post is set completely wrong, so I would like to ask you to other be helpful or not reply at all.
    As like I mentioned, I have no previous experience with Scala, so you are just behaving like a complete ass to somebody who is still learning.
    But if you happen to have any good tips or hints, please feel free to post those.

  13. #13
    Proficient Member LazyBui is offline
    MemberRank
    Apr 2008 Join Date
    Illinois, USLocation
    156Posts

    Re: MapleScala

    Quote Originally Posted by Minike View Post
    I ported it to Scala 1 on 1 for now so I have the possibility of changing it later.
    I am fully aware Scala has interoperability with Java, but like I said, this way I would lose the freedom of directly editing it as Scala.
    You're not editing it as Scala. You're writing Java. If that was an important freedom, why didn't you just do that at the outset?

    Quote Originally Posted by Minike View Post
    The tone in your post is set completely wrong


    Quote Originally Posted by Minike View Post
    so I would like to ask you to other be helpful or not reply at all.
    As like I mentioned, I have no previous experience with Scala, so you are just behaving like a complete ass to somebody who is still learning.
    You could at least change the license if you're going to copy-paste the entire thing and call it your own. Previous experience with Scala does not have anything to do with what he's saying.

  14. #14
    Proficient Member LazyBui is offline
    MemberRank
    Apr 2008 Join Date
    Illinois, USLocation
    156Posts

    Re: MapleScala

    You might have actually wanted to view the source before you start spouting baseless things

    https://github.com/Yaminike/MapleSca...X/NXFile.scala
    I'm not sure how to reply to a visitor message and it doesn't seem like you have them enabled, so I'll have to respond here.

    I realize that you may be slightly stupid, but do you understand what the word baseless means?

    https://github.com/aatxe/pkgnx/blob/...nx/NXFile.java
    https://github.com/Yaminike/MapleSca...X/NXFile.scala
    Imgur

    Baseless means that there is no evidence for the claim.

    They are exactly the same. This is as far from baseless as it gets. There is direct and irrefutable evidence that they are the same. Your suggestion that it is baseless is baseless.
    Last edited by LazyBui; 25-06-15 at 06:41 PM.

  15. #15
    Account Upgraded | Title Enabled! aaronweiss is offline
    MemberRank
    Apr 2012 Join Date
    351Posts

    Re: MapleScala

    Quote Originally Posted by Minike View Post
    I ported it to Scala 1 on 1 for now so I have the possibility of changing it later.
    I am fully aware Scala has interoperability with Java, but like I said, this way I would lose the freedom of directly editing it as Scala.
    The library is 100% feature-complete, seeing as we invented the format. I don't see a particular reason why you'd bother copy-pasteing all of my code and then updating the syntax. Also, please remove attribution to me on this code that I did not write, and change the name of the library in your project. It's a derivative work. I'm not responsible for it. It is not in any way associated with me.

    Quote Originally Posted by Minike View Post
    The tone in your post is set completely wrong, so I would like to ask you to other be helpful or not reply at all.
    Thank you, tone police.

    Quote Originally Posted by Minike View Post
    As like I mentioned, I have no previous experience with Scala, so you are just behaving like a complete ass to somebody who is still learning.
    I'm behaving like an ass because I said that you wrote this in Java style? Ok then.

    Quote Originally Posted by Minike View Post
    But if you happen to have any good tips or hints, please feel free to post those.
    You use Java-style inheritance like so:

    Code:
    class NXLongNode(override val name: String,
                     override val file: NXFile,
                     override val childIndex: Int,
                     override val childCount: Int,
                     val reader: BufferedReader)
      extends NXNode(name, file, childIndex, childCount) {
    
      final val value = reader.getLong
    
      override def get(): Long = value
    
    }
    Use a trait like so:
    Code:
    sealed trait NXNode(name: String, file: NXFile, childIndex: Int, childCount: Int)
    case class NXLongNode(name: String, file: NXFile, childIndex: Int, childCount: Int, value: Long) extends NXNode(name, file, childIndex, childCount)
    ...
    You allow things to be null:
    Code:
    class NXNullNode(override val name: String,
                     override val file: NXFile,
                     override val childIndex: Int,
                     override val childCount: Int,
                     val reader: BufferedReader)
      extends NXNode(name, file, childIndex, childCount) {
    
      reader.skip(8)
    
      override def get(): Any = null
    }
    Use Unit (the only value of type Unit is ()) in this case.

    Code:
    def resolve(path: Array[String]): NXNode = {
        var cursor: NXNode = getRoot
        for (piece <- path) {
          if (cursor == null)
            return null
          cursor = cursor.getChild(piece)
        }
    
        cursor
      }
    Use Option!

    On that note, you also use Java-style iterators and for loops.

    Code:
    for (node <- reader.resolve("MakeCharInfo.img/Info")) {
          for (subNode <- node) {
            // CharFemale | CharMale
            for (valueNode <- subNode) {
              val value = valueNode.asInstanceOf[NXLongNode].get()
              if (value > 1e6)
                allowedEquips += value
            }
          }
        }
    Use maps and folds!

    Also, if you use traits, you won't have to write garbage like this:
    Code:
    valueNode.asInstanceOf[NXLongNode].get()
    You also have mutability everywhere. The whole thing should be stateless. You don't need state at all for this task!

    EDIT: adding more things

    You keep writing unnecessary things like keywords for constructor parameters.

    Code:
    class LazyNXFile(val buffer: ByteBuffer)
    can just be
    Code:
    class LazyNXFile(buffer: ByteBuffer)
    You have an empty Iterator.

    Code:
    final class EmptyNodeIterator
      extends Iterator[NXNode] {
    
      override def hasNext: Boolean = false
    
      override def next(): NXNode = null
    }
    This is normal crufty Java boilerplate, but if you used Seq, you wouldn't need this.
    Last edited by aaronweiss; 25-06-15 at 06:54 PM.



Page 1 of 4 1234 LastLast

Advertisement