*******************************************************************************
* WarCraft III Replay ļʽ                                            *
*                                                                             *
* ĵ汾         : 1.13                                                     *
* ĵ         : 2004-07-18                                               *
* ĵ         : blue, nagger, soar(1.13 & )                          *
*                                                                             *
* w3gļʽϢ, :                                              *
*   http://warcraft.kliegman.com                                              *
* ۵̳:                                                           *
*   http://shadowflare.gameproc.com                                           *
* ʼϵ:                                                               *
*   mailto:w3g_format@nagger.net                                              *
*                                                                             *
*******************************************************************************

===============================================================================
Ŀ¼
===============================================================================
 1.0 
 2.0 [ļͷ]
     2.1  [ļͷ] ļͷ汾 0
     2.2  [ļͷ] ļͷ汾 1
     2.3  汾Ϣ
     2.4  WarCraft III The Frozen Throne beta replay Ϣ
 3.0 [ͷ]
 4.0 [ѹ]
     4.1  [Ҽ¼]
     4.2  [Ϸ]
     4.3  [ͼ]
     4.4  [ͼ¼]
     4.5  [ͼ&]
     4.6  []
     4.7  [Ϸ]
     4.8  [ID]
     4.9  [б]
     4.10 [Ϸʼ¼]
     4.11 [ͨ¼]
     4.12 []
 5.0 [Replay ]
 6.0 ۺϲ˵
     6.1  Blizzard ٷ Replay ˵
 7.0 л
 8.0 ĵʷ


===============================================================================
 (Ķ ...)
===============================================================================

ĵеϢͨоreplayļͲ²һЩݵ˼õ. 
֪ʶĶնǻϷеľ. ûʹκη, Ҳû޸κ
Ȩļ. ȷֹĵеϢκηǷΪ, Hack, ׻
. лBlizzardΰϷԼֱ׶Warcraft III replayļʽ ;-)

Ĺǰ, ޳ʹñĵṩϢ
Ըһڲ޸ĵǰ¸Ʊĵ(뽫ӵʼ -
 ϣԱּи)
ϣõĵṩϢܰǷcredits, Ƿһ
ʼ, Ϊ֪ĵŬļֵ ;-)


===============================================================================
1.0 
===============================================================================

ҪĿͷ

ĵеϢдЩ봴, ߺվԷḻWarcraft IIIϷ齻
Ŀõ

ȫHack׵Ϊ. 㲻ܽĵṩϢЩĿ

ļreplayʽ. ԺὫһЩ㷨ĸ˵ͽƵ
ļȥ("w3g_notes.txt")

ĵڲ. һЩ˼֪, һЩ"֪"Ҳڴ. 
ҵһЩδ֪ĺ"֪", ϵ

Լ:
-----
replayļд洢ص鶼÷[]


===============================================================================
2.0 [ļͷ]
===============================================================================

replayļļͷһЩѹ. ļͷĸʽΪ:

λַ   | / | 
-------+-----------+-----------------------------------------------------------
0x0000 | 28 chars  | 0βַ "Warcraft III recorded game\0x1A\0"
0x001c |  1 dword  | һѹλַ(༴ļͷС)
       |           |  Warcraft III 汾 <= v1.06 Ϊ 0x40
       |           |  Warcraft III 汾 >= 1.07 Լ TFT  replay Ϊ 0x44
0x0020 |  1 dword  | ѹļС
0x0024 |  1 dword  | replay ļͷ汾:
       |           |  Warcraft III 汾 <= v1.06 Ϊ 0x00
       |           |  Warcraft III 汾 >= 1.07 Լ TFT  replay Ϊ 0x01
0x0028 |  1 dword  | ѹݴС (ͷļ)
0x002c |  1 dword  | ļѹ
0x0030 |  n bytes  | ļͷ ( 2.1  2.2)

ļͷļͷСΪ 0x30 ֽ.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2.1 [ļͷ] ļͷ汾 0
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

ļͷڰ汾ŵڻ 1.06  replay ʹ

λַ   | / | 
-------+-----------+-----------------------------------------------------------
0x0000 |  1  word  | λ ( 0)
0x0002 |  1  word  | 汾 (汾 1.xx е xx)
0x0004 |  1  word  | Build ( 2.3)
0x0006 |  1  word  | ־
       |           |   0x0000 Ϸ
       |           |   0x8000 Ϸ (  Battle.net)
0x0008 |  1 dword  | replay  (λ: )
0x000C |  1 dword  | ļͷCRC32У
       |           | (УʱļͷΪ 0  CRC32 õ)

İ汾 0 ͷļС 0x40 ֽ.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2.2 [ļͷ] ļͷ汾 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

ļͷڰ汾ŵڻ 1.07  replay ʹ

λַ   | / | 
-------+-----------+-----------------------------------------------------------
0x0000 |  1 dword  | 汾У־:
       |           |  'WAR3' ʾ Warcraft III ԭ
       |           |  'W3XP' ʾ Warcraft III Ƭ 'The Frozen Throne'
       |           | ( 4 ֽڱ洢Ϊһ, ˳ǵߵ)
0x0004 |  1 dword  | 汾 (汾 1.xx е xx)
0x0008 |  1  word  | Build ( 2.3)
0x000A |  1  word  | ־
       |           |   0x0000 Ϸ
       |           |   0x8000 Ϸ (  Battle.net)
0x000C |  1 dword  | replay  (λ: )
0x0010 |  1 dword  | ļͷCRC32У
       |           | (УʱļͷΪ 0  CRC32 õ)

