32 PixelDimension map_w = pkt.read_uint32(); |
32 PixelDimension map_w = pkt.read_uint32(); |
33 PixelDimension map_h = pkt.read_uint32(); |
33 PixelDimension map_h = pkt.read_uint32(); |
34 |
34 |
35 // the terrain byte array |
35 // the terrain byte array |
36 size_t terrain_size = map_w * map_h; |
36 size_t terrain_size = map_w * map_h; |
37 uint8_t terrain_buf[map_w][map_h]; |
37 uint8_t terrain_buf[map_w * map_h]; |
38 |
38 |
39 // read uncompressed terrain data |
39 // read uncompressed terrain data |
40 size_t inflate_size = pkt.read_uncompressed(terrain_buf, terrain_size); |
40 size_t inflate_size = pkt.read_uncompressed(terrain_buf, terrain_size); |
41 |
41 |
42 // invalid data? |
42 // invalid data? |
43 if (inflate_size != terrain_size) |
43 if (inflate_size != terrain_size) |
44 throw Error("Corrupt terrain data"); |
44 throw Error("Corrupt terrain data"); |
45 |
45 |
46 // translate map data to terrain vector |
46 // XXX: rework access |
47 for (PixelDimension x = 0; x < map_w; x++) { |
47 if (terrain.getDimensions() != PixelCoordinate(map_w, map_h)) |
48 for (PixelDimension y = 0; y < map_h; y++) { |
48 throw Error("terrain is of the wrong size"); |
49 terrain.terrain[x][y] = (TerrainType) terrain_buf[x][y]; |
49 |
50 } |
50 // load into terrain |
51 } |
51 terrain.loadFromBuffer(terrain_buf); |
52 |
|
53 // update the pixbuf |
|
54 terrain.generatePixelBuffer(); |
|
55 } |
52 } |
56 |
53 |
57 void NetworkClient::player_quit (NetworkClientRemotePlayer *player) { |
54 void NetworkClient::player_quit (NetworkClientRemotePlayer *player) { |
58 (void) player; |
55 (void) player; |
59 } |
56 } |