<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
		<id>http://mm2kiwi.apan.is-a-geek.com/index.php?action=history&amp;feed=atom&amp;title=CPVS</id>
		<title>CPVS - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://mm2kiwi.apan.is-a-geek.com/index.php?action=history&amp;feed=atom&amp;title=CPVS"/>
		<link rel="alternate" type="text/html" href="http://mm2kiwi.apan.is-a-geek.com/index.php?title=CPVS&amp;action=history"/>
		<updated>2026-04-14T17:14:28Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.27.1</generator>

	<entry>
		<id>http://mm2kiwi.apan.is-a-geek.com/index.php?title=CPVS&amp;diff=1749&amp;oldid=prev</id>
		<title>Midas at 10:41, 14 May 2016</title>
		<link rel="alternate" type="text/html" href="http://mm2kiwi.apan.is-a-geek.com/index.php?title=CPVS&amp;diff=1749&amp;oldid=prev"/>
				<updated>2016-05-14T10:41:48Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&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;' lang='en-GB'&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 10:41, 14 May 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l28&quot; &gt;Line 28:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 28:&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;Another peculiarity with these lists is that the first two bits of every list is reserved for something unknown. So the status for block 0 is set in bits 2-3 of the first byte in the list.&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;Another peculiarity with these lists is that the first two bits of every list is reserved for something unknown. So the status for block 0 is set in bits 2-3 of the first byte in the list.&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;/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;/td&gt;&lt;/tr&gt;
&lt;tr&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: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So, consider a city consisting of 16 blocks. If blocks number 0, 2 and 4 are visible from a particular block, the list of that block would look like this:&lt;/div&gt;&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;So, consider a city consisting of 16 blocks. If blocks number 0, 2&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, 3 &lt;/ins&gt;and 4 are visible from a particular block, the list of that block would look like this:&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;&amp;#160; Hex:&amp;#160;  c&amp;#160;  c&amp;#160; &amp;#160; 0&amp;#160;  f&amp;#160; &amp;#160; 0&amp;#160;  0&amp;#160; &amp;#160; 0&amp;#160;  0&amp;#160; &amp;#160; 0&amp;#160;  0&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;&amp;#160; Hex:&amp;#160;  c&amp;#160;  c&amp;#160; &amp;#160; 0&amp;#160;  f&amp;#160; &amp;#160; 0&amp;#160;  0&amp;#160; &amp;#160; 0&amp;#160;  0&amp;#160; &amp;#160; 0&amp;#160;  0&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;&amp;#160; Bin:&amp;#160; |11001100|00001111|00000000|00000000|00000000|&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;&amp;#160; Bin:&amp;#160; |11001100|00001111|00000000|00000000|00000000|&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mm2kiwi:diff:version:1.11a:oldid:1325:newid:1749 --&gt;
&lt;/table&gt;</summary>
		<author><name>Midas</name></author>	</entry>

	<entry>
		<id>http://mm2kiwi.apan.is-a-geek.com/index.php?title=CPVS&amp;diff=1325&amp;oldid=prev</id>
		<title>Fre-Ber: /* Format description */</title>
		<link rel="alternate" type="text/html" href="http://mm2kiwi.apan.is-a-geek.com/index.php?title=CPVS&amp;diff=1325&amp;oldid=prev"/>
				<updated>2006-06-21T21:16:39Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Format description&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&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;' lang='en-GB'&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 21:16, 21 June 2006&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l64&quot; &gt;Line 64:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 64:&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;The compressed representation of the example list from above looks like this: (In hex)&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;The compressed representation of the example list from above looks like this: (In hex)&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;&amp;#160; 81 cc 0f 02 00&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;&amp;#160; 81 cc 0f 02 00&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&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: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;You probably noticed that this compressed representation actually requires the exact same number of bytes as the uncompressed list. This, however, depends only on the fact that the example city we used has very few blocks. In a normal city, with hundreds of blocks, the gain is considerable. Remember that each list holds two bits for every block in the city and most of these blocks will not be seen from any single block. This is likely to result in large series of zeros in the lists, these will effectively be eaten up by the run-length-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;encoing&lt;/del&gt;.&lt;/div&gt;&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;You probably noticed that this compressed representation actually requires the exact same number of bytes as the uncompressed list. This, however, depends only on the fact that the example city we used has very few blocks. In a normal city, with hundreds of blocks, the gain is considerable. Remember that each list holds two bits for every block in the city and most of these blocks will not be seen from any single block. This is likely to result in large series of zeros in the lists, these will effectively be eaten up by the run-length-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;encoding&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mm2kiwi:diff:version:1.11a:oldid:89:newid:1325 --&gt;