İ汾 1 ͷļС 0x44 ֽ.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2.3 汾Ϣ
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

   Ϸ汾   |   replayеİ汾  |    war3.exeİ汾   |   
--------------+-------------------+---------------------+----------------
    1.00      |     1.00.4448     |      1.0. 0.4448    |   2002-07-03
    1.01      |     1.01.4482     |      1.0. 1.4482    |   2002-07-05
    1.01b     |     1.01.4482     |      1.0. 1.4483    |   2002-07-10
    1.01c     |     1.01.4482     |                ?    |   2002-07-28
    1.02      |     1.02.4531     |      1.0. 1.4531    |   2002-08-15
    1.02a     |     1.02.4531     |      1.0. 1.4563    |   2002-09-06
    1.03      |     1.03.4572     |      1.0. 3.4653    |   2002-10-09
    1.04      |     1.04.4654     |      1.0. 3.4709    |   2002-11-04
    1.04b     |     1.04.4654     |      1.0. 3.4709    |   2002-11-07
    1.04c     |     1.04.4654     |      1.0. 4.4905    |   2003-01-30
    1.05      |     1.05.4654     |      1.0. 5.4944    |   2003-01-30
    1.06      |     1.06.4656     |      1.0. 6.5551    |   2003-06-03
    1.07      |     1.07.6031     |      1.0. 7.5535    |   2003-07-01
    1.10      |     1.10.6034     |      1.0.10.5610    |   2003-06-30
    1.11      |     1.11.6035     |      1.0.11.5616    |   2003-07-15
    1.12      |     1.12.6036     |      1.0.12.5636    |   2003-07-31
    1.13      |     1.13.6037     |      1.0.13.5816    |   2003-12-16
    1.13b     |     1.13.6037     |      1.0.13.5818    |   2003-12-19
    1.14      |     1.14.6039     |      1.0.13.5840    |   2004-01-07
    1.14b     |     1.14.6040     |      1.0.13.5840    |   2004-01-10
    1.15      |     1.15.6043     |      1.0.15.5926    |   2004-05-10
    1.16      |     1.16.6046     |      1.0.16.5926    |   2004-07-01

 汾Ĳ˵:
  o 1.02a  mpq  1.02c.
  o 汾 1.04b ֻж (bnet ϲ) һƱwar3.exe
  o 1.02, 1.02a, 1.04, 1.04b  war3.exe ĸ汾д.
  o Blizzard а汾ûзų patches: 1.01c, 1.04c, 1.10.
  o 汾 1.14 and 1.14b  replay 

 ۺϲ˵:
  o С汾µ replay ʽûв( 1.14  1.14b).
  o 鵱ǰ war3.exe ļԿԵõѰװ Warcraft III İ汾 (ο 3 )
  o RoC  TFT İ汾/Buildûв.
  o ԵϷİ汾Ҳûв.
  o ڰ汾 replay  'war3.exe'  Build/汾ͬ, Ͳͬ.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2.4 WarCraft III The Frozen Throne beta replay Ϣ
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Beta replay  RoC/TFT replay .
Ű汾ŵĶձ:

 汾   | ļͷ汾      | build# |  
--------+-------------------+--------+--------------
 301    | 汾 0            |  6010  |  2003-03-04
 302    | 汾 0            |  6011  |  2003-03-11
 303    | 汾 0            |  6012  |  2003-03-14
 304    | 汾 0            |  6013  |  2003-03-19
 304a   | 汾 0            |  6013  |  2003-03-24
 305    | 汾 1   (*)      |  6015  |  2003-03-28
 305a   | 汾 1   (*)      |  6016  |  2003-03-30
 306    | 汾 1            |  6018  |  2003-04-08
 307    | 汾 1            |  6019  |  2003-04-11
 308    | 汾 1            |  6021  |  2003-04-16
 309    | 汾 1            |  6022  |  2003-04-17
 310    | 汾 1            |  6023  |  2003-04-24
 311    | 汾 1            |  6027  |  2003-04-30
 312    | 汾 1            |  6030  |  2003-05-13
 313    | 汾 1            |  6031  |  2003-05-19
 314    | 汾 1            |  6034  |  2003-05-30
 314a   | 汾 1            |  6034  |  2003-06-02
 315    | 汾 1            |  6034  |  2003-06-10

 (*) 汾 305  305a ʹþ͵ V0 Ϸ汾ʽ (2 words).

  ˵:
  o 313 replay תΪ FT 1.07 replay.
  o 315 replay תΪ FT 1.10/1.11 replay.


===============================================================================
3.0 [ͷ]
===============================================================================

ÿѹһͷѹ.
һ replay ļͷиλַʼ(Ҳǽļͷ).
λַǴӽѹĿͷ.
ѹӳһ(ͷ). ( 4 )
ԭĻȫ޹.

λַ   | / | 
-------+-----------+-----------------------------------------------------------
0x0000 |  1  word  | ѹС n (ͷ)
0x0002 |  1  word  | ѹС (ǰΪ 0x8000)
0x0004 |  1 dword  | δ֪ (ӦУ, ޸ĺϷ޷ȡ, Ӱѹ)
0x0008 |  n bytes  | ѹ (zlibѹ)

 zlib ѹһķ:
 1.  'inflate_init'
 2.  'inflate'  Z_SYNC_FLUSH нѹ

һβ 0  0x8000 ֽ. ЩֽڿԺ.

//TODO: ӽѹϸƵļ


===============================================================================
4.0 [ѹ]
===============================================================================

ѹһɵ. λַı仯ȡǰÿ
ĴС

 replay ͷֵļ¼. Ǽ¼Ϸʼ֮ǰú
Ȩ޵Ϣ. Ϸе뿴 5 .

