<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
<link rel="self" type="application/atom+xml" href="http://www.joinuo.com/forums/feed.php?f=32" />

<title>JoinUO.com</title>
<subtitle>A discussion forum for the Ultima Online freeshard community.</subtitle>
<link href="http://www.joinuo.com/forums/index.php" />
<updated>2011-01-16T23:44:00+00:00</updated>

<author><name><![CDATA[JoinUO.com]]></name></author>
<id>http://www.joinuo.com/forums/feed.php?f=32</id>
<entry>
<author><name><![CDATA[Batlin]]></name></author>
<updated>2011-01-16T23:44:00+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=644&amp;p=1415#p1415</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=644&amp;p=1415#p1415"/>
<title type="html"><![CDATA[UO Demo • Connecting with client 1.25.35]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=644&amp;p=1415#p1415"><![CDATA[
We all know that we can multi-client with the Ultima Online Demo from 1998 using UoDemo+ <a href="http://uodemo.joinuo.com/index.php?title=Uodemo%2B" class="postlink">http://uodemo.joinuo.com/index.php?title=Uodemo%2B</a> and UoDmClnt <a href="http://uodemo.joinuo.com/?title=UoDmClnt" class="postlink">http://uodemo.joinuo.com/?title=UoDmClnt</a>, both patched versions of the original uodemo.exe. As an alternative to connecting to the UoDemo+ server, I've re-investigated the possibility to connect with a real client. I'm saying re-investigated, because more than a year ago Derrick and I were already testing with client 1.25.35. We then discovered that chatting didn't work and the client would hang after certain time. The problems we encountered back then were caused by UO protocol changes.<br /><br />Now, using the UoDemoDLL technique <a href="http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=608" class="postlink">http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=608</a> I've developed a Packets.DLL which you can attach to the demo. This DLL will intercept the packets it receives from a client and then patches those packets to make them compatible. For now, this DLL will only work with client 1.25.35 (possibly others too). Protocol changes are a common thing in the lifetime of UO <img src="http://www.joinuo.com/forums/images/smilies/icon_e_sad.gif" alt=":(" title="Sad" /> and cause a lot of pain in the free shard world.<br /><br />For client 1.25.35 I coded two actions:<br /><ul>1) The conversion from UNICODE speech to ASCII speech<br />2) The removal of Packet 0xB6 (Help Request) which the demo doesn't know about</ul><br />To demonstrate how it works and that it works, I've made a test video which you can download/view here: <a href="http://download.joinuo.com/video/UoDemo%20Video;%20Connecting%20with%20a%20real%20client,%20working%20books%20and%20no%20more%20Z%20problem.wmv" class="postlink">http://download.joinuo.com/video/UoDemo%20Video;%20Connecting%20with%20a%20real%20client,%20working%20books%20and%20no%20more%20Z%20problem.wmv</a><br /><br /><br />Client 1.25.35 shows that books are actually writeable in the demo, the message you get when you try to write in a book is a demo client limitation and not a server limitation!<br /><br />The Z-problem described originally in this post : <a href="http://forum.joinuo.com/viewtopic.php?f=32&amp;t=509" class="postlink">http://forum.joinuo.com/viewtopic.php?f=32&amp;t=509</a> does not exist with client 1.25.35. So whatever is causing it in the original demo, is a client issue and not a server issue!<br /><br />The attached ZIP contains a patched client and the DLL. To make it work I had to patch out the client encryption.<p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=758">Batlin</a> — Sun Jan 16, 2011 11:44 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Bicchus Dicchus]]></name></author>
<updated>2011-01-16T18:50:09+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=623&amp;p=1414#p1414</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=623&amp;p=1414#p1414"/>
<title type="html"><![CDATA[UO Demo • Re: Let's talk about Karma &amp; Fame]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=623&amp;p=1414#p1414"><![CDATA[
I checked it out, and I find it fascinating. I presume that all leftovers are, for the most part, left in for compatibility's sake, and not due to programming laziness. However, I'm of the opinion that there's been many a programmer working on the client, and perhaps more than one of these fellows were inept in the arts of code documentation. C'est la vie.<br /><br />I always had a soft spot for the Notoriety system. I like to keep things simple.<br /><br />-Bicchus Dicchus<p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=1588">Bicchus Dicchus</a> — Sun Jan 16, 2011 6:50 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Batlin]]></name></author>
<updated>2011-01-14T23:56:18+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=623&amp;p=1404#p1404</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=623&amp;p=1404#p1404"/>
<title type="html"><![CDATA[UO Demo • Re: Let's talk about Karma &amp; Fame]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=623&amp;p=1404#p1404"><![CDATA[
<blockquote class="uncited"><div><br />Hmm I find it odd that the T2A demo, which came out before UOR, has functions for fame and karma. <br />These two variables didn't exist in the Notoriety system, which was the standard of the day.<br /></div></blockquote>The demo contains leftovers from the Notoriety system but it's not active inside the EXE. If you have time, check out the scripts and read them with a correct analysis of the getCompileFlag function : <a href="http://uodemo.joinuo.com/index.php?title=GetCompileFlag" class="postlink">http://uodemo.joinuo.com/index.php?title=GetCompileFlag</a><br /><br />Inside the EXE there's also a reference to a &quot;remnoto&quot; script which in my opinion stands for &quot;remove notoriety&quot;. The script itself is not included in the DAT file.<br /><br />Another interesting script is the &quot;repconvert&quot; (reputation convert) script which actually converts notoriety to karma/fame. Pretty cool stuff in there.<p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=758">Batlin</a> — Fri Jan 14, 2011 11:56 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Bicchus Dicchus]]></name></author>
<updated>2011-01-14T22:58:36+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=623&amp;p=1403#p1403</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=623&amp;p=1403#p1403"/>
<title type="html"><![CDATA[UO Demo • Re: Let's talk about Karma &amp; Fame]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=623&amp;p=1403#p1403"><![CDATA[
Hmm I find it odd that the T2A demo, which came out before UOR, has functions for fame and karma. <br />These two variables didn't exist in the Notoriety system, which was the standard of the day. <br /><br />I reckon they had been considering and working on the Reputation system for a while before it was introduced. <br /><br />Always get nostalgic for the old Noto days though.<br /><br />-Bicchus Dicchus<p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=1588">Bicchus Dicchus</a> — Fri Jan 14, 2011 10:58 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Batlin]]></name></author>
<updated>2011-01-12T14:17:00+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=636&amp;p=1391#p1391</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=636&amp;p=1391#p1391"/>
<title type="html"><![CDATA[UO Demo • a bug in the server's packet receiving code...]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=636&amp;p=1391#p1391"><![CDATA[
While preparing my next project I discovered a flaw in the server's code that could lead into the server dropping certain fragmented packets.<br /><br />Let me first explain the server's loop per receive:<br /><ul> - Read as many bytes as possible, which can fit into the buffer (64KB)<br /> - This buffer is initially filled with zeroes<br /> - Ensure we have enough bytes to start handling the first packet available<br /> - Start handling the packets<br /></ul><br />Handling the packets consist of two big parts:<br /><ul>- Handling packets which do not require you to be logged on<br />- Handling packets which require you to be logged on<br />- At the end of handling a packet, copy the remainder of the buffer to the front<br /></ul><br />UO packets consist of two types of packets, packets with a fixed length and packets with a dynamic length. When handling packets with a fixed length both the server and the client must speak the same language. If one of them send a packet of different length other than the expected length, to other side will turn into an endless loop waiting for the remainder of the packet to be received. If you send too much data, then the other side will process the excess as if it were a new, seperate packet.<br /><br />The bug is this: when the server checks for the packet to be valid, it requires a packet ID. Therefor the first check the server does is ensuring atleast one byte has been received. After obtaining the packet ID it will query its internal database to know if the packet is of fixed length or dynamic length. In case of fixed length, the server will not continue handling the packet until at least all data has been received for it. In case of dynamic length, the server will check the next 2 bytes in the packet as they contain the size of the dynamic data. However, the server code DOES NOT test that atleast 3 bytes have been received and that could be a problem.<br /><br />The following python program demonstrates the potional problem:<br /><dl class="codebox"><dt>Code: </dt><dd><code>import socket<br />import time<br /><br />s = socket.socket()<br />s.connect((&quot;192.168.192.112&quot;, 10016))<br /><br />packet = &quot;\x03&quot;<br />s.send(packet)<br />time.sleep(1)<br />packet = &quot;\xA4&quot;.ljust(149,&quot;\xFF&quot;)<br />s.send(packet)<br /><br />time.sleep(3)<br /><br />packet = &quot;\x03&quot;<br />s.send(packet)<br />time.sleep(1)<br />packet = &quot;\x77&quot;<br />s.send(packet)<br /></code></dd></dl><br /><br /><br />First packet 0x03 is send, this is a dynamic packet.<br />The server's buffer will contain 0x03 00 00 00 00 and so-on.<br />Therefor the dynamic-length checked will be 0x0000.<br />The packet is discarded.<br /><br />Next packet 0xA4 is send, this is a fixed packet that is ignored by the server.<br />Normally this packet contains system information about the client's PC. I filled it here with 0xFF.<br />Therefor the buffer now contains 0xA4 FF FF FF and so-on<br /><br />Then packet 0x03 is send.<br />The buffer now contains 0x03 FF FF FF and so-on.<br />The dynamic-size is now 0xFFFF, and the server expects to receive 65535 more bytes and will wait.<br />Remember, there is only one valid client byte in the buffer.<br /><br />We send 0x77.<br />The buffer now contains 0x03 0x77 FF FF and so-on.<br />There are 2 valid bytes from the client in buffer now, 0x03 and 0x077, the first FF is still garbage which the server is interpreting as it were client data.<br /><br />I'm again gonna try to explain the effects of the bug:<br />If the packet arrives fragmented and in-case of a dynamic lengtht packet, less than 3 bytes are received, then the buffer will contain an invalid value. As the server fails to check that it has atleast 3 bytes, this will be a problem. The packet may be dropped, or may be parsed incorrectly or if you're lucky, the server keeps waiting up to the next byte. What will happen is up-to the packet being received, the new length and the data already in the buffer! In worst-case, the dynamic-length data is gonna be interpreted as if it were a seperate packet causing the client to hang. Validate packet siz.pngThe red line is where the dynamic-length is obtained.<p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=758">Batlin</a> — Wed Jan 12, 2011 2:17 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[roguan]]></name></author>
<updated>2011-01-10T11:51:35+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=635&amp;p=1387#p1387</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=635&amp;p=1387#p1387"/>
<title type="html"><![CDATA[UO Demo • Re: The Multi Script Bug - Ships &amp; Houses]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=635&amp;p=1387#p1387"><![CDATA[
Haha!  Great find and very nice research with the CVs!  <br /><br />Hilarious.  <br /><br />Thanks for clearing this up.  It definitely gives us an indication regarding the caliber of future bugs we'll be facing in the demo <img src="http://www.joinuo.com/forums/images/smilies/icon_razz.gif" alt=":P" title="Razz" /><p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=1544">roguan</a> — Mon Jan 10, 2011 11:51 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Batlin]]></name></author>
<updated>2011-01-10T11:34:04+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=635&amp;p=1386#p1386</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=635&amp;p=1386#p1386"/>
<title type="html"><![CDATA[UO Demo • The Multi Script Bug - Ships &amp; Houses]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=635&amp;p=1386#p1386"><![CDATA[
First I encourage you to read roguan's post about ships (if you haven't read it already) : <a href="http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=615" class="postlink">http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=615</a>.<br /><br />I've researched the source of the &quot;NAME INVALID&quot; issue roguan discovered using Process Monitor.<br />If you look at his screenshot (see his post), you will see that the name looks valid and that there is no real visible reason for the function to fail.<br /><br />However, if we investigate the actual loading and parsing of multi.txt.q using a debugger, then we see that the script name ends with an invalid 0D character (return character or \r).The Multi-Bug.png<br /><br />Why is that 0D character there? If you look at the screenshot you may notice that OSI's code is scanning for a 0A character (newline character or \n). The 0D 0A sequence as a line seperator is common in the DOS/Windows world. The 0A sequence is common in the Unix/Linux world. <a href="http://en.wikipedia.org/wiki/Newline" class="postlink">http://en.wikipedia.org/wiki/Newline</a><br /><br />Let's look at the multi.txt.q itself (using a hex editor so we can see the line seperators): multi.txt.q.png<br /><br />Why is the demo scanning for a Unix-sequence whereas the file itself is Windows-based?<br /><br />It's obvious that OSI's server code ran on Unix systems, check out this CV:<br /><a href="http://www.talisman.org/~erlkonig/resume/" class="postlink">http://www.talisman.org/~erlkonig/resume/</a><blockquote class="uncited"><div><br />Unix Systems Analyst (June 1994 - April 1997) <br />Origin Systems<br /> <br />Sole (until mid 1996) Unix systems administrator for a medium-sized network of Silicon Graphics machines at Origin Systems, ranging from desktop workstations to a half-million dollar SGI Onyx RE2, working tangent to the PC/Macintosh technical staff. Involved in or responsible for all Origin Internet services. My game credits include: <br /><br />ULTIMA ONLINE: Shattered Legacy pre-alpha<br /></div></blockquote>Also check out this one: <a href="http://jasons.wumple.com/Resume/" class="postlink">http://jasons.wumple.com/Resume/</a><blockquote class="uncited"><div><br />Senior Software Engineer, Origin Systems, studio of Electronic Arts, 11/1996 to 12/1997 <br />Released Ultima Online, the award winning massively multiplayer online game. <br />Programmer, Ultima Online, an award winning massively multi player online role playing game supporting tens of thousands of simultaneous players. <br />Designed and implemented auto patching system (client and server), interprocess script communication system, multiobj system, boats, player housing, global hint system, game master tools, object decay, communication crystals, magic item creation system. Worked on most systems in the game. <br />Extensive use of C++, templates, STL, TCP/IP (sockets), Win32, MFC, Win32 threads and POSIX pthreads with development under Linux, Solaris, and Windows. <br />Lead Programmer from 1/1998. Maintained task lists, reported progress, managed small team of engineers. <br />On call 24/7. Fixed many critical problems whenever they occurred. <br />Made numerous CPU and memory optimizations which greatly improved performance of game servers. Improved stability of service.<br /></div></blockquote><br /><br />My guess is that they converted the file itself to a Windows based file, but didn't do effort to fix/test the code when they converted the server code from Unix to Windows for creating the demo. Also, the Time Bug I described here : <a href="http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=569" class="postlink">http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=569</a>, is a bug I believe to be of the same origin, a unix-to-windows conversion related issue.<br /><br />Now, how to fix this bug?<br /><br />1) You can use roguan's approach which is quite technical (see his post). <br /><br />2) You can convert the multi.txt.q file back to Unix format by replacing the 0D 0A sequence by a 0A sequence using a hex editor.<br /><br />3) You patch the EXE, again using a hex editor, so that the demo scans up-to-the 0D character instead of the 0A character.<br />The Fix.pngAt 0x21B00E change 0x0A in 0x0D. That's it!<br /><br />Note, an-easy-to-use-and-free hex editor is HxD : <a href="http://mh-nexus.de/en/hxd/" class="postlink">http://mh-nexus.de/en/hxd/</a><br />I've also attached a pre-patched multi.txt.q file to this post.<p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=758">Batlin</a> — Mon Jan 10, 2011 11:34 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Derrick]]></name></author>
<updated>2010-12-31T18:21:54+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=630&amp;p=1375#p1375</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=630&amp;p=1375#p1375"/>
<title type="html"><![CDATA[UO Demo • Re: NPC states - The Old and The New]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=630&amp;p=1375#p1375"><![CDATA[
Nice thanks Batlin, and OSi <img src="http://www.joinuo.com/forums/images/smilies/icon_e_smile.gif" alt=":)" title="Smile" /><br />Hapy New Year!<p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=2">Derrick</a> — Fri Dec 31, 2010 6:21 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Batlin]]></name></author>
<updated>2010-12-31T09:10:24+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=630&amp;p=1374#p1374</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=630&amp;p=1374#p1374"/>
<title type="html"><![CDATA[UO Demo • NPC states - The Old and The New]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=630&amp;p=1374#p1374"><![CDATA[
I was working on decoding and understanding more of the NPC AI and I suddenly stumbled upon an uncalled function inside the EXE. I documented the function and named it &quot;FUNC_GetNPCstateString&quot;. This is a screenshot of the function: FUNC_GetNPCstateString.pngThis is the C version of the same function: <dl class="codebox"><dt>Code: </dt><dd><code>const char *GetNPCstateString(int NPCstate)<br />{<br />  const char *result;<br /><br />  switch(NPCstate)<br />  {<br />    case 0x00:<br />      result = &quot;Seek Food&quot;;<br />      break;<br />    case 0x01:<br />      result = &quot;Seek Shelter&quot;;<br />      break;<br />    case 0x02:<br />      result = &quot;Purse Shelter&quot;;<br />      break;<br />    case 0x03:<br />      result = &quot;Seek Desires&quot;;<br />      break;<br />    case 0x04:<br />      result = &quot;Purse Desires&quot;;<br />      break;<br />    case 0x05:<br />      result = &quot;Eat Food&quot;;<br />      break;<br />    case 0x06:<br />      result = &quot;Loiter&quot;;<br />      break;<br />    case 0x07:<br />      result = &quot;Runaway&quot;;<br />      break;<br />    case 0x08:<br />      result = &quot;Talking&quot;;<br />      break;<br />    case 0x09:<br />      result = &quot;Attack Target&quot;;<br />      break;<br />    case 0x0A:<br />      result = &quot;Idle&quot;;<br />      break;<br />    case 0x0B:<br />      result = &quot;Wander&quot;;<br />      break;<br />    case 0x0C:<br />      result = &quot;Sleep&quot;;<br />      break;<br />    case 0x0D:<br />      result = &quot;Following&quot;;<br />      break;<br />    default:<br />      result = &quot;Unknown State&quot;;<br />  }<br />  return result;<br />}</code></dd></dl><br /><br />In the past I had already found an unused function that would SuperBark the current state of the NPC. However, that function did not match the actual states being used inside the core and scripts. Here's a screenshot of that function: FUNC_SuperBarkNPCstate__OLD.pngAgain, the C version: <dl class="codebox"><dt>Code: </dt><dd><code>void FUNC_SuperBarkNPCstate__OLD(NPC *NPCobject)<br />{<br />  const char *result;<br />  char TempStringBuffer&#91;512&#93;;<br /><br />  switch(NPCobject-&gt;CurrentState)<br />  {<br />    case 0x00:<br />      result = &quot;Wander&quot;;<br />      break;<br />    case 0x01:<br />      result = &quot;Pursue&quot;;<br />      break;<br />    case 0x02:<br />      result = &quot;Runaway&quot;;<br />      break;<br />    case 0x03:<br />      result = &quot;Combat&quot;;<br />      break;<br />    case 0x04:<br />      result = &quot;Following&quot;;<br />      break;<br />    case 0x05:<br />      result = &quot;Talking&quot;;<br />      break;<br />    case 0x06:<br />      result = &quot;Loiter&quot;;<br />      break;<br />    case 0x07:<br />      result = &quot;Sleep&quot;;<br />      break;<br />    case 0x0A:<br />      result = &quot;Idle&quot;;<br />      break;<br />    default:<br />      result = &quot;Bad State&quot;;<br />  }<br /><br />  // Format the state into nice output<br />  sprintf(TempStringBuffer, &quot;myState: %d  (%s)&quot;, NPCobject-&gt;CurrentState, result);<br /><br />  // Bark the nicely formatted state<br />  NPCobject-&gt;SuperBark(TempStringBuffer, -1, -1, -1);<br />}</code></dd></dl>If you look closely you will see I added the tag __OLD to the function because it dates most probably from an older period in OSI's UO development.<br /><br />How did I know which state function is the correct one? Well, the biggest clue is the sleep-state. In the first function I posted that equals state 0x0C, in the other one it is 0x07. There is a script command &quot;goSleep&quot;. Let's take a look at that one: COMMAND_GoSleep.pngFor most people, the C version: <dl class="codebox"><dt>Code: </dt><dd><code>int COMMAND_goSleep(int NPCserial, int SleepTimeInTicks, int PostSleepState)<br />{<br />  int result;<br /><br />  // Validate the PostSleepState<br />  if(PostSleepState &gt;= 0 &amp;&amp; PostSleepState &lt; 14)<br />  {<br />    // Ensure the given NPC is really a NPC object<br />    NPC NPCobject = ConvertObjectBySerialToNPCobject(NPCserial, &quot;setNPCState&quot;);<br />    if(NPCobject != NULL)<br />    {<br />      // Go set the actual sleep state<br />      NPCobject-&gt;GoSleep(SleepTimeInTicks, PostSleepState);<br />      result = 1;<br />    }<br />    else<br />      result = 0;<br />  }<br />  else<br />    result = 0;<br /><br />  return result;<br />}</code></dd></dl>The most important thing we learn from this function is the range check of the PostSleepState. This range equals the switch/case-statement in the top function. Next, let's look at the actual NPC class function GoSleep: FUNC_NPCobject_GoSleep.pngAt 0x004AB8D6 you see &quot;push 0x0C&quot;, this is the NewState being set when the NPC goes into sleep state. Perfect match with that first function.<br /><br />Thank you OSI for leaving those 2 functions in there, it's gonna be a whole lot easier to understand the NPC AI now and it gives a glimp from your old AI. More to come, but that's going to be for the new year, old year is today. Happy holidays to you all!<p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=758">Batlin</a> — Fri Dec 31, 2010 9:10 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Batlin]]></name></author>
<updated>2010-12-30T11:26:29+00:00</updated>
<id>http://www.joinuo.com/forums/viewtopic.php?t=629&amp;p=1373#p1373</id>
<link href="http://www.joinuo.com/forums/viewtopic.php?t=629&amp;p=1373#p1373"/>
<title type="html"><![CDATA[UO Demo • CanSeeLoc aka OSI's LOS (Line Of Sight)]]></title>

<category term="UO Demo" scheme="http://www.joinuo.com/forums/viewforum.php?f=32" label="UO Demo"/>
<content type="html" xml:base="http://www.joinuo.com/forums/viewtopic.php?t=629&amp;p=1373#p1373"><![CDATA[
This article is about the LOS algorithm which we can find inside the demo. Everything starts with the 2 script functions we have: canSeeLoc and canSeeObj. Both of them will end up calling a class function I named CanSeeLoc located at EIP 0x46ADA5. FUNC_XXX_CanSeeLoc is the internal name I gave (because it belongs to a class I could give a proper name for yet)<br /><br />Let's first take a look at canSeeLoc: canSeeLoc.pngcanSeeLoc takes an object as parameter and a location variable. The function will thus test if a certain object can see a certain location. The object is converted to a location by taking its location and adding halve the height of the object to the Z-axis. Not shown in the dissambly but all mobiles have a fixed height of 16 (even those tiny, nasty rats).<br /><br />canSeeObj is a bit different: canSeeObj.pngIt takes two objects as a parameter and will check if the target object is a hidden mobile. If the target object is a hidden mobile no further action is taken and 0 is returned. Also, looking at 'yourself' will result in a quick termination of the function with a return value of 1. Otherwise the canSeeObj class function of the item class is called. Refer to this post about the class structure for the game objects : <a href="http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=539" class="postlink">http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=539</a>.<br /><br />This is the canSeeObj of the item class: ItemObject_CanSeeObj.pngAgain, both objects are converted by adding halve their height to the Z axis and then calling the internal CanSeeLoc function.<br /><br />The actual magic is going on in the CanSeeLoc (FUNC_XXX_CanSeeLoc) function. This is a screenshot of all cross references to this function :xrefs to CanSeeLoc.png<br /><br />I converted all the assembler to readable C(++) code and turned it into a DLL using the UODEMODLL technique introduced here : <a href="http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=608" class="postlink">http://www.joinuo.com/forums/viewtopic.php?f=32&amp;t=608</a>. You can download the full source code and a precompiled DLL here : <a href="http://download.joinuo.com/UoDemoDLL/Version%201.1.rar" class="postlink">http://download.joinuo.com/UoDemoDLL/Version%201.1.rar</a>. Posting the full source code would only clutter this post and if you're interested I guess you're gonna download it anyways <img src="http://www.joinuo.com/forums/images/smilies/icon_e_smile.gif" alt=":)" title="Smile" />.<br /><br />This DLL contains advanced hacking techniques that redirect all calls to CanSeeLoc (see the picture above) to the DLL, tthe DLL will then call both the original function and the decompiled function. I did this so we could/can detect mismatches (= errors in the decompilation).<br /><br />One note about the algo, there are some &quot;&lt;&lt; 16&quot; lines in there, they act as an optimization to avoid slow floating point math in the algo. If someone else also understands the optimization and can explain it better than myself, please do so.<br /><br />Screenshot of the DLL in action: CanSeeLoc DLL.png<br /><br />As always, feel free to ask any questions.<p>Statistics: Posted by <a href="http://www.joinuo.com/forums/memberlist.php?mode=viewprofile&amp;u=758">Batlin</a> — Thu Dec 30, 2010 11:26 am</p><hr />
]]></content>
</entry>
</feed>