From 73f95e4a6d38b71de6889cd3c285b1cdd1a1a6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 5 Mar 2010 01:57:51 +0100 Subject: [PATCH] Fix the mapblock reading - C++ was being 'helpful' again --- examples/veinlook.cpp | 5 ++++- shmserver/mod-maps.cpp | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/examples/veinlook.cpp b/examples/veinlook.cpp index 91a21f566..30c9bf212 100644 --- a/examples/veinlook.cpp +++ b/examples/veinlook.cpp @@ -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); + } } } diff --git a/shmserver/mod-maps.cpp b/shmserver/mod-maps.cpp index a34f01975..1ab220c58 100644 --- a/shmserver/mod-maps.cpp +++ b/shmserver/mod-maps.cpp @@ -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(block); + SHMBLOCK->origin = (uint32_t)block; SHMHDR->error = false; } else