[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUDs
. -> [Folder]  General
. . -> [Subject]  Suggested protocol for server to client "out of band" messages

Suggested protocol for server to client "out of band" messages

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19 20  21  22  23  

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #270 on Sun 28 Feb 2010 07:09 PM (UTC)

Amended on Sun 28 Feb 2010 07:11 PM (UTC) by Nick Gammon

Message
Ah yes, well back to semantics...

I think I need to tweak my design a bit.

It is becoming increasingly obvious that there are two ways you can look at an object/npc in the game:


  1. The generic object, which the area designer made
  2. The specific instance of the object, which exists in the game world space


For example:


minvoke 8905 15
Log: Admin: minvoke 8905 15
You invoke a deer (#8905 - deer - lvl 7)

minvoke 8905 16
Log: Admin: minvoke 8905 16
You invoke a deer (#8905 - deer - lvl 7)

minvoke 8905 10
Log: Admin: minvoke 8905 10
You invoke a deer (#8905 - deer - lvl 5)

oinvoke 1510
Log: Admin: oinvoke 1510
You invoke an electrum sword (#1510 - sword electrum - lvl 65 - qty 1)

oinvoke 1510 10
Log: Admin: oinvoke 1510 10
You invoke an electrum sword (#1510 - sword electrum - lvl 10 - qty 1)
The snow comes down heavily.

oinvoke 1510 20
Log: Admin: oinvoke 1510 20
You invoke an electrum sword (#1510 - sword electrum - lvl 20 - qty 1)

oinvoke 1510 30
Log: Admin: oinvoke 1510 30
You invoke an electrum sword (#1510 - sword electrum - lvl 30 - qty 1)

inv

You are carrying:
     a longsword
     (Magical) a silvery dagger
     (Magical) (Glowing) an electrum sword (4)


Somewhat amusingly, the minvoke command disregards the level I choose and substitutes one of its own choosing.

Also, the inventory list doesn't make clear that the four electrum swords are quite different levels, it looks like you have four of the same sword.

The important thing about these things is that they have a similarity: the original vnum (eg. 8905 for the deer) and a unique quality: (the GUID, eg. 2114, 2115, 2116).

The GUID is what identifies the deer if you want a specific one (for example, you might be fighting one but not the other, or one may have wandered into a different room).

Also in the case of the swords, we need the GUID to specify if we want the level 10 sword, the level 20 sword or the level 30 sword.

But for the purposes of downloading descriptions one sword, or one deer, is as good as another one.

So it seems that for efficiency purposes the client should cache at least the generic information (eg. 8905 is a deer) but still needs extra information for the GUID (eg. deer GUID 2114 is a level 7 deer, which has 50% health left).

I am guessing at this stage that rooms are unique (ie. the vnum would adequately identify them) but no doubt this isn't strictly true? For example, in an instance, or if you have rooms generated at runtime? Can anyone clear that up?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Xtian   (53 posts)  [Biography] bio
Date Reply #271 on Sun 28 Feb 2010 08:39 PM (UTC)
Message
Nick Gammon said:

So it seems that for efficiency purposes the client should cache at least the generic information (eg. 8905 is a deer) but still needs extra information for the GUID (eg. deer GUID 2114 is a level 7 deer, which has 50% health left).


I think it is sufficient if the client only uses the GUID for all these purposes only. My arguments:
- the server can always match a GUID to a generic object to produce its generic data
- using two IDs for every item you are caching is more complicated than one
- it uses more bandwidth
- do players really get in contact with that many equivalent objects (of the same generic type) that the overhead this adds is justifiable?
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #272 on Sun 28 Feb 2010 09:38 PM (UTC)
Message
By definition, a global *unique* identifier does not identify things of which there are more than one.

Xtian said:

do players really get in contact with that many equivalent objects (of the same generic type) that the overhead this adds is justifiable


Well, yes they do. In my example there are 4 swords in my inventory, all different levels. There were 3 deer in the room, of different levels. I might equip one sword but not the other. I might fight one deer but not the other.

If we sent down (say) the deer's vnum (and then get a single definition of what the deer looks like) and then I decide to attack it, which of the three deer am I attacking? If they all have the same number? And if one leaves the room, wounded, and I attack vnum 8905 is that the one that left the room, or the one still there?

This is the problem with Smaug where you have things like 1.sword, 2.sword and so on, to try to distinguish items. And that falls down quickly enough if you re-order your inventory (eg. by dropping something and picking it up again).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #273 on Sun 28 Feb 2010 09:43 PM (UTC)
Message
Nick Gammon said:
By definition, a global *unique* identifier does not identify things of which there are more than one.

Is it impossible for the server to take the GUID, look it up, and work out its model/replica ID?

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #274 on Sun 28 Feb 2010 10:23 PM (UTC)
Message
Well yes it's possible, but even sending down the vnum isn't enough, as in my example that would not distinguish between different swords created with different levels (or maybe they were enchanted or something).

However I think I *do* have the solution, but I want to test it out before presenting it. Suffice to say that a fair bit of earlier design is going out the window.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #275 on Sun 28 Feb 2010 10:28 PM (UTC)
Message
Suffice to say for now that my tentative solution is based on the way Git works. ;)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #276 on Sun 28 Feb 2010 10:33 PM (UTC)
Message
I like it already!

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #277 on Mon 01 Mar 2010 02:14 AM (UTC)
Message
The Lua interface to JSON is coming along nicely so far, and I've pushed my latest changes to my repository. It's not quite ready for real use, mainly because there's no decoding yet and the encoding has a few limitations, but it's getting there.

On the encoding side of things, I still need to seal up the memory leaks I create with every new JSON array or object. I also need to add new methods json.to_array and json.to_object, and a constant json.null. Both should be solved by giving each json_object* a Lua full userdata with a __gc metamethod. The current json.encode() will probably return a wrapped json_object* instead of a string, and the json_object* will have :to_string() and :to_lua() methods, since they can go either way.

Well, that's the plan, anyways.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #278 on Mon 01 Mar 2010 03:08 AM (UTC)
Message
Made a stupid slip-up and forgot to actually push it. It's there now.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #279 on Mon 01 Mar 2010 04:19 AM (UTC)
Message
Twisol said:

I like it already!


I'll give you a hint...

Internally, Git stores all of your files in a subdirectory of the .git directory, where the file name is the hash of the contents of the file. Thus, if two files have the same name they necessarily have the same contents.

So, when you pull a Git repository to your local disk, if you already have a file of a certain name, then you therefore have the exact contents as well. In other words, you don't need to pull copies of files of the same name "just in case" the contents have changed - they won't have.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #280 on Mon 01 Mar 2010 05:21 AM (UTC)
Message
There is already an extremely well-defined notion of "model/replica ID" -- the vnum. You can send a GUID along with the prototype identifier for that thing. Problem solved, ne?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #281 on Mon 01 Mar 2010 06:11 AM (UTC)
Message
No, afraid not.

For one thing, as my example earlier up shows, the same vnum can be invoked with different levels, so at the very least, the level isn't defined.

And as my earlier research showed, a vnum can be modified by the server so a corpse can change from "is slightly rotting" to "is buzzing with flies", even though it is the same object.

Even if that didn't happen, say a vnum identified "a large rat" and the MUD admin changed it to "a large bat" - if you cached that vnum as "a large rat" (on a database, for instance) how would you know the server had changed the meaning of the vnum? At the very least you would have to pass the vnum and a version number.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #282 on Mon 01 Mar 2010 06:16 AM (UTC)

Amended on Mon 01 Mar 2010 06:22 AM (UTC) by Twisol

Message
The json.encode function is complete; json.decode is next. I'm really happy with how this is turning out! Here's a brief explanation of what I've done.

json.encode takes Lua data and returns a "compiled" userdata-wrapped json_object. This object has :to_json() and :to_lua() methods. :to_json() will return a valid JSON string, whereas :to_lua() will return a decoded Lua representation. The compiled json objects can also be used as part of later json.encode calls.

Three helpful other items in the json table are json.array, json.object, and json.null. json.array and json.object take a table and return a compiled JSON userdata, treating the table as an array/object and ignoring any invalid keys. json.null is a pre-generated JSON userdata representing null, equivalent to json.encode(nil).

Examples:

chunk = json.encode{1, 2, nil, 4, json.null}
print(chunk:to_json())

--[[
Output:
  [1, 2, null, 4, null]
--]]

chunk = json.encode{foo=100, bar=chunk, baz=101}
print(chunk:to_json())

--[[
Output:
  { "baz": 101, "bar": [ 1, 2, null, 4, null ], "foo": 100 }
--]]

print(json.encode{}:to_json())
print(json.encode(json.array{}):to_json())
print(json.encode(json.object{}):to_json())

--[[
Output:
  ERROR: Ambiguous, could be array or object.
  [ ]
  { }
--]]



* :to_lua() isn't implemented yet, I'll be adding it along with json.decode.

EDIT: It's hard to see the difference between {} and () in the code font, so if you're confused by that, look closely.

EDIT 2: I'm moving this to a thread in the Development forum, so this one can focus on more relevant protocol details. JSON itself is obviously relevant, but less so the integration into MUSHclient.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #283 on Tue 02 Mar 2010 11:05 PM (UTC)
Message
Well, either way, I would rather not have this protocol make too many assumptions about "replicas" -- the more of those you make the closer you are getting to being a SMAUG-only protocol. Your "git-like" solution for example presumably creates a hash based off of a list of contents you choose, but how do you know that list is complete with some game that makes different design decisions?

I think it's quite reasonable to make sure that the protocol supports simple situations when we can.

The only real problem in what you brought up anyhow is when things change. It's not a problem if an item has extra information: you have the individual object ID, and you have the prototype ID, therefore you can pick up the prototype's information (that is easily cached) while waiting for the individual item's information to come in. In nearly all cases, this will come in as "no changes from prototype".

The corpse example isn't the prototype changing, it's the individual object. This is indeed a problem, but it's a problem no matter what scheme you decide to use: you'll always have to go fetch new information from time to time.

Some games don't even have an instance/prototype notion as strongly as SMAUG does. Will that be supported?

Anyhow I unfortunately don't have a lot of time to go into this now, but I'd just like to mention that caution is appropriate unless being SMAUG-only is ok.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] bio
Date Reply #284 on Tue 02 Mar 2010 11:16 PM (UTC)
Message
I think that the ID itself doesn't have to be particularly standardized, as long as there's a single ID field. Whatever happens to the ID on the server side shouldn't matter. So you could validly write a server with this git-like system, and use SHA1 identifiers.-

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


614,624 views.

This is page 19, subject is 23 pages long:  [Previous page]  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19 20  21  22  23  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]