15 #include "interface.h"
18 #include "publicServer.h"
21 typedef struct wall_struct
{
24 /* position of the teleport */
28 /* size of the teleport */
35 /* layer in the arena where the teleport lies */
44 static export_fce_t
*export_fce
;
46 static space_t
*spaceWall
;
49 static space_t
*spaceImgWall
;
52 static list_t
*listWall
;
55 static wall_t
*newWall(int x
, int y
, int w
, int h
, int img_x
, int img_y
, int layer
, image_t
*img
)
57 static wall_t
*newWall(int x
, int y
, int w
, int h
, int img_x
, int img_y
, int layer
)
60 static int last_id
= 0;
66 new = malloc(sizeof(wall_t
));
86 static void drawWall(wall_t
*p
)
90 export_fce
->fce_addLayer(p
->img
,
97 static void drawListWall(list_t
*list
)
102 assert(list
!= NULL
);
104 for (i
= 0; i
< list
->count
; i
++) {
105 thisWall
= (wall_t
*) list
->list
[i
];
106 assert(thisWall
!= NULL
);
113 static void destroyWall(wall_t
*p
)
119 static void getStatusWall(void *p
, int *id
, int *x
, int *y
, int *w
, int *h
)
132 static void setStatusWall(void *p
, int x
, int y
, int w
, int h
)
144 #ifndef PUBLIC_SERVER
145 static void getStatusImgWall(void *p
, int *id
, int *x
, int *y
, int *w
, int *h
)
158 static void setStatusImgWall(void *p
, int x
, int y
, int w
, int h
)
168 static void cmd_wall(char *line
)
170 char str_x
[STR_NUM_SIZE
];
171 char str_y
[STR_NUM_SIZE
];
172 char str_img_x
[STR_NUM_SIZE
];
173 char str_img_y
[STR_NUM_SIZE
];
174 char str_w
[STR_NUM_SIZE
];
175 char str_h
[STR_NUM_SIZE
];
176 char str_layer
[STR_NUM_SIZE
];
177 char str_image
[STR_SIZE
];
178 char str_rel
[STR_SIZE
];
179 int x
, y
, w
, h
, img_x
, img_y
, layer
;
185 if (export_fce
->fce_getValue(line
, "rel", str_rel
, STR_NUM_SIZE
) != 0)
186 strcpy(str_rel
, "0");
187 if (export_fce
->fce_getValue(line
, "x", str_x
, STR_NUM_SIZE
) != 0)
189 if (export_fce
->fce_getValue(line
, "y", str_y
, STR_NUM_SIZE
) != 0)
191 if (export_fce
->fce_getValue(line
, "w", str_w
, STR_NUM_SIZE
) != 0)
193 if (export_fce
->fce_getValue(line
, "h", str_h
, STR_NUM_SIZE
) != 0)
195 if (export_fce
->fce_getValue(line
, "img_x", str_img_x
, STR_NUM_SIZE
) != 0)
197 if (export_fce
->fce_getValue(line
, "img_y", str_img_y
, STR_NUM_SIZE
) != 0)
199 if (export_fce
->fce_getValue(line
, "layer", str_layer
, STR_NUM_SIZE
) != 0)
201 if (export_fce
->fce_getValue(line
, "image", str_image
, STR_SIZE
) != 0)
209 img_x
= atoi(str_img_x
);
210 img_y
= atoi(str_img_y
);
211 layer
= atoi(str_layer
);
217 #ifndef PUBLIC_SERVER
218 new = newWall(x
, y
, w
, h
, img_x
, img_y
, layer
, export_fce
->fce_image_get(IMAGE_GROUP_USER
, str_image
));
220 new = newWall(x
, y
, w
, h
, img_x
, img_y
, layer
);
223 if (spaceWall
== NULL
) {
224 spaceWall
= space_new(export_fce
->fce_arena_get_current()->w
,
225 export_fce
->fce_arena_get_current()->h
,
227 getStatusWall
, setStatusWall
);
230 #ifndef PUBLIC_SERVER
231 if (spaceImgWall
== NULL
) {
232 spaceImgWall
= space_new(export_fce
->fce_arena_get_current()->w
,
233 export_fce
->fce_arena_get_current()->h
,
235 getStatusImgWall
, setStatusImgWall
);
239 space_add(spaceWall
, new);
241 #ifndef PUBLIC_SERVER
242 space_add(spaceImgWall
, new);
246 static int init(export_fce_t
*p
)
249 listWall
= list_new();
254 #ifndef PUBLIC_SERVER
255 static void action_drawwall(space_t
*space
, wall_t
*wall
, void *p
)
263 static int draw(int x
, int y
, int w
, int h
)
265 if (spaceWall
== NULL
) {
269 space_action_from_location(spaceImgWall
, action_drawwall
, NULL
, x
, y
, w
, h
);
271 /*space_print(spaceWall);*/
277 static void action_eventwall(space_t
*space
, wall_t
*wall
, shot_t
*shot
)
285 arena
= export_fce
->fce_arena_get_current();
287 author
= space_get_object_id(arena
->spaceTux
, shot
->author_id
);
289 if (author
!= NULL
&& author
->bonus
== BONUS_GHOST
&& author
->bonus_time
> 0) {
293 if (shot
->gun
== GUN_BOMBBALL
) {
294 if (export_fce
->fce_net_multiplayer_get_game_type() != NET_GAME_TYPE_CLIENT
) {
295 export_fce
->fce_shot_bound_bombBall(shot
);
301 /*space_del_with_item(arena->spaceShot, shot, export_fce->fce_shot_destroy);*/
305 static void action_eventshot(space_t
*space
, shot_t
*shot
, space_t
*p_spaceWall
)
307 space_action_from_location(p_spaceWall
, action_eventwall
,
308 shot
, shot
->x
, shot
->y
,
311 if (shot
->del
== TRUE
) {
312 space_del_with_item(space
, shot
, export_fce
->fce_shot_destroy
);
318 if (spaceWall
== NULL
) {
322 space_action(export_fce
->fce_arena_get_current()->spaceShot
,
323 action_eventshot
, spaceWall
);
328 static int isConflict(int x
, int y
, int w
, int h
)
330 if (spaceWall
== NULL
) {
334 return space_is_conflict_with_object(spaceWall
, x
, y
, w
, h
);
337 static void cmdArena(char *line
)
339 if (strncmp(line
, "wall", 4) == 0) {
344 static void recvMsg(char *msg
)
351 space_destroy_with_item(spaceWall
, destroyWall
);
352 #ifndef PUBLIC_SERVER
353 space_destroy(spaceImgWall
);
356 list_destroy(listWall
);
364 mod_sym_t modwall_sym
= { &init
,
365 #ifndef PUBLIC_SERVER