<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.dspt.info/index.php?action=history&amp;feed=atom&amp;title=Server_Data_Flow</id>
		<title>Server Data Flow - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.dspt.info/index.php?action=history&amp;feed=atom&amp;title=Server_Data_Flow"/>
		<link rel="alternate" type="text/html" href="http://wiki.dspt.info/index.php?title=Server_Data_Flow&amp;action=history"/>
		<updated>2026-05-22T23:51:27Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.24.2</generator>

	<entry>
		<id>http://wiki.dspt.info/index.php?title=Server_Data_Flow&amp;diff=6818&amp;oldid=prev</id>
		<title>Kegsay: /* Examples */</title>
		<link rel="alternate" type="text/html" href="http://wiki.dspt.info/index.php?title=Server_Data_Flow&amp;diff=6818&amp;oldid=prev"/>
				<updated>2012-07-24T23:09:19Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Examples&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 23:09, 24 July 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 33:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 33:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Z2: Sends weaponskill action packet back to client.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Z2: Sends weaponskill action packet back to client.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Z2: Transfers state back to ACTION_ATTACK.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Z2: Transfers state back to ACTION_ATTACK.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=== Performing a zone ===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;''Z = Zone Thread, P = Packet Thread, the number indicates the 'round' (or tick) of the thread. That is to say, some time has elapsed between P1 and P2.''&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* P1: Server receives client position update (SmallPacket0x015) and sets new position.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* &amp;lt;Some time elapses between P1 and P2...&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* P2: Server receives client position update (SmallPacket0x015) and sets new position.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* P3: Server receives client position update (SmallPacket0x015) and sets new position.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* P4: Server receives client position update (SmallPacket0x015) and sets new position.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* P5: Server receives request to zone (yes, the client magically knows this) (SmallPacket0x05E).&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* P5: Server responds with OK (0x0b -&amp;gt; CServerIPPacket) if it's okay and sets PChar-&amp;gt;loc.destination to the new zone id, and PChar-&amp;gt;loc.p (position) to the right zoneline.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* P6: Server receives a farewell packet (SmallPacket0x00D) from the client. This packet is always sent when you leave a zone, including when you logoff. If you disconnect, the packet isn't sent obviously, but the server will cleanup your character by faking a farewell packet from your session. This saves your stuff to the database and calls '''zone::DecreaseZoneCounter'''. At this point you can distinguish between a zone and a logoff/dc by looking at PChar-&amp;gt;loc.destination which will be 0 if you're logging off or disconnecting.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* P7: Server receives a greeting packet (SmallPacket0x00A). This calls '''zone::IncreaseZoneCounter'''.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* P7: Server responds to the character as normal, after handling zone in stuff in IncreaseZoneCounter.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kegsay</name></author>	</entry>

	<entry>
		<id>http://wiki.dspt.info/index.php?title=Server_Data_Flow&amp;diff=6817&amp;oldid=prev</id>
		<title>Kegsay: Created page with &quot;Outlined here are several scenarios. The internal processes are briefly touched upon. You can think of it as 2 main threads at work: the '''Zone Thread''' and the '''Packet Th...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.dspt.info/index.php?title=Server_Data_Flow&amp;diff=6817&amp;oldid=prev"/>
				<updated>2012-07-24T22:49:41Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;Outlined here are several scenarios. The internal processes are briefly touched upon. You can think of it as 2 main threads at work: the &amp;#039;&amp;#039;&amp;#039;Zone Thread&amp;#039;&amp;#039;&amp;#039; and the &amp;#039;&amp;#039;&amp;#039;Packet Th...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Outlined here are several scenarios. The internal processes are briefly touched upon. You can think of it as 2 main threads at work: the '''Zone Thread''' and the '''Packet Thread'''. The first handles internal workings which do not rely on user input e.g. effects of poison, ticking of the Vana'diel day, roaming monsters, etc. The second handles direct requests from the client(s), e.g. request to attack a monster, request to trade with someone, sending a /tell, etc.&lt;br /&gt;
&lt;br /&gt;
== Zone Thread ==&lt;br /&gt;
* This is initialised when the server starts.&lt;br /&gt;
* zone.cpp -&amp;gt; ZoneServer(tick) - The main thread of execution is located here. This checks status effects, handles AI ticks, handles instances and handles treasure pools. This is slept for 500ms (half a second) every round.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Packet Thread ==&lt;br /&gt;
* packet_system.cpp - After a request is made to the server, the first major hurdle is deciding what the request it. The raw bytes are decoded into meaningful actions. Of particular interest is [[Packets/0x1A]] which governs many different actions.&lt;br /&gt;
* Some requests are handled immediately, e.g. calling for help simply sets a flag and returns the &amp;quot;You've called for help!&amp;quot; message, nice and simple.&lt;br /&gt;
* Other requests require the AI to actually ''do'' something, like start using a weaponskill. The action is set in the AI and started ''in this thread initially''. An example of such an action:&lt;br /&gt;
 uint16 WSkillID = RBUFW(data,(0x0C)); //grab the Weaponskill ID from the actual request packet&lt;br /&gt;
 PChar-&amp;gt;PBattleAI-&amp;gt;SetCurrentWeaponSkill(WSkillID); //Store that&lt;br /&gt;
 PChar-&amp;gt;PBattleAI-&amp;gt;SetCurrentAction(ACTION_WEAPONSKILL_START, TargID); //Tell the AI to start using a WS (state change)&lt;br /&gt;
 PChar-&amp;gt;PBattleAI-&amp;gt;CheckCurrentAction(gettick()); //Activate the state change, e.g. this will call ActionWeaponskillStart()&lt;br /&gt;
* The return is usually in the form of pushed packets, perhaps it's a message, or perhaps it's an entity update packet:&lt;br /&gt;
 PChar-&amp;gt;pushPacket(new CMessageBasicPacket(PChar,PChar,0,0,22));&lt;br /&gt;
* The thread then blocks until it receives another request.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Performing a Weaponskill on Monster A ===&lt;br /&gt;
''Z = Zone Thread, P = Packet Thread, the number indicates the 'round' (or tick) of the thread''&lt;br /&gt;
&lt;br /&gt;
* Z1: Zone server ticking away, character is in ACTION_ATTACK state and waiting for their weapon delay to be up.&lt;br /&gt;
* P1: packet_system.cpp receives a request packet for WS.&lt;br /&gt;
* P1: Character AI set to ACTION_WEAPONSKILL_START.&lt;br /&gt;
* P1: CheckCurrentAction is called.&lt;br /&gt;
* P1: ActionWeaponskillStart logic is checked, e.g. do you have enough TP, right distance from mob, etc.&lt;br /&gt;
* P1: All checks passed, state change to ACTION_WEAPONSKILL_FINISH.&lt;br /&gt;
* Z2: Zone server checks AI logic some time later (&amp;lt;500ms), sees you're in ACTION_WEAPONSKILL_FINISH state and handles logic (e.g. readying time passed, calculation of damage via LUA call, etc)&lt;br /&gt;
* Z2: Sends weaponskill action packet back to client.&lt;br /&gt;
* Z2: Transfers state back to ACTION_ATTACK.&lt;/div&gt;</summary>
		<author><name>Kegsay</name></author>	</entry>

	</feed>