6.3.08
Shattered World - Server Messaging Architecture
Posted by
Sara Pickell
at
12:00 PM
I IZ MAEK attack.getSkillID(this) ON target.getObjectID()? (A message is sent to the server that you are attacking.)
IZ I IN attack.getRange(getSkillID(this))? (Am I within range to for that attack to be valid?)
IZ I AT attack.getGoodVectors(getSkillID(this))? (Am I standing at the right angle for the attack to succeed?)
DID I HITZ? (A request for confirmation of successful attack is sent)
- IF I DID HITZ: SENDZMESSAEG attack.getSkillEffects()! (Send a message to the server to apply the damage and other effects of the succesful skill)
HAS I BEEN HITZ? (Check for incoming damage messages)
- IF I HAS BEEN HITZ: MyHealth.applyDamage(inc_message) AND ActiveSkills.checkAllValidity()! (Remove health equal to the damage taken, and check to see if any active skills are removed by being hit.)
IZ I DED? (Check against death)
IZ target.getObjecctID() DED? (Check against target death)
OMGLIKEHEALZ MY HEALZBAR! (Regenerate player health)
OMGLIKEHEALZ MY MAGICZBAR! ( Regenrate Mana)
OMGZLIKEHEARTBEAT ActiveSkills(thisPlayer)! (Run the heartbeats on any active skills, this applies all damages over time, heals over time, and removes the appropriate amount of remaining time from any temporary skills)
Back when I was trying to be a code monkey, didn't work out too well by the way, my primary focus whas actually on messaging architectures, thus why it didn't work out. Every time you click a button your UI your character does something right!? Wrong. Everytime you click a button it asks the in-client estimation engine if it's okay, and if it is, it then writes a polite little message to the server.
If we were to read it, it would look something like 0x1AFF6BCE7700F4. When roughly translated that means, "Server, old boy, this is John Smith's client requesting that you tell Mob #255 over there that I've hit him with a spot of damage and other nasty effects. Thanks in advance, and a good day sir."
The server would of course reply, 0x1A00FF0506AC7BFCA5FF88B21AAFB3. "Dear John Smith's client, I had no problems receiving your message regarding Mob #255 and would like to compliment you on your excellent penmanship. By the by, your damage went through, but mobs #255 and #63 both hit you quite hard, and one even landed a mostly harmless DoT on you. I'd recommend you hit #255 a little harder next time, but I'll be monitoring the situation with some interest."
Which is all well and good, except for one minor issue. Each server has to support at least a thouasand players. All of whom have to repeat the process at the top of the post every time the server cycles.
I used to hang around the MV forums, and my brother is working on the development of a game using it's engine. Basically from what I could gather, their basic messaging architecture was that all messages would be stored in a global array on arrival and then each entity would have to search the array for it's messages. I'm probably wrong, but that is how I read it.
Which got me thinking on how to build a better architecture. So I set to work on my first goal, building a message handler that allowed an entity to directly contact another enitity.
I eventually programmed a simple example that worked something like this. What would happen is that the global entity list, which has to exist anyways, would also contain a pointer to the receiver of every entity. Each receiver then had a vector, a dynamically sized array, which it would use as a message buffer.
The problem was, I still had to search the list with every buffer. So the way I fixed that was by making the recipient ID of messages the items list ID rather than true ID. So this meant that I could basically just tell it EntityList[getMsgRecip()].receiveMsg(this). What this meant was that rather than search the list for an object to call, I simply called the appropriate member of the list automatically.
The message handler on an entity would simply send out Item #0 in it's send list, then process item #0 in it's receive list, automatically working them as FIFO stacks, allowing things to streamline nicely.
Unfortunately I lost all the source code in my HDD wipe.
So what is the point?
The point is that SW needs to be more than just an exercise in Gameplay. It needs to have an architecture that can support the massive load of an almost pure overworld. The entire architecture of how a game runs on a server needs to be examined and rexamined, pushed for every last nanosecond of performance gain.
Labels:
Shattered World
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment