ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/layout.C
(Generate patch)

Comparing deliantra/server/random_maps/layout.C (file contents):
Revision 1.8 by root, Fri Jul 2 15:43:37 2010 UTC vs.
Revision 1.9 by root, Fri Jul 2 17:18:04 2010 UTC

23 23
24#include <global.h> 24#include <global.h>
25#include <random_map.h> 25#include <random_map.h>
26#include <rproto.h> 26#include <rproto.h>
27 27
28void
28layout::layout (int w, int h) 29layout::alloc (int w, int h)
29: w(w), h(h)
30{ 30{
31 assert (sizeof (cell) == 1); 31 assert (sizeof (cell) == 1);
32
33 this->w = w;
34 this->h = h;
32 35
33 // we store the layout in a single contiguous memory layout 36 // we store the layout in a single contiguous memory layout
34 // first part consists of pointers to each column, followed 37 // first part consists of pointers to each column, followed
35 // by the actual columns (not rows!) 38 // by the actual columns (not rows!)
36 int size = (sizeof (cell *) + sizeof (cell) * h) * w; 39 int size = (sizeof (cell *) + sizeof (cell) * h) * w;
39 42
40 cell *p = (cell *)(data + w); 43 cell *p = (cell *)(data + w);
41 44
42 for (int x = w; x--; ) 45 for (int x = w; x--; )
43 data [x] = p + x * h; 46 data [x] = p + x * h;
47}
48
49layout::layout (int w, int h)
50{
51 alloc (w, h);
52}
53
54layout::layout (layout &copy)
55{
56 alloc (copy.w, copy.h);
57
58 memcpy (data [0], copy.data [0], sizeof (cell) * h * w);
44} 59}
45 60
46layout::~layout () 61layout::~layout ()
47{ 62{
48 int size = (sizeof (cell *) + sizeof (cell) * h) * w; 63 int size = (sizeof (cell *) + sizeof (cell) * h) * w;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines