User Tag List

Results 1 to 7 of 7

Thread: Any Other Way To Do This?

  1. #1
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jan 2011
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Any Other Way To Do This?

    I have decided to try to make an MMORTS game in lacewing and i came to a small problem. I have a map that needs to be populated with the X and Y coordinates of all of the user's planets. I have it set up so when they create their account, they drag and drop their planet to the location they wish to put it, and then I save the X,Y of the location of the planet.

    To populate the map, I thought the only way would be to create a channel named: (X,Y,Username) for every planet, and then loop through all of the channels and populate the solar system using the x,y of every planet.

    Is there a better way to do this? Or am I stuck with this method because I can't get the string parser to work as I would like.

    Thanks for all of the help!

  2. #2
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Any Other Way To Do This?

    First you need to answer a few questions:

    1. Are you using an mmf server? c++? Are you just having a client host?
    2. Where/how are you storing your data on the server? Just in channel names? Because those aren't going to save if the server crashed or gets restarted.
    3. What can't you do with the string parser?

  3. #3
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jan 2011
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Any Other Way To Do This?

    1. I am using Lacewing Ver. 18 (I believe it's the latest) I am having a server program host the server and the client program connect.
    2. I store user data on my server in an .ini file. If the client application needs any information, it must send a request for it.
    3. I need to take the x and y values out of the channel name, and create a planet in the solar system with those coordinates. I posted another thread asking how to do this, and didn't get it to work.

    Sorry I wasn't very clear on my first post. Hope this helps.

  4. #4
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Any Other Way To Do This?

    What you want to do is to have the player send a binary message to the server containing the x and y values. Like:

    Lacewing : Push short xvalue
    Lacewing : Push short yvalue
    Lacewing : Send binary to server on subchannel 0

    The server would receive the binary on subchannel 0, and then you could store the information in an ini file by setting the group name to the lacewing clientname (the user's name who sent the data) and then the planetx and planety would be the receieved binary data (ie, Short("Lacewing", 0) and Short("Lacewing", 2)

    So if the username was "Test" and the xvalue was 500 and the yvalue was 850, your server's ini would look like this:

    [Test]
    planetx=500
    planety=850

    You'd also probably want to have a separate ini file that has a list of all planets created... So basically just store that same username you receive:

    [Planets]
    1=Test
    2=Nextperson
    3=Thirdname
    4=etc

    Unless somehow you can cycle through all of the groups in an ini... which I'm not sure of since I can't check right now. If that's the case, the extra list isn't necessary.

    When the player wants to load all the planets on their screen, they'd send a request to the server to get that data, the server would then loop through all of the planets in the ini file, and spit out binary messages to the player for each one...

    Lacewing : Push short planetx(from ini)
    Lacewing : Push short planety(from ini)
    Lacewing : Push string groupname(from ini)
    Lacewing : Send binary to client on subchannel 0

    On the client's side, you'd do the binary message received condition, and then extract the info as:

    Short("Lacewing", 0)
    Short("Lacewing", 2)
    String("Lacewing", 4, StackSize("Lacewing") - 4)

    That would give you the x,y,username to then create the planet on the clientside each time the client gets one of these messages from the server. (which if you have 100 planets, it would get 100 messages and create each one)

    That's how I figure it would work, anyway. Anyone here correct me if there's a better way to do this.

  5. #5
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jan 2011
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Any Other Way To Do This?

    Two more questions:

    1. If one client requested the list, and then another one did in the middle of the loop, would the lacewing server process them separately or would the loop restart and one user end up with duplicates.

    2.
    Short("Lacewing", 0)
    Short("Lacewing", 2)
    String("Lacewing", 4, StackSize("Lacewing") - 4)

    Why are those numbers at the end? All of this binary stuff is new to me.

    BTW Thanks for the help. This has really helped out.

  6. #6
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Any Other Way To Do This?

    1. I'm pretty sure it would process the requests separately. I have my server framerate set to 1000 so it's burning through the loops a lot faster than the client's 60 framerates... I'm probably not the best person to ask about this part though, but I'm sure someone else can answer this better. I'm pretty sure that it wouldn't restart the loop and make a duplicate... Jamie would know best about this... he might pop in and answer.

    2. The numbers represent the position of the binary message. You have different types of data which take up different amounts of bytes.

    Byte - takes up 1 byte, obviously
    Short - takes up 2 bytes
    Integer - takes up 4 bytes
    Float - takes up 4 bytes
    String - 1 byte per character

    So when you do:

    Short("Lacewing",0)

    The 0 represents the first byte of data sent. (which is your first number

    Short("Lacewing",2)

    Here the second number (y) is retrieved. The reason it's a 2 is because the first value (x) was a Short, which took up 2 bytes (0 and 1) Therefore the (y) value takes up 2 and 3.

    The string then uses 4, StackSize("Lacewing")-4

    The first 4 is the byte of data to start with (since the first two shorts were 2 bytes each, taking up bytes 0,1,2 and 3... then the string would start at byte 4.

    The remaining part is simply taking the entire stack size and subtracting 4 bytes, which means it's going to the last character in the text that was sent, keeping in mind that it subtracts 4 bytes that were used for the x/y values.

    There's a way better explanation here:

    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=186341#Post1863 41

    The simplest way to explain it is that when you send a binary, you're sending all these separate bits of information and they each have a place in the binary message, much like the tokens from a string parser.

    Once you figure this out, you'll see that it's the most efficient way of doing this and it's really easy once you understand how it works. It's just packing all the info into one message that lets you pull out whatever bit you want on the other end.

    Using strings takes up the absolute most space because they take up a byte per character... so if you send everything by strings, it will bog down your server and make things run slower.

    For example, the value "30000" can be sent as a minimal 2 bytes of data if sent as a Short. If you send the same "30000" as text, it's taking up 6 bytes of data (3x more data!) So you can see why doing things the "text and then string parser" way is not very efficient.

  7. #7
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jan 2011
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Any Other Way To Do This?

    Thank you for all of the help. If you want, you can beta test the game when I am done. Just send me a message.

    Jack

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •