Fix the mapblock reading - C++ was being 'helpful' again

develop
Petr Mrázek 2010-03-05 01:57:51 +01:00
parent 8e8d320a0b
commit 73f95e4a6d
2 changed files with 16 additions and 7 deletions

@ -407,6 +407,7 @@ main(int argc, char *argv[])
DF.ReadTileTypes(cursorX+i,cursorY+j,cursorZ, (uint16_t *) tiletypes);
DF.ReadDesignations(cursorX+i,cursorY+j,cursorZ, (uint32_t *) designations);
*/
for(int x = 0; x < 16; x++)
{
for(int y = 0; y < 16; y++)
@ -441,9 +442,10 @@ main(int argc, char *argv[])
blockaddr2 = Block.origin;
if(dump)
{
hexdump(DF,blockaddr,0x1E00/*0x1DB8*/,filenum);
hexdump(DF,blockaddr,0x1E00,filenum);
filenum++;
}
if(dig)
DF.WriteDesignations(cursorX+i,cursorY+j,cursorZ, (uint32_t *) Block.designaton);
DF.ReadDirtyBit(cursorX+i,cursorY+j,cursorZ,dirtybit);
@ -455,6 +457,7 @@ main(int argc, char *argv[])
veinVector.clear();
IceVeinVector.clear();
DF.ReadVeins(cursorX+i,cursorY+j,cursorZ,veinVector,IceVeinVector);
}
}
}

@ -69,16 +69,22 @@ void ReadBlockByCoords (void * data)
*/
mblock * *** mapArray = *(mblock * ****)offsets.map_offset;
mblock * block = mapArray[SHMHDR->x][SHMHDR->y][SHMHDR->z];
//fprintf(stderr, "Readblock: %d %d %d 0x%x\n", SHMHDR->x,SHMHDR->y,SHMHDR->z, block);
/*
fprintf(stderr, "map_offset: 0x%x\n", offsets.map_offset);
fprintf(stderr, "x_array: 0x%x\n", mapArray);
fprintf(stderr, "y_array: 0x%x\n", mapArray[SHMHDR->x]);
fprintf(stderr, "z_array: 0x%x\n", mapArray[SHMHDR->x][SHMHDR->y]);
fprintf(stderr, "Readblock: %d %d %d 0x%x\n", SHMHDR->x,SHMHDR->y,SHMHDR->z, block);
*/
if(block)
{
memcpy(&(SHMBLOCK->tiletypes), block + offsets.tile_type_offset, sizeof(SHMBLOCK->tiletypes));
memcpy(&(SHMBLOCK->designaton), block + offsets.designation_offset, sizeof(SHMBLOCK->designaton));
memcpy(&(SHMBLOCK->occupancy), block + offsets.occupancy_offset, sizeof(SHMBLOCK->occupancy));
memcpy(&(SHMBLOCK->biome_indices), block + offsets.biome_stuffs, sizeof(SHMBLOCK->biome_indices));
memcpy(&(SHMBLOCK->tiletypes), ((char *) block) + offsets.tile_type_offset, sizeof(SHMBLOCK->tiletypes));
memcpy(&(SHMBLOCK->designaton), ((char *) block) + offsets.designation_offset, sizeof(SHMBLOCK->designaton));
memcpy(&(SHMBLOCK->occupancy), ((char *) block) + offsets.occupancy_offset, sizeof(SHMBLOCK->occupancy));
memcpy(&(SHMBLOCK->biome_indices), ((char *) block) + offsets.biome_stuffs, sizeof(SHMBLOCK->biome_indices));
SHMBLOCK->dirty_dword = *block->ptr_to_dirty;
SHMBLOCK->origin = reinterpret_cast<uint32_t>(block);
SHMBLOCK->origin = (uint32_t)block;
SHMHDR->error = false;
}
else