Dragon Basher: v11 dragon server

  Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Next

Posted: 01‑13‑2015 20:48


Joe


Fire Flipper
1454 posts
[EDIT] This post is part of the DevTeam conversation concerning the 'dragon' server. With the release of the demo, I am locking this thread and moving into a public area for reference for those that wish to examine the 'dragon' code, which you can download here with an Open Source license. -Joe


I've started work on the new server; currently four map screens are drawn as one so the playing area is much larger (896 pixels wide x 640 pixels).

To accommodate this larger screen, we will need to alter the player interface to the inventory - I'm thinking either an option when the players click themselves, or maybe a OnMouseOver or something - we'll figure that out later.

I'm also updating the core networking code to use JQuery and AJAX - long past over due. This will smooth the entire game out. The new client will be "dumb" and only send commands to the server which will then send back the data for rendering.

QuaCzar - might want to look at the dragon.cgi script; it now produces plain text results. I'm thinking we'll need a parser that splits the data into single lines and then processes each line of text. Some type of simple data passing structure where each line is like "CharZ=34" and after all data is downloaded we re-render the map.

Anyways, still early but lots of progress. This is going to be the best update ever. :)

-Joe

DevTeam Member

 


Posted: 01‑14‑2015 05:40


QuaCzar


Fire Flipper
1814 posts
Sounds good.

So, 2 parts to parsing the line, a key and a value
matching /([=]*)=(.*)$/, $1 is the key, $2 is the value.

I see the following methods to parse this:

1. Each line could set window[$1]=$2 directly, but this would not have the best control, making timing issues more difficult to deal with, and operators like + can give problems if the type isn't explicitly set between numbers and text. The parser could either automatically detect numbers using isNaN() or something, or the key could end with a capital letter to show it should hold a number (PlayerX would be a number, and PlayerName would be a string, but idk how well that would fit,) or there are other ways, but this is probably not the best method.

2. For each request, create a new Map object, each line sets Map[$1]=$2, then after parsing is finished, Map is passed to a handler routine which changes the game and then discards Map. This could be done automatically with JSON or XML (I prefer the current simple line by line, though) The handler could take care of parsing numbers or whatever.

3. Each parsed value is immediately sent to a handler routine for the particluar key. (I believe with jQuery AJAX, the entire response is read before the parsing function is called, so immediate handling should not keep the server waiting, unless I'm wrong about that...) There could be a method for each key in an object, called as object[$1]($2); or we could just use a switch or something. This way, multiple identical keys can be handled in order, instead of overwriting each other, and each key's handler can parse the value into a number or whatever it needs before storing it. Something like this: for(/*each line in request*/){a=line.split("=");object[a.shift()](a);} opens up the option of sending several values in one line, each separated by "=" if that is desired, but also limits any text from including that character, so a different one may be better (though you could use "=", just for HTML display.)

Each of these has advantages in some applications, but I tend to prefer some form of #3 for its more dynamic, yet organized, nature. So, unless it has some problem I haven't considered in this case, that's what I'd recommend. I wouldn't really care if we used an object or a switch or if statements to organize the different handlers, whatever you like.

-QuaCzar : SysOp | P2P Guide | Anarchy Leader | #1 Magic

 


Posted: 01‑14‑2015 05:54


Joe


Fire Flipper
1454 posts
It is somewhat more complex, I'm sorting out an easy solution. The problem is we are downloading data for not one, but four screens. So we have to sort out which screen each line of data is on.

Too early to find a solution, once I have the login routines done I'll be able to lay down some code and then be in a better place to see what needs to be done.

I like #1 but think we should validate each 'name' before assigning a value. If we are going to be setting variables, might want a checksum although the current iframe setup doesn't have checksums so it might not be necessary.

-Joe

DevTeam Member

 


Posted: 01‑14‑2015 06:49


QuaCzar


Fire Flipper
1814 posts
With method #3, split by "|" instead of "=", the responses could be something like:

Login testguy, with one piece of food in inventory, and Spike on screen:

map|J1|...
map|J2|...
map|K1|...
map|K2|...
.
.
.
enter|testguy2|K2|67
login|success
inv|Z51234
enter|testguy|J1|34

I show up as Spike logs out:
enter|QuaCzar|J1|3
exit|Spike

Joe shows up and I attack testguy:
enter|Joe|J2|9
move|testguy|SWSW
attack|QuaCzar|testguy

I hit testguy for 5:
hitby|QuaCzar|5
HP|testguy|23

Joe moves, testguy hits me for 2 and eats food, gaining 1 hp at first:
move|Joe|SSSSSS
hit|QuaCzar|2
HP|QuaCzar|67
use|Z51234
hoverItem|Z5
HP|testguy|24

I suppose positions will include the screen code as well as the zposition on that screen?

In this example, each key is a command with parameters following. hoverItem is supposed to represent an item over the player's head, as in eating. Player hits are kept track of by HP, and only those related to the current player, in this case testguy, are sent with hit or hitby, which only display the messages. use removes an item from the inventory. Also, if testguy was a mod, on login he could get mod server commands in some menus sent by this method, so they wouldn't be in the public javascript.

-QuaCzar : SysOp | P2P Guide | Anarchy Leader | #1 Magic

 


Posted: 01‑14‑2015 07:01


QuaCzar


Fire Flipper
1814 posts
oops, I accidentally wrote testguy2 instead of Spike in one command. :S

-QuaCzar : SysOp | P2P Guide | Anarchy Leader | #1 Magic

 


Posted: 01‑14‑2015 07:38


QuaCzar


Fire Flipper
1814 posts
Ah. I know Queville basically uses #1 now, so I thought we might end up using that code. If more depth is needed, (and I'm not sure if this is the case, exactly,) an option for #1 might be to split into multiple keys, with the last a value. This way, any property could be set including the style of a DOM element, or a dynamic item in an array, so the server can basically have direct control of the display, as well as any variables it needs.

I'm not really sure how well that idea addresses the particular problems here, or if it just makes validating and things harder, but my basic point is that I see that #1 can be good for direct server handling, and can be dynamic and organized, as well.

-QuaCzar : SysOp | P2P Guide | Anarchy Leader | #1 Magic

 


  Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Next

Hunt food, smith weapons, and prepare for battle! Can you stop
the Evil Que from taking over the entire game? Browser based multi-player
fantasy role-playing game that requires no downloads or plug-ins! Free to play forever!

By being at queville.com, you agree to our Terms of Service.