@@ -106,14 +106,57 @@ function buildWpm() {
106106 return serializeWpm ( { version : 0 , width, height, data, tail : Buffer . alloc ( 0 ) } ) ;
107107}
108108
109- /** Writes a fresh temp dir containing war3map.w3i / .wts / .wpm and returns its path. */
109+ function buildMmp ( ) {
110+ const w = new BinWriter ( 8 + 4 * 16 ) ;
111+ w . writeI32 ( 0 ) ; // version
112+ w . writeI32 ( 4 ) ; // icon count
113+ const icon = ( type , x , y , blue , green , red , alpha = 0xff ) => {
114+ w . writeI32 ( type ) ; w . writeI32 ( x ) ; w . writeI32 ( y ) ;
115+ w . writeU8 ( blue ) ; w . writeU8 ( green ) ; w . writeU8 ( red ) ; w . writeU8 ( alpha ) ;
116+ } ;
117+ icon ( 0 , - 1024 , 512 , 0xff , 0xff , 0xff ) ; // default gold mine color
118+ icon ( 1 , 256 , - 768 , 0x40 , 0x80 , 0xc0 ) ;
119+ icon ( 2 , 1024 , 2048 , 0xff , 0xff , 0xff , 0x80 ) ;
120+ icon ( 77 , 0 , 0 , 0x10 , 0x20 , 0x30 ) ;
121+ return w . toBuffer ( ) ;
122+ }
123+
124+ function buildW3c ( ) {
125+ const w = new BinWriter ( 256 ) ;
126+ w . writeI32 ( 0 ) ; w . writeI32 ( 2 ) ;
127+ const camera = ( name , values ) => {
128+ for ( const value of values ) w . writeF32 ( value ) ;
129+ w . writeString ( name ) ;
130+ } ;
131+ camera ( 'Overview' , [ 128 , 256 , 32 , 90 , 304 , 1650 , 0 , 70 , 5000 , 0 ] ) ;
132+ camera ( 'Boss Arena' , [ - 512 , 1024 , 64 , 180 , 280 , 2200 , 3 , 75 , 6000 , 1 ] ) ;
133+ return w . toBuffer ( ) ;
134+ }
135+
136+ function buildW3r ( ) {
137+ const w = new BinWriter ( 256 ) ;
138+ w . writeI32 ( 5 ) ; w . writeI32 ( 2 ) ;
139+ const region = ( name , minX , maxX , minY , maxY , index , weather , sound , blue , green , red , endToken = 0 ) => {
140+ w . writeF32 ( minX ) ; w . writeF32 ( maxX ) ; w . writeF32 ( minY ) ; w . writeF32 ( maxY ) ;
141+ w . writeString ( name ) ; w . writeI32 ( index ) ; w . writeId ( weather ) ; w . writeString ( sound ) ;
142+ w . writeU8 ( blue ) ; w . writeU8 ( green ) ; w . writeU8 ( red ) ; w . writeU8 ( endToken ) ;
143+ } ;
144+ region ( 'Spawn Area' , - 128 , 256 , - 64 , 384 , 3 , 'NULL' , 'Sound\\Environment\\GrasslandDay' , 0x40 , 0x80 , 0xc0 ) ;
145+ region ( 'Boss Room' , 512 , 1024 , 768 , 1280 , 7 , 'SNOW' , '' , 0x10 , 0x20 , 0x30 , 1 ) ;
146+ return w . toBuffer ( ) ;
147+ }
148+
149+ /** Writes a fresh temp dir containing the editable map-data fixtures and returns its path. */
110150function makeMapFixtureDir ( ) {
111151 const dir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'wurst-e2e-map-' ) ) ;
112152 fs . writeFileSync ( path . join ( dir , 'war3map.w3i' ) , buildW3i ( ) ) ;
113153 fs . writeFileSync ( path . join ( dir , 'war3map.wts' ) , WTS , 'utf8' ) ;
114154 fs . writeFileSync ( path . join ( dir , 'war3map.wpm' ) , buildWpm ( ) ) ;
155+ fs . writeFileSync ( path . join ( dir , 'war3map.mmp' ) , buildMmp ( ) ) ;
156+ fs . writeFileSync ( path . join ( dir , 'war3map.w3c' ) , buildW3c ( ) ) ;
157+ fs . writeFileSync ( path . join ( dir , 'war3map.w3r' ) , buildW3r ( ) ) ;
115158 fs . writeFileSync ( path . join ( dir , 'wurst.build' ) , 'projectName = wurst-e2e\n' ) ;
116159 return dir ;
117160}
118161
119- module . exports = { makeMapFixtureDir, buildW3i, buildWpm, WTS , W3I_VERSION } ;
162+ module . exports = { makeMapFixtureDir, buildW3i, buildWpm, buildMmp , buildW3c , buildW3r , WTS , W3I_VERSION } ;
0 commit comments