&lt;/table&gt;</summary>
		<author><name>Fre-Ber</name></author>	</entry>

	<entry>
		<id>http://mm2kiwi.apan.is-a-geek.com/index.php?title=CPVS&amp;diff=89&amp;oldid=prev</id>
		<title>Fre-Ber: /* Format description: Cross-reference to PSDL */</title>
		<link rel="alternate" type="text/html" href="http://mm2kiwi.apan.is-a-geek.com/index.php?title=CPVS&amp;diff=89&amp;oldid=prev"/>
				<updated>2006-05-26T11:30:28Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Format description: Cross-reference to PSDL&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&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;' lang='en-GB'&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 11:30, 26 May 2006&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot; &gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&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;/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;/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;==Format description==&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;==Format description==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&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: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The CPVS file simply contains a list of visible blocks for every block in the PSDL. What makes the CPVS file a bit different is that the lists are compressed using a &amp;quot;run-length-encoding&amp;quot; algorithm.&lt;/div&gt;&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;The CPVS file simply contains a list of visible blocks for every block in the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[[&lt;/ins&gt;PSDL&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;]]&lt;/ins&gt;. What makes the CPVS file a bit different is that the lists are compressed using a &amp;quot;run-length-encoding&amp;quot; algorithm.&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;/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;/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;In a pseudo C-style format, the file looks like this:&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;In a pseudo C-style format, the file looks like this:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key mm2kiwi:diff:version:1.11a:oldid:74:newid:89 --&gt;
&lt;/table&gt;</summary>
		<author><name>Fre-Ber</name></author>	</entry>

	<entry>
		<id>http://mm2kiwi.apan.is-a-geek.com/index.php?title=CPVS&amp;diff=74&amp;oldid=prev</id>
		<title>Fre-Ber: /* Copied info from mm2c, corrected and added some info */</title>
		<link rel="alternate" type="text/html" href="http://mm2kiwi.apan.is-a-geek.com/index.php?title=CPVS&amp;diff=74&amp;oldid=prev"/>
				<updated>2006-05-26T11:26:26Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Copied info from mm2c, corrected and added some info&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Introduction==&lt;br /&gt;
