tprotocol.html - vaccinewars - be a doctor and try to vaccinate the world
 (HTM) git clone git://src.adamsgaard.dk/vaccinewars
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       tprotocol.html (26043B)
       ---
            1 <?xml version="1.0" encoding="UTF-8"?>
            2 
            3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
            4  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
            5 
            6 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
            7 
            8 <head>
            9 <title>The dopewars network protocol</title>
           10 <meta charset="utf-8"/>
           11 </head>
           12 
           13 <body>
           14 <h1>The dopewars network protocol</h1>
           15 
           16 <ul>
           17 <li><a href="#syntax">Syntax used in this document</a></li>
           18 <li><a href="#format">General message format</a></li>
           19 <li><a href="#startgame">Starting a game from the client</a></li>
           20 <li><a href="#refserver">Server to client message reference</a></li>
           21 <li><a href="#refclient">Client to server message reference</a></li>
           22 </ul>
           23 
           24 <h2><a id="syntax">Syntax used in this document</a></h2>
           25 
           26 <dl>
           27 <dt><tt>(runhere)</tt></dt>
           28 <dd>A single character field (equivalent to C's %c format).</dd>
           29 
           30 <dt><tt>&lt;ID&gt;</tt></dt>
           31 <dd>A numeric field - an integer printed in text form, without spaces, commas
           32 or other punctuation. Note that the number is not stored directly as its
           33 binary representation, but as a string - i.e. "100" takes 3 characters
           34 (bytes), not one. Equivalent to C's %d format.</dd>
           35 
           36 <dt><tt>"text"</tt></dt>
           37 <dd>Freeform text, equivalent to C's %s format.</dd>
           38 
           39 </dl>
           40 
           41 <p>Anything else should be taken as literal characters, which should appear in
           42 the message exactly as printed here.</p>
           43 
           44 <h2><a id="format">General message format</a></h2>
           45 
           46 <p>dopewars clients communicate with the dopewars server by means of a TCP/IP
           47 connection. Messages are sent in plain text, are of variable length, and
           48 are always terminated by a linefeed character ('\n', ASCII code 10)</p>
           49 
           50 <p>Messages themselves are typically split into 'words', delimited by the caret
           51 (^) character. The underline character (_) is also used to break up
           52 translatable strings (tstrings), if the <a href="#tstring">A_TSTRING</a>
           53 ability is active, and thus these two characters, together with the \n
           54 character, should normally be avoided in message data.</p>
           55 
           56 <p>Messages are usually of the format:-</p>
           57 
           58 <dl>
           59 <dt><tt>&lt;ID&gt;^(A)(C)"data"</tt></dt>
           60 <dd><tt>ID</tt> = player ID (may also be blank if this is not applicable)<br />
           61 <tt>A</tt> = one-letter message subtype code (used by AI players)<br />
           62 <tt>C</tt> = one-letter message type code<br />
           63 <tt>data</tt> = message-dependent information</dd>
           64 </dl>
           65 
           66 <p>e.g. "1^AFHello player"</p>
           67 
           68 <p>If ID is not specified, it should be left blank when sending to the server,
           69 and should be ignored in reading messages from the server.</p>
           70 
           71 <p>The "data" field often contains multiple items, separated by ^ characters.
           72 Note that the last field in such a message should <b>not</b> be assumed to be
           73 terminated by the message terminator, \n - although it always will be, it
           74 should also be first terminated by the field separator, the ^ character.
           75 This allows the client to ignore extra fields, if later versions
           76 of the protocol should add them. (N.B. This does not apply to free-form text
           77 fields, as in the C_QUESTION, C_PRINTMESSAGE, C_MSG, C_MSGTO, and C_FIGHTPRINT
           78 messages, which _do_ extend to the end of the message; for these messages,
           79 the caret is generally interpreted as a line break.) Note also that older
           80 servers may not send all the fields, so if fewer fields than expected are
           81 received, the client should substitute default values.</p>
           82 
           83 <p>Message codes are shown below, together with the symbolic constants used in
           84 the dopewars code for clarity (e.g. the 'A' code is represented by
           85 C_PRINTMESSAGE)</p>
           86 
           87 <p>For the AI codes, see the AICode type in src/message.h</p>
           88 
           89 <p><a id="oldprotocol">N.B. Older versions of dopewars used a less
           90 sophisticated protocol:-</a></p>
           91 
           92 <dl>
           93 <dt><tt>"From"^"To"^(A)(C)"data"</tt></dt>
           94 <dd><tt>A</tt>, <tt>C</tt>, and <tt>data</tt> are the same; however
           95 <tt>"From"</tt> and <tt>"To"</tt> are the player <b>names</b> (not IDs) of
           96 the players that the message is coming from and going to. Again, these can
           97 often be left blank. This old protocol is used if the
           98 <a href="#playerid">A_PLAYERID</a> ability is not present.</dd>
           99 </dl>
          100 
          101 <p>e.g. "Fred^Bert^AFHello player"</p>
          102 
          103 <h2><a id="startgame">Starting a game from the client</a></h2>
          104 
          105 <p>To start a game, the client must first notify the server of the protocol
          106 it can support (with the <a href="#abilities">C_ABILITIES</a> message) and
          107 then provide a suitable player name (with the <a href="#name">C_NAME</a>
          108 message). Note that both of these messages must be sent using the
          109 <a href="#oldprotocol">old protocol</a>, as before protocol negotiation is
          110 complete (both server and client have sent a C_ABILITIES message) the server
          111 will default to using this protocol, for backwards compatibility. After sending
          112 these two messages, the game is run mainly by the server; the client should
          113 listen for incoming messages, and respond appropriately.</p>
          114 
          115 <h2><a id="refserver">Server to client message reference</a></h2>
          116 
          117 <p>The messages listed below may be sent from a dopewars server to the client.
          118 Most of these messages require some kind of processing to be done, and may
          119 require a response. The client cannot safely ignore such messages, as the
          120 server will not "retry" if the client does not respond.</p>
          121 
          122 <dl>
          123 
          124 <dt><b>C_PRINTMESSAGE</b> ('<tt>A</tt>')</dt>
          125 <dd>Sent when the server wishes the client to display some text<br />
          126 <tt>data</tt> = The text that the client should display; any ^ delimiters in
          127 this text should be taken to mean a new line.<br />
          128 e.g. "^AAGame over^You made the high score list"<br />
          129 <b>Answer required:</b> no<p /></dd>
          130 
          131 <dt><b>C_LIST</b> ('<tt>B</tt>')</dt>
          132 <dd>Used by the server to tell the client about other logged on players<br />
          133 <tt>data</tt> = <tt>"name"^&lt;ID&gt;</tt><br />
          134 <tt>name</tt> = the name of the player<br />
          135 <tt>ID</tt> = the numeric ID that should be used to communicate with this
          136 player<br />
          137 e.g. "^ABFred^1"<br />
          138 <b>Answer required:</b> no<p /></dd>
          139 
          140 <dt><b>C_ENDLIST</b> ('<tt>C</tt>')</dt>
          141 <dd>Signals that all players have been listed (no more C_LIST messages to
          142 come)<br />
          143 e.g. "^AC"<br />
          144 <b>Answer required:</b> no<p /></dd>
          145 
          146 <dt><b>C_NEWNAME</b> ('<tt>D</tt>')</dt>
          147 <dd>Signals that the name provided by the client is unsuitable (usually, this
          148 is because it's already been taken by another player)<br />
          149 N.B. This is always sent at the start of the game, before protocol negotiation,
          150 so uses the old format, e.g. "^^AD"<br />
          151 <b>Answer required:</b> yes - must send a suitable C_NAME message to
          152 proceed<p /></dd>
          153 
          154 <dt><b>C_MSG</b> ('<tt>E</tt>')</dt>
          155 <dd>Contains a message from one player (or the server admin) broadcast to all
          156 connected players.<br />
          157 <tt>data</tt> = the message to display<br />
          158 <tt>ID</tt> = the ID of the player that sent the message<br />
          159 e.g. "1^AEHello world"<br />
          160 <b>Answer required:</b> no<p /></dd>
          161 
          162 <dt><b>C_MSGTO</b> ('<tt>F</tt>')</dt>
          163 <dd>Contains a private message from one player to another<br />
          164 <tt>data</tt> = the message to display<br />
          165 <tt>ID</tt> = the ID of the player that sent the message<br />
          166 e.g. "1^AFHello player"<br />
          167 <b>Answer required:</b> no<p /></dd>
          168 
          169 <dt><b>C_JOIN</b> ('<tt>G</tt>')</dt>
          170 <dd>Sent by the server to all players when a new player joins the game
          171 (See C_LIST for format)<br />
          172 <b>Answer required:</b> no<p /></dd>
          173 
          174 <dt><b>C_LEAVE</b> ('<tt>H</tt>')</dt>
          175 <dd>Sent by the server to all players when a player leaves the game<br />
          176 <tt>data</tt> = the name of the player that's leaving<br />
          177 <tt>ID</tt> = the ID of the player<br />
          178 e.g. "1^AHFred"<br />
          179 <b>Answer required:</b> no<p /></dd>
          180 
          181 <dt><b>C_SUBWAYFLASH</b> ('<tt>I</tt>')</dt>
          182 <dd>Used by the server to tell a client that it has just moved to a new
          183 location. (The client is not told where this location is, since this
          184 information is contained in a C_UPDATE message.) Clients usually reset any
          185 location-dependent state (e.g. fights) on receiving this message, and flash
          186 a "subway" indicator or similar<br />
          187 e.g. "^AI"<br />
          188 <b>Answer required:</b> no<p /></dd>
          189 
          190 <dt><b>C_UPDATE</b> ('<tt>J</tt>')</dt>
          191 <dd>Used by the server to update client state. This is also used to tell the
          192 player about the state of another player (a report from a spy)<br />
          193 <tt>data</tt> = <tt>&lt;cash&gt;^&lt;debt&gt;^&lt;bank&gt;^&lt;health&gt;^&lt;coatsize&gt;^&lt;locn&gt;^&lt;turn&gt;^&lt;flags&gt;^&lt;GUNS&gt;^&lt;DRUGS&gt;^&lt;DRUGVALUE&gt;^&lt;bitches&gt;</tt><br />
          194 <tt>cash</tt>, <tt>debt</tt>, <tt>bank</tt> = money available, owed to the
          195 loan shark, in the bank<br />
          196 <tt>coatsize</tt> = amount of space available for drugs/guns<br />
          197 <tt>locn</tt> = zero-based game location<br />
          198 <tt>turn</tt> = turn number<br />
          199 <tt>flags</tt> = player status flags - see PlayerFlags in src/dopewars.h for
          200 the individual binary bits. The only one currently used is SPYINGON (16) which
          201 is set if the player is currently spying on one or more other players<br />
          202 <tt>GUNS</tt> = the numbers of each gun carried, separated by ^ characters
          203 (there should be NumGun numbers in this list - see the C_INIT message)<br />
          204 <tt>DRUGS</tt> = similar, for carried drugs<br />
          205 <tt>DRUGVALUE</tt> = similar, but contains the total cash value of each drug;
          206 N.B. this field is only sent if the ability
          207 <a href="#drugvalue">A_DRUGVALUE</a> is present<br />
          208 <tt>bitches</tt> = number of accompanying bitches<br />
          209 <tt>ID</tt> = blank for a status update, otherwise the ID of the player that
          210 you're spying on<br />
          211 <b>Answer required:</b> no<p /></dd>
          212 
          213 <dt><b>C_DRUGHERE</b> ('<tt>K</tt>')</dt>
          214 <dd>Tells the client which drugs are available to buy at the current
          215 location<br />
          216 <tt>data</tt> = drug prices, separated by ^ characters. If a price is zero,
          217 that drug is not available here<br />
          218 <b>Answer required:</b> no<p /></dd>
          219 
          220 <dt><b>C_GUNSHOP</b> ('<tt>L</tt>')</dt>
          221 <dd>Tells the client to start up the "gun shop", for buying/selling guns<br />
          222 e.g. "^AL"<br />
          223 <b>Answer required:</b> yes - zero or more C_BUYOBJECT messages, followed by a
          224 C_DONE message<p /></dd>
          225 
          226 <dt><b>C_LOANSHARK</b> ('<tt>M</tt>')</dt>
          227 <dd>Tells the client that the player has a chance to pay back the loan<br />
          228 e.g. "^AM"<br />
          229 <b>Answer required:</b> yes - an optional C_PAYLOAN message, followed by a
          230 C_DONE message<p /></dd>
          231 
          232 <dt><b>C_BANK</b> ('<tt>N</tt>')</dt>
          233 <dd>Tells the client that the player has a chance to visit the bank<br />
          234 e.g. "^AN"<br />
          235 <b>Answer required:</b> yes - an optional C_DEPOSIT message, followed by a
          236 C_DONE message<p /></dd>
          237 
          238 <dt><b>C_QUESTION</b> ('<tt>O</tt>')</dt>
          239 <dd>Used to display a message from the server that requires a response<br />
          240 <tt>data</tt> = <tt>"keys"^"message"</tt><br />
          241 <tt>keys</tt> = a list of the valid single-character responses - e.g. "YN" for
          242 a yes/no question; the client may use these keys directly, or expand them to
          243 complete words (e.g. YN -> Yes/No)<br />
          244 <tt>message</tt> = the message to display<br />
          245 e.g. "^AOYN^Would you like to visit the bank?"<br />
          246 <b>Answer required:</b> yes - a C_ANSWER message, containing one of the valid
          247 response keys<p /></dd>
          248 
          249 <dt><b>C_HISCORE</b> ('<tt>Q</tt>')</dt>
          250 <dd>Used for the server to tell the client about a high score; C_HISCORE
          251 messages should only ever be sent after a C_STARTHISCORE message and before a
          252 C_ENDHISCORE message<br />
          253 <tt>data</tt> = <tt>&lt;index&gt;^(B)"score"</tt><br />
          254 <tt>index</tt> = the zero-based index of the high score (0 is the top
          255 score)<br />
          256 <tt>B</tt> = the single character 'B' if this score should be displayed in
          257 bold (usually to indicate that it's "your" score) or 'N' otherwise<br />
          258 <tt>score</tt> = the text containing the score, date, and player name<br />
          259 <b>Answer required:</b> no<p /></dd>
          260 
          261 <dt><b>C_STARTHISCORE</b> ('<tt>R</tt>')</dt>
          262 <dd>Tells the client that the server is about to send it a list of high scores;
          263 usually used by the client to display the title of a high score screen<br />
          264 e.g. "^AR"<br />
          265 <b>Answer required:</b> no<p /></dd>
          266 
          267 <dt><b>C_ENDHISCORE</b> ('<tt>S</tt>')</dt>
          268 <dd>Tells the client that the server has sent all of the high scores; usually
          269 used by the client to display a prompt to end the game (if data="end") or to
          270 return to the game (if data is not "end")<br />
          271 <tt>data</tt> = "end" if the game has finished, blank otherwise<br />
          272 e.g. "^ASend"<br />
          273 <b>Answer required:</b> no, but the client should disconnect if data="end"
          274 <p /></dd>
          275 
          276 <dt><b>C_PUSH</b> ('<tt>Z</tt>')</dt>
          277 <dd>Requests that the client leave the server<br />
          278 e.g. "^AZ"<br />
          279 <b>Answer required:</b> no, but the client should disconnect<p /></dd>
          280 
          281 <dt><b>C_QUIT</b> ('<tt>a</tt>')</dt>
          282 <dd>Notifies the client that the server is about to terminate<br />
          283 e.g. "^Aa"<br />
          284 <b>Answer required:</b> no, but the client should disconnect<p /></dd>
          285 
          286 <dt><b>C_RENAME</b> ('<tt>b</tt>')</dt>
          287 <dd>Instructs the client that another player has changed his/her name<br />
          288 <tt>data</tt> = the new player name<br />
          289 <tt>ID</tt> = the player's ID<br />
          290 e.g. "1^AbFred"<br />
          291 <b>Answer required:</b> no<p /></dd>
          292 
          293 <dt><b>C_INIT</b> ('<tt>k</tt>')</dt>
          294 <dd>Tells the client about various global game settings<br />
          295 <tt>data</tt> = <tt>"version"^&lt;numloc&gt;^&lt;numgun&gt;^&lt;numdrug&gt;^"bitch"^"bitches"^"gun"^"guns"^"drug"^"drugs"^"date"^&lt;ID&gt;^"loanshark"^"bank"^"gunshop"^"pub"^(prefix)"currency"</tt><br />
          296 <tt>version</tt> = dopewars version of the server - e.g. "1.5.2"<br />
          297 <tt>numloc</tt> = the number of locations in the game<br />
          298 <tt>numgun</tt> = the number of guns in the game<br />
          299 <tt>numdrug</tt> = the number of drugs in the game<br />
          300 <tt>bitch</tt>, <tt>bitches</tt>, <tt>gun</tt>, <tt>guns</tt>, <tt>drug</tt>,
          301 <tt>drugs</tt>, <tt>date</tt>, <tt>loanshark</tt>,
          302 <tt>bank</tt>, <tt>gunshop</tt>, <tt>pub</tt> = various names used in the
          303 game<br />
          304 <tt>ID</tt> = the ID that the client should use to refer to itself<br />
          305 <tt>prefix</tt> = '1' if the currency symbol (e.g. $) should be printed before
          306 prices in the game, '0' otherwise<br />
          307 <tt>currency</tt> = the currency symbol to use<br />
          308 e.g. "^Ak1.5.2^8^4^12^bitch^bitches^gun^guns^drug^drugs^12-^-1984^0^the Loan Shark^the Bank^Dan's House of Guns^the pub"^1$<br />
          309 <b>Answer required:</b> no<p /></dd>
          310 
          311 <dt><b>C_DATA</b> ('<tt>l</tt>')</dt>
          312 <dd>Tells the client about various game settings - 4 variants on this message
          313 are possible:-
          314 
          315 <dl>
          316 <dt>Information about locations in the game</dt>
          317 <dd><tt>data</tt> = <tt>&lt;index&gt;^A"name"</tt><br />
          318 <tt>index</tt> = zero-based index of the location<br />
          319 <tt>name</tt> = name of the location<br />
          320 e.g. "^Al0^ABronx"<p /></dd>
          321 
          322 <dt>Information about drugs</dt>
          323 <dd><tt>data</tt> = <tt>&lt;index&gt;^B"name"^&lt;min&gt;^&lt;max&gt;</tt>
          324 <tt>index</tt> = zero-based index of the drug<br />
          325 <tt>name</tt> = name of the drug<br />
          326 <tt>min</tt> = the minimum price of the drug<br />
          327 <tt>max</tt> = the maximum price of the drug<br />
          328 e.g. "^Al1^BCocaine^15000^29000"<p /></dd>
          329 
          330 <dt>Information about guns</dt>
          331 <dd><tt>data</tt> = <tt>&lt;index&gt;^C"name"^&lt;price&gt;^&lt;space&gt;^&lt;damage&gt;</tt><br />
          332 <tt>index</tt> = zero-based index of the gun<br />
          333 <tt>name</tt> = name of the gun<br />
          334 <tt>price</tt> = the normal cost of the gun<br />
          335 <tt>damage</tt> = the maximum damage that the gun can do<br />
          336 e.g. "^Al2^CRuger^2900^4^4"<p /></dd>
          337 
          338 <dt>Miscellaneous information</dt>
          339 <dd><tt>data</tt> = <tt>0^D&lt;spy&gt;^&lt;tipoff&gt;</tt><br />
          340 <tt>spy</tt> = the price to spy on another player<br />
          341 <tt>tipoff</tt> = the price to tip off the cops to another player<br />
          342 e.g. "^Al0^D20000^10000"</dd>
          343 </dl>
          344 
          345 <b>Answer required:</b> no<p /></dd>
          346 
          347 <dt><b>C_FIGHTPRINT</b> ('<tt>m</tt>')</dt>
          348 <dd><tt>data</tt> = <tt>"attack"^"defend"^&lt;health&gt;^&lt;bitches&gt;^"bitchname"^&lt;killed&gt;^&lt;armpct&gt;^(fightpoint)(runhere)(loot)(canfire)^"text"</tt><br />
          349 <tt>attack</tt> = name of the attacker player/cop if applicable (if blank,
          350 it's you)<br />
          351 <tt>defend</tt> = name of the defending player/cop if applicable (if blank,
          352 it's you)<br />
          353 <tt>health</tt> = defender's health, if applicable<br />
          354 <tt>bitches</tt> = number of bitches/deputies accompanying the defending
          355 player<br />
          356 <tt>bitchname</tt> = usually "bitch", "bitches", "deputy" or "deputies"<br />
          357 <tt>killed</tt> = number of bitches killed in this attack<br />
          358 <tt>armpct</tt> = a number between 0 and 100 showing how heavily armed the
          359 attacker is<br />
          360 <tt>fightpoint</tt> =<br />
          361 <dl>
          362 <dt>'<tt>A</tt>' (<b>F_ARRIVED</b>)</dt>
          363 <dd>The "defending" player has just arrived on the scene</dd>
          364 
          365 <dt>'<tt>S</tt>' (<b>F_STAND</b>)</dt>
          366 <dd>The "attacking" player chose not to shoot</dd>
          367 
          368 <dt>'<tt>H</tt>' (<b>F_HIT</b>)</dt>
          369 <dd>The "attacking" player fired on the defender, and hit</dd>
          370 
          371 <dt>'<tt>M</tt>' (<b>F_MISS</b>)</dt>
          372 <dd>The "attacking" player fired on the defender, and missed</dd>
          373 
          374 <dt>'<tt>R</tt>' (<b>F_RELOAD</b>)</dt>
          375 <dd>The "attacking" player is ready to fire again</dd>
          376 
          377 <dt>'<tt>L</tt>' (<b>F_LEAVE</b>)</dt>
          378 <dd>The "attacking" player has fled the fight, but other opponents remain</dd>
          379 
          380 <dt>'<tt>D</tt>' (<b>F_LASTLEAVE</b>)</dt>
          381 <dd>The "attacking" player has fled, and nobody else is present, so the fight
          382 is over</dd>
          383 
          384 <dt>'<tt>F</tt>' (<b>F_FAILFLEE</b>)</dt>
          385 <dd>The "attacking" player tried to get away, but failed</dd>
          386 
          387 <dt>'<tt>G</tt>' (<b>F_MSG</b>)</dt>
          388 <dd>Nothing exciting has happened, but "text" should still be displayed</dd>
          389 </dl>
          390 
          391 <tt>runhere</tt> = '1' if running should take you to the current location (if
          392 '0', you should jet to another location)<br />
          393 <tt>loot</tt> = '1' if the attack resulted in a kill and a loot of the body<br />
          394 <tt>canfire</tt> = '1' if you are allowed to shoot at other players right
          395 now<br />
          396 <tt>text</tt> = explanatory text from the server, to be printed<br />
          397 <b>Answer required:</b> yes, depending on the message contents: usually a
          398 C_REQUESTJET or C_FIGHTACT message<p /></dd>
          399 
          400 <dt><a id="abilities"><b>C_ABILITIES</b></a> ('<tt>r</tt>')</dt>
          401 <dd>Negotiates protocol extensions between client and server<br />
          402 <tt>data</tt> =
          403 <tt>(playerid)(drugvalue)(newfight)(tstring)(donefight)(utf8)(date)</tt>
          404 
          405 <p><a id="playerid"><tt>playerid</tt></a> = '1' if we use player IDs rather
          406 than player names to identify players in network messages ('0' otherwise). It is
          407 strongly recommended that this new protocol be used, as the old protocol is
          408 difficult to properly support, and is deprecated. However, the new protocol is
          409 only supported by servers of version 1.5.0 or above. (N.B. Since the old
          410 protocol does not support the C_ABILITIES message either, before the client and
          411 server have exchanged C_ABILITIES messages the server will "talk" using the old
          412 protocol. Thus, the C_ABILITIES message itself from the client, and any
          413 succeeding messages sent before the server sends C_ABILITIES back, must be
          414 sent using the old protocol. "Old" servers will ignore the C_ABILITIES
          415 message.) Ability name in dopewars code: <b>A_PLAYERID</b></p>
          416 
          417 <p><a id="drugvalue"><tt>drugvalue</tt></a> = '1' if the server should keep
          418 track of how much players paid for their drugs, so that they can see whether
          419 they're getting a good deal when they come to sell them ('0' otherwise).
          420 Ability name in dopewars code: <b>A_DRUGVALUE</b></p>
          421 
          422 <p><a id="newfight"><tt>newfight</tt></a> = '1' if we use the "new" fighting
          423 interface (documented here). Highly recommended. Ability name in dopewars
          424 code: <b>A_NEWFIGHT</b></p>
          425 
          426 <p><a id="tstring"><tt>tstring</tt></a> = '1' if names of drugs etc. should be
          427 sent in the <a href="i18n.html">translated string</a> (tstring) notation;
          428 only necessary if you are supporting non-English languages. Ability name
          429 in dopewars code: <b>A_TSTRING</b></p>
          430 
          431 <p><a id="donefight"><tt>donefight</tt></a> = '1' if, when a fight finishes,
          432 the client is expected to send a C_DONE message to instruct the server to
          433 move on. (This is to allow the user to close the fight dialog before any
          434 new dialogs pop up.) Ability name in dopewars code: <b>A_DONEFIGHT</b></p>
          435 
          436 <p><a id="utf8"><tt>utf8</tt></a> = '1' if all strings are sent over the
          437 network in UTF-8 (Unicode) encoding, rather than an encoding specific to
          438 the locale of the server or client. Ability name in dopewars code:
          439 <b>A_UTF8</b></p>
          440 
          441 <p><a id="date"><tt>date</tt></a> = '1' if the C_INIT message sends/receives
          442 the Names.Date variable, rather than Names.Month and Names.Year as older
          443 versions used to. Ability name in dopewars code: <b>A_DATE</b></p>
          444 
          445 <p><b>N.B.</b> Only seven abilities are listed here. Older servers or clients
          446 may not only not support some of these abilities, they may not even know
          447 of their existence (conversely, newer versions may add new abilities). Thus
          448 all servers and clients, if passed an unexpectedly short abilities string,
          449 should pad it out with zeroes. If passed a long string, it should be truncated.
          450 This will cause these extra (or unspecified) abilities to be unsupported.
          451 (The order of the abilities string should never change.)</p>
          452 
          453 e.g. "^^Ar1010000" (N.B. the double ^ is a feature of the "old" protocol)</dd>
          454 
          455 </dl>
          456 
          457 <h2><a id="refclient">Client to server message reference</a></h2>
          458 
          459 <p>The messages are below are typically sent from the client to the server. Note
          460 that players do not communicate directly between each other, but always via
          461 the server. Note also that some of these messages are also valid when sent
          462 from the server to the client.</p>
          463 
          464 <dl>
          465 
          466 <dt><b>C_MSG</b> ('<tt>E</tt>')</dt>
          467 <dd>Contains a message from one player to be broadcast to all connected
          468 players<br />
          469 <tt>data</tt> = the message to display<br />
          470 e.g. "^AEHello world"<p /></dd>
          471 
          472 <dt><b>C_MSGTO</b> ('<tt>F</tt>')</dt>
          473 <dd>Contains a private message from one player to another<br />
          474 <tt>data</tt> = the message to display<br />
          475 <tt>ID</tt> = the ID of the player to send the message to<br />
          476 e.g. "1^AFHello player"<p /></dd>
          477 
          478 <dt><b>C_BUYOBJECT</b> ('<tt>T</tt>')</dt>
          479 <dd>Requests the server to buy or sell an object<br />
          480 <tt>data</tt> = <tt>"type"^&lt;index&gt;^&lt;amount&gt;</tt><br />
          481 <tt>type</tt> = "bitch", "gun" or "drug"<br />
          482 <tt>index</tt> = the zero-based index of the gun/drug that you want to
          483 buy/sell, or zero if type="bitch"<br />
          484 <tt>amount</tt> = the number of objects to buy (or, if negative, to sell)<br />
          485 e.g. "^ATbitch^0^1"<p /></dd>
          486 
          487 <dt><b>C_DONE</b> ('<tt>U</tt>')</dt>
          488 <dd>Sent by the client when it's finished with the loan shark, bank, or gun
          489 shop<br />
          490 e.g. "^AU"<p /></dd>
          491 
          492 <dt><b>C_REQUESTJET</b> ('<tt>V</tt>')</dt>
          493 <dd>Asks the server to jet to a new location (or to run from a fight)<br />
          494 <tt>data</tt> = the numeric, zero-based, location to jet to<br />
          495 e.g. "^AV2"<p /></dd>
          496 
          497 <dt><b>C_PAYLOAN</b> ('<tt>W</tt>')</dt>
          498 <dd>Asks to pay back a loan to the loan shark<br />
          499 <tt>data</tt> = the amount of money to pay back<br />
          500 e.g. "^AW5000"<p /></dd>
          501 
          502 <dt><b>C_ANSWER</b> ('<tt>X</tt>')</dt>
          503 <dd>Sends the reply to a previous question from the server<br />
          504 <tt>data</tt> = the single character response<br />
          505 e.g. "^AXY"<p /></dd>
          506 
          507 <dt><b>C_DEPOSIT</b> ('<tt>Y</tt>')</dt>
          508 <dd>Asks to deposit money into (or withdraw money from) the bank<br />
          509 <tt>data</tt> = the amount of money to deposit, or (if negative) the amount
          510 to withdraw<br />
          511 e.g. "^AY10000"<p /></dd>
          512 
          513 <dt><a id="name"><b>C_NAME</b></a> ('<tt>c</tt>')</dt>
          514 <dd>Sent by the client to register the player name with the server<br />
          515 <tt>data</tt> = the player's name<br />
          516 N.B. this is always sent at the start of the game, in which case the old
          517 format should be used, e.g. "^^AcFred"<p /></dd>
          518 
          519 <dt><b>C_SACKBITCH</b> ('<tt>d</tt>')</dt>
          520 <dd>Requests that a bitch should be sacked<br />
          521 e.g. "^Ad"<p /></dd>
          522 
          523 <dt><b>C_TIPOFF</b> ('<tt>e</tt>')</dt>
          524 <dd>Asks the server to tip off the cops to another player<br />
          525 <tt>ID</tt> = the player ID to tip off the cops to<br />
          526 e.g. "1^Ae"<p /></dd>
          527 
          528 <dt><b>C_SPYON</b> ('<tt>f</tt>')</dt>
          529 <dd>Asks the server to spy on another player<br />
          530 <tt>ID</tt> = the player ID to spy on<br />
          531 e.g. "1^Af"<p /></dd>
          532 
          533 <dt><b>C_WANTQUIT</b> ('<tt>g</tt>')</dt>
          534 <dd>Tells the server that the client wishes to leave the game early<br />
          535 e.g. "^Ag"<p /></dd>
          536 
          537 <dt><b>C_CONTACTSPY</b> ('<tt>h</tt>')</dt>
          538 <dd>Asks the server to send back reports about all the players that we are
          539 currently spying on<br />
          540 e.g. "^Ah"<p /></dd>
          541 
          542 <dt><b>C_REQUESTSCORE</b> ('<tt>j</tt>')</dt>
          543 <dd>Asks the server to send back the high score list<br />
          544 e.g. "^Aj"<p /></dd>
          545 
          546 <dt><b>C_FIGHTACT</b> ('<tt>n</tt>')</dt>
          547 <dd>Responds to a previous C_FIGHTPRINT message<br />
          548 <tt>data</tt> = "<tt>F</tt>", "<tt>S</tt>", or "<tt>R</tt>"<br />
          549 <tt>F</tt> = return fire<br />
          550 <tt>S</tt> = stand and take it (do not return fire)<br />
          551 <tt>R</tt> = try to run away<br />
          552 N.B. If "runhere" is not set in the C_FIGHTPRINT message, the "R" response
          553 should not be sent - a C_REQUESTJET message should be sent instead.<br />
          554 e.g. "^AnF"<p /></dd>
          555 
          556 <dt><b>C_ABILITIES</b> ('<tt>r</tt>')</dt>
          557 <dd>Notifies the server of supported protocol features. See the explanation
          558 for the corresponding <a href="#abilities">server message</a>.
          559 
          560 <p>The client will receive this message in response to a previous C_ABILITIES
          561 message that it sent to the server. This reply message contains the abilities
          562 that the server is willing to support. The client should compare these to
          563 those that it previously offered, and then use only those abilities that both
          564 client and server support. (If the server does not support the new protocol,
          565 no C_ABILITIES reply message will be sent, and the client should assume that
          566 <b>no</b> abilities are supported.) The server will expect all client messages
          567 after the C_ABILITIES message to be compliant with these abilities.</p>
          568 
          569 e.g.<br />
          570 - client sends "1110111" (supports everything except
          571 <a href="#tstring">A_TSTRING</a>)<br />
          572 - server responds with "1011011" (supports everything except
          573 <a href="#drugvalue">A_DRUGVALUE</a> and
          574 <a href="#donefight">A_DONEFIGHT</a>)<br />
          575 - client should adopt the abilities "1010011"
          576 (<a href="#playerid">A_PLAYERID</a> and <a href="#newfight">A_NEWFIGHT</a>)</dd>
          577 
          578 </dl>
          579 
          580 <hr />
          581 <ul>
          582 <li><a href="index.html">Main index</a>
          583   <ul>
          584   <li><a href="developer.html">Notes for developers</a></li>
          585   </ul>
          586 </li>
          587 </ul>
          588 <p>
          589   Last update: <b>02-09-2002</b><br />
          590   Valid <a href="http://validator.w3.org/check/referer">XHTML 1.1</a>
          591 </p>
          592 </body>
          593 </html>