ͷֵ˳

 # |   С   | 
---+----------+--------------------------
 1 |   4 byte | δ֪ (0x00000110 - another record id?)
 2 | variable | Ҽ¼ ( 4.1)
 3 | variable | Ϸ (nullβַ) ( 4.2)
 4 |   6 byte | ͼ ( 4.3)
 5 |  10 byte | ͼ¼ ( 4.4)
 6 | variable | ͼ&  (encrypted null terminated string) ( 4.5)
 7 |   4 byte |  ( 4.6)
 8 |   4 byte | Ϸ ( 4.7)
 9 |   4 byte | ID ( 4.8)
10 | variable | б ( 4.9)
11 | variable | Ϸʼ¼ ( 4.10)

ֽϸЩ.
Щ(г)֮ĵݵϢڵ 5 ֽ.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.1 [Ҽ¼]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

λַ   | / | 
-------+-----------+-----------------------------------------------------------
0x0000 |  1 byte   | ¼ID:
       |           |  0x00 Ϸ
       |           |  0x16  ( 4.9)
0x0001 |  1 byte   | ID
0x0002 |  n bytes  |  (nullβַ)
   n+2 |  1 byte   | ݵĳ:
       |           |  0x01 = ԶϷ
       |           |  0x08 = ladder

ݸϷͲͬ¼:

o ԶϷ:

  λַ   | / | 
  -------+-----------+---------------------------------------------------------
  0x0000 | 1 byte    | ֽ (1 byte)