MM2 looks for and reads a CPVS file when a city is loaded. The CPVS file is used to speed up the rendering process of MM2. PVS stands for &amp;quot;Potentially Visible Sets&amp;quot; and this is a general algorithm for grouping objects in a certain way to make it easy for the renderer to determine what parts of a scene to take into account when rendering.&lt;br /&gt;
&lt;br /&gt;
==Format description==&lt;br /&gt;
The CPVS file simply contains a list of visible blocks for every block in the PSDL. What makes the CPVS file a bit different is that the lists are compressed using a &amp;quot;run-length-encoding&amp;quot; algorithm.&lt;br /&gt;
&lt;br /&gt;
In a pseudo C-style format, the file looks like this:&lt;br /&gt;
 struct CPVS&lt;br /&gt;
 {&lt;br /&gt;
     char[4] header = &amp;quot;PVS0&amp;quot;;&lt;br /&gt;
     ulong nBlocks;    // Number of blocks + 2&lt;br /&gt;
     ulong[nBlocks - 2] offsets;&lt;br /&gt;
     uchar[rest of file] pvsLists;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The ''offsets'' array indicates how far into the ''pvsLists'' block to go to find the start of the compressed list for each block.&lt;br /&gt;
&lt;br /&gt;
The ''pvsLists'' array contains all compressed PVS lists in block order. A PVS list is simply a list containing two bits for every block in the PSDL. There is one list for each block and they are stored consecutively in the ''pvsLists'' array of bytes.&lt;br /&gt;
&lt;br /&gt;
Each byte of a PVS list indicates the visibility status of four blocks. The order of the blocks in the byte is a bit awkward. Bits 0-1 are the first block, bits 2-3 are the second, 4-5 the third and finaly bits 6-7 are the fourth block. This may sound logical, but consider that the bits come in this order: 76543210&lt;br /&gt;
&lt;br /&gt;
The values of the two bits means this:&lt;br /&gt;
* 00 - Block is not visible&lt;br /&gt;
* 01 - Unknown (No apparent effect)&lt;br /&gt;
* 10 - Unknown (No apparent effect)&lt;br /&gt;
* 11 - Block is visible&lt;br /&gt;
&lt;br /&gt;
Another peculiarity with these lists is that the first two bits of every list is reserved for something unknown. So the status for block 0 is set in bits 2-3 of the first byte in the list.&lt;br /&gt;
&lt;br /&gt;
So, consider a city consisting of 16 blocks. If blocks number 0, 2 and 4 are visible from a particular block, the list of that block would look like this:&lt;br /&gt;
 Hex:   c   c    0   f    0   0    0   0    0   0&lt;br /&gt;
 Bin:  |11001100|00001111|00000000|00000000|00000000|&lt;br /&gt;
 Block: 2 1 0 *  6 5 4 3  a 9 8 7  e d c b  * * * f&lt;br /&gt;
Note that the last byte is padded with zero to fill up the byte.&lt;br /&gt;
&lt;br /&gt;
Before the lists are stored, however, they are individually compressed using a run-length-encoding algorithm. This is a simple compression algorithm, it compresses sequences of repeating bytes and stores them as a counter and a single byte instead of repeating them. So, the first byte of a compressed sequence is a seven bit counter, n and a one-bit operation code. The operation code, usually the top bit, bit 7, indicates one of two operations required to decompress the next segment of data. If the operation code is 0, i.e. the top bit is cleared, the decoder should read the next byte and duplicate it n times. If, instead, the operation code is 1, the decoder should read the following n bytes as they are. After this it reads a new counter and operation code and repeats the process.&lt;br /&gt;
&lt;br /&gt;
A run-length decoder can look something like this:&lt;br /&gt;
 char buf[bufSize];&lt;br /&gt;
 int bufPos = 0;&lt;br /&gt;
 int i;&lt;br /&gt;
 while (bufPos &amp;lt; listLen)&lt;br /&gt;
 {&lt;br /&gt;
     char n = read();&lt;br /&gt;
     if (n &amp;amp;0x7f == 0)&lt;br /&gt;
     {&lt;br /&gt;
         char c = read();&lt;br /&gt;
         for (i = 0; i &amp;lt; n + 1 &amp;amp; 0x7f; i++)&lt;br /&gt;
         {&lt;br /&gt;
             buf[bufPos++] = c;&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
     else&lt;br /&gt;
     {&lt;br /&gt;
         for (i = 0; i &amp;lt; n + 1; i++)&lt;br /&gt;
         {&lt;br /&gt;
             buf[bufPos++] = read();&lt;br /&gt;
         }&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Where ''bufSize'' is large enough to hold the decompressed data and ''listLen'' is the compressed length of the list.&lt;br /&gt;
&lt;br /&gt;
The compressed representation of the example list from above looks like this: (In hex)&lt;br /&gt;
 81 cc 0f 02 00&lt;br /&gt;
You probably noticed that this compressed representation actually requires the exact same number of bytes as the uncompressed list. This, however, depends only on the fact that the example city we used has very few blocks. In a normal city, with hundreds of blocks, the gain is considerable. Remember that each list holds two bits for every block in the city and most of these blocks will not be seen from any single block. This is likely to result in large series of zeros in the lists, these will effectively be eaten up by the run-length-encoing.&lt;/div&gt;</summary>
		<author><name>Fre-Ber</name></author>	</entry>

	</feed>