Skip to content

Commit

Permalink
made legacy 32bit props working
Browse files Browse the repository at this point in the history
  • Loading branch information
mheiniger committed Mar 27, 2014
1 parent c23d927 commit 6d1fb73
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions PalaceClient/palace/model/PalaceProp.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,41 +342,43 @@ function PalaceProp(guid/* :String */, assetId/* :uint */, assetCrc/* :uint */)
function decode32BitProp()/* :void */ {
// Implementation thanks to Phalanx team
// Translated from VB6 implementation
var data/* :ByteArray */ = new ByteArray();
var data/* :ByteArray */ = new ByteArray(that.asset.data.length);
for (var i/* :int */ = 12; i < that.asset.data.length; i++) {
data.writeByte(that.asset.data[i]);
}
data.position = 0;
//trace("Computed CRC: " + computeCRC(data) + " - Given CRC: " + asset.crc);

data.uncompress();

var bd/* :BitmapData */ = new BitmapData(that.width, that.height);
var ba/* :Vector.<uint> */ = []; //new Vector. < uint > (width * height, true);
var C/* :uint */ = 0;
var x/* :int */ = 0;
var y/* :int */ = 0;
var ofst/* :int */ = 0;
var X/* :int */ = 0;
var A/* :uint */ = 0;
var R/* :uint */ = 0;
var G/* :uint */ = 0;
var B/* :uint */ = 0;

var pos/* :uint */ = 0;
data.uncompress(function(err, data){
if (err) {
console.log('uncompress-error:');
console.log(data.toString('base64'));
}

for (X = 0; X <= 1935; X++) {
ofst = X * 4;
R = data[ofst];
G = data[ofst + 1];
B = data[ofst + 2];
A = data[ofst + 3];
var bitmapData/* :BitmapData */ = new BitmapData(that.width, that.height);
var ofst/* :int */ = 0;
var X/* :int */ = 0;
var A/* :uint */ = 0;
var R/* :uint */ = 0;
var G/* :uint */ = 0;
var B/* :uint */ = 0;

ba[pos++] = (A << 24 | R << 16 | G << 8 | B);
var rgba = [];
for (X = 0; X <= 1935; X++) {
ofst = X * 4;
R = data[ofst];
G = data[ofst + 1];
B = data[ofst + 2];
A = data[ofst + 3];

}
bd.setVector(rect, ba);
that.bitmap = bd.get();
rgba.push(R);
rgba.push(G);
rgba.push(B);
rgba.push(~A);
}
bitmapData.setVector(rect, rgba);
that.bitmap = bitmapData.get();
});
}

function decode20BitProp()/* :void */ {
Expand Down

0 comments on commit 6d1fb73

Please sign in to comment.