o  ladder Ϸ:

  λַ   | / | 
  -------+-----------+---------------------------------------------------------
  0x0000 | 4 bytes   | ҵϷгʱ(λ: )
  0x0004 | 4 bytes   | ־:
         |           |   0x01=human
         |           |   0x02=orc
         |           |   0x04=nightelf
         |           |   0x08=undead
         |           |  (0x10=daemon)
         |           |   0x20=random
         |           |   0x40=race selectable/fixed ( 4.11 Ĳ˵)


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.2 [Ϸ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

һnullβַ, ʾϷ

ֻԶ battle.net ϷһϷ, Ϸǹ̶:

o  ladder Ϸ, ϷΪ "BNet".

o ھϷ, ϷΪһԻİϷߵַ.
  : һ 'Blue' ϷϷΪ:
        Ӣİ: "Blue's game"
        ڵİ: "Spiel von Blue"

o ڵϷ, ϷΪһػԵַ.
        Ӣİ: "local game"
        ڵİ: "Lokales Spiel"

o ǱػԵĶӦַб
  Ӧ WarCraft III 1.06 ͵İ汾
  ( war3.mpq ڵ UI\FrameDef\GlobalStrings.fdf: GAMENAME, LOCAL_GAME):

  Ӣİ         : "%s's Game"         : "local game"
  ݿİ  (1029): "Hra %s"            : "Mstn?hra"
  İ    (1031): "Spiel von %s"      : "Lokales Spiel"
  İ(1034): "Partida de %s"     : "Partida local"
  İ    (1036): "Partie de %s"      : "Partie locale"
  İ(1040): "Partita di %s"     : "Partita locale"
  İ  (1045): "Gra (%s)"          : "Gra lokalna"

  %s ʾϷߵ ID.

o ǱػԵĶӦַб
  Ӧ WarCraft III  1.07 ߰汾
  ( war3.mpq ڵ UI\FrameDef\GlobalStrings.fdf: GAMENAME, LOCAL_GAME):

  İ    (1031): "Lokales Spiel (%s)"  : "Lokales Spiel"

  %s ʾϷߵ ID.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.3 [ͼ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

ͼ (Ϸĸѡ) һЩλ־ 6(?) ֽڿ.
ڸѡľĶϷĿ¼µ "support/Readme/(PC)UIMainMenus.html"

ĶǷ 0 λ־.
ע: 벿ԲӢİ.

λַ   |  λ   | 
-------+-------+---------------------------------------------------------------
0x0000 |       | ֽ 0x00
-------+-------+---------------------------------------------------------------
0x0001 |   0   | δ֪ (Ϊ 1?)
       |   1   | == 1 ʾϷٶΪ 'normal'
       |   2   | == 1 ʾ 'visibility: hide terrain'
       |   4   | == 1 ʾ 'Full Shared Unit Control'
       |   5   | λַ - ֻڵͼ "(12)DivideAndConquer.w3m" 
-------+-------+---------------------------------------------------------------
0x0002 |   0   | δ֪ (Ϊ 1?)
       |   1   | == 1 ʾϷٶΪ 'fast'
-------+-------+---------------------------------------------------------------
0x0003 |   0   | δ֪ (Ϊ 1?)
       |   1   | == 1 ʾ 'visibility: map explored'
       |   2   | == 1 ʾ 'visibility: always visible' (ս)
       |   3   | == 1 ʾ 'visibility: default'
       |   4   | == 1 ʾĹ۲
       |   5   | == 1 ʾ 'Observers on Defeat'
       |   6   | == 1 ʾ 'Teams Together'
       |       |    (ͬ)
-------+-------+---------------------------------------------------------------
0x0004 |   0   | δ֪ (Ϊ 1?)
       |   1   | == 1 ʾ 'fixed teams' (λ 1  2 )
       |   2   | == 1 ʾ 'fixed teams'
-------+-------+---------------------------------------------------------------
0x0005 |   0   | δ֪ (Ϊ 1?)
       |   1   | == 1 ʾ 'random hero'
       |   2   | == 1 ʾ 'random races'
       |   6   | == 1 ʾ'Referees'
-------+-------+---------------------------------------------------------------

 ˵:
  o ٶ 'normal'  'fast' ûдʱʾٶ "slow"
  o ֽ 0x03 λ 4  5 ûдʱʾ 'No Observers' 
  o ֽ 0x03 λ 4  5 ʱʾ 'Full Observers'
  o ֽ 0x03 λ 4  5 ûдֽ 0x05 λ 6 ʱʾ 'Referees'
  o ׼ ladder ϷĵͼֵΪ: 0x00 0x01 0x03 0x43 0x07 0x01


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.4 [ͼ¼]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

ʱһЩͼ¼.
ʱһЩ replay еõ 2 õͼֵ:

  01 01 01 91 01 01 F7 8F DB 05 - plunder 1.02 İ (ladder)
  01 01 01 91 01 01 F7 8F DB 05 - plunder 1.03 İ (ladder)
  01 01 01 A9 01 01 F5 89 A1 4F - plunder 1.04 İ (ladder)
  01 01 01 A9 01 01 F5 89 A1 4F - plunder 1.05 İ (ladder)
  01 01 01 A9 01 01 F5 89 A1 4F - plunder 1.06 İ (ladder)

  01 01 01 C9 01 01 11 F5 61 13 - LT 1.02 İ (ladder)
  01 01 01 C9 01 01 11 F5 61 13 - LT 1.03 İ (ladder)
  01 01 01 E9 01 01 5D 0D 87 05 - LT 1.04 İ (ladder)
  01 01 01 E9 01 01 5D 0D 87 05 - LT 1.05 İ (ladder)
  01 01 01 E9 01 01 5D 0D 87 05 - LT 1.06 İ (ladder)

- ֽ 2  5 ԶϷﲻͬ (ÿͼҲһ):

  01 01 01 A9 01 01 F5 89 A1 4F - plunder 1.05 İ (ladder)
  01 55 01 A9 75 01 F5 89 A1 4F - plunder 1.05 İ (Զ)
  01 55 01 A1 75 01 63 59 9F B7 - plunder 1.10 İ (Զ)

  01 01 01 E9 01 01 5D 0D 87 05 - LT 1.05 İ (ladder)
  01 7D 01 E9 7D 01 5D 0D 87 05 - LT 1.05 İ (Զ)

  Щֽڵ˼ʱ֪ !

-  dword ǵͼУ.
  Warcraft III ȡͼУ벻Ե replay.

// TODO: ԰汾


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.5 [ͼʹ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 3  null βַ, Ϊһ null βַ. һַ
ǵͼ, ڶǴ(ladder ϷʱΪ "Battle.Net"), ǿַ.

һֽδֽ(ͨΪ 'Maps' ĵһĸ 'M').

ÿ 8 ֽһ:

ֽ | 
-----+---------------------------------------
 0   | ֽ(Կ)
 1-7 | ַ

ֽڵÿλӦַһַ. λ 0 Ӧֽ 0, λ 1 Ӧֽ 1,
.
ֻֽ 1-7 õַ.
λ 0  1;
ķʽַ:

Ӧλ '1' ַ.
Ӧλ '0' ַԼ1.

ĿһֱظȥֱַNULLβ.

ʾ ( C ):

char* EncodedString;
char* DecodedString;
char  mask;
int   pos=1;
int   dpos=1;

DecodedString[0]=EncodedString[0];

while (EncodedString[pos] != 0)
{
  if ((pos-1)%8 == 0) mask=EncodedString[pos];
  else
  {
    if ((mask & (0x1 << ((pos-1)%8))) == 0)
      DecodedString[dpos++] = EncodedString[pos] - 1;
    else
      DecodedString[dpos++] = EncodedString[pos];
  }
  pos++;
}


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.6 []
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

4 bytes - һͨ
   Battal.Net ϷǾ
  ԶϷ, ǼϷͨ
  ڵϷΪ 12


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.7 [Ϸ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

λַ   | / | 
-------+-----------+-----------------------------------------------------------
0x0000 |  1 byte   | Ϸ:
       |           | (0x00 = λַ,  1.03 ֮ǰԶϷг)
       |           |  0x01 =   Ladder -> 1on1 or FFA
                               Զ -> 籾  ( 100% ȷ)
       |           |  0x09 = ԶϷ
       |           |  0x1D = Ϸ
       |           |  0x20 = Ladder Ϸ (AT  RT, 2on2/3on3/4on4)
0x0001 |  1 byte   | ˽ԶϷ־:
       |           |  0x00 -  /Battle.net Ϸ
       |           |  0x08 - ˽ Battle.net Ϸ
0x0002 |  1 word   | δ֪ (ͨΪ 0x0000)

TODO:
  汾 >= 1.07 ֵ:
    01 00 00 00 : ladder 1on1 / custom scenario
    20 00 00 00 : ladder team
    09 00 00 00 : custom game
    09 A8 12 00 : custom game
    09 A0 12 00 : custom game
    09 A8 42 00 : custom game
    09 A8 14 00 : custom game
    09 A0 14 00 : custom game
    01 40 13 00 : custom game
    09 A0 42 00 : custom game
    09 A8 44 00 : custon game


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.8 [ID]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4 ֽ - (ս, ͼ, Ϸ޹!)
ҲһУ.
Լ replays ҵ:

C4 F0 12 00 - patch 1.10 İ
90 F1 12 00 - patch 1.06 İ
90 F1 12 00 - patch 1.05 İ
A0 F6 6D 00 - patch 1.04 İ
24 F8 12 00 - patch 1.04 Ӣİ(?)
A0 F6 6D 00 - patch 1.03 İ
C0 F6 6D 00 - patch 1.02 İ

//TODO: ҳʾʲô.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.9 [б]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

бһ¼ϷϢ.
ֻдߵĵϷб!
ÿϢĽṹ:

λַ   | / | 
-------+-----------+-----------------------------------------------------------
0x0000 | 4/11 byte | Ҽ¼ ( 4.1)
0x000? |    4 byte | δ֪
       |           |  (ڰ汾 >= 1.07  0x00000000
       |           |   ڰ汾 <= 1.06  0x00000001)

ظ¼ֱһֽڲΪҼ¼ID(0x16).


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.10 [Ϸʼ¼]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

λַ   | / | 
-------+-----------+-----------------------------------------------------------
0x0000 |  1 byte   | ¼ID -  0x19
0x0001 |  1 word   | ֽ
0x0003 |  1 byte   | ͨ¼ nr (== ׼ nr ͨҼϷ)
0x0004 |  n bytes  | nr * ͨ¼ ( 4.11)
   n+4 |  1 dword  |  ( 4.12)
   n+8 |  1 byte   | ѡģʽ
       |           |   0x00 - /ѡ (ͨԶϷ)
       |           |   0x01 - 鲻ѡ
       |           |          (ͼ: fixed alliances in WorldEditor)
       |           |   0x03 - ͵ͼѡ
       |           |          (ͼ: fixed player properties in WorldEditor)
       |           |   0x04 - ΪRandom
       |           |          (չͼѡ: random races selected)
       |           |   0xcc - ԶϷ (ladder)
   n+9 |  1 byte   | ʼ (ڵͼϵĿʼλõĸ)


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.11 [ͨ¼]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

λַ   | / | 
-------+-----------+-----------------------------------------------------------
0x0000 |  1 byte   | ͨ (0x00 ʾ)
0x0001 |  1 byte   | δ֪ (ladderϷΪ0xff , ԶϷΪ0x64 ???)
0x0002 |  1 byte   | ͨ״̬:
       |           |   0x00 򿪵ͨ
       |           |   0x01 رյͨ
       |           |   0x02 ʹõͨ
0x0003 |  1 byte   | ұ־:
       |           |   0x00 ҿ
       |           |   0x01 Կ
0x0004 |  1 byte   | :0 - 11
       |           |    12 == ۲߻
0x0005 |  1 byte   | ɫ (0-11):
       |           |   ֵ+1 Ӧ world editor ɫ:
       |           |   (, , , , , , , ۺ, , , , )
       |           |   ɫ 12 == ۲߻
0x0006 |  1 byte   | ־ (׼ѡ):
       |           |   0x01=human
       |           |   0x02=orc
       |           |   0x04=nightelf
       |           |   0x08=undead
       |           |   0x20=
       |           |   0x40=ѡ/̶ (Ĳ˵)
0x0007 |  1 byte   |  AI ǿ: ( v1.03 ߰汾г)
       |           |   0x00 Easy
       |           |   0x01 Normal
       |           |   0x02 Insane
       |           |  AI ֽ 0x01
0x0008 |  1 byte   | ϰ(handicap)ٷֱ (׼ʾ)
       |           | Чֵ: 0x32, 0x3C, 0x46, 0x50, 0x5A, 0x64
       |           | ( v1.07 ߰汾г)

 ˵:
  o 汾 1.03 ֮ǰ replay ¼ֻ 7 ֽ, ֽû.

  o 汾 1.03 - 1.06  replay ¼ֻ 8 ֽ, һֽû.

  o ͨ״̬Ϊ򿪺͹رյͨ, ɫЧ.

  o  Warcraft III 汾 <= 1.06:
    ־ 0x40 , ̶ѡ ( 4.10).

  o  Warcraft III 汾 >= 1.07:
    ־ 0x40 , ѡ, һ ladder Ϸ
    ̶ ( 4.10).


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.12 []
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ΪпWarcraft IIIϷʼʱ趨. Ϊ
 replay ݽѾһӵǰ (Ҫȷʼ)

ԶϷ ( battle.net ǾϷ)  dword Ϸߵ
Ϸʱ (λ: )

ladderϷ, ֵ仯޳ -  battle.net ͻ˵һ "ȷ
ʵ" .


===============================================================================
5.0 [Replay ]
===============================================================================

 4 ֵ֮ڷӳϷ̵ Replay .

Replay ݱָΪһС̶仯С, Щ˳ǹ
, Ҳ֪һҪ.

һΪ ID ֽʼ. ͨ ID ҪҪ
Ĳ. ֪鶼ǰ ID , ˵. ÿ
С( ID Ǹֽ).

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x17  - 뿪Ϸ                                                    [ 14 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1 dword - 뿪
             0x01 - ӱԶϷر
             0x0C - ӱϷر
             0x0E - δ֪ (ټ) ( 0x01 )
  1 byte  - ұ
  1 dword - Ϸ - ı
  1 dword - δ֪ (replay Ĵ洢?)


 еһЩǽ:
     = ұŶӦ
   = replay ı ( = һ뿪)
  INC    = Ǹδ֪һ뿪Ϸ 1
  [?]    = ǺűǵĽͶھ replay õǴڸ
           replay Υ.
  [O]    =  replay  observer, õ 0x01

        |    | 
 ===========+========+=======================================================
    0x01    |  0x01  | 뿪 (ϿӻΪ۲)                  [O]
   (Զ)   |  0x07  | 뿪
            |  0x08  |  (ȫ)
            |  0x09  | ʤ
            |  0x0A  | ƽ (̫ĽϷ)
            |  0x0B  | 뿪 (Ϊ۲)                            [?]
 -----------+--------+-------------------------------------------------------
    0x0E    |  0x01  | 뿪                                           [?]
   (Զ)   |  0x07  | 뿪                                           [?]
            |  0x0B  | 뿪 (Ϊ۲)                            [?]
 ===========+========+=======================================================
    0x0C    |  0x01  | ߵ / ۲뿪                            [O]
  ()|  0x07  | , Ϣ                               [?]
            |  0x08  |  (ȫ), Ϣ
            |  0x09  | ʤ, Ϣ
            |  0x0A  | ƽ (̫ĽϷ)
            |  0x0B  |  (Ϊ۲, 򱻻ܺ䵱Ĺ۲)
 -----------+--------+-------------------------------------------------------
  last 0x0C |  0x01  | ߵ
   () |  0x07  |  INC => ʤ
            |        | û INC => 
            |  0x08  |  (ȫ)
            |  0x09  | ʤ
            |  0x0B  |  INC => ±ʤ, ʱΪ   [?]
            |        | û INC =>  (Ϊ۲)                [?]

 ˵:
  o Ϊֹǻûҵһÿ replay ʤж㷨.
    ǲ˴Լ 6000  replay. ͨ ladder Ϸж, ɹ۲
    ߱ FFA ϷжϽǳ. ȻҪо...

 ˵:
  o Ҫʹñǵ ([?],[O]) жʤ. ڴжпܵõ
    , ޱǵӦǰȫ޴(ٵ)

  o һҵõƽֽϷΪƽ.

  o replay ߵĽܴڶ - ΪЩ뿪Ϣ( = 0x0C)
    ͻ. ʱ޷жΪʤ (ʹδǵ).

  o 뿪ĽֵԵҵ.
    . һ뿪ϷжΪ伴ʹöʤ.

  o һһһʤöʤȫΪ.

  o һҶиöϷ.

  o ΪϷܼ¼˳Ľ, ǵһ˳, 
    и, ϷĻ, ޷ҵʤ(ж˫ʣԵõ
    ȷһ², ǾԵ, ҪȡҵĲԵ).


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x1A      - δ֪ (һʼ)                                    [ 5 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1 dword - δ֪ ( 0x01)

 ˵:
  o ƺǿʼϷĵһ, 治ظ.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x1B      - δ֪ (ڶʼ)                                    [ 5 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1 dword - δ֪ ( 0x01)

 ˵:
  o ƺǿʼϷĵڶ, 治ظ.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x1C      - δ֪ (ʼ)                                    [ 5 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1 dword - δ֪ ( 0x01)

 ˵:
  o ƺǿʼϷĵ, 治ظ.
  o ټڵڶ (0x1B) ͵ (0x1C) ʼ֮仹 (0x20)
    뿪Ϸ (0x17).


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x1E       - ʱ                                          [ n+3 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  0x1F

 ˵:
  o ڰ汾 <= 1.02  replay ﲻ 0x1F .
  o ڰ汾 >= 1.07  replay Ҳٵسֹ. ʱ沢ûи
     (0x22).


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x1F       - ʱ                                          [ n+3 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1 word   - n = ֽ
  1 word   - ʱ (λ: )
               battle.net Լ 250 
              ھ͵ϷԼ 100 
  n-2 byte - / ( n = 2 򲻴)

 ʱŹжÿйҶٴһ.

 ʽ:
   1 byte  - ұ
   1 word  - С
   n byte  -  ( 'w3g_actions.txt')

 ˵:
  o 'ʱ'  fastest ٶ¼.
  o ۼǰе 'ʱ' õǰʱ.
  o Ǹ (0x22)
  o ڰ汾 <= 1.02  replay  ID Ϊ 0x1E.
  o ڶϸڵĵ 'w3g_actions.txt' .


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x20       - Ϣ (汾 >= 1.07)                           [ n+4 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1 byte   - ұ (Ϣ)
  1 word   -  n = ֽ
  1 byte   - ־
              0x10   ׼ӳٽϷϢ? (˵)
              0x20   ͨϢ
  1 dword  - ģʽ (־Ϊ 0x10 ):
              0x00   ҵϢ
              0x01   ѵϢ
              0x02   ۲߻еϢ
              0x03+N  N Ϣ (N = ͨ)

  n bytes  - null βַ, ʾ

 ˵:
  o Ӱ汾 1.07 ʼ.
  o ֻ replay ߷ͺͽܵϢŻᱻ¼.
  o replay ߷۲ߵϢ¼.
  o ͨź 4.11 еͨŶӦ, һͨΪ 0.
  o ۼǰе 'ʱ' õϢʱ ( 0x1E  0x1F).

 Ա־ = 0x10 Ĳ˵:
  o ֻʼ 0x1B  0x1C ֮.
  o 'ģʽ' . ϢֱӸڱ־. ȷӳȱ仯.
  o Щڿ replay ʱʾ.
  o Щ¼ֻԶϷ replay . ҲΪ׼
    ϢΪӳûϷʼǰߴӶϷʼʾ.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x22      - δ֪ (У)                                [ 6 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1 byte  - ֽ ( 4)
  1 dword - δ֪ (ǳ)

 ˵:
  o ڰ汾 <= 1.02  replay  ID Ϊ 0x20.
  o ֵʱ, ҲʱһݵУ.
  o Ǹ 'ʱ' .


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x23      - δ֪                                                    [ 11 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 Ҳ:
  1 dword - δ֪
  1 byte  - δ֪ ( 4?)
  1 dword - δ֪ (?)
  1 byte  - δ֪ ( 0?)

 ˵:
  o ټ.
  o  '뿪Ϸ' ǰ.

 ʾ:
  23 4C 0D 00 00 04 0B B0 B1 FC 00  ->  "#L........."    3404 4 4239503371 0
  23 64 07 00 00 04 AC 34 28 7E 00  ->  "#d.....4(~."    1892 4 2116564140 0
  23 FB 0D 00 00 04 DD B8 B1 87 00  ->  "#.........."    3579 4 2276571357 0
  23 D5 15 00 00 04 19 ED 43 72 00  ->  "#.......Cr."    5589 4 1917054233 0
  23 1B 03 00 00 04 D8 2E 81 4F 00  ->  "#........O."     795 4 1333866200 0
  23 F2 04 00 00 04 91 7F C6 01 00  ->  "#........."    1266 4   29786001 0


  all following back-to-back in a single replay:
  23 3A 03 00 00 04 B5 1F DC 80 00  ->  "#:........."     826 4 2161909685 0
  23 3B 03 00 00 04 DE A7 93 77 00  ->  "#;.......w."     827 4 2006165470 0
  23 3C 03 00 00 04 A9 A6 78 3B 00  ->  "#<......x;."     828 4  997762729 0
  23 3D 03 00 00 04 25 87 97 9C 00  ->  "#=....%...."     829 4 2627176229 0

TODO: һ


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0x2F      - ǿϷʱ (ͼȫ)                            [ 9 byte ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1 dword - ģʽ:
             0x00 ڵʱ
             0x01 ʱ (**ǿƽϷ)
  1 dword -  ʱʣ

 ˵:
  o Ӱ汾 1.07 ʼ.
  o ֻڽʱ battle.net Ϸг.
  o һ㵹ʱ 4:58 ʼʱ, ÿ 30 ظһ
    (4:58, 4:28, 3:58, ..., 0:58, 0:28, 0:00).
  o һγʱ "ս" ر (ͼȫ).


===============================================================================
6.0 ۺϲ˵
===============================================================================

o  replay ûҵ:
    + Battle.net 
    + Ϸ/ʱ
    + ladder Ϸеҵȼ//ս

o  replay βԼ - Ϸڶȡ replay ʱ (
  Blizzard Ĺٷ replay,  6.1).

o replay ߾һ˳Ϸ. 뿪Ϸ ( 5.0) Ҳ replay
  һ. Ҳ˵, ѹݵ 9 ֽھreplay ߵ
  (ؽ replay), Աѩٷ replay Ч.

o Ϸȡ replay ϷΪۿ.

o Ϸȷм¼ replay :
   - AT ()  RT () Ϸ replay ͬ.
   - ͨҵĶжǷϷ.
   - ͨҵĲͬǷ 2 жǷ FFA Ϸ.

o Ϸʱ '-loadfile' ϷֱӲ¼:
    War3.exe -loadfile "replayfilename"
  ۿ replay ĵʺΪ World Editor 趨Ĳʺ(ͨΪ'WorldEdit')

o Warcraft III ԭ 1.07, 1.08  1.09 汾.
  1.06 ֱӸƬ 1.10 .

o Warcraft III Ƭ 1.07 ֱ 1.10, û 1.08, 1.09 汾.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6.1 Blizzard ٷ Replay ˵
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Щ replay  blizzard Ӹ߼ ladder Ϸ ׶εϷԶ¼
. ǿԴӹٷ Battle.net ҳص, һ replay һЩͬ.

֮ͬ:
 o build  ( 2.2)  0.

 o ļСļͷиֵ 132 ֽ (Ľ).

 o ͼ¼ ( 4.4)  '01 01  01 F9 01 01  FF FF FF FF'.

 o бÿǸδֵ֪ ( 4.9) ID ͬ ( 4.8).

 o ͨ ([Ϸʼ¼]λַ 0x0003,  4.10) Ϊ 0 - ͨ¼
   ( 4.11).

 o ʼ ([Ϸʼ¼],  4.10)  0xCC.

 o β 132 ֽΪһǩ:
    1 dword  : 4E 47 49 53 = 'NGIS' <=> 'SIGN'
    128 Byte : ǩ

:
 o Ϊûͨ¼, ΪҪԼЩ:
   ͨŴ 1  Ҽ¼ ( 4.1) :
     ұ     = ͨ
     ͨ״̬     = 0x02                   (ʹõͨ)
     ұ־ = 0x00                   (ҿ)
          = (ͨ - 1) mod 2   (ҲҼ¼ 2 )
     ɫ         = δ֪                   (õɫ)
              = Ҽ¼һ
      AI      = 0x01                   (ǵԿ)
     ϰ         = 0x64                   (100%)

 o  replay ʽ:
    'YYYYMMDDhhmmxxxxx-TAG-TYPEp.w3g'
   :
     YYYY  - 4 λ (GMT)
     MM    - ·
     DD    - 
     hh    - ʱ
     mm    - 
     xxxxx - ֱ
     TAG   - 'W3XP' ʾƬ, 'WAR3' ʾԭ
     TYPE  - ׼/ͼ
                (ڱʾ):
                 FRI - friday ()
                 SAT - saturday ()
                 SUN - sunday ()
               ƵĽ:
                 HUM - Human
                 ORC - Orc
                 NLF - Nightelf
                 UND - Undead
                 RND - Random
               ͼƵĽ:
                 CLD - Coldheart
                 FLD - Floodplains
                 GNW - Gnollwood
                 LST - Lost Temple
                 RCK - Turtle Rock
                 WET - Wetlands
     p     - ÿ

   ļʾ:
     20030816204000041-W3XP-SAT1.w3g
                        Ƭ 1on1 , Ϊ2003816
                        (ʼ 20:40 GMT)
     20030817222400050-W3XP-SUN2.w3g
                        Ƭ 2on2 , Ϊ2003817
     20030820205400081-W3XP-LST1.w3g
                        Ƭ 1on1 ʹõͼ "Lost Temple" ,
			Ϊ2003820


o ǲܸıļ޷ۿ replay, ɼӦǩļУ
  (Ҳ replay ).

o  replay  Blizzard  1.12 󲻾ù, ǰ汾ϷпҲ.


TODO: - ǩ


===============================================================================
7.0 л
===============================================================================

ҪлԱڸĵıдṩİ(ĸ˳):

o BlackDick
   - ļͷchecksum
   - 1.10
   - TFT beta replay汾Ϣ
   - һЩʾ͸

o DooMeer
   - '-loadfile'

o Ens
   - ģʽϢ (۲, ָ)

o Mark Pflug
   - ֶ 0x1E  0x23

o Kliegs
   -  notes.txt, ĵͻļ
   - ṩĵCVS

o ShadowFlare
   - WinMPQ
   - ṩ̳

o Soar
   - TFT replayʽһЩ

o Ziutek
   - Total Commander MPQ 


===============================================================================
8.0 ĵʷ (òûмݹʲ)
===============================================================================

 o general notes
 + information added
 - information changed

version 1.13 - 2004-07-18
-------------------------
 2004-07-18: + added build numbers for patch 1.16
 2004-07-18: - fixed some spelling mistakes

version 1.12 - 2004-01-18
-------------------------
 2004-01-17: - added build numbers for patches 1.14 and 1.14b


version 1.11 - 2004-01-02
-------------------------
 2003-12-20: - added build numbers for patches 1.13 and 1.13b
 2003-12-15: - fixed developer forum URL in header


version 1.10 - 2003-12-14
-------------------------
 2003-12-14: - fixed even more grammar/spelling mistakes
 2003-12-05: - fixed various grammar/spelling mistakes


version 1.09 - 2003-12-02
-------------------------
 2003-12-02: o killed a lot of trailing spaces
 2003-12-02: + added BETA patch release dates (section 2.4)
 2003-11-25: + added patch release dates (section 2.3)
 2003-11-23: - updated notes on version determination
 2003-11-11: - fixed some typos/grammar mistakes
 2003-11-11: - extended description of general block structure
 2003-11-06: + added many notes on winner detection (LeaveGame section)
 2003-11-03: + added version section (section 2.3)
 2003-10-11: - renamed "game creator" to "game host" in some places
 2003-10-11: - various minor layout improvements
 2003-10-05: + added note and examples on block 0x23
 2003-09-25: - changed one LeaveGame result
 2003-09-24: + added flag 0x10 description of chat blocks
 2003-09-24: + added note on third startblock


version 1.08 - 2003-09-20
-------------------------
 + added info on official Blizzard replays
 + added action blocks 0x1E and 0x23
 + added patch 1.12 build number
 + added note on loadfile-parameter
 + vastly improved leave game command (0x17) description
 - fixed error in header ID string
 - changed description of version number fields for subheaders version 0
 - renamed action block 0x1F to 'TimeSlot' and improved description
 - many minor updates and fixes


version 1.07 - 2003-07-31
-------------------------
 + added missing chat modes (thx Ens)
 + added size information to all blocks in section 5
 + improved introduction part of sections 4 and 5
 - fixed 'referee' bug in map settings section
 o various layout improvements


version 1.06 - 2003-07-22
-------------------------
 + added replay data block 0x2F
 + added some additional notes to disclaimer
 + added some more build numbers (thanks to blackdick)
 + added version/build information on TFT beta replays (thx BlackDick)
 - renamed mostly all 'patch 1.10' to 'patch 1.07',
   because first TFT release was 1.07 and the replays had the same structure
   as in 1.10


version 1.05 - 2003-07-01
-------------------------
 - fixed error in description of new chat message block (0x20)
 + added information on fixed races in patch 1.10
 + added some minor notes related to patch 1.10


version 1.04 - 2003-06-30
-------------------------
 + added note on game type in section 6.
 + added some minor notes
 + added patch 1.10 format changes:
    o new header (section 2)
    o handicap field (section 4.11)
    o referee type observers (sections 4.3 and 4.11)
    o chat message block (section 5)
 + added some patch 1.10 example records


version 1.03 - 2003-06-16
-------------------------
 + added build numbers for all released patches
 + added some minor notes in various sections
 + added some patch 1.06 example records
 - fixed missing dword (section [LeaveGame])
 + added some language strings (section [GameName])
 + added notes about replay saver


version 1.02 - 2003-06-14
-------------------------
 o removed all "//*" marks for better readability
 - fixed some typos
 - fixed patch version for blocks 0x1E and 0x20 in section 5
   (patch <= 1.02 instead of <1.05)
 - minor cleanups of various sections


version 1.01 - 2003-06-12
-------------------------
 o differences and additions to kliegs notes.txt are marked with //*
 o minor layout improvements in section 5
 - renamed 'Player Actions block' to 'Player commands block'
   and updated whole paragraph


version 1.00 - 2003-06-06
-------------------------
 o first public release
 o differences and additions to kliegs notes.txt are marked with //*
 + added info on header checksum calculation (thx BlackDick)
 + added info on first unknown field in header (thx BlackDick)


version 0.90 - 2003-06-04
-------------------------
 o beta release
 o differences and additions to kliegs notes.txt are marked with //*


This document was created using VIM 6.2 (www.vim.org).


===============================================================================
End of File
===============================================================================

