… | |
… | |
38 | #include "Attr.h" |
38 | #include "Attr.h" |
39 | #include "MapAttr.h" |
39 | #include "MapAttr.h" |
40 | #include "Str.h" |
40 | #include "Str.h" |
41 | #include "Bitmaps.h" |
41 | #include "Bitmaps.h" |
42 | |
42 | |
|
|
43 | #include "libproto.h" |
|
|
44 | #include "proto.h" |
43 | |
45 | |
44 | /* |
46 | /* |
45 | * This function relinks all _pointers_ to the objects from |
47 | * This function relinks all _pointers_ to the objects from |
46 | * one map to another. |
48 | * one map to another. |
47 | * Note: You can _not_ free the objects in the original map |
49 | * Note: You can _not_ free the objects in the original map |
48 | * after this function has been called. |
50 | * after this function has been called. |
49 | * (What happened to this function? It no longer copies the pointers! -Frank) |
51 | * (What happened to this function? It no longer copies the pointers! -Frank) |
50 | * moved to Edit.c from common/map.c since Edit.c is the only file that uses it. |
52 | * moved to Edit.c from common/map.c since Edit.c is the only file that uses it. |
51 | */ |
53 | */ |
52 | |
54 | |
53 | void copy_map(mapstruct *m1, mapstruct *m2) { |
55 | static void copy_map(mapstruct *m1, mapstruct *m2) { |
54 | int x,y; |
56 | int x,y; |
55 | |
57 | |
56 | memcpy(m2, m1, sizeof(mapstruct)); |
58 | memcpy(m2, m1, sizeof(mapstruct)); |
57 | |
59 | |
58 | for(x=0;x<MAP_WIDTH(m1)&&x<MAP_WIDTH(m2);x++) |
60 | for(x=0;x<MAP_WIDTH(m1)&&x<MAP_WIDTH(m2);x++) |
… | |
… | |
69 | * width : width of target map |
71 | * width : width of target map |
70 | * height: height of target map |
72 | * height: height of target map |
71 | * dx : positive translate to right |
73 | * dx : positive translate to right |
72 | * dy : positive translate to down |
74 | * dy : positive translate to down |
73 | */ |
75 | */ |
74 | mapstruct *MapMoveScrollResize(mapstruct *source, |
76 | static mapstruct *MapMoveScrollResize(mapstruct *source, |
75 | int width, int height, int dx, int dy) |
77 | int width, int height, int dx, int dy) |
76 | { |
78 | { |
77 | mapstruct *target; |
79 | mapstruct *target; |
78 | object *obj,*prt; /* PaRT of obj */ |
80 | object *obj,*prt; /* PaRT of obj */ |
79 | int x,y,sx = MAP_WIDTH(source), sy = MAP_HEIGHT(source); |
81 | int x,y,sx = MAP_WIDTH(source), sy = MAP_HEIGHT(source); |
… | |
… | |
158 | delete_map (source); |
160 | delete_map (source); |
159 | return target; |
161 | return target; |
160 | } |
162 | } |
161 | |
163 | |
162 | |
164 | |
163 | object * MapGetRealObject (mapstruct * emap, int x, int y, int z) |
165 | static object * MapGetRealObject (mapstruct * emap, int x, int y, int z) |
164 | { |
166 | { |
165 | object *tmp = MapGetObjectZ (emap, x, y, z); |
167 | object *tmp = MapGetObjectZ (emap, x, y, z); |
166 | return tmp ? (tmp->head ? tmp->head : tmp) : tmp; |
168 | return tmp ? (tmp->head ? tmp->head : tmp) : tmp; |
167 | } |
169 | } |
168 | |
170 | |
169 | int MapInsertObjectZ(mapstruct *emap,object *o,int x, int y, int z) |
171 | static int MapInsertObjectZ(mapstruct *emap,object *o,int x, int y, int z) |
170 | { |
172 | { |
171 | object *op, *above, *below; |
173 | object *op, *above, *below; |
172 | |
174 | |
173 | if (o->more) |
175 | if (o->more) |
174 | MapInsertObjectZ (emap,o->more, x, y, z); |
176 | MapInsertObjectZ (emap,o->more, x, y, z); |
… | |
… | |
207 | set_map_ob (emap, o->x, o->y, o); |
209 | set_map_ob (emap, o->x, o->y, o); |
208 | |
210 | |
209 | return (0); |
211 | return (0); |
210 | } |
212 | } |
211 | |
213 | |
212 | int MapObjectOut (mapstruct *target, object *obj, int x, int y) { |
214 | static int MapObjectOut (mapstruct *target, object *obj, int x, int y) { |
213 | object *tmp; |
215 | object *tmp; |
214 | for(tmp = obj; tmp; tmp = tmp->more) |
216 | for(tmp = obj; tmp; tmp = tmp->more) |
215 | if(OUT_OF_REAL_MAP(target,x + tmp->x,y + tmp->y)) return 1; |
217 | if(OUT_OF_REAL_MAP(target,x + tmp->x,y + tmp->y)) return 1; |
216 | return 0; |
218 | return 0; |
217 | } |
219 | } |