All pastes #27552 Raw Edit

Anonymous

public java v1 · immutable
#27552 ·published 2005-11-03 23:47 UTC
rendered paste body
public synchronized void map1aRead(DataInputStream mapdata) throws IOException {	System.out.println("map1aRead now called");	int 	maplen = mapdata.available();	boolean	bottom = true;	int	mask;	int 	x, y, layer, darkness;	int	faces[] = new int[3];	int 	pos = 0;	int	NUM_LAYERS=2; /* this should be defined somewhere nicer */	System.out.println("maplen is " + maplen);	while ( pos < maplen ) {		System.out.println("reading a new tile");		bottom = true;		//place = str.charAt(parse++);		mask = (int) mapdata.readUnsignedShort(); 		pos+=2;		System.out.println("mask is " + mask);			x = (mask >> 10) & 0x3f;;		y = (mask >> 4) & 0x3f;;		System.out.println("tile is at " + x + ":" + y);		if ((mask & 0xf) == 0) {			clearMapCell(x,y);			continue;	/* if empty mask, none of the checks will be true. */		}		/* If this space was previously stored for fog of war, need to clear		* it now.  Needs to be done before anything else happens that we		* might want to store in it.		*/			if ((mask & 0x8) == 1) { /* darkness bit */	    	darkness = mapdata.readUnsignedByte(); 		pos+=1;		System.out.println("darkness value is set, it is " + darkness);		}		else darkness = -1;				/* Reduce redundant by putting the get image		* and flags in a common block.  The layers		* are the inverse of the bit order unfortunately.		*/		for (layer=NUM_LAYERS; layer>=0; layer--) {			if ((mask & (1 << layer)) == 1) {				faces[NUM_LAYERS-layer] = mapdata.readUnsignedShort();				pos+=2;				System.out.println("facenumber for layer " + (NUM_LAYERS-layer) + " is " + faces[NUM_LAYERS-layer]);			}			else {				faces[NUM_LAYERS-layer] = -1;	    		}		}		for (layer=0; layer<=NUM_LAYERS; layer++) {			if (faces[layer] > -1) {				if (bottom) {					bottom = false;					setMapCell(x,y,faces[layer]);				}			}			else {				addToMapCell(x,y,faces[layer]);	    		}		}	}}