phantasmal-world/13.e06da0805ab744720dfa.js
Daan Vanden Bosch 74a9d89bd4 Release 52.
2020-01-29 13:24:47 +01:00

1 line
16 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[13],{"/UnV":function(t,e,i){"use strict";i.d(e,"a",(function(){return a}));var s=i("rwco"),n=i("BAAx"),r=i("5cb6");const o=s.a.get("core/data_formats/parsing/afs"),_=5457473;function a(t){const e=Object(n.b)(o);if(t.bytes_left<8)return e.add_problem(r.b.Error,"AFS archive is corrupted.","Too small to be an AFS archive.").failure();if(t.u32()!==_)return e.add_problem(r.b.Error,"AFS archive is corrupted.","Magic bytes not present.").failure();const i=t.u16();t.seek(2);const s=[];for(let n=1;n<=i;n++){if(t.bytes_left<8){e.add_problem(r.b.Warning,`AFS file entry ${n} is invalid.`,`Couldn't read file entry ${n}, only ${t.bytes_left} bytes left.`);break}const i=t.u32(),o=t.u32();if(i>t.size)e.add_problem(r.b.Warning,`AFS file entry ${n} is invalid.`,`Invalid file offset ${i} for entry ${n}.`);else if(i+o>t.size)e.add_problem(r.b.Warning,`AFS file entry ${n} is invalid.`,`File size ${o} (offset: ${i}) of entry ${n} too large.`);else{const e=t.position;t.seek_start(i),s.push(t.array_buffer(o)),t.seek_start(e)}}return e.success(s)}},"9dYx":function(t,e,i){"use strict";var s=i("bcBH");class n{constructor(t,e){this._position=0,this.endianness=t,this.offset=e}get position(){return this._position}get endianness(){return this.little_endian?s.a.Little:s.a.Big}set endianness(t){this.little_endian=t===s.a.Little}get bytes_left(){return this.size-this.position}seek(t){return this.seek_start(this.position+t)}seek_start(t){if(t<0||t>this.size)throw new Error(`Offset ${t} is out of bounds.`);return this._position=t,this}seek_end(t){if(t<0||t>this.size)throw new Error(`Offset ${t} is out of bounds.`);return this._position=this.size-t,this}u8(){return this.u8_at(this._position++)}u8_at(t){return this.check_offset(t,1),this.dv.getUint8(this.offset+t)}u16(){const t=this.u16_at(this.position);return this._position+=2,t}u16_at(t){return this.check_offset(t,2),this.dv.getUint16(this.offset+t,this.little_endian)}u32(){const t=this.u32_at(this.position);return this._position+=4,t}u32_at(t){return this.check_offset(t,4),this.dv.getUint32(this.offset+t,this.little_endian)}i8(){return this.i8_at(this._position++)}i8_at(t){return this.check_offset(t,1),this.dv.getInt8(this.offset+t)}i16(){const t=this.i16_at(this.position);return this._position+=2,t}i16_at(t){return this.check_offset(t,2),this.dv.getInt16(this.offset+t,this.little_endian)}i32(){const t=this.i32_at(this.position);return this._position+=4,t}i32_at(t){return this.check_offset(t,4),this.dv.getInt32(this.offset+t,this.little_endian)}f32(){const t=this.f32_at(this.position);return this._position+=4,t}f32_at(t){return this.check_offset(t,4),this.dv.getFloat32(this.offset+t,this.little_endian)}u8_array(t){this.check_size("n",t,t);const e=[];for(let i=0;i<t;++i)e.push(this.dv.getUint8(this.offset+this._position++));return e}u16_array(t){this.check_size("n",t,2*t);const e=[];for(let i=0;i<t;++i)e.push(this.dv.getUint16(this.offset+this.position,this.little_endian)),this._position+=2;return e}u32_array(t){this.check_size("n",t,4*t);const e=[];for(let i=0;i<t;++i)e.push(this.dv.getUint32(this.offset+this.position,this.little_endian)),this._position+=4;return e}i32_array(t){this.check_size("n",t,4*t);const e=[];for(let i=0;i<t;++i)e.push(this.dv.getInt32(this.offset+this.position,this.little_endian)),this._position+=4;return e}vec2_f32(){return{x:this.f32(),y:this.f32()}}vec3_f32(){return{x:this.f32(),y:this.f32(),z:this.f32()}}string_ascii(t,e,i){const s=[];for(let n=0;n<t;n++){const r=this.u8();if(e&&0===r){i&&this.seek(t-n-1);break}s.push(r)}return String.fromCodePoint(...s)}string_utf16(t,e,i){const s=[],n=Math.floor(t/2);for(let t=0;t<n;t++){const r=this.u16();if(e&&0===r){i&&this.seek(2*(n-t-1));break}s.push(r)}return String.fromCodePoint(...s)}string_ascii_at(t,e,i){const s=[];for(let n=0;n<e;n++){const e=this.u8_at(t+n);if(i&&0===e)break;s.push(e)}return String.fromCodePoint(...s)}string_utf16_at(t,e,i){const s=[],n=Math.floor(e/2);for(let e=0;e<n;e++){const n=this.u16_at(t+2*e);if(i&&0===n)break;s.push(n)}return String.fromCodePoint(...s)}array_buffer(t=this.size-this.position){this.check_size("size",t,t);const e=this.backing_buffer.slice(this.offset+this.position,this.offset+this.position+t);return this._position+=t,e}copy_to_uint8_array(t,e=this.size-this.position){return this.check_size("size",e,e),t.set(new Uint8Array(this.backing_buffer,this.offset+this.position,e)),this._position+=e,this}check_size(t,e,i){if(i<0||i>this.size-this.position)throw new Error(`${t} ${e} is out of bounds.`)}check_offset(t,e){if(t<0||t+e>this.size)throw new Error(`Offset ${t} is out of bounds.`)}}i.d(e,"a",(function(){return r}));class r extends n{write_u8(t){return this.write_u8_at(this.position,t),this._position+=1,this}write_u16(t){return this.write_u16_at(this.position,t),this._position+=2,this}write_u32(t){return this.write_u32_at(this.position,t),this._position+=4,this}write_i8(t){return this.write_i8_at(this.position,t),this._position+=1,this}write_i16(t){return this.write_i16_at(this.position,t),this._position+=2,this}write_i32(t){return this.write_i32_at(this.position,t),this._position+=4,this}write_f32(t){return this.write_f32_at(this.position,t),this._position+=4,this}write_u8_array(t){return this.write_u8_array_at(this.position,t),this._position+=t.length,this}write_u16_array(t){return this.write_u16_array_at(this.position,t),this._position+=2*t.length,this}write_u32_array(t){return this.write_u32_array_at(this.position,t),this._position+=4*t.length,this}write_i32_array(t){return this.write_i32_array_at(this.position,t),this._position+=4*t.length,this}write_vec2_f32(t){return this.write_vec2_f32_at(this.position,t),this._position+=8,this}write_vec3_f32(t){return this.write_vec3_f32_at(this.position,t),this._position+=12,this}write_cursor(t){const e=t.size-t.position;return this.ensure_size(e),t.copy_to_uint8_array(new Uint8Array(this.backing_buffer,this.offset+this.position,e),e),this._position+=e,this}write_string_ascii(t,e){return this.write_string_ascii_at(this.position,t,e),this._position+=e,this}write_string_utf16(t,e){return this.write_string_utf16_at(this.position,t,e),this._position+=e,this}write_u8_at(t,e){return this.ensure_size(1,t),this.dv.setUint8(t,e),this}write_u16_at(t,e){return this.ensure_size(2,t),this.dv.setUint16(t,e,this.little_endian),this}write_u32_at(t,e){return this.ensure_size(4,t),this.dv.setUint32(t,e,this.little_endian),this}write_i8_at(t,e){return this.ensure_size(1,t),this.dv.setInt8(t,e),this}write_i16_at(t,e){return this.ensure_size(2,t),this.dv.setInt16(t,e,this.little_endian),this}write_i32_at(t,e){return this.ensure_size(4,t),this.dv.setInt32(t,e,this.little_endian),this}write_f32_at(t,e){return this.ensure_size(4,t),this.dv.setFloat32(t,e,this.little_endian),this}write_u8_array_at(t,e){return this.ensure_size(e.length,t),new Uint8Array(this.backing_buffer,this.offset+t).set(new Uint8Array(e)),this}write_u16_array_at(t,e){this.ensure_size(2*e.length,t);const i=e.length;for(let s=0;s<i;s++)this.write_u16_at(t+2*s,e[s]);return this}write_u32_array_at(t,e){this.ensure_size(4*e.length,t);const i=e.length;for(let s=0;s<i;s++)this.write_u32_at(t+4*s,e[s]);return this}write_i32_array_at(t,e){this.ensure_size(4*e.length,t);const i=e.length;for(let s=0;s<i;s++)this.write_i32_at(t+4*s,e[s]);return this}write_vec2_f32_at(t,e){return this.ensure_size(8,t),this.dv.setFloat32(t,e.x,this.little_endian),this.dv.setFloat32(t+4,e.y,this.little_endian),this}write_vec3_f32_at(t,e){return this.ensure_size(12,t),this.dv.setFloat32(t,e.x,this.little_endian),this.dv.setFloat32(t+4,e.y,this.little_endian),this.dv.setFloat32(t+8,e.z,this.little_endian),this}write_string_ascii_at(t,e,i){this.ensure_size(i,t);const s=Math.min(i,e.length);for(let i=0;i<s;i++)this.write_u8_at(t+i,e.codePointAt(i));const n=i-s;for(let e=0;e<n;e++)this.write_u8_at(t+s+e,0);return this}write_string_utf16_at(t,e,i){this.ensure_size(i,t);const s=Math.floor(i/2),n=Math.min(s,e.length);for(let i=0;i<n;i++)this.write_u16_at(t+2*i,e.codePointAt(i));const r=s-n;for(let e=0;e<r;e++)this.write_u16_at(t+2*n+2*e,0);return this}ensure_size(t,e=this.position){const i=this.size-e;if(t>i)throw new Error(`${t} Bytes required but only ${i} available.`)}}},"9fJw":function(t,e,i){"use strict";i.d(e,"g",(function(){return n})),i.d(e,"h",(function(){return r})),i.d(e,"f",(function(){return o})),i.d(e,"e",(function(){return _})),i.d(e,"k",(function(){return a})),i.d(e,"l",(function(){return h})),i.d(e,"j",(function(){return c})),i.d(e,"i",(function(){return u})),i.d(e,"a",(function(){return d})),i.d(e,"b",(function(){return l})),i.d(e,"d",(function(){return f})),i.d(e,"c",(function(){return y}));class s{constructor(t){var e,i,s,n,r;this.name=t.name,this.body_style_count=null!=(e=t.body_style_count)?e:1,this.head_style_count=t.head_style_count,this.hair_style_count=t.hair_style_count,this.hair_styles_with_accessory=t.hair_styles_with_accessory,this.body_tex_ids=null!=(i=t.body_tex_ids)?i:[],this.head_tex_ids=null!=(s=t.head_tex_ids)?s:[],this.hair_tex_ids=null!=(n=t.hair_tex_ids)?n:[],this.accessory_tex_ids=null!=(r=t.accessory_tex_ids)?r:[]}}const n=new s({name:"HUmar",body_style_count:18,head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([6])}),r=new s({name:"HUnewearl",body_style_count:18,head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set}),o=new s({name:"HUcast",body_style_count:25,head_style_count:5,hair_style_count:0,hair_styles_with_accessory:new Set}),_=new s({name:"HUcaseal",body_style_count:25,head_style_count:5,hair_style_count:0,hair_styles_with_accessory:new Set}),a=new s({name:"RAmar",body_style_count:18,head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9])}),h=new s({name:"RAmarl",body_style_count:18,head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9])}),c=new s({name:"RAcast",body_style_count:25,head_style_count:5,hair_style_count:0,hair_styles_with_accessory:new Set}),u=new s({name:"RAcaseal",body_style_count:25,head_style_count:5,hair_style_count:0,hair_styles_with_accessory:new Set}),d=new s({name:"FOmar",body_style_count:18,head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9])}),l=new s({name:"FOmarl",body_style_count:18,head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9])}),f=new s({name:"FOnewm",body_style_count:18,head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9])}),y=new s({name:"FOnewearl",body_style_count:18,head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9])})},NRxM:function(t,e,i){"use strict";i.d(e,"a",(function(){return n}));var s=i("9dYx");class n extends s.a{constructor(t,e,i=0,s=t.byteLength-i){super(e,i),this._size=s,this.backing_buffer=t,this.dv=new DataView(t,0,t.byteLength)}get size(){return this._size}set size(t){if(t>this.backing_buffer.byteLength-this.offset)throw new Error(`Size ${t} is out of bounds.`);this._size=t}take(t){const e=this.offset+this.position,i=new n(this.backing_buffer,this.endianness,e,t);return this._position+=t,i}}},ZV42:function(t,e,i){"use strict";i.r(e),i.d(e,"CharacterClassAssetLoader",(function(){return l}));var s=i("kwt4"),n=i("NRxM"),r=i("bcBH"),o=i("VwSi"),_=i("9fJw"),a=i("yub1"),h=i("/UnV"),c=i("nsCy"),u=i("BAAx"),d=function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{a(s.next(t))}catch(t){r(t)}}function _(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,_)}a((s=s.apply(t,e||[])).next())}))};class l{constructor(t){this.http_client=t,this.nj_object_cache=new Map,this.xvr_texture_cache=new Map,this.nj_motion_cache=new Map}dispose(){for(const t of this.nj_object_cache.values())t.dispose();for(const t of this.nj_motion_cache.values())t.dispose();this.nj_object_cache.clear(),this.nj_motion_cache.clear()}load_geometry(t){let e=this.nj_object_cache.get(t.name);return e||(e=this.load_all_nj_objects(t),this.nj_object_cache.set(t.name,e)),e}load_all_nj_objects(t){const e=f(t,c.e.Viridia,0);return this.load_body_part_geometry(t.name,"Body").then(i=>{if(!i)throw new Error(`Couldn't load body for player class ${t.name}.`);return this.load_body_part_geometry(t.name,"Head",0).then(s=>{if(!s)return i;let n=1+e.body.length;return this.shift_texture_ids(s,n),this.add_to_bone(i,s,59),0===t.hair_style_count?i:this.load_body_part_geometry(t.name,"Hair",0).then(r=>r?(n+=e.head.length,this.shift_texture_ids(r,n),this.add_to_bone(s,r,0),t.hair_styles_with_accessory.has(0)?this.load_body_part_geometry(t.name,"Accessory",0).then(t=>(t&&(n+=e.hair.length,this.shift_texture_ids(t,n),this.add_to_bone(r,t,0)),i)):i):i)})})}load_body_part_geometry(t,e,i){return this.http_client.get(function(t,e,i){return`/player/${t}${e}${null==i?"":i}.nj`}(t,e,i)).array_buffer().then(t=>Object(u.d)(Object(s.c)(new n.a(t,r.a.Little)))[0])}shift_texture_ids(t,e){if(t.model)for(const i of t.model.meshes)null!=i.texture_id&&(i.texture_id+=e);for(const i of t.children)this.shift_texture_ids(i,e)}add_to_bone(t,e,i){const s=t.get_bone(i);s&&(s.evaluation_flags.hidden=!1,s.evaluation_flags.break_child_trace=!1,s.add_child(e))}load_textures(t,e,i){return d(this,void 0,void 0,(function*(){let s=this.xvr_texture_cache.get(t.name);s||(s=this.http_client.get(`/player/${t.name}Tex.afs`).array_buffer().then(t=>{const e=Object(h.a)(new n.a(t,r.a.Little)),i=[];if(e.success)for(const t of e.value){const e=Object(a.b)(new n.a(t,r.a.Little));e.success&&i.push(...e.value.textures)}return i}));const o=yield s,_=f(t,e,i);return[_.section_id,..._.body,..._.head,..._.hair,..._.accessories].map(t=>null==t?void 0:o[t])}))}load_animation(t,e){let i=this.nj_motion_cache.get(t);return i||(i=this.http_client.get(`/player/animation/animation_${t.toString().padStart(3,"0")}.njm`).array_buffer().then(t=>Object(o.c)(new n.a(t,r.a.Little),e))),i}}function f(t,e,i){switch(t){case _.g:{const t=3*i;return{section_id:e+126,body:[t,t+1,t+2,i+108],head:[54,55],hair:[94,95],accessories:[]}}case _.h:{const t=13*i;return{section_id:e+299,body:[t+13,t,t+1,t+2,t+3,277,i+281],head:[235,239],hair:[260,259],accessories:[]}}case _.f:{const t=5*i;return{section_id:e+275,body:[t,t+1,t+2,i+250],head:[t+3,t+4],hair:[],accessories:[]}}case _.e:{const t=5*i;return{section_id:e+375,body:[t,t+1,t+2],head:[t+3,t+4],hair:[],accessories:[]}}case _.k:{const t=7*i;return{section_id:e+197,body:[t+4,t+5,t+6,i+179],head:[126,127],hair:[166,167],accessories:[void 0,void 0,t+2]}}case _.l:{const t=16*i;return{section_id:e+322,body:[t+15,t+1,t],head:[288],hair:[308,309],accessories:[void 0,void 0,t+8]}}case _.j:{const t=5*i;return{section_id:e+300,body:[t,t+1,t+2,t+3,i+275],head:[t+4],hair:[],accessories:[]}}case _.i:{const t=5*i;return{section_id:e+375,body:[i+350,t,t+1,t+2],head:[t+3],hair:[t+4],accessories:[]}}case _.a:{const t=0===i?0:15*i+2;return{section_id:e+310,body:[t+12,t+13,t+14,t],head:[276,272],hair:[void 0,296,297],accessories:[t+4]}}case _.b:{const t=16*i;return{section_id:e+326,body:[t,t+2,t+1,322],head:[288],hair:[void 0,void 0,308],accessories:[t+3,t+4]}}case _.d:{const t=17*i;return{section_id:e+344,body:[t+4,340,t,t+5],head:[306,310],hair:[void 0,void 0,330],accessories:[t+6,t+16,330]}}case _.c:{const t=26*i;return{section_id:e+505,body:[t+1,t,t+2,501],head:[472,468],hair:[void 0,void 0,492],accessories:[t+12,t+13]}}default:throw new Error(`No textures for character class ${t.name}.`)}}},bcBH:function(t,e,i){"use strict";var s;i.d(e,"a",(function(){return s})),function(t){t[t.Little=0]="Little",t[t.Big=1]="Big"}(s||(s={}))},yub1:function(t,e,i){"use strict";i.d(e,"a",(function(){return c})),i.d(e,"b",(function(){return u}));var s=i("9Ykw"),n=i("rwco"),r=i("BAAx"),o=i("5cb6");const _=n.a.get("core/data_formats/parsing/ninja/texture"),a=1213027928,h=1414682200;function c(t){const e=Object(s.b)(t,!0);return t.seek_start(0),e.success&&null!=e.value.find(t=>t.type===a||t.type===h)}function u(t){const e=Object(s.a)(t);if(!e.success)return e;const i=Object(r.b)(_);i.add_result(e);const n=e.value,c=n.find(t=>t.type===a),u=c&&function(t){return{texture_count:t.u16()}}(c.data),d=n.filter(t=>t.type===h).map(t=>(function(t){const e=t.u32(),i=t.u32(),s=t.u32(),n=t.u16(),r=t.u16(),o=t.u32();return t.seek(36),{id:s,format:[e,i],width:n,height:r,size:o,data:t.array_buffer(o)}})(t.data));return u||0!==d.length?(u&&u.texture_count!==d.length&&i.add_problem(o.b.Warning,"Corrupted XVM file.",`Found ${d.length} textures instead of ${u.texture_count} as defined in the header.`),i.success({textures:d})):(i.add_problem(o.b.Error,"Corrupted XVM file.","No header and no XVRT chunks found."),i.failure())}}}]);